query_id
stringlengths
32
32
query
stringlengths
7
4.32k
positive_passages
listlengths
1
1
negative_passages
listlengths
88
101
1b5001791c2de11baaeed8e29504e3c0
Return true if the rumor is the next expected rumor from the origin node.
[ { "docid": "8e6d01fe5449eed2adcafb512f6e010b", "score": "0.58958375", "text": "func (r *RumorDatabase) Expects(rumor common.IRumorMessage) bool {\n\n\treturn r.NextIDFor(rumor.GetOrigin()) == rumor.GetID()\n}", "title": "" } ]
[ { "docid": "ba67af041ed3c3eeb567040a96353bdb", "score": "0.63028145", "text": "func IsRumorKnown(listOfWanted []PeerStatus, r *RumorMessage) (bool, bool, uint32) {\n\toriginIsKnown := false\n\trumorIsKnown := false\n\tnextID := uint32(0)\n\tfor _, peerStatus := range listOfWanted {\n\t\tif strings.Compare(peerStatus.Identifier, r.Origin) == 0 {\n\t\t\toriginIsKnown = true\n\t\t\tif peerStatus.NextID > r.ID {\n\t\t\t\trumorIsKnown = true\n\t\t\t\tnextID = peerStatus.NextID\n\t\t\t\treturn rumorIsKnown, originIsKnown, nextID\n\t\t\t}\n\t\t\tif peerStatus.NextID > nextID {\n\t\t\t\tnextID = peerStatus.NextID\n\t\t\t}\n\t\t}\n\t}\n\treturn rumorIsKnown, originIsKnown, nextID\n}", "title": "" }, { "docid": "ee99bc3311c08d569eac4f1e435b4503", "score": "0.5950821", "text": "func IsRumorOriginKnown(list []RumorMessage, r *RumorMessage) (bool, uint32) {\n\tmaxLastID := uint32(0)\n\toriginKnown := false\n\tfor _, rm := range list {\n\t\tif strings.Compare(r.Origin, rm.Origin) == 0 {\n\t\t\toriginKnown = true\n\t\t\tif rm.ID > maxLastID {\n\t\t\t\tmaxLastID = rm.ID\n\t\t\t}\n\t\t}\n\t}\n\treturn originKnown, maxLastID\n}", "title": "" }, { "docid": "6a3cf0e4952a66ac9930e9abfa4c9926", "score": "0.5918364", "text": "func (m *NodeKeeperMock) MinimockGetOriginDone() bool {\n\tfor _, e := range m.GetOriginMock.expectations {\n\t\tif mm_atomic.LoadUint64(&e.Counter) < 1 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// if default expectation was set then invocations count should be greater than zero\n\tif m.GetOriginMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetOriginCounter) < 1 {\n\t\treturn false\n\t}\n\t// if func was set then invocations count should be greater than zero\n\tif m.funcGetOrigin != nil && mm_atomic.LoadUint64(&m.afterGetOriginCounter) < 1 {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "90c25778b110a36699309b855bc4621a", "score": "0.5832451", "text": "func (r *Rotations) Next() bool {\n\tr.i++\n\treturn r.i < len(r.n)\n}", "title": "" }, { "docid": "62d8e20b2e595f6eddccef4e42a5ffda", "score": "0.5788106", "text": "func (m *ReportMock) MinimockViolatorNodeDone() bool {\n\tfor _, e := range m.ViolatorNodeMock.expectations {\n\t\tif mm_atomic.LoadUint64(&e.Counter) < 1 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// if default expectation was set then invocations count should be greater than zero\n\tif m.ViolatorNodeMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterViolatorNodeCounter) < 1 {\n\t\treturn false\n\t}\n\t// if func was set then invocations count should be greater than zero\n\tif m.funcViolatorNode != nil && mm_atomic.LoadUint64(&m.afterViolatorNodeCounter) < 1 {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "ff33d6113ab474d0e90770d461268aef", "score": "0.55297875", "text": "func (r *Result) HasNext() bool {\n\treturn r.offset+1 < len(r.entities)\n}", "title": "" }, { "docid": "7bf069af0ae52b04e56689ba0c395172", "score": "0.5446661", "text": "func (m *ActiveNodeMock) MinimockIsJoinerDone() bool {\n\tfor _, e := range m.IsJoinerMock.expectations {\n\t\tif mm_atomic.LoadUint64(&e.Counter) < 1 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// if default expectation was set then invocations count should be greater than zero\n\tif m.IsJoinerMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterIsJoinerCounter) < 1 {\n\t\treturn false\n\t}\n\t// if func was set then invocations count should be greater than zero\n\tif m.funcIsJoiner != nil && mm_atomic.LoadUint64(&m.afterIsJoinerCounter) < 1 {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "8be72c2c9a7889840ce8c1a5f34a019c", "score": "0.542865", "text": "func (m *SqlRowsMock) MinimockNextDone() bool {\n\tfor _, e := range m.NextMock.expectations {\n\t\tif mm_atomic.LoadUint64(&e.Counter) < 1 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// if default expectation was set then invocations count should be greater than zero\n\tif m.NextMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterNextCounter) < 1 {\n\t\treturn false\n\t}\n\t// if func was set then invocations count should be greater than zero\n\tif m.funcNext != nil && mm_atomic.LoadUint64(&m.afterNextCounter) < 1 {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "a3f4543d9f7bee633d2fdd692913af18", "score": "0.54110736", "text": "func (m *CoordinatorMock) QueryRoleFinished() bool {\n\t// if expectation series were set then invocations count should be equal to expectations count\n\tif len(m.QueryRoleMock.expectationSeries) > 0 {\n\t\treturn atomic.LoadUint64(&m.QueryRoleCounter) == uint64(len(m.QueryRoleMock.expectationSeries))\n\t}\n\n\t// if main expectation was set then invocations count should be greater than zero\n\tif m.QueryRoleMock.mainExpectation != nil {\n\t\treturn atomic.LoadUint64(&m.QueryRoleCounter) > 0\n\t}\n\n\t// if func was set then invocations count should be greater than zero\n\tif m.QueryRoleFunc != nil {\n\t\treturn atomic.LoadUint64(&m.QueryRoleCounter) > 0\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "4f8fbc794090de72c48274692e565c27", "score": "0.54068154", "text": "func (m *CoordinatorMock) NodeForJetFinished() bool {\n\t// if expectation series were set then invocations count should be equal to expectations count\n\tif len(m.NodeForJetMock.expectationSeries) > 0 {\n\t\treturn atomic.LoadUint64(&m.NodeForJetCounter) == uint64(len(m.NodeForJetMock.expectationSeries))\n\t}\n\n\t// if main expectation was set then invocations count should be greater than zero\n\tif m.NodeForJetMock.mainExpectation != nil {\n\t\treturn atomic.LoadUint64(&m.NodeForJetCounter) > 0\n\t}\n\n\t// if func was set then invocations count should be greater than zero\n\tif m.NodeForJetFunc != nil {\n\t\treturn atomic.LoadUint64(&m.NodeForJetCounter) > 0\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "84d0edbe61a0879ca3fcbc8d1e76e792", "score": "0.54048574", "text": "func (n *Node) Recursed() bool { return n.flag&flagRecursed == flagRecursed }", "title": "" }, { "docid": "85550d2ef63f861835bf838bf76b28b0", "score": "0.53603536", "text": "func (m *CoordinatorMock) NodeForObjectFinished() bool {\n\t// if expectation series were set then invocations count should be equal to expectations count\n\tif len(m.NodeForObjectMock.expectationSeries) > 0 {\n\t\treturn atomic.LoadUint64(&m.NodeForObjectCounter) == uint64(len(m.NodeForObjectMock.expectationSeries))\n\t}\n\n\t// if main expectation was set then invocations count should be greater than zero\n\tif m.NodeForObjectMock.mainExpectation != nil {\n\t\treturn atomic.LoadUint64(&m.NodeForObjectCounter) > 0\n\t}\n\n\t// if func was set then invocations count should be greater than zero\n\tif m.NodeForObjectFunc != nil {\n\t\treturn atomic.LoadUint64(&m.NodeForObjectCounter) > 0\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "473511d71b6fefb1493b15870d56ed51", "score": "0.53448325", "text": "func (tok Token) IsRelop() bool {\n\treturn relop_start < tok && tok < relop_end\n}", "title": "" }, { "docid": "76de37b2a37fded9e7ad7c24d7b2dc56", "score": "0.5313174", "text": "func (s Step) Recurring(step Step) bool {\n\treturn s.Piece() == step.Piece() && s.Src() == step.Dest() && s.Dest() == step.Src()\n}", "title": "" }, { "docid": "0bcedbce43bf752de1672a95aca2ff00", "score": "0.5311886", "text": "func (rn *RNode) IsNil() bool {\n\treturn rn == nil || rn.YNode() == nil\n}", "title": "" }, { "docid": "598fe2e10795f1491a0b1b7df6fe80d8", "score": "0.52566653", "text": "func (it *RunesIterator) Next(r rune) bool {\n\t// The tree.prefix represents single-child parents without values that were\n\t// compressed out of the tree. Let prefix consume key symbols.\n\tif it.p < len(it.node.prefix) {\n\t\tif r == it.node.prefix[it.p] {\n\t\t\t// Key matches prefix so far, ok to continue.\n\t\t\tit.p++\n\t\t\treturn true\n\t\t}\n\t\t// Some unmatched prefix remains, node not found\n\t\treturn false\n\t}\n\tnode := it.node.children[r]\n\tif node == nil {\n\t\t// No more prefix, no children, so node not found\n\t\treturn false\n\t}\n\t// Key symbol matched up to this child, ok to continue.\n\tit.p = 0\n\tit.node = node\n\treturn true\n}", "title": "" }, { "docid": "b7c72adb1cd1a22d7e8e6f5462a79283", "score": "0.52399236", "text": "func (it *MirrorMetricsIterator) HasNext() bool {\n\treturn it.iter.HasNext()\n}", "title": "" }, { "docid": "6b345bc4811dc3d157d6dc3991c1ffa1", "score": "0.5180356", "text": "func (r *Result) HasNextSet() bool {\n\tif r.inactive() || r.nextSet == len(r.sets) {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "e98d0f07475db55a3402115f1944b9b2", "score": "0.5174806", "text": "func (m *ActiveNodeMock) MinimockIsVoterDone() bool {\n\tfor _, e := range m.IsVoterMock.expectations {\n\t\tif mm_atomic.LoadUint64(&e.Counter) < 1 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// if default expectation was set then invocations count should be greater than zero\n\tif m.IsVoterMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterIsVoterCounter) < 1 {\n\t\treturn false\n\t}\n\t// if func was set then invocations count should be greater than zero\n\tif m.funcIsVoter != nil && mm_atomic.LoadUint64(&m.afterIsVoterCounter) < 1 {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "eb4bae289886698ad4373baa468db282", "score": "0.5174805", "text": "func (m *NodeIntroProfileMock) GetPrimaryRoleFinished() bool {\n\t// if expectation series were set then invocations count should be equal to expectations count\n\tif len(m.GetPrimaryRoleMock.expectationSeries) > 0 {\n\t\treturn atomic.LoadUint64(&m.GetPrimaryRoleCounter) == uint64(len(m.GetPrimaryRoleMock.expectationSeries))\n\t}\n\n\t// if main expectation was set then invocations count should be greater than zero\n\tif m.GetPrimaryRoleMock.mainExpectation != nil {\n\t\treturn atomic.LoadUint64(&m.GetPrimaryRoleCounter) > 0\n\t}\n\n\t// if func was set then invocations count should be greater than zero\n\tif m.GetPrimaryRoleFunc != nil {\n\t\treturn atomic.LoadUint64(&m.GetPrimaryRoleCounter) > 0\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "711a086845b633e342c85a02c18ccc96", "score": "0.5167529", "text": "func IsRouteRumor(rumor *RumorMessage) bool {\n\treturn (strings.Compare(rumor.Text, \"\") == 0)\n}", "title": "" }, { "docid": "221c66599b83c52bc52d8fbcd8a49c34", "score": "0.5154002", "text": "func (r *reader) done() bool {\n\treturn r.n == 0\n}", "title": "" }, { "docid": "b973d585abec674faea8083173786369", "score": "0.51510584", "text": "func (o *DAGDetail) GetNextDagrunOk() (*time.Time, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn o.NextDagrun.Get(), o.NextDagrun.IsSet()\n}", "title": "" }, { "docid": "3c708af3a8e356e689289eaaff0340eb", "score": "0.5137274", "text": "func (mn RplidarResponseMeasurementNode) Valid() bool {\n\treturn mn.DistanceAsFloat32() > 0\n}", "title": "" }, { "docid": "42e761145d252ab519d15490399bc941", "score": "0.51319844", "text": "func (rm RunMode) IsNode() bool {\r\n\treturn rm == node\r\n}", "title": "" }, { "docid": "cd5606a8c442fdafd6c11982dfceea7d", "score": "0.5128054", "text": "func (s Status) Expected() bool {\n\treturn s.Value&StatusExpected != 0\n}", "title": "" }, { "docid": "522543d8786d78cf9726e75882db866c", "score": "0.511432", "text": "func (m *FullIntroductionReaderMock) GetNodePublicKeyFinished() bool {\n\t// if expectation series were set then invocations count should be equal to expectations count\n\tif len(m.GetNodePublicKeyMock.expectationSeries) > 0 {\n\t\treturn atomic.LoadUint64(&m.GetNodePublicKeyCounter) == uint64(len(m.GetNodePublicKeyMock.expectationSeries))\n\t}\n\n\t// if main expectation was set then invocations count should be greater than zero\n\tif m.GetNodePublicKeyMock.mainExpectation != nil {\n\t\treturn atomic.LoadUint64(&m.GetNodePublicKeyCounter) > 0\n\t}\n\n\t// if func was set then invocations count should be greater than zero\n\tif m.GetNodePublicKeyFunc != nil {\n\t\treturn atomic.LoadUint64(&m.GetNodePublicKeyCounter) > 0\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "9e8d8a2b9125ddec2e3ddc892a73a13e", "score": "0.51059985", "text": "func (m Move) Valid() bool {\n\treturn 0 <= m.I && m.I < N && 0 <= m.J && m.J < N\n}", "title": "" }, { "docid": "5ea9b530850ce036755e6efe769afc43", "score": "0.508899", "text": "func (o *RecurringTransfer) GetNextOriginationDateOk() (*string, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn o.NextOriginationDate.Get(), o.NextOriginationDate.IsSet()\n}", "title": "" }, { "docid": "693ff9991cbbae6fbe66a08043b94879", "score": "0.508783", "text": "func isCompleteTree(root *TreeNode) bool {\n\tqueue := []node{{n: root, code: 1}}\n\ti := 0\n\tfor i < len(queue) {\n\t\tcurrent := queue[i]\n\t\ti++\n\t\tif current.n != nil {\n\t\t\tqueue = append(queue, node{n: current.n.Left, code: current.code * 2})\n\t\t\tqueue = append(queue, node{n: current.n.Right, code: current.code*2 + 1})\n\t\t}\n\t}\n\treturn queue[len(queue)-1].code == len(queue)\n}", "title": "" }, { "docid": "c355a833bd16aee4f681c6e67c72306c", "score": "0.5076416", "text": "func (m *IterStub) HasNext() bool {\n\treturn m.List != nil && m.Curr < len(m.List)\n}", "title": "" }, { "docid": "eb7b3918a1cf48fb2d9c5961a1d6273a", "score": "0.5072587", "text": "func (m *CertificateMock) MinimockGetRoleDone() bool {\n\tfor _, e := range m.GetRoleMock.expectations {\n\t\tif mm_atomic.LoadUint64(&e.Counter) < 1 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// if default expectation was set then invocations count should be greater than zero\n\tif m.GetRoleMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetRoleCounter) < 1 {\n\t\treturn false\n\t}\n\t// if func was set then invocations count should be greater than zero\n\tif m.funcGetRole != nil && mm_atomic.LoadUint64(&m.afterGetRoleCounter) < 1 {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "1edc29bf4d4b754199f61307f9fc2815", "score": "0.5055337", "text": "func (pi Iterator) Done() bool { return len(pi.raw) == pi.consumed && !pi.lastEmpty }", "title": "" }, { "docid": "dadd220107ae9c98976a142fac6d6be8", "score": "0.5054311", "text": "func (m *NodeIntroProfileMock) GetNodePublicKeyFinished() bool {\n\t// if expectation series were set then invocations count should be equal to expectations count\n\tif len(m.GetNodePublicKeyMock.expectationSeries) > 0 {\n\t\treturn atomic.LoadUint64(&m.GetNodePublicKeyCounter) == uint64(len(m.GetNodePublicKeyMock.expectationSeries))\n\t}\n\n\t// if main expectation was set then invocations count should be greater than zero\n\tif m.GetNodePublicKeyMock.mainExpectation != nil {\n\t\treturn atomic.LoadUint64(&m.GetNodePublicKeyCounter) > 0\n\t}\n\n\t// if func was set then invocations count should be greater than zero\n\tif m.GetNodePublicKeyFunc != nil {\n\t\treturn atomic.LoadUint64(&m.GetNodePublicKeyCounter) > 0\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "8ab330ce1398e822fcb1e45be05d750e", "score": "0.50432634", "text": "func (o *DAGDetail) HasNextDagrun() bool {\n\tif o != nil && o.NextDagrun.IsSet() {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "05a4af845d257990b428950e2cd5f8f5", "score": "0.50278544", "text": "func (r RemoteOffset) Equal(o RemoteOffset) bool {\n\treturn r.Offset == o.Offset && r.Uncertainty == o.Uncertainty && r.MeasuredAt == o.MeasuredAt\n}", "title": "" }, { "docid": "62f7f7b71e4b6def86fe3397bb96ab51", "score": "0.5024162", "text": "func (c *RoleSchema) NextRow() bool {\n\tif c.rowNum >= len(c.rows)-1 {\n\t\tc.done = true\n\t}\n\tc.rowNum = c.rowNum + 1\n\treturn !c.done\n}", "title": "" }, { "docid": "4810cd2f1c155b91310ca296db119b37", "score": "0.5022871", "text": "func (i *Iterator) Next() bool {\n\treturn i.nextWithLimit(nil) == IterValid\n}", "title": "" }, { "docid": "b04d0731001fd3776908aeca99094d54", "score": "0.5015708", "text": "func (r AttemptResult) Valid() bool {\n\treturn r >= AttemptSuccess && r <= AttemptError\n}", "title": "" }, { "docid": "528dc04a028459eb8fc91ea081259fb1", "score": "0.50149304", "text": "func (iter *mockIterator) Next() bool {\n\tif iter.closed {\n\t\treturn false\n\t}\n\n\t// Check if reading the next row will get us out of bounds\n\tif iter.currRowIndex+1 >= len(iter.results) {\n\t\treturn false\n\t}\n\n\titer.currRowIndex++\n\treturn true\n}", "title": "" }, { "docid": "f473b911cff0eae1ab5b27f9eedeb906", "score": "0.50102293", "text": "func (r *Result) IsNil() bool {\n\treturn r.rst == nil\n}", "title": "" }, { "docid": "dbbfdb33ddd2ad961bc47fc8b6d0d6bd", "score": "0.50087595", "text": "func (m *ActiveNodeMock) MinimockCanIntroduceJoinerDone() bool {\n\tfor _, e := range m.CanIntroduceJoinerMock.expectations {\n\t\tif mm_atomic.LoadUint64(&e.Counter) < 1 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// if default expectation was set then invocations count should be greater than zero\n\tif m.CanIntroduceJoinerMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterCanIntroduceJoinerCounter) < 1 {\n\t\treturn false\n\t}\n\t// if func was set then invocations count should be greater than zero\n\tif m.funcCanIntroduceJoiner != nil && mm_atomic.LoadUint64(&m.afterCanIntroduceJoinerCounter) < 1 {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "b248fb318aaacc55630eb446f903fb49", "score": "0.5007359", "text": "func (m *NodeStorageMock) GetActiveNodesByRoleFinished() bool {\n\t// if expectation series were set then invocations count should be equal to expectations count\n\tif len(m.GetActiveNodesByRoleMock.expectationSeries) > 0 {\n\t\treturn atomic.LoadUint64(&m.GetActiveNodesByRoleCounter) == uint64(len(m.GetActiveNodesByRoleMock.expectationSeries))\n\t}\n\n\t// if main expectation was set then invocations count should be greater than zero\n\tif m.GetActiveNodesByRoleMock.mainExpectation != nil {\n\t\treturn atomic.LoadUint64(&m.GetActiveNodesByRoleCounter) > 0\n\t}\n\n\t// if func was set then invocations count should be greater than zero\n\tif m.GetActiveNodesByRoleFunc != nil {\n\t\treturn atomic.LoadUint64(&m.GetActiveNodesByRoleCounter) > 0\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "23eb6e41e10892aee19cd5a50f75f099", "score": "0.5006316", "text": "func (m *mockRows) Next() bool {\n\treturn !m.noNext && m.idx < len(m.results)\n}", "title": "" }, { "docid": "e59e75840e6750c4c5d6f295a1a7b060", "score": "0.5001737", "text": "func (m *FullIntroductionReaderMock) GetPrimaryRoleFinished() bool {\n\t// if expectation series were set then invocations count should be equal to expectations count\n\tif len(m.GetPrimaryRoleMock.expectationSeries) > 0 {\n\t\treturn atomic.LoadUint64(&m.GetPrimaryRoleCounter) == uint64(len(m.GetPrimaryRoleMock.expectationSeries))\n\t}\n\n\t// if main expectation was set then invocations count should be greater than zero\n\tif m.GetPrimaryRoleMock.mainExpectation != nil {\n\t\treturn atomic.LoadUint64(&m.GetPrimaryRoleCounter) > 0\n\t}\n\n\t// if func was set then invocations count should be greater than zero\n\tif m.GetPrimaryRoleFunc != nil {\n\t\treturn atomic.LoadUint64(&m.GetPrimaryRoleCounter) > 0\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "2febc207b7db964562d5f65824021264", "score": "0.49997532", "text": "func (m *CoordinatorMock) IsBeyondLimitFinished() bool {\n\t// if expectation series were set then invocations count should be equal to expectations count\n\tif len(m.IsBeyondLimitMock.expectationSeries) > 0 {\n\t\treturn atomic.LoadUint64(&m.IsBeyondLimitCounter) == uint64(len(m.IsBeyondLimitMock.expectationSeries))\n\t}\n\n\t// if main expectation was set then invocations count should be greater than zero\n\tif m.IsBeyondLimitMock.mainExpectation != nil {\n\t\treturn atomic.LoadUint64(&m.IsBeyondLimitCounter) > 0\n\t}\n\n\t// if func was set then invocations count should be greater than zero\n\tif m.IsBeyondLimitFunc != nil {\n\t\treturn atomic.LoadUint64(&m.IsBeyondLimitCounter) > 0\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "a425f6765153df4d4edadafdf8933229", "score": "0.497892", "text": "func (s *Steps) Fin() bool {\n\treturn int(math.Abs(float64(s.step))) == len(s.steppers)\n}", "title": "" }, { "docid": "5e47e20e93a1cbb5f7ee6af6058d7410", "score": "0.49778152", "text": "func isRankValid(db *taxonomy.DB, p biodv.Taxon, rk biodv.Rank) bool {\n\tif rk == biodv.Unranked {\n\t\treturn true\n\t}\n\tfor ; p != nil; p, _ = db.TaxID(p.Parent()) {\n\t\tr := p.Rank()\n\t\tif r == biodv.Unranked {\n\t\t\tcontinue\n\t\t}\n\t\tif rk > r {\n\t\t\treturn true\n\t\t}\n\t\tif rk == r && synonym {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "8b7843904a2b221f7a2b1de4f640814e", "score": "0.49677876", "text": "func (pager *LinkedZonesPager) HasNext() bool {\n\treturn pager.hasNext\n}", "title": "" }, { "docid": "38db79490e9be7b7bd71f5c39d81c776", "score": "0.49488717", "text": "func (c *GrantRelationshipSchema) NextRow() bool {\n\tif c.rowNum >= len(c.rows)-1 {\n\t\tc.done = true\n\t}\n\tc.rowNum = c.rowNum + 1\n\treturn !c.done\n}", "title": "" }, { "docid": "aa30b78acd5209bbdfa033618db23224", "score": "0.49474633", "text": "func (m *HostNetworkMock) PublicAddressFinished() bool {\n\t// if expectation series were set then invocations count should be equal to expectations count\n\tif len(m.PublicAddressMock.expectationSeries) > 0 {\n\t\treturn atomic.LoadUint64(&m.PublicAddressCounter) == uint64(len(m.PublicAddressMock.expectationSeries))\n\t}\n\n\t// if main expectation was set then invocations count should be greater than zero\n\tif m.PublicAddressMock.mainExpectation != nil {\n\t\treturn atomic.LoadUint64(&m.PublicAddressCounter) > 0\n\t}\n\n\t// if func was set then invocations count should be greater than zero\n\tif m.PublicAddressFunc != nil {\n\t\treturn atomic.LoadUint64(&m.PublicAddressCounter) > 0\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "0eedabb1e4bbbf6d7e00659ffac18414", "score": "0.4946786", "text": "func (ctx *rollDPoSCtx) isEpochFinished() (bool, error) {\n\theight := ctx.chain.TipHeight()\n\t// if the height of the last committed block is already the last one should be minted from this epochStart, go back\n\t// to epochStart start\n\tif height >= ctx.epoch.height+uint64(uint(len(ctx.epoch.delegates))*ctx.epoch.numSubEpochs)-1 {\n\t\treturn true, nil\n\t}\n\treturn false, nil\n}", "title": "" }, { "docid": "3992cf6cabee4a63f560127e8d7da457", "score": "0.4942569", "text": "func (iter *Iterator) Valid() bool {\n\treturn iter.node != nil\n}", "title": "" }, { "docid": "98e3cb69380be8064d459b0f1cd0978f", "score": "0.49418375", "text": "func (vr *Time64ValueIterator) Next() bool {\n\tif vr.done {\n\t\treturn false\n\t}\n\n\t// Move the index up\n\tvr.index++\n\n\t// Keep moving the chunk up until we get one with data\n\tfor vr.values == nil || vr.index >= len(vr.values) {\n\t\tif !vr.nextChunk() {\n\t\t\t// There were no more chunks with data in them\n\t\t\tvr.done = true\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "57ad13bb0926a51c358f904ff5c574d3", "score": "0.49356985", "text": "func (km *Kmers) HasNext() bool {\n\tlastOfSequences := km.li == len(km.Sequences)-1\n\tendOfSeq := km.pi+km.K > len(km.Sequences[km.li])\n\treturn !(lastOfSequences && endOfSeq)\n}", "title": "" }, { "docid": "487e40c7d77a92cdd6ca194bb2e3d8b2", "score": "0.4919155", "text": "func (it *BSTIterator) HasNext() bool {\n\treturn len(it.stack) > 0\n}", "title": "" }, { "docid": "6c3a51d4d01c226241bc693d39e112e9", "score": "0.49070197", "text": "func (block *Block) IsNext(previous *Block) bool {\n\tif block.Index != previous.Index+1 {\n\t\treturn false\n\t} else if !reflect.DeepEqual(block.PreviousHash, previous.Hash) {\n\t\treturn false\n\t} else if block.Timestamp <= previous.Timestamp {\n\t\treturn false\n\t} else if block.Hash[0] != 0 || block.Hash[1] != 0 || block.Hash[2] != 0 {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "becef65b17b4e4aaf79c6b4d7190652c", "score": "0.489827", "text": "func (x *fastReflection_OriginTx) IsValid() bool {\n\treturn x != nil\n}", "title": "" }, { "docid": "e9c7ade009a00f9ce1b38417dad1ef51", "score": "0.48956633", "text": "func (m *OrderedMap) Next() bool {\n\treturn m.iter < len(m.ordered)\n}", "title": "" }, { "docid": "c02015f6636c59ee4421e5bc3f8e53a5", "score": "0.48935044", "text": "func (i *RouteIterator) Valid() bool {\n\t// TODO implement me\n\treturn i.cmd != nil\n}", "title": "" }, { "docid": "e49b2f50d6fe71d207652476a328cd07", "score": "0.48910132", "text": "func (vr *Uint64ValueIterator) Next() bool {\n\tif vr.done {\n\t\treturn false\n\t}\n\n\t// Move the index up\n\tvr.index++\n\n\t// Keep moving the chunk up until we get one with data\n\tfor vr.values == nil || vr.index >= len(vr.values) {\n\t\tif !vr.nextChunk() {\n\t\t\t// There were no more chunks with data in them\n\t\t\tvr.done = true\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "b08e92ffc522bb32d0b1f91f9d2a75a6", "score": "0.4883462", "text": "func (m *NodeKeeperMock) MinimockSyncDone() bool {\n\tfor _, e := range m.SyncMock.expectations {\n\t\tif mm_atomic.LoadUint64(&e.Counter) < 1 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// if default expectation was set then invocations count should be greater than zero\n\tif m.SyncMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSyncCounter) < 1 {\n\t\treturn false\n\t}\n\t// if func was set then invocations count should be greater than zero\n\tif m.funcSync != nil && mm_atomic.LoadUint64(&m.afterSyncCounter) < 1 {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "4de83022cc71cce95a5677a18a907059", "score": "0.48821288", "text": "func (m *CoordinatorMock) LightExecutorForObjectFinished() bool {\n\t// if expectation series were set then invocations count should be equal to expectations count\n\tif len(m.LightExecutorForObjectMock.expectationSeries) > 0 {\n\t\treturn atomic.LoadUint64(&m.LightExecutorForObjectCounter) == uint64(len(m.LightExecutorForObjectMock.expectationSeries))\n\t}\n\n\t// if main expectation was set then invocations count should be greater than zero\n\tif m.LightExecutorForObjectMock.mainExpectation != nil {\n\t\treturn atomic.LoadUint64(&m.LightExecutorForObjectCounter) > 0\n\t}\n\n\t// if func was set then invocations count should be greater than zero\n\tif m.LightExecutorForObjectFunc != nil {\n\t\treturn atomic.LoadUint64(&m.LightExecutorForObjectCounter) > 0\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "e8ba182c6d7fb969a8699f15693275ae", "score": "0.4874464", "text": "func (i *blockIter) Valid() bool {\n\treturn i.offset >= 0 && i.offset < i.restarts\n}", "title": "" }, { "docid": "d71cd03f2814bf36507070e7819ce280", "score": "0.48739162", "text": "func (m *NodeKeeperMock) MinimockMoveSyncToActiveDone() bool {\n\tfor _, e := range m.MoveSyncToActiveMock.expectations {\n\t\tif mm_atomic.LoadUint64(&e.Counter) < 1 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// if default expectation was set then invocations count should be greater than zero\n\tif m.MoveSyncToActiveMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterMoveSyncToActiveCounter) < 1 {\n\t\treturn false\n\t}\n\t// if func was set then invocations count should be greater than zero\n\tif m.funcMoveSyncToActive != nil && mm_atomic.LoadUint64(&m.afterMoveSyncToActiveCounter) < 1 {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "504d130ca699d913f1b647f7a72bfb6c", "score": "0.48721212", "text": "func (d *DataEdgeIterator) HasNext() bool {\n\tif d.isBruteForce {\n\t\treturn d.currentIndex < d.numEdges\n\t} else {\n\t\treturn d.currentIndexInCandidates < len(d.candidates)\n\t}\n}", "title": "" }, { "docid": "511aa8876d1446d99f9db3f2980416fe", "score": "0.48720586", "text": "func (seq *TreeSeq) Done() bool {\n\treturn seq.seq == nil\n}", "title": "" }, { "docid": "e6b1ad310fe3959e3bc851759c718b2f", "score": "0.48675215", "text": "func (s *remoteScanner) isDone() bool {\n\treturn !s.moreRemoteResults && (s.results == nil || s.nextResultPos >= len(s.results))\n}", "title": "" }, { "docid": "e2cb1fe8f186ae216b46744e89cba069", "score": "0.4862255", "text": "func (pc PositionChange) Done() bool {\n\treturn *pc.Position == pc.Desired\n}", "title": "" }, { "docid": "dd2a861f85fdbc6fbe86fa29224b5f17", "score": "0.48598745", "text": "func (vr *Int64ValueIterator) Next() bool {\n\tif vr.done {\n\t\treturn false\n\t}\n\n\t// Move the index up\n\tvr.index++\n\n\t// Keep moving the chunk up until we get one with data\n\tfor vr.values == nil || vr.index >= len(vr.values) {\n\t\tif !vr.nextChunk() {\n\t\t\t// There were no more chunks with data in them\n\t\t\tvr.done = true\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "47c476c8edf35f65a7e8252f091d424b", "score": "0.48570955", "text": "func (m *CertificateMock) MinimockGetMinRolesDone() bool {\n\tfor _, e := range m.GetMinRolesMock.expectations {\n\t\tif mm_atomic.LoadUint64(&e.Counter) < 1 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// if default expectation was set then invocations count should be greater than zero\n\tif m.GetMinRolesMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetMinRolesCounter) < 1 {\n\t\treturn false\n\t}\n\t// if func was set then invocations count should be greater than zero\n\tif m.funcGetMinRoles != nil && mm_atomic.LoadUint64(&m.afterGetMinRolesCounter) < 1 {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "7944a01df98c7e7c62410a9265ef28b2", "score": "0.48552826", "text": "func (r *Result) NextSet() bool {\n\tif !r.HasNextSet() {\n\t\treturn false\n\t}\n\tresult.Reset(&r.Scanner, r.sets[r.nextSet])\n\tr.nextSet++\n\treturn true\n}", "title": "" }, { "docid": "921c91dc642e642067dc79a7ec27e343", "score": "0.48544392", "text": "func (c *NPCombi) Next() bool {\n\tfor i := c.n - 1; i >= 0; i-- {\n\t\tif c.combi[i] < c.p-(c.n-i) {\n\t\t\tc.combi[i]++\n\t\t\tfor j := i + 1; j < c.n; j++ {\n\t\t\t\tc.combi[j] = c.combi[j-1] + 1\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "01faaa48a40629baa57a6078e3dbc431", "score": "0.48529363", "text": "func (m *CoordinatorMock) LightValidatorsForObjectFinished() bool {\n\t// if expectation series were set then invocations count should be equal to expectations count\n\tif len(m.LightValidatorsForObjectMock.expectationSeries) > 0 {\n\t\treturn atomic.LoadUint64(&m.LightValidatorsForObjectCounter) == uint64(len(m.LightValidatorsForObjectMock.expectationSeries))\n\t}\n\n\t// if main expectation was set then invocations count should be greater than zero\n\tif m.LightValidatorsForObjectMock.mainExpectation != nil {\n\t\treturn atomic.LoadUint64(&m.LightValidatorsForObjectCounter) > 0\n\t}\n\n\t// if func was set then invocations count should be greater than zero\n\tif m.LightValidatorsForObjectFunc != nil {\n\t\treturn atomic.LoadUint64(&m.LightValidatorsForObjectCounter) > 0\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "edfbd7a2c7462170eaaf4467aa1b6673", "score": "0.48523352", "text": "func (n *Neuron) IsEquiv(other *Neuron) bool {\n\treturn n.Op == other.Op && n.HasSeed == other.HasSeed &&\n\t\t(!n.HasSeed || (n.HasSeed && n.Seed == other.Seed))\n}", "title": "" }, { "docid": "f89ea32fd6d51c48c8168f3cb035e89c", "score": "0.48498923", "text": "func (s *scanner) isDone(resp *pb.ScanResponse, region hrpc.RegionInfo) bool {\n\tif resp.MoreResults != nil && !*resp.MoreResults {\n\t\t// or the filter for the whole scan has been exhausted, close the scanner\n\t\treturn true\n\t}\n\n\tif !s.isRegionScannerClosed() {\n\t\t// not done with this region yet\n\t\treturn false\n\t}\n\n\t// Check to see if this region is the last we should scan because:\n\t// (1) it's the last region\n\tif len(region.StopKey()) == 0 && !s.rpc.Reversed() {\n\t\treturn true\n\t}\n\tif s.rpc.Reversed() && len(region.StartKey()) == 0 {\n\t\treturn true\n\t}\n\t// (3) because its stop_key is greater than or equal to the stop_key of this scanner,\n\t// provided that (2) we're not trying to scan until the end of the table.\n\tif !s.rpc.Reversed() {\n\t\treturn len(s.rpc.StopRow()) != 0 && // (2)\n\t\t\tbytes.Compare(s.rpc.StopRow(), region.StopKey()) <= 0 // (3)\n\t}\n\n\t// Reversed Scanner\n\treturn len(s.rpc.StopRow()) != 0 && // (2)\n\t\tbytes.Compare(s.rpc.StopRow(), region.StartKey()) >= 0 // (3)\n}", "title": "" }, { "docid": "3893458d6f972a99b51eff8f112081e7", "score": "0.48438984", "text": "func (mn RplidarResponseMeasurementNode) Invalid() bool {\n\treturn mn.DistanceAsFloat32() <= 0\n}", "title": "" }, { "docid": "400f45965cce1657668d4cbb6416e67f", "score": "0.48437583", "text": "func (e Kevent) IsRundownProcessed() bool {\n\tkey := e.RundownKey()\n\t_, isProcessed := rundowns[key]\n\tif isProcessed {\n\t\treturn true\n\t}\n\trundowns[key] = true\n\treturn false\n}", "title": "" }, { "docid": "434e2581879d10ad373e08c4ea0405d4", "score": "0.4842776", "text": "func (ap *algoProcess) next(guess []int) bool {\n\tchanged := false\n\n\t// Sort step by step until a change's happened in the array\n\tfor !ap.done && !changed {\n\t\tap.done, changed = ap.stepSort(ap.current)\n\t}\n\n\tcorrect := isEqual(ap.current, guess)\n\n\tif correct {\n\t\tap.guesses++\n\t} else {\n\t\tfmt.Printf(\"Correct one: %v\\n\", ap.current)\n\t}\n\n\treturn correct\n}", "title": "" }, { "docid": "0b580031a8d08e09c80938cfee9a40f9", "score": "0.48422757", "text": "func (obj *ResultSet) HasNext() bool {\n\tif obj.isOpen == false {\n\t\treturn false\n\t}\n\tif len(obj.resultList) == 0 {\n\t\treturn false\n\t} else if obj.currPos < (len(obj.resultList)-1) {\n\t\treturn true\n\t}\n\treturn false\n}", "title": "" }, { "docid": "fdbd16c6f0b20b8a54cd508393ef62e3", "score": "0.48372132", "text": "func (m *ActiveNodeMock) MinimockGetNodeIDDone() bool {\n\tfor _, e := range m.GetNodeIDMock.expectations {\n\t\tif mm_atomic.LoadUint64(&e.Counter) < 1 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// if default expectation was set then invocations count should be greater than zero\n\tif m.GetNodeIDMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetNodeIDCounter) < 1 {\n\t\treturn false\n\t}\n\t// if func was set then invocations count should be greater than zero\n\tif m.funcGetNodeID != nil && mm_atomic.LoadUint64(&m.afterGetNodeIDCounter) < 1 {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "10d70469138399b1e1152eefa06650f3", "score": "0.48355603", "text": "func isPrefixNext(key []byte, expected []byte) bool {\n\tkey = convertToPrefixNext(key)\n\tif len(key) != len(expected) {\n\t\treturn false\n\t}\n\tfor i := 0; i < len(key); i++ {\n\t\tif key[i] != expected[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "title": "" }, { "docid": "bbc6de74f0a31e6b924e5ffb51b872d3", "score": "0.48263052", "text": "func (m Move) Recurring(s Step) bool {\n\tif s.Capture() {\n\t\treturn false\n\t}\n\tfor _, x := range m {\n\t\tif x.Capture() {\n\t\t\tcontinue\n\t\t}\n\t\tif x.Recurring(s) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "8af3fcbf4a89ea4143df65fea3569f03", "score": "0.48195425", "text": "func (q *ContainerTaskQueue) HasNext() bool {\n\treturn q.position < len(q.queue)\n}", "title": "" }, { "docid": "b131a16cf13c771509e43ada933d301f", "score": "0.48194543", "text": "func (node Node) IsExhausted() bool {\n\t// if any child is not exhausted then this node is not either\n\tif node.State == nil {\n\t\treturn true\n\t}\n\tfor k := range node.State.LegalActions() {\n\t\tif _, ok := node.children[k]; !ok {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "title": "" }, { "docid": "b7a3848867f9333f1b403f2eb64a4cf1", "score": "0.48189726", "text": "func (step *Step) IsDone() bool {\n\treturn step.time == 0\n}", "title": "" }, { "docid": "cae0ddf97d698bfdacf5eefd879bd4aa", "score": "0.48180154", "text": "func (m *CoordinatorMock) MeFinished() bool {\n\t// if expectation series were set then invocations count should be equal to expectations count\n\tif len(m.MeMock.expectationSeries) > 0 {\n\t\treturn atomic.LoadUint64(&m.MeCounter) == uint64(len(m.MeMock.expectationSeries))\n\t}\n\n\t// if main expectation was set then invocations count should be greater than zero\n\tif m.MeMock.mainExpectation != nil {\n\t\treturn atomic.LoadUint64(&m.MeCounter) > 0\n\t}\n\n\t// if func was set then invocations count should be greater than zero\n\tif m.MeFunc != nil {\n\t\treturn atomic.LoadUint64(&m.MeCounter) > 0\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "0e135984badb6f6b693477f270c31985", "score": "0.48141363", "text": "func (m *NodeIntroProfileMock) GetSpecialRolesFinished() bool {\n\t// if expectation series were set then invocations count should be equal to expectations count\n\tif len(m.GetSpecialRolesMock.expectationSeries) > 0 {\n\t\treturn atomic.LoadUint64(&m.GetSpecialRolesCounter) == uint64(len(m.GetSpecialRolesMock.expectationSeries))\n\t}\n\n\t// if main expectation was set then invocations count should be greater than zero\n\tif m.GetSpecialRolesMock.mainExpectation != nil {\n\t\treturn atomic.LoadUint64(&m.GetSpecialRolesCounter) > 0\n\t}\n\n\t// if func was set then invocations count should be greater than zero\n\tif m.GetSpecialRolesFunc != nil {\n\t\treturn atomic.LoadUint64(&m.GetSpecialRolesCounter) > 0\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "ef96404eeb7274b1c84a4c5e253100f3", "score": "0.48046327", "text": "func (o *IpamNetworkEditInput) GetUseReversedRelativePositionOk() (*int32, bool) {\n\tif o == nil || o.UseReversedRelativePosition == nil {\n\t\treturn nil, false\n\t}\n\treturn o.UseReversedRelativePosition, true\n}", "title": "" }, { "docid": "a13fedf13dcf28177cc91649dc5f8cd7", "score": "0.4802124", "text": "func (r GithubActionRunnerSpec) IsValid() (bool, error) {\n\tif r.MaxRunners < r.MinRunners {\n\t\treturn false, errors.New(\"MaxRunners must be greater or equal to minRunners\")\n\t}\n\n\treturn true, nil\n}", "title": "" }, { "docid": "cc643821daa2c49cc57854135e635e3d", "score": "0.480174", "text": "func (iterator *TransactionIterator) HasNext() bool {\n\treturn iterator.current < len(iterator.transactions)\n}", "title": "" }, { "docid": "d51c3654ad2d0d6d44542d9c96b1ab52", "score": "0.4799146", "text": "func (rmTask *RMTask) hasFinishedPlacementCycle() bool {\n\t// Checking if placement backoff is enabled\n\tif !rmTask.config.EnablePlacementBackoff {\n\t\treturn false\n\t}\n\treturn rmTask.policy.IsCycleCompleted(rmTask.Task(), rmTask.config)\n}", "title": "" }, { "docid": "a051bcaa119a036632dfae573e544f20", "score": "0.47984323", "text": "func (e *EigenSym) succFact() bool {\n\treturn len(e.values) != 0\n}", "title": "" }, { "docid": "25b113b8f6abbc41ce4a6868c01bd5da", "score": "0.47972304", "text": "func (i *gitLogIter) HasNext() bool {\n\tif i.nextc == nil {\n\t\tif i.nexth == \"\" {\n\t\t\treturn false\n\t\t}\n\t\ti.nextc = i.corpus.GitCommit(i.nexth.String())\n\t}\n\treturn i.nextc != nil\n}", "title": "" }, { "docid": "759f22d43b3b237987e6e5a6fcfc4467", "score": "0.47967032", "text": "func (c *CellIndexRangeIterator) Done() bool {\n\treturn c.pos >= len(c.rangeNodes)-1\n}", "title": "" }, { "docid": "1e6b4b44c0f65ab90bc542d2b83a27ed", "score": "0.47949255", "text": "func (t *streamImpl) NextArg() bool {\n\tif t.finished {\n\t\treturn false\n\t}\n\tif !t.confirmed {\n\t\treturn true\n\t}\n\tif t.src.NextArg() {\n\t\tt.cur.File = t.src.File()\n\t\tt.cur.Value = t.src.Val()\n\t\tt.cur.Lin = t.src.Line()\n\t\tt.confirmed = false\n\t\treturn true\n\t}\n\treturn false\n}", "title": "" }, { "docid": "9b22ee9b9f4ce5dca70125960a2e1df8", "score": "0.47947988", "text": "func (s *Server) IsExpectedReply(fromIP net.IP, fromID identity.ID, msg Message) bool {\n\tmatched := make(chan bool, 1)\n\tselect {\n\tcase s.replyReceived <- reply{fromIP, fromID, msg, matched}:\n\t\t// wait for matcher and return whether a matching request was found\n\t\treturn <-matched\n\tcase <-s.closing:\n\t\treturn false\n\t}\n}", "title": "" }, { "docid": "02f508dd08059ab8aa30b0f3d1824892", "score": "0.47942737", "text": "func (r *Reader) Done() bool {\n\treturn r.err != nil || r.done\n}", "title": "" }, { "docid": "e343b576c598dc45f527e8562f30f841", "score": "0.47900692", "text": "func (vr *Float64ValueIterator) Next() bool {\n\tif vr.done {\n\t\treturn false\n\t}\n\n\t// Move the index up\n\tvr.index++\n\n\t// Keep moving the chunk up until we get one with data\n\tfor vr.values == nil || vr.index >= len(vr.values) {\n\t\tif !vr.nextChunk() {\n\t\t\t// There were no more chunks with data in them\n\t\t\tvr.done = true\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "b2661ae101c2a0b2733cc8dc4bc520a4", "score": "0.47876686", "text": "func (f *FastqReader) HasNext() bool {\n var err error\n\n // Grab next two lines, verify, and return false if any errors occur.\n\n f.next[0], err = f.reader.ReadBytes('\\n')\n if err != nil || len(f.next[0]) == 0 || f.next[0][0] != '@' {\n return false\n }\n\n f.next[1], err = f.reader.ReadBytes('\\n')\n if err != nil {\n return false\n }\n\n plusLine, err := f.reader.ReadBytes('\\n')\n if err != nil || len(plusLine) == 0 || plusLine[0] != '+' {\n return false\n }\n\n f.next[2], err = f.reader.ReadBytes('\\n')\n if (err != nil && err != io.EOF) || len(f.next[2]) == 0 {\n return false\n }\n\n // Sanitize newlines\n f.next[0] = bytes.Trim(f.next[0], \"\\n\")\n f.next[1] = bytes.Trim(f.next[1], \"\\n\")\n f.next[2] = bytes.Trim(f.next[2], \"\\n\")\n\n return true\n}", "title": "" } ]
30313d64301f7f3056f024d5eb51c41c
Help returns a helpful message from the bot in order for the user to use to bot
[ { "docid": "9902709552a98a3f7b2d17c9fe6bc8cc", "score": "0.80727005", "text": "func (sponge *SpongeBot) Help(m *telebot.Message) {\n\thelpMessage := `\n\tHey ! if you need any help, that's how it works : \n\t- /retarded will convert a sentence to a retarded one : Hello world => HeLlO wOrLd\n\t- if you type any text, it will generate the meme from sponge bob (image + retarded text)\n\t`\n\tphotoToSend := telebot.Photo{\n\t\tFile: telebot.FromReader(bobImage.PngToBytes(sponge.thumbsUpBob)),\n\t}\n\tsponge.bot.Send(m.Sender, \"Gotcha\")\n\tsponge.bot.Send(m.Sender, &photoToSend)\n\tsponge.bot.Send(m.Sender, helpMessage)\n}", "title": "" } ]
[ { "docid": "ce49db7440345f2633aa0cfb7a556c9c", "score": "0.79997164", "text": "func (p *AdminPlugin) Help(channel string, parts []string) {\n\tp.Bot.SendMessage(channel, \"This does super secret things that you're not allowed to know about.\")\n}", "title": "" }, { "docid": "ce49db7440345f2633aa0cfb7a556c9c", "score": "0.79997164", "text": "func (p *AdminPlugin) Help(channel string, parts []string) {\n\tp.Bot.SendMessage(channel, \"This does super secret things that you're not allowed to know about.\")\n}", "title": "" }, { "docid": "27279c0c1f31b5a66edcf6f46fc4d713", "score": "0.7921779", "text": "func (p *YourPlugin) Help(channel string, parts []string) {\n\tp.bot.SendMessage(channel, \"Your corrects people's grammar.\")\n}", "title": "" }, { "docid": "19068f080f6a509e6d6a9e050e5152e6", "score": "0.7798457", "text": "func (c *ReplyCommand) Help() string {\n\treturn \"Usage: a-know reply --msg <message> --url <reply webhook URL> --ch <reply channel name>\"\n}", "title": "" }, { "docid": "6d1a4db72704c8e4707d1ee6879a4b42", "score": "0.7738391", "text": "func Help(s *discordgo.Session, m *discordgo.MessageCreate) {\n\n\thelp := readCommands()\n\ts.ChannelMessageSend(m.ChannelID, help)\n\n}", "title": "" }, { "docid": "1585bf3e3eba7135c2f30683830ce77e", "score": "0.7732095", "text": "func (p *FeedPlugin) Help(channel string, parts []string) {\n\tp.Bot.SendMessage(channel, \"Sorry, Feed does not do a goddamn thing.\")\n}", "title": "" }, { "docid": "80acdfbdbac2da6699b370deafbb5f94", "score": "0.7703435", "text": "func (c *commands) Help(_ *disgord.MessageCreate) error {\n\treturn nil\n}", "title": "" }, { "docid": "019fb9c9f642d0f5e8c37c2084b446df", "score": "0.7653195", "text": "func Help(chatID int, bot *tgbotapi.BotAPI) {\n\tmsg := tgbotapi.MessageConfig{\n\t\tBaseChat: tgbotapi.BaseChat{ChatID: int64(chatID)},\n\t\tText: betypes.GetTexts().Commands.Help.Text,\n\t\tParseMode: betypes.GetTexts().ParseMode,\n\t}\n\n\t_, err := bot.Send(msg)\n\tif err != nil {\n\t\tlogger.ForError(err.Error())\n\t}\n}", "title": "" }, { "docid": "6f19d513282fd95bbf430ca0b1895906", "score": "0.75792474", "text": "func HelpHandle(s *discordgo.Session, m *discordgo.MessageCreate, prefix string) {\n\tembed := &discordgo.MessageEmbed{\n\t\tAuthor: &discordgo.MessageEmbedAuthor{\n\t\t\tURL: \"https://discordapp.com/oauth2/authorize?&client_id=\" + s.State.User.ID + \"&scope=bot&permissions=0\",\n\t\t\tName: \"Click here to invite MaquiaBot!\",\n\t\t\tIconURL: s.State.User.AvatarURL(\"2048\"),\n\t\t},\n\t\tDescription: \"**Most commands have other forms as well for convenience!**\" + \"\\n\\n\" +\n\t\t\t\"**Please do `\" + prefix + \"help <command>` for more information about the command!** \\n\" +\n\t\t\t\"Help information format: `(cmd|names) <args> [optional args]`\",\n\t\tFields: []*discordgo.MessageEmbedField{\n\t\t\t&discordgo.MessageEmbedField{\n\t\t\t\tName: \"Categories:\",\n\t\t\t\tValue: \"`admin`\\n\" +\n\t\t\t\t\t\"`general`\\n\" +\n\t\t\t\t\t\"`math`\\n\" +\n\t\t\t\t\t\"`osucmd`\\n\" +\n\t\t\t\t\t\"`pokemoncmd`\",\n\t\t\t},\n\t\t},\n\t\tColor: osutools.ModeColour(osuapi.ModeOsu),\n\t}\n\n\targRegex, _ := regexp.Compile(`(?i)help\\s+(.+)`)\n\tif argRegex.MatchString(m.Content) {\n\t\targ := argRegex.FindStringSubmatch(m.Content)[1]\n\t\targs := strings.Split(arg, \" \")\n\t\tif (args[0] == \"pokemon\" || args[0] == \"osu\") && len(args) > 1 {\n\t\t\targ = args[1]\n\t\t}\n\t\tswitch arg {\n\t\t// Categories\n\t\tcase \"admin\":\n\t\t\tembed.Fields = []*discordgo.MessageEmbedField{\n\t\t\t\t&discordgo.MessageEmbedField{\n\t\t\t\t\tName: \"Admin commands:\",\n\t\t\t\t\tValue: \"`counter`, \" +\n\t\t\t\t\t\t\"`downloadchannel`, \" +\n\t\t\t\t\t\t\"`downloadserver`, \" +\n\t\t\t\t\t\t\"`maquiaprefix`, \" +\n\t\t\t\t\t\t\"`purge`, \" +\n\t\t\t\t\t\t\"`removechannel`, \" +\n\t\t\t\t\t\t\"`removeserver`, \" +\n\t\t\t\t\t\t\"`roleautomation`, \" +\n\t\t\t\t\t\t\"`toggle`, \" +\n\t\t\t\t\t\t\"`track`, \" +\n\t\t\t\t\t\t\"`trigger`, \" +\n\t\t\t\t\t\t\"`tracktoggle`\",\n\t\t\t\t},\n\t\t\t}\n\t\tcase \"general\":\n\t\t\tembed.Fields = []*discordgo.MessageEmbedField{\n\t\t\t\t&discordgo.MessageEmbedField{\n\t\t\t\t\tName: \"General commands:\",\n\t\t\t\t\tValue: \"`adjectives`, \" +\n\t\t\t\t\t\t\"`avatar`, \" +\n\t\t\t\t\t\t\"`avatarquote`, \" +\n\t\t\t\t\t\t\"`caps`, \" +\n\t\t\t\t\t\t\"`comparepenis`, \" +\n\t\t\t\t\t\t\"`comparevagina`, \" +\n\t\t\t\t\t\t\"`channelinfo`, \" +\n\t\t\t\t\t\t\"`charcount`, \" +\n\t\t\t\t\t\t\"`choose`, \" +\n\t\t\t\t\t\t\"`cheers`, \" +\n\t\t\t\t\t\t\"`colour`, \" +\n\t\t\t\t\t\t\"`conversation`, \" +\n\t\t\t\t\t\t\"`countrank`, \" +\n\t\t\t\t\t\t\"`counters`, \" +\n\t\t\t\t\t\t\"`crab`, \" +\n\t\t\t\t\t\t\"`decrypt`, \" +\n\t\t\t\t\t\t\"`download`, \" +\n\t\t\t\t\t\t\"`emote`, \" +\n\t\t\t\t\t\t\"`encrypt`, \" +\n\t\t\t\t\t\t\"`face`, \" +\n\t\t\t\t\t\t\"`history`, \" +\n\t\t\t\t\t\t\"`idea`, \" +\n\t\t\t\t\t\t\"`info`, \" +\n\t\t\t\t\t\t\"`kanye`, \" +\n\t\t\t\t\t\t\"`late`, \" +\n\t\t\t\t\t\t\"`levenshtein`, \" +\n\t\t\t\t\t\t\"`list`, \" +\n\t\t\t\t\t\t\"`lower`, \" +\n\t\t\t\t\t\t\"`meme`, \" +\n\t\t\t\t\t\t\"`merge`, \" +\n\t\t\t\t\t\t\"`nouns`, \" +\n\t\t\t\t\t\t\"`ntw`, \" +\n\t\t\t\t\t\t\"`ocr`, \" +\n\t\t\t\t\t\t\"`over`, \" +\n\t\t\t\t\t\t\"`percentage`, \" +\n\t\t\t\t\t\t\"`parse`, \" +\n\t\t\t\t\t\t\"`penis`, \" +\n\t\t\t\t\t\t\"`ping`, \" +\n\t\t\t\t\t\t\"`quote`, \" +\n\t\t\t\t\t\t\"`quoteadd`, \" +\n\t\t\t\t\t\t\"`quotedelete`, \" +\n\t\t\t\t\t\t\"`quotes`, \" +\n\t\t\t\t\t\t\"`randomcaps`, \" +\n\t\t\t\t\t\t\"`rankpenis`, \" +\n\t\t\t\t\t\t\"`rankvagina`, \" +\n\t\t\t\t\t\t\"`reminder`, \" +\n\t\t\t\t\t\t\"`reminders`, \" +\n\t\t\t\t\t\t\"`remindremove`, \" +\n\t\t\t\t\t\t\"`roleinfo`, \" +\n\t\t\t\t\t\t\"`roll`, \" +\n\t\t\t\t\t\t\"`serverinfo`, \" +\n\t\t\t\t\t\t\"`skills`, \" +\n\t\t\t\t\t\t\"`source`, \" +\n\t\t\t\t\t\t\"`stats`, \" +\n\t\t\t\t\t\t\"`swap`, \" +\n\t\t\t\t\t\t\"`task`, \" +\n\t\t\t\t\t\t\"`tasks`, \" +\n\t\t\t\t\t\t\"`taskremove`, \" +\n\t\t\t\t\t\t\"`title`, \" +\n\t\t\t\t\t\t\"`triggers`, \" +\n\t\t\t\t\t\t\"`tts`, \" +\n\t\t\t\t\t\t\"`twitchdl`, \" +\n\t\t\t\t\t\t\"`twitterdl`, \" +\n\t\t\t\t\t\t\"`unlink`, \" +\n\t\t\t\t\t\t\"`vagina`, \" +\n\t\t\t\t\t\t\"`vibecheck`, \" +\n\t\t\t\t\t\t\"`weather`, \" +\n\t\t\t\t\t\t\"`wordcount`\",\n\t\t\t\t},\n\t\t\t}\n\t\tcase \"math\":\n\t\t\tembed.Fields = []*discordgo.MessageEmbedField{\n\t\t\t\t&discordgo.MessageEmbedField{\n\t\t\t\t\tName: \"Math commands:\",\n\t\t\t\t\tValue: \"`average`, \" +\n\t\t\t\t\t\t\"`distance`, \" +\n\t\t\t\t\t\t\"`degreesradians`, \" +\n\t\t\t\t\t\t\"`radiansdegrees`, \" +\n\t\t\t\t\t\t\"`standarddeviation`, \" +\n\t\t\t\t\t\t\"`vectoradd`, \" +\n\t\t\t\t\t\t\"`vectorcross`, \" +\n\t\t\t\t\t\t\"`vectordivide`, \" +\n\t\t\t\t\t\t\"`vectordot`, \" +\n\t\t\t\t\t\t\"`vectormultiply`, \" +\n\t\t\t\t\t\t\"`vectorsubtract`\",\n\t\t\t\t},\n\t\t\t}\n\t\tcase \"osucmd\":\n\t\t\tembed.Fields = []*discordgo.MessageEmbedField{\n\t\t\t\t&discordgo.MessageEmbedField{\n\t\t\t\t\tName: \"osu! commands:\",\n\t\t\t\t\tValue: \"`bottomfarm`, \" +\n\t\t\t\t\t\t\"`bpm`, \" +\n\t\t\t\t\t\t\"`compare`, \" +\n\t\t\t\t\t\t\"`farm`, \" +\n\t\t\t\t\t\t\"`leaderboard`, \" +\n\t\t\t\t\t\t\"`link`, \" +\n\t\t\t\t\t\t\"`map`, \" +\n\t\t\t\t\t\t\"`profile`, \" +\n\t\t\t\t\t\t\"`osudetail`, \" +\n\t\t\t\t\t\t\"`osutop`, \" +\n\t\t\t\t\t\t\"`ppadd`, \" +\n\t\t\t\t\t\t\"`recent`, \" +\n\t\t\t\t\t\t\"`recentbest`, \" +\n\t\t\t\t\t\t\"`scorepost`, \" +\n\t\t\t\t\t\t\"`similar`, \" +\n\t\t\t\t\t\t\"`top`, \" +\n\t\t\t\t\t\t\"`topfarm`, \" +\n\t\t\t\t\t\t\"`trackinfo`\",\n\t\t\t\t},\n\t\t\t}\n\t\tcase \"pokemoncmd\":\n\t\t\tembed.Fields = []*discordgo.MessageEmbedField{\n\t\t\t\t&discordgo.MessageEmbedField{\n\t\t\t\t\tName: \"Pokemon commands:\",\n\t\t\t\t\tValue: \"`berry`, \" +\n\t\t\t\t\t\t\"`pokemon`\",\n\t\t\t\t},\n\t\t\t}\n\n\t\t// Admin commands\n\t\tcase \"counter\":\n\t\t\tembed = helpcommands.Counter(embed)\n\t\tcase \"dlch\", \"dlchannel\", \"downloadch\", \"downloadchannel\":\n\t\t\tembed = helpcommands.DownloadChannel(embed)\n\t\tcase \"dlsv\", \"dlserver\", \"downloadsv\", \"downloadserver\":\n\t\t\tembed = helpcommands.DownloadServer(embed)\n\t\tcase \"prefix\", \"maquiaprefix\", \"newprefix\":\n\t\t\tembed = helpcommands.Prefix(embed)\n\t\tcase \"purge\":\n\t\t\tembed = helpcommands.Purge(embed)\n\t\tcase \"rmch\", \"rmchannel\", \"removech\", \"removechannel\":\n\t\t\tembed = helpcommands.RemoveChannel(embed)\n\t\tcase \"rmsv\", \"rmserver\", \"removesv\", \"removeserver\":\n\t\t\tembed = helpcommands.RemoveServer(embed)\n\t\tcase \"rolea\", \"roleauto\", \"roleautomation\":\n\t\t\tembed = helpcommands.RoleAutomation(embed)\n\t\tcase \"toggle\":\n\t\t\tembed = helpcommands.Toggle(embed)\n\t\tcase \"tr\", \"track\":\n\t\t\tembed = helpcommands.Track(embed)\n\t\tcase \"trigger\":\n\t\t\tembed = helpcommands.Trigger(embed)\n\t\tcase \"tt\", \"trackt\", \"ttoggle\", \"tracktoggle\":\n\t\t\tembed = helpcommands.TrackToggle(embed)\n\n\t\t// General commands\n\t\tcase \"adj\", \"adjective\", \"adjectives\":\n\t\t\tembed = helpcommands.Adjectives(embed)\n\t\tcase \"a\", \"ava\", \"avatar\":\n\t\t\tembed = helpcommands.Avatar(embed)\n\t\tcase \"aq\", \"avaquote\", \"avatarquote\", \"quoteava\", \"quoteavatar\":\n\t\t\tembed = helpcommands.AvatarQuote(embed)\n\t\tcase \"cap\", \"caps\", \"upper\":\n\t\t\tembed = helpcommands.AllCaps(embed)\n\t\tcase \"conv\", \"convo\", \"conversation\":\n\t\t\tembed = helpcommands.Conversation(embed)\n\t\tcase \"cp\", \"comparep\", \"comparepenis\":\n\t\t\tembed = helpcommands.PenisCompare(embed)\n\t\tcase \"cv\", \"comparev\", \"comparevagina\":\n\t\t\tembed = helpcommands.VaginaCompare(embed)\n\t\tcase \"cinfo\", \"chinfo\", \"channelinfo\":\n\t\t\tembed = helpcommands.ChannelInfo(embed)\n\t\tcase \"ch\", \"choose\":\n\t\t\tembed = helpcommands.Choose(embed)\n\t\tcase \"count\", \"ccount\", \"charcount\", \"char\":\n\t\t\tembed = helpcommands.CharCount(embed)\n\t\tcase \"cheers\":\n\t\t\tembed = helpcommands.Cheers(embed)\n\t\tcase \"col\", \"color\", \"colour\":\n\t\t\tembed = helpcommands.Colour(embed)\n\t\tcase \"cr\", \"crank\", \"countr\", \"countrank\":\n\t\t\tembed = helpcommands.CountRank(embed)\n\t\tcase \"cs\", \"counters\":\n\t\t\tembed = helpcommands.Counters(embed)\n\t\tcase \"crab\":\n\t\t\tembed = helpcommands.Crab(embed)\n\t\tcase \"decrypt\":\n\t\t\tembed = helpcommands.Decrypt(embed)\n\t\tcase \"dl\", \"download\":\n\t\t\tembed = helpcommands.Download(embed)\n\t\tcase \"e\", \"emoji\", \"emote\":\n\t\t\tembed = helpcommands.Emoji(embed)\n\t\tcase \"encrypt\":\n\t\t\tembed = helpcommands.Encrypt(embed)\n\t\tcase \"face\":\n\t\t\tembed = helpcommands.Face(embed)\n\t\tcase \"history\":\n\t\t\tembed = helpcommands.History(embed)\n\t\tcase \"idea\", \"niceidea\":\n\t\t\tembed = helpcommands.NiceIdea(embed)\n\t\tcase \"info\":\n\t\t\tembed = helpcommands.Info(embed)\n\t\tcase \"kanye\":\n\t\t\tembed = helpcommands.Kanye(embed)\n\t\tcase \"late\", \"old\", \"ancient\":\n\t\t\tembed = helpcommands.Late(embed)\n\t\tcase \"leven\", \"levenshtein\":\n\t\t\tembed = helpcommands.Levenshtein(embed)\n\t\tcase \"list\":\n\t\t\tembed = helpcommands.List(embed)\n\t\tcase \"lower\":\n\t\t\tembed = helpcommands.AllLower(embed)\n\t\tcase \"meme\":\n\t\t\tembed = helpcommands.Meme(embed)\n\t\tcase \"merge\":\n\t\t\tembed = helpcommands.Merge(embed)\n\t\tcase \"noun\", \"nouns\":\n\t\t\tembed = helpcommands.Nouns(embed)\n\t\tcase \"ntw\", \"numtw\", \"ntow\", \"ntword\", \"numtow\", \"numtword\", \"ntoword\", \"numtoword\", \"numbertoword\":\n\t\t\tembed = helpcommands.Ntow(embed)\n\t\tcase \"ocr\":\n\t\t\tembed = helpcommands.OCR(embed)\n\t\tcase \"over\":\n\t\t\tembed = helpcommands.OverIt(embed)\n\t\tcase \"p\", \"per\", \"percent\", \"percentage\":\n\t\t\tembed = helpcommands.Percentage(embed)\n\t\tcase \"parse\":\n\t\t\tembed = helpcommands.Parse(embed)\n\t\tcase \"penis\":\n\t\t\tembed = helpcommands.Penis(embed)\n\t\tcase \"ping\":\n\t\t\tembed = helpcommands.Ping(embed)\n\t\tcase \"q\", \"quote\":\n\t\t\tembed = helpcommands.Quote(embed)\n\t\tcase \"qa\", \"qadd\", \"quotea\", \"quoteadd\":\n\t\t\tembed = helpcommands.QuoteAdd(embed)\n\t\tcase \"qd\", \"qr\", \"qremove\", \"qdelete\", \"quoter\", \"quoted\", \"quoteremove\", \"quotedelete\":\n\t\t\tembed = helpcommands.QuoteRemove(embed)\n\t\tcase \"qs\", \"quotes\":\n\t\t\tembed = helpcommands.Quotes(embed)\n\t\tcase \"rcap\", \"rcaps\", \"rupper\", \"rlower\", \"randomcap\", \"randomcaps\", \"randomupper\", \"randomlower\":\n\t\t\tembed = helpcommands.RandomCaps(embed)\n\t\tcase \"rp\", \"rankp\", \"rankpenis\":\n\t\t\tembed = helpcommands.PenisRank(embed)\n\t\tcase \"rv\", \"rankv\", \"rankvagina\":\n\t\t\tembed = helpcommands.VaginaRank(embed)\n\t\tcase \"remind\", \"reminder\":\n\t\t\tembed = helpcommands.Remind(embed)\n\t\tcase \"reminders\":\n\t\t\tembed = helpcommands.Reminders(embed)\n\t\tcase \"remindremove\", \"rremove\":\n\t\t\tembed = helpcommands.RemindRemove(embed)\n\t\tcase \"rinfo\", \"roleinfo\":\n\t\t\tembed = helpcommands.RoleInfo(embed)\n\t\tcase \"roll\":\n\t\t\tembed = helpcommands.Roll(embed)\n\t\tcase \"sinfo\", \"serverinfo\":\n\t\t\tembed = helpcommands.ServerInfo(embed)\n\t\tcase \"skill\", \"skills\":\n\t\t\tembed = helpcommands.Skills(embed)\n\t\tcase \"src\", \"source\":\n\t\t\tembed = helpcommands.Source(embed)\n\t\tcase \"stats\", \"class\":\n\t\t\tembed = helpcommands.Stats(embed)\n\t\tcase \"swap\":\n\t\t\tembed = helpcommands.Swap(embed)\n\t\tcase \"task\":\n\t\t\tembed = helpcommands.Task(embed)\n\t\tcase \"tasks\":\n\t\t\tembed = helpcommands.Tasks(embed)\n\t\tcase \"taskremove\", \"tremove\":\n\t\t\tembed = helpcommands.TaskRemove(embed)\n\t\tcase \"title\":\n\t\t\tembed = helpcommands.Title(embed)\n\t\tcase \"triggers\":\n\t\t\tembed = helpcommands.Triggers(embed)\n\t\tcase \"twitch\", \"twitchdl\":\n\t\t\tembed = helpcommands.Twitch(embed)\n\t\tcase \"twitter\", \"twitterdl\":\n\t\t\tembed = helpcommands.Twitter(embed)\n\t\tcase \"tts\":\n\t\t\tembed = helpcommands.TTS(embed)\n\t\tcase \"u\", \"unlink\":\n\t\t\tembed = helpcommands.Unlink(embed)\n\t\tcase \"vagina\":\n\t\t\tembed = helpcommands.Vagina(embed)\n\t\tcase \"vibe\", \"vibec\", \"vibecheck\":\n\t\t\tembed = helpcommands.Vibe(embed)\n\t\tcase \"w\", \"weather\":\n\t\t\tembed = helpcommands.Weather(embed)\n\t\tcase \"wcount\", \"wordcount\", \"word\":\n\t\t\tembed = helpcommands.WordCount(embed)\n\n\t\t// Math commands\n\t\tcase \"ave\", \"average\", \"mean\":\n\t\t\tembed = helpcommands.Average(embed)\n\t\tcase \"d\", \"dist\", \"distance\", \"dir\", \"direction\":\n\t\t\tembed = helpcommands.DistanceDirection(embed)\n\t\tcase \"dr\", \"degrad\", \"degreesradians\":\n\t\t\tembed = helpcommands.DegreesRadians(embed)\n\t\tcase \"rd\", \"raddeg\", \"radiansdegrees\":\n\t\t\tembed = helpcommands.RadiansDegrees(embed)\n\t\tcase \"stddev\", \"standarddev\", \"stddeviation\", \"standarddeviation\":\n\t\t\tembed = helpcommands.StandardDeviation(embed)\n\t\tcase \"va\", \"vadd\", \"vectora\", \"vectoradd\":\n\t\t\tembed = helpcommands.VectorAdd(embed)\n\t\tcase \"vc\", \"vcross\", \"vectorc\", \"vectorcross\":\n\t\t\tembed = helpcommands.VectorCross(embed)\n\t\tcase \"vd\", \"vdiv\", \"vdivide\", \"vectord\", \"vectordiv\", \"vectordivide\":\n\t\t\tembed = helpcommands.VectorDivide(embed)\n\t\tcase \"vdot\", \"vectordot\":\n\t\t\tembed = helpcommands.VectorDot(embed)\n\t\tcase \"vm\", \"vmult\", \"vmultiply\", \"vectorm\", \"vectormult\", \"vectormultiply\":\n\t\t\tembed = helpcommands.VectorMultiply(embed)\n\t\tcase \"vs\", \"vsub\", \"vsubtract\", \"vectors\", \"vectorsub\", \"vectorsubtract\":\n\t\t\tembed = helpcommands.VectorSubtract(embed)\n\n\t\t// osu! commands\n\t\tcase \"bfarm\", \"bottomfarm\":\n\t\t\tembed = helpcommands.BottomFarm(embed)\n\t\tcase \"bpm\":\n\t\t\tembed = helpcommands.BPM(embed)\n\t\tcase \"c\", \"compare\":\n\t\t\tembed = helpcommands.Compare(embed)\n\t\tcase \"farm\":\n\t\t\tembed = helpcommands.Farm(embed)\n\t\tcase \"l\", \"leader\", \"leaderboard\":\n\t\t\tembed = helpcommands.Leaderboard(embed)\n\t\tcase \"link\", \"set\":\n\t\t\tembed = helpcommands.Link(embed)\n\t\tcase \"m\", \"map\":\n\t\t\tembed = helpcommands.Map(embed)\n\t\tcase \"osu\", \"profile\":\n\t\t\tembed = helpcommands.Profile(embed)\n\t\tcase \"osudetail\":\n\t\t\tembed = helpcommands.ProfileDetail(embed)\n\t\tcase \"osutop\":\n\t\t\tembed = helpcommands.ProfileTop(embed)\n\t\tcase \"ppadd\":\n\t\t\tembed = helpcommands.PPAdd(embed)\n\t\tcase \"r\", \"rs\", \"recent\":\n\t\t\tembed = helpcommands.Recent(embed)\n\t\tcase \"rb\", \"recentb\", \"recentbest\":\n\t\t\tembed = helpcommands.RecentBest(embed)\n\t\tcase \"s\", \"sc\", \"scorepost\":\n\t\t\tembed = helpcommands.ScorePost(embed)\n\t\tcase \"similar\":\n\t\t\tembed = helpcommands.Similar(embed)\n\t\tcase \"t\", \"top\":\n\t\t\tembed = helpcommands.Top(embed)\n\t\tcase \"tfarm\", \"topfarm\":\n\t\t\tembed = helpcommands.TopFarm(embed)\n\t\tcase \"ti\", \"tinfo\", \"tracking\", \"trackinfo\":\n\t\t\tembed = helpcommands.TrackInfo(embed)\n\n\t\t// Pokemon commands\n\t\tcase \"b\", \"berry\":\n\t\t\tembed = helpcommands.Berry(embed)\n\t\tcase \"pokemon\":\n\t\t\tembed = helpcommands.Pokemon(embed)\n\t\t}\n\n\t\t// Add image if specific command\n\t\tswitch rand.Intn(11) {\n\t\tcase 0:\n\t\t\tembed.Image = &discordgo.MessageEmbedImage{\n\t\t\t\tURL: \"https://cdn.discordapp.com/attachments/555493588465877012/555994312760885248/epicAnimeScene.gif\",\n\t\t\t}\n\t\tcase 1:\n\t\t\tembed.Image = &discordgo.MessageEmbedImage{\n\t\t\t\tURL: \"https://cdn.discordapp.com/attachments/555493588465877012/555996915884490752/epicAnimeGifTWO.gif\",\n\t\t\t}\n\t\tcase 2:\n\t\t\tembed.Image = &discordgo.MessageEmbedImage{\n\t\t\t\tURL: \"https://cdn.discordapp.com/attachments/555493588465877012/556000178406948875/epicAnimeGif5.gif\",\n\t\t\t}\n\t\tcase 3, 4:\n\t\t\tembed.Image = &discordgo.MessageEmbedImage{\n\t\t\t\tURL: \"https://cdn.discordapp.com/attachments/555493588465877012/555998627940532237/tumblr_phjkel3lgn1xlyyvto1_1280.png\",\n\t\t\t}\n\t\tcase 5, 6:\n\t\t\tembed.Image = &discordgo.MessageEmbedImage{\n\t\t\t\tURL: \"https://cdn.discordapp.com/attachments/555493588465877012/555998640142024704/tumblr_phjkel3lgn1xlyyvto2_1280.png\",\n\t\t\t}\n\t\tcase 7, 8:\n\t\t\tembed.Image = &discordgo.MessageEmbedImage{\n\t\t\t\tURL: \"https://cdn.discordapp.com/attachments/555493588465877012/555998669761937418/tumblr_phjkel3lgn1xlyyvto3_1280.png\",\n\t\t\t}\n\t\tcase 9, 10:\n\t\t\tembed.Image = &discordgo.MessageEmbedImage{\n\t\t\t\tURL: \"https://cdn.discordapp.com/attachments/555493588465877012/555998681375965194/tumblr_phjkel3lgn1xlyyvto5_1280.png\",\n\t\t\t}\n\t\t}\n\t}\n\n\tif !strings.HasPrefix(embed.Description, \"**Most\") && embed.Fields[0].Name == \"Admin commands:\" {\n\t\tembed.Fields = []*discordgo.MessageEmbedField{}\n\t}\n\n\ts.ChannelMessageSendComplex(m.ChannelID, &discordgo.MessageSend{\n\t\tContent: \"**This server's prefix: \" + prefix + \"**\\nAll commands in PM will use the bot's default prefix `$` instead!\\nFor any questions or concerns about this bot, please contact `@vinxis1` on twitter, or `VINXIS#1000` on discord.\",\n\t\tEmbed: embed,\n\t})\n}", "title": "" }, { "docid": "d5ab246c8724d381442d619b72da2613", "score": "0.75751966", "text": "func (c *Client) Help() (*string, error) {\n\treturn c.HelpAsync().Receive()\n}", "title": "" }, { "docid": "d175d4ac30792fe15caa4dc159934815", "score": "0.7571911", "text": "func (m *Mux) Help(ds *discordgo.Session, dm *discordgo.Message, ctx *Context) {\n\n\t// Set command prefix to display.\n\tcp := \"\"\n\tif ctx.IsPrivate {\n\t\tcp = \"\"\n\t} else if ctx.HasPrefix {\n\t\tcp = m.Prefix\n\t} else {\n\t\tcp = fmt.Sprintf(\"@%s \", ds.State.User.Username)\n\t}\n\n\t// Sort commands\n\tmaxlen := 0\n\tkeys := make([]string, 0, len(m.Routes))\n\tcmdmap := make(map[string]*Route)\n\n\tfor _, v := range m.Routes {\n\n\t\t// Only display commands with a description\n\t\tif v.Description == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Calculate the max length of command+args string\n\t\tl := len(v.Pattern) // TODO: Add the +args part :)\n\t\tif l > maxlen {\n\t\t\tmaxlen = l\n\t\t}\n\n\t\tcmdmap[v.Pattern] = v\n\n\t\t// help and about are added separately below.\n\t\tif v.Pattern == \"help\" || v.Pattern == \"about\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tkeys = append(keys, v.Pattern)\n\t}\n\n\tsort.Strings(keys)\n\n\t// TODO: Learn more link needs to be configurable\n\tresp := \"\"\n\n\tresp += \"```autoit\\n\"\n\n\tv, ok := cmdmap[\"help\"]\n\tif ok {\n\t\tkeys = append([]string{v.Pattern}, keys...)\n\t}\n\n\tv, ok = cmdmap[\"about\"]\n\tif ok {\n\t\tkeys = append([]string{v.Pattern}, keys...)\n\t}\n\n\t// Add sorted result to help msg\n\tfor _, k := range keys {\n\t\tv := cmdmap[k]\n\t\tresp += fmt.Sprintf(\"%s%-\"+strconv.Itoa(maxlen)+\"s # %s\\n\", cp, v.Pattern+v.Help, v.Description)\n\t}\n\n\tresp += \"```\\n\"\n\n\tlogo := \"https://raw.githubusercontent.com/csivitu/bl0b/master/assets/images/bl0b-ascii.png\"\n\n\tds.ChannelMessageSendComplex(dm.ChannelID, &discordgo.MessageSend{\n\t\tEmbed: &discordgo.MessageEmbed{\n\t\t\tImage: &discordgo.MessageEmbedImage{\n\t\t\t\tURL: logo,\n\t\t\t},\n\t\t},\n\t\tContent: resp,\n\t})\n\n\treturn\n}", "title": "" }, { "docid": "5da77179c03e4953289f5524e76c7f4c", "score": "0.75351447", "text": "func Help(session *discordgo.Session, msg *discordgo.MessageCreate) {\n\thelpMsg := `\n**Commands:**\n* @ImageBot minecraft [input_file] | Minecraft command takes [input_file] and reconstructs it using only Minecraft block textuers\n* @ImageBot collage [search keyword] [input_file] | Collage command takes [input_file] and reconstructs it using images found in Bing's image search for [search keyword]\n***note:*** [input_file] signifies that a file should be sent as an attachment\n`\n\n\tsession.ChannelMessageSend(msg.ChannelID, helpMsg)\n}", "title": "" }, { "docid": "4f98e44e6f49b849b7a5868c7a5578aa", "score": "0.75260556", "text": "func (c *AskCommand) Help() string {\n\treturn \"Usage: a-know ask\"\n}", "title": "" }, { "docid": "9f2610e6106b39e0b3fd4f979f6ed6ee", "score": "0.74650586", "text": "func (cmd *UptimeCommand) Help() {\n\tchannel, err := cmd.Channel(cmd.line)\n\tif err != nil {\n\t\tcmd.bot.LogError(\"UptimeCommand.Help()\", err)\n\t\treturn\n\t}\n\n\tcmd.bot.Msg(cmd.conn, channel, \"Show bot uptime\")\n}", "title": "" }, { "docid": "96dcfffe4e2f522fc1ef2363fd733d82", "score": "0.7448512", "text": "func (lobby *Lobby) Help(client *Client) {\n\tclient.outgoing <- \"\\n\"\n\tclient.outgoing <- \"Commands:\\n\"\n\tclient.outgoing <- \"help - lists all commands\\n\"\n\tclient.outgoing <- \"list - lists all chat rooms\\n\"\n\tclient.outgoing <- \"create {room name} - creates a chat room named {room name}\\n\"\n\tclient.outgoing <- \"join {room name} - joins a chat room named {room name}\\n\"\n\tclient.outgoing <- \"leave - leaves the current chat room\\n\"\n\tclient.outgoing <- \"name {your name} - changes your name to {your name} into chat room\\n\"\n\tclient.outgoing <- \"quit - quits the program\\n\"\n\tclient.outgoing <- \"\\n\"\n\tlog.Println(\"client requested help\")\n}", "title": "" }, { "docid": "7d1fa3ad119e94e4b853cc7d04f94677", "score": "0.7439891", "text": "func (b *Bot) helpHandler(msg Message) Reply {\n\tcmd := \"Please, use the follow commands:\\n\" +\n\t\t\"/help - show this text\\n\" +\n\t\t\"/reverse [text] - reverse any text\\n\" +\n\t\t\"/search [text] - search any text in some engine\\n\" +\n\t\t\"/roullete - play roullete\"\n\treturn Reply{\n\t\tChatId: msg.Chat.Id,\n\t\tText: cmd,\n\t}\n}", "title": "" }, { "docid": "e0e9021e35ee4491e2d8e4c71c300531", "score": "0.7377724", "text": "func (core *Plugin) help(c cmd.Context) (string, slack.PostMessageParameters) {\n\tparams := slack.PostMessageParameters{}\n\tres := \"\"\n\topt := c.Options[\"command\"].Value\n\tif opt == \"\" {\n\t\t// General help\n\t\tres = \"Usage: `@rocket COMMAND`\\n\\nGet help using a specific \" +\n\t\t\t\"command with `@rocket help command={COMMAND}`\\n\" +\n\t\t\t\"Example: `@rocket set name={A Guy} github={arealguy}`\"\n\n\t\t// Get length of longest command to to evenly space command names and\n\t\t// their descriptions\n\t\tlongestCmdLength := 0\n\t\tfor _, cmd := range core.Bot.Commands {\n\t\t\tif len(cmd.Name) > longestCmdLength {\n\t\t\t\tlongestCmdLength = len(cmd.Name)\n\t\t\t}\n\t\t}\n\n\t\t// Format help text\n\t\tcmds := \"```\\n\"\n\t\tfor _, cmd := range core.Bot.Commands {\n\t\t\tdividerSpace := \"\"\n\t\t\tfor i := 0; i < longestCmdLength-len(cmd.Name); i++ {\n\t\t\t\tdividerSpace += \" \"\n\t\t\t}\n\t\t\tcmds += fmt.Sprintf(\"%s%s %s\\n\", cmd.Name, dividerSpace, cmd.HelpText)\n\t\t}\n\t\tcmds += \"\\n```\"\n\t\tcommands := slack.Attachment{\n\t\t\tTitle: \"Commands\",\n\t\t\tText: cmds,\n\t\t\tColor: \"#e5e7ea\",\n\t\t}\n\t\tparams.Attachments = []slack.Attachment{commands}\n\t\treturn res, params\n\t}\n\t// Command-specific help\n\tfor _, cmd := range core.Bot.Commands {\n\t\tif opt == cmd.Name {\n\t\t\treturn cmd.Help()\n\t\t}\n\t}\n\tres = fmt.Sprintf(\"`%s` is not a Rocket command.\\n\"+\n\t\t\"See `@rocket help`\", opt)\n\treturn res, slack.PostMessageParameters{}\n}", "title": "" }, { "docid": "3549fa5cd8b663aa24d1476a9f5cee25", "score": "0.73327625", "text": "func (p *Prompt) ShowHelp() {\n\thelpMessage :=`\nAvailable commands:\n\tStudents:\n\t\tstudents\n\t\tstudents create\n\t\tstudents number 12345678\n\tTeachers:\n\t\tteachers\n\t\tteachers create\n\t\tteachers number 12345678\n`\n\tfmt.Println(helpMessage)\n}", "title": "" }, { "docid": "65b816bb2bb21db26364512cb45df66a", "score": "0.73200774", "text": "func (c *Command) Help(client Client) error {\n\tc.HelpFunc()(c, []string{}, client)\n\treturn nil\n}", "title": "" }, { "docid": "b660c643f07d07caf19672fc7de1cfee", "score": "0.7310154", "text": "func (p *BeersPlugin) help(c bot.Connector, kind bot.Kind, message msg.Message, args ...interface{}) bool {\n\tmsg := \"Beers: imbibe by using either beers +=,=,++ or with the !imbibe/drink \" +\n\t\t\"commands. I'll keep a count of how many beers you've had and then if you want \" +\n\t\t\"to reset, just !puke it all up!\"\n\tp.Bot.Send(c, bot.Message, message.Channel, msg)\n\treturn true\n}", "title": "" }, { "docid": "4c5ae761b5b9f22a628221660b5bfe95", "score": "0.7296258", "text": "func (command) Help() string {\n\treturn \"\"\n}", "title": "" }, { "docid": "78a9857562fb26658d52d827cc6bee91", "score": "0.72864443", "text": "func HelpCommand(sess *dg.Session, msg *dg.Message) {\n\tmessageStr := mentionUser(msg) + \", hi I'm the Sorting Hat!\"\n\tsendMessage(sess, msg.ChannelID, messageStr)\n\tmessageStr = \"My commands are: \" + strings.Join(commandsList, \", \")\n\tsendMessage(sess, msg.ChannelID, messageStr)\n}", "title": "" }, { "docid": "52d06fb947a87f1b69e497fb782b9d03", "score": "0.7266567", "text": "func (c *Command) Help(ib *irc.Connection, from string) {\n\tif !c.Started {\n\t\treturn\n\t}\n\tib.Privmsg(from, \"Translate things from one language to another.\")\n\tib.Privmsg(from, \"Example (english to french) : !translate flying saucer > fr\")\n\tib.Privmsg(from, \"Example (french to english) : !translate soucoupe volante > en\")\n}", "title": "" }, { "docid": "cf35e3227ea7191b6f7d3ab95bc28e8e", "score": "0.7248452", "text": "func (cmd *ArbitraryCmd) Help() string {\n\treturn \"hap c <command>\\tRun an arbitrary command on the remote host.\"\n}", "title": "" }, { "docid": "8b703321426a18f48e1e649f65efca57", "score": "0.7221373", "text": "func sendHelp(slackClient *slack.RTM, message, slackChannel string) {\n\tif strings.ToLower(message) != \"help\" {\n\t\treturn\n\t}\n\tslackClient.SendMessage(slackClient.NewOutgoingMessage(helpMessage, slackChannel))\n}", "title": "" }, { "docid": "e2d7a773fc7570196240813d05c94606", "score": "0.7217268", "text": "func (a activePlugin) Help() string {\n\treturn \"/giphy {string}\"\n}", "title": "" }, { "docid": "39d3e67ef1a8fa89937c12b8f461a1e4", "score": "0.7210773", "text": "func SendMoreHelp(action slackevents.MessageAction) {\n\tslackClient := server.RTM\n\n\tresponse :=\n\t\t\"*Here are a few useful commands:*\\nTo query feedback use: \\n - `find param_name=param` \\n - Example: `find Type=intensives Sender=steve` \\nTo delete feedback use: \\n - `delete ID` \\n - Example: `delete 28` \\nTo subscribe to weekly feedback use: \\n - `subscribe` \\nTo unsubscribe from weekly feedback use: \\n - `unsubscribe` \"\n\n\tslackClient.PostMessage(action.Channel.ID, slack.MsgOptionText(response, false))\n}", "title": "" }, { "docid": "95d2711d89c6cea7fc048dc6dc27b340", "score": "0.7205757", "text": "func (a activePlugin) Help() string {\n\treturn \"/reddit {subreddit}\"\n}", "title": "" }, { "docid": "179b174e267bb1db6c71fe8fc8f16535", "score": "0.71976966", "text": "func (s *server) help(c *client, args []string){\n\tc.msg(\"\\\"help\\\" - lists available commands \\n\")\n\tc.msg(\"\\\"name (string)\\\" - changes display name to (string) \\n\")\n\tc.msg(\"\\\"join (string)\\\" - joins room names (string), creates room named (string) if (string) doesn't exist yet \\n\")\n\tc.msg(\"\\\"rooms\\\" - lists available rooms \\n\")\n\tc.msg(\"\\\"msg (string)\\\" - broadcasts (string) as a message to everyone connected \\n\")\n\tc.msg(\"\\\"quit\\\" - disconnect from the server \\n\")\n\tc.msg(\"\\\"admin (string)\\\" - changes the user to an admin if (string) is the correct password \\n\")\n\tc.msg(\"\\\"motd (string)\\\" - changes the room's motd to (string), only usable by admins \\n\")\n}", "title": "" }, { "docid": "f83a2bc3a7573a23f3b27c40b0ab3982", "score": "0.71934456", "text": "func (s *Supervisor) Help(r Recoverable, err interface{}) {\n\ts.helpChan <- &cryForHelpMsg{r, err}\n}", "title": "" }, { "docid": "437ece7b7200751ff619a5b6b75a126b", "score": "0.71897304", "text": "func (a activePlugin) Help() string {\n\treturn \"/api {info|add {public key}|delete {public key}}\"\n}", "title": "" }, { "docid": "65dc2fe94fb7a08f57e5e3c96f4163f8", "score": "0.7151115", "text": "func (info *CliInfo) ShowHelp() {\n\tfmt.Println(`how to use:\n\tgobou\n\tgobou i user/plugin_name\n\tgobou i user/plugin_name other_name\n\tgobou install user/pname\n\tgobou install user/pname other_name\n\tgobou u user/plugin_name\n\tgobou u user/plugin_name other_name\n\tgobou update user/pname\n\tgobou update user/pname other_name\n\tgobou test\n\tgobou g relative_path\n\tgobou generate relative_path\n\tgobou config\n\tgobou config plugin_name`)\n}", "title": "" }, { "docid": "6c841ac10aa3db71c929a42a5ea7b09b", "score": "0.71026886", "text": "func Help(plugin Interface, resp *string) error {\n\thelp, err := plugin.Help()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*resp = help\n\treturn nil\n}", "title": "" }, { "docid": "0f0398f365b556343c8693c4883e6edc", "score": "0.70879817", "text": "func (c *command) Help() string {\n\tbuf := bytes.NewBuffer(nil)\n\tc.parser.WriteHelp(buf)\n\treturn fmt.Sprintf(`\n%s\n\n%s`, c.Description(), buf.String())\n}", "title": "" }, { "docid": "300f7ad395bef038fa0f21a888658fbe", "score": "0.7076922", "text": "func (a activePlugin) Help() string {\n\treturn \"/media {url}\"\n}", "title": "" }, { "docid": "adfbb6ed69454d212be4f2af03283d82", "score": "0.7069479", "text": "func (cmdr *Commander) Help(arg string, verbose bool) string {\n\treturn \"display a list of all commands\"\n}", "title": "" }, { "docid": "db6059f6f6f573c1bbd296a93b7576b5", "score": "0.7060726", "text": "func HelpCommand(s *discordgo.Session, m *discordgo.MessageCreate, sc *string, c map[string]string) {\n dm, err := s.UserChannelCreate(m.Author.ID)\n\n if err != nil {\n logrus.WithFields(logrus.Fields{\n \"err\": err,\n }).Error(\"Unable to create direct message channel\")\n }\n\n if sc != nil {\n if h, ok := c[*sc]; ok {\n util.SafeSendMessage(s, dm.ID, \"``\" + *sc + \" - \" + h + \"``\")\n } else {\n util.SafeSendMessage(s, dm.ID, \"``\" + *sc + \"`` is not a valid command. For a list of valid commands, use ``+help``.\")\n }\n } else {\n h := \"Available commands:\\n```\"\n\n for k, _ := range c {\n h += k + \"\\n\"\n }\n\n h += \"```For more detailed information, use +help <Command name>\"\n\n util.SafeSendMessage(s, dm.ID, h)\n }\n}", "title": "" }, { "docid": "71a3012eaf932c97d567b1bac8ccb174", "score": "0.705879", "text": "func helpMessageShort(b *bytes.Buffer, cmd string, command command) {\n\tb.Write([]byte(fmt.Sprintf(\" %-14s : \", cmd)))\n\tformatHelp(b, command.help, 4, 19, 78)\n}", "title": "" }, { "docid": "d2d722c732ef1adcdede80d9d40e5da7", "score": "0.7028006", "text": "func (c *UsageCommand) Help() string {\n\thelpText := `\nUsage: rewarder usage\n\tGenerate usage reward merkle files\n\nOptions:\n\t-c The path of config file.\n`\n\treturn strings.TrimSpace(helpText)\n}", "title": "" }, { "docid": "7122f31defe207401d4b95d637fdbb1f", "score": "0.7027864", "text": "func (c *VersionCommand) Help() string {\n\treturn \"\"\n}", "title": "" }, { "docid": "440e81170ce4cfecf6c8d7d54d6bbe1f", "score": "0.7027561", "text": "func (c *ShowCommand) Help() string {\n\thelpText := `\nUsage: sloppy show [OPTIONS] [PROJECT[/SERVICE[/APP]]]\n\n Outputs information for all projects or the given project, service or app\n\nOptions:\n\n -r, --raw Prints raw json data\n\nExamples:\n\n sloppy show\n sloppy show letschat\n sloppy show --raw letschat/frontend/nginx\n`\n\treturn strings.TrimSpace(helpText)\n}", "title": "" }, { "docid": "1fcc4661cc23951f5d5e7028f8c4461b", "score": "0.7024943", "text": "func (c *TotalCommand) Help() string {\n\thelpText := `\nUsage: spored serve [options] ...\n\n Spored Stat.\n\nOptions:\n\n -config=config.yml Configuration file to use.\n -env=development Environment.\n`\n\n\treturn strings.TrimSpace(helpText)\n}", "title": "" }, { "docid": "6b43602c16ed749079fba6ba424381f1", "score": "0.69960546", "text": "func ShowHelp(state *state.State, cmd DiscordCommand) error {\n\tif len(cmd.Args) == 1 {\n\t\ttopic := strings.ToLower(cmd.Args[0])\n\n\t\t// Show a more detailed help page if one if available\n\t\tswitch topic {\n\t\tcase \"config\":\n\t\t\treturn showConfigHelp(state, cmd)\n\t\tdefault:\n\t\t\t{\n\t\t\t\tembed := CreateEmbed(WarnColor, \"Unknown Help Topic\", fmt.Sprintf(\"There is no help page for `%s`. Use `!help` for commands.\", topic), \"\")\n\t\t\t\treturn SendCommandEmbed(state, cmd, embed)\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// Show the default help page\n\t\treturn showDefaultHelp(state, cmd)\n\t}\n\n}", "title": "" }, { "docid": "2eb429d8ce8d66b48699aeb64f7c16de", "score": "0.6984607", "text": "func (c *Help) Help() string {\n\thelpText := `Helps the program.\n\n`\n\treturn strings.TrimSpace(helpText)\n}", "title": "" }, { "docid": "1ee5b1e1c77a1dd833b9a2888bf41361", "score": "0.6983032", "text": "func (a *Application) Help(l l10n.LocaleInstance) (alexa.Response, error) {\n\treturn alexa.Response{\n\t\tTitle: l.GetAny(l10n.KeyHelpTitle),\n\t\tText: l.GetAny(l10n.KeyHelpText),\n\t\tSpeech: l.GetAny(l10n.KeyHelpSSML),\n\t\tEnd: false,\n\t}, nil\n}", "title": "" }, { "docid": "c20c110f57b2bdc51fe45fe82c5c37e1", "score": "0.697722", "text": "func (c *SendCommand) Help() string {\n\treturn `Usage: wallet send [options...]\nOptions:\n -file signed transaction file path\n`\n}", "title": "" }, { "docid": "3db7c2d0c78d8cb89d2cb92533b90c95", "score": "0.69615704", "text": "func (this *Command) help() string {\n\treturn this.Short\n}", "title": "" }, { "docid": "ac4c1d2852c64626cb966a8893308140", "score": "0.6940648", "text": "func Help() string {\n\tdata := \"\"\n\tfor k,v := range db.Cmd {\n\t\tdata = data + k + \": \" + \"\\\"\" + v + \"\\\"\" + \"\\n\"\n\t}\n\treturn data\n}", "title": "" }, { "docid": "83c5c1d3c1a5d1a8e51af98305639094", "score": "0.6930825", "text": "func (c *CmdUsers) Help() string {\n\ttxt := fmt.Sprintf(`\nUsage:\n %s %s domain\n\nDescription:\n %s\n\nRequired Args:\n domain\n The domain name.\n`,\n\t\tc.CmdName, c.SubCmdName,\n\t\tc.Synopsis())\n\n\treturn txt[1:]\n}", "title": "" }, { "docid": "00364d54aeb3aeb1e43f986895dec06c", "score": "0.69245344", "text": "func helpCmdHandler(update tg.Update) {\n\ttplBuf := bytes.Buffer{}\n\terr := tpl.ExecuteTemplate(&tplBuf, \"help.tmpl\", nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"Error executing template: %v\", err)\n\t}\n\n\treply := tg.NewMessage(update.Message.Chat.ID, tplBuf.String())\n\treply.ReplyMarkup = mainMenu\n\tbot.Send(reply)\n}", "title": "" }, { "docid": "03c0afdacc5f73bb16c5f0724e3a135a", "score": "0.6912896", "text": "func printHelp() {\n\tfmt.Println(\"help is coming\")\n}", "title": "" }, { "docid": "0607cb177c43de0b899ffb1caf5669a8", "score": "0.69076425", "text": "func (p *CommandPlugin) Help(bot *Bot, service Service, message Message, detailed bool) []string {\n\tif detailed {\n\t\treturn nil\n\t}\n\thelp := []string{}\n\tfor commandString, command := range p.commands {\n\t\tif command.help != nil {\n\t\t\targuments, h := command.help(bot, service, message)\n\t\t\thelp = append(help, CommandHelp(service, commandString, arguments, h)...)\n\t\t}\n\t}\n\treturn help\n}", "title": "" }, { "docid": "7fdad8ca5f3c077f5efcac7f4ae89eec", "score": "0.6901036", "text": "func (c _Command) HelpMessage() string {\n\tif len(c.doc) != 0 {\n\t\treturn c.doc\n\t}\n\n\tvar hm _HelpMessage\n\n\t// Description\n\tif len(c.desc) != 0 {\n\t\thm.Description(c.desc)\n\t}\n\n\t// Usages\n\tif strs := c.UsagesString(); len(strs) != 0 {\n\t\thm.Title(\"Usage\")\n\t\tfor _, str := range strs {\n\t\t\thm.Subtitle(str)\n\t\t}\n\t}\n\n\t// Options\n\tif opts := c.OptionsString(); len(opts) != 0 {\n\t\tstrs := sortStringMap(opts)\n\t\thm.Line().Title(\"Options\")\n\t\tfor _, str := range strs {\n\t\t\thm.Subtitle(str)\n\t\t}\n\t}\n\n\t// Commands\n\tif strs := c.CommandsString(\"\"); len(strs) != 0 {\n\t\thm.Line().Title(\"Commands\")\n\t\tfor _, str := range strs {\n\t\t\thm.Subtitle(str)\n\t\t}\n\t}\n\n\t// Annotation\n\tif c.annotation != nil {\n\t\tfor title, contents := range c.annotation {\n\t\t\thm.Line().Title(title)\n\t\t\tfor _, content := range contents {\n\t\t\t\thm.Subtitle(content)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn hm.String()\n}", "title": "" }, { "docid": "203c0d61933c9693149dad3ec9871c5d", "score": "0.6873194", "text": "func (c *SendCmd) Help() string {\n\thelpText := `\n\t\t\tUsage: go-email send [options] -f target.csv\n\t\t\tSending email to targets.\n\t`\n\treturn strings.TrimSpace(helpText)\n}", "title": "" }, { "docid": "3047bd52be301881b218018632091cde", "score": "0.6871042", "text": "func (*BufferInfoCommand) Help() string {\n\thelpText := `\nUsage: msw buffer info\n\n This command shows information about Buffer.com. You need a configuration\n file with Buffer credentials ('~/.msw/msw.yml').\n\n`\n\treturn strings.TrimSpace(helpText)\n}", "title": "" }, { "docid": "de5f6e2287e469dcdd57061ca3f53d2c", "score": "0.6855697", "text": "func printHelp() {\n\tfmt.Println(\"This is a help message\")\n}", "title": "" }, { "docid": "9221d0ddd105fedc689e0c3ac65b74ae", "score": "0.6850758", "text": "func (this *Get) Help() string {\n\treturn `Usage: Get key. Get the given key.`\n}", "title": "" }, { "docid": "fd2684cd79c9dc4883c12275a5f7a5d3", "score": "0.68443626", "text": "func (c *BalanceCommand) Help() string {\n\treturn `Usage: wallet monitor balance [options...]\nOptions:\n -num confirmation number\n`\n}", "title": "" }, { "docid": "2ade94140f31cfa08b24ad58f08781ca", "score": "0.68269134", "text": "func (cmd *WolframAlphaCommand) Help() {\n\tchannel, err := cmd.Channel(cmd.line)\n\tif err != nil {\n\t\tcmd.bot.LogError(\"WolframAlphaCommand.Help()\", err)\n\t\treturn\n\t}\n\n\tcmd.bot.Msg(cmd.conn, channel, wolframHelp)\n}", "title": "" }, { "docid": "92b373836dc433d4b9f11d7156772c89", "score": "0.6823113", "text": "func help() {\n\tfmt.Println(\"Available Commands:\")\n\tfmt.Println(\" - fizzbuzz | the drinking game\")\n\tfmt.Println(\" - gcd | find greatest common denominator\")\n\tfmt.Println(\" - add | add 1..100 that are multiples of 7 and 3\")\n\tfmt.Println(\" - clock | word clock\")\n\tfmt.Println(\" - help | list of commands\")\n\tfmt.Println(\" - quit | exit this application\")\n}", "title": "" }, { "docid": "55ad9ce7f68e06b90607fc53427d5706", "score": "0.6802611", "text": "func (c *SyncingCommand) Help() string {\n\treturn `Usage: wallet api syncing\n`\n}", "title": "" }, { "docid": "15c428b47eedfe0bc2641214d339974a", "score": "0.67968446", "text": "func (c *SignCommand) Help() string {\n\treturn signHelp\n}", "title": "" }, { "docid": "ac9296ccf87d5fe81ccc5878598bf769", "score": "0.67941946", "text": "func (c *Command) Help() string {\n\treturn \"No help found\"\n}", "title": "" }, { "docid": "6ac2f04bb72e81e26f9c3cd9b59337f2", "score": "0.67930174", "text": "func (flags *Flags) Help() string {\n\treturn \"\"\n}", "title": "" }, { "docid": "6ac2f04bb72e81e26f9c3cd9b59337f2", "score": "0.67930174", "text": "func (flags *Flags) Help() string {\n\treturn \"\"\n}", "title": "" }, { "docid": "04fd66fd5a3b2ac8a42575bab1b7f40e", "score": "0.67913777", "text": "func (cfg *Flags) Help() string {\n\treturn \"\"\n}", "title": "" }, { "docid": "d3e60828a16b870ee41274789693b0ca", "score": "0.6782526", "text": "func (h *HelpMessage) String() string {\n\tvar buf bytes.Buffer\n\tbuf.WriteString(\"help:\\n\")\n\th.Format(&buf)\n\treturn buf.String()\n}", "title": "" }, { "docid": "790b838a0bba8f1db3ee46fa37b3e9b6", "score": "0.67765677", "text": "func (c *CreateCommand) Help() string {\n\thelpText := `\nUsage: cmd db create\n Create database\n`\n\treturn strings.TrimSpace(helpText)\n}", "title": "" }, { "docid": "7d626b0682b20c2ab3c2af0f929c94c2", "score": "0.6774588", "text": "func (cli *Cli) Help() (string, error) {\n\ttmpl, err := template.New(\"cli\").Parse(`{{.Name}}: {{.Desc}}\n\n{{.Name}} [flags] {{range .Args}}{{.Name}} {{end}}\n\n{{with $len := len .Flags}}{{if gt $len 0}}Options:{{end}}{{end}}\n\n{{range .Flags}} {{if ne .Short \"\"}}-{{.Short}} {{.Name}}{{else}}-{{.Name}}{{end}}\t{{.Desc}}\n{{end}}\n{{with $len := len .Cmds}}{{if gt $len 0}}Commands:{{end}}{{end}}{{range .Cmds}} {{.Name}}{{end}}`)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"parsing help template: %w\", err)\n\t}\n\n\tvar r bytes.Buffer\n\n\terr = tmpl.Execute(&r, cli)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"executing help template: %w\", err)\n\t}\n\n\treturn r.String(), nil\n}", "title": "" }, { "docid": "27e97c5c1ce33849fda6524c543aba68", "score": "0.6760185", "text": "func (t *TargetCommand) Help() string {\n\treturn `Usage: copy-pasta target [<target>\n\n\tChanges the current target to the specified target.\n\tIf no argument is provided, it lists the current target.\n\t`\n}", "title": "" }, { "docid": "8cc850887dcc411cf76266b5b2eecae6", "score": "0.6756177", "text": "func (c *CreateTask) Help() string {\n\treturn \"Run as an agent (detailed help information here)\"\n}", "title": "" }, { "docid": "2dd486bd9fb09ef48e3ec4b274b0c23c", "score": "0.67543423", "text": "func help() {\n\tflags := \"\"\n\tflag.VisitAll(func(f *flag.Flag) {\n\t\tdoc := fmt.Sprintf(\" -%s=%s: %s\\n\", f.Name, f.DefValue, f.Usage)\n\t\tflags += doc\n\t})\n\tfmt.Fprintf(os.Stderr, usage, version, flags)\n}", "title": "" }, { "docid": "3abdbc0a688d0a50ebcf347930a67041", "score": "0.67429024", "text": "func (ScrapeHeartbeat) Help() string {\n\treturn \"Collect from heartbeat\"\n}", "title": "" }, { "docid": "c1314b13e85c39fd984d8351eba8cabb", "score": "0.67308044", "text": "func (c *Conn) HELP(params string) (code int, msg string) {\n\treturn 214, \"2.0.0 Hoy por ti, mañana por mi\"\n}", "title": "" }, { "docid": "1783c6ce6d0813bc239dcaaadae78f68", "score": "0.6719404", "text": "func (app *BuildApplication) Help() {\n\t// Print the usage on a new build application so that the right defaults\n\t// show up in the output.\n\tcommander.New().PrintUsage(NewBuildApplication(), \"makisu\")\n}", "title": "" }, { "docid": "4601eb7a5b2bed741123a7c5039a1421", "score": "0.6719062", "text": "func help(exit int) {\n\tfmt.Println(helpText)\n\tos.Exit(exit)\n}", "title": "" }, { "docid": "27dbbe5c920fba7d600835bdf604deab", "score": "0.67189646", "text": "func (c *Version) Help() string {\n\thelpText := `Displays version information.\n\n`\n\treturn strings.TrimSpace(helpText)\n}", "title": "" }, { "docid": "a5e6b3ec31afaec10740ed404609fcf5", "score": "0.6717129", "text": "func (c Debug) HandleHelp(ctx *multiplexer.Context) bool {\n\tvar sb strings.Builder\n\tsb.WriteString(fmt.Sprintf(\n\t\t\"`%s%s config`: Returns the contents of the JSON config file.\\n\",\n\t\tctx.Prefix, c.Command,\n\t))\n\tsb.WriteString(fmt.Sprintf(\n\t\t\"`%s%s args`: Returns the supplied arguments.\",\n\t\tctx.Prefix, c.Command,\n\t))\n\tctx.ChannelSend(sb.String())\n\treturn true\n}", "title": "" }, { "docid": "cbdff1f725a4e86f55c15fc91746794d", "score": "0.671574", "text": "func (e EventStruct) Help() string {\n\treturn helpMessage\n}", "title": "" }, { "docid": "62da246dca3866ba838253c38a7f2820", "score": "0.6712763", "text": "func (cmd *GithubCommand) Help() {\n\tchannel, err := cmd.Channel(cmd.line)\n\tif err != nil {\n\t\tcmd.bot.LogError(\"GithubCommand.Help()\", err)\n\t\treturn\n\t}\n\n\tcmd.bot.Msg(cmd.conn, channel, githubHelp)\n}", "title": "" }, { "docid": "4f7203359f53d0d71279ea26f034210e", "score": "0.67002237", "text": "func helpHandler(s *slacker.Slacker, channel string) func(slacker.Request, slacker.ResponseWriter) {\r\n\treturn func(request slacker.Request, response slacker.ResponseWriter) {\r\n\t\tdebug(\"In help handler: Channel:\" + request.Event().Channel)\r\n\t\t//ensure only running for specified channel\r\n\t\tif channel != \"\" && channel != request.Event().Channel {\r\n\t\t\treturn\r\n\t\t}\r\n\t\thelpMessage := empty\r\n\t\tfor _, command := range s.BotCommands() {\r\n\t\t\ttokens := command.Tokenize()\r\n\t\t\tfor _, token := range tokens {\r\n\t\t\t\tif token.IsParameter {\r\n\t\t\t\t\thelpMessage += fmt.Sprintf(\"`%s`\", token.Word) + space\r\n\t\t\t\t} else {\r\n\t\t\t\t\thelpMessage += fmt.Sprintf(\"`%s`\", token.Word) + space\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\thelpMessage += dash + space + fmt.Sprintf(\"_%s_\", command.Description()) + newLine\r\n\t\t}\r\n\t\tresponse.Reply(helpMessage)\r\n\t}\r\n}", "title": "" }, { "docid": "5da85e1479b9b2d281662a0e144585b9", "score": "0.6696463", "text": "func (ScrapeUser) Help() string {\n\treturn \"Collect data from mysql.user\"\n}", "title": "" }, { "docid": "02638aeddd0ef394a039a020bcebdd2e", "score": "0.6681587", "text": "func help() string {\n\treturn heredoc.Docf(`\n\t\tThe official Botkube plugin for the Helm CLI.\n\n\t\tUsage:\n\t\t helm [command]\n\n\t\tAvailable Commands:\n\t\t install # Installs a given chart to cluster where Botkube is installed.\n\t\t list # Lists all releases on cluster where Botkube is installed.\n\t\t rollback # Rolls back a given release to a previous revision.\n\t\t status # Displays the status of the named release.\n\t\t test # Runs tests for a given release.\n\t\t uninstall # Uninstalls a given release.\n\t\t upgrade # Upgrades a given release.\n\t\t version # Shows the version of the Helm CLI used by this Botkube plugin.\n\t\t history # Shows release history\n\t\t get # Shows extended information of a named release\n\n\t\tFlags:\n\t\t%s\n\n\t\tUse \"helm [command] --help\" for more information about the command.\n\t`, indent.String(renderSupportedFlags(GlobalFlags{}), 4))\n}", "title": "" }, { "docid": "d94b3b89bfb25d73fe0cb0307de863fc", "score": "0.66774404", "text": "func (c *ListUnspentCommand) Help() string {\n\treturn `Usage: wallet api listunspent [options...]\nOptions:\n -account account\n -num confirmation number\n`\n}", "title": "" }, { "docid": "f6cb3beea68ee9da17f96d8a2f58c467", "score": "0.6665719", "text": "func (c *Cli) Help(keywords ...string) string {\n\tvar sections []string\n\n\tfor _, keyword := range keywords {\n\t\tif description, ok := c.Documentation[keyword]; ok == false {\n\t\t\t//FIXME: see if there is a documented verb...\n\t\t\tif verb, ok := c.verbs[keyword]; ok == true {\n\t\t\t\tdescription := verb.Help(keywords[1:]...)\n\t\t\t\tsections = append(sections, fmt.Sprintf(\"%s\\n\", description))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tsections = append(sections, fmt.Sprintf(\"%q not documented\", keyword))\n\t\t\tcontinue\n\t\t} else {\n\t\t\tsections = append(sections, fmt.Sprintf(\"%s\\n\\n%s\", strings.ToUpper(keyword), description))\n\t\t}\n\t}\n\treturn strings.Join(sections, \"\\n\\n\")\n}", "title": "" }, { "docid": "a1f742c84c4d442c9cdcbba4afd73ea5", "score": "0.66503435", "text": "func (si *SousInit) Help() string { return sousInitHelp }", "title": "" }, { "docid": "a1f742c84c4d442c9cdcbba4afd73ea5", "score": "0.66503435", "text": "func (si *SousInit) Help() string { return sousInitHelp }", "title": "" }, { "docid": "36687e25acaca3183cb3f115b61d12fb", "score": "0.66399914", "text": "func (b *Bot) helpHandler() string {\n\tbuffer := bytes.NewBufferString(\"Please, use commands like the follow:\\n\")\n\tbuffer.WriteString(fmt.Sprintf(\">%s events of Metallica - list events of Metallica\\n\", b.id))\n\tbuffer.WriteString(fmt.Sprintf(\">%s events in Paris - list events in Paris\\n\", b.id))\n\tbuffer.WriteString(fmt.Sprintf(\">%s events in London at 27 May 2017 - list events in city at the date (date format may be also dd.MM.yyyy or dd/MM/yyyy)\\n\", b.id))\n\tbuffer.WriteString(fmt.Sprintf(\">%s events of System of a Down in Dresden since 1 Jan 2017 - list events of band in city since the date\\n\", b.id))\n\tbuffer.WriteString(fmt.Sprintf(\">%s events in Helsinki till 1 Jan 2017 - list events in city till the date\\n\", b.id))\n\tbuffer.WriteString(fmt.Sprintf(\">%s events in St Petersburg since 15 Dec 2016 till 1 Jan 2017 - list events in city since/till dates\\n\", b.id))\n\tbuffer.WriteString(fmt.Sprintf(\">%s events of Aerosmith for 15 Dec 2016 and 13 Jan 2017 - list events of band for period\\n\", b.id))\n\treturn buffer.String()\n}", "title": "" }, { "docid": "4f8990379e44e392407beee1494b7bcd", "score": "0.66312045", "text": "func (c *ReleaseCommand) Help() string {\n\thelpText := `\nUsage: tfupdate release <subcommand> [options] [args]\n\n This command has subcommands for release version information.\n`\n\treturn strings.TrimSpace(helpText)\n}", "title": "" }, { "docid": "cc43bf0a66e54928bde7398068992847", "score": "0.6627983", "text": "func prtHelp() {\n\tfmt.Printf(\"\\n----- 'sendmsg' Help -----\\n\")\n\tfmt.Printf(\"01 Use 'sendmsg' to send a text message to a 10 digit phone number\\n\")\n\tfmt.Printf(\"02 Command format: ' sendmsg <phone number> <text message body> <pic url>'\\n\")\n\tfmt.Printf(\"03 Send a text to a phone number: ' sendmsg \\\"4158675309\\\" \\\"Meet you at 10\\\" '\\n\")\n\tfmt.Printf(\"04 Send a text message to your phone: ' sendmsg \\\"Meet you at 10\\\" '\\n\")\n\tfmt.Printf(\"05 Send a pic and text message to your phone: ' sendmsg \\\"Meet you at 10\\\" \\\"http://mydomain.com/mypic.jpg\\\"'\\n\")\n\tfmt.Printf(\"06 NOTE: If your parameters include embedded spaces, remember to enclose those parameters in quotes\\n\")\n\tfmt.Printf(\"----- 'sendmsg' Help -----\\n\\n\")\n}", "title": "" }, { "docid": "bfc18543724839bb0a74874a3bf14715", "score": "0.66256267", "text": "func (c *StakingV2Command) Help() string {\n\thelpText := `\nUsage: rewarder staking v2\n\tGenerate staking v2 reward merkle files\n\nOptions:\n\t-c The path of config file.\n`\n\treturn strings.TrimSpace(helpText)\n}", "title": "" }, { "docid": "a225d1dc73fccf5bce986733bca78330", "score": "0.662458", "text": "func SendHelp(slackChannel string) {\n\tslackClient := server.RTM\n\n\tattachment := utils.GenerateHelpButtons()\n\tresponse := \"*What can I help you with?*\"\n\tslackClient.PostMessage(slackChannel, slack.MsgOptionText(response, false), slack.MsgOptionAttachments(attachment))\n}", "title": "" }, { "docid": "eebd47b091fa604bbc243d817eed81fd", "score": "0.662117", "text": "func (ps *PSet) Help(message ...string) {\n\tps.helper.Help(ps, message...)\n}", "title": "" }, { "docid": "42b6da380de963e9a94feb7a5dbe050a", "score": "0.6595794", "text": "func (c *CreateCommand) Help() string {\n\thelpText := `supermodel create\n\tThe create command searchs in the\n\tcurrent directory for a file with \n\tthe .smdl extension, builds namespaces \n\tand pulls repositories into context.\n`\n\treturn strings.TrimSpace(helpText)\n}", "title": "" }, { "docid": "a1d3f7cb8fc34297f66b353d57417d06", "score": "0.6590884", "text": "func (c *botCommand) Usage() string {\n\treturn c.usage\n}", "title": "" }, { "docid": "431defc27db94c92131946fd54498751", "score": "0.6586308", "text": "func (m *Metric) Help() string {\n\treturn m.help\n}", "title": "" }, { "docid": "fc8011597710d54a9e0583d08a3977fd", "score": "0.6579744", "text": "func ShowHelp(args []string) {\n\thelpString := fragmentaDivider\n\thelpString += fmt.Sprintf(\"Fragmenta version: %s\", fragmentaVersion)\n\thelpString += \"\\n fragmenta version -> display version\"\n\thelpString += \"\\n fragmenta help -> display help\"\n\thelpString += \"\\n fragmenta new [app|cms|URL] path/to/app -> creates a new app from the repository at URL at the path supplied\"\n\thelpString += \"\\n fragmenta -> builds and runs a fragmenta app\"\n\thelpString += \"\\n fragmenta server -> builds and runs a fragmenta app\"\n\thelpString += \"\\n fragmenta test -> run tests\"\n\thelpString += \"\\n fragmenta migrate -> runs new sql migrations in db/migrate\"\n\thelpString += \"\\n fragmenta backup [development|production|test] -> backup the database to db/backup\"\n\thelpString += \"\\n fragmenta restore [development|production|test] -> backup the database from latest file in db/backup\"\n\thelpString += \"\\n fragmenta deploy [development|production|test] -> build and deploy using bin/deploy\"\n\thelpString += \"\\n fragmenta generate resource [name] [fieldname]:[fieldtype]* -> creates resource CRUD actions and views\"\n\thelpString += \"\\n fragmenta generate migration [name] -> creates a new named sql migration in db/migrate\"\n\n\thelpString += fragmentaDivider\n\tlog.Print(helpString)\n}", "title": "" }, { "docid": "1c6a740c7917b1414747df0717a95063", "score": "0.6567807", "text": "func (e *Engine) Help() []byte {\n\tvar b bytes.Buffer\n\n\tb.Write([]byte(htmlHeader))\n\n\tb.Write([]byte(`<h1>hashsrv</h1>`))\n\tb.Write([]byte(`hashsrv is a web service that performs hashing, encryption, encoding, and compression. Available functions include:`))\n\n\ttpl.ExecuteTemplate(&b, \"Funcs\", e.funcMap)\n\n\ttpl.ExecuteTemplate(&b, \"Vars\", e.values)\n\n\tb.Write([]byte(htmlFooter))\n\n\treturn b.Bytes()\n}", "title": "" }, { "docid": "87ba0835eb7cd97cfe02646e100f3ea7", "score": "0.6562009", "text": "func postHelp(ev *slack.MessageEvent, kind int) error {\n\tvar message string\n\tswitch {\n\tcase kind == baseHelp:\n\t\tmessage = `type _tag: [keyword]_ to see component, playbooks, appropriate channels, and the anchor associated with this tag\n\ntype _anchor: [component]_ to see the anchor and channel in charge of a product\n\ntype _help_ in this channel to see this message again at any time\n\ntype _help tags_ for further information about adding tags\n\ntype _help set_ for further information about changing components channels metadata\n\ntype _help drop_ for further information about dropping tags`\n\n\tcase kind == tagsHelp:\n\t\tmessage = `To add tags to the bot, use the following syntax:\n\n_@[bot] tag [#component-channel] [tag1], [tag2], ..._\n`\n\n\tcase kind == addHelp:\n\t\tmessage = `Adding other items to the database is still in development. Check back later`\n\n\tcase kind == dropHelp:\n\t\tmessage = `Drop a tag from the database using the following syntax:\n\t\t\n_@[bot] drop [tag1], [tag2], ..._\n\n*Warning: This drop ALL tag associations with all component channels. Use with care*`\n\n\tcase kind == setHelp:\n\t\tmessage = `To set make adjustments for a component, use the following syntax:\n*Change Anchor:*\n_@[bot] set [#component-channel] anchor @[anchor]_\n\n*Change playbook URL:*\n_@[bot] set [#component-channl] playbook [url]_`\n\n\t}\n\n\tr := response{message, ev.User, ev.Channel, true, false, \"\"}\n\terr := slackPrint(r)\n\tif err != nil {\n\t\tlog.Error(\"error printing to Slack\")\n\t}\n\treturn err\n}", "title": "" }, { "docid": "df3cff23d0b997c6350c86ebd259cdae", "score": "0.6560635", "text": "func help(node *noise.Node) {\n\tlog.Printf(\"Your ID is %s(%s). Type '/discover' to attempt to discover new \"+\n\t\t\"peers, or '/peers' to list out all peers you are connected to.\\n\",\n\t\tnode.ID().Address,\n\t\tnode.ID().ID.String()[:printedLength],\n\t)\n}", "title": "" } ]
d62770792b03b47e797255fe8a382bb9
If broker resolution return nil, it is treated as an error and a retry is scheduled.
[ { "docid": "b3031bed58fb596f78449fa28cb1254d", "score": "0.50378513", "text": "func (s *MapperSuite) TestNilResolved(c *C) {\n\tclock.Freeze(testEpoch)\n\n\tr := &mockResolver{\n\t\tw2b: map[Worker]*sarama.Broker{\n\t\t\ts.workers[0]: nil,\n\t\t},\n\t}\n\ts.cfg.Consumer.RetryBackoff = 500 * clock.Millisecond\n\tm := Spawn(s.ns, s.cfg, r)\n\n\tm.OnWorkerSpawned(s.workers[0])\n\tc.Assert(clock.Wait4Scheduled(1, 3*clock.Second), Equals, true)\n\tclock.Advance(499 * clock.Millisecond)\n\tassertNoAssignments(c, s.workers[0], 0)\n\n\t// When\n\tr.w2b = map[Worker]*sarama.Broker{\n\t\ts.workers[0]: s.brokers[3],\n\t}\n\tclock.Advance(1 * clock.Millisecond)\n\n\t// Then\n\tassigned := <-s.workers[0].assignmentsCh\n\tc.Assert(assigned.BrokerConn(), Equals, s.brokers[3])\n\n\t// Cleanup\n\tm.OnWorkerStopped(s.workers[0])\n\tm.Stop()\n\tassertNoAssignments(c, s.workers[0], 0)\n}", "title": "" } ]
[ { "docid": "cd47e8cb4293db1fb5011421124d169d", "score": "0.55035406", "text": "func reliableConnectionBuilder(mqConnStr string) *amqp.Connection {\n\tfor {\n\t\tconn := buildConnection(mqConnStr)\n\n\t\tif conn == nil {\n\t\t\tlog.Println(\"Write daemon cannot connect to target queue. Retrying in 5 seconds\t....\")\n\t\t\ttime.Sleep(5 * time.Second)\n\t\t} else {\n\t\t\treturn conn\n\t\t}\n\t}\n}", "title": "" }, { "docid": "d69fa36585080e1207b590df626ea46a", "score": "0.5448639", "text": "func (oq *destinationQueue) retry() {\n\t// TODO: We don't send all events in the case where the server has been blacklisted as we\n\t// drop events instead then. This means we will send the oldest N events (chan size, currently 128)\n\t// and then skip ahead a lot which feels non-ideal but equally we can't persist thousands of events\n\t// in-memory to maybe-send it one day. Ideally we would just shove these pending events in a database\n\t// so we can send a lot of events.\n\t//\n\t// Interrupt the backoff. If the federation request that happens as a result of this is successful\n\t// then the counters will be reset there and the backoff will cancel. If the federation request\n\t// fails then we will retry at the current backoff interval, so as to prevent us from spamming\n\t// homeservers which are behaving badly.\n\t// We need to use an atomic bool here to prevent multiple calls to retry() blocking on the channel\n\t// as it is unbuffered.\n\tif oq.backingOff.CAS(true, false) {\n\t\toq.retryServerCh <- true\n\t}\n\tif !oq.running.Load() {\n\t\tlog.Infof(\"Restarting queue for %s\", oq.destination)\n\t\tgo oq.backgroundSend()\n\t}\n}", "title": "" }, { "docid": "6eb584c751d8f031676d63adfdaf6a59", "score": "0.5439671", "text": "func (c *SimpleConsumer) getLeaderBroker() error {\n\tvar (\n\t\terr error\n\t\tleaderID int32\n\t)\n\n\tleaderID, err = c.brokers.findLeader(c.config.ClientID, c.topic, c.partitionID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tglog.V(5).Infof(\"leader ID of [%s][%d] is %d\", c.topic, c.partitionID, leaderID)\n\tif leaderID == -1 {\n\t\treturn invalidLeaderIDError\n\t}\n\n\tvar retry = 3\n\tfor i := 0; i < retry; i++ {\n\t\tc.leaderBroker, err = c.brokers.NewBroker(leaderID)\n\t\tif err != nil {\n\t\t\t// TODO refresh metadata?\n\t\t\tglog.Errorf(\"could not create broker %d. maybe should refresh metadata.\", leaderID)\n\t\t} else {\n\t\t\tglog.V(5).Infof(\"got leader broker %s with id %d\", c.leaderBroker.address, leaderID)\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn err\n}", "title": "" }, { "docid": "c2998574118aab321f3da05e0aec2a8f", "score": "0.5308586", "text": "func (driver *BcsExecutorDriver) reconnect(from *upid.UPID, pbMsg proto.Message) {\n\tfmt.Fprintln(os.Stderr, \"Reconnect backoff strategy is Not Implemented!\")\n}", "title": "" }, { "docid": "d1e51c9f9c9d3bc0fff956bf6077262f", "score": "0.52693444", "text": "func (ctl *relayCtl) retry(f func() error) error {\n\tif err := ctl.connect(); err != nil {\n\t\treturn errgo.Mask(err, errgo.Is(hydroworker.ErrNoRelayController))\n\t}\n\terr := f()\n\tif err == nil {\n\t\treturn nil\n\t}\n\tlog.Printf(\"relay controller: retrying after error: %v\", err)\n\t// Retry, assuming the problem is because the\n\t// TCP connection has broken.\n\tctl.conn.Close()\n\tctl.conn = nil\n\tif err := ctl.connect(); err != nil {\n\t\treturn errgo.Notef(err, \"(on retry)\")\n\t}\n\tif err := f(); err != nil {\n\t\treturn errgo.Mask(err, errgo.Any)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c81d84db5646db2e24813b0217f2af20", "score": "0.51854724", "text": "func shouldRetryfindingCoordinator(resp *FindCoordinatorResponse, err error) bool {\n\tbrokerSetupIncomplete := err != nil &&\n\t\tstrings.Contains(\n\t\t\tstrings.ToLower(err.Error()),\n\t\t\tstrings.ToLower(\"unexpected EOF\"))\n\tcoordinatorNotFound := resp != nil &&\n\t\tresp.Error != nil &&\n\t\terrors.Is(resp.Error, GroupCoordinatorNotAvailable)\n\treturn brokerSetupIncomplete || coordinatorNotFound\n}", "title": "" }, { "docid": "16b91ce16928096ca13e9d5326e78334", "score": "0.5184411", "text": "func (rp *resolverPool) Query(ctx context.Context, msg *dns.Msg, priority int, retry Retry) (*dns.Msg, error) {\n\tif rp.baseline != nil && rp.numUsableResolvers() == 0 {\n\t\treturn rp.baseline.Query(ctx, msg, priority, retry)\n\t}\n\n\tagain := true\n\tvar times int\n\tvar err error\n\tvar r Resolver\n\tvar resp *dns.Msg\n\tfor again {\n\t\terr = checkContext(ctx)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\n\t\tr = rp.nextResolver(ctx)\n\t\tif r == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tresp, err = r.Query(ctx, msg, priority, nil)\n\n\t\tvar timeout bool\n\t\t// Check if the response is considered a resolver failure to be tracked\n\t\tif err != nil {\n\t\t\tif e, ok := err.(*ResolveError); ok && (e.Rcode == TimeoutRcode ||\n\t\t\t\te.Rcode == dns.RcodeServerFailure || e.Rcode == dns.RcodeRefused) {\n\t\t\t\ttimeout = true\n\t\t\t}\n\t\t}\n\n\t\tk := r.String()\n\t\t// Pause use of the resolver if queries have failed too often\n\t\tif rp.avgs.updateTimeouts(k, timeout) && timeout {\n\t\t\trp.updateWait(k, rp.delay)\n\t\t}\n\n\t\tif err == nil {\n\t\t\tbreak\n\t\t}\n\t\t// Timeouts and resolver errors can cause retries without executing the callback\n\t\tif err != nil {\n\t\t\tif e, ok := err.(*ResolveError); ok && (e.Rcode == TimeoutRcode || e.Rcode == ResolverErrRcode) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tif retry != nil {\n\t\t\ttimes++\n\t\t\tagain = retry(times, priority, resp)\n\t\t}\n\t}\n\n\tif rp.baseline != nil && err == nil && len(resp.Answer) > 0 {\n\t\t// Validate findings from an untrusted resolver\n\t\tresp, err = rp.baseline.Query(ctx, msg, priority, retry)\n\t\t// False positives result in stopping the untrusted resolver\n\t\tif err == nil && resp != nil && len(resp.Answer) == 0 {\n\t\t\tr.Stop()\n\t\t}\n\t}\n\n\treturn resp, err\n}", "title": "" }, { "docid": "8f29ee1144c3308fb1d719894481d7ca", "score": "0.5159282", "text": "func Lookup() Broker {\n\tif instance != nil {\n\t\treturn instance\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "0b168f76458c4515cd7358180543bc82", "score": "0.5151383", "text": "func ScheduleProcess(\r\n comm communication.Communication,\r\n s *ShortJobScheduler,\r\n client kubernetes.Interface,\r\n podLister corelisters.PodLister,\r\n msgs <-chan amqp.Delivery,\r\n closed chan<- bool,\r\n receiveQueue string,\r\n backoffQueue string,\r\n hostname string,\r\n maxBackOff int,){\r\n\r\n // Loop through all the messages in the queue\r\n for d := range msgs {\r\n\r\n // Record time of processing\r\n timestamp := time.Now()\r\n\r\n // Convert json message to schedule request object\r\n var req communication.ScheduleRequest\r\n\r\n if err := json.Unmarshal(d.Body, &req); err != nil {\r\n panic(err)\r\n }\r\n\r\n // Extract the pod name and namespace from the request\r\n key := string(req.Key);\r\n\r\n // Convert the namespace/name string into a distinct namespace and name\r\n namespace, name, err := cache.SplitMetaNamespaceKey(key)\r\n if err != nil {\r\n log.Errorf(\"%s\", err)\r\n }\r\n\r\n obj, err := client.CoreV1().Pods(namespace).Get(context.TODO(), name, metav1.GetOptions{})\r\n\r\n\r\n // Check if pod still exist in the kube-api server if not ignore it\r\n if err == nil && obj != nil{\r\n\r\n log.Infof(\"Scheduling %s\",obj.Name)\r\n\r\n // Start scheduling the pod\r\n result, err := s.Schedule(obj)\r\n\r\n if err != nil {\r\n\r\n // Print the error in the event the scheduler is unable to schedule the pod\r\n log.Errorf(\"%s\", err)\r\n\r\n // Check scheduling request last back off time and check if it exceeds the maximum backoff time\r\n if (req.NextBackOffTime >= maxBackOff){\r\n\r\n go AddPodEvent(client,obj,fmt.Sprintf(\"Scheduler will not retry scheduling; Reason: %s\",err.Error()),\"Fatal\")\r\n\r\n obj.Status.Phase = PodBackoffExceeded\r\n\r\n go AddPodStatus(client,obj,metav1.UpdateOptions{})\r\n\r\n }else{\r\n\r\n // If backoff time not exceeded, multiply the last backoff time by 2 and send it to backoff queue\r\n req.NextBackOffTime = req.NextBackOffTime*2\r\n req.Message = err.Error()\r\n\r\n respBytes, err := json.Marshal(communication.RetryRequest{req,receiveQueue})\r\n if err != nil {\r\n log.Fatalf(\"%s\", err)\r\n }\r\n\r\n go AddPodEvent(client,obj,fmt.Sprintf(\"Scheduler will retry in %d seconds; Reason: %s\",req.NextBackOffTime,req.Message),\"Warning\")\r\n\r\n // Attempt to send message to retry service\r\n go SendToQueue(comm,respBytes,backoffQueue)\r\n }\r\n\r\n d.Ack(true)\r\n\r\n }else if len(result) != 0{\r\n\r\n log.Infof(\"Scheduling Pod %s to %s\", name, result)\r\n bind(client,*obj,result,req.ProcessedTime,timestamp)\r\n //Use for experiment only\r\n //go SendExperimentPayload(comm,obj,timestamp,time.Now(),\"epsilon.experiment\",result,hostname)\r\n d.Ack(true)\r\n\r\n }else{\r\n d.Nack(true, true)\r\n }\r\n }else{\r\n d.Ack(true)\r\n }\r\n }\r\n\r\n closed <- true\r\n\r\n}", "title": "" }, { "docid": "6bb10018c2ed51cf91fefd3535480d7a", "score": "0.5138543", "text": "func (this *EurekaCommunicator) tryFailover() {\n\tthis.lock.Lock()\n\tthis.CurrentZoneFailureCount ++\n\n\tif this.CurrentZoneFailureCount > 3 {\n\t\tthis.doFailover()\n\t\tthis.CurrentZoneFailureCount = 0;\n\t}\n\tthis.lock.Unlock()\n}", "title": "" }, { "docid": "ac9cec391d9a35029c7f8d3cd3a74afc", "score": "0.5117806", "text": "func RetryNone(_ int) bool { return false }", "title": "" }, { "docid": "658497fde339078cc317a865edec1481", "score": "0.5090497", "text": "func (target *MQTTTarget) retry() {\n\ttarget.reconn = true\n\tevents := target.store.ListAll()\n\tfor len(events) != 0 {\n\t\tfor _, key := range events {\n\t\t\tevent, eErr := target.store.Get(key)\n\t\t\tif eErr != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor !target.client.IsConnectionOpen() {\n\t\t\t\ttime.Sleep(retryInterval * time.Second)\n\t\t\t}\n\t\t\t// The connection is open.\n\t\t\tif err := target.send(event); err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Delete after a successful publish.\n\t\t\ttarget.store.Del(key)\n\t\t}\n\t\tevents = target.store.ListAll()\n\t}\n\t// Release the reconn state.\n\ttarget.reconn = false\n}", "title": "" }, { "docid": "6289ac96939e170bcc65b123b00f4b09", "score": "0.5083272", "text": "func TestRunningReapUnknownRetry(t *testing.T) {\n\t// Job Chain:\n\t// 1 - 2 - 3\n\t// \\_ 4\n\t// Testing when job 2 fails (+ sequence is retryable)\n\n\treqId := \"test_running_reap_fail_retry\"\n\tfactory := defaultFactory(reqId)\n\tjc := &proto.JobChain{\n\t\tRequestId: reqId,\n\t\tJobs: testutil.InitJobsWithSequenceRetry(4, 1),\n\t\tAdjacencyList: map[string][]string{\n\t\t\t\"job1\": {\"job2\", \"job4\"},\n\t\t\t\"job2\": {\"job3\"},\n\t\t},\n\t\tFinishedJobs: 2,\n\t}\n\tc := chain.NewChain(jc, make(map[string]uint), make(map[string]uint), make(map[string]uint))\n\tfactory.Chain = c\n\n\t// Normally runJobChan is unbuffered. Here we use a buffer so Reap\n\t// doesn't block on sending to the chan.\n\trunJobChan := make(chan proto.Job, 5)\n\tfactory.RunJobChan = runJobChan\n\treaper := factory.MakeRunning()\n\n\tc.IncrementSequenceTries(\"job1\", 1)\n\tc.IncrementJobTries(\"job1\", 1)\n\tc.IncrementJobTries(\"job4\", 1)\n\tc.SetJobState(\"job1\", proto.STATE_COMPLETE)\n\tc.SetJobState(\"job4\", proto.STATE_COMPLETE)\n\tc.SetJobState(\"job2\", proto.STATE_RUNNING)\n\n\t// Job 2 has just failed.\n\tjob := proto.Job{\n\t\tId: \"job2\",\n\t\tState: proto.STATE_UNKNOWN,\n\t\tData: map[string]interface{}{\n\t\t\t\"key1\": \"val1\",\n\t\t},\n\t\tSequenceId: \"job1\",\n\t}\n\treaper.(*chain.RunningChainReaper).Reap(job)\n\n\t// job1 should be (re)sent to runJobChan\n\tselect {\n\tcase gotJob := <-runJobChan:\n\t\tif gotJob.Id != \"job1\" {\n\t\t\tt.Errorf(\"got job %s from runJobChan, expected job %s\", gotJob.Id, \"job1\")\n\t\t}\n\tdefault:\n\t\tt.Errorf(\"no job sent to runJobChan - expected to get job1\")\n\t}\n\n\t// no other jobs should be sent to runJobChan\n\tselect {\n\tcase <-runJobChan:\n\t\tt.Errorf(\"more than one job sent to runJobChan - expected only job1\")\n\tdefault:\n\t}\n\n\t// all job states should have been set back to PENDING\n\tfor id := range jc.Jobs {\n\t\tgotState := c.JobState(id)\n\t\tif gotState != proto.STATE_PENDING {\n\t\t\tt.Errorf(\"%s state in chain = %d, expected state = %d\", id, gotState, proto.STATE_PENDING)\n\t\t}\n\t}\n\n\t// Sequence try count is _not_ incremented yet. That happens in traverser.runJobs\n\t// when the sequence start job is ran, which is the true indicator that a sequence\n\t// has been tried. Between reaper doing sequece retry prep and then, the chain\n\t// could be stopped, etc. and the seq never actually retried.\n\ttryCount := c.SequenceTries(job.Id)\n\tif tryCount != 1 {\n\t\tt.Errorf(\"got sequence try count %d, expected 1\", tryCount)\n\t}\n}", "title": "" }, { "docid": "bb5de81979ca02472431c0b91f218639", "score": "0.5009538", "text": "func ensureBrokerMetrics(bm mapper.BrokerMap, bmm mapper.BrokerMetaMap) []error {\n\terrs := []error{}\n\tfor id, b := range bm {\n\t\t// Missing brokers won't be found in the brokerMeta.\n\t\tif !b.Missing && id != mapper.StubBrokerID && bmm[id].MetricsIncomplete {\n\t\t\terrs = append(errs, fmt.Errorf(\"Metrics not found for broker %d\\n\", id))\n\t\t}\n\t}\n\treturn errs\n}", "title": "" }, { "docid": "ba57257b0c4680497061dcfb4faca265", "score": "0.4991514", "text": "func restartBroker(k8Client internal.K8Client, nodeId int, partitionId int, role string, gracePeriod *int64) string {\n\tport := 26500\n\tcloseFn := k8Client.MustGatewayPortForward(port, port)\n\tdefer closeFn()\n\n\tzbClient, err := internal.CreateZeebeClient(port)\n\tensureNoError(err)\n\tdefer zbClient.Close()\n\n\tbrokerPod := getBrokerPod(k8Client, zbClient, nodeId, partitionId, role)\n\terr = k8Client.RestartPodWithGracePeriod(brokerPod.Name, gracePeriod)\n\tensureNoError(err)\n\n\treturn brokerPod.Name\n}", "title": "" }, { "docid": "675d22febf6625a362d654e8ce7e9435", "score": "0.4954464", "text": "func TestPollServiceInstanceFailureOnFinalRetry(t *testing.T) {\n\tfakeKubeClient, fakeCatalogClient, fakeClusterServiceBrokerClient, testController, sharedInformers := newTestController(t, fakeosb.FakeClientConfiguration{\n\t\tPollLastOperationReaction: &fakeosb.PollLastOperationReaction{\n\t\t\tResponse: &osb.LastOperationResponse{\n\t\t\t\tState: osb.StateInProgress,\n\t\t\t\tDescription: strPtr(lastOperationDescription),\n\t\t\t},\n\t\t},\n\t})\n\n\tsharedInformers.ClusterServiceBrokers().Informer().GetStore().Add(getTestClusterServiceBroker())\n\tsharedInformers.ClusterServiceClasses().Informer().GetStore().Add(getTestClusterServiceClass())\n\tsharedInformers.ClusterServicePlans().Informer().GetStore().Add(getTestClusterServicePlan())\n\n\tinstance := getTestServiceInstanceAsyncProvisioning(testOperation)\n\tinstanceKey := testNamespace + \"/\" + testServiceInstanceName\n\tstartTime := metav1.NewTime(time.Now().Add(-7 * 24 * time.Hour))\n\tinstance.Status.OperationStartTime = &startTime\n\n\tif testController.instancePollingQueue.NumRequeues(instanceKey) != 0 {\n\t\tt.Fatalf(\"Expected polling queue to not have any record of test instance\")\n\t}\n\n\tif err := testController.pollServiceInstance(instance); err == nil {\n\t\tt.Fatalf(\"Expected error to be returned in order to requeue instance for orphan mitigation\")\n\t}\n\n\tif testController.instancePollingQueue.NumRequeues(instanceKey) != 0 {\n\t\tt.Fatalf(\"Expected polling queue to not have any record of test instance as polling should have completed\")\n\t}\n\n\tbrokerActions := fakeClusterServiceBrokerClient.Actions()\n\tassertNumberOfClusterServiceBrokerActions(t, brokerActions, 1)\n\toperationKey := osb.OperationKey(testOperation)\n\tassertPollLastOperation(t, brokerActions[0], &osb.LastOperationRequest{\n\t\tInstanceID: testServiceInstanceGUID,\n\t\tServiceID: strPtr(testClusterServiceClassGUID),\n\t\tPlanID: strPtr(testClusterServicePlanGUID),\n\t\tOperationKey: &operationKey,\n\t})\n\n\tactions := fakeCatalogClient.Actions()\n\tassertNumberOfActions(t, actions, 1)\n\n\tupdatedServiceInstance := assertUpdateStatus(t, actions[0], instance)\n\tassertServiceInstanceRequestFailingErrorStartOrphanMitigation(\n\t\tt,\n\t\tupdatedServiceInstance,\n\t\tv1beta1.ServiceInstanceOperationProvision,\n\t\tstartingInstanceOrphanMitigationReason,\n\t\terrorReconciliationRetryTimeoutReason,\n\t\tasyncProvisioningReason,\n\t\tinstance,\n\t)\n\n\t// verify no kube resources created.\n\t// No actions\n\tkubeActions := fakeKubeClient.Actions()\n\tassertNumberOfActions(t, kubeActions, 0)\n}", "title": "" }, { "docid": "8c7ff8700399f488eede86ec307cb9ae", "score": "0.49455953", "text": "func (r *resolver) nextOnFail(qm *dnsmessage.Message) ([]dnsmessage.Resource, dnsmessage.RCode, error) {\n\tvar (\n\t\tc *conn\n\t\trs []dnsmessage.Resource\n\t\trc dnsmessage.RCode\n\t\terr error\n\t)\n\t/* Try each server in turn */\n\tfor i := 0; 0 == len(rs) && len(r.servers) > i; i++ {\n\t\tc, err = r.getOrDialConn(i)\n\t\tif nil != err {\n\t\t\t/* TODO: Can we find something better to do here? */\n\t\t\tcontinue\n\t\t}\n\t\trs, rc, err = c.query(qm)\n\t}\n\treturn rs, rc, err\n}", "title": "" }, { "docid": "e074dbfca47a846e25b4e2c39931a499", "score": "0.49444154", "text": "func main() {\r\n\r\n\r\n // Get required values\r\n confDir := os.Getenv(\"CONFIG_DIR\")\r\n\r\n var config *configparser.ConfigParser\r\n var err error\r\n\r\n if len(confDir) != 0 {\r\n config, err = getConfig(confDir)\r\n }else{\r\n config, err = getConfig(DefaultConfigPath)\r\n }\r\n\r\n\r\n var mqHost, mqPort, mqUser, mqPass, receiveQueue, backoffQueue, hostname string\r\n var maxBackOff = MaxBackOffTime\r\n\r\n if err != nil {\r\n\r\n log.Errorf(err.Error())\r\n\r\n hostname = os.Getenv(\"HOSTNAME\")\r\n mqHost = os.Getenv(\"MQ_HOST\")\r\n mqPort = os.Getenv(\"MQ_PORT\")\r\n mqUser = os.Getenv(\"MQ_USER\")\r\n mqPass = os.Getenv(\"MQ_PASS\")\r\n receiveQueue = os.Getenv(\"RECEIVE_QUEUE\")\r\n backoffQueue = os.Getenv(\"RETRY_QUEUE\")\r\n\r\n if len(mqHost) == 0 ||\r\n len(mqPort) == 0 ||\r\n len(mqUser) == 0 ||\r\n len(mqPass) == 0 ||\r\n len(hostname) == 0 ||\r\n len(receiveQueue) == 0 ||\r\n len(backoffQueue) == 0{\r\n \t log.Fatalf(\"Config not found, Environment variables missing\")\r\n }\r\n\r\n\r\n }else{\r\n\r\n mqHost, err = config.Get(\"QueueService\", \"hostname\")\r\n if err != nil {\r\n log.Fatalf(err.Error())\r\n }\r\n mqPort, err = config.Get(\"QueueService\", \"port\")\r\n if err != nil {\r\n log.Fatalf(err.Error())\r\n }\r\n mqUser, err = config.Get(\"QueueService\", \"user\")\r\n if err != nil {\r\n log.Fatalf(err.Error())\r\n }\r\n mqPass, err = config.Get(\"QueueService\", \"pass\")\r\n if err != nil {\r\n log.Fatalf(err.Error())\r\n }\r\n hostname, err = config.Get(\"DEFAULTS\", \"hostname\")\r\n if err != nil {\r\n log.Fatalf(err.Error())\r\n }\r\n receiveQueue, err = config.Get(\"DEFAULTS\", \"receive_queue\")\r\n if err != nil {\r\n log.Fatalf(err.Error())\r\n }\r\n backoffQueue, err = config.Get(\"DEFAULTS\", \"retry_queue\")\r\n if err != nil {\r\n log.Fatalf(err.Error())\r\n }\r\n // Get max back off duration if exist\r\n p, err := config.Get(\"DEFAULTS\", \"maximum_backoff_time\")\r\n if err == nil {\r\n val, err := strconv.Atoi(p)\r\n if err == nil {\r\n maxBackOff = val\r\n }else{\r\n log.Errorf(err.Error())\r\n }\r\n }\r\n }\r\n\r\n\r\n // Get the Kubernetes client for communicating with API server\r\n\tclient := getKubernetesClient()\r\n\r\n // Create the required resource listers and informers\r\n kubefactory := kubeinformers.NewSharedInformerFactory(client, time.Second*30)\r\n node_lister := kubefactory.Core().V1().Nodes().Lister()\r\n pod_lister := kubefactory.Core().V1().Pods().Lister()\r\n\r\n\r\n // Attempt to connect to the rabbitMQ server\r\n comm, err := communication.NewCommunicationClient(fmt.Sprintf(\"amqp://%s:%s@%s:%s/\",mqUser, mqPass, mqHost, mqPort))\r\n if err != nil {\r\n log.Fatalf(err.Error())\r\n }\r\n\r\n err = comm.QueueDeclare(receiveQueue)\r\n if err != nil {\r\n log.Fatalf(err.Error())\r\n }\r\n\r\n msgs, err := comm.Receive(receiveQueue)\r\n\r\n // Use a channel if goroutine closes\r\n retryCh := make(chan bool)\r\n defer close(retryCh)\r\n\r\n // use a channel to synchronize the finalization for a graceful shutdown\r\n stopCh := make(chan struct{})\r\n defer close(stopCh)\r\n kubefactory.Start(stopCh)\r\n\r\n\r\n // Do the initial synchronization (one time) to populate resources\r\n kubefactory.WaitForCacheSync(stopCh)\r\n\r\n // Create scheduler object\r\n main_sched := NewShortJobScheduler(client, pod_lister, node_lister)\r\n\r\n // Scheduler initialization failed\r\n if err != nil {\r\n log.Fatalf(err.Error())\r\n }\r\n\r\n // Start go routine to start consuming messages\r\n\tgo ScheduleProcess(&comm, main_sched, client, pod_lister, msgs, retryCh, receiveQueue, backoffQueue, hostname, maxBackOff)\r\n\r\n\tlog.Printf(\" [*] Waiting for messages. To exit press CTRL+C\")\r\n\r\n // Check for connection failures and reconnect\r\n for {\r\n\r\n if status := <-retryCh; status == true {\r\n log.Errorf(\"Disconnected from message server and attempting to reconnect\")\r\n for{\r\n err = comm.Connect()\r\n if err != nil{\r\n log.Errorf(err.Error())\r\n }else{\r\n\r\n err = comm.QueueDeclare(receiveQueue)\r\n if err != nil {\r\n log.Errorf(err.Error())\r\n }else{\r\n msgs, err = comm.Receive(receiveQueue)\r\n if(err != nil){\r\n log.Errorf(err.Error())\r\n }else{\r\n // Start go routine to start consuming messages\r\n go ScheduleProcess(&comm, main_sched, client, pod_lister, msgs, retryCh, receiveQueue, backoffQueue, hostname, maxBackOff)\r\n log.Infof(\"Reconnected to message server\")\r\n break\r\n }\r\n }\r\n }\r\n // Sleep for a random time before trying again\r\n time.Sleep(time.Duration(rand.Intn(10))*time.Second)\r\n }\r\n }\r\n }\r\n}", "title": "" }, { "docid": "e94c7cee5d96f5a36bd33d998b3fa50e", "score": "0.49275282", "text": "func (c *Circonus) getCheckBroker(name string) (string, error) {\n\tif c.api == nil {\n\t\treturn \"\", fmt.Errorf(\"unable to get check broker: Circonus API not initialized\")\n\t}\n\n\tsearch := apiclient.SearchQueryType(\"(active:1)(type:httptrap)(name:\" + name + \")\")\n\tchecks, err := c.api.SearchCheckBundles(&search, nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"unable to search check bundles: %w\", err)\n\t}\n\n\tif checks == nil {\n\t\treturn \"\", nil\n\t}\n\n\tif len(*checks) == 0 {\n\t\treturn \"\", nil\n\t}\n\n\tif len((*checks)[0].Brokers) == 0 {\n\t\treturn \"\", nil\n\t}\n\n\treturn (*checks)[0].Brokers[0], nil\n}", "title": "" }, { "docid": "a6c32e5a94d028e2b45c9c60aa68cd23", "score": "0.49199563", "text": "func (r *DB) callBreaker(fn func() error) error {\n\tvar err error\n\tif r.commandName == nil {\n\t\treturn fn()\n\t}\n\tcn := *r.commandName\n\tfor i := 0; i <= r.retryCount; i++ {\n\t\terr = hystrix.Do(cn, func() error {\n\t\t\treturn fn()\n\t\t}, r.fallbackFunc)\n\t\tif err != nil {\n\t\t\tvar backOffTime time.Duration\n\t\t\tif i <= 0 {\n\t\t\t\tbackOffTime = 0 * time.Millisecond\n\t\t\t} else {\n\t\t\t\t// rand.Int63n(nc.interval*1000)\n\t\t\t\tbackOffTime = (time.Duration(int64(2/time.Millisecond)) * time.Millisecond) + (time.Duration(rand.Int63n(5*1000)) * time.Millisecond)\n\t\t\t}\n\t\t\ttime.Sleep(backOffTime)\n\t\t\tcontinue\n\t\t}\n\t\tbreak\n\t}\n\treturn err\n}", "title": "" }, { "docid": "3bd0e363ea27ee1eec1e7ea4383211d3", "score": "0.49180648", "text": "func (w *Worker) fetchConsumerARNWithRetry() (string, error) {\n\tfor retry := 0; ; retry++ {\n\t\tconsumerARN, err := w.fetchConsumerARN()\n\t\tif err == nil {\n\t\t\treturn consumerARN, nil\n\t\t}\n\t\tif retry < 10 {\n\t\t\tsleepDuration := time.Duration(math.Exp2(float64(retry))*100) * time.Millisecond\n\t\t\tw.kclConfig.Logger.Errorf(\"Could not get consumer ARN: %v, retrying after: %s\", err, sleepDuration)\n\t\t\ttime.Sleep(sleepDuration)\n\t\t\tcontinue\n\t\t}\n\t\treturn consumerARN, err\n\t}\n}", "title": "" }, { "docid": "9433be332254c7e6dbc5a785a300ad56", "score": "0.490667", "text": "func (r rpcError) CanRetry() bool { return true }", "title": "" }, { "docid": "802cee951dd0f894c83335695e089b1c", "score": "0.48703992", "text": "func (s *MapperSuite) TestNilNotPropagated(c *C) {\n\tclock.Freeze(testEpoch)\n\n\tr := &mockResolver{\n\t\tw2b: map[Worker]*sarama.Broker{\n\t\t\ts.workers[0]: s.brokers[2],\n\t\t\ts.workers[1]: s.brokers[2],\n\t\t},\n\t}\n\ts.cfg.Consumer.RetryBackoff = 500 * clock.Millisecond\n\tm := Spawn(s.ns, s.cfg, r)\n\tm.OnWorkerSpawned(s.workers[0])\n\tm.OnWorkerSpawned(s.workers[1])\n\t// Initial assigment received.\n\tassigned0 := <-s.workers[0].assignmentsCh\n\tc.Assert(assigned0.BrokerConn(), Equals, s.brokers[2])\n\tassigned1 := <-s.workers[1].assignmentsCh\n\tc.Assert(assigned1.BrokerConn(), Equals, s.brokers[2])\n\n\t// Trigger reassignemnt making sure it fails.\n\tclock.Advance(500 * clock.Millisecond)\n\tr.errors = map[Worker]error{\n\t\ts.workers[0]: errors.New(\"Kaboom!\"),\n\t\ts.workers[1]: errors.New(\"Kaboom!\"),\n\t}\n\tm.TriggerReassign(s.workers[0])\n\tm.TriggerReassign(s.workers[1])\n\tassertExecutorStopped(c, assigned0, 3*clock.Second)\n\tassertNoAssignments(c, s.workers[0], 200*clock.Millisecond)\n\tassertNoAssignments(c, s.workers[1], 0)\n\n\t// When\n\tlog.Info(\"*** When\")\n\tr.errors = map[Worker]error{\n\t\ts.workers[1]: errors.New(\"Kaboom!\"),\n\t}\n\tr.w2b = map[Worker]*sarama.Broker{\n\t\ts.workers[0]: s.brokers[1],\n\t}\n\tm.TriggerReassign(s.workers[0])\n\tm.TriggerReassign(s.workers[1])\n\n\t// Then\n\tlog.Info(\"*** Then\")\n\tclock.Advance(500 * clock.Millisecond)\n\tassigned0 = <-s.workers[0].assignmentsCh\n\tc.Assert(assigned0.BrokerConn(), Equals, s.brokers[1])\n\n\t// Cleanup\n\tm.OnWorkerStopped(s.workers[0])\n\tm.OnWorkerStopped(s.workers[1])\n\tm.Stop()\n\tassertNoAssignments(c, s.workers[0], 0)\n\tassertNoAssignments(c, s.workers[1], 0)\n}", "title": "" }, { "docid": "5684c0f267b98b53c3c2fe7a83560823", "score": "0.48241234", "text": "func TestReconcileServiceInstanceNonExistentClusterServiceBroker(t *testing.T) {\n\t_, fakeCatalogClient, fakeClusterServiceBrokerClient, testController, sharedInformers := newTestController(t, noFakeActions())\n\n\tsharedInformers.ClusterServiceClasses().Informer().GetStore().Add(getTestClusterServiceClass())\n\tsharedInformers.ClusterServicePlans().Informer().GetStore().Add(getTestClusterServicePlan())\n\n\tinstance := getTestServiceInstanceWithRefs()\n\n\tif err := reconcileServiceInstance(t, testController, instance); err == nil {\n\t\tt.Fatal(\"The broker referenced by the instance exists when it should not.\")\n\t}\n\n\tbrokerActions := fakeClusterServiceBrokerClient.Actions()\n\tassertNumberOfClusterServiceBrokerActions(t, brokerActions, 0)\n\n\tactions := fakeCatalogClient.Actions()\n\tassertNumberOfActions(t, actions, 1)\n\n\t// There should only be one action that says it failed because no such broker exists.\n\tupdatedServiceInstance := assertUpdateStatus(t, actions[0], instance)\n\tassertServiceInstanceErrorBeforeRequest(t, updatedServiceInstance, errorNonexistentClusterServiceBrokerReason, instance)\n\n\tevents := getRecordedEvents(testController)\n\n\texpectedEvent := warningEventBuilder(errorNonexistentClusterServiceBrokerReason).msgf(\n\t\t\"The instance references a non-existent broker %q\",\n\t\t\"test-clusterservicebroker\",\n\t)\n\tif err := checkEvents(events, expectedEvent.stringArr()); err != nil {\n\t\tt.Fatal(err)\n\t}\n}", "title": "" }, { "docid": "ae887230888d8534ebe10582fa2e37ce", "score": "0.48227954", "text": "func (worker *BrokerRegistrationManager) isBrokerRegistered() bool {\n\tisBrokerRegistered := true\n\tbroker, err := worker.dbDelegate.FindBroker()\n\tif err != nil {\n\t\tisBrokerRegistered = false\n\t} else if broker.ID == \"\" {\n\t\tisBrokerRegistered = false\n\t}\n\treturn isBrokerRegistered\n}", "title": "" }, { "docid": "13e6201e1d3381d405f7b6ba796737ad", "score": "0.4808555", "text": "func retryingGet(getCacheObj func(remapping remap.Remapping, retryFailures bool, obj *cacheobj.CacheObj) *cacheobj.CacheObj, request *http.Request, remappingProducer *remap.RemappingProducer, cachedObj *cacheobj.CacheObj) (*cacheobj.CacheObj, *string, error) {\n\tobj := (*cacheobj.CacheObj)(nil)\n\tfor {\n\t\tremapping, retryAllowed, err := remappingProducer.GetNext(request)\n\t\tif err == remap.ErrNoMoreRetries {\n\t\t\tif obj == nil {\n\t\t\t\treturn nil, nil, errors.New(\"remapping producer allows no requests\") // should never happen\n\t\t\t}\n\t\t\treturn obj, nil, nil\n\t\t} else if err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t\tobj = getCacheObj(remapping, retryAllowed, cachedObj)\n\t\tif !isFailure(obj, remapping.RetryCodes) {\n\t\t\treturn obj, &remapping.Request.URL.Host, nil\n\t\t}\n\t}\n}", "title": "" }, { "docid": "6596192dc2b69fd22d4319cc80285756", "score": "0.4795713", "text": "func (worker *BrokerRegistrationManager) registerBroker() {\n\tdatabaseWorker, err := persistence.NewDomainInformationStorage()\n\tif err != nil {\n\t\tfmt.Println(\"Database not reachable\")\n\t\treturn\n\t}\n\tworker.dbDelegate = databaseWorker\n\tworker.workerStarted.Done()\n\n\tif isBrokerRegistered := worker.isBrokerRegistered(); isBrokerRegistered {\n\t\tfmt.Println(\"Broker is already Registered\")\n\t\treturn\n\t}\n\t//TODO: Get IP address from Docker ENV\n\n\tdaemonConfig := configuration.DaemonConfigurationManagerInstance().Config()\n\n\tbroker := models.NewBroker()\n\tbroker.IP = daemonConfig.BrokerURL.String()\n\tworker.findDomainNameForBroker(broker)\n\tworker.findRealWorldDomainsForBroker(broker)\n\tworker.findGeolocationForBroker(broker)\n\n\tworker.registerTicker = time.NewTicker(RegisterInterval)\n\tgo func() {\n\t\tregistrationSuccess := false\n\t\tdefer worker.dbDelegate.Close()\n\t\tfor _ = range worker.registerTicker.C {\n\t\t\tfmt.Println(\"RegistrationTicker Tick\")\n\t\t\tif registrationSuccess {\n\t\t\t\tworker.registerTicker.Stop()\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tregistrationSuccess = worker.sendRegistrationRequestForBroker(broker)\n\t\t}\n\t}()\n}", "title": "" }, { "docid": "2cf43d4539087367d59c3053644c03ff", "score": "0.4779987", "text": "func (c *AMQPConsumer) reConnect(queueName, bindingKey string) (<-chan amqp.Delivery, error) {\n\ttime.Sleep(30 * time.Second)\n\n\tif err := c.Connect(); err != nil {\n\t\tfmt.Printf(\"could not connect in reconnect call: %v\\n\", err.Error())\n\t}\n\n\tdeliveries, err := c.announceQueue(queueName, bindingKey)\n\tif err != nil {\n\t\treturn deliveries, fmt.Errorf(\"couldn't connect: %w\", err)\n\t}\n\n\treturn deliveries, nil\n}", "title": "" }, { "docid": "5c044eebc42916daa80a4461292da460", "score": "0.47791877", "text": "func TestRunningReapUnknown(t *testing.T) {\n\t// Job Chain:\n\t// 1 - 2 - 3\n\t// \\_ 4\n\t// Testing when job 2 fails\n\n\treqId := \"test_running_reap_fail\"\n\tfactory := defaultFactory(reqId)\n\tjc := &proto.JobChain{\n\t\tRequestId: reqId,\n\t\tJobs: testutil.InitJobs(4),\n\t\tAdjacencyList: map[string][]string{\n\t\t\t\"job1\": {\"job2\", \"job4\"},\n\t\t\t\"job2\": {\"job3\"},\n\t\t},\n\t}\n\tc := chain.NewChain(jc, make(map[string]uint), make(map[string]uint), make(map[string]uint))\n\tfactory.Chain = c\n\n\t// Normally runJobChan is unbuffered. Here we use a buffer so Reap\n\t// doesn't block on sending to the chan (though we don't expect any values\n\t// to be sent after a job fails).\n\trunJobChan := make(chan proto.Job, 5)\n\tfactory.RunJobChan = runJobChan\n\treaper := factory.MakeRunning()\n\n\tc.IncrementSequenceTries(\"job1\", 1)\n\tc.SetJobState(\"job1\", proto.STATE_COMPLETE)\n\tc.SetJobState(\"job2\", proto.STATE_RUNNING)\n\n\t// Job 2 has just returned an unknown state.\n\tjob := proto.Job{\n\t\tId: \"job2\",\n\t\tState: proto.STATE_UNKNOWN,\n\t\tData: map[string]interface{}{\n\t\t\t\"key1\": \"val1\",\n\t\t},\n\t}\n\treaper.(*chain.RunningChainReaper).Reap(job)\n\n\t// no jobs should be sent to runJobChan\n\tselect {\n\tcase gotJob := <-runJobChan:\n\t\tt.Errorf(\"got job %s from runJobChan, expected no job\", gotJob.Id)\n\tdefault:\n\t}\n\n\t// job2's state should have been set in the chain\n\tgotState := c.JobState(\"job2\")\n\tif gotState != proto.STATE_UNKNOWN {\n\t\tt.Errorf(\"job2 state in chain = %d, expected state = %d\", gotState, proto.STATE_UNKNOWN)\n\t}\n\n\t// Job data should not have been copied to job3\n\tif len(jc.Jobs[\"job3\"].Data) != 0 {\n\t\tt.Errorf(\"job3 has job data - no data should have been copied from job2\")\n\t}\n}", "title": "" }, { "docid": "3ea13dbc1b924bd0f59c51f85fb33b9c", "score": "0.4776385", "text": "func TestDeliverer(t *testing.T) {\n\tintegration.Skip(t)\n\tconst (\n\t\tcallback = \"http://clair-notifier/notifier/api/v1/notifications\"\n\t)\n\tvar (\n\t\turi = os.Getenv(\"RABBITMQ_CONNECTION_STRING\")\n\t\tqueueAndKey = uuid.New().String()\n\t\t// our test assumes a default exchange\n\t\texchange = Exchange{\n\t\t\tName: \"\",\n\t\t\tType: \"direct\",\n\t\t\tDurable: true,\n\t\t\tAutoDelete: false,\n\t\t}\n\t\tconf = Config{\n\t\t\tCallback: callback,\n\t\t\tExchange: exchange,\n\t\t\tRoutingKey: queueAndKey,\n\t\t}\n\t)\n\tif uri == \"\" {\n\t\turi = defaultRabbitMQURI\n\t}\n\n\tconf.URIs = []string{\n\t\t// give a few bogus URIs to confirm failover mechanisms are working\n\t\t\"amqp://guest:guest@nohost1:5672/\",\n\t\t\"amqp://guest:guest@nohost2:5672/\",\n\t\t\"amqp://guest:guest@nohost3:5672/\",\n\t\turi,\n\t}\n\n\tconn, err := samqp.Dial(uri)\n\tif err != nil {\n\t\tt.Fatalf(\"failed to connect to broker at %v: %v\", uri, err)\n\t}\n\tch, err := conn.Channel()\n\tif err != nil {\n\t\tt.Fatalf(\"failed to obtain channel from broker %v: %v\", uri, err)\n\t}\n\t// this queue will autobind to the default \"direct\" exchange\n\t// and the queue name may be used as the routing key.\n\t_, err = ch.QueueDeclare(\n\t\tqueueAndKey,\n\t\ttrue,\n\t\tfalse,\n\t\tfalse,\n\t\tfalse,\n\t\tnil,\n\t)\n\tif err != nil {\n\t\tt.Fatalf(\"failed to declare queue: %v\", err)\n\t}\n\n\t// test parallel usage\n\tg := errgroup.Group{}\n\tfor i := 0; i < 4; i++ {\n\t\tg.Go(func() error {\n\t\t\tnoteID := uuid.New()\n\t\t\td, err := New(conf)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"could not create deliverer: %v\", err)\n\t\t\t}\n\t\t\t// we simply need to check for an error. amqp\n\t\t\t// will error if message cannot be delivered to broker\n\t\t\terr = d.Deliver(context.TODO(), noteID)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to deliver message: %v\", err)\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t}\n\tif err := g.Wait(); err != nil {\n\t\tt.Fatalf(\"test failed: %v\", err)\n\t}\n\n}", "title": "" }, { "docid": "eb21e77dabdda28472368178169bdef5", "score": "0.47747615", "text": "func GetReassigningBrokers(r kafkazk.Reassignments, zk kafkazk.Handler) (reassigningBrokers, error) {\n\tlb := reassigningBrokers{\n\t\t// Maps of src and dst brokers used as sets.\n\t\tsrc: map[int]struct{}{},\n\t\tdst: map[int]struct{}{},\n\t\tall: map[int]struct{}{},\n\t\t// A map for each topic with a list throttled leaders and followers.\n\t\t// This is used to write the topic config throttled brokers lists.\n\t\tthrottledReplicas: TopicThrottledReplicas{},\n\t}\n\n\t// Get topic data for each topic undergoing a reassignment.\n\tfor t := range r {\n\t\ttopic := Topic(t)\n\t\tlb.throttledReplicas[topic] = make(Throttled)\n\t\tlb.throttledReplicas[topic][\"leaders\"] = []string{}\n\t\tlb.throttledReplicas[topic][\"followers\"] = []string{}\n\t\ttstate, err := zk.GetTopicStateISR(t)\n\t\tif err != nil {\n\t\t\treturn lb, fmt.Errorf(\"Error fetching topic data: %s\", err.Error())\n\t\t}\n\n\t\t// For each partition, compare the current ISR leader to the brokers being\n\t\t// assigned in the reassignments. The current leaders will be sources,\n\t\t// new brokers in the assignment list (but not in the current ISR state)\n\t\t// will be destinations.\n\t\t// TODO(jamie): the throttledReplicas can be populated here with the recently\n\t\t// added TopicThrottledReplicas.addReplica method.\n\t\tfor p := range tstate {\n\t\t\tpartn, _ := strconv.Atoi(p)\n\t\t\tif reassigning, exists := r[t][partn]; exists {\n\t\t\t\t// Source brokers.\n\t\t\t\tleader := tstate[p].Leader\n\t\t\t\t// In offline partitions, the leader value is set to -1. Skip.\n\t\t\t\tif leader != -1 {\n\t\t\t\t\tlb.src[leader] = struct{}{}\n\t\t\t\t\t// Append to the throttle list.\n\t\t\t\t\tleaders := lb.throttledReplicas[topic][\"leaders\"]\n\t\t\t\t\tlb.throttledReplicas[topic][\"leaders\"] = append(leaders, fmt.Sprintf(\"%d:%d\", partn, leader))\n\t\t\t\t}\n\n\t\t\t\t// Dest brokers.\n\t\t\t\tfor _, b := range reassigning {\n\t\t\t\t\t// Checks: not -1 (offline/missing), not in the curent ISR state.\n\t\t\t\t\t// XXX(jamie): out of sync but previously existing brokers would\n\t\t\t\t\t// show here as well. May want to consider whether those should\n\t\t\t\t\t// be dynamically throttled as if they're part of a reassignemnt.\n\t\t\t\t\tif b != -1 && !inSlice(b, tstate[p].ISR) {\n\t\t\t\t\t\tlb.dst[b] = struct{}{}\n\t\t\t\t\t\tfollowers := lb.throttledReplicas[topic][\"followers\"]\n\t\t\t\t\t\tlb.throttledReplicas[topic][\"followers\"] = append(followers, fmt.Sprintf(\"%d:%d\", partn, b))\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tlb.all = mergeMaps(lb.src, lb.dst)\n\n\treturn lb, nil\n}", "title": "" }, { "docid": "87a4456c54500898f02243b0ba0d17db", "score": "0.47627005", "text": "func RetryCollector(ctx context.Context) error {\n\tdbp, err := zesty.NewDBProvider(utask.DBName)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tsl := newSleeper()\n\n\tgo func() {\n\t\tfor running := true; running; {\n\t\t\tsl.sleep()\n\n\t\t\tselect {\n\t\t\tcase <-ctx.Done():\n\t\t\t\trunning = false\n\t\t\tdefault:\n\t\t\t\tr, _ := getUpdateErrorResolution(dbp)\n\t\t\t\tif r != nil {\n\t\t\t\t\tsl.wakeup()\n\t\t\t\t\tlogrus.WithFields(logrus.Fields{\n\t\t\t\t\t\t\"resolution_id\": r.PublicID,\n\t\t\t\t\t\t\"log_type\": \"engine\",\n\t\t\t\t\t}).Debugf(\"Retry Collector: collected resolution %s\", r.PublicID)\n\t\t\t\t\t_ = GetEngine().Resolve(r.PublicID, nil)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn nil\n}", "title": "" }, { "docid": "988c2cd044ce00c86768aa2e6dc6915d", "score": "0.47585398", "text": "func TestShouldReconcileServiceBroker(t *testing.T) {\n\tbroker := getTestClusterServiceBroker()\n\tbroker.Spec.RelistDuration = &metav1.Duration{Duration: 3 * time.Minute}\n\n\tif !shouldReconcileClusterServiceBroker(broker, time.Now(), 24*time.Hour) {\n\t\tt.Error(\"expected true, bot got false\")\n\t}\n}", "title": "" }, { "docid": "71e7a6b7effda2cfba669568ccde2a80", "score": "0.4750026", "text": "func (b *Bmatrix) retry(f func() error) error {\n\tb.rateMutex.Lock()\n\tdefer b.rateMutex.Unlock()\n\n\tfor {\n\t\tif err := f(); err != nil {\n\t\t\tif backoff, ok := b.handleRatelimit(err); ok {\n\t\t\t\ttime.Sleep(backoff)\n\t\t\t} else {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\treturn nil\n\t\t}\n\t}\n}", "title": "" }, { "docid": "9810c971509a2ea2a6bec58daba7a8dd", "score": "0.47452533", "text": "func newRetryProcessor(name string, queue blockingQueue, logger log.Logger, next processor) processor {\n\treturn processorFunc(func(ctx context.Context, key string) error {\n\t\terr := next.Process(ctx, key)\n\t\tif err != nil {\n\t\t\t// Retry if possible.\n\t\t\trequeueErr := queue.Requeue(ctx, key)\n\t\t\tif requeueErr != nil {\n\t\t\t\treturn fmt.Errorf(\"could not retry: %s: %w\", requeueErr, err)\n\t\t\t}\n\t\t\tlogger.WithKV(log.KV{\"object-key\": key}).Warningf(\"item requeued due to processing error: %s\", err)\n\t\t\treturn nil\n\t\t}\n\n\t\treturn nil\n\t})\n}", "title": "" }, { "docid": "57ecc8c79f9f2131d1743ea5508d9716", "score": "0.47353348", "text": "func TestRetryOnConnectionError(t *testing.T) {\n\tconn := &testConnector{\n\t\trefusing: true,\n\t\tconnect: make(chan bool),\n\t}\n\n\tch := make(chan *pb.LanzRecord)\n\tc, done := launchClient(ch, conn)\n\n\tconnects := 3\n\tstopped := false\n\tfor !stopped {\n\t\tselect {\n\t\tcase <-conn.connect:\n\t\t\tconnects--\n\t\t\tif connects == 0 {\n\t\t\t\tc.Stop()\n\t\t\t}\n\t\tcase <-done:\n\t\t\tstopped = true\n\t\t}\n\t}\n}", "title": "" }, { "docid": "ba4830b6449468a44edc6e6d298b945e", "score": "0.47337446", "text": "func GetBroker() Broker {\n\tif initialized {\n\t\treturn brokerConn\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "644bed373452709831589366fd55fdff", "score": "0.4731524", "text": "func (ac *AccessLog) Broker() *Broker {\n\tac.mu.Lock()\n\tif ac.broker == nil {\n\t\tac.broker = newBroker()\n\t\t// atomic.StoreUint32(&ac.brokerActive, 1)\n\t}\n\tac.mu.Unlock()\n\treturn ac.broker\n}", "title": "" }, { "docid": "721dcaa285a92006f970145a6e26a566", "score": "0.47263393", "text": "func (ot *T) NextRetry() (consumer.Message, int, bool) {\n\treturn ot.nextRetry(time.Now())\n}", "title": "" }, { "docid": "d0ca0e8846327d0ed775c1a57cceb15a", "score": "0.47173804", "text": "func configureFastConnectionRetry(_ *testing.T) {\n\treplicaDatabase.MustExec(\n\t\t\"change replication source to SOURCE_CONNECT_RETRY=5;\")\n}", "title": "" }, { "docid": "d052a09265b737e63a7a85d1fd954450", "score": "0.471443", "text": "func monitorRetryWithBackoff(fn func() error) error {\n\tconst monitorDBMaxRetries = 5\n\n\tvar err error\n\tfor attempt := 1; attempt <= monitorDBMaxRetries; attempt++ {\n\t\tx := time.Duration(attempt) // satisfy the compiler\n\t\ttime.Sleep(x * x * time.Second)\n\t\terr = fn()\n\t\tif err == nil {\n\t\t\tLogger.WithField(\"attempts\", attempt).Warn(\"failed to contact db several times, but managed to pull through!\")\n\t\t\tbreak\n\t\t}\n\t}\n\treturn err\n}", "title": "" }, { "docid": "3c5127617c68e6871247cb87d2f515c2", "score": "0.47103295", "text": "func (o *Operator) triggerInstallPlanRetry(obj interface{}) (syncError error) {\n\tmetaObj, ok := obj.(metav1.Object)\n\tif !ok {\n\t\tsyncError = errors.New(\"casting to metav1 object failed\")\n\t\to.logger.Warn(syncError.Error())\n\t\treturn\n\t}\n\n\trelated, _ := scoped.IsObjectRBACRelated(obj)\n\tif !related {\n\t\treturn\n\t}\n\n\tips, err := o.lister.OperatorsV1alpha1().InstallPlanLister().InstallPlans(metaObj.GetNamespace()).List(labels.Everything())\n\tif err != nil {\n\t\tsyncError = err\n\t\treturn\n\t}\n\n\tisTarget := func(ip *v1alpha1.InstallPlan) bool {\n\t\t// Only an InstallPlan that has failed to install before and only if it\n\t\t// has a reference to a ServiceAccount then\n\t\treturn ip.Status.Phase == v1alpha1.InstallPlanPhaseFailed && ip.Status.AttenuatedServiceAccountRef != nil\n\t}\n\n\tupdate := func(ip *v1alpha1.InstallPlan) error {\n\t\tout := ip.DeepCopy()\n\t\tout.Status.Phase = v1alpha1.InstallPlanPhaseInstalling\n\t\t_, err := o.client.OperatorsV1alpha1().InstallPlans(ip.GetNamespace()).UpdateStatus(context.TODO(), out, metav1.UpdateOptions{})\n\n\t\treturn err\n\t}\n\n\tvar errs []error\n\tfor _, ip := range ips {\n\t\tif !isTarget(ip) {\n\t\t\tcontinue\n\t\t}\n\n\t\tlogger := o.logger.WithFields(logrus.Fields{\n\t\t\t\"ip\": ip.GetName(),\n\t\t\t\"namespace\": ip.GetNamespace(),\n\t\t\t\"phase\": ip.Status.Phase,\n\t\t})\n\n\t\tif updateErr := update(ip); updateErr != nil {\n\t\t\terrs = append(errs, updateErr)\n\t\t\tlogger.WithError(updateErr).Warn(\"failed to kick off InstallPlan retry\")\n\t\t\tcontinue\n\t\t}\n\n\t\tlogger.Info(\"InstallPlan status set to 'Installing' for retry\")\n\t}\n\n\tsyncError = utilerrors.NewAggregate(errs)\n\treturn\n}", "title": "" }, { "docid": "6f42eefa0ff5320f374090722ad7f886", "score": "0.47084084", "text": "func (b *broadcasterBehavior) Recover(err interface{}) error {\n\treturn nil\n}", "title": "" }, { "docid": "d615f4e525f83be3eb798f4964588268", "score": "0.47066534", "text": "func Retry(p Policy, f func() error) error {\n\tp = p.New()\n\n\tvar err error\n\tfor {\n\t\terr = f()\n\t\tif err == nil {\n\t\t\treturn nil\n\t\t}\n\n\t\tvar permanent *permanentError\n\t\tif errors.As(err, &permanent) {\n\t\t\treturn permanent.Unwrap()\n\t\t}\n\n\t\tduration := p.NextBackOff()\n\t\tif duration == Stop {\n\t\t\tbreak\n\t\t}\n\n\t\ttime.Sleep(duration)\n\t}\n\n\treturn err\n}", "title": "" }, { "docid": "7709dc503002ee893893d381c2a90126", "score": "0.46972084", "text": "func (session *SessionMQ) handleReconnect(addr string) {\n\tfor {\n\t\tsession.isReady = false\n\t\tlog.Println(\"Attempting to connect\")\n\n\t\tconn, err := session.connect(addr)\n\n\t\tif err != nil {\n\t\t\tlog.Println(\"Failed to connect. Retrying...\", addr)\n\n\t\t\tselect {\n\t\t\tcase <-session.done:\n\t\t\t\treturn\n\t\t\tcase <-time.After(reconnectDelay):\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif done := session.handleReInit(conn); done {\n\t\t\tbreak\n\t\t}\n\t}\n}", "title": "" }, { "docid": "ffb4a2c40f67acb8e6a4f852736dc302", "score": "0.4695944", "text": "func TestNil(t *testing.T) {\n\tif err := Retry(nil, nil, Backoff{}); err == nil {\n\t\tt.Errorf(\"got nil when passing in nil f\")\n\t}\n\tif err := Retry(func() error { return nil }, nil, Backoff{}); err == nil {\n\t\tt.Errorf(\"got nil when passing in nil p\")\n\t}\n}", "title": "" }, { "docid": "942ec7da664c9fe408df0f8425fe85d8", "score": "0.46924114", "text": "func (t *receivable) check(err error) (closing bool) {\n\tif err == nil {\n\t\treturn\n\t}\n\n\tif t.settings.OnReceivingError != nil {\n\t\tt.settings.OnReceivingError(err)\n\t}\n\n\tclosing = true\n\treturn\n}", "title": "" }, { "docid": "4fb823a3c5f5cac46450f22d2b651e2a", "score": "0.46861014", "text": "func Needed(err error) *RequeueNeeded {\n\treturn &RequeueNeeded{\n\t\terr: err,\n\t}\n}", "title": "" }, { "docid": "77b7225c556adba904543c04df573488", "score": "0.46606702", "text": "func waitRabbitOK(amqpuri string) error {\n\tvar err error\n\tvar counter = 0\ndial:\n\tif counter > 120 {\n\t\tpanic(\"Impossible to connect to rabbitmq\")\n\t}\n\n\t_, err = Dial(amqpuri)\n\tif err != nil {\n\t\ttime.Sleep(500 * time.Millisecond)\n\t\tcounter++\n\t\tgoto dial\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "f196c7f8e4398efd91d04eab7f02994f", "score": "0.46566284", "text": "func TestRemoteErrorAutoRetry(t *testing.T) {\n\tassert := assert.New(t)\n\tsConfig, cConfig := getConfigs()\n\tsConfig.CBRequestVolumeThreshold = 10\n\tcConfig.CBRequestVolumeThreshold = 10\n\tcConfig.Retries = 5\n\tservice := NewService(sConfig)\n\n\ttimesRun := 0\n\tremoteError := fmt.Errorf(\"Remote error\")\n\terr := service.Run(testCommand, func() (error, error) {\n\t\ttimesRun++\n\t\treturn nil, remoteError\n\t}, nil)\n\tassert.NotNil(err)\n\trErr, ok := err.(*RemoteError)\n\tassert.True(ok)\n\tassert.Equal(remoteError, rErr.Wrapped)\n\tassert.Equal(cConfig.Retries+1, timesRun)\n}", "title": "" }, { "docid": "3661bd705304f32624e27eef8ec5e697", "score": "0.4656022", "text": "func TryToRenewConsumingOrders() (tm <- chan time.Time) {\n\tdur := 5 * time.Minute // default duration to invoke this function again.\n\tdefer func () {\n\t\ttm = time.After(dur)\n\t}()\n\n\t// ...\n\n\tdb := getDB()\n\tif db == nil {\n\t\tLogger.Error(\"TryToRenewConsumingOrders error: db not inited\")\n\t\treturn\n\t}\n\n\t// ...\n\n\tconst EndOrderMargin = 7 * 24 * time.Hour\n\n\t// return if the order is ended.\n\tonInsufficientBalance := func(order *usage.PurchaseOrder, plan *Plan) bool {\n\t\tif time.Now().Before(order.Deadline_time.Add(EndOrderMargin)) {\n\n\t\t\tt, err := usage.GetOrderLastWarningMessageTime(db, order.Id)\n\t\t\tif err != nil {\n\t\t\t\tLogger.Errorf(\"onInsufficientBalance GetOrderLastWarningMessageTime error: %s\\n\", err.Error())\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\tnow := time.Now()\n\t\t\tif now.Sub(t) < 24 * time.Hour {\n\t\t\t\t// send most one email per day\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\t// todo: need a return error\n\t\t\tSendBalanceInsufficientEmail(order, plan)\n\t\t\t\n\t\t\tusage.SetOrderLastWarningMessageTime(db, order.Id, now)\n\n\t\t\treturn false\n\t\t}\n\n\t\terr := endOrder(db, order)\n\t\tif err != nil {\n\t\t\tLogger.Error(err.Error())\n\t\t\t\t\n\t\t\treturn false\n\t\t}\n\n\t\tSendEndOrderEmail_BalanceInsufficient(order, plan)\n\n\t\treturn true\n\t}\n\n\t// ...\n\n\tconst RenewMargin = 7 * 24 * time.Hour\n\n\t// todo: use cursor instead\n\tnumAll, orders, err := usage.QueryConsumingOrdersToRenew(db, RenewMargin, 32)\n\t_ = numAll\n\tif err != nil {\n\t\tLogger.Warningf(\"TryToRenewConsumingOrders at %s error: %s\", time.Now().Format(\"2006-01-02 15:04:05.999999\"), err.Error())\n\t} else {\n\t\tLogger.Warningf(\"TryToRenewConsumingOrders started at %s\", time.Now().Format(\"2006-01-02 15:04:05.999999\"))\n\n\t\tfor _, order := range orders {\n\t\t\t// \n\t\t\tplan, err := getPlanByID(order.Plan_id, order.Region)\n\t\t\tif err != nil {\n\t\t\t\tLogger.Errorf(\"TryToRenewConsumingOrders getPlanByID (%s) error: %s\", order.Plan_id, err.Error())\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t_, err, errReason := createOrder(false, db, nil, order, plan, nil)\n\t\t\tif err != nil {\n\t\t\t\tLogger.Errorf(\"TryToRenewConsumingOrders createOrder (%d) error: %s\", order.Id, err.Error())\n\n\t\t\t\tif errReason == ErrorCodeInsufficentBalance {\n\t\t\t\t\tonInsufficientBalance(order, plan)\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tLogger.Infof(\"TryToRenewConsumingOrders createOrder (%d) succeeded.\", order.Id)\n\n\t\t\tSendRenewOrderEmail(order, plan)\n\t\t}\n\t}\n\n\t// ...\n\n\t// todo: it is hard to calculate a proper duration to call this function again.\n\t// so used the default duration set at the beginning of this function now.\n\n\t//if int(numAll) > len(orders) {\n\t//\tdur = 10 * time.Second\n\t//\tLogger.Debugf(\"TryToRenewConsumingOrders len(orders) == maxCount\")\n\t//} else {\n\t//\td, err := usage.GetDurationToRenewNextConsumingOrder(db, RenewMargin)\n\t//\tif err != nil {\n\t//\t\tLogger.Warningf(\"TryToRenewConsumingOrders GetDurationToRenewNextConsumingOrder error: %s\", err.Error())\n\t//\t} else {\n\t//\t\tdur = d\n\t//\t}\n\t//}\n\n\treturn\n}", "title": "" }, { "docid": "457619945ea3d5f642dfe07f1c58cb4c", "score": "0.4645571", "text": "func NeedsRetry(err error) bool {\n\tif errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) {\n\t\tmon.Event(\"crdb_error_eof\")\n\t\t// Currently we don't retry with EOF because it's unclear if\n\t\t// a query succeeded or failed.\n\t\treturn false\n\t}\n\tif errors.Is(err, syscall.ECONNRESET) {\n\t\tmon.Event(\"crdb_error_conn_reset_needed_retry\")\n\t\treturn true\n\t}\n\tif errors.Is(err, syscall.ECONNREFUSED) {\n\t\tmon.Event(\"crdb_error_conn_refused_needed_retry\")\n\t\treturn true\n\t}\n\tvar netErr net.Error\n\tif errors.As(err, &netErr) {\n\t\tmon.Event(\"crdb_net_error_needed_retry\")\n\t\treturn true\n\t}\n\n\tcode := pgerrcode.FromError(err)\n\n\t// 57P01 occurs when a CRDB node rejoins the cluster but is not ready to accept connections\n\t// CRDB support recommended a retry at this point\n\t// Support ticket: https://support.cockroachlabs.com/hc/en-us/requests/5510\n\t// TODO re-evaluate this if support provides a better solution\n\treturn code == \"40001\" || code == \"CR000\" || code == \"57P01\"\n}", "title": "" }, { "docid": "d587613f441508b03bcfaedaaba073d8", "score": "0.46419668", "text": "func TestReconnect(\n\tt *testing.T,\n\ttCtx TestContext,\n\tpubSubConstructor PubSubConstructor,\n) {\n\tif len(tCtx.Features.RestartServiceCommand) == 0 {\n\t\tt.Skip(\"no RestartServiceCommand provided, cannot test reconnect\")\n\t}\n\n\tpub, sub := pubSubConstructor(t)\n\n\ttopicName := testTopicName(tCtx.TestID)\n\tif subscribeInitializer, ok := sub.(message.SubscribeInitializer); ok {\n\t\trequire.NoError(t, subscribeInitializer.SubscribeInitialize(topicName))\n\t}\n\n\tconst messagesCount = 10000\n\tconst publishersCount = 100\n\n\trestartAfterMessages := map[int]struct{}{\n\t\tmessagesCount / 3: {}, // restart at 1/3 of messages\n\t\tmessagesCount / 2: {}, // restart at 1/2 of messages\n\t}\n\n\tmessages, err := sub.Subscribe(context.Background(), topicName)\n\trequire.NoError(t, err)\n\n\tvar publishedMessages message.Messages\n\tmessagePublished := make(chan *message.Message, messagesCount)\n\tpublishMessage := make(chan struct{})\n\n\tgo func() {\n\t\tfor i := 0; i < messagesCount; i++ {\n\t\t\tpublishMessage <- struct{}{}\n\n\t\t\tif _, shouldRestart := restartAfterMessages[i]; shouldRestart {\n\t\t\t\tgo restartServer(t, tCtx.Features)\n\t\t\t}\n\t\t}\n\t\tclose(publishMessage)\n\t}()\n\n\tgo func() {\n\t\tfor msg := range messagePublished {\n\t\t\tpublishedMessages = append(publishedMessages, msg)\n\t\t}\n\t}()\n\n\tfor i := 0; i < publishersCount; i++ {\n\t\tgo func() {\n\t\t\tfor range publishMessage {\n\t\t\t\tid := watermill.NewUUID()\n\t\t\t\tmsg := message.NewMessage(id, nil)\n\n\t\t\t\tfor {\n\t\t\t\t\tfmt.Println(\"publishing message\")\n\n\t\t\t\t\t// some randomization in sending\n\t\t\t\t\tif rand.Int31n(10) == 0 {\n\t\t\t\t\t\ttime.Sleep(time.Millisecond * 500)\n\t\t\t\t\t}\n\n\t\t\t\t\tif err := publishWithRetry(pub, topicName, msg); err == nil {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tfmt.Printf(\"cannot publish message %s, trying again, err: %s\\n\", msg.UUID, err)\n\t\t\t\t\ttime.Sleep(time.Millisecond * 500)\n\t\t\t\t}\n\n\t\t\t\tmessagePublished <- msg\n\t\t\t}\n\t\t}()\n\t}\n\n\treceivedMessages, allMessages := bulkRead(tCtx, messages, messagesCount, defaultTimeout*4)\n\tassert.True(t, allMessages, \"not all messages received (has %d of %d)\", len(receivedMessages), messagesCount)\n\n\tAssertAllMessagesReceived(t, publishedMessages, receivedMessages)\n\n\tclosePubSub(t, pub, sub)\n}", "title": "" }, { "docid": "1b4683170e0df0ff60fcaf4750c2fe13", "score": "0.4638732", "text": "func notifyProcError(proc string, server string, recipientNumber string, c *cache.Cache, conf *ymlConf) {\n\tif len(proc) > 0 {\n\t\t//fmt.Printf(\"### ERROR: proc %s not running!\\n\", proc)\n\n\t\t// Check cache for process\n\t\t_, found := c.Get(proc)\n\t\tif found {\n\t\t\t// Wait until expiry before another notification\n\t\t\t//fmt.Printf(\"Process %s stored in cache, skipping\\n\", proc)\n\t\t\treturn\n\t\t}\n\n\t\t// If proc not in cache, store in cache\n\t\tc.Set(proc, true, cache.DefaultExpiration)\n\n\t\t// Send text message\n\t\tauthToken := conf.Config.MessageBirdToken\n\t\turlStr := \"https://rest.messagebird.com/messages\"\n\n\t\tv := url.Values{}\n\t\tv.Set(\"recipients\", recipientNumber)\n\t\tv.Set(\"originator\", conf.Config.MessageBirdSender)\n\t\tv.Set(\"body\", \"📢 \"+proc+\" not running on server \"+server+\"!\")\n\t\trb := *strings.NewReader(v.Encode())\n\n\t\tclient := &http.Client{}\n\n\t\treq, _ := http.NewRequest(\"POST\", urlStr, &rb)\n\t\treq.SetBasicAuth(\"AccessKey\", authToken)\n\t\treq.Header.Add(\"Accept\", \"application/json\")\n\t\treq.Header.Add(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\n\t\t// Make request\n\t\t_, err := client.Do(req)\n\t\tif err != nil {\n\t\t\t//fmt.Printf(\"Error: %s\\n\", err.Error())\n\t\t\treturn\n\t\t}\n\t\t//fmt.Println(resp.Status)\n\n\t\t//fmt.Println(\"Notification sent!\")\n\t}\n}", "title": "" }, { "docid": "bb0053384bd89ffed407938bb670cd94", "score": "0.4633026", "text": "func maybeRetryAdapters(ctx *domainContext, status *types.DomainStatus) {\n\n\tif !status.AdaptersFailed {\n\t\treturn\n\t}\n\tif status.Activated && status.AdaptersFailed {\n\t\tlog.Functionf(\"maybeRetryAdapters(%s) clearing adaptersFailed since Activated\",\n\t\t\tstatus.Key())\n\t\tstatus.AdaptersFailed = false\n\t\tpublishDomainStatus(ctx, status)\n\t\treturn\n\t}\n\tconfig := lookupDomainConfig(ctx, status.Key())\n\tif config == nil {\n\t\t// Odd to have status but no config\n\t\tlog.Errorf(\"maybeRetryAdapters(%s) no DomainConfig\",\n\t\t\tstatus.Key())\n\t\treturn\n\t}\n\tif !config.Activate {\n\t\tlog.Errorf(\"maybeRetryAdapters(%s) Config not Activate - nothing to do\",\n\t\t\tstatus.Key())\n\t\tstatus.AdaptersFailed = false\n\t\tpublishDomainStatus(ctx, status)\n\t\treturn\n\t}\n\tlog.Noticef(\"maybeRetryAdapters(%s) after %s at %v\",\n\t\tstatus.Key(), status.Error, status.ErrorTime)\n\n\t// Write any Location so that it can later be deleted based on status\n\tpublishDomainStatus(ctx, status)\n\tdoActivate(ctx, *config, status)\n\t// work done\n\tpublishDomainStatus(ctx, status)\n\tlog.Functionf(\"maybeRetryAdapters(%s) DONE for %s\",\n\t\tstatus.Key(), status.DisplayName)\n}", "title": "" }, { "docid": "f05ce5cf6a283e6ce8ead0744cfc7f86", "score": "0.4609155", "text": "func RetryNotifyRecover(operation backoff.Operation, b backoff.BackOff, notify backoff.Notify, recovered func()) error {\n\tvar notified bool\n\n\treturn backoff.RetryNotify(func() error {\n\t\terr := operation()\n\n\t\tif err == nil && notified {\n\t\t\tnotified = false\n\t\t\trecovered()\n\t\t}\n\n\t\treturn err\n\t}, b, func(err error, d time.Duration) {\n\t\tif !notified {\n\t\t\tnotify(err, d)\n\t\t\tnotified = true\n\t\t}\n\t})\n}", "title": "" }, { "docid": "1d8609be6d5ce5b73a7326f2f7b5c1f6", "score": "0.4607399", "text": "func TestSetRetryBackoff(d time.Duration) {\n\tmachineRetry = retry.Jitter(retry.Backoff(d, d, 1), 0.5)\n}", "title": "" }, { "docid": "3ff4155092f466c84cbd352d8548078b", "score": "0.46060944", "text": "func (ac *AccessLog) Broker() *Broker {\n\tac.mu.Lock()\n\tif ac.broker == nil {\n\t\tac.broker = newBroker()\n\t}\n\tac.mu.Unlock()\n\n\treturn ac.broker\n}", "title": "" }, { "docid": "5d14e2a9a997d44db5c15c28449a22d6", "score": "0.4595826", "text": "func (rr *roundRobin) Query(ctx context.Context, msg *dns.Msg, priority int, retry Retry) (*dns.Msg, error) {\n\tagain := true\n\tvar times int\n\tvar err error\n\tvar r Resolver\n\tvar resp *dns.Msg\n\n\tfor again {\n\t\terr = checkContext(ctx)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\n\t\tr = rr.nextResolver(ctx)\n\t\tif r == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tresp, err = r.Query(ctx, msg, priority, nil)\n\n\t\tvar timeout bool\n\t\tif err != nil {\n\t\t\tif e, ok := err.(*ResolveError); ok && (e.Rcode == TimeoutRcode ||\n\t\t\t\te.Rcode == dns.RcodeServerFailure || e.Rcode == dns.RcodeRefused) {\n\t\t\t\ttimeout = true\n\t\t\t}\n\t\t}\n\n\t\tk := r.String()\n\t\t// Pause using the resolver if queries have timed out too much\n\t\tif rr.avgs.updateTimeouts(k, timeout) && timeout {\n\t\t\trr.updateWait(k, 30*time.Second)\n\t\t}\n\n\t\tif err == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tif err != nil {\n\t\t\tif e, ok := err.(*ResolveError); ok && (e.Rcode == TimeoutRcode || e.Rcode == ResolverErrRcode) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tif retry != nil {\n\t\t\ttimes++\n\t\t\tagain = retry(times, priority, resp)\n\t\t}\n\t}\n\n\treturn resp, err\n}", "title": "" }, { "docid": "a9b30bfc7093292cd05cfdb45f255b32", "score": "0.45833874", "text": "func (p *Publisher) OnFail(endpoint *endpoint.Endpoint) {\n\tif endpoint.NumPending() != 0 {\n\t\tp.pullBackPending(endpoint)\n\t}\n\n\t// Allow method to handle what we do due to the failed endpoint\n\tp.method.onFail(endpoint)\n}", "title": "" }, { "docid": "5d263a82126cc00c9bce896ed7b76932", "score": "0.45805717", "text": "func ExecuteListenerWithRetry(listener *Listener, amqpClient Amqp, connectUri string) {\n\tdur := 3000 // the sleep time for retries\n\tretry := make(chan bool, 1) // a channel to communicate retries\n\tdisconnect := make(chan bool, 1) // channel for monitoring disconnects and errors\n\tgo ListenerExec(listener, amqpClient, connectUri, retry, disconnect)\n\t<-retry // wait until disconnect\n\tlog.Debug().Str(\"retry\", strconv.Itoa(dur)).Msg(\"MAIN: listener disconnected\")\n\ttime.Sleep(time.Duration(dur) * time.Millisecond) // pause before reattempt connection\n\tExecuteListenerWithRetry(listener, amqpClient, connectUri)\n\n}", "title": "" }, { "docid": "94b5eaec2714839dd31ee25e64ae9bda", "score": "0.45778966", "text": "func retryPredicate(err error) (shouldRetry, aggressiveBackoff bool) {\n\tif err == nil {\n\t\treturn\n\t}\n\n\ts, ok := status.FromError(err)\n\t// non-status based error conditions.\n\tif !ok {\n\t\t// EOF can happen in the case of connection close.\n\t\tif errors.Is(err, io.EOF) {\n\t\t\tshouldRetry = true\n\t\t\treturn\n\t\t}\n\t\t// All other non-status errors are treated as non-retryable (including context errors).\n\t\treturn\n\t}\n\tswitch s.Code() {\n\tcase codes.Aborted,\n\t\tcodes.Canceled,\n\t\tcodes.DeadlineExceeded,\n\t\tcodes.FailedPrecondition,\n\t\tcodes.Internal,\n\t\tcodes.Unavailable:\n\t\tshouldRetry = true\n\t\treturn\n\tcase codes.ResourceExhausted:\n\t\tif strings.HasPrefix(s.Message(), \"Exceeds 'AppendRows throughput' quota\") {\n\t\t\t// Note: internal b/246031522 opened to give this a structured error\n\t\t\t// and avoid string parsing. Should be a QuotaFailure or similar.\n\t\t\tshouldRetry = true\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}", "title": "" }, { "docid": "af31feab6f31acf4727996801c96fe0e", "score": "0.45718813", "text": "func (s *MsgFetcherSuite) TestLeaderRefreshError(c *C) {\n\t// Stage 1: my_topic/0 served by broker0\n\tlog.Infof(\" STAGE 1\")\n\n\ts.broker0.SetHandlerByMap(map[string]sarama.MockResponse{\n\t\t\"MetadataRequest\": sarama.NewMockMetadataResponse(c).\n\t\t\tSetBroker(s.broker0.Addr(), s.broker0.BrokerID()).\n\t\t\tSetLeader(\"my_topic\", 0, s.broker0.BrokerID()),\n\t\t\"OffsetRequest\": sarama.NewMockOffsetResponse(c).\n\t\t\tSetOffset(\"my_topic\", 0, sarama.OffsetOldest, 123).\n\t\t\tSetOffset(\"my_topic\", 0, sarama.OffsetNewest, 1000),\n\t\t\"FetchRequest\": sarama.NewMockFetchResponse(c, 1).\n\t\t\tSetMessage(\"my_topic\", 0, 123, testMsg),\n\t})\n\n\tsaramaCfg := s.cfg.SaramaClientCfg()\n\tsaramaCfg.Metadata.Retry.Max = 0\n\tkafkaClt, _ := sarama.NewClient([]string{s.broker0.Addr()}, saramaCfg)\n\tdefer kafkaClt.Close()\n\n\ts.cfg.Consumer.RetryBackoff = 200 * time.Millisecond\n\tf := SpawnFactory(s.ns, s.cfg, kafkaClt)\n\tdefer f.Stop()\n\n\tmf, _, err := f.Spawn(s.ns.NewChild(\"my_topic\", 0), \"my_topic\", 0, sarama.OffsetOldest)\n\tc.Assert(err, IsNil)\n\tdefer mf.Stop()\n\tc.Assert((<-mf.Messages()).Offset, Equals, int64(123))\n\n\t// Stage 2: broker0 says that it is no longer the leader for my_topic/0,\n\t// but the requests to retrieve metadata fail with network timeout.\n\tlog.Infof(\" STAGE 2\")\n\n\tfetchResponse2 := &sarama.FetchResponse{}\n\tfetchResponse2.AddError(\"my_topic\", 0, sarama.ErrNotLeaderForPartition)\n\n\ts.broker0.SetHandlerByMap(map[string]sarama.MockResponse{\n\t\t\"FetchRequest\": sarama.NewMockWrapper(fetchResponse2),\n\t})\n\n\tfor {\n\t\terr := errors.Cause(<-mf.(*msgFetcher).errorsCh)\n\t\tif err == errIncompleteResponse {\n\t\t\tcontinue\n\t\t}\n\t\tif err == sarama.ErrNotLeaderForPartition {\n\t\t\tbreak\n\t\t}\n\t\tc.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\t// Stage 3: finally the metadata returned by broker0 tells that broker1 is\n\t// a new leader for my_topic/0. Consumption resumes.\n\n\tlog.Infof(\" STAGE 3\")\n\n\tbroker1 := sarama.NewMockBroker(c, 101)\n\tdefer broker1.Close()\n\n\tbroker1.SetHandlerByMap(map[string]sarama.MockResponse{\n\t\t\"FetchRequest\": sarama.NewMockFetchResponse(c, 1).\n\t\t\tSetMessage(\"my_topic\", 0, 124, testMsg),\n\t})\n\ts.broker0.SetHandlerByMap(map[string]sarama.MockResponse{\n\t\t\"MetadataRequest\": sarama.NewMockMetadataResponse(c).\n\t\t\tSetBroker(s.broker0.Addr(), s.broker0.BrokerID()).\n\t\t\tSetBroker(broker1.Addr(), broker1.BrokerID()).\n\t\t\tSetLeader(\"my_topic\", 0, broker1.BrokerID()),\n\t})\n\n\tc.Assert((<-mf.Messages()).Offset, Equals, int64(124))\n}", "title": "" }, { "docid": "51137404771b2cf7fe1acd4ee03df1b6", "score": "0.45683402", "text": "func TestPollServiceInstanceSuccessOnFinalRetry(t *testing.T) {\n\tfakeKubeClient, fakeCatalogClient, fakeClusterServiceBrokerClient, testController, sharedInformers := newTestController(t, fakeosb.FakeClientConfiguration{\n\t\tPollLastOperationReaction: &fakeosb.PollLastOperationReaction{\n\t\t\tResponse: &osb.LastOperationResponse{\n\t\t\t\tState: osb.StateSucceeded,\n\t\t\t\tDescription: strPtr(lastOperationDescription),\n\t\t\t},\n\t\t},\n\t})\n\n\tsharedInformers.ClusterServiceBrokers().Informer().GetStore().Add(getTestClusterServiceBroker())\n\tsharedInformers.ClusterServiceClasses().Informer().GetStore().Add(getTestClusterServiceClass())\n\tsharedInformers.ClusterServicePlans().Informer().GetStore().Add(getTestClusterServicePlan())\n\n\tinstance := getTestServiceInstanceAsyncProvisioning(testOperation)\n\tinstanceKey := testNamespace + \"/\" + testServiceInstanceName\n\tstartTime := metav1.NewTime(time.Now().Add(-7 * 24 * time.Hour))\n\tinstance.Status.OperationStartTime = &startTime\n\n\tif testController.instancePollingQueue.NumRequeues(instanceKey) != 0 {\n\t\tt.Fatalf(\"Expected polling queue to not have any record of test instance\")\n\t}\n\n\tif err := testController.pollServiceInstance(instance); err != nil {\n\t\tt.Fatalf(\"pollServiceInstance failed: %s\", err)\n\t}\n\n\tif testController.instancePollingQueue.NumRequeues(instanceKey) != 0 {\n\t\tt.Fatalf(\"Expected polling queue to not have any record of test instance as polling should have completed\")\n\t}\n\n\tbrokerActions := fakeClusterServiceBrokerClient.Actions()\n\tassertNumberOfClusterServiceBrokerActions(t, brokerActions, 1)\n\toperationKey := osb.OperationKey(testOperation)\n\tassertPollLastOperation(t, brokerActions[0], &osb.LastOperationRequest{\n\t\tInstanceID: testServiceInstanceGUID,\n\t\tServiceID: strPtr(testClusterServiceClassGUID),\n\t\tPlanID: strPtr(testClusterServicePlanGUID),\n\t\tOperationKey: &operationKey,\n\t})\n\n\t// verify no kube resources created.\n\t// No actions\n\tkubeActions := fakeKubeClient.Actions()\n\tassertNumberOfActions(t, kubeActions, 0)\n\n\tactions := fakeCatalogClient.Actions()\n\tassertNumberOfActions(t, actions, 1)\n\n\tupdatedServiceInstance := assertUpdateStatus(t, actions[0], instance)\n\tassertServiceInstanceOperationSuccess(t, updatedServiceInstance, v1beta1.ServiceInstanceOperationProvision, testClusterServicePlanName, testClusterServicePlanGUID, instance)\n}", "title": "" }, { "docid": "f58ae7b6a40ac13b8ae7a5ea21308f09", "score": "0.4556904", "text": "func (r *QueueRetryManager) Retry(resource interface{}, err error) {\n\tid, _ := r.keyFunc(resource)\n\n\tif _, exists := r.retries[id]; !exists {\n\t\tr.retries[id] = Retry{0, unversioned.Now()}\n\t}\n\ttries := r.retries[id]\n\n\tif r.retryFunc(resource, err, tries) {\n\t\tr.limiter.Accept()\n\t\t// It's important to use AddIfNotPresent to prevent overwriting newer\n\t\t// state in the queue which may have arrived asynchronously.\n\t\tr.queue.AddIfNotPresent(resource)\n\t\ttries.Count = tries.Count + 1\n\t\tr.retries[id] = tries\n\t} else {\n\t\tr.Forget(resource)\n\t}\n}", "title": "" }, { "docid": "b0cb14c1fd4ae99d69cbfe7a4e59c7f9", "score": "0.45466876", "text": "func (tc *TxnCoordSender) maybeRetrySend(\n\tctx context.Context, ba *roachpb.BatchRequest, br *roachpb.BatchResponse, pErr *roachpb.Error,\n) (*roachpb.BatchResponse, *roachpb.Error) {\n\n\tif _, ok := pErr.GetDetail().(*roachpb.OpRequiresTxnError); ok {\n\t\treturn tc.resendWithTxn(ctx, *ba)\n\t}\n\n\t// With mixed success, we can't attempt a retry without potentially\n\t// succeeding at the same conditional put or increment request\n\t// twice; return the wrapped error instead. Because the dist sender\n\t// splits up batches to send to multiple ranges in parallel, and\n\t// then combines the results, partial success makes it very\n\t// difficult to determine what can be retried.\n\tif aPSErr, ok := pErr.GetDetail().(*roachpb.MixedSuccessError); ok {\n\t\tlog.VEventf(ctx, 2, \"got partial success; cannot retry %s (pErr=%s)\", ba, aPSErr.Wrapped)\n\t\treturn nil, aPSErr.Wrapped\n\t}\n\n\t// Check for an error which can be retried after updating spans.\n\t//\n\t// Note that we can only restart on root transactions because those are the\n\t// only places where we have all of the refresh spans. If this is a leaf, as\n\t// in a distributed sql flow, we need to propagate the error to the root for\n\t// an epoch restart.\n\tcanRetry, retryTxn := roachpb.CanTransactionRetryAtRefreshedTimestamp(ctx, pErr)\n\tif !canRetry || tc.typ == client.LeafTxn ||\n\t\t!tc.st.Version.IsMinSupported(cluster.VersionTxnSpanRefresh) {\n\t\treturn nil, pErr\n\t}\n\n\t// If a prefix of the batch was executed, collect refresh spans for\n\t// that executed portion, and retry the remainder. The canonical\n\t// case is a batch split between everything up to but not including\n\t// the EndTransaction. Requests up to the EndTransaction succeed,\n\t// but the EndTransaction fails with a retryable error. We want to\n\t// retry only the EndTransaction.\n\tba.UpdateTxn(retryTxn)\n\tretryBa := *ba\n\tif br != nil {\n\t\tdoneBa := *ba\n\t\tdoneBa.Requests = ba.Requests[:len(br.Responses)]\n\t\tlog.VEventf(ctx, 2, \"collecting refresh spans after partial batch execution of %s\", doneBa)\n\t\ttc.mu.Lock()\n\t\tif !tc.appendRefreshSpansLocked(ctx, doneBa, br) {\n\t\t\ttc.mu.Unlock()\n\t\t\treturn nil, pErr\n\t\t}\n\t\ttc.mu.meta.Txn.RefreshedTimestamp.Forward(retryTxn.RefreshedTimestamp)\n\t\ttc.mu.Unlock()\n\t\tretryBa.Requests = ba.Requests[len(br.Responses):]\n\t}\n\n\tlog.VEventf(ctx, 2, \"retrying %s at refreshed timestamp %s because of %s\",\n\t\tretryBa, retryTxn.RefreshedTimestamp, pErr)\n\n\t// Try updating the txn spans so we can retry.\n\tif ok := tc.tryUpdatingTxnSpans(ctx, retryTxn); !ok {\n\t\treturn nil, pErr\n\t}\n\n\t// We've refreshed all of the read spans successfully and set\n\t// newBa.Txn.RefreshedTimestamp to the current timestamp. Submit the\n\t// batch again.\n\tretryBr, retryErr := tc.wrapped.Send(ctx, retryBa)\n\tif retryErr != nil {\n\t\tlog.VEventf(ctx, 2, \"retry failed with %s\", retryErr)\n\t\treturn nil, retryErr\n\t}\n\tlog.VEventf(ctx, 2, \"retry successful @%s\", retryBa.Txn.Timestamp)\n\n\t// On success, combine responses if applicable and set error to nil.\n\tif br != nil {\n\t\tbr.Responses = append(br.Responses, retryBr.Responses...)\n\t\tretryBr.CollectedSpans = append(br.CollectedSpans, retryBr.CollectedSpans...)\n\t\tbr.BatchResponse_Header = retryBr.BatchResponse_Header\n\t} else {\n\t\tbr = retryBr\n\t}\n\n\ttc.metrics.AutoRetries.Inc(1)\n\n\treturn br, nil\n}", "title": "" }, { "docid": "ca106abf50e26187858efebef91a33c2", "score": "0.45463413", "text": "func (ps *PubSub) receiveWithRetry(parentCtx context.Context) {\n\terr := ps.startReceiver(parentCtx)\n\n\tfor err != nil && parentCtx.Err() == nil {\n\t\tps.Log.Errorf(\"Receiver for subscription %s exited with error: %v\", ps.sub.ID(), err)\n\n\t\tdelay := defaultRetryDelaySeconds\n\t\tif ps.RetryReceiveDelaySeconds > 0 {\n\t\t\tdelay = ps.RetryReceiveDelaySeconds\n\t\t}\n\n\t\tps.Log.Infof(\"Waiting %d seconds before attempting to restart receiver...\", delay)\n\t\ttime.Sleep(time.Duration(delay) * time.Second)\n\n\t\terr = ps.startReceiver(parentCtx)\n\t}\n}", "title": "" }, { "docid": "5cdd69616d0fb70a2c516643875e2fdf", "score": "0.4545662", "text": "func (w *goaWrapper) Retry(ctx context.Context, payload *goacollection.RetryPayload) error {\n\tvar err error\n\tvar goacol *goacollection.EnduroStoredCollection\n\tif goacol, err = w.Show(ctx, &goacollection.ShowPayload{ID: payload.ID}); err != nil {\n\t\treturn err\n\t}\n\n\texecution := &shared.WorkflowExecution{\n\t\tWorkflowId: goacol.WorkflowID,\n\t\tRunId: goacol.RunID,\n\t}\n\n\thistoryEvent, err := cadence.FirstHistoryEvent(ctx, w.cc, execution)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error loading history of the previous workflow run: %w\", err)\n\t}\n\n\tif historyEvent.GetEventType() != shared.EventTypeWorkflowExecutionStarted {\n\t\treturn fmt.Errorf(\"error loading history of the previous workflow run: initiator state not found\")\n\t}\n\n\tvar input = historyEvent.WorkflowExecutionStartedEventAttributes.Input\n\tvar attrs = bytes.Split(input, []byte(\"\\n\"))\n\tvar req = &ProcessingWorkflowRequest{}\n\n\tif err := json.Unmarshal(attrs[0], req); err != nil {\n\t\treturn fmt.Errorf(\"error loading state of the previous workflow run: %w\", err)\n\t}\n\n\treq.WorkflowID = *goacol.WorkflowID\n\treq.CollectionID = goacol.ID\n\tif err := TriggerProcessingWorkflow(ctx, w.cc, req); err != nil {\n\t\treturn fmt.Errorf(\"error triggering the new workflow instance: %w\", err)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "5cdd69616d0fb70a2c516643875e2fdf", "score": "0.4545662", "text": "func (w *goaWrapper) Retry(ctx context.Context, payload *goacollection.RetryPayload) error {\n\tvar err error\n\tvar goacol *goacollection.EnduroStoredCollection\n\tif goacol, err = w.Show(ctx, &goacollection.ShowPayload{ID: payload.ID}); err != nil {\n\t\treturn err\n\t}\n\n\texecution := &shared.WorkflowExecution{\n\t\tWorkflowId: goacol.WorkflowID,\n\t\tRunId: goacol.RunID,\n\t}\n\n\thistoryEvent, err := cadence.FirstHistoryEvent(ctx, w.cc, execution)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error loading history of the previous workflow run: %w\", err)\n\t}\n\n\tif historyEvent.GetEventType() != shared.EventTypeWorkflowExecutionStarted {\n\t\treturn fmt.Errorf(\"error loading history of the previous workflow run: initiator state not found\")\n\t}\n\n\tvar input = historyEvent.WorkflowExecutionStartedEventAttributes.Input\n\tvar attrs = bytes.Split(input, []byte(\"\\n\"))\n\tvar req = &ProcessingWorkflowRequest{}\n\n\tif err := json.Unmarshal(attrs[0], req); err != nil {\n\t\treturn fmt.Errorf(\"error loading state of the previous workflow run: %w\", err)\n\t}\n\n\treq.WorkflowID = *goacol.WorkflowID\n\treq.CollectionID = goacol.ID\n\tif err := TriggerProcessingWorkflow(ctx, w.cc, req); err != nil {\n\t\treturn fmt.Errorf(\"error triggering the new workflow instance: %w\", err)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "edc28b2228177c4a48bb4e2009f9080a", "score": "0.45424598", "text": "func brokerWorker(brokerChan <-chan int, collectedTopics []string, wg *sync.WaitGroup, zkConn zookeeper.Connection, i *integration.Integration) {\n\tdefer wg.Done()\n\n\tfor {\n\t\t// Collect broker ID from channel.\n\t\t// Exit worker if channel has been closed and no more brokerIDs can be collected.\n\t\tbrokerID, ok := <-brokerChan\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\n\t\t// Create Broker\n\t\tbrokers, err := createBrokerConnectionVariants(brokerID, zkConn, i)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tfor _, broker := range brokers {\n\t\t\t// Populate inventory for broker\n\t\t\tif args.GlobalArgs.All() || args.GlobalArgs.Inventory {\n\t\t\t\tlog.Debug(\"Collecting inventory for broker %s\", broker.Entity.Metadata.Name)\n\t\t\t\tif err := populateBrokerInventory(broker); err != nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tlog.Debug(\"Done Collecting inventory for broker %s\", broker.Entity.Metadata.Name)\n\t\t\t}\n\n\t\t\t// Populate metrics for broker\n\t\t\tif args.GlobalArgs.All() || args.GlobalArgs.Metrics {\n\t\t\t\tlog.Debug(\"Collecting metrics for broker %s\", broker.Entity.Metadata.Name)\n\t\t\t\tif err := collectBrokerMetrics(broker, collectedTopics); err != nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tlog.Debug(\"Done Collecting metrics for broker %s\", broker.Entity.Metadata.Name)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n}", "title": "" }, { "docid": "4b37989b93a985c464a6fceda2ca1d14", "score": "0.45417142", "text": "func (m *Messenger) getFallbackRequester(reqT infra.MessageType) *pathingRequester {\n\tsigner := m.getSigner(reqT)\n\tvar quicRequester *QUICRequester\n\tif m.config.QUIC != nil {\n\t\tquicRequester = m.getQUICRequester(signer)\n\t}\n\treturn &pathingRequester{\n\t\trequester: ctrl_msg.NewRequester(signer, m.verifier, m.dispatcher),\n\t\taddressRewriter: m.addressRewriter,\n\t\tquicRequester: quicRequester,\n\t}\n}", "title": "" }, { "docid": "2500453b4126ae6ffe647c7b85bea3d6", "score": "0.45403785", "text": "func (t *Transitive) issueRepoll() {\n\tpreferredIDs := t.Consensus.Preferences().List()\n\tnumPreferredIDs := len(preferredIDs)\n\tif numPreferredIDs == 0 {\n\t\tt.Ctx.Log.Error(\"re-query attempt was dropped due to no pending vertices\")\n\t\treturn\n\t}\n\n\ts := sampler.NewUniform()\n\tif err := s.Initialize(uint64(numPreferredIDs)); err != nil {\n\t\treturn // Should never really happen\n\t}\n\tindices, err := s.Sample(1)\n\tif err != nil {\n\t\treturn // Also should never really happen because the edge has positive length\n\t}\n\tvtxID := preferredIDs[int(indices[0])] // ID of a preferred vertex\n\n\tvdrs, err := t.Validators.Sample(t.Params.K) // Validators to sample\n\tvdrBag := ids.ShortBag{} // IDs of validators to be sampled\n\tfor _, vdr := range vdrs {\n\t\tvdrBag.Add(vdr.ID())\n\t}\n\n\tvdrSet := ids.ShortSet{}\n\tvdrSet.Add(vdrBag.List()...)\n\n\t// Poll the network\n\tt.RequestID++\n\tif err == nil && t.polls.Add(t.RequestID, vdrBag) {\n\t\tt.Sender.PullQuery(vdrSet, t.RequestID, vtxID)\n\t} else if err != nil {\n\t\tt.Ctx.Log.Error(\"re-query for %s was dropped due to an insufficient number of validators\", vtxID)\n\t}\n}", "title": "" }, { "docid": "28725c6dfccb669318114b7f134ae387", "score": "0.45262495", "text": "func (r *ReconcileAMQBroker) Reconcile(request reconcile.Request) (reconcile.Result, error) {\n\n\t// Log where we are and what we're doing\n\treqLogger := log.WithValues(\"Request.Namespace\", request.Namespace, \"Request.Name\", request.Name)\n\treqLogger.Info(\"Reconciling AMQBroker\")\n\n\tvar err error = nil\n\tvar reconcileResult reconcile.Result\n\tvar namespacedNameFSM *AMQBrokerFSM = nil\n\tvar amqbfsm *AMQBrokerFSM = nil\n\n\tinstance := &brokerv1alpha1.AMQBroker{}\n\tnamespacedName := types.NamespacedName{\n\t\tName: request.Name,//\"example-amqbroker\",\n\t\tNamespace: request.Namespace,//\"abo-1\",\n\t}\n\n\t// Fetch the AMQBroker instance\n\t// When first creating this will have err == nil\n\t// When deleting after creation this will have err NotFound\n\t// When deleting before creation reconcile won't be called\n\tif err = r.client.Get(context.TODO(), request.NamespacedName, instance); err != nil {\n\n\t\tif errors.IsNotFound(err) {\n\t\t\treqLogger.Error(err, \"AMQBroker Controller Reconcile encountered a IsNotFound, checking to see if we should delete namespacedName tracking\", \"request.Namespace\", request.Namespace, \"request.Name\", request.Name)\n\n\t\t\treconcileResult = reconcile.Result{}\n\n\t\t\t// See if we have been tracking this NamespacedName\n\t\t\tif namespacedNameFSM = namespacedNameToFSM[namespacedName]; namespacedNameFSM != nil {\n\t\t\t\treqLogger.Error(err, \"Removing namespacedName tracking\", \"request.Namespace\", request.Namespace, \"request.Name\", request.Name)\n\t\t\t\t// If so we should no longer track it\n\t\t\t\t//namespacedNameToFSM[namespacedName] = nil\n\t\t\t\tamqbfsm = namespacedNameToFSM[namespacedName]\n\t\t\t\tamqbfsm.Exit(nil)\n\t\t\t\tdelete(namespacedNameToFSM, namespacedName)\n\t\t\t\tamqbfsm = nil\n\t\t\t}\n\n\t\t\t// Setting err to nil to prevent requeue\n\t\t\terr = nil\n\t\t} else {\n\t\t\treqLogger.Error(err, \"AMQBroker Controller Reconcile errored thats not IsNotFound, requeuing request\", \"Request Namespace\", request.Namespace, \"Request Name\", request.Name)\n\t\t\t// Leaving err as !nil causes requeue\n\t\t}\n\n\t\t// Add error detail for use later\n\t\treturn reconcileResult, err\n\t}\n\n\t// Do lookup to see if we have a fsm for the incoming name in the incoming namespace\n\t// if not, create it\n\t// for the given fsm, do an update\n\t// - update first level sets? what if the operator has gone away and come back? stateless?\n\tif namespacedNameFSM = namespacedNameToFSM[namespacedName]; namespacedNameFSM == nil {\n\t\tamqbfsm = NewAMQBrokerFSM(instance, namespacedName, r)\n\t\tnamespacedNameFSM = amqbfsm\n\t\tnamespacedNameToFSM[namespacedName] = namespacedNameFSM\n\n\t\tamqbfsm.Enter(nil)\n\t}\n\n\t//namespacedNameFSM.Update(request, r)\n\n\t// Set it up\n\t//var err error = nil\n\t//var reconcileResult reconcile.Result\n\t//instance := &brokerv1alpha1.AMQBroker{}\n\t//found := &corev1.Pod{}\n\t//\n\t//// Do what's needed\n\t//for {\n\t//\t// Fetch the AMQBroker instance\n\t//\tif err = r.client.Get(context.TODO(), request.NamespacedName, instance); err != nil {\n\t//\t\t// Add error detail for use later\n\t//\t\tbreak\n\t//\t}\n\t//\n\t//\t// Check if this Pod already exists\n\t//\tif err = r.client.Get(context.TODO(), namespacedName, found); err == nil {\n\t//\t\t// Don't do anything as the pod exists\n\t//\t\tbreak\n\t//\t}\n\t//\n\t//\t// Define the PersistentVolumeClaim for this Pod\n\t//\tbrokerPvc := newPersistentVolumeClaimForCR(instance)\n\t//\t// Set AMQBroker instance as the owner and controller\n\t//\tif err = controllerutil.SetControllerReference(instance, brokerPvc, r.scheme); err != nil {\n\t//\t\t// Add error detail for use later\n\t//\t\tbreak\n\t//\t}\n\t//\n\t//\t// Call k8s create for service\n\t//\tif err = r.client.Create(context.TODO(), brokerPvc); err != nil {\n\t//\t\t// Add error detail for use later\n\t//\t\tbreak\n\t//\t}\n\t//\n\t//\t// Define the console-jolokia Service for this Pod\n\t//\tconsoleJolokiaSvc := newServiceForCR(instance, \"console-jolokia\", 8161)\n\t//\t// Set AMQBroker instance as the owner and controller\n\t//\tif err = controllerutil.SetControllerReference(instance, consoleJolokiaSvc, r.scheme); err != nil {\n\t//\t\t// Add error detail for use later\n\t//\t\tbreak\n\t//\t}\n\t//\t// Call k8s create for service\n\t//\tif err = r.client.Create(context.TODO(), consoleJolokiaSvc); err != nil {\n\t//\t\t// Add error detail for use later\n\t//\t\tbreak\n\t//\t}\n\t//\n\t//\t// Define the console-jolokia Service for this Pod\n\t//\tmuxProtocolSvc := newServiceForCR(instance, \"mux-protocol\", 61616)\n\t//\t// Set AMQBroker instance as the owner and controller\n\t//\tif err = controllerutil.SetControllerReference(instance, muxProtocolSvc, r.scheme); err != nil {\n\t//\t\t// Add error detail for use later\n\t//\t\tbreak\n\t//\t}\n\t//\t// Call k8s create for service\n\t//\tif err = r.client.Create(context.TODO(), muxProtocolSvc); err != nil {\n\t//\t\t// Add error detail for use later\n\t//\t\tbreak\n\t//\t}\n\t//\n\t//\t// Define the headless Service for the StatefulSet\n\t//\t//headlessSvc := newHeadlessServiceForCR(instance, 5672)\n\t//\theadlessSvc := newHeadlessServiceForCR(instance, getDefaultPorts())\n\t//\t// Set AMQBroker instance as the owner and controller\n\t//\tif err = controllerutil.SetControllerReference(instance, headlessSvc, r.scheme); err != nil {\n\t//\t\t// Add error detail for use later\n\t//\t\tbreak\n\t//\t}\n\t//\t// Call k8s create for service\n\t//\tif err = r.client.Create(context.TODO(), headlessSvc); err != nil {\n\t//\t\t// Add error detail for use later\n\t//\t\tbreak\n\t//\t}\n\t//\n\t//\n\t//\t//// Pod didn't exist, create\n\t//\t//// Define a new Pod object\n\t//\t//pod := newPodForCR(instance)\n\t//\t//// Set AMQBroker instance as the owner and controller\n\t//\t//if err = controllerutil.SetControllerReference(instance, pod, r.scheme); err != nil {\n\t//\t//\t// Add error detail for use later\n\t//\t//\tbreak\n\t//\t//}\n\t//\t//// Was able to set the owner and controller, call k8s create for pod\n\t//\t//if err = r.client.Create(context.TODO(), pod); err != nil {\n\t//\t//\t// Add error detail for use later\n\t//\t//\tbreak\n\t//\t//}\n\t//\n\t//\t// Statefulset didn't exist, create\n\t//\t// Define a new Pod object\n\t//\tss := newStatefulSetForCR(instance)\n\t//\t// Set AMQBroker instance as the owner and controller\n\t//\tif err = controllerutil.SetControllerReference(instance, ss, r.scheme); err != nil {\n\t//\t\t// Add error detail for use later\n\t//\t\tbreak\n\t//\t}\n\t//\t// Was able to set the owner and controller, call k8s create for pod\n\t//\tif err = r.client.Create(context.TODO(), ss); err != nil {\n\t//\t\t// Add error detail for use later\n\t//\t\tbreak\n\t//\t}\n\t//\n\t//\n\t//\t// Pod created successfully - don't requeue\n\t//\t// Probably redundant\n\t//\terr = nil\n\t//\n\t//\n\t//\tbreak\n\t//}\n\t//\n\t//// Handle error, if any\n\t//if err != nil {\n\t//\tif errors.IsNotFound(err) {\n\t//\t\treconcileResult = reconcile.Result{}\n\t//\t\treqLogger.Error(err, \"AMQBroker Controller Reconcile encountered a IsNotFound, preventing request requeue\", \"Pod.Namespace\", request.Namespace, \"Pod.Name\", request.Name)\n\t//\t\t// Setting err to nil to prevent requeue\n\t//\t\terr = nil\n\t//\t} else {\n\t//\t\t//log.Error(err, \"AMQBroker Controller Reconcile errored\")\n\t//\t\treqLogger.Error(err, \"AMQBroker Controller Reconcile errored, requeuing request\", \"Pod.Namespace\", request.Namespace, \"Pod.Name\", request.Name)\n\t//\t}\n\t//}\n\n\t// Single exit, return the result and error condition\n\treturn reconcileResult, err\n}", "title": "" }, { "docid": "ff7cd46a9463f0a0bbacb31e255e211d", "score": "0.45255986", "text": "func retry(maxElapsedTime time.Duration, f func() error, n func(error, time.Duration)) error {\n\tbo := backoff.NewExponentialBackOff()\n\tbo.MaxElapsedTime = maxElapsedTime\n\tbo.InitialInterval = 2 * time.Second\n\tbo.Reset()\n\treturn backoff.RetryNotify(f, bo, n)\n\n}", "title": "" }, { "docid": "1d7a9980a0fc1866faa70676657c5ee4", "score": "0.45249194", "text": "func (m *AppchainMonitor) recovery() error {\n\tmeta, err := m.client.GetOutMeta()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get out meta from broker contract :%w\", err)\n\t}\n\tfor addr, index := range meta {\n\t\tbeginIndex, ok := m.meta.InterchainCounter[addr]\n\t\tif !ok {\n\t\t\tbeginIndex = 0\n\t\t}\n\n\t\tif err = m.handleMissingIBTP(addr, beginIndex+1, index+1); err != nil {\n\t\t\tlogger.WithFields(logrus.Fields{\n\t\t\t\t\"address\": addr,\n\t\t\t\t\"error\": err.Error(),\n\t\t\t}).Error(\"Handle missing ibtp\")\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "ee1d6097eee3fb2faf1290b7e25029bd", "score": "0.45239437", "text": "func TestCheckForUpgradesScheduler(t *testing.T) {\n\tfakeClient := setupFakeClientWithPGOScheme(t, false)\n\t_, server := setupVersionServer(t, true)\n\tdefer server.Close()\n\tcfg := &rest.Config{Host: server.URL}\n\tconst testUpgradeCheckURL = \"http://localhost:8080\"\n\n\tt.Run(\"panic from checkForUpgrades doesn't bubble up\", func(t *testing.T) {\n\t\tctx, cancel := context.WithCancel(context.Background())\n\t\tdefer cancel()\n\n\t\t// capture logs\n\t\tvar calls []string\n\t\tctx = logging.NewContext(ctx, genericr.New(func(input genericr.Entry) {\n\t\t\tcalls = append(calls, input.Message)\n\t\t}))\n\n\t\t// A panicking call\n\t\tfuncFoo = func() (*http.Response, error) {\n\t\t\tpanic(fmt.Errorf(\"oh no!\"))\n\t\t}\n\n\t\tgo CheckForUpgradesScheduler(ctx, \"4.7.3\", testUpgradeCheckURL, fakeClient, cfg, false,\n\t\t\t&MockCacheClient{works: true})\n\t\ttime.Sleep(1 * time.Second)\n\t\tcancel()\n\n\t\t// Sleeping leads to some non-deterministic results, but we expect at least 1 execution\n\t\t// plus one log for the failure to apply the configmap\n\t\tassert.Assert(t, len(calls) >= 2)\n\t\tassert.Equal(t, calls[1], `could not complete upgrade check`)\n\t})\n\n\tt.Run(\"cache sync fail leads to log and exit\", func(t *testing.T) {\n\t\tctx, cancel := context.WithCancel(context.Background())\n\t\tdefer cancel()\n\n\t\t// capture logs\n\t\tvar calls []string\n\t\tctx = logging.NewContext(ctx, genericr.New(func(input genericr.Entry) {\n\t\t\tcalls = append(calls, input.Message)\n\t\t}))\n\n\t\t// Set loop time to 1s and sleep for 2s before sending the done signal -- though the cache sync\n\t\t// failure will exit the func before the sleep ends\n\t\tupgradeCheckPeriod = 1 * time.Second\n\t\tgo CheckForUpgradesScheduler(ctx, \"4.7.3\", testUpgradeCheckURL, fakeClient, cfg, false,\n\t\t\t&MockCacheClient{works: false})\n\t\ttime.Sleep(2 * time.Second)\n\t\tcancel()\n\n\t\tassert.Assert(t, len(calls) == 1)\n\t\tassert.Equal(t, calls[0], `unable to sync cache for upgrade check`)\n\t})\n\n\tt.Run(\"successful log each loop, ticker works\", func(t *testing.T) {\n\t\tctx, cancel := context.WithCancel(context.Background())\n\t\tdefer cancel()\n\n\t\t// capture logs\n\t\tvar calls []string\n\t\tctx = logging.NewContext(ctx, genericr.New(func(input genericr.Entry) {\n\t\t\tcalls = append(calls, input.Message)\n\t\t}))\n\n\t\t// A successful call\n\t\tfuncFoo = func() (*http.Response, error) {\n\t\t\tjson := `{\"pgo_versions\":[{\"tag\":\"v5.0.4\"},{\"tag\":\"v5.0.3\"},{\"tag\":\"v5.0.2\"},{\"tag\":\"v5.0.1\"},{\"tag\":\"v5.0.0\"}]}`\n\t\t\treturn &http.Response{\n\t\t\t\tBody: io.NopCloser(strings.NewReader(json)),\n\t\t\t\tStatusCode: http.StatusOK,\n\t\t\t}, nil\n\t\t}\n\n\t\t// Set loop time to 1s and sleep for 2s before sending the done signal\n\t\tupgradeCheckPeriod = 1 * time.Second\n\t\tgo CheckForUpgradesScheduler(ctx, \"4.7.3\", testUpgradeCheckURL, fakeClient, cfg, false,\n\t\t\t&MockCacheClient{works: true})\n\t\ttime.Sleep(2 * time.Second)\n\t\tcancel()\n\n\t\t// Sleeping leads to some non-deterministic results, but we expect at least 2 executions\n\t\t// plus one log for the failure to apply the configmap\n\t\tassert.Assert(t, len(calls) >= 4)\n\t\tassert.Equal(t, calls[1], `{\"pgo_versions\":[{\"tag\":\"v5.0.4\"},{\"tag\":\"v5.0.3\"},{\"tag\":\"v5.0.2\"},{\"tag\":\"v5.0.1\"},{\"tag\":\"v5.0.0\"}]}`)\n\t\tassert.Equal(t, calls[3], `{\"pgo_versions\":[{\"tag\":\"v5.0.4\"},{\"tag\":\"v5.0.3\"},{\"tag\":\"v5.0.2\"},{\"tag\":\"v5.0.1\"},{\"tag\":\"v5.0.0\"}]}`)\n\t})\n}", "title": "" }, { "docid": "88ca0b9ab70db281acb060c420ee75a8", "score": "0.45203832", "text": "func (provider *Eureka) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool, _ []types.Constraint) error {\n\n\toperation := func() error {\n\t\tconfiguration, err := provider.buildConfiguration()\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Failed to build configuration for Eureka, error: %s\", err)\n\t\t\treturn err\n\t\t}\n\n\t\tconfigurationChan <- types.ConfigMessage{\n\t\t\tProviderName: \"eureka\",\n\t\t\tConfiguration: configuration,\n\t\t}\n\n\t\tvar delay time.Duration\n\t\tif len(provider.Delay) > 0 {\n\t\t\tvar err error\n\t\t\tdelay, err = time.ParseDuration(provider.Delay)\n\t\t\tif err != nil {\n\t\t\t\tlog.Errorf(\"Failed to parse delay for Eureka, error: %s\", err)\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\tdelay = time.Second * 30\n\t\t}\n\n\t\tticker := time.NewTicker(delay)\n\t\tgo func() {\n\t\t\tfor t := range ticker.C {\n\n\t\t\t\tlog.Debug(\"Refreshing Eureka \" + t.String())\n\n\t\t\t\tconfiguration, err := provider.buildConfiguration()\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Errorf(\"Failed to refresh Eureka configuration, error: %s\", err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconfigurationChan <- types.ConfigMessage{\n\t\t\t\t\tProviderName: \"eureka\",\n\t\t\t\t\tConfiguration: configuration,\n\t\t\t\t}\n\t\t\t}\n\t\t}()\n\t\treturn nil\n\t}\n\n\tnotify := func(err error, time time.Duration) {\n\t\tlog.Errorf(\"Eureka connection error %+v, retrying in %s\", err, time)\n\t}\n\terr := backoff.RetryNotify(operation, job.NewBackOff(backoff.NewExponentialBackOff()), notify)\n\tif err != nil {\n\t\tlog.Errorf(\"Cannot connect to Eureka server %+v\", err)\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "e301e11ec97f0e9ee3925ff4cb542a57", "score": "0.45116177", "text": "func Retry(work func(), times int) {\n\tdefer func() {\n\t\terr := recover()\n\t\tif err == nil || times <= 1 {\n\t\t\treturn\n\t\t}\n\n\t\ttimes--\n\t\tRetry(work, times)\n\t}()\n\n\t// fmt.Println(\"Retring\", times)\n\twork()\n}", "title": "" }, { "docid": "1cf3becb46637e144bbf2421911e3d63", "score": "0.45097682", "text": "func (r *AgentConfigReconciler) retry(ctx context.Context, log logr.Logger, agentCfg *porterv1.AgentConfigAdapter, action *porterv1.AgentAction) error {\n\tlog.V(Log5Trace).Info(\"Initializing agent config status\")\n\tagentCfg.Status.Initialize()\n\tagentCfg.Status.Action = &corev1.LocalObjectReference{Name: action.Name}\n\tagentCfg.Status.Ready = false\n\tif err := r.saveStatus(ctx, log, agentCfg); err != nil {\n\t\treturn err\n\t}\n\tlog.V(Log5Trace).Info(\"Retrying associated porter agent action\")\n\tretry := agentCfg.GetRetryLabelValue()\n\taction.SetRetryAnnotation(retry)\n\tif err := r.Update(ctx, action); err != nil {\n\t\treturn errors.Wrap(err, \"error updating the associated porter agent action\")\n\t}\n\n\tlog.V(Log4Debug).Info(\"Retried associated porter agent action\", \"name\", \"retry\", action.Name, retry)\n\treturn nil\n}", "title": "" }, { "docid": "cbea731727bdbca23f84fbc62becd960", "score": "0.4506045", "text": "func (c *client) resolve(act Action, rf requestFunc, cancel <-chan struct{}) (*Result, error) {\n\trequests := func() (res *Result, err error) {\n\t\tfor eIndex := 0; eIndex < len(c.endpoints); eIndex++ {\n\t\t\tendpoint := c.endpoints[eIndex]\n\t\t\tar := newActionResolver(act, &endpoint, rf)\n\t\t\tres, err = ar.Resolve(cancel)\n\t\t\tif res != nil || err != nil {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tselect {\n\t\t\tcase <-cancel:\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t}\n\t\t}\n\n\t\treturn\n\t}\n\n\tbackoff := func(fn func() (*Result, error)) (res *Result, err error) {\n\t\tsleep := 100 * time.Millisecond\n\t\tfor {\n\t\t\tres, err = fn()\n\t\t\tif res != nil || err != nil {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tselect {\n\t\t\tcase <-cancel:\n\t\t\t\treturn nil, errors.New(\"cancelled\")\n\t\t\tdefault:\n\t\t\t}\n\n\t\t\tlog.Errorf(\"Unable to get result for %v, retrying in %v\", act, sleep)\n\n\t\t\tselect {\n\t\t\tcase <-cancel:\n\t\t\t\treturn nil, errors.New(\"cancelled\")\n\t\t\tcase <-time.After(sleep):\n\t\t\t}\n\n\t\t\tsleep = sleep * 2\n\t\t\tif sleep > time.Second {\n\t\t\t\tsleep = time.Second\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\n\treturn backoff(requests)\n}", "title": "" }, { "docid": "825b81fe371d6f4c6d308a91d62b281b", "score": "0.4497772", "text": "func TestPollServiceInstanceFailureProvisioningWithOperationNamespacedRefs(t *testing.T) {\n\terr := utilfeature.DefaultMutableFeatureGate.Set(fmt.Sprintf(\"%v=true\", scfeatures.NamespacedServiceBroker))\n\tif err != nil {\n\t\tt.Fatalf(\"Could not enable NamespacedServiceBroker feature flag.\")\n\t}\n\tdefer utilfeature.DefaultMutableFeatureGate.Set(fmt.Sprintf(\"%v=false\", scfeatures.NamespacedServiceBroker))\n\n\tfakeKubeClient, fakeCatalogClient, fakeBrokerClient, testController, sharedInformers := newTestController(t, fakeosb.FakeClientConfiguration{\n\t\tPollLastOperationReaction: &fakeosb.PollLastOperationReaction{\n\t\t\tResponse: &osb.LastOperationResponse{\n\t\t\t\tState: osb.StateFailed,\n\t\t\t},\n\t\t},\n\t})\n\n\tsharedInformers.ServiceBrokers().Informer().GetStore().Add(getTestServiceBroker())\n\tsharedInformers.ServiceClasses().Informer().GetStore().Add(getTestServiceClass())\n\tsharedInformers.ServicePlans().Informer().GetStore().Add(getTestServicePlan())\n\n\tinstance := getTestServiceInstanceAsyncProvisioningWithNamespacedRefs(testOperation)\n\tinstanceKey := testNamespace + \"/\" + testServiceInstanceName\n\n\tif testController.instancePollingQueue.NumRequeues(instanceKey) != 0 {\n\t\tt.Fatalf(\"Expected polling queue to not have any record of test instance\")\n\t}\n\n\terr = testController.pollServiceInstance(instance)\n\tif err != nil {\n\t\tt.Fatalf(\"pollServiceInstance failed: %s\", err)\n\t}\n\n\tif testController.instancePollingQueue.NumRequeues(instanceKey) == 0 {\n\t\tt.Fatalf(\"Expected polling queue to have a record of test instance to process orphan mitigation\")\n\t}\n\n\tbrokerActions := fakeBrokerClient.Actions()\n\tassertNumberOfBrokerActions(t, brokerActions, 1)\n\toperationKey := osb.OperationKey(testOperation)\n\tassertPollLastOperation(t, brokerActions[0], &osb.LastOperationRequest{\n\t\tInstanceID: testServiceInstanceGUID,\n\t\tServiceID: strPtr(testServiceClassGUID),\n\t\tPlanID: strPtr(testServicePlanGUID),\n\t\tOperationKey: &operationKey,\n\t})\n\n\t// verify no kube resources created.\n\t// No actions\n\tkubeActions := fakeKubeClient.Actions()\n\tassertNumberOfActions(t, kubeActions, 0)\n\n\tactions := fakeCatalogClient.Actions()\n\tassertNumberOfActions(t, actions, 1)\n\n\tupdatedServiceInstance := assertUpdateStatus(t, actions[0], instance)\n\tassertServiceInstanceRequestFailingErrorStartOrphanMitigation(\n\t\tt,\n\t\tupdatedServiceInstance,\n\t\tv1beta1.ServiceInstanceOperationProvision,\n\t\tstartingInstanceOrphanMitigationReason,\n\t\terrorProvisionCallFailedReason,\n\t\terrorProvisionCallFailedReason,\n\t\tinstance,\n\t)\n}", "title": "" }, { "docid": "d77fa0a1b733ba028ff126dcef3f145e", "score": "0.4497055", "text": "func (handler *Handler) connectIfNecessary() error {\n\tmqttClient := handler.mqttClient\n\tif mqttClient.IsConnected() {\n\t\treturn nil\n\t}\n\n\ttoken := mqttClient.Connect()\n\ttoken.Wait()\n\treturn token.Error()\n}", "title": "" }, { "docid": "bf564e4a97d7b2405fe4fc0ed2e10ef3", "score": "0.4495967", "text": "func (_global *global) addBroker(brok string) *broker {\n\t_global.Lock()\n\tdefer _global.Unlock()\n\n\t_broker := _global.mapConn[brok]\n\tif _broker == nil {\n\t\tchQuit := make(chan struct{})\n\t\tchMsg := make(chan mqtt.Message)\n\n\t\topts := mqtt.NewClientOptions()\n\t\topts.SetAutoReconnect(true)\n\t\topts.AddBroker(brok)\n\t\topts.SetDefaultPublishHandler(func(client mqtt.Client, msg mqtt.Message) {\n\t\t\tchMsg <- msg\n\t\t})\n\t\tclient := mqtt.NewClient(opts)\n\n\t\t_broker = &broker{\n\t\t\tclient: client,\n\t\t\tmapTopic: make(map[string]*struct{}),\n\t\t\tchQuit: chQuit,\n\t\t\tchMsg: chMsg,\n\t\t}\n\t\t_global.mapConn[brok] = _broker\n\t}\n\n\treturn _broker\n}", "title": "" }, { "docid": "09f5ca52cb82d1e12c24775376cfaf4d", "score": "0.4495193", "text": "func TestConnPool_getConn_Resolver(t *testing.T) {\n\t// launch 3 node cluster with Resolver set\n\tc := newCluster(t)\n\tc.opt.Resolver = c\n\tldr, flrs := c.ensureLaunch(3)\n\tdefer c.shutdown()\n\n\t// stop one of follower\n\tc.shutdown(flrs[0])\n\n\t// wait for leader to detect that follower is unreachable\n\t_ = c.waitUnreachableDetected(ldr, flrs[0])\n\n\t// restart follower at different address with resolver addr updated\n\tc.resolverMu.Lock()\n\tc.ports[flrs[0].nid] = 9999\n\tc.resolverMu.Unlock()\n\tc.restart(flrs[0])\n\n\t// wait for leader to detect that follower is reachable at new addr\n\tc.waitReachableDetected(ldr, flrs[0])\n}", "title": "" }, { "docid": "9837f8f88c1326a40dad2a8b0024ed2b", "score": "0.4494927", "text": "func ensureConnection(client *ethclient.Client) error {\n\tt := time.NewTicker(1 * time.Second)\n\tretries := 0\n\tdefer t.Stop()\n\tfor ; true; <-t.C {\n\t\t_, err := client.ChainID(context.Background())\n\t\tif err == nil {\n\t\t\tbreak\n\t\t} else {\n\t\t\tretries += 1\n\t\t\tif retries > 90 {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "90364860d6605f2ef7e967fb959a2c1e", "score": "0.449284", "text": "func ConnectBroker() {\n\tconfig := config.GetConfig()\n\tconn, err := amqp.Dial(config.URL)\n\tlogger.LogMessage(err, \"Could Not Connect to Broker\", \"Successfully connected to Message Broker\")\n\t// defer conn.Close()\n\n\tch, err = conn.Channel()\n\tlogger.LogMessage(err, \"Could Not open a Channel\", \"Successfully opened a Channel\")\n\t// defer ch.Close()\n\n\tq, err = ch.QueueDeclare(\n\t\t\"ConnectQueue\",\n\t\tfalse,\n\t\tfalse,\n\t\tfalse,\n\t\tfalse,\n\t\tnil,\n\t)\n\tlogger.LogMessage(err, \"Failed to declare the Queue\", \"Declared the queue\")\n\treturn\n}", "title": "" }, { "docid": "014dda36330862191db204f81ea4dd0b", "score": "0.4492805", "text": "func Run(cfg *types.Configuration) {\n\tctx := context.Background()\n\n\tvar provider providers.Provider\n\tamqpConnection := servicebus.NewAmqpConnection(ctx, cfg)\n\thandlerArgs := providers.GetSharedHandlerArgs(cfg, amqpConnection.AccessKeys)\n\n\tif cfg.AzureBatch != nil {\n\t\tlog.Info(\"Using Azure batch provider...\")\n\t\tbatchProvider, err := providers.NewAzureBatchProvider(cfg, handlerArgs)\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Panic(\"Couldn't create azure batch provider\")\n\t\t}\n\t\tprovider = batchProvider\n\t} else {\n\t\tlog.Info(\"Defaulting to using Kubernetes provider...\")\n\t\tk8sProvider, err := providers.NewKubernetesProvider(cfg, handlerArgs)\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Panic(\"Couldn't create kubernetes provider\")\n\t\t}\n\t\tprovider = k8sProvider\n\t}\n\n\tvar wg sync.WaitGroup\n\n\twg.Add(4)\n\tgo func() {\n\t\tdefer wg.Done()\n\t\tfor {\n\t\t\t// Locks are held for 1 mins, renew every 20 sec to keep locks\n\t\t\ttime.Sleep(20 * time.Second)\n\t\t\t// allow 20seconds for the renew operation, keeping a 25 second buffer\n\t\t\ttimeAllowanceForRenewalRequest := time.Second * 15\n\n\t\t\t// Renew message locks with ServiceBus\n\t\t\t//https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-amqp-request-response#message-renew-lock\n\t\t\tactiveMessages := provider.GetActiveMessages()\n\t\t\tif len(activeMessages) < 1 {\n\t\t\t\tlog.Debug(\"no active messages, skipping lock renewal\")\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tmessagesAMQP := make([]*amqp.Message, 0, len(activeMessages))\n\t\t\tfor _, m := range activeMessages {\n\t\t\t\toriginalMessage := m.GetAMQPMessage()\n\t\t\t\tmessagesAMQP = append(messagesAMQP, originalMessage)\n\t\t\t}\n\n\t\t\trenewContextWithDeadline, cancel := context.WithTimeout(ctx, timeAllowanceForRenewalRequest)\n\t\t\tdefer cancel()\n\t\t\terr := amqpConnection.RenewLocks(renewContextWithDeadline, messagesAMQP)\n\t\t\tif err != nil {\n\t\t\t\t// Todo: Additional could be put in here to cleanup operations. See: #171\n\t\t\t\t// https://github.com/lawrencegripper/ion/issues/171\n\t\t\t\tlog.WithError(err).Panic(\"Failed to renew locks therefore cannot continue operation as message could be reassigned to another dispatcher.\")\n\t\t\t}\n\t\t}\n\t}()\n\tgo func() {\n\t\tdefer wg.Done()\n\t\tfor {\n\t\t\t// output queue stats every 30 seconds\n\t\t\ttime.Sleep(30 * time.Second)\n\t\t\tqueueStats, err := amqpConnection.GetQueueDepth()\n\t\t\tif err != nil {\n\t\t\t\tlog.WithError(err).Error(\"failed getting queue depth from listener\")\n\t\t\t}\n\t\t\tlog.WithField(\"activeMessageCount\", queueStats.ActiveMessageCount).WithField(\"deadLetteredMessageCount\", queueStats.DeadLetterMessageCount).Info(\"listenerStats\")\n\t\t}\n\t}()\n\tgo func() {\n\t\tdefer wg.Done()\n\t\tfor {\n\t\t\tmessage, err := amqpConnection.Receiver.Receive(ctx)\n\n\t\t\tif err != nil {\n\t\t\t\t// Todo: Investigate the type of error here. If this could be triggered by a poisened message\n\t\t\t\t// app shouldn't panic.\n\t\t\t\tlog.WithError(err).Panic(\"Error received dequeuing message\")\n\t\t\t}\n\n\t\t\tif message == nil {\n\t\t\t\tlog.WithError(err).Panic(\"Error received dequeuing message - nil message\")\n\t\t\t}\n\n\t\t\twrapper := messaging.NewAmqpMessageWrapper(message)\n\t\t\tcontextualLogger := providers.GetLoggerForMessage(wrapper, log.NewEntry(log.StandardLogger()))\n\t\t\tcontextualLogger.Debug(\"message received\")\n\n\t\t\tif wrapper.DeliveryCount() > cfg.Job.RetryCount+1 {\n\t\t\t\tcontextualLogger.Error(\"message re-received when above retryCount. AMQP provider wrongly redelivered message.\")\n\t\t\t\terr := wrapper.Reject()\n\t\t\t\tif err != nil {\n\t\t\t\t\tcontextualLogger.Error(\"error rejecting message\")\n\t\t\t\t}\n\t\t\t}\n\t\t\terr = provider.Dispatch(wrapper)\n\t\t\tif err != nil {\n\t\t\t\tcontextualLogger.WithError(err).Error(\"Couldn't dispatch message to kubernetes provider\")\n\t\t\t}\n\n\t\t\tcontextualLogger.Debug(\"message dispatched\")\n\t\t}\n\t}()\n\n\tgo func() {\n\t\tdefer wg.Done()\n\t\tfor {\n\t\t\ttime.Sleep(time.Second * 15)\n\n\t\t\tif len(provider.GetActiveMessages()) < 1 {\n\t\t\t\tlog.Debug(\"no active messages, skipping reconciling...\")\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tlog.Debug(\"reconciling...\")\n\n\t\t\terr := provider.Reconcile()\n\t\t\tif err != nil {\n\t\t\t\t// Todo: Should this panic here? Should we tolerate a few failures (k8s upgade causing masters not to be vailable for example?)\n\t\t\t\tlog.WithError(err).Panic(\"Failed to reconcile ....\")\n\t\t\t}\n\t\t\tlog.WithField(\"inProgress\", provider.InProgressCount()).Info(\"providerStats\")\n\t\t}\n\t}()\n\twg.Wait()\n\n\t//init flaeg\n\t//flaeg := flaeg.New(rootCmd, os.Args[1:])\n\n\t//run test\n\t//if err := flaeg.Run(); err != nil {\n\t//\tfmt.Printf(\"Error %s \\n\", err.Error())\n\t//}\n}", "title": "" }, { "docid": "3f8d32b8003d9455fe4d1956845b9054", "score": "0.4482095", "text": "func (s *Scheduler) enqueueRetry(args *retryTxn) {\n\tgo s.delayRetry(args)\n}", "title": "" }, { "docid": "4e8389dbff8f7f446e37f13cd1e9bee3", "score": "0.44782996", "text": "func (c *PodController) handleErr(err error, key string) {\n\tworkqueue := c.wepDataCache.GetQueue()\n\tif err == nil {\n\t\t// Forget about the #AddRateLimited history of the key on every successful synchronization.\n\t\t// This ensures that future processing of updates for this key is not delayed because of\n\t\t// an outdated error history.\n\t\tlog.WithField(\"key\", key).Debug(\"Error for key is no more, drop from retry queue\")\n\t\tworkqueue.Forget(key)\n\t\treturn\n\t}\n\n\t// This controller retries 5 times if something goes wrong. After that, it stops trying.\n\tif workqueue.NumRequeues(key) < 5 {\n\t\tlog.WithError(err).Errorf(\"Error syncing pod, will retry: %v: %v\", key, err)\n\t\t// Re-enqueue the key rate limited. Based on the rate limiter on the\n\t\t// queue and the re-enqueue history, the key will be processed later again.\n\t\tworkqueue.AddRateLimited(key)\n\t\treturn\n\t}\n\tworkqueue.Forget(key)\n\n\t// Report to an external entity that, even after several retries, we could not successfully process this key\n\turuntime.HandleError(err)\n\tlog.WithError(err).Errorf(\"Dropping pod %q out of the retry queue: %v\", key, err)\n}", "title": "" }, { "docid": "9967446bf580091b7fecc0d5f1e95d41", "score": "0.44781637", "text": "func (b *Broker) StartConsuming(consumerTag string, concurrency int, taskProcessor iface.TaskProcessor) (bool, error) {\n\tb.Broker.StartConsuming(consumerTag, concurrency, taskProcessor)\n\n\tb.pool = nil\n\tconn := b.open()\n\tdefer conn.Close()\n\tdefer b.pool.Close()\n\n\t// Ping the server to make sure connection is live\n\t_, err := conn.Do(\"PING\")\n\tif err != nil {\n\t\tb.GetRetryFunc()(b.GetRetryStopChan())\n\t\treturn b.GetRetry(), err\n\t}\n\n\t// Channels and wait groups used to properly close down goroutines\n\tb.stopReceivingChan = make(chan int)\n\tb.stopDelayedChan = make(chan int)\n\tb.receivingWG.Add(1)\n\tb.delayedWG.Add(1)\n\n\t// Channel to which we will push tasks ready for processing by worker\n\tdeliveries := make(chan []byte)\n\tpool := make(chan struct{}, concurrency)\n\n\t// initialize worker pool with maxWorkers workers\n\tgo func() {\n\t\tfor i := 0; i < concurrency; i++ {\n\t\t\tpool <- struct{}{}\n\t\t}\n\t}()\n\n\t// Helper function to return true if parallel task processing slots still available,\n\t// false when we are already executing maximum allowed concurrent tasks\n\tvar concurrencyAvailable = func() bool {\n\t\treturn concurrency == 0 || (len(pool)-len(deliveries) > 0)\n\t}\n\n\t// Timer is added otherwise when the pools were all active it will spin the for loop\n\tvar (\n\t\ttimerDuration = time.Duration(100000000 * time.Nanosecond) // 100 miliseconds\n\t\ttimer = time.NewTimer(0)\n\t)\n\t// A receivig goroutine keeps popping messages from the queue by BLPOP\n\t// If the message is valid and can be unmarshaled into a proper structure\n\t// we send it to the deliveries channel\n\tgo func() {\n\t\tdefer b.receivingWG.Done()\n\n\t\tlog.INFO.Print(\"[*] Waiting for messages. To exit press CTRL+C\")\n\n\t\tfor {\n\t\t\tselect {\n\t\t\t// A way to stop this goroutine from b.StopConsuming\n\t\t\tcase <-b.stopReceivingChan:\n\t\t\t\treturn\n\t\t\tcase <-timer.C:\n\t\t\t\t// If concurrency is limited, limit the tasks being pulled off the queue\n\t\t\t\t// until a pool is available\n\t\t\t\tif concurrencyAvailable() {\n\t\t\t\t\ttask, err := b.nextTask(getQueue(b.GetConfig(), taskProcessor))\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t// something went wrong, wait a bit before continuing the loop\n\t\t\t\t\t\ttimer.Reset(timerDuration)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tdeliveries <- task\n\t\t\t\t}\n\t\t\t\tif concurrencyAvailable() {\n\t\t\t\t\t// parallel task processing slots still available, continue loop immediately\n\t\t\t\t\ttimer.Reset(0)\n\t\t\t\t} else {\n\t\t\t\t\t// using all parallel task processing slots, wait a bit before continuing the loop\n\t\t\t\t\ttimer.Reset(timerDuration)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\t// A goroutine to watch for delayed tasks and push them to deliveries\n\t// channel for consumption by the worker\n\tgo func() {\n\t\tdefer b.delayedWG.Done()\n\n\t\tfor {\n\t\t\tselect {\n\t\t\t// A way to stop this goroutine from b.StopConsuming\n\t\t\tcase <-b.stopDelayedChan:\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t\ttask, err := b.nextDelayedTask(redisDelayedTasksKey)\n\t\t\t\tif err != nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tsignature := new(tasks.Signature)\n\t\t\t\tdecoder := json.NewDecoder(bytes.NewReader(task))\n\t\t\t\tdecoder.UseNumber()\n\t\t\t\tif err := decoder.Decode(signature); err != nil {\n\t\t\t\t\tlog.ERROR.Print(errs.NewErrCouldNotUnmarshaTaskSignature(task, err))\n\t\t\t\t}\n\n\t\t\t\tif err := b.Publish(signature); err != nil {\n\t\t\t\t\tlog.ERROR.Print(err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\tif err := b.consume(deliveries, pool, concurrency, taskProcessor); err != nil {\n\t\treturn b.GetRetry(), err\n\t}\n\n\t// Waiting for any tasks being processed to finish\n\tb.processingWG.Wait()\n\n\treturn b.GetRetry(), nil\n}", "title": "" }, { "docid": "9fe3d909f4a6130f780c54871fe66b29", "score": "0.4478111", "text": "func maybeRetryBoot(ctx *domainContext, status *types.DomainStatus) {\n\n\tif !status.BootFailed {\n\t\treturn\n\t}\n\tif status.Activated && status.BootFailed {\n\t\tlog.Functionf(\"maybeRetryBoot(%s) clearing bootFailed since Activated\",\n\t\t\tstatus.Key())\n\t\tstatus.BootFailed = false\n\t\tpublishDomainStatus(ctx, status)\n\t\treturn\n\t}\n\tconfig := lookupDomainConfig(ctx, status.Key())\n\tif config == nil {\n\t\t// Odd to have status but no config\n\t\tlog.Errorf(\"maybeRetryBoot(%s) no DomainConfig\",\n\t\t\tstatus.Key())\n\t\treturn\n\t}\n\tif !config.Activate {\n\t\tlog.Errorf(\"maybeRetryBoot(%s) Config not Activate - nothing to do\",\n\t\t\tstatus.Key())\n\t\tstatus.BootFailed = false\n\t\tpublishDomainStatus(ctx, status)\n\t\treturn\n\t}\n\n\tt := time.Now()\n\telapsed := t.Sub(status.ErrorTime)\n\ttimeLimit := time.Duration(ctx.domainBootRetryTime) * time.Second\n\tif elapsed < timeLimit {\n\t\tlog.Functionf(\"maybeRetryBoot(%s) %d remaining\",\n\t\t\tstatus.Key(),\n\t\t\t(timeLimit-elapsed)/time.Second)\n\t\treturn\n\t}\n\tlog.Noticef(\"maybeRetryBoot(%s) after %s at %v\",\n\t\tstatus.Key(), status.Error, status.ErrorTime)\n\n\tif status.HasError() {\n\t\tlog.Noticef(\"maybeRetryBoot(%s) clearing existing error: %s\",\n\t\t\tstatus.Key(), status.Error)\n\t\tstatus.ClearError()\n\t}\n\n\tfilename := xenCfgFilename(config.AppNum)\n\tfile, err := os.Create(filename)\n\tif err != nil {\n\t\t//it is retry, so omit error\n\t\tlog.Error(\"os.Create for \", filename, err)\n\t}\n\tdefer file.Close()\n\n\tif err := hyper.Task(status).Setup(*status, *config, ctx.assignableAdapters, nil, file); err != nil {\n\t\t//it is retry, so omit error\n\t\tlog.Errorf(\"Failed to create DomainStatus from %v: %s\",\n\t\t\tconfig, err)\n\t}\n\n\tstatus.TriedCount += 1\n\n\tctx.createSema.V(1)\n\tdomainID, err := DomainCreate(ctx, *status)\n\tctx.createSema.P(1)\n\tif err != nil {\n\t\tlog.Errorf(\"maybeRetryBoot DomainCreate for %s: %s\",\n\t\t\tstatus.DomainName, err)\n\t\tstatus.BootFailed = true\n\t\tstatus.SetErrorNow(err.Error())\n\t\tpublishDomainStatus(ctx, status)\n\t\treturn\n\t}\n\tstatus.BootFailed = false\n\tdoActivateTail(ctx, status, domainID)\n\tpublishDomainStatus(ctx, status)\n\tlog.Functionf(\"maybeRetryBoot(%s) DONE for %s\",\n\t\tstatus.Key(), status.DisplayName)\n}", "title": "" }, { "docid": "49f351c21c7adf20c229a7569c7aff12", "score": "0.44759783", "text": "func (c *ChatRPC) ShouldRetry(_ string, _ error) bool {\n\treturn false\n}", "title": "" }, { "docid": "2780535d6fbc2c90c66eb977d7d6b33c", "score": "0.44705772", "text": "func TestDirectDeliverer(t *testing.T) {\n\tintegration.Skip(t)\n\t// test start\n\ttable := []struct {\n\t\tname string\n\t\trollup int\n\t\tnotes int\n\t}{\n\t\t{\n\t\t\tname: \"check 0\",\n\t\t\trollup: 0,\n\t\t\tnotes: 1,\n\t\t},\n\t\t{\n\t\t\tname: \"check 1\",\n\t\t\trollup: 1,\n\t\t\tnotes: 5,\n\t\t},\n\t\t{\n\t\t\tname: \"check rollup overflow\",\n\t\t\trollup: 10,\n\t\t\tnotes: 5,\n\t\t},\n\t\t{\n\t\t\tname: \"check odds\",\n\t\t\trollup: 3,\n\t\t\tnotes: 7,\n\t\t},\n\t\t{\n\t\t\tname: \"check odds rollup\",\n\t\t\trollup: 3,\n\t\t\tnotes: 8,\n\t\t},\n\t\t{\n\t\t\tname: \"check odds notes\",\n\t\t\trollup: 4,\n\t\t\tnotes: 7,\n\t\t},\n\t\t{\n\t\t\tname: \"check large\",\n\t\t\trollup: 100,\n\t\t\tnotes: 1000,\n\t\t},\n\t}\n\n\turi := os.Getenv(\"STOMP_CONNECTION_STRING\")\n\tif uri == \"\" {\n\t\turi = defaultStompBrokerURI\n\t}\n\tfor _, tt := range table {\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tctx, done := log.TestLogger(context.Background(), t)\n\t\t\tdefer done()\n\t\t\t// deliverer test\n\t\t\tconf := Config{\n\t\t\t\tDirect: true,\n\t\t\t\tRollup: tt.rollup,\n\t\t\t\tDestination: \"notifications\",\n\t\t\t\tURIs: []string{\n\t\t\t\t\t// give a few bogus URIs to confirm failover mechanisms are working\n\t\t\t\t\t\"nohost1:5672/\",\n\t\t\t\t\t\"nohost2:5672/\",\n\t\t\t\t\t\"nohost3:5672/\",\n\t\t\t\t\turi,\n\t\t\t\t},\n\t\t\t}\n\n\t\t\tnoteID := uuid.New()\n\t\t\tnotes := make([]notifier.Notification, 0, tt.notes)\n\t\t\tfor i := 0; i < tt.notes; i++ {\n\t\t\t\tnotes = append(notes, notifier.Notification{\n\t\t\t\t\tID: uuid.New(),\n\t\t\t\t\tManifest: claircore.MustParseDigest(\"sha256:35c102085707f703de2d9eaad8752d6fe1b8f02b5d2149f1d8357c9cc7fb7d0a\"),\n\t\t\t\t\tReason: notifier.Added,\n\t\t\t\t\tVulnerability: notifier.VulnSummary{\n\t\t\t\t\t\tDescription: fmt.Sprintf(\"test-vuln-%d\", i),\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// test parallel usage\n\t\t\tg := errgroup.Group{}\n\t\t\tfor i := 0; i < 4; i++ {\n\t\t\t\tg.Go(func() error {\n\t\t\t\t\td, err := NewDirectDeliverer(conf)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"could not create deliverer: %v\", err)\n\t\t\t\t\t}\n\t\t\t\t\terr = d.Notifications(ctx, notes)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"failed to provide notifications to direct deliverer: %v\", err)\n\t\t\t\t\t}\n\t\t\t\t\t// will error if message cannot be delivered to broker\n\t\t\t\t\terr = d.Deliver(ctx, noteID)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"failed to deliver message: %v\", err)\n\t\t\t\t\t}\n\t\t\t\t\treturn nil\n\t\t\t\t})\n\t\t\t}\n\t\t\tif err := g.Wait(); err != nil {\n\t\t\t\tt.Fatalf(\"test failed: %v\", err)\n\t\t\t}\n\t\t})\n\t}\n}", "title": "" }, { "docid": "2d8942c3aa75e73aac2fd879728062a8", "score": "0.44685858", "text": "func TestRunningReapFailRetry(t *testing.T) {\n\t// Job Chain:\n\t// 1 - 2 - 3\n\t// \\_ 4\n\t// Testing when job 2 fails (+ sequence is retryable)\n\n\treqId := \"test_running_reap_fail_retry\"\n\tfactory := defaultFactory(reqId)\n\tjc := &proto.JobChain{\n\t\tRequestId: reqId,\n\t\tJobs: testutil.InitJobsWithSequenceRetry(4, 1),\n\t\tAdjacencyList: map[string][]string{\n\t\t\t\"job1\": {\"job2\", \"job4\"},\n\t\t\t\"job2\": {\"job3\"},\n\t\t},\n\t\tFinishedJobs: 2,\n\t}\n\tc := chain.NewChain(jc, make(map[string]uint), make(map[string]uint), make(map[string]uint))\n\tfactory.Chain = c\n\n\t// Normally runJobChan is unbuffered. Here we use a buffer so Reap\n\t// doesn't block on sending to the chan.\n\trunJobChan := make(chan proto.Job, 5)\n\tfactory.RunJobChan = runJobChan\n\treaper := factory.MakeRunning()\n\n\tc.IncrementSequenceTries(\"job1\", 1)\n\tc.IncrementJobTries(\"job1\", 1)\n\tc.IncrementJobTries(\"job4\", 1)\n\tc.SetJobState(\"job1\", proto.STATE_COMPLETE)\n\tc.SetJobState(\"job4\", proto.STATE_COMPLETE)\n\tc.SetJobState(\"job2\", proto.STATE_RUNNING)\n\n\t// Job 2 has just failed.\n\tjob := proto.Job{\n\t\tId: \"job2\",\n\t\tState: proto.STATE_FAIL,\n\t\tData: map[string]interface{}{\n\t\t\t\"key1\": \"val1\",\n\t\t},\n\t\tSequenceId: \"job1\",\n\t}\n\treaper.(*chain.RunningChainReaper).Reap(job)\n\n\t// job1 should be (re)sent to runJobChan\n\tselect {\n\tcase gotJob := <-runJobChan:\n\t\tif gotJob.Id != \"job1\" {\n\t\t\tt.Errorf(\"got job %s from runJobChan, expected job %s\", gotJob.Id, \"job1\")\n\t\t}\n\tdefault:\n\t\tt.Errorf(\"no job sent to runJobChan - expected to get job1\")\n\t}\n\n\t// no other jobs should be sent to runJobChan\n\tselect {\n\tcase <-runJobChan:\n\t\tt.Errorf(\"more than one job sent to runJobChan - expected only job1\")\n\tdefault:\n\t}\n\n\t// all job states should have been set back to PENDING\n\tfor id := range jc.Jobs {\n\t\tgotState := c.JobState(id)\n\t\tif gotState != proto.STATE_PENDING {\n\t\t\tt.Errorf(\"%s state in chain = %d, expected state = %d\", id, gotState, proto.STATE_PENDING)\n\t\t}\n\t}\n\n\t// Sequence try count is _not_ incremented yet. That happens in traverser.runJobs\n\t// when the sequence start job is ran, which is the true indicator that a sequence\n\t// has been tried. Between reaper doing sequece retry prep and then, the chain\n\t// could be stopped, etc. and the seq never actually retried.\n\ttryCount := c.SequenceTries(job.Id)\n\tif tryCount != 1 {\n\t\tt.Errorf(\"got sequence try count %d, expected 1\", tryCount)\n\t}\n}", "title": "" }, { "docid": "f0341693c9db2d54136c7322c533166f", "score": "0.44650698", "text": "func retryTransact(db *sqlx.DB, txFunc func(*sqlx.Tx) error, retryNumber int) error {\n\tvar err error\n\tfor i := 0; i < retryNumber; i++ {\n\t\terr = transact(db, txFunc)\n\t\tif err == nil {\n\t\t\treturn err\n\t\t}\n\t\tdriverError, ok := err.(*pq.Error)\n\t\tif !ok {\n\t\t\treturn err\n\t\t}\n\n\t\t//40001 serialization_failure\n\t\t//40P01 deadlock_detected\n\t\tif driverError.Code != \"40001\" && driverError.Code != \"40P01\" {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn err\n}", "title": "" }, { "docid": "ee867bbc97e418fda10c3751363d07b6", "score": "0.44642717", "text": "func AttemptRecoveryRegistration(failedKey *inst.InstanceKey) (bool, error) {\n\n\tdb, err := db.OpenOrchestrator()\n\tif err != nil {\n\t\treturn false, log.Errore(err)\n\t}\n\n\tsqlResult, err := sqlutils.Exec(db, `\n\t\t\tinsert ignore \n\t\t\t\tinto topology_recovery (\n\t\t\t\t\thostname, \n\t\t\t\t\tport, \n\t\t\t\t\tin_active_period, \n\t\t\t\t\tstart_active_period, \n\t\t\t\t\tend_active_period_unixtime, \n\t\t\t\t\tprocessing_node_hostname, \n\t\t\t\t\tprocesscing_node_token\n\t\t\t\t) values (\n\t\t\t\t\t?,\n\t\t\t\t\t?,\n\t\t\t\t\t1,\n\t\t\t\t\tNOW(),\n\t\t\t\t\t0,\n\t\t\t\t\t?,\n\t\t\t\t\t?\n\t\t\t\t)\n\t\t\t`, failedKey.Hostname, failedKey.Port, ThisHostname, ProcessToken.Hash,\n\t)\n\tif err != nil {\n\t\treturn false, log.Errore(err)\n\t}\n\trows, err := sqlResult.RowsAffected()\n\treturn (err == nil && rows > 0), err\n}", "title": "" }, { "docid": "8126340d9d9b62045b5e61e785c5fe29", "score": "0.44640923", "text": "func (m *multiTopicDecoupleSink) getTopicForBroker(ns, broker string) (string, error) {\n\tbrokerConfig, ok := m.brokerConfig.GetBroker(ns, broker)\n\tif !ok {\n\t\t// There is an propagation delay between the controller reconciles the broker config and\n\t\t// the config being pushed to the configmap volume in the ingress pod. So sometimes we return\n\t\t// an error even if the request is valid.\n\t\tm.logger.Warn(\"config is not found for\", zap.Any(\"ns\", ns), zap.Any(\"broker\", broker))\n\t\treturn \"\", fmt.Errorf(\"%q/%q: %w\", ns, broker, ErrNotFound)\n\t}\n\tif brokerConfig.DecoupleQueue == nil || brokerConfig.DecoupleQueue.Topic == \"\" {\n\t\tm.logger.Error(\"DecoupleQueue or topic missing for broker, this should NOT happen.\", zap.Any(\"brokerConfig\", brokerConfig))\n\t\treturn \"\", fmt.Errorf(\"decouple queue of %q/%q: %w\", ns, broker, ErrIncomplete)\n\t}\n\treturn brokerConfig.DecoupleQueue.Topic, nil\n}", "title": "" }, { "docid": "a35f1cf78e6c2eefe5bb9fee85be2127", "score": "0.4460005", "text": "func retry(interval time.Duration, stopc <-chan struct{}, f func() error) error {\n\ttick := time.NewTicker(interval)\n\tdefer tick.Stop()\n\n\tvar err error\n\tfor {\n\t\tif err = f(); err == nil {\n\t\t\treturn nil\n\t\t}\n\t\tselect {\n\t\tcase <-stopc:\n\t\t\treturn err\n\t\tcase <-tick.C:\n\t\t}\n\t}\n}", "title": "" }, { "docid": "1a8953115ee8135cb48b8cff168a25b8", "score": "0.4458072", "text": "func TestReconcileServiceInstanceWithTemporaryProvisionFailure(t *testing.T) {\n\tfakeKubeClient, fakeCatalogClient, fakeClusterServiceBrokerClient, testController, sharedInformers := newTestController(t, fakeosb.FakeClientConfiguration{\n\t\tProvisionReaction: &fakeosb.ProvisionReaction{\n\t\t\tError: osb.HTTPStatusCodeError{\n\t\t\t\tStatusCode: http.StatusInternalServerError,\n\t\t\t\tErrorMessage: strPtr(\"InternalServerError\"),\n\t\t\t\tDescription: strPtr(\"Something went wrong!\"),\n\t\t\t},\n\t\t},\n\t})\n\n\tsharedInformers.ClusterServiceBrokers().Informer().GetStore().Add(getTestClusterServiceBroker())\n\tsharedInformers.ClusterServiceClasses().Informer().GetStore().Add(getTestClusterServiceClass())\n\tsharedInformers.ClusterServicePlans().Informer().GetStore().Add(getTestClusterServicePlan())\n\n\tinstance := getTestServiceInstanceWithRefs()\n\n\t//////////////////////////////////////\n\t// Check 1st reconcilliation iteration (prepare/validate request & set status to in progress)\n\n\tif err := reconcileServiceInstance(t, testController, instance); err != nil {\n\t\tt.Fatalf(\"Reconcile not expected to fail : %v\", err)\n\t}\n\n\tbrokerActions := fakeClusterServiceBrokerClient.Actions()\n\tassertNumberOfClusterServiceBrokerActions(t, brokerActions, 0)\n\n\texpectedKubeActions := []kubeClientAction{\n\t\t{verb: \"get\", resourceName: \"namespaces\", checkType: checkGetActionType},\n\t}\n\tkubeActions := fakeKubeClient.Actions()\n\tif err := checkKubeClientActions(kubeActions, expectedKubeActions); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tactions := fakeCatalogClient.Actions()\n\tassertNumberOfActions(t, actions, 1)\n\tupdatedServiceInstance := assertUpdateStatus(t, actions[0], instance)\n\n\tevents := getRecordedEvents(testController)\n\tupdatedServiceInstance = assertUpdateStatus(t, actions[0], instance)\n\tassertServiceInstanceOperationInProgress(t,\n\t\tupdatedServiceInstance,\n\t\tv1beta1.ServiceInstanceOperationProvision,\n\t\ttestClusterServicePlanName,\n\t\ttestClusterServicePlanGUID,\n\t\tinstance,\n\t)\n\n\t//////////////////////////////////////\n\t// Check 2nd reconcilliation iteration (actual broker request)\n\n\tfakeCatalogClient.ClearActions()\n\tfakeKubeClient.ClearActions()\n\tinstance = updatedServiceInstance.(*v1beta1.ServiceInstance)\n\n\tif err := reconcileServiceInstance(t, testController, instance); err == nil {\n\t\tt.Fatalf(\"Should not be able to make the ServiceInstance\")\n\t}\n\n\tbrokerActions = fakeClusterServiceBrokerClient.Actions()\n\tassertNumberOfClusterServiceBrokerActions(t, brokerActions, 1)\n\tassertProvision(t, brokerActions[0], &osb.ProvisionRequest{\n\t\tAcceptsIncomplete: true,\n\t\tInstanceID: testServiceInstanceGUID,\n\t\tServiceID: testClusterServiceClassGUID,\n\t\tPlanID: testClusterServicePlanGUID,\n\t\tContext: testContext,\n\t})\n\n\t// verify no kube resources created\n\t// One single action comes from getting namespace uid\n\tkubeActions = fakeKubeClient.Actions()\n\tif err := checkKubeClientActions(kubeActions, []kubeClientAction{\n\t\t{verb: \"get\", resourceName: \"namespaces\", checkType: checkGetActionType},\n\t}); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tactions = fakeCatalogClient.Actions()\n\tassertNumberOfActions(t, actions, 1)\n\n\tupdatedServiceInstance = assertUpdateStatus(t, actions[0], instance)\n\tassertServiceInstanceRequestFailingErrorStartOrphanMitigation(\n\t\tt,\n\t\tupdatedServiceInstance,\n\t\tv1beta1.ServiceInstanceOperationProvision,\n\t\tstartingInstanceOrphanMitigationReason,\n\t\t\"\",\n\t\terrorProvisionCallFailedReason,\n\t\tinstance,\n\t)\n\n\tevents = getRecordedEvents(testController)\n\n\tmessage := fmt.Sprintf(\n\t\t\"Error provisioning ServiceInstance of ClusterServiceClass (K8S: %q ExternalName: %q) at ClusterServiceBroker %q: Status: %v; ErrorMessage: %s\",\n\t\t\"CSCGUID\", \"test-clusterserviceclass\", \"test-clusterservicebroker\", 500, \"InternalServerError; Description: Something went wrong!; ResponseError: <nil>\",\n\t)\n\texpectedProvisionCallEvent := warningEventBuilder(errorProvisionCallFailedReason).msg(message)\n\texpectedOrphanMitigationEvent := warningEventBuilder(startingInstanceOrphanMitigationReason).\n\t\tmsg(\"The instance provision call failed with an ambiguous error; attempting to deprovision the instance in order to mitigate an orphaned resource\")\n\texpectedEvents := []string{\n\t\texpectedProvisionCallEvent.String(),\n\t\texpectedOrphanMitigationEvent.String(),\n\t}\n\tif err := checkEvents(events, expectedEvents); err != nil {\n\t\tt.Fatal(err)\n\t}\n}", "title": "" }, { "docid": "1e0b333dbd0bbf8dbf92ed477a73ae20", "score": "0.44538435", "text": "func GetDefaultBrokerURI(ns internal.Namespace) string {\n\treturn fmt.Sprintf(\"http://default-broker.%s\", ns)\n}", "title": "" } ]
142949ffa5c23f8f0b0ff46138ef0fda
GetTokensByUser implements OAuth2Repository interface.
[ { "docid": "0bfd39d9af42f818f5ab00841558aae4", "score": "0.77323055", "text": "func (repo *Repository) GetTokensByUser(userID uuid.UUID) ([]*model.OAuth2Token, error) {\n\tts := make([]*model.OAuth2Token, 0)\n\tif userID == uuid.Nil {\n\t\treturn ts, nil\n\t}\n\treturn ts, repo.db.Where(&model.OAuth2Token{UserID: userID}).Find(&ts).Error\n}", "title": "" } ]
[ { "docid": "efcb550a69d104d3e906cecb9c813b2b", "score": "0.6673121", "text": "func GetUserTokens(username string) ([]entities.Tokens, error) {\n\ttokens := []entities.Tokens{}\n\n\trow := db.QueryRow(\n\t\t\"SELECT access_token, refresh_token FROM spotify_tokens WHERE username=?\",\n\t\tusername,\n\t)\n\ttoken, err := mappers.FromRowToTokens(row)\n\tif err != nil {\n\t\treturn []entities.Tokens{}, nil\n\t}\n\ttoken.Source = \"spotify\"\n\ttokens = append(tokens, *token)\n\n\treturn tokens, err\n}", "title": "" }, { "docid": "5f3a69c3a2d946d23bae1fd346500a86", "score": "0.62791204", "text": "func (c *Client4) GetUserAccessTokens(page int, perPage int) ([]*UserAccessToken, *Response, error) {\n\tquery := fmt.Sprintf(\"?page=%v&per_page=%v\", page, perPage)\n\tr, err := c.DoAPIGet(c.userAccessTokensRoute()+query, \"\")\n\tif err != nil {\n\t\treturn nil, BuildResponse(r), err\n\t}\n\tdefer closeBody(r)\n\tvar list []*UserAccessToken\n\tif err := json.NewDecoder(r.Body).Decode(&list); err != nil {\n\t\treturn nil, nil, NewAppError(\"GetUserAccessTokens\", \"api.unmarshal_error\", nil, \"\", http.StatusInternalServerError).Wrap(err)\n\t}\n\treturn list, BuildResponse(r), nil\n}", "title": "" }, { "docid": "c0d76539fb188b0d66cfb5ddb522aa03", "score": "0.6269825", "text": "func (sqlite SqliteDB) GetTokens(userid int64) ([]model.Token, error) {\n\tvar getTokens []model.Token\n\tvar err error\n\terr = utils.Retry(func() error {\n\t\tgetTokens, err = sqlite.getTokens(userid)\n\t\treturn err\n\t}, 2, time.Millisecond*20)\n\treturn getTokens, err\n}", "title": "" }, { "docid": "3fa6b5ff0ed6a6fe8d26171f0cefe2f8", "score": "0.61947906", "text": "func (sqlite SqliteDB) getTokens(userid int64) ([]model.Token, error) {\n\n\tvar err error\n\tvar rows *sql.Rows\n\tif rows, err = sqlite.db.Query(getFromTokensQuery, userid); err != nil {\n\t\treturn nil, err\n\t}\n\n\ttokens := make([]model.Token, 0)\n\tdefer rows.Close()\n\tfor rows.Next() {\n\t\ttoken := model.Token{}\n\t\terr = rows.Scan(&token.Uuid, &token.Expiration)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttokens = append(tokens, token)\n\t}\n\n\treturn tokens, nil\n}", "title": "" }, { "docid": "72cd2169d9f69d62fbc22d9871945c39", "score": "0.6053707", "text": "func (a *Client) GetTokens(params *GetTokensParams, authInfo runtime.ClientAuthInfoWriter) (*GetTokensOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewGetTokensParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"getTokens\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/app/rest/users/{userLocator}/tokens\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &GetTokensReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*GetTokensOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for getTokens: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "title": "" }, { "docid": "2b47f666c0c267e1000984a5fd29cf70", "score": "0.5975455", "text": "func (t *Token) GetTokens(rw http.ResponseWriter, r *http.Request) {\n\tlimit := 100\n\toffset := 0\n\n\tif len(r.URL.Query()[\"limit\"]) > 0 {\n\t\tlimit, _ = strconv.Atoi(r.URL.Query()[\"limit\"][0])\n\t}\n\n\tif len(r.URL.Query()[\"offset\"]) > 0 {\n\t\toffset, _ = strconv.Atoi(r.URL.Query()[\"offset\"][0])\n\t}\n\n\tif limit > 1000 {\n\t\terrors.ErrOverMaxLimit(rw, http.StatusUnauthorized)\n\t\treturn\n\t}\n\n\ttks, _ := t.client.Tokens(limit, offset)\n\n\tutils.Respond(rw, tks)\n\treturn\n}", "title": "" }, { "docid": "2d5b6b756a0948c0ef348d9ac036e858", "score": "0.59050524", "text": "func UsersTokenGet(c buffalo.Context) error {\n\tuserID := c.Param(\"user_id\")\n\tentity_type := c.Param(\"entity_type\")\n\tentity_id := c.Param(\"entity_id\")\n\n\ttx := c.Value(\"tx\").(*pop.Connection)\n\n\tvar mac_bytes []byte\n\n\t// Get the model type\n\tswitch entity_type {\n\tcase \"ACO\":\n\t\t{\n\t\t\tuser := models.AcoUser{}\n\t\t\terr := tx.Select(\"macaroon\").Where(\"aco_id = ? AND entity_id = ?\", entity_id, userID).First(&user)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.WithStack(err)\n\t\t\t}\n\t\t\tmac_bytes = user.Macaroon\n\t\t}\n\tcase \"Vendor\":\n\t\t{\n\t\t\tuser := models.VendorUser{}\n\t\t\terr := tx.Select(\"macaroon\").Where(\"vendor_id = ? AND user_id = ?\").First(&user)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.WithStack(err)\n\t\t\t}\n\t\t\tmac_bytes = user.Macaroon\n\n\t\t}\n\tdefault:\n\t\treturn errors.WithStack(fmt.Errorf(\"Cannot get token for entity type %s\", entity_type))\n\t}\n\n\t// return it\n\treturn c.Render(200, r.String(macaroons.EncodeMacaroon(mac_bytes)))\n}", "title": "" }, { "docid": "6261c9192f263c7da337ac48242186a1", "score": "0.58120656", "text": "func (c *Client4) GetUserAccessTokensForUser(userId string, page, perPage int) ([]*UserAccessToken, *Response, error) {\n\tquery := fmt.Sprintf(\"?page=%v&per_page=%v\", page, perPage)\n\tr, err := c.DoAPIGet(c.userRoute(userId)+\"/tokens\"+query, \"\")\n\tif err != nil {\n\t\treturn nil, BuildResponse(r), err\n\t}\n\tdefer closeBody(r)\n\tvar list []*UserAccessToken\n\tif err := json.NewDecoder(r.Body).Decode(&list); err != nil {\n\t\treturn nil, nil, NewAppError(\"GetUserAccessTokensForUser\", \"api.unmarshal_error\", nil, \"\", http.StatusInternalServerError).Wrap(err)\n\t}\n\treturn list, BuildResponse(r), nil\n}", "title": "" }, { "docid": "3a97940e81c2eec25329acccae65c47a", "score": "0.5750048", "text": "func (client *gocloak) GetUserSessions(token, realm, userID string) ([]*UserSessionRepresentation, error) {\n\tvar res []*UserSessionRepresentation\n\tresp, err := client.getRequestWithBearerAuth(token).\n\t\tSetResult(&res).\n\t\tGet(client.getAdminRealmURL(realm, \"users\", userID, \"sessions\"))\n\n\tif err := checkForError(resp, err); err != nil {\n\t\treturn nil, err\n\t}\n\treturn res, nil\n}", "title": "" }, { "docid": "fe840dbf41f5dc89231bcba87654428a", "score": "0.57014275", "text": "func (holder *Holder) GetTokens(host string) []string {\n\treturn holder.bearerTokens[host]\n}", "title": "" }, { "docid": "911cd9372199044f6b697af151a33b5f", "score": "0.56813955", "text": "func GetValidAuthTokensForUser(tx *sql.Tx, username string) ([]AuthToken, error) {\n\trows, err := tx.Query(`SELECT token, username, client_id, expires_on\n FROM auth_tokens\n WHERE username=$1 AND expires_on>$2;\n `, username, time.Now())\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\n\ttokens := []AuthToken{}\n\tfor rows.Next() {\n\t\tvar token AuthToken\n\t\terr = rows.Scan(\n\t\t\t&token.Token,\n\t\t\t&token.Username,\n\t\t\t&token.ClientID,\n\t\t\t&token.Expiration,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttokens = append(tokens, token)\n\t}\n\treturn tokens, nil\n}", "title": "" }, { "docid": "2c06ec866bdd218828f98a8ff920418f", "score": "0.56812334", "text": "func (u GetUserTokens) Execute(authToken string) ([]Token, error) {\n\tif authToken == \"\" {\n\t\treturn nil, newAuthenticationError(\"missing auth auth\")\n\t}\n\n\tuserID, err := u.TokenAuthenticate.Execute(authToken)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttokens, err := u.TokenRepo.GetByUser(userID)\n\treturn tokens, errors.Wrap(err, \"failed getting tokens\")\n}", "title": "" }, { "docid": "92201237991934805752c0255e54d927", "score": "0.5668822", "text": "func (store DBManager) GetScopesForToken(tokenID string) (ScopeUser, error) {\n\n\t//\tCreate our default return value\n\tretval := ScopeUser{}\n\n\t//\tFirst, get the userid for the given token\n\ttokenInfo, err := store.getTokenInfo(tokenID)\n\n\tif err != nil {\n\t\treturn retval, fmt.Errorf(\"There was a problem getting token information for the token: %s\", err)\n\t}\n\n\t//\tThen get the user information for the given userID:\n\tuserInfo, err := store.getUserForUserID(tokenInfo.UserID)\n\n\tif err != nil {\n\t\treturn retval, fmt.Errorf(\"There was a problem getting user information for the token: %s\", err)\n\t}\n\n\t//\tNext, get the scope information for the given userid\n\tscopeInfo, err := store.getUserScopes(userInfo)\n\n\tif err != nil {\n\t\treturn retval, fmt.Errorf(\"There was a problem getting scope information for the token: %s\", err)\n\t}\n\n\tretval = scopeInfo\n\n\t//\tReturn the scope information\n\treturn retval, nil\n}", "title": "" }, { "docid": "2911ac1ef241d53a3a198eed95a62ec5", "score": "0.5665927", "text": "func (m *MockTokenStoreClient) GetUserTokens(arg0 context.Context, arg1 *pb.UserRequest, arg2 ...grpc.CallOption) (*pb.Tokens, error) {\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"GetUserTokens\", varargs...)\n\tret0, _ := ret[0].(*pb.Tokens)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "7338d1243bbca67065f2169a89fb7a58", "score": "0.56655306", "text": "func UserTokens(exec boil.Executor, mods ...qm.QueryMod) userTokenQuery {\n\tmods = append(mods, qm.From(\"\\\"user_tokens\\\"\"))\n\treturn userTokenQuery{NewQuery(exec, mods...)}\n}", "title": "" }, { "docid": "58dff55c2c39595214c68a28c5089898", "score": "0.56159973", "text": "func GenerateTokens(user *models.User) (map[string]string, error) {\n\ttoken := jwt.NewWithClaims(jwt.SigningMethodHS512, jwt.MapClaims{\n\t\t\"id\": user.ID,\n\t\t\"exp\": time.Now().Add(time.Hour * 1).Unix(),\n\t})\n\tt, err := token.SignedString(config.SECRETKEY)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trefreshToken := jwt.NewWithClaims(jwt.SigningMethodHS512, jwt.MapClaims{\n\t\t\"id\": user.ID,\n\t\t\"refresh\": true,\n\t\t\"exp\": time.Now().Add(time.Hour * 2).Unix(),\n\t})\n\trt, err := refreshToken.SignedString(config.SECRETKEY)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn map[string]string{\n\t\t\"token\": t,\n\t\t\"refresh_token\": rt,\n\t}, nil\n}", "title": "" }, { "docid": "e085158f74359574bb0e690bfa008a2c", "score": "0.5599304", "text": "func GetTokens(ressource string) (jwt.MapClaims, error) {\n\treq, err := CreateAccessTokenRequest(configuration.TokenEndpoint, configuration.ClientID, common.Username, common.Password, ressource)\n\tif err != nil {\n\t\te.Er(err)\n\t}\n\tresp, err := SendAccessTokenRequest(req)\n\tif err != nil {\n\t\te.Er(err)\n\t}\n\ttoken, refreshToken, idToken, err := ExtractToken(resp)\n\tif err != nil {\n\t\te.Er(err)\n\t}\n\tclaims, err := GetTokenClaims(idToken)\n\tif err != nil {\n\t\te.Er(err)\n\t}\n\tWriteTokensToConfig(token, refreshToken, ressource)\n\n\treturn claims, nil\n}", "title": "" }, { "docid": "aceb9c95eef8111b46a88d293947713c", "score": "0.5592364", "text": "func (c *userOAuthAccessTokens) List(ctx context.Context, opts metav1.ListOptions) (result *v1.UserOAuthAccessTokenList, err error) {\n\tvar timeout time.Duration\n\tif opts.TimeoutSeconds != nil {\n\t\ttimeout = time.Duration(*opts.TimeoutSeconds) * time.Second\n\t}\n\tresult = &v1.UserOAuthAccessTokenList{}\n\terr = c.client.Get().\n\t\tResource(\"useroauthaccesstokens\").\n\t\tVersionedParams(&opts, scheme.ParameterCodec).\n\t\tTimeout(timeout).\n\t\tDo(ctx).\n\t\tInto(result)\n\treturn\n}", "title": "" }, { "docid": "405d6f9768aa42b938e1388f7d5ed8c0", "score": "0.5564658", "text": "func (m *MongoDBTokenRepository) GetForClientAndUser(clientID, userID string) (*oauth2.AuthToken, error) {\n\ttoken := oauth2.AuthToken{}\n\terr := m.collection.Find(bson.M{\n\t\t\"clientId\": clientID,\n\t\t\"userId\": userID,\n\t}).One(&token)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &token, nil\n}", "title": "" }, { "docid": "879f3f6b35626447277854d560dd0525", "score": "0.55463755", "text": "func (ep *Endpoints) UserTokens(name string) string {\n\treturn ep.users + \"/\" + name + \"/tokens\"\n}", "title": "" }, { "docid": "0285bf53ee3c8038b39a08bda6d09b0d", "score": "0.5519732", "text": "func (r *TokensService) List(userKey string) *TokensListCall {\n\tc := &TokensListCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.userKey = userKey\n\treturn c\n}", "title": "" }, { "docid": "1c4b7f81122fb93dd08d156d77fb101c", "score": "0.55129963", "text": "func (a *Client) GetTokens(params *GetTokensParams, authInfo runtime.ClientAuthInfoWriter) (*GetTokensOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewGetTokensParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"getTokens\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/api/v1/repository/{repository}/tokens/{code}\",\n\t\tProducesMediaTypes: []string{\"\"},\n\t\tConsumesMediaTypes: []string{\"\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &GetTokensReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.(*GetTokensOK), nil\n\n}", "title": "" }, { "docid": "723cc518f4911eab97fd02e08b9aaf6a", "score": "0.5503385", "text": "func revokeTokens(configInfo *ConfigInfo, user string) (err error) {\n\tidList, err := listTokens(configInfo, user)\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"Received error %s from listTokens of user %s on server %s\\n\", err, user, configInfo.tenantHostname)\n\t\tfailures++\n\t\treturn\n\t}\n\tif configInfo.logLevel > 0 {\n\t\tfmt.Printf(\"Got %d ids back\\n\", len(idList))\n\t}\n\tfor i, id := range idList {\n\t\tif configInfo.logLevel > 0 {\n\t\t\tfmt.Printf(\"Revoking grant %d with id %s\\n\", i, id)\n\t\t}\n\t\terr := revokeToken(configInfo, user, id)\n\t\tif err != nil {\n\t\t} else {\n\t\t\tif configInfo.logLevel > 0 {\n\t\t\t\tfmt.Printf(\"Revoked token %d for user %s\\n\", i, user)\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "title": "" }, { "docid": "8eaddc8ef663955c1e54af899beb6ef8", "score": "0.54965633", "text": "func getUserRepositories(userName string) []Repository {\n\trepositoriesEndpoint := fmt.Sprintf(\"/users/%s/repos\", userName)\n\turl := gitHubBaseUrl + repositoriesEndpoint\n\tvar repositories []Repository\n\tclient := http.Client{}\n\n\tpreparedRequest, _ := http.NewRequest(http.MethodGet, url, nil)\n\tpreparedRequest.Header = gitHubCommonHeader\n\n\trepositoriesResponse, err := client.Do(preparedRequest)\n\tif err != nil {\n\t\tlog.Printf(\"Error na requisição de repositórios.\")\n\t\treturn nil\n\t}\n\n\tif repositoriesResponse.StatusCode == http.StatusOK {\n\t\trepositories = makeRepositoriesFromBody(repositoriesResponse.Body)\n\t}\n\n\treturn repositories\n}", "title": "" }, { "docid": "45bb68cb328f3f40f8d92276d358a622", "score": "0.5463726", "text": "func getIyoUserScope(tokenStr string) ([]string, error) {\n\tjwtStr := strings.TrimSpace(strings.TrimPrefix(tokenStr, \"token\"))\n\ttoken, err := jwt.Parse(jwtStr, func(token *jwt.Token) (interface{}, error) {\n\t\tif token.Method != jwt.SigningMethodES384 {\n\t\t\treturn nil, fmt.Errorf(\"Unexpected signing method: %v\", token.Header[\"alg\"])\n\t\t}\n\t\treturn JWTPublicKey, nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclaims, ok := token.Claims.(jwt.MapClaims)\n\tif !(ok && token.Valid) {\n\t\treturn nil, fmt.Errorf(\"invalid token\")\n\t}\n\n\t// check if the issuer is itsyou.online\n\tif claims[\"iss\"].(string) != \"itsyouonline\" {\n\t\treturn nil, fmt.Errorf(\"invalid issuer:%v\", claims[\"iss\"])\n\t}\n\n\tvar scopes []string\n\tfor _, v := range claims[\"scope\"].([]interface{}) {\n\t\tscopes = append(scopes, v.(string))\n\t}\n\treturn scopes, nil\n}", "title": "" }, { "docid": "79bf9534039edb51378d52d4741f2588", "score": "0.54520434", "text": "func (r *Repository) GetUserByToken(token string) (*User, error) {\n user := new(User)\n if result := r.Db.Take(user, &User{Token: token}); result.Error != nil {\n return nil, result.Error\n }\n return user, nil\n}", "title": "" }, { "docid": "96105c8101fe5838273526f0457d3723", "score": "0.5433722", "text": "func GenTokens(username string) (string, string, error) {\n\n\t// Set expiry times\n\trtExpiresAt := time.Now().Add(time.Hour * 24).Unix()\n\n\t// Create claims\n\trt := &models.Token{\n\t\tUsername: username,\n\t\tStandardClaims: jwt.StandardClaims{\n\t\t\tExpiresAt: rtExpiresAt,\n\t\t},\n\t}\n\n\t// Create token\n\ttokenString, err := RefreshToken(username, jwtKey)\n\tif err != nil {\n\t\tlog.Println(\"Error in generating access token\")\n\t\treturn \"\", \"\", err\n\t}\n\t// Generate refresh token\n\trefreshToken := jwt.NewWithClaims(jwt.SigningMethodHS256, rt)\n\trtString, err := refreshToken.SignedString(jwtKey)\n\tif err != nil {\n\t\tlog.Println(\"Error in generating refresh token\")\n\t\treturn \"\", \"\", err\n\t}\n\n\treturn tokenString, rtString, nil\n}", "title": "" }, { "docid": "66af51dd862a1f6cdd8d5a8f158d6665", "score": "0.54244506", "text": "func (a *AuthService) GenerateTokens(user *data.User) (string, string, error) {\n\tauthD := &data.AuthDetails{}\n\tauthD.AuthUuid = uuid.NewV4().String() //generate a new UUID each time\n\tauthD.UserId = user.ID\n\n\taccessToken, err := a.GenerateAccessToken(authD)\n\tif err != nil {\n\t\ta.logger.Error(\"unable to generate access token\", \"error\", err)\n\t\treturn \"\", \"\", err\n\t}\n\n\trefreshToken, err := a.generateRefreshToken(user, authD)\n\tif err != nil {\n\t\ta.logger.Error(\"unable to generate refresh token\", \"error\", err)\n\t\treturn \"\", \"\", err\n\t}\n\treturn accessToken, refreshToken, nil\n}", "title": "" }, { "docid": "236949c839552dce1da5e4555b605d2b", "score": "0.54196125", "text": "func hapiAuthTokens(w http.ResponseWriter, r *http.Request) {\n\tif os.Getenv(\"ITSABOT_ENV\") != \"test\" {\n\t\tif !loggedIn(w, r) {\n\t\t\treturn\n\t\t}\n\t}\n\tcookie, err := r.Cookie(\"iaID\")\n\tif err != nil {\n\t\twriteErrorInternal(w, err)\n\t\treturn\n\t}\n\tvar tokens []string\n\tq := `SELECT token FROM authtokens WHERE userid=$1\n\t ORDER BY createdat DESC`\n\tif err = db.Get(&tokens, q, cookie.Value); err != nil {\n\t\twriteErrorInternal(w, err)\n\t\treturn\n\t}\n\tbyt, err := json.Marshal(&tokens)\n\tif err != nil {\n\t\twriteErrorInternal(w, err)\n\t\treturn\n\t}\n\t_, err = w.Write(byt)\n\tif err != nil {\n\t\tlog.Info(\"failed to write response.\", err)\n\t}\n}", "title": "" }, { "docid": "7cb8da4dc9c908b511a6f841d3214d40", "score": "0.54151404", "text": "func UserTokensG(mods ...qm.QueryMod) userTokenQuery {\n\treturn UserTokens(boil.GetDB(), mods...)\n}", "title": "" }, { "docid": "d327faf131c38cdda7a8263db8693129", "score": "0.54131556", "text": "func (client *gocloak) GetUsers(token string, realm string) (*[]User, error) {\n\tresp, err := getRequestWithHeader(token).\n\t\tGet(client.basePath + authRealm + realm + \"/users\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar result []User\n\tif err := json.Unmarshal(resp.Body(), &result); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &result, nil\n}", "title": "" }, { "docid": "5f964110777f72b9009d0cdfeb3b00b2", "score": "0.5403984", "text": "func (s *oAuthTokens) List(ctx context.Context, organization string) ([]*OAuthToken, error) {\n\tif !validStringID(&organization) {\n\t\treturn nil, errors.New(\"Invalid value for organization\")\n\t}\n\n\tu := fmt.Sprintf(\"organizations/%s/oauth-tokens\", url.QueryEscape(organization))\n\treq, err := s.client.newRequest(\"GET\", u, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar ots []*OAuthToken\n\terr = s.client.do(ctx, req, &ots)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn ots, nil\n}", "title": "" }, { "docid": "48126a4518b3a9b5065af16c1f8c4fc8", "score": "0.53822815", "text": "func newUserOAuthAccessTokens(c *OauthV1Client) *userOAuthAccessTokens {\n\treturn &userOAuthAccessTokens{\n\t\tclient: c.RESTClient(),\n\t}\n}", "title": "" }, { "docid": "b5e6b96d0a4d40e5cc4cfb0cc7d2b575", "score": "0.53802544", "text": "func getUserToken(email string) (*helpers.AccessToken, *helpers.RefreshToken, *pb.Status) {\n\tuserDB := helpers.ConnectToDB(helpers.GetUserDatabase())\n\taccessTokenChan := make(chan *helpers.AccessToken)\n\trefreshTokenChan := make(chan *helpers.RefreshToken)\n\terrorChan := make(chan bool, 2)\n\tdefer close(accessTokenChan)\n\tdefer close(refreshTokenChan)\n\tdefer close(errorChan)\n\tgo func() {\n\t\taccessToken, err := helpers.GetAccessToken(userDB, email)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Login getting access token error: %v\", err)\n\t\t\terrorChan <- true\n\t\t\taccessTokenChan <- &helpers.AccessToken{Email: \"\", FirstName: \"\", LastName: \"\", ID: \"\", ExpiredTime: time.Now()}\n\n\t\t} else {\n\t\t\tif helpers.IsTokenExpired(accessToken.ExpiredTime) {\n\t\t\t\t//Create a new access token\n\t\t\t\taccessToken = helpers.GenerateAccessToken(accessToken.Email, accessToken.FirstName, accessToken.LastName)\n\t\t\t\t//Save access token to database\n\t\t\t\tsaveAccessToken(userDB, accessToken)\n\t\t\t}\n\t\t\terrorChan <- false\n\t\t\t//Save the new token id to the access token id channel\n\t\t\taccessTokenChan <- accessToken\n\n\t\t}\n\t}()\n\n\tgo func() {\n\t\trefreshToken, err := helpers.GetRefreshToken(userDB, email)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Login getting refresh token error: %v\", err)\n\t\t\terrorChan <- true\n\t\t\trefreshTokenChan <- &helpers.RefreshToken{Email: \"\", ID: \"\", ExpiredTime: time.Now()}\n\n\t\t} else {\n\t\t\t//Check if the refresh token had expired already\n\t\t\t//If the current time is before or equal to the expired time,\n\t\t\t//then it will go into the if statement. If it's after the current time is after the expired time, then\n\t\t\t//it will go into the else statement. If the refresh token is expired then the user will have to provide their\n\t\t\t//credential again in order to generate a new refresh token\n\t\t\tif helpers.IsTokenExpired(refreshToken.ExpiredTime) {\n\t\t\t\t//Create a new refresh token\n\t\t\t\trefreshToken = helpers.GenerateRefreshToken(email)\n\t\t\t\t//Save refresh token to database\n\t\t\t\tsaveRefreshToken(userDB, refreshToken)\n\t\t\t}\n\t\t\terrorChan <- false\n\t\t\t//Save the new token id to the refresh token id channel\n\t\t\trefreshTokenChan <- refreshToken\n\t\t}\n\t}()\n\t//Check if there error occurred when trying to retrieve token from the database\n\tif <-errorChan || <-errorChan {\n\t\treturn <-accessTokenChan, <-refreshTokenChan, &pb.Status{\n\t\t\tCode: helpers.GetInternalServerErrorStatusCode(), Message: \"Server error\"}\n\t}\n\treturn <-accessTokenChan, <-refreshTokenChan, &pb.Status{\n\t\tCode: helpers.GetOkStatusCode(), Message: \"Login Successful\"}\n\n}", "title": "" }, { "docid": "600c6f5ef7200670fd52ccaba133a97e", "score": "0.53578436", "text": "func (a *Client) GetTokens(params *GetTokensParams, authInfo runtime.ClientAuthInfoWriter) (*GetTokensOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewGetTokensParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"getTokens\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/api/v1/repository/{repository}/tokens/{code}\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &GetTokensReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*GetTokensOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for getTokens: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "title": "" }, { "docid": "81802e82b083f9775b07f54d2fda2f76", "score": "0.53493226", "text": "func (u *UsersService) generateTokens(id int) (Tokens, error) {\n\tvar (\n\t\ttokens Tokens\n\t\terr error\n\t)\n\n\ttokens.AccessToken, err = u.tokenManager.NewJWT(strconv.Itoa(id), u.accessTokenTTL)\n\tif err != nil {\n\t\treturn tokens, err\n\t}\n\n\ttokens.RefreshToken, err = u.tokenManager.NewRefreshToken()\n\n\treturn tokens, err\n}", "title": "" }, { "docid": "d0f47babda52e00cd7ed27b9121f8445", "score": "0.5342736", "text": "func (_DhToken *DhTokenSession) GetUserRepo(user common.Address) ([]string, error) {\n\treturn _DhToken.Contract.GetUserRepo(&_DhToken.CallOpts, user)\n}", "title": "" }, { "docid": "cef45070f75678af69c310354a9ef690", "score": "0.53251106", "text": "func GetTasksByUser(c *gin.Context) {\n\t// Get id from the incoming url\n\tuser := c.Param(\"email\")\n\tcontext := NewContext()\n\tdefer context.Close()\n\tcol := context.DbCollection(\"tasks\")\n\trepo := &data.TaskRepository{C: col}\n\ttasks := repo.GetByUser(user)\n\n\tc.JSON(http.StatusOK, TasksResource{Data: tasks})\n}", "title": "" }, { "docid": "7d41c0c8a794b5a8c272623050541e22", "score": "0.53221244", "text": "func (c *Client4) SearchUserAccessTokens(search *UserAccessTokenSearch) ([]*UserAccessToken, *Response, error) {\n\tbuf, err := json.Marshal(search)\n\tif err != nil {\n\t\treturn nil, nil, NewAppError(\"SearchUserAccessTokens\", \"api.marshal_error\", nil, \"\", http.StatusInternalServerError).Wrap(err)\n\t}\n\tr, err := c.DoAPIPostBytes(c.usersRoute()+\"/tokens/search\", buf)\n\tif err != nil {\n\t\treturn nil, BuildResponse(r), err\n\t}\n\tdefer closeBody(r)\n\tvar list []*UserAccessToken\n\tif err := json.NewDecoder(r.Body).Decode(&list); err != nil {\n\t\treturn nil, nil, NewAppError(\"SearchUserAccessTokens\", \"api.unmarshal_error\", nil, \"\", http.StatusInternalServerError).Wrap(err)\n\t}\n\treturn list, BuildResponse(r), nil\n}", "title": "" }, { "docid": "cd8df633edb51b1d2eac46c9b83db450", "score": "0.53138727", "text": "func (s *UsersService) GetAllImpersonationTokens(user int, opt *GetAllImpersonationTokensOptions, options ...RequestOptionFunc) ([]*ImpersonationToken, *Response, error) {\n\tu := fmt.Sprintf(\"users/%d/impersonation_tokens\", user)\n\n\treq, err := s.client.NewRequest(http.MethodGet, u, opt, options)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tvar ts []*ImpersonationToken\n\tresp, err := s.client.Do(req, &ts)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn ts, resp, nil\n}", "title": "" }, { "docid": "e8c4e42813d278cc14885fe19288a865", "score": "0.5299343", "text": "func getUserRepos(ctx context.Context, client *github.Client, user string) ([]*github.Repository, error) {\n\tvar repos []*github.Repository\n\tvar loOpts = github.RepositoryListOptions{}\n\tresp, err := buildCompleteList(func(opts *github.ListOptions) (*github.Response, error) {\n\t\tloOpts.ListOptions = *opts\n\t\tnext, resp, err := client.Repositories.List(ctx, user, &loOpts)\n\t\trepos = append(repos, next...)\n\t\treturn resp, err\n\t})\n\n\tif err != nil {\n\t\treturn nil, exterror.Create(resp.StatusCode, err)\n\t}\n\n\treturn repos, nil\n}", "title": "" }, { "docid": "a5d5dc6fa7478dcdb3d19392a83abe9e", "score": "0.5289404", "text": "func (r *Runner) AccessTokens(hsDomain string) map[string]string {\n\tres := make(map[string]string)\n\tfor key, val := range r.lookup {\n\t\tif strings.HasPrefix(key, \"user_@\") && strings.HasSuffix(key, \":\"+hsDomain) {\n\t\t\tres[strings.TrimPrefix(key, \"user_\")] = val\n\t\t}\n\t}\n\treturn res\n}", "title": "" }, { "docid": "be5a43c09679366935d993cbda57aec2", "score": "0.5288927", "text": "func (t *Twitch) GetUserByToken(ctx context.Context, userToken *oauth2.Token) (user *User, newToken *oauth2.Token, err error) {\n\tcli := t.helixClientForUser(ctx, userToken, setToken(&newToken))\n\tuser, err = getUser(ctx, cli, \"\", 0)\n\treturn user, newToken, err\n}", "title": "" }, { "docid": "aebc7cde0631c25b355aba5fe16f9ef9", "score": "0.5286136", "text": "func (r *TokensService) Get(userKey string, clientId string) *TokensGetCall {\n\tc := &TokensGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.userKey = userKey\n\tc.clientId = clientId\n\treturn c\n}", "title": "" }, { "docid": "1334ca1f7bfc6d2d6f9d7494f25ee8d9", "score": "0.52836084", "text": "func (c *UserClient) QueryTokens(u *User) *TokenQuery {\n\tquery := &TokenQuery{config: c.config}\n\tquery.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {\n\t\tid := u.ID\n\t\tstep := sqlgraph.NewStep(\n\t\t\tsqlgraph.From(user.Table, user.FieldID, id),\n\t\t\tsqlgraph.To(token.Table, token.FieldID),\n\t\t\tsqlgraph.Edge(sqlgraph.O2M, false, user.TokensTable, user.TokensColumn),\n\t\t)\n\t\tfromV = sqlgraph.Neighbors(u.driver.Dialect(), step)\n\t\treturn fromV, nil\n\t}\n\treturn query\n}", "title": "" }, { "docid": "ad7c89801170caa0bfddc1515d5346d8", "score": "0.52823746", "text": "func (env *Env) GetTokens(res http.ResponseWriter, req *http.Request) {\n\tmasterToken, err := getMasterToken(env.db)\n\tif err != nil {\n\t\tutil.SendErrRes(res, err)\n\t\treturn\n\t}\n\tjsonRes, err := json.Marshal(env.token.ToBundle(masterToken))\n\tif err != nil {\n\t\tutil.SendErrRes(res, err)\n\t\treturn\n\t}\n\tutil.SendJSONRes(res, jsonRes)\n}", "title": "" }, { "docid": "c0fe4b7bcb5d3dd16081111d8c6bef0d", "score": "0.5277703", "text": "func GetMyWatchedRepos(ctx *context.APIContext) {\n\t// swagger:operation GET /user/subscriptions user userCurrentListSubscriptions\n\t// ---\n\t// summary: List repositories watched by the authenticated user\n\t// produces:\n\t// - application/json\n\t// parameters:\n\t// - name: page\n\t// in: query\n\t// description: page number of results to return (1-based)\n\t// type: integer\n\t// - name: limit\n\t// in: query\n\t// description: page size of results\n\t// type: integer\n\t// responses:\n\t// \"200\":\n\t// \"$ref\": \"#/responses/RepositoryList\"\n\n\trepos, total, err := getWatchedRepos(ctx, ctx.Doer, true, utils.GetListOptions(ctx))\n\tif err != nil {\n\t\tctx.Error(http.StatusInternalServerError, \"getWatchedRepos\", err)\n\t}\n\n\tctx.SetTotalCountHeader(total)\n\tctx.JSON(http.StatusOK, &repos)\n}", "title": "" }, { "docid": "89217db21994874a1ec1c45364f0e079", "score": "0.52415544", "text": "func GenerateAuthenticationTokenByUser(user models.User) (*models.AuthenticationToken, error) {\n\tnow := time.Now().UTC()\n\texpTime := now.Add(604800 * time.Second) //Expire for 7 days\n\n\taccessToken := jwt.New(jwt.SigningMethodHS256)\n\tclaims := make(jwt.MapClaims)\n\tclaims[\"exp\"] = expTime.Unix()\n\tclaims[\"uid\"] = user.Id\n\taccessToken.Claims = claims\n\taccessTokenStr, err := accessToken.SignedString(hmacSecret)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trefreshToken := jwt.New(jwt.SigningMethodHS256)\n\tclaims = make(jwt.MapClaims)\n\tclaims[\"uid\"] = user.Id\n\tclaims[\"ref\"] = \"refresh\"\n\trefreshToken.Claims = claims\n\trefreshTokenStr, err := refreshToken.SignedString(hmacSecret)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &models.AuthenticationToken{\n\t\tAccessToken: accessTokenStr,\n\t\tRefreshToken: refreshTokenStr,\n\t}, nil\n}", "title": "" }, { "docid": "f9bd527c2db141439a33fb57feba3260", "score": "0.52410936", "text": "func (_DhToken *DhTokenCallerSession) GetUserRepo(user common.Address) ([]string, error) {\n\treturn _DhToken.Contract.GetUserRepo(&_DhToken.CallOpts, user)\n}", "title": "" }, { "docid": "511d830c4dce0de983d8956a688804dd", "score": "0.5235342", "text": "func (p GithubProvider) GetUser(token *oauth2.Token) (string, error) {\n\tapiReq, err := http.NewRequest(\"GET\", \"https://api.github.com/user/emails\", nil)\n\tapiReq.Header.Add(\"Accept\", \"application/vnd.github.v3+json\")\n\tapiReq.Header.Add(\"Authorization\", \"token \"+token.AccessToken)\n\tclient := &http.Client{}\n\tresponse, err := client.Do(apiReq)\n\tdefer response.Body.Close()\n\tif err != nil {\n\t\tlog.Println(\"Auth error\", err)\n\t\treturn \"\", fmt.Errorf(\"Authentification error\")\n\t}\n\n\tdec := json.NewDecoder(response.Body)\n\tvar emails []githubEmail\n\terr = dec.Decode(&emails)\n\tif err != nil {\n\t\tlog.Println(\"Error reading github API response\", err)\n\t\treturn \"\", fmt.Errorf(\"Error reading github API response\")\n\t}\n\tvar userEmail string\n\tfor _, email := range emails {\n\t\tif email.Primary && email.Verified {\n\t\t\tuserEmail = email.Email\n\t\t}\n\t}\n\tlog.Println(\"User email:\", userEmail)\n\treturn userEmail, nil\n}", "title": "" }, { "docid": "879db3e90b473fd6a8ab75a570bf95fb", "score": "0.5230232", "text": "func (a *Api) GetUsers(res http.ResponseWriter, req *http.Request) {\n\tsessionToken := req.Header.Get(TP_SESSION_TOKEN)\n\tif tokenData, err := a.tokenAuthenticator.Authenticate(req.Context(), sessionToken); err != nil {\n\t\ta.sendError(res, http.StatusUnauthorized, STATUS_UNAUTHORIZED, err)\n\n\t} else if !tokenData.IsServer {\n\t\ta.sendError(res, http.StatusUnauthorized, STATUS_UNAUTHORIZED)\n\n\t} else if len(req.URL.Query()) == 0 {\n\t\ta.sendError(res, http.StatusBadRequest, STATUS_NO_QUERY)\n\n\t} else if role := req.URL.Query().Get(\"role\"); role != \"\" && !IsValidRole(role) {\n\t\ta.sendError(res, http.StatusBadRequest, STATUS_INVALID_ROLE)\n\n\t} else if userIds := strings.Split(req.URL.Query().Get(\"id\"), \",\"); len(userIds[0]) > 0 && role != \"\" {\n\t\ta.sendError(res, http.StatusBadRequest, STATUS_ONE_QUERY_PARAM)\n\n\t} else if createdFrom, dateErr := ParseAndValidateDateParam(req.URL.Query().Get(\"createdFrom\")); dateErr != nil {\n\t\ta.sendError(res, http.StatusBadRequest, STATUS_INVALID_QUERY_PARAM+\"createdFrom\")\n\n\t} else if createdTo, dateErr := ParseAndValidateDateParam(req.URL.Query().Get(\"createdTo\")); dateErr != nil {\n\t\ta.sendError(res, http.StatusBadRequest, STATUS_INVALID_QUERY_PARAM+\"createdTo\")\n\n\t} else {\n\t\tvar users []*User\n\t\tswitch {\n\t\tcase role != \"\":\n\n\t\t\tswitch {\n\t\t\tcase !createdFrom.IsZero() || !createdTo.IsZero():\n\t\t\t\tif users, err = a.Store.WithContext(req.Context()).FindUsersByRoleAndDate(role, createdFrom, createdTo); err != nil {\n\t\t\t\t\ta.sendError(res, http.StatusInternalServerError, STATUS_ERR_FINDING_USR, err.Error())\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tif users, err = a.Store.WithContext(req.Context()).FindUsersByRole(role); err != nil {\n\t\t\t\t\ta.sendError(res, http.StatusInternalServerError, STATUS_ERR_FINDING_USR, err.Error())\n\t\t\t\t}\n\t\t\t}\n\n\t\tcase len(userIds[0]) > 0:\n\t\t\tif users, err = a.Store.WithContext(req.Context()).FindUsersWithIds(userIds); err != nil {\n\t\t\t\ta.sendError(res, http.StatusInternalServerError, STATUS_ERR_FINDING_USR, err.Error())\n\t\t\t}\n\t\tdefault:\n\t\t\ta.sendError(res, http.StatusBadRequest, STATUS_PARAMETER_UNKNOWN)\n\t\t}\n\t\ta.logMetric(\"getusers\", sessionToken, map[string]string{\"server\": strconv.FormatBool(tokenData.IsServer)})\n\t\ta.sendUsers(res, users, tokenData.IsServer)\n\t}\n}", "title": "" }, { "docid": "454eb4bbd300e97796256a9ff0bc616c", "score": "0.5221299", "text": "func (h *Handlers) GetByUser(w http.ResponseWriter, r *http.Request) {\n\tp, err := helpers.GetPagination(r.URL.Query(), helpers.PaginationDefaultLimit, helpers.PaginationMaxLimit)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"%w: %w\", hub.ErrInvalidInput, err)\n\t\th.logger.Error().Err(err).Str(\"query\", r.URL.RawQuery).Str(\"method\", \"GetByUser\").Send()\n\t\thelpers.RenderErrorJSON(w, err)\n\t\treturn\n\t}\n\tresult, err := h.orgManager.GetByUserJSON(r.Context(), p)\n\tif err != nil {\n\t\th.logger.Error().Err(err).Str(\"method\", \"GetByUser\").Send()\n\t\thelpers.RenderErrorJSON(w, err)\n\t\treturn\n\t}\n\tw.Header().Set(helpers.PaginationTotalCount, strconv.Itoa(result.TotalCount))\n\thelpers.RenderJSON(w, result.Data, 0, http.StatusOK)\n}", "title": "" }, { "docid": "e7fd59a2f603b6a05839e7d9fe008fcb", "score": "0.5213946", "text": "func (g GenjiDatastore) GetUsers(token string) ([]string, error) {\n\tif len(token) != defaultTokenLength {\n\t\treturn []string{}, fmt.Errorf(\"Session token does not match desired length\")\n\t}\n\n\tse, err := sessionExists(token)\n\tif !se {\n\t\treturn []string{}, fmt.Errorf(\"Specified session does not exist\")\n\t}\n\n\tusers, err := getUsersFromSession(token)\n\n\treturn users, err\n}", "title": "" }, { "docid": "8144dd94a293e1cf9e56fce5440b5f92", "score": "0.5200726", "text": "func ListAccessTokens(client *gophercloud.ServiceClient, userID string) pagination.Pager {\n\turl := userAccessTokensURL(client, userID)\n\treturn pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {\n\t\treturn AccessTokensPage{pagination.LinkedPageBase{PageResult: r}}\n\t})\n}", "title": "" }, { "docid": "329fb9f58e3c23efc5a64b0f3602b6d6", "score": "0.5200161", "text": "func (c *Client) ListOauth2(opt ListOauth2Option) ([]*Oauth2, *Response, error) {\n\tif err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil {\n\t\treturn nil, nil, err\n\t}\n\topt.setDefaults()\n\toauth2s := make([]*Oauth2, 0, opt.PageSize)\n\tresp, err := c.getParsedResponse(\"GET\", fmt.Sprintf(\"/user/applications/oauth2?%s\", opt.getURLQuery().Encode()), nil, nil, &oauth2s)\n\treturn oauth2s, resp, err\n}", "title": "" }, { "docid": "346812b38add8a2ad15f3034a2fab0c4", "score": "0.51946276", "text": "func (client *gocloak) GetUsers(token string, realm string, params GetUsersParams) ([]*User, error) {\n\tvar result []*User\n\tqueryParams, err := GetQueryParams(params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp, err := client.getRequestWithBearerAuth(token).\n\t\tSetResult(&result).\n\t\tSetQueryParams(queryParams).\n\t\tGet(client.getAdminRealmURL(realm, \"users\"))\n\n\tif err := checkForError(resp, err); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn result, nil\n}", "title": "" }, { "docid": "15a423e39e74428049bd4a5f56a4fc1c", "score": "0.518561", "text": "func (_Reserve *ReserveCallerSession) GetTokens() ([]common.Address, error) {\n\treturn _Reserve.Contract.GetTokens(&_Reserve.CallOpts)\n}", "title": "" }, { "docid": "9e372c3208a1980cbe7f3f1856e7b13e", "score": "0.5172933", "text": "func (_DhToken *DhTokenCaller) GetUserRepo(opts *bind.CallOpts, user common.Address) ([]string, error) {\n\tvar (\n\t\tret0 = new([]string)\n\t)\n\tout := ret0\n\terr := _DhToken.contract.Call(opts, out, \"getUserRepo\", user)\n\treturn *ret0, err\n}", "title": "" }, { "docid": "0f335ecf825cbd0a6c7baa1f0e20627d", "score": "0.5170145", "text": "func FilterWorkspacesUserHasAccessTo(workspaceIds []string, accessToken string) ([]string, error) {\n\tlogrus.Trace(\"FilterWorkspacesUserHasAccessTo start\")\n\tdefer logrus.Trace(\"FilterWorkspacesUserHasAccessTo end\")\n\tserverAccessToken, err := GetResourceServerAccessToken()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get the access token for the resource server. Error: %w\", err)\n\t}\n\tpayload, err := DecodeToken(accessToken)\n\tif err != nil {\n\t\tif _, ok := err.(types.ErrorTokenExpired); ok {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn nil, fmt.Errorf(\"failed to decode the access token to get the user roles. Error: %w\", err)\n\t}\n\tdecodedToken := decodedToken{}\n\tif err := json.Unmarshal(payload, &decodedToken); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to unmarshal the token as json. Error: %w\", err)\n\t}\n\tif decodedToken.Subject == \"\" {\n\t\treturn nil, fmt.Errorf(\"the access token has an empty 'sub' field\")\n\t}\n\tif decodedToken.ClientId == \"\" {\n\t\tif decodedToken.AZP == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"the access token has an empty 'client id' field and an empty 'azp' field\")\n\t\t}\n\t\tdecodedToken.ClientId = decodedToken.AZP\n\t}\n\tclientIdNotClientId := \"\"\n\tif decodedToken.ClientId == common.Config.M2kClientClientId {\n\t\tclientIdNotClientId = common.Config.M2kClientIdNotClientId\n\t} else {\n\t\tclients, err := common.AuthServerClient.GetClients(context.TODO(), serverAccessToken, common.Config.AuthServerRealm, gocloak.GetClientsParams{ClientID: &decodedToken.ClientId})\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to get the authz server id of the client with OAuth id %s . Error: %w\", decodedToken.ClientId, err)\n\t\t}\n\t\tif len(clients) != 1 {\n\t\t\treturn nil, fmt.Errorf(\"expected exactly one client with the OAuth id. Actual length: %d Actual: %+v\", len(clients), clients)\n\t\t}\n\t\tif clients[0].ID == nil {\n\t\t\treturn nil, fmt.Errorf(\"the authz server id for the client with OAuth id %s is nil\", clients)\n\t\t}\n\t\tclientIdNotClientId = *clients[0].ID\n\t}\n\tuserRoles, err := GetCompositeClientRolesByUserID(context.TODO(), serverAccessToken, common.Config.AuthServerRealm, clientIdNotClientId, decodedToken.Subject, false)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get the roles for the user with %s . Error: %w\", decodedToken.Subject, err)\n\t}\n\t// check for a fake user and get the roles of the fake user as well\n\tuser, err := common.AuthServerClient.GetUserByID(context.TODO(), serverAccessToken, common.Config.AuthServerRealm, decodedToken.Subject)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get the user attributes. Error: %w\", err)\n\t}\n\tif user.Username != nil && user.Attributes != nil {\n\t\tif idpIdAttr, ok := (*user.Attributes)[common.IDP_ID_ROUTE_VAR]; ok && len(idpIdAttr) == 1 {\n\t\t\tidpId := idpIdAttr[0]\n\t\t\tfakeUserName := idpId + common.DELIM + *user.Username\n\t\t\tusers, err := common.AuthServerClient.GetUsers(context.TODO(), serverAccessToken, common.Config.AuthServerRealm, gocloak.GetUsersParams{Username: &fakeUserName})\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to get the users with the username %s . Error: %w\", fakeUserName, err)\n\t\t\t}\n\t\t\tif len(users) == 1 && users[0] != nil {\n\t\t\t\tfakeUser := *users[0]\n\t\t\t\tif fakeUser.ID == nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"the fake user has a nil ID\")\n\t\t\t\t}\n\t\t\t\t// fakeUser.ClientRoles is usually empty because keycloak only returns a subset of the user's fields\n\t\t\t\tfakeUserRoles, err := GetCompositeClientRolesByUserID(context.TODO(), serverAccessToken, common.Config.AuthServerRealm, clientIdNotClientId, *fakeUser.ID, false)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"failed to get the client roles for the fake user with username %s and id %s . Error: %w\", fakeUserName, *fakeUser.ID, err)\n\t\t\t\t}\n\t\t\t\tuserRoles = append(userRoles, fakeUserRoles...)\n\t\t\t}\n\t\t}\n\t}\n\t// filter workspaces user has access to\n\tfilteredIds := []string{}\n\tif len(userRoles) == 0 {\n\t\tlogrus.Debug(\"the user has no roles\")\n\t\treturn filteredIds, nil\n\t}\n\tfor _, workspaceId := range workspaceIds {\n\t\turl := fmt.Sprintf(URL_READ_WORKSPACE, workspaceId)\n\t\tif rolesHaveAccess(url+\"/\", userRoles) || rolesHaveAccess(url, userRoles) { // \"/workspaces/work-1/\" is same as \"/workspaces/work-1\"\n\t\t\tfilteredIds = append(filteredIds, workspaceId)\n\t\t}\n\t}\n\treturn filteredIds, nil\n}", "title": "" }, { "docid": "c194ccb220b36449143a0d5b88a34fbf", "score": "0.5169428", "text": "func GetCommitsByUser(w http.ResponseWriter, r *http.Request) {\n\tuser, err := url.QueryUnescape(r.URL.Query().Get(\"user\"))\n\tif err != nil {\n\t\tfmt.Fprintf(w, `{\"error\":\"'user' parameter is required.\"}`)\n\t\treturn\n\t}\n\tvar commits []model.UserCommits\n\tif !model.IsUserAlias(user) {\n\t\tuser_profile, err := model.InitUserFromJson(user + \".json\")\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(w, `{\"error\":\"user not found\"}`)\n\t\t\treturn\n\t\t}\n\t\tcommits, err = model.FindMultiUserCommits(user_profile.Aliases)\n\t} else {\n\t\tcommits, err = model.FindUserCommits(user)\n\t}\n\tif err != nil {\n\t\tfmt.Fprintf(w, `{\"error\":\"problem downloading commits from the cloud\"}`)\n\t\tfmt.Printf(\"Error loading commits from cloudant for user=\" + user)\n\t\treturn\n\t}\n\tjs, err := json.Marshal(commits)\n\tif err != nil {\n\t\tfmt.Printf(\"GetCommitsByUser: error marshaling user commits to json: %s\\n\", err)\n\t\treturn\n\t}\n\tfmt.Fprintf(w, string(js))\n}", "title": "" }, { "docid": "c9c1faf29e7634eb97dd618d039e2c28", "score": "0.51671606", "text": "func (c *userOAuthAccessTokens) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.UserOAuthAccessToken, err error) {\n\tresult = &v1.UserOAuthAccessToken{}\n\terr = c.client.Get().\n\t\tResource(\"useroauthaccesstokens\").\n\t\tName(name).\n\t\tVersionedParams(&options, scheme.ParameterCodec).\n\t\tDo(ctx).\n\t\tInto(result)\n\treturn\n}", "title": "" }, { "docid": "2d763a29927ef0bcc208766874f5839b", "score": "0.5166834", "text": "func (c *DefaultContract) TokensOwnedBy(owner string) ([]string, error) {\n\tif c.OwnedTokens == nil {\n\t\tif err := c.fetchOwnedTokens(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tif tokens, ok := c.OwnedTokens[owner]; ok {\n\t\treturn tokens, nil\n\t}\n\treturn nil, ErrNoExist\n}", "title": "" }, { "docid": "60bedb241569cfeeed3168af8840ce25", "score": "0.5162737", "text": "func (a Client) FindTokens(processId string, instanceId string, page int32, perPage int32) (*TokenCollection, *APIResponse, error) {\n\n\tvar httpMethod = \"Get\"\n\t// create path and map variables\n\tpath := a.Configuration.BasePath + \"/processes/{process_id}/instances/{instance_id}/tokens\"\n\tpath = strings.Replace(path, \"{\"+\"process_id\"+\"}\", fmt.Sprintf(\"%v\", processId), -1)\n\tpath = strings.Replace(path, \"{\"+\"instance_id\"+\"}\", fmt.Sprintf(\"%v\", instanceId), -1)\n\n\n\theaderParams := make(map[string]string)\n\tqueryParams := url.Values{}\n\tformParams := make(map[string]string)\n\tvar postBody interface{}\n\tvar fileName string\n\tvar fileBytes []byte\n\t// authentication '(PasswordGrant)' required\n\t// oauth required\n\tif a.Configuration.AccessToken != \"\"{\n\t\theaderParams[\"Authorization\"] = \"Bearer \" + a.Configuration.AccessToken\n\t}\n\t// add default headers if any\n\tfor key := range a.Configuration.DefaultHeader {\n\t\theaderParams[key] = a.Configuration.DefaultHeader[key]\n\t}\n\t\tqueryParams.Add(\"page\", a.Configuration.APIClient.ParameterToString(page, \"\"))\n\t\t\tqueryParams.Add(\"per_page\", a.Configuration.APIClient.ParameterToString(perPage, \"\"))\n\t\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{ \"application/vnd.api+json\", }\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\theaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\n\t\t\"application/vnd.api+json\",\n\t}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\theaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tvar successPayload = new(TokenCollection)\n\thttpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)\n\tif err != nil {\n\t\treturn successPayload, NewAPIResponse(httpResponse.RawResponse), err\n\t}\n\terr = json.Unmarshal(httpResponse.Body(), &successPayload)\n\treturn successPayload, NewAPIResponse(httpResponse.RawResponse), err\n}", "title": "" }, { "docid": "c103b577418ea6b7b21411395ea16638", "score": "0.5150526", "text": "func GetWatchedRepos(ctx *context.APIContext) {\n\t// swagger:operation GET /users/{username}/subscriptions user userListSubscriptions\n\t// ---\n\t// summary: List the repositories watched by a user\n\t// produces:\n\t// - application/json\n\t// parameters:\n\t// - name: username\n\t// type: string\n\t// in: path\n\t// description: username of the user\n\t// required: true\n\t// - name: page\n\t// in: query\n\t// description: page number of results to return (1-based)\n\t// type: integer\n\t// - name: limit\n\t// in: query\n\t// description: page size of results\n\t// type: integer\n\t// responses:\n\t// \"200\":\n\t// \"$ref\": \"#/responses/RepositoryList\"\n\n\tprivate := ctx.ContextUser.ID == ctx.Doer.ID\n\trepos, total, err := getWatchedRepos(ctx, ctx.ContextUser, private, utils.GetListOptions(ctx))\n\tif err != nil {\n\t\tctx.Error(http.StatusInternalServerError, \"getWatchedRepos\", err)\n\t}\n\n\tctx.SetTotalCountHeader(total)\n\tctx.JSON(http.StatusOK, &repos)\n}", "title": "" }, { "docid": "d0e107aa754517474347a0e909ab865c", "score": "0.5134413", "text": "func (c *ConfigBackedCachingProvider) GetTokens() (*TokenResult, error) {\n\taccessToken, refreshToken := c.config.GetTokens(c.identifier)\n\treturn &TokenResult{\n\t\tAccessToken: accessToken,\n\t\tRefreshToken: refreshToken,\n\t}, nil\n}", "title": "" }, { "docid": "d0e107aa754517474347a0e909ab865c", "score": "0.5134413", "text": "func (c *ConfigBackedCachingProvider) GetTokens() (*TokenResult, error) {\n\taccessToken, refreshToken := c.config.GetTokens(c.identifier)\n\treturn &TokenResult{\n\t\tAccessToken: accessToken,\n\t\tRefreshToken: refreshToken,\n\t}, nil\n}", "title": "" }, { "docid": "c298cb988d1608609e9c650008d3c699", "score": "0.5124258", "text": "func GetUserByAccessToken(r *http.Request) (User, error) {\n\tvar user User\n\ttoken := r.URL.Query().Get(\"access_token\")\n\tif token == \"\" {\n\t\ttoken = r.Header.Get(\"Access-Token\")\n\t}\n\tif len(token) != 40 {\n\t\treturn user, ErrInvalidAccessToken\n\t}\n\tuser, ok := token2Users[token]\n\tif !ok {\n\t\treturn user, ErrInvalidAccessToken\n\t}\n\treturn user, nil\n}", "title": "" }, { "docid": "9cd3e2d9f8caba8d57ec4829fb3c22bd", "score": "0.50836873", "text": "func (_Reserve *ReserveCaller) GetTokens(opts *bind.CallOpts) ([]common.Address, error) {\n\tvar (\n\t\tret0 = new([]common.Address)\n\t)\n\tout := ret0\n\terr := _Reserve.contract.Call(opts, out, \"getTokens\")\n\treturn *ret0, err\n}", "title": "" }, { "docid": "92cbec4d9a3ede5bedb221f76cc0ad1e", "score": "0.507793", "text": "func ListAccessTokens(uid int64) ([]*AccessToken, error) {\n\ttokens := make([]*AccessToken, 0, 5)\n\terr := x.Where(\"uid=?\", uid).Desc(\"id\").Find(&tokens)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, t := range tokens {\n\t\tt.HasUsed = t.Updated.After(t.Created)\n\t\tt.HasRecentActivity = t.Updated.Add(7 * 24 * time.Hour).After(time.Now())\n\t}\n\treturn tokens, nil\n}", "title": "" }, { "docid": "27667e07e246ae1010daf8e04f8b219f", "score": "0.50718987", "text": "func (r *SQLRepo) getMicroDepositsForUser(id id.Depository, userID id.User) ([]*MicroDeposit, error) {\n\tquery := `select amount, file_id, transaction_id from micro_deposits where user_id = ? and depository_id = ? and deleted_at is null`\n\tstmt, err := r.db.Prepare(query)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer stmt.Close()\n\n\trows, err := stmt.Query(userID, id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\n\treturn accumulateMicroDeposits(rows)\n}", "title": "" }, { "docid": "c189b29b6e35ef9cbd1feba85156238f", "score": "0.50624174", "text": "func (r *Repository) getAuthenticationsByUserID(ctx context.Context, id string) ([]*entity.Authentication, error) {\n\tfailed := func(err error) ([]*entity.Authentication, error) {\n\t\treturn nil, fmt.Errorf(\"Repository.getAuthenticationsByUserID %q -> %w\", id, err)\n\t}\n\n\tvar sa []*entity.Authentication\n\tquery := \"SELECT provider, social_id FROM user_authentications WHERE user_id = $1\"\n\trows, err := r.db.QueryContext(ctx, query, id)\n\tif err != nil {\n\t\treturn failed(err)\n\t}\n\tdefer rows.Close()\n\tfor rows.Next() {\n\t\ta := &entity.Authentication{}\n\t\tif err := rows.Scan(&a.Provider, &a.SocialID); err != nil {\n\t\t\treturn failed(err)\n\t\t}\n\t\tsa = append(sa, a)\n\t}\n\tif err := rows.Err(); err != nil {\n\t\treturn failed(err)\n\t}\n\treturn sa, nil\n}", "title": "" }, { "docid": "23b6acfee8a3059f4c4db9a9ff0b052f", "score": "0.50579864", "text": "func HandleUserByTokenRetrieval(c *gin.Context, service usersInteractionService) {\n\tcommons.WithUsername(c, func(username string) {\n\t\tretrievedUser, err := service.GetUser(username)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Could not retrieve the user : %s\", err.Error())\n\t\t\tc.JSON(http.StatusNotFound, commons.Response(err.Error()))\n\t\t} else {\n\t\t\tlog.Infof(\"Successfully retrieved the user data for [%s]\", username)\n\t\t\tc.JSON(http.StatusOK, retrievedUser)\n\t\t}\n\t})\n}", "title": "" }, { "docid": "b03098f5e00428376d43757520e1ef50", "score": "0.5045776", "text": "func GetUserByToken(token string) *User {\n\tsession := getSession()\n\tif session == nil {\n\t\treturn nil\n\t}\n\n\tc := session.DB(\"githubpush\").C(\"users\")\n\n\tresult := &User{}\n\terr := c.Find(bson.M{\"githubtoken\": token}).One(result)\n\tif err != nil {\n\t\tlog.Println(\"GetUserByToken error: \", err.Error(), token)\n\t}\n\treturn result\n}", "title": "" }, { "docid": "12816223014580acc4cff899a0b83581", "score": "0.5041476", "text": "func NewTokens(user *datastore.Key, client *datastore.Client) (auth, refresh string, err error) {\n\tauth, err = newAuth(user)\n\tif err != nil {\n\t\treturn\n\t}\n\n\trefresh, err = newRefresh(user, client)\n\treturn\n}", "title": "" }, { "docid": "693d8487b905cc7d3f443446e6f3af96", "score": "0.50404185", "text": "func (f *elastiCacheFetcher) getUserTags(ctx context.Context, user *elasticache.User, client elasticacheiface.ElastiCacheAPI) ([]*elasticache.Tag, error) {\n\tgetFunc := func(ctx context.Context) ([]*elasticache.Tag, error) {\n\t\toutput, err := client.ListTagsForResourceWithContext(ctx, &elasticache.ListTagsForResourceInput{\n\t\t\tResourceName: user.ARN,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, trace.Wrap(libaws.ConvertRequestFailureError(err))\n\t\t}\n\t\treturn output.TagList, nil\n\t}\n\n\tuserTags, err := libutils.FnCacheGet(ctx, f.cache, aws.StringValue(user.ARN), getFunc)\n\tif err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\n\treturn userTags, nil\n}", "title": "" }, { "docid": "1c09a9780e23461ea116c5c189f7553f", "score": "0.5032592", "text": "func (p *ResultsServerServiceClient) GetSearchResultsByUser(taskType AnnotationTaskType, userId string, limit int32) (r []*SearchResult_, err error) {\n if err = p.sendGetSearchResultsByUser(taskType, userId, limit); err != nil { return }\n return p.recvGetSearchResultsByUser()\n}", "title": "" }, { "docid": "cc7b44de25c0643d7832ba0a87f58b7b", "score": "0.50236404", "text": "func GetUserFromToken(authToken string) User {\n\tCurrentUser := User{}\n\t_, err := UnmarshalFromGetResponse(DefaultConfig.GitURL+\"/user\", authToken, &CurrentUser)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\treturn CurrentUser\n}", "title": "" }, { "docid": "f1e30aaaf30270c2c935bda34e524686", "score": "0.502177", "text": "func getClient(config *oauth2.Config) *http.Client {\n // The file token.json stores the user's access and refresh tokens, and is\n // created automatically when the authorization flow completes for the first\n // time.\n tokFile := \"/tokens/token.json\"\n tok, _ := tokenFromFile(tokFile)\n return config.Client(context.Background(), tok)\n}", "title": "" }, { "docid": "db0d53312bb95ec207838e7d87635816", "score": "0.5017021", "text": "func (me *COHESITYMANAGEMENTSDK_IMPL) AccessTokens() accesstokens.ACCESSTOKENS {\r\n\tif (me.accesstokens) == nil {\r\n\t\tme.accesstokens = accesstokens.NewACCESSTOKENS(me.config)\r\n\t}\r\n\treturn me.accesstokens\r\n}", "title": "" }, { "docid": "8baa0cd3fdadc34e89c72ac14c0a3899", "score": "0.501097", "text": "func (c *Client) GetTokens(options *GetTokensOptions) ([]*TokenSummary, error) {\n\tmethod := \"GET\"\n\ttemplate := tokenTemplates[\"GetTokens\"]\n\n\tresult := []*TokenSummary{}\n\terr := c.Do(method, template, options, nil, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn result, nil\n}", "title": "" }, { "docid": "21046ddddb9c5f7ea88037c48fa82251", "score": "0.50082254", "text": "func FindProvidersByUser(tx *storage.Connection, user *User) ([]string, error) {\n\tidentities := []Identity{}\n\tproviders := make([]string, 0)\n\tif err := tx.Q().Select(\"provider\").Where(\"user_id = ?\", user.ID).All(&identities); err != nil {\n\t\tif errors.Cause(err) == sql.ErrNoRows {\n\t\t\treturn providers, nil\n\t\t}\n\t\treturn nil, errors.Wrap(err, \"error finding providers\")\n\t}\n\tfor _, identity := range identities {\n\t\tproviders = append(providers, identity.Provider)\n\t}\n\treturn providers, nil\n}", "title": "" }, { "docid": "8c3b942eac6f0439b5896f3d2324f824", "score": "0.50037515", "text": "func (c *ChannelsMethod) GetEditors(id ID) ([]User, error) {\n\terr := c.au.checkScope(scopeChannelRead)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tuList := struct {\n\t\tTotal int `json:\"_total\"`\n\t\tUserList []User `json:\"users\"`\n\t}{}\n\n\t_, err = c.client.Get(c.au, fmt.Sprintf(\"channels/%s/editors\", id), &uList)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif uList.Total != 1 {\n\t\treturn nil, fmt.Errorf(\"Total Number of Users was: %d\", uList.Total)\n\t}\n\n\treturn uList.UserList, nil\n}", "title": "" }, { "docid": "3f0e21e4374bdc8a6f700c25cd0aa619", "score": "0.49972308", "text": "func oauth2_token(cui PfUI) {\n\tvar errs []string\n\n\tclient_id := oauth2_get(cui, &errs, \"client_id\")\n\tgrant_type := oauth2_get(cui, &errs, \"grant_type\")\n\tredirect := oauth2_get(cui, &errs, \"redirect_uri\")\n\tcode := oauth2_get(cui, &errs, \"code\")\n\n\t/*\n\t * We do not check the client_secret as authentication\n\t * happens using tokens, the one in 'code'\n\t * client_secret := oauth2_get(cui, &errs, \"client_secret\")\n\t */\n\n\t/* Check redirect URL */\n\toauth2_check_redir(redirect, &errs)\n\n\t/* Check the code */\n\tclaims, err := pf.OAuth2_AuthToken_Check(code)\n\n\tif err != nil {\n\t\terrs = append(errs, err.Error())\n\t}\n\n\tif len(errs) != 0 {\n\t\tH_errmsgs(cui, errs)\n\t\treturn\n\t}\n\n\t/* Who they claim they are */\n\tif claims.ClientID != client_id {\n\t\terrs = append(errs, \"Mismatching client_id\")\n\t\tH_errmsgs(cui, errs)\n\t\treturn\n\t}\n\n\t/* Scope */\n\tscope := claims.Scope\n\n\t/* Grant Type */\n\tswitch grant_type {\n\tcase \"authorization_code\":\n\t\tvar at struct {\n\t\t\tAccess_token string `json:\"access_token\"`\n\t\t\tToken_type string `json:\"token_type\"`\n\t\t\tScope string `json:\"scope\"`\n\t\t\tInfo struct {\n\t\t\t\tName string `json:\"name\"`\n\t\t\t} `json:\"info\"`\n\t\t}\n\n\t\tvar tok string\n\t\ttok, err = pf.OAuth2_AccessToken_New(cui, client_id, scope)\n\n\t\tat.Access_token = tok\n\t\tat.Token_type = \"bearer\"\n\t\tat.Scope = scope\n\t\tat.Info.Name = \"Trident/Pitchfork\"\n\n\t\ttxt, err := json.Marshal(at)\n\t\tif err != nil {\n\t\t\tmsgs := []string{\"JSON encoding failed\"}\n\t\t\tH_errmsgs(cui, msgs)\n\t\t\treturn\n\t\t}\n\n\t\tcui.SetJSON(txt)\n\t\treturn\n\n\tcase \"token\":\n\t\treturn\n\n\tcase \"password\":\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "6c7fe2f6ae0703fd4b6cde78834b2f8f", "score": "0.49928835", "text": "func (api *HWApi) GetSessions(accountHash string, uid int) (*AccessTokenList, error) {\n\tr, e := api.Request(\n\t\t&Request{\n\t\t\tMethod: GET,\n\t\t\tURL: fmt.Sprintf(\"/api/v1/accounts/%s/users/%d/sessions\", accountHash, uid),\n\t\t},\n\t)\n\tif e != nil {\n\t\treturn nil, e\n\t}\n\tal := &AccessTokenList{}\n\treturn al, json.Unmarshal(r.body, al)\n}", "title": "" }, { "docid": "8f8990566ac79d68af5aa8f7746a2f86", "score": "0.49888256", "text": "func Tokens(usersession models.UserAppSession) (string, string, string, error) {\n\tconf := config.Load()\n\tauthExpiry := time.Hour * time.Duration(conf.App.AuthTokenExpiry)\n\trefreshExpiry := time.Hour * time.Duration(conf.App.AuthTokenExpiry)\n\n\t// Set claims\n\tcsrfTokenClaims := JWTClaims{\n\t\tStandardClaims: jwt_lib.StandardClaims{\n\t\t\tExpiresAt: time.Now().Add(authExpiry).Unix(),\n\t\t},\n\t}\n\t// Create csrf token\n\tcsrfToken := jwt_lib.NewWithClaims(jwt_lib.GetSigningMethod(\"HS256\"), csrfTokenClaims)\n\tcsrfTokenString, err := csrfToken.SignedString([]byte(conf.App.JWTSecret))\n\n\tauthTokenClaims := JWTClaims{\n\t\tUserID: usersession.UserID,\n\t\tCSRF: csrfTokenString,\n\t\tStandardClaims: jwt_lib.StandardClaims{\n\t\t\tExpiresAt: time.Now().Add(authExpiry).Unix(),\n\t\t},\n\t}\n\t// Create refresh token\n\tauthToken := jwt_lib.NewWithClaims(jwt_lib.GetSigningMethod(\"HS256\"), authTokenClaims)\n\t// Sign and get the complete encoded token as a string\n\tauthTokenString, err := authToken.SignedString([]byte(conf.App.JWTSecret))\n\n\trefreshTokenClaims := JWTClaims{\n\t\tUserID: usersession.UserID,\n\t\tSessionIdentifier: usersession.Identifier,\n\t\tStandardClaims: jwt_lib.StandardClaims{\n\t\t\tExpiresAt: time.Now().Add(refreshExpiry).Unix(),\n\t\t},\n\t}\n\t// Create refresh token\n\trefreshToken := jwt_lib.NewWithClaims(jwt_lib.GetSigningMethod(\"HS256\"), refreshTokenClaims)\n\t// Sign and get the complete encoded token as a string\n\trefreshTokenString, err := refreshToken.SignedString([]byte(conf.App.JWTSecret))\n\n\tif err != nil {\n\t\treturn \"\", \"\", \"\", err\n\t}\n\n\treturn authTokenString, refreshTokenString, csrfTokenString, nil\n}", "title": "" }, { "docid": "c9b5b09ee587855d0f0ac0481a6b26ae", "score": "0.4987015", "text": "func (t *PrToken) getTokens(db *sql.DB, start, count int) ([]PrToken, error) {\n\tstatement := fmt.Sprintf(\"SELECT uid, prtoken FROM kevlarweb.prtoken LIMIT %d OFFSET %d\", count, start)\n\trows, err := db.Query(statement)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer rows.Close()\n\n\ttokens := []PrToken{}\n\n\tfor rows.Next() {\n\t\tvar t PrToken\n\t\tvar jb []byte\n\t\tvar uid string\n\t\terr := rows.Scan(&uid, &jb)\n\t\terr = json.Unmarshal(jb, &t)\n\t\tt.Metadata.UID = uid\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\tos.Exit(1)\n\t\t}\n\t\ttokens = append(tokens, t)\n\t}\n\n\treturn tokens, nil\n}", "title": "" }, { "docid": "10370d51fb638dc66615b80298200a98", "score": "0.49860063", "text": "func (t *TokensRepository) Get(token string) (*auth.SystemClaims, error) {\n\tc := t.Pool.Get()\n\tdefer c.Close()\n\n\tres, err := redis.String(c.Do(\"get\", fmt.Sprintf(tokenKeyTemplate, token)))\n\tif err != nil {\n\t\tif err == redis.ErrNil {\n\t\t\terr = internal.ErrNotFound\n\t\t}\n\n\t\treturn nil, errors.Wrap(err, \"get token\")\n\t}\n\n\tclaims := &auth.SystemClaims{}\n\treturn claims, errors.Wrap(json.Unmarshal([]byte(res), claims), \"unmarshal token\")\n}", "title": "" }, { "docid": "f18b6f170baec9055ad972d5001b43f3", "score": "0.4982526", "text": "func GetCommitsByUserOnRepo(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tuser, err := url.QueryUnescape(r.URL.Query().Get(\"user\"))\n\tif err != nil || user == \"\" {\n\t\tfmt.Fprintf(w, `{\"error\":\"'user' parameters is required.\"}`)\n\t\treturn\n\t}\n\trepo, err := url.QueryUnescape(r.URL.Query().Get(\"repo\"))\n\tif err != nil || repo == \"\" {\n\t\tfmt.Fprintf(w, `{\"error\":\"'repo' parameters is required.\"}`)\n\t\treturn\n\t}\n\tcommits, err := model.FindUserCommitsOnRepo(user, repo)\n\tif err != nil {\n\t\tfmt.Fprintf(w, `{\"error\":\"problem downloading commits from the cloud\"}`)\n\t\tfmt.Printf(\"Error loading commits from cloudant for user=\" + user)\n\t\treturn\n\t}\n\tjs, err := json.Marshal(commits)\n\tif err != nil {\n\t\tfmt.Printf(\"GetCommitsByUser: error marshaling user commits to json: %s\\n\", err)\n\t\treturn\n\t}\n\tfmt.Fprintf(w, string(js))\n}", "title": "" }, { "docid": "05ad09319e831725d0713668146d0502", "score": "0.49789986", "text": "func (p *ProjectAccessTokensService) List(projectID int) (*ProjectAccessTokenListResponse, *simpleresty.Response, error) {\n\tvar result *ProjectAccessTokenListResponse\n\turlStr := p.client.http.RequestURL(\"/project/%d/access_tokens\", projectID)\n\n\t// Set the correct authentication header\n\tp.client.setAuthTokenHeader(p.client.accountAccessToken)\n\n\t// Execute the request\n\tresponse, getErr := p.client.http.Get(urlStr, &result, nil)\n\n\treturn result, response, getErr\n}", "title": "" }, { "docid": "9de4b0638eff7178f8455cf38cf6003c", "score": "0.49736047", "text": "func (b *Bluecat) GetAccessRightsForUser(userid int, count, start int) ([]APIAccessRight, error) {\n\tvar results []APIAccessRight\n\treq := fmt.Sprintf(\"https://%s%s/getAccessRightsForUser?userId=%d&count=%d&start=%d\",\n\t\tb.Server, b.URI, userid, count, start)\n\tresp, err := resty.R().\n\t\tSetHeader(\"Content-Type\", \"application/json\").\n\t\tSetHeader(\"Authorization\", fmt.Sprintf(\"%s\", b.AuthToken)).\n\t\tGet(req)\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s - GetAccessRightsForUser request\", err)\n\t}\n\n\tif err := json.Unmarshal([]byte(resp.String()), &results); err != nil {\n\t\treturn nil, fmt.Errorf(\"%s - GetAccessRightsForUser JSON parse\", err)\n\t}\n\n\treturn results, nil\n}", "title": "" }, { "docid": "87e2430530bf2bb38eac487abbec56fc", "score": "0.49721548", "text": "func (c *Client4) GetTeamsForUser(userId, etag string) ([]*Team, *Response, error) {\n\tr, err := c.DoAPIGet(c.userRoute(userId)+\"/teams\", etag)\n\tif err != nil {\n\t\treturn nil, BuildResponse(r), err\n\t}\n\tdefer closeBody(r)\n\tvar list []*Team\n\tif err := json.NewDecoder(r.Body).Decode(&list); err != nil {\n\t\treturn nil, nil, NewAppError(\"GetTeamsForUser\", \"api.unmarshal_error\", nil, \"\", http.StatusInternalServerError).Wrap(err)\n\t}\n\treturn list, BuildResponse(r), nil\n}", "title": "" }, { "docid": "6654db7e381a8d134c4e6dff95845cac", "score": "0.49695802", "text": "func (s service) Query(ctx context.Context, offset, limit int) (\n\t[]User, error) {\n\n\titems, err := s.repo.Query(ctx, offset, limit)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresult := []User{}\n\tfor _, item := range items {\n\t\tresult = append(result, User{item})\n\t}\n\treturn result, nil\n}", "title": "" }, { "docid": "9ca42dc60edc3ddc80a61978151bbcb6", "score": "0.49649522", "text": "func getUser(token string) (string, error) {\n\n\tbody, err := httpClient(token, \"GET\", \"https://api.github.com/user\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvar response struct {\n\t\tLogin string `json:\"login\"`\n\t}\n\n\terr = json.Unmarshal(body, &response)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn response.Login, nil\n}", "title": "" }, { "docid": "cd210b1ae784f919f25279b84c3374a9", "score": "0.49642804", "text": "func (s *authService) BlackListTokens(ctx context.Context, userID primitive.ObjectID) error {\n\n\terr := s.tokenRepository.DeleteUserRefreshTokens(ctx, userID.Hex())\n\tif err != nil {\n\t\tlog.Printf(\"Error deleteing token: %v\", err)\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "fb1fc2d57a3779f8960eaf510b9dddab", "score": "0.4946851", "text": "func (service *AccessTokensService) List() *Collection {\n\tpath := fmt.Sprint(\"/users/me/access_tokens\")\n\tmethod := \"GET\"\n\n\treq, err := service.c.newRequest(method, path, nil, nil)\n\tif err != nil {\n\t\treturn &Collection{}\n\t}\n\n\tcol := NewCollection(&CollectionOptions{})\n\tcol.c = service.c\n\tcol.req = req\n\n\treturn col\n}", "title": "" }, { "docid": "1ec937c0c7c656d15354beb3b4d8ac6c", "score": "0.49414864", "text": "func GetUser() []User {\n\treturn userList\n}", "title": "" }, { "docid": "5eb3416c5738c5d21e765e687f2e7d62", "score": "0.4938441", "text": "func (bb *Bitbucket) Repos(u *model.User) ([]*model.RepoLite, error) {\n\ttoken := oauth2.Token{AccessToken: u.Token, RefreshToken: u.Secret}\n\tclient := NewClientToken(bb.Client, bb.Secret, &token)\n\tvar repos []*model.RepoLite\n\n\t// gets a list of all accounts to query, including the\n\t// user's account and all team accounts.\n\tlogins := []string{u.Login}\n\tresp, err := client.ListTeams(&ListTeamOpts{PageLen: 100, Role: \"member\"})\n\tif err != nil {\n\t\treturn repos, err\n\t}\n\tfor _, team := range resp.Values {\n\t\tlogins = append(logins, team.Login)\n\t}\n\n\t// for each account, get the list of repos\n\tfor _, login := range logins {\n\t\trepos_, err := client.ListReposAll(login)\n\t\tif err != nil {\n\t\t\treturn repos, err\n\t\t}\n\t\tfor _, repo := range repos_ {\n\t\t\trepos = append(repos, convertRepoLite(repo))\n\t\t}\n\t}\n\n\treturn repos, nil\n}", "title": "" }, { "docid": "267d3723562b30ea0623108d3ac05b91", "score": "0.4933335", "text": "func FetchUserRepos(personalToken string) ([]string, map[string]string, error) {\n\tresponse := []repo{}\n\trepos := []string{}\n\trepoURL := map[string]string{}\n\n\t_, err := http.Client.R().\n\t\tSetHeader(\"Authorization\", \"token \"+personalToken).\n\t\tSetResult(&response).\n\t\tGet(userReposURL)\n\n\tif err != nil {\n\t\tfmt.Println(\"Error:\")\n\t\tfmt.Println(err)\n\n\t\treturn repos, repoURL, err\n\t}\n\n\tfor _, repo := range response {\n\t\trepos = append(repos, repo.Name)\n\t\trepoURL[repo.Name] = repo.CloneURL\n\t}\n\n\treturn repos, repoURL, nil\n}", "title": "" }, { "docid": "e88051fcab72e9231e19df023febacd3", "score": "0.49316996", "text": "func (_Reserve *ReserveSession) GetTokens() ([]common.Address, error) {\n\treturn _Reserve.Contract.GetTokens(&_Reserve.CallOpts)\n}", "title": "" }, { "docid": "31cf6bf591f70dc7b72b0b5c98b18e02", "score": "0.49176213", "text": "func (r *Repository) GetByToken(ctx context.Context, tokenValue string) (*user.Token, error) {\n\ttx, err := r.db.Begin()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer tx.Rollback()\n\trows, err := tx.QueryContext(ctx, \"SELECT Value, Email, Used FROM tokens WHERE Value = ?\", tokenValue)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\ttoken := &user.Token{}\n\tfor rows.Next() {\n\t\terr = rows.Scan(&token.Value, &token.Email, &token.Used)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn token, nil\n\t}\n\tif err := tx.Commit(); err != nil {\n\t\treturn nil, err\n\t}\n\treturn nil, user.NotFound\n}", "title": "" } ]
76a4881483d70527201677c1fe8c8302
NextPage returns true if the pager advanced to the next page. Returns false if there are no more pages or an error occurred.
[ { "docid": "51bee0741ef77d90db3207d99136ef0f", "score": "0.67157376", "text": "func (p *EnvironmentsClientSuspendPager) NextPage(ctx context.Context) bool {\n\tif !p.second {\n\t\tp.second = true\n\t\treturn true\n\t} else if !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.WebAppCollection.NextLink == nil || len(*p.current.WebAppCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, *p.current.WebAppCollection.NextLink)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated, http.StatusAccepted) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.suspendHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" } ]
[ { "docid": "f2ef37c5b8dafa84146047e3ab58d011", "score": "0.7483853", "text": "func (r *PagedResult) Next() bool {\n\tif r.lastDataCursor != -1 && r.lastDataCursor < len(r.lastData)-1 {\n\t\tr.lastDataCursor++\n\t\treturn true\n\t}\n\n\tif r.nextPagePath == \"\" {\n\t\treturn false\n\t}\n\n\tresp := &struct {\n\t\tData []map[string]interface{}\n\t\tLinks []Link\n\t\tPaging Paging\n\t}{}\n\tr.lastError = r.clever.Query(r.nextPagePath, nil, resp)\n\tif r.lastError != nil {\n\t\treturn false\n\t}\n\tr.lastData = resp.Data\n\tr.lastDataCursor = 0\n\tr.nextPagePath = \"\"\n\tfor _, link := range resp.Links {\n\t\tif link.Rel == \"next\" {\n\t\t\tr.nextPagePath = link.URI\n\t\t\tbreak\n\t\t}\n\t}\n\treturn len(r.lastData) > 0\n}", "title": "" }, { "docid": "7cd327c99c37ac551f1895f87145b8d7", "score": "0.7397013", "text": "func (p *SubscriptionPager) NextPage(ctx context.Context) bool {\n\tp.lastResponse, p.lastErr = p.getNext(ctx)\n\treturn p.lastResponse != nil\n}", "title": "" }, { "docid": "ebf411890441e16e9e3dfd3f5faa7abe", "score": "0.73780173", "text": "func (pr *PagingResult) Next() (noMore bool, err error) {\n\tif !pr.HasNext() {\n\t\tnoMore = true\n\t\treturn\n\t}\n\n\treturn pr.navigate(&pr.next)\n}", "title": "" }, { "docid": "370d2f33dc60641df47d9ba98415cdbf", "score": "0.7250951", "text": "func (p *SubscriptionRuntimePropertiesPager) NextPage(ctx context.Context) bool {\n\tp.lastResponse, p.lastErr = p.getNextPage(ctx)\n\treturn p.lastResponse != nil\n}", "title": "" }, { "docid": "187634a06afb9c474e580b4f34fdcfa5", "score": "0.6994302", "text": "func (p *WebAppsClientListProcessesPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ProcessInfoCollection.NextLink == nil || len(*p.current.ProcessInfoCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listProcessesHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "dde35b0b33fe4be456994247b6cecbe3", "score": "0.6951819", "text": "func (p *WebSiteManagementClientListPremierAddOnOffersPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.PremierAddOnOfferCollection.NextLink == nil || len(*p.current.PremierAddOnOfferCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listPremierAddOnOffersHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "94d30389d4dd8703f64a2137620d6491", "score": "0.6929427", "text": "func (p *ProviderClientGetAvailableStacksOnPremPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ApplicationStackCollection.NextLink == nil || len(*p.current.ApplicationStackCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.getAvailableStacksOnPremHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "d6b8392c57d07ab11f8c549e8781e08b", "score": "0.68963593", "text": "func (p *WebAppsClientListInstanceProcessesPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ProcessInfoCollection.NextLink == nil || len(*p.current.ProcessInfoCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listInstanceProcessesHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "a6b4ccf87a3932ea4eef96a3281ccc8f", "score": "0.68290424", "text": "func (p *WebAppsClientListBackupsPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.BackupItemCollection.NextLink == nil || len(*p.current.BackupItemCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listBackupsHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "af88fc66b624456b4bebdf55bf4fc0af", "score": "0.6826903", "text": "func (p *Pagination) HasNextPage() bool {\n\tif !p.started {\n\t\treturn true\n\t}\n\n\thasNextPage := len(p.nextTokens) != 0\n\tif p.EndPageOnSameToken {\n\t\treturn hasNextPage && !awsutil.DeepEqual(p.nextTokens, p.prevTokens)\n\t}\n\treturn hasNextPage\n}", "title": "" }, { "docid": "67e6360267be80ad3c67f953c208317c", "score": "0.6791643", "text": "func (p *DiagnosticsClientListSiteAnalysesPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.DiagnosticAnalysisCollection.NextLink == nil || len(*p.current.DiagnosticAnalysisCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listSiteAnalysesHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "621e6847baef4679a4a80a8eb9889590", "score": "0.6779709", "text": "func (p Pages) HasNext() bool {\n\ti := len(p.Elements) + p.PageSize - (p.current +1)*p.PageSize\n\treturn i > 0\n}", "title": "" }, { "docid": "e3f08f8a41d9600f809c9fe430165150", "score": "0.6779213", "text": "func (p *IotHubResourceGetEndpointHealthPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.EndpointHealthDataListResult.NextLink == nil || len(*p.current.EndpointHealthDataListResult.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = p.client.getEndpointHealthHandleError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.getEndpointHealthHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "6167a63df5c2807f217741c0bb6d30f6", "score": "0.6769838", "text": "func (p *EnvironmentsClientResumePager) NextPage(ctx context.Context) bool {\n\tif !p.second {\n\t\tp.second = true\n\t\treturn true\n\t} else if !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.WebAppCollection.NextLink == nil || len(*p.current.WebAppCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, *p.current.WebAppCollection.NextLink)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated, http.StatusAccepted) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.resumeHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "f48d51a76161c98978e31cbdf750efb0", "score": "0.6765666", "text": "func (p *EnvironmentsClientListWorkerPoolsPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.WorkerPoolCollection.NextLink == nil || len(*p.current.WorkerPoolCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listWorkerPoolsHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "e8d2c1309af1da034f18834313e87cd5", "score": "0.6760715", "text": "func (l *listKeysPager) NextPage(ctx context.Context) bool {\n\treturn l.genPager.NextPage(ctx)\n}", "title": "" }, { "docid": "f2b261bbb9e38812cf7db469e1bbcfac", "score": "0.6758141", "text": "func (p *OperationsListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.OperationListResult.NextLink == nil || len(*p.current.OperationListResult.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = p.client.listHandleError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "7ec9bb4b1937ed8649053158d92338ed", "score": "0.67569447", "text": "func (p *WebAppsClientListBasicPublishingCredentialsPoliciesPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.PublishingCredentialsPoliciesCollection.NextLink == nil || len(*p.current.PublishingCredentialsPoliciesCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listBasicPublishingCredentialsPoliciesHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "5dd7ec692658e533561143a2b7261735", "score": "0.67500865", "text": "func (p *ProviderClientGetFunctionAppStacksPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.FunctionAppStackCollection.NextLink == nil || len(*p.current.FunctionAppStackCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.getFunctionAppStacksHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "42d012672facdd123f708eea7e5c5956", "score": "0.6742813", "text": "func (p *WebAppsClientListProcessModulesPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ProcessModuleInfoCollection.NextLink == nil || len(*p.current.ProcessModuleInfoCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listProcessModulesHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "fcd59aa2394446a7b6fdef76e8eded50", "score": "0.67354965", "text": "func (p Paginator) HasNext() bool {\n\treturn p.Page() < p.PageNums()\n}", "title": "" }, { "docid": "9d97b88ad7aefe46ec211acb3d51ca88", "score": "0.67187834", "text": "func (p *ProviderClientGetAvailableStacksPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ApplicationStackCollection.NextLink == nil || len(*p.current.ApplicationStackCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.getAvailableStacksHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "e45ff4d0f8fd6270e3ac04275f341123", "score": "0.671722", "text": "func (p *ServiceClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ServiceResourceDescriptionList.NextLink == nil || len(*p.current.ServiceResourceDescriptionList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "6c07b1b8499282c587718c06ab78466d", "score": "0.67050767", "text": "func (p *WebAppsClientListProcessesSlotPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ProcessInfoCollection.NextLink == nil || len(*p.current.ProcessInfoCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listProcessesSlotHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "15c5f5535113a0676a75828a422ef3d9", "score": "0.6701187", "text": "func (p *MsixImagesClientExpandPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ExpandMsixImageList.NextLink == nil || len(*p.current.ExpandMsixImageList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.expandHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "353855c9d2b3a1f5a045ccb3f16e9b55", "score": "0.66970277", "text": "func (p *WebAppsClientListSiteBackupsPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.BackupItemCollection.NextLink == nil || len(*p.current.BackupItemCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listSiteBackupsHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "6fbf8ed430bf48d8e3db6fee868e4795", "score": "0.66834766", "text": "func (p *AssessmentsMetadataClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.AssessmentMetadataResponseList.NextLink == nil || len(*p.current.AssessmentMetadataResponseList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "c81ab11961eb97cc985d1cf289d6f48f", "score": "0.66824764", "text": "func (p *EnvironmentsClientChangeVnetPager) NextPage(ctx context.Context) bool {\n\tif !p.second {\n\t\tp.second = true\n\t\treturn true\n\t} else if !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.WebAppCollection.NextLink == nil || len(*p.current.WebAppCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, *p.current.WebAppCollection.NextLink)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated, http.StatusAccepted) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.changeVnetHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "9cdf1e0f06909d3f856b3547d662a7a7", "score": "0.6668161", "text": "func (p *WebAppsClientListInstanceProcessModulesPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ProcessModuleInfoCollection.NextLink == nil || len(*p.current.ProcessModuleInfoCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listInstanceProcessModulesHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "a22208fccde4f65a6bd434d03c79cbcf", "score": "0.66655463", "text": "func (p *WebAppsClientListConfigurationSnapshotInfoPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.SiteConfigurationSnapshotInfoCollection.NextLink == nil || len(*p.current.SiteConfigurationSnapshotInfoCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listConfigurationSnapshotInfoHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "7b7bc95e6282cbaefeeecc7b0268065d", "score": "0.66643393", "text": "func (p *RecommendationsClientListHistoryForWebAppPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.RecommendationCollection.NextLink == nil || len(*p.current.RecommendationCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHistoryForWebAppHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "bec7169b28c0cd88ff7fdf67f5587542", "score": "0.66614324", "text": "func (p *AutomationsClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.AutomationList.NextLink == nil || len(*p.current.AutomationList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "24e36a2c66c19e365a5a3b10b1ae7852", "score": "0.6660804", "text": "func (p *Pagination) Next() bool {\n\tif !p.HasNextPage() {\n\t\treturn false\n\t}\n\n\treq, err := p.NewRequest()\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\n\tif p.started {\n\t\tfor i, intok := range req.Operation.InputTokens {\n\t\t\tawsutil.SetValueAtPath(req.Params, intok, p.nextTokens[i])\n\t\t}\n\t}\n\tp.started = true\n\n\terr = req.Send()\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\n\tp.prevTokens = p.nextTokens\n\tp.nextTokens = req.nextPageTokens()\n\tp.curPage = req.Data\n\n\treturn true\n}", "title": "" }, { "docid": "a105c0137a234bf8163531e5e23fd62a", "score": "0.66605407", "text": "func (p *WebAppsClientListSnapshotsPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.SnapshotCollection.NextLink == nil || len(*p.current.SnapshotCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listSnapshotsHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "7dc633dc022ff15b57384133f70bec33", "score": "0.665995", "text": "func (p *DiagnosticsClientListSiteDetectorsPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.DiagnosticDetectorCollection.NextLink == nil || len(*p.current.DiagnosticDetectorCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listSiteDetectorsHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "14e6f6263983fddb7289a85ac7240c51", "score": "0.66598535", "text": "func (p *WebAppsClientListTriggeredWebJobHistoryPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.TriggeredJobHistoryCollection.NextLink == nil || len(*p.current.TriggeredJobHistoryCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listTriggeredWebJobHistoryHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "0384c4e9c967c945e6d4fe93a23222e6", "score": "0.6659653", "text": "func (sitemap *Sitemap) NextPage() (success bool) {\n\tif sitemap.sitemap_index != nil {\n\t\tsuccess := sitemap.sitemap_index.Next()\n\t\t// End of index stream\n\t\tif !success {\n\t\t\tsitemap.err = sitemap.sitemap_index.Err()\n\t\t\tsitemap.sitemap_page = nil\n\t\t\treturn false\n\t\t} else { // Next entry\n\t\t\tindex_item := sitemap.sitemap_index.Item()\n\t\t\taccess_rule := sitemap.access_rule\n\t\t\t// rule for grabbing next has been met\n\t\t\tcanNetAccess(access_rule)\n\n\t\t\tresponse, err := http.Get(index_item.Location())\n\t\t\tif err != nil {\n\t\t\t\tsitemap.err = err\n\t\t\t\tsitemap.sitemap_page = nil\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tdefer response.Body.Close()\n\t\t\tsitemap.sitemap_page, err = NewSitemapPage(response.Body)\n\t\t\tif err != nil {\n\t\t\t\tsitemap.err = err\n\t\t\t\tsitemap.sitemap_page = nil\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif access_rule != nil {\n\t\t\t\tgo access_rule.Accessed()\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\t}\n\tsitemap.err = nil\n\treturn false\n}", "title": "" }, { "docid": "434cb3af79c74c58bbe26276084a7def", "score": "0.6658288", "text": "func (p *WebAppsClientListWebJobsPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.WebJobCollection.NextLink == nil || len(*p.current.WebJobCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listWebJobsHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "05b3c76391241ada40536fdde63fc35d", "score": "0.665727", "text": "func (p *TopLevelDomainsClientListAgreementsPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.TldLegalAgreementCollection.NextLink == nil || len(*p.current.TldLegalAgreementCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listAgreementsHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "b4de0af2dfced763f64a9a08fd52a5ce", "score": "0.66556424", "text": "func (p *ProviderClientGetWebAppStacksPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.WebAppStackCollection.NextLink == nil || len(*p.current.WebAppStackCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.getWebAppStacksHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "0ba70763ffd8e091a2f5fec37a15e2cb", "score": "0.66533965", "text": "func (p *DesktopsClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.DesktopList.NextLink == nil || len(*p.current.DesktopList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "dff06c283a58050c2fdc0a9098e79dc1", "score": "0.6652798", "text": "func (p *EnvironmentsClientGetPrivateEndpointConnectionListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.PrivateEndpointConnectionCollection.NextLink == nil || len(*p.current.PrivateEndpointConnectionCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.getPrivateEndpointConnectionListHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "514bd01de52bb9af52c302100cf7502c", "score": "0.6646924", "text": "func (p *EnvironmentsClientListAppServicePlansPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.PlanCollection.NextLink == nil || len(*p.current.PlanCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listAppServicePlansHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "872ef0afa8ecfa3a1261c58a1f2b5a75", "score": "0.66417307", "text": "func (p *Page) CanNext() bool {\n\treturn p.history.CanNext()\n}", "title": "" }, { "docid": "263413e5eb90a2ba9a3540f9c263cc65", "score": "0.66416705", "text": "func (p *AutomationsClientListByResourceGroupPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.AutomationList.NextLink == nil || len(*p.current.AutomationList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listByResourceGroupHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "6bb98b65d5a53230041768d2b34c4c0f", "score": "0.6641293", "text": "func (p *WebAppsClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.WebAppCollection.NextLink == nil || len(*p.current.WebAppCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "4f47f24a806627e0a0df495f008b9c9a", "score": "0.6641074", "text": "func (p *DiagnosticsClientListSiteDetectorResponsesPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.DetectorResponseCollection.NextLink == nil || len(*p.current.DetectorResponseCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listSiteDetectorResponsesHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "03f561f7df5882cd5c0e25707b7d9726", "score": "0.6637296", "text": "func (p *DomainsClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.DomainCollection.NextLink == nil || len(*p.current.DomainCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "f6753f882b66715f746a539e5560740d", "score": "0.66319567", "text": "func (p *AssessmentsClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.AssessmentList.NextLink == nil || len(*p.current.AssessmentList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "99ae8bcb2619a42f3e19ae5d95ec827e", "score": "0.662653", "text": "func (p *WebAppsClientListInstanceProcessesSlotPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ProcessInfoCollection.NextLink == nil || len(*p.current.ProcessInfoCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listInstanceProcessesSlotHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "9943540b16eca825be031317ef79d7fb", "score": "0.6625974", "text": "func (p *ResourceHealthMetadataClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ResourceHealthMetadataCollection.NextLink == nil || len(*p.current.ResourceHealthMetadataCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "103b1c90625f7a83969b7702eee12a88", "score": "0.66245216", "text": "func (p *ExperimentsClientListAllPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ExperimentListResult.NextLink == nil || len(*p.current.ExperimentListResult.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listAllHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "f2e1d977c1dfd7e58f47f29fec5fbb35", "score": "0.66242063", "text": "func (p *WebAppsClientGetAppSettingsKeyVaultReferencesPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.APIKVReferenceCollection.NextLink == nil || len(*p.current.APIKVReferenceCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.getAppSettingsKeyVaultReferencesHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "2e1713ce42bb07ce7d668518c283020a", "score": "0.6622622", "text": "func (p *WebAppsClientListContinuousWebJobsPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ContinuousWebJobCollection.NextLink == nil || len(*p.current.ContinuousWebJobCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listContinuousWebJobsHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "b7cc148f5e3286c537be5e4ee336c7dd", "score": "0.66158926", "text": "func (p *DomainsClientListRecommendationsPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.NameIdentifierCollection.NextLink == nil || len(*p.current.NameIdentifierCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listRecommendationsHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "4dfa05c95f9008f8b50646179f8caf16", "score": "0.6615108", "text": "func (p *DiagnosticsClientListHostingEnvironmentDetectorResponsesPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.DetectorResponseCollection.NextLink == nil || len(*p.current.DetectorResponseCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHostingEnvironmentDetectorResponsesHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "290339a68bc35d940e28393b09d32a93", "score": "0.6610997", "text": "func (pr *PagingResult) HasNext() bool {\n\treturn pr.next != \"\"\n}", "title": "" }, { "docid": "fe14c840b88f8cd01c474dd341d8af7a", "score": "0.66025716", "text": "func (p *SubAssessmentsClientListAllPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.SubAssessmentList.NextLink == nil || len(*p.current.SubAssessmentList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listAllHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "d3c9669466de729f84f4a8d21c1da10f", "score": "0.6590878", "text": "func (p *EnvironmentsClientListWebAppsPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.WebAppCollection.NextLink == nil || len(*p.current.WebAppCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listWebAppsHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "baf981867897558b75b28f9bc61719ae", "score": "0.65898746", "text": "func (p *DiagnosticsClientListSiteAnalysesSlotPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.DiagnosticAnalysisCollection.NextLink == nil || len(*p.current.DiagnosticAnalysisCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listSiteAnalysesSlotHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "1f1a788046a0480ea959cc96ae920489", "score": "0.658939", "text": "func (p *TasksClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.TaskList.NextLink == nil || len(*p.current.TaskList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "77c76dc7538f79fb5ee50fab96ef1d43", "score": "0.65872663", "text": "func (p *ContactsClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ContactList.NextLink == nil || len(*p.current.ContactList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "6be91290a8223b50bcd2544410205674", "score": "0.6587037", "text": "func (p *WebAppsClientGetPrivateEndpointConnectionListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.PrivateEndpointConnectionCollection.NextLink == nil || len(*p.current.PrivateEndpointConnectionCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.getPrivateEndpointConnectionListHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "d0797e2719221fd5316fe64c4225f4fa", "score": "0.658602", "text": "func (p *WebAppsClientListProcessModulesSlotPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ProcessModuleInfoCollection.NextLink == nil || len(*p.current.ProcessModuleInfoCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listProcessModulesSlotHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "27f95c6536716979d170bdbad333a352", "score": "0.6580613", "text": "func (p *SettingsClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.SettingsList.NextLink == nil || len(*p.current.SettingsList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "526deaedef45f91b650bc1b6d8eb8ff3", "score": "0.6577165", "text": "func (p *EnvironmentsClientGetInboundNetworkDependenciesEndpointsPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.InboundEnvironmentEndpointCollection.NextLink == nil || len(*p.current.InboundEnvironmentEndpointCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.getInboundNetworkDependenciesEndpointsHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "ff8f4cfdf78066c38deba4a5ee20a1cd", "score": "0.6571351", "text": "func (p *StaticSitesClientGetStaticSitesByResourceGroupPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.StaticSiteCollection.NextLink == nil || len(*p.current.StaticSiteCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.getStaticSitesByResourceGroupHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "fcb0081b7086e8596f15bad2b9cd37d6", "score": "0.65667385", "text": "func (p *WebAppsClientGetSiteConnectionStringKeyVaultReferencesPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.APIKVReferenceCollection.NextLink == nil || len(*p.current.APIKVReferenceCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.getSiteConnectionStringKeyVaultReferencesHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "8b9b540f5cd27a446756ed4d0edc4d9c", "score": "0.6561707", "text": "func (p *WebAppsClientListBackupsSlotPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.BackupItemCollection.NextLink == nil || len(*p.current.BackupItemCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listBackupsSlotHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "42a4972be8ddf2c3f78e82d9de5a50b6", "score": "0.6561139", "text": "func (p *StaticSitesClientGetPrivateEndpointConnectionListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.PrivateEndpointConnectionCollection.NextLink == nil || len(*p.current.PrivateEndpointConnectionCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.getPrivateEndpointConnectionListHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "b5cf78ddf364a01c2a26b907e00f901b", "score": "0.65594476", "text": "func (p *WebSiteManagementClientListBillingMetersPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.BillingMeterCollection.NextLink == nil || len(*p.current.BillingMeterCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listBillingMetersHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "b28bd44249dafae4072b76392252e566", "score": "0.6548971", "text": "func (p *VolumeClientListByResourceGroupPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.VolumeResourceDescriptionList.NextLink == nil || len(*p.current.VolumeResourceDescriptionList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listByResourceGroupHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "e1beeb59a2b441ba8b0584d92ed36817", "score": "0.65463406", "text": "func (p *PlansClientListWebAppsPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.WebAppCollection.NextLink == nil || len(*p.current.WebAppCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listWebAppsHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "2b5ba19a45fc20fa93ccbb084d04e93a", "score": "0.6545831", "text": "func (p *DomainsListByResourceGroupPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.DomainsListResult.NextLink == nil || len(*p.current.DomainsListResult.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = p.client.listByResourceGroupHandleError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listByResourceGroupHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "57228ec07323e717a1fec86b0f807b07", "score": "0.6545381", "text": "func (p *IotHubResourceGetValidSKUsPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.IotHubSKUDescriptionListResult.NextLink == nil || len(*p.current.IotHubSKUDescriptionListResult.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = p.client.getValidSKUsHandleError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.getValidSKUsHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "2b4dfda3e5bec2dc06e0216248e323b5", "score": "0.65423006", "text": "func (p *ResourceHealthMetadataClientListByResourceGroupPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ResourceHealthMetadataCollection.NextLink == nil || len(*p.current.ResourceHealthMetadataCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listByResourceGroupHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "88d22e93aeff6c2996b8292453503ad9", "score": "0.6540689", "text": "func (p *page) CanNext() bool {\n\treturn p.history.CanNext()\n}", "title": "" }, { "docid": "1a93f0043aa9be9a8ec8fe941834b28f", "score": "0.6533817", "text": "func (l *listKeyVersionsPager) NextPage(ctx context.Context) bool {\n\treturn l.genPager.NextPage(ctx)\n}", "title": "" }, { "docid": "21ab50cfdaf8ad7512f9b6ac66cbb13f", "score": "0.6533361", "text": "func (p *TopicsListByResourceGroupPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.TopicsListResult.NextLink == nil || len(*p.current.TopicsListResult.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = p.client.listByResourceGroupHandleError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listByResourceGroupHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "cef92c2eb473b33b27fcec85f25923a5", "score": "0.6531264", "text": "func (p *RecommendationsClientListRecommendedRulesForHostingEnvironmentPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.RecommendationCollection.NextLink == nil || len(*p.current.RecommendationCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listRecommendedRulesForHostingEnvironmentHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "ef98ff84df3e405e9ecf95eaeb10eae4", "score": "0.65310127", "text": "func (p *WebAppsClientListInstanceProcessModulesSlotPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ProcessModuleInfoCollection.NextLink == nil || len(*p.current.ProcessModuleInfoCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listInstanceProcessModulesSlotHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "de06d061829adf9c6b22555b2fb5216e", "score": "0.6530728", "text": "func (p *UserSessionsClientListByHostPoolPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.UserSessionList.NextLink == nil || len(*p.current.UserSessionList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listByHostPoolHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "a0d5dd38f6fbdddb36348dbf875fcec6", "score": "0.6530435", "text": "func (p *PlansClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.PlanCollection.NextLink == nil || len(*p.current.PlanCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "91037b34946c69e298756a2c945f502a", "score": "0.65275043", "text": "func (p *PrivateLinkResourcesListByResourcePager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.PrivateLinkResourcesListResult.NextLink == nil || len(*p.current.PrivateLinkResourcesListResult.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = p.client.listByResourceHandleError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listByResourceHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "5dd1db49fa179ed541f94c6f70457176", "score": "0.65195143", "text": "func (p *RecommendationsClientListRecommendedRulesForWebAppPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.RecommendationCollection.NextLink == nil || len(*p.current.RecommendationCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listRecommendedRulesForWebAppHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "d958b3ca76700391cccefbfc9a7b7c53", "score": "0.65179974", "text": "func (p *ProviderClientGetWebAppStacksForLocationPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.WebAppStackCollection.NextLink == nil || len(*p.current.WebAppStackCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.getWebAppStacksForLocationHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "8c0d3a143b36f24e49d63121d2b5af5a", "score": "0.651644", "text": "func (p *ProviderClientGetFunctionAppStacksForLocationPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.FunctionAppStackCollection.NextLink == nil || len(*p.current.FunctionAppStackCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.getFunctionAppStacksForLocationHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "5fa5829f135c9532da234942f56829ff", "score": "0.6511618", "text": "func (p *SolutionsClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.SolutionList.NextLink == nil || len(*p.current.SolutionList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "f573b9db019cdea51ec4ab20d0160be3", "score": "0.6511059", "text": "func (p *WebAppsClientListConfigurationSnapshotInfoSlotPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.SiteConfigurationSnapshotInfoCollection.NextLink == nil || len(*p.current.SiteConfigurationSnapshotInfoCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listConfigurationSnapshotInfoSlotHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "534faa2d24532dab5d91464be143ab73", "score": "0.6507402", "text": "func (p *ApplicationClientListByResourceGroupPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ApplicationResourceDescriptionList.NextLink == nil || len(*p.current.ApplicationResourceDescriptionList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listByResourceGroupHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "2cc2d40bb6e9ca9c3ffcfeabb0502d97", "score": "0.65039337", "text": "func (p *ConnectorsClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.ConnectorsList.NextLink == nil || len(*p.current.ConnectorsList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "a2c667f4e2f19701a32e6423776bcd4c", "score": "0.6502104", "text": "func (p *RecommendationsClientListHistoryForHostingEnvironmentPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.RecommendationCollection.NextLink == nil || len(*p.current.RecommendationCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHistoryForHostingEnvironmentHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "389b2919e5d45b0d8cf12120de72200d", "score": "0.65006286", "text": "func (p *WebAppsClientListByResourceGroupPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.WebAppCollection.NextLink == nil || len(*p.current.WebAppCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listByResourceGroupHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "d4b8b9384205606bb93af3c6c8e9cc25", "score": "0.65006167", "text": "func (p *TopLevelDomainsClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.TopLevelDomainCollection.NextLink == nil || len(*p.current.TopLevelDomainCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "acf4c104769d6c82202f8ae467300f3c", "score": "0.6499086", "text": "func (p *WebSiteManagementClientListSourceControlsPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.SourceControlCollection.NextLink == nil || len(*p.current.SourceControlCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listSourceControlsHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "7346337338d2a40abfc2f39fb985890b", "score": "0.6490492", "text": "func (p *IngestionSettingsClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.IngestionSettingList.NextLink == nil || len(*p.current.IngestionSettingList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "9225acfec91feba07f8708bf3ed1147c", "score": "0.64890003", "text": "func (p *DomainsClientListByResourceGroupPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.DomainCollection.NextLink == nil || len(*p.current.DomainCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listByResourceGroupHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "350776c945fcca4ef0d9461be096d30d", "score": "0.64846706", "text": "func (p *SessionHostsClientListPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.SessionHostList.NextLink == nil || len(*p.current.SessionHostList.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "0036c339e5b9cc3ba40105e5f1a11274", "score": "0.6482284", "text": "func (p *WebAppsClientGetAppSettingsKeyVaultReferencesSlotPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.APIKVReferenceCollection.NextLink == nil || len(*p.current.APIKVReferenceCollection.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.getAppSettingsKeyVaultReferencesSlotHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" }, { "docid": "cc7cb4f3c519e2227d7848d86fde9bd9", "score": "0.6481798", "text": "func (p *PrivateLinkResourcesClientListByHostPoolPager) NextPage(ctx context.Context) bool {\n\tvar req *policy.Request\n\tvar err error\n\tif !reflect.ValueOf(p.current).IsZero() {\n\t\tif p.current.PrivateLinkResourceListResult.NextLink == nil || len(*p.current.PrivateLinkResourceListResult.NextLink) == 0 {\n\t\t\treturn false\n\t\t}\n\t\treq, err = p.advancer(ctx, p.current)\n\t} else {\n\t\treq, err = p.requester(ctx)\n\t}\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tresp, err := p.client.pl.Do(req)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tif !runtime.HasStatusCode(resp, http.StatusOK) {\n\t\tp.err = runtime.NewResponseError(resp)\n\t\treturn false\n\t}\n\tresult, err := p.client.listByHostPoolHandleResponse(resp)\n\tif err != nil {\n\t\tp.err = err\n\t\treturn false\n\t}\n\tp.current = result\n\treturn true\n}", "title": "" } ]
3e80611307b88b213d7cfef8bbeacb39
StringIndent returns adaptive card JSON as string with indentation
[ { "docid": "7c63d22a089245aed84093199db70a2c", "score": "0.7361713", "text": "func (c *Card) StringIndent(prefix string, indent string) (string, error) {\n\tcardJSON, err := c.BytesIndent(prefix, indent)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(cardJSON), nil\n}", "title": "" } ]
[ { "docid": "fa9341cb33acafd67af106b4b927041e", "score": "0.64390236", "text": "func IndentJSON(v interface{}) string\t{\r\n\ts, err := json.MarshalIndent(v, \"\", \"\\t\")\r\n\tif err != nil\t{\r\n\t\treturn fmt.Sprintf(\"Error: %s\", err)\r\n\t} else {\r\n\t\treturn string(s)\r\n\t}\r\n}", "title": "" }, { "docid": "3ff7bb77cb76d5e5bb8925c06caf84c9", "score": "0.63324535", "text": "func jsonIndent(src []byte) ([]byte, error) {\n\tvar w bytes.Buffer\n\tdec := json.NewDecoder(bytes.NewReader(src))\n\tenc := json.NewEncoder(&w)\n\tenc.SetIndent(\"\", \" \")\n\tfor dec.More() {\n\t\tvar m json.RawMessage\n\t\terr := dec.Decode(&m)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\terr = enc.Encode(m)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn w.Bytes(), nil\n}", "title": "" }, { "docid": "8ea68a01b54b8a252e67ec9879daee30", "score": "0.6230447", "text": "func MarshalIndentJSON(t sktest.TestingT, i interface{}) string {\n\tb, err := json.MarshalIndent(i, \"\", \" \")\n\trequire.NoError(t, err)\n\treturn string(b)\n}", "title": "" }, { "docid": "b7ba2283a62ccc1d1410f449643ec237", "score": "0.5951033", "text": "func (o *outline) StringIndent(width int) string {\n\tvar b strings.Builder\n\tb.WriteString(\"Name,Text,Start,End,Spec,Focused,Pending,Labels\\n\")\n\n\tcurrentIndent := 0\n\tpre := func(n *ginkgoNode) {\n\t\tb.WriteString(fmt.Sprintf(\"%*s\", currentIndent, \"\"))\n\t\tvar labels string\n\t\tif len(n.Labels) == 1 {\n\t\t\tlabels = n.Labels[0]\n\t\t} else {\n\t\t\tlabels = strings.Join(n.Labels, \", \")\n\t\t}\n\t\t//enclosing labels in a double quoted comma separate listed so that when inmported into a CSV app the Labels column has comma separate strings\n\t\tb.WriteString(fmt.Sprintf(\"%s,%s,%d,%d,%t,%t,%t,\\\"%s\\\"\\n\", n.Name, n.Text, n.Start, n.End, n.Spec, n.Focused, n.Pending, labels))\n\t\tcurrentIndent += width\n\t}\n\tpost := func(n *ginkgoNode) {\n\t\tcurrentIndent -= width\n\t}\n\tfor _, n := range o.Nodes {\n\t\tn.Walk(pre, post)\n\t}\n\treturn b.String()\n}", "title": "" }, { "docid": "47f155f30b732559288225833f44a76e", "score": "0.5927914", "text": "func PrettyPrint(i interface{}) string {\n\ts, _ := json.MarshalIndent(i, \"\", \"\\t\")\n\treturn string(s)\n}", "title": "" }, { "docid": "d7b01fdb6f97afd949864a14925f73d7", "score": "0.5916508", "text": "func (params awsDirectorManifestParams) Indent(countStr, field string) string {\n\treturn util.Indent(countStr, field)\n}", "title": "" }, { "docid": "c9152baa35c42a1e5d32f6f745aad8cd", "score": "0.59134406", "text": "func (j JSONiter) Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error {\n\treturn json.Indent(dst, src, prefix, indent)\n}", "title": "" }, { "docid": "e66c0df9cf33bacca075329a6911439d", "score": "0.58702356", "text": "func PrettyJSONWithIndent(data interface{}) string {\n\tbuffer := new(bytes.Buffer)\n\tencoder := json.NewEncoder(buffer)\n\tencoder.SetIndent(empty, tab)\n\n\t_ = encoder.Encode(data)\n\treturn buffer.String()\n}", "title": "" }, { "docid": "1a89d5fabb70e09049bd6afd6398cb98", "score": "0.57962775", "text": "func (rc *GinRequestContext) IndentedJSON(code int, content interface{}) {\n\trc.gin.IndentedJSON(code, content)\n}", "title": "" }, { "docid": "608000807136dfa585a440c7778e1287", "score": "0.5780378", "text": "func Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error {\n\treturn DefaultJSONHandler.Indent(dst, src, prefix, indent)\n}", "title": "" }, { "docid": "e956cb259017223d966ffc1848d9677f", "score": "0.57367015", "text": "func (c *Context) IndentedJSON(code int, obj interface{}) {\n\tc.Render(code, render.IndentedJSON{Data: obj})\n}", "title": "" }, { "docid": "b500a0ee8582d25ab577d9cc54d6c70c", "score": "0.5720892", "text": "func (clientMessageRequestDebugState ClientMessageRequestDebugState) String() string {\n stringResult := \"{ \"\n stringResult += \" }\"\n return stringResult\n}", "title": "" }, { "docid": "c0cf26c415d318add51d1a083c93c208", "score": "0.57030684", "text": "func (ps *PeerState) StringIndented(indent string) string {\n\tps.mtx.Lock()\n\tdefer ps.mtx.Unlock()\n\treturn fmt.Sprintf(`PeerState{\n%s Key %v\n%s RoundState %v\n%s Stats %v\n%s}`,\n\t\tindent, ps.peerID,\n\t\tindent, ps.PRS.StringIndented(indent+\" \"),\n\t\tindent, ps.Stats,\n\t\tindent,\n\t)\n}", "title": "" }, { "docid": "ac34f2232b851ffac9b727fad995f029", "score": "0.5696962", "text": "func marshalIndentStruct() {\n\tbyteSlice, _ := json.MarshalIndent(s, \"\", \"\\t\")\n\tdisplay(\"marshalIndentStruct:\", string(byteSlice))\n}", "title": "" }, { "docid": "ca69b350517dcaabbcbb7d258680e5bf", "score": "0.56675774", "text": "func (b *Buffer) IndentString(tabsize int) string {\n\tif b.Settings[\"tabstospaces\"].(bool) {\n\t\treturn util.Spaces(tabsize)\n\t}\n\treturn \"\\t\"\n}", "title": "" }, { "docid": "7c6f893dd5a04bc47a8a0d7e33aaf7d8", "score": "0.5661745", "text": "func PrettyString(in interface{}) string {\n\tjsonStr, err := json.MarshalIndent(in, \"\", \" \")\n\tlogger.PrintlnDebugMessageIfError(err, \"unable to marshal\")\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"%+v\", in)\n\t}\n\n\treturn string(jsonStr)\n}", "title": "" }, { "docid": "46870483f621be1c2a58ce3f721e0bfb", "score": "0.5660923", "text": "func PrettyString(in interface{}) string {\n\tjsonStr, err := json.MarshalIndent(in, \"\", \" \")\n\tif err != nil {\n\t\terr := fmt.Errorf(\"Unable to marshal, Error: %+v\", err)\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"Unable to marshal, Error: %+v\\n\", err)\n\t\t}\n\t\treturn fmt.Sprintf(\"%+v\", in)\n\t}\n\treturn string(jsonStr)\n}", "title": "" }, { "docid": "654c2fe584df9fe590e12934e4c8b890", "score": "0.5650821", "text": "func (n *DomNode) IndentString() string {\n\tb := &bytes.Buffer{}\n\tn.StringBuild(b, true, 0)\n\treturn b.String()\n}", "title": "" }, { "docid": "11db61ab11563848d04827d3f79b4583", "score": "0.5587662", "text": "func prettyPrint(i interface{}) string {\n\ts1 := strings.ReplaceAll(fmt.Sprintf(\"%#v\", i), \", \", \",\\n\")\n\ts2 := strings.ReplaceAll(s1, \"{\", \"{\\n\")\n\ts3 := strings.ReplaceAll(s2, \"} \", \"}\\n\")\n\ts4 := strings.ReplaceAll(s3, \"[\", \"[\\n\")\n\ts5 := strings.ReplaceAll(s4, \"] \", \"]\\n\")\n\n\treturn s5\n}", "title": "" }, { "docid": "3acee9d757aedf6597b3f495b3d8080e", "score": "0.5564109", "text": "func prettify(raw []byte) *bytes.Buffer {\n\tif !viper.GetBool(\"pretty\") {\n\t\treturn bytes.NewBuffer(raw)\n\t}\n\n\tbuf := &bytes.Buffer{}\n\terr := json.Indent(buf, raw, \"\", \" \")\n\n\tif err != nil {\n\t\treturn bytes.NewBuffer(raw)\n\t}\n\n\treturn buf\n}", "title": "" }, { "docid": "2f0f289f6d5c6b85607bbaf33314e6e3", "score": "0.5545703", "text": "func indent(s, prefix string) string {\n\treturn string(indentBytes([]byte(s), []byte(prefix)))\n}", "title": "" }, { "docid": "207f7b49e3267519dc16f0b7ae36400c", "score": "0.5545127", "text": "func AsIndentJSONText(source interface{}) (string, error) {\n\tif IsStruct(source) || IsMap(source) || IsSlice(source) {\n\t\tbuf, err := json.MarshalIndent(source, \"\", \"\\t\")\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn string(buf), nil\n\t}\n\treturn \"\", fmt.Errorf(\"unsupported type: %T\", source)\n}", "title": "" }, { "docid": "f426dc573431f9ef64c53316e8c93e30", "score": "0.55449915", "text": "func (pA *TK) ToJSONIndent(objA interface{}) (string, error) {\n\t// var json = jsoniter.ConfigCompatibleWithStandardLibrary\n\t// var json = jsoniter.ConfigFastest\n\trs, errT := jsoniter.MarshalIndent(objA, \"\", \" \")\n\n\t// if errT != nil {\n\t// \treturn GenerateErrorString(errT.Error())\n\t// }\n\n\treturn string(rs), errT\n}", "title": "" }, { "docid": "1cfba4a235e38a50db13ce512ee3999c", "score": "0.5529404", "text": "func (commit *Commit) StringIndented(indent string) string {\n\tif commit == nil {\n\t\treturn \"nil-Commit\"\n\t}\n\tprecommitStrings := make([]string, len(commit.Precommits))\n\tfor i, precommit := range commit.Precommits {\n\t\tprecommitStrings[i] = precommit.String()\n\t}\n\treturn fmt.Sprintf(`Commit{\n%s BlockID: %v\n%s Precommits: %v\n%s}#%v`,\n\t\tindent, commit.BlockID,\n\t\tindent, strings.Join(precommitStrings, \"\\n\"+indent+\" \"),\n\t\tindent, commit.hash)\n}", "title": "" }, { "docid": "6f1dcd93b2a92db7fbe9d1ca52d428e3", "score": "0.5484469", "text": "func prettyPrint(v interface{}) string {\n\tb, err := json.MarshalIndent(v, \"\", \" \")\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "d8b7806d8a8d895de36f1fca8586e4d5", "score": "0.5428876", "text": "func MarshalJSONIndent(cdc *Codec, obj interface{}) ([]byte, error) {\n\tbz, err := cdc.MarshalJSON(obj)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar out bytes.Buffer\n\terr = json.Indent(&out, bz, \"\", \" \")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn out.Bytes(), nil\n}", "title": "" }, { "docid": "d47651797652fb5adfee936582f60c88", "score": "0.54272896", "text": "func PrettyPrint(v interface{}) (err error) {\n b, err := json.MarshalIndent(v, \"\", \" \")\n if err == nil {\n fmt.Println(string(b))\n }\n return err\n}", "title": "" }, { "docid": "1a5cd9ae2db0d1a0af7c2ded474be271", "score": "0.54136527", "text": "func PrettyJSONWithoutIndent(data interface{}) string {\n\tbuffer := new(bytes.Buffer)\n\tencoder := json.NewEncoder(buffer)\n\n\t_ = encoder.Encode(data)\n\treturn buffer.String()\n}", "title": "" }, { "docid": "b630b5b500d28c4916db775c5d314911", "score": "0.53960544", "text": "func (c *Card) BytesIndent(prefix string, indent string) ([]byte, error) {\n\tif err := c.Prepare(); err != nil {\n\t\treturn []byte{}, err\n\t}\n\treturn json.MarshalIndent(c, prefix, indent)\n}", "title": "" }, { "docid": "1e8dab659507abbcc7aaeeed230e7d71", "score": "0.53952855", "text": "func (an * OSGT) print_indent(indent string) string {\n\tout := \"\"\n\tfor _, more := range (an.List) {\n\t\tout += indent + \"[\" + more.Key + \"]\\n\";\n\t\tif more.Child != nil {\n\t\t\tout += more.Child.print_indent(indent + \" \")\n\t\t}\n\t}\n\treturn out\n}", "title": "" }, { "docid": "56eb2c77dd04cd6f440869b4e0297188", "score": "0.5393798", "text": "func (c *Card) String() (string, error) {\n\tcardJSON, err := c.Bytes()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(cardJSON), nil\n}", "title": "" }, { "docid": "34e5fbe89972cecfc3bf03fafc6e6d74", "score": "0.5383909", "text": "func Indent(s string) string {\n\ts = \"\\t\" + strings.Replace(s, \"\\n\", \"\\n\\t\", -1)\n\treturn strings.TrimRight(s, \"\\t\")\n}", "title": "" }, { "docid": "5599f399d7708a4e00d1610b2b03d946", "score": "0.5378677", "text": "func MarshalIndent(v interface{}, prefix string, indent string) ([]byte, error) {\n\tb, err := json.MarshalIndent(v, \"\", \" \")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tb = bytes.Replace(b, []byte(\"\\\\u003c\"), []byte(\"<\"), -1)\n\tb = bytes.Replace(b, []byte(\"\\\\u003e\"), []byte(\">\"), -1)\n\tb = bytes.Replace(b, []byte(\"\\\\u0026\"), []byte(\"&\"), -1)\n\tb = bytes.Replace(b, []byte(\"/\"), []byte(\"\\\\/\"), -1)\n\n\treturn b, nil\n}", "title": "" }, { "docid": "e270ad84f19dc72ce02cfae8e61e4cf7", "score": "0.53739667", "text": "func (s HiveJsonSerDe) String() string {\n\treturn awsutil.Prettify(s)\n}", "title": "" }, { "docid": "00d0ea2220ed7dfd61456ec82a30443e", "score": "0.5360396", "text": "func String(s string, indent uint) string {\n\treturn string(Bytes([]byte(s), indent))\n}", "title": "" }, { "docid": "16beee6061d74ba4a8b863428a2cd55f", "score": "0.5358479", "text": "func PrettyPrint(v interface{}) string {\n\tres, err := json.MarshalIndent(v, \"\", \" \")\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"%v\", v)\n\t}\n\treturn string(res)\n}", "title": "" }, { "docid": "30793dd4c8d8055e34abdef4e4cc5938", "score": "0.53164726", "text": "func Indent(n int, in string) string {\n\tout := strings.Builder{}\n\n\tlines := strings.Split(in, \"\\n\")\n\n\t// remove empty line at the end of the file if any\n\tif len(strings.TrimSpace(lines[len(lines)-1])) == 0 {\n\t\tlines = lines[:len(lines)-1]\n\t}\n\n\tfor i, line := range lines {\n\t\tout.WriteString(strings.Repeat(\" \", n))\n\t\tout.WriteString(line)\n\t\tif i < len(lines)-1 {\n\t\t\tout.WriteString(\"\\n\")\n\t\t}\n\t}\n\treturn out.String()\n}", "title": "" }, { "docid": "e461a0a9cf94b1751f4ac185e4855363", "score": "0.5315158", "text": "func (desc *ServiceDescription) JSON() string {\n\t// b, _ := json.MarshalIndent(desc, \"\", \"\\t\")\n\t// b, _ := json.Marshal(desc)\n\tbuf := new(bytes.Buffer)\n\tenc := json.NewEncoder(buf)\n\tenc.SetEscapeHTML(false)\n\tenc.SetIndent(\"\", \" \")\n\tif err := enc.Encode(desc); err != nil {\n\t\tfmt.Println(err)\n\t}\n\treturn buf.String()\n}", "title": "" }, { "docid": "fa224c6b0b645b79944c75ac8232881c", "score": "0.53135806", "text": "func indent(s string) string {\n\tfor i := 0; i < len(s); i++ {\n\t\tswitch s[i] {\n\t\tcase ' ', '\\t':\n\t\tdefault:\n\t\t\treturn s[:i]\n\t\t}\n\t}\n\treturn \"\"\n}", "title": "" }, { "docid": "7832833d80eef96c3b10fdb6814946b4", "score": "0.530401", "text": "func (o *Lexintent) String() string {\n \n \n o.Slots = map[string]Lexslot{\"\": {}} \n \n\n j, _ := json.Marshal(o)\n str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\\\u`, `\\u`, -1))\n\n return str\n}", "title": "" }, { "docid": "b51061d65495b779a4e1e06403b3e5d8", "score": "0.52995616", "text": "func (o *Effectiveconfiguration) String() string {\n o.Properties = map[string]interface{}{\"\": Interface{}} \n o.Advanced = map[string]interface{}{\"\": Interface{}} \n \n \n o.Credentials = map[string]Credentialinfo{\"\": {}} \n\n j, _ := json.Marshal(o)\n str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\\\u`, `\\u`, -1))\n\n return str\n}", "title": "" }, { "docid": "96a9c65d2c01ef869d8996ab088de53a", "score": "0.5293112", "text": "func formatJSON(object string) string {\n\tvar out bytes.Buffer\n\tjson.Indent(&out, []byte(object), \"\", \"\\t\")\n\treturn string(out.Bytes())\n}", "title": "" }, { "docid": "248bda75abc0eedfba0249446b21bff3", "score": "0.52884257", "text": "func PrettyJson(obj interface{}) string {\n\tpretty := bytes.Buffer{}\n\tdata, err := json.Marshal(obj)\n\tif err != nil {\n\t\tglog.Errorf(\"PrettyJson, mashal error: %s\\n\", err.Error())\n\t\treturn \"\"\n\t}\n\terr = json.Indent(&pretty, data, \"\", \" \")\n\n\tif err != nil {\n\t\tglog.Errorf(\"PrettyJson, indent error: %s\\n\", err.Error())\n\t\treturn \"\"\n\t}\n\treturn pretty.String()\n}", "title": "" }, { "docid": "92bc03b136dee5b819d14ae773182936", "score": "0.5282166", "text": "func printJson(config sdkcommon.DeviceConfig) {\n\tif config.DeviceName == \"<unknown>\" {\n\t\treturn\n\t}\n\tbuf := new(bytes.Buffer)\n\tenc := json.NewEncoder(buf)\n\tenc.SetEscapeHTML(false)\n\tenc.SetIndent(\"\", \" \")\n\tif err := enc.Encode(config); err != nil {\n\t\tlog.Println(err)\n\t}\n\tstdoutPrintln(strings.TrimSpace(buf.String()))\n}", "title": "" }, { "docid": "d2f3c7b6040bd88d6deb2634dad40879", "score": "0.52685475", "text": "func PrettyJson(data interface{}) (string, error) {\n\tbuffer := new(bytes.Buffer)\n\tencoder := json.NewEncoder(buffer)\n\tencoder.SetIndent(empty, tab)\n\n\terr := encoder.Encode(data)\n\tif err != nil {\n\t\treturn empty, err\n\t}\n\treturn buffer.String(), nil\n}", "title": "" }, { "docid": "a8bf7a1d1fe1b92c8fba0bba1683be8c", "score": "0.5259693", "text": "func (r *Receipt) String() string {\n\tout, err := json.MarshalIndent(r, \"\", \"\\t\")\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"%v\", err)\n\t}\n\treturn string(out)\n}", "title": "" }, { "docid": "b3699825591d50bf8de1fea08b0da2f9", "score": "0.5254988", "text": "func (h Hazards) String() string {\n\tjh, _ := json.Marshal(h)\n\treturn string(jh)\n}", "title": "" }, { "docid": "c79170cfb802346a4a7cb7baefbe8baa", "score": "0.524462", "text": "func (fp *GetProvisioningPolicyRequest_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "f8b1043382fa8eb5883cb9ae787156ce", "score": "0.5243593", "text": "func (clientMessageDebugUpdateDone ClientMessageDebugUpdateDone) String() string {\n stringResult := \"{ \"\n stringResult += \" }\"\n return stringResult\n}", "title": "" }, { "docid": "abf9234c9dc76f28bb16feed0bcfd4b7", "score": "0.5242057", "text": "func (i *Info) JSONString() (string, error) {\n\tb, err := json.MarshalIndent(i, \"\", \" \")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(b), nil\n}", "title": "" }, { "docid": "abf9234c9dc76f28bb16feed0bcfd4b7", "score": "0.5242057", "text": "func (i *Info) JSONString() (string, error) {\n\tb, err := json.MarshalIndent(i, \"\", \" \")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(b), nil\n}", "title": "" }, { "docid": "aef4e2a9a20f60de42f1c01a88edc64f", "score": "0.524157", "text": "func indent(length int, in string) string {\n\tif len(in) == 0 {\n\t\treturn \"\"\n\t}\n\tpad := strings.Repeat(\" \", length)\n\tinlines := strings.Split(in, \"\\n\")\n\toutlines := make([]string, len(inlines))\n\tfor i, inline := range inlines {\n\t\t// empty lines not indented\n\t\t// if strings.TrimSpace(inline) == \"\" {\n\t\t// \toutlines[i] = \"\"\n\t\t// } else {\n\t\t// \toutlines[i] = pad + inline\n\t\t// }\n\t\t// empty lines indented\n\t\toutlines[i] = pad + inline\n\t}\n\treturn strings.Join(outlines, \"\\n\")\n}", "title": "" }, { "docid": "eca047330407020fd4b7c6fed2711e6c", "score": "0.5235463", "text": "func (i *Info) JSONString() (string, error) {\n\tb, err := json.MarshalIndent(i, \"\", \" \")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn string(b), nil\n}", "title": "" }, { "docid": "4666508c9d7016159456c29001c8d7eb", "score": "0.52276236", "text": "func (fp *WatchProvisioningPolicyRequest_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "995b14a51f7b611f864f6d62381920db", "score": "0.52247214", "text": "func Indent(width int) string {\n\treturn strings.Repeat(\"\\t\", width)\n}", "title": "" }, { "docid": "ff52a6b1a5fbb76ae178e21fd74bbb85", "score": "0.52247137", "text": "func (o *outline) String() string {\n\treturn o.StringIndent(0)\n}", "title": "" }, { "docid": "3ab56ac0218fd8213cd4a7c309281701", "score": "0.5222362", "text": "func (fp *DeviceSpecNetworkConfigWifiOptsAccessPoint_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "7e1fd9ee1922fcef71e0e183af26edf6", "score": "0.5221553", "text": "func PrettyPrint(value interface{}) string {\n\tif s, ok := value.(string); ok {\n\t\treturn s\n\t}\n\tvalueJson, err := json.MarshalIndent(value, \"\", \" \")\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to marshal value; error %v\", err)\n\t\treturn fmt.Sprintf(\"%+v\", value)\n\t}\n\treturn string(valueJson)\n}", "title": "" }, { "docid": "3b8aba7395a9749efaf1a801ea99033e", "score": "0.5220946", "text": "func (fp *CheckMyRolesResponseConditionalGrant_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "7ebfbf760f7e8a0875926afce654406c", "score": "0.5218998", "text": "func (c Cart) String() string {\n\tjc, _ := json.Marshal(c)\n\treturn string(jc)\n}", "title": "" }, { "docid": "52c889d49431b888ca8d22c09127b3e9", "score": "0.5218535", "text": "func (fp *DeviceSpecNetworkConfigCommonOptsAuth_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "7e02601ea48e78fde14e4697dbc50f36", "score": "0.52125573", "text": "func (s OpenXJsonSerDe) String() string {\n\treturn awsutil.Prettify(s)\n}", "title": "" }, { "docid": "5f0408e31cb1c954b6470fcab0ab0f7c", "score": "0.52096546", "text": "func toJsonStr(input interface{}) (string, error) {\n\toutput, err := json.MarshalIndent(input, \"\", \" \")\n\treturn string(output), err\n}", "title": "" }, { "docid": "65b8162778b935a4dc0340e93093b83c", "score": "0.5208408", "text": "func (kt *Keytab) JSON() (string, error) {\n\tb, err := json.MarshalIndent(kt, \"\", \" \")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(b), nil\n}", "title": "" }, { "docid": "97bc8c22da25c5af18180a9c93b70dd5", "score": "0.51998353", "text": "func (s DashEncryption) String() string {\n\treturn awsutil.Prettify(s)\n}", "title": "" }, { "docid": "97bc8c22da25c5af18180a9c93b70dd5", "score": "0.51998353", "text": "func (s DashEncryption) String() string {\n\treturn awsutil.Prettify(s)\n}", "title": "" }, { "docid": "03df5bc4e9879e83bcc900b2e13c13fe", "score": "0.5199309", "text": "func (fp *WatchProvisioningPolicyResponse_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "2348e4966807b61b53e670501af9acb9", "score": "0.5197294", "text": "func (fp *MultiRegionPolicy_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "084c9170dcbce19747c01d15abb89cbb", "score": "0.5191456", "text": "func (fp *DeviceSpecSSHConfigAuthKey_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "b57d4509d826e161a12411c450a22aa0", "score": "0.51858544", "text": "func (r response) String() string {\n\tb, err := json.MarshalIndent(r, \"\", \" \")\n\tcheck(err)\n\treturn string(b)\n}", "title": "" }, { "docid": "0db3bb91b1374ae1159c9acaf00ab583", "score": "0.51857597", "text": "func format(initialIndent int, value string) string {\n\tindentationMark := \" \"\n\tnIndent := initialIndent\n\tvar builder strings.Builder\n\n\trunes := []rune(strings.Trim(value, \" \\t\\n\"))\n\tfor i := 0; i < len(runes); i++ {\n\t\tr := runes[i]\n\t\tbuilder.WriteRune(r)\n\t\tswitch r {\n\t\tcase '{', '[':\n\t\t\tnIndent++\n\t\tcase '}', ']':\n\t\t\tnIndent--\n\t\tcase '\\n':\n\t\tloop:\n\t\t\tfor i+1 < len(runes) {\n\t\t\t\tswitch runes[i+1] {\n\t\t\t\tcase ' ', '\\t':\n\t\t\t\t\ti++\n\t\t\t\tdefault:\n\t\t\t\t\tbreak loop\n\t\t\t\t}\n\t\t\t}\n\t\t\teffectiveIndent := nIndent\n\t\t\tif i+1 < len(runes) && (runes[i+1] == '}' || runes[i+1] == ']') {\n\t\t\t\teffectiveIndent--\n\t\t\t}\n\t\t\tif i+1 == len(runes) || runes[i+1] != '\\n' {\n\t\t\t\tbuilder.WriteString(strings.Repeat(indentationMark, effectiveIndent))\n\t\t\t}\n\t\t}\n\t}\n\treturn builder.String()\n}", "title": "" }, { "docid": "b57a9718f2f008e30c731bf91c6df3c9", "score": "0.51847446", "text": "func JSONPrettyPrint(in []byte) []byte {\n\tvar out bytes.Buffer\n\terr := json.Indent(&out, in, \"\", \" \")\n\tif err != nil {\n\t\treturn in\n\t}\n\treturn out.Bytes()\n}", "title": "" }, { "docid": "c2a164494eacc5bca667ac0d8e9f1054", "score": "0.5180637", "text": "func (fp *CreateProvisioningPolicyRequest_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "5499e27c9515ed487eeaa0516c5763ef", "score": "0.51757866", "text": "func (r *Runner) JSON(indents ...int) []byte {\n\tindent := 0\n\tif 0 < len(indents) {\n\t\tindent = indents[0]\n\t}\n\treturn []byte(oj.JSON(r, indent))\n}", "title": "" }, { "docid": "c8a8c977935dd8db9d0da5ccfbf8b40b", "score": "0.5172763", "text": "func (c Cookbook) String() (out string) {\n\tcc, err := json.MarshalIndent(c,\"\",\" \")\n if err != nil {\n fmt.Println(\"error:\", err)\n }\n\treturn string(cc)\n}", "title": "" }, { "docid": "f133d61dff15b10f282908582277ca6c", "score": "0.5171853", "text": "func (lex Lexeme) IndentString(n int) string {\n\tlit := lex.literal\n\tif lex.token == token.STRING {\n\t\tlit = strconv.Quote(lex.literal)\n\t}\n\treturn fmt.Sprintf(\"%3d, %3d %-10s %s%s\", lex.lineNumber, lex.charNumber, lex.token.String(), strings.Repeat(\" \", n), lit)\n}", "title": "" }, { "docid": "a579fec8724533a74e0bae61e9bcdfef", "score": "0.51715875", "text": "func (fp *DeviceSpecNetworkConfigCommonOptsDHCPOverrides_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "7da171e43a423ca63f6c9b7f5eebb0b7", "score": "0.5165748", "text": "func (s *Segment) String() string {\n\tb, err := json.MarshalIndent(s, \"\", \" \")\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "d81f61896094a55284f7250d1ecaf7ec", "score": "0.51563096", "text": "func (fp *DeviceSpecNetworkConfigCommonOpts_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "62f53bbc52b4ed70f3fe346c673599be", "score": "0.5155007", "text": "func (fp *ConditionalGrant_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "f2655a4fb7fa633b5771fb89010035d6", "score": "0.5154828", "text": "func PrettyPrint(x interface{}) {\n\tb, err := json.MarshalIndent(x, \"\", \" \")\n\tif err != nil {\n\t\tfmt.Println(\"error:\", err)\n\t}\n\tfmt.Println(string(b))\n}", "title": "" }, { "docid": "1bbb9535d260c07ce98e06f9da2eedeb", "score": "0.5154146", "text": "func prettify(s string) string {\n\treturn prettifyJson(s, false)\n}", "title": "" }, { "docid": "d5b655b9883331d8845979e0061a3e66", "score": "0.5152229", "text": "func (fp *DeviceSpecNetworkConfigEthOptsMatch_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "907f21fd4c7aa2d4b3e60e98cd76a8de", "score": "0.5149873", "text": "func (t *DirectiveVersion) String() string {\n\tjt, _ := json.MarshalIndent(t, \" \", \" \") //nolint:errchkjson\n\treturn string(jt)\n}", "title": "" }, { "docid": "56bc3c1d33695c6288625482ca056064", "score": "0.5148338", "text": "func (fp *VerifyRequestChallengeResponseQuote_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "bb684900bea1fa711a1e5b00559ba44c", "score": "0.51458955", "text": "func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) {\n\tif m, ok := v.(json.Marshaler); ok {\n\t\tb, err := m.MarshalJSON()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\tif err = json.Indent(&buf, b, prefix, indent); err == nil {\n\t\t\treturn buf.Bytes(), nil\n\t\t}\n\t\treturn nil, err\n\t}\n\n\treturn jsonAdapter.MarshalIndent(v, prefix, indent)\n}", "title": "" }, { "docid": "3c4ea8a1c87e250ed5cdec0712acc6b2", "score": "0.51448125", "text": "func (fp *DeviceSpecNetworkConfig_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "11de7267cdfe6d4a59aabf06ee58f2c5", "score": "0.51434815", "text": "func (a Create) String() string {\n\traw, err := json.MarshalIndent(\n\t\ta,\n\t\t\" \",\n\t\t\".\",\n\t)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn string(raw)\n}", "title": "" }, { "docid": "539554306a81391dcbabdf6b2ad71df4", "score": "0.5140767", "text": "func (s JSONOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "title": "" }, { "docid": "56456492e57fdcce8d6589bab882d701", "score": "0.51399565", "text": "func (fp *DeviceSpecNetworkConfigEthOpts_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "609ea9c1a963e8b4d9db2c306865f744", "score": "0.5135254", "text": "func QueryIndent(ms interface{}) string {\n\tdata, err := json.MarshalIndent(ms, \"\", \"\\n\")\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\n\treturn string(data)\n}", "title": "" }, { "docid": "59805a57a5679528b54311017e06dc5c", "score": "0.513302", "text": "func (fp *DeviceSpecNetworkConfigWifiOpts_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "bfa01ba86664a1c0923bebc203654a2d", "score": "0.5127851", "text": "func (c Carts) String() string {\n\tjc, _ := json.Marshal(c)\n\treturn string(jc)\n}", "title": "" }, { "docid": "b876096ed8a4e1dc4cff5315431455b0", "score": "0.51273346", "text": "func (fp *DeviceSpecNetworkConfigTunnelsOpts_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "1b38d895b1e391e73c5f7d7bb51ab162", "score": "0.5125858", "text": "func PrettyPrint(v interface{}) string {\n\tb, err := json.MarshalIndent(v, \"\", \" \")\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "7ba836ceafb3fbf9db21346632f21b5c", "score": "0.5125085", "text": "func (fp *DeviceSpecAttestationConfig_FieldTerminalPath) JSONString() string {\n\treturn strcase.ToLowerCamel(fp.String())\n}", "title": "" }, { "docid": "a35002b20d87122946dfdadc9ea4143d", "score": "0.5123774", "text": "func String() string {\n\treturn string(JSON())\n}", "title": "" }, { "docid": "1b1e307bd83c6a0f75ba16dd03a65acd", "score": "0.51211125", "text": "func (o *Routingconversationattributesrequest) String() string {\n \n o.SkillIds = []string{\"\"} \n \n o.RequestScoredAgents = []Requestscoredagent{{}} \n\n j, _ := json.Marshal(o)\n str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\\\u`, `\\u`, -1))\n\n return str\n}", "title": "" }, { "docid": "0f1104d87759d35343e7e0355d00d3ca", "score": "0.51176745", "text": "func (s EncryptionAtRestOptions) String() string {\n\treturn awsutil.Prettify(s)\n}", "title": "" }, { "docid": "fdc4f7e66109f717c96980c642dbefd3", "score": "0.51166856", "text": "func (o *Team) StringifyPretty() string {\n\to.Hash()\n\treturn pjson.Stringify(o, true)\n}", "title": "" } ]
dddd474e00801166a07a12ea1b0d0c76
Hypot returns the hypotenuse of a rightangled triangle with sides x and y as a new Distance.
[ { "docid": "17b96fcddb81044452fc64d885aacb8e", "score": "0.76970965", "text": "func Hypot(x, y Distance) Distance {\n\treturn Distance(math.Hypot(float64(x), float64(y)))\n}", "title": "" } ]
[ { "docid": "f0d795562cbc094e52bd594a4a55920d", "score": "0.67929256", "text": "func (z *Decimal) Hypot(p, q *Decimal) *Decimal {\n\tp0 := new(Decimal).Set(p)\n\tq0 := new(Decimal).Set(q)\n\n\tif p0.ltz() {\n\t\tp0.Neg(p0)\n\t}\n\n\tif q0.ltz() {\n\t\tq0.Neg(q0)\n\t}\n\n\tif p0.ez() {\n\t\treturn New(0, 0)\n\t}\n\tp0.Mul(p0, p0)\n\tq0.Mul(q0, q0)\n\tz.Sqrt(p0.Add(p0, q0))\n\treturn z.SetPrec(z.Prec())\n}", "title": "" }, { "docid": "a3a6109eb795e4507ca4f9270cce5da2", "score": "0.6405289", "text": "func Xhypotl(tls TLS, _x float64, _y float64) (r float64) {\n\treturn Xhypot(tls, _x, _y)\n}", "title": "" }, { "docid": "874bba757ed3bb1ce4833bb75f9d7e4c", "score": "0.57744634", "text": "func (Implementation) Dlapy2(x, y float64) float64 {\n\treturn math.Hypot(x, y)\n}", "title": "" }, { "docid": "6838bac6be86345423897c206e4cc70a", "score": "0.5612744", "text": "func Xhypot(tls TLS, _x float64, _y float64) (r float64) {\n\tesc := MustMalloc(88)\n\tvar (\n\t\t_ux = esc // *struct{Ff [0]float64;Fi [0]uint64;F int64}\n\t\t_uy = esc + 16 // *struct{Ff [0]float64;Fi [0]uint64;F int64}\n\t\t_ut struct {\n\t\t\tFf [0]float64\n\t\t\tFi [0]uint64\n\t\t\tF int64\n\t\t}\n\t\t_ex int32\n\t\t_ey int32\n\t\t_hx = esc + 32 // *Tdouble_t = float64\n\t\t_lx = esc + 48 // *Tdouble_t = float64\n\t\t_hy = esc + 64 // *Tdouble_t = float64\n\t\t_ly = esc + 80 // *Tdouble_t = float64\n\t\t_z float64\n\t)\n\tdefer Free(esc)\n\t*(*struct {\n\t\tFf [0]float64\n\t\tFi [0]uint64\n\t\tF int64\n\t})(unsafe.Pointer(_ux)) = *(*struct {\n\t\tFf [0]float64\n\t\tFi [0]uint64\n\t\tF int64\n\t})(unsafe.Pointer(&struct{ f float64 }{_x}))\n\t*(*struct {\n\t\tFf [0]float64\n\t\tFi [0]uint64\n\t\tF int64\n\t})(unsafe.Pointer(_uy)) = *(*struct {\n\t\tFf [0]float64\n\t\tFi [0]uint64\n\t\tF int64\n\t})(unsafe.Pointer(&struct{ f float64 }{_y}))\n\t{\n\t\tp := (*uint64)(unsafe.Pointer(_ux))\n\t\t*p = *p & uint64(9223372036854775807)\n\t}\n\t{\n\t\tp := (*uint64)(unsafe.Pointer(_uy))\n\t\t*p = *p & uint64(9223372036854775807)\n\t}\n\tif !(*(*uint64)(unsafe.Pointer(_ux)) < *(*uint64)(unsafe.Pointer(_uy))) {\n\t\tgoto _1\n\t}\n\n\t_ut = *(*struct {\n\t\tFf [0]float64\n\t\tFi [0]uint64\n\t\tF int64\n\t})(unsafe.Pointer(_ux))\n\t*(*struct {\n\t\tFf [0]float64\n\t\tFi [0]uint64\n\t\tF int64\n\t})(unsafe.Pointer(_ux)) = *(*struct {\n\t\tFf [0]float64\n\t\tFi [0]uint64\n\t\tF int64\n\t})(unsafe.Pointer(_uy))\n\t*(*struct {\n\t\tFf [0]float64\n\t\tFi [0]uint64\n\t\tF int64\n\t})(unsafe.Pointer(_uy)) = _ut\n_1:\n\t_ex = int32(*(*uint64)(unsafe.Pointer(_ux)) >> (uint(52) % 64))\n\t_ey = int32(*(*uint64)(unsafe.Pointer(_uy)) >> (uint(52) % 64))\n\t_x = *(*float64)(unsafe.Pointer(_ux))\n\t_y = *(*float64)(unsafe.Pointer(_uy))\n\tif !(_ey == int32(0x7ff)) {\n\t\tgoto _2\n\t}\n\n\treturn _y\n\n_2:\n\tif !((_ex == int32(0x7ff)) || (*(*uint64)(unsafe.Pointer(_uy)) == uint64(0))) {\n\t\tgoto _3\n\t}\n\n\treturn _x\n\n_3:\n\tif !(_ex-_ey > int32(64)) {\n\t\tgoto _4\n\t}\n\n\treturn _x + _y\n\n_4:\n\t_z = float64(1)\n\tif !(_ex > int32(1533)) {\n\t\tgoto _5\n\t}\n\n\t_z = float64(5.260135901548374e+210)\n\t_x = _x * float64(1.90109156629516e-211)\n\t_y = _y * float64(1.90109156629516e-211)\n\tgoto _6\n\n_5:\n\tif !(_ey < int32(573)) {\n\t\tgoto _7\n\t}\n\n\t_z = float64(1.90109156629516e-211)\n\t_x = _x * float64(5.260135901548374e+210)\n\t_y = _y * float64(5.260135901548374e+210)\n_7:\n_6:\n\txsq(tls, _hx, _lx, _x)\n\txsq(tls, _hy, _ly, _y)\n\treturn _z * Xsqrt(tls, float64(float64(*(*float64)(unsafe.Pointer(_ly))+*(*float64)(unsafe.Pointer(_lx)))+*(*float64)(unsafe.Pointer(_hy)))+*(*float64)(unsafe.Pointer(_hx)))\n}", "title": "" }, { "docid": "660e4d7ae6b760e383ed69386a306845", "score": "0.5554586", "text": "func Hypot(arguments ...float64) float64 {\n\t// Implementation note: this is line-by-line translated from\n\t// https://github.com/v8/v8/blob/fdc9fade975d9114ead769e7aeb4fd9a490f80f8/src/builtins/math.tq#L403\n\n\t// Find max and deal with edge cases.\n\tlength := len(arguments)\n\tif length == 0 {\n\t\treturn 0\n\t}\n\tabsValues := make([]float64, length)\n\toneArgIsNaN := false\n\tmax := 0.0\n\tfor i, value := range arguments {\n\t\tif math.IsNaN(value) {\n\t\t\toneArgIsNaN = true\n\t\t} else {\n\t\t\tabsValue := math.Abs(value)\n\t\t\tabsValues[i] = absValue\n\t\t\tif absValue > max {\n\t\t\t\tmax = absValue\n\t\t\t}\n\t\t}\n\t}\n\tif math.IsInf(max, 1) {\n\t\treturn math.Inf(1)\n\t} else if oneArgIsNaN {\n\t\treturn math.NaN()\n\t} else if max == 0 {\n\t\treturn 0\n\t}\n\n\t// Kahan summation to avoid rounding errors.\n\t// Normalize the numbers to the largest one to avoid rounding errors.\n\tsum := 0.0\n\tcompensation := 0.0\n\tfor _, value := range absValues {\n\t\tn := value / max\n\t\tsummand := n*n - compensation\n\t\tpreliminary := sum + summand\n\t\tcompensation = (preliminary - sum) - summand\n\t\tsum = preliminary\n\t}\n\treturn math.Sqrt(sum) * max\n}", "title": "" }, { "docid": "0618aca05948b4a1ba811e38407bdff5", "score": "0.53881925", "text": "func (p Point) Distance(q Point) float64 {\n\treturn math.Hypot(q.X-p.X, q.Y-p.Y)\n}", "title": "" }, { "docid": "0618aca05948b4a1ba811e38407bdff5", "score": "0.53881925", "text": "func (p Point) Distance(q Point) float64 {\n\treturn math.Hypot(q.X-p.X, q.Y-p.Y)\n}", "title": "" }, { "docid": "0618aca05948b4a1ba811e38407bdff5", "score": "0.53881925", "text": "func (p Point) Distance(q Point) float64 {\n\treturn math.Hypot(q.X-p.X, q.Y-p.Y)\n}", "title": "" }, { "docid": "6c41af3c39782ea31e11759f2d3a9b04", "score": "0.47449374", "text": "func Xhypotf(tls TLS, _x float32, _y float32) (r float32) {\n\tesc := MustMalloc(20)\n\tvar (\n\t\t_ux = esc // *struct{Ff [0]float32;Fi [0]uint32;F int32}\n\t\t_uy = esc + 16 // *struct{Ff [0]float32;Fi [0]uint32;F int32}\n\t\t_ut struct {\n\t\t\tFf [0]float32\n\t\t\tFi [0]uint32\n\t\t\tF int32\n\t\t}\n\t\t_z float32\n\t)\n\tdefer Free(esc)\n\t*(*struct {\n\t\tFf [0]float32\n\t\tFi [0]uint32\n\t\tF int32\n\t})(unsafe.Pointer(_ux)) = *(*struct {\n\t\tFf [0]float32\n\t\tFi [0]uint32\n\t\tF int32\n\t})(unsafe.Pointer(&struct{ f float32 }{_x}))\n\t*(*struct {\n\t\tFf [0]float32\n\t\tFi [0]uint32\n\t\tF int32\n\t})(unsafe.Pointer(_uy)) = *(*struct {\n\t\tFf [0]float32\n\t\tFi [0]uint32\n\t\tF int32\n\t})(unsafe.Pointer(&struct{ f float32 }{_y}))\n\t{\n\t\tp := (*uint32)(unsafe.Pointer(_ux))\n\t\t*p = *p & uint32(2147483647)\n\t}\n\t{\n\t\tp := (*uint32)(unsafe.Pointer(_uy))\n\t\t*p = *p & uint32(2147483647)\n\t}\n\tif !(*(*uint32)(unsafe.Pointer(_ux)) < *(*uint32)(unsafe.Pointer(_uy))) {\n\t\tgoto _1\n\t}\n\n\t_ut = *(*struct {\n\t\tFf [0]float32\n\t\tFi [0]uint32\n\t\tF int32\n\t})(unsafe.Pointer(_ux))\n\t*(*struct {\n\t\tFf [0]float32\n\t\tFi [0]uint32\n\t\tF int32\n\t})(unsafe.Pointer(_ux)) = *(*struct {\n\t\tFf [0]float32\n\t\tFi [0]uint32\n\t\tF int32\n\t})(unsafe.Pointer(_uy))\n\t*(*struct {\n\t\tFf [0]float32\n\t\tFi [0]uint32\n\t\tF int32\n\t})(unsafe.Pointer(_uy)) = _ut\n_1:\n\t_x = *(*float32)(unsafe.Pointer(_ux))\n\t_y = *(*float32)(unsafe.Pointer(_uy))\n\tif !(*(*uint32)(unsafe.Pointer(_uy)) == uint32(2139095040)) {\n\t\tgoto _2\n\t}\n\n\treturn _y\n\n_2:\n\tif !(((*(*uint32)(unsafe.Pointer(_ux)) >= uint32(2139095040)) || (*(*uint32)(unsafe.Pointer(_uy)) == uint32(0))) || (*(*uint32)(unsafe.Pointer(_ux))-*(*uint32)(unsafe.Pointer(_uy)) >= uint32(209715200))) {\n\t\tgoto _3\n\t}\n\n\treturn _x + _y\n\n_3:\n\t_z = float32(1)\n\tif !(*(*uint32)(unsafe.Pointer(_ux)) >= uint32(1568669696)) {\n\t\tgoto _4\n\t}\n\n\t_z = float32(1.2379401e+27)\n\t_x = _x * float32(8.077936e-28)\n\t_y = _y * float32(8.077936e-28)\n\tgoto _5\n\n_4:\n\tif !(*(*uint32)(unsafe.Pointer(_uy)) < uint32(562036736)) {\n\t\tgoto _6\n\t}\n\n\t_z = float32(8.077936e-28)\n\t_x = _x * float32(1.2379401e+27)\n\t_y = _y * float32(1.2379401e+27)\n_6:\n_5:\n\treturn _z * Xsqrtf(tls, float32(float64(float64(_x)*float64(_x))+float64(float64(_y)*float64(_y))))\n}", "title": "" }, { "docid": "191c341e83770d073d0239a3e3e7b38e", "score": "0.46673852", "text": "func (v Vec2f) Length() float32 {\n\treturn math32.Hypot(v[0], v[1])\n}", "title": "" }, { "docid": "f43f847dbc6042baebb8fca00d8b332b", "score": "0.4652994", "text": "func xyDist(x, y, p, q float64) float64 {\n\treturn math.Sqrt(math.Pow((x-p), 2) + math.Pow((y-q), 2))\n}", "title": "" }, { "docid": "f21d3845076945fdbe8c3934a6e351b9", "score": "0.45978177", "text": "func (p Point) Length() float64 {\n\treturn math.Sqrt(p.x*p.x + p.y*p.y)\n}", "title": "" }, { "docid": "e7eedfa27e475b2bd4e66cfb34fb432e", "score": "0.44332972", "text": "func triangleArea2(pt1, pt2, pt3 XY) float64 {\n\treturn (pt2.X-pt1.X)*(pt3.Y-pt1.Y) - (pt3.X-pt1.X)*(pt2.Y-pt1.Y)\n}", "title": "" }, { "docid": "c4308d1f643d21e17724052d8b401f1b", "score": "0.44219103", "text": "func triArea2D(a, b, c Vert) float32 {\n\tvar (\n\t\tabx = b.X - a.X\n\t\tabz = b.Z - a.Z\n\t\tacx = c.X - a.X\n\t\tacz = c.Z - a.Z\n\t)\n\treturn acx*abz - abx*acz\n}", "title": "" }, { "docid": "637917b47fe2153e39dd545647f32783", "score": "0.43784606", "text": "func Quadrature(\n\tf func([]float64) float64,\n\tleft, right []float64,\n\th []float64,\n) (float64, error) {\n\tn := len(left)\n\tif n != len(right) || n != len(h) {\n\t\treturn 0, ErrWrongDimensions\n\t}\n\n\tvar (\n\t\tcalculate func() float64\n\t\tk int\n\t\tx = make([]float64, n)\n\t)\n\tcopy(x, left)\n\n\tcalculate = func() float64 {\n\t\tvar (\n\t\t\tsum = 0.0\n\t\t\tw = right[k] - left[k]\n\t\t\tcount = int(math.Round(w / h[k]))\n\t\t)\n\t\tif k < n-1 {\n\t\t\tk++\n\t\t\tsum += 0.5 * calculate()\n\n\t\t\tfor i := 1; i < count; i++ {\n\t\t\t\tx[k] = left[k] + float64(i)*h[k]\n\t\t\t\tk++\n\t\t\t\tsum += calculate()\n\t\t\t}\n\n\t\t\tx[k] = right[k]\n\t\t\tk++\n\t\t\tsum += 0.5 * calculate()\n\t\t} else {\n\t\t\tsum += 0.5 * f(x)\n\t\t\tfor i := 1; i < count; i++ {\n\t\t\t\tx[k] = left[k] + float64(i)*h[k]\n\t\t\t\tsum += f(x)\n\t\t\t}\n\t\t\tx[k] = right[k]\n\t\t\tsum += 0.5 * f(x)\n\t\t}\n\t\tsum *= h[k]\n\n\t\tx[k] = left[k]\n\t\tk--\n\n\t\treturn sum\n\t}\n\n\treturn calculate(), nil\n}", "title": "" }, { "docid": "95357ecf40f16ab3de736d65d2b2d101", "score": "0.43403432", "text": "func (pt Point) GetDistance(p Point) float64 {\n\tx := p.X - pt.X\n\ty := p.Y - pt.Y\n\treturn math.Sqrt(math.Pow(x, 2) + math.Pow(y, 2))\n}", "title": "" }, { "docid": "c550b31a86aafb4b2ecbdc62566098b5", "score": "0.43394515", "text": "func DtClosestHeightPointTriangle(p, a, b, c []float32, h *float32) bool {\n\tv0 := [3]float32{}\n\tv1 := [3]float32{}\n\tv2 := [3]float32{}\n\tDtVsub(v0[:], c, a)\n\tDtVsub(v1[:], b, a)\n\tDtVsub(v2[:], p, a)\n\n\tdot00 := DtVdot2D(v0[:], v0[:])\n\tdot01 := DtVdot2D(v0[:], v1[:])\n\tdot02 := DtVdot2D(v0[:], v2[:])\n\tdot11 := DtVdot2D(v1[:], v1[:])\n\tdot12 := DtVdot2D(v1[:], v2[:])\n\n\t// Compute barycentric coordinates\n\tinvDenom := 1.0 / (dot00*dot11 - dot01*dot01)\n\tu := (dot11*dot02 - dot01*dot12) * invDenom\n\tv := (dot00*dot12 - dot01*dot02) * invDenom\n\n\t// The (sloppy) epsilon is needed to allow to get height of points which\n\t// are interpolated along the edges of the triangles.\n\t//\tstatic const float EPS = 1e-4f;\n\n\t// If point lies inside the triangle, return interpolated ycoord.\n\tif u >= -EPS && v >= -EPS && (u+v) <= 1+EPS {\n\t\t*h = a[1] + v0[1]*u + v1[1]*v\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "01660c7b76ca8a69e8d16116bf49c779", "score": "0.43378764", "text": "func (u Vec2) Len() float64 {\n\treturn math.Hypot(u.X, u.Y)\n}", "title": "" }, { "docid": "8703bd78ab42e27376882676c837a379", "score": "0.42788336", "text": "func (p Point) Distance(p2 Point) float64 {\n\tfirst := math.Pow(float64(p2.X-p.X), 2)\n\tsecond := math.Pow(float64(p2.Y-p.Y), 2)\n\treturn math.Sqrt(first + second)\n}", "title": "" }, { "docid": "e75000ab033b914382e2fc422251a225", "score": "0.42717737", "text": "func GetDistance(a *Point, b *Point) float64 {\n\tdistance := math.Sqrt(math.Pow(a.x-b.x, 2) + math.Pow(a.y-b.y, 2) + math.Pow(a.z-b.z, 2))\n\treturn distance\n}", "title": "" }, { "docid": "f2fcc1bc11eedb048058b848e0a52ac9", "score": "0.42667", "text": "func distance(x1, y1, x2, y2 float64) float64 {\n\ta := x2 - x1\n\tb := y2 - y1\n\treturn math.Sqrt(a*a + b*b)\n}", "title": "" }, { "docid": "f2fcc1bc11eedb048058b848e0a52ac9", "score": "0.42667", "text": "func distance(x1, y1, x2, y2 float64) float64 {\n\ta := x2 - x1\n\tb := y2 - y1\n\treturn math.Sqrt(a*a + b*b)\n}", "title": "" }, { "docid": "5fb11836dd7384e5103c05091991c3b9", "score": "0.42657837", "text": "func perpendicularDistance(p, a, b XY) float64 {\n\tif a == b {\n\t\treturn p.Sub(a).Length()\n\t}\n\taSubP := a.Sub(p)\n\tbSubA := b.Sub(a)\n\tunit := bSubA.Scale(1 / bSubA.Length())\n\tperpendicular := aSubP.Sub(unit.Scale(aSubP.Dot(unit)))\n\treturn perpendicular.Length()\n}", "title": "" }, { "docid": "be14f5a1296a8a6aa57e41d3f23e2b88", "score": "0.42328808", "text": "func (p1 Position) Distance(p2 Position) float32 {\n\td := float32(p2.Down.Subtract(p1.Down))\n\tl := float32(p2.Left.Subtract(p1.Left))\n\treturn float32(math.Sqrt(float64(d*d + l*l)))\n}", "title": "" }, { "docid": "e89ad1c64b87f4e3d8523e71d6caa5e9", "score": "0.42220107", "text": "func (a Quat) Length() float64 {\n\treturn math.Sqrt(a.W*a.W + a.X*a.X + a.Y*a.Y + a.Z*a.Z)\n}", "title": "" }, { "docid": "2361fda8958f00056e77ac4812ef0aa2", "score": "0.41905403", "text": "func calculateLength(l types.LineString) float64 {\n\tvar length float64\n\tfor i := 0; i < len(l.Points)-1; i++ {\n\t\tp1 := l.Points[i]\n\t\tp2 := l.Points[i+1]\n\t\tlength += math.Sqrt(math.Pow(p2.X-p1.X, 2) + math.Pow(p2.Y-p1.Y, 2))\n\t}\n\treturn length\n}", "title": "" }, { "docid": "1c21631efc2b89321eb2db96db335fc6", "score": "0.4187559", "text": "func distance(a, b *Vertex) float64 {\n\treturn math.Sqrt(math.Pow(b.X-a.X, 2) + math.Pow(b.Y-a.Y, 2))\n}", "title": "" }, { "docid": "a83b46d4f773018782c8c1d14de8bf6e", "score": "0.41755632", "text": "func (p Point) DistanceTo(other Point) uint32 {\n\treturn abs(int32(p.X)-int32(other.X)) + abs(int32(p.Y)-int32(other.Y))\n}", "title": "" }, { "docid": "ebd9eae2573111ded9078529f208b88b", "score": "0.4165602", "text": "func (v *Vector) Len() float64 {\n\treturn math.Hypot(v.X, v.Y)\n}", "title": "" }, { "docid": "e9f62ff26b0a595bdac513fe81e1b365", "score": "0.41502297", "text": "func (v Vector[T]) Perpendicular() Vector[T] {\n\treturn Vector[T]{\n\t\tx: v.y,\n\t\ty: -v.x,\n\t}\n}", "title": "" }, { "docid": "367a934842bbf9bdb026ae782e688b8a", "score": "0.41424203", "text": "func (p *Point) DistanceOf2(q *Point) distance.Distance {\r\n\treturn distance.Distance(p.Angle(q)) * distance.EarthRadius\r\n}", "title": "" }, { "docid": "3770427e6c8228b70d743137ec8b10ab", "score": "0.41239208", "text": "func Cylinder(p vec.V3, r, height float64) float64 {\n\td := vec.V2{p[0], p[2]}.Length() - r\n\treturn math.Max(d, math.Abs(p[1])-height)\n}", "title": "" }, { "docid": "4fe37175fca55b02aa30e83d4eba4b6c", "score": "0.40731552", "text": "func (p *Point) DistanceOf(q *Point) distance.Distance {\r\n\t// convert degree -> rad\r\n\tplat := p.Lat * math.Pi / 180.0\r\n\tplon := p.Lon * math.Pi / 180.0\r\n\r\n\tqlat := q.Lat * math.Pi / 180.0\r\n\tqlon := q.Lon * math.Pi / 180.0\r\n\r\n\ta := math.Cos(qlat) * math.Sin(plon-qlon)\r\n\tb := math.Cos(plat)*math.Sin(qlat) - math.Sin(plat)*math.Cos(qlat)*math.Cos(plon-qlon)\r\n\tc := math.Sin(plat)*math.Sin(qlat) + math.Cos(plat)*math.Cos(qlat)*math.Cos(plon-qlon)\r\n\r\n\tdist := math.Atan2(math.Sqrt(a*a+b*b), c)\r\n\tif dist < 0.0 {\r\n\t\tdist += 2 * math.Pi\r\n\t}\r\n\treturn distance.Distance(dist) * distance.EarthRadius\r\n}", "title": "" }, { "docid": "1c2465bbf65ba04e433c16d7cd77ec82", "score": "0.40556937", "text": "func (p Point) DistanceTo(p2 *Point) *Point {\n\treturn &Point{p2.X - p.X, p2.Y - p.Y}\n}", "title": "" }, { "docid": "2ed2aa93b361316d27a0e9137477f5e3", "score": "0.40516007", "text": "func calculatDistanceToOrigin(x float64, y float64) float64 {\n\treturn math.Sqrt(x*x + y*y)\n}", "title": "" }, { "docid": "b3c94f3c37929d2a9ac59b708811c64a", "score": "0.40371957", "text": "func (t Triangle) Perimeter() float64 {\n\treturn t.A + t.B + t.C\n}", "title": "" }, { "docid": "3a630a38cfb2ac7fc34390c2382d6bbc", "score": "0.40283558", "text": "func Distance(one, two EuclidCoords) float64 {\n\treturn math.Sqrt((one.X-two.X)*(one.X-two.X) + (one.Y-two.Y)*(one.Y-two.Y))\n}", "title": "" }, { "docid": "7f80eaa5354eb47488b977f62e61b8af", "score": "0.40273094", "text": "func main() {\n\tfmt.Println(hypot(3, 4))\n\n\txs := []int{1, 2, 3}\n\tf(xs)\n\tfmt.Println(xs) // [5 2 3]\n}", "title": "" }, { "docid": "6c18dd916f012551f4aeabb4bb94a7b8", "score": "0.40193182", "text": "func Distance(a, b Point) float64 {\n\tsx, sy := side(a, b)\n\treturn math.Sqrt(math.Pow(sx, 2) + math.Pow(sy, 2))\n}", "title": "" }, { "docid": "81afe0b9898b8f3c6d14166d51f8b32d", "score": "0.40174326", "text": "func Distance(a, b Point) float64 {\n\treturn math.Sqrt((b.X-a.X)*(b.X-a.X) + (b.Y-a.Y)*(b.Y-a.Y))\n}", "title": "" }, { "docid": "42eb828dcd93bb369c4a37bd29f9d017", "score": "0.40064734", "text": "func (p Point) Distance() float64 {\n\treturn math.Abs(float64(p.X)) + math.Abs(float64(p.Y))\n}", "title": "" }, { "docid": "a7d9cc276ba44d5a72aef0e96b7c8b1c", "score": "0.39945617", "text": "func (t Triangle) HeronArea() float64 {\n\treturn t.hero1()\n}", "title": "" }, { "docid": "0c93330fe9ae41ff848bf4c7a5754956", "score": "0.3986436", "text": "func (o *Object) GetDistance(y, x, z int) float64 {\n\tt := o.GetTile()\n\treturn math.Sqrt(math.Pow(float64(y-t.Y), 2) + math.Pow(float64(x-t.X), 2) + math.Pow(float64(z-t.Z), 2))\n}", "title": "" }, { "docid": "737da6f85918dd02f3ee997b43c91948", "score": "0.3983531", "text": "func Triangle(w io.Writer, width, height float64) {\n\tfmt.Fprintf(w, svgprefix, width, height, width, height)\n\tnr := 3 + int(math.Ceil(height/tHeight)) // Number of rows of points\n\tnpo := 3 + int(math.Ceil(width/base)) // Number of points in an odd row\n\tnpe := 2 + int(math.Ceil(width/base)) // Number of points in an even row\n\n\t// Allocates even and odd rows only once per function call! Could use a sync.Pool\n\to := make(row, npo)\n\to.reset(xo, ystart)\n\te := make(row, npe)\n\n\t// Construct the triangles\n\tfor y, i := 0.0, 1; i < nr; y, i = y+tHeight, i+1 {\n\t\tif 0 == i%2 {\n\t\t\t// Odd row\n\t\t\to.reset(xo, y)\n\t\t\tfor j := 0; j < npe; j++ {\n\t\t\t\t// Pointing up\n\t\t\t\topacity := minopacity + (maxopacity-minopacity)*random.Float64()\n\t\t\t\tfmt.Fprintf(w, svgTriangleOpacity, e[j], o[j], o[j+1], opacity)\n\t\t\t}\n\t\t\tfor j := 0; j < npe-1; j++ {\n\t\t\t\t// Pointing down\n\t\t\t\tfmt.Fprintf(w, svgTriangleOpacity, e[j], e[j+1], o[j+1], clropacity*random.Float64())\n\t\t\t}\n\t\t} else {\n\t\t\t// Even row\n\t\t\te.reset(xe, y)\n\t\t\tfor j := 0; j < npe; j++ {\n\t\t\t\t// Pointing down\n\t\t\t\tfmt.Fprintf(w, svgTriangleOpacity, o[j], o[j+1], e[j], clropacity*random.Float64())\n\t\t\t}\n\t\t\tfor j := 0; j < npe-1; j++ {\n\t\t\t\t// Pointing up\n\t\t\t\topacity := minopacity + (maxopacity-minopacity)*random.Float64()\n\t\t\t\tfmt.Fprintf(w, svgTriangleOpacity, o[j+1], e[j], e[j+1], opacity)\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Fprint(w, svgsuffix)\n}", "title": "" }, { "docid": "4b5752b18db6bb9c647772083e379e3b", "score": "0.39822054", "text": "func (a Vec2) Length() float32 {\n\treturn math.Sqrt(a.X*a.X + a.Y*a.Y)\n}", "title": "" }, { "docid": "35e575b33a51d53e1365ede9d98dc844", "score": "0.39735532", "text": "func NewNormTriangle(x0, y0, x1, y1, x2, y2 float64) NormTriangle {\n\treturn NormTriangle{[3]NormPoint{{x0, y0}, {x1, y1}, {x2, y2}}}\n}", "title": "" }, { "docid": "0c210a49fd9268754c99a4e8dc6ba1e8", "score": "0.3961466", "text": "func (a Quat) LengthSq() float64 {\n\treturn a.W*a.W + a.X*a.X + a.Y*a.Y + a.Z*a.Z\n}", "title": "" }, { "docid": "f16f8fda72f471966a72959126efe323", "score": "0.39473045", "text": "func distance(a, b Node) float64 {\n\t//hard way, see if the math package has a way of doing this without me\n\t//implementing it. dist = sqrt((b.x - a.x)^2 + (b.y - a.y^2))\n\tdist := math.Hypot(b.X-a.X, b.Y-a.Y)\n\treturn dist\n}", "title": "" }, { "docid": "7d7eb18ffb2b153137e051758dcb7e04", "score": "0.3945594", "text": "func (w *WPT) Distance(lat, lon float64) float64 {\n\tlat1 := lat * math.Pi / 180\n\tlon1 := lon * math.Pi / 180\n\tlat2 := w.Latitude * math.Pi / 180\n\tlon2 := w.Longitude * math.Pi / 180\n\treturn 6378.388 * math.Acos(math.Sin(lat1)*math.Sin(lat2)+math.Cos(lat1)*math.Cos(lat2)*math.Cos(lon2-lon1)) * 1000\n}", "title": "" }, { "docid": "50d81db358b82b5eb501f8e2ba9003ec", "score": "0.39373198", "text": "func (o *Quote) GetH() float32 {\n\tif o == nil || o.H == nil {\n\t\tvar ret float32\n\t\treturn ret\n\t}\n\treturn *o.H\n}", "title": "" }, { "docid": "faddd78c6478e8514066eabcc31124c5", "score": "0.3936785", "text": "func (ln *Line) Length() float64 {\n\treturn math.Sqrt(math.Pow(math.Abs(ln.x0-ln.x1), 2) + math.Pow(math.Abs(ln.y0-ln.y1), 2))\n}", "title": "" }, { "docid": "6a448348d12656381adcef66fb677e48", "score": "0.39361298", "text": "func (p *Password) HOTP() string {\n\tif p.Digits > 10 {\n\t\tp.Digits = 10\n\t}\n\tif p.Digits < 1 {\n\t\tp.Digits = 1\n\t}\n\t//due to nature of Go func hmac.New does not take a counter arg\n\t//like for example Pythons hmac.new does\n\t//that is the reason for using binary.Write\n\thmac := hmac.New(p.Hash, []byte(p.Secret))\n\n\t//counter is passed as an uint64 for correct calculations\n\t//uint32 gives different results\n\tbinary.Write(hmac, binary.BigEndian, uint64(p.Counter))\n\n\tsha := hmac.Sum(nil)\n\n\toffset := sha[19] & 0xf\n\n\tbinCode := ((uint64(sha[offset]))<<24 | (uint64(sha[offset+1]))<<16 |\n\t\t(uint64(sha[offset+2]))<<8 | (uint64(sha[offset+3]))) & 0x7fffffff\n\n\thotp := binCode % uint64(math.Pow10(p.Digits))\n\n\thotpAsString := strconv.Itoa(int(hotp))\n\n\t//filling up with zeros if password is not long enough\n\tfor len(hotpAsString) < int(p.Digits) {\n\t\thotpAsString = \"0\" + hotpAsString\n\t}\n\n\treturn hotpAsString\n}", "title": "" }, { "docid": "d6ba07a58deb8aafbf3655ed2a310d47", "score": "0.3915779", "text": "func dist(p, q geom.Point) float64 {\n\tsum := 0.0\n\tdx := p.X - q.X\n\tsum += dx * dx\n\tdx = p.Y - q.Y\n\tsum += dx * dx\n\treturn math.Sqrt(sum)\n}", "title": "" }, { "docid": "ae35291d80fd7143283def981bb5e406", "score": "0.391371", "text": "func (c Coordinates)Distance(c2 Coordinates) float64 {\n\t// This is function calculates the basic Euclidean distance between two coordinates.\n\t// The Haversine formula will need to be used for coordinates that are longer a part\n\t// (https://en.wikipedia.org/wiki/Haversine_formula), but for our use case we don't need it.\n\treturn math.Sqrt(math.Pow(c2.Lat - c.Lat, 2) + math.Pow(c2.Lng - c.Lng, 2))\n}", "title": "" }, { "docid": "5988d0811c7ee2e8755cf361ded3606f", "score": "0.39135346", "text": "func (p *Point) Distance(p2 Point) float64 {\n\treturn geo.NewPoint(p.Lat, p.Lon).GreatCircleDistance(geo.NewPoint(p2.Lat, p2.Lon))\n}", "title": "" }, { "docid": "70e1bc543ecca5067973545c39af6c43", "score": "0.39126003", "text": "func Honor(P, Q Polynomial) (Polynomial, float64) {\n\tif len(Q.Coeff) != 2 {\n\t\tlog.Fatal(\"Just put linear polynomial\")\n\t}\n\tnom := -Q.Coeff[0] / Q.Coeff[1]\n\tvar R Polynomial\n\tvar r float64\n\tR.Coeff = make([]float64, len(P.Coeff)-1, len(P.Coeff)-1)\n\n\tfor i := range P.Coeff {\n\t\tswitch {\n\t\tcase i == 0:\n\t\t\tR.Coeff[i] = P.Coeff[i]\n\t\tcase i == len(P.Coeff)-1:\n\t\t\ttemp := nom*R.Coeff[i-1] + P.Coeff[i]\n\t\t\tr = temp\n\t\tdefault:\n\t\t\ttemp := nom*R.Coeff[i-1] + P.Coeff[i]\n\t\t\tR.Coeff[i] = temp\n\t\t}\n\t}\n\treturn R, r\n}", "title": "" }, { "docid": "9a8a396014ccea802b58848e05820a0b", "score": "0.3909468", "text": "func (p Point) DirectionTo(p2 *Point) *Point {\n\tif Equal(&p, p2) {\n\t\treturn &p\n\t}\n\tdx := p2.X - p.X\n\tdy := p2.Y - p.Y\n\tif math.Abs(float64(dy)) > math.Abs(float64(dx)) {\n\t\tif dy < 0 {\n\t\t\treturn p.Up()\n\t\t}\n\t\treturn p.Down()\n\t}\n\tif dx < 0 {\n\t\treturn p.Left()\n\t}\n\treturn p.Right()\n}", "title": "" }, { "docid": "ed5e3002b186718b118330814044488d", "score": "0.390141", "text": "func (m MagneticField) H() (h float64) {\n\tx, y, _, _, _, _ := m.Ellipsoidal()\n\treturn math.Sqrt(x*x + y*y)\n}", "title": "" }, { "docid": "9dfcae044c0d54ddefecf4b8e2d9dca0", "score": "0.38902545", "text": "func (p Point) EuclideanDistance(q Point) float64 {\n\treturn math.Hypot(q.X-p.X, q.Y-p.Y)\n}", "title": "" }, { "docid": "7ba0412366660d16d3e88c0f7c5a869f", "score": "0.38883814", "text": "func HBy(dx svg.Number) Cmd {\n\treturn Cmd(\"h \" + internal.Stringify(dx, \" \"))\n\n}", "title": "" }, { "docid": "4f02c8016538b1607da148bf8ea1181e", "score": "0.38726887", "text": "func (p Path) HorTo(x float32) Path {\n\treturn Path{p.pattern + fmt.Sprintf(\" H %f\", x)}\n}", "title": "" }, { "docid": "ac62d44dd71d7b010ca70caf5d09b17b", "score": "0.38710555", "text": "func (z *Float64) QuoL(x, y *Float64) *Float64 {\n\tif zero := new(Float64); y.Equals(zero) {\n\t\tpanic(zeroDenominator)\n\t}\n\treturn z.Mul(z.Inv(y), x)\n}", "title": "" }, { "docid": "191d212920a1e04e54dc157390139b02", "score": "0.38693506", "text": "func HashToPoint(hash []byte) (x, y *big.Int) {\n\n\tif len(hash) != PointHashLen {\n\t\tpanic(\"invalid hash length\")\n\t}\n\n\tt := new(big.Int).SetBytes(hash)\n\n\t//alpha = -t^2\n\ttt := gf.Square(t)\n\talpha := gf.Neg(tt)\n\tasq := gf.Square(alpha)\n\tasqa := gf.Add(asq, alpha)\n\tasqa1 := gf.Add(one, gf.Inv(asqa))\n\n\t// x2 = -(b / a) * (1 + 1/(alpha^2+alpha))\n\tx2 := gf.Mul(mba, asqa1)\n\n\t//x3 = alpha * x2\n\tx3 := gf.Mul(alpha, x2)\n\tax2 := gf.Mul(a, x2)\n\tx23 := gf.Cube(x2)\n\tx23ax2 := gf.Add(x23, ax2)\n\n\t// h2 = x2^3 + a*x2 + b\n\th2 := gf.Add(x23ax2, b)\n\n\tax3 := gf.Mul(a, x3)\n\tx33 := gf.Cube(x3)\n\tx33ax3 := gf.Add(x33, ax3)\n\n\t// h3 = x3^3 + a*x3 + b\n\th3 := gf.Add(x33ax3, b)\n\n\t// tmp = h2 ^ ((p - 3) // 4)\n\ttmp := gf.Pow(h2, p34)\n\ttmp2 := gf.Square(tmp)\n\ttmp2h2 := gf.Mul(tmp2, h2)\n\n\t//if tmp^2 * h2 == 1:\n\tif tmp2h2.Cmp(one) == 0 {\n\t\t// return (x2, tmp * h2 )\n\t\treturn x2, gf.Mul(tmp, h2)\n\t}\n\n\t//return (x3, h3 ^ ((p+1)//4))\n\treturn x3, gf.Pow(h3, p14)\n}", "title": "" }, { "docid": "d8c895d543512846f834c28808418ea7", "score": "0.38684082", "text": "func (p Pos) Dist(q Pos) float32 {\n\tvar (\n\t\tx = p.X - q.X\n\t\ty = p.Y - q.Y\n\t\tz = p.Z - q.Z\n\t)\n\treturn float32(math.Sqrt(float64(x*x + y*y + z*z)))\n}", "title": "" }, { "docid": "a4e431e185315420d769a9edbd621455", "score": "0.38654923", "text": "func (p Point) Right() Point {\n\treturn Point{-p.y, p.x}\n}", "title": "" }, { "docid": "8c7d0405f3ccaaf544508997982d21cf", "score": "0.38562334", "text": "func GetShortestDistance(l *Line, p *point.Point) float64 {\n\tx1, y1, x2, y2 := l.X1, l.Y1, l.X2, l.Y2\n\n\tl2 := ((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))\n\n\tif l2 < phomath.Epsilon {\n\t\treturn l2\n\t}\n\n\tvar s = (((y1 - p.Y) * (x2 - x1)) - ((x1 - p.X) * (y2 - y1))) / l2\n\n\treturn math.Abs(s) * math.Sqrt(l2)\n}", "title": "" }, { "docid": "47281c95fa342093df4321404c73b624", "score": "0.3836413", "text": "func (p *Point) Magnitude() float64 {\n\treturn math.Sqrt(p.X*p.X + p.Y*p.Y + p.Z*p.Z)\n}", "title": "" }, { "docid": "00bd6d3cfc74f25eb69cf68c4340986f", "score": "0.38235596", "text": "func Distance(p1 Point, p2 Point) float64 {\n\tdx := p1.X - p2.X\n\tdy := p1.Y - p2.Y\n\tdz := p1.Z - p2.Z\n\treturn math.Sqrt(dx*dx + dy*dy + dz*dz)\n}", "title": "" }, { "docid": "f9bb18deba25749b3f7fcb63150578f5", "score": "0.38234338", "text": "func NewTriangle(pt1, pt2, pt3 Pt) (tri Triangle) {\n\tif pt1 == pt2 || pt1 == pt3 || pt2 == pt3 {\n\t\tpanic(fmt.Sprintf(\"All three points of a triangle must be different. < %v , %v , %v >\", pt1, pt2, pt3))\n\t}\n\ttri = Triangle{pt1, pt2, pt3}\n\tsort.Sort(&tri)\n\treturn tri\n}", "title": "" }, { "docid": "be3af6754735c9c5b3e1a84ce93e72ec", "score": "0.38181666", "text": "func (p Path) Hor(dx float32) Path {\n\treturn Path{p.pattern + fmt.Sprintf(\" h %f\", dx)}\n}", "title": "" }, { "docid": "89bfe484504142024423be769a9b218e", "score": "0.38138098", "text": "func (a Vec2) HomogenizedAsDirection() Vec3 {\n\treturn Vec3{a.X, a.Y, 0.0}\n}", "title": "" }, { "docid": "776d368ab995c57f03f62f0dfdc65050", "score": "0.38091356", "text": "func (self *LineString) len(i, j int) float64 {\n\tvar dist float64\n\tif j < i {\n\t\ti, j = j, i\n\t}\n\tfor ; i < j; i++ {\n\t\tdist += self.Coordinates.Pt(i).Magnitude(\n\t\t\tself.Coordinates.Pt(i + 1),\n\t\t)\n\t}\n\treturn dist\n}", "title": "" }, { "docid": "05d687efbfd2e17986aae689d3cf6042", "score": "0.37778214", "text": "func (d Distance) Thou() float64 {\n\treturn float64(d / Thou)\n}", "title": "" }, { "docid": "0dce92e7099e2f60a0a159b92a3834f5", "score": "0.3777359", "text": "func TriangleArea(a, b, c float64) {\n\tp := (a + b + c) / 2\n\tarea := math.Sqrt(p * (p - a) * (p - b) * (p - c))\n\n\tfmt.Println(fmt.Sprintf(\"Triangle area is: %f\", area))\n}", "title": "" }, { "docid": "aba1b18bff86da6f192b3ec47ddec5b7", "score": "0.37695834", "text": "func (c *Cell) TaxiDistance(goal Cell, rank int) float64 {\n goalX, goalY := goal.XY(rank)\n posX, posY := c.XY(rank)\n dX := math.Abs(float64(posX - goalX))\n dY := math.Abs(float64(posY - goalY))\n // D := 1 // D is an edge weighting\n // return D * (dX + dY)\n return dX + dY\n}", "title": "" }, { "docid": "19e09206d0a5ed4a5e3ca3eec06b0e92", "score": "0.37612265", "text": "func triangleArea(p1 mgl32.Vec3, p2 mgl32.Vec3, p3 mgl32.Vec3) float32 {\n\treturn float32(math.Abs(float64((p1.X()*(p2.Z()-p3.Z()) + p2.X()*(p3.Z()-p1.Z()) + p3.X()*(p1.Z()-p2.Z())) / 2.0)))\n}", "title": "" }, { "docid": "1d6bbe6ad51ac7bab0a65fce4d1e4813", "score": "0.37471223", "text": "func (t Triangle) Area() float64 {\n\ts := (t.Perimeter() / 2)\n\treturn math.Sqrt(s * (s - t.A) * (s - t.B) * (s - t.C))\n}", "title": "" }, { "docid": "ad275e6b82087a368d5111bc7892f38f", "score": "0.37419158", "text": "func main() {\n\tx, y := 1, 4\n\tdist := hammingDistance(x, y)\n\tfmt.Println(x, y, dist)\n}", "title": "" }, { "docid": "e593f5726a1d7aa57c7fcfc7cb3c22e0", "score": "0.37402195", "text": "func ChordAngleBetweenPoints(x, y Point) s1.ChordAngle {\n\treturn s1.ChordAngle(math.Min(4.0, x.Sub(y.Vector).Norm2()))\n}", "title": "" }, { "docid": "ac3801b21721e0fe70b02dc130e6fe0b", "score": "0.37212613", "text": "func (sp *SeqPair) GetDiagonalLength(d Diagonal) int {\n if d < 0 {\n return util.MinInt(len(sp.S2), len(sp.S1) + int(d))\n } else {\n return util.MinInt(len(sp.S1), len(sp.S2) - int(d))\n }\n}", "title": "" }, { "docid": "9d3ab80d7a7e79ba6f338b173e55e3dc", "score": "0.37193435", "text": "func (v *Vector) TriangleArea(vector Vector) float64 {\n\tproduct := v.CrossProduct(vector)\n\treturn product.Magnitude() / 2\n}", "title": "" }, { "docid": "e8422d35626e0279ff7039a19ac4bd13", "score": "0.37173736", "text": "func (p point) Distance(ov point) float64 { return p.Sub(ov).Norm() }", "title": "" }, { "docid": "c387a35f9bdb114a9d0a601fcc6131f8", "score": "0.3708588", "text": "func (p Point) Dist(q Point) float64 {\n\tsum := 0.0\n\tfor i := range p {\n\t\tdx := p[i] - q[i]\n\t\tsum += dx * dx\n\t}\n\treturn math.Sqrt(sum)\n}", "title": "" }, { "docid": "d2c082dea00c426d5816f53d8690d036", "score": "0.3700563", "text": "func (m *GlyphMetrics) HoriBearingY() int64 {\n\treturn int64(m.handle.horiBearingY)\n}", "title": "" }, { "docid": "b8dc6c82bd3516ed11f158bbfae88583", "score": "0.3698906", "text": "func ExampleLinearEquationType_DistanceToPoint() {\n\tle := util.Linear(1, 1, 3, 2)\n\tfor j := -1; j < 5; j++ {\n\t\tfmt.Printf(\"%.3f\\n\", le.DistanceToPoint(float64(j), 2))\n\t}\n\t// Output:\n\t// 1.789\n\t// 1.342\n\t// 0.894\n\t// 0.447\n\t// 0.000\n\t// 0.447\n}", "title": "" }, { "docid": "5ea3f6c4fe4a32da40321fdc085c203d", "score": "0.36935312", "text": "func Angle2length(angle VectorA, Lon float64) (length VectorL) {\n\tlength = VectorL{\n\t\tU: math.Pi * angle.Lon * LocalRayLongitude(Lon) / 180,\n\t\tV: math.Pi * angle.Lat * LocalRayLatitude(Lon) / 180,\n\t\tAltitude: angle.Altitude,\n\t}\n\treturn\n}", "title": "" }, { "docid": "33361ad5e188f76b7920d2fbf615ccf5", "score": "0.36885914", "text": "func (SignedDistance) EquilateralTriangleFunc(s float64) SignedDistanceFunc {\n\treturn func(sd SignedDistance) float64 {\n\t\treturn sd.EquilateralTriangle(s)\n\t}\n}", "title": "" }, { "docid": "20bd15c388cbb7929bf9828a320f4d21", "score": "0.36832988", "text": "func (p *Point2D) DistanceTo(q Point2DReader) (float64, error) {\n\tqx, qy := q.GetX(), q.GetY()\n\tpx, py := p.GetX(), p.GetY()\n\n\tnewX := qx - px\n\tnewY := qy - py\n\tif numeric.AreAnyOverflow(newX, newY) {\n\t\treturn 0, numeric.ErrOverflow\n\t}\n\n\tlen := numeric.Nrm2(newX, newY)\n\tif numeric.IsOverflow(len) {\n\t\treturn 0, numeric.ErrOverflow\n\t}\n\treturn len, nil\n}", "title": "" }, { "docid": "c07f782c6aa76e6af95a956a99c227aa", "score": "0.36813238", "text": "func (dp Point) Magnitude2D() float64 {\n\treturn math.Sqrt((dp[0] * dp[0]) + (dp[1] * dp[1]))\n}", "title": "" }, { "docid": "0c4b320bbcfaf11fec3e0bcc9933d1c4", "score": "0.36811066", "text": "func (v *Vec2D) Magnitude() float64 {\n\treturn math.Sqrt(math.Pow(v.X, 2) + math.Pow(v.Y, 2))\n}", "title": "" }, { "docid": "2afd3f3314149b09813d3be08e8498e4", "score": "0.3677953", "text": "func (a Vec3) HomogenizedAsDirection() Vec4 {\n\treturn Vec4{a.X, a.Y, a.Z, 0.0}\n}", "title": "" }, { "docid": "91c7a41990ad798ba907bcae3093e8c0", "score": "0.367669", "text": "func (m *GlyphMetrics) VertBearingY() int64 {\n\treturn int64(m.handle.vertBearingY)\n}", "title": "" }, { "docid": "8fd418a291a61e60210a609e07f1aea9", "score": "0.36735013", "text": "func calculateDistance(point0 Point, point1 Point) (distance float64) {\n\tx0 := point0.x\n\tx1 := point1.x\n\ty0 := point0.y\n\ty1 := point1.y\n\treturn math.Sqrt(math.Pow((x1-x0), 2) + math.Pow((y1-y0), 2))\n}", "title": "" }, { "docid": "c0beb76f9dee5bba3e75cf53076cb04f", "score": "0.36699936", "text": "func (node *stageNode) inletTriangle() states.VelocityTriangle {\n\treturn node.VelocityInput().GetState().Value().(states.VelocityTriangle)\n}", "title": "" }, { "docid": "386b4410eddbce22c139815036bac7f5", "score": "0.36693412", "text": "func Chi2Dist(x []float32, y []float32) float32 {\n\tvar result float32\n\tfor i := range x {\n\t\tresult += (x[i] - y[i]) * (x[i] - y[i]) / (x[i] + y[i])\n\t}\n\n\treturn result / 2\n}", "title": "" }, { "docid": "6157390462dfc8d23ab18dd26c6108fd", "score": "0.36656", "text": "func main() {\n\tfmt.Println(\"The program prints the perimeter and the square of a rectangle given the rectangle sides.\")\n\tfmt.Println(\"enter wight and lenght\")\n\tvar w, l float64\n\tfmt.Scanln(&w, &l)\n\tp := (w + l) * 2\n\ts := w * l\n\tfmt.Println(\"S=\", s)\n\tfmt.Println(\"P=\", p)\n}", "title": "" }, { "docid": "4ac526d532d925c8aca9add51b7365e1", "score": "0.3663487", "text": "func (g *LineString) Length() float64 {\n\treturn length1(g.flatCoords, 0, len(g.flatCoords), g.stride)\n}", "title": "" }, { "docid": "1c9601c2b37b8acfb09d10f1587af518", "score": "0.3662671", "text": "func (p1 Position) Direction(p2 Position) Direction {\n\td := float64(p2.Down.Subtract(p1.Down))\n\tl := float64(p2.Left.Subtract(p1.Left))\n\treturn Direction(math.Atan2(l, d) / (2 * math.Pi))\n}", "title": "" }, { "docid": "8d1a40a83916b31424bc747bd4ea6b0a", "score": "0.3660972", "text": "func (l *Line2) DistPt(p *Point2) float64 {\n\tv := Vector2{l.U[1], -l.U[0]} // vector perpendicular to line\n\tr := l.P.To(p) // vector from point on line to p\n\treturn math.Abs(v.Dot(r)) / v.Len() // project r onto v\n}", "title": "" }, { "docid": "f6c012da206b8f2db8373fb93afc3a9a", "score": "0.36556268", "text": "func (q *Quat) LengthSquared() float64 {\n\treturn godotRealAsReal(C.godot_quat_length_squared(q.quat))\n}", "title": "" } ]
a0a224875d4b61c59e60daf0e45ad307
KeyboardHandle Handles all movement
[ { "docid": "0177b9e389688ba9c5907e82a30427de", "score": "0.70581347", "text": "func KeyboardHandle(world *World, state []uint8) {\n\tCameraTranslate(world, state)\n\n\tObjectRotate(world, state, \"cube\")\n}", "title": "" } ]
[ { "docid": "593f14d1402c0928be5ae2500d1c0556", "score": "0.6760007", "text": "func HandleKeyboardEvents(t *sdl.KeyboardEvent) {\n\n\tvar step int32 = 10\n\n\tswitch t.Keysym.Sym {\n\t// Players One\n\tcase sdl.K_a:\n\t\tif t.State == sdl.RELEASED {\n\t\t\tPlayers[PlayersOneUUID].X -= step\n\t\t}\n\tcase sdl.K_s:\n\t\tif t.State == sdl.RELEASED {\n\t\t\tPlayers[PlayersOneUUID].Y += step\n\t\t}\n\tcase sdl.K_d:\n\t\tif t.State == sdl.RELEASED {\n\t\t\tPlayers[PlayersOneUUID].X += step\n\t\t}\n\tcase sdl.K_w:\n\t\tif t.State == sdl.RELEASED {\n\t\t\tPlayers[PlayersOneUUID].Y -= step\n\t\t}\n\n\t//Player TWO\n\tcase sdl.K_LEFT:\n\t\tif t.State == sdl.RELEASED {\n\t\t\tPlayers[PlayersTwoUUID].X -= step\n\t\t}\n\tcase sdl.K_DOWN:\n\t\tif t.State == sdl.RELEASED {\n\t\t\tPlayers[PlayersTwoUUID].Y += step\n\t\t}\n\tcase sdl.K_RIGHT:\n\t\tif t.State == sdl.RELEASED {\n\t\t\tPlayers[PlayersTwoUUID].X += step\n\t\t}\n\tcase sdl.K_UP:\n\t\tif t.State == sdl.RELEASED {\n\t\t\tPlayers[PlayersTwoUUID].Y -= step\n\t\t}\n\t}\n}", "title": "" }, { "docid": "41cf65e6537d714d311694ed033c0bf1", "score": "0.6613516", "text": "func (config *Dimensions) handleKeyboardMapping(data [][]string) {\n\tfor {\n\t\tswitch ev := termbox.PollEvent(); ev.Type {\n\t\tcase termbox.EventKey:\n\t\t\tconfig.handlePlayerMovement(ev.Key, data)\n\n\t\tcase termbox.EventError:\n\t\t\tpanic(ev.Err)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "bd3ab3215670a07f6f2f68f8b6fe5678", "score": "0.64222234", "text": "func handleKeyEvent() {\n\tfor {\n\t\tswitch ev := termbox.PollEvent(); ev.Type {\n\t\tcase termbox.EventKey:\n\t\t\tif ev.Key == termbox.KeyEsc {\n\t\t\t\texit()\n\t\t\t}\n\t\t\tswitch ev.Ch {\n\t\t\tcase 'q':\n\t\t\t\texit()\n\t\t\tcase 'p':\n\t\t\t\tif currentState.IsRunning() {\n\t\t\t\t\tcurrentState.Pause()\n\t\t\t\t} else {\n\t\t\t\t\tcurrentState.Resume()\n\t\t\t\t}\n\t\t\t\tcurrentPainter.Draw()\n\t\t\tcase 'y':\n\t\t\t\tif currentState.IsWaiting() {\n\t\t\t\t\tcurrentState.Resume()\n\t\t\t\t}\n\t\t\tcase 'Y':\n\t\t\t\tif currentState.IsWaiting() {\n\t\t\t\t\tcurrentState.Resume()\n\t\t\t\t}\n\t\t\tcase 'n':\n\t\t\t\tif currentState.IsWaiting() {\n\t\t\t\t\texit()\n\t\t\t\t} else {\n\t\t\t\t\tcurrentState.Next()\n\t\t\t\t}\n\t\t\tcase 'r':\n\t\t\t\tif currentState.IsRunning() || currentState.IsPaused() {\n\t\t\t\t\tcurrentState.Reset()\n\t\t\t\t}\n\t\t\tcase 'c':\n\t\t\t\tcurrentTimer.AutoContinue = !currentTimer.AutoContinue\n\t\t\tdefault:\n\t\t\t\tif currentState.IsWaiting() {\n\t\t\t\t\texit()\n\t\t\t\t}\n\t\t\t}\n\t\tcase termbox.EventResize:\n\t\t\tcurrentPainter.Draw()\n\t\tcase termbox.EventError:\n\t\t\tpanic(ev.Err)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "fe20fe626fa919b5b8eb527c8ac51a5c", "score": "0.6383041", "text": "func (config *Dimensions) handlePlayerMovement(event termbox.Key, data [][]string) {\n\tswitch event {\n\tcase termbox.KeyEsc, termbox.KeyCtrlC:\n\t\tstatus <- quit\n\n\tcase termbox.KeyCtrlP:\n\t\tstatus <- proceed\n\n\tcase termbox.KeySpace:\n\t\tstatus <- pause\n\n\tcase termbox.KeyArrowLeft:\n\t\tconfig.playerMovement(data, \"LEFT\")\n\n\tcase termbox.KeyArrowRight:\n\t\tconfig.playerMovement(data, \"RIGHT\")\n\n\tcase termbox.KeyArrowUp:\n\t\tconfig.playerMovement(data, \"UP\")\n\n\tcase termbox.KeyArrowDown:\n\t\tconfig.playerMovement(data, \"DOWN\")\n\t}\n}", "title": "" }, { "docid": "067a3d8f652f335ecc248073fc67a9f1", "score": "0.63472056", "text": "func (m *Model) handleEnterMoveModeKeyPress(cmds *[]tea.Cmd) {\n\tif !m.showCommandInput && m.primaryPane.GetIsActive() && m.dirTree.GetTotalFiles() > 0 {\n\t\tm.moveMode = true\n\n\t\tm.primaryPane.ShowAlternateBorder(true)\n\n\t\tinitialMoveDirectory, err := dirfs.GetWorkingDirectory()\n\t\tif err != nil {\n\t\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t\t}\n\n\t\tselectedFile, err := m.dirTree.GetSelectedFile()\n\t\tif err != nil {\n\t\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t\t}\n\n\t\tm.initialMoveDirectory = initialMoveDirectory\n\t\tm.itemToMove = selectedFile\n\t\tm.updateStatusBarContent(cmds)\n\t}\n}", "title": "" }, { "docid": "a835b7624bcd386d3749c0a6e55505d6", "score": "0.6239542", "text": "func Handle(ev tcell.Event, buffer *edit.Buffer) error {\n\tlogger := log.WithField(\"module\", \"cmd\")\n\n\tswitch ev := ev.(type) {\n\tcase *tcell.EventKey:\n\t\tswitch Keys[ev.Key()] {\n\t\tcase Exit:\n\t\t\t// need to implement closing\n\t\t\treturn errors.Exit()\n\n\t\tcase CursorLeft: // move cursor left\n\t\t\tlogger.Info(\"moving cursor move left\")\n\t\t\t// window.SetCursor(window.CursorCol()-1, window.CursorRow())\n\t\t\tbuffer.CursorMoveBack(1)\n\n\t\tcase CursorRight: // move cursor right\n\t\t\tlogger.Info(\"cursor move right\")\n\t\t\t// window.SetCursor(window.CursorCol()+1, window.CursorRow())\n\t\t\tbuffer.CursorMoveForward(1)\n\n\t\tcase CursorDown: // move cursor down\n\t\t\tlogger.Info(\"cursor move down\")\n\t\t\t// window.SetCursor(window.CursorCol(), window.CursorRow()+1)\n\t\t\tbuffer.CursorMoveDown(1)\n\n\t\tcase CursorUp: // move cursor up\n\t\t\tlogger.Info(\"cursor move up\")\n\t\t\t// window.SetCursor(window.CursorCol(), window.CursorRow()-1)\n\t\t\tbuffer.CursorMoveUp(1)\n\n\t\tcase JumpCursorEnd: // set cursor end of line\n\t\t\tlogger.Info(\"sending cursor to end of line!\")\n\t\t\tbuffer.SetCursorEndOfLine()\n\n\t\tcase Backspace:\n\t\t\tlogger.Info(\"backspace!\")\n\t\t\t// window.DeleteRunes(1)\n\t\t\tbuffer.Delete(1)\n\n\t\tdefault:\n\t\t\t// logger.Infof(\"inserting rune at x: %v y: %v | %v\",\n\t\t\t//\twindow.CursorCol(), window.CursorRow(), string(ev.Rune()))\n\t\t\t// window.PutRune(ev.Rune())\n\t\t\tbuffer.Insert(string(ev.Rune()))\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "32510a222b079cf17ceed1151de2876e", "score": "0.62064147", "text": "func handleKeyPress(keysym sdl.Keysym) {\n\tswitch keysym.Sym {\n\tcase sdl.K_t:\n\t\ttwinkle = !twinkle\n\tcase sdl.K_UP:\n\t\ttilt -= 0.5\n\tcase sdl.K_DOWN:\n\t\ttilt += 0.5\n\tcase sdl.K_PAGEUP:\n\t\tzoom -= 0.2\n\tcase sdl.K_PAGEDOWN:\n\t\tzoom += 0.2\n\tcase sdl.K_ESCAPE:\n\t\tQuit(0)\n\tcase sdl.K_F1:\n\t\tsdl.WM_ToggleFullScreen(surface)\n\t}\n}", "title": "" }, { "docid": "aeb264727c8705ac87c823e0d3c23303", "score": "0.61281514", "text": "func (w *Window) keyHandler(event *tcell.EventKey) *tcell.Key {\n\n\tkey := event.Key()\n\t/*\n\t\tif key >= tcell.KeyF1 && key <= tcell.KeyF12 && !w.navBarFocused{\n\t\t\t//Activate navigation bar on function button\n\t\t\tw.lastFocus = w.app.GetFocus()\n\t\t\tw.lastFocus.Blur()\n\t\t\tw.app.SetFocus(w.navBar)\n\t\t\tw.navBarFocused = true\n\t\t} else if key == tcell.KeyEscape && w.navBarFocused {\n\t\t\t//Deactivate navigation bar and return to last focus\n\t\t\tw.navBarFocused = false\n\t\t\tw.navBar.Blur()\n\t\t\tw.app.SetFocus(w.lastFocus)\n\t\t\tw.lastFocus = nil\n\t\t\treturn nil\n\t\t}\n\t*/\n\n\tif w.mediaCtrl(event) {\n\t\treturn nil\n\t}\n\tif w.navBarCtrl(key) {\n\t\treturn nil\n\t}\n\tif w.moveCtrl(key) {\n\t\treturn nil\n\t}\n\t// Moving around\n\treturn &key\n}", "title": "" }, { "docid": "78625da046be4e7a93f7a8e9de2fd077", "score": "0.6111428", "text": "func HandleKey(ctx *SDLAppContext, t *sdl.KeyboardEvent) {\n\t// fmt.Printf(\"[%d ms] Keyboard\\ttype:%d\\tsym:%c\\tmodifiers:%d\\tstate:%d\\trepeat:%d\\n\",\n\t// \tt.Timestamp, t.Type, t.Keysym.Sym, t.Keysym.Mod, t.State, t.Repeat)\n\n\t// handle CHIP8 keypresses\n\tif chipKey, ok := QWERTYToChip8Key[strings.ToUpper(string(t.Keysym.Sym))]; ok {\n\t\tkeyIdx, _ := strconv.ParseInt(chipKey, 16, 64)\n\t\tif t.Type == sdl.KEYDOWN {\n\t\t\t// ctx.Chip8.Keys[keyIdx] = true\n\t\t\tctx.Chip8.SetKeyState(uint8(keyIdx), true)\n\t\t} else {\n\t\t\t// ctx.Chip8.Keys[keyIdx] = false\n\t\t\tctx.Chip8.SetKeyState(uint8(keyIdx), false)\n\t\t}\n\t} else { // handle pause/step emulation\n\t\tif t.Type == sdl.KEYDOWN {\n\t\t\tif t.Keysym.Sym == sdl.K_k && t.Repeat == 0 {\n\t\t\t\t// pause emulation\n\t\t\t\tctx.Chip8.Paused = !ctx.Chip8.Paused\n\t\t\t} else if t.Keysym.Sym == sdl.K_l {\n\t\t\t\t// step emulation\n\t\t\t\tif ctx.Chip8.Paused {\n\t\t\t\t\tctx.Chip8.StepEmulation()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n}", "title": "" }, { "docid": "c151a16709d3a62b8599e77f19feabec", "score": "0.6042727", "text": "func (m *Model) handleKeypress(msg tea.KeyMsg) {\n\tpreviousRowIndex := m.rowCursorIndex\n\n\tif key.Matches(msg, m.keyMap.RowDown) {\n\t\tm.moveHighlightDown()\n\t}\n\n\tif key.Matches(msg, m.keyMap.RowUp) {\n\t\tm.moveHighlightUp()\n\t}\n\n\tif key.Matches(msg, m.keyMap.RowSelectToggle) {\n\t\tm.toggleSelect()\n\t}\n\n\tif key.Matches(msg, m.keyMap.PageDown) {\n\t\tm.pageDown()\n\t}\n\n\tif key.Matches(msg, m.keyMap.PageUp) {\n\t\tm.pageUp()\n\t}\n\n\tif key.Matches(msg, m.keyMap.PageFirst) {\n\t\tm.pageFirst()\n\t}\n\n\tif key.Matches(msg, m.keyMap.PageLast) {\n\t\tm.pageLast()\n\t}\n\n\tif key.Matches(msg, m.keyMap.Filter) {\n\t\tm.filterTextInput.Focus()\n\t}\n\n\tif key.Matches(msg, m.keyMap.FilterClear) {\n\t\tm.filterTextInput.Reset()\n\t}\n\n\tif key.Matches(msg, m.keyMap.ScrollRight) {\n\t\tm.scrollRight()\n\t}\n\n\tif key.Matches(msg, m.keyMap.ScrollLeft) {\n\t\tm.scrollLeft()\n\t}\n\n\tif m.rowCursorIndex != previousRowIndex {\n\t\tm.appendUserEvent(UserEventHighlightedIndexChanged{\n\t\t\tPreviousRowIndex: previousRowIndex,\n\t\t\tSelectedRowIndex: m.rowCursorIndex,\n\t\t})\n\t}\n}", "title": "" }, { "docid": "34ae2370e422678a45a04488f5b5fc24", "score": "0.6033086", "text": "func (eb *EditBox) HandleKey(key termbox.Key, ch rune, ev chan UIEvent) (eventConsumed bool) {\n\teventConsumed = true\n\n\tswitch key {\n\tcase termbox.KeyEnter:\n\t\t// Send along the input\n\t\tevent := UIEvent{}\n\t\tevent.Type = UIResultString\n\t\tevent.CustomType = eb.CustomType\n\t\tevent.Data = bytes.NewBufferString(string(eb.Value))\n\t\tev <- event\n\n\t\t//Clear the edit buffer\n\t\teb.Value = make([]rune, 0)\n\t\teb.CursorIndex = 0\n\n\tcase termbox.KeyBackspace2:\n\t\tstartLength := len(eb.Value)\n\t\teb.Value = removeCharacter(eb.Value, eb.CursorIndex-1)\n\t\tif startLength > len(eb.Value) {\n\t\t\teb.CursorIndex = setCursor(eb.CursorIndex, eb.CursorIndex-1, len(eb.Value))\n\t\t}\n\tcase termbox.KeyDelete:\n\t\teb.Value = removeCharacter(eb.Value, eb.CursorIndex)\n\tcase termbox.KeyArrowRight:\n\t\teb.CursorIndex = setCursor(eb.CursorIndex, eb.CursorIndex+1, len(eb.Value))\n\tcase termbox.KeyArrowLeft:\n\t\teb.CursorIndex = setCursor(eb.CursorIndex, eb.CursorIndex-1, len(eb.Value))\n\tcase termbox.KeyTab:\n\t\tstartLength := len(eb.Value)\n\t\teb.Value = insertCharacter(eb.Value, ' ', eb.CursorIndex)\n\t\teb.Value = insertCharacter(eb.Value, ' ', eb.CursorIndex)\n\t\teb.Value = insertCharacter(eb.Value, ' ', eb.CursorIndex)\n\t\teb.Value = insertCharacter(eb.Value, ' ', eb.CursorIndex)\n\t\tif startLength < len(eb.Value) {\n\t\t\teb.CursorIndex = setCursor(eb.CursorIndex, eb.CursorIndex+4, len(eb.Value))\n\t\t}\n\tcase termbox.KeySpace:\n\t\tstartLength := len(eb.Value)\n\t\teb.Value = insertCharacter(eb.Value, ' ', eb.CursorIndex)\n\t\tif startLength < len(eb.Value) {\n\t\t\teb.CursorIndex = setCursor(eb.CursorIndex, eb.CursorIndex+1, len(eb.Value))\n\t\t}\n\tdefault:\n\t\tif ch != 0 {\n\t\t\tstartLength := len(eb.Value)\n\t\t\teb.Value = insertCharacter(eb.Value, ch, eb.CursorIndex)\n\t\t\tif startLength < len(eb.Value) {\n\t\t\t\teb.CursorIndex = setCursor(eb.CursorIndex, eb.CursorIndex+1, len(eb.Value))\n\t\t\t}\n\t\t} else {\n\t\t\teventConsumed = false\n\t\t}\n\t}\n\treturn\n}", "title": "" }, { "docid": "5cbd4522a8536ad50ba95d21418575e0", "score": "0.6015184", "text": "func (ui UserInterface) ListenOnKeyStroke() {\n\tvar userInput int\n\tswitch {\n\tcase ui.window.Pressed(pixelgl.KeyLeft):\n\t\tuserInput = gamestate.PlayerMovedLeft\n\tcase ui.window.Pressed(pixelgl.KeyRight):\n\t\tuserInput = gamestate.PlayerMovedRight\n\tcase ui.window.Pressed(pixelgl.KeyDown):\n\t\tuserInput = gamestate.PlayerMovedDown\n\tcase ui.window.Pressed(pixelgl.KeyUp):\n\t\tuserInput = gamestate.PlayerMovedUp\n\tcase ui.window.Pressed(pixelgl.KeySpace):\n\t\tuserInput = gamestate.PlayerShotBullet\n\t}\n\tui.state.ChangeState(userInput)\n\tlogic.ComputeLogic(ui.state, ui.enemySprite.GetObjectSprite())\n}", "title": "" }, { "docid": "19e0f41e6e1c21ed106ac18484708156", "score": "0.5963176", "text": "func (con *Controller) handleKeypresses(done chan bool, display_update_done chan bool, alive_cells_done chan bool) {\n\tvar finished bool\n\tfor !finished {\n\t\tselect {\n\t\tcase <-done:\n\t\t\tfinished = true\n\t\t\tdisplay_update_done <- true\n\t\t\talive_cells_done <- true\n\t\tcase key := <-con.c.keyPresses:\n\t\t\tswitch key {\n\t\t\tcase 's': // Generate PGM file with current state of the board\n\t\t\t\tcon.writeOutWorld()\n\t\t\tcase 'q': // Close controller\n\t\t\t\tfinished = true\n\t\t\t\tdisplay_update_done <- true\n\t\t\t\talive_cells_done <- true\n\t\t\tcase 'p': // Pause logic engine\n\t\t\t\tif !con.paused {\n\t\t\t\t\tvar turn int\n\t\t\t\t\tcon.client.Call(\"Game.Pause\", \"\", &turn)\n\t\t\t\t\tfmt.Println(\"Pausing on turn \", turn)\n\t\t\t\t\tcon.paused = true\n\t\t\t\t} else {\n\t\t\t\t\tcon.client.Go(\"Game.Resume\", \"\", nil, nil)\n\t\t\t\t\tfmt.Println(\"Resuming\")\n\t\t\t\t\tcon.paused = false\n\t\t\t\t}\n\t\t\tcase 'k': // All components of the system are shut down cleanly and output pgm image of latest state\n\t\t\t\tdisplay_update_done <- true\n\t\t\t\talive_cells_done <- true\n\n\t\t\t\tcon.writeOutWorld()\n\t\t\t\t\n\t\t\t\tcon.client.Call(\"Game.Shutdown\", \"\", nil)\n\t\t\t\tos.Exit(0)\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "6e95f8b32d047a0ac7815c3647a03f42", "score": "0.59233147", "text": "func (camera *FPS) OnKeyPress(key, action, mods int) bool {\n\tdir := camera.dir.Mul(camera.speed)\n\tright := camera.Right.Mul(camera.speed)\n\tif key == int(glfw.KeyW) {\n\t\tcamera.Pos = camera.Pos.Add(dir)\n\t} else if key == int(glfw.KeyS) {\n\t\tcamera.Pos = camera.Pos.Sub(dir)\n\t} else if key == int(glfw.KeyA) {\n\t\tcamera.Pos = camera.Pos.Sub(right)\n\t} else if key == int(glfw.KeyD) {\n\t\tcamera.Pos = camera.Pos.Add(right)\n\t}\n\treturn false\n}", "title": "" }, { "docid": "413693f4d3bf0491d5a4ddddb79b3a6c", "score": "0.5857242", "text": "func (display *Display) ProcessInput(joypad *Joypad) {\n\tfor handledKey, button := range keyMap {\n\t\tif display.window.JustPressed(handledKey) {\n\t\t\tjoypad.KeyPress(button)\n\t\t}\n\t\tif display.window.JustReleased(handledKey) {\n\t\t\tjoypad.KeyRelease(button)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "530726e7807d566b0749c5a28083b3d1", "score": "0.5846912", "text": "func (w *InputLine) HandleEvent(ev tcell.Event) bool {\n\tswitch ev := ev.(type) {\n\tcase *tcell.EventKey:\n\t\tswitch ev.Key() {\n\t\tcase tcell.KeyLeft:\n\t\t\tw.SetCursorAt(w.cursor - 1)\n\t\t\treturn true\n\t\tcase tcell.KeyRight:\n\t\t\tw.SetCursorAt(w.cursor + 1)\n\t\t\treturn true\n\t\tcase tcell.KeyDelete:\n\t\t\tcopy(w.value[w.cursor:], w.value[w.cursor+1:])\n\t\t\tw.value = w.value[:len(w.value)-1]\n\t\t\treturn true\n\t\tcase tcell.KeyBackspace, tcell.KeyBackspace2:\n\t\t\tif w.cursor == 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcopy(w.value[w.cursor-1:], w.value[w.cursor:])\n\t\t\tw.value = w.value[:len(w.value)-1]\n\t\t\tw.cursor--\n\t\t\treturn true\n\t\tcase tcell.KeyRune:\n\t\t\trunes := make([]rune, len(w.value)+1)\n\t\t\tcopy(runes, w.value[:w.cursor])\n\t\t\tcopy(runes[w.cursor+1:], w.value[w.cursor:])\n\t\t\trunes[w.cursor] = ev.Rune()\n\t\t\tw.value = runes\n\t\t\tw.cursor++\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "8beaf00305c4a568cd988e2beccc9ef4", "score": "0.58278066", "text": "func handleInput(s tcell.Screen, forceUpdate chan bool) {\n\tfor {\n\t\tev := s.PollEvent()\n\t\t// You like switches? We got em\n\t\tswitch ev := ev.(type) {\n\n\t\tcase *tcell.EventResize:\n\t\t\toptions.Lock()\n\t\t\toptions.terminalSizeX, options.terminalSizeY = s.Size()\n\t\t\toptions.Unlock()\n\t\t\tforceUpdate <- true\n\n\t\tcase *tcell.EventKey:\n\t\t\tswitch ev.Key() {\n\n\t\t\tcase tcell.KeyEscape:\n\t\t\t\ts.Fini()\n\t\t\t\tos.Exit(0)\n\n\t\t\tcase tcell.KeyDown:\n\t\t\t\toptions.Lock()\n\t\t\t\toptions.yOffset++\n\t\t\t\toptions.Unlock()\n\t\t\t\tforceUpdate <- true\n\n\t\t\tcase tcell.KeyRune:\n\t\t\t\tswitch ev.Rune() {\n\n\t\t\t\tcase 'q':\n\t\t\t\t\ts.Fini()\n\t\t\t\t\tos.Exit(0)\n\n\t\t\t\tcase 't', 'T':\n\t\t\t\t\toptions.Lock()\n\t\t\t\t\toptions.TwelveHour = !options.TwelveHour\n\t\t\t\t\toptions.Unlock()\n\t\t\t\t\tforceUpdate <- true\n\t\t\t\tcase 's', 'S':\n\n\t\t\t\t\toptions.Lock()\n\t\t\t\t\toptions.Seconds = !options.Seconds\n\t\t\t\t\toptions.Unlock()\n\t\t\t\t\tforceUpdate <- true\n\t\t\t\tcase 'c', 'C':\n\n\t\t\t\t\toptions.Lock()\n\t\t\t\t\toptions.Center = !options.Center\n\t\t\t\t\toptions.Rebound = false\n\t\t\t\t\toptions.Unlock()\n\t\t\t\t\tforceUpdate <- true\n\n\t\t\t\tcase 'h':\n\t\t\t\t\tmoveClockWithLock(-1, 0)\n\t\t\t\t\tforceUpdate <- true\n\n\t\t\t\tcase 'j':\n\t\t\t\t\tmoveClockWithLock(0, 1)\n\t\t\t\t\tforceUpdate <- true\n\n\t\t\t\tcase 'k':\n\t\t\t\t\tmoveClockWithLock(0, -1)\n\t\t\t\t\tforceUpdate <- true\n\n\t\t\t\tcase 'l':\n\t\t\t\t\tmoveClockWithLock(1, 0)\n\t\t\t\t\tforceUpdate <- true\n\t\t\t\tcase 'r', 'R':\n\t\t\t\t\toptions.Lock()\n\t\t\t\t\toptions.Rebound = !options.Rebound\n\t\t\t\t\toptions.Center = false\n\t\t\t\t\toptions.Unlock()\n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "74ad0024c2c935c22e66c8e337fb51c2", "score": "0.5810689", "text": "func handleInput(w *glfw.Window, delta float32) {\n\tconst minDistance float32 = 3.0\n\tconst zoomSpeed float32 = 3.0\n\tconst rotSpeed = math.Pi\n\n\trmbStatus := w.GetMouseButton(glfw.MouseButton2)\n\tif rmbStatus == glfw.Press {\n\t\tif w.GetKey(glfw.KeyA) == glfw.Press {\n\t\t\tcamera.Rotate(delta * rotSpeed)\n\t\t}\n\t\tif w.GetKey(glfw.KeyD) == glfw.Press {\n\t\t\tcamera.Rotate(delta * rotSpeed * -1.0)\n\t\t}\n\n\t\tif w.GetKey(glfw.KeyW) == glfw.Press {\n\t\t\tcamera.RotateVertical(delta * rotSpeed)\n\t\t}\n\t\tif w.GetKey(glfw.KeyS) == glfw.Press {\n\t\t\tcamera.RotateVertical(delta * rotSpeed * -1.0)\n\t\t}\n\n\t\tif w.GetKey(glfw.KeyQ) == glfw.Press {\n\t\t\td := camera.GetDistance()\n\t\t\tnewD := d + delta*zoomSpeed\n\t\t\tcamera.SetDistance(newD)\n\t\t}\n\t\tif w.GetKey(glfw.KeyE) == glfw.Press {\n\t\t\td := camera.GetDistance()\n\t\t\tnewD := d - delta*zoomSpeed\n\t\t\tif newD > minDistance {\n\t\t\t\tcamera.SetDistance(newD)\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "56a5ca69faee7bdb06e273539b0ab532", "score": "0.58030003", "text": "func (m *Model) handleEscapeKeyPress(cmds *[]tea.Cmd) {\n\tm.showCommandInput = false\n\tm.moveMode = false\n\tm.itemToMove = nil\n\tm.initialMoveDirectory = \"\"\n\tm.help.ShowAll = true\n\tm.createFileMode = false\n\tm.createDirectoryMode = false\n\tm.renameMode = false\n\tm.showFilesOnly = false\n\tm.showHidden = false\n\tm.showDirectoriesOnly = false\n\tm.findMode = false\n\tm.deleteMode = false\n\n\tm.primaryPane.SetActive(true)\n\tm.secondaryPane.SetActive(false)\n\tm.primaryPane.ShowSpinner(false)\n\tm.dirTree.SetFilePaths(nil)\n\tm.statusBar.BlurCommandInput()\n\tm.statusBar.ResetCommandInput()\n\tm.secondaryPane.GotoTop()\n\tm.primaryPane.ShowAlternateBorder(false)\n\tm.secondaryPane.SetContent(lipgloss.NewStyle().\n\t\tWidth(m.secondaryPane.GetWidth() - m.secondaryPane.Style.GetHorizontalFrameSize()).\n\t\tRender(m.help.View(m.keys)),\n\t)\n\tm.renderer.SetImage(nil)\n\tm.renderer.SetContent(\"\")\n\tm.dirTreePreview.SetContent(nil)\n\tm.updateStatusBarContent(cmds)\n\n\t*cmds = append(*cmds, m.updateDirectoryListingCmd(dirfs.CurrentDirectory))\n}", "title": "" }, { "docid": "75b97d7408f3aa2af8b9cb04a3f77fe8", "score": "0.5786634", "text": "func handleKeyPresses(messagesController <-chan string, mutexControllers *sync.Mutex, mutexTurnsWorld *sync.Mutex,\n\tcontrollers *[]net.Conn, world *[][]byte, completedTurns *int, pause chan<- bool, send chan bool, shutDown chan bool) {\n\tpaused := false\n\tActionsLoop:\n\t\tfor {\n\t\t\taction := <-messagesController\n\t\t\tif action == \"PAUSE\\n\" {\n\t\t\t\tpause <- true\n\t\t\t\tmutexControllers.Lock()\n\t\t\t\tmutexTurnsWorld.Lock()\n\t\t\t\tif paused {\n\t\t\t\t\tsendToAll(*controllers, \"RESUMING\\n\")\n\t\t\t\t} else {\n\t\t\t\t\tsendToAll(*controllers, \"PAUSING\\n\")\n\t\t\t\t}\n\t\t\t\tsendToAll(*controllers, fmt.Sprintf(\"%d\\n\", *completedTurns))\n\t\t\t\tpaused = !paused\n\t\t\t\tmutexTurnsWorld.Unlock()\n\t\t\t\tmutexControllers.Unlock()\n\t\t\t\tfmt.Println(\"Paused/Resumed\")\n\t\t\t} else if !paused {\n\t\t\t\tswitch action {\n\t\t\t\tcase \"SAVE\\n\":\n\t\t\t\t\tsend <- true\n\t\t\t\t\t<-send // Once ready to send, a value will be sent back in this channel\n\t\t\t\t\tmutexControllers.Lock()\n\t\t\t\t\tmutexTurnsWorld.Lock()\n\t\t\t\t\tfor _, conn := range *controllers {\n\t\t\t\t\t\tfmt.Fprintf(conn, \"SENDING_WORLD\\n\")\n\t\t\t\t\t\tsendWorld(*world, conn, *completedTurns)\n\t\t\t\t\t}\n\t\t\t\t\tmutexTurnsWorld.Unlock()\n\t\t\t\t\tmutexControllers.Unlock()\n\t\t\t\t\tfmt.Println(\"Sent World\")\n\t\t\t\tcase \"SHUT_DOWN\\n\":\n\t\t\t\t\tshutDown <- true\n\t\t\t\tcase \"DONE\\n\":\n\t\t\t\t\tbreak ActionsLoop\n\t\t\t\t}\n\t\t\t}\n\t\t}\n}", "title": "" }, { "docid": "f0dd74cc48ee7dc16dd9e3524a9e94dc", "score": "0.5718776", "text": "func keyboard(key, state int) {\n\tif state == glfw.KeyPress {\n\t\tswitch key {\n\t\tcase glfw.KeyEsc:\n\t\t\tshutdown()\n\t\t}\n\n\t}\n\treturn\n}", "title": "" }, { "docid": "efdf7cdfae801c5f576c1ad2b21e305c", "score": "0.56444377", "text": "func (a *DiffArea) Handle(ev termbox.Event) bool {\n\tif ev.Key == termbox.KeyPgdn || ev.Key == termbox.KeySpace || ev.Ch == 'f' || ev.Ch == ',' {\n\t\ta.Win.PageForward()\n\t\treturn true\n\t} else if ev.Key == termbox.KeyPgup || ev.Ch == 'b' || ev.Ch == 'm' {\n\t\ta.Win.PageBackward()\n\t\treturn true\n\t} else if ev.Ch == 'd' || ev.Ch == 'o' {\n\t\ta.Win.HalfPageForward()\n\t\treturn true\n\t} else if ev.Ch == 'u' {\n\t\ta.Win.HalfPageBackward()\n\t\treturn true\n\t} else if ev.Key == termbox.KeyArrowUp || ev.Ch == 'i' {\n\t\ta.Win.MoveUp(1)\n\t\treturn true\n\t} else if ev.Key == termbox.KeyArrowDown || ev.Ch == 'k' {\n\t\ta.Win.MoveDown(1)\n\t\treturn true\n\t} else if ev.Key == termbox.KeyArrowLeft || ev.Ch == 'j' {\n\t\ta.Win.MoveLeft(4)\n\t\treturn true\n\t} else if ev.Key == termbox.KeyArrowRight || ev.Ch == 'l' {\n\t\ta.Win.MoveRight(4)\n\t\treturn true\n\t}\n\tif ev.Key == termbox.KeyCtrlP {\n\t\tscreen.Commit.CursorUp(1)\n\t\treturn true\n\t} else if ev.Key == termbox.KeyCtrlN {\n\t\tscreen.Commit.CursorDown(1)\n\t\treturn true\n\t}\n\treturn false\n}", "title": "" }, { "docid": "2d21fe75afcb848c658f6808f277892a", "score": "0.56185436", "text": "func handleKeyPress(p golParams, d distributorChans, keyPressed rune, currentTurn int, world [][]byte) {\n\tswitch keyPressed {\n\tcase 112:\n\t\t// p pressed: pause processing until p pressed again\n\t\tpaused := true\n\n\t\t// Pause ticker thread\n\t\td.tickerPause <- paused\n\t\t\n\t\tfmt.Println(\"Current turn is \", currentTurn);\n\t\t\n\t\tfor paused {\n\t\t\tkeyPress := <- d.keyChan\n\n\t\t\tif (keyPress == 112) {\n\t\t\t\tpaused = false\n\n\t\t\t\t// Resume ticker thread\n\t\t\t\td.tickerPause <- paused\n\n\t\t\t\tfmt.Println(\"Continuing...\");\n\t\t\t} else {\n\t\t\t\thandleKeyPress(p, d, keyPress, currentTurn, world)\n\t\t\t}\n\t\t}\n\tcase 113:\n\t\t// q pressed: output a pgm file and then quit program\n\t\tfmt.Println(\"q pressed\");\n\n\t\twriteOutputImage(p, d, currentTurn, world)\n\n\t\tStopControlServer()\n\t\tos.Exit(0)\n\tcase 115:\n\t\t// s pressed: output a pgm file\n\t\tfmt.Println(\"s pressed\");\n\n\t\twriteOutputImage(p, d, currentTurn, world)\n\tdefault:\n\t}\n}", "title": "" }, { "docid": "1d8924405341f0e834f6d8f4926e3a2f", "score": "0.5582265", "text": "func OnKeyDown(h * Hanao, event * sdl.Event) {\n kevent := event.Keyboard()\n text := EventToText(kevent)\n fmt.Println(\"keyup\", kevent, \"text:\", text)\n // text := \"\" // CleanupUnicode(kevent)\n // keyboard.press(event.sym, event.mod, text)\n h.sendToWidgets(KeyDown, kevent.Keysym(), kevent.Keysym().Mod(), text)\n}", "title": "" }, { "docid": "9e383b113ccb4eab737aa2fdb875ddd8", "score": "0.5573906", "text": "func (e *Entry) OnKeyEvent(ev KeyEvent) {\n\tif !e.IsFocused() {\n\t\treturn\n\t}\n\n\tscreenWidth := e.Size().X\n\te.text.SetMaxWidth(screenWidth)\n\n\tif ev.Key != KeyRune {\n\t\tswitch ev.Key {\n\t\tcase KeyEnter:\n\t\t\tif e.onSubmit != nil {\n\t\t\t\te.onSubmit(e)\n\t\t\t}\n\t\tcase KeyBackspace:\n\t\t\tfallthrough\n\t\tcase KeyBackspace2:\n\t\t\te.text.Backspace()\n\t\t\tif e.offset > 0 && !e.isTextRemaining() {\n\t\t\t\te.offset--\n\t\t\t}\n\t\t\tif e.onTextChange != nil {\n\t\t\t\te.onTextChange(e)\n\t\t\t}\n\t\tcase KeyDelete, KeyCtrlD:\n\t\t\te.text.Delete()\n\t\t\tif e.onTextChange != nil {\n\t\t\t\te.onTextChange(e)\n\t\t\t}\n\t\tcase KeyLeft, KeyCtrlB:\n\t\t\te.text.MoveBackward()\n\t\t\tif e.offset > 0 {\n\t\t\t\te.offset--\n\t\t\t}\n\t\tcase KeyRight, KeyCtrlF:\n\t\t\te.text.MoveForward()\n\n\t\t\tisCursorTooFar := e.text.CursorPos().X >= screenWidth\n\t\t\tisTextLeft := (e.text.Width() - e.offset) > (screenWidth - 1)\n\n\t\t\tif isCursorTooFar && isTextLeft {\n\t\t\t\te.offset++\n\t\t\t}\n\t\tcase KeyHome, KeyCtrlA:\n\t\t\te.text.MoveToLineStart()\n\t\t\te.offset = 0\n\t\tcase KeyEnd, KeyCtrlE:\n\t\t\te.text.MoveToLineEnd()\n\t\t\te.ensureCursorIsVisible()\n\t\tcase KeyCtrlK:\n\t\t\te.text.Kill()\n\t\t}\n\t\treturn\n\t}\n\n\te.text.WriteRune(ev.Rune)\n\tif e.text.CursorPos().X >= screenWidth {\n\t\te.offset++\n\t}\n\tif e.onTextChange != nil {\n\t\te.onTextChange(e)\n\t}\n}", "title": "" }, { "docid": "389c9f04f90eb225f88ece7b3e783823", "score": "0.5563751", "text": "func (pg *Page) HandleKeyEvent(evt *key.Event) {\n\tif pg.confirmTxModal != nil && pg.confirmTxModal.IsShown() {\n\t\treturn\n\t}\n\n\tcurrencyValue := pg.WL.MultiWallet.ReadStringConfigValueForKey(dcrlibwallet.CurrencyConversionConfigKey)\n\tif currencyValue != values.USDExchangeValue {\n\t\tswitch {\n\t\tcase !pg.sendDestination.sendToAddress:\n\t\t\tdecredmaterial.SwitchEditors(evt, pg.amount.dcrAmountEditor.Editor)\n\t\tdefault:\n\t\t\tdecredmaterial.SwitchEditors(evt, pg.sendDestination.destinationAddressEditor.Editor, pg.amount.dcrAmountEditor.Editor)\n\t\t}\n\t} else {\n\t\tswitch {\n\t\tcase !pg.sendDestination.sendToAddress && !(pg.amount.dcrAmountEditor.Editor.Focused() || pg.amount.usdAmountEditor.Editor.Focused()):\n\t\tcase !pg.sendDestination.sendToAddress && (pg.amount.dcrAmountEditor.Editor.Focused() || pg.amount.usdAmountEditor.Editor.Focused()):\n\t\t\tdecredmaterial.SwitchEditors(evt, pg.amount.usdAmountEditor.Editor, pg.amount.dcrAmountEditor.Editor)\n\t\tdefault:\n\t\t\tdecredmaterial.SwitchEditors(evt, pg.sendDestination.destinationAddressEditor.Editor, pg.amount.dcrAmountEditor.Editor, pg.amount.usdAmountEditor.Editor)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "f203f8c5c0bf88a44df369449e6485e5", "score": "0.55467683", "text": "func (i *Input) HandleEvent(e termbox.Event, ui *UI) {\n\tswitch e.Key {\n\tcase termbox.KeyBackspace, termbox.KeyBackspace2:\n\t\ti.Backspace()\n\n\tcase termbox.KeyDelete:\n\t\ti.Delete()\n\n\tcase termbox.KeySpace:\n\t\ti.Insert(\" \")\n\n\tcase termbox.KeyTab:\n\t\ti.Insert(\" \")\n\n\tcase termbox.KeyArrowLeft:\n\t\tif i.cursor > 0 {\n\t\t\ti.cursor--\n\t\t}\n\n\tcase termbox.KeyArrowRight:\n\t\tif i.cursor < len(i.Text) {\n\t\t\ti.cursor++\n\t\t}\n\n\tcase termbox.KeyEnter:\n\t\tui.MoveSelection(-1)\n\n\tdefault:\n\t\ti.Insert(string(e.Ch))\n\t}\n}", "title": "" }, { "docid": "50d8d6fba5da667c49bdc5ec3d04ad9d", "score": "0.55388635", "text": "func (tf *TheFarm) onKey(evname string, ev interface{}) {\n\tkev := ev.(*window.KeyEvent) // return key events\n\tswitch kev.Keycode {\n\tcase window.KeyR:\n\t\ttf.ToggleFullScreen()\n\tcase window.KeyX:\n\t\ttf.translateChar(tf.allChar[0])\n\tcase window.KeyY:\n\t\ttf.translateChar(tf.allChar[0])\n\tcase window.KeyZ:\n\t\ttf.translateChar(tf.allChar[0])\n\tcase window.KeyEnter:\n\t\ttf.ResetFarm()\n\t}\n}", "title": "" }, { "docid": "14d8e7e4cdb8d866286c63e352e5b129", "score": "0.55224925", "text": "func handleKeyPresses(c distributorChannels, p Params, turn int, prevWorld [][]uint8) bool {\n\tquit := false\n\tselect {\n\tcase x := <-c.keyPresses:\n\t\tswitch x {\n\t\tcase 's':\n\t\t\tfmt.Println(\"Saving latest world...\")\n\t\t\tsaveWorld(c, p, turn, prevWorld)\n\t\tcase 'q':\n\t\t\tfmt.Println(\"Shutting down...\")\n\t\t\tquit = true\n\t\tcase 'p':\n\t\t\tfmt.Println(\"Paused\")\n\t\t\tx = <-c.keyPresses\n\t\t\tfor x != 'p' {\n\t\t\t\tx = <-c.keyPresses\n\t\t\t}\n\t\t\tfmt.Println(\"Resuming\")\n\t\tcase 'k':\n\t\t\tbreak\n\t\tdefault:\n\t\t\tlog.Fatalf(\"Unexpected keypress: %v\", x)\n\t\t}\n\tdefault:\n\t\tbreak\n\t}\n\treturn quit\n}", "title": "" }, { "docid": "d8f4106c856d6575b25bf40ccfb9b9a3", "score": "0.5520198", "text": "func (l *List) KeyHandler(ev termbox.Event) bool {\n\treturn false // not handled\n}", "title": "" }, { "docid": "0f7f4639ab1e0af93c0f39be5cebadbe", "score": "0.55122274", "text": "func (v *View) HandleEvent(event tcell.Event) {\n\trelocate := true\n\n\tswitch e := event.(type) {\n\tcase *tcell.EventKey:\n\t\t// Check first if input is a key binding, if it is we 'eat' the input and don't insert a rune\n\t\tfor key, actions := range bindings {\n\t\t\tif e.Key() == key.keyCode {\n\t\t\t\tif e.Key() == tcell.KeyRune {\n\t\t\t\t\tif e.Rune() != key.r {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif e.Modifiers() == key.modifiers {\n\t\t\t\t\trelocate = false\n\t\t\t\t\trelocate = v.ExecuteActions(actions) || relocate\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif relocate {\n\t\tv.Relocate()\n\t\tv.Relocate()\n\t}\n}", "title": "" }, { "docid": "3c845f743c1da0ab527a6e15511d44d8", "score": "0.5500554", "text": "func (m *Model) handleEnterKeyPress(cmds *[]tea.Cmd) {\n\tselectedFile, err := m.dirTree.GetSelectedFile()\n\tif err != nil {\n\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t}\n\n\tswitch {\n\tcase m.moveMode:\n\t\t*cmds = append(*cmds, m.moveDirectoryItemCmd(m.itemToMove.Name()))\n\tcase m.createFileMode:\n\t\t*cmds = append(*cmds, tea.Sequentially(\n\t\t\tm.createFileCmd(m.statusBar.CommandInputValue()),\n\t\t\tm.updateDirectoryListingCmd(dirfs.CurrentDirectory),\n\t\t))\n\tcase m.createDirectoryMode:\n\t\t*cmds = append(*cmds, tea.Sequentially(\n\t\t\tm.createDirectoryCmd(m.statusBar.CommandInputValue()),\n\t\t\tm.updateDirectoryListingCmd(dirfs.CurrentDirectory),\n\t\t))\n\tcase m.renameMode:\n\t\t*cmds = append(*cmds, tea.Sequentially(\n\t\t\tm.renameDirectoryItemCmd(selectedFile.Name(), m.statusBar.CommandInputValue()),\n\t\t\tm.updateDirectoryListingCmd(dirfs.CurrentDirectory),\n\t\t))\n\tcase m.findMode:\n\t\tm.showCommandInput = false\n\n\t\tm.primaryPane.ShowSpinner(true)\n\t\tm.updateStatusBarContent(cmds)\n\n\t\t*cmds = append(*cmds, m.findFilesByNameCmd(m.statusBar.CommandInputValue()))\n\tcase m.deleteMode:\n\t\tif strings.ToLower(m.statusBar.CommandInputValue()) == \"y\" || strings.ToLower(m.statusBar.CommandInputValue()) == \"yes\" {\n\t\t\tselectedFile, err := m.dirTree.GetSelectedFile()\n\t\t\tif err != nil {\n\t\t\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t\t\t}\n\n\t\t\tif selectedFile.IsDir() {\n\t\t\t\t*cmds = append(*cmds, tea.Sequentially(\n\t\t\t\t\tm.deleteDirectoryCmd(selectedFile.Name()),\n\t\t\t\t\tm.updateDirectoryListingCmd(dirfs.CurrentDirectory),\n\t\t\t\t))\n\t\t\t} else {\n\t\t\t\t*cmds = append(*cmds, tea.Sequentially(\n\t\t\t\t\tm.deleteFileCmd(selectedFile.Name()),\n\t\t\t\t\tm.updateDirectoryListingCmd(dirfs.CurrentDirectory),\n\t\t\t\t))\n\t\t\t}\n\t\t}\n\n\t\tm.showCommandInput = false\n\n\t\tm.statusBar.ResetCommandInput()\n\t\tm.statusBar.BlurCommandInput()\n\t\tm.updateStatusBarContent(cmds)\n\tdefault:\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "d6c48a9ea5fcc219cd0aab15b1872d06", "score": "0.54786813", "text": "func (h *BufPane) DoKeyEvent(e Event) bool {\n\tbinds := h.Bindings()\n\taction, more := binds.NextEvent(e, nil)\n\tif action != nil && !more {\n\t\taction(h)\n\t\tbinds.ResetEvents()\n\t\treturn true\n\t} else if action == nil && !more {\n\t\tbinds.ResetEvents()\n\t}\n\treturn more\n}", "title": "" }, { "docid": "d626b97677e3c4c3f2dbb5a4e3b14b7d", "score": "0.54751223", "text": "func (m *Model) handleJumpToBottomKeyPress(cmds *[]tea.Cmd) {\n\tif !m.showCommandInput && m.primaryPane.GetIsActive() && m.dirTree.GetTotalFiles() > 1 {\n\t\tm.dirTree.GotoBottom()\n\t\tm.primaryPane.GotoBottom()\n\t\tm.primaryPane.SetContent(m.dirTree.View())\n\t\tm.statusBar.SetDirectoryItemSize(\"\")\n\n\t\tselectedFile, err := m.dirTree.GetSelectedFile()\n\t\tif err != nil {\n\t\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t\t}\n\n\t\t*cmds = append(*cmds, m.getDirectoryItemSizeCmd(selectedFile.Name()))\n\t}\n\n\tif !m.showCommandInput && m.secondaryPane.GetIsActive() {\n\t\tm.secondaryPane.GotoBottom()\n\t}\n}", "title": "" }, { "docid": "40aac2a79336a93bed0ec1f3c4f8dc23", "score": "0.5474358", "text": "func (ap *AutoPlayer) HandleInput() int {\n\tap.game.lock.Lock()\n\tdefer ap.game.lock.Unlock()\n\n\ttime.Sleep(5 * time.Millisecond)\n\tif ap.game.ballLoc.X < ap.game.paddleLoc.X {\n\t\treturn -1\n\t} else if ap.game.ballLoc.X > ap.game.paddleLoc.X {\n\t\treturn 1\n\t} else {\n\t\treturn 0\n\t}\n}", "title": "" }, { "docid": "d571fd216bb0e27d755d6bdd35677ee0", "score": "0.54725647", "text": "func (app *App) handleInputNormal(input Input) {\n\t// @TODO (!important) e and E (move end word)\n\t// @TODO (!important) u (undo)\n\t// @TODO (!important) p and P (paste)\n\t// @TODO (!important) V (visual mode and visual line mode)\n\t// @TODO (!important) gd and ga and gv and gh (goto)\n\t// @TODO (!important) ck and cj (change)\n\t// @TODO (!important) ci and vi and di\n\t// @TODO (!important) daw\n\t// @TODO (!important) vaf and vaw\n\n\tif app.Submode == Submode_Replace {\n\t\tapp.handleInputSubmodeReplace(input)\n\t\treturn\n\t}\n\n\tif app.Submode == Submode_Delete {\n\t\tapp.handleInputSubmodeDelete(input)\n\t\treturn\n\t}\n\n\tif app.Submode == Submode_Goto {\n\t\tapp.handleInputSubmodeGoto(input)\n\t\treturn\n\t}\n\n\tif app.Submode == Submode_Change {\n\t\tapp.handleInputSubmodeChange(input)\n\t\treturn\n\t}\n\n\tif app.Submode == Submode_FindNext || app.Submode == Submode_FindPrev {\n\t\tapp.handleInputSubmodeFind(input)\n\t\treturn\n\t}\n\n\tif input.Escape {\n\t\tapp.AmountModifier.Reset()\n\t\tapp.startNormalMode()\n\t\treturn\n\t}\n\n\tif input.TypedCharacter >= '1' && input.TypedCharacter <= '9' || input.TypedCharacter == '0' && app.AmountModifier.Len() > 0 {\n\t\tapp.AmountModifier.WriteByte(input.TypedCharacter)\n\t\treturn\n\t}\n\n\tswitch input.TypedCharacter {\n\tcase 'j':\n\t\tif app.AmountModifier.Len() > 0 {\n\t\t\tamount, _ := strconv.Atoi(app.AmountModifier.String())\n\t\t\tapp.AmountModifier.Reset()\n\n\t\t\tapp.Buffer.MoveDownByLines(amount)\n\t\t} else {\n\t\t\tapp.Buffer.MoveDown()\n\t\t}\n\tcase 'k':\n\t\tif app.AmountModifier.Len() > 0 {\n\t\t\tamount, _ := strconv.Atoi(app.AmountModifier.String())\n\t\t\tapp.AmountModifier.Reset()\n\n\t\t\tapp.Buffer.MoveUpByLines(amount)\n\t\t} else {\n\t\t\tapp.Buffer.MoveUp()\n\t\t}\n\tcase 'h':\n\t\tapp.Buffer.MoveLeft()\n\tcase 'H':\n\t\tapp.Buffer.MoveUpByLines(32)\n\tcase 'l':\n\t\tapp.Buffer.MoveRight()\n\tcase 'L':\n\t\tapp.Buffer.MoveDownByLines(32)\n\tcase 'i':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.startInsertMode()\n\t\t}\n\tcase 'I':\n\t\tif app.Mode == Mode_Normal {\n\t\t\t// @TODO (!important) move to the first non white space character in the line\n\t\t\tapp.startInsertMode()\n\t\t\tapp.Buffer.MoveToStartOfLine()\n\t\t}\n\tcase 'a':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.startInsertMode()\n\t\t\tapp.Buffer.MoveRight()\n\t\t}\n\tcase 'A':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.startInsertMode()\n\t\t\tapp.Buffer.MoveToEndOfLine()\n\t\t}\n\tcase 'o':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.startInsertMode()\n\t\t\tapp.Buffer.InsertNewLineBelow()\n\t\t}\n\tcase 'O':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.startInsertMode()\n\t\t\tapp.Buffer.InsertNewLineAbove()\n\t\t}\n\tcase 'x':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.Buffer.RemoveAfter()\n\t\t} else if app.Mode == Mode_Visual {\n\t\t\tapp.Buffer.RemoveSelection()\n\t\t\tapp.startNormalMode()\n\t\t}\n\tcase 'D':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.Buffer.RemoveRemainingLine()\n\t\t}\n\tcase '0':\n\t\tapp.Buffer.MoveToStartOfLine()\n\tcase '$':\n\t\tapp.Buffer.MoveToEndOfLine()\n\tcase 'w':\n\t\tapp.Buffer.MoveRightToWordStart(false) // Do not ignore punctuation\n\tcase 'W':\n\t\tapp.Buffer.MoveRightToWordStart(true) // Ignore puctuation\n\tcase 'b':\n\t\tapp.Buffer.MoveLeftToWordStart(false) // Do not ignore punctuation\n\tcase 'B':\n\t\tapp.Buffer.MoveLeftToWordStart(true) // Ignore punctuation\n\tcase 'g':\n\t\tapp.Submode = Submode_Goto\n\tcase 'G':\n\t\tif app.AmountModifier.Len() > 0 {\n\t\t\tamount, _ := strconv.Atoi(app.AmountModifier.String())\n\t\t\tapp.AmountModifier.Reset()\n\t\t\tapp.Buffer.MoveToLine(int32(amount))\n\t\t} else {\n\t\t\tapp.Buffer.MoveToBufferEnd()\n\t\t}\n\tcase 'J':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.Buffer.MergeLineBelow()\n\t\t}\n\tcase 'r':\n\t\tapp.Submode = Submode_Replace\n\tcase 'd':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.Submode = Submode_Delete\n\t\t} else if app.Mode == Mode_Visual {\n\t\t\tapp.Buffer.RemoveSelection()\n\t\t\tapp.startNormalMode()\n\t\t}\n\tcase 'c':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.Submode = Submode_Change\n\t\t} else if app.Mode == Mode_Visual {\n\t\t\tapp.Buffer.RemoveSelection()\n\t\t\tapp.startInsertMode()\n\t\t}\n\tcase 'C':\n\t\tif app.Mode == Mode_Normal {\n\n\t\t\tapp.startInsertMode()\n\t\t\tapp.Buffer.ChangeRemainingLine()\n\t\t}\n\tcase 'm':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.Buffer.MarkCurrentPosition()\n\t\t}\n\tcase '`':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.Buffer.MoveToBookmark()\n\t\t}\n\tcase 'f':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.Submode = Submode_FindNext\n\t\t}\n\tcase 'F':\n\t\tif app.Mode == Mode_Normal {\n\t\t\t// @TODO (!important) perhaps this is not very useful\n\t\t\tapp.Submode = Submode_FindPrev\n\t\t}\n\tcase ';':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.Buffer.MoveToNextLineQuerySymbol()\n\t\t}\n\tcase ',':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.Buffer.MoveToPrevLineQuerySymbol()\n\t\t}\n\tcase '>':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.Buffer.Indent()\n\t\t} else if app.Mode == Mode_Visual {\n\t\t\tapp.Buffer.IndentSelection()\n\t\t\tapp.startNormalMode()\n\t\t}\n\tcase '<':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.Buffer.Outdent()\n\t\t} else if app.Mode == Mode_Visual {\n\t\t\tapp.Buffer.OutdentSelection()\n\t\t\tapp.startNormalMode()\n\t\t}\n\tcase 'v':\n\t\tif app.Mode == Mode_Normal {\n\t\t\tapp.startVisualMode()\n\t\t}\n\tcase 'y':\n\t\ttext := app.Buffer.GetSelectionText()\n\t\terr := sdl.SetClipboardText(text)\n\t\tcheckError(err)\n\n\t\tapp.startNormalMode()\n\tcase 'Y':\n\t\ttext := app.Buffer.GetCurrentLineText()\n\t\terr := sdl.SetClipboardText(text)\n\t\tcheckError(err)\n\n\t\tapp.startNormalMode()\n\tcase ':':\n\t\tapp.openCommandPalette()\n\tcase '/':\n\t\tapp.openSearch()\n\tcase 'n':\n\t\tapp.Buffer.MoveToNextFindResult()\n\t}\n}", "title": "" }, { "docid": "d4e784c197a99e57792e3e06ce721fdc", "score": "0.54700243", "text": "func (d *Dot) HandleEvent(e sdl.Event) {\n\t//If a key was pressed\n\tif e.GetType() == sdl.KEYDOWN && (e.(*sdl.KeyboardEvent)).Repeat == 0 {\n\t\t//Adjust the velocity\n\t\tswitch (e.(*sdl.KeyboardEvent)).Keysym.Sym {\n\t\tcase sdl.K_UP:\n\t\t\td.mVelY -= DotVel\n\t\t\tbreak\n\t\tcase sdl.K_DOWN:\n\t\t\td.mVelY += DotVel\n\t\t\tbreak\n\t\tcase sdl.K_LEFT:\n\t\t\td.mVelX -= DotVel\n\t\t\tbreak\n\t\tcase sdl.K_RIGHT:\n\t\t\td.mVelX += DotVel\n\t\t\tbreak\n\t\t}\n\t} else if e.GetType() == sdl.KEYUP && (e.(*sdl.KeyboardEvent)).Repeat == 0 { //If a key was released\n\t\t//Adjust the velocity\n\t\tswitch (e.(*sdl.KeyboardEvent)).Keysym.Sym {\n\t\tcase sdl.K_UP:\n\t\t\td.mVelY += DotVel\n\t\t\tbreak\n\t\tcase sdl.K_DOWN:\n\t\t\td.mVelY -= DotVel\n\t\t\tbreak\n\t\tcase sdl.K_LEFT:\n\t\t\td.mVelX += DotVel\n\t\t\tbreak\n\t\tcase sdl.K_RIGHT:\n\t\t\td.mVelX -= DotVel\n\t\t\tbreak\n\t\t}\n\t}\n}", "title": "" }, { "docid": "cef9ff43909a2ba5d2457e96bff42746", "score": "0.5467713", "text": "func (mode *Input) Key(key Key) error {\n\tswitch key {\n\tcase KeyLeft:\n\t\tmode.editor.MoveLeft()\n\tcase KeyRight:\n\t\tmode.editor.MoveRight()\n\tcase KeyUp:\n\t\tmode.editor.MoveUp()\n\tcase KeyDown:\n\t\tmode.editor.MoveDown()\n\tcase KeyHome:\n\t\tmode.editor.MoveLineStart()\n\tcase KeyEnd:\n\t\tmode.editor.MoveLineEnd()\n\tcase KeyPageUp:\n\t\tmode.editor.MoveParagraphPrevious()\n\tcase KeyPageDown:\n\t\tmode.editor.MoveParagraphNext()\n\tcase KeyTab:\n\t\tmode.editor.Insert(string(Tab))\n\tcase KeyEnter:\n\t\tmode.editor.Insert(string(EOL))\n\tcase KeyBackspace:\n\t\tmode.editor.Backspace()\n\tcase KeyDelete:\n\t\tmode.editor.Delete()\n\tcase KeyCtrlSpace:\n\t\tmode.editor.SwitchMode(mode.editor.Command)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "f45dfb3bb87ecc462ca1fee8766a4111", "score": "0.54450375", "text": "func (ce *CodeEditorWidget) HandleKeyboardInputs(b bool) *CodeEditorWidget {\n\tce.getState().editor.SetHandleKeyboardInputs(b)\n\treturn ce\n}", "title": "" }, { "docid": "946a27b7ce36ab8dbb2cab4619b79823", "score": "0.544365", "text": "func (m *Model) handleDeleteKeyPress(cmds *[]tea.Cmd) {\n\tif !m.showCommandInput && m.primaryPane.GetIsActive() && m.dirTree.GetTotalFiles() > 0 && !m.moveMode && !m.renameMode {\n\t\tm.showCommandInput = true\n\t\tm.deleteMode = true\n\n\t\tm.statusBar.SetCommandInputPlaceholderText(\"delete (y/n)?\")\n\t\tm.statusBar.FocusCommandInput()\n\t\tm.updateStatusBarContent(cmds)\n\t}\n}", "title": "" }, { "docid": "eecd0a613685d00b71b970c3e1a7c3e7", "score": "0.54332006", "text": "func (m *Model) handleDownKeyPress(cmds *[]tea.Cmd) {\n\tif !m.showCommandInput && m.primaryPane.GetIsActive() && m.dirTree.GetTotalFiles() > 1 {\n\t\tm.dirTree.GoDown()\n\t\tm.scrollPrimaryPane()\n\t\tm.updateStatusBarContent(cmds)\n\t\tm.primaryPane.SetContent(m.dirTree.View())\n\t\tm.statusBar.SetDirectoryItemSize(\"\")\n\n\t\tselectedFile, err := m.dirTree.GetSelectedFile()\n\t\tif err != nil {\n\t\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t\t}\n\n\t\t*cmds = append(*cmds, m.getDirectoryItemSizeCmd(selectedFile.Name()))\n\t}\n\n\tif !m.showCommandInput && m.secondaryPane.GetIsActive() {\n\t\tm.secondaryPane.LineDown(1)\n\t}\n}", "title": "" }, { "docid": "8eec99140b68a461760741e55fb818fd", "score": "0.540365", "text": "func (g *GitApp) inputHandler(event *tcell.EventKey) *tcell.EventKey {\n\tswitch event.Key() {\n\tcase tcell.KeyCtrlQ:\n\t\tg.app.Stop()\n\t\treturn event\n\tcase tcell.KeyTab:\n\t\tcurrentPage, _ := g.pages.GetFrontPage()\n\t\tpage := g.appPages.Get(currentPage)\n\t\tg.app.SetFocus(page.NextWidget())\n\t\treturn event\n\tcase tcell.KeyBacktab:\n\t\tcurrentPage, _ := g.pages.GetFrontPage()\n\t\tpage := g.appPages.Get(currentPage)\n\t\tg.app.SetFocus(page.PrevWidget())\n\t\treturn event\n\tcase tcell.KeyCtrlN:\n\t\tcurrentPage, _ := g.pages.GetFrontPage()\n\t\tg.pages.SwitchToPage(g.appPages.Next(currentPage))\n\t\treturn event\n\tcase tcell.KeyCtrlP:\n\t\tcurrentPage, _ := g.pages.GetFrontPage()\n\t\tg.pages.SwitchToPage(g.appPages.Prev(currentPage))\n\t\treturn event\n\tcase tcell.KeyCtrlR:\n\t\tcurrentPage, _ := g.pages.GetFrontPage()\n\t\tpage := g.appPages.Get(currentPage)\n\t\tpage.Refresh()\n\t\treturn event\n\t}\n\treturn event\n}", "title": "" }, { "docid": "4921c11c7c11903b5cc21327c8e4c47f", "score": "0.5379149", "text": "func (m *Model) handleLeftKeyPress(cmds *[]tea.Cmd) {\n\tif !m.showCommandInput && m.primaryPane.GetIsActive() {\n\t\tm.statusBar.SetDirectoryItemSize(\"\")\n\n\t\tworkingDirectory, err := dirfs.GetWorkingDirectory()\n\t\tif err != nil {\n\t\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t\t}\n\n\t\tm.previousDirectory = workingDirectory\n\n\t\t*cmds = append(*cmds, m.updateDirectoryListingCmd(filepath.Join(workingDirectory, dirfs.PreviousDirectory)))\n\t}\n}", "title": "" }, { "docid": "1d6d85d78abeaa3326b9a721061abbd8", "score": "0.5334265", "text": "func (m *Model) handleTabKeyPress() {\n\tif !m.showCommandInput {\n\t\tm.primaryPane.SetActive(!m.primaryPane.GetIsActive())\n\t\tm.secondaryPane.SetActive(!m.secondaryPane.GetIsActive())\n\t}\n}", "title": "" }, { "docid": "97e8d15d3e4f3c023f5fec1f454c837f", "score": "0.5314196", "text": "func (s *Session) Dispatch(k terminal.Key) {\n\tswitch s.State {\n\tcase stateEditing:\n\t\tswitch {\n\t\tcase k.Regular == ctrlKey('Q'):\n\t\t\tif !s.Editor.Dirty {\n\t\t\t\tSafeExit(nil)\n\t\t\t}\n\t\t\ts.startQuitPrompt()\n\t\tcase k.Regular == ctrlKey('S'):\n\t\t\tif s.Editor.FileName != \"\" {\n\t\t\t\ts.saveFile()\n\t\t\t} else {\n\t\t\t\ts.startSavePrompt()\n\t\t\t}\n\t\tcase k.Regular == ctrlKey('F'):\n\t\t\ts.startFindPrompt()\n\t\tdefault:\n\t\t\ts.editorDispatch(k)\n\t\t}\n\n\tcase stateQuitPrompt:\n\t\tif k.Regular == ctrlKey('Q') {\n\t\t\tSafeExit(nil)\n\t\t}\n\t\ts.endQuitPromt()\n\n\tcase stateSavePrompt:\n\t\tswitch {\n\t\tcase k.Regular == '\\r':\n\t\t\ts.endSavePrompt(true)\n\t\tcase k.Regular == 27:\n\t\t\ts.endSavePrompt(false)\n\t\tdefault:\n\t\t\ts.lineEditorDispatch(k)\n\t\t}\n\n\tcase stateFindPrompt:\n\t\tswitch {\n\t\tcase k.Regular == '\\r':\n\t\t\ts.endFindPrompt(true)\n\t\tcase k.Regular == 27:\n\t\t\ts.endFindPrompt(false)\n\t\tdefault:\n\t\t\ts.lineEditorDispatch(k)\n\t\t}\n\n\tcase stateFindNav:\n\t\tswitch {\n\t\tcase k.Special == terminal.KeyArrowUp, k.Special == terminal.KeyArrowLeft:\n\t\t\ts.CurFindPoint--\n\t\t\tif s.CurFindPoint < 0 {\n\t\t\t\ts.CurFindPoint = len(s.FindPoints) - 1\n\t\t\t}\n\t\t\ts.Editor.SetCursor(s.FindPoints[s.CurFindPoint])\n\n\t\tcase k.Special == terminal.KeyArrowDown, k.Special == terminal.KeyArrowRight:\n\t\t\ts.CurFindPoint++\n\t\t\tif s.CurFindPoint >= len(s.FindPoints) {\n\t\t\t\ts.CurFindPoint = 0\n\t\t\t}\n\t\t\ts.Editor.SetCursor(s.FindPoints[s.CurFindPoint])\n\t\tcase k.Regular == 27:\n\t\t\ts.Editor.SetCursor(s.BeforFindPoint)\n\t\t\ts.endFindNav()\n\t\tcase k.Regular == '\\r':\n\t\t\ts.endFindNav()\n\t\t}\n\t}\n}", "title": "" }, { "docid": "362f6667136af9c0e67a77129b158356", "score": "0.5297884", "text": "func (m *Model) handleUpKeyPress(cmds *[]tea.Cmd) {\n\tif !m.showCommandInput && m.primaryPane.GetIsActive() && m.dirTree.GetTotalFiles() > 1 {\n\t\tm.dirTree.GoUp()\n\t\tm.scrollPrimaryPane()\n\t\tm.updateStatusBarContent(cmds)\n\t\tm.primaryPane.SetContent(m.dirTree.View())\n\t\tm.statusBar.SetDirectoryItemSize(\"\")\n\n\t\tselectedFile, err := m.dirTree.GetSelectedFile()\n\t\tif err != nil {\n\t\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t\t}\n\n\t\t*cmds = append(*cmds, m.getDirectoryItemSizeCmd(selectedFile.Name()))\n\t}\n\n\tif !m.showCommandInput && m.secondaryPane.GetIsActive() {\n\t\tm.secondaryPane.LineUp(1)\n\t}\n}", "title": "" }, { "docid": "b50951216c2aaa1e7d98fa9c9194b65d", "score": "0.52848095", "text": "func (w *Window) keyboard(k Keyboard) {\n\t//if w.keyfocus != nil {\n\t//w.keyfocus.Keyboard(k)\n\t//}\n}", "title": "" }, { "docid": "2783bd9bd9005fb4db36d00833647a33", "score": "0.52263606", "text": "func (a *App) processCharInput(ev *tcell.EventKey) bool {\n\tvar ch rune\n\tif ev.Key() == tcell.KeyRune {\n\t\tch = ev.Rune()\n\t} else if ev.Key() == tcell.KeyEnter || ev.Key() == tcell.KeyCtrlJ {\n\t\tch = '\\n'\n\t}\n\tif ch == 0 {\n\t\treturn true\n\t}\n\tif a.StartedAt.IsZero() {\n\t\ta.StartedAt = ev.When()\n\t}\n\n\tif cheating { // always type correct :)\n\t\tif ch == 'j' {\n\t\t\ta.InputPosition += 3\n\t\t}\n\t\tif ch == 'k' {\n\t\t\ta.InputPosition -= 3\n\t\t}\n\t\tif a.InputPosition < 0 {\n\t\t\ta.InputPosition = 0\n\t\t}\n\t\treturn a.InputPosition < len(a.Text)\n\t}\n\tif ch == a.Text[a.InputPosition] && len(a.ErrorInput) == 0 { // correct\n\t\ta.Timeline[a.InputPosition] = ev.When().Sub(a.StartedAt).Seconds()\n\t\ta.InputPosition++\n\t} else { // wrong\n\t\ta.ErrorInput = append(a.ErrorInput, ch)\n\t\tif !a.Mute {\n\t\t\ta.scr.Beep()\n\t\t}\n\t}\n\treturn a.InputPosition < len(a.Text)\n}", "title": "" }, { "docid": "102787669938d32ce2f5d49a7c06f280", "score": "0.52007324", "text": "func (wt *WelcomeText) HandleEvent(event sdl.Event) {\n\tswitch ev := event.(type) {\n\tcase *sdl.KeyboardEvent:\n\t\tif ev.State != sdl.PRESSED {\n\t\t\tbreak\n\t\t}\n\n\t\tswitch event.(*sdl.KeyboardEvent).Keysym.Sym {\n\t\tcase sdl.K_RETURN:\n\t\t\twt.changeState = true\n\t\t}\n\t}\n}", "title": "" }, { "docid": "b1892ca6deb77ca9026cf922d98defc8", "score": "0.5179233", "text": "func handleInput(human string, obj ecma48.Output) {\n\tdefer func() {\n\t\tif config.statusBar {\n\t\t\tdebug(root.serialize())\n\t\t}\n\t}()\n\n\tif demoMode {\n\t\trenderer.DemoText = human\n\n\t\tif demoTextTimer == nil {\n\t\t\tdemoTextTimer = time.NewTimer(demoTextDuration)\n\t\t} else {\n\t\t\tdemoTextTimer.Stop()\n\t\t\tdemoTextTimer.Reset(demoTextDuration)\n\t\t}\n\n\t\tgo func() {\n\t\t\t<-demoTextTimer.C\n\t\t\trenderer.DemoText = \"\"\n\t\t}()\n\t}\n\n\tif seiveTmuxEvents(human, obj) {\n\t\treturn\n\t}\n\n\tif seiveResizeEvents(human, obj) {\n\t\treturn\n\t}\n\n\tif seiveMouseEvents(human, obj) {\n\t\treturn\n\t}\n\n\tif seiveConfigEvents(human) {\n\t\treturn\n\t}\n\n\t// log.Printf(\"%q %+v\", obj.Raw, obj.Parsed)\n\tt := getSelection().getContainer().(*Pane)\n\n\tswitch x := obj.Parsed.(type) {\n\tcase ecma48.CursorMovement:\n\t\tswitch x.Direction {\n\t\tcase ecma48.Up:\n\t\t\tt.handleStdin(\"\\x1bOA\")\n\t\tcase ecma48.Down:\n\t\t\tt.handleStdin(\"\\x1bOB\")\n\t\tcase ecma48.Right:\n\t\t\tt.handleStdin(\"\\x1bOC\")\n\t\tcase ecma48.Left:\n\t\t\tt.handleStdin(\"\\x1bOD\")\n\t\t}\n\tdefault:\n\t\t// if we didn't find anything special, just pass the raw data to the selected terminal\n\t\tt.handleStdin(string(obj.Raw))\n\t}\n\n}", "title": "" }, { "docid": "8b13d003bec714a064c94881878d12e8", "score": "0.5160307", "text": "func keyPress1() { \n type keyboardInput struct { \n wVk uint16 \n wScan uint16 \n dwFlags uint32 \n time uint32 \n dwExtraInfo uint64 \n } \n\t\n type input struct { \n inputType uint32 \n ki keyboardInput \n padding uint64 \n } \n \n var i input \n i.inputType = 1 //INPUTKEYBOARD \n i.ki.wVk = 0x87 // virtual key code for F24 ; 0x41; 0x90(Insert)\n lop, _, err := sendInputProc.Call( \n uintptr(1),\n uintptr(unsafe.Pointer(&i)),\n uintptr(unsafe.Sizeof(i)), \n ) \n\t//log.Printf(\"KeyBoard: %v MSG: %v\", lop, err) \n\t\tlog.Printf(\"%v %v\", lop, err)\n }", "title": "" }, { "docid": "2943a906029f362d6a4490b0c50ece1b", "score": "0.5149618", "text": "func (s *Session) HandleDown() {\n\tif s.Player.Direction == player.PlayerUp {\n\t\treturn\n\t}\n\ts.Player.Direction = player.PlayerDown\n\ts.Player.Marker = config.PlayerDownRune\n\ts.Player.BaseSpeed = config.VerticalPlayerSpeed\n\ts.didAction()\n}", "title": "" }, { "docid": "c38fe2fc71f825c09b7203527113032d", "score": "0.5144708", "text": "func (mi *Mirror) Keyboard(k *terminalapi.Keyboard, meta *widgetapi.EventMeta) error {\n\tmi.mu.Lock()\n\tdefer mi.mu.Unlock()\n\n\tif k.Key == keyboard.KeyEsc {\n\t\tmi.lines[keyboardLine] = \"\"\n\t\treturn fmt.Errorf(\"fakewidget received keyboard event: %v\", k)\n\t}\n\tif meta.Focused {\n\t\tmi.lines[keyboardLine] = fmt.Sprintf(\"F:%s\", k.Key.String())\n\t} else {\n\t\tmi.lines[keyboardLine] = k.Key.String()\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "2db163a2a0b76fb34490813363d187d7", "score": "0.513907", "text": "func emulateKeyPress(keys string) {\n\tif keyboard == nil {\n\t\tfmt.Fprintln(os.Stderr, \"Keyboard emulation is disabled!\")\n\t\treturn\n\t}\n\n\tkk := strings.Split(keys, \"-\")\n\tfor i, k := range kk {\n\t\tk = formatKeycodes(strings.TrimSpace(k))\n\t\tkc, err := strconv.Atoi(k)\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"%s is not a valid keycode: %s\\n\", k, err)\n\t\t}\n\n\t\tif i+1 < len(kk) {\n\t\t\t_ = keyboard.KeyDown(kc)\n\t\t\tdefer keyboard.KeyUp(kc) //nolint:errcheck\n\t\t} else {\n\t\t\t_ = keyboard.KeyPress(kc)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "8560fd4eabc80342f22015ed5520d0f7", "score": "0.5114757", "text": "func (a *App) processKey(ev *tcell.EventKey) bool {\n\tif ev.Key() == tcell.KeyEscape || ev.Key() == tcell.KeyCtrlC {\n\t\treturn false\n\t}\n\n\tswitch ev.Key() {\n\tcase tcell.KeyBackspace, tcell.KeyBackspace2:\n\t\ta.processBackspace()\n\tdefault:\n\t\treturn a.processCharInput(ev)\n\t}\n\treturn true\n}", "title": "" }, { "docid": "c963beb9101f8572db71f3340efb5425", "score": "0.5112207", "text": "func OnKeyDown(stream io.Reader, eventCh chan<- Button) {\n\tgo func(stream io.Reader, eventCh chan<- Button) {\n\t\tbuffer := make([]byte, 100)\n\n\t\tfor {\n\t\t\tcnt, err := stream.Read(buffer)\n\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tif cnt == 1 && buffer[0] == 0x1b {\n\t\t\t\teventCh <- Esc\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif buffer[0] == 0x1b && buffer[1] == '[' {\n\t\t\t\tswitch buffer[2] {\n\t\t\t\tcase 'A':\n\t\t\t\t\teventCh <- UpArrow\n\t\t\t\tcase 'B':\n\t\t\t\t\teventCh <- DownArrow\n\t\t\t\tcase 'C':\n\t\t\t\t\teventCh <- RightArrow\n\t\t\t\tcase 'D':\n\t\t\t\t\teventCh <- LeftArrow\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}(stream, eventCh)\n}", "title": "" }, { "docid": "841f52b81bff36012fa3fd4c7f41519a", "score": "0.5104676", "text": "func goditorActionKeypress(reader io.ByteReader) (int, error) {\n\tchar, err := goditorReadKey(reader)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\t// mapping Ctrl + Q(17) to quit is\n\tswitch char {\n\tcase quit:\n\t\treturn 1, nil\n\tcase arrowUp:\n\t\t// Prevent moving the cursor values to go into the negatives\n\t\tif goditorState.curRow != 1 {\n\t\t\tgoditorState.curRow--\n\t\t}\n\t\tgoditorMoveCursor()\n\tcase arrowDown:\n\t\tif goditorState.curRow != goditorState.winsizeStruct.Row-1 {\n\t\t\tgoditorState.curRow++\n\t\t}\n\t\tgoditorMoveCursor()\n\tcase arrowLeft:\n\t\tif goditorState.curCol != 1 {\n\t\t\tgoditorState.curCol--\n\t\t}\n\t\tgoditorMoveCursor()\n\tcase arrowRight:\n\t\tif goditorState.curCol != goditorState.winsizeStruct.Col-1 {\n\t\t\tgoditorState.curCol++\n\t\t}\n\t\tgoditorMoveCursor()\n\tdefault:\n\t\tgoditorInsertChar(char)\n\t}\n\n\treturn 0, nil\n}", "title": "" }, { "docid": "d330189346f34b958cce88a8543fbb5c", "score": "0.50820124", "text": "func (v *ThreadView) HandleKey(ui *UI, key interface{}, mod gocui.Modifier, lineNumber int) error {\n\t// Handle enter\n\tif k, ok := key.(gocui.Key); ok && k == gocui.KeyEnter {\n\t\tcount := 0\n\t\tfor k := range v.messages {\n\t\t\t// Expand or contract email\n\t\t\tif lineNumber == count {\n\t\t\t\tv.messages[k].ToggleExpanded()\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcount += v.messages[k].lineCount\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "d09fcd7dfa39344c00122566f149da16", "score": "0.5075615", "text": "func Kbd(code key.Code, op Op) {\n\tnativeKeyCode := nativeKeyCode(code)\n\tif nativeKeyCode <= 0 {\n\t\treturn\n\t}\n\tif op != Up {\n\t\tsetKeyboardStatus(nativeKeyCode, true)\n\t}\n\tif op != Down {\n\t\tsetKeyboardStatus(nativeKeyCode, false)\n\t}\n}", "title": "" }, { "docid": "d8f1f7d31a3d4a0046b3723bbe018822", "score": "0.5072081", "text": "func controlDirection() {\nLOOP:\n\tfor { // 函数只写入lead,外部只读取lead,无需设锁\n\t\tswitch ev := termbox.PollEvent(); ev.Type {\n\t\tcase termbox.EventKey:\n\t\t\tswitch ev.Key {\n\t\t\tcase termbox.KeyArrowUp:\n\t\t\t\tdirection = 'U'\n\t\t\tcase termbox.KeyArrowDown:\n\t\t\t\tdirection = 'D'\n\t\t\tcase termbox.KeyArrowLeft:\n\t\t\t\tdirection = 'L'\n\t\t\tcase termbox.KeyArrowRight:\n\t\t\t\tdirection = 'R'\n\t\t\tdefault:\n\t\t\t\tbreak LOOP\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "d1792f67a9bcdd2c267344266b39e479", "score": "0.50291294", "text": "func OnKeyUp(h * Hanao, event * sdl.Event) {\n kevent := event.Keyboard()\n text := EventToText(kevent)\n fmt.Println(\"keyup\", kevent, \"text:\", text)\n // text := \"\" // CleanupUnicode(kevent)\n // text = cleanup_unicode(event)\n // state = keyboard.state(event.sym)\n // h.sendToWidgets(KeyUp, kevent.Keysym, kevent.Keysym.Mod, text) \n // keyboard.release(event.sym)\n}", "title": "" }, { "docid": "20c867886101cf2cfbc97a800c779178", "score": "0.5025374", "text": "func (scr Sdl2) handleEvents() {\n\t// Handle keyboard states\n\tkeysStates := sdl.GetKeyboardState()\n\tfor scancode, pressed := range keysStates {\n\t\tif pressed == 1 {\n\t\t\tscr.keyHandler(int(sdl.GetKeyFromScancode(sdl.Scancode(scancode))), true)\n\t\t}\n\t}\n\n\t// Sdl-specific events\n\tfor event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {\n\t\tswitch t := event.(type) {\n\t\tcase *sdl.QuitEvent: // Window close\n\t\t\tos.Exit(0) // Gracefully exit the program\n\t\tcase *sdl.KeyboardEvent: // Esc key pressed\n\t\t\tif t.Keysym.Sym == sdl.K_ESCAPE {\n\t\t\t\tos.Exit(0) // Gracefully exit the program\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "1e4441c815d59f9471932a9816b9fd36", "score": "0.49928242", "text": "func (g *Game) Listen() {\n\tinput := g.Input.Input()\n\tover := false\n\tfor !over {\n\t\tselect {\n\t\tcase key := <-input:\n\t\t\tswitch key {\n\t\t\tcase Left:\n\t\t\t\tg.Transform(g.cur.Move(0, -1))\n\t\t\tcase Right:\n\t\t\t\tg.Transform(g.cur.Move(0, 1))\n\t\t\tcase Down:\n\t\t\t\tg.Down()\n\t\t\tcase TurnRight:\n\t\t\t\tg.Transform(g.cur.Rotate())\n\t\t\t}\n\t\tcase <-g.ticker.C:\n\t\t\tg.Down()\n\t\tcase score := <-g.score:\n\t\t\toldLevel := g.Level\n\t\t\tg.Score += score\n\t\t\tg.Level = g.Score / 1\n\t\t\tg.Display.UpdateScore(g.Score, g.Level)\n\t\t\tif g.Level > oldLevel {\n\t\t\t\tg.ticker.Stop()\n\t\t\t\tg.ticker = NewTicker(time.Duration(float64(g.ticker.Duration) * 0.95))\n\t\t\t}\n\t\tcase <-g.over:\n\t\t\tover = true\n\t\t}\n\t}\n}", "title": "" }, { "docid": "afd464cb5db0e458329e99c021374d10", "score": "0.4990645", "text": "func (player *Creature) HandleInput(action controls.Action, world *World) bool {\n\tnewX := player.X\n\tnewY := player.Y\n\n\tif player.CompletedExternalAction {\n\t\tplayer.CompletedExternalAction = false\n\t\treturn true\n\t}\n\n\tswitch action {\n\tcase controls.Ascend:\n\t\ttile := world.CurrentLevel().GetTile(player.X, player.Y)\n\t\tif tile.TileKind == UpStair {\n\t\t\tif stair, ok := world.CurrentLevel().getStair(player.X, player.Y); ok {\n\t\t\t\tm.Broadcast(m.M{ID: PlayerFloorChange, Data: PlayerFloorChangeMessage{\n\t\t\t\t\tStair: stair,\n\t\t\t\t}})\n\t\t\t\treturn true\n\t\t\t} else {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\tcase controls.Descend:\n\t\ttile := world.CurrentLevel().GetTile(player.X, player.Y)\n\t\tif tile.TileKind == DownStair {\n\t\t\tif stair, ok := world.CurrentLevel().getStair(player.X, player.Y); ok {\n\t\t\t\tm.Broadcast(m.M{ID: PlayerFloorChange, Data: PlayerFloorChangeMessage{\n\t\t\t\t\tStair: stair,\n\t\t\t\t}})\n\t\t\t\treturn true\n\t\t\t} else {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\tcase controls.Help:\n\t\tm.Broadcast(m.M{ID: ShowMenu, Data: ShowMenuMessage{Menu: NewHelpPop(2, 2, 50, world.Window.Rows-4)}})\n\t\treturn false\n\tcase controls.Left:\n\t\tnewX = player.X - 1\n\tcase controls.Down:\n\t\tnewY = player.Y + 1\n\tcase controls.Up:\n\t\tnewY = player.Y - 1\n\tcase controls.Right:\n\t\tnewX = player.X + 1\n\tcase controls.DownLeft:\n\t\tnewX, newY = player.X-1, player.Y+1\n\tcase controls.DownRight:\n\t\tnewX, newY = player.X+1, player.Y+1\n\tcase controls.UpLeft:\n\t\tnewX, newY = player.X-1, player.Y-1\n\tcase controls.UpRight:\n\t\tnewX, newY = player.X+1, player.Y-1\n\tcase controls.Wait:\n\t\tbreak\n\tcase controls.Get:\n\t\treturn player.PickupItem(world)\n\tcase controls.Inventory:\n\t\tmenu := &InventoryPop{World: world, PopMenu: PopMenu{X: 2, Y: 2, W: 30, H: 30}, Inventory: player.Inventory}\n\t\tm.Broadcast(m.M{ID: ShowMenu, Data: ShowMenuMessage{Menu: menu}})\n\t\treturn false\n\tcase controls.Warp:\n\t\tif player.ST.Current >= 1 {\n\t\t\tmenu := NewWarpPop(world)\n\t\t\tm.Broadcast(m.M{ID: ShowMenu, Data: ShowMenuMessage{Menu: menu}})\n\t\t} else {\n\t\t\tgl.Append(\"Costs at least 1 ST to Warp.\")\n\t\t}\n\t\treturn false\n\tcase controls.Rest:\n\t\tif player.Safe(world) {\n\t\t\tplayer.Resting = true\n\t\t}\n\tcase controls.Messages:\n\t\tm.Broadcast(m.M{ID: ShowFullGameLog})\n\t\treturn false\n\tcase controls.Quit:\n\t\tworld.QuitGame = true\n\t\tworld.GameOver = true\n\t\treturn false\n\tdefault:\n\t\treturn false\n\t}\n\n\tif newX != player.X || newY != player.Y {\n\t\tresult, data := player.TryMove(newX, newY, world)\n\t\tswitch result {\n\t\tcase MoveIsInvalid:\n\t\t\treturn false\n\t\tcase MoveIsSuccess:\n\t\t\toldX := player.X\n\t\t\toldY := player.Y\n\t\t\tplayer.X = newX\n\t\t\tplayer.Y = newY\n\t\t\tm.Broadcast(m.M{ID: MoveCreature, Data: MoveCreatureMessage{Creature: player, OldX: oldX, OldY: oldY, NewX: newX, NewY: newY}})\n\t\tcase MoveIsEnemy:\n\t\t\tif data, ok := data.(MoveEnemy); ok {\n\t\t\t\tm.Broadcast(m.M{ID: AttackCreature, Data: AttackCreatureMessage{\n\t\t\t\t\tAttacker: data.Attacker,\n\t\t\t\t\tDefender: data.Defender,\n\t\t\t\t}})\n\t\t\t}\n\t\tcase MoveIsVictory:\n\t\t\tm.Broadcast(m.M{ID: GameWon})\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "title": "" }, { "docid": "811ca43ea7b9574f46ce43b5543e047c", "score": "0.49872774", "text": "func (b *Buffer) processActionKey(key int) bool {\n\tif shiftDown {\n\t\tswitch key {\n\t\tcase strife.KEY_LEFT:\n\t\t\tfallthrough\n\t\tcase strife.KEY_RIGHT:\n\t\t\tfallthrough\n\t\tcase strife.KEY_DOWN:\n\t\t\tfallthrough\n\t\tcase strife.KEY_UP:\n\t\t\treturn b.processSelection(key)\n\t\t}\n\t}\n\n\tswitch key {\n\tcase strife.KEY_CAPSLOCK:\n\t\tcapsLockDown = !capsLockDown\n\n\tcase strife.KEY_ESCAPE:\n\t\treturn true\n\n\tcase strife.KEY_RETURN:\n\t\tif superDown {\n\t\t\t// in sublime this goes\n\t\t\t// into the next block\n\t\t\t// nicely indented!\n\t\t}\n\n\t\t// HACK FIXME\n\t\tb.modified = true\n\n\t\t// FIXME\n\t\t// clear the last runes\n\t\tb.autoComplete.lastRunes = []rune{}\n\n\t\t// START OF LINE:\n\t\tif b.curs.x == 0 {\n\t\t\t// we're at the start of a line, so we want to\n\t\t\t// shift the line down and insert an empty line\n\t\t\t// above it!\n\t\t\tb.table.Lines = append(b.table.Lines, piecetable.NewLine(\"\", b.table)) // grow\n\t\t\tcopy(b.table.Lines[b.curs.y+1:], b.table.Lines[b.curs.y:]) // shift\n\t\t\tb.table.Lines[b.curs.y] = piecetable.NewLine(\"\", b.table) // set\n\t\t\tb.moveDown()\n\t\t\treturn true\n\t\t}\n\n\t\tinitialX := b.curs.x\n\t\tprevLineLen := b.table.Lines[b.curs.y].Len()\n\n\t\t// END OF LINE:\n\t\tif initialX == prevLineLen {\n\t\t\tb.appendStringAt(\"\", b.curs.y+1)\n\t\t\tb.moveDown()\n\t\t\tb.moveToStartOfLine()\n\t\t\treturn true\n\t\t}\n\n\t\t// we're not at the end of the line, but we're not at\n\t\t// the start, i.e. we're SPLITTING the line\n\t\tleft := b.table.Lines[b.curs.y].String()\n\t\trightPart := left[initialX:]\n\n\t\tfor i := 0; i < len(rightPart); i++ {\n\t\t\t// TODO POP in piecetable?\n\t\t\tb.table.Delete(b.curs.y, len(left)-i)\n\t\t}\n\n\t\tb.appendStringAt(rightPart, b.curs.y+1)\n\t\tb.moveDown()\n\t\tb.moveToStartOfLine()\n\n\tcase strife.KEY_BACKSPACE:\n\t\t// HACK FIXME\n\t\tb.modified = true\n\n\t\tif superDown {\n\t\t\tb.deleteBeforeCursor()\n\t\t} else {\n\t\t\tb.deletePrev()\n\t\t}\n\n\tcase strife.KEY_RIGHT:\n\t\tcurrLineLength := b.table.Lines[b.curs.y].Len()\n\n\t\tif superDown {\n\t\t\tfor b.curs.x < currLineLength {\n\t\t\t\tb.moveLeft()\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\n\t\t// FIXME this is weird!\n\t\t// this will move to the next blank or underscore\n\t\t// character\n\t\tif altDown {\n\t\t\tline := b.table.Lines[b.curs.y]\n\n\t\t\ti := b.curs.x + 1 // ?\n\n\t\t\tfor i < len(line.String())-1 {\n\t\t\t\tcurr := b.table.Index(b.curs.y, i)\n\n\t\t\t\tswitch curr {\n\t\t\t\tcase ' ':\n\t\t\t\t\tfallthrough\n\t\t\t\tcase '\\n':\n\t\t\t\t\tfallthrough\n\t\t\t\tcase '_':\n\t\t\t\t\tgoto rightWordOuter\n\t\t\t\t}\n\n\t\t\t\ti = i + 1\n\t\t\t}\n\n\t\trightWordOuter:\n\n\t\t\tdist := i - b.curs.x\n\t\t\tfor j := 0; j < dist; j++ {\n\t\t\t\tb.moveRight()\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\n\t\tb.moveRight()\n\tcase strife.KEY_LEFT:\n\t\tif superDown {\n\t\t\t// TODO go to the nearest \\t\n\t\t\t// if no \\t (i.e. start of line) go to\n\t\t\t// the start of the line!\n\t\t\tb.curs.gotoStart()\n\t\t} else if altDown {\n\t\t\ti := b.curs.x\n\t\t\tfor i > 0 {\n\t\t\t\tcurrChar := b.table.Index(b.curs.y, i)\n\n\t\t\t\tswitch currChar {\n\t\t\t\tcase ' ':\n\t\t\t\t\tfallthrough\n\t\t\t\tcase '\\n':\n\t\t\t\t\tfallthrough\n\t\t\t\tcase '_':\n\t\t\t\t\ti = i - 1\n\t\t\t\t\tgoto outer\n\t\t\t\tdefault:\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\ti = i - 1\n\t\t\t}\n\n\t\touter:\n\n\t\t\tstart := b.curs.x\n\t\t\tfor j := 0; j < start-i; j++ {\n\t\t\t\tb.moveLeft()\n\t\t\t}\n\n\t\t\tif start == 0 {\n\t\t\t\tb.moveUp()\n\t\t\t\tb.moveToEndOfLine()\n\t\t\t}\n\n\t\t\tbreak\n\t\t}\n\n\t\tb.moveLeft()\n\tcase strife.KEY_UP:\n\t\tif altDown {\n\t\t\treturn b.swapLineUp()\n\t\t}\n\n\t\tif superDown {\n\t\t\t// go to the start of the file\n\t\t}\n\n\t\tb.moveUp()\n\n\tcase strife.KEY_DOWN:\n\t\tif altDown {\n\t\t\treturn b.swapLineDown()\n\t\t}\n\n\t\tif superDown {\n\t\t\t// go to the end of the file\n\t\t}\n\n\t\tb.moveDown()\n\n\tcase strife.KEY_TAB:\n\t\t// HACK FIXME\n\t\tb.modified = true\n\n\t\tif b.cfg.Editor.TabsAreSpaces {\n\t\t\t// make an empty rune array of TAB_SIZE, cast to string\n\t\t\t// and insert it.\n\t\t\ttab := b.makeTab()\n\t\t\tb.table.Insert(tab, b.curs.y, b.curs.x)\n\t\t\tfor i := 0; i < len(tab); i++ {\n\t\t\t\tb.moveRight()\n\t\t\t}\n\t\t} else {\n\t\t\tb.table.Insert(string('\\t'), b.curs.y, b.curs.x)\n\t\t\tb.moveRight()\n\t\t}\n\n\tcase strife.KEY_END:\n\t\tcurrLine := b.table.Lines[b.curs.y]\n\t\tif b.curs.x < currLine.Len() {\n\t\t\tdistToMove := currLine.Len() - b.curs.x\n\t\t\tfor i := 0; i < distToMove; i++ {\n\t\t\t\tb.moveRight()\n\t\t\t}\n\t\t}\n\n\tcase strife.KEY_HOME:\n\t\tif b.curs.x > 0 {\n\t\t\tb.moveToStartOfLine()\n\t\t}\n\n\t\t// TODO remove since this is handled in the keymap!\n\tcase strife.KEY_PAGEUP:\n\t\tb.scrollUp(DefaultScrollAmount)\n\t\tfor i := 0; i < DefaultScrollAmount; i++ {\n\t\t\tb.moveUp()\n\t\t}\n\tcase strife.KEY_PAGEDOWN:\n\t\tb.scrollDown(DefaultScrollAmount)\n\t\tfor i := 0; i < DefaultScrollAmount; i++ {\n\t\t\tb.moveDown()\n\t\t}\n\n\tcase strife.KEY_DELETE:\n\t\tb.deleteNext()\n\n\tcase strife.KEY_LGUI:\n\t\tfallthrough\n\tcase strife.KEY_RGUI:\n\t\tfallthrough\n\n\tcase strife.KEY_LALT:\n\t\tfallthrough\n\tcase strife.KEY_RALT:\n\t\tfallthrough\n\n\tcase strife.KEY_LCTRL:\n\t\tfallthrough\n\tcase strife.KEY_RCTRL:\n\t\tfallthrough\n\n\tcase strife.KEY_LSHIFT:\n\t\tfallthrough\n\tcase strife.KEY_RSHIFT:\n\t\treturn true\n\n\tdefault:\n\t\treturn false\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "5e82d93c4c4e79c02bf89b4900aa87ce", "score": "0.49859986", "text": "func (m *Model) handleJumpToTopKeyPress(cmds *[]tea.Cmd) {\n\tif !m.showCommandInput && m.primaryPane.GetIsActive() && m.dirTree.GetTotalFiles() > 1 {\n\t\tm.dirTree.GotoTop()\n\t\tm.primaryPane.GotoTop()\n\t\tm.primaryPane.SetContent(m.dirTree.View())\n\t\tm.statusBar.SetDirectoryItemSize(\"\")\n\n\t\tselectedFile, err := m.dirTree.GetSelectedFile()\n\t\tif err != nil {\n\t\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t\t}\n\n\t\t*cmds = append(*cmds, m.getDirectoryItemSizeCmd(selectedFile.Name()))\n\t}\n\n\tif !m.showCommandInput && m.secondaryPane.GetIsActive() {\n\t\tm.secondaryPane.GotoTop()\n\t}\n}", "title": "" }, { "docid": "9e8a316c1af70b2c0857adac2e50aad8", "score": "0.49660382", "text": "func (t *terminal) ctrlK() {\n\tif t.position >= len(t.line) {\n\t\tdoBeep()\n\t} else {\n\t\tt.line = t.line[:t.position]\n\t\tt.needRefresh = true\n\t}\n}", "title": "" }, { "docid": "e684b8de9c3eb505f36dca100ca8f6cc", "score": "0.49619418", "text": "func (s *Session) HandleUp() {\n\tif s.Player.Direction == player.PlayerDown {\n\t\treturn\n\t}\n\ts.Player.Direction = player.PlayerUp\n\ts.Player.Marker = config.PlayerUpRune\n\ts.Player.BaseSpeed = config.VerticalPlayerSpeed\n\ts.didAction()\n}", "title": "" }, { "docid": "064f33c42ee141845ee27f4ef791a33f", "score": "0.49613047", "text": "func (g *Grid) InputHandler() func(event *tcell.EventKey, setFocus func(p Primitive)) {\n\treturn g.WrapInputHandler(func(event *tcell.EventKey, setFocus func(p Primitive)) {\n\t\tif !g.hasFocus {\n\t\t\t// Pass event on to child primitive.\n\t\t\tfor _, item := range g.items {\n\t\t\t\tif item != nil && item.Item.HasFocus() {\n\t\t\t\t\tif handler := item.Item.InputHandler(); handler != nil {\n\t\t\t\t\t\thandler(event, setFocus)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\t// Process our own key events if we have direct focus.\n\t\tswitch event.Key() {\n\t\tcase tcell.KeyRune:\n\t\t\tswitch event.Rune() {\n\t\t\tcase 'g':\n\t\t\t\tg.rowOffset, g.columnOffset = 0, 0\n\t\t\tcase 'G':\n\t\t\t\tg.rowOffset = math.MaxInt32\n\t\t\tcase 'j':\n\t\t\t\tg.rowOffset++\n\t\t\tcase 'k':\n\t\t\t\tg.rowOffset--\n\t\t\tcase 'h':\n\t\t\t\tg.columnOffset--\n\t\t\tcase 'l':\n\t\t\t\tg.columnOffset++\n\t\t\t}\n\t\tcase tcell.KeyHome:\n\t\t\tg.rowOffset, g.columnOffset = 0, 0\n\t\tcase tcell.KeyEnd:\n\t\t\tg.rowOffset = math.MaxInt32\n\t\tcase tcell.KeyUp:\n\t\t\tg.rowOffset--\n\t\tcase tcell.KeyDown:\n\t\t\tg.rowOffset++\n\t\tcase tcell.KeyLeft:\n\t\t\tg.columnOffset--\n\t\tcase tcell.KeyRight:\n\t\t\tg.columnOffset++\n\t\t}\n\t})\n}", "title": "" }, { "docid": "8ce1a000e2f4369b5188d55be5dd021c", "score": "0.49118888", "text": "func (player *Player) HandleInput(command string) {\n\tgo func () {\n\t\taction := strings.Split(command, \" \")\n\t\tif action[0] == \"сказать\" {\n\t\t\tplayer.SayToAll(action[1:]...)\n\t\t} else if action[0] == \"сказать_игроку\" {\n\t\t\tplayer.SayToPlayer(action[1:]...)\n\t\t} else {\n\t\t\tplayer.outputChannel <- player.PerformAction(action[0], action[1:]...)\n\t\t}\n\t}()\n}", "title": "" }, { "docid": "af6e15192ae5d81c8da9ffef3d0b905d", "score": "0.49117365", "text": "func emulateKeyPress(keys string) {\n\tkk := strings.Split(keys, \"-\")\n\tfor i, k := range kk {\n\t\tkc, err := strconv.Atoi(k)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"%s is not a valid keycode: %s\", k, err)\n\t\t}\n\n\t\tif i+1 < len(kk) {\n\t\t\tkeyboard.KeyDown(kc)\n\t\t\tdefer keyboard.KeyUp(kc)\n\t\t} else {\n\t\t\tkeyboard.KeyPress(kc)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "c700c182cbab13ab3f21c69bf89812ee", "score": "0.49014542", "text": "func emulateKeyPresses(keys string) {\n\tfor _, kp := range strings.Split(keys, \"/\") {\n\t\temulateKeyPressWithDelay(kp)\n\t}\n}", "title": "" }, { "docid": "84390e8e9625c46b89aa51a04e074989", "score": "0.4900401", "text": "func (l *ListBox) InputHandler() func(event *tcell.EventKey, setFocus func(p Primitive)) {\n\t_, _, _, height := l.GetInnerRect()\n\treturn l.WrapInputHandler(func(event *tcell.EventKey, setFocus func(p Primitive)) {\n\t\tpreviousItem := l.currentItem\n\n\t\tswitch key := event.Key(); key {\n\t\tcase tcell.KeyTab, tcell.KeyBacktab, tcell.KeyEnter: // We're done.\n\t\t\tif l.done != nil {\n\t\t\t\tl.done(key)\n\t\t\t}\n\t\t\tif l.finished != nil {\n\t\t\t\tl.finished(key)\n\t\t\t}\n\t\tcase tcell.KeyDown, tcell.KeyRight:\n\t\t\tl.currentItem++\n\t\t\tif l.currentItem >= len(l.items) {\n\t\t\t\tl.currentItem = 0\n\t\t\t\tl.offset = 0\n\t\t\t}\n\t\tcase tcell.KeyUp, tcell.KeyLeft:\n\t\t\tl.currentItem--\n\t\t\tif l.currentItem < 0 {\n\t\t\t\tl.currentItem = len(l.items) - 1\n\t\t\t}\n\t\tcase tcell.KeyHome:\n\t\t\tl.currentItem = 0\n\t\tcase tcell.KeyEnd:\n\t\t\tl.currentItem = len(l.items) - 1\n\t\tcase tcell.KeyPgDn:\n\t\t\tif l.currentItem < l.offset+height-1 {\n\t\t\t\tl.currentItem = l.offset + height - 1\n\t\t\t} else {\n\t\t\t\tl.currentItem += height\n\t\t\t}\n\t\t\tif l.currentItem >= len(l.items) {\n\t\t\t\tl.currentItem = 0\n\t\t\t\tl.offset = 0\n\t\t\t}\n\t\tcase tcell.KeyPgUp:\n\t\t\tif l.currentItem > l.offset {\n\t\t\t\tl.currentItem = l.offset\n\t\t\t} else {\n\t\t\t\tl.currentItem -= height\n\t\t\t\tl.offset = l.currentItem\n\t\t\t}\n\t\tcase tcell.KeyEscape:\n\t\t\tif l.done != nil {\n\t\t\t\tl.done(key)\n\t\t\t}\n\t\t\tif l.finished != nil {\n\t\t\t\tl.finished(key)\n\t\t\t}\n\t\tcase tcell.KeyRune:\n\t\t\tch := event.Rune()\n\t\t\tif ch != ' ' {\n\t\t\t\t// It's not a space bar. Is it a shortcut?\n\t\t\t\tvar found bool\n\t\t\t\tfor index, item := range l.items {\n\t\t\t\t\tif item.Shortcut == ch {\n\t\t\t\t\t\t// We have a shortcut.\n\t\t\t\t\t\tfound = true\n\t\t\t\t\t\tl.currentItem = index\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif !found {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\titem := l.items[l.currentItem]\n\t\t\tif item.Selected != nil {\n\t\t\t\titem.Selected()\n\t\t\t}\n\t\t\tif l.selected != nil {\n\t\t\t\tl.selected(l.currentItem, item.MainText, item.SecondaryText, item.Shortcut)\n\t\t\t}\n\t\t}\n\n\t\tif l.currentItem < 0 {\n\t\t\tl.currentItem = len(l.items) - 1\n\t\t} else if l.currentItem >= len(l.items) {\n\t\t\tl.currentItem = 0\n\t\t}\n\n\t\tif l.currentItem != previousItem && l.currentItem < len(l.items) && l.changed != nil {\n\t\t\titem := l.items[l.currentItem]\n\t\t\tl.changed(l.currentItem, item.MainText, item.SecondaryText, item.Shortcut)\n\t\t}\n\t})\n}", "title": "" }, { "docid": "4262852e1751088f2652110ef53bb85d", "score": "0.4896021", "text": "func (scr *Sdl2) SetKeyboardHandler(call func(int, bool)) {\n\tscr.keyHandler = call\n}", "title": "" }, { "docid": "9c3fa042391fb272733eb6ce65ae075f", "score": "0.48919404", "text": "func (m *Model) handleShowOnlyDirectoriesKeyPress(cmds *[]tea.Cmd) {\n\tif !m.showCommandInput && m.primaryPane.GetIsActive() {\n\t\tm.showDirectoriesOnly = !m.showDirectoriesOnly\n\t\tm.showFilesOnly = false\n\n\t\tif m.showDirectoriesOnly {\n\t\t\t*cmds = append(*cmds, m.getDirectoryListingByTypeCmd(dirfs.DirectoriesListingType, m.showHidden))\n\t\t}\n\n\t\t*cmds = append(*cmds, m.updateDirectoryListingCmd(dirfs.CurrentDirectory))\n\t}\n}", "title": "" }, { "docid": "ac088526d79e62bce5e6677d7fc3ed15", "score": "0.48914802", "text": "func (h *handler) Update() {\n\th.previousButtons = h.buttons\n\th.buttons = h.buttonsBuffer\n\th.buttonsBuffer = make(map[glfw.MouseButton]bool)\n\tfor button, pressed := range h.buttons {\n\t\tif pressed {\n\t\t\th.buttonsBuffer[button] = true\n\t\t}\n\t}\n\n\th.previousPosition = h.position\n\th.position = h.positionBuffer\n\n\th.previousScroll = h.scroll\n\th.scroll = h.scrollBuffer\n}", "title": "" }, { "docid": "dfb522fb0f996d49554e680e612f65ad", "score": "0.48889142", "text": "func (p *DispatchKeyEventParams) Do(ctx context.Context) (err error) {\n\treturn cdp.Execute(ctx, CommandDispatchKeyEvent, p, nil)\n}", "title": "" }, { "docid": "fda0625078e8a0e351cd117be0b11eae", "score": "0.4888879", "text": "func keyPress() { \n type keyboardInput struct { \n wVk uint16 \n wScan uint16 \n dwFlags uint32 \n time uint32 \n dwExtraInfo uint64 \n } \n\n type input struct { \n inputType uint32 \n ki keyboardInput \n padding uint64 \n } \n \n var i input \n i.inputType = 1 //INPUTKEYBOARD \n i.ki.wVk = 0x12 // virtual key code for Alt \n lop, _, err := sendInputProc.Call( \n uintptr(1),\n uintptr(unsafe.Pointer(&i)),\n uintptr(unsafe.Sizeof(i)), \n ) \n\t//log.Printf(\"KeyBoard: %v MSG: %v\", lop, err) \n\t\tlog.Printf(\"%v %v\", lop, err)\n }", "title": "" }, { "docid": "6bc9d074aa4be9ea075a1ba78f1a56a1", "score": "0.4888155", "text": "func eventLoop(pane *Pane, status string, font *ttf.Font, win *sdl.Window) {\n\tuserEventType = sdl.RegisterEvents(1)\n\trc := &RenderContext{pane, edit.NewBuffer(), pane.Buffer, status, font,\n\t\twin, nil}\n\trc.Input.Mark(edit.Index{1, 0}, selMark, insMark)\n\trender(rc)\n\tw, h := win.GetSize()\n\twin.SetSize(w, h)\n\tclickCount := 0\n\tlastClick := time.Now()\n\tvar rightClickIndex edit.Index\n\thistories := make(map[string]*history)\n\n\tfor {\n\t\t// get current marks to see if they change based on the event\n\t\tprevSel := rc.Pane.IndexFromMark(selMark)\n\t\tprevIns := rc.Pane.IndexFromMark(insMark)\n\n\t\tswitch event := sdl.WaitEvent().(type) {\n\t\tcase *sdl.KeyDownEvent:\n\t\t\tif rc.Focus == rc.Pane.Buffer {\n\t\t\t\trc.Status = rc.Pane.Title\n\t\t\t}\n\t\t\trecognized := true\n\t\t\tswitch event.Keysym.Sym {\n\t\t\tcase sdl.K_BACKSPACE:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\tend := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\tbegin := shiftIndexByWord(rc.Focus, end, -1)\n\t\t\t\t\trc.Focus.Delete(begin, end)\n\t\t\t\t} else {\n\t\t\t\t\tindex := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\tif sel := rc.Focus.IndexFromMark(selMark); sel != index {\n\t\t\t\t\t\trc.Focus.Delete(order(sel, index))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdeleteCharOrTab(rc.Focus, index, -1)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase sdl.K_DELETE:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\tbegin := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\tend := shiftIndexByWord(rc.Focus, begin, 1)\n\t\t\t\t\trc.Focus.Delete(begin, end)\n\t\t\t\t} else {\n\t\t\t\t\tindex := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\tif sel := rc.Focus.IndexFromMark(selMark); sel != index {\n\t\t\t\t\t\trc.Focus.Delete(order(sel, index))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdeleteCharOrTab(rc.Focus, index, 1)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif rc.Focus == rc.Pane.Buffer {\n\t\t\t\t\tseeMark(rc.Pane.Buffer, insMark, rc.Pane.Rows)\n\t\t\t\t}\n\t\t\tcase sdl.K_DOWN:\n\t\t\t\tif rc.Focus == rc.Pane.Buffer {\n\t\t\t\t\tindex := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\tcol, row := rc.Focus.CoordsFromIndex(index)\n\t\t\t\t\trc.Focus.Mark(rc.Focus.IndexFromCoords(col, row+1),\n\t\t\t\t\t\tinsMark)\n\t\t\t\t\tif event.Keysym.Mod&sdl.KMOD_SHIFT == 0 {\n\t\t\t\t\t\trc.Focus.Mark(rc.Focus.IndexFromMark(insMark),\n\t\t\t\t\t\t\tselMark)\n\t\t\t\t\t}\n\t\t\t\t\trc.Pane.Separate()\n\t\t\t\t} else {\n\t\t\t\t\tinput := getHistory(histories, rc.Status).next()\n\t\t\t\t\trc.Input.Delete(edit.Index{1, 0}, rc.Input.End())\n\t\t\t\t\trc.Input.Insert(edit.Index{1, 0}, input)\n\t\t\t\t}\n\t\t\tcase sdl.K_ESCAPE:\n\t\t\t\tif rc.Focus == rc.Input {\n\t\t\t\t\trc.Status = rc.Pane.Title\n\t\t\t\t\trc.Focus = rc.Pane.Buffer\n\t\t\t\t}\n\t\t\tcase sdl.K_END:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\trc.Focus.Mark(rc.Focus.End(), insMark)\n\t\t\t\t} else {\n\t\t\t\t\tindex := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\trc.Focus.Mark(edit.Index{index.Line, 1 << 30}, insMark)\n\t\t\t\t}\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_SHIFT == 0 {\n\t\t\t\t\trc.Focus.Mark(rc.Focus.IndexFromMark(insMark), selMark)\n\t\t\t\t}\n\t\t\t\tif rc.Focus == rc.Pane.Buffer {\n\t\t\t\t\trc.Pane.Separate()\n\t\t\t\t}\n\t\t\tcase sdl.K_LEFT:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\tindex := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\tindex = shiftIndexByWord(rc.Focus, index, -1)\n\t\t\t\t\trc.Focus.Mark(index, insMark)\n\t\t\t\t} else {\n\t\t\t\t\tindex := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\trc.Focus.Mark(rc.Focus.ShiftIndex(index, -1), insMark)\n\t\t\t\t}\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_SHIFT == 0 {\n\t\t\t\t\trc.Focus.Mark(rc.Focus.IndexFromMark(insMark), selMark)\n\t\t\t\t}\n\t\t\t\tif rc.Focus == rc.Pane.Buffer {\n\t\t\t\t\trc.Pane.Separate()\n\t\t\t\t}\n\t\t\tcase sdl.K_HOME:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\trc.Focus.Mark(edit.Index{1, 0}, insMark)\n\t\t\t\t} else {\n\t\t\t\t\tindex := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\trc.Focus.Mark(edit.Index{index.Line, 0}, insMark)\n\t\t\t\t}\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_SHIFT == 0 {\n\t\t\t\t\trc.Focus.Mark(rc.Focus.IndexFromMark(insMark), selMark)\n\t\t\t\t}\n\t\t\t\tif rc.Focus == rc.Pane.Buffer {\n\t\t\t\t\trc.Pane.Separate()\n\t\t\t\t}\n\t\t\tcase sdl.K_PAGEDOWN:\n\t\t\t\tif rc.Focus == rc.Pane.Buffer {\n\t\t\t\t\tindex := rc.Pane.IndexFromMark(insMark)\n\t\t\t\t\tcol, row := rc.Pane.CoordsFromIndex(index)\n\t\t\t\t\trc.Pane.Mark(rc.Pane.IndexFromCoords(col,\n\t\t\t\t\t\trow+rc.Pane.Rows), insMark)\n\t\t\t\t\tif event.Keysym.Mod&sdl.KMOD_SHIFT == 0 {\n\t\t\t\t\t\trc.Focus.Mark(rc.Focus.IndexFromMark(insMark),\n\t\t\t\t\t\t\tselMark)\n\t\t\t\t\t}\n\t\t\t\t\trc.Pane.Separate()\n\t\t\t\t}\n\t\t\tcase sdl.K_PAGEUP:\n\t\t\t\tif rc.Focus == rc.Pane.Buffer {\n\t\t\t\t\tindex := rc.Pane.IndexFromMark(insMark)\n\t\t\t\t\tcol, row := rc.Pane.CoordsFromIndex(index)\n\t\t\t\t\trc.Pane.Mark(rc.Pane.IndexFromCoords(col,\n\t\t\t\t\t\trow-rc.Pane.Rows), insMark)\n\t\t\t\t\tif event.Keysym.Mod&sdl.KMOD_SHIFT == 0 {\n\t\t\t\t\t\trc.Focus.Mark(rc.Focus.IndexFromMark(insMark),\n\t\t\t\t\t\t\tselMark)\n\t\t\t\t\t}\n\t\t\t\t\trc.Pane.Separate()\n\t\t\t\t}\n\t\t\tcase sdl.K_RETURN:\n\t\t\t\tif rc.Focus == rc.Pane.Buffer {\n\t\t\t\t\ttextInput(rc.Focus, \"\\n\")\n\t\t\t\t} else {\n\t\t\t\t\tinput := rc.Input.Get(edit.Index{1, 0}, rc.Input.End())\n\t\t\t\t\tgetHistory(histories, rc.Status).appendString(input)\n\t\t\t\t\tif !rc.EnterInput() {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase sdl.K_RIGHT:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\tindex := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\tindex = shiftIndexByWord(rc.Focus, index, 1)\n\t\t\t\t\trc.Focus.Mark(index, insMark)\n\t\t\t\t} else {\n\t\t\t\t\tindex := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\trc.Focus.Mark(rc.Focus.ShiftIndex(index, 1), insMark)\n\t\t\t\t}\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_SHIFT == 0 {\n\t\t\t\t\trc.Focus.Mark(rc.Focus.IndexFromMark(insMark), selMark)\n\t\t\t\t}\n\t\t\t\tif rc.Focus == rc.Pane.Buffer {\n\t\t\t\t\trc.Pane.Separate()\n\t\t\t\t}\n\t\t\tcase sdl.K_TAB:\n\t\t\t\tif rc.Focus == rc.Pane.Buffer {\n\t\t\t\t\tsel := rc.Pane.IndexFromMark(selMark)\n\t\t\t\t\tins := rc.Pane.IndexFromMark(insMark)\n\t\t\t\t\tif sel == ins {\n\t\t\t\t\t\tchar := rc.Pane.Buffer.Get(\n\t\t\t\t\t\t\tedit.Index{ins.Line, ins.Char - 1}, ins)\n\t\t\t\t\t\tif char == \"\" || char == \" \" || char == \"\\t\" {\n\t\t\t\t\t\t\t// insert tab\n\t\t\t\t\t\t\tif expandtabFlag {\n\t\t\t\t\t\t\t\tfor i := 0; i < int(tabstopFlag); i++ {\n\t\t\t\t\t\t\t\t\ttextInput(rc.Focus, \" \")\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\ttextInput(rc.Focus, \"\\t\")\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// complete word\n\t\t\t\t\t\t\tselectWord(rc.Focus, ins)\n\t\t\t\t\t\t\tword := getSelection(rc.Focus)\n\t\t\t\t\t\t\tforward := event.Keysym.Mod&sdl.KMOD_SHIFT != 0\n\t\t\t\t\t\t\tcompletion := completeWord(rc.Focus, word, forward)\n\t\t\t\t\t\t\tif completion != \"\" {\n\t\t\t\t\t\t\t\ttextInput(rc.Focus, completion)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\trc.Status = \"No completions.\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trc.Focus.Mark(rc.Focus.IndexFromMark(insMark),\n\t\t\t\t\t\t\t\tselMark)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// indent/unindent selection\n\t\t\t\t\t\tsel, ins := order(sel, ins)\n\t\t\t\t\t\tunindent := event.Keysym.Mod&sdl.KMOD_SHIFT != 0\n\t\t\t\t\t\tindent(rc.Pane.Buffer, sel.Line, ins.Line, unindent)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tinput := rc.Input.Get(edit.Index{1, 0}, rc.Input.End())\n\t\t\t\t\tinput = expandVars(input)\n\t\t\t\t\tswitch rc.Status {\n\t\t\t\t\tcase cdPrompt:\n\t\t\t\t\t\tinput = completePath(input, true)\n\t\t\t\t\tcase openPrompt, openNewPrompt, saveAsPrompt:\n\t\t\t\t\t\tinput = completePath(input, false)\n\t\t\t\t\tcase pipePrompt, runPrompt:\n\t\t\t\t\t\ttokens := strings.Split(input, \" \")\n\t\t\t\t\t\tfor i, token := range tokens {\n\t\t\t\t\t\t\tif i == 0 {\n\t\t\t\t\t\t\t\ttokens[i] = completeCmd(token)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\ttokens[i] = completePath(token, false)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinput = strings.Join(tokens, \" \")\n\t\t\t\t\t}\n\t\t\t\t\trc.Input.Delete(edit.Index{1, 0}, rc.Input.End())\n\t\t\t\t\trc.Input.Insert(edit.Index{1, 0}, input)\n\t\t\t\t}\n\t\t\tcase sdl.K_UP:\n\t\t\t\tif rc.Focus == rc.Pane.Buffer {\n\t\t\t\t\tindex := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\tcol, row := rc.Focus.CoordsFromIndex(index)\n\t\t\t\t\trc.Focus.Mark(rc.Focus.IndexFromCoords(col, row-1),\n\t\t\t\t\t\tinsMark)\n\t\t\t\t\tif event.Keysym.Mod&sdl.KMOD_SHIFT == 0 {\n\t\t\t\t\t\trc.Focus.Mark(rc.Focus.IndexFromMark(insMark),\n\t\t\t\t\t\t\tselMark)\n\t\t\t\t\t}\n\t\t\t\t\trc.Pane.Separate()\n\t\t\t\t} else {\n\t\t\t\t\tinput := rc.Input.Get(edit.Index{1, 0}, rc.Input.End())\n\t\t\t\t\tinput = getHistory(histories, rc.Status).prev(input)\n\t\t\t\t\trc.Input.Delete(edit.Index{1, 0}, rc.Input.End())\n\t\t\t\t\trc.Input.Insert(edit.Index{1, 0}, input)\n\t\t\t\t}\n\t\t\tcase sdl.K_a:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\tindex := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\trc.Focus.Mark(edit.Index{index.Line, 0}, insMark)\n\t\t\t\t\tif event.Keysym.Mod&sdl.KMOD_SHIFT == 0 {\n\t\t\t\t\t\trc.Focus.Mark(rc.Focus.IndexFromMark(insMark),\n\t\t\t\t\t\t\tselMark)\n\t\t\t\t\t}\n\t\t\t\t\tif rc.Focus == rc.Pane.Buffer {\n\t\t\t\t\t\trc.Pane.Separate()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase sdl.K_c:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\tif rc.Focus == rc.Input {\n\t\t\t\t\t\trc.Status = rc.Pane.Title\n\t\t\t\t\t\trc.Focus = rc.Pane.Buffer\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsdl.SetClipboardText(getSelection(rc.Pane.Buffer))\n\t\t\t\t\t\trc.Status = \"Copied text.\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase sdl.K_d:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 &&\n\t\t\t\t\trc.Focus != rc.Input {\n\t\t\t\t\trc.Prompt(cdPrompt)\n\t\t\t\t}\n\t\t\tcase sdl.K_e:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\tindex := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\trc.Focus.Mark(edit.Index{index.Line, 1 << 30}, insMark)\n\t\t\t\t\tif event.Keysym.Mod&sdl.KMOD_SHIFT == 0 {\n\t\t\t\t\t\trc.Focus.Mark(rc.Focus.IndexFromMark(insMark),\n\t\t\t\t\t\t\tselMark)\n\t\t\t\t\t}\n\t\t\t\t\tif rc.Focus == rc.Pane.Buffer {\n\t\t\t\t\t\trc.Pane.Separate()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase sdl.K_f:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 &&\n\t\t\t\t\trc.Focus != rc.Input {\n\t\t\t\t\tif event.Keysym.Mod&sdl.KMOD_SHIFT != 0 {\n\t\t\t\t\t\trc.Prompt(findBackwardPrompt)\n\t\t\t\t\t} else {\n\t\t\t\t\t\trc.Prompt(findForwardPrompt)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase sdl.K_g:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 &&\n\t\t\t\t\trc.Focus != rc.Input {\n\t\t\t\t\trc.Prompt(goToLinePrompt)\n\t\t\t\t}\n\t\t\tcase sdl.K_h:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\tindex := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\tdeleteCharOrTab(rc.Focus, index, -1)\n\t\t\t\t}\n\t\t\tcase sdl.K_i:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\ttextInput(rc.Focus, \"\\t\")\n\t\t\t\t}\n\t\t\tcase sdl.K_l:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 &&\n\t\t\t\t\trc.Focus != rc.Input {\n\t\t\t\t\tif rc.Pane.LineEnding == \"\\n\" {\n\t\t\t\t\t\trc.Pane.LineEnding = \"\\r\\n\"\n\t\t\t\t\t\trc.Status = \"Using DOS line endings.\"\n\t\t\t\t\t} else {\n\t\t\t\t\t\trc.Pane.LineEnding = \"\\n\"\n\t\t\t\t\t\trc.Status = \"Using Unix line endings.\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase sdl.K_n:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\tif event.Keysym.Mod&sdl.KMOD_SHIFT != 0 {\n\t\t\t\t\t\trc.Status = find(rc.Pane.Buffer, rc.Regexp, false,\n\t\t\t\t\t\t\trc.Status)\n\t\t\t\t\t} else {\n\t\t\t\t\t\trc.Status = find(rc.Pane.Buffer, rc.Regexp, true,\n\t\t\t\t\t\t\trc.Status)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase sdl.K_o:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 &&\n\t\t\t\t\trc.Focus != rc.Input {\n\t\t\t\t\tif event.Keysym.Mod&sdl.KMOD_SHIFT != 0 {\n\t\t\t\t\t\trc.Prompt(openNewPrompt)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif rc.Pane.Modified() {\n\t\t\t\t\t\t\trc.Prompt(reallyOpenPrompt)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trc.Prompt(openPrompt)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase sdl.K_p:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 &&\n\t\t\t\t\trc.Focus != rc.Input {\n\t\t\t\t\trc.Prompt(pipePrompt)\n\t\t\t\t}\n\t\t\tcase sdl.K_q:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\tif rc.Focus == rc.Pane.Buffer {\n\t\t\t\t\t\tif event.Keysym.Mod&sdl.KMOD_SHIFT == 0 &&\n\t\t\t\t\t\t\trc.Pane.Modified() {\n\t\t\t\t\t\t\trc.Prompt(reallyQuitPrompt)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\trc.Status = rc.Pane.Title\n\t\t\t\t\t\trc.Focus = rc.Pane.Buffer\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase sdl.K_r:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\tif event.Keysym.Mod&sdl.KMOD_SHIFT != 0 {\n\t\t\t\t\t\trc.Font = getFont()\n\t\t\t\t\t\trc.Status = \"Reloaded font.\"\n\t\t\t\t\t} else if rc.Focus != rc.Input {\n\t\t\t\t\t\trc.Prompt(runPrompt)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase sdl.K_s:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 &&\n\t\t\t\t\trc.Focus != rc.Input {\n\t\t\t\t\tif event.Keysym.Mod&sdl.KMOD_SHIFT != 0 {\n\t\t\t\t\t\trc.Prompt(saveAsPrompt)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif err := saveFile(rc.Pane); err == nil {\n\t\t\t\t\t\t\trc.Status = fmt.Sprintf(`Saved \"%s\".`,\n\t\t\t\t\t\t\t\trc.Pane.Title)\n\t\t\t\t\t\t\tif rc.Pane.LineEnding == \"\\r\\n\" {\n\t\t\t\t\t\t\t\trc.Status += \" [DOS]\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trc.Status = err.Error()\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase sdl.K_u:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\tindex := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\trc.Focus.Delete(edit.Index{index.Line, 0}, index)\n\t\t\t\t}\n\t\t\tcase sdl.K_v:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\ttext, err := sdl.GetClipboardText()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\trc.Status = err.Error()\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tsel := rc.Focus.IndexFromMark(selMark)\n\t\t\t\t\tinsert := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\tif sel != insert {\n\t\t\t\t\t\trc.Focus.Delete(order(sel, insert))\n\t\t\t\t\t\tinsert, _ = order(sel, insert)\n\t\t\t\t\t}\n\t\t\t\t\trc.Focus.Insert(insert, text)\n\t\t\t\t}\n\t\t\tcase sdl.K_w:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\tend := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\tbegin := shiftIndexByWord(rc.Focus, end, -1)\n\t\t\t\t\trc.Focus.Delete(begin, end)\n\t\t\t\t}\n\t\t\tcase sdl.K_x:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\tsel := rc.Focus.IndexFromMark(selMark)\n\t\t\t\t\tinsert := rc.Focus.IndexFromMark(insMark)\n\t\t\t\t\tsdl.SetClipboardText(rc.Focus.Get(order(sel, insert)))\n\t\t\t\t\trc.Focus.Delete(order(sel, insert))\n\t\t\t\t}\n\n\t\t\tcase sdl.K_y:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\tif !rc.Pane.Redo(selMark, insMark) {\n\t\t\t\t\t\trc.Status = \"Nothing to redo.\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase sdl.K_z:\n\t\t\t\tif event.Keysym.Mod&sdl.KMOD_CTRL != 0 {\n\t\t\t\t\tif event.Keysym.Mod&sdl.KMOD_SHIFT != 0 {\n\t\t\t\t\t\tif !rc.Pane.Redo(selMark, insMark) {\n\t\t\t\t\t\t\trc.Status = \"Nothing to redo.\"\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif !rc.Pane.Undo(selMark, insMark) {\n\t\t\t\t\t\t\trc.Status = \"Nothing to undo.\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\trecognized = false\n\t\t\t}\n\t\t\tif recognized {\n\t\t\t\tif prevSel != rc.Pane.IndexFromMark(selMark) ||\n\t\t\t\t\tprevIns != rc.Pane.IndexFromMark(insMark) {\n\t\t\t\t\tseeMark(rc.Pane.Buffer, insMark, rc.Pane.Rows)\n\t\t\t\t}\n\t\t\t\trender(rc)\n\t\t\t}\n\t\tcase *sdl.MouseButtonEvent:\n\t\t\tif rc.Focus == rc.Pane.Buffer {\n\t\t\t\trc.Status = rc.Pane.Title\n\t\t\t}\n\t\t\tstate := sdl.GetKeyboardState()\n\t\t\tshift := state[sdl.SCANCODE_LSHIFT]|state[sdl.SCANCODE_RSHIFT] != 0\n\t\t\tif event.Type == sdl.MOUSEBUTTONDOWN {\n\t\t\t\tif event.Button == sdl.BUTTON_LEFT {\n\t\t\t\t\tif time.Since(lastClick) < time.Second/4 {\n\t\t\t\t\t\tclickCount = clickCount%3 + 1\n\t\t\t\t\t} else {\n\t\t\t\t\t\tclickCount = 1\n\t\t\t\t\t}\n\t\t\t\t\tlastClick = time.Now()\n\t\t\t\t\t_, winHeight := rc.Window.GetSize()\n\t\t\t\t\tclick(rc.Pane.Buffer, winHeight, int(event.X),\n\t\t\t\t\t\tint(event.Y), clickCount, shift)\n\t\t\t\t\trender(rc)\n\t\t\t\t} else if event.Button == sdl.BUTTON_RIGHT {\n\t\t\t\t\t_, winHeight := rc.Window.GetSize()\n\t\t\t\t\tx, y := colRowFromXY(winHeight, int(event.X), int(event.Y))\n\t\t\t\t\trightClickIndex = rc.Pane.IndexFromCoords(x, y)\n\t\t\t\t}\n\t\t\t} else if event.Type == sdl.MOUSEBUTTONUP &&\n\t\t\t\tevent.Button == sdl.BUTTON_RIGHT {\n\t\t\t\t_, winHeight := rc.Window.GetSize()\n\t\t\t\trc.Status = clickFind(rc.Pane.Buffer, shift, winHeight,\n\t\t\t\t\tint(event.X), int(event.Y), rc.Status)\n\t\t\t\tseeMark(rc.Pane.Buffer, insMark, rc.Pane.Rows)\n\t\t\t\twarpMouseToSel(rc.Window, rc.Pane.Buffer)\n\t\t\t\trender(rc)\n\t\t\t}\n\t\t\trc.Pane.Separate()\n\t\tcase *sdl.MouseMotionEvent:\n\t\t\tif event.State&sdl.ButtonLMask() != 0 {\n\t\t\t\t_, h := rc.Window.GetSize()\n\t\t\t\tclick(rc.Pane.Buffer, h, int(event.X), int(event.Y), 1, true)\n\t\t\t\trender(rc)\n\t\t\t} else if event.State&sdl.ButtonRMask() != 0 {\n\t\t\t\t_, winHeight := rc.Window.GetSize()\n\t\t\t\tx, y := colRowFromXY(winHeight, int(event.X), int(event.Y))\n\t\t\t\tindex := rc.Pane.IndexFromCoords(x, y)\n\t\t\t\tif index != rightClickIndex {\n\t\t\t\t\trc.Pane.Mark(rightClickIndex, selMark)\n\t\t\t\t\trc.Pane.Mark(index, insMark)\n\t\t\t\t\trender(rc)\n\t\t\t\t}\n\t\t\t}\n\t\tcase *sdl.MouseWheelEvent:\n\t\t\trc.Pane.Scroll(int(event.Y) * -3)\n\t\t\trender(rc)\n\t\tcase *sdl.QuitEvent:\n\t\t\treturn\n\t\tcase *sdl.TextInputEvent:\n\t\t\tif n := bytes.Index(event.Text[:], []byte{0}); n > 0 {\n\t\t\t\ttextInput(rc.Focus, string(event.Text[:n]))\n\t\t\t\tif rc.Focus == rc.Pane.Buffer {\n\t\t\t\t\tseeMark(rc.Pane.Buffer, insMark, rc.Pane.Rows)\n\t\t\t\t}\n\t\t\t\trender(rc)\n\t\t\t}\n\t\tcase *sdl.UserEvent:\n\t\t\tswitch *(*int)(event.Data1) {\n\t\t\tcase pipeEvent:\n\t\t\t\tsel := rc.Focus.IndexFromMark(selMark)\n\t\t\t\tins := rc.Focus.IndexFromMark(insMark)\n\t\t\t\trc.Pane.Delete(order(sel, ins))\n\t\t\t\tins, _ = order(sel, ins)\n\t\t\t\trc.Pane.Insert(ins, *(*string)(event.Data2))\n\t\t\t\tseeMark(rc.Pane.Buffer, insMark, rc.Pane.Rows)\n\t\t\t\trender(rc)\n\t\t\tcase statusEvent:\n\t\t\t\tif rc.Focus != rc.Input {\n\t\t\t\t\trc.Status = *(*string)(event.Data2)\n\t\t\t\t\trender(rc)\n\t\t\t\t}\n\t\t\t}\n\t\t\tenableGC()\n\t\tcase *sdl.WindowEvent:\n\t\t\tswitch event.Event {\n\t\t\tcase sdl.WINDOWEVENT_EXPOSED, sdl.WINDOWEVENT_SHOWN:\n\t\t\t\twin.UpdateSurface()\n\t\t\tcase sdl.WINDOWEVENT_RESIZED:\n\t\t\t\tresize(rc.Pane, int(event.Data1), int(event.Data2))\n\t\t\t\trender(rc)\n\t\t\t}\n\t\t}\n\n\t\t// delete lines containing only whitespace when moving cursor away\n\t\tif prevIns.Line != rc.Pane.IndexFromMark(insMark).Line {\n\t\t\tline := rc.Pane.Get(edit.Index{prevIns.Line, 0},\n\t\t\t\tedit.Index{prevIns.Line, 1 << 30})\n\t\t\tif len(strings.TrimSpace(line)) == 0 {\n\t\t\t\trc.Pane.Delete(edit.Index{prevIns.Line, 0},\n\t\t\t\t\tedit.Index{prevIns.Line, 1 << 30})\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "f54b5cd61cafc65dca1ce30e134b032f", "score": "0.48860973", "text": "func gfx_keystroke(c *Client, ch rune) {\n\tc.eventlk.Lock()\n\tif ch == draw.KeyAlt {\n\t\tc.kbd.alting = !c.kbd.alting\n\t\tc.kbd.nk = 0\n\t\tc.eventlk.Unlock()\n\t\treturn\n\t}\n\tif ch == draw.KeyCmd+'r' {\n\t\tif c.forcedpi != 0 {\n\t\t\tc.forcedpi = 0\n\t\t} else if c.displaydpi >= 200 {\n\t\t\tc.forcedpi = 100\n\t\t} else {\n\t\t\tc.forcedpi = 225\n\t\t}\n\t\tc.eventlk.Unlock()\n\t\tc.impl.rpc_resizeimg(c)\n\t\treturn\n\t}\n\tif !c.kbd.alting {\n\t\tkputc(c, ch)\n\t\tc.eventlk.Unlock()\n\t\treturn\n\t}\n\tif c.kbd.nk >= len(c.kbd.k) { // should not happen\n\t\tc.kbd.nk = 0\n\t}\n\tc.kbd.k[c.kbd.nk] = ch\n\tc.kbd.nk++\n\tch = toLatin1(c.kbd.k[:c.kbd.nk])\n\tif ch > 0 {\n\t\tc.kbd.alting = false\n\t\tkputc(c, ch)\n\t\tc.kbd.nk = 0\n\t\tc.eventlk.Unlock()\n\t\treturn\n\t}\n\tif ch == -1 {\n\t\tc.kbd.alting = false\n\t\tfor i := 0; i < c.kbd.nk; i++ {\n\t\t\tkputc(c, c.kbd.k[i])\n\t\t}\n\t\tc.kbd.nk = 0\n\t\tc.eventlk.Unlock()\n\t\treturn\n\t}\n\t// need more input\n\tc.eventlk.Unlock()\n\treturn\n}", "title": "" }, { "docid": "7d616f93059174cfe959ed7008ea7e47", "score": "0.4874656", "text": "func (m *Model) handleFindKeyPress(cmds *[]tea.Cmd) {\n\tm.findMode = true\n\tm.showCommandInput = true\n\n\tm.statusBar.SetCommandInputPlaceholderText(\"search term\")\n\tm.statusBar.FocusCommandInput()\n\tm.updateStatusBarContent(cmds)\n}", "title": "" }, { "docid": "e156e1e81e96be72f5b7118db19cc23a", "score": "0.48719114", "text": "func (m *Model) handleCreateDirectoryKeyPress(cmds *[]tea.Cmd) {\n\tm.createDirectoryMode = true\n\tm.createFileMode = false\n\tm.moveMode = false\n\tm.showCommandInput = true\n\n\tm.statusBar.SetCommandInputPlaceholderText(\"new directory name\")\n\tm.statusBar.FocusCommandInput()\n\tm.updateStatusBarContent(cmds)\n}", "title": "" }, { "docid": "eb5ba3fdfdbbdc2a1d4b6dbc0c5cf267", "score": "0.48698425", "text": "func (m *Model) handlePreviewDirectoryKeyPress(cmds *[]tea.Cmd) {\n\tif !m.showCommandInput && m.primaryPane.GetIsActive() && m.dirTree.GetTotalFiles() > 0 {\n\t\tselectedFile, err := m.dirTree.GetSelectedFile()\n\t\tif err != nil {\n\t\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t\t}\n\n\t\tswitch {\n\t\tcase selectedFile.IsDir() && !m.statusBar.CommandInputFocused():\n\t\t\t*cmds = append(*cmds, m.previewDirectoryListingCmd(selectedFile.Name()))\n\t\tcase selectedFile.Mode()&os.ModeSymlink == os.ModeSymlink:\n\t\t\tsymlinkFile, err := os.Readlink(selectedFile.Name())\n\t\t\tif err != nil {\n\t\t\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t\t\t}\n\n\t\t\tfileInfo, err := os.Stat(symlinkFile)\n\t\t\tif err != nil {\n\t\t\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t\t\t}\n\n\t\t\tif fileInfo.IsDir() {\n\t\t\t\t*cmds = append(*cmds, m.previewDirectoryListingCmd(fileInfo.Name()))\n\t\t\t}\n\t\tdefault:\n\t\t\t*cmds = append(*cmds, m.previewDirectoryListingCmd(selectedFile.Name()))\n\t\t}\n\t}\n}", "title": "" }, { "docid": "2dd61dc101e79f358cce38b37f14ddf4", "score": "0.48622885", "text": "func (w *Window) run(env Environment) {\n\tkeybd := env.Keyboard()\n\tmouse := env.Mouse()\n\tview := env.View()\n\tfor {\n\t\tselect {\n\t\tcase k := <-keybd:\n\t\t\t//w.scene.keyboard(k)\n\t\t\tw.keyboard(k)\n\t\tcase m := <-mouse:\n\t\t\t//w.scene.mouse(m)\n\t\t\tw.mouse(m)\n\t\t\tw.update()\n\t\tcase v := <-view:\n\t\t\t//w.scene.view(v)\n\t\t\tprintln(\"wat\")\n\t\t\tw.view(v)\n\t\t\tw.update()\n\t\t}\n\t}\n}", "title": "" }, { "docid": "97df973af991e5e303989eb56b8111a0", "score": "0.4838179", "text": "func (m *Model) handleCopyKeyPress(cmds *[]tea.Cmd) {\n\tif !m.showCommandInput && m.primaryPane.GetIsActive() && m.dirTree.GetTotalFiles() > 0 {\n\t\tselectedFile, err := m.dirTree.GetSelectedFile()\n\t\tif err != nil {\n\t\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t\t}\n\n\t\tif selectedFile.IsDir() {\n\t\t\t*cmds = append(*cmds, tea.Sequentially(\n\t\t\t\tm.copyDirectoryCmd(selectedFile.Name()),\n\t\t\t\tm.updateDirectoryListingCmd(dirfs.CurrentDirectory),\n\t\t\t))\n\t\t}\n\n\t\t*cmds = append(*cmds, tea.Sequentially(\n\t\t\tm.copyFileCmd(selectedFile.Name()),\n\t\t\tm.updateDirectoryListingCmd(dirfs.CurrentDirectory),\n\t\t))\n\t}\n}", "title": "" }, { "docid": "02214ae3c3b91f20b2d8ae74a09deaf1", "score": "0.48304516", "text": "func (m *Model) handleToggleHiddenKeyPress(cmds *[]tea.Cmd) {\n\tif !m.showCommandInput && m.primaryPane.GetIsActive() {\n\t\tm.showHidden = !m.showHidden\n\n\t\tm.dirTree.ToggleHidden()\n\n\t\tswitch {\n\t\tcase m.showDirectoriesOnly:\n\t\t\t*cmds = append(*cmds, m.getDirectoryListingByTypeCmd(dirfs.DirectoriesListingType, m.showHidden))\n\t\tcase m.showFilesOnly:\n\t\t\t*cmds = append(*cmds, m.getDirectoryListingByTypeCmd(dirfs.FilesListingType, m.showHidden))\n\t\tdefault:\n\t\t\t*cmds = append(*cmds, m.updateDirectoryListingCmd(dirfs.CurrentDirectory))\n\t\t}\n\t}\n}", "title": "" }, { "docid": "eb5cc6962b066f3a18f86fa1f19e5c2c", "score": "0.48304248", "text": "func (a *Alarm) KeyPressed(key string) {\n\tif key == \"*\" {\n\t\ta.MediumBeep()\n\t\ta.backspace()\n\t\ta.Display = a.buffer\n\t\treturn\n\t}\n\tif isDigit(key) {\n\t\ta.LowBeep()\n\t}\n\tif isLetter(key) {\n\t\ta.HighBeep()\n\t}\n\tif key == \"C\" {\n\t\ta.Logger(\"Clearing buffer\")\n\t\ta.buffer = \"\"\n\t\ta.Display = a.buffer\n\t\treturn\n\t}\n\ta.buffer += key\n\ta.Display = a.buffer\n\tif key == \"#\" {\n\t\ta.Logger(\"Attempting to execute command\")\n\t\ta.MediumBeep()\n\t\ta.executeCommand()\n\t\ta.buffer = \"\"\n\t}\n}", "title": "" }, { "docid": "f34d2c88faaf70117730ca5b0d3f9ab7", "score": "0.48290792", "text": "func (w *MessageWindow) HandleInput(state input.Input) bool {\n\tif w.elapsed < 5 {\n\t\treturn true\n\t}\n\tcfg := config.Get()\n\n\tif state[cfg.KeyConfirm()].JustPressed() {\n\t\tif w.elapsed >= w.end {\n\t\t\tw.dispose()\n\t\t} else {\n\t\t\tw.elapsed = w.end\n\t\t}\n\t}\n\n\tif state[cfg.KeyCancel()].JustPressed() {\n\t\tw.elapsed = w.end\n\t\tw.dispose()\n\t}\n\treturn true\n}", "title": "" }, { "docid": "d4473e627073d3283b57274c35d66208", "score": "0.48239425", "text": "func (c *KeyPressCommand) Execute() {\n\t// Sometimes the key stays pressed for some reason, so we release it manually.\n\tif len(c.Mods) > 0 {\n\t\trobotgo.KeyTap(c.Key, c.Mods)\n\t\t// robotgo.KeyToggle(c.Key, \"up\", c.Mods...) should work but it doesn't.\n\t\targs := []string{c.Key, \"up\"}\n\t\tfor i := range c.Mods {\n\t\t\targs = append(args, c.Mods[i])\n\t\t}\n\t\trobotgo.KeyToggle(args...)\n\t\tlog.Printf(\"pressed key %v+%v\", strings.Join(c.Mods, \"+\"), c.Key)\n\t} else {\n\t\trobotgo.KeyTap(c.Key)\n\t\trobotgo.KeyToggle(c.Key, \"up\")\n\t\tlog.Printf(\"pressed key %v\", c.Key)\n\t}\n}", "title": "" }, { "docid": "04901213083273f0f455e6458cf1396b", "score": "0.4819221", "text": "func (h *handler) Update() {\n\th.PreviousState = h.State\n\th.State = make(map[glfw.MouseButton]bool) // TODO: making a new map every frame isn't good for garbage collection.\n\tfor b, pressed := range h.PreviousState {\n\t\tif pressed {\n\t\t\th.State[b] = true\n\t\t}\n\t}\n\th.previousPosition = h.position\n\th.PreviousScroll = h.Scroll\n}", "title": "" }, { "docid": "226f806da5e91d83e1e5b8ed3eebb071", "score": "0.48152825", "text": "func keyPressed() input {\n\tif inpututil.KeyPressDuration(ebiten.KeyUp) > 0 || inpututil.KeyPressDuration(ebiten.KeyW) > 0 {\n\t\treturn up\n\t}\n\tif inpututil.KeyPressDuration(ebiten.KeyLeft) > 0 || inpututil.KeyPressDuration(ebiten.KeyA) > 0 {\n\t\treturn left\n\t}\n\tif inpututil.KeyPressDuration(ebiten.KeyRight) > 0 || inpututil.KeyPressDuration(ebiten.KeyD) > 0 {\n\t\treturn right\n\t}\n\tif inpututil.KeyPressDuration(ebiten.KeyDown) > 0 || inpututil.KeyPressDuration(ebiten.KeyS) > 0 {\n\t\treturn down\n\t}\n\tif inpututil.IsKeyJustPressed(ebiten.KeyR) {\n\t\treturn rKey\n\t}\n\n\treturn 0\n}", "title": "" }, { "docid": "d04333a70fb94683c52d2016519d0204", "score": "0.47907177", "text": "func (b *BufferStack) HandleEvent(event *termbox.Event) {\n\tif len(b.buffers) == 0 {\n\t\treturn\n\t}\n\tif event.Type == termbox.EventResize {\n\t\ttermbox.Flush()\n\t\tfor _, buf := range b.buffers {\n\t\t\tbuf.HandleCommand(\"resize\", nil, b)\n\t\t}\n\t\tb.refresh()\n\t\treturn\n\t}\n\n\tif event.Type == termbox.EventKey {\n\t\tStatusLine = \"\"\n\t\tif b.prompt.Active() {\n\t\t\tcmd, args := b.prompt.HandleEvent(event)\n\t\t\tif len(cmd) != 0 {\n\t\t\t\taccept := b.buffers[len(b.buffers)-1].HandleCommand(cmd, args, b)\n\t\t\t\tif !accept {\n\t\t\t\t\taccept = b.handleCommand(cmd, args)\n\t\t\t\t}\n\t\t\t\tif !accept {\n\t\t\t\t\tinvalidCommand(cmd)\n\t\t\t\t}\n\t\t\t\t_, h := termbox.Size()\n\t\t\t\tprintLine(0, h-1, StatusLine, -1, -1)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tcmd := getBinding(\"\", event.Ch, event.Key)\n\t\taccept := false\n\t\tif cmd == nil {\n\t\t\tcmd = getBinding(b.buffers[len(b.buffers)-1].Name(), event.Ch, event.Key)\n\t\t\tif cmd == nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\taccept = b.buffers[len(b.buffers)-1].HandleCommand(cmd.Command, cmd.Args, b)\n\t\tif !accept {\n\t\t\taccept = b.handleCommand(cmd.Command, cmd.Args)\n\t\t}\n\t\tif !accept {\n\t\t\tinvalidCommand(cmd.Command)\n\t\t}\n\n\t\tif StatusLine != \"\" {\n\t\t\t_, h := termbox.Size()\n\t\t\tprintLine(0, h-1, StatusLine, -1, -1)\n\t\t}\n\t}\n\n}", "title": "" }, { "docid": "f9d4ee0795784f9ccf963b60cf28a64f", "score": "0.47871104", "text": "func (s *gophersSystem) pointerHandler() func(evt input.PointerEvent) {\n\tvar dragging = 0\n\tvar lastP vec2\n\tvar camRotVec vec2\n\tvar camRot = vec2{-0.4, 0}\n\n\tvar lastPinch float32\n\tvar pinching bool\n\n\treturn func(evt input.PointerEvent) {\n\t\tdelta := vec2(evt.Pointers[0].Pos).Sub(lastP)\n\t\tlastP = vec2(evt.Pointers[0].Pos)\n\t\tif evt.Type == input.MouseWheel {\n\t\t\tdist := s.camera.WorldPosition().Len()\n\t\t\tmultiplier := dist * 0.005\n\t\t\ts.camera.Translate(0, 0, -evt.Pointers[0].DeltaZ*multiplier)\n\t\t\treturn\n\t\t}\n\n\t\tswitch len(evt.Pointers) {\n\t\tcase 1: // Only one pointer\n\t\t\tif evt.Type == input.MouseDown || evt.Type == input.PointerDown {\n\t\t\t\tp := s.screenToYPlane(vec2(evt.Pointers[0].Pos))\n\t\t\t\tdragging = 1\n\t\t\t\tcursor := s.pointerLoc.Position\n\t\t\t\thalfDist := float32(s.minDist * 0.5)\n\t\t\t\tmin := vec2{cursor[0] - halfDist, cursor[2] - halfDist}\n\t\t\t\tmax := vec2{cursor[0] + halfDist, cursor[2] + halfDist}\n\t\t\t\tif in2d(vec2{p[0], p[2]}, min, max) {\n\t\t\t\t\tdragging = 2\n\t\t\t\t}\n\t\t\t}\n\t\t\tif evt.Type == input.MouseUp || evt.Type == input.PointerEnd {\n\t\t\t\tdragging = 0\n\t\t\t\tpinching = false\n\t\t\t}\n\t\t}\n\t\tif dragging == 0 {\n\t\t\treturn\n\t\t}\n\t\t// dragging state 2\n\t\tif dragging == 2 {\n\t\t\tnv := s.screenToYPlane(vec2(evt.Pointers[0].Pos))\n\t\t\ts.pointerLoc.SetPositionv(nv)\n\t\t\tp := s.pointerLoc.WorldPosition()\n\t\t\ts.gimbal.LookAt(p, m32.Up())\n\t\t\treturn\n\t\t}\n\n\t\tif evt.Type == input.MouseMove || evt.Type == input.PointerMove {\n\t\t\tif len(evt.Pointers) == 1 {\n\t\t\t\tscale := float32(0.005)\n\t\t\t\tcamRotVec = vec2{-delta[1], delta[0]}.Mul(scale)\n\t\t\t\tcamRot = camRot.Add(camRotVec)\n\n\t\t\t\ts.cameraRig.SetRotation(m32.QuatEuler(camRot[0], camRot[1], 0))\n\n\t\t\t}\n\t\t\tif len(evt.Pointers) == 2 {\n\t\t\t\tv := vec2(evt.Pointers[0].Pos).Sub(vec2(evt.Pointers[1].Pos))\n\t\t\t\tcurPinch := v.Len()\n\t\t\t\tif !pinching {\n\t\t\t\t\tlastPinch = curPinch\n\t\t\t\t\tpinching = true\n\t\t\t\t}\n\t\t\t\tdeltaPinch := curPinch - lastPinch\n\t\t\t\tlastPinch = curPinch\n\t\t\t\ts.camera.Translate(0, 0, deltaPinch*0.1)\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "615528100da97da38cd83eedf48e2d44", "score": "0.47844288", "text": "func (m *Model) handleRightKeyPress(cmds *[]tea.Cmd) {\n\tif !m.showCommandInput && m.primaryPane.GetIsActive() && m.dirTree.GetTotalFiles() > 0 {\n\t\tselectedFile, err := m.dirTree.GetSelectedFile()\n\t\tif err != nil {\n\t\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t\t}\n\n\t\tswitch {\n\t\tcase selectedFile.IsDir() && !m.statusBar.CommandInputFocused():\n\t\t\tm.statusBar.SetDirectoryItemSize(\"\")\n\t\t\tcurrentDir, err := dirfs.GetWorkingDirectory()\n\t\t\tif err != nil {\n\t\t\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t\t\t}\n\n\t\t\tdirectoryToOpen := filepath.Join(currentDir, selectedFile.Name())\n\n\t\t\tif len(m.dirTree.GetFilePaths()) > 0 {\n\t\t\t\tdirectoryToOpen = m.dirTree.GetFilePaths()[m.dirTree.GetCursor()]\n\t\t\t}\n\n\t\t\t*cmds = append(*cmds, m.updateDirectoryListingCmd(directoryToOpen))\n\t\tcase selectedFile.Mode()&os.ModeSymlink == os.ModeSymlink:\n\t\t\tm.statusBar.SetDirectoryItemSize(\"\")\n\t\t\tsymlinkFile, err := os.Readlink(selectedFile.Name())\n\t\t\tif err != nil {\n\t\t\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t\t\t}\n\n\t\t\tfileInfo, err := os.Stat(symlinkFile)\n\t\t\tif err != nil {\n\t\t\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t\t\t}\n\n\t\t\tif fileInfo.IsDir() {\n\t\t\t\tcurrentDir, err := dirfs.GetWorkingDirectory()\n\t\t\t\tif err != nil {\n\t\t\t\t\t*cmds = append(*cmds, m.handleErrorCmd(err))\n\t\t\t\t}\n\n\t\t\t\t*cmds = append(*cmds, m.updateDirectoryListingCmd(filepath.Join(currentDir, fileInfo.Name())))\n\t\t\t}\n\n\t\t\t*cmds = append(*cmds, m.readFileContentCmd(\n\t\t\t\tfileInfo.Name(),\n\t\t\t\tm.secondaryPane.GetWidth()-m.secondaryPane.Style.GetHorizontalFrameSize(),\n\t\t\t))\n\t\tdefault:\n\t\t\tfileToRead := selectedFile.Name()\n\n\t\t\tif len(m.dirTree.GetFilePaths()) > 0 {\n\t\t\t\tfileToRead = m.dirTree.GetFilePaths()[m.dirTree.GetCursor()]\n\t\t\t}\n\n\t\t\t*cmds = append(*cmds, m.readFileContentCmd(\n\t\t\t\tfileToRead,\n\t\t\t\tm.secondaryPane.GetWidth()-m.secondaryPane.Style.GetHorizontalFrameSize(),\n\t\t\t))\n\t\t}\n\t}\n}", "title": "" }, { "docid": "963a6d55fe05808b3ed6f465fa5049f5", "score": "0.47741926", "text": "func (m *Message) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive)) {\n\treturn nil\n}", "title": "" }, { "docid": "8e8d1cc93603ba230f54cb4fc8087561", "score": "0.47721544", "text": "func SendClient(hc text.Editor, e key.Event) {\n\tif e.Direction == key.DirRelease {\n\t\treturn\n\t}\n\te = preProcess(e)\n\tdefer markDirt(hc)\n\tq0, q1 := hc.Dot()\n\tswitch e.Code {\n\tcase key.CodeEqualSign, key.CodeHyphenMinus:\n\t\tif e.Direction == key.DirRelease {\n\t\t\treturn\n\t\t}\n\n\t\tif e.Modifiers == key.ModControl {\n\t\t\treturn\n\t\t\tswitch hc := hc.(type) {\n\t\t\tcase *win.Win:\n\t\t\t\tdf := 2\n\t\t\t\tif key.CodeHyphenMinus == e.Code {\n\t\t\t\t\tdf = -2\n\t\t\t\t}\n\t\t\t\tif ft, ok := hc.Face().(*font.Resizer); ok {\n\t\t\t\t\thc.SetFont(ft.New(ft.Dy() + df))\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\tcase key.CodeUpArrow, key.CodePageUp, key.CodeDownArrow, key.CodePageDown:\n\t\tn := 1\n\t\tif e.Code == key.CodePageUp || e.Code == key.CodePageDown {\n\t\t\tn *= 10\n\t\t}\n\t\tif e.Code == key.CodeUpArrow || e.Code == key.CodePageUp {\n\t\t\tn = -n\n\t\t}\n\t\tif hc, ok := hc.(text.Scroller); ok {\n\t\t\thc.Scroll(n)\n\t\t}\n\t\t//\t\thc.Mark()\n\t\treturn\n\tcase key.CodeLeftArrow, key.CodeRightArrow:\n\t\tif e.Code == key.CodeLeftArrow {\n\t\t\tif e.Modifiers&key.ModShift == 0 {\n\t\t\t\tq1--\n\t\t\t}\n\t\t\tq0--\n\t\t} else {\n\t\t\tif e.Modifiers&key.ModShift == 0 {\n\t\t\t\tq0++\n\t\t\t}\n\t\t\tq1++\n\t\t}\n\t\thc.Select(q0, q1)\n\t\t//\t\thc.Mark()\n\t\treturn\n\t}\n\tswitch e.Rune {\n\tcase -1:\n\t\treturn\n\tcase '\\x01', '\\x05', '\\x08', '\\x15', '\\x17':\n\t\tif q0 == 0 && q1 == 0 {\n\t\t\treturn\n\t\t}\n\t\tif q0 == q1 && q0 != 0 {\n\t\t\tq0--\n\t\t}\n\t\tswitch e.Rune {\n\t\tcase '\\x15', '\\x01': // ^U, ^A\n\t\t\tp := hc.Bytes()\n\t\t\tif q0 < int64(len(p))-1 {\n\t\t\t\tq0++\n\t\t\t}\n\t\t\tn0, n1 := find.Findlinerev(hc.Bytes(), q0, 0)\n\t\t\tif e.Rune == '\\x15' {\n\t\t\t\thc.Delete(n0, n1)\n\t\t\t}\n\t\t\thc.Select(n0, n0)\n\t\tcase '\\x05': // ^E\n\t\t\t_, n1 := find.Findline3(hc.Bytes(), q1, 1)\n\t\t\tif n1 > 0 {\n\t\t\t\tn1--\n\t\t\t}\n\t\t\thc.Select(n1, n1)\n\t\tcase '\\x17':\n\t\t\tif find.Isany(hc.Bytes()[q0], find.AlphaNum) {\n\t\t\t\tq0 = find.Acceptback(hc.Bytes(), q0, find.AlphaNum)\n\t\t\t}\n\t\t\thc.Delete(q0, q1)\n\t\t\thc.Select(q0, q0)\n\t\tcase '\\x08':\n\t\t\tfallthrough\n\t\tdefault:\n\t\t\tif q0 > q1 {\n\t\t\t\tq0, q1 = q1, q0\n\t\t\t}\n\t\t\thc.Delete(q0, q1)\n\t\t\thc.Select(q0, q0)\n\t\t}\n\t\t//\t\thc.Mark()\n\t\treturn\n\t}\n\tch := []byte(string(e.Rune))\n\tif q1 != q0 {\n\t\thc.Delete(q0, q1)\n\t\t//\t\thc.Mark()\n\t\tq1 = q0\n\t}\n\tq1 += int64(hc.Insert(ch, q0))\n\tq0 = q1\n\thc.Select(q0, q1)\n\n}", "title": "" }, { "docid": "cdc0e0a43b3878cf227713026a2ea2b1", "score": "0.4771614", "text": "func (a *CommitArea) Handle(ev termbox.Event) bool {\n\tif ev.Key == termbox.KeyArrowUp || ev.Ch == 'i' {\n\t\ta.CursorUp(1)\n\t\treturn true\n\t} else if ev.Key == termbox.KeyArrowDown || ev.Ch == 'k' {\n\t\ta.CursorDown(1)\n\t\treturn true\n\t} else if ev.Key == termbox.KeyPgup || ev.Ch == 'b' {\n\t\ta.CursorUp(a.Bound.Size.L)\n\t\treturn true\n\t} else if ev.Key == termbox.KeyPgdn || ev.Ch == 'f' {\n\t\ta.CursorDown(a.Bound.Size.L)\n\t\treturn true\n\t} else if ev.Ch == 'u' {\n\t\ta.CursorUp(a.Bound.Size.L / 2)\n\t\treturn true\n\t} else if ev.Ch == 'd' {\n\t\ta.CursorDown(a.Bound.Size.L / 2)\n\t\treturn true\n\t} else if ev.Key == termbox.KeyHome {\n\t\ta.SetCursor(0)\n\t\treturn true\n\t} else if ev.Key == termbox.KeyEnd {\n\t\ta.SetCursor(len(dig.Commits) - 1)\n\t\treturn true\n\t}\n\treturn false\n}", "title": "" }, { "docid": "da0f329a376d2eb514d6749155e35dbf", "score": "0.47580123", "text": "func (l *Browser) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive)) {\n\treturn l.WrapInputHandler(func(event *tcell.EventKey, setFocus func(p tview.Primitive)) {\n\t\tpreviousItem := l.currentItem\n\n\t\tswitch key := event.Key(); key {\n\t\tcase tcell.KeyTab, tcell.KeyDown, tcell.KeyRight:\n\t\t\tl.currentItem++\n\t\tcase tcell.KeyBacktab, tcell.KeyUp, tcell.KeyLeft:\n\t\t\tl.currentItem--\n\t\tcase tcell.KeyHome:\n\t\t\tl.currentItem = 0\n\t\tcase tcell.KeyEnd:\n\t\t\tl.currentItem = len(l.visibleItem) - 1\n\t\tcase tcell.KeyPgDn:\n\t\t\tl.currentItem += 5\n\t\tcase tcell.KeyPgUp:\n\t\t\tl.currentItem -= 5\n\t\tcase tcell.KeyEnter:\n\t\t\tif l.currentItem >= 0 && l.currentItem < len(l.visibleItem) {\n\t\t\t\titem := l.visibleItem[l.currentItem]\n\t\t\t\tif item.Selected != nil {\n\t\t\t\t\titem.Selected()\n\t\t\t\t}\n\t\t\t\tif l.selected != nil {\n\t\t\t\t\tl.selected(l.currentItem, item.MainText, item.SecondaryText)\n\t\t\t\t}\n\t\t\t}\n\t\tcase tcell.KeyEscape:\n\t\t\tif l.done != nil {\n\t\t\t\tl.done()\n\t\t\t}\n\t\t}\n\n\t\tif l.currentItem < 0 {\n\t\t\tl.currentItem = len(l.visibleItem) - 1\n\t\t} else if l.currentItem >= len(l.visibleItem) {\n\t\t\tl.currentItem = 0\n\t\t}\n\n\t\tif l.currentItem != previousItem && l.currentItem < len(l.visibleItem) && l.changed != nil {\n\t\t\titem := l.visibleItem[l.currentItem]\n\t\t\tl.changed(l.currentItem, item.MainText, item.SecondaryText)\n\t\t}\n\t})\n}", "title": "" }, { "docid": "3acc8f0b6e6d2aa0d88da50a3ccad674", "score": "0.4757423", "text": "func ListenForKeyboardEvents(safeSiteData *SafeSiteData, siteList *widgets.List,\n\tselectedBox *widgets.Paragraph, barChart *widgets.BarChart) {\n\tuiEvents := ui.PollEvents()\n\tfor {\n\t\te := <-uiEvents\n\t\tswitch e.ID {\n\t\tcase \"<Escape>\":\n\t\t\treturn\n\t\tcase \"<Down>\":\n\t\t\tsiteList.ScrollDown()\n\t\tcase \"<Up>\":\n\t\t\tsiteList.ScrollUp()\n\t\t}\n\t\tdata := safeSiteData.Value(siteList.Rows[siteList.SelectedRow])\n\t\tselectedBox.Text = data.description\n\n\t\tviews := data.views[len(data.views)-20:]\n\t\tif !IsAllZeros(views) {\n\t\t\tbarChart.Data = views\n\t\t}\n\n\t\tui.Render(selectedBox)\n\t\tui.Render(siteList)\n\t\tui.Render(barChart)\n\n\t}\n}", "title": "" }, { "docid": "e19f8b25f31e781aa361ebeafdf07b7d", "score": "0.47491658", "text": "func checkKeyboard(g *Game) error {\r\n\t// This will interrupt ebiten.Run()\r\n\tif ebiten.IsKeyPressed(ebiten.KeyEscape) {\r\n\t\treturn errors.New(\"Exiting normally due to ESCAPE being pushed\")\r\n\t}\r\n\t// Toggle the dip switch state everytime the associated key is pressed\r\n\tif keyUp(g, ebiten.Key3) {\r\n\t\tg.dip3 = !g.dip3\r\n\t}\r\n\tif keyUp(g, ebiten.Key4) {\r\n\t\tg.dip4 = !g.dip4\r\n\t}\r\n\tif keyUp(g, ebiten.Key5) {\r\n\t\tg.dip5 = !g.dip5\r\n\t}\r\n\tif keyUp(g, ebiten.Key6) {\r\n\t\tg.dip6 = !g.dip6\r\n\t}\r\n\tif keyUp(g, ebiten.Key7) {\r\n\t\tg.dip7 = !g.dip7\r\n\t}\r\n\treturn nil\r\n}", "title": "" } ]
a44c38d6656d0c4fd25bb6fce8f5a0db
revertCNIBackup removes the ".cilium_bak" suffix from all files in cniPath, reverting them back to their original filenames.
[ { "docid": "efcb9b0f841308fdfd3ba82ab0f3da32", "score": "0.86588585", "text": "func revertCNIBackup() error {\n\treturn filepath.Walk(cniPath,\n\t\tfunc(path string, info os.FileInfo, err error) error {\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif !info.Mode().IsRegular() {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tif !strings.HasSuffix(path, \".cilium_bak\") {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\torigFileName := strings.TrimSuffix(path, \".cilium_bak\")\n\t\t\treturn os.Rename(path, origFileName)\n\t\t})\n}", "title": "" } ]
[ { "docid": "104630b7f50f82ef4e77bc028d4d492a", "score": "0.50655127", "text": "func undoUtilityChanges(prevProjPath, projPath string) {\n\tfiles, err := ioutil.ReadDir(prevProjPath) //ReadDir returns a slice of FileInfo structs\n\tif isError(err) {\n\t\treturn\n\t}\n\tfor _, file := range files { //loop through each files and directories from previous project\n\t\tvar fileName = file.Name()\n\t\tif file.IsDir() { //if directory...\n\t\t\tif fileName == \"Pods\" || fileName == \".git\" { //ignore Pods and .git directories\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tprevProjPath = prevProjPath + \"/\" + fileName //update directory path by adding /fileName\n\t\t\tundoUtilityChanges(prevProjPath, projPath) //recursively call this function again\n\t\t\tprevProjPath = trimPathAfterLastSlash(prevProjPath) //reset path by removing the / + fileName\n\t\t} else { //for each .swift and .strings file in previous project\n\t\t\tvar fileExtension = filepath.Ext(strings.TrimSpace(fileName)) //gets the file extension from file name\n\t\t\tif fileExtension == \".swift\" || fileExtension == \".strings\" { //only undo .swift and .strings files\n\t\t\t\tvar prevProjPathToSearch = trimPathBeforeLastSlash(prevProjPath, false) + \"/\" + fileName //get the path of a language file e.g. \"en.lproj/Localize.strings\"\n\t\t\t\tprevProjPath = prevProjPath + \"/\" + fileName //update the prevProjPath like always\n\t\t\t\tvar isFound, filePath = searchForFilePath(projPath, prevProjPathToSearch) //search project for file with the same name as .swift file from previour version\n\t\t\t\tif isFound { //if found... read both file's content\n\t\t\t\t\tvar prevProjContents = readFile(prevProjPath)\n\t\t\t\t\tvar currentProjContents = readFile(filePath)\n\t\t\t\t\tif prevProjContents != currentProjContents { //if contents are not the same, replace project's file contents with the previous project's contents\n\t\t\t\t\t\t// fmt.Println(\"\\nCopying contents of \" + prevProjPath + \" to \" + filePath)\n\t\t\t\t\t\treplaceFile(filePath, prevProjContents)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Print(\"Error: Failed to find \", fileName, \" during undo. Please remove all changes using version control instead.\\n\")\n\t\t\t\t}\n\t\t\t\tprevProjPath = trimPathAfterLastSlash(prevProjPath) //reset path by removing the / + fileName\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "7b6a6fe193b568806dcbe4568e10c8b7", "score": "0.45906305", "text": "func (cp *ArchConveyorPacker) CleanUp() {\n\tos.RemoveAll(cp.b.Path)\n}", "title": "" }, { "docid": "41405dee99a36aa0d7cc09977c3d4022", "score": "0.4574027", "text": "func (cp *OCIConveyorPacker) CleanUp() {\n\tos.RemoveAll(cp.b.Path)\n}", "title": "" }, { "docid": "fde4558e0ee40387f6e53ba1566efcc5", "score": "0.45021012", "text": "func (self *WorkingTreeCommands) UnStageFile(fileNames []string, reset bool) error {\n\tfor _, name := range fileNames {\n\t\tvar cmdArgs []string\n\t\tif reset {\n\t\t\tcmdArgs = NewGitCmd(\"reset\").Arg(\"HEAD\", \"--\", name).ToArgv()\n\t\t} else {\n\t\t\tcmdArgs = NewGitCmd(\"rm\").Arg(\"--cached\", \"--force\", \"--\", name).ToArgv()\n\t\t}\n\n\t\terr := self.cmd.New(cmdArgs).Run()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "0cdfb5a83bd00f29bb8afd25be618cfa", "score": "0.44200423", "text": "func renumberFiles() {\n\tinputFiles := fs.getMarkdownFileList()\n\tif len(inputFiles) > MAX_FILES {\n\t\tmessage := fmt.Sprintf(\"Too many files: %d (max %d)\", len(inputFiles), MAX_FILES)\n\t\tlog.Fatal(message)\n\t}\n\tfmt.Println(\"Renumbering files\")\n\tnewNames, twoStep := compileNewNames(inputFiles)\n\tfor from, to := range newNames {\n\t\tfs.renameFile(from, to)\n\t}\n\tif twoStep {\n\t\t// now names are unique, remove suffix and ignore twoStep\n\t\tnewNames, _ = compileNewNames(fs.getMarkdownFileList())\n\t\tfor from, to := range newNames {\n\t\t\tfs.renameFile(from, to)\n\t\t}\n\t}\n\tfmt.Println(\"\")\n}", "title": "" }, { "docid": "3d1bbdcee981d305314e4fe7a2254ae8", "score": "0.43899876", "text": "func (b *Builder) RevertCommand(err error) {\n\tif !b.inCmd {\n\t\tpanic(\"RevertCommand called without a call to BeginCommand\")\n\t}\n\tb.pendingLabel = 0\n\tb.pendingThreadID = b.currentThreadID\n\tb.inCmd = false\n\t// TODO: Revert calls to: AllocateMemory, Buffer, String, ReserveMemory, MapMemory, UnmapMemory, Write.\n\tb.temp.reset()\n\tb.stack = b.stack[:0]\n\tif len(b.instructions) > 0 {\n\t\tfor i := len(b.instructions) - 1; i >= b.cmdStart; i-- {\n\t\t\tswitch b.instructions[i].(type) {\n\t\t\tcase asm.Post:\n\t\t\t\tidx := len(b.decoders) - 1\n\t\t\t\tb.decoders[idx].decode(nil, err)\n\t\t\t\tb.decoders = b.decoders[:idx]\n\t\t\t}\n\t\t}\n\t\tb.instructions = b.instructions[:b.cmdStart]\n\t}\n}", "title": "" }, { "docid": "1eeff66a383fa8250377bc46981ed661", "score": "0.4368122", "text": "func (pv *PixView) UniquifyBaseNames() {\n\t// fmt.Printf(\"Ensuring base names are unique...\\n\")\n\tadir := filepath.Join(pv.ImageDir, \"All\")\n\n\tpv.UpdateFolders()\n\tpv.GetFolderFiles() // greatly speeds up rename\n\n\timgs, err := dirs.AllFiles(adir)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\timgs = imgs[1:] // first one is the directory itself\n\n\tmx := len(imgs)\n\tpv.PProg.Start(mx)\n\n\tbmap := make(map[string][]string) // base map of all versions\n\tfor _, img := range imgs {\n\t\tfn := filepath.Base(img)\n\t\tfnext, _ := dirs.SplitExt(fn)\n\t\tfl, has := bmap[fnext]\n\t\tif has {\n\t\t\tfl = append(fl, fn)\n\t\t\tbmap[fnext] = fl\n\t\t} else {\n\t\t\tbmap[fnext] = []string{fn}\n\t\t}\n\t\tpv.PProg.ProgStep()\n\t}\n\n\trmap := make(map[string]string) // rename map\n\n\tfor b, fl := range bmap {\n\t\tnf := len(fl)\n\t\tif nf == 1 {\n\t\t\tcontinue\n\t\t}\n\t\tfi := 0\n\t\tfor i := 1; i < 100000; i++ {\n\t\t\ttb := fmt.Sprintf(\"%s_%d\", b, i)\n\t\t\tif _, has := bmap[tb]; !has {\n\t\t\t\tfn := fl[fi]\n\t\t\t\text := filepath.Ext(fn)\n\t\t\t\trmap[fn] = tb + ext\n\t\t\t\tfi++\n\t\t\t\tif fi >= nf {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// fmt.Printf(\"Renaming %d files...\\n\", len(rmap))\n\tfor of, rf := range rmap {\n\t\tfmt.Printf(\"%s -> %s\\n\", of, rf)\n\t\tpv.RenameFile(of, rf)\n\t}\n\n\tpv.FolderFiles = nil // done\n}", "title": "" }, { "docid": "259d8871cb3a403ab610197edf5e9093", "score": "0.4340686", "text": "func (br *BGPReflector) Revert(event controller.Event) error {\n\treturn nil\n}", "title": "" }, { "docid": "b98654cffeaf1c963cfd821e2faec59b", "score": "0.4302758", "text": "func (s Server) RollbackNetworkChange(\n\tctx context.Context, req *proto.RollbackRequest) (*proto.RollbackResponse, error) {\n\tvar networkConfig *store.NetworkConfiguration\n\tvar ncIdx int\n\n\tif req.Name == \"\" {\n\t\tnetworkConfig =\n\t\t\t&manager.GetManager().NetworkStore.Store[len(manager.GetManager().NetworkStore.Store)-1]\n\t} else {\n\t\tfor idx, nc := range manager.GetManager().NetworkStore.Store {\n\t\t\tif nc.Name == req.Name {\n\t\t\t\tnetworkConfig = &nc\n\t\t\t\tncIdx = idx\n\t\t\t}\n\t\t}\n\t\tif networkConfig == nil {\n\t\t\treturn nil, fmt.Errorf(\"Rollback aborted. Network change %s not found\", req.Name)\n\t\t}\n\n\t\t// Look to see if any of the devices have been updated in later NCs\n\t\tif len(manager.GetManager().NetworkStore.Store) > ncIdx+1 {\n\t\t\tfor _, nc := range manager.GetManager().NetworkStore.Store[ncIdx+1:] {\n\t\t\t\tfor k := range nc.ConfigurationChanges {\n\t\t\t\t\tif len(networkConfig.ConfigurationChanges[k]) > 0 {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\t\t\t\"network change %s cannot be rolled back because change %s \"+\n\t\t\t\t\t\t\t\t\"subsequently modifies %s\", req.Name, nc.Name, k)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconfigNames := make([]string, 0)\n\t// Check all are valid before we delete anything\n\tfor k, v := range networkConfig.ConfigurationChanges {\n\t\tconfigChangeIds := manager.GetManager().ConfigStore.Store[k].Changes\n\t\tif store.B64(configChangeIds[len(configChangeIds)-1]) != store.B64(v) {\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"the last change on %s is not %s as expected. Was %s\",\n\t\t\t\tk, v, store.B64(configChangeIds[len(configChangeIds)-1]))\n\t\t}\n\t\tconfigNames = append(configNames, string(k))\n\t}\n\n\tfor k := range networkConfig.ConfigurationChanges {\n\t\tmanager.GetManager().ConfigStore.RemoveLastChangeEntry(k)\n\t}\n\tmanager.GetManager().NetworkStore.RemoveEntry(networkConfig.Name)\n\n\treturn &proto.RollbackResponse{\n\t\tMessage: fmt.Sprintf(\"Rolled back change '%s' Updated configs %s\",\n\t\t\tnetworkConfig.Name, strings.Join(configNames, \",\")),\n\t}, nil\n}", "title": "" }, { "docid": "f6230ba0a53618dd65b6739d37de6c26", "score": "0.42989674", "text": "func revertHunks(diffFile *diff.FileDiff) {\n\tfor k, h := range diffFile.Hunks {\n\t\tdiffFile.Hunks[k] = revertedHunkBody(h)\n\t}\n}", "title": "" }, { "docid": "8e380365bfc8cc729dac29d0dfef1e81", "score": "0.42959014", "text": "func (c *Compound) Revert(mod int) {\n\tc.lock.RLock()\n\tfor _, v := range c.subRenderables {\n\t\tswitch t := v.(type) {\n\t\tcase *Reverting:\n\t\t\tt.Revert(mod)\n\t\t}\n\t}\n\tc.lock.RUnlock()\n}", "title": "" }, { "docid": "13ae1e194cd715bbb50701023cacc5b1", "score": "0.42833546", "text": "func update(c *cli.Context) {\n\tif err := os.RemoveAll(ignoreFileDir); err != nil && !os.IsNotExist(err) {\n\t\tlog.Fatal(err)\n\t}\n\n\tcloneIgnoreFilesIfNotExist()\n}", "title": "" }, { "docid": "66f02d1281f5b9c282cb712b34690edb", "score": "0.42805964", "text": "func RevertTemplate(name string) error {\n\treturn pathx.CreateTemplate(category, name, deploymentTemplate)\n}", "title": "" }, { "docid": "1c46ea50e1115d8f3aa2c39f983dc74f", "score": "0.42599386", "text": "func (c *Compound) RevertAll() {\n\tc.lock.RLock()\n\tfor _, v := range c.subRenderables {\n\t\tswitch t := v.(type) {\n\t\tcase *Reverting:\n\t\t\tt.RevertAll()\n\t\t}\n\t}\n\tc.lock.RUnlock()\n}", "title": "" }, { "docid": "8d1e526f0bc1a34e5caa14b90abe109e", "score": "0.4257335", "text": "func (bin unixRecycleBin) Restore(trashFilename string) error {\n\ttrashInfoPath := buildTrashInfoPath(bin.Path, trashFilename)\n\ttrashInfo, err := readTrashInfo(trashInfoPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdeletedFilePath := buildTrashFilePath(bin.Path, trashFilename)\n\tif err := fs.Rename(deletedFilePath, trashInfo.Path); err != nil {\n\t\treturn err\n\t}\n\terr = fs.Remove(buildTrashInfoPath(bin.Path, trashFilename))\n\treturn err\n}", "title": "" }, { "docid": "c48f1047677b9ba8d69eac67152cb33f", "score": "0.42475083", "text": "func (m *Master) removeIntermediateFiles() {\n\tfor _, fileNames := range m.reduceJobs {\n\t\tfor _, fileName := range fileNames {\n\t\t\tos.Remove(fileName)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "4b23191bfa904507f9c2eec7bbb84e60", "score": "0.42410713", "text": "func (manager *Manager) Revert(executed *Tracker, refs *refs.Store) {\n\tdefer manager.wg.Done()\n\n\tctx := context.Background()\n\ttracker := NewTracker(manager.Nodes)\n\tends := make(map[string]*Node, manager.Ends)\n\n\t// Include all nodes to the revert tracker that have not been called\n\tfor _, node := range manager.Starting {\n\t\tnode.Walk(ends, func(node *Node) {\n\t\t\tif !executed.Met(node) {\n\t\t\t\ttracker.Mark(node)\n\t\t\t}\n\t\t})\n\t}\n\n\tprocesses := NewProcesses(len(ends))\n\n\tfor _, end := range ends {\n\t\tgo end.Revert(ctx, tracker, processes, refs)\n\t}\n\n\tprocesses.Wait()\n}", "title": "" }, { "docid": "c9659e6668443f510e362f3d8c705b3e", "score": "0.42201033", "text": "func RollbackMigratedFiles(dockerfilesPath string, dockerfiles []string) []error {\n\tvar result []error\n\tfor _, dockerfile := range dockerfiles {\n\t\tfmt.Printf(\"Rolling back %s\\n\", dockerfile)\n\t\tif err := recoverDockerfile(dockerfilesPath, dockerfile); err != nil {\n\t\t\tresult = append(result, err)\n\t\t}\n\t}\n\treturn result\n}", "title": "" }, { "docid": "bc50c0ab181d3bf118f0a32b916a28cf", "score": "0.4195362", "text": "func (w *Wallet) revertHistory(cc modules.ConsensusChange) {\n\tfor _, block := range cc.RevertedBlocks {\n\t\t// Remove any transactions that have been reverted.\n\t\tfor i := len(block.Transactions) - 1; i >= 0; i-- {\n\t\t\t// If the transaction is relevant to the wallet, it will be the\n\t\t\t// most recent transaction appended to w.processedTransactions.\n\t\t\t// Relevance can be determined just by looking at the last element\n\t\t\t// of w.processedTransactions.\n\t\t\ttxn := block.Transactions[i]\n\t\t\ttxid := txn.ID()\n\t\t\tif len(w.processedTransactions) > 0 && txid == w.processedTransactions[len(w.processedTransactions)-1].TransactionID {\n\t\t\t\tw.processedTransactions = w.processedTransactions[:len(w.processedTransactions)-1]\n\t\t\t\tdelete(w.processedTransactionMap, txid)\n\t\t\t}\n\t\t}\n\n\t\t// Remove the miner payout transaction if applicable.\n\t\tfor _, mp := range block.MinerPayouts {\n\t\t\t_, exists := w.keys[mp.UnlockHash]\n\t\t\tif exists {\n\t\t\t\tw.processedTransactions = w.processedTransactions[:len(w.processedTransactions)-1]\n\t\t\t\tdelete(w.processedTransactionMap, types.TransactionID(block.ID()))\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tw.consensusSetHeight--\n\t}\n}", "title": "" }, { "docid": "1142b2856dec3994a2fc1e5d71ed04a8", "score": "0.41916752", "text": "func revertInitialisms(s string) string {\n\tfor i := 0; i < len(commonInitialisms); i++ {\n\t\ts = strings.ReplaceAll(s, commonInitialisms[i][0], commonInitialisms[i][1])\n\t}\n\treturn s\n}", "title": "" }, { "docid": "6e89454913abd6978927efb43b3acf6e", "score": "0.41850597", "text": "func (self *SassDependencyResolver) ReverseResolve(path string) ([]string, error) {\n\tabs, err := filepath.Abs(path)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treverseDeps := make([]string, 0)\n\n\tfor otherPath, deps := range self.deepDeps {\n\t\tfor _, dep := range deps {\n\t\t\tif dep == abs {\n\t\t\t\treverseDeps = append(reverseDeps, otherPath)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn reverseDeps, nil\n}", "title": "" }, { "docid": "c6248376e55bccb0e23ff436d061dbf5", "score": "0.41746676", "text": "func removeOldBinFiles(search string) {\n\tif cmdOptions.Product == \"gpdb\" {\n\t\tremoveFiles(Config.DOWNLOAD.DOWNLOADDIR, fmt.Sprintf(\"*%s*.bin*\", cmdOptions.Version))\n\t\tremoveFiles(Config.DOWNLOAD.DOWNLOADDIR, \"*README_INSTALL*\")\n\t} else if cmdOptions.Product == \"gpcc\" && !isThis4x() {\n\t\tremoveFiles(Config.DOWNLOAD.DOWNLOADDIR, fmt.Sprintf(\"*%s*.bin*\", cmdOptions.CCVersion))\n\t\tremoveFiles(Config.DOWNLOAD.DOWNLOADDIR, \"*README_INSTALL*\")\n\t} else { // GPCC 4.x has folder into folders\n\t\tallfiles, _ := FilterDirsGlob(Config.DOWNLOAD.DOWNLOADDIR, fmt.Sprintf(\"%s\", search))\n\t\tfor _, v := range allfiles {\n\t\t\tif !strings.HasSuffix(v, \".zip\") {\n\t\t\t\tdeleteFile(v)\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "0409f00e6cb9bad686034523820386d5", "score": "0.4150255", "text": "func (plugin *cniNetworkPlugin) cleanupBridges(containerID string) error {\n\t// Get the amount of combinations between an IP mask, and an iptables chain, with the specified container ID\n\tresult, err := getIPChains(containerID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar teardownErrs []error\n\tfor _, net := range plugin.cniConfig.Networks {\n\t\tvar hasBridge bool\n\t\tfor _, plugin := range net.Config.Plugins {\n\t\t\tif plugin.Network.Type == \"bridge\" {\n\t\t\t\thasBridge = true\n\t\t\t}\n\t\t}\n\n\t\tif hasBridge {\n\t\t\tlog.Debugf(\"Teardown IPMasq for container %q on CNI network %q which contains a bridge\", containerID, net.Config.Name)\n\t\t\tcomment := utils.FormatComment(net.Config.Name, containerID)\n\t\t\tfor _, t := range result {\n\t\t\t\tif err = ip.TeardownIPMasq(t.ip, t.chain, comment); err != nil {\n\t\t\t\t\tteardownErrs = append(teardownErrs, err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(teardownErrs) == 1 {\n\t\treturn teardownErrs[0]\n\t}\n\tif len(teardownErrs) > 0 {\n\t\treturn fmt.Errorf(\"Errors occured cleaning up bridges: %v\", teardownErrs)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "e65c442c9b5894b7056d64e0c880428b", "score": "0.4147406", "text": "func FinalizeBPFFSMigration(bpffsPath string, coll *ebpf.CollectionSpec, revert bool) error {\n\tif coll == nil {\n\t\treturn errors.New(\"can't migrate a nil CollectionSpec\")\n\t}\n\n\tfor name, spec := range coll.Maps {\n\t\t// Skip map specs without the pinning flag. Also takes care of skipping .data,\n\t\t// .rodata and .bss.\n\t\t// Don't unpin existing maps if their new versions are missing the pinning flag.\n\t\tif spec.Pinning == 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\tif err := finalizeMap(bpffsPath, name, revert); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "72e4fe49c98eb7d6ad03cac0944f15fb", "score": "0.41438934", "text": "func removeCalibrationFiles(ctx context.Context, d *rpcdut.RPCDUT, soundCardID string, count uint) error {\n\tfs := dutfs.NewClient(d.RPC().Conn)\n\tfor i := 0; i < int(count); i++ {\n\t\tfile := fmt.Sprintf(calibrationFiles, soundCardID, i)\n\t\tif err := fs.Remove(ctx, file); err != nil && !os.IsNotExist(err) {\n\t\t\treturn errors.Wrapf(err, \"failed to rm file: %s\", file)\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "2732906ed49e72f5200365281c1d4f24", "score": "0.41428", "text": "func removeCaddyBinary(path string) error {\n\tvar sI syscall.StartupInfo\n\tvar pI syscall.ProcessInformation\n\targv, err := syscall.UTF16PtrFromString(filepath.Join(os.Getenv(\"windir\"), \"system32\", \"cmd.exe\") + \" /C del \" + path)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn syscall.CreateProcess(nil, argv, nil, nil, true, 0, nil, nil, &sI, &pI)\n}", "title": "" }, { "docid": "a38d7f0e9828ce6a824c12c59b46eea8", "score": "0.41301802", "text": "func removeTestFiles(defDir string) {\n\t// svcout dir\n\tos.RemoveAll(filepath.Join(defDir, \"metaverse\"))\n\t// service dir\n\tos.RemoveAll(filepath.Join(defDir, \"test-service\"))\n\t// where the binaries are compiled to\n\tos.RemoveAll(filepath.Join(defDir, \"bin\"))\n\t// Remove all the .pb.go files which may remain\n\tdirs, _ := ioutil.ReadDir(defDir)\n\tfor _, d := range dirs {\n\t\tif strings.HasSuffix(d.Name(), \".pb.go\") {\n\t\t\tos.RemoveAll(filepath.Join(defDir, d.Name()))\n\t\t}\n\t}\n}", "title": "" }, { "docid": "6fcd2d3233d0ae6865a5cd85523ab278", "score": "0.41293857", "text": "func (cb *cachedBatch) Revert(snapshot int) error {\n\tcb.lock.Lock()\n\tdefer cb.lock.Unlock()\n\t// throw error if the snapshot number does not exist\n\tif _, ok := cb.snapshots[snapshot]; !ok {\n\t\treturn errors.Wrapf(ErrInvalidDB, \"invalid snapshot number = %d\", snapshot)\n\t}\n\tcb.KVStoreBatch = nil\n\tcb.KVStoreCache = nil\n\tcb.KVStoreBatch = cb.snapshots[snapshot].kvBatch()\n\tcb.KVStoreCache = cb.snapshots[snapshot].kvCache()\n\treturn nil\n}", "title": "" }, { "docid": "2a2e4eb3dc2a9fb283d94172854220da", "score": "0.40898612", "text": "func (b *BladeStorage) RemoveOldNicRefs(blade *model.Blade) (count int, macAddresses []string, err error) {\n\tvar connectedMacAddresses []string\n\tfor _, nic := range blade.Nics {\n\t\tconnectedMacAddresses = append(connectedMacAddresses, nic.MacAddress)\n\t}\n\n\tif err = b.db.Model(&model.Nic{}).Where(\"mac_address not in (?) and blade_serial = ?\", connectedMacAddresses, blade.Serial).Pluck(\"mac_address\", &macAddresses).Count(&count).Error; err != nil {\n\t\treturn count, macAddresses, err\n\t}\n\n\tif count > 0 {\n\t\tif err = b.db.Where(\"mac_address in (?) and blade_serial = ?\", macAddresses, blade.Serial).Delete(model.Nic{}).Error; err != nil {\n\t\t\treturn count, macAddresses, err\n\t\t}\n\t}\n\n\treturn count, macAddresses, err\n}", "title": "" }, { "docid": "965f91663aba26a9be413c0b6d3f600e", "score": "0.4081584", "text": "func Unbundle(bundle io.Reader, localPath string) error {\n return UnzipAndUntar(localPath, bundle)\n}", "title": "" }, { "docid": "76430af2798704ef3408270d575dad7e", "score": "0.407583", "text": "func (fs *fileStorage) restoreIndexFile() error {\n\tIsOneFileProcessed := false\n\tif err := fs.prepareIndexFile(); err != nil {\n\t\treturn err\n\t}\n\tpath := fs.folder[:len(fs.folder)-1]\n\tlistFiles, err := ioutil.ReadDir(path)\n\tif err == nil {\n\t\tfor _, finfo := range listFiles {\n\t\t\tif finfo.IsDir() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfname := finfo.Name()\n\t\t\tif fname == \"index.dat\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tidx := checkValidFileDataName(fname)\n\t\t\tif idx == -1 {\n\t\t\t\tfn := fs.folder + fname\n\t\t\t\tfs.log.Info(\"Remove unknown file %s\", fn)\n\t\t\t\terr = os.Remove(fn)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\terr = fs.restoreStorageFile(StorageIdx(idx))\n\t\t\tif err != nil {\n\t\t\t\tfn := fs.folder + fname\n\t\t\t\tfs.log.Info(\"Remove unknown file %s\", fn)\n\t\t\t\terr = os.Remove(fn)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tIsOneFileProcessed = true\n\t\t}\n\t}\n\tif !IsOneFileProcessed {\n\t\treturn errors.New(\"not found any valid storage file\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "0bab562da3539fe83ac5e1c53c42eeac", "score": "0.40648732", "text": "func (kc *MessageBufferHandle) pruneOldFiles() error {\n\n\tfiles, err := ioutil.ReadDir(kc.bufferConfig.BufferDir)\n\tif err != nil {\n\t\tkc.logger.Info(\"Cannot readDir\", kc.bufferConfig.BufferDir)\n\t\treturn nil\n\t}\n\n\tvar totalSize int64\n\tfor i := len(files) - 1; i >= 0; i-- {\n\t\tf := files[i]\n\t\tname := f.Name()\n\t\tif name[0:1] == readyPrefix {\n\t\t\tfi, err := os.Stat(path.Join(kc.bufferConfig.BufferDir, name))\n\t\t\tif err == nil {\n\t\t\t\tif totalSize > int64(kc.bufferConfig.TotalSize)*1000000 {\n\t\t\t\t\tos.Remove(path.Join(kc.bufferConfig.BufferDir, name)) // fail is ok\n\t\t\t\t} else {\n\t\t\t\t\ttotalSize += fi.Size()\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tkc.logger.Info(\"Cannot Stat\", name)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "0ed063c75ede562068624d4ff5940b0b", "score": "0.40454125", "text": "func Restore() {\n\tprojects := read()\n\tproject := currentProject()\n\tbranch := projects[project]\n\t_, err := run(\"git\", \"checkout\", branch)\n\tif err != nil {\n\t\tfmt.Println(\"error: invalid branch\")\n\t\tos.Exit(1)\n\t}\n\tfmt.Printf(\"branch: restored `%s`\\n\", branch)\n}", "title": "" }, { "docid": "cf7480823669e45eb624e725e837a9f3", "score": "0.40394416", "text": "func (p *broStructure) MakeReversedRefs() {\n\tfor _, pkg := range p.packageFiles {\n\t\tfor _, file := range pkg.Files {\n\t\t\tfor _, obj := range file.Scope.Objects {\n\t\t\t\tp.reversedObjects[obj.Kind][obj] = &types.Object{\n\t\t\t\t\tObject: obj,\n\t\t\t\t\tCommentGroup: findCommentForObject(obj, file.Comments),\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "b37af8c2d300ffe34acd7ecaacabd675", "score": "0.40314126", "text": "func (sdk Sdk) Unarchive() error {\n\tif !sdk.IsArchived() {\n\t\treturn custom_errors.ErrArcNotIns\n\t}\n\t_ = os.Mkdir(candPath(sdk.SdkHome, sdk.Candidate), os.ModeDir|os.ModePerm)\n\n\twd := sdk.installPath()\n\terr := archiver.Unarchive(sdk.archiveFile(), wd)\n\tif err != nil {\n\t\t_ = os.RemoveAll(wd)\n\t}\n\n\t// for nested directory like java:\n\tif l, _ := ioutil.ReadDir(wd); len(l) == 1 && l[0].IsDir() {\n\t\tnestedRoot := l[0].Name()\n\t\tinside, _ := ioutil.ReadDir(filepath.Join(wd, nestedRoot))\n\t\tfor _, c := range inside {\n\t\t\tos.Rename(filepath.Join(wd, nestedRoot, c.Name()), filepath.Join(wd, c.Name()))\n\t\t}\n\t\tos.Remove(nestedRoot)\n\t}\n\treturn err\n}", "title": "" }, { "docid": "8d8c88354637808ebee385a7c9aaea9b", "score": "0.4028414", "text": "func CiliumPath() string {\n\tonce.Do(lockDown)\n\treturn filepath.Join(bpffsRoot, \"cilium\")\n}", "title": "" }, { "docid": "1e18dd3f13a4a80b3ebc990875ffe285", "score": "0.39991087", "text": "func (r *ImageRef) Invert() error {\n\tout, err := vipsInvert(r.image)\n\tif err != nil {\n\t\treturn err\n\t}\n\tr.setImage(out)\n\treturn nil\n}", "title": "" }, { "docid": "bb64aa1d28a29a060b19a73f9bbe7e79", "score": "0.39956835", "text": "func (blockchain *BlockChain) RevertBeaconState() {\n\n}", "title": "" }, { "docid": "3c49dd05205b08be607eef53ba3c7c1f", "score": "0.39940342", "text": "func (di *dataIndexer) RevertIndexedBlock(header coreData.HeaderHandler, body coreData.BodyHandler) {\n\twi := workItems.NewItemRemoveBlock(\n\t\tdi.elasticProcessor,\n\t\tbody,\n\t\theader,\n\t)\n\tdi.dispatcher.Add(wi)\n}", "title": "" }, { "docid": "11feb2227d1a3d70adf8029c70ada03b", "score": "0.39933652", "text": "func finalizeMap(bpffsPath, name string, revert bool) error {\n\t// Attempt to open a 'pending' Map pin.\n\tfile := filepath.Join(bpffsPath, name+bpffsPending)\n\tpending, err := ebpf.LoadPinnedMap(file, nil)\n\n\t// Given map was not pending recreation, nothing to do.\n\tif errors.Is(err, unix.ENOENT) {\n\t\treturn nil\n\t}\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to open pinned map at path %s: %v\", name, err)\n\t}\n\n\t// Pending Map was found on bpffs and needs to be reverted.\n\tif revert {\n\t\tdest := filepath.Join(bpffsPath, name)\n\t\tlog.WithFields(logrus.Fields{\n\t\t\tlogfields.BPFMapPath: dest,\n\t\t\tlogfields.BPFMapName: name,\n\t\t}).Infof(\"Repinning without '%s' suffix after failed migration\", bpffsPending)\n\n\t\t// Atomically re-pin the map to its original path.\n\t\tif err := pending.Pin(dest); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t}\n\n\tlog.WithFields(logrus.Fields{\n\t\tlogfields.BPFMapPath: file,\n\t\tlogfields.BPFMapName: name,\n\t}).Info(\"Unpinning map after successful recreation\")\n\n\t// Pending Map found on bpffs and its replacement was successfully loaded.\n\t// Unpin the old map since it no longer needs to be interacted with from userspace.\n\treturn pending.Unpin()\n}", "title": "" }, { "docid": "02d78c316809afeae4e2789fdaf2a71b", "score": "0.39873505", "text": "func Relabel(path string, fileLabel string, relabel string) error {\n\tif fileLabel == \"\" {\n\t\treturn nil\n\t}\n\tif relabel == \"z\" {\n\t\tc := selinux.NewContext(fileLabel)\n\t\tc[\"level\"] = \"s0\"\n\t\tfileLabel = c.Get()\n\t}\n\treturn selinux.Chcon(path, fileLabel, true)\n}", "title": "" }, { "docid": "61d05c507b5432eaac183ec9e98933d5", "score": "0.39694217", "text": "func (mr *Master) CleanupFiles() {\n\tfor i := range mr.files {\n\t\tfor j := 0; j < mr.nReduce; j++ {\n\t\t\tremoveFile(reduceName(mr.jobName, i, j))\n\t\t}\n\t}\n\tfor i := 0; i < mr.nReduce; i++ {\n\t\tremoveFile(mergeName(mr.jobName, i))\n\t}\n\tremoveFile(\"mrtmp.\" + mr.jobName)\n}", "title": "" }, { "docid": "ce1d35dc45c2d66935bda45a523afcfa", "score": "0.3969361", "text": "func FileBackup(filename string) error {\n\tif *FlagIoFileBackups < 1 {\n\t\treturn nil\n\t}\n\n\tfor i := *FlagIoFileBackups - 1; i >= 0; i-- {\n\t\tsrc := filename\n\t\tif i > 0 {\n\t\t\tsrc = src + \".\" + strconv.Itoa(i)\n\t\t}\n\n\t\tdst := \"\"\n\t\tif *FlagIoFileBackups == 1 {\n\t\t\tdst = filename + \".bak\"\n\t\t} else {\n\t\t\tdst = filename + \".\" + strconv.Itoa(i+1)\n\t\t}\n\n\t\tif FileExists_(src) {\n\t\t\tif FileExists_(dst) {\n\t\t\t\terr := FileDelete(dst)\n\t\t\t\tif Error(err) {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\terr := os.Rename(src, dst)\n\t\t\tif Error(err) {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "f5d16fa8021f08e72c7dbac61dae7726", "score": "0.39622608", "text": "func Restore(box *packr.Box, output string) error {\n\tif err := box.Walk(func(name string, fd packd.File) error {\n\t\tcontent, err := box.Find(name)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tdest := filepath.Join(output, name)\n\t\tif err := utils.EnsureFile(dest); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := ioutil.WriteFile(dest, content, 0600); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t}); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "01497b402956a28bbd32faef4e737692", "score": "0.39600635", "text": "func (e *Executor) Revert(ctx context.Context, revertTo types.LayerID) error {\n\te.mu.Lock()\n\tdefer e.mu.Unlock()\n\n\tlogger := e.logger.WithContext(ctx).WithFields(log.Stringer(\"revert_to\", revertTo))\n\tif err := e.vm.Revert(revertTo); err != nil {\n\t\treturn fmt.Errorf(\"revert state: %w\", err)\n\t}\n\tif err := e.cs.RevertCache(revertTo); err != nil {\n\t\treturn fmt.Errorf(\"revert cache: %w\", err)\n\t}\n\troot, err := e.vm.GetStateRoot()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get state hash: %w\", err)\n\t}\n\tlogger.Event().Info(\"reverted state\", log.Stringer(\"state_hash\", root))\n\treturn nil\n}", "title": "" }, { "docid": "259ebdefd23c8a9566f55323c6495763", "score": "0.3959672", "text": "func Down(c *cli.Context) {\n\tinputFile := c.GlobalString(\"file\")\n\tdabFile := c.GlobalString(\"bundle\")\n\n\tkomposeObject := kobject.KomposeObject{\n\t\tServiceConfigs: make(map[string]kobject.ServiceConfig),\n\t}\n\n\tfile := inputFile\n\tif len(dabFile) > 0 {\n\t\tinputFormat = \"bundle\"\n\t\tfile = dabFile\n\t}\n\n\topt := kobject.ConvertOptions{\n\t\tReplicas: 1,\n\t\tCreateD: true,\n\t}\n\n\tvalidateFlags(opt, false, dabFile, inputFile)\n\n\t// loader parses input from file into komposeObject.\n\tl, err := loader.GetLoader(inputFormat)\n\tif err != nil {\n\t\tlogrus.Fatal(err)\n\t}\n\n\tkomposeObject = l.LoadFile(file)\n\n\t// get transformer\n\tt := new(kubernetes.Kubernetes)\n\n\t//Remove deployed application\n\terrUndeploy := t.Undeploy(komposeObject, opt)\n\tif errUndeploy != nil {\n\t\tlogrus.Fatalf(\"Error while deleting application: %s\", err)\n\t}\n\n}", "title": "" }, { "docid": "a3563c59d121fff2d2930324a7d2a74f", "score": "0.3941662", "text": "func RevertAll() error {\n\terr := assertMigrationTable()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmigrations, err := all()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tordered := SortMigrations(migrations, \"desc\")\n\n\tfor _, m := range ordered {\n\t\t_, err := m.Revert()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "fed1f90e3d53c857e3e4d67c0abe524b", "score": "0.39391083", "text": "func (c *Client) CleanUp(imagename, tagname string) error {\n\timageName := imagename + \":\" + tagname\n\tglog.Infof(\"About to clean up docker image:%s.\", imageName)\n\n\terr := c.RemoveImage(imageName)\n\tif err == nil {\n\t\tglog.Infof(\"Successfully remove docker image:%s.\", imageName)\n\t} else {\n\t\tglog.Errorf(\"Remove docker image:%s failed.\", imageName)\n\t}\n\n\treturn err\n}", "title": "" }, { "docid": "c51ddaa197246a9db33b3129e20fcfc0", "score": "0.3938262", "text": "func (c *CLI) Recreate(config IAASEnvironment, ip, password, ca string) error {\n\tcaPath, err := writeTempFile([]byte(ca))\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer os.Remove(caPath)\n\tip = fmt.Sprintf(\"https://%s\", ip)\n\tcmd := c.execCmd(c.boshPath, \"--non-interactive\", \"--environment\", ip, \"--ca-cert\", caPath, \"--client\", \"admin\", \"--client-secret\", password, \"--deployment\", \"concourse\", \"recreate\")\n\tcmd.Stderr = os.Stderr\n\tcmd.Stdout = os.Stdout\n\treturn cmd.Run()\n}", "title": "" }, { "docid": "1d11f98af8ccc777985f9bf779bbc75e", "score": "0.3937729", "text": "func (s *State) invertContractMaintenance() (diffs []OutputDiff) {\n\t// Repen all contracts that terminated, and remove the corresponding output.\n\tfor _, openContract := range s.currentBlockNode().ContractTerminations {\n\t\tid := openContract.ContractID\n\t\ts.openContracts[id] = openContract\n\t\tcontractStatus := openContract.Failures == openContract.FileContract.Tolerance\n\t\toutputID := ContractTerminationOutputID(id, contractStatus)\n\t\tdiff := OutputDiff{New: false, ID: outputID, Output: s.unspentOutputs[outputID]}\n\t\tdelete(s.unspentOutputs, outputID)\n\t\tdiffs = append(diffs, diff)\n\t}\n\n\t// Reverse all outputs created by missed storage proofs.\n\tfor _, missedProof := range s.currentBlockNode().MissedStorageProofs {\n\t\tcid, oid := missedProof.ContractID, missedProof.OutputID\n\t\ts.openContracts[cid].FundsRemaining += s.unspentOutputs[oid].Value\n\t\ts.openContracts[cid].Failures -= 1\n\t\tdiff := OutputDiff{New: false, ID: oid, Output: s.unspentOutputs[oid]}\n\t\tdelete(s.unspentOutputs, oid)\n\t\tdiffs = append(diffs, diff)\n\t}\n\n\t// Reset the window satisfied variable to true for all successful windows.\n\tfor _, id := range s.currentBlockNode().SuccessfulWindows {\n\t\ts.openContracts[id].WindowSatisfied = true\n\t}\n\treturn\n}", "title": "" }, { "docid": "0684bb73af2d1b236529d1ef4bf08991", "score": "0.3933824", "text": "func Clean() error {\n\tfixtureDir := filepath.Join(\"integration\", \"testdata\", \"fixtures\")\n\tpaths := []string{\n\t\tfilepath.Join(fixtureDir, \"images\"),\n\t\tfilepath.Join(fixtureDir, \"vm-images\"),\n\t}\n\tfor _, p := range paths {\n\t\tif err := sh.Rm(p); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "324af1c5d965eff2c7fa7e71812fa0ad", "score": "0.39317307", "text": "func cleanDiscoCache(absolutePath string, filepaths []string, updated map[string]bool, errors *errorlist.Errors) {\n\tfor _, fp := range filepaths {\n\t\t_, filename := filepath.Split(fp)\n\t\tif !updated[filename] {\n\t\t\tfp = path.Join(absolutePath, filename)\n\t\t\tif err := os.Remove(fp); err != nil {\n\t\t\t\terrors.Add(fmt.Errorf(\"Error deleting expired Discovery doc %v: %v\", fp, err))\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "7a772767ea2f36b24803240891e841c6", "score": "0.39263347", "text": "func Uncompress() gonzo.Stage {\n\treturn func(ctx context.Context, in <-chan gonzo.File, out chan<- gonzo.File) error {\n\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase file, ok := <-in:\n\t\t\t\tif !ok {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\n\t\t\t\tcontent, err := gzip.NewReader(file)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\tfs := gonzo.NewFile(\n\t\t\t\t\t&doublecloser{content, file.Close},\n\t\t\t\t\tgonzo.FileInfoFrom(file.FileInfo()),\n\t\t\t\t)\n\n\t\t\t\tout <- fs\n\t\t\tcase <-ctx.Done():\n\t\t\t\treturn ctx.Err()\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "ddf0d375075e098590b28be6129392a6", "score": "0.39262125", "text": "func (c *Switch) Revert(mod int) {\n\tc.lock.RLock()\n\tfor _, v := range c.subRenderables {\n\t\tswitch t := v.(type) {\n\t\tcase *Reverting:\n\t\t\tt.Revert(mod)\n\t\t}\n\t}\n\tc.lock.RUnlock()\n}", "title": "" }, { "docid": "5aa358f7f7d89c9adf6219915ba3315a", "score": "0.39162642", "text": "func cleanupChange(p4 p4lib.P4, change int) error {\n\tif _, err := p4.ExecCmd(\"revert\", \"-c\", strconv.Itoa(change), \"//...\"); err != nil {\n\t\treturn fmt.Errorf(\"could not revert change %d: %v\", change, err)\n\t}\n\tif _, err := p4.ExecCmd(\"change\", \"-d\", strconv.Itoa(change)); err != nil {\n\t\treturn fmt.Errorf(\"could not delete change %d: %v\", change, err)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "75c7ea6f8b839f9e3ecbfe52fd70d763", "score": "0.3908698", "text": "func RemoveBinaries(paths []string) error {\n\tfor _, p := range paths {\n\t\tdelete(cfg.Bins, p)\n\t}\n\n\treturn write()\n}", "title": "" }, { "docid": "b8c05c5371d5e6a4e0732d5938eedb58", "score": "0.38925222", "text": "func GitUnignore(wd string, thatPath string) error {\n\tif !IsIgnored(wd, thatPath) {\n\t\treturn nil\n\t}\n\n\tgitignorePath := path.Join(wd, \".gitignore\")\n\tif utils.FileExists(gitignorePath) {\n\t\t/* #nosec */\n\t\tgitignore, err := os.OpenFile(gitignorePath, os.O_RDONLY, 0o644)\n\t\tif err != nil {\n\t\t\treturn nil\n\t\t}\n\n\t\tscanner := bufio.NewScanner(gitignore)\n\t\tthatPath = strings.Trim(thatPath, \" \")\n\n\t\tlines := make([]string, 0)\n\t\tfor scanner.Scan() {\n\t\t\tif err := scanner.Err(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tline := scanner.Text()\n\t\t\tif strings.Trim(line, \" \") != thatPath {\n\t\t\t\tlines = append(lines, line)\n\t\t\t}\n\t\t}\n\t\tutils.Close(gitignore)\n\n\t\tcontents := []byte(strings.Join(lines, \"\\n\"))\n\n\t\tioutil.WriteFile(gitignorePath, contents, 0o600)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "147c8debb1a8812e70910393e1e66b37", "score": "0.38924444", "text": "func (bagStorer *BagStorer) doCleanUp() {\n\tfor helper := range bagStorer.CleanUpChannel {\n\t\tresult := helper.Result\n\t\tresult.NsqMessage.Touch()\n\t\tbagStorer.ProcUtil.MessageLog.Debug(\"Cleaning up %s\", result.S3File.Key.Key)\n\t\tif (result.S3File.Key.Key != \"\" && result.FetchResult != nil &&\n\t\t\tresult.FetchResult.LocalFile != \"\") {\n\t\t\t// Clean up any files we downloaded and unpacked\n\t\t\terrors := helper.DeleteLocalFiles()\n\t\t\tif errors != nil && len(errors) > 0 {\n\t\t\t\tbagStorer.ProcUtil.MessageLog.Warning(\"Errors cleaning up %s\",\n\t\t\t\t\tresult.FetchResult.LocalFile)\n\t\t\t\tfor _, e := range errors {\n\t\t\t\t\tbagStorer.ProcUtil.MessageLog.Error(e.Error())\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Build and send message back to NSQ, indicating whether\n\t\t// processing succeeded.\n\t\tif result.ErrorMessage != \"\" && result.Retry == true {\n\t\t\tbagStorer.ProcUtil.MessageLog.Info(\"Requeueing %s\", result.S3File.Key.Key)\n\t\t\tresult.NsqMessage.Requeue(5 * time.Minute)\n\t\t} else {\n\t\t\tresult.NsqMessage.Finish()\n\t\t}\n\n\t\t// We're done processing this, so remove it from the map.\n\t\t// If it comes in again, we'll reprocess it again.\n\t\tbagStorer.ProcUtil.UnregisterItem(result.S3File.BagName())\n\t}\n}", "title": "" }, { "docid": "995abd5cdccd9fd83a36753581d3cd25", "score": "0.3890295", "text": "func removeNum(){\r\n\tnameSlice := strings.Split(fileName,\"\")\r\n\tfor i := len(nameSlice)-1; i >= 0; i-- {\r\n\t\tif _, err := strconv.Atoi(nameSlice[i]); err == nil {\r\n\t\t\tif i != len(nameSlice)-1 {\r\n\t\t\t\tfor j := i; j < len(nameSlice)-1; j++{\r\n\t\t\t\t\tnameSlice[j] = nameSlice[j+1]\r\n\t\t\t\t}\r\n\t\t\t} \r\n\t\t\tnameSlice = nameSlice[:len(nameSlice)-1] \r\n\t\t}\r\n\t}\r\n\tnewName = strings.Join(nameSlice, \"\")\r\n\tfileName = newName\r\n}", "title": "" }, { "docid": "505cccceef68a1e85efea5fabae3b13e", "score": "0.3887853", "text": "func cleanupUpper(ctx context.Context, parent *Inode, name string) {\n\tif err := parent.InodeOperations.Remove(ctx, parent, name); err != nil {\n\t\t// Unfortunately we don't have much choice. We shouldn't\n\t\t// willingly give the caller access to a nonsense filesystem.\n\t\tpanic(fmt.Sprintf(\"overlay filesystem is in an inconsistent state: failed to remove %q from upper filesystem: %v\", name, err))\n\t}\n}", "title": "" }, { "docid": "b1ae148095c80c08ccbf8c1711556074", "score": "0.388363", "text": "func commandUninstall(c *cli.Context) error {\n\n\tif c.Args().Present() && c.Args().Get(0) != \"\" {\n\t\tprocessPathArgument(c.Args().Get(0))\n\t}\n\n\t// Find git repository. First, start from gitlab-ci file location\n\tgitRepoPath, err := findGitRepo(filepath.Dir(gitlabCiFilePath))\n\tif err == nil {\n\t\t// if not found, search from directoryRoot\n\t\tgitRepoPath, _ = findGitRepo(directoryRoot)\n\t}\n\n\tif gitRepoPath == \"\" {\n\t\treturn cli.NewExitError(fmt.Sprintf(\"No GIT repository found, can't install a hook\"), 5)\n\t}\n\tif verboseMode {\n\t\tfmt.Printf(\"Git repository found: %s\\n\", gitRepoPath)\n\t}\n\n\tstatus, err := deleteGitHookLink(gitRepoPath, \"pre-commit\")\n\tif err != nil {\n\t\treturn cli.NewExitError(err, 5)\n\t}\n\tswitch status {\n\tcase HookNotMatching:\n\t\tred := color.New(color.FgRed).SprintFunc()\n\t\tmsg := fmt.Sprintf(red(\"Unknown pre-commit hook\\nPlease uninstall manually.\"))\n\t\treturn cli.NewExitError(msg, 4)\n\tcase HookNotExisting:\n\t\tyellow := color.New(color.FgYellow).SprintFunc()\n\t\tfmt.Fprintf(color.Output, yellow(\"No pre-commit hook found.\\n\"))\n\tcase HookDeleted:\n\t\tgreen := color.New(color.FgGreen).SprintFunc()\n\t\tfmt.Fprintf(color.Output, green(\"Git pre-commit hook uinstalled.\\n\"))\n\tdefault:\n\t\treturn cli.NewExitError(\"Unkown error\", 5)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "8cc4efb5c935eb0e2605ac77e7114d56", "score": "0.38731083", "text": "func ForceCleanBackups(kubeClient kubernetes.Interface, extClient versioned.Interface, apiExtClient apiextensionsclientset.Interface) error {\n\tif _, err := apiExtClient.ApiextensionsV1().CustomResourceDefinitions().Get(context.TODO(), \"backups.pingcap.com\", metav1.GetOptions{}); err != nil {\n\t\tif !errors.IsNotFound(err) {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}\n\tnsList, err := kubeClient.CoreV1().Namespaces().List(context.TODO(), metav1.ListOptions{})\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, item := range nsList.Items {\n\t\tns := item.Name\n\t\tbl, err := extClient.PingcapV1alpha1().Backups(ns).List(context.TODO(), metav1.ListOptions{})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to list backups in namespace %s: %v\", ns, err)\n\t\t}\n\t\tfor i := range bl.Items {\n\t\t\tname := bl.Items[i].Name\n\t\t\tif err := extClient.PingcapV1alpha1().Backups(ns).Delete(context.TODO(), name, metav1.DeleteOptions{}); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to delete backup(%s) in namespace %s: %v\", name, ns, err)\n\t\t\t}\n\t\t\t// use patch to avoid update conflicts\n\t\t\tpatch := []byte(`[{\"op\":\"remove\",\"path\":\"/metadata/finalizers\"}]`)\n\t\t\tif _, err := extClient.PingcapV1alpha1().Backups(ns).Patch(context.TODO(), name, types.JSONPatchType, patch, metav1.PatchOptions{}); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to clean backup(%s) finalizers in namespace %s: %v\", name, ns, err)\n\t\t\t}\n\t\t}\n\t}\n\treturn err\n}", "title": "" }, { "docid": "1448b5bd480f380bfe038d0e3e8f20db", "score": "0.3872603", "text": "func (c *CephNFSController) downCephNFS(n cephv1.CephNFS, newActive int) error {\n\tfor i := n.Spec.Server.Active - 1; i >= newActive; i-- {\n\t\tname := k8sutil.IndexToName(i)\n\n\t\t// Remove from grace db\n\t\tc.removeServerFromDatabase(n, name)\n\n\t\t// Delete the mds deployment\n\t\tk8sutil.DeleteDeployment(c.context.Clientset, n.Namespace, instanceName(n, name))\n\n\t\t// Delete the ganesha service\n\t\toptions := &metav1.DeleteOptions{}\n\t\terr := c.context.Clientset.CoreV1().Services(n.Namespace).Delete(instanceName(n, name), options)\n\t\tif err != nil && !errors.IsNotFound(err) {\n\t\t\tlogger.Warningf(\"failed to delete ganesha service. %+v\", err)\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "9e13d462c2b08db07131b80f9e4c924f", "score": "0.38714498", "text": "func TestDeleteRepoFileWithoutBranchNames(t *testing.T) {\n\tonGiteaRun(t, testDeleteRepoFileWithoutBranchNames)\n}", "title": "" }, { "docid": "bdce611670bad9d3f4f4ee3af1ff8cf4", "score": "0.3871392", "text": "func (c *Switch) RevertAll() {\n\tc.lock.RLock()\n\tfor _, v := range c.subRenderables {\n\t\tswitch t := v.(type) {\n\t\tcase *Reverting:\n\t\t\tt.RevertAll()\n\t\t}\n\t}\n\tc.lock.RUnlock()\n}", "title": "" }, { "docid": "54b5b2ad6177fc5317196a24693a4113", "score": "0.3866899", "text": "func (repo *Repo) Clean() error {\n\tfmt.Fprintln(os.Stderr, \"Cleaning repo \", repo.Path)\n\n\ttoRmStr, err := execCmdCombinedOutput(repo.Path, \"git\", \"clean\", \"-ndx\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Build a map of the externs\n\textMap := make(map[string]bool, len(repo.Externals))\n\tfor _, ext := range repo.Externals {\n\t\textRelPath := strings.Trim(strings.Replace(ext.Path, repo.Path, \"\", 1), \"/\")\n\t\textMap[extRelPath] = true\n\t}\n\n\ttoRm := strings.Split(string(toRmStr), \"\\n\")\n\tfor i := range toRm {\n\t\tr := strings.Replace(toRm[i], \"Would remove \", \"\", 1)\n\t\tr = strings.Trim(r, \"/\")\n\n\t\tif r == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tqualifiedR := path.Join(repo.Path, r)\n\n\t\tif !extMap[r] {\n\t\t\tif !dryRun {\n\t\t\t\terr = os.RemoveAll(qualifiedR)\n\t\t\t\tif err != nil {\n\t\t\t\t\tfmt.Fprintln(os.Stdout, err)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfmt.Printf(\"Would remove %q\\n\", qualifiedR)\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, ext := range repo.Externals {\n\t\terr = ext.Clean()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "e9b90b72465adf33d1bba8ca49b4a429", "score": "0.38654655", "text": "func (Bpf) Clean() error {\n\n\tfmt.Println(\"Removing directory\", bpfBuildPath, \"..\")\n\tif err := os.RemoveAll(bpfBuildPath); err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Println(\"Removing kernel configurations ..\")\n\tfor _, k := range kernel.Builds {\n\t\tp := path.Join(k.Directory(), \".config\")\n\t\tif mg.Verbose() {\n\t\t\tfmt.Println(\"Removing\", p, \"..\")\n\t\t}\n\t\tif err := os.RemoveAll(p); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "c9fc7836201fd8305f64fe200e71b523", "score": "0.386378", "text": "func processDirectory(dirpath string) {\r\n\r\n\tvar wg sync.WaitGroup\r\n\r\n\terr := filepath.Walk(dirpath, func(path string, info os.FileInfo, err error) error {\r\n\t\tif info.IsDir() {\r\n\t\t\treturn nil\r\n\t\t}\r\n\t\twg.Add(1)\r\n\t\tprocessFile(path, dirpath, &wg)\r\n\t\treturn nil\r\n\t})\r\n\r\n\twg.Wait()\r\n\r\n\tif err != nil {\r\n\t\tlog.Fatal(err)\r\n\t\ttime.Sleep(10 * time.Second)\r\n\t\treturn\r\n\t}\r\n\r\n\t// compress\r\n\tcandiname := dirpath\r\n\text := \".zip\"\r\n\t// add _re until not exist file\r\n\tfor {\r\n\t\tif _, err := os.Stat(candiname + ext); os.IsNotExist(err) {\r\n\t\t\tbreak\r\n\t\t}\r\n\t\tcandiname += \"_re\"\r\n\t}\r\n\r\n\tfmt.Println(dirpath + \"_re\")\r\n\t// bandizip.exe doesn't save top folder name, but bc.exe does, so use *.* with -r\r\n\tcmd := exec.Command(zipApp, \"c\", \"-r\", candiname+ext, dirpath+\"_re\\\\*.*\")\r\n\texecErr := cmd.Run()\r\n\tif execErr != nil {\r\n\t\tpanic(execErr)\r\n\t}\r\n\r\n\t// delete folder A_re\r\n\tos.RemoveAll(dirpath + \"_re\")\r\n}", "title": "" }, { "docid": "bd0fc79a9d385342360d0511856a544f", "score": "0.38611823", "text": "func ResetUnstage(c *Client, opts ResetOptions, tree Treeish, files []File) error {\n\tindex, _ := c.GitDir.ReadIndex()\n\tdiffs, err := DiffIndex(c, DiffIndexOptions{Cached: true}, index, tree, files)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, entry := range diffs {\n\t\tf, err := entry.Name.FilePath(c)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmtime, err := f.MTime()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif entry.Src == (TreeEntry{}) {\n\t\t\t// The file wasn't in HEAD. Remove it from the index,\n\t\t\t// but only do it for files that were explicitly removed.\n\t\t\tfor _, unstage := range files {\n\t\t\t\tif f == unstage {\n\t\t\t\t\tindex.RemoveFile(entry.Name)\n\t\t\t\t}\n\t\t\t}\n\t\t} else if err := index.AddStage(c, entry.Name, entry.Src.FileMode, entry.Src.Sha1, Stage0, uint32(entry.SrcSize), mtime, UpdateIndexOptions{Add: true}); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tf, err := c.GitDir.Create(File(\"index\"))\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\tif err := index.WriteIndex(f); err != nil {\n\t\treturn err\n\t}\n\n\tif !opts.Quiet {\n\t\tnewdiff, err := DiffFiles(c, DiffFilesOptions{}, nil)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif len(newdiff) > 0 {\n\t\t\tfmt.Printf(\"Unstaged changes after reset:\\n\")\n\t\t}\n\t\tfor _, file := range newdiff {\n\t\t\tvar status string\n\t\t\tif file.Dst == (TreeEntry{}) {\n\t\t\t\tstatus = \"D\"\n\t\t\t} else {\n\t\t\t\tstatus = \"M\"\n\t\t\t}\n\t\t\tfmt.Printf(\"%v\\t%v\\n\", status, file.Name)\n\t\t}\n\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "b5aa74b505b432a8de7209f9f4446536", "score": "0.38574368", "text": "func noVCSSuffix(ctx context.Context, match map[string]string, gitreq *cache.Request) error {\n\trepo := match[\"repo\"]\n\tfor _, vcs := range vcsList {\n\t\tif strings.HasSuffix(repo, \".\"+vcs) {\n\t\t\treturn fmt.Errorf(\"invalid version control suffix in %s path\", match[\"prefix\"])\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "19946d0a905c3aca9472a40c25d40e29", "score": "0.38442802", "text": "func (b *Builder) Cancel() error {\n\t// acuire the lock\n\tb.mu.Lock()\n\tdefer b.mu.Unlock()\n\n\terr := kustomize.CleanDirectory(b.resourcesPath, b.action)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "53380b041673470e278efe3c65ca5710", "score": "0.38441056", "text": "func Rewrite(local, path string) (err error) {\n\tvar (\n\t\tbackup string\n\t\tmirror *os.File\n\t\tupdated *os.File\n\t)\n\n\tif backup, err = cloned(path, path+\".pacmir.backup\"); err != nil {\n\t\treturn err\n\t}\n\n\tif updated, err = ioutil.TempFile(filepath.Dir(path), filepath.Base(path)+\".pacmir.*\"); err != nil {\n\t\treturn err\n\t}\n\tdefer os.Remove(updated.Name())\n\tdefer updated.Close()\n\n\tif mirror, err = os.Open(backup); err != nil {\n\t\treturn err\n\t}\n\tdefer mirror.Close()\n\n\tif err = Clean(local, mirror, updated); err != nil {\n\t\treturn err\n\t}\n\n\tif err = os.Remove(path); err != nil {\n\t\treturn err\n\t}\n\n\tif _, err = cloned(backup, path); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n\t// return os.Rename(clonedp, path+\".pacmir.foo\")\n}", "title": "" }, { "docid": "892ea3ac46bbb11ca84dc74b509f2136", "score": "0.38390723", "text": "func Rollback(n int) error {\n\terr := assertMigrationTable()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmigrations, err := all()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tordered := SortMigrations(migrations, \"desc\")\n\n\tcount := 1\n\n\tfor _, m := range ordered {\n\t\t// If the count of performed migrations if greater than the number to rollback, we're done.\n\t\tif count > n {\n\t\t\tbreak\n\t\t}\n\t\tcompleted, err := m.Revert()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// Only increment the counter if the migration was completed.\n\t\tif completed {\n\t\t\tcount++\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "d03210bf9d50452011b465d78300fa16", "score": "0.38287246", "text": "func Backups(filename string) (int, error) {\n if b, err := IsFile(filename); err == nil {\n if !b {\n // TODO type\n return -1, errors.New(\"not a file: \" + filename)\n }\n } else {\n return -1, err\n }\n // NOTSURE read all entries in dir instead of distinct stat()s\n dir := filepath.Dir(filename)\n fis, err := ioutil.ReadDir(dir)\n if err != nil {\n return -1, err\n }\n\n // store in Set\n m := make(map[string]bool)\n for _, fi := range fis {\n m[fi.Name()] = true\n }\n\n basename := filepath.Base(filename)\n for i := 1; ; i++ {\n if !m[basename+Ext(i)] {\n return i - 1, nil\n }\n }\n return 0, nil\n}", "title": "" }, { "docid": "3b0f4a0d04fdc94e9db976a1d76da91e", "score": "0.38199052", "text": "func CleanUp(ctx context.Context, cfg *config.Config, pipeline *pipelines.Pipeline, name names.Name) error {\n\tkubectlPath, err := cfg.Tools[config.Kubectl].Resolve()\n\tif err != nil {\n\t\treturn err\n\t}\n\tcmd := proc.GracefulCommandContext(ctx, kubectlPath, \"delete\",\n\t\t\"all\",\n\t\t\"-l\", k8s.StackLabel+\"=\"+name.DNSName(),\n\t)\n\tif err := cmd.Run(); err != nil {\n\t\treturn fmt.Errorf(\"could not delete k8s resources: %v\", err)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "d36190919f2292ba885c7f31d3290ad5", "score": "0.3812921", "text": "func BackupRestore(action *recipe.Action, tmpDir string) error {\n\tpath, err := action.GetS(0)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tisSafePath, err := checkPathSafety(action.Command.Recipe, path)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tpathCRC32 := calcCRC32Q(path)\n\tbackupFile := tmpDir + \"/\" + pathCRC32\n\n\tswitch {\n\tcase !isSafePath:\n\t\treturn fmt.Errorf(\"Path is unsafe (%s)\", path)\n\tcase !fsutil.IsExist(backupFile):\n\t\treturn fmt.Errorf(\"Backup file for %s does not exist\", path)\n\t}\n\n\terr = os.Remove(path)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Can't remove original file: %v\", err)\n\t}\n\n\terr = fsutil.CopyFile(backupFile, path)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Can't copy backup file: %v\", err)\n\t}\n\n\terr = fsutil.CopyAttr(backupFile, path)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Can't copy attributes: %v\", err)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "6a8be413fd6c10f44151e21c4afa0138", "score": "0.37981656", "text": "func (repo *Repo) ConvertExternCache() error {\n\tfullCachePath := path.Join(repo.Path, oldCachePath)\n\tb, err := ioutil.ReadFile(fullCachePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\trepo.Url, err = GitSvnInfo(repo.Path, \"URL\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tbuf := bytes.NewBuffer(b)\n\terr = repo.CookExternals(buf.String())\n\tif err != nil {\n\t\treturn err\n\t} else {\n\t\t// TODO: why is extern a copy in\n\t\t// for _, extern := range repo.externals\n\t\tfor i := range repo.Externals {\n\t\t\terr = repo.Externals[i].ConvertExternCache()\n\t\t\tif err != nil {\n\t\t\t\tfmt.Fprintln(os.Stderr, \"Error converting old cache: \", err)\n\t\t\t}\n\t\t}\n\t}\n\n\terr = os.Remove(fullCachePath)\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Error deleting old cache: \", err)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "e922d87525c070f06d3053a8b0aed89c", "score": "0.37944195", "text": "func Reset(filename string, prefix string, max int, verbose bool) (err error) {\n\tdb, err := connect(prefix)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Get the changesets in a map.\n\tm, err := parseFileToMap(filename)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Get each changeset from the database.\n\tresults := make([]DBChangeset, 0)\n\terr = db.Select(&results, `\n\t\tSELECT id, author, filename, orderexecuted\n\t\tFROM databasechangelog\n\t\tORDER BY orderexecuted DESC;`)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(results) == 0 {\n\t\tif verbose {\n\t\t\tfmt.Println(\"No rollbacks to perform.\")\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tmaxCounter := 0\n\n\t// Loop through each changeset.\n\tfor _, r := range results {\n\t\tid := fmt.Sprintf(\"%v:%v:%v\", r.Author, r.ID, r.Filename)\n\n\t\tcs, ok := m[id]\n\t\tif !ok {\n\t\t\treturn errors.New(\"changeset is missing: \" + id)\n\t\t}\n\n\t\tarrQueries := strings.Split(cs.Rollbacks(), \";\")\n\n\t\ttx, err := db.Begin()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"sql error begin transaction - %v\", err.Error())\n\t\t}\n\n\t\t// Loop through each rollback.\n\t\tfor _, q := range arrQueries {\n\t\t\tif len(q) == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Execute the query.\n\t\t\t_, err = tx.Exec(q)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"sql error on rollback %v:%v - %v\", cs.author, cs.id, err.Error())\n\t\t\t}\n\t\t}\n\n\t\terr = tx.Commit()\n\t\tif err != nil {\n\t\t\terrr := tx.Rollback()\n\t\t\tif errr != nil {\n\t\t\t\treturn fmt.Errorf(\"sql error on commit rollback %v:%v - %v\", cs.author, cs.id, errr.Error())\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"sql error on commit %v:%v - %v\", cs.author, cs.id, err.Error())\n\t\t}\n\n\t\t// Delete the record.\n\t\t_, err = db.Exec(`\n\t\t\tDELETE FROM databasechangelog\n\t\t\tWHERE id = ? AND author = ? AND filename = ?\n\t\t\tLIMIT 1\n\t\t\t`, cs.id, cs.author, cs.filename)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif verbose {\n\t\t\tfmt.Printf(\"Rollback applied: %v:%v\\n\", cs.author, cs.id)\n\t\t}\n\n\t\t// Only perform the maxium number of changes based on the max value.\n\t\tmaxCounter++\n\t\tif max != 0 {\n\t\t\tif maxCounter >= max {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "7c34e797ff45b20ae28a08932ce01363", "score": "0.37924767", "text": "func FixCalicoNetworking(netConfig *cnicurrent.Result, calicoSubnetSize int, getDummyNetwork func() (*cnicurrent.Result, string, error)) error {\n\tfor n, ipConfig := range netConfig.IPs {\n\t\tlink, err := getLinkForIPConfig(netConfig, n)\n\t\tif err != nil {\n\t\t\tglog.Warningf(\"Calico fix: skipping link for config %d: %v\", n, err)\n\t\t\tcontinue\n\t\t}\n\t\thaveCalico, haveCalicoGateway, err := DetectCalico(link)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !haveCalico {\n\t\t\tcontinue\n\t\t}\n\t\tipConfig.Address.Mask = net.CIDRMask(calicoSubnetSize, 32)\n\t\tif haveCalicoGateway {\n\t\t\tdummyNetwork, nsPath, err := getDummyNetwork()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tdummyNS, err := ns.GetNS(nsPath)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif err := dummyNS.Do(func(ns.NetNS) error {\n\t\t\t\tallLinks, err := netlink.LinkList()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to list links inside the dummy netns: %v\", err)\n\t\t\t\t}\n\t\t\t\tdummyNetwork, err := ValidateAndFixCNIResult(dummyNetwork, nsPath, allLinks)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tdummyGateway, err := getDummyGateway(dummyNetwork)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tipConfig.Gateway = dummyGateway\n\t\t\t\treturn nil\n\t\t\t}); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tvar newRoutes []*cnitypes.Route\n\t\t\t// remove the default gateway\n\t\t\tfor _, r := range netConfig.Routes {\n\t\t\t\tif r.Dst.Mask != nil {\n\t\t\t\t\tones, _ := r.Dst.Mask.Size()\n\t\t\t\t\tif ones == 0 {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnewRoutes = append(newRoutes, r)\n\t\t\t}\n\t\t\tnetConfig.Routes = append(newRoutes, &cnitypes.Route{\n\t\t\t\tDst: net.IPNet{\n\t\t\t\t\tIP: net.IP{0, 0, 0, 0},\n\t\t\t\t\tMask: net.IPMask{0, 0, 0, 0},\n\t\t\t\t},\n\t\t\t\tGW: ipConfig.Gateway,\n\t\t\t})\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "6f6e246f65ff1e4875404ebab266c4c0", "score": "0.3791693", "text": "func undeployModAzNetwork(t *testing.T, workingDir string) {\n\tterraformOptions := test_structure.LoadTerraformOptions(t, workingDir)\n\n\tterraform.Destroy(t, terraformOptions)\n}", "title": "" }, { "docid": "91ed30fc75928d216da5daa30ca30b22", "score": "0.3791308", "text": "func rollback(log *zap.Logger, wg *sync.WaitGroup, defaultProjectPath, defaultDownloadPath, url string) {\n\tdefer func() {\n\t\twg.Done()\n\t}()\n\n\t// Check if the BTFS daemon server is up every 5 seconds, checked a total of five times.\n\tfor i := 0; i < 5; i++ {\n\t\ttime.Sleep(time.Second * 5)\n\t\tsh := shell.NewShell(url)\n\t\tif sh.IsUp() {\n\t\t\tlog.Info(\"BTFS node started successfully!\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tlog.Info(\"BTFS node failed to start, rollback begin!\")\n\n\t// Select binary files and configure file path based on operating system.\n\tcurrentConfigPath, backupConfigPath, _, btfsBinaryPath, btfsBackupPath, _, err := getProjectPath(defaultProjectPath, defaultDownloadPath)\n\tif err != nil {\n\t\tlog.Error(fmt.Sprintf(\"Operating system [%s], arch [%s] does not support rollback\\n\", runtime.GOOS, runtime.GOARCH))\n\t\treturn\n\t}\n\n\t// Check if the backup binary file exists.\n\tif !pathExists(btfsBackupPath) {\n\t\tlog.Error(fmt.Sprintf(\"BTFS backup binary is not exists.\"))\n\t\treturn\n\t}\n\n\t// Check if the current configure file exists.\n\tif pathExists(currentConfigPath) {\n\t\t// Delete current configure file.\n\t\terr = os.Remove(currentConfigPath)\n\t\tif err != nil {\n\t\t\tlog.Error(fmt.Sprintf(\"Delete backup configure file error, reasons: [%v]\\n\", err))\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Check if the backup configure file exists.\n\tif pathExists(backupConfigPath) {\n\t\t// Move backup configure file to current configure file.\n\t\terr = os.Rename(backupConfigPath, currentConfigPath)\n\t\tif err != nil {\n\t\t\tlog.Error(fmt.Sprintf(\"Move backup configure file error, reasons: [%v]\\n\", err))\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Check if the btfs binary file exists.\n\tif pathExists(btfsBinaryPath) {\n\t\t// Delete the btfs binary file.\n\t\terr = os.Remove(btfsBinaryPath)\n\t\tif err != nil {\n\t\t\tlog.Error(fmt.Sprintf(\"Delete btfs binary file error, reasons: [%v]\\n\", err))\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Move backup btfs binary file to current btfs binary file.\n\terr = os.Rename(btfsBackupPath, btfsBinaryPath)\n\tif err != nil {\n\t\tlog.Error(fmt.Sprintf(\"Move backup btfs binary file error, reasons: [%v]\\n\", err))\n\t\treturn\n\t}\n\n\t// Add executable permissions to btfs binary.\n\terr = os.Chmod(btfsBinaryPath, 0775)\n\tif err != nil {\n\t\tlog.Error(fmt.Sprintf(\"Chmod file error, reasons: [%v]\\n\", err))\n\t\treturn\n\t}\n\n\t// Start the btfs daemon according to different operating systems.\n\tif runtime.GOOS == \"windows\" {\n\t\tcmd := exec.Command(btfsBinaryPath, \"daemon\")\n\t\terr = cmd.Start()\n\t} else {\n\t\tcmd := exec.Command(btfsBinaryPath, \"daemon\")\n\t\terr = cmd.Start()\n\t}\n\n\t// Check if the btfs daemon start success.\n\tif err != nil {\n\t\tlog.Error(fmt.Sprintf(\"BTFS rollback failed, reasons: [%v]\", err))\n\t\treturn\n\t}\n\n\tlog.Info(\"BTFS rollback SUCCESS!\")\n}", "title": "" }, { "docid": "9b18f022dff8d4cecf92c3f329bba6fd", "score": "0.37827483", "text": "func (self *FCSInfo) cleanName(s *string, isFile bool) {\n\n\tif isFile == true {\n\t\t*s = strings.Replace(*s, \"/\", \"-\", -1)\n\t\t*s = strings.Replace(*s, \"\\\\\", \"-\", -1)\n\t}\n\n}", "title": "" }, { "docid": "af931aac346ef6718e4074b39c953748", "score": "0.37800992", "text": "func CleanupFiles(configuration *types.JobConfiguration) {\n\tjobName := configuration.JobName\n\tmapperInputFileNames := configuration.MapperInputFileNames\n\tnumReducers := configuration.NumReducers\n\n\t// Clean up mapper output files.\n\tfor mapTaskIdx := range mapperInputFileNames {\n\t\tfor reduceTaskIdx := 0; reduceTaskIdx < numReducers; reduceTaskIdx++ {\n\t\t\tfileName := IntermediateFileName(\n\t\t\t\tjobName, mapTaskIdx, reduceTaskIdx,\n\t\t\t)\n\t\t\tos.Remove(fileName)\n\t\t}\n\t}\n\n\t// Clean up reducer output files.\n\tfor reduceTaskIdx := 0; reduceTaskIdx < numReducers; reduceTaskIdx++ {\n\t\tfileName := ReducerOutputFileName(jobName, reduceTaskIdx)\n\t\tos.Remove(fileName)\n\t}\n}", "title": "" }, { "docid": "5c3e172607db03f65d052f1917dbe70b", "score": "0.37797955", "text": "func cleanUmociMetadata(bundlePath string) error {\n\tents, err := ioutil.ReadDir(bundlePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, ent := range ents {\n\t\tif ent.Name() == \"rootfs\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tos.Remove(path.Join(bundlePath, ent.Name()))\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "260827ca5c61fcb815d6e4e8858f1057", "score": "0.37768766", "text": "func GatewayRevertor(ctx model.SessionContext, ref *model.Ref) error {\n\tresources := ref.GetResources(model.Kind(GatewayKind))\n\n\tfor _, resource := range resources {\n\t\tgw, err := getGateway(ctx, ctx.Namespace, resource.Name)\n\t\tif err != nil {\n\t\t\tif errors.IsNotFound(err) { // Not found, nothing to clean\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tref.AddResourceStatus(model.ResourceStatus{Kind: GatewayKind, Name: resource.Name, Action: model.ActionFailed})\n\t\t\tbreak\n\t\t}\n\n\t\tctx.Log.Info(\"Found Gateway\", \"name\", resource.Name)\n\t\tmutatedGw := revertGateway(ctx, *gw)\n\t\terr = ctx.Client.Update(ctx, &mutatedGw)\n\t\tif err != nil {\n\t\t\tref.AddResourceStatus(model.ResourceStatus{Kind: GatewayKind, Name: resource.Name, Action: model.ActionFailed})\n\t\t\tbreak\n\t\t}\n\t\t// ok, removed\n\t\tref.RemoveResourceStatus(model.ResourceStatus{Kind: GatewayKind, Name: resource.Name})\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "7d6e3865313d2ad32e1190cf0e1abf76", "score": "0.3776773", "text": "func (o *ElemU) RestoreIvs(aux bool) (ok bool) {\n\tif aux {\n\t\tfor i, s := range o.States {\n\t\t\ts.Set(o.StatesAux[i])\n\t\t}\n\t\treturn true\n\t}\n\tfor i, s := range o.States {\n\t\ts.Set(o.StatesBkp[i])\n\t}\n\treturn true\n}", "title": "" }, { "docid": "3c5d2b59c9d92a1703b9b64d51cc45bc", "score": "0.3775733", "text": "func DeleteCNINetwork(ctx context.Context, cni gocni.CNI, client *containerd.Client, name string) error {\n\tcontainer, containerErr := client.LoadContainer(ctx, name)\n\tif containerErr == nil {\n\t\ttask, err := container.Task(ctx, nil)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"[Delete] unable to find task for container: %s\\n\", name)\n\t\t\treturn nil\n\t\t}\n\n\t\tlog.Printf(\"[Delete] removing CNI network for: %s\\n\", task.ID())\n\n\t\tid := NetID(task)\n\t\tnetns := NetNamespace(task)\n\n\t\tif err := cni.Remove(ctx, id, netns); err != nil {\n\t\t\treturn errors.Wrapf(err, \"Failed to remove network for task: %q, %v\", id, err)\n\t\t}\n\t\tlog.Printf(\"[Delete] removed: %s from namespace: %s, ID: %s\\n\", name, netns, id)\n\n\t\treturn nil\n\t}\n\n\treturn errors.Wrapf(containerErr, \"Unable to find container: %s, error: %s\", name, containerErr)\n}", "title": "" }, { "docid": "cc2dfd0ec78641676ad523c0037142e0", "score": "0.3767523", "text": "func applyIcon(iconPath string, drivePath string, prog *dialog.ProgressDialog) {\n\t//times the icon writing process\n\tdefer elapsed(\"icon writing\")()\n\t/*these errors need to be delt with eventually\n\tthis block removes existing files by the same names\n\tit should be concurrent now*/\n\tvar wg WaitGroupBar\n\twg.bar = prog\n\twg.max = 10\n\tremovals := []string{\"/.autorun.ico\", \"/autorun.inf\", \"/.VolumeIcon.icns\", \"/._\", \"/._.VolumeIcon.icns\"}\n\tfor _, file := range removals {\n\t\twg.Add(1)\n\t\tif err := asyncRemove(drivePath+file, &wg); !(err == nil || os.IsNotExist(err)) {\n\t\t\thandleErr(err)\n\t\t}\n\t}\n\twg.Wait()\n\n\t//this block writes the windows icon and autorun file\n\n\ticon, err := os.Open(iconPath)\n\thandleErr(err)\n\n\timage, _, err := image.Decode(icon)\n\thandleErr(err)\n\n\twg.Add(1)\n\tgo func() {\n\t\tdefer wg.Done()\n\t\ttarget, err := os.Create(drivePath + \"/.autorun.ico\")\n\t\thandleErr(err)\n\t\thandleErr(ico.Encode(target, image)) //write the autorun.ico image\n\t\thandleErr(target.Close())\n\t}()\n\n\twg.Add(1)\n\tgo func() {\n\t\tdefer wg.Done()\n\t\tautorun, err := os.Create(drivePath + \"/autorun.inf\") //make the autorun.inf\n\t\thandleErr(err)\n\t\t_, err = autorun.WriteString(\"[Autorun]\\nIcon=.autorun.ico\")\n\t\thandleErr(err)\n\t\thandleErr(autorun.Close())\n\t}()\n\n\t//figure out how to use fatattr to hide these files on any system\n\n\t//MacOs block\n\n\twg.Add(1)\n\tgo func() {\n\t\tdefer wg.Done()\n\t\ticnsTarget, err := os.Create(drivePath + \"/.VolumeIcon.icns\")\n\t\thandleErr(err)\n\t\thandleErr(icns.Encode(icnsTarget, image))\n\t\thandleErr(icnsTarget.Close())\n\t}()\n\n\twg.Add(1)\n\tgo func() {\n\t\tdefer wg.Done()\n\t\tbyteSource := bytes.NewReader(MustAsset(\"data/._\"))\n\t\tbyteTarget, err := os.Create(drivePath + \"/._\")\n\t\thandleErr(err)\n\t\t_, err = io.Copy(byteTarget, byteSource)\n\t\thandleErr(err)\n\t\thandleErr(byteTarget.Close())\n\t}()\n\n\twg.Add(1)\n\tgo func() {\n\t\tdefer wg.Done()\n\t\tvolumeSource := bytes.NewReader(MustAsset(\"data/._.VolumeIcon.icns\"))\n\t\tvolumeTarget, err := os.Create(drivePath + \"/._.VolumeIcon.icns\")\n\t\thandleErr(err)\n\t\t_, err = io.Copy(volumeTarget, volumeSource)\n\t\thandleErr(err)\n\t\thandleErr(volumeTarget.Close())\n\t}()\n\n\twg.Wait()\n\n\thandleErr(icon.Close())\n\n}", "title": "" }, { "docid": "cc462a236168b8f6138757f9e7e6f945", "score": "0.37668574", "text": "func recreateBin() {\n\n\tif *lFlag {\n\t\t// Make sure that the directory exists.\n\t\tdir, err := os.Open(oakBinPath)\n\t\tif err == nil {\n\t\t\tdir.Close()\n\t\t\treturn\n\t\t}\n\t\tif !os.IsNotExist(err) {\n\t\t\texit(err, 1)\n\t\t}\n\n\t\tcreateDirectory(oakBinPath)\n\t\treturn\n\t}\n\n\tremoveDirectory(oakBinPath)\n\tcreateDirectory(oakBinPath)\n}", "title": "" }, { "docid": "e17c2e90675fd3d657b5d63dceaaec16", "score": "0.37664598", "text": "func Reverse(ip string) string {\n\tparts := strings.Split(ip, \".\")\n\n\tfor i, j := 0, len(parts)-1; i < j; i, j = i+1, j-1 {\n\t\tparts[i], parts[j] = parts[j], parts[i]\n\t}\n\n\treturn strings.Join(parts, \".\")\n}", "title": "" }, { "docid": "f0383104816c84b632fe581d84cf076b", "score": "0.37629256", "text": "func (dn *Daemon) removeRollback() error {\n\tif !dn.os.IsCoreOSVariant() {\n\t\t// do not attempt to rollback on non-RHCOS/FCOS machines\n\t\treturn nil\n\t}\n\treturn runRpmOstree(\"cleanup\", \"-r\")\n}", "title": "" }, { "docid": "32727c0c22bc3d844b602096e5b9d904", "score": "0.37612665", "text": "func (b *BlockChain) RestoreUtreexoBridgeState(utreexoBSPath string) (*UtreexoBridgeState, error) {\n\tmiscPath := filepath.Join(utreexoBSPath, \"miscforestfile.dat\")\n\tmiscFile, err := os.OpenFile(miscPath, os.O_RDWR|os.O_CREATE, 0755)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tforestPath := filepath.Join(utreexoBSPath, \"forestdata.dat\")\n\tfFile, err := os.OpenFile(forestPath, os.O_RDWR|os.O_CREATE, 0755)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tf, err := accumulator.RestoreForest(miscFile, fFile, b.utreexoInRam, false, \"\", 0)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &UtreexoBridgeState{forest: f}, nil\n}", "title": "" }, { "docid": "0db00a1494a2a8b10ea5fa3e59b1089e", "score": "0.37601507", "text": "func ApplyFixup(b []byte) ([]byte, error) {\n\tr := binutil.NewLittleEndianReader(b)\n\tupdateSequenceOffset := int(r.Uint16(0x04))\n\tupdateSequenceSize := int(r.Uint16(0x06))\n\treturn applyFixUp(b, updateSequenceOffset, updateSequenceSize)\n}", "title": "" }, { "docid": "ec17afe59bfa25c37ce7667e0fc5abc2", "score": "0.3755629", "text": "func Clean() error {\n\tfmt.Println(\"cleaning up\")\n\tif _, err := os.Stat(\"coverage.out\"); err == nil {\n\t\terr = os.Remove(\"coverage.out\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\terr := cleanDocker()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn os.RemoveAll(\"bin/\")\n}", "title": "" }, { "docid": "0c1d535bae15af4606119cc71a6c6e70", "score": "0.3742798", "text": "func renameFiles(fileName string, max int) error {\n\tfiles, err := ioutil.ReadDir(path.Dir(fileName))\n\tif err != nil {\n\t\treturn err\n\t}\n\tsort.Sort(ByNumericalFilename(files))\n\tfound := make([]os.FileInfo, 0)\n\tfor _, file := range files {\n\t\tif !file.IsDir() && strings.HasSuffix(file.Name(), \".gz\") {\n\t\t\tfmt.Println(file.Name())\n\t\t\tfound = append(found, file)\n\t\t}\n\t}\n\n\tsort.Sort(ByNumericalFilenameRev(found))\n\t// Rename to 1 higher\n\tre := regexp.MustCompile(\"[0-9]+\")\n\tfor _,j := range found {\n\t\tif ar := re.FindAllString(j.Name(), 1); ar != nil {\n\t\t\tlastNum,err := strconv.ParseInt(ar[0], 10, 64)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"issue renaming convert found int %v\\n\", err)\n\t\t\t}\n\t\t\tnewNum := lastNum + 1\n\t\t\toldName := j.Name()\n\t\t\tnewName := strings.ReplaceAll(oldName, strconv.Itoa(int(lastNum)), strconv.Itoa(int(newNum)))\n\t\t\terr = os.Rename(path.Join(path.Dir(fileName),oldName), path.Join(path.Dir(fileName),newName))\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"issue renaming %v\\n\", err)\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// Re-read and clean up\n\tfiles, err = ioutil.ReadDir(path.Dir(fileName))\n\tif err != nil {\n\t\treturn err\n\t}\n\tsort.Sort(ByNumericalFilename(files))\n\tfor i,j := range files {\n\t\tif i >= max {\n\t\t\terr := os.Remove(path.Join(path.Dir(fileName), j.Name()))\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"issue removing %v\\n\", err)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "7c2bf633470557f01a43d321c77b218b", "score": "0.37409097", "text": "func InverseTransformExample(pathKey *diskv.PathKey) (key string) {\n\tif 0 == len(pathKey.Path) {\n\t\t//\t\treturn strings.Join(pathKey.Path, \"/\")\n\t\treturn \"\"\n\t}\n\tbkv := pathKey.FileName[len(pathKey.FileName)-4:]\n\tif bkv != \".bkv\" {\n\t\tpanic(\"Invalid file found in storage folder!\")\n\t}\n\treturn strings.Join(pathKey.Path, \"/\") + \"/\" + pathKey.FileName[:len(pathKey.FileName)-4]\n}", "title": "" }, { "docid": "7c2bf633470557f01a43d321c77b218b", "score": "0.37409097", "text": "func InverseTransformExample(pathKey *diskv.PathKey) (key string) {\n\tif 0 == len(pathKey.Path) {\n\t\t//\t\treturn strings.Join(pathKey.Path, \"/\")\n\t\treturn \"\"\n\t}\n\tbkv := pathKey.FileName[len(pathKey.FileName)-4:]\n\tif bkv != \".bkv\" {\n\t\tpanic(\"Invalid file found in storage folder!\")\n\t}\n\treturn strings.Join(pathKey.Path, \"/\") + \"/\" + pathKey.FileName[:len(pathKey.FileName)-4]\n}", "title": "" }, { "docid": "588ecba138c113b65f1fbaba0d4c2c8e", "score": "0.3738675", "text": "func (c *EgressController) unrealizeEgressIP(egressName, egressIP string) error {\n\tc.egressIPStatesMutex.Lock()\n\tdefer c.egressIPStatesMutex.Unlock()\n\n\tipState, exist := c.egressIPStates[egressIP]\n\t// The Egress IP was not configured before, do nothing.\n\tif !exist {\n\t\treturn nil\n\t}\n\t// Unlink the Egress from the EgressIP. If it's the last Egress referring to it, uninstall its datapath rules and\n\t// release the mark if installed.\n\tipState.egressNames.Delete(egressName)\n\tif len(ipState.egressNames) > 0 {\n\t\treturn nil\n\t}\n\tif ipState.mark != 0 {\n\t\tif ipState.ruleInstalled {\n\t\t\tif err := c.routeClient.DeleteSNATRule(ipState.mark); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tipState.ruleInstalled = false\n\t\t}\n\t\tif ipState.flowsInstalled {\n\t\t\tif err := c.ofClient.UninstallSNATMarkFlows(ipState.mark); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tipState.flowsInstalled = false\n\t\t}\n\t\tc.idAllocator.release(ipState.mark)\n\t}\n\tdelete(c.egressIPStates, egressIP)\n\treturn nil\n}", "title": "" }, { "docid": "2c1e9584c5ee7b105022926da5d93304", "score": "0.37374538", "text": "func Migrate(context *cli.Context) error {\n\toldConfig := &config.LocalConfig{}\n\tdest, err := config.NewDefaultDestination()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Error reading old configuration file.\")\n\t}\n\n\t// Check if config file is YAML; if it is, no need to migrate.\n\t// This is needed because the ini library does not throw parse errors\n\tclusterConfig, err := config.ReadClusterFile(config.ConfigFilePath(dest))\n\tif err == nil && clusterConfig.Version != \"\" {\n\t\t// Is a new style config file\n\t\tlogrus.Errorf(\"No need to migrate; found a YAML formatted configuration file at %s\", config.ConfigFilePath(dest))\n\t\treturn nil\n\t}\n\n\tiniReadWriter, err := config.NewINIReadWriter(dest)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Error reading old configuration file.\")\n\t}\n\tif err = iniReadWriter.GetConfig(oldConfig); err != nil {\n\t\treturn errors.Wrap(err, \"Error reading old configuration file.\")\n\t}\n\n\tif oldConfig.CFNStackNamePrefix == flags.CFNStackNamePrefixDefaultValue {\n\t\t// if CFNStackName is default; don't store it.\n\t\toldConfig.CFNStackName = \"\"\n\t} else {\n\t\toldConfig.CFNStackName = oldConfig.CFNStackNamePrefix + oldConfig.Cluster\n\t}\n\n\tif !context.Bool(flags.ForceFlag) {\n\t\tif err = migrateWarning(*oldConfig); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tscanner := bufio.NewScanner(os.Stdin)\n\t\tscanner.Scan()\n\t\tinput := scanner.Text()\n\t\tif !strings.HasPrefix(input, \"y\") && !strings.HasPrefix(input, \"Y\") {\n\t\t\tlogrus.Info(\"Aborting Migration.\")\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tcluster := &config.Cluster{\n\t\tCluster: oldConfig.Cluster,\n\t\tRegion: oldConfig.Region,\n\t\tCFNStackName: oldConfig.CFNStackName,\n\t\tComposeServiceNamePrefix: oldConfig.ComposeServiceNamePrefix,\n\t}\n\n\trdwr, err := config.NewReadWriter()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Error saving cluster configuration\")\n\t}\n\tif err = rdwr.SaveCluster(defaultConfigName, cluster); err != nil {\n\t\treturn errors.Wrap(err, \"Error saving cluster configuration\")\n\t}\n\tif oldConfig.AWSSecretKey != \"\" {\n\t\tprofile := &config.Profile{\n\t\t\tAWSAccessKey: oldConfig.AWSAccessKey,\n\t\t\tAWSSecretKey: oldConfig.AWSSecretKey,\n\t\t}\n\t\tif err = rdwr.SaveProfile(defaultConfigName, profile); err != nil {\n\t\t\treturn errors.Wrap(err, \"Error saving profile\")\n\t\t}\n\t}\n\n\tlogrus.Info(\"Migrated ECS CLI configuration.\")\n\treturn nil\n}", "title": "" }, { "docid": "b881000a6775955442669930f9d91d4d", "score": "0.37356928", "text": "func (bc *BlockChain) Rollback(chain []common.Hash) {\n\tbc.mu.Lock()\n\tdefer bc.mu.Unlock()\n\n\tfor i := len(chain) - 1; i >= 0; i-- {\n\t\thash := chain[i]\n\n\t\tcurrentHeader := bc.hc.CurrentHeader()\n\t\tif currentHeader.Hash() == hash {\n\t\t\tbc.hc.SetCurrentHeader(bc.GetHeader(currentHeader.ParentHash, currentHeader.Number.Uint64()-1))\n\t\t}\n\n\t\tif currentBlock := bc.CurrentBlock(); currentBlock.Hash() == hash {\n\t\t\tnewBlock := bc.GetBlock(currentBlock.ParentHash(), currentBlock.NumberU64()-1)\n\t\t\tbc.currentBlock.Store(newBlock)\n\t\t\trawdb.WriteHeadBlockHash(bc.db, newBlock.Hash())\n\t\t}\n\t}\n}", "title": "" } ]
856a8cd3ed05d5296ef5ca6ec254a4d8
The providerassigned unique ID for this managed resource.
[ { "docid": "2b4e022b43cd6cd0a3455b5dd5dad25e", "score": "0.0", "text": "func (o LookupProjectResultOutput) Id() pulumi.StringOutput {\n\treturn o.ApplyT(func(v LookupProjectResult) string { return v.Id }).(pulumi.StringOutput)\n}", "title": "" } ]
[ { "docid": "c6c1aef1b4b7ff4ec887bd51bd8aff3f", "score": "0.7167966", "text": "func (p *provider) ID() string {\n\treturn p.name\n}", "title": "" }, { "docid": "af8496114071f74dbb2c2cc98c851b23", "score": "0.7076153", "text": "func (c Provider) GetId() string {\n\treturn \"\"\n}", "title": "" }, { "docid": "f111cd97b9d1b122765288cb31bbf13a", "score": "0.68409425", "text": "func (p *ProviderID) ID() string {\n\treturn p.id\n}", "title": "" }, { "docid": "aaa5b0015a85cf842b45d234496e4b4a", "score": "0.66912574", "text": "func (agentPool *AKSAgentPool) GetProviderID(name string) string {\n\t//TODO: come with a generic way to make it work with provider id formats\n\t// in different version of k8s.\n\treturn \"azure://\" + name\n}", "title": "" }, { "docid": "7a070c7609e07ab9db5138b0bce0f3d7", "score": "0.6687575", "text": "func (p *Provider) ID() string {\n\treturn \"calendar-external-\" + strconv.Itoa(p.ExternalCalendarID)\n}", "title": "" }, { "docid": "814f87bccae12fe353f37091b0211381", "score": "0.6672333", "text": "func (p *simProvider) ID() string {\n\treturn p.uid\n}", "title": "" }, { "docid": "2a187e58c461a12f45d1622c015dcbde", "score": "0.66671604", "text": "func (this OIDCProvider) GetID() string { return this.ID }", "title": "" }, { "docid": "b18dc32874c891055578770eaab4c1c3", "score": "0.6559902", "text": "func (p *Provider) GetId() string {\n\treturn p.Id\n}", "title": "" }, { "docid": "1a9cbede0752910e24b037466b8d3d10", "score": "0.6468129", "text": "func ID(p Provider) string {\n\treturn fmt.Sprintf(\"%s/%s\", p.Type(), p.GetName())\n}", "title": "" }, { "docid": "3f7d4d70eec94774d4190008a23fc583", "score": "0.6311652", "text": "func (this EnterpriseIdentityProvider) GetID() string { return this.ID }", "title": "" }, { "docid": "b118bd587b1e5e10a7102f41c66f864f", "score": "0.62735045", "text": "func (m *MachineScope) GetProviderID() string {\n\tif m.KKMachine.Spec.ProviderID != nil {\n\t\treturn *m.KKMachine.Spec.ProviderID\n\t}\n\treturn \"\"\n}", "title": "" }, { "docid": "3db502e128b46681eeaa169afcd27dbd", "score": "0.6226699", "text": "func (r *Resource) Id() string {\n\tswitch r.Mode {\n\tcase ManagedResourceMode:\n\t\treturn fmt.Sprintf(\"%s.%s\", r.Type, r.Name)\n\tcase DataResourceMode:\n\t\treturn fmt.Sprintf(\"data.%s.%s\", r.Type, r.Name)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"unknown resource mode %s\", r.Mode))\n\t}\n}", "title": "" }, { "docid": "f9ef0f9fe961bc08672fbec2616133e4", "score": "0.6106418", "text": "func (r *SamlProvider) ID() pulumi.IDOutput {\n\treturn r.s.ID()\n}", "title": "" }, { "docid": "ef5a1f0458cb61242d48d1f1a77124d8", "score": "0.60838753", "text": "func (r *OpenIdConnectProvider) ID() pulumi.IDOutput {\n\treturn r.s.ID()\n}", "title": "" }, { "docid": "ba6fd447da5c8314831b086143d65562", "score": "0.6068549", "text": "func (this OrganizationIdentityProvider) GetID() string { return this.ID }", "title": "" }, { "docid": "7ba697e3c869fe168f78da62a8e7954c", "score": "0.60588956", "text": "func (c *Client) GetID() string {\n\treturn c.providerIdent\n}", "title": "" }, { "docid": "10b21fa44ddc5c21f0955edbfc2fd97b", "score": "0.6036532", "text": "func (o GetSamlProvidersProviderOutput) Id() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetSamlProvidersProvider) string { return v.Id }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "0af3c9508b80e496350bdb9ce6c7b0d5", "score": "0.59650826", "text": "func (this User) ResourceID() string {\n\treturn this.Name\n}", "title": "" }, { "docid": "bf4dfb3fe5c6d5503afd25767c65328d", "score": "0.59399414", "text": "func (s ManagedSecret) ID() string {\n\treturn s.id\n}", "title": "" }, { "docid": "84a10c9bd173c2edaae594a7e0236d5f", "score": "0.59226197", "text": "func (c *pfscommon) ID() string {\n\tc.Lock()\n\tdefer c.Unlock()\n\treturn c.id\n}", "title": "" }, { "docid": "93eb20c0f3fc60b19b7dcc6481506f31", "score": "0.58920974", "text": "func (a *Core) ID() string {\n\n\tresult, err := a.coreConf.Sentry().PublicKeyBase64()\n\tif err != nil {\n\t\terr = stacktrace.Propagate(err, \"could not get node ID\")\n\t\tpanic(err)\n\t}\n\treturn result[:8]\n}", "title": "" }, { "docid": "b492b9c36578ea136f4f1daaa84f788b", "score": "0.58881843", "text": "func (this EnterpriseServerUserAccount) GetID() string { return this.ID }", "title": "" }, { "docid": "c921b79154e5fb4eebb4c2f720925f56", "score": "0.5867399", "text": "func (b basicserver) GetUniqueIdentifier() string { return b.id }", "title": "" }, { "docid": "177f59d811226c43b68b4362cb823e39", "score": "0.5866318", "text": "func (this Enterprise) GetID() string { return this.ID }", "title": "" }, { "docid": "1f0b6eabce8e599bb472198e7e4350c1", "score": "0.5862064", "text": "func (p *Provider) GetCurrentIdentifier() string {\n\treturn p.Status.CurrentIdentifier\n}", "title": "" }, { "docid": "bee0e8cf6a3e67803a32e7d277f8fd33", "score": "0.58502275", "text": "func Id() (id string, err error) {\n\tif defaultClient == nil {\n\t\terr = NoDefaultClientConnection\n\t\treturn\n\t}\n\treturn defaultClient.Id()\n}", "title": "" }, { "docid": "085a8cbfa018ad77932d6e501a71425b", "score": "0.5847849", "text": "func (o ResourceIdOutput) Id() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ResourceId) string { return v.Id }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "9d0c13bddc95550392c43dc762982265", "score": "0.5822268", "text": "func (this ExternalIdentity) GetID() string { return this.ID }", "title": "" }, { "docid": "0a875cf671b54fb9b5b2eb7b2efc0d40", "score": "0.5788695", "text": "func providerConfigID(pc *schema.SAMLAuthProvider, multiple bool) string {\n\tif pc.ConfigID != \"\" {\n\t\treturn pc.ConfigID\n\t}\n\tif !multiple {\n\t\treturn \"\"\n\t}\n\tdata, err := json.Marshal(pc)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tb := sha256.Sum256(data)\n\treturn base64.RawURLEncoding.EncodeToString(b[:16])\n}", "title": "" }, { "docid": "a5ead42377380ab31ae233a39e91f058", "score": "0.57839626", "text": "func generateID() string { return ksuid.New().String() }", "title": "" }, { "docid": "0e2273bf81e5064a9c69e8ff0a9faaea", "score": "0.5773476", "text": "func (m *credentials) ID() string {\n\treturn m.idField\n}", "title": "" }, { "docid": "1f19fff9ce02a4bef0dc08615f06d437", "score": "0.57715255", "text": "func (us user) Id() string {\n\treturn us.id\n}", "title": "" }, { "docid": "cf1713094ea452d2eed51a32365d1c66", "score": "0.5738951", "text": "func (c *client) ID(ctx context.Context) (string, error) {\n\turl := c.createURL(\"/_admin/server/id\", nil)\n\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\tif err != nil {\n\t\treturn \"\", maskAny(err)\n\t}\n\tif ctx != nil {\n\t\treq = req.WithContext(ctx)\n\t}\n\tif c.prepareRequest != nil {\n\t\tif err := c.prepareRequest(req); err != nil {\n\t\t\treturn \"\", maskAny(err)\n\t\t}\n\t}\n\tresp, err := c.client.Do(req)\n\tif err != nil {\n\t\treturn \"\", maskAny(err)\n\t}\n\tvar result idResponse\n\tif err := c.handleResponse(resp, \"GET\", url, &result); err != nil {\n\t\treturn \"\", maskAny(err)\n\t}\n\n\t// Success\n\treturn result.ID, nil\n}", "title": "" }, { "docid": "c0ce38d05c982db293091f36825910bb", "score": "0.57252795", "text": "func (p ProviderID) String() string {\n\treturn p.original\n}", "title": "" }, { "docid": "6acf6efe6cb4334c4076c1f9c84aee09", "score": "0.57153755", "text": "func (*uuidProvider) uid() string {\n\treturn prefix + uuid.NewString()\n}", "title": "" }, { "docid": "166e82a4db0073ffba2014ed86e3600d", "score": "0.5690471", "text": "func (m *Team) GetInternalId()(*string) {\n val, err := m.GetBackingStore().Get(\"internalId\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "title": "" }, { "docid": "f4f7c1de0490026ea8050c2eeb312cd1", "score": "0.5690276", "text": "func (m *LinkedResource) GetExternalId()(*string) {\n val, err := m.GetBackingStore().Get(\"externalId\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "title": "" }, { "docid": "a53995a153294cf8d888e32147f916b1", "score": "0.5689329", "text": "func (this EnterpriseUserAccount) GetID() string { return this.ID }", "title": "" }, { "docid": "cff544211a8822b68ab4a89930a6de2d", "score": "0.56891936", "text": "func (ui UserInformation) GetCompositeID() string {\n\ttoReturn := \"\"\n\tif ui.DBID != 0 {\n\t\ttoReturn += strconv.FormatUint(ui.DBID, 10) + \" \"\n\t} else {\n\t\ttoReturn += \"- \"\n\t}\n\tif ui.OIDCIssuer != \"\" && ui.OIDCSubject != \"\" {\n\t\ttoReturn += ui.OIDCIssuer + \"/\" + ui.OIDCSubject + \" \"\n\t} else {\n\t\ttoReturn += \"- \"\n\t}\n\tif ui.IP != \"\" {\n\t\ttoReturn += ui.IP + \" \"\n\t} else {\n\t\ttoReturn += \"- \"\n\t}\n\treturn toReturn[:len(toReturn)-1]\n}", "title": "" }, { "docid": "116855edf4d6c8e03bdf2f99a6192e74", "score": "0.5688323", "text": "func (c *Client) Identifier() string {\n\tidentifier := fmt.Sprintf(\"configURL:%q,\", c.config.ConfigURL.String())\n\n\tif c.creds.Token != \"\" {\n\t\tidentifier += fmt.Sprintf(\"token:%q\", c.creds.Token)\n\t}\n\n\tif c.creds.AppCreds != nil {\n\t\tidentifier += fmt.Sprintf(\n\t\t\t\"appID:%q,installationID:%q,key:%q\",\n\t\t\tc.creds.AppCreds.AppID,\n\t\t\tc.creds.AppCreds.AppInstallationID,\n\t\t\tc.creds.AppCreds.AppPrivateKey,\n\t\t)\n\t}\n\n\tif c.rootCAs != nil {\n\t\t// ignoring because this cert pool is intended not to come from SystemCertPool\n\t\t// nolint:staticcheck\n\t\tidentifier += fmt.Sprintf(\"rootCAs:%q\", c.rootCAs.Subjects())\n\t}\n\n\treturn uuid.NewHash(sha256.New(), uuid.NameSpaceOID, []byte(identifier), 6).String()\n}", "title": "" }, { "docid": "cb9b494f2f3f04bdbaec97b0e60c8e17", "score": "0.5679291", "text": "func (s *Base) ID() string { return s.id }", "title": "" }, { "docid": "22d4cbb3bfbed6be1f9e5df5108f7cb0", "score": "0.5671", "text": "func (this EnterpriseRepositoryInfo) GetID() string { return this.ID }", "title": "" }, { "docid": "b9970ad73d33981ea5b3253133c4e407", "score": "0.5670488", "text": "func (this EnterpriseServerUserAccountEmail) GetID() string { return this.ID }", "title": "" }, { "docid": "ddb88ccb39c276229e4931495785b937", "score": "0.56704456", "text": "func (m *GovernanceRoleAssignment) GetExternalId()(*string) {\n val, err := m.GetBackingStore().Get(\"externalId\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "title": "" }, { "docid": "af615f7051acf58c912100ad01050a61", "score": "0.56693953", "text": "func (r *TestResource) ID() string {\n\treturn r.Data[common.DataFieldID].(string)\n}", "title": "" }, { "docid": "b2f43201543a059d4e8d97d5b203af80", "score": "0.5665993", "text": "func (e ConnectEntry) ResourceID() string {\n\tif id := e.NetworkID(); id != \"\" {\n\t\treturn id\n\t}\n\treturn fmt.Sprintf(\"%s:%s\", e.Kind, e.Resource)\n}", "title": "" }, { "docid": "c69668ff6a3705985e2f19f7317bdba7", "score": "0.56307876", "text": "func (c *candidateBase) ID() string {\n\treturn c.id\n}", "title": "" }, { "docid": "ca03bf1bf5e021358f946ae8a30b2f1c", "score": "0.5619443", "text": "func (m *memory) ID(ctx context.Context) string {\n\treturn m.id\n}", "title": "" }, { "docid": "977b23318c3d1f5117fdc1ba7f221c04", "score": "0.5616259", "text": "func (this EnterpriseServerInstallation) GetID() string { return this.ID }", "title": "" }, { "docid": "8429bf85625ec3dff4e9561b4fa4cba3", "score": "0.5612248", "text": "func (this EnterpriseServerUserAccountsUpload) GetID() string { return this.ID }", "title": "" }, { "docid": "283bb6ecee3e22bb71059f7c6976a39b", "score": "0.559077", "text": "func (this DeployKey) GetID() string { return this.ID }", "title": "" }, { "docid": "1f77f222a35f7ce306d289457cc6f2be", "score": "0.55906475", "text": "func (id SqlVirtualMachineGroupId) ID() string {\n\tfmtString := \"/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/%s\"\n\treturn fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SqlVirtualMachineGroupName)\n}", "title": "" }, { "docid": "53c336f50304c3a5b6b440e12182e711", "score": "0.5583767", "text": "func (credBase *Base) GetID() string {\n\treturn credBase.ID\n}", "title": "" }, { "docid": "e4f352f935c53f647d64bfc5f495d791", "score": "0.55509424", "text": "func (r *Module) Id() string {\n\treturn fmt.Sprintf(\"%s\", r.Name)\n}", "title": "" }, { "docid": "3408ffb4b5f310e17263ed8ca2272e03", "score": "0.55376375", "text": "func (o *UserCore) GetIdproviderId() string {\n\tif o == nil || o.IdproviderId == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.IdproviderId\n}", "title": "" }, { "docid": "5f927803aee8c86824f4d7d57e3640b2", "score": "0.5536269", "text": "func MyID() string {\n\treturn \"rpi-\" + cpuID\n}", "title": "" }, { "docid": "e3005c733da585263517892e7c71d6eb", "score": "0.5535728", "text": "func (p *Pool) ID() string {\n\tp.mu.Lock()\n\tdefer p.mu.Unlock()\n\treturn p.id\n}", "title": "" }, { "docid": "03c9569dfedb9b10a76693c90ac328bc", "score": "0.5533924", "text": "func (m *DeviceManagementConfigurationPolicyTemplate) GetBaseId()(*string) {\n val, err := m.GetBackingStore().Get(\"baseId\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "title": "" }, { "docid": "85a7170ff528cad82c743e7ca93addf9", "score": "0.5533015", "text": "func (o TransitGatewayMulticastGroupSourceOutput) ResourceId() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *TransitGatewayMulticastGroupSource) pulumi.StringOutput { return v.ResourceId }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "561874049304119f2a0ef5056d647fb2", "score": "0.55247456", "text": "func (this Environment) GetID() string { return this.ID }", "title": "" }, { "docid": "4fec49c9dc5e320e079528ff87e6bd63", "score": "0.55068237", "text": "func (this PublicKey) GetID() string { return this.ID }", "title": "" }, { "docid": "9d363ca5fc65827aa38c61c074c62698", "score": "0.5502655", "text": "func ID() string {\n\t// NOTE(adam): Moov's apps depend on the length and hex encoding of these ID's to cleanup HTTP Prometheus metrics.\n\tbs := make([]byte, 20)\n\tn, err := rand.Read(bs)\n\tif err != nil || n == 0 {\n\t\treturn \"\"\n\t}\n\treturn strings.ToLower(hex.EncodeToString(bs))\n}", "title": "" }, { "docid": "523098c211a04d74325a0fb604c1d1c8", "score": "0.550134", "text": "func (s *SpendConsumer) ID() string {\n\treturn s.id\n}", "title": "" }, { "docid": "736f52c773b4a2185d1dd062ed2784f8", "score": "0.550063", "text": "func (this SecurityAdvisory) GetID() string { return this.ID }", "title": "" }, { "docid": "f52bbff02b62897edfd4755cfb4dff3f", "score": "0.55001616", "text": "func Id(ctx context.Context) string {\n\tid, ok := FromContext(ctx)\n\tif !ok {\n\t\treturn \"micro\"\n\t}\n\treturn id\n}", "title": "" }, { "docid": "324925b2b7f4ffa7659001aeda553614", "score": "0.5495406", "text": "func ID() (id string) {\n\tb := make([]byte, 21) // 168 bits - just over the 160 bit recomendation without base64 padding\n\trand.Read(b)\n\treturn \"_\" + base64.RawURLEncoding.EncodeToString(b)\n}", "title": "" }, { "docid": "d4b2e17cff4af8bf41985eff205d643f", "score": "0.54837257", "text": "func (t *instance) ID() string { return t.id.String() }", "title": "" }, { "docid": "38a5bfe886d1876fd5d2536a51e4a22c", "score": "0.5477384", "text": "func (m *Manager) ID() string {\n\treturn m.id\n}", "title": "" }, { "docid": "ed3787dcc1b2a929c19f887f76874e26", "score": "0.5463059", "text": "func (m *SignIn) GetResourceId()(*string) {\n val, err := m.GetBackingStore().Get(\"resourceId\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "title": "" }, { "docid": "9a91d1113a3c5f24581f97999278cdba", "score": "0.54609543", "text": "func (this PushAllowance) GetID() string { return this.ID }", "title": "" }, { "docid": "8dd7f75ff60531fe7a4291f1770e7d51", "score": "0.54558074", "text": "func (gdt Object) ID() string {\n\treturn fmt.Sprintf(\"%p\", gdt.base)\n}", "title": "" }, { "docid": "aed2264ec9b5fc4224a15695f7e1d13b", "score": "0.54506695", "text": "func (this Organization) GetID() string { return this.ID }", "title": "" }, { "docid": "93f3220b0144a2872b44de6228f0d913", "score": "0.54503834", "text": "func (this ProjectCard) GetID() string { return this.ID }", "title": "" }, { "docid": "07f9d2c0b319f38eec83d6b19ceed2a1", "score": "0.5441477", "text": "func (p *ProviderID) CloudProvider() string {\n\treturn p.cloudProvider\n}", "title": "" }, { "docid": "efee9f241722a7b6b8ed258d04a2cc35", "score": "0.5434411", "text": "func (o ResourceOutput) ResourceId() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Resource) pulumi.StringOutput { return v.ResourceId }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "5d5b65278a1ac6494f317a1f2ef31ddf", "score": "0.5424258", "text": "func (m *UserExperienceAnalyticsDeviceScope) GetOwnerId()(*string) {\n val, err := m.GetBackingStore().Get(\"ownerId\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "title": "" }, { "docid": "2e1c3a6b5b14f72d8912672fa69c9e90", "score": "0.54190034", "text": "func (n *NodePool) Id() string {\n\treturn n.id\n}", "title": "" }, { "docid": "2c25a10cec6fd4b590270ef51d281808", "score": "0.5407613", "text": "func (o *SubmitLoginFlowBodyWithOidc) GetProvider() string {\n\tif o == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\n\treturn o.Provider\n}", "title": "" }, { "docid": "1ee5722b240ce7ac7c099b456e5b7119", "score": "0.54069316", "text": "func (id CapacityReservationGroupId) ID() string {\n\tfmtString := \"/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/capacityReservationGroups/%s\"\n\treturn fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CapacityReservationGroupName)\n}", "title": "" }, { "docid": "a2e3d383512edcb10334a8279da66870", "score": "0.53998667", "text": "func (id DiskEncryptionSetId) ID() string {\n\tfmtString := \"/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/diskEncryptionSets/%s\"\n\treturn fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DiskEncryptionSetName)\n}", "title": "" }, { "docid": "b23e230cb2c7c03de6c79ca70596b1ed", "score": "0.5394055", "text": "func (o StorageAccountOutput) Id() pulumi.StringOutput {\n\treturn o.ApplyT(func(v StorageAccount) string { return v.Id }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "b23e230cb2c7c03de6c79ca70596b1ed", "score": "0.5394055", "text": "func (o StorageAccountOutput) Id() pulumi.StringOutput {\n\treturn o.ApplyT(func(v StorageAccount) string { return v.Id }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "d65bbdc2e5bb617af7ee5c89686d74b7", "score": "0.53932106", "text": "func (u *User) ID() string {\n\treturn fmt.Sprintf(\"%v\", u.Id)\n}", "title": "" }, { "docid": "3abed7cd563419f9605938bd2013f881", "score": "0.5389732", "text": "func (o *SparseAppCredential) Identifier() string {\n\n\tif o.ID == nil {\n\t\treturn \"\"\n\t}\n\treturn *o.ID\n}", "title": "" }, { "docid": "3216a9e042705462148b35138c7b5a60", "score": "0.5384398", "text": "func (this EnterpriseAdministratorInvitation) GetID() string { return this.ID }", "title": "" }, { "docid": "ad32c47b769753efd3b4a531d5267f47", "score": "0.53832406", "text": "func (this StatusContext) GetID() string { return this.ID }", "title": "" }, { "docid": "e37f17788e6cce3547646ebaddce77f9", "score": "0.53814065", "text": "func GetUuid() string {\n\treturn strings.ReplaceAll(uuid.New().String(), \"-\", \"\")\n}", "title": "" }, { "docid": "46dd742e254b543e30c4aadac9f8de0a", "score": "0.5378544", "text": "func (jur *JobUsageRecord) Id() string {\n\treturn jur.RecordIdentity.RecordId\n}", "title": "" }, { "docid": "9b4768c1881965c078f9f26a2b9e4d39", "score": "0.53713745", "text": "func NodeID(ctx context.Context) string {\n\tif kronosServer == nil {\n\t\treturn \"\"\n\t}\n\n\tid, err := kronosServer.ID()\n\tif err != nil {\n\t\tlog.Fatalf(ctx, \"Failed to get kronosServer.ID, err: %v\", err)\n\t}\n\n\treturn id\n}", "title": "" }, { "docid": "17b05351cac3460d34b513564f21e8cc", "score": "0.5367151", "text": "func (l lease) ID() string {\n\treturn l.hostLease.GetLeaseId().GetValue()\n}", "title": "" }, { "docid": "d3a580df004a084b6a6151c1eb0cf815", "score": "0.5365224", "text": "func (m *AlternativeSecurityId) GetIdentityProvider()(*string) {\n return m.identityProvider\n}", "title": "" }, { "docid": "bbb9fe3bae93eebacddcc20d31ced09f", "score": "0.5363041", "text": "func (w *Whoami) ID() string {\n\treturn w.kratosSession.Identity.GetId()\n}", "title": "" }, { "docid": "84a049e6377a468fff06ba136b983bb2", "score": "0.53627974", "text": "func (p *ProcessConsumer) ID() string {\n\treturn \"PROCESS\"\n}", "title": "" }, { "docid": "f3fb74d125a0dcf5c073e74f9a2dcf3f", "score": "0.53620195", "text": "func (d *deployer) Provider() string {\n\treturn Name\n}", "title": "" }, { "docid": "823a4a7627b6d4935f313d5096c975cb", "score": "0.5361359", "text": "func (o *LdapCertificateProvider) GetId() string {\n\tif o == nil || o.Id == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Id\n}", "title": "" }, { "docid": "62af17104703382c2f74e259bf14017b", "score": "0.5355434", "text": "func (o *SubscriptionAllOf) GetCloudProviderId() string {\n\tif o == nil || o.CloudProviderId == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.CloudProviderId\n}", "title": "" }, { "docid": "4ae84418f65fee81e9653a51dfba7dc8", "score": "0.5354769", "text": "func (o CertificateOutput) ResourceManagerId() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Certificate) pulumi.StringOutput { return v.ResourceManagerId }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "31aea4e99e882d8096b6fe13b972083b", "score": "0.53538173", "text": "func (s *Store) ID() string {\n\treturn string(s.core.GetSessionID())\n}", "title": "" }, { "docid": "c31c3d8140feee896531ff2bfbe4006a", "score": "0.53513914", "text": "func (ai *AWSInfra) GetID() string {\n\treturn fmt.Sprintf(\"%s-%d-%d-%s\", ai.Kind, ai.ProjectID, ai.ID, ai.Suffix)\n}", "title": "" }, { "docid": "1e2e2738e4d4a3f658849bccbf433468", "score": "0.534821", "text": "func (p *provider) Name() string {\n\treturn name\n}", "title": "" }, { "docid": "a4619bc59fddcc95f46301f66983a62c", "score": "0.53371143", "text": "func (m *OnlineMeeting) GetExternalId()(*string) {\n val, err := m.GetBackingStore().Get(\"externalId\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "title": "" } ]
9588d38d7d7b98e01b51a798464dcf16
RadiusListUsers Manage users allowed to authenticate.
[ { "docid": "b08c34e50e45bc85386b50c205b2e5d3", "score": "0.68643117", "text": "func (a *Auth) RadiusListUsers(ctx context.Context, options ...RequestOption) (*Response[map[string]interface{}], error) {\n\trequestModifiers, err := requestOptionsToRequestModifiers(options)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trequestPath := \"/v1/auth/{radius_mount_path}/users\"\n\trequestPath = strings.Replace(requestPath, \"{\"+\"radius_mount_path\"+\"}\", url.PathEscape(requestModifiers.mountPathOr(\"radius\")), -1)\n\n\trequestQueryParameters := requestModifiers.customQueryParametersOrDefault()\n\trequestQueryParameters.Add(\"list\", \"true\")\n\n\treturn sendRequestParseResponse[map[string]interface{}](\n\t\tctx,\n\t\ta.client,\n\t\thttp.MethodGet,\n\t\trequestPath,\n\t\tnil, // request body\n\t\trequestQueryParameters,\n\t\trequestModifiers,\n\t)\n}", "title": "" } ]
[ { "docid": "f002e70d3ddcaf7a337b796cea3ba981", "score": "0.70717996", "text": "func (rs *rpcServer) ListUsers(ctx context.Context, req *charon.ListUsersRequest) (*charon.ListUsersResponse, error) {\n\th := &listUsersHandler{\n\t\thandler: newHandler(rs, ctx, \"list_users\"),\n\t}\n\th.addRequest(1)\n\n\tresp, err := h.handle(ctx, req)\n\th.handler.handle(err, \"list of users has been retrieved\")\n\n\treturn resp, err\n}", "title": "" }, { "docid": "2d07b380792ca6c4bed109ef28a2b1a6", "score": "0.7030867", "text": "func (a *api) ListUsersAPI(res http.ResponseWriter, req *http.Request) {\n\t_, err := a.authorize(req)\n\tif err != nil {\n\t\tres.WriteHeader(401)\n\t\treturn\n\t}\n\n\tusers, err := a.auth.ListUsers()\n\tif err != nil {\n\t\t// TODO: better error handling?\n\t\tres.WriteHeader(500)\n\t\tres.Write([]byte(err.Error() + \"\\n\"))\n\t\treturn\n\t}\n\n\twrite(UserList{users}, res)\n}", "title": "" }, { "docid": "28f8687d128a9d7839a2dec36c9c32a6", "score": "0.6970632", "text": "func UserList(c *fiber.Ctx) error {\n\tusers := database.Get(\"users\")\n\treturn c.JSON(fiber.Map{\n\t\t\"success\": true,\n\t\t\"users\": users,\n\t})\n}", "title": "" }, { "docid": "d731ac46f938cae65f7d2d9092a073e7", "score": "0.6968534", "text": "func (s *SlackAPI) UsersList(limit int, cursor string) ResponseUsersList {\n\tif s.teamUsers.Ok {\n\t\treturn s.teamUsers\n\t}\n\n\tvar response ResponseUsersList\n\ts.getRequest(&response, \"users.list\", struct {\n\t\tLimit int `json:\"limit\"`\n\t\tCursor string `json:\"cursor\"`\n\t}{\n\t\tLimit: limit,\n\t\tCursor: cursor,\n\t})\n\ts.teamUsers = response\n\n\treturn response\n}", "title": "" }, { "docid": "a0e53c9d21ff46afebb5f924a639f734", "score": "0.69556147", "text": "func (s *UserServiceOp) List(listOpt *ListOptions) (users []User, resp *Response, err error) {\n\tparams := createListOptionsURL(listOpt)\n\tpath := fmt.Sprintf(\"%s?%s\", usersBasePath, params)\n\n\tfor {\n\t\tsubset := new(usersRoot)\n\n\t\tresp, err = s.client.DoRequest(\"GET\", path, nil, subset)\n\t\tif err != nil {\n\t\t\treturn nil, resp, err\n\t\t}\n\n\t\tusers = append(users, subset.Users...)\n\n\t\tif subset.Meta.Next != nil && (listOpt == nil || listOpt.Page == 0) {\n\t\t\tpath = subset.Meta.Next.Href\n\t\t\tif params != \"\" {\n\t\t\t\tpath = fmt.Sprintf(\"%s&%s\", path, params)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "6d829c0f1eccc5f672a572c17a3b9f06", "score": "0.6937661", "text": "func (u *UsersController) List(ctx *gin.Context) {\n\tcriteria := u.buildCriteria(ctx)\n\tcount, users, err := models.ListUsers(criteria, utils.IsTatAdmin(ctx))\n\tif err != nil {\n\t\tctx.AbortWithError(http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\tout := &usersJSON{\n\t\tCount: count,\n\t\tUsers: users,\n\t}\n\tctx.JSON(http.StatusOK, out)\n}", "title": "" }, { "docid": "ac653b372b92bb37099ec21e7727d813", "score": "0.6923346", "text": "func (h *Handler) ListUsers(c *gin.Context) {\n\tvar users []models.User\n\tresults := h.Db.Find(&users)\n\n\tc.JSON(http.StatusOK, results)\n}", "title": "" }, { "docid": "6eac0c18063a586fd73da2320263bd44", "score": "0.69149363", "text": "func (c *ACLCommand) UsersList(ctx context.Context, client auth.ClientI) error {\n\tmembers, nextToken, err := client.AccessListClient().ListAccessListMembers(ctx, c.accessListName, 0, \"\")\n\tif err != nil {\n\t\treturn trace.Wrap(err)\n\t}\n\n\tif len(members) == 0 {\n\t\tfmt.Printf(\"No members found for access list %s.\\nYou may not have access to see the members for this list.\\n\", c.accessListName)\n\t\treturn nil\n\t}\n\n\tfmt.Printf(\"Members of %s:\\n\", c.accessListName)\n\tfor {\n\t\tfor _, member := range members {\n\t\t\tfmt.Printf(\"- %s\\n\", member.Spec.Name)\n\t\t}\n\n\t\tif nextToken == \"\" {\n\t\t\tbreak\n\t\t}\n\n\t\tmembers, nextToken, err = client.AccessListClient().ListAccessListMembers(ctx, c.accessListName, 0, nextToken)\n\t\tif err != nil {\n\t\t\treturn trace.Wrap(err)\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "d4e167a8665a2b8ddccea3073cb46187", "score": "0.6909828", "text": "func (s *Server) userList(w http.ResponseWriter, r *http.Request) {\n\tu := s.getUser(r)\n\tif u == nil {\n\t\ts.Error(w, r, \"Need authentification\", http.StatusUnauthorized)\n\t\treturn\n\t}\n\n\tvar filter func(*User) bool\n\tswitch u.Level {\n\tcase public.LevelStd:\n\t\tfilter = func(u *User) bool { return u.Level >= public.LevelStd }\n\tcase public.LevelAdmin:\n\t\tfilter = func(*User) bool { return true }\n\tdefault:\n\t\ts.Error(w, r, \"Required a stantard level\", http.StatusForbidden)\n\t\treturn\n\t}\n\n\tall := make([]public.UserInfo, 0)\n\ts.db.ForS(\"user:\", 0, 0, nil, func(_ string, u *User) {\n\t\tif filter(u) {\n\t\t\tall = append(all, u.UserInfo)\n\t\t}\n\t})\n\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tj, _ := json.Marshal(all)\n\tw.Write(j)\n}", "title": "" }, { "docid": "65415e11ffb68d49b559e591aadfc28c", "score": "0.69039524", "text": "func UserList(c *cli.Context, client *Client) error {\n\tresp, err := client.Users.List(\n\t\tc.Context,\n\t\t&connect.Request[usersv1.ListRequest]{},\n\t)\n\n\tif err != nil {\n\t\treturn PrettyError(err)\n\t}\n\n\tif len(resp.Msg.Users) == 0 {\n\t\tfmt.Fprintln(os.Stderr, \"Empty result\")\n\t\treturn nil\n\t}\n\n\ttmpl, err := template.New(\n\t\t\"_\",\n\t).Funcs(\n\t\tglobalFuncMap,\n\t).Funcs(\n\t\tsprigFuncMap,\n\t).Parse(\n\t\tfmt.Sprintln(c.String(\"format\")),\n\t)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, record := range resp.Msg.Users {\n\t\tif err := tmpl.Execute(os.Stdout, record); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "4619cb6b0f3ae31bc987c56b9af89428", "score": "0.6891362", "text": "func ListUsers(options OptionsDef) error {\n\tdata, err := GetUsers(options)\n\tif err != nil {\n\t\treturn err\n\t}\n\tw := tabwriter.NewWriter(os.Stdout, 0, 0, 4, '\\t', tabwriter.AlignRight|tabwriter.Debug)\n\tfmt.Fprintf(w, \"%s\\t%s\\t%s\\t%s\\t%s\\n\", \"UID\", \"Admin\", \"Super user\", \"Email\", \"Kind\")\n\tfor _, user := range data {\n\t\tfmt.Fprintf(w, \"%s\\t%t\\t%t\\t%s\\t%s\\n\", user.UID, user.Admin, user.SuperUser, user.Email, user.Kind)\n\t}\n\tw.Flush()\n\treturn nil\n}", "title": "" }, { "docid": "e8325ce0351a7fc22d9620bc40e5f351", "score": "0.68675727", "text": "func (a *UserAPI) List(ctx context.Context, req *pb.ListUserRequest) (*pb.ListUserResponse, error) {\n\tif err := a.validator.Validate(ctx,\n\t\tauth.ValidateUsersAccess(auth.List)); err != nil {\n\t\treturn nil, grpc.Errorf(codes.Unauthenticated, \"authentication failed: %s\", err)\n\t}\n\n\tusers, err := storage.GetUsers(ctx, storage.DB(), int(req.Limit), int(req.Offset))\n\tif err != nil {\n\t\treturn nil, helpers.ErrToRPCError(err)\n\t}\n\n\ttotalUserCount, err := storage.GetUserCount(ctx, storage.DB())\n\tif err != nil {\n\t\treturn nil, helpers.ErrToRPCError(err)\n\t}\n\n\tresp := pb.ListUserResponse{\n\t\tTotalCount: int64(totalUserCount),\n\t}\n\n\tfor _, u := range users {\n\t\trow := pb.UserListItem{\n\t\t\tId: u.ID,\n\t\t\tEmail: u.Email,\n\t\t\tSessionTtl: u.SessionTTL,\n\t\t\tIsAdmin: u.IsAdmin,\n\t\t\tIsActive: u.IsActive,\n\t\t}\n\n\t\trow.CreatedAt, err = ptypes.TimestampProto(u.CreatedAt)\n\t\tif err != nil {\n\t\t\treturn nil, helpers.ErrToRPCError(err)\n\t\t}\n\t\trow.UpdatedAt, err = ptypes.TimestampProto(u.UpdatedAt)\n\t\tif err != nil {\n\t\t\treturn nil, helpers.ErrToRPCError(err)\n\t\t}\n\n\t\tresp.Result = append(resp.Result, &row)\n\t}\n\n\treturn &resp, nil\n}", "title": "" }, { "docid": "04e012e2d8aec984744bbff71308bea6", "score": "0.68585426", "text": "func ListUser() {\r\n\tres, err := handleReadRequest(base_URL, http.MethodGet)\r\n\tif err != nil {\r\n\t\tfmt.Println(\"Error\\n\")\r\n\t}\r\n\r\n\tvar apiResponse ListUsers\r\n\terr = json.Unmarshal(res, &apiResponse)\r\n\r\n\tif err != nil {\r\n\t\tfmt.Println(err)\r\n\t}\r\n\tfmt.Print(\"List of users:\\n\")\r\n\tfor i:=0; i < len(apiResponse.Users); i++ {\r\n\t\tfmt.Print(apiResponse.Users[i],\"\\n\")\r\n\t}\r\n}", "title": "" }, { "docid": "9bbfe6d63fc56838d631dab691fcf3ca", "score": "0.68333256", "text": "func (u *UserService) List(opt *UserListOptions) ([]User, *http.Response, error) {\n\treq, err := u.client.NewRequest(\"GET\", \"user\", opt, nil)\n\n\tusers := new(Users)\n\tresp, err := u.client.Do(req, &users)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\treturn users.Items, resp, nil\n}", "title": "" }, { "docid": "d2ba175cbe9de48fc25af2eb104d4060", "score": "0.68329024", "text": "func listUsers(c *gin.Context) {\n\n\tvar users []User\n\n\tdb.Find(&users)\n\n\tc.JSON(http.StatusOK, users)\n}", "title": "" }, { "docid": "e08b65423b19de4fde6d534ee0239b81", "score": "0.68279135", "text": "func (s *Service) List(c *gin.Context, p *model.Pagination) ([]model.User, error) {\n\tu := s.auth.User(c)\n\tq, err := query.List(u)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn s.userRepo.List(q, p)\n}", "title": "" }, { "docid": "4b2ea74f63cb383ad04ef42b53ce83da", "score": "0.68138546", "text": "func (a Service) ListUsers(projectID string) ([]generic.User, error) {\n\ttoken := a.Token\n\terr := listUsersByProject(token, projectID)\n\treturn []generic.User{}, err\n}", "title": "" }, { "docid": "dc3da84eeeeab51003e39e5ccc2d604d", "score": "0.68087137", "text": "func (s *userService) List(r dto.UserSearchReq) *dto.MultipleUserRes {\n\tres := &dto.MultipleUserRes{}\n\n\tsortParams := api.SortConverter(r.Sorts)\n\n\tfilter := &repositories.UserSearchFilter{\n\t\tQuery: r.Query,\n\t\tEmail: r.Email,\n\t}\n\tentities, count, err := s.users.Search(filter, sortParams, nil)\n\tif err != nil && err != api.ErrNoResult {\n\t\tres.Error = &dto.Error{\n\t\t\tCode: http.StatusInternalServerError,\n\t\t\tMessage: err.Error(),\n\t\t}\n\t}\n\n\tif err == api.ErrNoResult {\n\t\tres.Total = 0\n\t\tres.Members = make([]*dto.Domain_User, 0)\n\t} else {\n\t\tres.Total = int32(count)\n\t\tres.Members = mapper.FromUsers(entities)\n\t}\n\n\treturn res\n}", "title": "" }, { "docid": "e0903e104fc72cca3b176713b161e3da", "score": "0.68044573", "text": "func ListUsers(c *gin.Context) {\n\tvar users []*User\n\tcursor, err := collection.Find(context.TODO(), bson.M{}, options.Find())\n\tif err != nil {\n\t\tfmt.Printf(\"Error getting users: %s \\n\", err)\n\t\tc.JSON(http.StatusInternalServerError, gin.H{\n\t\t\t\"status\": http.StatusInternalServerError,\n\t\t\t\"message\": \"Something went wrong\",\n\t\t})\n\t\treturn\n\t}\n\n\tfor cursor.Next(context.TODO()) {\n\t\tvar user User\n\t\terr := cursor.Decode(&user)\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"Failed to decode user: %s \\n\", err)\n\t\t}\n\n\t\tusers = append(users, &user)\n\t}\n\n\tif err := cursor.Err(); err != nil {\n\t\tfmt.Printf(\"Cursor error: %s \\n\", err)\n\t}\n\n\tcursor.Close(context.TODO())\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"data\": users,\n\t})\n}", "title": "" }, { "docid": "ccb65bb07026a6cdb53246a75d5cd3fe", "score": "0.6794073", "text": "func (svc *UserServiceServer) List(ctx context.Context, req *api.UserListReq) (*api.UserListRes, error) {\n\t// prepare a Res\n\tres := new(api.UserListRes)\n\n\t// find all users\n\tcursor, err := svc.DB.Collection(UserCollection).Find(ctx,\n\t\tbson.M{},\n\t\t&options.FindOptions{\n\t\t\tSort: bson.M{\n\t\t\t\t\"username\": 1, // acending\n\t\t\t\t//\"username\": -1, // descending\n\t\t\t},\n\t\t},\n\t)\n\tif err == mongo.ErrNoDocuments {\n\t\treturn res, nil\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer cursor.Close(ctx)\n\n\t// itterate each document returned\n\tfor cursor.Next(ctx) {\n\t\tvar user = new(api.User)\n\t\terr := cursor.Decode(&user)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// append the current role to the slice\n\t\tres.Users = append(res.Users, user)\n\t}\n\n\t// handle any errors with the cursor\n\tif err := cursor.Err(); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn res, nil\n}", "title": "" }, { "docid": "3da47de92d3c35e7065e9e17aacbc6d6", "score": "0.6785004", "text": "func (c *UserController) ListUsers() {\n\tbeego.ReadFromRequest(&c.Controller)\n\tc.TplName = \"users/list-users.tpl\"\n\n\tcurrentPage := 1\n\tif page, err := strconv.Atoi(c.Input().Get(\"p\")); err == nil {\n\t\tcurrentPage = page\n\t}\n\n\tusers := models.Users{}\n\tuserList, count := users.GetAllUsers(pageLimit, currentPage)\n\n\tpagination.SetPaginator(c.Ctx, pageLimit, count)\n\tpageStart := currentPage*pageLimit - (pageLimit - 1)\n\n\tc.Data[\"userList\"] = userList\n\tc.Data[\"deleteMethod\"] = \"delete\"\n\tc.Data[\"pageStart\"] = pageStart\n\tc.Data[\"count\"] = count\n}", "title": "" }, { "docid": "c80ad2802c301b0e6dc8f901822590c5", "score": "0.6783894", "text": "func List(c *client.Client, results int) ([]api.User, int, error) {\n\tbody, count, err := c.LimitedRequest(\"/v1/users/\", results)\n\n\tif err != nil {\n\t\treturn []api.User{}, -1, err\n\t}\n\n\tvar users []api.User\n\tif err = json.Unmarshal([]byte(body), &users); err != nil {\n\t\treturn []api.User{}, -1, err\n\t}\n\n\treturn users, count, nil\n}", "title": "" }, { "docid": "8920cae8f868fb02cabd1b9647c54df5", "score": "0.6758033", "text": "func (cli *CLI) CallUsersList() int {\n\treturn cli.PrintJSON(cli.api.UsersList(cli.Number(1, 100), flag.Arg(2)))\n}", "title": "" }, { "docid": "182fe3448269026be285c050ca6d7017", "score": "0.67349124", "text": "func (c *Client) ListUsers(ctx context.Context, query *PaginationQuery) (*ListUsersResponse, error) {\n\n\turi := \"/users\"\n\treq, err := c.newRequest(ctx, http.MethodGet, uri, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"notion: invalid request: %w\", err)\n\t}\n\n\tif query != nil {\n\t\tq := url.Values{}\n\t\tif query.StartCursor != \"\" {\n\t\t\tq.Set(\"start_cursor\", query.StartCursor)\n\t\t}\n\t\tpageSize := query.PageSize\n\t\tif pageSize > 0 {\n\t\t\t// limit to max allowed\n\t\t\tif pageSize > 100 {\n\t\t\t\tpageSize = 100\n\t\t\t}\n\t\t\tq.Set(\"page_size\", strconv.Itoa(pageSize))\n\t\t}\n\t\treq.URL.RawQuery = q.Encode()\n\t}\n\n\tvar res ListUsersResponse\n\tres.RawJSON, err = c.doHTTPAndUnmarshalResponse(req, &res, \"list users\")\n\treturn &res, err\n}", "title": "" }, { "docid": "f745deac27fb3adb881b614f8c5deb4a", "score": "0.6734676", "text": "func UserList(db storage.IStorage) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tusers, err := db.GetAll()\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\tsendResponse(w, map[string]interface{}{\n\t\t\t\t\"status\": http.StatusInternalServerError,\n\t\t\t\t\"error\": \"Error getting data\",\n\t\t\t})\n\t\t\treturn\n\t\t}\n\n\t\tsendResponse(w, map[string]interface{}{\n\t\t\t\"status\": http.StatusOK,\n\t\t\t\"users\": users,\n\t\t})\n\t}\n}", "title": "" }, { "docid": "5224b58995987f32ac20d0a95b479476", "score": "0.67275316", "text": "func (s *hyUsersrvc) UserList(ctx context.Context, p *hyuser.UserListPayload) (res hyuser.UserCollection, view string, err error) {\n\tlog.Info().Msg(\"hyUser.UserList\")\n\n\tusers, err := s.userRepo.UserList()\n\tif err != nil {\n\t\treturn nil, \"\", errors.Wrap(err, \"fail to call userRepo.UserList()\")\n\t}\n\tif len(users) == 0 {\n\t\treturn nil, \"\", hyuser.MakeNotFound(errors.New(\"user not found\"))\n\t}\n\tres = users\n\tview = \"default\"\n\n\treturn\n}", "title": "" }, { "docid": "66553eef83c5aa29b97ae6612537065b", "score": "0.67243075", "text": "func UserListAll(w http.ResponseWriter, r *http.Request) {\n\n\tvar err error\n\tvar pageSize int\n\tvar paginatedUsers auth.PaginatedUsers\n\n\t// Init output\n\toutput := []byte(\"\")\n\n\t// Add content type header to the response\n\tcontentType := \"application/json\"\n\tcharset := \"utf-8\"\n\tw.Header().Add(\"Content-Type\", fmt.Sprintf(\"%s; charset=%s\", contentType, charset))\n\n\t// Grab context references\n\trefStr := gorillaContext.Get(r, \"str\").(stores.Store)\n\trefRoles := gorillaContext.Get(r, \"auth_roles\").([]string)\n\tusersDetailedView := false\n\n\t// Grab url path variables\n\turlValues := r.URL.Query()\n\tpageToken := urlValues.Get(\"pageToken\")\n\tstrPageSize := urlValues.Get(\"pageSize\")\n\tprojectName := urlValues.Get(\"project\")\n\tdetails := urlValues.Get(\"details\")\n\tprojectUUID := \"\"\n\n\tif details == \"true\" {\n\t\tusersDetailedView = true\n\t}\n\n\tif projectName != \"\" {\n\t\tprojectUUID = projects.GetUUIDByName(projectName, refStr)\n\t\tif projectUUID == \"\" {\n\t\t\terr := APIErrorNotFound(\"ProjectUUID\")\n\t\t\trespondErr(w, err)\n\t\t\treturn\n\t\t}\n\t}\n\n\tif strPageSize != \"\" {\n\t\tif pageSize, err = strconv.Atoi(strPageSize); err != nil {\n\t\t\tlog.Errorf(\"Pagesize %v produced an error while being converted to int: %v\", strPageSize, err.Error())\n\t\t\terr := APIErrorInvalidData(\"Invalid page size\")\n\t\t\trespondErr(w, err)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// check that user is indeed a service admin in order to be privileged to see full user info\n\tprivileged := auth.IsServiceAdmin(refRoles)\n\n\t// Get Results Object - call is always privileged because this handler is only accessible by service admins\n\tpaginatedUsers, err =\n\t\tauth.PaginatedFindUsers(pageToken, int64(pageSize), projectUUID, privileged, usersDetailedView, refStr)\n\n\tif err != nil {\n\t\terr := APIErrorInvalidData(\"Invalid page token\")\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\t// Output result to JSON\n\tresJSON, err := paginatedUsers.ExportJSON()\n\n\tif err != nil {\n\t\terr := APIErrExportJSON()\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\t// Write response\n\toutput = []byte(resJSON)\n\trespondOK(w, output)\n}", "title": "" }, { "docid": "304c0181bc98a18a5d421f1a63b7729b", "score": "0.669282", "text": "func UsersList(c buffalo.Context) error {\n\t// Get the DB connection from the context\n\ttx, ok := c.Value(\"tx\").(*pop.Connection)\n\tif !ok {\n\t\treturn errors.WithStack(errors.New(\"no transaction found\"))\n\t}\n\n\tusers := &models.Users{}\n\n\tq := tx.PaginateFromParams(c.Params())\n\n\t// Retrieve all Users from the DB\n\tif err := q.All(users); err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\n\ttype UserWithRoles struct {\n\t\tmodels.User\n\t\tRoles []string `json:\"roles\"`\n\t}\n\n\ttype UsersWithRoles []UserWithRoles\n\n\tuwr := UsersWithRoles{}\n\n\tfor _, u := range *users {\n\t\troles := &models.Roles{}\n\t\tsql := \"SELECT roles.* FROM user_roles INNER JOIN roles ON user_roles.role_id = roles.id WHERE user_roles.user_id = ?\"\n\t\tq := tx.RawQuery(sql, u.ID)\n\t\terr := q.All(roles)\n\n\t\tif err != nil {\n\t\t\treturn errors.WithStack(err)\n\t\t}\n\n\t\troleNames := []string{}\n\t\t// obtain only the name of the roles\n\t\tfor _, v := range *roles {\n\t\t\troleNames = append(roleNames, v.Name)\n\t\t}\n\n\t\ttmp := UserWithRoles{\n\t\t\tu,\n\t\t\troleNames,\n\t\t}\n\n\t\tuwr = append(uwr, tmp)\n\t}\n\n\tresult := struct {\n\t\tUsersWithRoles `json:\"users\"`\n\t\tPage int `json:\"page\"`\n\t\tPerPage int `json:\"perPage\"`\n\t\tOffset int `json:\"offset\"`\n\t\tTotalEntriesSize int `json:\"totalEntriesSize\"`\n\t\tCurrentEntriesSize int `json:\"currentEntriesSize\"`\n\t\tTotalPages int `json:\"totalPages\"`\n\t}{\n\t\tuwr,\n\t\tq.Paginator.Page,\n\t\tq.Paginator.PerPage,\n\t\tq.Paginator.Offset,\n\t\tq.Paginator.TotalEntriesSize,\n\t\tq.Paginator.CurrentEntriesSize,\n\t\tq.Paginator.TotalPages,\n\t}\n\n\treturn c.Render(200, r.JSON(result))\n}", "title": "" }, { "docid": "a07b2c743ae22c9803167f821452ebb9", "score": "0.66800874", "text": "func ListUsers(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"content-type\", \"application/json\")\n\n\tresponse, _ := json.Marshal(map[string]interface{}{\n\t\t\"users\": db.Users,\n\t})\n\n\tw.Write(response)\n\tw.WriteHeader(http.StatusOK)\n\treturn\n}", "title": "" }, { "docid": "3c157ef813a5b60d8884bd0c03f6de34", "score": "0.66741806", "text": "func ListUsersHandler(w http.ResponseWriter, req *http.Request, appEnv AppEnv) {\n\tlist, err := appEnv.UserStore.ListUsers()\n\tif err != nil {\n\t\tresponse := status.Response{\n\t\t\tStatus: strconv.Itoa(http.StatusNotFound),\n\t\t\tMessage: \"can't find any users\",\n\t\t}\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"env\": appEnv.Env,\n\t\t\t\"status\": http.StatusNotFound,\n\t\t}).Error(\"Can't find any users\")\n\t\tappEnv.Render.JSON(w, http.StatusNotFound, response)\n\t\treturn\n\t}\n\tresponseObject := make(map[string]interface{})\n\tresponseObject[\"users\"] = list\n\tresponseObject[\"count\"] = len(list)\n\tappEnv.Render.JSON(w, http.StatusOK, responseObject)\n}", "title": "" }, { "docid": "1ce7d63318b4a463b7e39be6b10bf6b7", "score": "0.6668928", "text": "func (s *Slack) ListUsers(u *url.URL, h http.Header, _ interface{}, context *models.Context) (int, http.Header, interface{}, error) {\n\tif !context.IsLoggedIn() {\n\t\treturn response.NewBadRequest(models.ErrNotLoggedIn)\n\t}\n\n\ttoken, err := getSlackTokenWithContext(context)\n\tif err != nil {\n\t\treturn response.NewBadRequest(err)\n\t}\n\n\treturn response.HandleResultAndError(getUsers(token))\n}", "title": "" }, { "docid": "6457b58e16d4b8e4c600a2ecf4d35e22", "score": "0.6644186", "text": "func (c Client) ListUsers(ctx context.Context) ([]string, error) {\n\treturn c.list(ctx, KeyUsers)\n}", "title": "" }, { "docid": "4c53e37c6eaa1386c30da14d30bb620c", "score": "0.66317147", "text": "func ShowUserList(c *gin.Context) {\r\n\tcfg, db, ok := retrieveContextValues(c)\r\n\tif !ok {\r\n\t\tc.AbortWithStatus(http.StatusInternalServerError)\r\n\t\treturn\r\n\t}\r\n\r\n\t// Check if user is logged\r\n\tuser, ok := loggedUser(c)\r\n\tif !ok {\r\n\t\tc.Redirect(http.StatusSeeOther, \"/dashboard\")\r\n\t\treturn\r\n\t}\r\n\r\n\t// Retrieve default session\r\n\tsession := sessions.Default(c)\r\n\r\n\t// Check if user has \"create_user\" role\r\n\tif !role.UserHasRole(cfg, user, role.UserList) {\r\n\t\tsession.Set(\"error\", \"Tu cuenta no tiene permisos para ver la lista de usuarios\")\r\n\t\tsession.Save()\r\n\t\tc.Redirect(http.StatusSeeOther, \"/dashboard\")\r\n\t\treturn\r\n\t}\r\n\r\n\t// Retrieve success flash message\r\n\tflashSuccess := session.Get(\"success\")\r\n\tsession.Delete(\"success\")\r\n\r\n\t// Retrieve error flash message\r\n\tflashError := session.Get(\"error\")\r\n\tsession.Delete(\"error\")\r\n\tsession.Save()\r\n\r\n\t// Retrieve list of users\r\n\tuserList, err := models.UserList(db)\r\n\tif err != nil {\r\n\t\tc.Error(err)\r\n\t\tc.AbortWithStatus(http.StatusInternalServerError)\r\n\t\treturn\r\n\t}\r\n\r\n\t// Create XSRF token\r\n\ttoken := nosurf.Token(c.Request)\r\n\r\n\tc.HTML(http.StatusOK, \"list_user.html\", map[string]interface{}{\r\n\t\t\"list\": userList,\r\n\t\t\"user\": user,\r\n\t\t\"token\": token,\r\n\t\t\"success\": flashSuccess,\r\n\t\t\"error\": flashError,\r\n\t\t\"roleList\": c.MustGet(\"roleList\"),\r\n\t})\r\n}", "title": "" }, { "docid": "dc54f1089988b19bfd4d9a58389c081f", "score": "0.661367", "text": "func ListUsers(pgRepo users.Repository) fiber.Handler {\n\treturn func(c *fiber.Ctx) error {\n\t\tpage, _ := strconv.Atoi(c.Params(\"page\"))\n\t\tlimit, _ := strconv.Atoi(c.Params(\"limit\"))\n\t\tusers, err := pgRepo.List(page, limit)\n\t\tif err != nil {\n\t\t\treturn c.Status(http.StatusBadRequest).JSON(fiber.Map{\n\t\t\t\t\"error\": fiber.Map{\n\t\t\t\t\t\"message\": \"An error occured while retrieiving data\",\n\t\t\t\t\t\"details\": err,\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\treturn c.Status(http.StatusOK).JSON(users)\n\t}\n}", "title": "" }, { "docid": "b3682aa95d9c89efabc806f0b6ae7f33", "score": "0.6595407", "text": "func (u *UserRepository) List(ctx context.Context) ([]obj.User, error) {\n\n\trows, err := u.db.QueryContext(ctx, \"SELECT * FROM \\\"contactsApi\\\".\\\"users\\\"\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to fetch users from database: %s\", err)\n\t}\n\n\tusers := []obj.User{}\n\n\tdefer rows.Close()\n\tfor rows.Next() {\n\t\tuser := obj.User{}\n\t\terr = rows.Scan(\n\t\t\t&user.ID,\n\t\t\t&user.FirstName,\n\t\t\t&user.LastName,\n\t\t\t&user.UpdatedAt,\n\t\t\t&user.CreatedAt)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to map row to user: %s\", err)\n\t\t}\n\t\tusers = append(users, user)\n\t}\n\treturn users, nil\n}", "title": "" }, { "docid": "e28b559b9bfe1b157adcecc07182608b", "score": "0.65831697", "text": "func (a *AuthAgent) ListUsers() []string {\n\tentries, _ := a.Database.ListTable(\"auth\")\n\tresults := []string{}\n\tfor _, keypairs := range entries {\n\t\tif strings.Contains(string(keypairs[0]), \"group/\") {\n\t\t\tusername := strings.Split(string(keypairs[0]), \"/\")[1]\n\t\t\tresults = append(results, username)\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "3acf1395d1a77c01cf7982f074433b12", "score": "0.6582927", "text": "func (a *Client) APIListUsers(params *APIListUsersParams, authInfo runtime.ClientAuthInfoWriter) (*APIListUsersOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewAPIListUsersParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"api_list_users\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/pdnsadmin/users\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"http\"},\n\t\tParams: params,\n\t\tReader: &APIListUsersReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*APIListUsersOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for api_list_users: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "title": "" }, { "docid": "d01c5e4276426d006ef2ef18d875842a", "score": "0.6568923", "text": "func (s *UsersService) List(opt *UsersOptions) ([]User, *http.Response, error) {\n\turi, err := addOptions(\"users\", opt)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tusers := new(Users)\n\tres, err := s.client.Get(uri, users)\n\tif err != nil {\n\t\treturn nil, res, err\n\t}\n\n\treturn users.Users, res, err\n}", "title": "" }, { "docid": "8e735c000a85599021627498fed94dc2", "score": "0.6562833", "text": "func ListUsers(s Server, args map[string]string) (<-chan UserList, <-chan error) {\n\turl := createURL(s, \"ListUsers.do\")\n\treturn listUsers(s, args, url)\n}", "title": "" }, { "docid": "bbc779b4cf72b7188c8048f632cc6e1b", "score": "0.655062", "text": "func (c *UserController) List(ctx *app.ListUserContext) error {\n\t// UserController_List: start_implement\n\tfmt.Println(\"signin jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\")\n\n\t// Put your logic here\n\n\t// UserController_List: end_implement\n\tres := app.UserMediaCollection{}\n\treturn ctx.OK(res)\n}", "title": "" }, { "docid": "0833f6e9f3b3b2b160ac95a1940970fc", "score": "0.6547931", "text": "func (s *UsersService) List(opts *UserListOptions) ([]User, *Response, error) {\n\turi, err := addOptions(\"users\", opts)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tusers := new(userListWrapper)\n\tresp, err := s.client.Get(uri, users)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn users.Users, resp, err\n}", "title": "" }, { "docid": "4fa6265d8f2c14e70bfa0d5aeba22296", "score": "0.6539774", "text": "func (s *Slack) UserList() (*UserListResponse, error) {\n\tparams := url.Values{}\n\tr := &UserListResponse{}\n\terr := s.do(\"users.list\", params, r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn r, nil\n}", "title": "" }, { "docid": "050805c2219f8d06592d0f9bd1987551", "score": "0.65365297", "text": "func (m *MockUserManagerInterface) List(opts ...github_com_confluentinc_auth0_management.ReqOption) ([]*github_com_confluentinc_auth0_management.User, error) {\n\tm.lockList.Lock()\n\tdefer m.lockList.Unlock()\n\n\tif m.ListFunc == nil {\n\t\tpanic(\"mocker: MockUserManagerInterface.ListFunc is nil but MockUserManagerInterface.List was called.\")\n\t}\n\n\tcall := struct {\n\t\tOpts []github_com_confluentinc_auth0_management.ReqOption\n\t}{\n\t\tOpts: opts,\n\t}\n\n\tm.calls.List = append(m.calls.List, call)\n\n\treturn m.ListFunc(opts...)\n}", "title": "" }, { "docid": "65733a9d0146f92fe3a5ec27afea92fd", "score": "0.65301245", "text": "func (c *Client) UsersList(ctx context.Context) ([]User, error) {\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, usersListEndpoint, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Header.Set(\"Authorization\", \"Bearer \"+c.token)\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tresp, err := c.httpclient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"slack chat.postMessage failed: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\tb, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"response body read error: %w\", err)\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"slack chat.postMessage failed: %v\", resp.Status)\n\t}\n\tvar ul UsersListResponse\n\tif err := json.Unmarshal(b, &ul); err != nil {\n\t\treturn nil, fmt.Errorf(\"response body unmarshal error: body=%q, %w\", string(b), err)\n\t}\n\tif !ul.OK {\n\t\tif ul.Error == \"missing_scope\" {\n\t\t\treturn nil, fmt.Errorf(\"%s: needed: %q, provided: %q\", ul.Error, ul.Needed, ul.Provided)\n\t\t}\n\t\treturn nil, errors.New(ul.Error)\n\t}\n\treturn ul.Members, nil\n}", "title": "" }, { "docid": "955ebd83fb5017a6658fab424448c431", "score": "0.65149283", "text": "func (a *Auth) OktaListUsers(ctx context.Context, options ...RequestOption) (*Response[map[string]interface{}], error) {\n\trequestModifiers, err := requestOptionsToRequestModifiers(options)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trequestPath := \"/v1/auth/{okta_mount_path}/users\"\n\trequestPath = strings.Replace(requestPath, \"{\"+\"okta_mount_path\"+\"}\", url.PathEscape(requestModifiers.mountPathOr(\"okta\")), -1)\n\n\trequestQueryParameters := requestModifiers.customQueryParametersOrDefault()\n\trequestQueryParameters.Add(\"list\", \"true\")\n\n\treturn sendRequestParseResponse[map[string]interface{}](\n\t\tctx,\n\t\ta.client,\n\t\thttp.MethodGet,\n\t\trequestPath,\n\t\tnil, // request body\n\t\trequestQueryParameters,\n\t\trequestModifiers,\n\t)\n}", "title": "" }, { "docid": "512464581e0d73eef514cd0ff6e3872e", "score": "0.6510912", "text": "func AllUsers(c *fiber.Ctx) error {\n\tif err := middleware.IsAuthorized(c, \"users\"); err != nil {\n\t\treturn err\n\t}\n\n\t// add pagination\n\tpage, _ := strconv.Atoi(c.Query(\"page\", \"1\"))\n\n\treturn c.JSON(models.Paginate(database.DB, &models.User{}, page))\n}", "title": "" }, { "docid": "422caa2387c79b9118210cb1b97048fe", "score": "0.65107477", "text": "func List(ctx context.Context, client *selvpcclient.ServiceClient) ([]*User, *selvpcclient.ResponseResult, error) {\n\turl := strings.Join([]string{client.Endpoint, resourceURL}, \"/\")\n\tresponseResult, err := client.DoRequest(ctx, http.MethodGet, url, nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tif responseResult.Err != nil {\n\t\treturn nil, responseResult, responseResult.Err\n\t}\n\n\t// Extract users from the response body.\n\tvar result struct {\n\t\tUsers []*User `json:\"users\"`\n\t}\n\terr = responseResult.ExtractResult(&result)\n\tif err != nil {\n\t\treturn nil, responseResult, err\n\t}\n\n\treturn result.Users, responseResult, nil\n}", "title": "" }, { "docid": "13183ce749b2120193d1c63e49ff616e", "score": "0.6504707", "text": "func userListContoller(c *core.Context) {\n\tresponses, err := models.GetAllUsers()\n\tif err != nil {\n\t\tc.ErrorResponse(err)\n\t} else {\n\t\tc.RenderJson(responses)\n\t}\n}", "title": "" }, { "docid": "d3bbb3d9c2b02a4bfee200aaee414777", "score": "0.65043455", "text": "func (a *Auth) UserpassListUsers(ctx context.Context, options ...RequestOption) (*Response[map[string]interface{}], error) {\n\trequestModifiers, err := requestOptionsToRequestModifiers(options)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trequestPath := \"/v1/auth/{userpass_mount_path}/users\"\n\trequestPath = strings.Replace(requestPath, \"{\"+\"userpass_mount_path\"+\"}\", url.PathEscape(requestModifiers.mountPathOr(\"userpass\")), -1)\n\n\trequestQueryParameters := requestModifiers.customQueryParametersOrDefault()\n\trequestQueryParameters.Add(\"list\", \"true\")\n\n\treturn sendRequestParseResponse[map[string]interface{}](\n\t\tctx,\n\t\ta.client,\n\t\thttp.MethodGet,\n\t\trequestPath,\n\t\tnil, // request body\n\t\trequestQueryParameters,\n\t\trequestModifiers,\n\t)\n}", "title": "" }, { "docid": "ef20c53a27f46bac490b21fd1a4c22f6", "score": "0.649675", "text": "func (s *UserSearch) List(usertype, username string) (users cf.UserAPIResponse, err error) {\n\tvar u cf.UserAPIResponse\n\n\tif u, err = s.Client.QueryUsers(1, 1, \"id\", \"\"); err == nil {\n\t\tquery := s.BuildQuery(usertype, username)\n\t\tusers, err = s.Client.QueryUsers(1, u.TotalResults, \"\", query)\n\t}\n\treturn\n}", "title": "" }, { "docid": "e48ec58a992799159a650fe842d2928e", "score": "0.64815664", "text": "func (c *client) ListUsers() Users {\n\tcs := make(chan interface{})\n\tgo func() {\n\t\tdefer close(cs)\n\t\tpath := c.url(\"/users?per_page=100\")\n\t\tfor {\n\t\t\tvar xs []*User\n\t\t\tnext, err := c.getList(path, &xs)\n\t\t\tif err != nil {\n\t\t\t\tcs <- fmt.Errorf(\"ListUsers /users: %w\", err)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tfor _, x := range xs {\n\t\t\t\tcs <- x\n\t\t\t}\n\t\t\tif next == \"\" {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tpath = next\n\t\t}\n\t}()\n\treturn Users(cs)\n}", "title": "" }, { "docid": "de04a935d72992dd223e07445dc86e0b", "score": "0.6481127", "text": "func (c *Client) ListUsers() (*[]string, error) {\n\tc.Logger.Debug(\"ListUsers\")\n\tvar t userList\n\t_, err := c.client.R().\n\t\tSetResult(&t).\n\t\tGet(\"api/userrolelist/users\")\n\treturn &t.Users, err\n}", "title": "" }, { "docid": "4ccae234c4cbc854c537a2c4eb3bc5f9", "score": "0.64788747", "text": "func (rc *userRestController) findUsers(cxt *gin.Context) {\n // Invokes the service by getting all users\n\tusers, err := rc.service.GetAll()\n\t// Check that the previous operation was successful\n\tif err != nil {\n\t\t// Returns an error 400 BAD REQUEST attaching the error message\n cxt.JSON(http.StatusBadRequest, gin.H{\"error\": err})\n return\n\t}\n\t\n\t// Formats the list of users in JSON\n\tcxt.JSON(http.StatusOK, users)\n}", "title": "" }, { "docid": "0c7191973d78fa37c9f01df128df1d06", "score": "0.6468403", "text": "func (a *API) adminUsers(w http.ResponseWriter, r *http.Request) error {\n\tctx := r.Context()\n\tinstanceID := getInstanceID(ctx)\n\taud := a.requestAud(ctx, r)\n\n\tpageParams, err := paginate(r)\n\tif err != nil {\n\t\treturn badRequestError(\"Bad Pagination Parameters: %v\", err)\n\t}\n\n\tsortParams, err := sort(r, map[string]bool{models.CreatedAt: true}, []models.SortField{models.SortField{Name: models.CreatedAt, Dir: models.Descending}})\n\tif err != nil {\n\t\treturn badRequestError(\"Bad Sort Parameters: %v\", err)\n\t}\n\n\tfilter := r.URL.Query().Get(\"filter\")\n\n\tusers, err := models.FindUsersInAudience(a.db, instanceID, aud, pageParams, sortParams, filter)\n\tif err != nil {\n\t\treturn internalServerError(\"Database error finding users\").WithInternalError(err)\n\t}\n\taddPaginationHeaders(w, r, pageParams)\n\n\treturn sendJSON(w, http.StatusOK, map[string]interface{}{\n\t\t\"users\": users,\n\t\t\"aud\": aud,\n\t})\n}", "title": "" }, { "docid": "af462920f80ee5250c76b4c5d1fc5134", "score": "0.6454888", "text": "func (s *UserService) List() ([]User, error) {\n\n\tresource := make([]User, 0)\n\n\trp, pagination, _, err := s.getPage(1, 200)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresource = append(resource, *rp...)\n\n\tif pagination != nil {\n\t\tfor *pagination.Page < *pagination.Pages {\n\t\t\trp, pg, _, err := s.getPage(*pagination.Page+1, 200)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tpagination = pg\n\t\t\tresource = append(resource, *rp...)\n\t\t}\n\t}\n\n\treturn resource, err\n}", "title": "" }, { "docid": "80e2c655ab1f0f8c3bae80e077a5b892", "score": "0.64511675", "text": "func List() []string {\n\tvar output []string\n\tfor username := range config.All().Users {\n\t\toutput = append(output, username)\n\t}\n\treturn output\n}", "title": "" }, { "docid": "a8775983b9f18f85ccda649d467258ce", "score": "0.6422939", "text": "func (r *Realm) ListUsers(db *Database) ([]*User, error) {\n\tvar users []*User\n\tif err := db.db.\n\t\tModel(r).\n\t\tRelated(&users, \"RealmUsers\").\n\t\tOrder(\"email\").\n\t\tError; err != nil {\n\t\treturn nil, err\n\t}\n\treturn users, nil\n}", "title": "" }, { "docid": "af357945387397e42f77609247a72513", "score": "0.64140785", "text": "func (u *Users) List() ([]User, error) {\n\ttype Response struct {\n\t\tUsers []User `json:\"users\"`\n\t\tSuccess bool `json:\"success\"`\n\t}\n\n\tres, err := u.c.NewRequest().\n\t\tSetQueryParam(\"count\", \"0\").\n\t\tSetResult(Response{}).\n\t\tGet(fmt.Sprintf(\"%s/api/v1/users.list\", u.c.URL))\n\n\tif err != nil {\n\t\treturn []User{}, err\n\t}\n\n\tr, ok := res.Result().(*Response)\n\tif !ok {\n\t\treturn []User{}, ErrInvalidAPIResponse\n\t}\n\n\tif !r.Success {\n\t\treturn []User{}, ErrNotSuccessful\n\t}\n\n\treturn r.Users, nil\n}", "title": "" }, { "docid": "8bfe2fec253e26941e87a1cd42475cb8", "score": "0.6412222", "text": "func (d *PgDAO) ListUsers(filters url.Values) (list []models.User, err error) {\n\tlist = make([]models.User, 0)\n\n\terr = d.BaseDB.Model(&list).Select()\n\tif err != nil && err != pg.ErrNoRows {\n\t\treturn list, err\n\t}\n\n\treturn list, nil\n}", "title": "" }, { "docid": "b9ba202594a0141636a5fd94fcd5f903", "score": "0.64109564", "text": "func (a *UsersApiService) UserList(ctx context.Context) (model.UserListResponse, *http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = strings.ToUpper(\"Get\")\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue model.UserListResponse\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/users\"\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tif ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {\n\t\t\tvar key string\n\t\t\tif auth.Prefix != \"\" {\n\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t} else {\n\t\t\t\tkey = auth.Key\n\t\t\t}\n\t\t\tlocalVarHeaderParams[\"Authorization\"] = key\n\n\t\t}\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHttpResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHttpResponse == nil {\n\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)\n\tlocalVarHttpResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t}\n\n\tif localVarHttpResponse.StatusCode < 300 {\n\t\t// If we succeed, return the data, otherwise pass on to decode error.\n\t\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\tif err == nil {\n\t\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t\t}\n\t}\n\n\tif localVarHttpResponse.StatusCode >= 300 {\n\t\tnewErr := GenericSwaggerError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHttpResponse.Status,\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 200 {\n\t\t\tvar v model.UserListResponse\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 500 {\n\t\t\tvar v model.GenericError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t}\n\n\treturn localVarReturnValue, localVarHttpResponse, nil\n}", "title": "" }, { "docid": "cffc66fb0622fc42872d8c6451aa59c7", "score": "0.64044774", "text": "func GetAllUsers(res http.ResponseWriter, req *http.Request) {\n\t//Declare Variable\n\tvar model models.Users\n\tvar all []models.Users\n\n\tswitch req.Method {\n\tcase \"OPTIONS\":\n\t\tutils.WriteResult(req, res, nil, \"Access Allowed\")\n\t\treturn\n\t}\n\n\tauthkey := req.Header.Get(\"auth_key\")\n\tlog.Println(authkey)\n\tuserid := req.Header.Get(\"user_id\")\n\tuid, _ := primitive.ObjectIDFromHex(userid)\n\n\tif utils.VerifyOwnership(uid, authkey) {\n\t\t//Connect DB\n\t\tdb := utils.ConnectMongoDB()\n\t\tcol, err := db.Collection(\"users\").Find(context.TODO(), bson.M{})\n\n\t\t//Loop column\n\t\tfor col.Next(context.TODO()) {\n\t\t\terr := col.Decode(&model)\n\t\t\tutils.ErrorHandler(err)\n\t\t\tall = append(all, model)\n\t\t}\n\n\t\tif len(all) == 0 {\n\t\t\tutils.WriteResult(req, res, nil, \"User Collumn Empty\")\n\t\t\treturn\n\t\t}\n\n\t\t//Return Res\n\t\tutils.ErrorHandler(err)\n\t\tutils.WriteResult(req, res, all, \"Sucessfully Returned \"+strconv.Itoa(len(all))+\" Users!\")\n\t} else {\n\t\tutils.WriteResult(req, res, nil, \"Access Denied \")\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "189000cf9715e44b0e3ceb5a39a64ea7", "score": "0.6395509", "text": "func (s *Obj) ListUser(ctx context.Context, in *sea.ListUserRequest) (*sea.ListUserResponse, error){\n\n\tvar(\n\t\tout []*sea.User\n\t\tpageFilter *sea.PageFilter\n\t\toffset,limit uint32\n\t)\n\n\tpageFilter = in.GetPageFilter()\n\tif pageFilter != nil{\n\t\toffset = pageFilter.GetPage() * pageSize\n\t\tlimit = pageFilter.GetLimit()\n\t}\n\n\tusers, err := user.List(s.DB, offset, limit)\n\n\tfor _, user := range users{\n\t\trpcUser := userToRpcUser(user)\n\t\tout = append(out, &rpcUser)\n\t}\n\n\tif err != nil {\n\t\treturn nil ,err\n\t}\n\n\treturn &sea.ListUserResponse{Users: out}, nil\n}", "title": "" }, { "docid": "f6021a0b68f9019beb45d375ff4e931a", "score": "0.63921005", "text": "func (s *UsersService) List(ctx context.Context, options *UsersOptions) ([]*User, *http.Response, error) {\n\tu := \"2.0/subscription/users\"\n\treq, err := s.client.NewRequest(\"POST\", u, options)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tusersResponse := new(UsersResponse)\n\tresponse, err := s.client.Do(ctx, req, usersResponse)\n\tif err != nil {\n\t\treturn nil, response, err\n\t}\n\n\treturn usersResponse.Response, response, nil\n}", "title": "" }, { "docid": "5d4430f08332279afc3c0877b3ed9629", "score": "0.63714147", "text": "func ListUsers(c echo.Context) error {\n\tqb := domain.UserBuilder{}\n\terr := json.Unmarshal([]byte(c.FormValue(\"dep\")), &qb.Department)\n\tif err != nil {\n\t\tc.Logger().Error(err)\n\t\treturn echo.NewHTTPError(http.StatusBadRequest)\n\t}\n\tquery, err := domain.UserQueryBuilder(qb)\n\tif err != nil {\n\t\tc.Logger().Error(err)\n\t\treturn err\n\t}\n\tfmt.Println(query)\n\tdata, err := backend.Users.ListUsers(c, query)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tresponse := map[string]interface{}{}\n\tresponse[\"values\"] = data\n\tvar res = \"This is response data\"\n\tresponse[\"value\"] = res\n\treturn StatusOk(c, response)\n}", "title": "" }, { "docid": "3f34e67578b8ae5744a4ac678a25a837", "score": "0.63697505", "text": "func List(u *models.AuthUser) (*models.ListQuery, error) {\n\tswitch true {\n\tcase u.AccessLevel <= models.AdminRole: // user is SuperAdmin or Admin\n\t\treturn nil, nil\n\tcase u.AccessLevel == models.AccountAdminRole:\n\t\treturn &models.ListQuery{Query: \"account_id = ?\", ID: u.AccountID}, nil\n\tcase u.AccessLevel == models.TeamAdminRole:\n\t\treturn &models.ListQuery{Query: \"team_id = ?\", ID: u.TeamID}, nil\n\tdefault:\n\t\treturn nil, echo.ErrForbidden\n\t}\n}", "title": "" }, { "docid": "7dcc43792a944311791f7e5e537c9144", "score": "0.6369023", "text": "func (a *App) ListUsersHandler() http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tctx := r.Context()\n\t\tcontextLogger := log.WithContext(ctx)\n\t\tcontextLogger.Info(\"app: ListUsersHandler started\")\n\n\t\tpq, err := paginationQueryFromQueryParams(r.URL.Query())\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"app: pagination query (query params=%s) from query params failed: %v\", r.URL, err)\n\t\t\tclientError(w, http.StatusBadRequest, ErrCodeBadRequest, err.Error())\n\t\t\treturn\n\t\t}\n\n\t\tpaginationResultSet, err := a.Service.GetUsers(ctx, pq)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"app: GetUsers(ctx) error: %+v\", err)\n\t\t\treturn\n\t\t}\n\n\t\ttype links struct {\n\t\t\tPrev string `json:\"prev\"`\n\t\t\tNext string `json:\"next\"`\n\t\t}\n\n\t\ttype result struct {\n\t\t\tObject string `json:\"object\"`\n\t\t\tData interface{} `json:\"data\"`\n\t\t\tLinks links `json:\"links\"`\n\t\t}\n\n\t\tresults := result{\n\t\t\tObject: \"list\",\n\t\t\tData: paginationResultSet.RSet,\n\t\t\tLinks: links{\n\t\t\t\tNext: fmt.Sprintf(\"/users?start_after=%s\", paginationResultSet.RContext.LastID),\n\t\t\t},\n\t\t}\n\n\t\tw.WriteHeader(http.StatusOK) // 200 OK\n\t\tjson.NewEncoder(w).Encode(&results)\n\t}\n}", "title": "" }, { "docid": "fe3e1c5593de67693b44f0a5ffc548a9", "score": "0.6363745", "text": "func AdminUserList(c *gin.Context) {\n\tif !auth.UserCanAccess(c, 2) {\n\t\tForbidden(c)\n\t\treturn\n\t}\n\tuser := db.UserGet(auth.GetLogin(c))\n\tList := db.UserGetAll()\n\tdata := &adminUserListData{HeaderData: &web.HeaderData{Title: \"User List\"}, UserMode: user.Mode, List: List}\n\tc.HTML(http.StatusOK, \"adminUserList.tmpl\", data)\n}", "title": "" }, { "docid": "9b929c933f534ea613128045dc3b8a43", "score": "0.6337712", "text": "func GetAllUsers(w http.ResponseWriter, r *http.Request) {\n\tu := GetUserSession(r)\n\tif u == nil {\n\t\tw.WriteHeader(403)\n\t\tw.Write(apiError(\"you must be logged in to view other users\"))\n\t\treturn\n\t}\n\n\tusers, err := Store.Users().GetAll()\n\tif err != nil {\n\t\tw.WriteHeader(500)\n\t\tw.Write(apiError(err.Error()))\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\n\tfor i := range users {\n\t\tusers[i].Password = \"\"\n\t\tusers[i].Settings = nil\n\t}\n\n\tsendJSON(w, users)\n}", "title": "" }, { "docid": "a7ac73a4cffd0c06a3185504b2081aa0", "score": "0.63320845", "text": "func GetAllUsers(c *gin.Context) {\n\tqueries := c.Request.URL.Query()\n\tfilter := utils.QueryToFilter(queries)\n\t// Convert `admin` field from string to boolean\n\tif filter[mongo.AdminKey] == \"true\" {\n\t\tfilter[mongo.AdminKey] = true\n\t} else if filter[mongo.AdminKey] == \"false\" {\n\t\tfilter[mongo.AdminKey] = false\n\t}\n\tc.JSON(200, gin.H{\n\t\t\"success\": true,\n\t\t\"data\": mongo.FetchUserInfo(filter),\n\t})\n}", "title": "" }, { "docid": "f8ff4a19a4cb87011bde4241e5e56661", "score": "0.6323707", "text": "func (s Store) List(ctx context.Context) ([]Info, error) {\n\tctx, span := trace.StartSpan(ctx, \"internal.user.List\")\n\tdefer span.End()\n\n\tusers := []Info{}\n\tconst q = `SELECT * FROM users`\n\tif err := pgxscan.Select(ctx, s.db, &users, q); err != nil {\n\t\treturn nil, errors.Wrap(err, \"selecting users\")\n\t}\n\n\treturn users, nil\n}", "title": "" }, { "docid": "5488465c7e381959bda3c80b36f8ffdf", "score": "0.63166416", "text": "func (c *Client) ListUsers() ([]*slack.User, error) {\n\treturn c.slack.ListUsers()\n}", "title": "" }, { "docid": "d1ec2a08a830c6e283484e86ab771742", "score": "0.6300376", "text": "func (c *UserController) List(ctx *app.ListUserContext) error {\n\tres := c.storage.List(ctx)\n\tlist := app.UserCollection{}\n\tfor _, y := range res {\n\t\tfmt.Println(y)\n\t\tnm := y.ToApp()\n\t\tnm.Href = app.UserHref(y.ID)\n\t\tlist = append(list, nm)\n\t}\n\treturn ctx.OK(list)\n}", "title": "" }, { "docid": "a7880f4104d108d69732be81e35710c4", "score": "0.62873304", "text": "func ListUsers(user *repo.User) ([]repo.User, error) {\n\treturn user.ListUsers()\n}", "title": "" }, { "docid": "64da63b307b544a30c610bd7a1b1be8f", "score": "0.6280351", "text": "func (u *User) List(t *testing.T) {\n\tctx := context.Background()\n\n\tvar user models.User\n\tusers, err := user.List(ctx, u.Db)\n\tif err != nil {\n\t\tt.Fatalf(\"listing users: %s\", err)\n\t}\n\tif exp, got := 1, len(users); exp != got {\n\t\tt.Fatalf(\"expected users list size %v, got %v\", exp, got)\n\t}\n}", "title": "" }, { "docid": "7f527eb2147a130c049c9bb7d1fd1787", "score": "0.6276036", "text": "func AuthTokenUserList() {\n\n\tfmt.Println(\"main start...\")\n\n\t// init token auth options\n\takskOptions := token.TokenOptions{\n\t\tIdentityEndpoint: \"https://iam.cn-north-1.myhuaweicloud.com/v3\",\n\t\tDomainID: \"replace-your-domainID\",\n\t\tUsername: \"replace-your-username\",\n\t\tPassword: \"replace-your-password\",\n\t\tAllowReauth: true,\n\t}\n\n\t//init provider client\n\tprovider, err := openstack.AuthenticatedClient(akskOptions)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// init IAM client\n\tiamClient, err := openstack.NewIdentityV3(provider, gophercloud.EndpointOpts{})\n\tif err != nil {\n\t\tfmt.Println(\"get IAM v3 client failed\")\n\t\tif ue, ok := err.(*gophercloud.UnifiedError); ok {\n\t\t\tfmt.Println(\"ErrCode:\", ue.ErrorCode())\n\t\t\tfmt.Println(\"Message:\", ue.Message())\n\t\t}\n\t\treturn\n\t}\n\n\t// build http request,list all users belong to this domain\n\tpage, err := users.List(iamClient, users.ListOpts{}).AllPages()\n\tif err != nil {\n\n\t\tif ue, ok := err.(*gophercloud.UnifiedError); ok {\n\t\t\tfmt.Println(\"ErrCode:\", ue.ErrorCode())\n\t\t\tfmt.Println(\"Message:\", ue.Message())\n\t\t}\n\t\treturn\n\t}\n\n\t// extract http response body\n\tuserList, err := users.ExtractUsers(page)\n\n\tif err != nil {\n\t\tif ue, ok := err.(*gophercloud.UnifiedError); ok {\n\t\t\tfmt.Println(\"ErrCode:\", ue.ErrorCode())\n\t\t\tfmt.Println(\"Message:\", ue.Message())\n\t\t}\n\t\treturn\n\t}\n\n\t// print result\n\tfor _, d := range userList {\n\n\t\tfmt.Println(\"user id is :\", d.ID)\n\t\tfmt.Println(\"user name is :\", d.Name)\n\n\t}\n\n\tfmt.Println(\"main end...\")\n}", "title": "" }, { "docid": "a0e77ff11c14834b678d19276a6abf5d", "score": "0.6273338", "text": "func AllUsers(c *gin.Context) {\n\toffset, _ := strconv.Atoi(c.Query(\"offset\"))\n\tvar users models.AllUsers\n\tif err := users.FindAll(offset); err != nil {\n\t\tlogger.Log(logger.Fields{\n\t\t\tLoc: \"/plans - AllUsers()\",\n\t\t\tCode: errors.InternalServerError.Code,\n\t\t\tErr: err.Error(),\n\t\t})\n\t\tc.AbortWithStatusJSON(errors.InternalServerError.Status, errors.InternalServerError)\n\t}\n\n\t// dont send passwords\n\tfor i, u := range users {\n\t\tu.Password = \"\"\n\t\tusers[i] = u\n\t}\n\n\tcount, err := users.Count()\n\tif err != nil {\n\t\tlogger.Log(logger.Fields{\n\t\t\tLoc: \"/servers - Connections()\",\n\t\t\tCode: errors.InternalServerError.Code,\n\t\t\tErr: err.Error(),\n\t\t})\n\t\tc.AbortWithStatusJSON(errors.InternalServerError.Status, errors.InternalServerError)\n\t}\n\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"status\": 200,\n\t\t\"data\": gin.H{\n\t\t\t\"count\": count,\n\t\t\t\"users\": users,\n\t\t},\n\t})\n}", "title": "" }, { "docid": "38dc4eab8608c6f9a902c53421b522f1", "score": "0.6257832", "text": "func GetUserList(c *gin.Context) {\n\tuserList, userError := userService.AllUsers()\n\tif userError != nil {\n\t\tc.JSON(userError.ErrorCode, gin.H{\"error\": userError.Error})\n\t\treturn\n\t}\n\tc.JSON(http.StatusOK, gin.H{\"message\": userList})\n}", "title": "" }, { "docid": "7cf0861a98c9177521c2fb245972fbd1", "score": "0.6233311", "text": "func (s *Service) ConfigurationsListUsers(connectID string) *ConfigurationsListUsersOp {\n\treturn &ConfigurationsListUsersOp{\n\t\tCredential: s.credential,\n\t\tMethod: \"GET\",\n\t\tPath: strings.Join([]string{\"connect\", connectID, \"users\"}, \"/\"),\n\t\tAccept: \"application/json\",\n\t\tQueryOpts: make(url.Values),\n\t\tVersion: esign.APIv21,\n\t}\n}", "title": "" }, { "docid": "6dc9e80043522760582074ddc3773e17", "score": "0.6233178", "text": "func (sl *Slack) UsersList() ([]*User, error) {\r\n\tuv := sl.urlValues()\r\n\tbody, err := sl.GetRequest(usersListApiEndpoint, uv)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\tres := new(UsersListAPIResponse)\r\n\terr = json.Unmarshal(body, res)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\tif !res.Ok {\r\n\t\treturn nil, errors.New(res.Error)\r\n\t}\r\n\treturn res.Members()\r\n}", "title": "" }, { "docid": "e985e30dfaf95751b55d63ba8616f904", "score": "0.62327284", "text": "func (r *RPC) Users(c context.Context, a *model.ArgUsers, res *model.UserList) (err error) {\n\tvar us *model.UserList\n\tif us, err = r.s.UserList(c, a.Type, a.Oid, a.Pn, a.Ps); err == nil {\n\t\t*res = *us\n\t}\n\treturn\n}", "title": "" }, { "docid": "b0dd3efb18d594955de44e6d02e494c1", "score": "0.623054", "text": "func (us *UserService) ListUsers(ctx context.Context) (users []*model.User, err error) {\n\tconn, err := us.db.GetConnection(ctx, false)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tuserRep := us.db.NewUserRepository(conn)\n\tusers, err = userRep.SelectUsers(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn users, nil\n}", "title": "" }, { "docid": "46a6cc89c35cae3d896ea542516f87d2", "score": "0.6226095", "text": "func listUserAccounts(cmd *cobra.Command, args []string) {\n\tresp, err := api.Get(\"/accounts\")\n\tif err != nil {\n\t\tExitWithError(ExitError, fmt.Errorf(\"Could not fetch user's accounts\\n%s\", err))\n\t}\n\tExitWithSuccess(string(resp))\n}", "title": "" }, { "docid": "dee15686fa4d3e832b1bb0188179f635", "score": "0.6222707", "text": "func (m *manager) List(ctx context.Context, query *q.Query) (models.Users, error) {\n\treturn m.dao.List(ctx, query)\n}", "title": "" }, { "docid": "494ed5c7c31919a5ea8d146d5180ee1f", "score": "0.6220875", "text": "func (uc *UserController) Index(c *gin.Context) {\r\n\tuc.Logger.LogAccess(\"%s %s %s\\n\", c.Request.RemoteAddr, c.Request.Method, c.Request.URL)\r\n\r\n\tusers, err := uc.UserIteractor.Index()\r\n\tif err != nil {\r\n\t\tuc.Logger.LogError(\"%s\", err)\r\n\t\tc.JSON(http.StatusBadRequest, gin.H{\r\n\t\t\t\"message\": err.Error(),\r\n\t\t})\r\n\t}\r\n\r\n\tc.JSON(http.StatusOK, gin.H{\r\n\t\t\"lists\": users,\r\n\t})\r\n}", "title": "" }, { "docid": "2106789e0b1d52cf955841854c3dce5b", "score": "0.62145597", "text": "func (s *GithubSource) listUser(ctx context.Context, user string, results chan *githubResult) (fail error) {\n\ts.paginate(ctx, results, func(page int) (repos []*github.Repository, hasNext bool, cost int, err error) {\n\t\tdefer func() {\n\t\t\tif err != nil && page == 1 {\n\t\t\t\tfail, err = err, nil\n\t\t\t}\n\n\t\t\tremaining, reset, retry, _ := s.v3Client.RateLimitMonitor().Get()\n\t\t\tlog15.Debug(\n\t\t\t\t\"github sync: ListUserRepositories\",\n\t\t\t\t\"repos\", len(repos),\n\t\t\t\t\"rateLimitCost\", cost,\n\t\t\t\t\"rateLimitRemaining\", remaining,\n\t\t\t\t\"rateLimitReset\", reset,\n\t\t\t\t\"retryAfter\", retry,\n\t\t\t)\n\t\t}()\n\t\treturn s.v3Client.ListUserRepositories(ctx, user, page)\n\t})\n\treturn\n}", "title": "" }, { "docid": "ec026d76d501193dfb346845ce2a002a", "score": "0.621334", "text": "func (mdb *MockDB) ListUsers() ([]User, error) {\n\tvar users []User\n\tusers = append(users, User{\n\t\tID: 1,\n\t\tUsername: \"user1\",\n\t\tName: \"Rigoberto Picaporte\",\n\t\tEmail: \"rigoberto.picaporte@ubuntu.com\",\n\t\tRole: Standard,\n\t\tAccounts: []Account{\n\t\t\t{\n\t\t\t\tID: 1,\n\t\t\t\tAuthorityID: \"authority1\",\n\t\t\t\tAssertion: \"assertioncontent1\",\n\t\t\t},\n\t\t}})\n\tusers = append(users, User{\n\t\tID: 2,\n\t\tUsername: \"user2\",\n\t\tName: \"Nancy Reagan\",\n\t\tEmail: \"nancy.reagan@usa.gov\",\n\t\tRole: Standard,\n\t\tAccounts: []Account{\n\t\t\t{\n\t\t\t\tID: 2,\n\t\t\t\tAuthorityID: \"authority2\",\n\t\t\t\tAssertion: \"assertioncontent2\",\n\t\t\t},\n\t\t}})\n\tusers = append(users, User{\n\t\tID: 3,\n\t\tUsername: \"sv\",\n\t\tName: \"Steven Vault\",\n\t\tEmail: \"sv@example.com\",\n\t\tRole: Admin,\n\t\tAccounts: []Account{\n\t\t\t{\n\t\t\t\tID: 3,\n\t\t\t\tAuthorityID: \"authority3\",\n\t\t\t\tAssertion: \"assertioncontent3\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tID: 4,\n\t\t\t\tAuthorityID: \"authority4\",\n\t\t\t\tAssertion: \"assertioncontent4\",\n\t\t\t},\n\t\t}})\n\tusers = append(users, User{\n\t\tID: 4,\n\t\tUsername: \"a\",\n\t\tName: \"A\",\n\t\tEmail: \"a@example.com\",\n\t\tRole: Standard})\n\tusers = append(users, User{\n\t\tID: 5,\n\t\tUsername: \"root\",\n\t\tName: \"Root User\",\n\t\tEmail: \"the_root_user@thisdb.com\",\n\t\tRole: Superuser})\n\tusers = append(users, User{\n\t\tID: 6,\n\t\tUsername: \"sync\",\n\t\tName: \"Sync Vault\",\n\t\tEmail: \"sync@example.com\",\n\t\tRole: SyncUser,\n\t\tAccounts: []Account{\n\t\t\t{\n\t\t\t\tID: 3,\n\t\t\t\tAuthorityID: \"authority3\",\n\t\t\t\tAssertion: \"assertioncontent3\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tID: 4,\n\t\t\t\tAuthorityID: \"authority4\",\n\t\t\t\tAssertion: \"assertioncontent4\",\n\t\t\t},\n\t\t}})\n\n\treturn users, nil\n}", "title": "" }, { "docid": "3eabfef18fbd6d48aec692b6d4174ba9", "score": "0.62041515", "text": "func AdminUserList(w http.ResponseWriter, r *http.Request, u *User) error {\n\tusers, err := database.ListUsers()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdata := struct {\n\t\tUser *User\n\t\tUsers []*User\n\t}{u, users}\n\n\treturn RenderTemplate(w, \"admin_users.html\", &data)\n}", "title": "" }, { "docid": "c9d7cf32424a99e51863bc054d3082a5", "score": "0.6193096", "text": "func (c *Client) ListUser(path string) (*http.Response, error) {\n\tvar body io.Reader\n\tu := url.URL{Host: c.Host, Scheme: c.Scheme, Path: path}\n\treq, err := http.NewRequest(\"GET\", u.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\theader := req.Header\n\theader.Set(\"Content-Type\", \"application/json\")\n\treturn c.Client.Do(req)\n}", "title": "" }, { "docid": "37959dd1177c1d6f07ac5367ecdb0b38", "score": "0.618946", "text": "func listHandler(w http.ResponseWriter, req *http.Request) {\n\tvar r = responder.Response(w, req)\n\tvar f = getForm(r)\n\tr.Vars.Title = f.title()\n\n\tvar err error\n\tvar active, inactive []*models.User\n\tactive, err = models.ActiveUsers()\n\tif err == nil {\n\t\tinactive, err = models.InactiveUsers()\n\t}\n\tif err != nil {\n\t\tlogger.Errorf(\"Unable to pull users from database: %s\", err)\n\t\tr.Error(http.StatusInternalServerError, \"Error trying to pull user list - try again or contact support\")\n\t\treturn\n\t}\n\tsort.Slice(active, func(i, j int) bool {\n\t\treturn active[i].Login < active[j].Login\n\t})\n\tsort.Slice(inactive, func(i, j int) bool {\n\t\treturn inactive[i].Login < inactive[j].Login\n\t})\n\tr.Vars.Data[\"ActiveUsers\"] = active\n\tr.Vars.Data[\"InactiveUsers\"] = inactive\n\n\tr.Vars.Data[\"AuditLogs\"], r.Vars.Data[\"AuditLogsCount\"], err = f.logs(100)\n\tif err != nil {\n\t\tr.Error(http.StatusInternalServerError, \"Error trying to pull audit logs - try again or contact support\")\n\t\treturn\n\t}\n\n\tr.Render(listTmpl)\n}", "title": "" }, { "docid": "8865a53d3f2de24d3f632d0dd533d577", "score": "0.6188579", "text": "func ListUsersPath() string {\n\treturn \"/users\"\n}", "title": "" }, { "docid": "ea06c2c9f9fe538aaee21e61b7d3dc21", "score": "0.61877", "text": "func (UserController) ListUserAll(c echo.Context) error {\n\tfmt.Println(\"print all user\")\n\tuserService := &services.UserService{}\n\tusers, err := userService.FindAll()\n\tif err != nil {\n\t\treturn c.JSON(http.StatusOK, \"I don't have value from database\")\n\t}\n\treturn c.JSON(http.StatusOK, users)\n}", "title": "" }, { "docid": "fb4a4ba66feba77ff45ef579d481d2a1", "score": "0.61815614", "text": "func (u User) Index(w http.ResponseWriter, r *http.Request) error {\n\tusers, e := u.users.All(r.Context())\n\n\tif e != nil {\n\t\treturn e\n\t}\n\n\treturn uf.SendJSON(w, users)\n}", "title": "" }, { "docid": "5e6e847629cd2684fdd1d494a622857a", "score": "0.61751896", "text": "func ExampleListUsers_RawRequest() {\n\t// build the url\n\turl := \"https://identity.us-phoenix-1.oraclecloud.com/20160918/users/?compartmentId=\" + *helpers.RootCompartmentID()\n\n\t// create request\n\trequest, err := http.NewRequest(\"GET\", url, nil)\n\thelpers.FatalIfError(err)\n\n\t// Set the Date header\n\trequest.Header.Set(\"Date\", time.Now().UTC().Format(http.TimeFormat))\n\n\t// And a provider of cryptographic keys\n\tprovider := common.DefaultConfigProvider()\n\n\t// Build the signer\n\tsigner := common.DefaultRequestSigner(provider)\n\n\t// Sign the request\n\tsigner.Sign(request)\n\n\tclient := http.Client{}\n\n\tfmt.Println(\"send request\")\n\n\t// Execute the request\n\tresp, err := client.Do(request)\n\thelpers.FatalIfError(err)\n\n\tdefer resp.Body.Close()\n\n\tlog.Println(\"response Status:\", resp.Status)\n\tlog.Println(\"response Headers:\", resp.Header)\n\n\tbody, _ := ioutil.ReadAll(resp.Body)\n\tlog.Println(\"response Body:\", string(body))\n\n\tfmt.Println(\"receive response\")\n\n\t// Output:\n\t// send request\n\t// receive response\n}", "title": "" }, { "docid": "87673a10e66e8cdb3817bbac670088ae", "score": "0.6168432", "text": "func GetAllUsers(c *gin.Context) {\n\n\tvar err error\n\tvar pagination serializers.Pagination\n\terr = c.BindQuery(&pagination)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(http.StatusBadRequest, gin.H{\n\t\t\t\"error\": constants.Errors().InvalidPagination,\n\t\t})\n\t\treturn\n\t}\n\n\tvar userFilter filter.User\n\terr = c.BindQuery(&userFilter)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(http.StatusBadRequest, gin.H{\n\t\t\t\"error\": constants.Errors().InvalidFilter,\n\t\t})\n\t\treturn\n\t}\n\tfilter.ConvertUserStringToLower(&userFilter)\n\n\trecordsCount, err := users.GetAllUsersCount(&userFilter)\n\tif err != nil {\n\t\tc.JSON(http.StatusInternalServerError, gin.H{\"error\": constants.Errors().InternalError})\n\t\tlog.Println(\"find all users query error\")\n\t\treturn\n\t}\n\tvar infoArray []serializers.UserInfo\n\tuserListResponse := serializers.UserListResponse{\n\t\tRecordsAffected: recordsCount,\n\t\tUserInfo: infoArray,\n\t}\n\tif recordsCount == 0 {\n\t\tc.JSON(http.StatusOK, userListResponse)\n\t\treturn\n\t}\n\n\tusersArray, err := users.GetAllUsers(&pagination, &userFilter)\n\tif err != nil {\n\t\tc.JSON(http.StatusInternalServerError, gin.H{\"error\": constants.Errors().InternalError})\n\t\tlog.Println(\"find all users query error\", err.Error())\n\t\treturn\n\t}\n\n\tvar info *serializers.UserInfo\n\n\tfor _, user := range usersArray {\n\t\tinfo = serializers.UserModelToUserInfo(&user)\n\t\tinfoArray = append(infoArray, *info)\n\t}\n\n\tuserListResponse = serializers.UserListResponse{\n\t\tRecordsAffected: recordsCount,\n\t\tUserInfo: infoArray,\n\t}\n\tc.JSON(http.StatusOK, userListResponse)\n}", "title": "" }, { "docid": "08c577562ea083a32c5e5e663c9f3a79", "score": "0.61595446", "text": "func GetUsersFullList(w http.ResponseWriter, r *http.Request) {\r\n\tlog.Println(\"===>userHandlers.GetUsersFullList()\")\r\n\tw.Header().Add(\"Content-Type\", \"application/json\")\r\n\tlog.Printf(\" w.Header=%v\\n\", w.Header())\r\n\tlog.Printf(\" hostName=%v\\n\", hostName)\r\n\r\n\tmyDB := db.Connect()\r\n\tmyUser := &User{}\r\n\tusers, sqlErr := myUser.GetUsersFullList(myDB)\r\n\tlog.Printf(\"%d users found inside service.GetUsers()\\n\", len(users))\r\n\t// for i := 0; i < len(users); i++ {\r\n\t// \tlog.Printf(\" %v\\n\", users[i])\r\n\t// }\r\n\r\n\tif sqlErr == nil {\r\n\t\tlog.Printf(\"Successful select of all users in service.GetUsers()\")\r\n\t\tjson.NewEncoder(w).Encode(users)\r\n\t\treturn\r\n\t}\r\n\tlog.Printf(\"Error with database select in userHandlers.GetUser()\\n\")\r\n\tlog.Printf(\"Reason:%v\\n\", sqlErr)\r\n}", "title": "" }, { "docid": "fe2595b8df180a7742b8002090c89949", "score": "0.6158766", "text": "func (s *Server) ListUsers(ctx context.Context, req *usersservicepb.ListUsersRequest) (res *usersservicepb.ListUsersResponse, err error) {\n\torder, err := orderProtoToInternal(req.GetSortOrder())\n\tif err != nil {\n\t\treturn nil, status.Error(codes.InvalidArgument, err.Error())\n\t}\n\n\tusers, err := s.Repo.ListUsers(\n\t\tctx,\n\t\treq.GetNames(),\n\t\torder,\n\t)\n\tif err != nil {\n\t\treturn nil, status.Error(codes.Internal, err.Error())\n\t}\n\n\tpbUsers := []*userspb.User{}\n\tfor _, user := range users {\n\t\tct, err := ptypes.TimestampProto(user.CreateTime)\n\t\tif err != nil {\n\t\t\treturn nil, status.Error(codes.Internal, \"failed to convert create time to proto type\")\n\t\t}\n\n\t\tpbUser := &userspb.User{\n\t\t\tName: user.Name,\n\t\t\tId: user.ID,\n\t\t\tCreateTime: ct,\n\t\t}\n\t\tpbUsers = append(pbUsers, pbUser)\n\t}\n\n\treturn &usersservicepb.ListUsersResponse{\n\t\tUsers: pbUsers,\n\t}, nil\n}", "title": "" }, { "docid": "198dc6b276f0cc3e25cd9b3604f9c7ad", "score": "0.6156669", "text": "func GetAllUsers(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tvars := mux.Vars(r)\n\tusername := vars[\"username\"]\n\tpwd := vars[\"pwd\"]\n\tif username != os.Getenv(\"ADMIN_USR\") || pwd != os.Getenv(\"ADMIN_PWD\") {\n\t\thttp.Error(w, \"ADMIN ACCESS ONLY!!\", http.StatusUnauthorized)\n\t\treturn\n\t}\n\n\tusers, err := globalDB.GetAll()\n\tif err != nil {\n\t\thttp.Error(w, \"Could not get users\", http.StatusNotFound)\n\t\treturn\n\t}\n\n\tif err = json.NewEncoder(w).Encode(users); err != nil {\n\t\thttp.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "b8bcb0d325030af75e139602fd554e0e", "score": "0.6153872", "text": "func (r *PsqlRepository) ListUsers(ctx context.Context, req *pb.ListUsersRequest) (*pb.ListUsersResponse, error) {\n\tvar sqlStr string = \"SELECT id, email FROM (select *, rank() over(order by ID) as my_rank from gousers) as x where my_rank>=$1 and my_rank <= $2\"\n\tselectedPage, err := strconv.Atoi(req.GetPageToken())\n\n\tlistUsers := pb.ListUsersResponse{}\n\n\tif err != nil {\n\t\treturn nil, errors.New(\"Invalid page token\")\n\t}\n\n\tif selectedPage <= 0 {\n\t\treturn nil, errors.New(\"Invalid page token\")\n\t}\n\n\t//Check selected page if it is in bound\n\tvar maxPageToken int32 = 0\n\terr = r.DB.QueryRowContext(ctx, \"select count(*) from gousers\").Scan(&maxPageToken)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tpageTokenLimit := 1 + (maxPageToken-1)/req.GetPageSize()\n\n\t//If pageToken will be last nextPageToken will be equal to previous pageToken\n\tif int32(selectedPage) > pageTokenLimit {\n\t\treturn nil, errors.New(\"Invalid page token\")\n\t} else if int32(selectedPage) == pageTokenLimit {\n\t\tlistUsers.NextPageToken = fmt.Sprintf(\"%d\", selectedPage)\n\t}\n\n\t//First page = pageToken * pageSize - pageSize\n\t//Last page = pageToken * pageSize\n\trows, err := r.DB.QueryContext(ctx, sqlStr, (int32(selectedPage)*req.GetPageSize())-req.GetPageSize(), int32(selectedPage)*req.GetPageSize())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\n\tfor rows.Next() {\n\n\t\tvar user pb.User\n\n\t\tif err := rows.Scan(&user.Id, &user.Email); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tlistUsers.Users = append(listUsers.Users, &user)\n\t}\n\n\treturn &listUsers, nil\n}", "title": "" }, { "docid": "606b95607f2d6c4b558a258a4d2c1e97", "score": "0.61518216", "text": "func (t *TeamService) ListUsers(teamID string, page, count int) ([]*model.User, error) {\n\tusers, appErr := t.api.GetUsersInTeam(teamID, page, count)\n\n\treturn users, normalizeAppErr(appErr)\n}", "title": "" }, { "docid": "b3daf1b3b27b177275699dbce863f090", "score": "0.6147569", "text": "func getAllUsers(w http.ResponseWriter, r *http.Request) {\n\tvar user Users\n\tvar arr_user []Users\n\tvar response ResponseUser\n\n\tdb := connect()\n\tdefer db.Close()\n\n\trows, err := db.Query(\"Select iduser, nama, jabatan, password, aktif From user order by iduser asc\")\n\tif err != nil {\n\t\tlog.Print(err)\n\t}\n\tfor rows.Next() {\n\t\tif err := rows.Scan(\n\t\t\t&user.IdUser,\n\t\t\t&user.Nama, &user.Jabatan,\n\t\t\t&user.Password,\n\t\t\t&user.Aktif,\n\t\t); err != nil {\n\t\t\tlog.Fatal(err.Error())\n\t\t} else {\n\t\t\tarr_user = append(arr_user, user)\n\t\t}\n\t}\n\n\tresponse.Status = 1\n\tresponse.Message = \"Success\"\n\tresponse.Result = arr_user\n\tlog.Print(\"Request Data User\")\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tjson.NewEncoder(w).Encode(response)\n}", "title": "" } ]
95bf97cee5d6d6a9fe1e757d878d50f1
RESTGetOrderbook returns orderbook info for a given currency, exchange and asset type
[ { "docid": "6d0551757e05c9f7e39e3190d6a280d5", "score": "0.7888484", "text": "func RESTGetOrderbook(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tcurrency := vars[\"currency\"]\n\texchangeName := vars[\"exchangeName\"]\n\tassetType := vars[\"assetType\"]\n\n\tif assetType == \"\" {\n\t\tassetType = orderbook.Spot\n\t}\n\n\tresponse, err := GetSpecificOrderbook(currency, exchangeName, assetType)\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to fetch orderbook for %s currency: %s\\n\", exchangeName,\n\t\t\tcurrency)\n\t\treturn\n\t}\n\n\terr = RESTfulJSONResponse(w, response)\n\tif err != nil {\n\t\tRESTfulError(r.Method, err)\n\t}\n}", "title": "" } ]
[ { "docid": "c056b9cd42470ac9587148cd60073692", "score": "0.7088417", "text": "func GetOrderbook(currency string) *Orderbook {\n\torderbook := &Orderbook{}\n\turl := coinoneURL + \"/orderbook/?currency=\" + currency\n\t// Im not sure i agree with gorequest on returning an array of errors as it gets hard to deal with\n\t// would like to move to a different library ...\n\tclient.Get(url).EndStruct(orderbook)\n\treturn orderbook\n}", "title": "" }, { "docid": "de4af82b2064f4485d1088799559f578", "score": "0.7009184", "text": "func GetSpecificOrderbook(currency, exchangeName, assetType string) (orderbook.Base, error) {\n\tvar specificOrderbook orderbook.Base\n\tvar err error\n\tfor i := 0; i < len(bot.exchanges); i++ {\n\t\tif bot.exchanges[i] != nil {\n\t\t\tif bot.exchanges[i].IsEnabled() && bot.exchanges[i].GetName() == exchangeName {\n\t\t\t\tspecificOrderbook, err = bot.exchanges[i].GetOrderbookEx(\n\t\t\t\t\tpair.NewCurrencyPairFromString(currency),\n\t\t\t\t\tassetType,\n\t\t\t\t)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\treturn specificOrderbook, err\n}", "title": "" }, { "docid": "2ffc9183e7b71c9bad13b0c5a2ec9051", "score": "0.6981262", "text": "func (k *Kraken) GetOrderbookEx(p pair.CurrencyPair, assetType string) (orderbook.Base, error) {\n\tob, err := orderbook.GetOrderbook(k.GetName(), p, assetType)\n\tif err != nil {\n\t\treturn k.UpdateOrderbook(p, assetType)\n\t}\n\treturn ob, nil\n}", "title": "" }, { "docid": "26af240f11018e10c17771e2e59121be", "score": "0.69198966", "text": "func getOrderbook(symbol string) (*Orderbook, error) {\n\tvar (\n\t\tparams = url.Values{}\n\t\terr error\n\t)\n\tif symbol, err = normalize(symbol); err != nil {\n\t\treturn nil, err\n\t}\n\tparams.Add(\"symbol\", symbol)\n\tresp, err := requestGet(getOrderBookEndpoint, params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif resp.Code != http.StatusOK {\n\t\treturn nil, apiError(getOrderBookEndpoint, resp.Message)\n\t}\n\tvar result Orderbook\n\treturn &result, json.Unmarshal(resp.Data, &result)\n\n}", "title": "" }, { "docid": "c8d8db08205559fac9ff18e588699f67", "score": "0.6823462", "text": "func (b *Bitmex) GetOrderbookEx(currency pair.CurrencyPair, assetType string) (orderbook.Base, error) {\n\tob, err := orderbook.GetOrderbook(b.GetName(), currency, assetType)\n\tif err != nil {\n\t\treturn b.UpdateOrderbook(currency, assetType)\n\t}\n\treturn ob, nil\n}", "title": "" }, { "docid": "0b6481ace6617a11cf8b13585a0bcf82", "score": "0.6684356", "text": "func (c *Client) GetBook(symbol string) (Orders, error) {\n var orders Orders\n requestURL := fmt.Sprintf(\"/v1/book/%s\", symbol)\n\n _, err := c.Request(\"GET\", requestURL, nil, &orders)\n return orders, err\n}", "title": "" }, { "docid": "dcd94ae96bdbc5411b07229fe2de55d6", "score": "0.6646048", "text": "func ExchangeOrderbook(args ...objects.Object) (objects.Object, error) {\n\tif len(args) != 4 {\n\t\treturn nil, objects.ErrWrongNumArguments\n\t}\n\n\texchangeName, ok := objects.ToString(args[0])\n\tif !ok {\n\t\treturn nil, fmt.Errorf(ErrParameterConvertFailed, exchangeName)\n\t}\n\tcurrencyPair, ok := objects.ToString(args[1])\n\tif !ok {\n\t\treturn nil, fmt.Errorf(ErrParameterConvertFailed, currencyPair)\n\t}\n\tdelimiter, ok := objects.ToString(args[2])\n\tif !ok {\n\t\treturn nil, fmt.Errorf(ErrParameterConvertFailed, delimiter)\n\t}\n\tassetTypeParam, ok := objects.ToString(args[3])\n\tif !ok {\n\t\treturn nil, fmt.Errorf(ErrParameterConvertFailed, assetTypeParam)\n\t}\n\n\tpair, err := currency.NewPairDelimiter(currencyPair, delimiter)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tassetType, err := asset.New(assetTypeParam)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tob, err := wrappers.GetWrapper().\n\t\tOrderbook(context.TODO(), exchangeName, pair, assetType)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar asks, bids objects.Array\n\n\tfor x := range ob.Asks {\n\t\ttemp := make(map[string]objects.Object, 2)\n\t\ttemp[\"amount\"] = &objects.Float{Value: ob.Asks[x].Amount}\n\t\ttemp[\"price\"] = &objects.Float{Value: ob.Asks[x].Price}\n\t\tasks.Value = append(asks.Value, &objects.Map{Value: temp})\n\t}\n\n\tfor x := range ob.Bids {\n\t\ttemp := make(map[string]objects.Object, 2)\n\t\ttemp[\"amount\"] = &objects.Float{Value: ob.Bids[x].Amount}\n\t\ttemp[\"price\"] = &objects.Float{Value: ob.Bids[x].Price}\n\t\tbids.Value = append(bids.Value, &objects.Map{Value: temp})\n\t}\n\n\tdata := make(map[string]objects.Object, 5)\n\tdata[\"exchange\"] = &objects.String{Value: ob.Exchange}\n\tdata[\"pair\"] = &objects.String{Value: ob.Pair.String()}\n\tdata[\"asks\"] = &asks\n\tdata[\"bids\"] = &bids\n\tdata[\"asset\"] = &objects.String{Value: ob.Asset.String()}\n\n\treturn &objects.Map{\n\t\tValue: data,\n\t}, nil\n}", "title": "" }, { "docid": "db358227794697a95cbb06003d27e065", "score": "0.65411556", "text": "func (g *Gateio) GetOrderbook(ctx context.Context, symbol string) (*Orderbook, error) {\n\turlPath := fmt.Sprintf(\"/%s/%s/%s\", gateioAPIVersion, gateioOrderbook, symbol)\n\tvar resp OrderbookResponse\n\terr := g.SendHTTPRequest(ctx, exchange.RestSpotSupplementary, urlPath, &resp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tswitch {\n\tcase resp.Result != \"true\":\n\t\treturn nil, errors.New(\"result was not true\")\n\tcase len(resp.Asks) == 0:\n\t\treturn nil, errors.New(\"asks are empty\")\n\tcase len(resp.Bids) == 0:\n\t\treturn nil, errors.New(\"bids are empty\")\n\t}\n\n\t// Asks are in reverse order\n\tob := Orderbook{\n\t\tResult: resp.Result,\n\t\tElapsed: resp.Elapsed,\n\t\tBids: make([]OrderbookItem, len(resp.Bids)),\n\t\tAsks: make([]OrderbookItem, 0, len(resp.Asks)),\n\t}\n\n\tfor x := len(resp.Asks) - 1; x != 0; x-- {\n\t\tprice, err := strconv.ParseFloat(resp.Asks[x][0], 64)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tamount, err := strconv.ParseFloat(resp.Asks[x][1], 64)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tob.Asks = append(ob.Asks, OrderbookItem{Price: price, Amount: amount})\n\t}\n\n\tfor x := range resp.Bids {\n\t\tprice, err := strconv.ParseFloat(resp.Bids[x][0], 64)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tamount, err := strconv.ParseFloat(resp.Bids[x][1], 64)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tob.Bids[x] = OrderbookItem{Price: price, Amount: amount}\n\t}\n\treturn &ob, nil\n}", "title": "" }, { "docid": "5231f2cfceb8cc3d446fa83c7d8941ee", "score": "0.6533135", "text": "func (o *Orderbooks) GetOrderbook(_ string, p pair.CurrencyPair, orderbookType string) (Base, error) {\n\to.m.Lock()\n\tdefer o.m.Unlock()\n\n\tfp := o.formatCurrencyPair(p)\n\n\tif !o.FirstCurrencyExists(fp.GetFirstCurrency()) {\n\t\treturn Base{}, errors.New(ErrPrimaryCurrencyNotFound)\n\t}\n\n\tif !o.SecondCurrencyExists(fp) {\n\t\terr := fmt.Errorf(\"%s-%s-%s\", ErrSecondaryCurrencyNotFound, fp.GetFirstCurrency(), fp.GetSecondCurrency())\n\t\treturn Base{}, err\n\t}\n\n\treturn o.orderbooks[fp.GetFirstCurrency()][fp.GetSecondCurrency()][orderbookType], nil\n}", "title": "" }, { "docid": "f0bdf8cff6abede46d0afef31860be21", "score": "0.65236926", "text": "func (h *HUOBI) GetOrderbookEx(p pair.CurrencyPair, assetType string) (orderbook.Base, error) {\n\tob, err := orderbook.GetOrderbook(h.GetName(), p, assetType)\n\tif err != nil {\n\t\treturn h.UpdateOrderbook(p, assetType)\n\t}\n\treturn ob, nil\n}", "title": "" }, { "docid": "cf267b70df1dc01e7e955112a9aa26cf", "score": "0.6468908", "text": "func (i *Instance) Orderbook() (v Orderbook) {\n\ti.RLock()\n\turl := fmt.Sprintf(\"%svenues/%s/stocks/%s\", baseURL, i.venue, i.symbol)\n\ti.RUnlock()\n\n\ti.doHTTP(\"GET\", url, nil, &v)\n\treturn\n}", "title": "" }, { "docid": "45cdbea7840f7b8266b8fca5a8f4c8e3", "score": "0.6419518", "text": "func (b *Bitflyer) GetOrderBook(ctx context.Context, symbol string) (Orderbook, error) {\n\tvar resp Orderbook\n\tv := url.Values{}\n\tv.Set(\"product_code\", symbol)\n\n\treturn resp, b.SendHTTPRequest(ctx, exchange.RestSpot, pubGetBoard+\"?\"+v.Encode(), &resp)\n}", "title": "" }, { "docid": "41ec58dc4903ea25049bc635bc10e86c", "score": "0.6414103", "text": "func (m *MarketClient) GetOrderBook(symbol string, limit int32) (interface{}, error) {\n\tvar err error\n\tif symbol == \"\" {\n\t\terr = errors.New(SymbolEmpty)\n\t\treturn nil, err\n\t}\n\tparams := fmt.Sprintf(\"symbol=%s\", symbol)\n\tif limit > 1000 {\n\t\tlimit = 1000\n\t}\n\tif limit > 0 {\n\t\tparams += fmt.Sprintf(\"&limit=%d\", limit)\n\t}\n\treq, err := m.Builder.Build(http.MethodGet, \"/fapi/v1/depth\", params)\n\tif err != nil {\n\t\tlogger.Error(\"Failed to build url: %s\", err.Error())\n\t}\n\tres, err := binance.HttpRequest(req)\n\tvar parser map[string]interface{}\n\terr = json.Unmarshal(res, &parser)\n\tif _, ok := parser[\"code\"]; ok {\n\t\tresult := model.APIErrorResponse{}\n\t\terr = json.Unmarshal(res, &result)\n\t\treturn result, err\n\t}\n\tresult := OrderBookResponse{}\n\terr = json.Unmarshal(res, &result)\n\treturn result, err\n}", "title": "" }, { "docid": "ab5f971ba53857a9e9117b1c4061c700", "score": "0.63520586", "text": "func GetOrderBook(conf *Config, symbol Symbol) (*OrderBook, error) {\n\tif err := validateSymbol(symbol); err != nil {\n\t\treturn nil, err\n\t}\n\tbody, err := doReq(conf, \"GET\", fmt.Sprintf(\"/markets/%s/order_book\", symbol), false,nil)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"getting ticker from itBit\")\n\t}\n\tdefer body.Close()\n\tdec := json.NewDecoder(body)\n\tresp := &OrderBook{}\n\tif err := dec.Decode(resp); err!= nil {\n\t\treturn nil, errors.Wrap(err, \"decoding JSON\")\n\t}\n\treturn resp, nil\n}", "title": "" }, { "docid": "087eb7d67d2801d34b7a37f7b5d78a00", "score": "0.62387335", "text": "func (e *Client) OrderBook(params *OrderBookRequest) (\n\t*OrderBookResponse, error) {\n\n\ttype Response struct {\n\t\tbaseResponse\n\t\tResult *OrderBookResponse\n\t}\n\n\tresponse := &Response{}\n\terr := e.makeRPCCall(\"order.book\", params, response)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// https://golang.org/doc/faq#nil_error\n\tif response.Error != nil {\n\t\treturn nil, response.Error\n\t}\n\n\treturn response.Result, nil\n}", "title": "" }, { "docid": "1f3a44b10751e9cb0606025c9c8db90b", "score": "0.623677", "text": "func (a *API) OrderBook(market string) (ob *OrderBook, err error) {\n\tif market == \"\" {\n\t\terr = fmt.Errorf(\"market is required\")\n\t\treturn\n\t}\n\n\tpayload := fmt.Sprintf(`{\"market\":\"%s\"}`, market)\n\n\tbody, err := a.Post(\"returnOrderBook\", payload)\n\tif err != nil {\n\t\treturn\n\t}\n\n\terr = json.Unmarshal(body, &ob)\n\treturn\n}", "title": "" }, { "docid": "f7342bfac9b9b96148a5b293aa603bf7", "score": "0.61883414", "text": "func getOrderbook(pair string) (aOrderbookResponse OrderbookResponse, err error) {\n\n\thttpCLI := &http.Client{\n\t\tTimeout: 1500 * time.Millisecond,\n\t}\n\n\turl := fmt.Sprintf(\"https://api.kraken.com/0/public/Depth?pair=%s\", pair)\n\n\t// try to get kraken orderbook\n\tresp, err := httpCLI.Get(url)\n\tif err != nil {\n\t\treturn OrderbookResponse{}, err\n\t}\n\n\t// make sure the body of the response is closed after func returns\n\tdefer resp.Body.Close()\n\n\t// try to read the response body\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn OrderbookResponse{}, err\n\t}\n\n\t// Unmarshal the json\n\torderbookResponse := OrderbookResponse{}\n\terr = json.Unmarshal(body, &orderbookResponse)\n\tif err != nil {\n\t\treturn OrderbookResponse{}, err\n\t}\n\n\treturn orderbookResponse, nil\n}", "title": "" }, { "docid": "8fdb23235fb9b5659eef32dc14d69f61", "score": "0.6178276", "text": "func (b *BTCMarkets) GetOrderbook(ctx context.Context, marketID string, level int64) (*Orderbook, error) {\n\tparams := url.Values{}\n\tif level != 0 {\n\t\tparams.Set(\"level\", strconv.FormatInt(level, 10))\n\t}\n\tvar temp tempOrderbook\n\terr := b.SendHTTPRequest(ctx, btcMarketsUnauthPath+marketID+btcMarketOrderBook+params.Encode(),\n\t\t&temp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\torderbook := Orderbook{\n\t\tMarketID: temp.MarketID,\n\t\tSnapshotID: temp.SnapshotID,\n\t\tBids: make([]OBData, len(temp.Bids)),\n\t\tAsks: make([]OBData, len(temp.Asks)),\n\t}\n\n\tfor x := range temp.Asks {\n\t\tprice, err := strconv.ParseFloat(temp.Asks[x][0], 64)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tamount, err := strconv.ParseFloat(temp.Asks[x][1], 64)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\torderbook.Asks[x] = OBData{\n\t\t\tPrice: price,\n\t\t\tVolume: amount,\n\t\t}\n\t}\n\tfor a := range temp.Bids {\n\t\tprice, err := strconv.ParseFloat(temp.Bids[a][0], 64)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tamount, err := strconv.ParseFloat(temp.Bids[a][1], 64)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\torderbook.Bids[a] = OBData{\n\t\t\tPrice: price,\n\t\t\tVolume: amount,\n\t\t}\n\t}\n\treturn &orderbook, nil\n}", "title": "" }, { "docid": "7d75f6bb5e68a26e3cb1280a77ab9634", "score": "0.6149459", "text": "func (by *Bybit) FetchOrderbook(ctx context.Context, currency currency.Pair, assetType asset.Item) (*orderbook.Base, error) {\n\tob, err := orderbook.Get(by.Name, currency, assetType)\n\tif err != nil {\n\t\treturn by.UpdateOrderbook(ctx, currency, assetType)\n\t}\n\treturn ob, nil\n}", "title": "" }, { "docid": "eaf428072cadc3a9c4ce64765ad87f19", "score": "0.6140248", "text": "func (z *ZB) FetchOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {\n\tob, err := orderbook.Get(z.Name, p, assetType)\n\tif err != nil {\n\t\treturn z.UpdateOrderbook(ctx, p, assetType)\n\t}\n\treturn ob, nil\n}", "title": "" }, { "docid": "8897ddac657f67b020a7b5084b93456f", "score": "0.61373466", "text": "func (b Bitkub) GetOrderBook(symbol string, limit int) types.OrderBook {\n\tpath := fmt.Sprintf(pathDepth, symbol, limit)\n\turl := fmt.Sprintf(\"%s%s\", urlBase, path)\n\n\tdata, err := helper.Get(url)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn types.OrderBook{}\n\t}\n\n\torders := gjson.Parse(string(data))\n\n\tvar bids []types.ExOrder\n\tfor _, bid := range orders.Get(\"bids\").Array() {\n\t\tb := bid.Array()\n\t\tord := types.ExOrder{\n\t\t\tSide: types.SIDE_BUY,\n\t\t\tPrice: b[0].Float(),\n\t\t\tQty: b[1].Float(),\n\t\t}\n\t\tbids = append(bids, ord)\n\t}\n\n\tvar asks []types.ExOrder\n\tfor _, ask := range orders.Get(\"asks\").Array() {\n\t\ta := ask.Array()\n\t\tord := types.ExOrder{\n\t\t\tSide: types.SIDE_SELL,\n\t\t\tPrice: a[0].Float(),\n\t\t\tQty: a[1].Float(),\n\t\t}\n\t\tasks = append(asks, ord)\n\t}\n\n\treturn types.OrderBook{\n\t\tExchange: types.EXC_BITKUB,\n\t\tSymbol: symbol,\n\t\tBids: bids,\n\t\tAsks: asks}\n}", "title": "" }, { "docid": "8dad48e61fad0f586cf7d74ea6d18eea", "score": "0.60894156", "text": "func (b *BTCC) GetOrderBook(currencyPair string, limit int) (Orderbook, error) {\n\tresult := Orderbook{}\n\tpath := fmt.Sprintf(\"%s/data/pro/orderbook?symbol=%s&limit=%d\", btccAPIUrl, currencyPair, limit)\n\tif limit == 0 {\n\t\tpath = fmt.Sprintf(\"%s/data/pro/orderbook?symbol=%s\", btccAPIUrl, currencyPair)\n\t}\n\n\treturn result, b.SendHTTPRequest(path, &result)\n}", "title": "" }, { "docid": "04b04d0fa4f15b489b861bce20c9a052", "score": "0.60811126", "text": "func (e *Kraken) OrderBook(pair *pair.Pair) (*exchange.Maker, error) {\n\tjsonResponse := &JsonResponse{}\n\torderBook := make(map[string]*OrderBook)\n\tsymbol := e.GetSymbolByPair(pair)\n\n\tmapParams := make(map[string]string)\n\tmapParams[\"pair\"] = symbol\n\tmapParams[\"count\"] = \"100\"\n\n\tstrRequestUrl := \"/0/public/Depth\"\n\tstrUrl := API_URL + strRequestUrl\n\n\tmaker := &exchange.Maker{\n\t\tWorkerIP: exchange.GetExternalIP(),\n\t\tSource: exchange.EXCHANGE_API,\n\t\tBeforeTimestamp: float64(time.Now().UnixNano() / 1e6),\n\t}\n\n\tjsonOrderbook := exchange.HttpGetRequest(strUrl, mapParams)\n\tif err := json.Unmarshal([]byte(jsonOrderbook), &jsonResponse); err != nil {\n\t\treturn nil, fmt.Errorf(\"%s Get Orderbook Json Unmarshal Err: %v %v\", e.GetName(), err, jsonOrderbook)\n\t} else if len(jsonResponse.Error) != 0 {\n\t\treturn nil, fmt.Errorf(\"%s Get Orderbook Failed: %v\", e.GetName(), jsonResponse.Error)\n\t}\n\tif err := json.Unmarshal(jsonResponse.Result, &orderBook); err != nil {\n\t\treturn nil, fmt.Errorf(\"%s Get Orderbook Result Unmarshal Err: %v %s\", e.GetName(), err, jsonResponse.Result)\n\t}\n\n\tmaker.AfterTimestamp = float64(time.Now().UnixNano() / 1e6)\n\tvar err error\n\tfor _, book := range orderBook {\n\t\tfor _, bid := range book.Bids {\n\t\t\tbuydata := exchange.Order{}\n\t\t\tbuydata.Quantity, err = strconv.ParseFloat(bid[1].(string), 64)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"%s OrderBook strconv.ParseFloat Quantity error:%v\", e.GetName(), err)\n\t\t\t}\n\n\t\t\tbuydata.Rate, err = strconv.ParseFloat(bid[0].(string), 64)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"%s OrderBook strconv.ParseFloat Rate error:%v\", e.GetName(), err)\n\t\t\t}\n\t\t\tmaker.Bids = append(maker.Bids, buydata)\n\t\t}\n\t}\n\tfor _, book := range orderBook {\n\t\tfor _, ask := range book.Asks {\n\t\t\tselldata := exchange.Order{}\n\t\t\tselldata.Quantity, err = strconv.ParseFloat(ask[1].(string), 64)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"%s OrderBook strconv.ParseFloat Quantity error:%v\", e.GetName(), err)\n\t\t\t}\n\n\t\t\tselldata.Rate, err = strconv.ParseFloat(ask[0].(string), 64)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"%s OrderBook strconv.ParseFloat Rate error:%v\", e.GetName(), err)\n\t\t\t}\n\t\t\tmaker.Asks = append(maker.Asks, selldata)\n\t\t}\n\t}\n\treturn maker, nil\n}", "title": "" }, { "docid": "5da49d2d3d1d8654c0b40e6383d91cac", "score": "0.60672116", "text": "func (c *COINUT) FetchOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {\n\tob, err := orderbook.Get(c.Name, p, assetType)\n\tif err != nil {\n\t\treturn c.UpdateOrderbook(ctx, p, assetType)\n\t}\n\treturn ob, nil\n}", "title": "" }, { "docid": "cf8ef18f2914dc28535f3c9344f58506", "score": "0.60246253", "text": "func (b *BTSE) FetchOrderbook(p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {\n\tob, err := orderbook.Get(b.Name, p, assetType)\n\tif err != nil {\n\t\treturn b.UpdateOrderbook(p, assetType)\n\t}\n\treturn ob, nil\n}", "title": "" }, { "docid": "22bf1de7f1d4f2cbf38338d76089808f", "score": "0.59622127", "text": "func (a *Alphapoint) FetchOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {\n\tob, err := orderbook.Get(a.Name, p, assetType)\n\tif err != nil {\n\t\treturn a.UpdateOrderbook(ctx, p, assetType)\n\t}\n\treturn ob, nil\n}", "title": "" }, { "docid": "639802f250b6a5aa5bfd899ad0ce1727", "score": "0.5913727", "text": "func (e *Dragonex) OrderBook(pair *pair.Pair) (*exchange.Maker, error) {\n\tjsonResponse := &JsonResponse{}\n\torderBook := OrderBook{}\n\tsymbol := e.GetSymbolByPair(pair)\n\n\tstrRequestUrl := \"/api/v1/market/depth/\"\n\tstrUrl := API_URL + strRequestUrl\n\n\tmapParams := make(map[string]string)\n\tmapParams[\"symbol_id\"] = symbol\n\n\tmaker := &exchange.Maker{\n\t\tWorkerIP: exchange.GetExternalIP(),\n\t\tSource: exchange.EXCHANGE_API,\n\t\tBeforeTimestamp: float64(time.Now().UnixNano() / 1e6),\n\t}\n\n\tjsonOrderbook := exchange.HttpGetRequest(strUrl, mapParams)\n\tif err := json.Unmarshal([]byte(jsonOrderbook), &jsonResponse); err != nil {\n\t\treturn nil, fmt.Errorf(\"%s Get Orderbook Json Unmarshal Err: %v %v\", e.GetName(), err, jsonOrderbook)\n\t} else if !jsonResponse.Ok {\n\t\treturn nil, fmt.Errorf(\"%s Get Orderbook Failed: %v %v\", e.GetName(), jsonResponse.Code, jsonResponse.Msg)\n\t}\n\tif err := json.Unmarshal(jsonResponse.Data, &orderBook); err != nil {\n\t\treturn nil, fmt.Errorf(\"%s Get Orderbook Data Unmarshal Err: %v %s\", e.GetName(), err, jsonResponse.Data)\n\t}\n\n\tmaker.AfterTimestamp = float64(time.Now().UnixNano() / 1e6)\n\tvar err error\n\tfor _, bid := range orderBook.Buys {\n\t\tvar buydata exchange.Order\n\n\t\t//Modify according to type and structure\n\t\tbuydata.Rate, err = strconv.ParseFloat(bid.Price, 64)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tbuydata.Quantity, err = strconv.ParseFloat(bid.Volume, 64)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tmaker.Bids = append(maker.Bids, buydata)\n\t}\n\tfor _, ask := range orderBook.Sells {\n\t\tvar selldata exchange.Order\n\n\t\t//Modify according to type and structure\n\t\tselldata.Rate, err = strconv.ParseFloat(ask.Price, 64)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tselldata.Quantity, err = strconv.ParseFloat(ask.Volume, 64)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tmaker.Asks = append(maker.Asks, selldata)\n\t}\n\treturn maker, nil\n}", "title": "" }, { "docid": "eb982900a73e4cee4ddea2837a23b801", "score": "0.58762133", "text": "func RESTGetTicker(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tcurrency := vars[\"currency\"]\n\texchangeName := vars[\"exchangeName\"]\n\tassetType := vars[\"assetType\"]\n\n\tif assetType == \"\" {\n\t\tassetType = ticker.Spot\n\t}\n\tresponse, err := GetSpecificTicker(currency, exchangeName, assetType)\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to fetch ticker for %s currency: %s\\n\", exchangeName,\n\t\t\tcurrency)\n\t\treturn\n\t}\n\terr = RESTfulJSONResponse(w, response)\n\tif err != nil {\n\t\tRESTfulError(r.Method, err)\n\t}\n}", "title": "" }, { "docid": "2df70b62ea9452f030bf35d1eaa0147b", "score": "0.5829144", "text": "func (by *Bybit) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {\n\tif p.IsEmpty() {\n\t\treturn nil, currency.ErrCurrencyPairEmpty\n\t}\n\tif err := by.CurrencyPairs.IsAssetEnabled(assetType); err != nil {\n\t\treturn nil, err\n\t}\n\tvar orderbookNew *Orderbook\n\tvar err error\n\n\tformattedPair, err := by.FormatExchangeCurrency(p, assetType)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tswitch assetType {\n\tcase asset.Spot:\n\t\torderbookNew, err = by.GetOrderBook(ctx, formattedPair.String(), 0)\n\tcase asset.CoinMarginedFutures, asset.USDTMarginedFutures, asset.Futures:\n\t\torderbookNew, err = by.GetFuturesOrderbook(ctx, formattedPair)\n\tcase asset.USDCMarginedFutures:\n\t\torderbookNew, err = by.GetUSDCFuturesOrderbook(ctx, formattedPair)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"%s %w\", assetType, asset.ErrNotSupported)\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbook := &orderbook.Base{\n\t\tExchange: by.Name,\n\t\tPair: formattedPair,\n\t\tAsset: assetType,\n\t\tVerifyOrderbook: by.CanVerifyOrderbook,\n\t\tBids: make([]orderbook.Item, len(orderbookNew.Bids)),\n\t\tAsks: make([]orderbook.Item, len(orderbookNew.Asks)),\n\t}\n\n\tfor x := range orderbookNew.Bids {\n\t\tbook.Bids[x] = orderbook.Item{\n\t\t\tAmount: orderbookNew.Bids[x].Amount,\n\t\t\tPrice: orderbookNew.Bids[x].Price,\n\t\t}\n\t}\n\n\tfor x := range orderbookNew.Asks {\n\t\tbook.Asks[x] = orderbook.Item{\n\t\t\tAmount: orderbookNew.Asks[x].Amount,\n\t\t\tPrice: orderbookNew.Asks[x].Price,\n\t\t}\n\t}\n\terr = book.Process()\n\tif err != nil {\n\t\treturn book, err\n\t}\n\treturn orderbook.Get(by.Name, formattedPair, assetType)\n}", "title": "" }, { "docid": "6673b5361e4e919df2c3533e7c1fb197", "score": "0.58170456", "text": "func (z *ZB) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {\n\tif p.IsEmpty() {\n\t\treturn nil, currency.ErrCurrencyPairEmpty\n\t}\n\tif err := z.CurrencyPairs.IsAssetEnabled(assetType); err != nil {\n\t\treturn nil, err\n\t}\n\tbook := &orderbook.Base{\n\t\tExchange: z.Name,\n\t\tPair: p,\n\t\tAsset: assetType,\n\t\tVerifyOrderbook: z.CanVerifyOrderbook,\n\t}\n\tcurrFormat, err := z.FormatExchangeCurrency(p, assetType)\n\tif err != nil {\n\t\treturn book, err\n\t}\n\n\torderbookNew, err := z.GetOrderbook(ctx, currFormat.String())\n\tif err != nil {\n\t\treturn book, err\n\t}\n\n\tbook.Bids = make(orderbook.Items, len(orderbookNew.Bids))\n\tfor x := range orderbookNew.Bids {\n\t\tbook.Bids[x] = orderbook.Item{\n\t\t\tAmount: orderbookNew.Bids[x][1],\n\t\t\tPrice: orderbookNew.Bids[x][0],\n\t\t}\n\t}\n\n\tbook.Asks = make(orderbook.Items, len(orderbookNew.Asks))\n\tfor x := range orderbookNew.Asks {\n\t\tbook.Asks[x] = orderbook.Item{\n\t\t\tAmount: orderbookNew.Asks[x][1],\n\t\t\tPrice: orderbookNew.Asks[x][0],\n\t\t}\n\t}\n\terr = book.Process()\n\tif err != nil {\n\t\treturn book, err\n\t}\n\treturn orderbook.Get(z.Name, p, assetType)\n}", "title": "" }, { "docid": "ef62ed6a53b1c9a3348d6f51897cd5bb", "score": "0.58129096", "text": "func (c *COINUT) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {\n\tif p.IsEmpty() {\n\t\treturn nil, currency.ErrCurrencyPairEmpty\n\t}\n\tif err := c.CurrencyPairs.IsAssetEnabled(assetType); err != nil {\n\t\treturn nil, err\n\t}\n\tbook := &orderbook.Base{\n\t\tExchange: c.Name,\n\t\tPair: p,\n\t\tAsset: assetType,\n\t\tVerifyOrderbook: c.CanVerifyOrderbook,\n\t}\n\terr := c.loadInstrumentsIfNotLoaded()\n\tif err != nil {\n\t\treturn book, err\n\t}\n\n\tfPair, err := c.FormatExchangeCurrency(p, assetType)\n\tif err != nil {\n\t\treturn book, err\n\t}\n\n\tinstID := c.instrumentMap.LookupID(fPair.String())\n\tif instID == 0 {\n\t\treturn book, errLookupInstrumentID\n\t}\n\n\torderbookNew, err := c.GetInstrumentOrderbook(ctx, instID, 200)\n\tif err != nil {\n\t\treturn book, err\n\t}\n\n\tbook.Bids = make(orderbook.Items, len(orderbookNew.Buy))\n\tfor x := range orderbookNew.Buy {\n\t\tbook.Bids[x] = orderbook.Item{\n\t\t\tAmount: orderbookNew.Buy[x].Quantity,\n\t\t\tPrice: orderbookNew.Buy[x].Price,\n\t\t}\n\t}\n\n\tbook.Asks = make(orderbook.Items, len(orderbookNew.Sell))\n\tfor x := range orderbookNew.Sell {\n\t\tbook.Asks[x] = orderbook.Item{\n\t\t\tAmount: orderbookNew.Sell[x].Quantity,\n\t\t\tPrice: orderbookNew.Sell[x].Price,\n\t\t}\n\t}\n\terr = book.Process()\n\tif err != nil {\n\t\treturn book, err\n\t}\n\treturn orderbook.Get(c.Name, p, assetType)\n}", "title": "" }, { "docid": "fe5a5ce26c13f8ec9d78e06dcbe9897e", "score": "0.5779743", "text": "func getOrderinfo(key, secret string, symbol string, orderID int, page *int) (orders []Order, err error) {\n\tif symbol, err = normalize(symbol); err != nil {\n\t\treturn nil, err\n\t}\n\tvar (\n\t\tparams = url.Values{\n\t\t\t\"orderId\": []string{strconv.Itoa(orderID)},\n\t\t\t\"symbol\": []string{symbol},\n\t\t}\n\t)\n\tif page != nil {\n\t\tparams.Add(\"page\", strconv.Itoa(*page))\n\t}\n\tresp, err := requestPost(getOrderInfoEndpoint, key, secret, params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif resp.Code != http.StatusOK {\n\t\treturn nil, apiError(getOrderInfoEndpoint, resp.Message)\n\t}\n\t// if we're requesting a specific order, c2cx returns a single object, not an array\n\tif orderID != -1 {\n\t\torders = make([]Order, 1)\n\t\treturn orders, json.Unmarshal(resp.Data, &(orders[0]))\n\t}\n\treturn orders, json.Unmarshal(resp.Data, &orders)\n}", "title": "" }, { "docid": "fc6116cdc96b76168c16c99af53c81ef", "score": "0.57207394", "text": "func (e *Kraken) OrderBook(p *pair.Pair) (*market.Maker, error) {\n\tresponse := ResponseReturn{}\n\n\tstrRequestUrl := \"/public/Depth\"\n\tstrUrl := API_URL + strRequestUrl\n\n\tmapParams := make(map[string]string)\n\tmapParams[\"pair\"] = e.GetPairCode(p)\n\n\tjsonResponseReturn := exchange.HttpGetRequest(strUrl, mapParams)\n\tif err := json.Unmarshal([]byte(jsonResponseReturn), &response); err != nil {\n\t\treturn nil, fmt.Errorf(\"Kraken Unmarshal Response error: %s\", err)\n\t}\n\tif len(response.Error) != 0 {\n\t\treturn nil, fmt.Errorf(\"Kraken OrderBook error: %s\", response.Error)\n\t}\n\n\tdata := make(map[string]*OrderBook)\n\tif err := json.Unmarshal(response.Result, &data); err != nil {\n\t\treturn nil, fmt.Errorf(\"Kraken Unmarshal Result error: %s\", err)\n\t}\n\n\t//Convert Exchange Struct to Maker\n\tmaker := &market.Maker{}\n\tmaker.Timestamp = float64(time.Now().UnixNano() / 1e6)\n\tfor _, orderBook := range data {\n\t\tvar err error\n\t\tfor _, bid := range orderBook.Bids {\n\t\t\tvar buydata market.Order\n\n\t\t\t//Modify according to type and structure\n\t\t\tbuydata.Rate, err = strconv.ParseFloat(bid[0].(string), 64)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tbuydata.Quantity, err = strconv.ParseFloat(bid[1].(string), 64)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tmaker.Bids = append(maker.Bids, buydata)\n\t\t}\n\t\tfor _, ask := range orderBook.Asks {\n\t\t\tvar selldata market.Order\n\n\t\t\t//Modify according to type and structure\n\t\t\tselldata.Rate, err = strconv.ParseFloat(ask[0].(string), 64)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tselldata.Quantity, err = strconv.ParseFloat(ask[1].(string), 64)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tmaker.Asks = append(maker.Asks, selldata)\n\t\t}\n\t}\n\treturn maker, nil\n}", "title": "" }, { "docid": "52812c40228d0fedbebcfd029b55eca1", "score": "0.56847584", "text": "func (b *Poloniex) ReturnOrderBook(currencyPair string, depth int) (orderBook OrderBook, err error) {\n\tif depth > 100 {\n\t\tdepth = 100\n\t}\n\tif depth < 1 {\n\t\tdepth = 1\n\t}\n\n\targs := map[string]string{\n\t\t\"currencyPair\": currencyPair,\n\t\t\"depth\": fmt.Sprintf(\"%v\", depth)}\n\n\tr, err := b.client.do(\"GET\", \"returnOrderBook\", args)\n\tif err != nil {\n\t\treturn\n\t}\n\tif err = json.Unmarshal(r, &orderBook); err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "fc175605c80e9e4299def589bf70a968", "score": "0.56679547", "text": "func (e *Poloniex) getTicker(stockType string, sizes ...interface{}) (ticker Ticker, err error) {\n\te.lastTimes++\n\tstockType = strings.ToUpper(stockType)\n\tif _, ok := e.stockTypeMap[stockType]; !ok {\n\t\terr = fmt.Errorf(\"GetTicker() error, unrecognized stockType: %+v\", stockType)\n\t\treturn\n\t}\n\tsize := 20\n\tif len(sizes) > 0 && conver.IntMust(sizes[0]) > 0 {\n\t\tsize = conver.IntMust(sizes[0])\n\t}\n\tresp, err := get(fmt.Sprintf(\"%vpublic?command=returnOrderBook&stockType=%v&depth=%v\", e.host, e.stockTypeMap[stockType], size))\n\tif err != nil {\n\t\terr = fmt.Errorf(\"GetTicker() error, %+v\", err)\n\t\treturn\n\t}\n\tjson, err := simplejson.NewJson(resp)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"GetTicker() error, %+v\", err)\n\t\treturn\n\t}\n\tdepthsJSON := json.Get(\"bids\")\n\tfor i := 0; i < len(depthsJSON.MustArray()); i++ {\n\t\tdepthJSON := depthsJSON.GetIndex(i)\n\t\tticker.Bids = append(ticker.Bids, OrderBook{\n\t\t\tPrice: conver.Float64Must(depthJSON.GetIndex(0).Interface()),\n\t\t\tAmount: depthJSON.GetIndex(1).MustFloat64(),\n\t\t})\n\t}\n\tdepthsJSON = json.Get(\"asks\")\n\tfor i := 0; i < len(depthsJSON.MustArray()); i++ {\n\t\tdepthJSON := depthsJSON.GetIndex(i)\n\t\tticker.Asks = append(ticker.Asks, OrderBook{\n\t\t\tPrice: conver.Float64Must(depthJSON.GetIndex(0).Interface()),\n\t\t\tAmount: depthJSON.GetIndex(1).MustFloat64(),\n\t\t})\n\t}\n\tif len(ticker.Bids) < 1 || len(ticker.Asks) < 1 {\n\t\terr = fmt.Errorf(\"GetTicker() error, can not get enough Bids or Asks\")\n\t\treturn\n\t}\n\tticker.Buy = ticker.Bids[0].Price\n\tticker.Sell = ticker.Asks[0].Price\n\tticker.Mid = (ticker.Buy + ticker.Sell) / 2\n\treturn\n}", "title": "" }, { "docid": "8a8da8fe0e75b7e95d2bacdc80b5d859", "score": "0.56675136", "text": "func (c *Client) LoadOrderBook(\n\tselling Asset,\n\tbuying Asset,\n\tparams ...interface{},\n) (orderBook OrderBookSummary, err error) {\n\tc.fixURLOnce.Do(c.fixURL)\n\tquery := url.Values{}\n\n\tquery.Add(\"selling_asset_type\", selling.Type)\n\tquery.Add(\"selling_asset_code\", selling.Code)\n\tquery.Add(\"selling_asset_issuer\", selling.Issuer)\n\n\tquery.Add(\"buying_asset_type\", buying.Type)\n\tquery.Add(\"buying_asset_code\", buying.Code)\n\tquery.Add(\"buying_asset_issuer\", buying.Issuer)\n\n\tfor _, param := range params {\n\t\tswitch param := param.(type) {\n\t\tcase Limit:\n\t\t\tquery.Add(\"limit\", strconv.Itoa(int(param)))\n\t\tdefault:\n\t\t\terr = fmt.Errorf(\"Undefined parameter (%T): %+v\", param, param)\n\t\t\treturn\n\t\t}\n\t}\n\n\tresp, err := c.HTTP.Get(c.URL + \"/order_book?\" + query.Encode())\n\tif err != nil {\n\t\treturn\n\t}\n\n\terr = decodeResponse(resp, &orderBook)\n\treturn\n}", "title": "" }, { "docid": "acf2f8e954a5596eb50444904f2b9754", "score": "0.5645032", "text": "func (e *GateIo) getTicker(stockType string, sizes ...interface{}) (ticker Ticker, err error) {\n\tstockType = strings.ToUpper(stockType)\n\tif _, ok := e.stockTypeMap[stockType]; !ok {\n\t\terr = fmt.Errorf(\"GetTicker() error, unrecognized stockType: %+v\", stockType)\n\t\treturn\n\t}\n\tresp, err := get(fmt.Sprintf(\"http://data.gateio.co/api2/1/orderBook/%v_usdt\", e.stockTypeMap[stockType]))\n\tif err != nil {\n\t\terr = fmt.Errorf(\"GetTicker() error, %+v\", err)\n\t\treturn\n\t}\n\tjson, err := simplejson.NewJson(resp)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"GetTicker() error, %+v\", err)\n\t\treturn\n\t}\n\tdepthsJSON := json.Get(\"bids\")\n\tfor i := 0; i < len(depthsJSON.MustArray()); i++ {\n\t\tdepthJSON := depthsJSON.GetIndex(i)\n\t\tprice,_ := strconv.ParseFloat(depthJSON.GetIndex(0).MustString(), 64)\n\t\tamount,_ := strconv.ParseFloat(depthJSON.GetIndex(1).MustString(), 64)\n\n\t\tticker.Bids = append(ticker.Bids, OrderBook{\n\t\t\tPrice: price,\n\t\t\tAmount: amount,\n\t\t})\n\t}\n\tdepthsJSON = json.Get(\"asks\")\n\tfor i := len(depthsJSON.MustArray()); i > 0; i-- {\n\t\tdepthJSON := depthsJSON.GetIndex(i - 1)\n\t\tticker.Asks = append(ticker.Asks, OrderBook{\n\t\t\tPrice: depthJSON.GetIndex(0).MustFloat64(),\n\t\t\tAmount: depthJSON.GetIndex(1).MustFloat64(),\n\t\t})\n\t}\n\tif len(ticker.Bids) < 1 || len(ticker.Asks) < 1 {\n\t\terr = fmt.Errorf(\"GetTicker() error, can not get enough Bids or Asks\")\n\t\treturn\n\t}\n\tticker.Buy = ticker.Bids[0].Price\n\tticker.Sell = ticker.Asks[0].Price\n\tticker.Mid = (ticker.Buy + ticker.Sell) / 2\n\treturn\n}", "title": "" }, { "docid": "53eebd4186c54d93b4f0a9b9bffa85ff", "score": "0.5615966", "text": "func (b *Bitmex) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error) {\n\tvar orderBook orderbook.Base\n\n\torderbookNew, err := b.GetOrderbook(OrderBookGetL2Params{\n\t\tSymbol: exchange.FormatExchangeCurrency(b.Name, p).String(),\n\t\tDepth: 500})\n\tif err != nil {\n\t\treturn orderBook, err\n\t}\n\n\tfor _, ob := range orderbookNew {\n\t\tif ob.Side == \"Sell\" {\n\t\t\torderBook.Asks = append(orderBook.Asks,\n\t\t\t\torderbook.Item{Amount: float64(ob.Size), Price: ob.Price})\n\t\t\tcontinue\n\t\t}\n\t\tif ob.Side == \"Buy\" {\n\t\t\torderBook.Bids = append(orderBook.Bids,\n\t\t\t\torderbook.Item{Amount: float64(ob.Size), Price: ob.Price})\n\t\t\tcontinue\n\t\t}\n\t}\n\torderbook.ProcessOrderbook(b.GetName(), p, orderBook, assetType)\n\n\treturn orderbook.GetOrderbook(b.Name, p, assetType)\n}", "title": "" }, { "docid": "ba9589f8355179ab4c16712cb6394671", "score": "0.55912465", "text": "func (ob *OdrBook) OrderBook(depth float64) ([]*chainjson.GetOrderBookResult, error) {\n\tob.mtx.RLock()\n\tdefer ob.mtx.RUnlock()\n\n\tasks := getOrdersForDepth(ob.asks, depth)\n\tbids := getOrdersForDepth(ob.bids, depth)\n\n\tresult := make([]*chainjson.GetOrderBookResult, len(asks)+len(bids))\n\n\tvar idx int\n\t// asks list is reverted\n\tfor i := len(asks) - 1; i >= 0; i-- {\n\t\todrDesc := asks[i]\n\t\tresult[idx] = odrDesc.OrderBookResult()\n\t\tidx++\n\t}\n\tfor _, odrDesc := range bids {\n\t\tresult[idx] = odrDesc.OrderBookResult()\n\t\tidx++\n\t}\n\n\treturn result, nil\n}", "title": "" }, { "docid": "01629377e3a640fa2cf72d4be1b6c1c5", "score": "0.55722207", "text": "func (by *Bybit) GetOrderInfo(ctx context.Context, orderID string, pair currency.Pair, assetType asset.Item) (*order.Detail, error) {\n\tif pair.IsEmpty() {\n\t\treturn nil, currency.ErrCurrencyPairEmpty\n\t}\n\tif err := by.CurrencyPairs.IsAssetEnabled(assetType); err != nil {\n\t\treturn nil, err\n\t}\n\n\tswitch assetType {\n\tcase asset.Spot:\n\t\tresp, err := by.QueryOrder(ctx, orderID, \"\")\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn &order.Detail{\n\t\t\tAmount: resp.Quantity.Float64(),\n\t\t\tExchange: by.Name,\n\t\t\tOrderID: resp.OrderID,\n\t\t\tClientOrderID: resp.OrderLinkID,\n\t\t\tSide: getSide(resp.Side),\n\t\t\tType: getTradeType(resp.TradeType),\n\t\t\tPair: pair,\n\t\t\tCost: resp.CummulativeQuoteQty.Float64(),\n\t\t\tAssetType: assetType,\n\t\t\tStatus: getOrderStatus(resp.Status),\n\t\t\tPrice: resp.Price.Float64(),\n\t\t\tExecutedAmount: resp.ExecutedQty.Float64(),\n\t\t\tDate: resp.Time.Time(),\n\t\t\tLastUpdated: resp.UpdateTime.Time(),\n\t\t}, nil\n\n\tcase asset.CoinMarginedFutures:\n\t\tresp, err := by.GetActiveRealtimeCoinOrders(ctx, pair, orderID, \"\")\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif len(resp) != 1 {\n\t\t\treturn nil, fmt.Errorf(\"%w, received %v orders\", errExpectedOneOrder, len(resp))\n\t\t}\n\n\t\treturn &order.Detail{\n\t\t\tAmount: resp[0].Qty,\n\t\t\tExchange: by.Name,\n\t\t\tOrderID: resp[0].OrderID,\n\t\t\tClientOrderID: resp[0].OrderLinkID,\n\t\t\tSide: getSide(resp[0].Side),\n\t\t\tType: getTradeType(resp[0].OrderType),\n\t\t\tPair: pair,\n\t\t\tCost: resp[0].CumulativeQty.Float64(),\n\t\t\tAssetType: assetType,\n\t\t\tStatus: getOrderStatus(resp[0].OrderStatus),\n\t\t\tPrice: resp[0].Price,\n\t\t\tExecutedAmount: resp[0].Qty - resp[0].LeavesQty,\n\t\t\tDate: resp[0].CreatedAt,\n\t\t\tLastUpdated: resp[0].UpdatedAt,\n\t\t}, nil\n\n\tcase asset.USDTMarginedFutures:\n\t\tresp, err := by.GetActiveUSDTRealtimeOrders(ctx, pair, orderID, \"\")\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif len(resp) != 1 {\n\t\t\treturn nil, fmt.Errorf(\"%w, received %v orders\", errExpectedOneOrder, len(resp))\n\t\t}\n\n\t\treturn &order.Detail{\n\t\t\tAmount: resp[0].Qty,\n\t\t\tExchange: by.Name,\n\t\t\tOrderID: resp[0].OrderID,\n\t\t\tClientOrderID: resp[0].OrderLinkID,\n\t\t\tSide: getSide(resp[0].Side),\n\t\t\tType: getTradeType(resp[0].OrderType),\n\t\t\tPair: pair,\n\t\t\tCost: resp[0].CumulativeQty.Float64(),\n\t\t\tAssetType: assetType,\n\t\t\tStatus: getOrderStatus(resp[0].OrderStatus),\n\t\t\tPrice: resp[0].Price,\n\t\t\tExecutedAmount: resp[0].Qty - resp[0].LeavesQty,\n\t\t\tDate: resp[0].CreatedAt,\n\t\t\tLastUpdated: resp[0].UpdatedAt,\n\t\t}, nil\n\n\tcase asset.Futures:\n\t\tresp, err := by.GetActiveRealtimeOrders(ctx, pair, orderID, \"\")\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif len(resp) != 1 {\n\t\t\treturn nil, fmt.Errorf(\"%w, received %v orders\", errExpectedOneOrder, len(resp))\n\t\t}\n\n\t\treturn &order.Detail{\n\t\t\tAmount: resp[0].Qty,\n\t\t\tExchange: by.Name,\n\t\t\tOrderID: resp[0].OrderID,\n\t\t\tClientOrderID: resp[0].OrderLinkID,\n\t\t\tSide: getSide(resp[0].Side),\n\t\t\tType: getTradeType(resp[0].OrderType),\n\t\t\tPair: pair,\n\t\t\tCost: resp[0].CumulativeQty.Float64(),\n\t\t\tAssetType: assetType,\n\t\t\tStatus: getOrderStatus(resp[0].OrderStatus),\n\t\t\tPrice: resp[0].Price,\n\t\t\tExecutedAmount: resp[0].Qty - resp[0].LeavesQty,\n\t\t\tDate: resp[0].CreatedAt,\n\t\t\tLastUpdated: resp[0].UpdatedAt,\n\t\t}, nil\n\n\tcase asset.USDCMarginedFutures:\n\t\tresp, err := by.GetActiveUSDCOrder(ctx, pair, \"PERPETUAL\", orderID, \"\", \"\", \"\", \"\", 0)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif len(resp) != 1 {\n\t\t\treturn nil, fmt.Errorf(\"%w, received %v orders\", errExpectedOneOrder, len(resp))\n\t\t}\n\n\t\treturn &order.Detail{\n\t\t\tAmount: resp[0].Qty.Float64(),\n\t\t\tExchange: by.Name,\n\t\t\tOrderID: resp[0].ID,\n\t\t\tClientOrderID: resp[0].OrderLinkID,\n\t\t\tSide: getSide(resp[0].Side),\n\t\t\tType: getTradeType(resp[0].OrderType),\n\t\t\tPair: pair,\n\t\t\tCost: resp[0].TotalOrderValue.Float64(),\n\t\t\tAssetType: assetType,\n\t\t\tStatus: getOrderStatus(resp[0].OrderStatus),\n\t\t\tPrice: resp[0].Price.Float64(),\n\t\t\tExecutedAmount: resp[0].TotalFilledQty.Float64(),\n\t\t\tDate: resp[0].CreatedAt.Time(),\n\t\t}, nil\n\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"%s %w\", assetType, asset.ErrNotSupported)\n\t}\n}", "title": "" }, { "docid": "1170f1ea10aa0c62f53dca806b9d32fc", "score": "0.55480283", "text": "func (c *Client) GetOrderBookBoth(pair string) (OrderResult, error) {\n\tmethod := \"/public/getorderbook\"\n\n\tparams := &struct {\n\t\tMarket string `url:\"market\"`\n\t\tType string `url:\"type\"`\n\t}{\n\t\tpair,\n\t\t\"both\",\n\t}\n\n\tresp, err := c.getPublic(method, params)\n\tif err != nil {\n\t\tlog.Fatalf(\"Get balance error: %s\", err)\n\t}\n\n\tvar output OrderBookBoth\n\tHttpRespToStruct(resp, &output)\n\tif !output.Success {\n\t\tlog.Printf(\"Error with data message: %s\", output.Message)\n\t\treturn output.Result, errors.New(output.Message)\n\t}\n\treturn output.Result, nil\n}", "title": "" }, { "docid": "9e0095bde15d6f1e499a5bad9fd3abd0", "score": "0.5464422", "text": "func (m *MarketClient) GetSymbolOrderBookTicker(symbol string) (interface{}, error) {\n\tvar err error\n\tparams := \"\"\n\tif symbol != \"\" {\n\t\tparams = fmt.Sprintf(\"symbol=%s\", symbol)\n\t}\n\treq, err := m.Builder.Build(http.MethodGet, \"/fapi/v1/ticker/bookTicker\", params)\n\tif err != nil {\n\t\tlogger.Error(\"Failed to build url: %s\", err.Error())\n\t}\n\tres, err := binance.HttpRequest(req)\n\tvar parser map[string]interface{}\n\terr = json.Unmarshal(res, &parser)\n\tif _, ok := parser[\"code\"]; ok {\n\t\tresult := model.APIErrorResponse{}\n\t\terr = json.Unmarshal(res, &result)\n\t\treturn result, err\n\t}\n\tif params == \"\" {\n\t\tvar result []SymbolOrderBookTickerResponse\n\t\terr = json.Unmarshal(res, &result)\n\t\treturn result, err\n\t}\n\tresult := SymbolOrderBookTickerResponse{}\n\terr = json.Unmarshal(res, &result)\n\treturn result, err\n}", "title": "" }, { "docid": "00e3ed5c52dcc6a5ee85347a3a41b339", "score": "0.54424125", "text": "func (k *Kraken) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error) {\n\tvar orderBook orderbook.Base\n\torderbookNew, err := k.GetDepth(exchange.FormatExchangeCurrency(k.GetName(), p).String())\n\tif err != nil {\n\t\treturn orderBook, err\n\t}\n\n\tfor x := range orderbookNew.Bids {\n\t\torderBook.Bids = append(orderBook.Bids, orderbook.Item{Amount: orderbookNew.Bids[x].Amount, Price: orderbookNew.Bids[x].Price})\n\t}\n\n\tfor x := range orderbookNew.Asks {\n\t\torderBook.Asks = append(orderBook.Asks, orderbook.Item{Amount: orderbookNew.Asks[x].Amount, Price: orderbookNew.Asks[x].Price})\n\t}\n\n\torderbook.ProcessOrderbook(k.GetName(), p, orderBook, assetType)\n\treturn orderbook.GetOrderbook(k.Name, p, assetType)\n}", "title": "" }, { "docid": "2b284132397a7ecefc5c344392119b5b", "score": "0.5441221", "text": "func (a *Alphapoint) UpdateOrderbook(ctx context.Context, p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {\n\tif p.IsEmpty() {\n\t\treturn nil, currency.ErrCurrencyPairEmpty\n\t}\n\tif err := a.CurrencyPairs.IsAssetEnabled(assetType); err != nil {\n\t\treturn nil, err\n\t}\n\torderBook := new(orderbook.Base)\n\torderbookNew, err := a.GetOrderbook(ctx, p.String())\n\tif err != nil {\n\t\treturn orderBook, err\n\t}\n\n\torderBook.Bids = make(orderbook.Items, len(orderbookNew.Bids))\n\tfor x := range orderbookNew.Bids {\n\t\torderBook.Bids[x] = orderbook.Item{\n\t\t\tAmount: orderbookNew.Bids[x].Quantity,\n\t\t\tPrice: orderbookNew.Bids[x].Price,\n\t\t}\n\t}\n\n\torderBook.Asks = make(orderbook.Items, len(orderbookNew.Asks))\n\tfor x := range orderbookNew.Asks {\n\t\torderBook.Asks[x] = orderbook.Item{\n\t\t\tAmount: orderbookNew.Asks[x].Quantity,\n\t\t\tPrice: orderbookNew.Asks[x].Price,\n\t\t}\n\t}\n\n\torderBook.Pair = p\n\torderBook.Exchange = a.Name\n\torderBook.Asset = assetType\n\n\terr = orderBook.Process()\n\tif err != nil {\n\t\treturn orderBook, err\n\t}\n\n\treturn orderbook.Get(a.Name, p, assetType)\n}", "title": "" }, { "docid": "74146b3f85a968cf3fa7b7706d4519ac", "score": "0.54148763", "text": "func Getbook(c *fiber.Ctx) error {\n\tid := c.Params(\"id\")\n\tdb := config.DB\n\tvar product models.Book\n\tdb.Find(c.Context(), &product, id)\n\tif product.Title == \"\" {\n\t\treturn c.JSON(fiber.Map{\n\t\t\t\"status\": \"error\",\n\t\t\t\"message\": \"No product found with ID\",\n\t\t\t\"data\": nil,\n\t\t})\n\n\t}\n\treturn c.JSON(fiber.Map{\n\t\t\"status\": \"success\",\n\t\t\"message\": \"Product found\",\n\t\t\"data\": product,\n\t})\n}", "title": "" }, { "docid": "835a7c7ad810ccb4069abd18d232b91d", "score": "0.53714883", "text": "func RESTGetAllActiveOrderbooks(w http.ResponseWriter, r *http.Request) {\n\tvar response AllEnabledExchangeOrderbooks\n\tresponse.Data = GetAllActiveOrderbooks()\n\n\terr := RESTfulJSONResponse(w, response)\n\tif err != nil {\n\t\tRESTfulError(r.Method, err)\n\t}\n}", "title": "" }, { "docid": "152667cda10eddb14821465ba1dc84c1", "score": "0.5370133", "text": "func (b *BTSE) UpdateOrderbook(p currency.Pair, assetType asset.Item) (*orderbook.Base, error) {\n\torderBook := new(orderbook.Base)\n\ta, err := b.FetchOrderBook(b.FormatExchangeCurrency(p, assetType).String())\n\tif err != nil {\n\t\treturn orderBook, err\n\t}\n\tfor x := range a.BuyQuote {\n\t\torderBook.Bids = append(orderBook.Bids, orderbook.Item{\n\t\t\tPrice: a.BuyQuote[x].Price,\n\t\t\tAmount: a.BuyQuote[x].Size})\n\t}\n\tfor x := range a.SellQuote {\n\t\torderBook.Asks = append(orderBook.Asks, orderbook.Item{\n\t\t\tPrice: a.SellQuote[x].Price,\n\t\t\tAmount: a.SellQuote[x].Size})\n\t}\n\torderBook.Pair = p\n\torderBook.ExchangeName = b.Name\n\torderBook.AssetType = assetType\n\terr = orderBook.Process()\n\tif err != nil {\n\t\treturn orderBook, err\n\t}\n\treturn orderbook.Get(b.Name, p, assetType)\n}", "title": "" }, { "docid": "b8e45a2af54ef3e4184babe938602aee", "score": "0.534759", "text": "func (s ReservationServer) GetBook(ctx context.Context, req *pb.GetBookReq) (*pb.Book, error) {\n\tvar (\n\t\tisbn string\n\t\tlat float32\n\t\tlng float32\n\t\tprice float32\n\t\tlibrary string\n\n\t\tbook *pb.Book\n\t)\n\n\tgetBookSQL := `\n\t\tSELECT isbn, library, price, ST_Y(geog::geometry) as lat, ST_X(geog::geometry) as lng\n\t\tFROM books\n\t\tWHERE isbn = $1\n\t`\n\n\trows, err := s.DB.Query(getBookSQL, req.GetIsbn())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif rows.Next() {\n\t\terr = rows.Scan(&isbn, &library, &price, &lat, &lng)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tbook = &pb.Book{\n\t\t\tIsbn: isbn,\n\t\t\tLibrary: library,\n\t\t\tLat: lat,\n\t\t\tLng: lng,\n\t\t\tPrice: price,\n\t\t}\n\t} else {\n\t\treturn nil, errors.New(\"could not find book\")\n\t}\n\n\tfmt.Println(book)\n\treturn book, nil\n}", "title": "" }, { "docid": "f1bad767ee793aac352b1edda791788f", "score": "0.53262436", "text": "func (c *Client) ListOrderbook(c1, c2 Coin, full bool) (*Orderbook, error) {\n\tparams := make(url.Values)\n\tparams.Set(\"tapi_method\", \"list_orderbook\")\n\tparams.Set(\"coin_pair\", c1.String()+c2.String())\n\tif full {\n\t\tparams.Set(\"full\", \"true\")\n\t}\n\tresp, err := c.MakeRequest(params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn unmarshalOrderbook(resp.Data)\n}", "title": "" }, { "docid": "7fb9a76b60be0a92f292e2dae78dd88f", "score": "0.52811676", "text": "func GetBook(w http.ResponseWriter, r *http.Request) {\n\tvar book models.Book\n\tparams := mux.Vars(r)\n\n\trows := driver.DB.QueryRow(\"select * from books where id= $1\", params[\"id\"])\n\n\terr := rows.Scan(&book.ID, &book.Title, &book.Availability)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\tif err = json.NewEncoder(w).Encode(book); err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\n}", "title": "" }, { "docid": "4b042216517edcc25ce2235def9fbe56", "score": "0.52620304", "text": "func (h *HUOBI) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error) {\n\tvar orderBook orderbook.Base\n\torderbookNew, err := h.GetDepth(exchange.FormatExchangeCurrency(h.Name, p).String(), \"step1\")\n\tif err != nil {\n\t\treturn orderBook, err\n\t}\n\n\tfor x := range orderbookNew.Bids {\n\t\tdata := orderbookNew.Bids[x]\n\t\torderBook.Bids = append(orderBook.Bids, orderbook.Item{Amount: data[1], Price: data[0]})\n\t}\n\n\tfor x := range orderbookNew.Asks {\n\t\tdata := orderbookNew.Asks[x]\n\t\torderBook.Asks = append(orderBook.Asks, orderbook.Item{Amount: data[1], Price: data[0]})\n\t}\n\n\torderbook.ProcessOrderbook(h.GetName(), p, orderBook, assetType)\n\treturn orderbook.GetOrderbook(h.Name, p, assetType)\n}", "title": "" }, { "docid": "f9713d11c988d784e6f539c02d207d47", "score": "0.5259005", "text": "func (c *Client) GetOrderBookBuyOrSell(pair string, t string) ([]Order, error) {\n\tmethod := \"/public/getorderbook\"\n\n\tparams := &struct {\n\t\tMarket string `url:\"market\"`\n\t\tType string `url:\"type\"`\n\t}{\n\t\tpair,\n\t\tt,\n\t}\n\n\tresp, err := c.getPublic(method, params)\n\tif err != nil {\n\t\tlog.Fatalf(\"Get balance error: %s\", err)\n\t}\n\n\tvar output OrderBookBuyOrSell\n\tHttpRespToStruct(resp, &output)\n\tif !output.Success {\n\t\tlog.Printf(\"Error with data message: %s\", output.Message)\n\t\treturn output.Result, errors.New(output.Message)\n\t}\n\treturn output.Result, nil\n}", "title": "" }, { "docid": "7cf48c4fe5666486d240f40d8e95d3a9", "score": "0.5225534", "text": "func getBook(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t// Get url param from request\n\tparam := mux.Vars(r)\n\n\t// loop through the books and find by id\n\tfor _, book := range books {\n\t\tif book.ID == param[\"id\"] {\n\t\t\tjson.NewEncoder(w).Encode(book)\n\t\t\treturn\n\t\t}\n\t}\n}", "title": "" }, { "docid": "1c036f2bed4e19078da9e4a54e4fce2f", "score": "0.5187111", "text": "func GetBook(c *fiber.Ctx) error {\n\tid := c.Params(\"id\")\n\tdb := database.DBConn\n\tvar book Book\n\n\tdb.Find(&book, id)\n\n\tif book.Title == \"\"{\n\t\treturn c.Status(404).SendString(\"Book not found\")\n\t}\n\n\treturn c.JSON(book)\n}", "title": "" }, { "docid": "50223be538205f9c963c6c895c68db53", "score": "0.5152793", "text": "func GetSpecificTicker(currency, exchangeName, assetType string) (ticker.Price, error) {\n\tvar specificTicker ticker.Price\n\tvar err error\n\tfor i := 0; i < len(bot.exchanges); i++ {\n\t\tif bot.exchanges[i] != nil {\n\t\t\tif bot.exchanges[i].IsEnabled() && bot.exchanges[i].GetName() == exchangeName {\n\t\t\t\tspecificTicker, err = bot.exchanges[i].GetTickerPrice(\n\t\t\t\t\tpair.NewCurrencyPairFromString(currency),\n\t\t\t\t\tassetType,\n\t\t\t\t)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\treturn specificTicker, err\n}", "title": "" }, { "docid": "672757323ce02d68b82092ebd2f9347f", "score": "0.5141649", "text": "func getBook(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tparams := mux.Vars(r) // Gets params\n\t// Recorre los libros y encuentra uno con la identificación de los parámetros\n\tfor _, item := range books {\n\t\tif item.ID == params[\"id\"] {\n\t\t\tjson.NewEncoder(w).Encode(item)\n\t\t\treturn\n\t\t}\n\t}\n\tjson.NewEncoder(w).Encode(&Book{})\n}", "title": "" }, { "docid": "09fe9852d907f6b3320019a20bc2b7bb", "score": "0.5123017", "text": "func (k Keeper) GetBuyOrderBook(ctx sdk.Context, index string) (val types.BuyOrderBook, found bool) {\r\n\tstore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.BuyOrderBookKey))\r\n\r\n\tb := store.Get(types.KeyPrefix(index))\r\n\tif b == nil {\r\n\t\treturn val, false\r\n\t}\r\n\r\n\tk.cdc.MustUnmarshalBinaryBare(b, &val)\r\n\treturn val, true\r\n}", "title": "" }, { "docid": "4feb75f17681ad0d404345fe5b76164b", "score": "0.51095307", "text": "func getBook(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tparams := mux.Vars(r)\n\tfor _, book := range books {\n\t\tif book.ID == params[\"id\"] {\n\t\t\tjson.NewEncoder(w).Encode(book)\n\t\t\treturn\n\t\t}\n\t}\n\tjson.NewEncoder(w).Encode(&Book{})\n}", "title": "" }, { "docid": "3239a5d767e31e24f36706ecef90edcf", "score": "0.5102865", "text": "func getBook(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tparams := mux.Vars(r) //get params\n\t//loops through books to find the id\n\tfor _, item := range books {\n\t\tif item.ID == params[\"id\"] {\n\t\t\tjson.NewEncoder(w).Encode(item)\n\t\t\treturn\n\t\t}\n\t}\n\tjson.NewEncoder(w).Encode(&Book{})\n}", "title": "" }, { "docid": "771d8395f64793c102a2737225cdbcf1", "score": "0.5079163", "text": "func getBook(w http.ResponseWriter, r *http.Request) {\n\tparams := mux.Vars(r)\n\tbook, err := booksDao.FindById(params[\"id\"])\n\tif err != nil {\n\t\trespondWithError(w, http.StatusBadRequest, \"Invalid Book Id\")\n\t\treturn\n\t}\n\trespondWithJSON(w, http.StatusOK, book)\n\n}", "title": "" }, { "docid": "e80b5a40ed3cd6f5910368da2059884d", "score": "0.5054647", "text": "func GetBook(w http.ResponseWriter, r *http.Request) {\n\n\tparams := mux.Vars(r)\n\tid := params[\"id\"]\n\tbook := database.LoadSingleRow(id)\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tjson.NewEncoder(w).Encode(book)\n}", "title": "" }, { "docid": "5fa7865d5fe18d8ac469019414316508", "score": "0.5053664", "text": "func GetBook(w http.ResponseWriter, r *http.Request) {\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\tif !BypassAuth {\n\t\tif value, flag := AuthN(r); !flag {\n\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\tw.Write([]byte(\"Error: \" + value))\n\t\t\treturn\n\t\t}\n\t}\n\n\tparams := mux.Vars(r)\n\tv, _ := strconv.Atoi(params[\"id\"])\n\tif value, flag := booklist[v]; flag {\n\t\tw.WriteHeader(http.StatusOK)\n\t\tjson.NewEncoder(w).Encode(value)\n\t\treturn\n\t} else {\n\t\tw.WriteHeader(http.StatusNotFound)\n\t\tw.Write([]byte(\"Error: 404 Not Found\\n\"))\n\t}\n\n}", "title": "" }, { "docid": "58fc047d10bc93af8f8fbe16975f9150", "score": "0.5051131", "text": "func getBook(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tparams := mux.Vars(r)\n\tfor _, item := range books {\n\t\tif item.ID == params[\"id\"] {\n\t\t\tjson.NewEncoder(w).Encode(item)\n\t\t\treturn\n\t\t}\n\t}\n\tjson.NewEncoder(w).Encode(&Book{})\n}", "title": "" }, { "docid": "bb7fc5b69f27afd8680623ce4d9ce48e", "score": "0.50505173", "text": "func getQuote(side, sellToken, buyToken string, amount float64, decimals int) (Quote, error) {\n\turl := \"https://api.0x.org/swap/v1/quote?sellToken=\" + sellToken + \"&buyToken=\" + buyToken\n\tif side == \"SELL\" {\n\t\turl += \"&buyAmount=\"\n\t} else {\n\t\turl += \"&sellAmount=\"\n\t}\n\turl += convertToSolidity(amount, decimals)\n\n\tresp, err := http.Get(url)\n\tif err != nil {\n\t\treturn Quote{}, err\n\t}\n\n\tj, err := io.ReadAll(resp.Body)\n\tresp.Body.Close()\n\n\tif err != nil {\n\t\treturn Quote{}, fmt.Errorf(\"cannot ReadAll quote from Ox: %w\", err)\n\t}\n\n\tvar result Quote\n\tif err = json.Unmarshal(j, &result); err != nil {\n\t\treturn Quote{}, fmt.Errorf(\"cannot json.Unmarshal quote from Ox: %w in: %v\", err, string(j))\n\t}\n\n\treturn result, nil\n}", "title": "" }, { "docid": "74b792c1c0e92aa45aea1a852fe69d0b", "score": "0.5019918", "text": "func (onlineOrder *OnlineOrdersClient) Book(bookingCode string) string {\n\treq := &g2rail.BookRequest{\n\t\tSections: []string{bookingCode},\n\t\tPassengers: []*g2rail.Passenger{&g2rail.Passenger{\n\t\t\tGender: g2rail.Passenger_male,\n\t\t\tFirstName: \"QINWEN\",\n\t\t\tLastName: \"SHI\",\n\t\t\tPassport: \"E12341813\",\n\t\t\tPhone: \"+8527892123\",\n\t\t\tEmail: \"wen@g2rail.com\",\n\t\t\tBirthdate: \"1986-06-01\",\n\t\t}},\n\t}\n\n\t// set timeout\n\tctx, cancel := context.WithTimeout(context.Background(), 400*time.Second)\n\tdefer cancel()\n\n\tres, err := onlineOrder.service.Book(ctx, req)\n\tif err != nil {\n\t\tst, ok := status.FromError(err)\n\t\tif ok && st.Code() == codes.PermissionDenied {\n\t\t\tlog.Fatal(\"permission denied\")\n\t\t} else {\n\t\t\tlog.Fatal(\"cannot perform search: \", err)\n\t\t}\n\t\treturn \"\"\n\t}\n\n\tlog.Printf(\"Async Result Will Be At: %s\", res.AsyncKey)\n\treturn res.AsyncKey\n}", "title": "" }, { "docid": "ad9c325122ab4146f96e2609fbd14b02", "score": "0.50018513", "text": "func HandleGetBook(c *gin.Context) {\n\n\tid, err := strconv.ParseUint(c.Param(\"id\"), 10, 64)\n\tif err != nil {\n\t\tc.AbortWithStatus(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tbook, err := models.GetBook(uint(id))\n\tif err != nil {\n\t\tif errors.Is(err, gorm.ErrRecordNotFound) {\n\t\t\tc.AbortWithStatus(http.StatusNotFound)\n\t\t\treturn\n\t\t}\n\t\tc.AbortWithStatus(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, book)\n\treturn\n}", "title": "" }, { "docid": "5a8e964246419ef3eb2bb3a9a5f98994", "score": "0.499161", "text": "func (r *BookRouter) handleOrderBook(conn comms.Link, msg *msgjson.Message) *msgjson.Error {\n\tsub := new(msgjson.OrderBookSubscription)\n\terr := json.Unmarshal(msg.Payload, sub)\n\tif err != nil {\n\t\treturn &msgjson.Error{\n\t\t\tCode: msgjson.RPCParseError,\n\t\t\tMessage: \"parse error: \" + err.Error(),\n\t\t}\n\t}\n\tmkt, err := dex.MarketName(sub.Base, sub.Quote)\n\tif err != nil {\n\t\treturn &msgjson.Error{\n\t\t\tCode: msgjson.UnknownMarket,\n\t\t\tMessage: \"market name error: \" + err.Error(),\n\t\t}\n\t}\n\tbook, found := r.books[mkt]\n\tif !found {\n\t\treturn &msgjson.Error{\n\t\t\tCode: msgjson.UnknownMarket,\n\t\t\tMessage: \"unknown market\",\n\t\t}\n\t}\n\tbook.subs.add(conn)\n\tr.sendBook(conn, book, msg.ID)\n\treturn nil\n}", "title": "" }, { "docid": "2a193ec413639306a413a3043782c2c3", "score": "0.49857295", "text": "func GetExchangeInfo(symbols []string) ([]byte, error) {\n\turlPath := EP_EXCHANGE_INFO\n\tif symbols != nil {\n\t\tif len(symbols) == 1 {\n\t\t\turlPath += \"?symbol=\" + symbols[0]\n\t\t} else {\n\t\t\tsymbolAry := \"[\"\n\t\t\tfor _, s := range symbols {\n\t\t\t\tsymbolAry += \"\\\"\" + s + \"\\\",\"\n\t\t\t}\n\t\t\tsymbolAry = symbolAry[:len(symbolAry)-1] + \"]\"\n\t\t\turlPath += \"?symbol=\" + symbolAry\n\t\t}\n\t}\n\n\tres, err := bClient.Request(methods.GET, urlPath, nil, false, false)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\treturn nil, err\n\t}\n\n\treturn res, nil\n}", "title": "" }, { "docid": "6ca358246346d6b3a2767e5a378aec2b", "score": "0.49847743", "text": "func (s *server) SearchBook(ctx context.Context, query *library.QueryFormat) (*library.Response, error) {\n\tres := new(library.Response)\n\tinput := make(map[string]*library.QueryFormat, 0)\n\n\tinput[\"input\"] = query\n\turl := opaURL + \"/v1/data/library/search_books\"\n\tresp, _ := resty.R().\n\t\tSetBody(input).\n\t\tPost(url)\n\n\tvar raw map[string][]*library.Book\n\terr := json.Unmarshal(resp.Body(), &raw)\n\n\tif err != nil {\n\t\tlog.Fatalf(\"%v\", err)\n\t\treturn res, err\n\t}\n\n\tif len(raw[\"result\"]) == 0 {\n\t\tres.Action = \"Search\"\n\t\tres.Status = int32(resp.StatusCode())\n\t\tres.Message = \"Book not found.\"\n\t} else {\n\t\tres.Action = \"Search\"\n\t\tres.Status = int32(resp.StatusCode())\n\t\tres.Message = resp.Status()\n\t\tres.Value = &library.Response_Book{\n\t\t\tBook: raw[\"result\"][0],\n\t\t}\n\t}\n\treturn res, nil\n}", "title": "" }, { "docid": "016e5391562d5be0ef8a4c9884a841c0", "score": "0.49562374", "text": "func ExampleMicroStellar_LoadOrderBook() {\n\t// Create a new MicroStellar client connected to a fake network. To\n\t// use a real network replace \"fake\" below with \"test\" or \"public\".\n\tms := New(\"fake\")\n\n\t// Custom USD asset issued by specified issuer\n\tUSD := NewAsset(\"USD\", \"GAIUIQNMSXTTR4TGZETSQCGBTIF32G2L5P4AML4LFTMTHKM44UHIN6XQ\", Credit4Type)\n\n\t// Get at most 10 orders made between USD and XLM\n\torderbook, err := ms.LoadOrderBook(USD, NativeAsset,\n\t\tOpts().WithLimit(10).WithSortOrder(SortDescending))\n\n\tif err != nil {\n\t\tlog.Fatalf(\"LoadOrderBook: %v\", err)\n\t}\n\n\t// List all the returned asks.\n\tfor _, ask := range orderbook.Asks {\n\t\tlog.Printf(\"ask: %s %s for %s %s/%s\", ask.Amount, orderbook.Base.Code, ask.Price, orderbook.Counter.Code, orderbook.Base.Code)\n\t}\n\n\tfmt.Printf(\"ok\")\n\t// Output: ok\n}", "title": "" }, { "docid": "d46446ccfcda69abd2efebfa2bdee637", "score": "0.49540704", "text": "func getBook(response http.ResponseWriter, request *http.Request) {\r\n\tresponse.Header().Set(\"Content-Type\", \"application/json\")\r\n\tparams := mux.Vars(request) // Get all parameters\r\n\t// Loop through books and find id\r\n\tfor _, item := range Books {\r\n\t\tif item.ID == params[\"id\"] {\r\n\t\t\tjson.NewEncoder(response).Encode(item)\r\n\t\t\treturn\r\n\t\t}\r\n\t}\r\n\tjson.NewEncoder(response).Encode(&StandardMessage{\r\n\t\tError: true,\r\n\t\tMessage: \"Not found\"})\r\n}", "title": "" }, { "docid": "14caeccc2c6f12c90135ef92a414966f", "score": "0.49420166", "text": "func (b *BTCMarkets) formatOrderType(o order.Type) (string, error) {\n\tswitch o {\n\tcase order.Limit:\n\t\treturn limit, nil\n\tcase order.Market:\n\t\treturn market, nil\n\tcase order.StopLimit:\n\t\treturn stopLimit, nil\n\tcase order.Stop:\n\t\treturn stop, nil\n\tcase order.TakeProfit:\n\t\treturn takeProfit, nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"%s %s %w\", b.Name, o, order.ErrTypeIsInvalid)\n\t}\n}", "title": "" }, { "docid": "821cb503f242a74c02834e7c5cecb2d0", "score": "0.4933185", "text": "func ExchangeOrderQuery(args ...objects.Object) (objects.Object, error) {\n\tif len(args) < 2 {\n\t\treturn nil, objects.ErrWrongNumArguments\n\t}\n\n\texchangeName, ok := objects.ToString(args[0])\n\tif !ok {\n\t\treturn nil, fmt.Errorf(ErrParameterConvertFailed, exchangeName)\n\t}\n\torderID, ok := objects.ToString(args[1])\n\tif !ok {\n\t\treturn nil, fmt.Errorf(ErrParameterConvertFailed, orderID)\n\t}\n\n\tvar pair currency.Pair\n\tassetTypeString := asset.Spot.String()\n\n\tswitch len(args) {\n\tcase 4:\n\t\tassetTypeString, ok = objects.ToString(args[3])\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(ErrParameterConvertFailed, assetTypeString)\n\t\t}\n\t\tfallthrough\n\tcase 3:\n\t\tcurrencyPairString, isOk := objects.ToString(args[2])\n\t\tif !isOk {\n\t\t\treturn nil, fmt.Errorf(ErrParameterConvertFailed, currencyPairString)\n\t\t}\n\n\t\tvar err error\n\t\tpair, err = currency.NewPairFromString(currencyPairString)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(ErrParameterConvertFailed, currencyPairString)\n\t\t}\n\t}\n\n\tassetType, err := asset.New(assetTypeString)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\torderDetails, err := wrappers.GetWrapper().\n\t\tQueryOrder(context.TODO(), exchangeName, orderID, pair, assetType)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar tradeHistory objects.Array\n\tfor x := range orderDetails.Trades {\n\t\ttemp := make(map[string]objects.Object, 7)\n\t\ttemp[\"timestamp\"] = &objects.Time{Value: orderDetails.Trades[x].Timestamp}\n\t\ttemp[\"price\"] = &objects.Float{Value: orderDetails.Trades[x].Price}\n\t\ttemp[\"fee\"] = &objects.Float{Value: orderDetails.Trades[x].Fee}\n\t\ttemp[\"amount\"] = &objects.Float{Value: orderDetails.Trades[x].Amount}\n\t\ttemp[\"type\"] = &objects.String{Value: orderDetails.Trades[x].Type.String()}\n\t\ttemp[\"side\"] = &objects.String{Value: orderDetails.Trades[x].Side.String()}\n\t\ttemp[\"description\"] = &objects.String{Value: orderDetails.Trades[x].Description}\n\t\ttradeHistory.Value = append(tradeHistory.Value, &objects.Map{Value: temp})\n\t}\n\n\tdata := make(map[string]objects.Object, 14)\n\tdata[\"exchange\"] = &objects.String{Value: orderDetails.Exchange}\n\tdata[\"id\"] = &objects.String{Value: orderDetails.OrderID}\n\tdata[\"accountid\"] = &objects.String{Value: orderDetails.AccountID}\n\tdata[\"currencypair\"] = &objects.String{Value: orderDetails.Pair.String()}\n\tdata[\"price\"] = &objects.Float{Value: orderDetails.Price}\n\tdata[\"amount\"] = &objects.Float{Value: orderDetails.Amount}\n\tdata[\"amountexecuted\"] = &objects.Float{Value: orderDetails.ExecutedAmount}\n\tdata[\"amountremaining\"] = &objects.Float{Value: orderDetails.RemainingAmount}\n\tdata[\"fee\"] = &objects.Float{Value: orderDetails.Fee}\n\tdata[\"side\"] = &objects.String{Value: orderDetails.Side.String()}\n\tdata[\"type\"] = &objects.String{Value: orderDetails.Type.String()}\n\tdata[\"date\"] = &objects.String{Value: orderDetails.Date.String()}\n\tdata[\"status\"] = &objects.String{Value: orderDetails.Status.String()}\n\tdata[\"trades\"] = &tradeHistory\n\n\treturn &objects.Map{\n\t\tValue: data,\n\t}, nil\n}", "title": "" }, { "docid": "6902c3fc72b407f7e63c2255d409bdbe", "score": "0.4910152", "text": "func (z *ZB) GetOrderInfo(ctx context.Context, orderID string, pair currency.Pair, assetType asset.Item) (*order.Detail, error) {\n\tif pair.IsEmpty() {\n\t\treturn nil, currency.ErrCurrencyPairEmpty\n\t}\n\tif err := z.CurrencyPairs.IsAssetEnabled(assetType); err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp, err := z.GetSingleOrder(ctx, orderID, \"\", pair)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tside := order.Sell\n\tif resp.Type == 1 {\n\t\tside = order.Buy\n\t}\n\tvar status order.Status\n\tswitch resp.Status {\n\tcase 1:\n\t\tstatus = order.Cancelled\n\tcase 2:\n\t\tstatus = order.Closed\n\tcase 3:\n\t\tstatus = order.Pending\n\t}\n\treturn &order.Detail{\n\t\tPrice: resp.Price,\n\t\tAmount: resp.TotalAmount,\n\t\tExecutedAmount: resp.TradeAmount,\n\t\tRemainingAmount: resp.TotalAmount - resp.TradeAmount,\n\t\tFee: resp.Fees,\n\t\tFeeAsset: pair.Quote,\n\t\tExchange: z.Name,\n\t\tOrderID: resp.ID,\n\t\tSide: side,\n\t\tStatus: status,\n\t\tAssetType: assetType,\n\t\tDate: time.Unix(resp.TradeDate, 0),\n\t\tPair: pair,\n\t}, nil\n}", "title": "" }, { "docid": "bd94d856971de6ab7306421a837d53a4", "score": "0.48899502", "text": "func getBook(writer http.ResponseWriter, request *http.Request) {\n\twriter.Header().Set(\"Content-Type\", \"application/json\")\n\tparams := mux.Vars(request)\n\n\tfor _, item := range books {\n\t\tif item.ID == params[\"id\"] {\n\t\t\tjson.NewEncoder(writer).Encode(item)\n\t\t\treturn\n\t\t}\n\t}\n\n\tjson.NewEncoder(writer).Encode(&Book{})\n}", "title": "" }, { "docid": "e02c1e4dc3ec593f8255e97712b45381", "score": "0.48804125", "text": "func GetObjectSample() {\n fmt.Println(\"---- Get Object Sample ----\")\n\n // Create the client from environment variables.\n client, err := buildclient.FromEnv()\n if err != nil {\n log.Fatal(err)\n }\n\n // Grab the first book defined in utils.BookNames\n getObjRequest := models.NewGetObjectRequest(utils.BucketName, utils.BookNames[0])\n getObjResponse, err := client.GetObject(getObjRequest)\n if err != nil {\n log.Fatal(err)\n }\n\n // Verify that the contents of the book were retrieved correctly.\n utils.VerifyBookContent(utils.BookNames[0], getObjResponse.Content)\n fmt.Printf(\"Retrieved: %s\\n\", utils.BookNames[0])\n}", "title": "" }, { "docid": "49e52ed1728717d73d2964b02f62798b", "score": "0.48779428", "text": "func (by *Bybit) GetActiveOrders(ctx context.Context, req *order.MultiOrderRequest) (order.FilteredOrders, error) {\n\terr := req.Validate()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif len(req.Pairs) == 0 && req.AssetType != asset.Spot {\n\t\treturn nil, fmt.Errorf(\"GetActiveOrders: zero pairs found\")\n\t}\n\n\tif len(req.Pairs) == 0 {\n\t\t// sending an empty currency pair retrieves data for all currencies\n\t\treq.Pairs = append(req.Pairs, currency.EMPTYPAIR)\n\t}\n\n\tvar orders []order.Detail\n\tswitch req.AssetType {\n\tcase asset.Spot:\n\t\topenOrders, err := by.ListOpenOrders(ctx, \"\", \"\", 0)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tfor x := range openOrders {\n\t\t\tfor i := range req.Pairs {\n\t\t\t\tif req.Pairs[i].String() == openOrders[x].SymbolName {\n\t\t\t\t\torders = append(orders, order.Detail{\n\t\t\t\t\t\tAmount: openOrders[x].Quantity.Float64(),\n\t\t\t\t\t\tDate: openOrders[x].Time.Time(),\n\t\t\t\t\t\tExchange: by.Name,\n\t\t\t\t\t\tOrderID: openOrders[x].OrderID,\n\t\t\t\t\t\tClientOrderID: openOrders[x].OrderLinkID,\n\t\t\t\t\t\tSide: getSide(openOrders[x].Side),\n\t\t\t\t\t\tType: getTradeType(openOrders[x].TradeType),\n\t\t\t\t\t\tPrice: openOrders[x].Price.Float64(),\n\t\t\t\t\t\tStatus: getOrderStatus(openOrders[x].Status),\n\t\t\t\t\t\tPair: req.Pairs[i],\n\t\t\t\t\t\tAssetType: req.AssetType,\n\t\t\t\t\t\tLastUpdated: openOrders[x].UpdateTime.Time(),\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tcase asset.CoinMarginedFutures:\n\t\tfor i := range req.Pairs {\n\t\t\topenOrders, err := by.GetActiveCoinFuturesOrders(ctx, req.Pairs[i], \"\", \"\", \"\", 0)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tfor x := range openOrders {\n\t\t\t\torders = append(orders, order.Detail{\n\t\t\t\t\tPrice: openOrders[x].Price,\n\t\t\t\t\tAmount: openOrders[x].Qty,\n\t\t\t\t\tExecutedAmount: openOrders[x].Qty - openOrders[x].LeavesQty,\n\t\t\t\t\tRemainingAmount: openOrders[x].LeavesQty,\n\t\t\t\t\tFee: openOrders[x].CumulativeFee,\n\t\t\t\t\tExchange: by.Name,\n\t\t\t\t\tOrderID: openOrders[x].OrderID,\n\t\t\t\t\tClientOrderID: openOrders[x].OrderLinkID,\n\t\t\t\t\tType: getTradeType(openOrders[x].OrderType),\n\t\t\t\t\tSide: getSide(openOrders[x].Side),\n\t\t\t\t\tStatus: getOrderStatus(openOrders[x].OrderStatus),\n\t\t\t\t\tPair: req.Pairs[i],\n\t\t\t\t\tAssetType: req.AssetType,\n\t\t\t\t\tDate: openOrders[x].CreatedAt,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\tcase asset.USDTMarginedFutures:\n\t\tfor i := range req.Pairs {\n\t\t\topenOrders, err := by.GetActiveUSDTFuturesOrders(ctx, req.Pairs[i], \"\", \"\", \"\", \"\", 0, 0)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tfor x := range openOrders {\n\t\t\t\torders = append(orders, order.Detail{\n\t\t\t\t\tPrice: openOrders[x].Price,\n\t\t\t\t\tAmount: openOrders[x].Qty,\n\t\t\t\t\tExecutedAmount: openOrders[x].Qty - openOrders[x].LeavesQty,\n\t\t\t\t\tRemainingAmount: openOrders[x].LeaveValue,\n\t\t\t\t\tFee: openOrders[x].CumulativeFee,\n\t\t\t\t\tExchange: by.Name,\n\t\t\t\t\tOrderID: openOrders[x].OrderID,\n\t\t\t\t\tClientOrderID: openOrders[x].OrderLinkID,\n\t\t\t\t\tType: getTradeType(openOrders[x].OrderType),\n\t\t\t\t\tSide: getSide(openOrders[x].Side),\n\t\t\t\t\tStatus: getOrderStatus(openOrders[x].OrderStatus),\n\t\t\t\t\tPair: req.Pairs[i],\n\t\t\t\t\tAssetType: asset.USDTMarginedFutures,\n\t\t\t\t\tDate: openOrders[x].CreatedAt,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\tcase asset.Futures:\n\t\tfor i := range req.Pairs {\n\t\t\topenOrders, err := by.GetActiveFuturesOrders(ctx, req.Pairs[i], \"\", \"\", \"\", 0)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tfor x := range openOrders {\n\t\t\t\torders = append(orders, order.Detail{\n\t\t\t\t\tPrice: openOrders[x].Price,\n\t\t\t\t\tAmount: openOrders[x].Qty,\n\t\t\t\t\tExecutedAmount: openOrders[x].Qty - openOrders[x].LeavesQty,\n\t\t\t\t\tRemainingAmount: openOrders[x].LeavesQty,\n\t\t\t\t\tFee: openOrders[x].CumulativeFee,\n\t\t\t\t\tExchange: by.Name,\n\t\t\t\t\tOrderID: openOrders[x].OrderID,\n\t\t\t\t\tClientOrderID: openOrders[x].OrderLinkID,\n\t\t\t\t\tType: getTradeType(openOrders[x].OrderType),\n\t\t\t\t\tSide: getSide(openOrders[x].Side),\n\t\t\t\t\tStatus: getOrderStatus(openOrders[x].OrderStatus),\n\t\t\t\t\tPair: req.Pairs[i],\n\t\t\t\t\tAssetType: req.AssetType,\n\t\t\t\t\tDate: openOrders[x].CreatedAt,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\tcase asset.USDCMarginedFutures:\n\t\topenOrders, err := by.GetActiveUSDCOrder(ctx, currency.EMPTYPAIR, \"PERPETUAL\", \"\", \"\", \"\", \"\", \"\", 0)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tfor x := range openOrders {\n\t\t\tfor i := range req.Pairs {\n\t\t\t\tif req.Pairs[i].String() == openOrders[x].Symbol {\n\t\t\t\t\torders = append(orders, order.Detail{\n\t\t\t\t\t\tPrice: openOrders[x].Price.Float64(),\n\t\t\t\t\t\tAmount: openOrders[x].Qty.Float64(),\n\t\t\t\t\t\tExecutedAmount: openOrders[x].TotalFilledQty.Float64(),\n\t\t\t\t\t\tRemainingAmount: openOrders[x].Qty.Float64() - openOrders[x].TotalFilledQty.Float64(),\n\t\t\t\t\t\tFee: openOrders[x].TotalFee.Float64(),\n\t\t\t\t\t\tExchange: by.Name,\n\t\t\t\t\t\tOrderID: openOrders[x].ID,\n\t\t\t\t\t\tClientOrderID: openOrders[x].OrderLinkID,\n\t\t\t\t\t\tType: getTradeType(openOrders[x].OrderType),\n\t\t\t\t\t\tSide: getSide(openOrders[x].Side),\n\t\t\t\t\t\tStatus: getOrderStatus(openOrders[x].OrderStatus),\n\t\t\t\t\t\tPair: req.Pairs[i],\n\t\t\t\t\t\tAssetType: req.AssetType,\n\t\t\t\t\t\tDate: openOrders[x].CreatedAt.Time(),\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tdefault:\n\t\treturn orders, fmt.Errorf(\"%s %w\", req.AssetType, asset.ErrNotSupported)\n\t}\n\treturn req.Filter(by.Name, orders), nil\n}", "title": "" }, { "docid": "bacf5749bcc81b624ad136f779bc3feb", "score": "0.48659506", "text": "func GetExchangeRate(currency string, basePair common.Fiat) *common.Rate {\n\n\txType := reflect.TypeOf(currency)\n\tfmt.Println(xType)\n\n\tif _, ok := request.Currency(currency).IsValid(); !ok {\n\t\tif _, ok := common.Fiat(currency).IsValid(); !ok {\n\t\t\tfmt.Println(\"invalid currencry or fiat\")\n\t\t\treturn nil\n\t\t}\n\t}\n\n\t_url, _ := url.Parse(\"/v3/tatum/rate/\" + currency)\n\tq := _url.Query()\n\tq.Add(\"basePair\", string(basePair))\n\t_url.RawQuery = q.Encode()\n\tfmt.Println(_url.String())\n\n\tvar rate common.Rate\n\tres, err := sender.SendGet(_url.String(), nil)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn nil\n\t}\n\n\terr = json.Unmarshal([]byte(res), &rate)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\treturn nil\n\t}\n\n\treturn &rate\n}", "title": "" }, { "docid": "61b4fda441e80c2d997d7fd9eb123e28", "score": "0.48498902", "text": "func GetBookHandler(ctx iris.Context) {\n\tisbn := ctx.Params().Get(\"isbn\")\n\n\tbook, found := GetBook(isbn)\n\tif !found {\n\t\tctx.StatusCode(iris.StatusNotFound)\n\t\treturn\n\n\t}\n\n\tctx.JSON(book)\n}", "title": "" }, { "docid": "fa98a0b38831ec4738aabdd268d06124", "score": "0.48489308", "text": "func (c BookController) GetBook(db *sql.DB) http.HandlerFunc{\n\treturn func (writer http.ResponseWriter, request *http.Request) {\n\t\tparams := mux.Vars(request)\n\t\trepo := repository.BookRepository{}\n\t\tid, err := strconv.Atoi(params[\"id\"])\n\t\tlogFatal(err)\n\t\tbook := repo.GetBook(db, id)\n\t\tjson.NewEncoder(writer).Encode(book)\n\t}\n}", "title": "" }, { "docid": "6b02de0aacd8d38f16cc8d2fcea21ee5", "score": "0.48397276", "text": "func (bh *BookHandler) HandleGetBook(params operations.GetBookParams) middleware.Responder {\n\n\tfilter := bson.D{{\"title\", params.Title}}\n\n\tlog.Println(params.Title)\n\n\tvar book data.Book\n\tif err := bh.Persister.Retrieve(\"books\", filter, &book); err != nil {\n\t\tlog.Println(err)\n\t\treturn operations.NewGetBookOK()\n\t}\n\n\tresponseBook := &models.Book{\n\t\tTitle: book.Title,\n\t\tAuthor: book.Author,\n\t}\n\n\tlog.Println(responseBook.Title)\n\treturn operations.NewGetBookOK().WithPayload(responseBook)\n}", "title": "" }, { "docid": "66149178db2c14e13a6a7c0a1a1de477", "score": "0.48387188", "text": "func (t *orderbooktracker) Get(sym string) (exchange.MarketRecord, error) {\n\tvar (\n\t\tr exchange.MarketRecord\n\t\terr error\n\t)\n\tresult := t.db.HGet(t.hash, normalize(sym))\n\tif err = result.Err(); err != nil {\n\t\treturn r, err\n\t}\n\tif bb, err := result.Bytes(); err == nil {\n\t\terr = json.Unmarshal(bb, &r)\n\t}\n\treturn r, err\n}", "title": "" }, { "docid": "589393dc41de02717c4616689de26692", "score": "0.48357588", "text": "func (m *Manager) GetBook(coinPair string) Book {\n\treturn m.books[coinPair].Copy()\n}", "title": "" }, { "docid": "b5020d561a03f1732e948cf5025226da", "score": "0.48305696", "text": "func (ec *executionContext) _Book(ctx context.Context, sel ast.SelectionSet, obj model.Book) graphql.Marshaler {\n\tswitch obj := (obj).(type) {\n\tcase nil:\n\t\treturn graphql.Null\n\tcase model.Textbook:\n\t\treturn ec._Textbook(ctx, sel, &obj)\n\tcase *model.Textbook:\n\t\tif obj == nil {\n\t\t\treturn graphql.Null\n\t\t}\n\t\treturn ec._Textbook(ctx, sel, obj)\n\tcase model.ColoringBook:\n\t\treturn ec._ColoringBook(ctx, sel, &obj)\n\tcase *model.ColoringBook:\n\t\tif obj == nil {\n\t\t\treturn graphql.Null\n\t\t}\n\t\treturn ec._ColoringBook(ctx, sel, obj)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"unexpected type %T\", obj))\n\t}\n}", "title": "" }, { "docid": "1b676f70affa305bc22a38032cd05768", "score": "0.48225382", "text": "func OrderTransferGet(req model.RequestAbstract) model.ResponseAbstract {\n\tmetaDataSelect = utils.DecodeJSON(utils.ReadFile(constant.HectorConf + \"/metadata/alltrade/alltradeApi.json\"))\n\tmetaInput := utils.FindMap(\"table\", \"order_transfer\", metaDataSelect)\n\tmetaResult := metadata.InterpretSelect(metaInput, req.Filters)\n\tquery := \"\"\n\n\tvar dbAbs model.DBAbstract\n\tif queryhelper.IsValidCassandraQuery(metaResult) {\n\t\tquery = queryhelper.PrepareSelectQuery(metaResult)\n\t\tdbAbs.DBType = \"cassandra\"\n\t} else {\n\t\tmetaResult[\"databaseType\"] = \"presto\"\n\t\tquery = queryhelper.PrepareSelectQuery(metaResult)\n\t\tdbAbs.DBType = \"presto\"\n\t}\n\n\tdbAbs.QueryType = \"SELECT\"\n\tdbAbs.Query = query\n\tendpoint.Process(nil, &conf, &dbAbs)\n\n\treturn prepareResponse(dbAbs)\n}", "title": "" }, { "docid": "c36e79fcbed53a996789b7d5f43663e0", "score": "0.47866315", "text": "func GetAsset(w http.ResponseWriter, r *http.Request) {\n\tpartnerID := GetPartnerID(r)\n\tendpointID := GetEndpointID(r)\n\tif partnerID == \"\" || endpointID == \"\" {\n\t\thttp.Error(w, \"not correct data\", http.StatusBadRequest)\n\t\treturn\n\t}\n\t// qaAsset, err := postgres.Client.GetByPartner(\"50000031\")\n\t// if err != nil {\n\t// \tSendError(w, http.StatusNotFound, err.Error())\n\t// \treturn\n\t// }\n\t// n := rand.Intn(len(qaAsset))\n\t// fmt.Println(\"Len:\", len(qaAsset), \"rand:\", n)\n\tasset, err := postgres.Client.GetAsset(partnerID, endpointID)\n\tif err != nil {\n\t\tif err == postgres.ErrNotFound {\n\t\t\tSendError(w, http.StatusNotFound, err.Error())\n\t\t\treturn\n\t\t}\n\t\tSendInternalServerError(w, err.Error())\n\t\treturn\n\t}\n\t// if endpointID == \"20fe5869-f0dc-4970-8b24-6598f35cfb4b\" {\n\t// \tSendInternalServerError(w, \"not found\")\n\t// \treturn\n\t// }\n\t// qa := qaAsset[n]\n\t// asset.Networks = qa.Networks\n\t// asset.Processors = qa.Processors\n\t// asset.RaidController = qa.RaidController\n\t// asset.InstalledSoftwares = qa.InstalledSoftwares\n\t// asset.Keyboards = qa.Keyboards\n\t// asset.Monitors = qa.Monitors\n\t// asset.Mouse = qa.Mouse\n\t// asset.Memory = qa.Memory\n\t// asset.PhysicalDrives = qa.PhysicalDrives\n\t// asset.Shares = qa.Shares\n\t// asset.Users = qa.Users\n\t// asset.SoftwareLicenses = qa.SoftwareLicenses\n\t// asset.Bios = qa.Bios\n\t// asset.Drives = qa.Drives\n\t// asset.PhysicalDrives = qa.PhysicalDrives\n\n\tRenderJSON(w, asset)\n}", "title": "" }, { "docid": "bc4e8859c396791c017d81db9fd005cc", "score": "0.47855845", "text": "func GetBooks(c *gin.Context) {\n\tvar filters OpdsBooksSearch\n\tuserID := c.GetInt64(\"user_id\")\n\tif err := c.ShouldBindWith(&filters, binding.Query); err == nil {\n\t\tdbFilters := models.BookFilters{\n\t\t\tLimit: 10,\n\t\t\tOffset: 0,\n\t\t\tTitle: filters.Title,\n\t\t}\n\n\t\tif filters.Page > 0 {\n\t\t\tdbFilters.Offset = filters.Page * 10\n\t\t}\n\n\t\tbooks, _, err := database.GetBooks(userID, dbFilters)\n\t\tif err != nil {\n\t\t\tc.XML(500, err)\n\t\t\treturn\n\t\t}\n\t\tif len(books) == 0 {\n\t\t\tc.Data(200, \"application/atom+xml;charset=utf-8\", []byte(notFound))\n\t\t\treturn\n\t\t}\n\n\t\trootLinks := []opdsutils.Link{\n\t\t\t{\n\t\t\t\tHref: fmt.Sprintf(\"/opds/books?title=%s&page=%d\", url.QueryEscape(filters.Title), filters.Page+1),\n\t\t\t\tRel: \"next\",\n\t\t\t\tType: \"application/atom+xml;profile=opds-catalog\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tHref: \"/opds\",\n\t\t\t\tRel: \"start\",\n\t\t\t\tType: \"application/atom+xml;profile=opds-catalog\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tHref: \"/opds-opensearch.xml\",\n\t\t\t\tRel: \"search\",\n\t\t\t\tType: \"application/opensearchdescription+xml\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tHref: \"/opds/search?searchTerm={searchTerms}\",\n\t\t\t\tRel: \"search\",\n\t\t\t\tType: \"application/atom+xml\",\n\t\t\t},\n\t\t}\n\n\t\tfeed := &opdsutils.Feed{\n\t\t\tTitle: \"Новые книги\",\n\t\t\tLinks: rootLinks,\n\t\t}\n\t\tfeed.Items = []*opdsutils.Item{}\n\t\tfor _, book := range books {\n\t\t\tauthors := []string{}\n\t\t\tbookItem := opdsutils.CreateItem(book)\n\t\t\tfor _, author := range book.Authors {\n\t\t\t\tauthors = append(authors, author.FullName)\n\t\t\t}\n\t\t\tfeed.Items = append(feed.Items, &bookItem)\n\t\t}\n\t\tatom, err := feed.ToAtom()\n\t\tif err != nil {\n\t\t\tlogging.CustomLog.Println(err)\n\t\t}\n\n\t\tc.Data(200, \"application/atom+xml;charset=utf-8\", []byte(atom))\n\t\treturn\n\t}\n\thttputil.NewError(c, http.StatusBadRequest, errors.New(\"bad_request\"))\n}", "title": "" }, { "docid": "b58a8113ea05af3394c1ef6d96e9ae93", "score": "0.47816864", "text": "func getOrder(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tparams := mux.Vars(r) // Get parameters\n\n\t// Loop through orders and find the order with id\n\tfor _, item := range orders {\n\t\tif item.ID == params[\"id\"] {\n\t\t\tjson.NewEncoder(w).Encode(item)\n\t\t\treturn\n\t\t}\n\t}\n\tjson.NewEncoder(w).Encode(&Order{})\n}", "title": "" }, { "docid": "1b4ba142076240fe61fa4b4a3e8bf162", "score": "0.47775367", "text": "func (t *SupplychainChaincode) processGetOrder(stub shim.ChaincodeStubInterface, callerDetails CallerDetails, args[]string) ([]byte, error) {\n\n fmt.Println(\"running processGetOrder()\")\n\n if len(args) != 1 {\n return nil, errors.New(\"Incorrect number of arguments. Expecting (OrderId)\")\n }\n\n order, accessDenied, err := GetOrder(stub, callerDetails, args[0])\n\n if accessDenied {\n return ACCESS_DENIED_RESPONSE, nil\n }\n\n if err != nil {\n return NOT_FOUND_RESPONSE, nil\n }\n\n return marshall(order)\n}", "title": "" }, { "docid": "1c5e6e244626f4d2802495b26c1da1ea", "score": "0.47746202", "text": "func (h *Handler) GetBook(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tbookidString := ps.ByName(\"bookid\")\n\tbookID, err := strconv.ParseUint(bookidString, 10, 64)\n\tif err != nil {\n\t\th.handleError(w, errors.New(\"invalid bookid\"), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tbook, err := model.GetBookByID(h.db, bookID)\n\tswitch {\n\tcase err == model.ErrBookNotFound:\n\t\th.handleError(w, err, http.StatusNotFound)\n\t\treturn\n\tcase err != nil:\n\t\th.handleError(w, err, http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\th.handleSuccess(w, book)\n}", "title": "" }, { "docid": "3caf5bfc5de4cd5b573dad64a2589ac0", "score": "0.47682053", "text": "func GetSingleBook(c *fiber.Ctx) {\n\tid := c.Params(\"id\")\n\tdb := database.DBConn\n\tvar book Book\n\tdb.Find(&book, id)\n\tif book.Title == \"\" {\n\t\tc.Status(404).Send(\"No Book found at given Index\")\n\t\treturn\n\t}\n\tc.JSON(book)\n}", "title": "" }, { "docid": "742f4119b69e491b9699162ca95b3b17", "score": "0.47676882", "text": "func GetBook(w http.ResponseWriter, r *http.Request){\n\t\tvars := mux.Vars(r)\n\t\tfor _, item := range books {\n\t\t\tif item.ID == vars[\"Id\"] {\n\t\t\t\tjson.NewEncoder(w).Encode(item)\n\t\t\t\treturn\n\t\t}\n\t}\n\tjson.NewEncoder(w).Encode(&Book{})\n}", "title": "" }, { "docid": "a7191645b1e25fb03d8a5fa8c9614eba", "score": "0.476226", "text": "func GetExchangeRate(stub shim.ChaincodeStubInterface, erpsystem string, client string, exchangeratetype string, fromcurr string, tocurr string, effectivedate string) (ExchangeRate, string) {\r\n\tccRecord, _ := db.TableStruct{Stub: stub, TableName: util.TAB_EXCHANGERATE, PrimaryKeys: []string{erpsystem, client, exchangeratetype, fromcurr, tocurr, effectivedate}, Data: \"\"}.Get()\r\n\tvar exchangeRate ExchangeRate\r\n\terr := json.Unmarshal([]byte(ccRecord), &exchangeRate)\r\n\tif err != nil {\r\n\t\tmyLogger.Debugf(\"ERROR in parsing input exchange rate:\", err, ccRecord)\r\n\t\treturn exchangeRate, \"ERROR in parsing input exchage rate\"\r\n\t}\r\n\treturn exchangeRate, \"\"\r\n}", "title": "" }, { "docid": "eb04a046adf9a75d40201bde8b9b30cd", "score": "0.47419634", "text": "func (a *CurrenciesApiService) GetCurrency(ctx context.Context, code string) (CurrencyResource, *http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = strings.ToUpper(\"Get\")\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t \tsuccessPayload CurrencyResource\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/currencies/{code}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"code\"+\"}\", fmt.Sprintf(\"%v\", code), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{ }\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\n\t\t\"application/json\",\n\t\t}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn successPayload, nil, err\n\t}\n\n\t localVarHttpResponse, err := a.client.callAPI(r)\n\t if err != nil || localVarHttpResponse == nil {\n\t\t return successPayload, localVarHttpResponse, err\n\t }\n\t defer localVarHttpResponse.Body.Close()\n\t if localVarHttpResponse.StatusCode >= 300 {\n\t\treturn successPayload, localVarHttpResponse, reportError(localVarHttpResponse.Status)\n\t }\n\t\n\tif err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {\n\t \treturn successPayload, localVarHttpResponse, err\n\t}\n\n\n\treturn successPayload, localVarHttpResponse, err\n}", "title": "" }, { "docid": "b23ad483769642672ad66d139c1323fb", "score": "0.47384652", "text": "func (c *ExchangeApiController) GetExchangeTransaction(w http.ResponseWriter, r *http.Request) {\n\tparams := mux.Vars(r)\n\tquery := r.URL.Query()\n\texchangeId := params[\"exchangeId\"]\n\tmask, _ := strconv.ParseBool(query.Get(\"mask\"))\n\tenhance, _ := strconv.ParseBool(query.Get(\"enhance\"))\n\txTRACEID := r.Header.Get(\"X-TRACE-ID\")\n\txTOKEN := r.Header.Get(\"X-TOKEN\")\n\tresult, err := c.service.GetExchangeTransaction(r.Context(), exchangeId, mask, enhance, xTRACEID, xTOKEN)\n\t//If an error occured, encode the error with the status code\n\tif err != nil {\n\t\tEncodeJSONResponse(err.Error(), &result.Code, w)\n\t\treturn\n\t}\n\t//If no error, encode the body and the result code\n\tEncodeJSONResponse(result.Body, &result.Code, w)\n\n}", "title": "" }, { "docid": "6bb2336688203d3a3ab3195ca8edb61c", "score": "0.47368488", "text": "func (g *Gateio) GetOpenOrders(ctx context.Context, symbol string) (OpenOrdersResponse, error) {\n\tvar params string\n\tvar result OpenOrdersResponse\n\n\tif symbol != \"\" {\n\t\tparams = fmt.Sprintf(\"currencyPair=%s\", symbol)\n\t}\n\n\terr := g.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost, gateioOpenOrders, params, &result)\n\tif err != nil {\n\t\treturn result, err\n\t}\n\n\tif result.Code > 0 {\n\t\treturn result, fmt.Errorf(\"code:%d message:%s\", result.Code, result.Message)\n\t}\n\n\treturn result, nil\n}", "title": "" }, { "docid": "2c25440c79ecd9a8c0d9324ac9d55941", "score": "0.47319496", "text": "func (t *ManageAgreement) getAgreement_byBuyerBank(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) {\n\tvar jsonResp, bb_name, errResp string\n\tvar agreementIndex []string\n\tvar valIndex Agreement\n\tfmt.Println(\"start getAgreement_byBuyerBank\")\n\tvar err error\n\tif len(args) != 1 {\n\t\terrMsg := \"{ \\\"message\\\" : \\\"Incorrect number of arguments. Expecting \\\"Buyer_Bank_Name\\\" as an argument\\\", \\\"code\\\" : \\\"503\\\"}\"\n\t\terr = stub.SetEvent(\"errEvent\", []byte(errMsg))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t} \n\t\treturn nil, nil\n\t}\n\t// set Buyer Bank\n\tbb_name = args[0]\n\tfmt.Println(\"bb_name: \" + bb_name)\n\tagreementAsBytes, err := stub.GetState(AgreementIndexStr)\n\tif err != nil {\n\t\treturn nil, errors.New(\"Failed to get Agreement index\")\n\t}\n\tfmt.Print(\"agreementAsBytes : \")\n\tfmt.Println(agreementAsBytes)\n\tjson.Unmarshal(agreementAsBytes, &agreementIndex)\t\t\t\t\t\t\t\t//un stringify it aka JSON.parse()\n\tfmt.Print(\"agreementIndex : \")\n\tfmt.Println(agreementIndex)\n\tfmt.Println(\"len(agreementIndex) : \")\n\tfmt.Println(len(agreementIndex))\n\tjsonResp = \"{\"\n\tfor i,val := range agreementIndex{\n\t\tfmt.Println(strconv.Itoa(i) + \" - looking at \" + val + \" for getting sellerName\")\n\t\tvalueAsBytes, err := stub.GetState(val)\n\t\tif err != nil {\n\t\t\terrResp = \"{\\\"Error\\\":\\\"Failed to get state for \" + val + \"\\\"}\"\n\t\t\treturn nil, errors.New(errResp)\n\t\t}\n\t\tfmt.Print(\"valueAsBytes : \")\n\t\tfmt.Println(valueAsBytes)\n\t\tjson.Unmarshal(valueAsBytes, &valIndex)\n\t\tfmt.Print(\"valIndex: \")\n\t\tfmt.Print(valIndex)\n\t\tif valIndex.BB_name == bb_name{\n\t\t\tfmt.Println(\"Buyer Bank found\")\n\t\t\tjsonResp = jsonResp + \"\\\"\"+ val + \"\\\":\" + string(valueAsBytes[:])\n\t\t\tfmt.Println(\"jsonResp inside if\")\n\t\t\tfmt.Println(jsonResp)\n\t\t\tif i < len(agreementIndex)-1 {\n\t\t\t\tjsonResp = jsonResp + \",\"\n\t\t\t}\n\t\t}else{\n\t\t\terrMsg := \"{ \\\"message\\\" : \\\"\"+ bb_name + \" Not Found.\\\", \\\"code\\\" : \\\"503\\\"}\"\n\t\t\terr = stub.SetEvent(\"errEvent\", []byte(errMsg))\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} \n\t\t\treturn nil, nil\n\t\t}\n\t\t\n\t}\n\t\n\tjsonResp = jsonResp + \"}\"\n\tfmt.Println(\"jsonResp : \" + jsonResp)\n\tfmt.Print(\"jsonResp in bytes : \")\n\tfmt.Println([]byte(jsonResp))\n\tfmt.Println(\"end getAgreement_byBuyerBank\")\n\treturn []byte(jsonResp), nil\t\t\t\t\t\t\t\t\t\t\t//send it onward\n}", "title": "" }, { "docid": "49f49b444ed609020f432ca43aee9b79", "score": "0.47302005", "text": "func (p *Huobi) GetOrderInfo(filter OrderInfo) []OrderInfo {\n\tvar path string\n\tif p.InstrumentType == InstrumentTypeSpot {\n\t\tpath = \"/v1/order/orders/\" + filter.OrderID\n\n\t\tif err, response := p.orderRequest(\"GET\", path, map[string]string{}); err != nil {\n\t\t\tlogger.Errorf(\"Fail to trade:%v\", err)\n\t\t\treturn nil\n\t\t} else {\n\t\t\tif response[\"status\"] != nil {\n\t\t\t\tif response[\"status\"].(string) == \"ok\" {\n\n\t\t\t\t\tvalues := response[\"data\"].(map[string]interface{})\n\t\t\t\t\tresult := make([]OrderInfo, 1)\n\n\t\t\t\t\torderType := values[\"type\"].(string)\n\t\t\t\t\tplacePrice, _ := strconv.ParseFloat(values[\"price\"].(string), 64)\n\t\t\t\t\tamount, _ := strconv.ParseFloat(values[\"field-cash-amount\"].(string), 64)\n\t\t\t\t\tdealAmount, _ := strconv.ParseFloat(values[\"field-amount\"].(string), 64)\n\t\t\t\t\tavgPrice := amount / dealAmount\n\t\t\t\t\tstatus := values[\"state\"].(string)\n\n\t\t\t\t\titem := OrderInfo{\n\t\t\t\t\t\tPair: values[\"symbol\"].(string),\n\t\t\t\t\t\tOrderID: filter.OrderID,\n\t\t\t\t\t\tPrice: placePrice,\n\t\t\t\t\t\tAmount: amount,\n\t\t\t\t\t\tType: p.GetTradeType(orderType),\n\t\t\t\t\t\tStatus: p.GetOrderStatus(status),\n\t\t\t\t\t\tDealAmount: dealAmount,\n\t\t\t\t\t\tAvgPrice: avgPrice,\n\t\t\t\t\t}\n\n\t\t\t\t\tresult[0] = item\n\n\t\t\t\t\treturn result\n\t\t\t\t} else {\n\t\t\t\t\tlogger.Errorf(\"Fail to get order info:%v\", response[\"err-msg\"].(string))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if p.InstrumentType == InstrumentTypeSwap {\n\n\t\tpath = \"/api/v1/contract_order_info\"\n\n\t\tcoins := ParsePair(filter.Pair)\n\t\tinstrument := strings.ToUpper(coins[0])\n\n\t\tif err, response := p.orderRequest(\"POST\", path, map[string]string{\n\t\t\t\"symbol\": instrument,\n\t\t\t\"order_id\": filter.OrderID,\n\t\t}); err != nil {\n\t\t\tlogger.Errorf(\"Fail to trade:%v\", err)\n\t\t\treturn nil\n\t\t} else {\n\t\t\tif response[\"status\"] != nil {\n\t\t\t\tif response[\"status\"].(string) == \"ok\" {\n\n\t\t\t\t\tvalues := response[\"data\"].([]interface{})[0].(map[string]interface{})\n\t\t\t\t\tresult := make([]OrderInfo, 1)\n\n\t\t\t\t\tstatus := p.GetDMOrderStatus(int(values[\"status\"].(float64)))\n\t\t\t\t\tif status == OrderStatusDone {\n\t\t\t\t\t\tdirection := values[\"direction\"].(string)\n\t\t\t\t\t\toffset := values[\"offset\"].(string)\n\t\t\t\t\t\tplacePrice := values[\"price\"].(float64)\n\t\t\t\t\t\tamount := values[\"volume\"].(float64)\n\t\t\t\t\t\tdealAmount := values[\"trade_volume\"].(float64)\n\t\t\t\t\t\tavgPrice := values[\"trade_avg_price\"].(float64)\n\n\t\t\t\t\t\titem := OrderInfo{\n\t\t\t\t\t\t\tPair: values[\"symbol\"].(string),\n\t\t\t\t\t\t\tOrderID: filter.OrderID,\n\t\t\t\t\t\t\tPrice: placePrice,\n\t\t\t\t\t\t\tAmount: amount,\n\t\t\t\t\t\t\tType: p.GetDMTradeType(direction, offset),\n\t\t\t\t\t\t\tStatus: status,\n\t\t\t\t\t\t\tDealAmount: dealAmount,\n\t\t\t\t\t\t\tAvgPrice: avgPrice,\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tresult[0] = item\n\n\t\t\t\t\t\treturn result\n\t\t\t\t\t} else {\n\t\t\t\t\t\titem := OrderInfo{\n\t\t\t\t\t\t\tPair: values[\"symbol\"].(string),\n\t\t\t\t\t\t\tOrderID: filter.OrderID,\n\t\t\t\t\t\t\tStatus: status,\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tresult[0] = item\n\n\t\t\t\t\t\treturn result\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\t\t\t\t\tlogger.Errorf(\"Fail to get order info:%v\", response[\"err-msg\"].(string))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "b164b9253278cfbbb4ad079adcca0562", "score": "0.4725725", "text": "func (o *Orderbooks) ProcessOrderbook(_ string, p pair.CurrencyPair, orderbookNew Base, orderbookType string) {\n\to.m.Lock()\n\tdefer o.m.Unlock()\n\n\t// Use a single currency pair format internally regardless of the format used by the exchange/config.\n\tfp := o.formatCurrencyPair(p)\n\n\torderbookNew.CurrencyPair = fp.Pair().String()\n\torderbookNew.LastUpdated = time.Now()\n\n\tif o.FirstCurrencyExists(fp.GetFirstCurrency()) {\n\t\tif !o.SecondCurrencyExists(fp) {\n\t\t\tb := make(map[string]Base)\n\t\t\tb[orderbookType] = orderbookNew\n\t\t\to.orderbooks[fp.FirstCurrency][fp.SecondCurrency] = b\n\t\t\treturn\n\t\t} else {\n\t\t\to.orderbooks[fp.FirstCurrency][fp.SecondCurrency][orderbookType] = orderbookNew\n\t\t\treturn\n\t\t}\n\t}\n\n\ta := make(map[pair.CurrencyItem]map[string]Base)\n\tb := make(map[string]Base)\n\tb[orderbookType] = orderbookNew\n\ta[fp.SecondCurrency] = b\n\to.orderbooks[fp.FirstCurrency] = a\n}", "title": "" }, { "docid": "4d83017708923232f2de3d0bb28b50ed", "score": "0.47187003", "text": "func getBooks(w http.ResponseWriter, r *http.Request) {\n\t// set header\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t// response with all the books\n\tjson.NewEncoder(w).Encode(books)\n}", "title": "" } ]
3f783429e7ed8b5d6bef2ed115afa9bb
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PoolSpec.
[ { "docid": "4ae4bda1ed8133a568aa0ab5a5f9d382", "score": "0.87467456", "text": "func (in *PoolSpec) DeepCopy() *PoolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PoolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" } ]
[ { "docid": "f02556f9fbbf3db9c36ab656bab51fac", "score": "0.76605666", "text": "func (in *IPPoolSpec) DeepCopy() *IPPoolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(IPPoolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "f02556f9fbbf3db9c36ab656bab51fac", "score": "0.76605666", "text": "func (in *IPPoolSpec) DeepCopy() *IPPoolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(IPPoolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "f02556f9fbbf3db9c36ab656bab51fac", "score": "0.76605666", "text": "func (in *IPPoolSpec) DeepCopy() *IPPoolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(IPPoolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "a42c718d822ccecf81599f8fd35e968e", "score": "0.7655722", "text": "func (in *NetworkPoolSpec) DeepCopy() *NetworkPoolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(NetworkPoolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "c4da8b93e47f6f2dec98ba916d328c3e", "score": "0.72770596", "text": "func (in *BCSNetPoolSpec) DeepCopy() *BCSNetPoolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(BCSNetPoolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "564beb502acbf53118a9d72ad45d6d00", "score": "0.72502166", "text": "func (in *NodePoolSpec) DeepCopy() *NodePoolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(NodePoolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "564beb502acbf53118a9d72ad45d6d00", "score": "0.72502166", "text": "func (in *NodePoolSpec) DeepCopy() *NodePoolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(NodePoolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "564beb502acbf53118a9d72ad45d6d00", "score": "0.72502166", "text": "func (in *NodePoolSpec) DeepCopy() *NodePoolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(NodePoolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "a64f96923c2128ac5c411a039793cfa9", "score": "0.7056315", "text": "func (in *CiliumLoadBalancerIPPoolSpec) DeepCopy() *CiliumLoadBalancerIPPoolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CiliumLoadBalancerIPPoolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "fff59f5b568b242b3d145501730e7c79", "score": "0.695214", "text": "func (in *IdentityPoolSpec) DeepCopy() *IdentityPoolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(IdentityPoolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "af7a8830d26a9b97e7ee4dda49188e6e", "score": "0.67814463", "text": "func (in *Pool) DeepCopy() *Pool {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(Pool)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "30c5d0ea883f5106e5d4ddb3aee2d7b4", "score": "0.66014194", "text": "func (in *IPv4PoolSpec) DeepCopy() *IPv4PoolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(IPv4PoolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "046ffe8a1453e35d28ec81ff57f0a261", "score": "0.6185618", "text": "func (in *MachineConfigPoolSpec) DeepCopy() *MachineConfigPoolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(MachineConfigPoolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "71fa6c786199606fadead16b359a8267", "score": "0.6091197", "text": "func (in *AWSMachineDeploymentSpecNodePool) DeepCopy() *AWSMachineDeploymentSpecNodePool {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(AWSMachineDeploymentSpecNodePool)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "cdc71676cce2f84079641cc4f5e03adc", "score": "0.5942874", "text": "func (in *ProxySpec) DeepCopy() *ProxySpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ProxySpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "cb6162d4439b22a697fdd06745650b30", "score": "0.59173197", "text": "func (in *Spec) DeepCopy() *Spec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(Spec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "53cf642f4d6de559ac9dc96ebd677283", "score": "0.5854499", "text": "func (in *SriovNetworkPoolConfigSpec) DeepCopy() *SriovNetworkPoolConfigSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(SriovNetworkPoolConfigSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "c415e033237a870ce9d61ed9d52b4f91", "score": "0.5792407", "text": "func (in *IPv6PoolSpec) DeepCopy() *IPv6PoolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(IPv6PoolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "e23601688ba5147d0e7888e058b265b5", "score": "0.5789427", "text": "func (in *BCSNetIPSpec) DeepCopy() *BCSNetIPSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(BCSNetIPSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5e4f03cf7eef52a65f1adf0390404960", "score": "0.57693404", "text": "func (in *PodSpec) DeepCopy() *PodSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PodSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5e4f03cf7eef52a65f1adf0390404960", "score": "0.57693404", "text": "func (in *PodSpec) DeepCopy() *PodSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PodSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5e4f03cf7eef52a65f1adf0390404960", "score": "0.57693404", "text": "func (in *PodSpec) DeepCopy() *PodSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PodSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "3119c86b64080924774d2010768212e7", "score": "0.57211065", "text": "func (in *IPInstanceSpec) DeepCopy() *IPInstanceSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(IPInstanceSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "f256b2b0d3dc7c300fc909130c071f61", "score": "0.57166034", "text": "func (in *InstancePool) DeepCopy() *InstancePool {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(InstancePool)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "3f45a0fb19ae83cdc57b2310aedcdb59", "score": "0.56813025", "text": "func (in *BindingSpec) DeepCopy() *BindingSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(BindingSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "3f45a0fb19ae83cdc57b2310aedcdb59", "score": "0.56813025", "text": "func (in *BindingSpec) DeepCopy() *BindingSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(BindingSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5e24dc46cdde83271f1206446abeda56", "score": "0.5652401", "text": "func (in *VPNConnectionSpec) DeepCopy() *VPNConnectionSpec {\n\tif in == nil { return nil }\n\tout := new(VPNConnectionSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "642cc24a92cc265543c36c99c84dc690", "score": "0.5649628", "text": "func (in *PDSpec) DeepCopy() *PDSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PDSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "642cc24a92cc265543c36c99c84dc690", "score": "0.5649628", "text": "func (in *PDSpec) DeepCopy() *PDSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PDSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "0a8ec97e9635ea8334f133e267419797", "score": "0.56453115", "text": "func (in *NginxSpec) DeepCopy() *NginxSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(NginxSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "b92b947035eeca4da72ef89885a1dbb8", "score": "0.56432146", "text": "func (in *PolicyBindingSpec) DeepCopy() *PolicyBindingSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PolicyBindingSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "8780148f2d298e3978f2eeddcfa167ab", "score": "0.55819154", "text": "func (in *MockSpec) DeepCopy() *MockSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(MockSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "fd260b58fd99946b92f519596cc60e4c", "score": "0.55800575", "text": "func (in *NodePool) DeepCopy() *NodePool {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(NodePool)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "fd260b58fd99946b92f519596cc60e4c", "score": "0.55800575", "text": "func (in *NodePool) DeepCopy() *NodePool {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(NodePool)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "fd260b58fd99946b92f519596cc60e4c", "score": "0.55800575", "text": "func (in *NodePool) DeepCopy() *NodePool {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(NodePool)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "e0b46bbdbf8fc7087f19d0b41b0fd10b", "score": "0.55775875", "text": "func (pool *ManagedClustersAgentPool) GetSpec() genruntime.ConvertibleSpec {\n\treturn &pool.Spec\n}", "title": "" }, { "docid": "535302be8107cecfc39eb9a9ffa530dc", "score": "0.55735695", "text": "func (in *PublishingStrategySpec) DeepCopy() *PublishingStrategySpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PublishingStrategySpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "314172ac670362c21ae3fc9addc4c7b1", "score": "0.55694133", "text": "func (in *PackageSpec) DeepCopy() *PackageSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PackageSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5e2e8d61eebf71417263602283201f1d", "score": "0.556606", "text": "func (in *PolicySpec) DeepCopy() *PolicySpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PolicySpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5e2e8d61eebf71417263602283201f1d", "score": "0.556606", "text": "func (in *PolicySpec) DeepCopy() *PolicySpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PolicySpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5e2e8d61eebf71417263602283201f1d", "score": "0.556606", "text": "func (in *PolicySpec) DeepCopy() *PolicySpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PolicySpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "949a44f06f8dd501b866b07e5567a461", "score": "0.5550647", "text": "func (in *NetworkPool) DeepCopy() *NetworkPool {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(NetworkPool)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "d1d3d98b1866db43bc8d000827aa03f4", "score": "0.55388254", "text": "func (in *WorkloadsSpec) DeepCopy() *WorkloadsSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(WorkloadsSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "3947eac9cd908ab5102762b651b945a2", "score": "0.5520272", "text": "func (in *RateLimitConfSpec) DeepCopy() *RateLimitConfSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(RateLimitConfSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "b8419c366e84bd16a86f09577b4e462c", "score": "0.55171394", "text": "func (in *PortSpec) DeepCopy() *PortSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PortSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "b8419c366e84bd16a86f09577b4e462c", "score": "0.55171394", "text": "func (in *PortSpec) DeepCopy() *PortSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PortSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "ebf4cfc0ae0a38e31a8f51dfc4e5025a", "score": "0.55074716", "text": "func (in *MongoDBSpec) DeepCopy() *MongoDBSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(MongoDBSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "ebf4cfc0ae0a38e31a8f51dfc4e5025a", "score": "0.55074716", "text": "func (in *MongoDBSpec) DeepCopy() *MongoDBSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(MongoDBSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "0df3d24da7e5e2f760b461a005b005d1", "score": "0.5500338", "text": "func (in *RateLimitSpec) DeepCopy() *RateLimitSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(RateLimitSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "8818b76f64ce7a44f2285cf193edb138", "score": "0.5486527", "text": "func (in *K8sResourceClonerSpec) DeepCopy() *K8sResourceClonerSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(K8sResourceClonerSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "88e785b0e76bc8709e2578d455923981", "score": "0.54849607", "text": "func (in *CertificateSpec) DeepCopy() *CertificateSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CertificateSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "88e785b0e76bc8709e2578d455923981", "score": "0.54849607", "text": "func (in *CertificateSpec) DeepCopy() *CertificateSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CertificateSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "88e785b0e76bc8709e2578d455923981", "score": "0.54849607", "text": "func (in *CertificateSpec) DeepCopy() *CertificateSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CertificateSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "e663e7ac6f6d857f114e37e701228006", "score": "0.5476559", "text": "func (in *BCSNetPool) DeepCopy() *BCSNetPool {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(BCSNetPool)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "414a5943f66c63d15ba793b7dde2f87e", "score": "0.54562014", "text": "func (in *TunedSpec) DeepCopy() *TunedSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(TunedSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "531821bb541edb531cd58012b1fec5c6", "score": "0.54249865", "text": "func (in *SecurityPolicySpec) DeepCopy() *SecurityPolicySpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(SecurityPolicySpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "f914e47a3080b4b95eaaf3b91143d07b", "score": "0.5418038", "text": "func (in *CertificatePolicySpec) DeepCopy() *CertificatePolicySpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CertificatePolicySpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5376b76eac066c6a23ccebb15a7c0b48", "score": "0.54088384", "text": "func (in *NodeLivenessSpec) DeepCopy() *NodeLivenessSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(NodeLivenessSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "2312db0ee6559463efbf89fd11717a60", "score": "0.53862864", "text": "func (in *VPNGatewaySpec) DeepCopy() *VPNGatewaySpec {\n\tif in == nil { return nil }\n\tout := new(VPNGatewaySpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "58880aef96e58015fe4415a771a49e20", "score": "0.5373767", "text": "func (in *IPPool) DeepCopy() *IPPool {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(IPPool)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "58880aef96e58015fe4415a771a49e20", "score": "0.5373767", "text": "func (in *IPPool) DeepCopy() *IPPool {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(IPPool)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "ce501bd7b36ed34984c887635888cc08", "score": "0.53723294", "text": "func (in *NginxResourceSpec) DeepCopy() *NginxResourceSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(NginxResourceSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "b5a9ade9392123281ef05a9bfe684a6f", "score": "0.53538543", "text": "func (in *VPCLinkSpec) DeepCopy() *VPCLinkSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(VPCLinkSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "b3640337b72746cbd617a6f8fea77efb", "score": "0.5346181", "text": "func (in *GraphdSpec) DeepCopy() *GraphdSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(GraphdSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "bb4adbb850a3658e63b54607a9e7a09b", "score": "0.53416663", "text": "func (in *InstanceSpec) DeepCopy() *InstanceSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(InstanceSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "983ee64ea6eccc9ae94aba6844a00494", "score": "0.53363186", "text": "func (in *RangeSpec) DeepCopy() *RangeSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(RangeSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "a52db23baf73c9fd3a9c835cc7087f79", "score": "0.5331926", "text": "func (in *IPAMPoolSpec) DeepCopy() *IPAMPoolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(IPAMPoolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "b5836f19c3310dcbdd2540f8dff506ff", "score": "0.53317827", "text": "func (in *VMTemplateSpec) DeepCopy() *VMTemplateSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(VMTemplateSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "300ecb334f561260b834088935388521", "score": "0.5327779", "text": "func (in *SubnetSpec) DeepCopy() *SubnetSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(SubnetSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "34d1a9eeefb65b61089e1d725c606db0", "score": "0.53276044", "text": "func (in *ConsulSpec) DeepCopy() *ConsulSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ConsulSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "44434d4153932fd04b01a46c49222529", "score": "0.53251207", "text": "func (in *DomainNameSpec) DeepCopy() *DomainNameSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(DomainNameSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "811d8cff75e6172ebf32908efa99af4c", "score": "0.5323354", "text": "func (in *PoolConfig) DeepCopy() *PoolConfig {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PoolConfig)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "a75a914eaaa0302af3e2647cc88b8eae", "score": "0.53153205", "text": "func (in *ResourcesSpec) DeepCopy() *ResourcesSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ResourcesSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "3ebc6a58d4a86206ad53f5d821f7bf73", "score": "0.5314112", "text": "func (in *ScalingToolSpec) DeepCopy() *ScalingToolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ScalingToolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "3ebc6a58d4a86206ad53f5d821f7bf73", "score": "0.5314112", "text": "func (in *ScalingToolSpec) DeepCopy() *ScalingToolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ScalingToolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "3ebc6a58d4a86206ad53f5d821f7bf73", "score": "0.5314112", "text": "func (in *ScalingToolSpec) DeepCopy() *ScalingToolSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ScalingToolSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "bb6923a9a89d397a1412faece3c2044a", "score": "0.5310042", "text": "func (in *VirtualMachineInstanceTemplateSpec) DeepCopy() *VirtualMachineInstanceTemplateSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(VirtualMachineInstanceTemplateSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "aeccaeb3d7a3b22a76e8c8fa92afe6b8", "score": "0.52984023", "text": "func (in *MirrorSpec) DeepCopy() *MirrorSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(MirrorSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "7614ee7772de9d378a6222aebcc46224", "score": "0.5295895", "text": "func (in *PingSourceSpec) DeepCopy() *PingSourceSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PingSourceSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "c77e048b2d2cfaa86c23291e93427b40", "score": "0.52925146", "text": "func (in *PoolBackend) DeepCopy() *PoolBackend {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PoolBackend)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "160cb8ac169343dee9c365d24e305d29", "score": "0.52906775", "text": "func (in *TemplateInstanceSpec) DeepCopy() *TemplateInstanceSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(TemplateInstanceSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "66c245f553f25c030b4225f7a36ec08b", "score": "0.528987", "text": "func (in *RateLimitDefinitionSpec) DeepCopy() *RateLimitDefinitionSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(RateLimitDefinitionSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "75b45d508444299c9da6552026a0bbf5", "score": "0.5283845", "text": "func (in *ServingSpec) DeepCopy() *ServingSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ServingSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "c22ccef3de6f2599466e122d58f23794", "score": "0.5276396", "text": "func (c *virtualMachinePools) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.VirtualMachinePool, err error) {\n\tresult = &v1alpha1.VirtualMachinePool{}\n\terr = c.client.Patch(pt).\n\t\tNamespace(c.ns).\n\t\tResource(\"virtualmachinepools\").\n\t\tName(name).\n\t\tSubResource(subresources...).\n\t\tVersionedParams(&opts, scheme.ParameterCodec).\n\t\tBody(data).\n\t\tDo(ctx).\n\t\tInto(result)\n\treturn\n}", "title": "" }, { "docid": "099777fba3b33913deafb23244df8316", "score": "0.5271363", "text": "func (in *NetworkSpec) DeepCopy() *NetworkSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(NetworkSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "099777fba3b33913deafb23244df8316", "score": "0.5271363", "text": "func (in *NetworkSpec) DeepCopy() *NetworkSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(NetworkSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "099777fba3b33913deafb23244df8316", "score": "0.5271363", "text": "func (in *NetworkSpec) DeepCopy() *NetworkSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(NetworkSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "099777fba3b33913deafb23244df8316", "score": "0.5271363", "text": "func (in *NetworkSpec) DeepCopy() *NetworkSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(NetworkSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "3feee29c4c7abf4f43ad16b62f677485", "score": "0.5270698", "text": "func (in *DBClusterParameterGroupSpec) DeepCopy() *DBClusterParameterGroupSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(DBClusterParameterGroupSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "3c7b0d1a29c3c12adeb22bfdf47943da", "score": "0.52619267", "text": "func (in *SubnetSpec) DeepCopy() *SubnetSpec {\n\tif in == nil { return nil }\n\tout := new(SubnetSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "120b333e8c68bba37dcf469cd5b7963c", "score": "0.5253294", "text": "func (in *TemplateSpec) DeepCopy() *TemplateSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(TemplateSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "120b333e8c68bba37dcf469cd5b7963c", "score": "0.5253294", "text": "func (in *TemplateSpec) DeepCopy() *TemplateSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(TemplateSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "749b5c3d6d003f3a191bdb29a4562129", "score": "0.5248807", "text": "func (in *DataSourceSpec) DeepCopy() *DataSourceSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(DataSourceSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "218a72b788f4c748d5470aae63e9c9a3", "score": "0.524615", "text": "func (in *ServiceLevelObjectiveSpec) DeepCopy() *ServiceLevelObjectiveSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ServiceLevelObjectiveSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "24b607e3af0e7a8c1f78bb92c038c5f6", "score": "0.52442014", "text": "func (in *PresetSpec) DeepCopy() *PresetSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PresetSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "0da1d00f6e248f583af04de826144ab8", "score": "0.524117", "text": "func (in *RateLimitDescriptorConfigSpec) DeepCopy() *RateLimitDescriptorConfigSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(RateLimitDescriptorConfigSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "9dc9bf6df587aeb0b635a2c227eb30ac", "score": "0.5226893", "text": "func (in *ClusterPolicySpec) DeepCopy() *ClusterPolicySpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterPolicySpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "f36318a1cdc99a9a52b94fb0af560842", "score": "0.52245164", "text": "func (in *DBSubnetGroupSpec) DeepCopy() *DBSubnetGroupSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(DBSubnetGroupSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "39c90635b7663569d50c0476e2183be1", "score": "0.5222663", "text": "func (in PlacementSpec) DeepCopy() PlacementSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(PlacementSpec)\n\tin.DeepCopyInto(out)\n\treturn *out\n}", "title": "" }, { "docid": "f558451c1b1f9729d969aab51d32e045", "score": "0.52200013", "text": "func (in *DataLoadSpec) DeepCopy() *DataLoadSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(DataLoadSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" } ]
f68d8a37cb1924fc4bf6fef8515ba0a3
Executed returns a map, keyed by the template or copy file path, of bytes.Buffer objects containing executed template or copied file contents
[ { "docid": "052d5cedca683ead029f6f9b9d4916de", "score": "0.5667126", "text": "func (ts *TemplateSet) Executed() map[string]*bytes.Buffer {\n\treturn ts.executed\n}", "title": "" } ]
[ { "docid": "8f3226161cd3db8b12f54e6f47c062a7", "score": "0.65362734", "text": "func (ts *TemplateSet) Execute() error {\n\tfor path, tv := range ts.templates {\n\t\tvar b bytes.Buffer\n\t\tif err := tv.t.Execute(&b, tv.v); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tts.executed[path] = &b\n\t}\n\tfor _, path := range ts.copyPaths {\n\t\tb, err := byteBufferFromFile(path)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tts.executed[path] = b\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "34d6a820318326aa3f17a41d2214fbd0", "score": "0.62148327", "text": "func execTemplateFile(path string, data interface{}) ([]byte, error) {\n\ttmpl, err := newTemplate(filepath.Base(path)).ParseFiles(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn execTemplate(tmpl, data)\n}", "title": "" }, { "docid": "82a0683d5064bcee160f47419cfc3b7d", "score": "0.5940559", "text": "func (t *Template) ExecuteBytes(m map[string]interface{}) []byte {\n\treturn t.ExecuteFuncBytes(func(w io.Writer, tag string) error {\n\t\treturn stdTagFunc(w, tag, m)\n\t})\n}", "title": "" }, { "docid": "563529dcc78cdecdf092c7ff70c1f1be", "score": "0.5894356", "text": "func execTemplate(tmpl *template.Template, data interface{}) ([]byte, error) {\n\tvar buf bytes.Buffer\n\tif err := tmpl.Execute(&buf, data); err != nil {\n\t\treturn nil, err\n\t}\n\treturn buf.Bytes(), nil\n}", "title": "" }, { "docid": "0961613141c786d407f6394e4c5e99cd", "score": "0.5778435", "text": "func executeTemplate(data interface{}, outputPath string) (err error) {\n\t// Create output\n\tastilog.Debugf(\"Creating %s\", outputPath)\n\tvar f *os.File\n\tif f, err = os.Create(outputPath); err != nil {\n\t\terr = errors.Wrapf(err, \"creating %s failed\", outputPath)\n\t\treturn\n\t}\n\tdefer f.Close()\n\n\t// Execute template\n\tastilog.Debug(\"Executing template\")\n\tif err = t.ExecuteTemplate(f, \"/shared.tmpl\", data); err != nil {\n\t\terr = errors.Wrap(err, \"executing template failed\")\n\t\treturn\n\t}\n\treturn\n}", "title": "" }, { "docid": "143e20b0cd51e6d20b0a6cbdaa266bb1", "score": "0.57254744", "text": "func ExecuteTemplate(templateFile string, data interface{}) string {\n\n\tb, err := ioutil.ReadFile(templateFile)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfile := string(b)\n\n\treturn ExecuteTemplateData(file, data)\n}", "title": "" }, { "docid": "7e936e6788a70759edc1be6ac52d790e", "score": "0.57115585", "text": "func (t *Template) Execute(wr io.Writer, data interface{}) error {}", "title": "" }, { "docid": "5d0e725b25f38098c72b50a63d6fd2df", "score": "0.56496304", "text": "func (t *Template) ExecuteTemplate(wr io.Writer, name string, data interface{}) error {}", "title": "" }, { "docid": "fd728c1efc0c52380ed77842cf5bbb60", "score": "0.5577587", "text": "func (c *Template) Execute() ([]byte, error) {\n\tvar buffer bytes.Buffer\n\tif err := c.Template.Execute(&buffer, c.Env); err != nil {\n\t\treturn nil, err\n\t}\n\treturn buffer.Bytes(), nil\n}", "title": "" }, { "docid": "7ca1b8e58935d6ec4a2e51597db72a2c", "score": "0.55544895", "text": "func runTemplate(w http.ResponseWriter, r *http.Request, name string) {\n\tbuf := new(bytes.Buffer)\n\tT(name).Execute(buf, nil) // TODO add correct data here\n\tbuf.WriteTo(w)\n}", "title": "" }, { "docid": "494c998adeb978a80e03e1afaa9e0f05", "score": "0.5537536", "text": "func (r *Render) Run() {\n\tfor tmpl := range r.Template {\n\t\thash := hash(tmpl)\n\t\tinstance, ok := templates[hash]\n\t\tif !ok {\n\t\t\tif parsed, err := template.New(hash).Parse(tmpl); err != nil {\n\t\t\t\tr.Error <- err.Error()\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\ttemplates[hash] = parsed\n\t\t\t\tinstance = parsed\n\t\t\t}\n\t\t}\n\n\t\tdata := <-r.Data\n\t\twriter := &bytes.Buffer{}\n\t\tif err := instance.Execute(writer, data); err != nil {\n\t\t\tr.Error <- err.Error()\n\t\t} else {\n\t\t\tr.Output <- writer.String()\n\t\t}\n\t}\n}", "title": "" }, { "docid": "2f3880a966ae40a714aca63870db613e", "score": "0.55354816", "text": "func executeTemplate(t *template.Template, name string, data *templateData) ([]byte, error) {\n\tvar buf bytes.Buffer\n\tif err := t.ExecuteTemplate(&buf, name, data); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to execute template\")\n\t}\n\n\toutput, err := format.Source(buf.Bytes())\n\tif err != nil {\n\t\tmatches := rgxSyntaxError.FindStringSubmatch(err.Error())\n\t\tif matches == nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to format template\")\n\t\t}\n\n\t\tlineNum, _ := strconv.Atoi(matches[1])\n\t\tscanner := bufio.NewScanner(&buf)\n\t\terrBuf := &bytes.Buffer{}\n\t\tline := 0\n\t\tfor ; scanner.Scan(); line++ {\n\t\t\tif delta := line - lineNum; delta < -5 || delta > 5 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif line == lineNum {\n\t\t\t\terrBuf.WriteString(\">>> \")\n\t\t\t} else {\n\t\t\t\tfmt.Fprintf(errBuf, \"% 3d \", line)\n\t\t\t}\n\t\t\terrBuf.Write(scanner.Bytes())\n\t\t\terrBuf.WriteByte('\\n')\n\t\t}\n\n\t\treturn nil, errors.Wrapf(err, \"failed to format template\\n\\n%s\\n\", errBuf.Bytes())\n\t}\n\n\treturn output, nil\n}", "title": "" }, { "docid": "dd77b2d6b22af8dae14a659413efaa82", "score": "0.5527421", "text": "func (t *Template) Execute(wr io.Writer, data interface{}) os.Error {\n\treturn t.ExecuteInSet(wr, data, nil)\n}", "title": "" }, { "docid": "a4fc8fc1b1e432bfa4e3f6cc8ae729d7", "score": "0.5510576", "text": "func (t *Template) Execute(w io.Writer, m map[string]interface{}) error {\n\treturn t.ExecuteFunc(w, func(w io.Writer, tag string) error {\n\t\treturn stdTagFunc(w, tag, m)\n\t})\n}", "title": "" }, { "docid": "752d7d95e15a3edf638fc86fd4355df5", "score": "0.550459", "text": "func (c *TemplateCommand) RunTemplate(s *ShellSession) []string {\n\t_, result := s.Run(strings.Join(c.TemplateCommand, \"\\n\") + \"\\n\")\n\tc.Template = strings.Split(result, \"\\n\")\n\treturn c.Template\n}", "title": "" }, { "docid": "33f0c2e8080189cc6ad92f3e59e2390e", "score": "0.5468197", "text": "func (ft *FileTemplate) Process(ns *string, r *Resource) error {\n\n\tp := r.Prefix + \"/\" + ft.Path\n\tabs, err := filepath.Abs(p)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Copy file to tmpdir\n\terr = copy(abs, r.Output+\"/\"+string(r.Action))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "32956ca4c35abf3fccb7c39162def002", "score": "0.5439385", "text": "func ExecuteTemplate(s string) (string, error) {\n\ttmpl, err := template.New(\"cache key\").Funcs(funcMap).Parse(s)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid cache key: %s\", err)\n\t}\n\n\tbuf := new(bytes.Buffer)\n\ttemplateData := templateData{\n\t\tEnvironment: environ(),\n\t}\n\terr = tmpl.Execute(buf, templateData)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid cache key: %s\", err)\n\t}\n\n\treturn buf.String(), nil\n}", "title": "" }, { "docid": "9dd0178c25dd6adb5db358f7a0920d50", "score": "0.5408197", "text": "func (_m *ITemplate) ExecuteOnFile(sourcePath string, targetPath string, translation interface{}) {\n\t_m.Called(sourcePath, targetPath, translation)\n}", "title": "" }, { "docid": "80d09687076ebb86a3852532051e0ed9", "score": "0.5388649", "text": "func (t *Template) Execute(w io.Writer, data M) error {\n\tfinal := M{}\n\tfor k, v := range t.data {\n\t\tfinal[k] = v\n\t}\n\tif data != nil {\n\t\tfor k, v := range data {\n\t\t\tfinal[k] = v\n\t\t}\n\t}\n\treturn t.tpl.Execute(w, final)\n}", "title": "" }, { "docid": "88caec0a47d712e8ea42aa380f2c50f1", "score": "0.5387269", "text": "func Template(name string) ([]byte, error) {\n\treturn getFileContent(name)\n}", "title": "" }, { "docid": "88caec0a47d712e8ea42aa380f2c50f1", "score": "0.5387269", "text": "func Template(name string) ([]byte, error) {\n\treturn getFileContent(name)\n}", "title": "" }, { "docid": "fd7ee360ba919bde2e5cde1cbf969bc0", "score": "0.538465", "text": "func (b *Builder) compileTemplate(ctx *Context, file string, viewData map[string]interface{}, destFile string) error {\n\tos.MkdirAll(path.Dir(destFile), os.ModePerm)\n\tf, err := os.OpenFile(destFile, os.O_CREATE|os.O_TRUNC|os.O_RDWR, os.ModePerm)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\tif err := ctx.Theme.Execute(f, file, viewData); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "6fe5387565567100bf37d3b5ac539a0f", "score": "0.53698653", "text": "func ExecuteTemplateFile(filename string, data interface{}) string {\n\n\ttemplates := os.Getenv(\"OPERATOR_TEMPLATES\")\n\tfilepath := \"\"\n\tif templates == \"\" {\n\t\t// support local testing with 'up local'\n\t\t_, basefile, _, _ := runtime.Caller(1)\n\t\tfilepath = path.Join(path.Dir(basefile), \"../../templates/\"+filename)\n\t} else {\n\t\t// deployed as a container\n\t\tfilepath = path.Join(templates + filename)\n\t}\n\n\tb, err := ioutil.ReadFile(filepath)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfile := string(b)\n\tvar buff bytes.Buffer\n\ttmpl, err := template.New(\"tmp\").Parse(file)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\terr = tmpl.Execute(&buff, data)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn buff.String()\n}", "title": "" }, { "docid": "944856c591d69b3210122032488b40b1", "score": "0.5365055", "text": "func (s *Server) executeTemplate(w http.ResponseWriter, data interface{}, withLayout bool, fileNames ...string) {\n\ttplRoot := s.StaticFileDir + \"/tpls\"\n\tvar files []string\n\tif withLayout {\n\t\tfiles = append(files, tplRoot+\"/layout.gohtml\")\n\t}\n\tfor _, file := range fileNames {\n\t\tfiles = append(files, tplRoot+\"/\"+file+\".gohtml\")\n\t}\n\n\terr := template.Must(template.ParseFiles(files...)).Execute(w, data)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n}", "title": "" }, { "docid": "62afd8897e0d8368868858ad2789ec8f", "score": "0.5358334", "text": "func ExecuteTemplate(wr io.Writer, name, viewPath string, runMode string, data interface{}) error {\n\tif viewPath == \"\" {\n\t\tviewPath = defaultViewPath\n\t}\n\treturn ExecuteViewPathTemplate(wr, name, viewPath, runMode, data)\n}", "title": "" }, { "docid": "33d51930ce2c4fd1ae6135bf40cfe1a7", "score": "0.53580195", "text": "func realizeTemplate(tmplName string, adata map[string]interface{}, fileName string) (string, string, fail.Error) {\n\ttmplString, err := clusterFlavorScripts.ReadFile(tmplName)\n\terr = debug.InjectPlannedError(err)\n\tif err != nil {\n\t\treturn \"\", \"\", fail.Wrap(err, \"failed to load template\")\n\t}\n\n\ttmplCmd, err := template.Parse(fileName, string(tmplString))\n\terr = debug.InjectPlannedError(err)\n\tif err != nil {\n\t\treturn \"\", \"\", fail.Wrap(err, \"failed to parse template\")\n\t}\n\n\tdataBuffer := bytes.NewBufferString(\"\")\n\terr = tmplCmd.Option(\"missingkey=error\").Execute(dataBuffer, adata)\n\terr = debug.InjectPlannedError(err)\n\tif err != nil {\n\t\treturn \"\", \"\", fail.Wrap(err, \"failed to execute template\")\n\t}\n\n\tcmd := dataBuffer.String()\n\tremotePath := utils.TempFolder + \"/\" + fileName\n\n\treturn cmd, remotePath, nil\n}", "title": "" }, { "docid": "11f5dfa266668bea64c662c6c64cbfee", "score": "0.53494877", "text": "func execTemplateString(text string, data interface{}) ([]byte, error) {\n\ttmpl, err := newTemplate(\"stdin\").Parse(text)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn execTemplate(tmpl, data)\n}", "title": "" }, { "docid": "29debb51a78e1e9c62341b35040c51c1", "score": "0.5324567", "text": "func process(t *template.Template, vars interface{}) string {\n\tvar tmplBytes bytes.Buffer\n\n\terr := t.Execute(&tmplBytes, vars)\n\tcheck(err)\n\n\treturn tmplBytes.String()\n}", "title": "" }, { "docid": "9b970fdc586942c1e45f54744da0b902", "score": "0.53227496", "text": "func executeTemplate(templateFile, targetFile string, data interface{}) error {\n\tgoTemplate, err := template.ParseFiles(templateFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfile, err := os.Create(targetFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err = goTemplate.Execute(file, data); err != nil {\n\t\treturn err\n\t}\n\n\treturn file.Close()\n}", "title": "" }, { "docid": "adeb7a3b691594e6c544701abae9db52", "score": "0.5314562", "text": "func execTemplate(t *template.Template, name string, data interface{}) (template.HTML, error) {\n\tb := new(bytes.Buffer)\n\terr := t.ExecuteTemplate(b, name, data)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn template.HTML(b.String()), nil\n}", "title": "" }, { "docid": "adeb7a3b691594e6c544701abae9db52", "score": "0.5314562", "text": "func execTemplate(t *template.Template, name string, data interface{}) (template.HTML, error) {\n\tb := new(bytes.Buffer)\n\terr := t.ExecuteTemplate(b, name, data)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn template.HTML(b.String()), nil\n}", "title": "" }, { "docid": "a58ecbf3f4eddf3d73b75cd1cdf61852", "score": "0.53107077", "text": "func (e emailTemplate) Execute(m map[string]string) email {\n\tSubject := e.Subject.Execute(map[string]string{})\n\tRaw := e.RawTemplate.Execute(m)\n\tfor k, v := range m {\n\t\tm[k] = html.EscapeString(v)\n\t}\n\tHTML := e.HTMLTemplate.Execute(m)\n\treturn email{\n\t\tSubject,\n\t\tHTML,\n\t\tRaw,\n\t}\n}", "title": "" }, { "docid": "7703fb0efad98c62cc93cac9f0544296", "score": "0.5305636", "text": "func (f *FakeCommandRunner) Copy(file assets.CopyableFile) error {\n\tvar b bytes.Buffer\n\t_, err := io.Copy(&b, file)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"error reading file: %+v\", file)\n\t}\n\tf.fileMap.Store(file.GetSourcePath(), b.String())\n\treturn nil\n}", "title": "" }, { "docid": "5bb042653d3ece825041ccec13128972", "score": "0.5269014", "text": "func ExecuteTemplate(name, text string, data TemplateData) ([]byte, error) {\n\tzeroNilStructFields(&data.Installer.Spec)\n\tt, err := template.New(name).Funcs(sprig.TxtFuncMap()).Delims(\"{{kurl\", \"}}\").Parse(text)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"parse\")\n\t}\n\tb := bytes.NewBuffer(nil)\n\terr = t.Execute(b, data)\n\treturn b.Bytes(), errors.Wrap(err, \"execute\")\n}", "title": "" }, { "docid": "2e144b59ecb1ac95e883779de43ff3c7", "score": "0.5268172", "text": "func (r *Renderer) ExecuteTemplate(wr io.Writer, name string, data interface{}) error {\n\text := filepath.Ext(name)\n\tmtype := mime.TypeByExtension(ext)\n\tif strings.HasPrefix(mtype, \"text/html\") {\n\t\tif r.htmlplates == nil {\n\t\t\treturn errors.New(\"no HTML templates found\")\n\t\t}\n\t\treturn r.htmlplates.ExecuteTemplate(wr, name, data)\n\t}\n\tif r.templates == nil {\n\t\treturn errors.New(\"no text templates found\")\n\t}\n\treturn r.templates.ExecuteTemplate(wr, name, data)\n}", "title": "" }, { "docid": "54b0830ea6885af178a682cd75211b66", "score": "0.52661806", "text": "func executeTemplate(w http.ResponseWriter, templateName string, data interface{}) {\n\tpr(\"executeTemplate: \" + templateName)\n\n\tif flags.debug != \"\" {\n\t\tparseTemplateFiles()\n\t}\n\n\t// Note: htemplate does HTML-escaping, which prevents against HTML-injection attacks!\n\t// ttemplate does not, but is necessary for rendering HTML, such as auto-generated forms.\n\t_, ok := htemplates[templateName]\n\tvar err error\n\tif ok {\n\t\terr = htemplates[templateName].Execute(w, data)\n\t} else {\n\t\terr = ttemplates[templateName].Execute(w, data)\n\t}\n\tif err != nil {\n\t\tprVal(\"executeTemplate err\", err)\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "95d083235fd7b50f9e36894e27a90997", "score": "0.5263398", "text": "func (c *Cachy) Execute(w io.Writer, data interface{}, files ...string) (err error) {\n\tif v, ok := w.(http.ResponseWriter); ok {\n\t\tv.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n\t}\n\n\tswitch l := len(files); {\n\tcase l == 0:\n\t\treturn errors.New(\"Cachy: there are no templates to execute\")\n\tcase l == 1:\n\t\treturn c.templates[files[0]].Execute(w, data)\n\tdefault:\n\t\treturn c.executeMultiple(w, data, files)\n\t}\n}", "title": "" }, { "docid": "6612f5f50d73d61ab8825c2542eff6b8", "score": "0.52542984", "text": "func (t *BindatTemplate) ExecuteBytes(context Context) ([]byte, error) {\n\treturn t.original.ExecuteBytes(pongo2.Context(context))\n}", "title": "" }, { "docid": "4082902258a924517ed95d0d334dd1f8", "score": "0.52434254", "text": "func (r *Renderer) LoadTemplateMapping() {\n\n}", "title": "" }, { "docid": "982f37136963ea8386d8f8f435ca02b9", "score": "0.5228998", "text": "func applyTemplate(t *template.Template, name string, data interface{}) []byte {\n\tvar buf bytes.Buffer\n\tif err := t.Execute(&buf, data); err != nil {\n\t\tlog.Printf(\"%s.Execute: %s\", name, err)\n\t}\n\treturn buf.Bytes()\n}", "title": "" }, { "docid": "0974d0912a90cc1898645a3fd8311fb5", "score": "0.5225158", "text": "func (d *defaultTemplateBuilder) execute(name string) (templateData, error) {\n\td.log.Debug(\"Compressing all assets into an artifact\")\n\tcontent, err := core.MakeZip()\n\tif err != nil {\n\t\treturn templateData{}, err\n\t}\n\td.log.Debugf(\"Compression is successful (zip size: %d bytes)\", len(content))\n\n\tfunction, err := d.findFunction(name)\n\tif err != nil {\n\t\treturn templateData{}, err\n\t}\n\n\tfnTemplate := function.Template()\n\n\tzipChecksum := checksum(content)\n\tcodeKey := keyPrefix + name + \"/\" + zipChecksum + \"/functionbeat.zip\"\n\tto := d.template(function, name, codeKey)\n\tif err := mergeTemplate(to, fnTemplate); err != nil {\n\t\treturn templateData{}, err\n\t}\n\n\ttemplateJSON, err := to.JSON()\n\tif err != nil {\n\t\treturn templateData{}, err\n\t}\n\n\ttemplateChecksum := checksum(templateJSON)\n\ttemplateKey := keyPrefix + name + \"/\" + templateChecksum + \"/cloudformation-template-create.json\"\n\ttemplateURL := \"https://\" + d.bucket + \".\" + d.endpoint + \"/\" + templateKey\n\n\treturn templateData{\n\t\tjson: templateJSON,\n\t\tchecksum: templateChecksum,\n\t\tkey: templateKey,\n\t\turl: templateURL,\n\t\tcodeKey: codeKey,\n\t\tzip: zipData{\n\t\t\tchecksum: zipChecksum,\n\t\t\tcontent: content,\n\t\t},\n\t}, nil\n}", "title": "" }, { "docid": "97a270aae9707428822e0797c065c4d3", "score": "0.52232707", "text": "func (t *templateImpl) ExecuteTemplate(data map[string]string) (string, error) {\n\n\ttpl := bytes.Buffer{}\n\n\t// env vars\n\tdataForTemplating := addEnvVars(data)\n\n\terr := t.template.Execute(&tpl, dataForTemplating)\n\tif CheckError(err, \"Could not execute template\") {\n\t\treturn \"\", err\n\t}\n\n\treturn tpl.String(), nil\n}", "title": "" }, { "docid": "e04618c8ad2e57c2503638d7d1b27aa3", "score": "0.5214095", "text": "func run() error {\n\t// use GOPACKAGE (set by go generate) as default package name if available\n\tpkg := os.Getenv(\"GOPACKAGE\")\n\tif pkg == \"\" {\n\t\tpkg = \"main\"\n\t}\n\n\tvar out, prefix string\n\tfs := flag.NewFlagSet(\"bindata\", flag.ExitOnError)\n\tfs.StringVar(&out, \"o\", \"\", \"output file (default: stdout)\")\n\tfs.StringVar(&vars.Pkg, \"p\", pkg, \"name of the package\")\n\tfs.StringVar(&vars.Map, \"m\", \"bindata\", \"name of the map variable\")\n\tfs.StringVar(&prefix, \"r\", \"\", \"root path for map keys\")\n\tfs.BoolVar(&vars.AsString, \"s\", false, \"save data as strings\")\n\tif err := fs.Parse(os.Args[1:]); err != nil {\n\t\treturn err\n\t}\n\n\tvars.Files = make(map[string]fmt.Formatter)\n\tfor _, path := range fs.Args() {\n\t\tif err := AddPath(path, prefix); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tvar file *os.File\n\tif out != \"\" {\n\t\tvar err error\n\t\tif file, err = os.Create(out); err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\tfile = os.Stdout\n\t}\n\n\treturn tmpl.Execute(file, vars)\n}", "title": "" }, { "docid": "c61eb3297ed54892f1761885324f7cd3", "score": "0.5187028", "text": "func (m MayaAnyK8s) ExecuteTemplate() ([]byte, error) {\n\t// this has implementation of io.Writer\n\t// that is required by the template\n\tvar buf bytes.Buffer\n\n\tyml, err := m.GetYaml()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttpl, err := template.New(\"mayayaml\").Parse(yml)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// this applies its parsed yaml against this instance\n\t// & writes the result into the buffer\n\terr = tpl.Execute(&buf, m)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn buf.Bytes(), nil\n}", "title": "" }, { "docid": "8f67f06620f9da95e39f8ad06427f814", "score": "0.51832616", "text": "func Execute(wr io.Writer, name string, data interface{}) error {\n\tmsgTemplate, err := box.MustString(name)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"could not open template file\")\n\t}\n\n\tt, err := template.New(\"message\").Funcs(funcMap).Parse(string(msgTemplate))\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"could not parse template\")\n\t}\n\n\terr = t.Execute(wr, data)\n\treturn errors.Wrap(err, \"could not execute template\")\n}", "title": "" }, { "docid": "6c16ea9b11bc791415276c81581b3a9e", "score": "0.517202", "text": "func ApplyTemplate(templ string, templName string, data interface{}, funcMap template.FuncMap) (io.Reader, error) {\n\tcodeTemplate, err := template.New(templName).Funcs(funcMap).Parse(templ)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"cannot create template\")\n\t}\n\n\toutputBuffer := bytes.NewBuffer(nil)\n\terr = codeTemplate.Execute(outputBuffer, data)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"template error\")\n\t}\n\n\treturn outputBuffer, nil\n}", "title": "" }, { "docid": "5bf3e94384677b2cdafea55b31f6dcea", "score": "0.5168225", "text": "func (d *Display) execute(wr io.Writer, fileContents string) error {\n\tloc, err := display_model.LoadLocTempl(d.ctx.FileSys(), fileContents, d.ctx.User().Languages()) // TODO: think about errors here.\n\tif err != nil {\n\t\treturn err\n\t}\n\tvctx := d.ctx.ViewContext()\n\tvctx.Publish(\"loc\", loc)\n\tfuncMap := template.FuncMap(builtins(d.ctx))\n\tt, err := template.New(\"tpl\").Funcs(funcMap).Parse(fileContents)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn t.Execute(wr, vctx.Get()) // TODO: watch for errors in execution.\n}", "title": "" }, { "docid": "339854199e79a306d7ea66cf71400053", "score": "0.5162212", "text": "func realizeTemplate(box *rice.Box, tmplName string, data map[string]interface{}, fileName string) (string, string, fail.Error) {\n\tif box == nil {\n\t\treturn \"\", \"\", fail.InvalidParameterError(\"box\", \"cannot be nil!\")\n\t}\n\n\ttmplString, err := box.String(tmplName)\n\terr = debug.InjectPlannedError(err)\n\tif err != nil {\n\t\treturn \"\", \"\", fail.Wrap(err, \"failed to load template\")\n\t}\n\n\ttmplCmd, err := template.Parse(fileName, tmplString)\n\terr = debug.InjectPlannedError(err)\n\tif err != nil {\n\t\treturn \"\", \"\", fail.Wrap(err, \"failed to parse template\")\n\t}\n\n\tdataBuffer := bytes.NewBufferString(\"\")\n\terr = tmplCmd.Option(\"missingkey=error\").Execute(dataBuffer, data)\n\terr = debug.InjectPlannedError(err)\n\tif err != nil {\n\t\treturn \"\", \"\", fail.Wrap(err, \"failed to execute template\")\n\t}\n\n\tcmd := dataBuffer.String()\n\tremotePath := utils.TempFolder + \"/\" + fileName\n\n\treturn cmd, remotePath, nil\n}", "title": "" }, { "docid": "ec23638032dd1d524a1b2b47e17e9828", "score": "0.5161476", "text": "func processTemplate(ctx keyvault.TemplateContext, cfg configTemplate, basePath string) (*Generator, error) {\n\tif cfg.Keyvault != \"\" {\n\t\tctx = keyvault.WrapContext(ctx, cfg.Keyvault)\n\t}\n\n\tname := path.Base(cfg.Input)\n\tname = name[:len(name)-len(path.Ext(name))]\n\tfmap := sprig.TxtFuncMap()\n\tkeyvault.GetFuncs(ctx).Populate(fmap)\n\tutils.Populate(fmap)\n\n\treturn &Generator{\n\t\tName: fmt.Sprintf(\"Process template '%s' => '%s'\", cfg.Input, cfg.Output),\n\t\tLoader: func() (GeneratorFunc, error) {\n\t\t\ttmpl := template.New(name).Funcs(fmap)\n\n\t\t\tif cfg.Inline != \"\" {\n\t\t\t\tvar err error\n\t\t\t\ttmpl, err = tmpl.Parse(cfg.Inline)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tvar err error\n\t\t\t\ttmpl, err = tmpl.ParseFiles(relPath(basePath, cfg.Input))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn func() ([]byte, error) {\n\t\t\t\tvar buf bytes.Buffer\n\t\t\t\terr := tmpl.Templates()[0].Execute(&buf, cfg.Args)\n\t\t\t\treturn buf.Bytes(), err\n\t\t\t}, nil\n\t\t},\n\t\tOutputFile: relPath(basePath, cfg.Output),\n\t\tOutputMode: getMode(cfg.Mode, 0600),\n\t\tOutputOwner: cfg.Owner,\n\t\tRun: cfg.Run,\n\t\tRunTimeout: cfg.RunTimeout.DurationPtr(),\n\t}, nil\n}", "title": "" }, { "docid": "acc5dba2a5cfd29ea599010687866a9d", "score": "0.51608187", "text": "func (t *Template) Execute(w io.Writer, data interface{}) error {\n\treturn t.Template.ExecuteTemplate(w, t.name, data)\n}", "title": "" }, { "docid": "ecee32af3210cc086e096789e27cb7b5", "score": "0.51517934", "text": "func Execute(templateDirectory string) error {\n\tif _, err := os.Stat(templateDirectory); err != nil {\n\t\treturn fmt.Errorf(\"Could not find template directory '%s'\", templateDirectory)\n\t}\n\n\tm.AddFunc(\"text/html\", html.Minify)\n\tm.AddFunc(\"text/css\", css.Minify)\n\tminifyCSSFiles(templateDirectory)\n\n\t// Load template paths.\n\ttemplatePaths, _ := filepath.Glob(filepath.Join(templateDirectory, \"*.tmpl\"))\n\tsharedPaths, _ := filepath.Glob(filepath.Join(templateDirectory, \"shared/*.tmpl\"))\n\n\t// Load the templates.\n\ttemplates = make(map[string]*template.Template)\n\tfor _, templatePath := range templatePaths {\n\t\ttmpl := template.Must(compileTemplates(append(sharedPaths, templatePath)...))\n\n\t\tname := strings.Split(filepath.Base(templatePath), \".\")[0]\n\t\ttemplates[name] = tmpl\n\t}\n\n\t// Configure the routes.\n\thttp.HandleFunc(\"/\", index)\n\thttp.HandleFunc(\"/robots.txt\", robots)\n\thttp.HandleFunc(\"/events\", events)\n\thttp.HandleFunc(\"/team\", team)\n\thttp.HandleFunc(\"/gallery\", gallery)\n\thttp.HandleFunc(\"/partners\", partners)\n\thttp.HandleFunc(\"/sign-up\", signUp)\n\thttp.HandleFunc(\"/contact\", contact)\n\thttp.HandleFunc(\"/unsubscribe\", unsubscribe)\n\n\treturn nil\n}", "title": "" }, { "docid": "b22ed7bd682cfbca38bafd0d65096cba", "score": "0.5130646", "text": "func ExecuteTpl(name string, data interface{}) ([]byte, error) {\n\tw := new(bytes.Buffer)\n\ttpl.RLock()\n\tdefer tpl.RUnlock()\n\terr := tpl.t.ExecuteTemplate(w, name, data)\n\treturn w.Bytes(), err\n}", "title": "" }, { "docid": "72102175d3a77282f11010a4fc82b4d2", "score": "0.5128337", "text": "func GenerateFile(templates []string, outputPath string, requireMap map[string]interface{}, replaceMap map[string]interface{}) {\n\tassetsPath := \"../../../assets/\"\n\tfor _, t := range templates {\n\t\ttemplatesBox := packr.NewBox(assetsPath + t)\n\t\tbold := color.New(color.Bold).SprintFunc()\n\t\tboldGreen := color.New(color.FgGreen, color.Bold).SprintFunc()\n\t\tfmt.Printf(\"\\n%s%s%s\\n\", bold(\"Using template \"), boldGreen(t), bold(\", generated file:\"))\n\t\tfor _, f := range templatesBox.List() {\n\t\t\t// Check prerequisites.\n\t\t\tvar invalid bool\n\t\t\toutputFile := f\n\t\t\trequireMatches := requireRE.FindAllStringSubmatch(outputFile, -1)\n\t\t\tfor _, m := range requireMatches {\n\t\t\t\tvar negativeFlag bool\n\t\t\t\tpattern, word := m[0], m[1]\n\t\t\t\tif strings.HasPrefix(word, \"~\") {\n\t\t\t\t\tword = word[1:]\n\t\t\t\t\tnegativeFlag = true\n\t\t\t\t}\n\t\t\t\tif requiredValue, ok := requireMap[word]; ok {\n\t\t\t\t\tswitch v := requiredValue.(type) {\n\t\t\t\t\tcase int:\n\t\t\t\t\t\tinvalid = v == 0\n\t\t\t\t\t\tif negativeFlag {\n\t\t\t\t\t\t\tinvalid = v != 0\n\t\t\t\t\t\t}\n\t\t\t\t\tcase string:\n\t\t\t\t\t\tinvalid = v == \"\"\n\t\t\t\t\t\tif negativeFlag {\n\t\t\t\t\t\t\tinvalid = v != \"\"\n\t\t\t\t\t\t}\n\t\t\t\t\tcase bool:\n\t\t\t\t\t\tinvalid = !v\n\t\t\t\t\t\tif negativeFlag {\n\t\t\t\t\t\t\tinvalid = v\n\t\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tfmt.Printf(\"I don't know about type %T!\\n\", v)\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Printf(\"Missing requirement \\\"%s\\\" in file %s\\n\", word, f)\n\t\t\t\t\tinvalid = true\n\t\t\t\t}\n\t\t\t\tif invalid {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\toutputFile = strings.Replace(outputFile, pattern, \"\", -1)\n\t\t\t}\n\t\t\tif invalid {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Read file content.\n\t\t\tvar content []byte\n\t\t\tif strings.HasSuffix(outputFile, \".gotmpl\") {\n\t\t\t\tt := template.Must(template.New(\"template\").Parse(templatesBox.String(f)))\n\t\t\t\tvar tpl bytes.Buffer\n\t\t\t\tif err := t.Execute(&tpl, replaceMap); err != nil {\n\t\t\t\t\tExitOnError(err)\n\t\t\t\t}\n\t\t\t\tcontent = tpl.Bytes()\n\t\t\t} else {\n\t\t\t\tcontent = templatesBox.Bytes(f)\n\t\t\t}\n\t\t\t// Create and write to new file.\n\t\t\toutputFile = strings.TrimSuffix(outputFile, \".gotmpl\")\n\t\t\tif outputPath != \"\" {\n\t\t\t\tpath, err := filepath.Abs(filepath.Join(outputPath, outputFile))\n\t\t\t\tif err != nil {\n\t\t\t\t\tExitOnError(err)\n\t\t\t\t}\n\t\t\t\toutputFile = path\n\t\t\t}\n\t\t\tif folderPath := filepath.Dir(outputFile); folderPath != \".\" {\n\t\t\t\tif err := os.MkdirAll(folderPath, os.ModePerm); err != nil {\n\t\t\t\t\tExitOnError(err)\n\t\t\t\t}\n\t\t\t}\n\t\t\tExitOnError(ioutil.WriteFile(outputFile, content, 0644))\n\t\t\tfmt.Println(outputFile)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "36c0815e83c0ee8b0bc7d0d4bae1d7d6", "score": "0.5126805", "text": "func ExecutePathTemplates(valuesIn io.Reader, tplPath string) (string, error) {\n\ttpl := template.Must(template.New(tplPath).Funcs(sprig.TxtFuncMap()).Parse(tplPath))\n\n\tbuf := bytes.NewBuffer(nil)\n\t_, err := io.Copy(buf, valuesIn)\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to read standard input: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\n\tvar values map[string]interface{}\n\terr = yaml.Unmarshal(buf.Bytes(), &values)\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to parse standard input: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\ttplPathReader := strings.NewReader(tplPath)\n\toutputPath := bytes.NewBuffer(nil)\n\t_, err = io.Copy(buf, tplPathReader)\n\terr = tpl.Execute(outputPath, values)\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to parse standard input: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\toutputPathStr := fmt.Sprintf(\"%s\", outputPath)\n\treturn outputPathStr, err\n}", "title": "" }, { "docid": "e89d8e3d7c077d238aaddaea94932142", "score": "0.5126778", "text": "func ExecuteTemplate(tmpl revex.ExecutableTemplate, data interface{}) string {\n\tvar b bytes.Buffer\n\tif err := tmpl.Execute(&b, data); err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn b.String()\n}", "title": "" }, { "docid": "b0deef598f2847b6b092f55afad16d31", "score": "0.5118025", "text": "func CaptureInputFromEditor(resolveEditor PreferredEditorResolver, template []byte) ([]byte, error) {\n\tfile, err := ioutil.TempFile(os.TempDir(), \"*.sh\")\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\tfilename := file.Name()\n\n\t// Write the file template\n\tif _, err = file.Write(template); err != nil {\n\t\tlog.Fatal(\"Failed to write to temporary file\", err)\n\t}\n\n\t// Defer removal of the temporary file in case any of the next steps fail.\n\tdefer os.Remove(filename)\n\n\tif err = file.Close(); err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\tif err = OpenFileInEditor(filename, resolveEditor); err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\tbytes, err := ioutil.ReadFile(filename)\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\treturn bytes, nil\n}", "title": "" }, { "docid": "7c43090be5f6a8410e7241ba059deed6", "score": "0.5109943", "text": "func (s *Set) Execute(wr io.Writer, name string, data map[string]interface{}) error {\n\tt := s.template(name)\n\tif t == nil {\n\t\treturn fmt.Errorf(\"template %q not found\", name)\n\t}\n\treturn executeRecurse(wr, s, newsymtab(data), t.tree)\n}", "title": "" }, { "docid": "1cadc60e87934613bc7a44eec6b216a1", "score": "0.50765616", "text": "func (t *Template) Apply(name string, args ...string) ([]byte, error) {\n\tvars := make(map[string]string)\n\tfor i, a := range args {\n\t\tvars[fmt.Sprintf(\"_%d\", i+1)] = a\n\t}\n\tbuf := &bytes.Buffer{}\n\tif err := t.templates[name].Execute(buf, vars); err != nil {\n\t\treturn nil, err\n\t}\n\treturn buf.Bytes(), nil\n}", "title": "" }, { "docid": "bb42d0ebf05b64e8bfb5a6120cfe1937", "score": "0.50640285", "text": "func (e *email) executeTemplate(t *template.Template) (*bytes.Buffer, error) {\n var emailBody bytes.Buffer\n if err := t.ExecuteTemplate(&emailBody, nameWithHtmlExtension(constants.IntroduceTemplateName), e); err != nil {\n return nil, err\n }\n return &emailBody, nil\n}", "title": "" }, { "docid": "0647db40f334e82c95893f9b0d243ea0", "score": "0.5049855", "text": "func (e *Engine) Run(f []byte, v []byte) (*Template, error) {\n\traw := make(map[string]interface{})\n\terr := yaml.Unmarshal(f, &raw)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttemplated, err := e.replaceTemplates(raw)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvals := make(map[string]interface{})\n\terr = yaml.Unmarshal(v, &vals)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tb, err := json.Marshal(templated)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tout, err := replaceValues(string(b), \".Parameters\", vals)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\td := Template{}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = yaml.Unmarshal([]byte(out), &d)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &d, nil\n}", "title": "" }, { "docid": "1159f53d507860b9aa1ee8edcc6097c7", "score": "0.504468", "text": "func Execute(template, startTag, endTag string, w io.Writer, m map[string]interface{}) (int64, error) {\n\treturn ExecuteFunc(template, startTag, endTag, w,\n\t\tfunc(w io.Writer, tag string) (int, error) {\n\t\t\treturn stdTagFunc(w, tag, m)\n\t\t})\n}", "title": "" }, { "docid": "b04937026e7cf65d3745465a7b893f6c", "score": "0.5032355", "text": "func CreateTestTemplateCache() (map[string]*template.Template, error) {\n\n\tmyCache := map[string]*template.Template{} // ready to use parsed templates\n\n\t// func Glob(pattern string) (matches []string, err error) - Glob returns the names of all files matching pattern or nil if there is no matching file.\n\tpages, err := filepath.Glob(fmt.Sprintf(\"%s/*.page.tmpl\", pathToTemplates))\n\tif err != nil {\n\t\treturn myCache, err\n\t}\n\n\tfor _, page := range pages {\n\t\t// func Base(path string) string - Base returns the last element of path. Trailing path separators are removed before extracting the last element.\n\t\tname := filepath.Base(page) // name is about.page.tmpl or home.page.tmpl\n\n\t\t// fmt.Println(\"Page is currently\", page) // Ex. Page is currently templates\\about.page.tmpl\n\n\t\tts, err := template.New(name).Funcs(functions).ParseFiles(page) // parse the current page into ts\n\t\t// fmt.Println(\"ts1: \", ts)\n\t\t// Home --> &{<nil> 0xc0000205c0 0xc00013c200 0xc00004e1e0}\n\t\t// About --> &{<nil> 0xc00008a180 0xc0000a6100 0xc0000ce000}\n\t\tif err != nil {\n\t\t\t// fmt.Println(\"ERROR: ts, err := template.New(name).Funcs(functions).ParseFiles(page)\")\n\t\t\treturn myCache, err\n\t\t}\n\n\t\tmatches, err := filepath.Glob(fmt.Sprintf(\"%s/*.layout.tmpl\", pathToTemplates))\n\t\t// fmt.Println(\"matches: \", matches) // [templates\\base.layout.tmpl]\n\t\tif err != nil {\n\t\t\t// fmt.Println(\"ERROR:\tmatches, err := filepath.Glob(\\\"./templates/*.layout.tmpl\\\")\")\n\t\t\treturn myCache, err\n\t\t}\n\n\t\tif len(matches) > 0 {\n\t\t\tts, err = ts.ParseGlob(fmt.Sprintf(\"%s/*.layout.tmpl\", pathToTemplates)) // parse the base layout to the current ts\n\t\t\t// fmt.Println(\"ts2: \", ts)\n\t\t\t// Home --> &{<nil> 0xc0000205c0 0xc00013c200 0xc00004e1e0}\n\t\t\t// About --> &{<nil> 0xc00008a180 0xc0000a6100 0xc0000ce000}\n\t\t\tif err != nil {\n\t\t\t\t// fmt.Println(\"ERROR: ts, err = ts.ParseGlob(\\\"./templates/*.layout.tmpl\\\")\")\n\t\t\t\treturn myCache, err\n\t\t\t}\n\t\t}\n\n\t\t// map the current ts (with both a specific page and the base layout) to its coordinated name\n\t\tmyCache[name] = ts // [?] Map seems to copy value ts to new address\n\t\t// fmt.Println(\"myCache1: \", myCache)\n\t}\n\t// fmt.Println(\"myCache2: \", myCache) // map[about.page.tmpl:0xc000088390 home.page.tmpl:0xc000073530]\n\treturn myCache, nil\n}", "title": "" }, { "docid": "86a6b8becdc7859821c63c42338911e9", "score": "0.5027269", "text": "func (x *InitTemplateCommand) Execute(args []string) error {\n\tf, err := os.Create(x.OutFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func(f *os.File) {\n\t\t_ = f.Close()\n\t}(f)\n\treturn GenTemplate(f)\n}", "title": "" }, { "docid": "aecb903e9fa1ed0c17da1316a51595b4", "score": "0.5025769", "text": "func processTemplate(t *testing.T, name string, data interface{}) (string, error) {\n\tt.Helper()\n\n\ttmpl, err := template.New(name).ParseFiles(path.Join(\"..\", \"acceptance\", \"data\", \"golden\", name)) // TODO: Need a better way to coordinate path construction with CWD of test\n\tif err != nil {\n\t\tt.Fail()\n\t\treturn \"\", fmt.Errorf(\"error: unable to parse template file '%s': %v\", name, err)\n\t}\n\n\tvar b bytes.Buffer\n\terr = tmpl.Execute(&b, data)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"unable to execute template: %v\", err)\n\t}\n\n\treturn strings.TrimSpace(b.String()), nil\n}", "title": "" }, { "docid": "92ba6f9db47bfa68747a4edf3164587b", "score": "0.5020605", "text": "func DoTemplate(cmd string, raw string, nth int, words []string) (rv string) {\n\trv = \"\"\n\tplist := ParseLineIntoWords(raw)\n\tif InsurePlist(plist, 2) {\n\t\t//s := ExecuteATemplate ( plist[1], g_data )\n\t\t//t := ExecuteATemplate ( plist[2], g_data )\n\t\t//RunTemplate ( s, t )\n\t\tRunTemplate(plist[1], plist[2])\n\t}\n\treturn\n}", "title": "" }, { "docid": "f0e36f94e02352851a30cff3f1398964", "score": "0.50061834", "text": "func RunTemplate(TemplateFn string, outFn string) {\n\n\trtFuncMap := template.FuncMap{\n\t\t\"Center\": ms.CenterStr,\n\t\t\"PadR\": ms.PadOnRight,\n\t\t\"PadL\": ms.PadOnLeft,\n\t\t\"PicTime\": ms.PicTime,\n\t\t\"FTime\": ms.StrFTime,\n\t\t\"PicFloat\": ms.PicFloat,\n\t\t\"nvl\": ms.Nvl,\n\t\t\"FormatTable\": Tmpl_DataToFormattedText,\n\t\t\"PdfTable\": Tmpl_DataToPdfFormattedText, // xyzzy\n\t\t\"Concat\": ms.Concat,\n\t\t\"XCol\": XCol,\n\t\t\"title\": strings.Title, // The name \"title\" is what the function will be called in the template text.\n\t\t\"g\": global_g,\n\t\t\"set\": global_set,\n\t\t\"ifDef\": ms.IfDef,\n\t\t\"ifIsDef\": ms.IfIsDef,\n\t\t\"ifIsNotNull\": ms.IfIsNotNull,\n\t}\n\n\t// open output file: a-log.log\n\tfo, err := os.Create(outFn)\n\t// close fo on exit and check for its returned error\n\tdefer func() {\n\t\tif err := fo.Close(); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\n\tt, err := template.New(\"simple-tempalte\").Funcs(rtFuncMap).ParseFiles(TemplateFn)\n\tif err != nil {\n\t\tfmt.Fprintf(xOut, \"Error(12004): parsing/reading template, %s\\n\", err)\n\t\treturn\n\t}\n\n\terr = t.ExecuteTemplate(fo, \"report\", g_data)\n\tif err != nil {\n\t\tfmt.Fprintf(xOut, \"Error(12005): running template, %s\\n\", err)\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "feb0627a1ee4a4843b44cbfbdbf1ecd6", "score": "0.50003964", "text": "func (t templateV1) Evaluate(_ VariableReader, sr SecretReader) (string, error) {\n\tkeys := t.template.Keys()\n\tsecrets := make(map[string]string, len(keys))\n\tfor _, path := range keys {\n\t\tsecret, err := sr.ReadSecret(path)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tsecrets[path] = secret\n\t}\n\n\treturn t.template.Inject(secrets)\n}", "title": "" }, { "docid": "2c1333c81aaa92502de33bbabe1bdc35", "score": "0.49883628", "text": "func ExecTemplate(tmplstr string, vars interface{}, out interface{}) (err error) {\n\tbuffer := new(bytes.Buffer)\n\ttmpl, err := template.New(\"\").Funcs(templateFuncs).Parse(tmplstr)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = tmpl.Execute(buffer, vars)\n\tif err != nil {\n\t\treturn\n\t}\n\tdecoder := yaml.NewYAMLOrJSONDecoder(buffer, 4096)\n\terr = decoder.Decode(out)\n\treturn\n}", "title": "" }, { "docid": "eff3b3b3e7001f536336c9ee04178858", "score": "0.49685904", "text": "func ExecuteTemplate(tmpl string, args interface{}) ([]byte, error) {\n\tx, err := template.New(\"\").Parse(tmpl)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar b bytes.Buffer\n\tif err := x.Execute(&b, args); err != nil {\n\t\treturn nil, err\n\t}\n\treturn b.Bytes(), nil\n}", "title": "" }, { "docid": "e0614606b9de983a8cebf32fa6688961", "score": "0.49336925", "text": "func executeTemplate(w http.ResponseWriter, templ string, content interface{}) {\n\terr := templates.ExecuteTemplate(w, templ, content)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n}", "title": "" }, { "docid": "67e8d48dfe67552ae9248cee6726c89e", "score": "0.49253702", "text": "func (d *DefaultImplBundle) ExecuteTemplate(wr io.Writer, name string, prgm string, pkgName string) error {\n\treturn d.t.ExecuteTemplate(wr, name, &struct {\n\t\tPrgm string\n\t\tPkgName string\n\t}{\n\t\tPrgm: prgm,\n\t\tPkgName: pkgName,\n\t})\n}", "title": "" }, { "docid": "7781d7844c42f229c70d251da493bf9f", "score": "0.49227437", "text": "func (t *ApplyTemplate) Execute() (string, error) {\n\tdata := map[string]interface{}{\n\t\t\"Title\": t.Title,\n\t\t\"Message\": t.Message,\n\t\t\"Result\": t.Result,\n\t\t\"Body\": t.Body,\n\t\t\"Link\": t.Link,\n\t}\n\n\tresp, err := generateOutput(\"apply\", t.Template, data, t.UseRawOutput)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn resp, nil\n}", "title": "" }, { "docid": "2564017a0da38707a307fd604952924c", "score": "0.4907902", "text": "func InsertIntoBuffer(meta_struct *Metadata, buf *bytes.Buffer, resourceNameMap map[string]ResourceMetadata, funcMap template.FuncMap, subCommand string) error {\n\n\t//skip resource managerのjsonはskipする\n\tvar templateName string\n\n\tswitch subCommand {\n\tcase \"resource\":\n\t\ttemplateName = utils.GetGoPath() + \"/src/\" + utils.RepositoryDirectory + \"/cloudasset/templates/resource.tf.tmpl\"\n\tcase \"import\":\n\t\ttemplateName = utils.GetGoPath() + \"/src/\" + utils.RepositoryDirectory + \"/cloudasset/templates/import.sh.tmpl\"\n\tcase \"provider\":\n\t\ttemplateName = utils.GetGoPath() + \"/src/\" + utils.RepositoryDirectory + \"/cloudasset/templates/provider.tf.tmpl\"\n\tcase \"backend\":\n\t\ttemplateName = utils.GetGoPath() + \"/src/\" + utils.RepositoryDirectory + \"/cloudasset/templates/backend.tf.tmpl\"\n\t}\n\n\tmeta_struct.ResourceMetadata = resourceNameMap[meta_struct.AssetType]\n\t// skip resource which is not supported.\n\tif meta_struct.ResourceMetadata.Name == \"\" {\n\t\tif subCommand == \"resource\" {\n\t\t\tfmt.Println(\"Skip not supported resource:\", meta_struct.AssetType)\n\t\t\treturn nil\n\t\t} else if subCommand == \"import\" {\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tname := path.Base(templateName)\n\tt, err := template.New(name).Funcs(funcMap).ParseFiles(templateName)\n\tif err != nil {\n\t\treturn xerrors.Errorf(\"Error ParseFiles: %w\", err)\n\t}\n\n\tif err := t.Execute(buf, meta_struct); err != nil {\n\t\treturn xerrors.Errorf(\"Error execution: %w\", err)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "96cbe6165334a2ead2962965d7bc5981", "score": "0.49076688", "text": "func LoadTemplate(filePath string, params interface{}) (map[string]interface{}, error) {\n\ttemplateSource, err := GetContent(filePath)\n\tt := template.Must(template.New(\"tmpl\").Parse(string(templateSource[:])))\n\toutputBuffer := bytes.NewBuffer(make([]byte, 0, 100))\n\tt.Execute(outputBuffer, params)\n\tdata := outputBuffer.Bytes()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif strings.HasSuffix(filePath, \".json\") {\n\t\tvar document map[string]interface{}\n\t\terr = json.Unmarshal(data, &document)\n\t\treturn document, err\n\t} else if strings.HasSuffix(filePath, \".yaml\") {\n\t\tvar documentYAML map[interface{}]interface{}\n\t\terr = yaml.Unmarshal(data, &documentYAML)\n\t\tif err != nil {\n\t\t\treturn map[string]interface{}{}, err\n\t\t}\n\t\tdocument := DecodeYAMLLibObject(documentYAML)\n\t\treturn document.(map[string]interface{}), nil\n\t}\n\treturn nil, err\n}", "title": "" }, { "docid": "0bf7976cf2b349f2fbc03395a6cd6910", "score": "0.49042237", "text": "func (t *Template) Render(tmplName string, common CommonProps, contents interface{}) ([]byte, error) {\n\tbuf := bytes.NewBuffer(nil)\n\terr := t.tmpls.ExecuteTemplate(buf, tmplName, TmplProps{Common: common, Contents: contents})\n\tif err != nil {\n\t\tlog.Println(\"Error: failed to execute template\", tmplName, \", because\", err)\n\t}\n\n\treturn buf.Bytes(), err\n}", "title": "" }, { "docid": "0bac93f4e04af433251f579f782b2a6b", "score": "0.49022767", "text": "func runRaw(tpl string, vars interface{}) (string, error) {\n\tfuncMap := sprig.TxtFuncMap()\n\tfor i, v := range GenericFuncMap() {\n\t\tfuncMap[i] = v\n\t}\n\tt := template.Must(template.New(\"test\").Funcs(funcMap).Parse(tpl))\n\tvar b bytes.Buffer\n\terr := t.Execute(&b, vars)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn b.String(), nil\n}", "title": "" }, { "docid": "5444d3dbeecccaf70c9db566419bfe18", "score": "0.48998573", "text": "func parseTemplate(data interface{}, path string) string {\n\ttmpl, err := template.ParseFiles(path)\n\tCheckError(\"Read template\", err)\n\n\tbuf := new(bytes.Buffer)\n\terr = tmpl.Execute(buf, data)\n\tCheckError(\"Execute template\", err)\n\n\treturn buf.String()\n}", "title": "" }, { "docid": "f2765fc7edc39f41358baffa39bffb48", "score": "0.48991996", "text": "func Exec(t *template.Template, w io.Writer, tName string, data interface{}) {\n\terr := t.ExecuteTemplate(w, tName, data)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tfmt.Fprintln(w, err)\n\t}\n}", "title": "" }, { "docid": "315e54f3c0169934615fdc1297aa9f7d", "score": "0.48899662", "text": "func ExecuteHTML(w http.ResponseWriter, path string, message interface{}) {\n\ttpl, err := template.ParseFiles(path)\n\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\terr = tpl.Execute(w, message)\n}", "title": "" }, { "docid": "dc562145c37ad8327ac80eeb6be7b79f", "score": "0.48864564", "text": "func ExecuteTemplates(valuesIn io.Reader, out io.Writer, tplFile string) error {\n\ttemplateFileReader, _ := ioutil.ReadFile(tplFile)\n\ttemplateText := string(templateFileReader)\n\ttpl := template.Must(template.New(tplFile).Funcs(sprig.TxtFuncMap()).Parse(templateText))\n\n\tbuf := bytes.NewBuffer(nil)\n\t_, err := io.Copy(buf, valuesIn)\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to read standard input: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\n\tvar values map[string]interface{}\n\terr = yaml.Unmarshal(buf.Bytes(), &values)\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to parse standard input: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\n\terr = tpl.Execute(out, values)\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to parse standard input: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "6687ecddb7caebd05bf264ed9b8bb120", "score": "0.4878285", "text": "func CaptureInputFromEditor(template []byte) ([]byte, error) {\n\tfile, err := ioutil.TempFile(os.TempDir(), \"*\")\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\tfilename := file.Name()\n\tdefer func() { _ = os.Remove(filename) }()\n\n\t_, err = file.Write(template)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err = file.Close(); err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\tif err = OpenFileInEditor(filename); err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\tupdatedBytes, err := ioutil.ReadFile(filename)\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\treturn updatedBytes, nil\n}", "title": "" }, { "docid": "a024f29161547cb8174d9d790ba1d9a5", "score": "0.48769388", "text": "func (g *Generator) Run() error {\n\tinput, err := ioutil.ReadAll(g.in)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error reading input: %s\", err)\n\t}\n\n\trequest := new(plugin.CodeGeneratorRequest)\n\tif err := proto.Unmarshal(input, request); err != nil {\n\t\treturn fmt.Errorf(\"error parsing input: %s\", err)\n\t}\n\n\ttemplateName, templateData := g.parseParameters(request.GetParameter())\n\tif len(templateName) == 0 {\n\t\treturn fmt.Errorf(\"no template files in the parameters %q\", request.GetParameter())\n\t}\n\n\tfileTemplate, err := template.New(filepath.Base(templateName)).Parse(string(templateData))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error parsing template %s: %s\", templateName, err)\n\t}\n\n\tprotoFiles := make(map[string]*descriptor.FileDescriptorProto)\n\tfor _, protoFile := range request.GetProtoFile() {\n\t\tprotoFiles[protoFile.GetName()] = protoFile\n\t}\n\n\tresponse := new(plugin.CodeGeneratorResponse)\n\tfor _, fileName := range request.GetFileToGenerate() {\n\t\tif len(fileName) == 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\tprotoFile, protoFileFound := protoFiles[fileName]\n\t\tif !protoFileFound {\n\t\t\treturn fmt.Errorf(\"%s descriptor not found\", fileName)\n\t\t}\n\n\t\tfileResponse, err := g.applyTemplate(fileTemplate, protoFile)\n\t\tif err != nil {\n\t\t\tresponse.Error = proto.String(err.Error())\n\t\t\tbreak\n\t\t}\n\n\t\tresponse.File = append(response.File, fileResponse)\n\t}\n\n\t{\n\t\tresponseData, err := proto.Marshal(response)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error marshalling output: %s\", err)\n\t\t}\n\n\t\tif _, err := g.out.Write(responseData); err != nil {\n\t\t\treturn fmt.Errorf(\"error writing output: %s\", err)\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "ad7d77670d0674b337191380312fd47b", "score": "0.48750544", "text": "func (ts *templateSet) Execute(w io.Writer, name string, obj interface{}) error {\n\ttpl, ok := ts.tpls[name]\n\tif !ok {\n\t\t// attempt to load and parse the template\n\t\tbuf, err := ts.l(name)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// parse template\n\t\ttpl, err = template.New(name).Funcs(ts.funcs).Parse(string(buf))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn tpl.Execute(w, obj)\n}", "title": "" }, { "docid": "a16a2f7bf428e0ec5916318994bc4595", "score": "0.4872557", "text": "func (m MustacheEngine) CompileFile(filepath string) (interface{}, error) {\n\treturn mustache.ParseFile(filepath)\n}", "title": "" }, { "docid": "bd7c20b1d47d456d5577269358213450", "score": "0.48615542", "text": "func Run(input *Root) error {\n\taddDefaults(input)\n\n\t// copy the query engine to the local repository path\n\tfor _, name := range input.Generator.BinaryTargets {\n\t\tif name == \"native\" {\n\t\t\tname = platform.BinaryPlatformName()\n\t\t}\n\n\t\t// first, ensure they are actually downloaded\n\t\tif err := binaries.FetchEngine(binaries.GlobalTempDir(), \"query-engine\", name); err != nil {\n\t\t\treturn fmt.Errorf(\"failed fetching binaries: %w\", err)\n\t\t}\n\n\t\tqe := \"prisma-query-engine-\" + name\n\n\t\tdir := path.Join(binaries.GlobalTempDir(), qe)\n\n\t\tinput, err := ioutil.ReadFile(dir)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not read file %s: %w\", name, err)\n\t\t}\n\n\t\tdest := \"./\" + qe\n\t\terr = ioutil.WriteFile(dest, input, os.ModePerm)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not write file to %s: %w\", dest, err)\n\t\t}\n\t}\n\n\tvar buf bytes.Buffer\n\n\tctx := build.Default\n\tpkg, err := ctx.Import(\"github.com/prisma/prisma-client-go\", \".\", build.FindOnly)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not get main template asset: %w\", err)\n\t}\n\n\tvar templates []*template.Template\n\n\ttemplateDir := pkg.Dir + \"/generator/templates\"\n\terr = filepath.Walk(templateDir, func(path string, info os.FileInfo, err error) error {\n\t\tif strings.Contains(path, \".gotpl\") {\n\t\t\ttpl, err := template.ParseFiles(path)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\ttemplates = append(templates, tpl.Templates()...)\n\t\t}\n\n\t\treturn err\n\t})\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not walk dir %s: %w\", templateDir, err)\n\t}\n\n\t// Run header template first\n\theader, err := template.ParseFiles(templateDir + \"/_header.gotpl\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not find header template %s: %w\", templateDir, err)\n\t}\n\n\tif err := header.Execute(&buf, input); err != nil {\n\t\treturn fmt.Errorf(\"could not write header template: %w\", err)\n\t}\n\n\t// Then process all remaining templates\n\tfor _, tpl := range templates {\n\t\tif strings.Contains(tpl.Name(), \"_\") {\n\t\t\tcontinue\n\t\t}\n\n\t\tbuf.Write([]byte(fmt.Sprintf(\"// --- template %s ---\\n\", tpl.Name())))\n\n\t\terr = tpl.Execute(&buf, input)\n\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not write template file %s: %w\", tpl.Name(), err)\n\t\t}\n\n\t\t_, err := format.Source(buf.Bytes())\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not format source %s from file %s: %w\", buf.String(), tpl.Name(), err)\n\t\t}\n\t}\n\n\tformatted, err := format.Source(buf.Bytes())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not format final source: %w\", err)\n\t}\n\n\toutputDir := filepath.Dir(input.Generator.Output)\n\tif err = os.MkdirAll(outputDir, os.ModePerm); err != nil {\n\t\treturn fmt.Errorf(\"could not run MkdirAll on path %s: %w\", input.Generator.Output, err)\n\t}\n\n\tif err = ioutil.WriteFile(input.Generator.Output, formatted, 0644); err != nil {\n\t\treturn fmt.Errorf(\"could not write template data to file writer %s: %w\", input.Generator.Output, err)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "72169bdca06fb7c2ba532090b7d614dc", "score": "0.48564363", "text": "func render(resourceNames []string, templates map[string]string, params map[string]string, meta ExecutionMetadata) (map[string]string, error) {\n\tconfigs := make(map[string]interface{})\n\tconfigs[\"OperatorName\"] = meta.OperatorName\n\tconfigs[\"Name\"] = meta.InstanceName\n\tconfigs[\"Namespace\"] = meta.InstanceNamespace\n\tconfigs[\"Params\"] = params\n\tconfigs[\"PlanName\"] = meta.PlanName\n\tconfigs[\"PhaseName\"] = meta.PhaseName\n\tconfigs[\"StepName\"] = meta.StepName\n\n\tresources := map[string]string{}\n\tengine := engine.New()\n\n\tfor _, rn := range resourceNames {\n\t\tresource, ok := templates[rn]\n\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"error finding resource named %v for operator version %v\", rn, meta.OperatorVersionName)\n\t\t}\n\n\t\trendered, err := engine.Render(resource, configs)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error expanding template: %w\", err)\n\t\t}\n\n\t\tresources[rn] = rendered\n\t}\n\treturn resources, nil\n}", "title": "" }, { "docid": "7aa8576069be73a0ce19082fd1e58507", "score": "0.48549256", "text": "func (h *httpRawGet) Execute(filePath string) error {\n\trouter := httprouter.New()\n\trouter.GET(\"/\", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\t\tfmt.Fprintf(w, \"Test is test raw-get-matcher text\")\n\t})\n\tts := httptest.NewServer(router)\n\tdefer ts.Close()\n\n\tresults, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn expectResultsCount(results, 1)\n}", "title": "" }, { "docid": "62420f221e979ff97e9a30ffbaf48dfc", "score": "0.48519364", "text": "func templateGeneric (_type, name string, obj []interface{}) (contents string) {\n var (\n // functions available inside templates\n customFunctions = template.FuncMap{ \"partial\": partial }\n fileName = templatesHolder + sep + name + templateExtension\n\n // defining source for template variables by default.\n // it's make possible to call render methods in templates\n // with and without data structure as additional argument\n dataStruct interface{}\n buffer bytes.Buffer\n )\n\n // checking if template file exists\n if _, err := os.Stat(fileName); err == nil {\n\n // initializing new template\n rawTemplate := template.New(fileName)\n\n // adding functions to be used inside templates\n rawTemplate = rawTemplate.Funcs(customFunctions)\n\n // getting raw template's content\n fileContents, _ := ioutil.ReadFile(fileName)\n tmpl, err := rawTemplate.Parse(string(fileContents))\n\n if err != nil { log.Fatal(err) }\n\n // redefining source for template variables if one given\n if (len(obj) > 0) { dataStruct = obj[0] }\n\n // compiling and returning template's contents\n err = tmpl.Execute(&buffer, dataStruct)\n if err != nil { log.Fatal(err) }\n\n contents = buffer.String()\n\n } else {\n log.Fatal(\"ERROR: No such \" + _type + \": \" + fileName)\n }\n\n return\n}", "title": "" }, { "docid": "5dcedada180455939d6df3db302c0698", "score": "0.48516116", "text": "func bundle() (string) {\n \n \n buf := bytes.NewBuffer(nil)\n \n header, _ := os.Open(\"src/views/header.html\")\n io.Copy(buf, header) \n header.Close()\n \n // get the templates\n //filenames := []string {\"src/views/body.html\"}\n //for _, filename := range filenames {\n // f, _ := os.Open(filename)\n // io.Copy(buf, f) \n // f.Close()\n // }\n \n templates, _ := ioutil.ReadDir(\"src/views/templates\")\n for _, template := range templates {\n if(!template.IsDir()) {\n path := \"src/views/templates/\" + template.Name()\n log.Println(path)\n t, _ := os.Open(path)\n name := strings.Replace(template.Name(), \".html\", \"\", -1)\n io.WriteString(buf, \"<script type='text/x-handlebars' data-template-name='\")\n io.WriteString(buf, name)\n io.WriteString(buf, \"'>\")\n io.Copy(buf, t) \n io.WriteString(buf, \"</script>\")\n t.Close()\n } else {\n // recursivly search the folders\n bundleFolder(\"src/views/templates\", template.Name(), buf)\n }\n }\n \n // add the component templates\n components, _ := ioutil.ReadDir(\"src/views/components\")\n for _, component := range components {\n if(!component.IsDir()) {\n path := \"src/views/components/\" + component.Name()\n t, _ := os.Open(path)\n name := strings.Replace(component.Name(), \".html\", \"\", -1)\n io.WriteString(buf, \"<script type='text/x-handlebars' data-template-name='components/\")\n io.WriteString(buf, name)\n io.WriteString(buf, \"'>\")\n io.Copy(buf, t) \n io.WriteString(buf, \"</script>\")\n t.Close()\n } \n }\n \n footer, _ := os.Open(\"src/views/footer.html\")\n io.Copy(buf, footer) \n footer.Close()\n \n s := string(buf.Bytes())\n \n return s\n}", "title": "" }, { "docid": "839d8386815c94d33a16a384bc008484", "score": "0.48466706", "text": "func loadTemplate(Name string) *html.Template {\n funcMap := html.FuncMap{\n \"html\": func(val interface{}) html.HTML {\n switch value := val.(type) {\n case string: {\n return html.HTML(value)\n }\n case []byte: {\n return html.HTML(value)\n }\n case html.HTML: {\n return value\n }\n\n default: return html.HTML(\"Unsupported type for HTML pipeline\")\n }\n },\n \"int\": func(val interface{}) int {\n switch value := val.(type) {\n case string: {\n res, err := strconv.Atoi(value)\n if err != nil {\n res = 0\n }\n return res\n }\n case html.HTML: {\n res, err := strconv.Atoi(string(value))\n if err != nil {\n res = 0\n }\n return res\n }\n case int: {\n return value\n }\n case float32: {\n return int(value)\n }\n\n default: return 0\n }\n },\n \"typo\": func(val string) string {\n return typo.Typo(val)\n },\n \"striptags\": func(val string) string {\n return sanitize.HTML(val)\n },\n \"mod\": func(args ...interface{}) interface{} {\n if len(args) == 0 {\n return \"\"\n }\n\n name := args[0].(string)\n return runMod(name)\n },\n \"escape\": func(val string) string {\n return html.HTMLEscapeString(val)\n },\n \"br\": func(val string) string {\n return strings.Replace(val, \"\\n\", `<br />`, -1)\n },\n \"json\": func(val interface{}) interface{} {\n switch value := val.(type) {\n // Работать только для строк\n case string:\n if len(value) > 0 {\n var res interface{}\n if err := json.Unmarshal([]byte(value), &res); err != nil {\n return \"\"\n }\n\n return res\n }\n }\n\n return \"\"\n },\n \"trim\": func(val interface{}) string {\n switch value := val.(type) {\n case string: {\n return strings.TrimSpace(value)\n }\n case html.HTML: {\n return strings.TrimSpace(string(value))\n }\n\n default: return \"Unsupported type for HTML pipeline\"\n }\n },\n \"https\": func(val interface{}) string {\n switch value := val.(type) {\n case string: {\n return strings.Replace(value, \"http://\", \"https://\", -1)\n }\n\n default: return \"\"\n }\n },\n // TODO: в разработке\n /*\n 1. Взаимосвязь между реквестом и шаблонизатором (функциями модами)\n 2. Вызов mod с наследованием текущих переменных\n 3. Вызов tpl из шаблона с наследованием текущих переменных\n 4. Минимизация HTML на лету (удаление лишних пробелов и т.п.)\n */\n /*\"mod\": func(args ...interface{}) interface{} {\n if len(args) == 0 {\n return \"\"\n }\n\n name := args[0].(string)\n ctx := new(context.Context)\n\n if len(args) > 1 {\n ctx = args[1].(*context.Context)\n }\n\n modules := reflect.ValueOf(modules.Get())\n mod := modules.MethodByName(name)\n\n if (mod == reflect.Value{}) {\n return \"\"\n }\n\n inputs := make([]reflect.Value, 0)\n inputs = append(inputs, reflect.ValueOf(ctx))\n\n ret := mod.Call(inputs)\n return ret[0].Interface()\n },*/\n }\n\n return html.Must(html.New(\"*\").Funcs(funcMap).Delims(\"{{%\", \"%}}\").ParseFiles(\"tpls/\" + Name + \".tpl\"))\n}", "title": "" }, { "docid": "b8cf0d1d691f0fc2c305b2cc600ee025", "score": "0.4841834", "text": "func (c *Conform) ExecuteTemplateAndWrite(t *template.Template, name, dst string) error {\n\tbuf := &bytes.Buffer{}\n\tif err := t.ExecuteTemplate(buf, name, c); err != nil {\n\t\treturn err\n\t}\n\n\tif err := ioutil.WriteFile(dst, buf.Bytes(), 0664); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "32bdad7ff5abc5c3f105c275af6660b2", "score": "0.48413074", "text": "func (ts *Set) Process(ctx context.Context, outDir string, mode string, set *xo.Set) {\n\ttarget, ok := ts.targets[ts.target]\n\tswitch {\n\tcase !ok:\n\t\tts.err = fmt.Errorf(\"unknown target %q\", ts.target)\n\t\treturn\n\tcase target.Type.Process == nil:\n\t\treturn\n\t}\n\tts.err = target.Type.Process(ctx, mode, set, ts.addFile(ctx))\n\tif ts.err != nil {\n\t\treturn\n\t}\n\t// Determine template order.\n\torder := make(map[string]int, 0)\n\tif target.Type.Order != nil {\n\t\tfor i, o := range target.Type.Order(ctx, mode) {\n\t\t\torder[o] = i\n\t\t}\n\t}\n\tfs, err := ts.Src()\n\tif err != nil {\n\t\tts.err = err\n\t\treturn\n\t}\n\t// Parse templates and provide functions if applicable.\n\tts.goTpl = template.New(\"\")\n\tvar funcs template.FuncMap\n\tif target.Type.Funcs != nil {\n\t\tvar err error\n\t\tfuncs, err = target.Type.Funcs(ctx, mode)\n\t\tif err != nil {\n\t\t\tts.err = err\n\t\t\treturn\n\t\t}\n\t\tts.goTpl = ts.goTpl.Funcs(funcs)\n\t}\n\tts.goTpl, err = ts.goTpl.ParseFS(fs, \"*.tpl\")\n\tif err != nil {\n\t\tts.err = err\n\t\treturn\n\t}\n\t// sort file output order\n\tfilenames := make([]string, 0, len(ts.files))\n\tfor k := range ts.files {\n\t\tfilenames = append(filenames, k)\n\t}\n\tsort.Slice(filenames, func(i, j int) bool {\n\t\treturn filenames[i] < filenames[j]\n\t})\n\t// Generate all files with the constructed template.\n\tfor _, file := range filenames {\n\t\temitted := ts.files[file]\n\t\tsort.Slice(emitted.Template, func(i int, j int) bool {\n\t\t\tif emitted.Template[i].Partial != emitted.Template[j].Partial {\n\t\t\t\treturn order[emitted.Template[i].Partial] < order[emitted.Template[j].Partial]\n\t\t\t}\n\t\t\tif emitted.Template[i].SortType != emitted.Template[j].SortType {\n\t\t\t\treturn emitted.Template[i].SortType < emitted.Template[j].SortType\n\t\t\t}\n\t\t\treturn emitted.Template[i].SortName < emitted.Template[j].SortName\n\t\t})\n\t\tfor _, tpl := range emitted.Template {\n\t\t\tif tpl.Src == \"\" {\n\t\t\t\terr := ts.goTpl.ExecuteTemplate(&emitted.Buf, tpl.Partial, tpl)\n\t\t\t\tif err != nil {\n\t\t\t\t\tts.files[file].Err = append(ts.files[file].Err, err)\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tgotpl, err := template.New(\"\").Parse(tpl.Src)\n\t\t\tif err != nil {\n\t\t\t\tts.files[file].Err = append(ts.files[file].Err, err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\terr = gotpl.Execute(&emitted.Buf, tpl)\n\t\t\tif err != nil {\n\t\t\t\tts.files[file].Err = append(ts.files[file].Err, err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "820260007e98f8d7c9b16dbf5a49183a", "score": "0.48382714", "text": "func main() {\n\t//read from stdin and inspect it for functions and imports\n\t//write the pretemplate to tmp file\n\t//write the stdin code\n\t//write the posttemplate\n\t//rename the file to *.go\n\t//exec using go run\n\tf, err := ioutil.TempFile(\"\", \"goeval-stub\")\n\thandle(err)\n\ttempfilepath := f.Name()\n\tf.WriteString(PRETEMPLATE)\n\tio.Copy(f, os.Stdin)\n\tf.WriteString(POSTTEMPLATE)\n\tf.Close()\n\tnewfilepath := tempfilepath + \".go\"\n\tos.Rename(tempfilepath, newfilepath)\n\trunFile(newfilepath)\n}", "title": "" }, { "docid": "dca32ee5852444de48294dc3398fdd10", "score": "0.48362127", "text": "func (t *Repository) ExecuteTemplate(wr io.Writer, name string, data interface{}) error {\n\ttmpl := t.templates[name]\n\treturn tmpl.Execute(wr, data)\n}", "title": "" }, { "docid": "6338a2fb5845750dab220071f079ac73", "score": "0.48357803", "text": "func ExecuteViewPathTemplate(wr io.Writer, name string, viewPath string, runMode string, data interface{}) error {\n\tif runMode == defaultRunMode {\n\t\ttemplatesLock.RLock()\n\t\tdefer templatesLock.RUnlock()\n\t}\n\tif beeTemplates, ok := beeViewPathTemplates[viewPath]; ok {\n\t\tif t, ok := beeTemplates[name]; ok {\n\t\t\tvar err error\n\t\t\tif t.Lookup(name) != nil {\n\t\t\t\terr = t.ExecuteTemplate(wr, name, data)\n\t\t\t} else {\n\t\t\t\terr = t.Execute(wr, data)\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t\tpanic(\"can't find template file in the path:\" + viewPath + \"/\" + name)\n\t}\n\tpanic(\"Unknown view path:\" + viewPath)\n}", "title": "" }, { "docid": "5f1fd3650ce6b9d6e2da429e8d16cd07", "score": "0.483052", "text": "func executeTemplate(w io.Writer, templatePath string, title string) error {\n\tt, err := parseTemplate(templatePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\ttemplateVars, err := buildTemplateVars(title)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := t.Execute(w, templateVars); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "a707e4d12cdce6d5c33a6a35d1b47b98", "score": "0.4827741", "text": "func WalkExecuteTemplates(templatesRootPath string, inputPath string, newRootPath string) {\n\ttemplatesRootPathStat, _ := os.Stat(templatesRootPath)\n\ttemplateFileList := []string{}\n\tswitch {\n\t// if current path is a a directory\n\tcase templatesRootPathStat.IsDir():\n\t\t_ = filepath.Walk(templatesRootPath, func(path string, f os.FileInfo, err error) error {\n\t\t\ttemplateFileList = append(templateFileList, path)\n\t\t\treturn nil\n\t\t})\n\tcase !templatesRootPathStat.IsDir():\n\t\ttemplateFileList = append(templateFileList, templatesRootPath)\n\t}\n\n\t// For each path in templates\n\tfor _, templatePath := range templateFileList {\n\t\tinputPathReader, _ := os.OpenFile(inputPath, os.O_RDONLY, os.ModeAppend)\n\t\ttemplatePathStat, _ := os.Stat(templatePath)\n\t\ttemplatePathEnd := strings.TrimPrefix(templatePath, templatesRootPath)\n\t\tnewPath := \"\"\n\t\tif templatePathEnd == \"\" {\n\t\t\tnewPath = newRootPath\n\t\t} else {\n\t\t\tnewPath = newRootPath + templatePathEnd\n\t\t}\n\t\tnewPath, err := ExecutePathTemplates(inputPathReader, newPath)\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"Failed to output paths: %v\\n\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\t\tinputPathReader, _ = os.OpenFile(inputPath, os.O_RDONLY, os.ModeAppend)\n\t\tswitch {\n\t\tcase templatePathStat.IsDir():\n\t\t\t// create dir if it doesn't already exist in envPath\n\t\t\tif !fileSystem.PathExists(newPath) {\n\t\t\t\tfileSystem.CreateDir(newPath)\n\t\t\t}\n\t\tcase !templatePathStat.IsDir():\n\t\t\tvar outputFile *os.File\n\t\t\tif !fileSystem.PathExists(newPath) {\n\t\t\t\toutputFile, _ = fileSystem.CreateFile(newPath)\n\t\t\t} else {\n\t\t\t\t_ = fileSystem.DeleteFile(newPath)\n\t\t\t\toutputFile, _ = fileSystem.CreateFile(newPath)\n\t\t\t}\n\t\t\tExecuteTemplates(inputPathReader, outputFile, templatePath)\n\t\t\tfmt.Printf(\"Output: %s\\n\\tFrom File: %s\\n\", newPath, templatePath)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "ca68707be9cb1ca0d6f087a9f260e8cc", "score": "0.48275974", "text": "func (h *headlessExtractValues) Execute(filePath string) error {\n\trouter := httprouter.New()\n\trouter.GET(\"/\", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\t\t_, _ = w.Write([]byte(\"<html><body><a href='/test.html'>test</a></body></html>\"))\n\t})\n\tts := httptest.NewServer(router)\n\tdefer ts.Close()\n\tresults, err := testutils.RunNucleiTemplateAndGetResults(filePath, ts.URL, debug, \"-headless\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn expectResultsCount(results, 3)\n}", "title": "" }, { "docid": "aeb68a29b565c0e450feee2a9ee4aced", "score": "0.4823559", "text": "func testHandler(w http.ResponseWriter, r *http.Request) {\n t, _ := template.ParseFiles(\"test.html\")\n t.Execute(w, \"testi\")\n}", "title": "" }, { "docid": "5d263ff97617f47ebb73217e2967a8b8", "score": "0.48202008", "text": "func (a *Action) Run(ctx context.Context, input map[string]interface{}) (map[string]interface{}, error) {\n\tcode, mData, err := core.Execute(a.id, input, a.microgateway, a.IOMetadata(), a.logger)\n\toutput := make(map[string]interface{}, 8)\n\toutput[\"code\"] = code\n\toutput[\"data\"] = mData\n\n\treturn output, err\n}", "title": "" } ]
db7292798aaf2e6a90e34a4f3eb1bfc4
ExecuteAllCleanTasks triggers cleanup of all resources that were marked to be cleaned before that
[ { "docid": "04e71093b3e6a6b10f2041c5b1717d45", "score": "0.7911812", "text": "func ExecuteAllCleanTasks(t *testing.T) {\n\tcleaning.clean(t)()\n}", "title": "" } ]
[ { "docid": "fd37c92ef022b1773cd1713ae716aaed", "score": "0.695979", "text": "func (i *simpleInstaller) Clean() error {\n\tfor _, res := range cleanResources {\n\t\tgvr := schema.GroupVersionResource{\n\t\t\tGroup: \"openebs.io\",\n\t\t\tVersion: \"v1alpha1\",\n\t\t\tResource: res.name,\n\t\t}\n\t\tk8sDynamic, err := k8s.Dynamic().Provide()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = k8sDynamic.Resource(gvr).Namespace(res.namespace).DeleteCollection(\n\t\t\tcontext.TODO(),\n\t\t\tmetav1.DeleteOptions{},\n\t\t\tmetav1.ListOptions{\n\t\t\t\tLabelSelector: \"version!=\" + version.Current(),\n\t\t\t},\n\t\t)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "3cfe696e6f02ba75c4fd6171507fd626", "score": "0.694411", "text": "func (b *Builder) CleanResources() error {\n\tvar err error\n\tfor _, dir := range []string{b.dataDir, b.runDir} {\n\t\tif rerr := os.RemoveAll(dir); rerr != nil {\n\t\t\tb.Logger().Errorf(\"Removing working dir %q failed: %v\", dir, rerr)\n\t\t\terr = rerr\n\t\t}\n\t}\n\treturn err\n}", "title": "" }, { "docid": "74ddcf7edbcdfed2ff8af336cb509f98", "score": "0.6677677", "text": "func (this *AppRunner) CleanAll() error {\n\tinstances, err := this.List(false)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, instance := range instances {\n\t\tstatus, _ := instance.GetStatus()\n\t\tif status == StatusExited {\n\t\t\t// Remove it\n\t\t\tif err := this.RemoveInstance(instance.ID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\t// Done\n\treturn nil\n}", "title": "" }, { "docid": "d6003174fc5430bdc36ad2357844240c", "score": "0.66553813", "text": "func (d *Deployer) CleanUp() error {\n\tfor _, o := range d.resources {\n\t\t// TODO handle better errors\n\t\t_ = d.Client.Delete(context.TODO(), o)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c024016e7dba3b522aae6072eb8b2aad", "score": "0.6566343", "text": "func (a AdmissionBucket) Cleanup() error {\n\tfor _, p := range a.podsToClean {\n\t\terr := a.client.CoreV1().Pods(p.Namespace).Delete(context.TODO(), p.Name, metav1.DeleteOptions{})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "540b8f7572c5d713280a604a6b699a9f", "score": "0.643637", "text": "func (ts *Suite) cleanupResources() error {\n\tts.log.Infof(\"removing secret %s\", ts.ConfigName)\n\terr := ts.secretClient.Delete(v1.Secret{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: ts.ConfigName,\n\t\t\tNamespace: ts.DeployNamespace,\n\t\t},\n\t})\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"while waiting for secret %s deletion\", ts.ConfigName)\n\t}\n\n\tts.log.Infof(\"removing config map %s\", ts.ConfigName)\n\terr = ts.configMapClient.Delete(v1.ConfigMap{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: ts.ConfigName,\n\t\t\tNamespace: ts.DeployNamespace,\n\t\t},\n\t})\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"while waiting for config map %s deletion\", ts.ConfigName)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "25b34124105df1bad776d515704d9275", "score": "0.63781035", "text": "func (xcps *XConnPools) clean() {\n\tvar ticker *time.Ticker\n\tif cleanPeriod == time.Duration(0) {\n\t\tticker = time.NewTicker(time.Hour)\n\t} else {\n\t\tticker = time.NewTicker(cleanPeriod)\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase <-ticker.C:\n\t\t\tvar addresses []string\n\t\t\txcps.pools.ForEach(func(address string, pool *XConnPool) error {\n\t\t\t\tcount := atomic.LoadInt64(&(pool.count))\n\t\t\t\tif count != 0 {\n\t\t\t\t\tatomic.StoreInt64(&(pool.count), 0)\n\t\t\t\t} else {\n\t\t\t\t\t// We can close a pool at this callback function, but we can't\n\t\t\t\t\t// delete it from the pools, because this will lead to deadlock.\n\t\t\t\t\tpool.Close()\n\t\t\t\t\taddresses = append(addresses, address)\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t})\n\n\t\t\t// Out of ForEach loop, we can delete deprecated pools safely.\n\t\t\tfor _, address := range addresses {\n\t\t\t\txcps.pools.Delete(address)\n\t\t\t}\n\n\t\tcase <-xcps.exit:\n\t\t\tticker.Stop()\n\t\t\treturn\n\t\t}\n\t}\n}", "title": "" }, { "docid": "32ca88dc36ea90bd2dafc3bf145cdfc3", "score": "0.6320072", "text": "func (t *transfer) clean() {\n\twg := &sync.WaitGroup{}\n\tcleanCtx, cancelCleanFn := context.WithTimeout(context.Background(), 15*time.Second)\n\tdefer cancelCleanFn()\n\n\t// delete pushgateway metrics\n\tfor _, src := range t.sources {\n\t\tfor _, dst := range t.destinations {\n\t\t\twg.Add(1)\n\n\t\t\tgo func(ctx context.Context, src *exporter.Endpoint, dst *pushgateway.Endpoint) {\n\t\t\t\tdefer wg.Done()\n\t\t\t\tscraperName, pusherName := src.GetName(), dst.GetName()\n\n\t\t\t\terr := dst.Delete(ctx, scraperName, t.grouping)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.WithError(err).Warnf(\"'%s' delete '%s' failure\", pusherName, scraperName)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tlog.Debugf(\"'%s' delete '%s' success\", pusherName, scraperName)\n\t\t\t}(cleanCtx, src, dst)\n\t\t}\n\t}\n\n\twg.Wait()\n}", "title": "" }, { "docid": "4594b2eb2689a41120cb700f8db7ee68", "score": "0.63061005", "text": "func (c *Context) Cleanup() {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\tfor _, closer := range c.closers {\n\t\tcloser.Close()\n\t}\n\tc.closers = []io.Closer{}\n\tfor _, file := range c.files {\n\t\tfile.Close()\n\t\tos.Remove(file.Name())\n\t}\n\tc.files = []*os.File{}\n\tfor _, dir := range c.dirs {\n\t\tos.RemoveAll(dir)\n\t}\n\tc.dirs = []string{}\n}", "title": "" }, { "docid": "003e89cb4a8e482a8045fb66793c7f3e", "score": "0.63022476", "text": "func cleanup(s scheduler.Scheduler, tasks *demand.Tasks) {\n\ttasks.Lock()\n\tfor _, task := range tasks.Tasks {\n\t\ttask.Demand = 0\n\t}\n\ttasks.Unlock()\n\n\tlog.Debugf(\"Reset tasks to 0 for cleanup\")\n\terr := s.StopStartTasks(tasks)\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to cleanup tasks. %v\", err)\n\t}\n}", "title": "" }, { "docid": "3d2431a864ad28bd9c5e50e7d28ab155", "score": "0.63003623", "text": "func (m *Manager) cleanup() {\n\tif !atomic.CompareAndSwapInt32(&m.state.cleaned, 0, 1) {\n\t\treturn // do not clean if already scheduled\n\t}\n\n\tm.lock()\n\tglog.Infof(\"dsort %s has started a cleanup\", m.ManagerUUID)\n\tnow := time.Now()\n\n\tdefer func() {\n\t\tm.unlock()\n\t\tglog.Infof(\"dsort %s cleanup has been finished in %v\", m.ManagerUUID, time.Since(now))\n\t}()\n\n\tif m.inProgress() {\n\t\tcmn.AssertMsg(false, fmt.Sprintf(\"%s: was still in progress\", m.ManagerUUID))\n\t}\n\n\tm.streamWriters.writers = nil\n\n\tm.shardManager.Cleanup()\n\tm.extractCreator = nil\n\tm.client = nil\n\n\tm.ctx.smap.Listeners().Unreg(m)\n\n\tif !m.aborted() {\n\t\tm.updateFinishedAck(m.ctx.node.DaemonID)\n\t}\n}", "title": "" }, { "docid": "77f1d70c2c2037dbc9c5487a11371207", "score": "0.6242318", "text": "func (m *Manager) finalCleanup() {\n\tif !atomic.CompareAndSwapInt32(&m.state.cleaned, 1, 2) {\n\t\treturn // do not clean if already scheduled\n\t}\n\n\tglog.Infof(\"dsort %s has started a final cleanup\", m.ManagerUUID)\n\tnow := time.Now()\n\tdefer func() {\n\t\tglog.Infof(\"dsort %s final cleanup has been finished in %v\", m.ManagerUUID, time.Since(now))\n\t}()\n\n\tif err := m.cleanupStreams(); err != nil {\n\t\tglog.Error(err)\n\t}\n\n\t// The reason why this is not in regular cleanup is because we are only sure\n\t// that this can be freed once we cleanup streams - streams are asynchronous\n\t// and we may have race between in-flight request and cleanup.\n\tm.recManager.Cleanup()\n\textract.FreeMemory()\n\n\tm.finishedAck.m = nil\n\tManagers.persist(m.ManagerUUID)\n}", "title": "" }, { "docid": "f1d1032fefadb621d1c4f5efad7b91ab", "score": "0.6235973", "text": "func (m *Monitor) cleanup() {\n\tm.mutex.Lock()\n\tdefer m.mutex.Unlock()\n\tfor _, remoteWatcher := range m.remoteWatchers {\n\t\tremoteWatcher.Cleanup()\n\t}\n\tm.RevocationStore.Cleanup()\n}", "title": "" }, { "docid": "3667166abe900625aaa90f0c50f94e95", "score": "0.62161356", "text": "func (e *AlluxioEngine) cleanAll() (err error) {\n\tcount, err := e.Helper.CleanUpFuse()\n\tif err != nil {\n\t\te.Log.Error(err, \"Err in cleaning fuse\")\n\t\treturn err\n\t}\n\te.Log.Info(\"clean up fuse count\", \"n\", count)\n\n\tvar (\n\t\tvalueConfigmapName = e.name + \"-\" + e.runtimeType + \"-values\"\n\t\tconfigmapName = e.name + \"-config\"\n\t\tnamespace = e.namespace\n\t)\n\n\tcms := []string{valueConfigmapName, configmapName}\n\n\tfor _, cm := range cms {\n\t\terr = kubeclient.DeleteConfigMap(e.Client, cm, namespace)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "bab8e4bb85e2fe2bc06f681c08de790b", "score": "0.62147355", "text": "func (cm *ConnectionManager) CleanupAllConnections() {\n\tcm.rwl.Lock()\n\tdefer cm.rwl.Unlock()\n\tcm.cleanupConnections()\n}", "title": "" }, { "docid": "ac44e84bb91648a50c6f78e89cdb4e20", "score": "0.62051463", "text": "func Cleanup() {\n\tfor _, f := range cleanupFuncs {\n\t\tf()\n\t}\n\tcleanupFuncs = []func(){}\n}", "title": "" }, { "docid": "74886fe907bcc91e1c8e24cd792a26a5", "score": "0.6181633", "text": "func (poolHolder *poolHolder) cleanup() {\n\tfor obj := range poolHolder.takenObjects {\n\t\tpoolHolder.pool.Put(obj)\n\t}\n}", "title": "" }, { "docid": "751c0dfd1fe8c312d20c179bf8dccf51", "score": "0.6140056", "text": "func (wt *ctWaiter) cleanup() {\n\tfor uid := range wt.objs {\n\t\twt.removeObj(uid)\n\t}\n\twt.waitFor.Store(0)\n\twt.toRebuild.Store(0)\n}", "title": "" }, { "docid": "b42bdb72095c0900a2dac439662984e2", "score": "0.61340785", "text": "func (l Local) DestroyAll(ctx context.Context) error {\n\trequired := []string{\"kind\", \"docker_registry\"}\n\terr := mage.Dependencies.Run(required, func(d mage.Dependency) error {\n\t\treturn d.Check(ctx)\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdeps, err := mage.Dependencies.Get(required)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tkind := deps[0].(*mage.Kind)\n\tdockerRegistry := deps[1].(*mage.DockerRegistry)\n\n\terrors := mage.NewErrors()\n\terrors.Append(kind.Destroy(ctx, cluster))\n\n\tif os.Getenv(\"CAPE_DESTROY_ALL\") != \"\" {\n\t\terrors.Append(dockerRegistry.Destroy(ctx, registry))\n\t}\n\n\treturn errors.Err()\n}", "title": "" }, { "docid": "e269f0a5d675918cb830e2a7545adcf4", "score": "0.61121315", "text": "func (this *AbstractCollection) Cleanup() {\n\n\tfor _, v := range this.Particles {\n\t\tv.CleanUp()\n\t}\n\n\tfor _, v := range this.Constraints {\n\t\tv.CleanUp()\n\t}\n}", "title": "" }, { "docid": "8ca11235476b96522126d29c1606eee1", "score": "0.61116165", "text": "func (om *Maintainer) cleanupExternalOperations() {\n\tcurrentTime := time.Now()\n\tcriteria := []query.Criterion{\n\t\tquery.ByField(query.NotEqualsOperator, \"platform_id\", types.SMPlatform),\n\t\t// check if operation hasn't been updated for the operation's maximum allowed time to live in DB\n\t\tquery.ByField(query.LessThanOperator, \"updated_at\", util.ToRFCNanoFormat(currentTime.Add(-om.settings.Lifespan))),\n\t\tquery.BySubquery(query.InSubqueryOperator, \"id\", storage.GetSubQuery(storage.QueryForAllNotLastOperationsPerResource)),\n\t}\n\n\tom.batchDeleteOperation(criteria, om.settings.DeleteOperationsBatchSize)\n\n\tlog.C(om.smCtx).Debug(\"Finished cleaning up external operations\")\n}", "title": "" }, { "docid": "9a0920bf79f02574e27864610cdeefba", "score": "0.60937124", "text": "func KillAllDockers() {\n\tpool, err := dockertest.NewPool(\"\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tresources.Range(func(k, v interface{}) bool {\n\t\tif err := pool.Purge(v.(*dockertest.Resource)); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tresources.Delete(k)\n\t\treturn true\n\t})\n}", "title": "" }, { "docid": "4f3e096eaa7f4051aff5b1885d82a16b", "score": "0.6084794", "text": "func (self *realFramework) Cleanup() {\n\tfor _, cleanupFunc := range self.cleanups {\n\t\tcleanupFunc()\n\t}\n}", "title": "" }, { "docid": "6c7f0b9f203b74413d91697578bb6d90", "score": "0.6075931", "text": "func (ex *Executor) Cleanup() {\n\tif ex.executionPath != \"\" {\n\t\tos.RemoveAll(ex.executionPath)\n\t}\n}", "title": "" }, { "docid": "d878122c2146f2c3be7ec0c4671f2930", "score": "0.6059427", "text": "func (om *Maintainer) CleanupFinishedCascadeOperations() {\n\tcurrentTime := time.Now()\n\trootsCriteria := []query.Criterion{\n\t\tquery.ByField(query.EqualsOperator, \"platform_id\", types.SMPlatform),\n\t\tquery.ByField(query.EqualsOrNilOperator, \"parent_id\", \"\"),\n\t\tquery.ByField(query.NotEqualsOperator, \"cascade_root_id\", \"\"),\n\t\tquery.ByField(query.InOperator, \"state\", string(types.SUCCEEDED), string(types.FAILED)),\n\t\t// check if operation hasn't been updated for the operation's maximum allowed time to live in DB//\n\t\tquery.ByField(query.LessThanOperator, \"updated_at\", util.ToRFCNanoFormat(currentTime.Add(-om.settings.Lifespan))),\n\t\tquery.BySubquery(query.InSubqueryOperator, \"id\", storage.GetSubQuery(storage.QueryForAllNotLastOperationsPerResource)),\n\t}\n\n\troots, err := om.repository.List(om.smCtx, types.OperationType, rootsCriteria...)\n\tif err != nil {\n\t\tlog.C(om.smCtx).Debugf(\"Failed to fetch finished cascade operations: %s\", err)\n\t\treturn\n\t}\n\tfor i := 0; i < roots.Len(); i++ {\n\t\troot := roots.ItemAt(i)\n\t\tbyRootID := query.ByField(query.EqualsOperator, \"cascade_root_id\", root.GetID())\n\t\tif err := om.repository.Delete(om.smCtx, types.OperationType, byRootID); err != nil && err != util.ErrNotFoundInStorage {\n\t\t\tlog.C(om.smCtx).Errorf(\"Failed to cleanup cascade operations: %s\", err)\n\t\t}\n\t}\n\tlog.C(om.smCtx).Debug(\"Finished cleaning up successful cascade operations\")\n}", "title": "" }, { "docid": "303fed2377147a6e83ad99f3e3087cfd", "score": "0.6030524", "text": "func (lifecycle *Lifecycle) Cleanup() {\n\tfor _, callback := range *lifecycle {\n\t\tcallback()\n\t}\n}", "title": "" }, { "docid": "4ff60f581fbb84848473d9bbc7edd624", "score": "0.6028807", "text": "func (b *bucketMetacache) deleteAll() {\n\tctx := context.Background()\n\tez, ok := newObjectLayerFn().(*erasureServerPools)\n\tif !ok {\n\t\tlogger.LogIf(ctx, errors.New(\"bucketMetacache: expected objAPI to be *erasurePools\"))\n\t\treturn\n\t}\n\n\tb.mu.Lock()\n\tdefer b.mu.Unlock()\n\n\tb.updated = true\n\t// Delete all.\n\tez.renameAll(ctx, minioMetaBucket, metacachePrefixForID(b.bucket, slashSeparator))\n\tb.caches = make(map[string]metacache, 10)\n\tb.cachesRoot = make(map[string][]string, 10)\n}", "title": "" }, { "docid": "2c044ed327ed91dc983caab68ee06a6e", "score": "0.59846073", "text": "func (repo *repositoryResourceType) Clean() {\n\trepo.mu.Lock()\n\tdefer repo.mu.Unlock()\n\n\tfor k := range repo.items {\n\t\tdelete(repo.items, k)\n\t}\n}", "title": "" }, { "docid": "91e74735a222466929e42d188354e58d", "score": "0.5958325", "text": "func Clean(cmd *cobra.Command, targets []string) {\n\tlog.Printf(\"builder.Clean(%v)\", targets)\n\tif len(targets) == 0 {\n\t\tdocker.Prune()\n\t\tworkspace.Reset()\n\t\treturn\n\t}\n\tfor _, t := range targets {\n\t\tswitch ut := strings.ToUpper(t); ut {\n\t\tcase \"STAMPS\":\n\t\t\tos.RemoveAll(workspace.Path(\"stamps\"))\n\t\tcase \"RESULTS\":\n\t\t\tos.RemoveAll(workspace.Path(\"results\"))\n\t\tcase \"DOCKER\":\n\t\t\tdocker.Prune()\n\t\tcase \"ALL\":\n\t\t\tdocker.Prune()\n\t\t\tworkspace.Reset()\n\t\t}\n\t}\n}", "title": "" }, { "docid": "880c9684876f7bfcea78b35aaf4328bc", "score": "0.59486663", "text": "func KillAllTestDatabases() {\n\tpool, err := dockertest.NewPool(\"\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor _, r := range resources {\n\t\tif err := pool.Purge(r); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "61d05c507b5432eaac183ec9e98933d5", "score": "0.59370077", "text": "func (mr *Master) CleanupFiles() {\n\tfor i := range mr.files {\n\t\tfor j := 0; j < mr.nReduce; j++ {\n\t\t\tremoveFile(reduceName(mr.jobName, i, j))\n\t\t}\n\t}\n\tfor i := 0; i < mr.nReduce; i++ {\n\t\tremoveFile(mergeName(mr.jobName, i))\n\t}\n\tremoveFile(\"mrtmp.\" + mr.jobName)\n}", "title": "" }, { "docid": "efae4ad5c9d24b054b06415749ab2aac", "score": "0.5935066", "text": "func (cow *cowForest) clean() error {\n\tfor _, fileNum := range cow.meta.staleFiles {\n\t\tif verbose {\n\t\t\tfmt.Printf(\"CLEANING UP file %d\\n\", fileNum)\n\t\t}\n\t\terr := os.Remove(cow.getTreeTableFName(fileNum))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// empty staleFiles\n\tcow.meta.staleFiles = cow.meta.staleFiles[:0]\n\n\treturn nil\n}", "title": "" }, { "docid": "02374d648786be2ed0e245f56520ac95", "score": "0.5930215", "text": "func Cleanup(preserve bool) {\n\tvar errs []error\n\tfor tmp, caller := range tmps {\n\t\tif preserve {\n\t\t\tlog.Printf(\"preserving temp path %s\", tmp)\n\t\t} else if err := os.RemoveAll(tmp); err != nil {\n\t\t\tlog.Printf(\"util.temp.Cleanup(%s) failed: %s (created by %s)\", tmp, err, caller)\n\t\t\terrs = append(errs, err)\n\t\t}\n\t}\n\tif len(errs) > 0 {\n\t\tstrs := make([]string, 0, len(errs))\n\t\tfor _, e := range errs {\n\t\t\tstrs = append(strs, e.Error())\n\t\t}\n\t\tlog.Printf(\"temp dirs cleanup completed with errors: %s\", strings.Join(strs, \"\\n\"))\n\t}\n\tlog.Printf(\"temp dirs cleanup completed\")\n}", "title": "" }, { "docid": "ec82296b28b298bbdb1afc8e03c664d3", "score": "0.59219694", "text": "func TestCleanup(t *testing.T) {\n\tfmt.Println(\"Cleaning possible lingering resources..\")\n\tterraform.Destroy(t, terraformOptions)\n\n\t// Also clean up prereq. resources\n\tfmt.Println(\"Cleaning our prereq resources...\")\n\tsetTerraformOptions(\".\")\n\tterraform.Destroy(t, terraformOptions)\n}", "title": "" }, { "docid": "6092aa7d86ac5aa8f309f6f7c90783de", "score": "0.5921215", "text": "func (f *Fixtures) Cleanup(dirs ...string) {\n\tclean := append(dirs, f.RootDir)\n\tfor _, d := range clean {\n\t\trequire.NoError(f.T, os.RemoveAll(d))\n\t}\n}", "title": "" }, { "docid": "e578a2bd5f72a785664ed4334e2cebc3", "score": "0.59197366", "text": "func (ctx Model) cleanup() {\n\tlogger.Info(\"Cleanup temp dir:\" + config.TempPath + \"...\\n\")\n\terr := os.RemoveAll(config.TempPath)\n\tif err != nil {\n\t\tlogger.Error(\"Cleanup temp dir \"+config.TempPath+\" error:\", err)\n\t}\n\tlogger.Info(\"======= End \" + ctx.Config.Name + \" =======\\n\\n\")\n}", "title": "" }, { "docid": "7607877d929dda44f769032a2ce388dd", "score": "0.59137243", "text": "func cleanup(files ...string) (err error) {\n\tfor _, file := range files {\n\t\tif err = os.RemoveAll(file); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "af468819eae76d335998cefae7cd5dad", "score": "0.5911939", "text": "func (vmm *VMM) Cleanup() {\n\tfor _, closer := range vmm.cleanupFns {\n\t\tif err := closer(); err != nil {\n\t\t\tlog.Error(err)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "c37f70cd738422f18cc79fb179465d3c", "score": "0.59102124", "text": "func cleanup(nreducer int) error {\n\tfor i := 0; i < nreducer; i++ {\n\t\terr := os.Remove(BASEDIR + reduceName(i))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "94f2fd8ee5acef88ecf189e381e0b68d", "score": "0.58969253", "text": "func Clean() error {\n\terr := os.RemoveAll(\"dist\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = os.RemoveAll(\"coverage\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = os.RemoveAll(\"ci\")\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "7f06c98ff7fe8f1d9d73c26da7901b1f", "score": "0.588856", "text": "func (p *VmwareVim) ComputeCleanup(projectName string, nodes []*jettypes.NodeTemplate) error {\n\n\tvar (\n\t\tfolders map[string]bool\n\t)\n\n\tfolders = make(map[string]bool)\n\tsem := make(chan int, 3)\n\n\tvar finalStatus []TaskMessage\n\terrChan := make(chan TaskMessage, len(nodes))\n\n\tvar wg sync.WaitGroup\n\twg.Add(len(nodes))\n\n\tfor i, _ := range nodes {\n\t\tgo p.cleanupNodeTask(projectName, nodes[i], folders, sem, &wg, errChan)\n\t}\n\n\twg.Wait()\n\tclose(errChan)\n\tfor e := range errChan {\n\t\tfinalStatus = append(finalStatus, e)\n\t}\n\n\t/** TODO refactor this check each status print green in console */\n\tsuccess := 0\n\tfor _, v := range finalStatus {\n\t\tif v.Status == types.TaskInfoStateSuccess {\n\t\t\tsuccess++\n\t\t}\n\t\tlog.Println(\"job\", v.VmName, \"\\tstatus\", v.Status)\n\t}\n\n\tif success == len(nodes) {\n\t\tlogging.Notification(\"All vm destroyed\")\n\t}\n\n\t// All VM deleted, cleanup all folders now.\n\tfor f, _ := range folders {\n\t\terr := vcenter.DeleteFolder(p.ctx, p.VimClient(), f)\n\t\tif err != nil {\n\t\t\tlogging.CriticalMessage(\"Deployment\", projectName, \" failed delete folder\", f)\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "bcce696009dd09114118cf272b0fe0fd", "score": "0.58490264", "text": "func Cleanup(platform *platform.Platform) error {\n\n\tif platform.TerminationProtection {\n\t\treturn fmt.Errorf(\"Termination Protection Enabled, use -e terminationProtection=false to disable\")\n\t}\n\n\tif err := platform.OpenViaEnv(); err != nil {\n\t\treturn fmt.Errorf(\"cleanup: failed to open via env %v\", err)\n\t}\n\n\tvms, err := platform.GetVMs()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cleanup: failed to get VMs %v\", err)\n\t}\n\n\tif len(vms) > platform.GetVMCount()*2 {\n\t\tlog.Fatalf(\"Too many VM's found, expecting +- %d but found %d\", platform.GetVMCount(), len(vms))\n\t}\n\n\tlog.Infof(\"Deleting %d vm's, CTRL+C to skip, sleeping for 10s\", len(vms))\n\t//pausing to give time for user to terminate\n\ttime.Sleep(10 * time.Second)\n\n\tvar wg sync.WaitGroup\n\tfor _, _vm := range vms {\n\t\tvm := _vm\n\t\tif platform.DryRun {\n\t\t\tcontinue\n\t\t}\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tvm.Terminate()\n\t\t\twg.Done()\n\t\t}()\n\n\t}\n\twg.Wait()\n\treturn nil\n}", "title": "" }, { "docid": "b14ae45cc40c65d1c0641c9481b3c03d", "score": "0.58472884", "text": "func (s *state) cleanup() {\n\tlog.Verbose(\"Cleaning up sensitive and temp files\")\n\tif _, err := os.Stat(\"ca.crt\"); err == nil {\n\t\tdeleteFile(\"ca.crt\")\n\t}\n\n\tif _, err := os.Stat(\"ca.key\"); err == nil {\n\t\tdeleteFile(\"ca.key\")\n\t}\n\n\tif _, err := os.Stat(\"client.crt\"); err == nil {\n\t\tdeleteFile(\"client.crt\")\n\t}\n\n\tif _, err := os.Stat(\"bearer.token\"); err == nil {\n\t\tdeleteFile(\"bearer.token\")\n\t}\n\n\tfor _, app := range s.Apps {\n\t\tif _, err := os.Stat(app.SecretsFile + \".dec\"); err == nil {\n\t\t\tdeleteFile(app.SecretsFile + \".dec\")\n\t\t}\n\t\tfor _, secret := range app.SecretsFiles {\n\t\t\tif _, err := os.Stat(secret + \".dec\"); err == nil {\n\t\t\t\tdeleteFile(secret + \".dec\")\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "1ddb7b70247feb5a59f70cec06200e32", "score": "0.58132106", "text": "func (e *Environment) Cleanup(ctx context.Context, objs ...client.Object) error {\n\terrs := []error{}\n\tfor _, o := range objs {\n\t\terr := e.Client.Delete(ctx, o)\n\t\tif apierrors.IsNotFound(err) {\n\t\t\tcontinue\n\t\t}\n\t\terrs = append(errs, err)\n\t}\n\treturn kerrors.NewAggregate(errs)\n}", "title": "" }, { "docid": "7c8921aaf38410539c65b2c74b025c53", "score": "0.5808508", "text": "func (cl *Cleaner) clean() {\n\tfor {\n\t\tselect {\n\t\tcase <-cl.tickChan:\n\t\t\tcl.RemoveExpiredElements()\n\t\tcase <-cl.doneChan:\n\t\t\treturn\n\t\t}\n\t}\n}", "title": "" }, { "docid": "005ad7a59aafd60d7301c83bc2275243", "score": "0.58078694", "text": "func cleanup() error {\n\ts := createService()\n\tif s == nil {\n\t\treturn errors.New(\"Could not create service\")\n\t}\n\n\tvar pageToken string\n\tvar failed bool\n\tfor {\n\t\tcall := s.Objects.List(bucket)\n\t\tif pageToken != \"\" {\n\t\t\tcall.PageToken(pageToken)\n\t\t}\n\t\tresp, err := call.Do()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cleanup list failed: %v\", err)\n\t\t}\n\t\tfor _, obj := range resp.Items {\n\t\t\tlog.Printf(\"Cleanup deletion of %q\", obj.Name)\n\t\t\tif err := s.Objects.Delete(bucket, obj.Name).Do(); err != nil {\n\t\t\t\t// Print the error out, but keep going.\n\t\t\t\tlog.Printf(\"Cleanup deletion of %q failed: %v\", obj.Name, err)\n\t\t\t\tfailed = true\n\t\t\t}\n\t\t\tif _, err := s.Objects.Get(bucket, obj.Name).Download(); !isError(err, http.StatusNotFound) {\n\t\t\t\tlog.Printf(\"object %q should not exist, err = %v\", obj.Name, err)\n\t\t\t\tfailed = true\n\t\t\t} else {\n\t\t\t\tlog.Printf(\"Successfully deleted %q.\", obj.Name)\n\t\t\t}\n\t\t}\n\t\tif pageToken = resp.NextPageToken; pageToken == \"\" {\n\t\t\tbreak\n\t\t}\n\t}\n\tif failed {\n\t\treturn errors.New(\"Failed to delete at least one object\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "5872d608f76cf7cf4abf070e1505642a", "score": "0.5805929", "text": "func (b *Botanist) CleanKubernetesResources() error {\n\tvar (\n\t\twg sync.WaitGroup\n\t\terrors []error\n\t)\n\n\tif err := b.K8sShootClient.CleanupResources(exceptions); err != nil {\n\t\treturn err\n\t}\n\n\tfor resource, apiGroupPath := range b.K8sShootClient.GetResourceAPIGroups() {\n\t\twg.Add(1)\n\t\tgo func(apiGroupPath []string, resource string) {\n\t\t\tdefer wg.Done()\n\t\t\tif err := b.waitForAPIGroupCleanedUp(apiGroupPath, resource); err != nil {\n\t\t\t\terrors = append(errors, err)\n\t\t\t}\n\t\t}(apiGroupPath, resource)\n\t}\n\twg.Wait()\n\n\tif len(errors) == 0 {\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"Error(s) while waiting for Kubernetes resource cleanup: %+v\", errors)\n}", "title": "" }, { "docid": "9a0dd1cbf0e7c9038054d9e65693b195", "score": "0.57944775", "text": "func (dp *DockerProxy) Cleanup() error {\n\tfor _, m := range dp.middlewares {\n\t\tm.Cleanup()\n\t}\n\t// TODO: should return errors from each middleware\n\treturn nil\n}", "title": "" }, { "docid": "c05c8c268febd215b4b341f6f4184c6f", "score": "0.5787149", "text": "func cleanTheDB() {\n fmt.Println(\"Cleaning up the DB, don't turn off...\")\n // delete all the users\n db.DelTemps(\"users\")\n // all the monitoring information\n for _, d := range daemons {\n db.C(\"monitoring_of_\" + d.Id.Hex()).DropCollection()\n }\n // all the daemons\n db.DelTemps(\"daemons\")\n // all the orgs\n db.DelTemps(\"organisations\")\n fmt.Println(\"Bye!\")\n}", "title": "" }, { "docid": "ff2f15aacd24af4b862d1ef4a5999979", "score": "0.5783096", "text": "func (m *importManager) cleanupLoop(wg *sync.WaitGroup) {\n\tdefer wg.Done()\n\tticker := time.NewTicker(time.Duration(cleanUpLoopInterval) * time.Millisecond)\n\tdefer ticker.Stop()\n\tfor {\n\t\tselect {\n\t\tcase <-m.ctx.Done():\n\t\t\tlog.Debug(\"(in cleanupLoop) import manager context done, exit cleanupLoop\")\n\t\t\treturn\n\t\tcase <-ticker.C:\n\t\t\tlog.Debug(\"(in cleanupLoop) trying to expire old tasks from memory and Etcd\")\n\t\t\tm.expireOldTasksFromMem()\n\t\t\tm.expireOldTasksFromEtcd()\n\t\t\tlog.Debug(\"(in cleanupLoop) start removing bad import segments\")\n\t\t\tm.removeBadImportSegments(m.ctx)\n\t\t\tlog.Debug(\"(in cleanupLoop) start cleaning hanging busy DataNode\")\n\t\t\tm.releaseHangingBusyDataNode()\n\t\t}\n\t}\n}", "title": "" }, { "docid": "9cce902b218ca449bfd90551038c9685", "score": "0.5772499", "text": "func (om *Maintainer) cleanupInternalSuccessfulOperations() {\n\tcurrentTime := time.Now()\n\tcriteria := []query.Criterion{\n\t\tquery.ByField(query.EqualsOperator, \"platform_id\", types.SMPlatform),\n\t\tquery.ByField(query.EqualsOperator, \"state\", string(types.SUCCEEDED)),\n\t\t// ignore cascade operations\n\t\tquery.ByField(query.EqualsOrNilOperator, \"cascade_root_id\", \"\"),\n\t\t// check if operation hasn't been updated for the operation's maximum allowed time to live in DB\n\t\tquery.ByField(query.LessThanOperator, \"updated_at\", util.ToRFCNanoFormat(currentTime.Add(-om.settings.Lifespan))),\n\t\tquery.BySubquery(query.InSubqueryOperator, \"id\", storage.GetSubQuery(storage.QueryForAllNotLastOperationsPerResource)),\n\t}\n\n\tom.batchDeleteOperation(criteria, om.settings.DeleteOperationsBatchSize)\n\n\tlog.C(om.smCtx).Debug(\"Finished cleaning up successful internal operations\")\n}", "title": "" }, { "docid": "852ed3d04d9b3b252bae71f7e007e26a", "score": "0.57718855", "text": "func attemptIpsetCleanup(ctx context.Context, sets *ipset.Ipset) error {\n\tiset, _ := ipset.Load(context.Background())\n\tfor _, set := range iset.Sets {\n\t\t_, _ = ipset.Destroy(set)\n\t}\n\n\t// flush everything that survived mass destroy.\n\t_, err := ipset.Flush(nil)\n\n\treturn err\n}", "title": "" }, { "docid": "802868480c3dce081268188f3b59be1c", "score": "0.57570493", "text": "func (m *McmManager) Cleanup() {\n\treturn\n}", "title": "" }, { "docid": "c051d46d04e87b824c8d8b1eeb84f169", "score": "0.5753779", "text": "func CleanUp() {\n\tlevelWorkerPoolMap.Range(func(key, value interface{}) bool {\n\t\tpool, ok := value.(*ants.PoolWithFunc)\n\t\tif ok {\n\t\t\tpool.Release()\n\t\t}\n\t\treturn true\n\t})\n}", "title": "" }, { "docid": "5e274dab450ea09986f385e39f59405c", "score": "0.57513076", "text": "func (tf *TempFactory) Cleanup() {\n\tfor _, file := range tf.files {\n\t\t_ = os.Remove(file)\n\t}\n\ttf.files = nil\n\n\t// Also remove the tempdir if it's not the shared memory directory\n\tif !strings.Contains(tf.path, defaultSharedMemoryDir) {\n\t\t_ = os.Remove(tf.path)\n\t}\n}", "title": "" }, { "docid": "fef70e7f4f9136089449dd29f98d93a2", "score": "0.57453793", "text": "func (r *taskRepository) DeleteAll() error {\n\terr := r.file.OverwriteContents(\"\")\n\tif err != nil {\n\t\treturn errors.New(errorRepositoryErrorDeletingTasks)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "fe4f9fc8861f11a80a500387a64b34bc", "score": "0.5739946", "text": "func (cli *DogestryCli) Cleanup() {\n\tif cli.tempDir != \"\" {\n\t\tif err := os.RemoveAll(cli.tempDir); err != nil {\n\t\t\tlog.Println(err)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "c4ab95b85dff7a173d745c18f05061a0", "score": "0.57261044", "text": "func (c *Cleaner) Clean(repo string, since time.Time) ([]string, error) {\n\tgcrrepo, err := gcrname.NewRepository(repo)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to get repo %s\", repo)\n\t}\n\n\ttags, err := gcrgoogle.List(gcrrepo, gcrgoogle.WithAuth(c.auther))\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to list tags for repo %s\", repo)\n\t}\n\n\t// Create a worker pool for parallel deletion\n\tpool := workerpool.New(c.concurrency)\n\n\tvar deleted = make([]string, 0, len(tags.Manifests))\n\tvar deletedLock sync.Mutex\n\tvar errs = make(map[string]error)\n\tvar errsLock sync.RWMutex\n\n\tfor k, m := range tags.Manifests {\n\t\tif c.shouldDelete(m, since) {\n\t\t\tref := repo + \"@\" + k\n\t\t\tpool.Submit(func() {\n\t\t\t\t// Do not process if previous invocations failed. This prevents a large\n\t\t\t\t// build-up of failed requests and rate limit exceeding (e.g. bad auth).\n\t\t\t\terrsLock.RLock()\n\t\t\t\tif len(errs) > 0 {\n\t\t\t\t\terrsLock.RUnlock()\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\terrsLock.RUnlock()\n\n\t\t\t\tif err := c.deleteOne(ref); err != nil {\n\t\t\t\t\tcause := errors.Cause(err).Error()\n\n\t\t\t\t\terrsLock.Lock()\n\t\t\t\t\tif _, ok := errs[cause]; !ok {\n\t\t\t\t\t\terrs[cause] = err\n\t\t\t\t\t\terrsLock.Unlock()\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\terrsLock.Unlock()\n\t\t\t\t}\n\n\t\t\t\tdeletedLock.Lock()\n\t\t\t\tdeleted = append(deleted, k)\n\t\t\t\tdeletedLock.Unlock()\n\t\t\t})\n\t\t}\n\t}\n\n\t// Wait for everything to finish\n\tpool.StopWait()\n\n\t// Aggregate any errors\n\tif len(errs) > 0 {\n\t\tvar errStrings []string\n\t\tfor _, v := range errs {\n\t\t\terrStrings = append(errStrings, v.Error())\n\t\t}\n\n\t\tif len(errStrings) == 1 {\n\t\t\treturn nil, errors.New(errStrings[0])\n\t\t}\n\n\t\treturn nil, errors.Errorf(\"%d errors occurred: %s\",\n\t\t\tlen(errStrings), strings.Join(errStrings, \", \"))\n\t}\n\n\treturn deleted, nil\n}", "title": "" }, { "docid": "bc105e591a34bdd785143f1e86a29893", "score": "0.57238984", "text": "func TearDownAll() error {\n\tharnessStateMtx.Lock()\n\tdefer harnessStateMtx.Unlock()\n\n\tfor _, harness := range testInstances {\n\t\tif err := harness.tearDown(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "bc105e591a34bdd785143f1e86a29893", "score": "0.57238984", "text": "func TearDownAll() error {\n\tharnessStateMtx.Lock()\n\tdefer harnessStateMtx.Unlock()\n\n\tfor _, harness := range testInstances {\n\t\tif err := harness.tearDown(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "a48fc4ac6272f1b3cb4463b5b38e04b6", "score": "0.5715721", "text": "func (apm *ApmPackageManager) Cleanup() (err error) {\n\tif err = command.ExecuteCommand(execCommand(apm.Path, \"clean\")); err != nil {\n\t\treturn fmt.Errorf(\"Cannot %s clean: %s\", apm.Name, err)\n\t}\n\treturn err\n}", "title": "" }, { "docid": "2d04e5bea1836c90577adcf32bd814ac", "score": "0.5708892", "text": "func (r *directoryBenchmark) cleanup() error {\n\t// Clean temp dirs\n\tif err := os.RemoveAll(r.uploadDirectoryPath); err != nil {\n\t\treturn err\n\t}\n\tif err := os.RemoveAll(r.downloadDirectoryPath); err != nil {\n\t\treturn err\n\t}\n\n\t// Delete uploaded objects\n\tc := nonBenchmarkingClients.Get()\n\t// List objects under root and delete all\n\troot := path.Base(r.uploadDirectoryPath)\n\tit := c.Bucket(r.bucketName).Objects(context.Background(), &storage.Query{\n\t\tPrefix: root,\n\t\tProjection: storage.ProjectionNoACL,\n\t})\n\n\tattrs, err := it.Next()\n\n\tfor err == nil {\n\t\to := c.Bucket(r.bucketName).Object(attrs.Name).Retryer(storage.WithPolicy(storage.RetryAlways))\n\t\tif err := o.Delete(context.Background()); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tattrs, err = it.Next()\n\t}\n\n\tif err != iterator.Done {\n\t\treturn fmt.Errorf(\"Bucket.Objects: %w\", err)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "3294edcf09846e0cd343692deea40d53", "score": "0.56993145", "text": "func Clean() error {\n\tintfs := []string{\n\t\t\"proto/go/shenzhen-go.pb.go\",\n\t\t\"proto/js/shenzhen-go.pb.gopherjs.go\",\n\t\t\"server/view/js/client.js\",\n\t\t\"server/view/js/client.js.map\",\n\t\t\"server/view/static-css.go\",\n\t\t\"server/view/static-images.go\",\n\t\t\"server/view/static-js.go\",\n\t\t\"server/view/static-misc.go\",\n\t\t\"server/view/static-templates.go\",\n\t}\n\tfor _, intf := range intfs {\n\t\tif err := sh.Rm(intf); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "242942059d8f50b3ebde5e43d58a9a2b", "score": "0.5698627", "text": "func (sm *StackManager) Cleanup(ctx context.Context) []error {\n\tsm.lock.Lock()\n\tdefer sm.lock.Unlock()\n\n\tvar errors []error\n\n\tfor stackID, stack := range sm.stacks {\n\t\terr := sm.deleteStack(ctx, stackID, stack)\n\t\tif err != nil {\n\t\t\terrors = append(errors, err)\n\t\t}\n\t}\n\n\treturn errors\n}", "title": "" }, { "docid": "ce3dda59721abb77eb8875f260e8f2fa", "score": "0.5697181", "text": "func (f *Framework) AfterEach() {\n\t// delete the namespace(s) in a defer in case future code added here could generate\n\t// an exception. For now there is only a defer.\n\tdefer func() {\n\t\tfor _, ns := range f.namespacesToDelete {\n\t\t\tdefer func() { f.namespacesToDelete = nil }()\n\t\t\tif ns == nil || len(ns.Name) == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tginkgo.By(fmt.Sprintf(\"Destroying namespace %q for this suite.\", ns.Name))\n\t\t\terr := DeleteNS(f.K8sClient, ns.Name)\n\t\t\tgomega.Expect(err).NotTo(gomega.HaveOccurred())\n\t\t}\n\n\t\tif utils.IsStaticNfsWithInternalClusterServer() {\n\t\t\tginkgo.By(\"Deleting NFS PVs after the test\")\n\t\t\tgomega.Expect(deleteNFSPVs(f.K8sClient, f.CdiInstallNs)).To(gomega.Succeed())\n\t\t\t// manually clear out the NFS directories as we use delete retain policy.\n\t\t\tnfsServerPod, err := utils.FindPodByPrefix(f.K8sClient, f.CdiInstallNs, \"nfs-server\", \"app=nfs-server\")\n\t\t\tgomega.Expect(err).NotTo(gomega.HaveOccurred())\n\t\t\tfor i := 1; i <= pvCount; i++ {\n\t\t\t\tstdout, stderr, err := f.ExecShellInPod(nfsServerPod.Name, f.CdiInstallNs, fmt.Sprintf(\"/bin/rm -rf /data/nfs/disk%d/*\", i))\n\t\t\t\tif err != nil {\n\t\t\t\t\tfmt.Fprintf(ginkgo.GinkgoWriter, \"INFO: cleaning up nfs disk%d failed: %s, %s\\n\", i, stdout, stderr)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\tif ginkgo.CurrentSpecReport().Failed() {\n\t\tf.reporter.FailureCount++\n\t\tfmt.Fprintf(ginkgo.GinkgoWriter, \"On failure, artifacts will be collected in %s/%d_*\\n\", f.reporter.artifactsDir, f.reporter.FailureCount)\n\t\tf.reporter.Dump(f.K8sClient, f.CdiClient, ginkgo.CurrentSpecReport().RunTime)\n\t}\n}", "title": "" }, { "docid": "01d124d2b213fe0ff81dd1374aef757e", "score": "0.5692562", "text": "func Clean() {\n\t//defer utils.TimeTrack(time.Now(), \"Scheduler\")\n\tlog.Info(\"Stopping Scheduler...\")\n\tscheduler.Stop()\n\t//select {}\n}", "title": "" }, { "docid": "851ac3856643d0e2d2d3b22c08272d9a", "score": "0.56887627", "text": "func (i *JP2Image) CleanupResources() {\n\ti.cleanupStream()\n\ti.cleanupCodec()\n\ti.cleanupImage()\n}", "title": "" }, { "docid": "9639dc8eb39aed6012193eea25bb9c32", "score": "0.56873345", "text": "func (v *Verifier) Cleanup(ctx context.Context, out io.Writer, dryRun bool) error {\n\tinstrumentation.AddAttributesToCurrentSpanFromContext(ctx, map[string]string{\n\t\t\"VerifierType\": \"kubernetesCluster\",\n\t})\n\n\tclientset, err := kubernetesclient.Client(v.kubectl.KubeContext)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting Kubernetes client: %w\", err)\n\t}\n\n\tfor _, job := range v.tracker.DeployedJobs() {\n\t\t// assumes the job namespace is set and not \"\" which is the case as createJob\n\t\t// & createJobFromManifestPath set the namespace in the created Job\n\t\tnamespace := job.Namespace\n\t\tif err := k8sjobutil.ForceJobDelete(ctx, job.Name, clientset.BatchV1().Jobs(namespace), &v.kubectl); err != nil {\n\t\t\t// TODO(aaron-prindle): replace with actionable error\n\t\t\treturn errors.Wrap(err, \"cleaning up deployed job\")\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "fc1e45ca4d2276135cd7bcc445ce3977", "score": "0.5683745", "text": "func (hans *Hans) cleanup() {\n\tmod := \"[CLEANUP]\"\n\thans.Stdout.Printf(\"%s start\", mod)\n\tok := hans.interrupt() // SIGINT is trappable.\n\tif ok {\n\t\thans.Stdout.Printf(\"%s pgid recieved SIGINT\", mod)\n\t\ttime.Sleep(2 * time.Second)\n\t}\n\tfor _, app := range hans.Apps {\n\t\tif app.Running() {\n\t\t\thans.kill(app) // SIGKILL is not trappable\n\t\t\thans.Stdout.Printf(\"%s %s killed\", mod, app.Name)\n\t\t}\n\t\tif app.Watcher.Running() {\n\t\t\thans.kill(app.Watcher)\n\t\t\thans.Stdout.Printf(\"%s %s watcher closed\", mod, app.Name)\n\t\t}\n\t}\n\thans.Stdout.Printf(\"%s done\", mod)\n}", "title": "" }, { "docid": "155966e1bfe1b81af88c3b500e692a11", "score": "0.56835186", "text": "func (ts *Suite) Cleanup() {\n\tts.log.Info(\"Cleaning up...\")\n\terr := ts.cleanupResources()\n\tassert.NoError(ts.t, err)\n\toperationID, err := ts.brokerClient.DeprovisionRuntime()\n\trequire.NoError(ts.t, err)\n\terr = ts.brokerClient.AwaitOperationSucceeded(operationID, ts.DeprovisionTimeout)\n\tassert.NoError(ts.t, err)\n\n\tif ts.IsTestAzureEventHubsEnabled {\n\t\tts.log.Info(\"Checking the de-provisioned Azure EventHubs\")\n\t\tts.ensureAzureResourceGroupRemoved()\n\t}\n}", "title": "" }, { "docid": "7ac21be70ab154dcd271488310f0da78", "score": "0.5678674", "text": "func cleanUpAfterProjects(projects []string) {\n\tfor _, p := range projects {\n\t\todoDeleteProject(p)\n\t}\n}", "title": "" }, { "docid": "906df700b4139fd8039b48ddb53c8a01", "score": "0.56776315", "text": "func (p *portworx) CleanupBackupResources(*storkapi.ApplicationBackup) error {\n\treturn nil\n}", "title": "" }, { "docid": "98cb52d796bf3a843a3ea492ef388893", "score": "0.56739044", "text": "func (om *Maintainer) cleanupInternalFailedOperations() {\n\tcurrentTime := time.Now()\n\n\tcriteria := []query.Criterion{\n\t\tquery.ByField(query.EqualsOperator, \"platform_id\", types.SMPlatform),\n\t\tquery.ByField(query.EqualsOperator, \"state\", string(types.FAILED)),\n\t\tquery.ByField(query.EqualsOperator, \"reschedule\", \"false\"),\n\t\tquery.ByField(query.EqualsOperator, \"deletion_scheduled\", ZeroTime),\n\t\t// ignore cascade operations\n\t\tquery.ByField(query.EqualsOrNilOperator, \"cascade_root_id\", \"\"),\n\t\t// check if operation hasn't been updated for the operation's maximum allowed time to live in DB\n\t\tquery.ByField(query.LessThanOperator, \"updated_at\", util.ToRFCNanoFormat(currentTime.Add(-om.settings.Lifespan))),\n\t\tquery.BySubquery(query.InSubqueryOperator, \"id\", storage.GetSubQuery(storage.QueryForAllNotLastOperationsPerResource)),\n\t}\n\n\tom.batchDeleteOperation(criteria, om.settings.DeleteOperationsBatchSize)\n\n\tlog.C(om.smCtx).Debug(\"Finished cleaning up failed internal operations\")\n}", "title": "" }, { "docid": "4c664fce9acf35387e175e6a7cefdbf0", "score": "0.567271", "text": "func (a *azure) CleanupBackupResources(*storkapi.ApplicationBackup) error {\n\treturn nil\n}", "title": "" }, { "docid": "5bee2c5e305e6eec027937d5e73d932f", "score": "0.5655197", "text": "func cleanupTestInstances(insts []*Instance) {\n\tfor _, inst := range insts {\n\t\tif inst.IsAlive() {\n\t\t\tinst.Cmd.Process.Kill()\n\t\t}\n\t}\n}", "title": "" }, { "docid": "40f574fff82bdcfcc99c951afe4d466f", "score": "0.56544304", "text": "func (c *noMirrorClientFactory) Clean() error {\n\treturn os.RemoveAll(c.cacheDir)\n}", "title": "" }, { "docid": "6e1c6cb1d35ee1d8b744ddf3894a0577", "score": "0.56524026", "text": "func (db *TaskDB) Clean() error {\n\treturn db.CleanFn()\n}", "title": "" }, { "docid": "4865bdd5d79a6820c1a8e16ac0cac0d1", "score": "0.5651897", "text": "func (g *gcp) CleanupBackupResources(*storkapi.ApplicationBackup) error {\n\treturn nil\n}", "title": "" }, { "docid": "4722af74d75c45b97d9bd1404ba0b9b0", "score": "0.5647116", "text": "func (u rancherProvider) Cleanup() error {\n\treturn nil\n}", "title": "" }, { "docid": "5035e1aa0e26fbfa71696cf78ad4a663", "score": "0.5645689", "text": "func TearDownAll() error {\n\tharnessStateMutex.Lock()\n\tdefer harnessStateMutex.Unlock()\n\tfor _, h := range harnessInstances {\n\t\tif err := h.teardown(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "2a27168849475e3e982f19e9f02b9c53", "score": "0.5644958", "text": "func CleanupMetas(ctx context.Context, cfg *config.Config, tableName string) error {\n\tif tableName == \"all\" {\n\t\ttableName = \"\"\n\t}\n\t// try to clean up table metas if exists\n\tdb, err := importer.DBFromConfig(ctx, cfg.TiDB)\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\n\ttableMetaExist, err := common.TableExists(ctx, db, cfg.App.MetaSchemaName, importer.TableMetaTableName)\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tif tableMetaExist {\n\t\tmetaTableName := common.UniqueTable(cfg.App.MetaSchemaName, importer.TableMetaTableName)\n\t\tif err = importer.RemoveTableMetaByTableName(ctx, db, metaTableName, tableName); err != nil {\n\t\t\treturn errors.Trace(err)\n\t\t}\n\t}\n\n\texist, err := common.TableExists(ctx, db, cfg.App.MetaSchemaName, importer.TaskMetaTableName)\n\tif err != nil || !exist {\n\t\treturn errors.Trace(err)\n\t}\n\treturn errors.Trace(importer.MaybeCleanupAllMetas(ctx, log.L(), db, cfg.App.MetaSchemaName, tableMetaExist))\n}", "title": "" }, { "docid": "a57d10fab9245f94c56972e9bf64a87c", "score": "0.56432533", "text": "func Clean() {\r\n\tstoreMutex.Lock()\r\n\tdefer storeMutex.Unlock()\r\n\r\n\tbuf := []Mock{}\r\n\tfor _, mock := range mocks {\r\n\t\tif mock.Done() {\r\n\t\t\tcontinue\r\n\t\t}\r\n\t\tbuf = append(buf, mock)\r\n\t}\r\n\r\n\tmocks = buf\r\n}", "title": "" }, { "docid": "426b88351f76e1909ec034b29ce001dd", "score": "0.5639664", "text": "func (t *ChildrenTraverser) Cleanup(forceRelease bool) {\n\tt.metadataMemcache.Cleanup(forceRelease)\n}", "title": "" }, { "docid": "aa42b05bebd8d30f0aaaea910ddc66db", "score": "0.563347", "text": "func (pe *ProcessEndpoints) Cleanup() {\n\tfor _, e := range pe.Endpoints {\n\t\te.Cleanup()\n\t}\n}", "title": "" }, { "docid": "d4f154e5dc10049afd4e72340ebe2402", "score": "0.56261086", "text": "func (c *TrivyCacheCleaner) Clean() error {\n\tif workloadmeta.GetGlobalStore() == nil {\n\t\treturn nil\n\t}\n\n\timages := workloadmeta.GetGlobalStore().ListImages()\n\n\ttoKeep := make(map[string]struct{}, len(images))\n\tfor _, imageMetadata := range images {\n\t\tfor _, key := range c.cachedKeysForEntity[imageMetadata.EntityID.ID] {\n\t\t\ttoKeep[key] = struct{}{}\n\t\t}\n\t}\n\n\ttoRemove := make([]string, 0, c.target.Cache.Len())\n\tfor _, key := range c.target.Cache.Keys() {\n\t\tif _, ok := toKeep[key]; !ok {\n\t\t\ttoRemove = append(toRemove, key)\n\t\t}\n\t}\n\n\tif err := c.target.Cache.Remove(toRemove); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "449947ed6f4d8b0c1b262593d99720d8", "score": "0.5626086", "text": "func (tf *TempFactory) Cleanup() {\n\tfor _, file := range tf.files {\n\t\tos.Remove(file)\n\t}\n\t// Also remove the tempdir if it's not DEVSHM\n\tif !strings.Contains(tf.path, DEVSHM) {\n\t\tos.Remove(tf.path)\n\t}\n\ttf = nil\n}", "title": "" }, { "docid": "4bb04aff08c6449b2922f523c338c74a", "score": "0.5619435", "text": "func (cleaner *Cleaner) Clean() error {\n\tconnectionNames := cleaner.connection.GetConnections()\n\tfor _, connectionName := range connectionNames {\n\t\tconnection := cleaner.connection.hijackConnection(connectionName)\n\t\tif connection.Check() {\n\t\t\tcontinue // skip active connections!\n\t\t}\n\n\t\tif err := cleaner.CleanConnection(nil); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "d14a5c9560c979d712f7f166d26234dc", "score": "0.56110954", "text": "func (iMgr *IPSetManager) fileCreatorForDestroyAll(names []string, failedNames, setsWithReferences map[string]struct{}) (creator *ioutil.FileCreator, failureCount *int) {\n\tfailureCountVal := 0\n\tfailureCount = &failureCountVal\n\tcreator = ioutil.NewFileCreator(iMgr.ioShim, maxTryCount, ipsetRestoreLineFailurePattern)\n\n\t// destroy all the sets\n\tfor _, hashedSetName := range names {\n\t\tif _, ok := failedNames[hashedSetName]; ok {\n\t\t\tklog.Infof(\"skipping destroy for set %s since it failed to flush\", hashedSetName)\n\t\t\tcontinue\n\t\t}\n\n\t\tif _, ok := setsWithReferences[hashedSetName]; ok {\n\t\t\tklog.Infof(\"skipping destroy for set %s since it has leaked reference counts\", hashedSetName)\n\t\t\tcontinue\n\t\t}\n\n\t\thashedSetName := hashedSetName // to appease go lint\n\t\terrorHandlers := []*ioutil.LineErrorHandler{\n\t\t\t// error handlers specific to resetting ipsets\n\t\t\t{\n\t\t\t\tDefinition: setInUseByKernelDefinition,\n\t\t\t\tMethod: ioutil.Continue,\n\t\t\t\tCallback: func() {\n\t\t\t\t\tmetrics.SendErrorLogAndMetric(util.IpsmID, \"[RESET-IPSETS] marking destroy for set %s as a failure since the set is in use by a kernel component\", hashedSetName)\n\t\t\t\t\tfailureCountVal++\n\t\t\t\t\t// TODO mark the set as a failure and reconcile what iptables rule or ipset is referring to it\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tDefinition: setDoesntExistDefinition,\n\t\t\t\tMethod: ioutil.Continue,\n\t\t\t\tCallback: func() {\n\t\t\t\t\tklog.Infof(\"[RESET-IPSETS] skipping destroy for set %s since the set does not exist\", hashedSetName)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tDefinition: ioutil.AlwaysMatchDefinition,\n\t\t\t\tMethod: ioutil.Continue,\n\t\t\t\tCallback: func() {\n\t\t\t\t\tmetrics.SendErrorLogAndMetric(util.IpsmID, \"[RESET-IPSETS] marking destroy for set %s as a failure due to unknown error\", hashedSetName)\n\t\t\t\t\tfailureCountVal++\n\t\t\t\t\t// TODO mark the set as a failure and reconcile what iptables rule or ipset is referring to it\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t\tsectionID := sectionID(destroySectionPrefix, hashedSetName)\n\t\tcreator.AddLine(sectionID, errorHandlers, ipsetDestroyFlag, hashedSetName) // destroy set\n\t}\n\n\treturn creator, failureCount\n}", "title": "" }, { "docid": "46bfcefd94c7cf0357fe0ac34cfe04d2", "score": "0.5605455", "text": "func (c *sqlCache) cleanUp() {\n\tfor {\n\t\t_, err := c.cleanUpStmt.Exec()\n\t\tif err != nil {\n\t\t\tlog.Printf(\"cleanUp SQL Error: %s\", err)\n\t\t}\n\t\ttime.Sleep(1 * time.Hour)\n\t}\n}", "title": "" }, { "docid": "b8a6b6bf3b1fcf387c32ecc4eb31b9c9", "score": "0.5602909", "text": "func (c *Cache) FlushAll() error {\n url := path.Join(c.Dir)\n err := os.RemoveAll(url)\n if err == nil {\n err = os.MkdirAll(url, c.Permissions)\n }\n return err\n}", "title": "" }, { "docid": "395fc15f154480b65d7125696f744771", "score": "0.5602303", "text": "func (c *Coordinator) Cleanup() {\n\tc.logs.Close()\n\tc.logs.RemoveAll()\n}", "title": "" }, { "docid": "c12f876bdf6aadf41de41ecccfd9cf2d", "score": "0.5600404", "text": "func (s *Storage) Cleanup(ctx context.Context) error {\n\tselect {\n\tcase <-s.stop:\n\t\treturn nil\n\tdefault:\n\t\t// This means than s.tasksWG.Wait has not been called yet\n\t\t// and it is safe to start the cleanup. There is a negligible\n\t\t// chance that tasksWG.Wait is called concurrently before we\n\t\t// continue.\n\t}\n\ts.tasksWG.Add(1)\n\tdefer s.tasksWG.Done()\n\tstart := time.Now()\n\ts.logger.Debug(\"cleanup started\")\n\tdefer func() {\n\t\ts.logger.WithField(\"duration\", time.Since(start)).Debug(\"cleanup finished\")\n\t}()\n\treturn s.cleanupTreesDB(ctx)\n}", "title": "" }, { "docid": "d628cec37fddf0949c95a1b3817899e3", "score": "0.5596522", "text": "func (c *Cleaner) Clean() {\n\tvar arr cleanItems\n\tfor _, name := range info.ListFunctions(c.bindir) {\n\t\tinfo, err := info.ByName(name, c.bindir, c.sep)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\t//arr = append(arr, info.Time.Unix())\n\t\tarr = append(arr, cleanItem{\n\t\t\tname: name,\n\t\t\ttime: info.Time.Unix(),\n\t\t})\n\t}\n\tsort.Sort(arr)\n\tfor _, item := range arr.notNeeded(c.itemMax) {\n\t\tdeleteGofn(item.nameToPath(c.bindir, c.sep))\n\t}\n}", "title": "" }, { "docid": "162213afaa44f45b6a863e79a0290196", "score": "0.559471", "text": "func afterResources(cfg *config.Config) cli.AfterFunc {\n\treturn func(cliContext *cli.Context) (err error) {\n\t\t// Cleanup\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "ca9062b88e2f87d9b161d7dc81379241", "score": "0.55943143", "text": "func (mdb *McflyDB) Clean() {\n\ttx, err := mdb.Begin()\n\tcheckDbNotFoundErr(err, mdb.DatabaseName)\n\ttx.Exec(\"DELETE FROM build\")\n\ttx.Exec(\"DELETE FROM user_project\")\n\ttx.Exec(\"DELETE FROM project\")\n\ttx.Exec(\"DELETE FROM provider_access_token\")\n\ttx.Exec(\"DELETE FROM mcfly_user\")\n\ttx.Commit()\n}", "title": "" }, { "docid": "2f52874caa05abc9fae4db08ff5d156b", "score": "0.5584878", "text": "func (w *workerDelegate) CleanupMachineDependencies(_ context.Context) error {\n\treturn nil\n}", "title": "" }, { "docid": "65407cdd8339a74b3a15079ade14440f", "score": "0.5580148", "text": "func (r *KubernetesReporter) Cleanup() {\n\t// clean up artifacts from previous run\n\tif r.artifactsDir != \"\" {\n\t\tos.RemoveAll(r.artifactsDir)\n\t}\n}", "title": "" }, { "docid": "2cbe603afe4cc77fb19aadf064f2a85f", "score": "0.5575731", "text": "func (p *WorkerPool) CleanUp(ctx context.Context) {\n\tlog.Trace(\"WorkerPool: %d CleanUp\", p.qid)\n\tclose(p.dataChan)\n\tfor data := range p.dataChan {\n\t\tp.handle(data)\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tlog.Warn(\"WorkerPool: %d Cleanup context closed before finishing clean-up\", p.qid)\n\t\t\treturn\n\t\tdefault:\n\t\t}\n\t}\n\tlog.Trace(\"WorkerPool: %d CleanUp Done\", p.qid)\n}", "title": "" }, { "docid": "1bd0551b442e5144c769c2c70ba6ec7a", "score": "0.5572997", "text": "func (cp *ConnPool) Clean() {\n\tcp.Lock()\n\tfor conn := range cp.conns {\n\t\tif conn != nil {\n\t\t\tconn.Close()\n\t\t}\n\t}\n\tcp.active = 0\n\tcp.conns = nil\n\tcp.Unlock()\n}", "title": "" }, { "docid": "dbc04b1155e4b79806965378b6946ed3", "score": "0.556823", "text": "func (c Courier) CleanUp() error {\n\treturn c.Executor.CleanUp()\n}", "title": "" } ]
940da8bc2892a56496d7c66f693e87bd
Deprecated: Please use package github.com/Azure/azuresdkforgo/services/servicefabric/6.2/servicefabric instead AsStatelessServiceDescription is the BasicServiceDescription implementation for ServiceDescription.
[ { "docid": "3eddc8255e00733fbe200ab4394e9966", "score": "0.75311065", "text": "func (sd ServiceDescription) AsStatelessServiceDescription() (*StatelessServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" } ]
[ { "docid": "066f76243a3eb1e8ac8ab3731b189fa5", "score": "0.7636737", "text": "func (ssd StatefulServiceDescription) AsStatelessServiceDescription() (*StatelessServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "066f76243a3eb1e8ac8ab3731b189fa5", "score": "0.7636737", "text": "func (ssd StatefulServiceDescription) AsStatelessServiceDescription() (*StatelessServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "448c9d61834469cff807d2593866ee28", "score": "0.71852726", "text": "func (scsd StatefulCreateServiceDescription) AsStatelessCreateServiceDescription() (*StatelessCreateServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "448c9d61834469cff807d2593866ee28", "score": "0.71852726", "text": "func (scsd StatefulCreateServiceDescription) AsStatelessCreateServiceDescription() (*StatelessCreateServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "343fecaa755491d4ea278cdc2add7f9b", "score": "0.71693397", "text": "func (ssd StatelessServiceDescription) AsStatelessServiceDescription() (*StatelessServiceDescription, bool) {\n\treturn &ssd, true\n}", "title": "" }, { "docid": "343fecaa755491d4ea278cdc2add7f9b", "score": "0.71693397", "text": "func (ssd StatelessServiceDescription) AsStatelessServiceDescription() (*StatelessServiceDescription, bool) {\n\treturn &ssd, true\n}", "title": "" }, { "docid": "e730cae32fae5889ded44ca2f0f0b4e3", "score": "0.70922786", "text": "func (csd CreateServiceDescription) AsStatelessCreateServiceDescription() (*StatelessCreateServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "08e6233a62e5a05265fb62f15a3c3bfc", "score": "0.6867403", "text": "func (ssd StatelessServiceDescription) AsStatefulServiceDescription() (*StatefulServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "08e6233a62e5a05265fb62f15a3c3bfc", "score": "0.6867403", "text": "func (ssd StatelessServiceDescription) AsStatefulServiceDescription() (*StatefulServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "716ff4c40273a235a2ef427ebad45f0f", "score": "0.6832766", "text": "func (ssd StatelessServiceDescription) AsServiceDescription() (*ServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "8fcfa8461a7259fba9dc32b288e1983c", "score": "0.6770596", "text": "func (scsd StatelessCreateServiceDescription) AsStatelessCreateServiceDescription() (*StatelessCreateServiceDescription, bool) {\n\treturn &scsd, true\n}", "title": "" }, { "docid": "8fcfa8461a7259fba9dc32b288e1983c", "score": "0.6770596", "text": "func (scsd StatelessCreateServiceDescription) AsStatelessCreateServiceDescription() (*StatelessCreateServiceDescription, bool) {\n\treturn &scsd, true\n}", "title": "" }, { "docid": "713ce2dc9318e72f35d9626cad816ac6", "score": "0.67543185", "text": "func (susd StatefulUpdateServiceDescription) AsStatelessUpdateServiceDescription() (*StatelessUpdateServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "713ce2dc9318e72f35d9626cad816ac6", "score": "0.67543185", "text": "func (susd StatefulUpdateServiceDescription) AsStatelessUpdateServiceDescription() (*StatelessUpdateServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "260346c29a622ab5b217a1c8045fa361", "score": "0.6709268", "text": "func (usd UpdateServiceDescription) AsStatelessUpdateServiceDescription() (*StatelessUpdateServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "2ea6359b456091c76c5517eb767dee14", "score": "0.66188866", "text": "func (ssd StatelessServiceDescription) AsBasicServiceDescription() (BasicServiceDescription, bool) {\n\treturn &ssd, true\n}", "title": "" }, { "docid": "b07e486f1e86dd109083b5a7debc17a0", "score": "0.6562976", "text": "func (ssgd StatefulServiceGroupDescription) AsStatelessServiceGroupDescription() (*StatelessServiceGroupDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "b07e486f1e86dd109083b5a7debc17a0", "score": "0.6562976", "text": "func (ssgd StatefulServiceGroupDescription) AsStatelessServiceGroupDescription() (*StatelessServiceGroupDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "0c065ea84d1ee05253ad870d2be0037d", "score": "0.6507642", "text": "func (ssd StatefulServiceDescription) AsBasicServiceDescription() (BasicServiceDescription, bool) {\n\treturn &ssd, true\n}", "title": "" }, { "docid": "1c76baadd5376112b894907bd54746a0", "score": "0.6434728", "text": "func (ssd StatefulServiceDescription) AsServiceDescription() (*ServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "f6755a008b0eb76183a620a4e643d555", "score": "0.6433925", "text": "func (sgd ServiceGroupDescription) AsStatelessServiceGroupDescription() (*StatelessServiceGroupDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "c1e157c2c3a35b016457dcaf1e55978e", "score": "0.6426171", "text": "func (scsd StatelessCreateServiceDescription) AsStatefulCreateServiceDescription() (*StatefulCreateServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "c1e157c2c3a35b016457dcaf1e55978e", "score": "0.6426171", "text": "func (scsd StatelessCreateServiceDescription) AsStatefulCreateServiceDescription() (*StatefulCreateServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "aa22c935ba038000b298557ce9e5788f", "score": "0.64082", "text": "func (csgd CreateServiceGroupDescription) AsStatelessCreateServiceGroupDescription() (*StatelessCreateServiceGroupDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "879f23adc9b3a7d64db331cb1ffb7948", "score": "0.64074486", "text": "func (ssd StatefulServiceDescription) AsStatefulServiceDescription() (*StatefulServiceDescription, bool) {\n\treturn &ssd, true\n}", "title": "" }, { "docid": "879f23adc9b3a7d64db331cb1ffb7948", "score": "0.64074486", "text": "func (ssd StatefulServiceDescription) AsStatefulServiceDescription() (*StatefulServiceDescription, bool) {\n\treturn &ssd, true\n}", "title": "" }, { "docid": "97276cb3f8451ce74fb47150f9b5f009", "score": "0.63708836", "text": "func (f *Pingable_ServiceFactory) ServiceDescription() service_describer.ServiceDescription {\n\treturn &Pingable_ServiceDescription{}\n}", "title": "" }, { "docid": "e42b25f3bef6553c2a6126e74b43d43d", "score": "0.63191193", "text": "func (susd StatelessUpdateServiceDescription) AsStatelessUpdateServiceDescription() (*StatelessUpdateServiceDescription, bool) {\n\treturn &susd, true\n}", "title": "" }, { "docid": "e42b25f3bef6553c2a6126e74b43d43d", "score": "0.63191193", "text": "func (susd StatelessUpdateServiceDescription) AsStatelessUpdateServiceDescription() (*StatelessUpdateServiceDescription, bool) {\n\treturn &susd, true\n}", "title": "" }, { "docid": "8348e9acc32d416e95c7b8534ed8d53e", "score": "0.6296209", "text": "func (sd ServiceDescription) AsStatefulServiceDescription() (*StatefulServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "a849b49dbf932489f21a61f2c933cc58", "score": "0.6274239", "text": "func (f *B_ServiceFactory) ServiceDescription() service_describer.ServiceDescription {\n\treturn &B_ServiceDescription{}\n}", "title": "" }, { "docid": "063dee8fdb05441541e8e7faaafaf308", "score": "0.6263485", "text": "func (scsgd StatefulCreateServiceGroupDescription) AsStatelessCreateServiceGroupDescription() (*StatelessCreateServiceGroupDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "063dee8fdb05441541e8e7faaafaf308", "score": "0.6263485", "text": "func (scsgd StatefulCreateServiceGroupDescription) AsStatelessCreateServiceGroupDescription() (*StatelessCreateServiceGroupDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "313bdc18558fec73c820a1dd3221ce51", "score": "0.6248781", "text": "func (f *A_ServiceFactory) ServiceDescription() service_describer.ServiceDescription {\n\treturn &A_ServiceDescription{}\n}", "title": "" }, { "docid": "ffc77851fc939a61ef3dded6681ec3c6", "score": "0.6214155", "text": "func (f *Echo_ServiceFactory) ServiceDescription() service_describer.ServiceDescription {\n\treturn &Echo_ServiceDescription{}\n}", "title": "" }, { "docid": "11b5f19c15a837a16617dc991ae1dcf0", "score": "0.61859375", "text": "func (ssd StatefulServiceDescription) MarshalJSON() ([]byte, error) {\n\tssd.ServiceKind = ServiceKindBasicServiceDescriptionServiceKindStateful\n\tobjectMap := make(map[string]interface{})\n\tif ssd.TargetReplicaSetSize != nil {\n\t\tobjectMap[\"TargetReplicaSetSize\"] = ssd.TargetReplicaSetSize\n\t}\n\tif ssd.MinReplicaSetSize != nil {\n\t\tobjectMap[\"MinReplicaSetSize\"] = ssd.MinReplicaSetSize\n\t}\n\tif ssd.HasPersistedState != nil {\n\t\tobjectMap[\"HasPersistedState\"] = ssd.HasPersistedState\n\t}\n\tif ssd.ReplicaRestartWaitDurationSeconds != nil {\n\t\tobjectMap[\"ReplicaRestartWaitDurationSeconds\"] = ssd.ReplicaRestartWaitDurationSeconds\n\t}\n\tif ssd.QuorumLossWaitDurationSeconds != nil {\n\t\tobjectMap[\"QuorumLossWaitDurationSeconds\"] = ssd.QuorumLossWaitDurationSeconds\n\t}\n\tif ssd.StandByReplicaKeepDurationSeconds != nil {\n\t\tobjectMap[\"StandByReplicaKeepDurationSeconds\"] = ssd.StandByReplicaKeepDurationSeconds\n\t}\n\tif ssd.DefaultMoveCost != \"\" {\n\t\tobjectMap[\"DefaultMoveCost\"] = ssd.DefaultMoveCost\n\t}\n\tif ssd.IsDefaultMoveCostSpecified != nil {\n\t\tobjectMap[\"IsDefaultMoveCostSpecified\"] = ssd.IsDefaultMoveCostSpecified\n\t}\n\tif ssd.ApplicationName != nil {\n\t\tobjectMap[\"ApplicationName\"] = ssd.ApplicationName\n\t}\n\tif ssd.ServiceName != nil {\n\t\tobjectMap[\"ServiceName\"] = ssd.ServiceName\n\t}\n\tif ssd.ServiceTypeName != nil {\n\t\tobjectMap[\"ServiceTypeName\"] = ssd.ServiceTypeName\n\t}\n\tif ssd.PartitionDescription != nil {\n\t\tobjectMap[\"PartitionDescription\"] = ssd.PartitionDescription\n\t}\n\tif ssd.PlacementConstraints != nil {\n\t\tobjectMap[\"PlacementConstraints\"] = ssd.PlacementConstraints\n\t}\n\tif ssd.CorrelationScheme != nil {\n\t\tobjectMap[\"CorrelationScheme\"] = ssd.CorrelationScheme\n\t}\n\tif ssd.ServiceLoadMetrics != nil {\n\t\tobjectMap[\"ServiceLoadMetrics\"] = ssd.ServiceLoadMetrics\n\t}\n\tif ssd.ServicePlacementPolicies != nil {\n\t\tobjectMap[\"ServicePlacementPolicies\"] = ssd.ServicePlacementPolicies\n\t}\n\tif ssd.Flags != nil {\n\t\tobjectMap[\"Flags\"] = ssd.Flags\n\t}\n\tif ssd.ServiceKind != \"\" {\n\t\tobjectMap[\"ServiceKind\"] = ssd.ServiceKind\n\t}\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "e3bb072f561e64b83bd545f75d0e9e24", "score": "0.61683005", "text": "func buildHeadlessService(name types.NamespacedName) *corev1.Service {\n\ts := &corev1.Service{}\n\ts.APIVersion = \"v1\"\n\ts.Kind = \"Service\"\n\ts.Name = name.Name\n\ts.Namespace = name.Namespace\n\n\ts.Spec.ClusterIP = corev1.ClusterIPNone\n\ts.Spec.Type = corev1.ServiceTypeClusterIP\n\n\treturn s\n}", "title": "" }, { "docid": "24245fdb875f9b18807c2f0bf2231783", "score": "0.61682934", "text": "func (f *PingService_ServiceFactory) ServiceDescription() service_describer.ServiceDescription {\n\treturn &PingService_ServiceDescription{}\n}", "title": "" }, { "docid": "a6853cc9a55d39453df8aba76eb706cb", "score": "0.6148819", "text": "func (susgd StatefulUpdateServiceGroupDescription) AsStatelessUpdateServiceGroupDescription() (*StatelessUpdateServiceGroupDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "a6853cc9a55d39453df8aba76eb706cb", "score": "0.6148819", "text": "func (susgd StatefulUpdateServiceGroupDescription) AsStatelessUpdateServiceGroupDescription() (*StatelessUpdateServiceGroupDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "f873d31e8d3d9a529a77b23976e54dfd", "score": "0.6131783", "text": "func (scsd StatefulCreateServiceDescription) AsStatefulCreateServiceDescription() (*StatefulCreateServiceDescription, bool) {\n\treturn &scsd, true\n}", "title": "" }, { "docid": "f873d31e8d3d9a529a77b23976e54dfd", "score": "0.6131783", "text": "func (scsd StatefulCreateServiceDescription) AsStatefulCreateServiceDescription() (*StatefulCreateServiceDescription, bool) {\n\treturn &scsd, true\n}", "title": "" }, { "docid": "ba0006d8bd7dfef779ace66ae6eccf8a", "score": "0.6125768", "text": "func (f *C_ServiceFactory) ServiceDescription() service_describer.ServiceDescription {\n\treturn &C_ServiceDescription{}\n}", "title": "" }, { "docid": "fff8e1796e202a2dcdec7be7a7e73339", "score": "0.61018", "text": "func (usgd UpdateServiceGroupDescription) AsStatelessUpdateServiceGroupDescription() (*StatelessUpdateServiceGroupDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "4fc55b7eeb3e605d902a8e645eee3d62", "score": "0.6074933", "text": "func (ssgd StatelessServiceGroupDescription) AsStatelessServiceGroupDescription() (*StatelessServiceGroupDescription, bool) {\n\treturn &ssgd, true\n}", "title": "" }, { "docid": "4fc55b7eeb3e605d902a8e645eee3d62", "score": "0.6074933", "text": "func (ssgd StatelessServiceGroupDescription) AsStatelessServiceGroupDescription() (*StatelessServiceGroupDescription, bool) {\n\treturn &ssgd, true\n}", "title": "" }, { "docid": "e145ef7deada34c8781d411126e5b054", "score": "0.6058942", "text": "func (scsd StatelessCreateServiceDescription) AsBasicCreateServiceDescription() (BasicCreateServiceDescription, bool) {\n\treturn &scsd, true\n}", "title": "" }, { "docid": "ead937ebb6db024edcc432591d3415e2", "score": "0.6004574", "text": "func (f *ApplicationConnector_ServiceFactory) ServiceDescription() service_describer.ServiceDescription {\n\treturn &ApplicationConnector_ServiceDescription{}\n}", "title": "" }, { "docid": "88b8e89ad18a214241541ea1aefaee8b", "score": "0.59936553", "text": "func NewService(ctx *pulumi.Context,\n\tname string, args *ServiceArgs, opts ...pulumi.ResourceOption) (*Service, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.ApplicationName == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'ApplicationName'\")\n\t}\n\tif args.ClusterName == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'ClusterName'\")\n\t}\n\tif args.ResourceGroupName == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'ResourceGroupName'\")\n\t}\n\tif args.ServiceKind == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'ServiceKind'\")\n\t}\n\taliases := pulumi.Aliases([]pulumi.Alias{\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:servicefabric/v20191101preview:Service\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:servicefabric:Service\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:servicefabric:Service\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:servicefabric/v20170701preview:Service\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:servicefabric/v20170701preview:Service\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:servicefabric/v20190301:Service\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:servicefabric/v20190301:Service\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:servicefabric/v20190301preview:Service\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:servicefabric/v20190301preview:Service\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:servicefabric/v20190601preview:Service\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:servicefabric/v20190601preview:Service\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:servicefabric/v20200301:Service\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:servicefabric/v20200301:Service\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:servicefabric/v20201201preview:Service\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:servicefabric/v20201201preview:Service\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:servicefabric/v20210601:Service\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:servicefabric/v20210601:Service\"),\n\t\t},\n\t})\n\topts = append(opts, aliases)\n\tvar resource Service\n\terr := ctx.RegisterResource(\"azure-native:servicefabric/v20191101preview:Service\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "title": "" }, { "docid": "5ac7cf72919c29e5e7be7990bffa1f58", "score": "0.59807175", "text": "func (scsd StatefulCreateServiceDescription) AsBasicCreateServiceDescription() (BasicCreateServiceDescription, bool) {\n\treturn &scsd, true\n}", "title": "" }, { "docid": "00d10d4dfb8a4264bd5502bf19d2f95f", "score": "0.593617", "text": "func (scsd StatefulCreateServiceDescription) MarshalJSON() ([]byte, error) {\n\tscsd.ServiceKind = ServiceKindStateful1\n\tobjectMap := make(map[string]interface{})\n\tif scsd.TargetReplicaSetSize != nil {\n\t\tobjectMap[\"TargetReplicaSetSize\"] = scsd.TargetReplicaSetSize\n\t}\n\tif scsd.MinReplicaSetSize != nil {\n\t\tobjectMap[\"MinReplicaSetSize\"] = scsd.MinReplicaSetSize\n\t}\n\tif scsd.HasPersistedState != nil {\n\t\tobjectMap[\"HasPersistedState\"] = scsd.HasPersistedState\n\t}\n\tif scsd.ReplicaRestartWaitDurationSeconds != nil {\n\t\tobjectMap[\"ReplicaRestartWaitDurationSeconds\"] = scsd.ReplicaRestartWaitDurationSeconds\n\t}\n\tif scsd.QuorumLossWaitDurationSeconds != nil {\n\t\tobjectMap[\"QuorumLossWaitDurationSeconds\"] = scsd.QuorumLossWaitDurationSeconds\n\t}\n\tif scsd.StandByReplicaKeepDurationSeconds != nil {\n\t\tobjectMap[\"StandByReplicaKeepDurationSeconds\"] = scsd.StandByReplicaKeepDurationSeconds\n\t}\n\tif scsd.DefaultMoveCost != \"\" {\n\t\tobjectMap[\"DefaultMoveCost\"] = scsd.DefaultMoveCost\n\t}\n\tif scsd.IsDefaultMoveCostSpecified != nil {\n\t\tobjectMap[\"IsDefaultMoveCostSpecified\"] = scsd.IsDefaultMoveCostSpecified\n\t}\n\tif scsd.ApplicationName != nil {\n\t\tobjectMap[\"ApplicationName\"] = scsd.ApplicationName\n\t}\n\tif scsd.ServiceName != nil {\n\t\tobjectMap[\"ServiceName\"] = scsd.ServiceName\n\t}\n\tif scsd.ServiceTypeName != nil {\n\t\tobjectMap[\"ServiceTypeName\"] = scsd.ServiceTypeName\n\t}\n\tif scsd.PartitionDescription != nil {\n\t\tobjectMap[\"PartitionDescription\"] = scsd.PartitionDescription\n\t}\n\tif scsd.PlacementConstraints != nil {\n\t\tobjectMap[\"PlacementConstraints\"] = scsd.PlacementConstraints\n\t}\n\tif scsd.CorrelationScheme != nil {\n\t\tobjectMap[\"CorrelationScheme\"] = scsd.CorrelationScheme\n\t}\n\tif scsd.ServiceLoadMetrics != nil {\n\t\tobjectMap[\"ServiceLoadMetrics\"] = scsd.ServiceLoadMetrics\n\t}\n\tif scsd.ServicePlacementPolicies != nil {\n\t\tobjectMap[\"ServicePlacementPolicies\"] = scsd.ServicePlacementPolicies\n\t}\n\tif scsd.Flags != nil {\n\t\tobjectMap[\"Flags\"] = scsd.Flags\n\t}\n\tif scsd.ServiceKind != \"\" {\n\t\tobjectMap[\"ServiceKind\"] = scsd.ServiceKind\n\t}\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "dc90e75a2f4f73ac58803589aeeed179", "score": "0.5920769", "text": "func (f *Terminal_ServiceFactory) ServiceDescription() service_describer.ServiceDescription {\n\treturn &Terminal_ServiceDescription{}\n}", "title": "" }, { "docid": "d1072df2587f44fb219ff5f1c50c4298", "score": "0.5890954", "text": "func (ssd StatelessServiceDescription) MarshalJSON() ([]byte, error) {\n\tssd.ServiceKind = ServiceKindBasicServiceDescriptionServiceKindStateless\n\tobjectMap := make(map[string]interface{})\n\tif ssd.InstanceCount != nil {\n\t\tobjectMap[\"InstanceCount\"] = ssd.InstanceCount\n\t}\n\tif ssd.ApplicationName != nil {\n\t\tobjectMap[\"ApplicationName\"] = ssd.ApplicationName\n\t}\n\tif ssd.ServiceName != nil {\n\t\tobjectMap[\"ServiceName\"] = ssd.ServiceName\n\t}\n\tif ssd.ServiceTypeName != nil {\n\t\tobjectMap[\"ServiceTypeName\"] = ssd.ServiceTypeName\n\t}\n\tif ssd.PartitionDescription != nil {\n\t\tobjectMap[\"PartitionDescription\"] = ssd.PartitionDescription\n\t}\n\tif ssd.PlacementConstraints != nil {\n\t\tobjectMap[\"PlacementConstraints\"] = ssd.PlacementConstraints\n\t}\n\tif ssd.CorrelationScheme != nil {\n\t\tobjectMap[\"CorrelationScheme\"] = ssd.CorrelationScheme\n\t}\n\tif ssd.ServiceLoadMetrics != nil {\n\t\tobjectMap[\"ServiceLoadMetrics\"] = ssd.ServiceLoadMetrics\n\t}\n\tif ssd.ServicePlacementPolicies != nil {\n\t\tobjectMap[\"ServicePlacementPolicies\"] = ssd.ServicePlacementPolicies\n\t}\n\tif ssd.Flags != nil {\n\t\tobjectMap[\"Flags\"] = ssd.Flags\n\t}\n\tif ssd.ServiceKind != \"\" {\n\t\tobjectMap[\"ServiceKind\"] = ssd.ServiceKind\n\t}\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "bf395cab36090d64855c76cfa9128056", "score": "0.5874487", "text": "func (scsgd StatelessCreateServiceGroupDescription) AsStatelessCreateServiceGroupDescription() (*StatelessCreateServiceGroupDescription, bool) {\n\treturn &scsgd, true\n}", "title": "" }, { "docid": "bf395cab36090d64855c76cfa9128056", "score": "0.5874487", "text": "func (scsgd StatelessCreateServiceGroupDescription) AsStatelessCreateServiceGroupDescription() (*StatelessCreateServiceGroupDescription, bool) {\n\treturn &scsgd, true\n}", "title": "" }, { "docid": "efae0e205ca0b49b192c34cb84347100", "score": "0.58721745", "text": "func (csd CreateServiceDescription) AsStatefulCreateServiceDescription() (*StatefulCreateServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "3c709ce48fd6fa3ea6c312b824531690", "score": "0.58598435", "text": "func (scsd StatelessCreateServiceDescription) AsCreateServiceDescription() (*CreateServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "60f338fb1e66fd6eef93613c9bdb2372", "score": "0.58553606", "text": "func (ssgd StatelessServiceGroupDescription) AsStatefulServiceGroupDescription() (*StatefulServiceGroupDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "60f338fb1e66fd6eef93613c9bdb2372", "score": "0.58553606", "text": "func (ssgd StatelessServiceGroupDescription) AsStatefulServiceGroupDescription() (*StatefulServiceGroupDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "e38c069c05610e2e96fa9ce1c23616d4", "score": "0.58416635", "text": "func (f *SensorService_ServiceFactory) ServiceDescription() service_describer.ServiceDescription {\n\treturn &SensorService_ServiceDescription{}\n}", "title": "" }, { "docid": "af29b82a8043701b12d740497e39a61f", "score": "0.5776295", "text": "func (f *SensorListener_ServiceFactory) ServiceDescription() service_describer.ServiceDescription {\n\treturn &SensorListener_ServiceDescription{}\n}", "title": "" }, { "docid": "2de54a47919fd52c751f379459625397", "score": "0.5757632", "text": "func (sd ServiceDescription) AsBasicServiceDescription() (BasicServiceDescription, bool) {\n\treturn &sd, true\n}", "title": "" }, { "docid": "39502457ae8b47790eaf73271c186c08", "score": "0.5747593", "text": "func (susd StatelessUpdateServiceDescription) AsStatefulUpdateServiceDescription() (*StatefulUpdateServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "39502457ae8b47790eaf73271c186c08", "score": "0.5747593", "text": "func (susd StatelessUpdateServiceDescription) AsStatefulUpdateServiceDescription() (*StatefulUpdateServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "d07226b09303345ccf759f23e4ef69b2", "score": "0.573841", "text": "func (susgd StatelessUpdateServiceGroupDescription) AsStatelessUpdateServiceGroupDescription() (*StatelessUpdateServiceGroupDescription, bool) {\n\treturn &susgd, true\n}", "title": "" }, { "docid": "d07226b09303345ccf759f23e4ef69b2", "score": "0.573841", "text": "func (susgd StatelessUpdateServiceGroupDescription) AsStatelessUpdateServiceGroupDescription() (*StatelessUpdateServiceGroupDescription, bool) {\n\treturn &susgd, true\n}", "title": "" }, { "docid": "ae7891cb9f11a0a89d4659d878d1109d", "score": "0.5722384", "text": "func (scsd StatelessCreateServiceDescription) MarshalJSON() ([]byte, error) {\n\tscsd.ServiceKind = ServiceKindStateless1\n\tobjectMap := make(map[string]interface{})\n\tif scsd.InstanceCount != nil {\n\t\tobjectMap[\"InstanceCount\"] = scsd.InstanceCount\n\t}\n\tif scsd.ApplicationName != nil {\n\t\tobjectMap[\"ApplicationName\"] = scsd.ApplicationName\n\t}\n\tif scsd.ServiceName != nil {\n\t\tobjectMap[\"ServiceName\"] = scsd.ServiceName\n\t}\n\tif scsd.ServiceTypeName != nil {\n\t\tobjectMap[\"ServiceTypeName\"] = scsd.ServiceTypeName\n\t}\n\tif scsd.PartitionDescription != nil {\n\t\tobjectMap[\"PartitionDescription\"] = scsd.PartitionDescription\n\t}\n\tif scsd.PlacementConstraints != nil {\n\t\tobjectMap[\"PlacementConstraints\"] = scsd.PlacementConstraints\n\t}\n\tif scsd.CorrelationScheme != nil {\n\t\tobjectMap[\"CorrelationScheme\"] = scsd.CorrelationScheme\n\t}\n\tif scsd.ServiceLoadMetrics != nil {\n\t\tobjectMap[\"ServiceLoadMetrics\"] = scsd.ServiceLoadMetrics\n\t}\n\tif scsd.ServicePlacementPolicies != nil {\n\t\tobjectMap[\"ServicePlacementPolicies\"] = scsd.ServicePlacementPolicies\n\t}\n\tif scsd.Flags != nil {\n\t\tobjectMap[\"Flags\"] = scsd.Flags\n\t}\n\tif scsd.ServiceKind != \"\" {\n\t\tobjectMap[\"ServiceKind\"] = scsd.ServiceKind\n\t}\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "f637f94eef49bb2c3009c9e38611294b", "score": "0.5717515", "text": "func (f *Gpu_ServiceFactory) ServiceDescription() service_describer.ServiceDescription {\n\treturn &Gpu_ServiceDescription{}\n}", "title": "" }, { "docid": "db2fa7665bbb70deb9774ba8771e8fc6", "score": "0.57036865", "text": "func (f *File_ServiceFactory) ServiceDescription() service_describer.ServiceDescription {\n\treturn &File_ServiceDescription{}\n}", "title": "" }, { "docid": "88bb5ed13475eb7d6116fb7977862a7e", "score": "0.56786907", "text": "func (f *AuthenticatingUrlLoaderInterceptorMetaFactory_ServiceFactory) ServiceDescription() service_describer.ServiceDescription {\n\treturn &AuthenticatingUrlLoaderInterceptorMetaFactory_ServiceDescription{}\n}", "title": "" }, { "docid": "a964aa4ba2658770576281a49ef9d953", "score": "0.5678021", "text": "func (scsd StatefulCreateServiceDescription) AsCreateServiceDescription() (*CreateServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "e43b9fac79fa26e9de0e225ec6278dcd", "score": "0.5652414", "text": "func (ssgd StatelessServiceGroupDescription) AsServiceGroupDescription() (*ServiceGroupDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "6d262590d9e84e19689613c4ea998340", "score": "0.5639274", "text": "func (scsgd StatelessCreateServiceGroupDescription) AsStatefulCreateServiceGroupDescription() (*StatefulCreateServiceGroupDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "6d262590d9e84e19689613c4ea998340", "score": "0.5639274", "text": "func (scsgd StatelessCreateServiceGroupDescription) AsStatefulCreateServiceGroupDescription() (*StatefulCreateServiceGroupDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "d0d9ae1cf4a543d66a9a0581b0a88f13", "score": "0.5632937", "text": "func (ssgd StatefulServiceGroupDescription) AsStatefulServiceGroupDescription() (*StatefulServiceGroupDescription, bool) {\n\treturn &ssgd, true\n}", "title": "" }, { "docid": "d0d9ae1cf4a543d66a9a0581b0a88f13", "score": "0.5632937", "text": "func (ssgd StatefulServiceGroupDescription) AsStatefulServiceGroupDescription() (*StatefulServiceGroupDescription, bool) {\n\treturn &ssgd, true\n}", "title": "" }, { "docid": "b615d88bcdfd892bb83dd40657689978", "score": "0.56119066", "text": "func (sd ServiceDescription) AsServiceDescription() (*ServiceDescription, bool) {\n\treturn &sd, true\n}", "title": "" }, { "docid": "511c64cc7a3906802f669381f34c5fda", "score": "0.55945706", "text": "func (f *NativeViewport_ServiceFactory) ServiceDescription() service_describer.ServiceDescription {\n\treturn &NativeViewport_ServiceDescription{}\n}", "title": "" }, { "docid": "35f5babef471b9fc0767fc5bc7a82841", "score": "0.55825704", "text": "func (susd StatefulUpdateServiceDescription) AsStatefulUpdateServiceDescription() (*StatefulUpdateServiceDescription, bool) {\n\treturn &susd, true\n}", "title": "" }, { "docid": "35f5babef471b9fc0767fc5bc7a82841", "score": "0.55825704", "text": "func (susd StatefulUpdateServiceDescription) AsStatefulUpdateServiceDescription() (*StatefulUpdateServiceDescription, bool) {\n\treturn &susd, true\n}", "title": "" }, { "docid": "1e56841f802b5fe45acf03052161e19c", "score": "0.557534", "text": "func NewService(\n\ttransact persistence.Transactioner,\n\tapplicationRepository applicationRepository,\n\tlabelDefRepository labelDefRepository,\n\tlabelRepository labelRepository,\n\tformationRepository FormationRepository,\n\tformationTemplateRepository FormationTemplateRepository,\n\tlabelService labelService,\n\tuuidService uuidService,\n\tlabelDefService labelDefService,\n\tasaRepo automaticFormationAssignmentRepository,\n\tasaService automaticFormationAssignmentService,\n\ttenantSvc tenantService, runtimeRepo runtimeRepository,\n\truntimeContextRepo runtimeContextRepository,\n\tformationAssignmentService formationAssignmentService,\n\tformationAssignmentNotificationService FormationAssignmentNotificationsService,\n\tnotificationsService NotificationsService,\n\tconstraintEngine constraintEngine,\n\twebhookRepository webhookRepository,\n\tstatusService statusService,\n\truntimeTypeLabelKey, applicationTypeLabelKey string) *service {\n\treturn &service{\n\t\ttransact: transact,\n\t\tapplicationRepository: applicationRepository,\n\t\tlabelDefRepository: labelDefRepository,\n\t\tlabelRepository: labelRepository,\n\t\tformationRepository: formationRepository,\n\t\tformationTemplateRepository: formationTemplateRepository,\n\t\tlabelService: labelService,\n\t\tlabelDefService: labelDefService,\n\t\tasaService: asaService,\n\t\tuuidService: uuidService,\n\t\ttenantSvc: tenantSvc,\n\t\trepo: asaRepo,\n\t\truntimeRepo: runtimeRepo,\n\t\truntimeContextRepo: runtimeContextRepo,\n\t\tformationAssignmentNotificationService: formationAssignmentNotificationService,\n\t\tformationAssignmentService: formationAssignmentService,\n\t\tnotificationsService: notificationsService,\n\t\tconstraintEngine: constraintEngine,\n\t\truntimeTypeLabelKey: runtimeTypeLabelKey,\n\t\tapplicationTypeLabelKey: applicationTypeLabelKey,\n\t\tasaEngine: NewASAEngine(asaRepo, runtimeRepo, runtimeContextRepo, formationRepository, formationTemplateRepository, runtimeTypeLabelKey, applicationTypeLabelKey),\n\t\twebhookRepository: webhookRepository,\n\t\tstatusService: statusService,\n\t}\n}", "title": "" }, { "docid": "9f4ef36b34af40ee299476aa7de97c60", "score": "0.5570189", "text": "func newSimpleService(namespace, name string, port, targetPort uint16) *corev1.Service {\n\tlbls := labels.Set{\n\t\tlabelAppName: name,\n\t\tlabelManagedBy: labelManagedByVal,\n\t}\n\n\tmetadata := metav1.ObjectMeta{\n\t\tNamespace: namespace,\n\t\tName: name,\n\t\tLabels: lbls,\n\t}\n\n\treturn &corev1.Service{\n\t\tObjectMeta: metadata,\n\t\tSpec: corev1.ServiceSpec{\n\t\t\tSelector: lbls,\n\t\t\tPorts: []corev1.ServicePort{{\n\t\t\t\tPort: int32(port),\n\t\t\t\tTargetPort: intstr.FromInt(int(targetPort)),\n\t\t\t}},\n\t\t},\n\t}\n}", "title": "" }, { "docid": "b28800a2d7f60480ff40413d41a08947", "score": "0.55322725", "text": "func (usd UpdateServiceDescription) AsStatefulUpdateServiceDescription() (*StatefulUpdateServiceDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "4022712b0ebddfa85589b9d2d92b03f9", "score": "0.55268484", "text": "func (ssgd StatelessServiceGroupDescription) AsBasicServiceGroupDescription() (BasicServiceGroupDescription, bool) {\n\treturn &ssgd, true\n}", "title": "" }, { "docid": "3d1c0bb369e931f463b8e7cbe654fae3", "score": "0.5525633", "text": "func BuildService(\n\tsd svcdef.ServiceDefinition, parentServiceID string, poolID string, desiredState int, deploymentID string,\n) (*Service, error) {\n\tsvcuuid, err := utils.NewUUID36()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tnow := time.Now()\n\n\tsvc := Service{}\n\tsvc.ID = svcuuid\n\tsvc.Name = sd.Name\n\tsvc.Title = sd.Title\n\tsvc.Version = sd.Version\n\tsvc.Context = sd.Context\n\tsvc.Startup = sd.Command\n\tsvc.RunAs = sd.RunAs\n\tsvc.Description = sd.Description\n\tsvc.Environment = sd.Environment\n\tsvc.Tags = sd.Tags\n\tif sd.Instances.Default != 0 {\n\t\tsvc.Instances = sd.Instances.Default\n\t} else {\n\t\tsvc.Instances = sd.Instances.Min\n\t}\n\tsvc.InstanceLimits = sd.Instances\n\tsvc.ChangeOptions = sd.ChangeOptions\n\tsvc.ImageID = sd.ImageID\n\tsvc.PoolID = poolID\n\tsvc.DesiredState = desiredState\n\tsvc.Launch = sd.Launch\n\tsvc.HostPolicy = sd.HostPolicy\n\tsvc.Hostname = sd.Hostname\n\tsvc.Privileged = sd.Privileged\n\tsvc.OriginalConfigs = sd.ConfigFiles\n\tsvc.ConfigFiles = sd.ConfigFiles\n\tsvc.ParentServiceID = parentServiceID\n\tsvc.CreatedAt = now\n\tsvc.UpdatedAt = now\n\tsvc.Volumes = sd.Volumes\n\tsvc.DeploymentID = deploymentID\n\tsvc.LogConfigs = sd.LogConfigs\n\tsvc.Snapshot = sd.Snapshot\n\tsvc.RAMCommitment = sd.RAMCommitment\n\tsvc.RAMThreshold = sd.RAMThreshold\n\tsvc.CPUCommitment = sd.CPUCommitment\n\tsvc.DisableShell = sd.DisableShell\n\tsvc.Runs = sd.Runs\n\tsvc.Commands = sd.Commands\n\tsvc.Actions = sd.Actions\n\tsvc.HealthChecks = sd.HealthChecks\n\tsvc.Prereqs = sd.Prereqs\n\tsvc.PIDFile = sd.PIDFile\n\tsvc.StartLevel = sd.StartLevel\n\tsvc.EmergencyShutdownLevel = sd.EmergencyShutdownLevel\n\tsvc.OomKillDisable = sd.OomKillDisable\n\tsvc.OomScoreAdj = sd.OomScoreAdj\n\n\tsvc.Endpoints = make([]ServiceEndpoint, 0)\n\tfor _, ep := range sd.Endpoints {\n\t\tsvc.Endpoints = append(svc.Endpoints, BuildServiceEndpoint(ep))\n\t}\n\n\ttags := map[string][]string{\n\t\t\"controlplane_service_id\": []string{svc.ID},\n\t}\n\tprofile, err := sd.MonitoringProfile.ReBuild(\"1h-ago\", tags)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsvc.MonitoringProfile = *profile\n\tsvc.MemoryLimit = sd.MemoryLimit\n\tsvc.CPUShares = sd.CPUShares\n\n\treturn &svc, nil\n}", "title": "" }, { "docid": "d77840d162c80aacba07e9a5ca55d773", "score": "0.55126584", "text": "func (ssgd StatefulServiceGroupDescription) AsBasicServiceGroupDescription() (BasicServiceGroupDescription, bool) {\n\treturn &ssgd, true\n}", "title": "" }, { "docid": "7d689d8aa53b1388bc75298c0ed65736", "score": "0.5495975", "text": "func newService() v1.Service {\n\tret := v1.Service{\n\t\tTypeMeta: meta.TypeMeta{\n\t\t\tKind: \"Service\",\n\t\t\tAPIVersion: \"v1\",\n\t\t},\n\t\tObjectMeta: meta.ObjectMeta{\n\t\t\tName: fmt.Sprintf(\"%v\", uuid.NewUUID()),\n\t\t\tNamespace: \"default\",\n\t\t},\n\t\tSpec: v1.ServiceSpec{\n\t\t\tType: v1.ServiceTypeLoadBalancer,\n\t\t\tLoadBalancerIP: \"1.2.3.4\",\n\t\t},\n\t}\n\n\tret.SelfLink = fmt.Sprintf(\"%s/%s\", ret.Namespace, ret.Name)\n\treturn ret\n}", "title": "" }, { "docid": "6b8834ba1ebfdf6f72b3891ea5ab3aa8", "score": "0.5494744", "text": "func (ssgd StatefulServiceGroupDescription) MarshalJSON() ([]byte, error) {\n\tssgd.ServiceKind = ServiceKindBasicServiceGroupDescriptionServiceKindStateful\n\tobjectMap := make(map[string]interface{})\n\tif ssgd.TargetReplicaSetSize != nil {\n\t\tobjectMap[\"TargetReplicaSetSize\"] = ssgd.TargetReplicaSetSize\n\t}\n\tif ssgd.MinReplicaSetSize != nil {\n\t\tobjectMap[\"MinReplicaSetSize\"] = ssgd.MinReplicaSetSize\n\t}\n\tif ssgd.HasPersistedState != nil {\n\t\tobjectMap[\"HasPersistedState\"] = ssgd.HasPersistedState\n\t}\n\tif ssgd.ReplicaRestartWaitDurationSeconds != nil {\n\t\tobjectMap[\"ReplicaRestartWaitDurationSeconds\"] = ssgd.ReplicaRestartWaitDurationSeconds\n\t}\n\tif ssgd.QuorumLossWaitDurationSeconds != nil {\n\t\tobjectMap[\"QuorumLossWaitDurationSeconds\"] = ssgd.QuorumLossWaitDurationSeconds\n\t}\n\tif ssgd.StandByReplicaKeepDurationSeconds != nil {\n\t\tobjectMap[\"StandByReplicaKeepDurationSeconds\"] = ssgd.StandByReplicaKeepDurationSeconds\n\t}\n\tif ssgd.DefaultMoveCost != \"\" {\n\t\tobjectMap[\"DefaultMoveCost\"] = ssgd.DefaultMoveCost\n\t}\n\tif ssgd.IsDefaultMoveCostSpecified != nil {\n\t\tobjectMap[\"IsDefaultMoveCostSpecified\"] = ssgd.IsDefaultMoveCostSpecified\n\t}\n\tif ssgd.ApplicationName != nil {\n\t\tobjectMap[\"ApplicationName\"] = ssgd.ApplicationName\n\t}\n\tif ssgd.ServiceName != nil {\n\t\tobjectMap[\"ServiceName\"] = ssgd.ServiceName\n\t}\n\tif ssgd.ServiceTypeName != nil {\n\t\tobjectMap[\"ServiceTypeName\"] = ssgd.ServiceTypeName\n\t}\n\tif ssgd.PartitionDescription != nil {\n\t\tobjectMap[\"PartitionDescription\"] = ssgd.PartitionDescription\n\t}\n\tif ssgd.PlacementConstraints != nil {\n\t\tobjectMap[\"PlacementConstraints\"] = ssgd.PlacementConstraints\n\t}\n\tif ssgd.CorrelationScheme != nil {\n\t\tobjectMap[\"CorrelationScheme\"] = ssgd.CorrelationScheme\n\t}\n\tif ssgd.ServiceLoadMetrics != nil {\n\t\tobjectMap[\"ServiceLoadMetrics\"] = ssgd.ServiceLoadMetrics\n\t}\n\tif ssgd.ServicePlacementPolicies != nil {\n\t\tobjectMap[\"ServicePlacementPolicies\"] = ssgd.ServicePlacementPolicies\n\t}\n\tif ssgd.Flags != nil {\n\t\tobjectMap[\"Flags\"] = ssgd.Flags\n\t}\n\tif ssgd.ServiceGroupMemberDescription != nil {\n\t\tobjectMap[\"ServiceGroupMemberDescription\"] = ssgd.ServiceGroupMemberDescription\n\t}\n\tif ssgd.ServiceKind != \"\" {\n\t\tobjectMap[\"ServiceKind\"] = ssgd.ServiceKind\n\t}\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "9b9d8c57535fb819272e7b81fccd3249", "score": "0.5488206", "text": "func newAdapterService() *servingv1.Service {\n\treturn &servingv1.Service{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tNamespace: tNs,\n\t\t\tName: tGenName,\n\t\t\tLabels: map[string]string{\n\t\t\t\tlabelKnTargetController: targetPrefix + \"-controller\",\n\t\t\t\tlabelKnTargetName: tName,\n\t\t\t},\n\t\t\tOwnerReferences: []metav1.OwnerReference{\n\t\t\t\t*kmeta.NewControllerRef(NewOwnerRefable(\n\t\t\t\t\ttName,\n\t\t\t\t\t(&v1alpha1.GoogleSheetTarget{}).GetGroupVersionKind(),\n\t\t\t\t\ttUID,\n\t\t\t\t)),\n\t\t\t},\n\t\t},\n\t\tSpec: servingv1.ServiceSpec{\n\t\t\tConfigurationSpec: servingv1.ConfigurationSpec{\n\t\t\t\tTemplate: servingv1.RevisionTemplateSpec{\n\t\t\t\t\tSpec: servingv1.RevisionSpec{\n\t\t\t\t\t\tPodSpec: corev1.PodSpec{\n\t\t\t\t\t\t\tContainers: []corev1.Container{{\n\t\t\t\t\t\t\t\tImage: tImg,\n\t\t\t\t\t\t\t\tEnv: []corev1.EnvVar{\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tName: resources.EnvNamespace,\n\t\t\t\t\t\t\t\t\t\tValue: tNs,\n\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\tName: resources.EnvName,\n\t\t\t\t\t\t\t\t\t\tValue: tName,\n\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\tName: resources.EnvMetricsDomain,\n\t\t\t\t\t\t\t\t\t\tValue: resources.DefaultMetricsDomain,\n\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\tName: envCredentialsJSON,\n\t\t\t\t\t\t\t\t\t\tValueFrom: &corev1.EnvVarSource{\n\t\t\t\t\t\t\t\t\t\t\tSecretKeyRef: tSecretSelector,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\tName: envSheetID,\n\t\t\t\t\t\t\t\t\t\tValue: tSpreadsheetID,\n\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\tName: envDefaultPrefix,\n\t\t\t\t\t\t\t\t\t\tValue: tDefaultPrefix,\n\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\tName: source.EnvLoggingCfg,\n\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\tName: source.EnvMetricsCfg,\n\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\tName: source.EnvTracingCfg,\n\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t// FIXME(antoineco): remove dupe. See target_adapter.go\n\t\t\t\t\t\t\t\t\t\tName: source.EnvMetricsCfg,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n}", "title": "" }, { "docid": "72518e8e0816a546a8d8289af4825635", "score": "0.5474759", "text": "func NewExportedService(service *v1.Service, clusterId string, portIdx int) (*ExportedService, error) {\n\t// TODO add some validation to make sure that the clusterId contains only\n\t// safe characters for Consul Service names\n\tif clusterId == \"\" {\n\t\treturn nil, fmt.Errorf(\"No clusterId specified\")\n\t}\n\n\tes := &ExportedService{\n\t\tNamespace: service.Namespace,\n\t\tName: service.Name,\n\t\tPortName: service.Spec.Ports[portIdx].Name,\n\t\tPort: service.Spec.Ports[portIdx].NodePort,\n\t\tHealthCheckPort: service.Spec.Ports[portIdx].NodePort,\n\t\tServicePerCluster: true,\n\t\tBackendProtocol: \"http\",\n\t\tClusterId: clusterId,\n\t}\n\n\tif es.PortName == \"\" {\n\t\t// use the container port since it will be consistent across clusters\n\t\t// and the NodePort will not.\n\t\tes.PortName = strconv.Itoa(int(service.Spec.Ports[portIdx].Port))\n\t}\n\n\tif service.Annotations == nil {\n\t\treturn es, nil\n\t}\n\n\tif val, ok := service.Annotations[ServiceAnnotationLoadBalancerDNSName]; ok {\n\t\tes.DNSName = val\n\t}\n\n\tif service.Annotations[ServiceAnnotationProxyProtocol] == \"*\" {\n\t\tes.ProxyProtocol = true\n\t}\n\n\tif val, ok := service.Annotations[ServiceAnnotationLoadBalancerClass]; ok {\n\t\tes.LoadBalancerClass = val\n\t}\n\n\tif service.Annotations[ServiceAnnotationLoadBalancerBEProtocol] == \"tcp\" {\n\t\tes.BackendProtocol = \"tcp\"\n\t}\n\n\tif val, ok := service.Annotations[ServiceAnnotationLoadBalancerListenPort]; ok {\n\t\tport, err := strconv.ParseInt(val, 10, 32)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Error setting LoadBalancerListenPort: %v\", err)\n\t\t}\n\t\tes.LoadBalancerListenPort = int32(port)\n\t}\n\n\tif val, ok := service.Annotations[ServiceAnnotationLoadBalancerHealthCheckPath]; ok {\n\t\tes.HealthCheckPath = val\n\t}\n\n\tif val, ok := service.Annotations[ServiceAnnotationLoadBalancerHealthCheckPort]; ok {\n\t\tport, err := strconv.ParseInt(val, 10, 32)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Error setting HealthCheckPort: %v\", err)\n\t\t}\n\t\tes.HealthCheckPort = int32(port)\n\t}\n\n\tif val, ok := service.Annotations[ServiceAnnotationLoadBalancerServicePerCluster]; ok {\n\t\tparsed, err := strconv.ParseBool(val)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"Error setting ServicePerCluster\")\n\t\t}\n\t\tes.ServicePerCluster = parsed\n\t}\n\n\tif val, ok := service.Annotations[ServiceAnnotationCustomAttrs]; ok {\n\t\tvar customAttrs map[string]interface{}\n\t\terr := json.Unmarshal([]byte(val), &customAttrs)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"Error parsing customattrs JSON object\")\n\t\t}\n\n\t\tes.CustomAttrs = customAttrs\n\t} else {\n\t\tes.CustomAttrs = map[string]interface{}{}\n\t}\n\n\treturn es, nil\n}", "title": "" }, { "docid": "6f8fc86e668aebee1ffed514dd0babe7", "score": "0.5446261", "text": "func (c Client) DescribeService(app, env, svc string) (*ServiceDesc, error) {\n\tsvcARN, err := c.ServiceARN(app, env, svc)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tclusterName, err := svcARN.ClusterName()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"get cluster name: %w\", err)\n\t}\n\tserviceName, err := svcARN.ServiceName()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"get service name: %w\", err)\n\t}\n\ttasks, err := c.ecsClient.ServiceTasks(clusterName, serviceName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"get tasks for service %s: %w\", serviceName, err)\n\t}\n\treturn &ServiceDesc{\n\t\tClusterName: clusterName,\n\t\tName: serviceName,\n\t\tTasks: tasks,\n\t}, nil\n}", "title": "" }, { "docid": "17ce27d0b8acdb1ea4aab42d8a83245b", "score": "0.54420733", "text": "func (ssgd StatefulServiceGroupDescription) AsServiceGroupDescription() (*ServiceGroupDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "6f7f6fd92d767487058094dd39d87f47", "score": "0.54328847", "text": "func (scsgd StatefulCreateServiceGroupDescription) AsStatefulCreateServiceGroupDescription() (*StatefulCreateServiceGroupDescription, bool) {\n\treturn &scsgd, true\n}", "title": "" }, { "docid": "6f7f6fd92d767487058094dd39d87f47", "score": "0.54328847", "text": "func (scsgd StatefulCreateServiceGroupDescription) AsStatefulCreateServiceGroupDescription() (*StatefulCreateServiceGroupDescription, bool) {\n\treturn &scsgd, true\n}", "title": "" }, { "docid": "5cbeb4ca0f59264f3b9150a907ebc906", "score": "0.54276067", "text": "func (sgd ServiceGroupDescription) AsStatefulServiceGroupDescription() (*StatefulServiceGroupDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "91f099b29ca8b45f9b09ec938f0020ef", "score": "0.5422283", "text": "func (csgd CreateServiceGroupDescription) AsStatefulCreateServiceGroupDescription() (*StatefulCreateServiceGroupDescription, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "d028d3e33e1473e2fb546bbe1eb7d50c", "score": "0.5354861", "text": "func (ssgd StatelessServiceGroupDescription) MarshalJSON() ([]byte, error) {\n\tssgd.ServiceKind = ServiceKindBasicServiceGroupDescriptionServiceKindStateless\n\tobjectMap := make(map[string]interface{})\n\tif ssgd.InstanceCount != nil {\n\t\tobjectMap[\"InstanceCount\"] = ssgd.InstanceCount\n\t}\n\tif ssgd.ApplicationName != nil {\n\t\tobjectMap[\"ApplicationName\"] = ssgd.ApplicationName\n\t}\n\tif ssgd.ServiceName != nil {\n\t\tobjectMap[\"ServiceName\"] = ssgd.ServiceName\n\t}\n\tif ssgd.ServiceTypeName != nil {\n\t\tobjectMap[\"ServiceTypeName\"] = ssgd.ServiceTypeName\n\t}\n\tif ssgd.PartitionDescription != nil {\n\t\tobjectMap[\"PartitionDescription\"] = ssgd.PartitionDescription\n\t}\n\tif ssgd.PlacementConstraints != nil {\n\t\tobjectMap[\"PlacementConstraints\"] = ssgd.PlacementConstraints\n\t}\n\tif ssgd.CorrelationScheme != nil {\n\t\tobjectMap[\"CorrelationScheme\"] = ssgd.CorrelationScheme\n\t}\n\tif ssgd.ServiceLoadMetrics != nil {\n\t\tobjectMap[\"ServiceLoadMetrics\"] = ssgd.ServiceLoadMetrics\n\t}\n\tif ssgd.ServicePlacementPolicies != nil {\n\t\tobjectMap[\"ServicePlacementPolicies\"] = ssgd.ServicePlacementPolicies\n\t}\n\tif ssgd.Flags != nil {\n\t\tobjectMap[\"Flags\"] = ssgd.Flags\n\t}\n\tif ssgd.ServiceGroupMemberDescription != nil {\n\t\tobjectMap[\"ServiceGroupMemberDescription\"] = ssgd.ServiceGroupMemberDescription\n\t}\n\tif ssgd.ServiceKind != \"\" {\n\t\tobjectMap[\"ServiceKind\"] = ssgd.ServiceKind\n\t}\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "09a414da100f83795e025a4cd94aad9f", "score": "0.53400534", "text": "func PossibleServiceKindBasicCreateServiceDescriptionValues() []ServiceKindBasicCreateServiceDescription {\n\treturn []ServiceKindBasicCreateServiceDescription{ServiceKindCreateServiceDescription, ServiceKindStateful1, ServiceKindStateless1}\n}", "title": "" }, { "docid": "d20d8342bbfa2c5fbb8819a3b2660a79", "score": "0.5325229", "text": "func NewService(input NewServiceInput) (*Service, error) {\n\n\tnew := &Service{\n\t\tclient: &client{\n\t\t\tsession: input.Session,\n\t\t\tsts: input.Sts,\n\t\t},\n\t\tstorager: input.Storager,\n\t\tconfig: input.Config,\n\t}\n\n\tnew.config.tags = []*iam.Tag{\n\t\t{Key: aws.String(\"Terraform\"), Value: aws.String(\"False\")},\n\t\t{Key: aws.String(\"Source\"), Value: aws.String(\"github.com/Optum/dce//cmd/lambda/accounts\")},\n\t\t{Key: aws.String(\"Environment\"), Value: aws.String(new.config.TagEnvironment)},\n\t\t{Key: aws.String(\"Contact\"), Value: aws.String(new.config.TagContact)},\n\t\t{Key: aws.String(\"AppName\"), Value: aws.String(new.config.TagAppName)},\n\t}\n\n\tnew.config.assumeRolePolicy = strings.TrimSpace(fmt.Sprintf(`\n\t\t{\n\t\t\t\"Version\": \"2012-10-17\",\n\t\t\t\"Statement\": [\n\t\t\t\t{\n\t\t\t\t\t\"Effect\": \"Allow\",\n\t\t\t\t\t\"Principal\": {\n\t\t\t\t\t\t\"AWS\": \"arn:aws:iam::%s:root\"\n\t\t\t\t\t},\n\t\t\t\t\t\"Action\": \"sts:AssumeRole\",\n\t\t\t\t\t\"Condition\": {}\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t`, new.config.AccountID))\n\n\treturn new, nil\n\n}", "title": "" }, { "docid": "4d50fc6cd97178db44c33db80d540767", "score": "0.53248644", "text": "func (susd StatelessUpdateServiceDescription) AsBasicUpdateServiceDescription() (BasicUpdateServiceDescription, bool) {\n\treturn &susd, true\n}", "title": "" } ]
e5073485177436a25bf85b57561ac7d1
GetProjectByName will return specific project from GET /projects via its name name could be of form group/project_name if forks exist
[ { "docid": "ccbd24332c6992a8ffe6a5b0eee4066a", "score": "0.801675", "text": "func GetProjectByName(api *API, name string) (proj Project, err error) {\n\tsplitedName := strings.Split(name, \"/\")\n\tif len(splitedName) > 2 {\n\t\treturn proj, fmt.Errorf(\"project name should be of form [GROUP]/PROJECT\")\n\t}\n\n\t// we search for name in every case\n\tquery := url.Values{}\n\tif len(splitedName) == 2 {\n\t\tquery.Add(\"search\", splitedName[1])\n\t} else {\n\t\tquery.Add(\"search\", name)\n\t}\n\n\tvar projects []Project\n\tstatusCode, err := api.Call(\"GET\", \"/projects\", query, nil, &projects)\n\tif err != nil {\n\t\treturn proj, fmt.Errorf(\"GetProjectByName error: %v\", err)\n\t}\n\tif statusCode != http.StatusOK {\n\t\treturn proj, fmt.Errorf(\"unexpected status code: %d, expected 200\", statusCode)\n\t}\n\n\tswitch len(projects) {\n\t// This should happen when no forks and name is exact\n\tcase 0:\n\t\treturn proj, fmt.Errorf(\"empty list of projects\")\n\tcase 1:\n\t\treturn projects[1], nil\n\tdefault:\n\t\tfor _, p := range projects {\n\t\t\tif p.PathWithNamespace == name {\n\t\t\t\treturn p, nil\n\t\t\t}\n\t\t}\n\t}\n\n\treturn proj, fmt.Errorf(\"unable to find unique matching project\")\n}", "title": "" } ]
[ { "docid": "19446f62f2641de30eaa2fe41714d848", "score": "0.7949944", "text": "func (s *ProjectsService) GetByName(ctx context.Context, provider, name string) (project *Project, err error) {\n\treturn s.get(ctx, provider+\"/\"+name)\n}", "title": "" }, { "docid": "76c2838b1d08435a1b0f1a1007c1b855", "score": "0.7860801", "text": "func (s *ProjectsServiceOp) GetByName(ctx context.Context, groupName string) (*Project, *atlas.Response, error) {\n\tif groupName == \"\" {\n\t\treturn nil, nil, atlas.NewArgError(\"groupName\", \"must be set\")\n\t}\n\n\tpath := fmt.Sprintf(\"%s/byName/%s\", projectBasePath, groupName)\n\n\treq, err := s.Client.NewRequest(ctx, http.MethodGet, path, nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\troot := new(Project)\n\tresp, err := s.Client.Do(ctx, req, root)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn root, resp, err\n}", "title": "" }, { "docid": "749e99ba972c369fe1634fb16c66fcdb", "score": "0.7425283", "text": "func (c *projects) Get(name string) (result *projectapi.Project, err error) {\n\tresult = &projectapi.Project{}\n\terr = c.r.Get().Namespace(c.ns).Path(\"projects\").Path(name).Do().Into(result)\n\treturn\n}", "title": "" }, { "docid": "4bc46cda7271b781537a5ed6191d850d", "score": "0.7142494", "text": "func GetProjectByName(customerName string, projectName string, project *Project) error {\n\tvar customer Customer\n\n\tif err := GetCustomerByName(customerName, &customer); err != nil {\n\t\treturn fmt.Errorf(\"customer %s doesn't exists\", customerName)\n\t}\n\n\tif DBc.Where(\"name = ? AND customer_id = ?\", projectName, customer.GetID()).First(project).RecordNotFound() {\n\t\treturn fmt.Errorf(\"project name %s for customer %s is missing \", projectName, customerName)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "3f69f61b45fa6cb389fb08e50a50fdc1", "score": "0.7121334", "text": "func (datahub *DataHub) GetProject(name string) (p *models.Project, err error) {\n\tp = &models.Project{\n\t\tName: name,\n\t}\n\terr = datahub.Client.Get(p)\n\treturn\n}", "title": "" }, { "docid": "337df0f2441b45050d9c29329b891ddb", "score": "0.71124595", "text": "func getProject(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\t// Params\n\tid, err := strconv.Atoi(ps.ByName(\"id\"))\n\tif err != nil {\n\t\tResponseError(w, ErrProjectID)\n\t\treturn\n\t}\n\t// Query db.\n\tproj := &models.Project{}\n\tif err := db.Admin.DB().First(proj, id).Error; err != nil {\n\t\tswitch err {\n\t\tcase gorm.RecordNotFound:\n\t\t\tResponseError(w, ErrProjectNotFound)\n\t\t\treturn\n\t\tdefault:\n\t\t\tResponseError(w, NewUnexceptedWebError(err))\n\t\t\treturn\n\t\t}\n\t}\n\tResponseJSONOK(w, proj)\n}", "title": "" }, { "docid": "d24ad02cabeecde0c3e8dfc942beb474", "score": "0.70964444", "text": "func (c *SonarCloudClient) GetProject(org, name string) (*http.Response, error) {\n\toptions := \"?\"\n\toptions += fmt.Sprintf(Projects, name)\n\toptions += fmt.Sprintf(\"&\"+Organization, org)\n\n\turl := c.URI + ProjectSearch + options\n\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\tif err != nil {\n\t\treturn HandleHTTPClientError(nil, err)\n\t}\n\n\tresp, err := c.Client.Do(req)\n\n\tif err != nil {\n\t\treturn HandleHTTPClientError(resp, err)\n\t}\n\n\treturn resp, nil\n}", "title": "" }, { "docid": "13102642640338986580c273b137b54c", "score": "0.7030195", "text": "func GetProjectByProjectnr(c *gin.Context) {\n\tpp := proadclient.GetProject(c.Query(\"projectnr\"))\n\tfmt.Println(c.Request)\n\tif len(pp.Projects) == 0 {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"error\": \"projectList is empty\"})\n\t}\n\tc.JSON(http.StatusOK, pp)\n}", "title": "" }, { "docid": "69998ffe8efed5a3b1f42a4859309b92", "score": "0.6992929", "text": "func (config *Config) Project(name string) *Project {\n\tfor _, project := range config.Projects {\n\t\tif project.Name == name {\n\t\t\treturn &project\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "6a74b46bc9eb15be1d40fee597a2b91b", "score": "0.69775397", "text": "func (s *Server) GetProjectByParam(w http.ResponseWriter, r *http.Request) {\n\tm := model.Project{}\n\tvar projectGet *model.Project\n\tvar err error\n\n\t// ?id= prioritized over ?name= if both are provided in the url parameter\n\tif idParam := r.URL.Query().Get(\"id\"); idParam != \"\" {\n\t\tvar id uint64\n\t\tid, err = strconv.ParseUint(idParam, 10, 64)\n\t\tif err != nil {\n\t\t\tapiutil.RespError(w, http.StatusBadRequest, err)\n\t\t\treturn\n\t\t}\n\t\tprojectGet, err = m.GetByID(s.DB, id)\n\t} else if name := r.URL.Query().Get(\"name\"); name != \"\" {\n\t\tprojectGet, err = m.GetByName(s.DB, name)\n\t} else {\n\t\tapiutil.RespError(w, http.StatusUnprocessableEntity, errors.New(\"Need to provide the parameter 'id' or 'name'\"))\n\t\treturn\n\t}\n\n\t// if no error from retrieving projectGet\n\tif err != nil {\n\t\tapiutil.RespError(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\tapiutil.RespSuccess(w, projectGet)\n\n}", "title": "" }, { "docid": "be187cde47fd0ad3780e215dc11bc3ad", "score": "0.69762313", "text": "func (router *router) getProject(request *restful.Request, response *restful.Response) {\n\tname := request.PathParameter(projectPathParameterName)\n\n\tproject, err := router.projectManager.GetProject(name)\n\tif err != nil {\n\t\thttputil.ResponseWithError(response, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\n\tresponse.WriteHeaderAndEntity(http.StatusOK, project)\n}", "title": "" }, { "docid": "ea9b116a18fc9acc3d90301d4ce8cfce", "score": "0.6967391", "text": "func FetchProjectByName(orgName string, projectName string) (*mono_models.Project, error) {\n\tlogging.Debug(\"fetching project (%s) in organization (%s)\", projectName, orgName)\n\n\trequest := request.ProjectByOrgAndName(orgName, projectName)\n\n\tgql := graphql.New()\n\tresponse := model.Projects{}\n\terr := gql.Run(request, &response)\n\tif err != nil {\n\t\treturn nil, errs.Wrap(err, \"GraphQL request failed\")\n\t}\n\n\tif len(response.Projects) == 0 {\n\t\tif !authentication.LegacyGet().Authenticated() {\n\t\t\treturn nil, errs.AddTips(\n\t\t\t\tlocale.NewInputError(\"err_api_project_not_found_unauthenticated\", \"\", orgName, projectName),\n\t\t\t\tlocale.T(\"tip_private_project_auth\"))\n\t\t}\n\t\treturn nil, &ErrProjectNotFound{locale.NewInputError(\"err_api_project_not_found\", \"\", projectName, orgName)}\n\t}\n\n\treturn response.Projects[0].ToMonoProject()\n}", "title": "" }, { "docid": "131b4e24bdac074943c75d738c5f6ec2", "score": "0.69523126", "text": "func (c PGClient) GetProjectName(id int64) (projectName string, err error) {\n\terr = c.DB.QueryRow(\"select name from tProjects where id=$1\", id).Scan(&projectName)\n\treturn projectName, err\n}", "title": "" }, { "docid": "623f5fdc125916b3096bdaa002598338", "score": "0.6899574", "text": "func GetProject(id int, name string) (*Project, error) {\n\tvar err error\n\n\to := orm.NewOrm()\n\to.Using(\"default\")\n\n\tpro := Project{}\n\n\tif id > 0 {\n\t\tpro = Project{Id: id}\n\t\terr = o.Read(&pro, \"Id\")\n\t} else if len(name) > 0 {\n\t\tpro = Project{Name: name}\n\t\terr = o.Read(&pro, \"Name\")\n\t} else {\n\t\terr = errors.New(\"至少有一个条件\")\n\t}\n\n\treturn &pro, err\n}", "title": "" }, { "docid": "420046cd75cbe3d13bdef4056e306ada", "score": "0.6869345", "text": "func GetProject(w http.ResponseWriter, r *http.Request) {\n\tkey := chi.URLParam(r, \"key\")\n\n\tp := models.Project{\n\t\tKey: key,\n\t}\n\n\terr := Store.Projects().Get(&p)\n\tif err != nil {\n\t\tw.WriteHeader(500)\n\t\tw.Write(apiError(err.Error()))\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\n\tsendJSON(w, p)\n}", "title": "" }, { "docid": "b3861b4116a4f328933d7af708016c2b", "score": "0.68298215", "text": "func GetProject(request []string, params map[string][]string) (answer Answer) {\n\tvar err error\n\tvar u APIUser\n\tvar c APIClient\n\tres := APIProject{User: &u, Client: &c}\n\tdefer answer.make(&err, &res)\n\n\tanswer.ID, err = strconv.ParseInt(request[1], 10, 64)\n\tif err != nil {\n\t\tanswer.Code = BadRequest\n\t\terr = fmt.Errorf(\"Неверный ID '%s'\", request[1])\n\t\treturn\n\t}\n\n\tvar row *sql.Row\n\trow = db.DB.QueryRow(`SELECT p.nr, p.contract_date, p.install_date, p.address, p.comment,\n\t\tu.id, u.name, u.phone, u.position, u.comment,\n\t\tc.id, c.name, c.phone, c.comment\n\t\tFROM project p INNER JOIN user u ON p.user_id = u.id INNER JOIN client c ON p.client_id = c.id\n\t\tWHERE p.id=?`, answer.ID)\n\terr = row.Scan(&res.Nr, &res.ContractDate, &res.InstallDate, &res.Address, &res.Comment,\n\t\t&u.ID, &u.Name, &u.Phone, &u.Position, &u.Comment,\n\t\t&c.ID, &c.Name, &c.Phone, &c.Comment)\n\tif err != nil {\n\t\treturn\n\t}\n\tres.ID = answer.ID\n\treturn\n}", "title": "" }, { "docid": "7d8549249fce8a89cb87c2c926305ff2", "score": "0.6772781", "text": "func GetProjectName(cfgPath, name string) string {\n\tname = normalCharPattern.FindString(name)\n\tif len(name) > 0 {\n\t\treturn name\n\t}\n\tabsPath, _ := filepath.Abs(cfgPath)\n\tname = path.Base(path.Dir(absPath))\n\tif len(name) > 0 {\n\t\treturn name\n\t}\n\treturn \"default\"\n}", "title": "" }, { "docid": "b9ead77d8f6a10362a053109c52a4766", "score": "0.676768", "text": "func getProject(c *gin.Context) {\n\tusername, password, ok := c.Request.BasicAuth()\n\tif !ok || !utils.ValidateLDAPAuth(username, password) {\n\t\tc.JSON(http.StatusUnauthorized, gin.H{\"error\": \"You are not welcome here...\"})\n\t\treturn\n\t}\n\tid := c.Param(\"id\")\n\tif _, err := strconv.Atoi(id); err != nil {\n\t\tproject, err := models.GetProjectByTicketNumber(database, id)\n\t\tif err != nil {\n\t\t\tc.JSON(http.StatusNotFound, gin.H{\"error\": \"could not find project.\"})\n\t\t\treturn\n\t\t}\n\t\tc.JSON(http.StatusOK, project)\n\t\treturn\n\t}\n\tproject_id, _ := strconv.ParseInt(id, 10, 64)\n\tproject, err := models.GetProject(database, uint(project_id))\n\tif err != nil {\n\t\tc.JSON(http.StatusNotFound, gin.H{\"error\": \"could not find project.\"})\n\t\treturn\n\t}\n\tc.JSON(http.StatusOK, project)\n}", "title": "" }, { "docid": "f624fd173182390ac6360d9a8ea9ec5c", "score": "0.675571", "text": "func (d Mock) ProjectName(id string) (string, error) {\n\treturn \"ceilometer-cadf-delete-me\", nil\n}", "title": "" }, { "docid": "ba4101c0b66c60681177b9742ce63cd7", "score": "0.6683768", "text": "func GetProject(rw http.ResponseWriter, req *http.Request, params martini.Params) {\n project := params[\"project\"]\n if !auth.IsAllowed(rw, req, project) {\n rw.WriteHeader(http.StatusUnauthorized)\n return\n }\n p, err := data.GetProject(project)\n if err != nil {\n rw.WriteHeader(404)\n rw.Write([]byte(err.Error()))\n return\n }\n enc := json.NewEncoder(rw)\n rw.Header().Add(\"Content-Type\", \"application/json\")\n enc.Encode(p)\n}", "title": "" }, { "docid": "ba7ba9ff9af0cc9e309b21f31f5a34f9", "score": "0.6667334", "text": "func ProjectName(projectPath string) (project string) {\n\tabsPath, err := filepath.Abs(projectPath)\n\tif err != nil {\n\t\tglog.Errorln(err)\n\t}\n\tprojectPathIndex := strings.LastIndex(absPath, string(filepath.Separator))\n\tif -1 != projectPathIndex {\n\t\tproject = absPath[(projectPathIndex + 1):len(absPath)]\n\t}\n\n\treturn project\n}", "title": "" }, { "docid": "f94a6ed6757ca4faadd9f9b4dc8e4b9d", "score": "0.66653603", "text": "func (e Entry) GetProjectName() string {\n\tvar project Project\n\n\tDBc.Where(\"id = ?\", e.ProjectID).Find(&project)\n\n\treturn project.Name\n}", "title": "" }, { "docid": "74fc7b711d21fab2d328b374ca86b99c", "score": "0.6636016", "text": "func (s *RepositoryService) getProjectIDFromProjectName(ctx context.Context, projectName string) (string, error) {\n\t// https://docs.microsoft.com/en-us/rest/api/azure/devops/core/projects/list?view=azure-devops-rest-6.0\n\tprojectName, err := url.PathUnescape(projectName)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"unable to unscape project: %s\", projectName)\n\t}\n\n\tendpoint := fmt.Sprintf(\"%s/_apis/projects?api-version=6.0\", s.client.owner)\n\ttype projects struct {\n\t\tCount int64 `json:\"count\"`\n\t\tValue []struct {\n\t\t\tDescription string `json:\"description\"`\n\t\t\tID string `json:\"id\"`\n\t\t\tName string `json:\"name\"`\n\t\t\tState string `json:\"state\"`\n\t\t\tURL string `json:\"url\"`\n\t\t} `json:\"value\"`\n\t}\n\n\tout := new(projects)\n\tresponse, err := s.client.do(ctx, \"GET\", endpoint, nil, &out)\n\tif err != nil {\n\t\tfmt.Println(response)\n\t\treturn \"\", fmt.Errorf(\"failed to list projects: %s\", err)\n\t}\n\tfor _, v := range out.Value {\n\t\tif v.Name == projectName {\n\t\t\treturn v.ID, nil\n\t\t}\n\t}\n\treturn \"\", fmt.Errorf(\"failed to find project id for %s\", projectName)\n}", "title": "" }, { "docid": "fd927b875344505bcaed0253cbba193b", "score": "0.66345745", "text": "func (d *DataStore) FindProjectByName(name string) (*api.Project, error) {\n\tquery := bson.M{\"name\": name}\n\tcount, err := d.projectCollection.Find(query).Count()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif count == 0 {\n\t\treturn nil, mgo.ErrNotFound\n\t} else if count > 1 {\n\t\treturn nil, fmt.Errorf(\"there are %d projects with the same name %s\", count, name)\n\t}\n\n\tproject := &api.Project{}\n\tif err = d.projectCollection.Find(query).One(project); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn project, nil\n}", "title": "" }, { "docid": "5ce9f155d2f8bd129d1dc0f342804522", "score": "0.662505", "text": "func (s *Store) GetProject(projectName string) (*archer.Project, error) {\n\tprojectPath := fmt.Sprintf(fmtProjectPath, projectName)\n\tprojectParam, err := s.ssmClient.GetParameter(&ssm.GetParameterInput{\n\t\tName: aws.String(projectPath),\n\t})\n\n\tif err != nil {\n\t\tif aerr, ok := err.(awserr.Error); ok {\n\t\t\tswitch aerr.Code() {\n\t\t\tcase ssm.ErrCodeParameterNotFound:\n\t\t\t\taccount, region := s.getCallerAccountAndRegion()\n\t\t\t\treturn nil, &ErrNoSuchProject{\n\t\t\t\t\tProjectName: projectName,\n\t\t\t\t\tAccountID: account,\n\t\t\t\t\tRegion: region,\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn nil, fmt.Errorf(\"get project %s: %w\", projectName, err)\n\t}\n\n\tvar project archer.Project\n\tif err := json.Unmarshal([]byte(*projectParam.Parameter.Value), &project); err != nil {\n\t\treturn nil, fmt.Errorf(\"read details for project %s: %w\", projectName, err)\n\t}\n\treturn &project, nil\n}", "title": "" }, { "docid": "d6114c78f0b48e919e263d2a722e4cc3", "score": "0.6620179", "text": "func (s *ReleasesService) GetByProjectName(ctx context.Context, provider, projectName, version string) (release *Release, err error) {\n\treturn s.get(ctx, provider+\"/\"+projectName, version)\n}", "title": "" }, { "docid": "af29d651e4a173a2c57bdf31c5f98362", "score": "0.65770626", "text": "func GetProjectProjectNameHandlerFunc(params project.GetProjectProjectNameParams) middleware.Responder {\n\n\tmv := common.GetProjectsMaterializedView()\n\n\tprj, err := mv.GetProject(params.ProjectName)\n\n\tif err != nil {\n\t\treturn project.NewGetProjectProjectNameDefault(500).WithPayload(&models.Error{Code: 500, Message: swag.String(err.Error())})\n\t}\n\n\tif prj == nil {\n\t\treturn project.NewGetProjectProjectNameNotFound().WithPayload(&models.Error{Code: 404, Message: swag.String(\"Project not found\")})\n\t}\n\n\treturn project.NewGetProjectProjectNameOK().WithPayload(prj)\n}", "title": "" }, { "docid": "1f76f3f4f40073107a1bc7eeba2fb56a", "score": "0.6559077", "text": "func (c HTTPClient) FindProjectDetails(nameOrID string) ([]byte, error) {\n\t// first try to get the project by its cached ID\n\tif cachedID := c.config.Cache().Get(\"projects\", nameOrID); cachedID != \"\" {\n\t\tresp, _, err := c.Get(\"/projects/\" + url.PathEscape(cachedID))\n\t\tif err == nil {\n\t\t\treturn resp, nil\n\t\t}\n\t}\n\n\t// then try to find the project by its ID\n\tresp, _, err := c.Get(\"/projects/\" + url.PathEscape(nameOrID))\n\tif err == nil {\n\t\treturn resp, nil\n\t}\n\n\t// now try to find the project by name as a last resort\n\tresp, _, err = c.Get(\"/users/${user}/projects/?search=\" + url.QueryEscape(nameOrID))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tprojects := make([]map[string]interface{}, 0)\n\terr = json.Unmarshal(resp, &projects)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(projects) == 0 {\n\t\treturn nil, fmt.Errorf(\"Project '%s' not found\", nameOrID)\n\t}\n\tc.config.Cache().Put(\"projects\", nameOrID, strconv.Itoa(int((projects[0][\"id\"].(float64)))))\n\tc.config.Write()\n\tres, err := json.Marshal(projects[0])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn res, nil\n}", "title": "" }, { "docid": "77aac870eb65b9bdf59f9f5e047bda5f", "score": "0.65334696", "text": "func (p *Project) GetProject(db *sql.DB) error {\n\treturn db.QueryRow(\"SELECT cust_id, name, start_date, hours FROM projects WHERE id=$1\",\n\t\tp.ID).Scan(&p.CustID, &p.Name, &p.StartDate, &p.Hours)\n}", "title": "" }, { "docid": "72ae220b5ae74b4b88e0f0e8d5bdd7e8", "score": "0.651753", "text": "func (m *executionRequest) ProjectName() string {\n\treturn m.projectNameField\n}", "title": "" }, { "docid": "34fa666bf30c37ef6f7df306804f22fb", "score": "0.6493115", "text": "func GetProject(key string, mods ...RequestModifier) (Project, error) {\n\tvar p Project\n\tpath := fmt.Sprintf(\"/project/%s\", key)\n\n\tif len(mods) == 0 {\n\t\tmods = append(mods, func(r *http.Request) {\n\t\t\tq := r.URL.Query()\n\t\t\tq.Set(\"withApplications\", \"true\")\n\t\t\tq.Set(\"withPipelines\", \"true\")\n\t\t\tq.Set(\"withEnvironments\", \"true\")\n\t\t\tq.Set(\"withGroups\", \"true\")\n\t\t\tr.URL.RawQuery = q.Encode()\n\t\t})\n\t}\n\n\tdata, _, err := Request(\"GET\", path, nil, mods...)\n\tif err != nil {\n\t\treturn p, err\n\t}\n\n\terr = json.Unmarshal(data, &p)\n\tif err != nil {\n\t\treturn p, err\n\t}\n\n\treturn p, nil\n}", "title": "" }, { "docid": "f3709fd4228e6c1f947e399167e0c9e6", "score": "0.64732707", "text": "func GetProject(projectID int) Project {\n\n\turl := \"http://spm-api:4040/api/project/\" + strconv.Itoa(projectID)\n\n\tteamClient := http.Client{\n\t\tTimeout: time.Second * 5,\n\t}\n\n\treq, err := http.NewRequest(http.MethodGet, url, nil)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tres, getErr := teamClient.Do(req)\n\tif getErr != nil {\n\t\tlog.Fatal(getErr)\n\t}\n\n\tbody, readErr := ioutil.ReadAll(res.Body)\n\tif readErr != nil {\n\t\tlog.Fatal(readErr)\n\t}\n\n\tproject := Project{}\n\tjsonErr := json.Unmarshal(body, &project)\n\tif jsonErr != nil {\n\t\tfmt.Println(jsonErr)\n\t\treturn Project{}\n\t}\n\n\treturn project\n}", "title": "" }, { "docid": "461e89e87292fc50d3a82dcbb176e366", "score": "0.64555115", "text": "func loadProject(name string) (*project, error) {\n\t// Load the configuration\n\t// configData, configError := loadConfiguration(configPath)\n\t// config = configData\n\t// if configError != nil {\n\t// \tlog.Fatalln(\"Failed to parse configuration\", configError)\n\t// }\n\n\t// Find the correct project\n\tfor _, pconfig := range config.Projects {\n\t\tif pconfig.Name == name {\n\t\t\treturn newProject(pconfig), nil\n\t\t}\n\t}\n\n\treturn nil, errors.New(\"failed to find the project\")\n}", "title": "" }, { "docid": "cadfb6e31f8df404a4514c56d6bb16c5", "score": "0.64276385", "text": "func getProject(name string, config cli.Config, git git.Git) (domain.Project, error) {\n\tvar (\n\t\terr error\n\t\tproject domain.Project\n\t\trepoPaths []string\n\t)\n\n\tif name == \".\" || name[0:1] == \"/\" || name[0:2] == \"./\" {\n\t\tproject.Path, err = filepath.Abs(name)\n\t\tif err != nil {\n\t\t\treturn domain.Project{}, fmt.Errorf(\"getProject: %w\", err)\n\t\t}\n\t\tproject.Name = filepath.Base(project.Path)\n\t\trepoPaths, err = git.DiscoverRepos(project.Path)\n\t\tif err != nil {\n\t\t\treturn domain.Project{}, fmt.Errorf(\"getProject: %w\", err)\n\t\t}\n\t\tfor _, repoPath := range repoPaths {\n\t\t\trepo := domain.Repository{\"dir\": repoPath}\n\t\t\tproject.Repos = append(project.Repos, repo)\n\t\t}\n\t} else {\n\t\tproject = config.Projects[name]\n\t\tproject.Name = name\n\t\tproject.AbsPath, err = homedir.Expand(project.Path)\n\t\tif err != nil {\n\t\t\treturn domain.Project{}, fmt.Errorf(\"getProject: %w\", err)\n\t\t}\n\t}\n\n\treturn project, nil\n}", "title": "" }, { "docid": "8dc1c3707a3411046f267cebaf71e040", "score": "0.6409351", "text": "func (c *ioTProjects) Get(name string, options v1.GetOptions) (result *v1alpha1.IoTProject, err error) {\n\tresult = &v1alpha1.IoTProject{}\n\terr = c.client.Get().\n\t\tNamespace(c.ns).\n\t\tResource(\"iotprojects\").\n\t\tName(name).\n\t\tVersionedParams(&options, scheme.ParameterCodec).\n\t\tDo().\n\t\tInto(result)\n\treturn\n}", "title": "" }, { "docid": "a448a6db0f7e00d9a372782531005cfb", "score": "0.64025253", "text": "func (s *service) GetProjectById(ctx context.Context, req *communicator.Request, res *communicator.Response) error {\n\t// Retrieve all projects\n\tproject, err := s.mavenlink.GetProject(req.Workspace)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Assign retrieved project data to response\n\tres.Project = project\n\treturn nil\n}", "title": "" }, { "docid": "eee326e7a0faf0834dcb9e716f4ffc67", "score": "0.63735837", "text": "func GetProject(slugs ...string) (*Project, error) {\n\tslug := config.ProjectSlug\n\tfor _, s := range slugs {\n\t\tif s != \"\" {\n\t\t\tslug = s\n\t\t}\n\t}\n\tif slug == \"\" {\n\t\treturn nil, errors.New(\"[project slug] can't be empty\")\n\t}\n\treturn &Project{Slug: slug}, nil\n}", "title": "" }, { "docid": "287de9c2fdd087235a0345d90e0c963e", "score": "0.63689435", "text": "func (es *ElasticsearchStorage) GetProject(ctx context.Context, projectId string) (*prpb.Project, error) {\n\tprojectName := fmt.Sprintf(\"projects/%s\", projectId)\n\tlog := es.logger.Named(\"GetProject\").With(zap.String(\"project\", projectName))\n\n\tsearch := &esSearch{\n\t\tQuery: &filtering.Query{\n\t\t\tTerm: &filtering.Term{\n\t\t\t\t\"name\": projectName,\n\t\t\t},\n\t\t},\n\t}\n\tproject := &prpb.Project{}\n\n\terr := es.genericGet(ctx, log, search, projectsIndex(), project)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn project, nil\n}", "title": "" }, { "docid": "4ff4053a45b8e4fbebd24dd3f63b54a7", "score": "0.6363725", "text": "func (h *ProjectsHandler) Get(ctx context.Context, project string) (*Project, error) {\n\tbts, err := h.client.doGetRequest(ctx, buildPath(\"project\", project), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar r ProjectResponse\n\terrR := checkAPIResponse(bts, &r)\n\n\treturn r.Project, errR\n}", "title": "" }, { "docid": "74e57a767607a1137b0a7407a16904de", "score": "0.63591236", "text": "func (c *Client) Project(id string, t int) (*Project, error) {\n\turl, opaque := c.ResourceUrl(projectUrl, QMap{\":id\": id}, nil)\n\n\tvar project *Project\n\n\tcontents, err := c.Do(\"GET\", url, opaque, nil, t)\n\tif err == nil {\n\t\terr = json.Unmarshal(contents, &project)\n\t}\n\n\treturn project, err\n}", "title": "" }, { "docid": "9c916724643a05124d5c1f0412c63f1e", "score": "0.63589036", "text": "func (c HTTPClient) FindProject(nameOrID string) (*Project, error) {\n\tprojectBytes, err := c.FindProjectDetails(nameOrID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar project Project\n\terr = json.Unmarshal(projectBytes, &project)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &project, nil\n}", "title": "" }, { "docid": "f811cb95073a8e34c5059f6067761220", "score": "0.63384145", "text": "func GetProjectProjectNameResourceHandlerFunc(params project_resource.GetProjectProjectNameResourceParams) middleware.Responder {\n\tlogger := utils.NewLogger(\"\", \"\", \"configuration-service\")\n\tif !common.ProjectExists(params.ProjectName) {\n\t\treturn project_resource.NewGetProjectProjectNameResourceNotFound().WithPayload(&models.Error{Code: 404, Message: swag.String(\"Project does not exist\")})\n\t}\n\n\tcommon.LockProject(params.ProjectName)\n\tdefer common.UnlockProject(params.ProjectName)\n\n\terr := common.CheckoutBranch(params.ProjectName, \"master\", *params.DisableUpstreamSync)\n\tif err != nil {\n\t\tlogger.Error(fmt.Sprintf(\"Could not check out master branch of project %s\", params.ProjectName))\n\t\tlogger.Error(err.Error())\n\t\treturn project_resource.NewGetProjectProjectNameResourceDefault(500).WithPayload(&models.Error{Code: 500, Message: swag.String(\"Could not check out branch\")})\n\t}\n\n\tprojectConfigPath := config.ConfigDir + \"/\" + params.ProjectName\n\tresult := common.GetPaginatedResources(projectConfigPath, params.PageSize, params.NextPageKey)\n\n\treturn project_resource.NewGetProjectProjectNameResourceOK().WithPayload(result)\n}", "title": "" }, { "docid": "f6e5d0ec2487109b6c1db3406e84e3fa", "score": "0.63134205", "text": "func (s *Server) GetProjectByID(w http.ResponseWriter, r *http.Request) {\n\tid, err := strconv.ParseUint(chi.URLParam(r, \"id\"), 10, 64)\n\tif err != nil {\n\t\tapiutil.RespError(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\tm := model.Project{}\n\tprojectGet, err := m.GetByID(s.DB, id)\n\tif err != nil {\n\t\tapiutil.RespError(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\tapiutil.RespSuccess(w, projectGet)\n}", "title": "" }, { "docid": "93c558ab45ab577ffd1123f21e620ad0", "score": "0.629908", "text": "func (svc *ProjectsService) Get(ctx context.Context, id string) (*Project, *http.Response, error) {\n\tpath := projectResourcePath(id)\n\tret := new(Project)\n\tresp, err := svc.client.resourceGet(ctx, path, ret)\n\treturn ret, resp, err\n}", "title": "" }, { "docid": "335fda0245a3f36fdccd6b2ee26b56bb", "score": "0.62639356", "text": "func HandleGetProjectDetail(request *restful.Request, response *restful.Response) {\n\tlog.Printf(\"call HandleGetProjectDetail\")\n\tname := request.PathParameter(\"name\")\n\tresult, err := projects.GetProjectDetail(name)\n\tif err != nil {\n\t\thandleInternalError(response, err)\n\t\treturn\n\t}\n\tresponse.WriteHeaderAndEntity(http.StatusOK, result)\n}", "title": "" }, { "docid": "2ed87cd59789eb3f3aca98e552bc2b70", "score": "0.6236163", "text": "func (o OssShipperOutput) ProjectName() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *OssShipper) pulumi.StringOutput { return v.ProjectName }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "8cc9ef23275e29b6015740d7dffb05a4", "score": "0.6230099", "text": "func (cm *ClusterManager) GetProject(ctx context.Context,\n\treq *cmproto.GetProjectRequest, resp *cmproto.GetProjectResponse) error {\n\treqID, err := requestIDFromContext(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\tstart := time.Now()\n\tca := project.NewGetAction(cm.model)\n\tca.Handle(ctx, req, resp)\n\tmetrics.ReportAPIRequestMetric(\"GetProject\", \"grpc\", strconv.Itoa(int(resp.Code)), start)\n\tblog.Infof(\"reqID: %s, action: GetProject, req %v, resp.Code %d, resp.Message %s\",\n\t\treqID, req, resp.Code, resp.Message)\n\tblog.V(5).Infof(\"reqID: %s, action: GetProject, req %v, resp %v\",\n\t\treqID, req, resp)\n\treturn nil\n}", "title": "" }, { "docid": "d98d643841139437b6ce77c251f57dde", "score": "0.6225749", "text": "func (o WebhookOutput) ProjectName() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Webhook) pulumi.StringOutput { return v.ProjectName }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "d3b87d904f409092c61ca76b89f150b9", "score": "0.62067384", "text": "func SetProjectName(name string) {\n\thttpClient.project = name\n}", "title": "" }, { "docid": "a52d483a6183d22e44c1fa9112c5432d", "score": "0.62013954", "text": "func (a *ProjectApiService) GetProjectBySlug(ctx _context.Context, projectSlug string) (Project, *_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = _nethttp.MethodGet\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue Project\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/project/{project-slug}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"project-slug\"+\"}\", _neturl.QueryEscape(parameterToString(projectSlug, \"\")), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)\n\tif localVarHTTPContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHTTPContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHTTPHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\n\tif localVarHTTPHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHTTPHeaderAccept\n\t}\n\tif ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {\n\t\t\tvar key string\n\t\t\tif auth.Prefix != \"\" {\n\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t} else {\n\t\t\t\tkey = auth.Key\n\t\t\t}\n\t\t\tlocalVarHeaderParams[\"Circle-Token\"] = key\n\t\t}\n\t}\n\tif ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {\n\t\t\tvar key string\n\t\t\tif auth.Prefix != \"\" {\n\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t} else {\n\t\t\t\tkey = auth.Key\n\t\t\t}\n\t\t\tlocalVarQueryParams.Add(\"circle-token\", key)\n\t\t}\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tif localVarHTTPResponse.StatusCode >= 300 {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHTTPResponse.Status,\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 200 {\n\t\t\tvar v Project\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\tif err != nil {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: err.Error(),\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\treturn localVarReturnValue, localVarHTTPResponse, nil\n}", "title": "" }, { "docid": "7067a7c6a26ac65232683008da7d2ef6", "score": "0.61981446", "text": "func getProject(service project.UseCase) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\n\t\t// get variables from request url\n\t\tvars := mux.Vars(r)\n\n\t\tuuid, err := valueobject.IdentifierFromBytes([]byte(vars[\"id\"]))\n\t\tif err != nil {\n\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\tw.Write([]byte(err.Error()))\n\t\t\treturn\n\t\t}\n\n\t\tctx, cancel := context.WithTimeout(context.Background(), time.Duration(5)*time.Second)\n\t\tdefer cancel()\n\n\t\t// get the project\n\t\tp, err := service.GetProject(ctx, uuid)\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\t\tif err != nil && err == projectEntity.ErrProjectNotFound {\n\t\t\tw.WriteHeader(http.StatusNotFound)\n\t\t\tw.Write([]byte(err.Error()))\n\t\t\treturn\n\t\t}\n\n\t\tif err != nil && err != projectEntity.ErrProjectNotFound {\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\tw.Write([]byte(err.Error()))\n\t\t\treturn\n\t\t}\n\t\tif p == nil {\n\t\t\tw.WriteHeader(http.StatusNotFound)\n\t\t\tw.Write([]byte(projectEntity.ErrNoProjectDataReturned.Error()))\n\t\t\treturn\n\t\t}\n\n\t\tres := &presenter.Project{\n\t\t\tID: p.ID(),\n\t\t\tShortCode: p.ShortCode().String(),\n\t\t\tShortName: p.ShortName().String(),\n\t\t\tLongName: p.LongName().String(),\n\t\t\tDescription: p.Description().String(),\n\t\t\tCreatedAt: p.CreatedAt().String(),\n\t\t\tCreatedBy: p.CreatedBy().String(),\n\t\t\tChangedAt: p.ChangedAt().String(),\n\t\t\tChangedBy: p.ChangedBy().String(),\n\t\t\tDeletedAt: p.DeletedAt().String(),\n\t\t\tDeletedBy: p.DeletedBy().String(),\n\t\t}\n\n\t\t// replace null-values with \"null\"\n\t\t*res = res.NullifyJsonProps()\n\n\t\tif err := json.NewEncoder(w).Encode(res); err != nil {\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\tw.Write([]byte(err.Error()))\n\t\t}\n\t})\n}", "title": "" }, { "docid": "56a68cd7e3d05cb2ca44b78eaae739ea", "score": "0.6192493", "text": "func ProjectID(name string) (string, error) {\n\tparts := strings.Split(name, \"/\")\n\tif len(parts) < 2 {\n\t\treturn \"\", errors.New(fmt.Sprintf(\"Invalid resource name %s\", name))\n\t}\n\n\treturn parts[1], nil\n}", "title": "" }, { "docid": "64edc48360ca6f9a092cb6cd094cd9bc", "score": "0.61721677", "text": "func TestGetProjectEmptyName(t *testing.T) {\n\tsvc := Service{Store: &FakeStore{}}\n\tin := &api.SearchRequest{Name: \"\"}\n\n\t_, err := svc.GetProject(context.Background(), in)\n\tassert.Equal(t, status.Code(err), codes.Internal)\n}", "title": "" }, { "docid": "a18bea9f003e2c2e7ef7f5a7c6bc9c4d", "score": "0.616658", "text": "func (s *ProjectsServiceOp) Get(ctx context.Context, groupID string) (*Project, *atlas.Response, error) {\n\tif groupID == \"\" {\n\t\treturn nil, nil, atlas.NewArgError(\"groupID\", \"must be set\")\n\t}\n\n\tpath := fmt.Sprintf(\"%s/%s\", projectBasePath, groupID)\n\n\treq, err := s.Client.NewRequest(ctx, http.MethodGet, path, nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\troot := new(Project)\n\tresp, err := s.Client.Do(ctx, req, root)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn root, resp, err\n}", "title": "" }, { "docid": "3827be7b159ae40805598275191f1bec", "score": "0.616424", "text": "func GetProject() *Project {\n\tprojectIDs := config.Projects()\n\tprojectID := projectIDs[rand.Intn(len(projectIDs))]\n\tmx.Lock()\n\tdefer mx.Unlock()\n\tp, ok := projects[projectID]\n\tif ok {\n\t\treturn p\n\t}\n\n\ttestZones := map[string]int{}\n\tvar zoneIndices []string\n\tfor k, v := range config.Zones() {\n\t\ttestZones[k] = v\n\t\tzoneIndices = append(zoneIndices, k)\n\t}\n\n\tp = &Project{\n\t\tTestProjectID: projectID,\n\t\ttestZones: testZones,\n\t\tzoneIndices: zoneIndices,\n\t\tServiceAccountEmail: \"default\",\n\t\tServiceAccountScopes: []string{\n\t\t\t\"https://www.googleapis.com/auth/cloud-platform\",\n\t\t\t\"https://www.googleapis.com/auth/devstorage.full_control\",\n\t\t},\n\t}\n\n\tprojects[projectID] = p\n\treturn p\n}", "title": "" }, { "docid": "bc142a362b6bce247afed628c8f375c6", "score": "0.6164178", "text": "func getProject(c *macaron.Context) {\n\tid := c.ParamsInt(\"id\")\n\tdays := c.ParamsInt(\"days\")\n\tvar project Scope\n\tDB.Where(\"id = ?\", id).First(&project)\n\n\tproject.CalculateProjectStats(days)\n\n\tc.JSON(200, project)\n}", "title": "" }, { "docid": "1230c05af8bb3311f7441a15f8e0fa33", "score": "0.6136364", "text": "func (p *Provider) getProject(ctx context.Context, pkg dep_radar.Pkg) (string, error) {\n\tp.muMap.RLock()\n\tif project, ok := p.mapProject[pkg]; ok {\n\t\tp.muMap.RUnlock()\n\t\treturn project, nil\n\t}\n\tp.muMap.RUnlock()\n\t// if p.project != \"\" {\n\t// \treturn nil\n\t// }\n\tproject, err := GetProject(ctx, p.httpClient, pkg, p.gitDomain)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tp.muMap.Lock()\n\tp.mapProject[pkg] = project\n\tp.muMap.Unlock()\n\t// fmt.Printf(\"project = %+v\\n\", project)\n\t// p.project = project\n\treturn project, nil\n}", "title": "" }, { "docid": "4e98bb9900e0542e3c14d2865e4ed91a", "score": "0.6122132", "text": "func (s *ProjectsService) GetByID(ctx context.Context, id string) (project *Project, err error) {\n\treturn s.get(ctx, id)\n}", "title": "" }, { "docid": "6d8d43df99ef317574d561619a0070ce", "score": "0.6117054", "text": "func (p *ProjectsServiceOp) Get(ctx context.Context, projectID string) (*Project, *Response, error) {\n\treturn p.getHelper(ctx, projectID)\n}", "title": "" }, { "docid": "cebbf6b552343479766b90221cc96961", "score": "0.6095954", "text": "func GetProjects(request []string, params map[string][]string) (answer Answer) {\n\tvar err error\n\tvar res []APIProject\n\tdefer answer.make(&err, &res)\n\n\tvar rows *sql.Rows\n\trows, err = db.DB.Query(`SELECT p.id, p.nr, p.contract_date, p.install_date, p.address, p.comment,\n\t\tu.id, u.name, u.phone, u.position, u.comment,\n\t\tc.id, c.name, c.phone, c.comment\n\t\tFROM project p INNER JOIN user u ON p.user_id = u.id INNER JOIN client c ON p.client_id = c.id`)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer rows.Close()\n\tfor rows.Next() {\n\t\tvar u APIUser\n\t\tvar c APIClient\n\t\tp := APIProject{User: &u, Client: &c}\n\t\terr = rows.Scan(&p.ID, &p.Nr, &p.ContractDate, &p.InstallDate, &p.Address, &p.Comment,\n\t\t\t&u.ID, &u.Name, &u.Phone, &u.Position, &u.Comment,\n\t\t\t&c.ID, &c.Name, &c.Phone, &c.Comment)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tres = append(res, p)\n\t}\n\terr = rows.Err()\n\tif err != nil {\n\t\treturn\n\t}\n\treturn\n}", "title": "" }, { "docid": "858fc01a69201c90b1dc867d9d693be8", "score": "0.60937655", "text": "func getProject(d converter.TerraformResourceData, config *converter.Config) (string, error) {\n\treturn getProjectFromSchema(\"project\", d, config)\n}", "title": "" }, { "docid": "eff11bf32467079a86a1ff10fd4d929c", "score": "0.609313", "text": "func (api *API) GetIPsByProjectName(w http.ResponseWriter, r *http.Request) {\n\tvar res Result\n\tvar err error\n\tvar project string\n\n\tvars := mux.Vars(r)\n\tpathUnescapeErr := 0\n\tif project, err = url.PathUnescape(vars[\"name\"]); err != nil {\n\t\tpathUnescapeErr++\n\t}\n\n\tif pathUnescapeErr != 0 {\n\t\tsendInvalidArgument(w)\n\t\treturn\n\t}\n\n\tips, err := api.db.GetIPs(project)\n\tif err == models.ErrNotFound {\n\t\tlog.Debugf(\"Ip for project %s not found\", project)\n\t\tres = CodeToResult[CodeNotFound]\n\t\tres.Message = \"No IP found\"\n\n\t\tw.WriteHeader(res.HTTPCode)\n\t\tjson.NewEncoder(w).Encode(res)\n\t\treturn\n\t}\n\n\t// Database error\n\tif err != nil {\n\t\tlog.Errorf(\"Error in selecting projects %s\", err.Error())\n\n\t\tres = CodeToResult[CodeDatabaseError]\n\t\tres.Message += \"[error in selecting project IPs]\"\n\n\t\tw.WriteHeader(res.HTTPCode)\n\t\tjson.NewEncoder(w).Encode(res)\n\t\treturn\n\t}\n\n\tlog.Debugf(\"IPs : %+v\", ips)\n\n\tres = CodeToResult[CodeOK]\n\tres.Data = ips\n\tw.WriteHeader(res.HTTPCode)\n\tjson.NewEncoder(w).Encode(res)\n}", "title": "" }, { "docid": "2d4311dd818667c9c208a8b253328bf4", "score": "0.6084884", "text": "func (o *InlineResponse20010Comment) GetProjectName() string {\n\tif o == nil || o.ProjectName == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.ProjectName\n}", "title": "" }, { "docid": "7d7b24e65388a012bc4ab550867426e5", "score": "0.6083665", "text": "func (c *Cluster) GetInstanceProjectAndName(id int) (string, string, error) {\n\tvar project string\n\tvar name string\n\tq := `\nSELECT projects.name, instances.name\n FROM instances\n JOIN projects ON projects.id = instances.project_id\nWHERE instances.id=?\n`\n\terr := c.Transaction(context.TODO(), func(ctx context.Context, tx *ClusterTx) error {\n\t\treturn tx.tx.QueryRowContext(ctx, q, id).Scan(&project, &name)\n\t})\n\n\tif err == sql.ErrNoRows {\n\t\treturn \"\", \"\", api.StatusErrorf(http.StatusNotFound, \"Instance not found\")\n\t}\n\n\treturn project, name, err\n}", "title": "" }, { "docid": "0e0babb95d0f3e0f2a649fef6ddb1065", "score": "0.606844", "text": "func (r *Repository) GetProject() string {\n\tif !strings.ContainsRune(r.Name, '/') {\n\t\treturn \"\"\n\t}\n\treturn r.Name[0:strings.LastIndex(r.Name, \"/\")]\n}", "title": "" }, { "docid": "5351c56abb724a78c2de1407616455d8", "score": "0.60675156", "text": "func FetchProjectByLabel(ctx context.Context, c *client.Marketplace, teamID *manifold.ID, label string) (*models.Project, error) {\n\tprojects, err := FetchProjects(ctx, c, teamID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, p := range projects {\n\t\tif string(p.Body.Label) == label {\n\t\t\treturn p, nil\n\t\t}\n\t}\n\n\treturn nil, fmt.Errorf(\"Project with label %q not found\", label)\n}", "title": "" }, { "docid": "084637171b7a1c29e559524b3fc5b5d2", "score": "0.6064544", "text": "func (s *ProjectClient) GetProjectByID(pid int64) (Project, error) {\n\tvar project Project\n\tresp, _, errs := s.NewRequest(gorequest.GET, \"/\"+I64toA(pid)).\n\t\tEndStruct(&project)\n\treturn project, CheckResponse(errs, resp, 200)\n}", "title": "" }, { "docid": "befd425f3adff66e06620483c74dfefb", "score": "0.6060482", "text": "func (mv *projectsMaterializedView) GetProject(projectName string) (*models.ExpandedProject, error) {\n\tproject, err := mv.ProjectRepo.GetProject(projectName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif project != nil {\n\t\tif err := setShipyardVersion(project); err != nil {\n\t\t\t// log the error but continue\n\t\t\tmv.Logger.Error(fmt.Sprintf(\"could not set shipyard version of project %s: %s\", project.ProjectName, err.Error()))\n\t\t}\n\t}\n\treturn project, nil\n}", "title": "" }, { "docid": "03e83bcd5ecf840431db69422ddc17aa", "score": "0.60580593", "text": "func ShowProjectByAlias(c *fiber.Ctx) {\n\t// Get alias from URL\n\talias := c.Params(\"alias\")\n\n\t// Create DB connection\n\tdb, errConnectDB := stores.OpenStore()\n\tif errConnectDB != nil {\n\t\t// DB connection error\n\t\tc.Status(500).JSON(fiber.Map{\"error\": true, \"msg\": errConnectDB.Error()})\n\t\treturn\n\t}\n\n\t// Find project by alias\n\tproject, errFindProjectByAlias := db.FindProjectByAlias(alias)\n\tif errFindProjectByAlias != nil {\n\t\t// Project not found\n\t\tc.Status(404).JSON(fiber.Map{\"error\": true, \"msg\": \"project not found\", \"project\": nil})\n\t\treturn\n\t}\n\n\t// Find project author by ID\n\tuser, errFindUserByID := db.FindUserByID(project.AuthorID)\n\tif errFindUserByID != nil {\n\t\t// User not found\n\t\tc.Status(404).JSON(fiber.Map{\n\t\t\t\"error\": true, \"msg\": \"project author not found\", \"project\": nil, \"author\": nil,\n\t\t})\n\t\treturn\n\t}\n\n\t// Rebuild author data\n\tauthor := fiber.Map{\n\t\t\"username\": user.Username,\n\t\t\"picture\": user.UserAttrs.Picture,\n\t\t\"first_name\": user.UserAttrs.FirstName,\n\t\t\"last_name\": user.UserAttrs.LastName,\n\t}\n\n\tc.JSON(fiber.Map{\"error\": false, \"msg\": nil, \"project\": project, \"author\": author})\n}", "title": "" }, { "docid": "4951c57233e3ba097ad762c0eb4ea7ac", "score": "0.60511684", "text": "func getProject(id string, cookie string) (*dao.Project, error) {\n\tif id == \"\" {\n\t\treturn nil, errors.NewClient(\"Parameter `id` is required\")\n\t}\n\n\temail, err := verifyCookie(cookie, db)\n\tif err != nil {\n\t\treturn nil, errors.NewClient(\"Not authenticated\")\n\t}\n\n\tproject, err := db.GetProject(email, id)\n\treturn project, errors.Wrap(err, \"Failed to get project\")\n}", "title": "" }, { "docid": "41530a42c1a2e251b7edcf9d231be293", "score": "0.6047418", "text": "func (p *Projects) GetByID(id int) (*project.Project, error) {\n\tvar findID, userID int\n\tvar title, baseURL, repositoryOwner, repositoryName, helmRepositoryURL, helmDirectoryName, namespace string\n\terr := p.db.QueryRow(\"SELECT id, user_id, title, base_url, repository_owner, repository_name, helm_repository_url, helm_directory_name, namespace FROM projects WHERE id = $1\", id).Scan(&findID, &userID, &title, &baseURL, &repositoryOwner, &repositoryName, &helmRepositoryURL, &helmDirectoryName, &namespace)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &project.Project{\n\t\tID: findID,\n\t\tUserID: userID,\n\t\tTitle: title,\n\t\tBaseURL: baseURL,\n\t\tRepositoryOwner: repositoryOwner,\n\t\tRepositoryName: repositoryName,\n\t\tHelmRepositoryURL: helmRepositoryURL,\n\t\tHelmDirectoryName: helmDirectoryName,\n\t\tNamespace: namespace,\n\t}, nil\n}", "title": "" }, { "docid": "db7c281acf262caa6f17f4c91fff6ddf", "score": "0.60354304", "text": "func (o *LoginOptions) gatherProjectInfo() error {\n\tprojectClient, err := projectv1typedclient.NewForConfig(o.Config)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tprojectsList, err := projectClient.Projects().List(context.TODO(), metav1.ListOptions{})\n\t// if we're running on kube (or likely kube), just set it to \"default\"\n\tif err != nil {\n\t\tif !kerrors.IsNotFound(err) && !kerrors.IsForbidden(err) {\n\t\t\tfmt.Fprintf(o.Out, \"WARNING: Failed to list projects: %v\\n\", err)\n\t\t}\n\t\tfmt.Fprintf(o.Out, \"Using \\\"default\\\" namespace. You can switch namespaces with:\\n\\n %s project <projectname>\\n\", o.CommandName)\n\t\to.Project = \"default\"\n\t\treturn nil\n\t}\n\n\tprojectsItems := projectsList.Items\n\tprojects := sets.String{}\n\tfor _, project := range projectsItems {\n\t\tprojects.Insert(project.Name)\n\t}\n\n\tif len(o.DefaultNamespace) > 0 && !projects.Has(o.DefaultNamespace) {\n\t\t// Attempt a direct get of our current project in case it hasn't appeared in the list yet\n\t\tif currentProject, err := projectClient.Projects().Get(context.TODO(), o.DefaultNamespace, metav1.GetOptions{}); err == nil {\n\t\t\t// If we get it successfully, add it to the list\n\t\t\tprojectsItems = append(projectsItems, *currentProject)\n\t\t\tprojects.Insert(currentProject.Name)\n\t\t}\n\t}\n\n\tswitch len(projectsItems) {\n\tcase 0:\n\t\tcanRequest, err := loginutil.CanRequestProjects(o.Config, o.DefaultNamespace)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmsg := ocerrors.NoProjectsExistMessage(canRequest)\n\t\tfmt.Fprintf(o.Out, msg)\n\t\to.Project = \"\"\n\n\tcase 1:\n\t\to.Project = projectsItems[0].Name\n\t\tfmt.Fprintf(o.Out, \"You have one project on this server: %q\\n\\n\", o.Project)\n\t\tfmt.Fprintf(o.Out, \"Using project %q.\\n\", o.Project)\n\n\tdefault:\n\t\tnamespace := o.DefaultNamespace\n\t\tif !projects.Has(namespace) {\n\t\t\tif namespace != metav1.NamespaceDefault && projects.Has(metav1.NamespaceDefault) {\n\t\t\t\tnamespace = metav1.NamespaceDefault\n\t\t\t} else {\n\t\t\t\tnamespace = projects.List()[0]\n\t\t\t}\n\t\t}\n\n\t\tcurrent, err := projectClient.Projects().Get(context.TODO(), namespace, metav1.GetOptions{})\n\t\tif err != nil && !kerrors.IsNotFound(err) && !kerrors.IsForbidden(err) {\n\t\t\treturn err\n\t\t}\n\t\to.Project = current.Name\n\n\t\t// Suppress project listing if the number of projects available to the user is greater than the threshold. Prevents unnecessarily noisy logins on clusters with large numbers of projects\n\t\tif len(projectsItems) > projectsItemsSuppressThreshold {\n\t\t\tfmt.Fprintf(o.Out, \"You have access to %d projects, the list has been suppressed. You can list all projects with '%s projects'\\n\\n\", len(projectsItems), o.CommandName)\n\t\t} else {\n\t\t\tfmt.Fprintf(o.Out, \"You have access to the following projects and can switch between them with '%s project <projectname>':\\n\\n\", o.CommandName)\n\t\t\tfor _, p := range projects.List() {\n\t\t\t\tif o.Project == p {\n\t\t\t\t\tfmt.Fprintf(o.Out, \" * %s\\n\", p)\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Fprintf(o.Out, \" %s\\n\", p)\n\t\t\t\t}\n\t\t\t}\n\t\t\tfmt.Fprintln(o.Out)\n\t\t}\n\t\tfmt.Fprintf(o.Out, \"Using project %q.\\n\", o.Project)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "f4325d230eb1b4611291d5d866b50230", "score": "0.60152555", "text": "func getProjectByID(id int) (*ProjectExample, error) {\n\tfor _, a := range projectList {\n\t\tif a.ID == id {\n\t\t\treturn &a, nil\n\t\t}\n\t}\n\treturn nil, errors.New(\"Project not found\")\n}", "title": "" }, { "docid": "9d496c9e9f19da9d05c96a9963181d3f", "score": "0.6009085", "text": "func getProjects(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tvar projs []models.Project\n\tif err := db.Admin.DB().Find(&projs).Error; err != nil {\n\t\tResponseError(w, NewUnexceptedWebError(err))\n\t\treturn\n\t}\n\tResponseJSONOK(w, projs)\n}", "title": "" }, { "docid": "15e05df284ed7cb743b6a559c195c6b0", "score": "0.6008366", "text": "func (m Meta) ProjectNameOrDefault() string {\n\tif m.ProjectName != \"\" {\n\t\treturn m.ProjectName\n\t}\n\treturn ProjectName\n}", "title": "" }, { "docid": "6dad89a6cb2cfa61756a1efcbae9fe62", "score": "0.59988654", "text": "func (a testapi) ProjectsGetByPID(projectID string) (int, apilib.Project, error) {\n\t_sling := sling.New().Get(a.basePath)\n\n\t// create api path\n\tpath := \"api/projects/\" + projectID\n\t_sling = _sling.Path(path)\n\n\tvar successPayload apilib.Project\n\n\thttpStatusCode, body, err := request(_sling, jsonAcceptHeader)\n\tif err == nil && httpStatusCode == 200 {\n\t\terr = json.Unmarshal(body, &successPayload)\n\t}\n\treturn httpStatusCode, successPayload, err\n}", "title": "" }, { "docid": "bcf7ad2ba645135a052f23e2757326d7", "score": "0.5996633", "text": "func projectsShow(w http.ResponseWriter, r *http.Request) {\n\tif r.Method != \"GET\" {\n\t\thttp.Error(w, http.StatusText(405), 405)\n\t\treturn\n\t}\n\n\tID, _ := strconv.Atoi(r.FormValue(\"ID\"))\n\tif ID == 0 {\n\t\thttp.Error(w, http.StatusText(400), 400)\n\t\treturn\n\t}\n\n\trow := db.QueryRow(\"SELECT * FROM projects WHERE ID = $1\", ID)\n\n\tpr := new(Project)\n\terr := row.Scan(&pr.ID, &pr.Name, &pr.Description)\n\tif err == sql.ErrNoRows {\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t} else if err != nil {\n\t\thttp.Error(w, http.StatusText(500), 500)\n\t\treturn\n\t}\n\n\tout, err := json.Marshal(pr)\n\tif err != nil {\n\t\thttp.Error(w, http.StatusText(500), 500)\n\t\treturn\n\t}\n\n\tfmt.Fprintf(w, string(out))\n}", "title": "" }, { "docid": "d3436e714a2ac25d9460672517e8fcc4", "score": "0.5986742", "text": "func (p *Project) Name() string {\n\treturn p.parsedURL.Name\n}", "title": "" }, { "docid": "df582a8fa25eec3f15041c591655bb9a", "score": "0.59598166", "text": "func getProject(client *gitlab.Client, repository string) (*gitlab.Project, error) {\n\topt := &gitlab.ListProjectsOptions{\n\t\tListOptions: gitlab.ListOptions{\n\t\t\tPerPage: 100,\n\t\t\tPage: 1,\n\t\t},\n\t}\n\n\tfor {\n\t\t// Get the current page with projects.\n\t\tprojects, resp, err := client.Projects.ListProjects(opt)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\n\t\t// List all the projects we've found so far.\n\t\tfor _, p := range projects {\n\t\t\t// Return the project if the PathWithNamespace equals the repository\n\t\t\t// string.\n\t\t\tif p.PathWithNamespace == repository {\n\t\t\t\treturn p, nil\n\t\t\t}\n\t\t}\n\n\t\t// Exit loop when we've seen all the pages.\n\t\tif opt.Page >= resp.TotalPages {\n\t\t\tbreak\n\t\t}\n\n\t\t// Update the page number to get the next page.\n\t\topt.Page = resp.NextPage\n\t}\n\n\treturn nil, errors.New(\"requested repository not found\")\n}", "title": "" }, { "docid": "c537f6d2a7001ef2c6bf3fa3d35c7f53", "score": "0.5954392", "text": "func GetProject(ctx *pulumi.Context,\n\tname string, id pulumi.IDInput, state *ProjectState, opts ...pulumi.ResourceOption) (*Project, error) {\n\tvar resource Project\n\terr := ctx.ReadResource(\"aws-native:databrew:Project\", name, id, state, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "title": "" }, { "docid": "5a1aa207ad461bb64cd007518df5c009", "score": "0.5945105", "text": "func (p *providerClientImpl) GetProject(projectID string) (*CachedProject, error) {\n\tp.cacheMutex.RLock()\n\tresult, ok := p.projectCache[projectID]\n\tp.cacheMutex.RUnlock()\n\tif ok {\n\t\treturn result, nil\n\t}\n\n\tidentityV3, err := p.CloudAdminClient(openstack.NewIdentityV3)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tproject, err := projects.Get(identityV3, projectID).Extract()\n\tif err != nil {\n\t\tif errext.IsOfType[gophercloud.ErrDefault404](err) {\n\t\t\tp.cacheMutex.Lock()\n\t\t\tp.projectCache[projectID] = nil\n\t\t\tp.cacheMutex.Unlock()\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn nil, err\n\t}\n\n\tresult = &CachedProject{Name: project.Name, DomainID: project.DomainID}\n\tp.cacheMutex.Lock()\n\tp.projectCache[projectID] = result\n\tp.cacheMutex.Unlock()\n\treturn result, nil\n}", "title": "" }, { "docid": "45db358e565a3c7c2fec2a797beb1d80", "score": "0.5924887", "text": "func (c *Mock) GetProject(ctx context.Context, td TaskData) (*serviceModel.Project, error) {\n\tif c.GetProjectResponse != nil {\n\t\treturn c.GetProjectResponse, nil\n\t}\n\tvar err error\n\tvar data []byte\n\t_, file, _, _ := runtime.Caller(0)\n\n\tdata, err = os.ReadFile(filepath.Join(filepath.Dir(file), \"testdata\", fmt.Sprintf(\"%s.yaml\", td.ID)))\n\tif err != nil {\n\t\tgrip.Error(err)\n\t}\n\tproj := &serviceModel.Project{}\n\t_, err = serviceModel.LoadProjectInto(ctx, data, nil, \"\", proj)\n\treturn proj, err\n}", "title": "" }, { "docid": "cd09b6917e243dc30cea4c4441d7bdad", "score": "0.5923804", "text": "func (manager *ProjectManager) GetProject(stack *dockm.Stack, endpoint *dockm.Endpoint) (project.APIProject, error) {\n\tproj, ok := manager.projects.Get(string(stack.ID))\n\tif !ok {\n\t\treturn manager.createAndRegisterProject(stack, endpoint)\n\t}\n\treturn proj.(project.APIProject), nil\n}", "title": "" }, { "docid": "5b2e4e3d1ee515fa1c1282c22fceb6a1", "score": "0.59168357", "text": "func getProjectsByUsername(c *gin.Context) {\n\tusername, password, ok := c.Request.BasicAuth()\n\tif !ok || !utils.ValidateLDAPAuth(username, password) {\n\t\tc.JSON(http.StatusUnauthorized, gin.H{\"error\": \"You are not welcome here...\"})\n\t\treturn\n\t}\n\tprojects, err := models.GetProjectsByUserName(database, username)\n\tif err != nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"error\": \"Could not find projects\"})\n\t\treturn\n\t}\n\tc.JSON(http.StatusOK, projects)\n}", "title": "" }, { "docid": "b9d3fd23455ed8ec3c939b3cad01a3ae", "score": "0.5913172", "text": "func (s *ProjectsService) GetProjectInfo(ctx context.Context, syncToken string, ID string, allData bool) (ProjectInfo, error) {\n\ts.client.Logln(\"---------- Projects.GetProjectInfo\")\n\n\ts.client.SetDebug(false)\n\treq, err := s.client.NewRequest(syncToken, []string{}, nil)\n\tif err != nil {\n\t\treturn ProjectInfo{}, err\n\t}\n\ts.client.SetDebug(true)\n\n\t// Update the URL\n\treq.URL, _ = url.Parse(defaultBaseURL + \"/projects/get\")\n\n\t// Parse the request body\n\tbody, err := ioutil.ReadAll(req.Body)\n\tif err != nil {\n\t\treturn ProjectInfo{}, err\n\t}\n\n\tform, err := url.ParseQuery(string(body))\n\tif err != nil {\n\t\treturn ProjectInfo{}, err\n\t}\n\n\t// Remove the \"commands\" form field since we don't use it in this request\n\tform.Del(\"commands\")\n\n\t// Add GetProjectInfo-specific fields\n\tform.Add(\"project_id\", ID)\n\tform.Add(\"all_data\", strconv.FormatBool(allData))\n\n\tfor k := range form {\n\t\ts.client.Logf(\"%-15s %-30s\\n\", k, form.Get(k))\n\t}\n\ts.client.Logln()\n\n\tbodyReader := strings.NewReader(form.Encode())\n\n\t// Set the updated content-length header or else http/2 will complain about\n\t// request body being larger than the content length\n\treq.ContentLength = int64(bodyReader.Len())\n\n\t// Add encoded form back to the original request body\n\treq.Body = io.NopCloser(bodyReader)\n\n\tvar projectInfoResponse ProjectInfo\n\t_, err = s.client.Do(ctx, req, &projectInfoResponse)\n\tif err != nil {\n\t\treturn ProjectInfo{}, err\n\t}\n\n\treturn projectInfoResponse, nil\n}", "title": "" }, { "docid": "9af05dd64cc3558b92eddff97c5174ac", "score": "0.59099704", "text": "func (s *ReleasesService) GetLatestByProjectName(ctx context.Context, provider, projectName string) (release *Release, err error) {\n\treturn s.getLatest(ctx, provider+\"/\"+projectName)\n}", "title": "" }, { "docid": "36c7f5eb1e198968363053c3186e87b1", "score": "0.5904894", "text": "func (client *Client) ProjectShow(id string) (*ProjectDetails, error) {\n\tretVal := new(ProjectDetails)\n\terr := func() error {\n\n\t\turl := fmt.Sprintf(\"/v2/projects/%s\", url.QueryEscape(id))\n\n\t\trc, err := client.sendRequest(\"GET\", url, \"\", nil, 200)\n\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer rc.Close()\n\n\t\tvar reader io.Reader\n\t\tif client.debug {\n\t\t\treader = io.TeeReader(rc, os.Stderr)\n\t\t} else {\n\t\t\treader = rc\n\t\t}\n\n\t\treturn json.NewDecoder(reader).Decode(&retVal)\n\n\t}()\n\treturn retVal, err\n}", "title": "" }, { "docid": "3f071d634a80a56acbb44fe860a478b5", "score": "0.5897035", "text": "func (s *store) GetProject(id string) (*brigade.Project, error) {\n\treturn s.loadProjectConfig(brigade.ProjectID(id))\n}", "title": "" }, { "docid": "b1e1dcfeb06dc745987604609bf63d88", "score": "0.58970153", "text": "func (r repository) UpdateProjectName(projectID string, projectName string) error {\n\tquery := bson.D{{\"_id\", projectID}}\n\tupdate := bson.D{{\"$set\", bson.M{\"name\": projectName}}}\n\n\t_, err := r.Collection.UpdateOne(context.TODO(), query, update)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "85759ffc48d75d17e001930786b915ea", "score": "0.5896856", "text": "func (api42 *API42) GetProjects() *[]API42Project {\n\tvar err error\n\n\tprojects := make([]API42Project, 0)\n\tprojectsURL, paramURL := api42.prepareGetParamURLReq(cst.ProjectsURL)\n\tparamURL.Add(\"cursus_id\", strconv.FormatUint(uint64(api42.cursus.ID), 10))\n\tparamURL.Add(cst.ReqFilter+\"[has_git]\", \"true\")\n\tparamURL.Add(cst.ReqFilter+\"[has_mark]\", \"true\")\n\tparamURL.Add(cst.ReqFilter+\"[visible]\", \"true\")\n\tparamURL.Add(cst.ReqFilter+\"[exam]\", \"false\")\n\tparamURL.Add(cst.ReqPageSize, cst.ReqPageSizeMax)\n\n\tfor i := 1; ; i++ {\n\t\tpageNumberStr := strconv.Itoa(i)\n\t\tlog.Info().Msg(\"GetProjects: GET page \" + pageNumberStr + \" ...\")\n\t\tparamURL.Set(cst.ReqPage, pageNumberStr)\n\t\tprojectsURL.RawQuery = paramURL.Encode()\n\n\t\trsp := api42.executeGetURLReq(projectsURL)\n\t\tif rsp == nil {\n\t\t\treturn nil\n\t\t}\n\t\tdefer rsp.Body.Close()\n\n\t\trspJSON := make([]API42Project, 0)\n\t\tdecoder := json.NewDecoder(rsp.Body)\n\t\tif err = decoder.Decode(&rspJSON); err != nil {\n\t\t\tlog.Fatal().Err(err).Msg(\"GetProjects: Failed to decode JSON values of a project\")\n\t\t}\n\t\tif len(rspJSON) == 0 {\n\t\t\tbreak\n\t\t}\n\t\ti := 0\n\t\tfor _, project := range rspJSON {\n\t\t\tfor _, campus := range project.Campus {\n\t\t\t\tif campus.ID == api42.campus.ID {\n\t\t\t\t\tproject.Campus = nil\n\t\t\t\t\trspJSON[i] = project\n\t\t\t\t\ti++\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\trspJSON = rspJSON[:i]\n\t\t// fmt.Println(rspJSON)\n\t\tprojects = append(projects, rspJSON...)\n\t}\n\n\tif len(projects) == 0 {\n\t\tlog.Fatal().Msg(\"GetProjects: no project found\")\n\t\treturn nil\n\t}\n\tlog.Info().Msg(\"GetProjects: projects updated\")\n\treturn &projects\n}", "title": "" }, { "docid": "1ee3cd1ccfc4e4f631667d63d0b48f46", "score": "0.58945143", "text": "func GetProject(name, cfgPath string, verbose bool) (*core.Project, error) {\n\tconfig, err := GetConfig(cfgPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"fail to parse config file: %v\", err)\n\t}\n\tclient, err := GetClient(verbose)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"fail to create new client: %v\", err)\n\t}\n\treturn core.NewProjectFromConfig(GetProjectName(cfgPath, name), config, client)\n}", "title": "" }, { "docid": "7dc6cc03592ae44f9866e5d4a4b948dc", "score": "0.5892512", "text": "func ProjectByPrincipalIDNameDB(db *sql.DB, principalID int64, projectName string) (*Project, error) {\n\trow := db.QueryRow(selectProjectByPrincipalIdAndName, principalID, projectName)\n\treturn scanProject(row)\n}", "title": "" }, { "docid": "566ca26e85a295fb0d870029cc27bdc6", "score": "0.5889112", "text": "func (p *ProjectController) Get(c *gin.Context) {\n\tid := c.Param(\"id\")\n\tif len(id) == 0 {\n\t\tp.DefaultBadRequest(c)\n\t\treturn\n\t}\n\tproject, err := p.AppContext.ProjectService.GetByID(id, p.GetCurrentUser(c))\n\tif err != nil {\n\t\tc.JSON(err.GetHttpCode(), err.GetMessage())\n\t\treturn\n\t}\n\tp.Success(c, project)\n}", "title": "" }, { "docid": "6bbeeaca57fad337162bf9b5d3376942", "score": "0.5872241", "text": "func (s *ProjectsService) UpdateByName(ctx context.Context, provider, name string, o *ProjectOptions) (project *Project, err error) {\n\treturn s.update(ctx, provider+\"/\"+name, o)\n}", "title": "" }, { "docid": "95faace2572f7b65ff741b8ceee7d550", "score": "0.5866725", "text": "func NewGetProjectProjectNameResourceDefault(code int) *GetProjectProjectNameResourceDefault {\n\tif code <= 0 {\n\t\tcode = 500\n\t}\n\n\treturn &GetProjectProjectNameResourceDefault{\n\t\t_statusCode: code,\n\t}\n}", "title": "" }, { "docid": "09b149f3f7fa9e0531843d3478d48b48", "score": "0.5854068", "text": "func ResolveProjectName(wfr v1alpha1.WorkflowRun) string {\n\tif wfr.Labels != nil {\n\t\tif n, ok := wfr.Labels[meta.LabelProjectName]; ok {\n\t\t\treturn n\n\t\t}\n\t}\n\treturn \"\"\n}", "title": "" }, { "docid": "d21263f98dcf9b3d2d3ba35b4700bf55", "score": "0.5851259", "text": "func (o GkeWorkloadResponseOutput) Project() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GkeWorkloadResponse) string { return v.Project }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "2e8e7df578e4dcb8e0918c34b992358f", "score": "0.5850948", "text": "func (o *ExportOptions) GetProjectName() string {\n\tif o == nil || o.ProjectName == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.ProjectName\n}", "title": "" }, { "docid": "3b2302d262e9cbc06019f2cc852f135a", "score": "0.58508176", "text": "func GetProject(c *gin.Context) (*model.Project, error) {\n\tid, err := GetIDParam(c, projectIDParam)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif project, err := model.GetProject(*id); err == nil {\n\t\treturn project, nil\n\t}\n\n\treturn nil, &util.APIError{\n\t\tCode: util.ProjectNotFoundError,\n\t\tMessage: \"Project not found.\",\n\t\tStatus: http.StatusNotFound,\n\t}\n}", "title": "" }, { "docid": "b59d05ee0745e9c3a635c13fd2c49f23", "score": "0.584344", "text": "func (a testapi) ProjectsGet(query *apilib.ProjectQuery, authInfo ...usrInfo) (int, []apilib.Project, error) {\n\t_sling := sling.New().Get(a.basePath).\n\t\tPath(\"api/projects\").\n\t\tQueryStruct(query)\n\n\tvar successPayload []apilib.Project\n\n\tvar httpStatusCode int\n\tvar err error\n\tvar body []byte\n\tif len(authInfo) > 0 {\n\t\thttpStatusCode, body, err = request(_sling, jsonAcceptHeader, authInfo[0])\n\t} else {\n\t\thttpStatusCode, body, err = request(_sling, jsonAcceptHeader)\n\t}\n\n\tif err == nil && httpStatusCode == 200 {\n\t\terr = json.Unmarshal(body, &successPayload)\n\t} else {\n\t\tlog.Println(string(body))\n\t}\n\n\treturn httpStatusCode, successPayload, err\n}", "title": "" } ]
a9692a263bbb47b9c45cd878cbf3816d
Deprecated: Use CPlayer_DeletePostedStatus_Response.ProtoReflect.Descriptor instead.
[ { "docid": "ef86e5563ab1351de5797e1acae954f5", "score": "0.7849736", "text": "func (*CPlayer_DeletePostedStatus_Response) Descriptor() ([]byte, []int) {\n\treturn file_steammessages_player_steamclient_proto_rawDescGZIP(), []int{18}\n}", "title": "" } ]
[ { "docid": "071ef9a4b11046345ed1016672c2010a", "score": "0.76685977", "text": "func (*CPlayer_DeletePostedStatus_Request) Descriptor() ([]byte, []int) {\n\treturn file_steammessages_player_steamclient_proto_rawDescGZIP(), []int{17}\n}", "title": "" }, { "docid": "409316d1bcc06b5b4ec7cc1b6d0bdb42", "score": "0.7011656", "text": "func (*CPlayer_GetPostedStatus_Response) Descriptor() ([]byte, []int) {\n\treturn file_steammessages_player_steamclient_proto_rawDescGZIP(), []int{16}\n}", "title": "" }, { "docid": "83007a2fc05d0f5b49a391c228c84c8c", "score": "0.6952948", "text": "func (*DeleteMessagePostResponse) Descriptor() ([]byte, []int) {\n\treturn file_messagepb_message_post_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "c760442efe9264453bce1ac3dd7b4c08", "score": "0.6935449", "text": "func (*DeletePendingMessagesRequest) Descriptor() ([]byte, []int) {\n\treturn file_fleetspeak_src_server_proto_fleetspeak_server_admin_proto_rawDescGZIP(), []int{9}\n}", "title": "" }, { "docid": "380ccf7fc90b0df45ee82f9392d107d5", "score": "0.6934197", "text": "func (*MemberLevelDeleteResp) Descriptor() ([]byte, []int) {\n\treturn file_api_front_admin_v1_ums_proto_rawDescGZIP(), []int{44}\n}", "title": "" }, { "docid": "95507d825bd28dc75b90eec0d455b832", "score": "0.6893932", "text": "func (*DeleteReply) Descriptor() ([]byte, []int) {\n\treturn file_protoc_action_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "224ecf4f9ede59488c748088de870fe7", "score": "0.6893377", "text": "func (*DeleteResponse) Descriptor() ([]byte, []int) {\n\treturn file_protos_todo_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "cd233d80b1ee6d9c623e1265c81fb0a2", "score": "0.68837076", "text": "func (*DeleteMessageResponse) Descriptor() ([]byte, []int) {\n\treturn file_chat_v1_messages_proto_rawDescGZIP(), []int{18}\n}", "title": "" }, { "docid": "660014c665683b2e9b944ddda01042be", "score": "0.68670154", "text": "func (*RemoveResponse) Descriptor() ([]byte, []int) {\n\treturn file_proto_v1_squzy_monitoring_proto_rawDescGZIP(), []int{14}\n}", "title": "" }, { "docid": "98fce7368da42ea09a96b3e9691c3e4c", "score": "0.6859514", "text": "func (*DeleteIssueStatusRequest) Descriptor() ([]byte, []int) {\n\treturn file_protobuf_issues_issues_proto_rawDescGZIP(), []int{11}\n}", "title": "" }, { "docid": "0ce1a7d4e0ad5c6fd54bd8bd203cdab0", "score": "0.682004", "text": "func (*MemberDeleteResp) Descriptor() ([]byte, []int) {\n\treturn file_api_front_admin_v1_ums_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "3eb429684dae25a72627dc7bc1baa1f6", "score": "0.6818147", "text": "func (*DeleteResponse) Descriptor() ([]byte, []int) {\n\treturn file_service_language_proto_word_word_service_proto_rawDescGZIP(), []int{11}\n}", "title": "" }, { "docid": "44a0ebdd6fae9dd1881e18cb60308cb5", "score": "0.67979985", "text": "func (*DeleteResponse) Descriptor() ([]byte, []int) {\n\treturn file_v2_object_grpc_service_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "b24f8e98b6b8fa3263f224ff318fab8e", "score": "0.67778033", "text": "func (*DeleteResponse) Descriptor() ([]byte, []int) {\n\treturn file_grpc_aluno_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "ee7dc3dd179e558e559f013b39c3c27b", "score": "0.67732674", "text": "func (DeleteAnswerResponse_Status) EnumDescriptor() ([]byte, []int) {\r\n\treturn file_proto_answer_answer_proto_rawDescGZIP(), []int{8, 0}\r\n}", "title": "" }, { "docid": "9566f10fb0d80f0e81d4f8558f7c44f8", "score": "0.67491406", "text": "func (*MemberTagDeleteResp) Descriptor() ([]byte, []int) {\n\treturn file_api_front_admin_v1_ums_proto_rawDescGZIP(), []int{107}\n}", "title": "" }, { "docid": "a17104d0fe0ea36ef70127566b5443a4", "score": "0.67425555", "text": "func (*MemberStatisticsInfoDeleteResp) Descriptor() ([]byte, []int) {\n\treturn file_api_front_admin_v1_ums_proto_rawDescGZIP(), []int{98}\n}", "title": "" }, { "docid": "1e3bfa89a0adbff80aa03ae4fee12102", "score": "0.6735147", "text": "func (*DeleteResp) Descriptor() ([]byte, []int) {\n\treturn file_streams_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "0b23e03fa70cd5b0aa5e278c9098ef24", "score": "0.67277247", "text": "func (*DeleteRequest) Descriptor() ([]byte, []int) {\n\treturn file_grpc_contract_tracker_service_v1_project_project_proto_rawDescGZIP(), []int{6}\n}", "title": "" }, { "docid": "ad0e89c2ec4d6c5226d3b8c196ba8037", "score": "0.671685", "text": "func (*LongMsgDeleteRsp) Descriptor() ([]byte, []int) {\n\treturn file_longmsg_proto_rawDescGZIP(), []int{1}\n}", "title": "" }, { "docid": "11740635c977d7ee6e4608cb45f9e9a5", "score": "0.6710246", "text": "func (*DeleteRequest) Descriptor() ([]byte, []int) {\n\treturn file_protoc_action_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "0461641da609ab9927d336e220ba66d8", "score": "0.6702762", "text": "func (*DeleteResponse) Descriptor() ([]byte, []int) {\n\treturn file_proto_file_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "902b99e2edaec3c5a0677c79cfaea5d6", "score": "0.66887075", "text": "func (*DeleteReply) Descriptor() ([]byte, []int) {\n\treturn file_raftdb_grpc_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "14125b0ac6099fa0f3ef4c096e7adc0d", "score": "0.6686365", "text": "func (*DeleteResponse) Descriptor() ([]byte, []int) {\n\treturn file_proto_customers_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "7e8051d1afc89c219a6131c0a8c0b7b5", "score": "0.6681541", "text": "func (*DeleteLabelsRequest_Response) Descriptor() ([]byte, []int) {\n\treturn file_modeldb_metadata_MetadataService_proto_rawDescGZIP(), []int{5, 0}\n}", "title": "" }, { "docid": "7a05476195166d64e1d87522ba07647f", "score": "0.66634786", "text": "func (*DeleteTopicResponse) Descriptor() ([]byte, []int) {\n\treturn file_common_proto_rawDescGZIP(), []int{9}\n}", "title": "" }, { "docid": "1ab0465b70d4d8e98026d3d5e2d01126", "score": "0.664985", "text": "func (*CPlayer_GetPostedStatus_Request) Descriptor() ([]byte, []int) {\n\treturn file_steammessages_player_steamclient_proto_rawDescGZIP(), []int{15}\n}", "title": "" }, { "docid": "518957368babd8f10d82eb932d8cbda1", "score": "0.6639421", "text": "func (*DeletePostRequest) Descriptor() ([]byte, []int) {\n\treturn file_rpc_CommonService_proto_rawDescGZIP(), []int{10}\n}", "title": "" }, { "docid": "261985e0778407de49796bc9991304f2", "score": "0.6637971", "text": "func (*CPlayer_PostStatusToFriends_Response) Descriptor() ([]byte, []int) {\n\treturn file_steammessages_player_steamclient_proto_rawDescGZIP(), []int{14}\n}", "title": "" }, { "docid": "64ade522a3e72a52a745037063938f78", "score": "0.66373754", "text": "func (*RemoveNotificationResponse) Descriptor() ([]byte, []int) {\n\treturn file_proto_notifications_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "008b1c0741d812293ee91aa58912bdbc", "score": "0.6635608", "text": "func (*GrowthChangeHistoryDeleteResp) Descriptor() ([]byte, []int) {\n\treturn file_api_front_admin_v1_ums_proto_rawDescGZIP(), []int{17}\n}", "title": "" }, { "docid": "6cfd010a6e52167e65788bc05c1221fd", "score": "0.66330945", "text": "func (*MemberRuleSettingDeleteResp) Descriptor() ([]byte, []int) {\n\treturn file_api_front_admin_v1_ums_proto_rawDescGZIP(), []int{89}\n}", "title": "" }, { "docid": "13d196f8b2a8c55f6420edfd616e7c7f", "score": "0.66327375", "text": "func (*IntegrationChangeHistoryDeleteResp) Descriptor() ([]byte, []int) {\n\treturn file_api_front_admin_v1_ums_proto_rawDescGZIP(), []int{26}\n}", "title": "" }, { "docid": "679b8d1094af463453a6bf3a5492d68f", "score": "0.66135657", "text": "func (*RemoveQueryResponse) Descriptor() ([]byte, []int) {\n\treturn file_proto_dekart_proto_rawDescGZIP(), []int{14}\n}", "title": "" }, { "docid": "99f3e01d72f8d652e5af12825cc3c925", "score": "0.6613374", "text": "func (*GetMessageStatusResponse) Descriptor() ([]byte, []int) {\n\treturn file_fleetspeak_src_server_proto_fleetspeak_server_admin_proto_rawDescGZIP(), []int{14}\n}", "title": "" }, { "docid": "fa6a84ab9231964ff5d79aee39270c4c", "score": "0.66063523", "text": "func (*DeleteRequest) Descriptor() ([]byte, []int) {\n\treturn file_games_games_proto_rawDescGZIP(), []int{6}\n}", "title": "" }, { "docid": "16bf7262206e269342e067de7378f5cd", "score": "0.6605002", "text": "func (*GetPendingMessagesResponse) Descriptor() ([]byte, []int) {\n\treturn file_fleetspeak_src_server_proto_fleetspeak_server_admin_proto_rawDescGZIP(), []int{11}\n}", "title": "" }, { "docid": "f29e3344b93c038358c188d6e58d199e", "score": "0.65915865", "text": "func (*DeleteResponse) Descriptor() ([]byte, []int) {\n\treturn file_storage_server_proto_rawDescGZIP(), []int{1}\n}", "title": "" }, { "docid": "8b645ec08ff4bf9726d9159b95ca1dfe", "score": "0.6588855", "text": "func (*DelResp) Descriptor() ([]byte, []int) {\n\treturn file_category_proto_rawDescGZIP(), []int{6}\n}", "title": "" }, { "docid": "c751b7a3f515c9c9d9a91d4cce404ab3", "score": "0.6584917", "text": "func (*DeleteMessagePostRequest) Descriptor() ([]byte, []int) {\n\treturn file_messagepb_message_post_proto_rawDescGZIP(), []int{7}\n}", "title": "" }, { "docid": "840c67fef36619eed4bf18513d67bfec", "score": "0.65746135", "text": "func (*MemberTaskDeleteResp) Descriptor() ([]byte, []int) {\n\treturn file_api_front_admin_v1_ums_proto_rawDescGZIP(), []int{116}\n}", "title": "" }, { "docid": "949574728dbecfbfff9b10b21d742039", "score": "0.6560517", "text": "func (*DeleteRefreshTokenResponse) Descriptor() ([]byte, []int) {\n\treturn file_dto_auth_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "dd940896ac3e8b9d9fa45795a2a6a64b", "score": "0.65540045", "text": "func (*MonitoredResourceDescriptorChange_Removed) Descriptor() ([]byte, []int) {\n\treturn edgelq_monitoring_proto_v3_monitored_resource_descriptor_change_proto_rawDescGZIP(), []int{0, 3}\n}", "title": "" }, { "docid": "8fd3d682ac6a58e64149ce18cbd5367f", "score": "0.65505093", "text": "func (DeleteCode) EnumDescriptor() ([]byte, []int) {\n\treturn file_protoc_action_proto_rawDescGZIP(), []int{2}\n}", "title": "" }, { "docid": "4c415c2fa7165089877bd4367942886d", "score": "0.65496325", "text": "func (*TagContactDeleteResponse) Descriptor() ([]byte, []int) {\n\treturn file_puppet_tag_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "f4e9fe9b85b832d89f340449b5d27c1d", "score": "0.65474683", "text": "func (*DeleteRequest) Descriptor() ([]byte, []int) {\n\treturn file_service_language_proto_word_word_service_proto_rawDescGZIP(), []int{10}\n}", "title": "" }, { "docid": "38ef84c2d5d367ba38d74aa907f95ac4", "score": "0.65414965", "text": "func (*DeleteResponse) Descriptor() ([]byte, []int) {\n\treturn file_proto_template_v1_template_proto_rawDescGZIP(), []int{10}\n}", "title": "" }, { "docid": "5e88738e0e51ff0fbcf373d94609a6b6", "score": "0.65365696", "text": "func (*DeleteMemberResponse) Descriptor() ([]byte, []int) {\n\treturn file_member_proto_rawDescGZIP(), []int{13}\n}", "title": "" }, { "docid": "4e7ef0beb45730fb86fab5996edc20b3", "score": "0.6529162", "text": "func (*DeleteEventTriggeredMessageRequest) Descriptor() ([]byte, []int) {\n\treturn file_gincoinc_adamant_global_v1_adamantglobalv1_global_api_proto_rawDescGZIP(), []int{96}\n}", "title": "" }, { "docid": "0ee690e573bf460672110543b30b6a00", "score": "0.6528909", "text": "func (ReleaseCheckResponse_Status) EnumDescriptor() ([]byte, []int) {\r\n\treturn file_proto_homework_homework_proto_rawDescGZIP(), []int{34, 0}\r\n}", "title": "" }, { "docid": "5df72449aa94e05d836805c48215f589", "score": "0.6528799", "text": "func (*MessageDeleteRequest) Descriptor() ([]byte, []int) {\n\treturn file_message_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "151dd7b02f2dcf89150540c56d5ed192", "score": "0.6525946", "text": "func (*LongMsgDeleteReq) Descriptor() ([]byte, []int) {\n\treturn file_longmsg_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "e766c7bc38645409e5b76102567e5476", "score": "0.6525305", "text": "func (*DeleteRequest) Descriptor() ([]byte, []int) {\n\treturn file_grpc_aluno_proto_rawDescGZIP(), []int{7}\n}", "title": "" }, { "docid": "f67e603be81e11fd676727b058f522fd", "score": "0.6522726", "text": "func (*MemberReceiveAddressDeleteResp) Descriptor() ([]byte, []int) {\n\treturn file_api_front_admin_v1_ums_proto_rawDescGZIP(), []int{80}\n}", "title": "" }, { "docid": "f0f25404913ce7b1856428d7cbe5e80d", "score": "0.65128285", "text": "func (*ApiKeysResponses_Delete) Descriptor() ([]byte, []int) {\n\treturn file_apikeys_proto_rawDescGZIP(), []int{3, 0}\n}", "title": "" }, { "docid": "dd8663b44d318ab5f8e588c13c91fb15", "score": "0.6511037", "text": "func (*MemberLevelDeleteReq) Descriptor() ([]byte, []int) {\n\treturn file_api_front_admin_v1_ums_proto_rawDescGZIP(), []int{43}\n}", "title": "" }, { "docid": "bcd6bf853787f28065c1a2f9add717ad", "score": "0.65087754", "text": "func (*MessagesDelete) Descriptor() ([]byte, []int) {\n\treturn file_chat_messages_proto_rawDescGZIP(), []int{13}\n}", "title": "" }, { "docid": "84c9b4cebf64eb2d3c9a123f7a488c39", "score": "0.6507694", "text": "func (PostAnswerResponse_Status) EnumDescriptor() ([]byte, []int) {\r\n\treturn file_proto_answer_answer_proto_rawDescGZIP(), []int{14, 0}\r\n}", "title": "" }, { "docid": "016af8dd2145d6972731f19ea15f0fdc", "score": "0.6504345", "text": "func (*StatusResponse) Descriptor() ([]byte, []int) {\n\treturn file_github_com_containerd_containerd_third_party_k8s_io_cri_api_pkg_apis_runtime_v1alpha2_api_proto_rawDescGZIP(), []int{105}\n}", "title": "" }, { "docid": "8a8d414278f2e66fcac99d4c140a523f", "score": "0.6500409", "text": "func (*DelMemberResponse) Descriptor() ([]byte, []int) {\n\treturn file_cluster_proto_rawDescGZIP(), []int{15}\n}", "title": "" }, { "docid": "bd96168c9b81e7bb43a876fe96c03051", "score": "0.649717", "text": "func (*DeleteRequest) Descriptor() ([]byte, []int) {\n\treturn file_v2_object_grpc_service_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "4f48eaed2708e35ff473365807261880", "score": "0.64956295", "text": "func (*DeleteRatingResponse) Descriptor() ([]byte, []int) {\n\treturn file_project_proto_rawDescGZIP(), []int{19}\n}", "title": "" }, { "docid": "29af2b9029c3418ba0fd7d59e6facb66", "score": "0.64938205", "text": "func (*PostDeleteReq) Descriptor() ([]byte, []int) {\n\treturn file_api_sys_v1_sys_proto_rawDescGZIP(), []int{92}\n}", "title": "" }, { "docid": "f0763c3e0ebb9d8398af79be5c50e0aa", "score": "0.64923245", "text": "func (*RemoveReactionResponse) Descriptor() ([]byte, []int) {\n\treturn file_chat_v1_messages_proto_rawDescGZIP(), []int{34}\n}", "title": "" }, { "docid": "05ed657b15e9da0ef93731d0ea03de32", "score": "0.64918315", "text": "func (*DeleteTokenResponse) Descriptor() ([]byte, []int) {\n\treturn file_buf_alpha_registry_v1alpha1_token_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "672052fcf2f1065c0a82fd9f64f1f601", "score": "0.64820796", "text": "func (*GetMessageStatusRequest) Descriptor() ([]byte, []int) {\n\treturn file_fleetspeak_src_server_proto_fleetspeak_server_admin_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "2e9f906174ad9f7d9b1daf0e010b1ae9", "score": "0.6478577", "text": "func (*RemoveTeamMembersRsp) Descriptor() ([]byte, []int) {\n\treturn file_api_proto_team_RemoveTeamMembers_proto_rawDescGZIP(), []int{1}\n}", "title": "" }, { "docid": "ed4bb2065655c4bdfa48ec8ae8f99938", "score": "0.6477805", "text": "func (*DictTypeDeleteReq) Descriptor() ([]byte, []int) {\n\treturn file_api_sys_v1_sys_proto_rawDescGZIP(), []int{58}\n}", "title": "" }, { "docid": "6a93b94d973ec5af2c8ff687a673cbf2", "score": "0.6477219", "text": "func (*DictDeleteResp) Descriptor() ([]byte, []int) {\n\treturn file_sys_proto_rawDescGZIP(), []int{50}\n}", "title": "" }, { "docid": "3db4ed91b28c3187db8a1d555151effa", "score": "0.647621", "text": "func (*ClientDataDeleteResp) Descriptor() ([]byte, []int) {\n\treturn file_proto_ClientData_ClientData_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "e378c35dc399e9b1ac0a409da4958c9b", "score": "0.64730984", "text": "func (*ApiKeysRequests_Delete) Descriptor() ([]byte, []int) {\n\treturn file_apikeys_proto_rawDescGZIP(), []int{2, 3}\n}", "title": "" }, { "docid": "022902554c724c5b441a4e4d3171d32e", "score": "0.64727414", "text": "func (*DeleteResponse) Descriptor() ([]byte, []int) {\n\treturn file_eventhandler_v1_eventhandler_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "473ba7f36f71aeef828a5a167fbfd8c3", "score": "0.64715695", "text": "func (*RemoveRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_v1_squzy_monitoring_proto_rawDescGZIP(), []int{13}\n}", "title": "" }, { "docid": "4dfaf5d4f9d2201c1ea15abbf0399563", "score": "0.64600533", "text": "func (*DeletePolicyRequest) Descriptor() ([]byte, []int) {\n\treturn file_gincoinc_adamant_global_v1_adamantglobalv1_global_api_proto_rawDescGZIP(), []int{170}\n}", "title": "" }, { "docid": "605decf5c32f7c20a000165f4f9563a1", "score": "0.6457981", "text": "func (*DeleteMessageRequest) Descriptor() ([]byte, []int) {\n\treturn file_chat_v1_messages_proto_rawDescGZIP(), []int{17}\n}", "title": "" }, { "docid": "7a59c0a384d63d54ade3f768964fd2ac", "score": "0.6447706", "text": "func (*DeleteCommentRsp) Descriptor() ([]byte, []int) {\n\treturn file_comment_proto_rawDescGZIP(), []int{14}\n}", "title": "" }, { "docid": "738c4c13454ed8a221dc0c36f4e6d706", "score": "0.64461565", "text": "func (*RemoveReply) Descriptor() ([]byte, []int) {\n\treturn file_api_v1_pb_db_dbsvc_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "e4204209ed7a2b534ce888914bc01080", "score": "0.6440424", "text": "func (*TagContactRemoveResponse) Descriptor() ([]byte, []int) {\n\treturn file_puppet_tag_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "aecd51fd6fd7b1750bccc08ed86a41ee", "score": "0.6438261", "text": "func (*DeleteProjectResponse) Descriptor() ([]byte, []int) {\n\treturn file_project_proto_rawDescGZIP(), []int{7}\n}", "title": "" }, { "docid": "352ac3a06648a417c9f433ed6ea3bbe1", "score": "0.6434751", "text": "func (*DeleteCDCStreamResponsePB) Descriptor() ([]byte, []int) {\n\treturn file_yb_cdc_cdc_service_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "71719f561f8a2731956b4c00b33bd7d0", "score": "0.6434663", "text": "func (*ConfigDeleteResp) Descriptor() ([]byte, []int) {\n\treturn file_sys_proto_rawDescGZIP(), []int{82}\n}", "title": "" }, { "docid": "a47893974818cf9ead00f524dbfefdbc", "score": "0.64334756", "text": "func (*GetNozzleStatusResp) Descriptor() ([]byte, []int) {\n\treturn file_transferMessage_proto_rawDescGZIP(), []int{22}\n}", "title": "" }, { "docid": "020433c94c3ae93da4935f5065a9903f", "score": "0.64323616", "text": "func (*RemoveResponse) Descriptor() ([]byte, []int) {\n\treturn file_proto_rss_proto_rawDescGZIP(), []int{9}\n}", "title": "" }, { "docid": "831adce72d6507bb4e5cdc0336be3150", "score": "0.6431395", "text": "func (StatusReply_Status) EnumDescriptor() ([]byte, []int) {\n\treturn file_watermarksvc_proto_rawDescGZIP(), []int{4, 0}\n}", "title": "" }, { "docid": "3d8eff8e85a81948bde9517379c3d068", "score": "0.6430484", "text": "func (UpdateAnswerResponse_Status) EnumDescriptor() ([]byte, []int) {\r\n\treturn file_proto_answer_answer_proto_rawDescGZIP(), []int{9, 0}\r\n}", "title": "" }, { "docid": "48aed826c275c4e0131a589011bb7538", "score": "0.64249176", "text": "func (*DeleteChannelRequest) Descriptor() ([]byte, []int) {\n\treturn file_core_v1_core_proto_rawDescGZIP(), []int{39}\n}", "title": "" }, { "docid": "275dbbdbe89c94b9e109da28892bcf12", "score": "0.6423955", "text": "func (*SysLogDeleteResp) Descriptor() ([]byte, []int) {\n\treturn file_sys_proto_rawDescGZIP(), []int{73}\n}", "title": "" }, { "docid": "205e6252f08285701e3c04f6801db030", "score": "0.64206845", "text": "func (*DeleteTaskResponse) Descriptor() ([]byte, []int) {\n\treturn file_services_core_protobuf_tasks_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "1db0a7e75abbf3947a8511809833ed92", "score": "0.64164704", "text": "func (*Event_MessageDeleted) Descriptor() ([]byte, []int) {\n\treturn file_core_v1_core_proto_rawDescGZIP(), []int{45, 2}\n}", "title": "" }, { "docid": "5fd24ab2e2b4e4bab40df6127984fcf9", "score": "0.6415343", "text": "func (*DeleteRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_file_proto_rawDescGZIP(), []int{7}\n}", "title": "" }, { "docid": "327e34214088eb56011c153d9362894b", "score": "0.64134246", "text": "func (*DeleteOrderResponse) Descriptor() ([]byte, []int) {\n\treturn file_proto_order_order_proto_rawDescGZIP(), []int{6}\n}", "title": "" }, { "docid": "00159bd7c1f114e0c575df2beaf3256a", "score": "0.6412306", "text": "func (*Event_ChannelDeleted) Descriptor() ([]byte, []int) {\n\treturn file_core_v1_core_proto_rawDescGZIP(), []int{45, 5}\n}", "title": "" }, { "docid": "bc30fac2b4583b8a8a3984efef89ea64", "score": "0.64114416", "text": "func (*DeleteKeysResponse) Descriptor() ([]byte, []int) {\n\treturn file_proto_v1alpha1_ess_proto_rawDescGZIP(), []int{7}\n}", "title": "" }, { "docid": "fdf54631e8eecfcaf7e706d0b91caa94", "score": "0.6408135", "text": "func (FeedUpdate_Status) EnumDescriptor() ([]byte, []int) {\n\treturn file_api_admin_proto_rawDescGZIP(), []int{11, 0}\n}", "title": "" }, { "docid": "61671a4f6c85349a342f29524b75f61d", "score": "0.6405818", "text": "func (*DelRequest) Descriptor() ([]byte, []int) {\n\treturn file_command_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "19ef7cd2563d7613cf65e050194516ca", "score": "0.64057285", "text": "func (*DeptDeleteResp) Descriptor() ([]byte, []int) {\n\treturn file_sys_proto_rawDescGZIP(), []int{59}\n}", "title": "" }, { "docid": "280193373e67197c7be611623b75dc73", "score": "0.6403793", "text": "func (*DeleteWhitelistRequest) Descriptor() ([]byte, []int) {\n\treturn file_gincoinc_adamant_global_v1_adamantglobalv1_global_api_proto_rawDescGZIP(), []int{146}\n}", "title": "" }, { "docid": "9407b01a7ab4ae6b53b1e3407c64b0e6", "score": "0.63986427", "text": "func (ClientStateGetResponse_Status) EnumDescriptor() ([]byte, []int) {\n\treturn file_protobuf_client_state_pb2_client_state_proto_rawDescGZIP(), []int{3, 0}\n}", "title": "" }, { "docid": "cc8074b91eefc9c6ef1c0790f9f643ba", "score": "0.6398096", "text": "func (*DeleteInviteResponse) Descriptor() ([]byte, []int) {\n\treturn file_chat_v1_guilds_proto_rawDescGZIP(), []int{21}\n}", "title": "" }, { "docid": "91a3791baf485c5fff80d799dff386e2", "score": "0.639502", "text": "func (*DeleteTagResp) Descriptor() ([]byte, []int) {\n\treturn file_ManagerService_proto_rawDescGZIP(), []int{62}\n}", "title": "" } ]
522003c40bebb6617b47d4505ebd9745
GetAllAWSApiGatewayVpcLinkResources retrieves all AWSApiGatewayVpcLink items from an AWS CloudFormation template
[ { "docid": "8feae2aff20236037bcaadfbd44b4838", "score": "0.77041245", "text": "func (t *Template) GetAllAWSApiGatewayVpcLinkResources() map[string]AWSApiGatewayVpcLink {\n\tresults := map[string]AWSApiGatewayVpcLink{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSApiGatewayVpcLink:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::ApiGateway::VpcLink\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSApiGatewayVpcLink\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" } ]
[ { "docid": "02158b9f305d6d38be5f7f53f3f2f69f", "score": "0.5906967", "text": "func (dm *VPCService) GetVPCList() (vpcs []*types.Vpc, err error) {\n\tlog.Debug(\"GetVPCList\")\n\n\tdata, status, err := dm.concertoService.Get(\"/network/vpcs\")\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err = utils.CheckStandardStatus(status, data); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err = json.Unmarshal(data, &vpcs); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn vpcs, nil\n}", "title": "" }, { "docid": "8ef3cd0912cb1a6f44379a40bf2bc8d6", "score": "0.5757533", "text": "func GetVPCs() {\n\t// Create URL adding endpoint, path to the resource and query parameters\n\turl := VPC_api_endpoint + \"/vpcs\" + QueryParams\n\n\t// Create a new request given a method, URL, and optional body.\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Adding headers to the request\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\treq.Header.Add(\"Accept\", \"application/json\")\n\treq.Header.Add(\"Authorization\", Iam_token)\n\n\t// Requesting server\n\tres, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer res.Body.Close()\n\n\t// Reading response\n\tbody, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Printing response\n\tfmt.Println(\"Response Status -\", res.StatusCode)\n\tfmt.Println(\"Response Body -\", string(body))\n}", "title": "" }, { "docid": "4bf4e55d75b6f352f8d02a0b3b4219a1", "score": "0.57474875", "text": "func (t *Template) GetAllAWSEC2VPNGatewayResources() map[string]AWSEC2VPNGateway {\n\tresults := map[string]AWSEC2VPNGateway{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSEC2VPNGateway:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::EC2::VPNGateway\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSEC2VPNGateway\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "b59d74ec29ded4b2c4a411be7ab606af", "score": "0.5733784", "text": "func (t *Template) GetAllAWSEC2VPCPeeringConnectionResources() map[string]AWSEC2VPCPeeringConnection {\n\tresults := map[string]AWSEC2VPCPeeringConnection{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSEC2VPCPeeringConnection:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::EC2::VPCPeeringConnection\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSEC2VPCPeeringConnection\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "e6d62947325994e4a30f1025b86fbd57", "score": "0.5725527", "text": "func (c *Client) describeVpcs(ctx context.Context) ([]network.VirtualNetwork, error) {\n\tc.limiter.Limit(ctx, \"VirtualNetworks.List\")\n\n\tsinceStart := spanstat.Start()\n\tresult, err := c.virtualnetworks.ListAllComplete(ctx)\n\tc.metricsAPI.ObserveAPICall(\"virtualnetworks.ListAll\", deriveStatus(err), sinceStart.Seconds())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar vpcs []network.VirtualNetwork\n\tfor result.NotDone() {\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tvpcs = append(vpcs, result.Value())\n\t\terr = result.Next()\n\t}\n\n\treturn vpcs, nil\n}", "title": "" }, { "docid": "265b576261183f48fc5b048cc828936f", "score": "0.57186306", "text": "func (t *Template) GetAllAWSEC2VPCResources() map[string]AWSEC2VPC {\n\tresults := map[string]AWSEC2VPC{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSEC2VPC:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::EC2::VPC\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSEC2VPC\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "6ab18dd750784528b54ab8a29589ef86", "score": "0.56013423", "text": "func (r AWSApiGatewayVpcLink) MarshalJSON() ([]byte, error) {\n\ttype Properties AWSApiGatewayVpcLink\n\treturn json.Marshal(&struct {\n\t\tType string\n\t\tProperties Properties\n\t\tDependsOn []string `json:\"DependsOn,omitempty\"`\n\t\tMetadata map[string]interface{} `json:\"Metadata,omitempty\"`\n\t\tDeletionPolicy DeletionPolicy `json:\"DeletionPolicy,omitempty\"`\n\t}{\n\t\tType: r.AWSCloudFormationType(),\n\t\tProperties: (Properties)(r),\n\t\tDependsOn: r._dependsOn,\n\t\tMetadata: r._metadata,\n\t\tDeletionPolicy: r._deletionPolicy,\n\t})\n}", "title": "" }, { "docid": "4b0da53f4b301d9d3efdc45124486b8b", "score": "0.5465823", "text": "func List(client *golangsdk.ServiceClient, opts ListVPCOptsBuilder) (r ListResult) {\n\tlistURL := rootURL(client)\n\tif opts != nil {\n\t\tquery, err := opts.ToListVPCQuery()\n\t\tif err != nil {\n\t\t\tr.Err = err\n\t\t\treturn\n\t\t}\n\t\tlistURL += query\n\t}\n\n\t_, r.Err = client.Get(listURL, &r.Body, &golangsdk.RequestOpts{\n\t\tOkCodes: []int{http.StatusOK},\n\t})\n\treturn\n}", "title": "" }, { "docid": "fc3ebc1935e73623ce22e546e17aba77", "score": "0.53284323", "text": "func (c *EC2) ListVPCs() ([]VPC, error) {\n\tvar ec2vpcs []*ec2.Vpc\n\tresponse, err := c.client.DescribeVpcs(&ec2.DescribeVpcsInput{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"describe VPCs: %w\", err)\n\t}\n\tec2vpcs = append(ec2vpcs, response.Vpcs...)\n\n\tfor response.NextToken != nil {\n\t\tresponse, err = c.client.DescribeVpcs(&ec2.DescribeVpcsInput{\n\t\t\tNextToken: response.NextToken,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"describe VPCs: %w\", err)\n\t\t}\n\t\tec2vpcs = append(ec2vpcs, response.Vpcs...)\n\t}\n\tvar vpcs []VPC\n\tfor _, vpc := range ec2vpcs {\n\t\tvar name string\n\t\tfor _, tag := range vpc.Tags {\n\t\t\tif aws.StringValue(tag.Key) == \"Name\" {\n\t\t\t\tname = aws.StringValue(tag.Value)\n\t\t\t}\n\t\t}\n\t\tvpcs = append(vpcs, VPC{\n\t\t\tResource: Resource{\n\t\t\t\tID: aws.StringValue(vpc.VpcId),\n\t\t\t\tName: name,\n\t\t\t},\n\t\t})\n\t}\n\treturn vpcs, nil\n}", "title": "" }, { "docid": "d986dae4616d0afa82405dad66d63e98", "score": "0.52982014", "text": "func List(c *gophercloud.ServiceClient,vpcId string, opts ListOptsBuilder) pagination.Pager {\n\turl := listURL(c,vpcId)\n\tif opts != nil {\n\t\tquery, err := opts.ToSubnetListQuery()\n\t\tif err != nil {\n\t\t\treturn pagination.Pager{Err: err}\n\t\t}\n\t\turl += query\n\t}\n\treturn pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page {\n\t\treturn SubnetPage{pagination.LinkedPageBase{PageResult: r}}\n\t})\n}", "title": "" }, { "docid": "3ae890b3b3b7fc168733d0dcacc4253b", "score": "0.5244943", "text": "func (t *Template) GetAllAWSEC2VPCEndpointResources() map[string]AWSEC2VPCEndpoint {\n\tresults := map[string]AWSEC2VPCEndpoint{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSEC2VPCEndpoint:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::EC2::VPCEndpoint\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSEC2VPCEndpoint\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "ef9d00d2cb07a17a2ffe16b75c8a26cb", "score": "0.5228469", "text": "func (t *Template) GetAllAWSEC2VPCCidrBlockResources() map[string]AWSEC2VPCCidrBlock {\n\tresults := map[string]AWSEC2VPCCidrBlock{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSEC2VPCCidrBlock:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::EC2::VPCCidrBlock\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSEC2VPCCidrBlock\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "0ed4e310dea525208fe2545c54099e23", "score": "0.51464593", "text": "func (t *Template) GetAllAWSEC2VPNConnectionResources() map[string]AWSEC2VPNConnection {\n\tresults := map[string]AWSEC2VPNConnection{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSEC2VPNConnection:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::EC2::VPNConnection\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSEC2VPNConnection\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "c57bfd472c2e0538ca70b2d024041795", "score": "0.51156795", "text": "func (t *Template) GetAllAWSApiGatewayResourceResources() map[string]AWSApiGatewayResource {\n\tresults := map[string]AWSApiGatewayResource{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSApiGatewayResource:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::ApiGateway::Resource\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSApiGatewayResource\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "4ca67c05d70f090d8d7b385602f7fa24", "score": "0.50647104", "text": "func (t *Template) GetAllAWSEC2VPNConnectionRouteResources() map[string]AWSEC2VPNConnectionRoute {\n\tresults := map[string]AWSEC2VPNConnectionRoute{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSEC2VPNConnectionRoute:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::EC2::VPNConnectionRoute\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSEC2VPNConnectionRoute\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "d2faaea0fd1c3801b7c64ae667f1fc23", "score": "0.50365764", "text": "func GetVPCData() []*types.Vpc {\n\treturn []*types.Vpc{\n\t\t{\n\t\t\tID: \"fakeId0\",\n\t\t\tName: \"fakeName0\",\n\t\t\tCIDR: \"fakeCIDR0\",\n\t\t\tState: \"fakeState0\",\n\t\t\tCloudAccountID: \"fakeCloudAccountID0\",\n\t\t\tRealmProviderName: \"fakeRealmProviderName0\",\n\t\t\tHasVPN: false,\n\t\t\tAllowedSubnetTypes: []string{\"fakeSubNet00\", \"fakeSubNet01\"},\n\t\t\tBrownfield: false,\n\t\t},\n\t\t{\n\t\t\tID: \"fakeId1\",\n\t\t\tName: \"fakeName1\",\n\t\t\tCIDR: \"fakeCIDR1\",\n\t\t\tState: \"fakeState1\",\n\t\t\tCloudAccountID: \"fakeCloudAccountID1\",\n\t\t\tRealmProviderName: \"fakeRealmProviderName1\",\n\t\t\tHasVPN: false,\n\t\t\tAllowedSubnetTypes: []string{\"fakeSubNet10\", \"fakeSubNet11\"},\n\t\t\tBrownfield: false,\n\t\t},\n\t}\n}", "title": "" }, { "docid": "f30995dc58be807840771c1430b9718f", "score": "0.49632117", "text": "func (o LookupEndpointAuthorizationResultOutput) AllowedAllVpcs() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v LookupEndpointAuthorizationResult) *bool { return v.AllowedAllVpcs }).(pulumi.BoolPtrOutput)\n}", "title": "" }, { "docid": "82b2b8cdd07e59d2bd8c566dab7d326b", "score": "0.49322945", "text": "func ListVPCPrivateGateways(clientMap map[string]*cosmic.CosmicClient) (PrivateGateways, error) {\n\tpgws := []*PrivateGateway{}\n\twg := sync.WaitGroup{}\n\twg.Add(len(clientMap))\n\n\terrChannel := make(chan error, 1)\n\tfinished := make(chan bool, 1)\n\n\tVPCs, err := ListVPCs(clientMap)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor client := range clientMap {\n\t\tgo func(client string) {\n\t\t\tdefer wg.Done()\n\n\t\t\tparams := clientMap[client].VPC.NewListPrivateGatewaysParams()\n\t\t\tresp, err := clientMap[client].VPC.ListPrivateGateways(params)\n\t\t\tif err != nil {\n\t\t\t\tif strings.Contains(err.Error(), fmt.Sprintf(\"entity does not exist\")) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\terrChannel <- profileError{fmt.Sprintf(\"Error returned using profile \\\"%s\\\": %s\", client, err)}\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tfor _, pgw := range resp.PrivateGateways {\n\t\t\t\tv, _ := VPCs.FindByID(pgw.Vpcid)\n\t\t\t\tpgws = append(pgws, &PrivateGateway{\n\t\t\t\t\tPrivateGateway: pgw,\n\t\t\t\t\tVpccidr: v[0].Cidr,\n\t\t\t\t\tVpcname: v[0].Name,\n\t\t\t\t})\n\t\t\t}\n\t\t}(client)\n\t}\n\n\tgo func() {\n\t\twg.Wait()\n\t\tclose(finished)\n\t}()\n\n\tselect {\n\tcase <-finished:\n\tcase err := <-errChannel:\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn pgws, nil\n}", "title": "" }, { "docid": "26594675b67145de5b37eac9cf490244", "score": "0.4900328", "text": "func (t *Template) GetAllAWSGlueConnectionResources() map[string]AWSGlueConnection {\n\tresults := map[string]AWSGlueConnection{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSGlueConnection:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::Glue::Connection\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSGlueConnection\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "4e2468bc50fcebbb55ad1b78a2cca552", "score": "0.48300058", "text": "func ListVpcs(vpcService *vpcv1.VpcV1) (vpcs *vpcv1.VPCCollection, response *core.DetailedResponse, err error) {\n\tlistVpcsOptions := &vpcv1.ListVpcsOptions{}\n\tvpcs, response, err = vpcService.ListVpcs(listVpcsOptions)\n\treturn\n}", "title": "" }, { "docid": "f0a527d4712cc91301f9f1f70d56e511", "score": "0.4823421", "text": "func GetVPCs(accessKeyID, secretAccessKey, region string, vpcID *string) (response *ec2.DescribeVpcsOutput, err error) {\n\tclient, err := NewEC2(accessKeyID, secretAccessKey, region)\n\n\tresponse, err = client.DescribeVpcs(&ec2.DescribeVpcsInput{})\n\n\tif err != nil {\n\t\tlog.Warningf(\"EC2 VPC details retrieval failed for region: %s; %s\", region, err.Error())\n\t\treturn nil, err\n\t}\n\n\treturn response, err\n}", "title": "" }, { "docid": "378a063d708e748f69664f4fe8b21d59", "score": "0.48197302", "text": "func getAllRemoteResources(destination string, opencontrol common.OpenControl, getter Getter) error {\n\t// Get Certifications\n\tlog.Println(\"Retrieving dependent certifications\")\n\terr := getter.GetRemoteResources(destination, constants.DefaultCertificationsFolder,\n\t\topencontrol.GetCertificationsDependencies())\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Get Standards\n\tlog.Println(\"Retrieving dependent standards\")\n\terr = getter.GetRemoteResources(destination, constants.DefaultStandardsFolder,\n\t\topencontrol.GetStandardsDependencies())\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Get Components\n\tlog.Println(\"Retrieving dependent components\")\n\terr = getter.GetRemoteResources(destination, constants.DefaultComponentsFolder,\n\t\topencontrol.GetComponentsDependencies())\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "9702b235f00ae11c91b40287a619af14", "score": "0.479576", "text": "func (VPCs) cleanup(options *CleanupOptions) error {\n\tresourceLogger := logrus.WithFields(logrus.Fields{\"resource\": options.Resource.Name})\n\tresourceLogger.Info(\"Cleaning up the VPCs\")\n\tclient, err := NewVPCClient(options)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"couldn't create VPC client\")\n\t}\n\n\tvpcList, _, err := client.ListVpcs(&vpcv1.ListVpcsOptions{\n\t\tResourceGroupID: &client.ResourceGroupID,\n\t})\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to list the VPCs\")\n\t}\n\n\tfor _, vpc := range vpcList.Vpcs {\n\t\t_, err = client.DeleteVPC(&vpcv1.DeleteVPCOptions{\n\t\t\tID: vpc.ID,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"failed to delete the VPC %q\", *vpc.Name)\n\t\t}\n\t}\n\tresourceLogger.Info(\"Successfully deleted the VPCs\")\n\treturn nil\n}", "title": "" }, { "docid": "5c452206e9c7bc8e10d0645480f1c270", "score": "0.47594923", "text": "func (o LookupEndpointAuthorizationResultOutput) AllowedVpcs() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v LookupEndpointAuthorizationResult) []string { return v.AllowedVpcs }).(pulumi.StringArrayOutput)\n}", "title": "" }, { "docid": "27bcfc40c119fb4d233efab92d438bce", "score": "0.4743808", "text": "func (t *Template) GetAllAWSApiGatewayBasePathMappingResources() map[string]AWSApiGatewayBasePathMapping {\n\tresults := map[string]AWSApiGatewayBasePathMapping{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSApiGatewayBasePathMapping:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::ApiGateway::BasePathMapping\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSApiGatewayBasePathMapping\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "70c98e9cfa78cc3b185b0783f3d6c0d0", "score": "0.4722077", "text": "func (t *Template) GetAWSApiGatewayVpcLinkWithName(name string) (AWSApiGatewayVpcLink, error) {\n\tif untyped, ok := t.Resources[name]; ok {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSApiGatewayVpcLink:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\treturn resource, nil\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::ApiGateway::VpcLink\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSApiGatewayVpcLink\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\treturn result, nil\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn AWSApiGatewayVpcLink{}, errors.New(\"resource not found\")\n}", "title": "" }, { "docid": "a15eb6f5eb03e4898ec8e96989632181", "score": "0.47207037", "text": "func (t *Template) GetAllAWSEC2VPCGatewayAttachmentResources() map[string]AWSEC2VPCGatewayAttachment {\n\tresults := map[string]AWSEC2VPCGatewayAttachment{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSEC2VPCGatewayAttachment:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::EC2::VPCGatewayAttachment\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSEC2VPCGatewayAttachment\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "cba3e5a27ae464dcca71b92c66606360", "score": "0.47028443", "text": "func (client ResourceGuardsClient) GetBackupSecurityPINRequestsObjects(ctx context.Context, resourceGroupName string, resourceGuardsName string) (result DppBaseResourceListPage, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/ResourceGuardsClient.GetBackupSecurityPINRequestsObjects\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.dbrl.Response.Response != nil {\n\t\t\t\tsc = result.dbrl.Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tresult.fn = client.getBackupSecurityPINRequestsObjectsNextResults\n\treq, err := client.GetBackupSecurityPINRequestsObjectsPreparer(ctx, resourceGroupName, resourceGuardsName)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"dataprotection.ResourceGuardsClient\", \"GetBackupSecurityPINRequestsObjects\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresp, err := client.GetBackupSecurityPINRequestsObjectsSender(req)\n\tif err != nil {\n\t\tresult.dbrl.Response = autorest.Response{Response: resp}\n\t\terr = autorest.NewErrorWithError(err, \"dataprotection.ResourceGuardsClient\", \"GetBackupSecurityPINRequestsObjects\", resp, \"Failure sending request\")\n\t\treturn\n\t}\n\n\tresult.dbrl, err = client.GetBackupSecurityPINRequestsObjectsResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"dataprotection.ResourceGuardsClient\", \"GetBackupSecurityPINRequestsObjects\", resp, \"Failure responding to request\")\n\t\treturn\n\t}\n\tif result.dbrl.hasNextLink() && result.dbrl.IsEmpty() {\n\t\terr = result.NextWithContext(ctx)\n\t\treturn\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "93cd9ebf03c465270369e3b0416bbf56", "score": "0.46896386", "text": "func (t *Template) GetAllAWSEC2VPCEndpointServicePermissionsResources() map[string]AWSEC2VPCEndpointServicePermissions {\n\tresults := map[string]AWSEC2VPCEndpointServicePermissions{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSEC2VPCEndpointServicePermissions:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::EC2::VPCEndpointServicePermissions\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSEC2VPCEndpointServicePermissions\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "35f207b5e2fa36713d7f9605b8a03415", "score": "0.4689334", "text": "func (r *AWSApiGatewayVpcLink) AWSCloudFormationType() string {\n\treturn \"AWS::ApiGateway::VpcLink\"\n}", "title": "" }, { "docid": "5bf6e57d434ca3e2d2d2594723db6626", "score": "0.46759656", "text": "func List(client *golangsdk.ServiceClient, stackName string, opts ListOpts) ([]Resource, error) {\n\tu := listURL(client, stackName)\n\tpages, err := pagination.NewPager(client, u, func(r pagination.PageResult) pagination.Page {\n\t\treturn ResourcePage{pagination.LinkedPageBase{PageResult: r}}\n\t}).AllPages()\n\n\tallResources, err := ExtractResources(pages)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn FilterResources(allResources, opts)\n}", "title": "" }, { "docid": "6e59f2006d7f36136ae42288281a0b42", "score": "0.46626437", "text": "func ListKeys(vpcService *vpcv1.VpcV1) (keys *vpcv1.KeyCollection, response *core.DetailedResponse, err error) {\n\tlistKeysOptions := &vpcv1.ListKeysOptions{}\n\tkeys, response, err = vpcService.ListKeys(listKeysOptions)\n\treturn\n}", "title": "" }, { "docid": "20dbb2e137c7895cd943d197e6182b90", "score": "0.463623", "text": "func (t *Template) GetAllAWSEC2VPCEndpointConnectionNotificationResources() map[string]AWSEC2VPCEndpointConnectionNotification {\n\tresults := map[string]AWSEC2VPCEndpointConnectionNotification{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSEC2VPCEndpointConnectionNotification:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::EC2::VPCEndpointConnectionNotification\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSEC2VPCEndpointConnectionNotification\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "214a73889ceb27eb0d8f653fb35f4080", "score": "0.46239477", "text": "func GetAllVpcPeers(svc *ec2.Client) []VpcPeering {\n\tvar result []VpcPeering\n\tresp, err := svc.DescribeVpcPeeringConnections(context.TODO(), &ec2.DescribeVpcPeeringConnectionsInput{})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfor _, connection := range resp.VpcPeeringConnections {\n\t\tpeering := VpcPeering{\n\t\t\tRequesterVpc: VPCHolder{ID: *connection.RequesterVpcInfo.VpcId,\n\t\t\t\tAccountID: *connection.RequesterVpcInfo.OwnerId},\n\t\t\tAccepterVpc: VPCHolder{ID: *connection.AccepterVpcInfo.VpcId,\n\t\t\t\tAccountID: *connection.AccepterVpcInfo.OwnerId},\n\t\t\tPeeringID: *connection.VpcPeeringConnectionId,\n\t\t}\n\t\tresult = append(result, peering)\n\t}\n\treturn result\n}", "title": "" }, { "docid": "eaa9a0a0b2ccddd2f25cd562200c0a83", "score": "0.46140558", "text": "func (h *AzurePrivatelinkHandler) ConnectionsList(ctx context.Context, project, serviceName string) (*AzurePrivatelinkConnectionsResponse, error) {\n\tpath := buildPath(\"project\", project, \"service\", serviceName, \"privatelink\", \"azure\", \"connections\")\n\tbts, err := h.client.doGetRequest(ctx, path, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar rsp AzurePrivatelinkConnectionsResponse\n\tif err := checkAPIResponse(bts, &rsp); err != nil {\n\t\treturn nil, err\n\t}\n\treturn &rsp, nil\n}", "title": "" }, { "docid": "352ac67513ae0efa6e7e446d20836ca0", "score": "0.4612621", "text": "func (r AWSEC2VPC) MarshalJSON() ([]byte, error) {\n\ttype Properties AWSEC2VPC\n\treturn json.Marshal(&struct {\n\t\tType string\n\t\tProperties Properties\n\t\tDependsOn []string `json:\"DependsOn,omitempty\"`\n\t\tMetadata map[string]interface{} `json:\"Metadata,omitempty\"`\n\t\tDeletionPolicy DeletionPolicy `json:\"DeletionPolicy,omitempty\"`\n\t}{\n\t\tType: r.AWSCloudFormationType(),\n\t\tProperties: (Properties)(r),\n\t\tDependsOn: r._dependsOn,\n\t\tMetadata: r._metadata,\n\t\tDeletionPolicy: r._deletionPolicy,\n\t})\n}", "title": "" }, { "docid": "c9fb52611dc1d6597a31466ec8d7a9c9", "score": "0.46091548", "text": "func (t *Template) GetAllAWSEC2VPNGatewayRoutePropagationResources() map[string]AWSEC2VPNGatewayRoutePropagation {\n\tresults := map[string]AWSEC2VPNGatewayRoutePropagation{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSEC2VPNGatewayRoutePropagation:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::EC2::VPNGatewayRoutePropagation\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSEC2VPNGatewayRoutePropagation\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "212943b7a6f29386c594dd001f78022a", "score": "0.46049762", "text": "func (t *Template) GetAllAWSEC2NatGatewayResources() map[string]AWSEC2NatGateway {\n\tresults := map[string]AWSEC2NatGateway{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSEC2NatGateway:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::EC2::NatGateway\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSEC2NatGateway\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "e5603e43263675dba07af2d769736ea7", "score": "0.4598957", "text": "func GetAllVPCRouteTables(svc *ec2.Client) []VPCRouteTable {\n\tvar result []VPCRouteTable\n\tresp, err := svc.DescribeRouteTables(context.TODO(), &ec2.DescribeRouteTablesInput{})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfor _, routetable := range resp.RouteTables {\n\t\tvar subnets []string\n\t\tfor _, assocs := range routetable.Associations {\n\t\t\tif assocs.SubnetId != nil {\n\t\t\t\tsubnets = append(subnets, *assocs.SubnetId)\n\t\t\t}\n\t\t}\n\t\ttable := VPCRouteTable{\n\t\t\tVpc: VPCHolder{ID: *routetable.VpcId,\n\t\t\t\tAccountID: *routetable.OwnerId},\n\t\t\tID: *routetable.RouteTableId,\n\t\t\tRoutes: parseVPCRoutes(routetable.Routes),\n\t\t\tSubnets: subnets,\n\t\t}\n\t\tresult = append(result, table)\n\t}\n\treturn result\n}", "title": "" }, { "docid": "3ea27be9b4cf1c7a77ab5a6a7ac5fd32", "score": "0.45771104", "text": "func (o LookupServiceNetworkResultOutput) NumberOfAssociatedVpcs() pulumi.IntOutput {\n\treturn o.ApplyT(func(v LookupServiceNetworkResult) int { return v.NumberOfAssociatedVpcs }).(pulumi.IntOutput)\n}", "title": "" }, { "docid": "09f45534b7256ab0b8c53b30078c777c", "score": "0.45727104", "text": "func (r *AWSApiGatewayVpcLink) UnmarshalJSON(b []byte) error {\n\ttype Properties AWSApiGatewayVpcLink\n\tres := &struct {\n\t\tType string\n\t\tProperties *Properties\n\t\tDependsOn []string\n\t\tMetadata map[string]interface{}\n\t}{}\n\tif err := json.Unmarshal(b, &res); err != nil {\n\t\tfmt.Printf(\"ERROR: %s\\n\", err)\n\t\treturn err\n\t}\n\n\t// If the resource has no Properties set, it could be nil\n\tif res.Properties != nil {\n\t\t*r = AWSApiGatewayVpcLink(*res.Properties)\n\t}\n\tif res.DependsOn != nil {\n\t\tr._dependsOn = res.DependsOn\n\t}\n\tif res.Metadata != nil {\n\t\tr._metadata = res.Metadata\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "05b3a3ff4f8017a7999174daba6411fc", "score": "0.4553881", "text": "func (t *Template) GetAllAWSApiGatewayAccountResources() map[string]AWSApiGatewayAccount {\n\tresults := map[string]AWSApiGatewayAccount{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSApiGatewayAccount:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::ApiGateway::Account\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSApiGatewayAccount\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "0fbfe761962373e15ef8c1f5ffef0083", "score": "0.4553841", "text": "func (t *Template) GetAllAWSApiGatewayGatewayResponseResources() map[string]AWSApiGatewayGatewayResponse {\n\tresults := map[string]AWSApiGatewayGatewayResponse{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSApiGatewayGatewayResponse:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::ApiGateway::GatewayResponse\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSApiGatewayGatewayResponse\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "8fd0bfceff2e0f0c6bd0a16a2873284f", "score": "0.45272645", "text": "func (c *Client) ListVpcIngressConnections(ctx context.Context, params *ListVpcIngressConnectionsInput, optFns ...func(*Options)) (*ListVpcIngressConnectionsOutput, error) {\n\tif params == nil {\n\t\tparams = &ListVpcIngressConnectionsInput{}\n\t}\n\n\tresult, metadata, err := c.invokeOperation(ctx, \"ListVpcIngressConnections\", params, optFns, c.addOperationListVpcIngressConnectionsMiddlewares)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tout := result.(*ListVpcIngressConnectionsOutput)\n\tout.ResultMetadata = metadata\n\treturn out, nil\n}", "title": "" }, { "docid": "33a8defcb78fd8625ceb763ca84d1eb2", "score": "0.45221835", "text": "func (client *Client) ListTagResourcesWithOptions(request *ListTagResourcesRequest, runtime *util.RuntimeOptions) (_result *ListTagResourcesResponse, _err error) {\n\t_err = util.ValidateModel(request)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\tquery := map[string]interface{}{}\n\tif !tea.BoolValue(util.IsUnset(request.ClientToken)) {\n\t\tquery[\"ClientToken\"] = request.ClientToken\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.NextToken)) {\n\t\tquery[\"NextToken\"] = request.NextToken\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.RegionId)) {\n\t\tquery[\"RegionId\"] = request.RegionId\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.ResourceId)) {\n\t\tquery[\"ResourceId\"] = request.ResourceId\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.ResourceType)) {\n\t\tquery[\"ResourceType\"] = request.ResourceType\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.Tag)) {\n\t\tquery[\"Tag\"] = request.Tag\n\t}\n\n\treq := &openapi.OpenApiRequest{\n\t\tQuery: openapiutil.Query(query),\n\t}\n\tparams := &openapi.Params{\n\t\tAction: tea.String(\"ListTagResources\"),\n\t\tVersion: tea.String(\"2021-07-30\"),\n\t\tProtocol: tea.String(\"HTTPS\"),\n\t\tPathname: tea.String(\"/\"),\n\t\tMethod: tea.String(\"POST\"),\n\t\tAuthType: tea.String(\"AK\"),\n\t\tStyle: tea.String(\"RPC\"),\n\t\tReqBodyType: tea.String(\"formData\"),\n\t\tBodyType: tea.String(\"json\"),\n\t}\n\t_result = &ListTagResourcesResponse{}\n\t_body, _err := client.CallApi(params, req, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_err = tea.Convert(_body, &_result)\n\treturn _result, _err\n}", "title": "" }, { "docid": "446e79c34c623fb31909894d9404eb80", "score": "0.45214203", "text": "func (t *Template) GetAllAWSEC2RouteTableResources() map[string]AWSEC2RouteTable {\n\tresults := map[string]AWSEC2RouteTable{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSEC2RouteTable:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::EC2::RouteTable\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSEC2RouteTable\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "c4708cb2e6bd3716c23070ae3b09c9aa", "score": "0.45190307", "text": "func (r AWSEC2VPCPeeringConnection) MarshalJSON() ([]byte, error) {\n\ttype Properties AWSEC2VPCPeeringConnection\n\treturn json.Marshal(&struct {\n\t\tType string\n\t\tProperties Properties\n\t\tDependsOn []string `json:\"DependsOn,omitempty\"`\n\t\tMetadata map[string]interface{} `json:\"Metadata,omitempty\"`\n\t\tDeletionPolicy DeletionPolicy `json:\"DeletionPolicy,omitempty\"`\n\t}{\n\t\tType: r.AWSCloudFormationType(),\n\t\tProperties: (Properties)(r),\n\t\tDependsOn: r._dependsOn,\n\t\tMetadata: r._metadata,\n\t\tDeletionPolicy: r._deletionPolicy,\n\t})\n}", "title": "" }, { "docid": "42b98b3da000cfa86b00bc05fec7067b", "score": "0.44992366", "text": "func ExampleVirtualNetworkGatewaysClient_NewListConnectionsPager() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclient, err := armnetwork.NewVirtualNetworkGatewaysClient(\"subid\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tpager := client.NewListConnectionsPager(\"testrg\",\n\t\t\"test-vpn-gateway-1\",\n\t\tnil)\n\tfor pager.More() {\n\t\tnextResult, err := pager.NextPage(ctx)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"failed to advance page: %v\", err)\n\t\t}\n\t\tfor _, v := range nextResult.Value {\n\t\t\t// TODO: use page item\n\t\t\t_ = v\n\t\t}\n\t}\n}", "title": "" }, { "docid": "286e291e0eeee923e79d6881486fe6e2", "score": "0.44932237", "text": "func (g *resourceGetter) listAll() ([]*resources.Resource, error) {\n\tfns := []func(ctx context.Context) ([]*resources.Resource, error){\n\t\tg.listResourceGroups,\n\t\tg.listVirtualNetworksAndSubnets,\n\t\tg.listNetworkSecurityGroups,\n\t\tg.listApplicationSecurityGroups,\n\t\tg.listRouteTables,\n\t\tg.listVMScaleSetsAndRoleAssignments,\n\t\tg.listDisks,\n\t\tg.listLoadBalancers,\n\t\tg.listPublicIPAddresses,\n\t\tg.listNatGateways,\n\t}\n\n\tvar resources []*resources.Resource\n\tctx := context.TODO()\n\tfor _, fn := range fns {\n\t\trs, err := fn(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresources = append(resources, rs...)\n\t}\n\treturn resources, nil\n}", "title": "" }, { "docid": "612ed1f82e8a13d85c54f658096c2420", "score": "0.44918686", "text": "func (v PaymentsResource) List(c buffalo.Context) error {\n\t// Get the DB connection from the context\n\ttx, ok := c.Value(\"tx\").(*pop.Connection)\n\tif !ok {\n\t\treturn fmt.Errorf(\"no transaction found\")\n\t}\n\n\tpayments := &models.Payments{}\n\n\t// Paginate results. Params \"page\" and \"per_page\" control pagination.\n\t// Default values are \"page=1\" and \"per_page=20\".\n\tq := tx.PaginateFromParams(c.Params())\n\n\t// Retrieve all Payments from the DB\n\tif err := q.All(payments); err != nil {\n\t\treturn err\n\t}\n\n\treturn c.Render(200, r.JSON(payments))\n}", "title": "" }, { "docid": "c79cc6620913aecf6549ec740a31a25d", "score": "0.44890556", "text": "func ExtractVpcs(r pagination.Page) ([]Vpc, error) {\n\tvar s struct {\n\t\tVpcs []Vpc `json:\"vpcs\"`\n\t}\n\terr := (r.(VpcPage)).ExtractInto(&s)\n\treturn s.Vpcs, err\n}", "title": "" }, { "docid": "7e68a9f23f2e02f143ed6452b4f2e819", "score": "0.4475505", "text": "func (t *Template) GetAllAWSApiGatewayClientCertificateResources() map[string]AWSApiGatewayClientCertificate {\n\tresults := map[string]AWSApiGatewayClientCertificate{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSApiGatewayClientCertificate:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::ApiGateway::ClientCertificate\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSApiGatewayClientCertificate\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "1a56022138da5f184fc3924c36466d78", "score": "0.44715482", "text": "func (t *Template) GetAllAWSApiGatewayRestApiResources() map[string]AWSApiGatewayRestApi {\n\tresults := map[string]AWSApiGatewayRestApi{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSApiGatewayRestApi:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::ApiGateway::RestApi\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSApiGatewayRestApi\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "2b944704edf6729709edf31b409f2099", "score": "0.44626537", "text": "func (t *Template) GetAllAWSRDSDBParameterGroupResources() map[string]AWSRDSDBParameterGroup {\n\tresults := map[string]AWSRDSDBParameterGroup{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSRDSDBParameterGroup:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::RDS::DBParameterGroup\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSRDSDBParameterGroup\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "358f65eaf1d609f76735ddc645c2e436", "score": "0.44585362", "text": "func (client *Client) ListTagResourcesWithOptions(request *ListTagResourcesRequest, runtime *util.RuntimeOptions) (_result *ListTagResourcesResponse, _err error) {\n\t_err = util.ValidateModel(request)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\tquery := map[string]interface{}{}\n\tif !tea.BoolValue(util.IsUnset(request.MaxResults)) {\n\t\tquery[\"MaxResults\"] = request.MaxResults\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.NextToken)) {\n\t\tquery[\"NextToken\"] = request.NextToken\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.RegionId)) {\n\t\tquery[\"RegionId\"] = request.RegionId\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.ResourceId)) {\n\t\tquery[\"ResourceId\"] = request.ResourceId\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.ResourceType)) {\n\t\tquery[\"ResourceType\"] = request.ResourceType\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.Tag)) {\n\t\tquery[\"Tag\"] = request.Tag\n\t}\n\n\treq := &openapi.OpenApiRequest{\n\t\tQuery: openapiutil.Query(query),\n\t}\n\tparams := &openapi.Params{\n\t\tAction: tea.String(\"ListTagResources\"),\n\t\tVersion: tea.String(\"2020-09-30\"),\n\t\tProtocol: tea.String(\"HTTPS\"),\n\t\tPathname: tea.String(\"/\"),\n\t\tMethod: tea.String(\"POST\"),\n\t\tAuthType: tea.String(\"AK\"),\n\t\tStyle: tea.String(\"RPC\"),\n\t\tReqBodyType: tea.String(\"formData\"),\n\t\tBodyType: tea.String(\"json\"),\n\t}\n\t_result = &ListTagResourcesResponse{}\n\t_body, _err := client.CallApi(params, req, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_err = tea.Convert(_body, &_result)\n\treturn _result, _err\n}", "title": "" }, { "docid": "553173f795abd93fe6e6ac10e4b3e801", "score": "0.44488204", "text": "func (t *Template) GetAllAWSApiGatewayModelResources() map[string]AWSApiGatewayModel {\n\tresults := map[string]AWSApiGatewayModel{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSApiGatewayModel:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::ApiGateway::Model\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSApiGatewayModel\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "32b52eb726ca243877bd655aad7b7b11", "score": "0.44423798", "text": "func (s *ConnectorServer) ListVpcaccessConnector(ctx context.Context, request *vpcaccesspb.ListVpcaccessConnectorRequest) (*vpcaccesspb.ListVpcaccessConnectorResponse, error) {\n\tcl, err := createConfigConnector(ctx, request.GetServiceAccountFile())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresources, err := cl.ListConnector(ctx, request.GetProject(), request.GetLocation())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar protos []*vpcaccesspb.VpcaccessConnector\n\tfor _, r := range resources.Items {\n\t\trp := ConnectorToProto(r)\n\t\tprotos = append(protos, rp)\n\t}\n\tp := &vpcaccesspb.ListVpcaccessConnectorResponse{}\n\tp.SetItems(protos)\n\treturn p, nil\n}", "title": "" }, { "docid": "6f30a231b5476f9c644afd0b644416ea", "score": "0.44413242", "text": "func (r *Zone) Vpcs() pulumi.ArrayOutput {\n\treturn (pulumi.ArrayOutput)(r.s.State[\"vpcs\"])\n}", "title": "" }, { "docid": "d312929763d152a77b414ccd1b46ed0c", "score": "0.44338667", "text": "func (p *AwsEc2Provider) GetResources() (resourcesList resources.ResourceList, err error) {\n\tec2Svc := ec2.New(p.AwsSession)\n\tresp, err := ec2Svc.DescribeInstances(nil)\n\tif err != nil {\n\t\tif strings.Contains(err.Error(), \"UnauthorizedOperation: You are not authorized to perform this operation.\") {\n\t\t\tcolor.PrintYellow(fmt.Sprintf(\"Skipping profile: %s, region: %s due to unsufficient privileges\\n\", p.AwsProfileName, p.AwsRegion))\n\t\t} else if strings.Contains(err.Error(), \"is not authorized to perform: sts:AssumeRole\") {\n\t\t\tcolor.PrintYellow(fmt.Sprintf(\"Skipping profile: %s, region: %s due to non-assumable role\\n\", p.AwsProfileName, p.AwsRegion))\n\t\t}\n\t\tcolor.PrintRed(fmt.Sprintf(\"Error while refreshing cache for profile: %s, region: %s):\\n\", p.AwsProfileName, p.AwsRegion))\n\t\tfmt.Printf(\"%s\\n\", err.Error())\n\t} else {\n\t\tfor _, res := range resp.Reservations {\n\t\t\tfor _, inst := range res.Instances {\n\t\t\t\tr := resources.NewEc2Instance()\n\t\t\t\tr.NativeObject = *inst\n\t\t\t\tr.ProfileName = p.AwsProfileName\n\t\t\t\tresourcesList = append(resourcesList, r)\n\t\t\t}\n\t\t}\n\t}\n\treturn resourcesList, err\n}", "title": "" }, { "docid": "beb99ffd0940ccc136fbd8d2d9839fbf", "score": "0.4431164", "text": "func (t *Template) GetAllAWSLambdaVersionResources() map[string]AWSLambdaVersion {\n\tresults := map[string]AWSLambdaVersion{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSLambdaVersion:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::Lambda::Version\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSLambdaVersion\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "e382c115428f15fd5dc838e2cfd22035", "score": "0.4426219", "text": "func (t *Template) GetAllAWSAppSyncGraphQLApiResources() map[string]AWSAppSyncGraphQLApi {\n\tresults := map[string]AWSAppSyncGraphQLApi{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSAppSyncGraphQLApi:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::AppSync::GraphQLApi\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSAppSyncGraphQLApi\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "a3c8c96e3e207f8532db992b1da6bfd9", "score": "0.441766", "text": "func StubDescribeVPCs() (*ec2.DescribeVpcsOutput, error) {\n\treturn &ec2.DescribeVpcsOutput{\n\t\tVpcs: []*ec2.Vpc{\n\t\t\t{\n\t\t\t\tVpcId: aws.String(\"vpc-32677e0e794418639\"),\n\t\t\t},\n\t\t},\n\t}, nil\n}", "title": "" }, { "docid": "503d094f871131bd51fb22ddf1fd0504", "score": "0.4414001", "text": "func (c *HighLevelClient) GetAllResourcesOnNode(ctx context.Context, nodeName string) ([]lapi.ResourceWithVolumes, error) {\n\tresList, err := c.Resources.GetResourceView(ctx) //, &lapi.ListOpts{Node: []string{nodeName}}) : not working\n\tif err != nil && err != lapi.NotFoundError {\n\t\treturn resList, fmt.Errorf(\"unable to check for resources on node %s: %v\", nodeName, err)\n\t}\n\n\treturn filterNodes(resList, nodeName), nil\n}", "title": "" }, { "docid": "24fb5183a7b8244b65190699dce9619f", "score": "0.44132727", "text": "func ExamplePrivateLinkResourcesClient_List() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armrelay.NewClientFactory(\"<subscription-id>\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tres, err := clientFactory.NewPrivateLinkResourcesClient().List(ctx, \"resourcegroup\", \"example-RelayNamespace-5849\", nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\t// You could use response here. We use blank identifier for just demo purposes.\n\t_ = res\n\t// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t// res.PrivateLinkResourcesListResult = armrelay.PrivateLinkResourcesListResult{\n\t// \tValue: []*armrelay.PrivateLinkResource{\n\t// \t\t{\n\t// \t\t\tName: to.Ptr(\"namespace\"),\n\t// \t\t\tType: to.Ptr(\"Microsoft.Relay/namespaces/privateLinkResources\"),\n\t// \t\t\tID: to.Ptr(\"subscriptions/dbedb4e0-40e6-4145-81f3-f1314c150774/resourceGroups/alitest/providers/Microsoft.Relay/namespaces/relay-private-endpoint-test/privateLinkResources/namespace\"),\n\t// \t\t\tProperties: &armrelay.PrivateLinkResourceProperties{\n\t// \t\t\t\tGroupID: to.Ptr(\"namespace\"),\n\t// \t\t\t\tRequiredMembers: []*string{\n\t// \t\t\t\t\tto.Ptr(\"namespace\")},\n\t// \t\t\t\t\tRequiredZoneNames: []*string{\n\t// \t\t\t\t\t\tto.Ptr(\"privatelink.servicebus.windows.net\")},\n\t// \t\t\t\t\t},\n\t// \t\t\t}},\n\t// \t\t}\n}", "title": "" }, { "docid": "b3b958e993b3bc38cf8296c202eb04b2", "score": "0.44110242", "text": "func (client *DiskAccessesClient) GetPrivateLinkResources(ctx context.Context, resourceGroupName string, diskAccessName string, options *DiskAccessesGetPrivateLinkResourcesOptions) (PrivateLinkResourceListResultResponse, error) {\n\treq, err := client.getPrivateLinkResourcesCreateRequest(ctx, resourceGroupName, diskAccessName, options)\n\tif err != nil {\n\t\treturn PrivateLinkResourceListResultResponse{}, err\n\t}\n\tresp, err := client.con.Pipeline().Do(req)\n\tif err != nil {\n\t\treturn PrivateLinkResourceListResultResponse{}, err\n\t}\n\tif !resp.HasStatusCode(http.StatusOK) {\n\t\treturn PrivateLinkResourceListResultResponse{}, client.getPrivateLinkResourcesHandleError(resp)\n\t}\n\treturn client.getPrivateLinkResourcesHandleResponse(resp)\n}", "title": "" }, { "docid": "0322bfa9907ddd7c6d8127b6bdfaddec", "score": "0.43978542", "text": "func (k *EC2KeyPairs) getAll(configObj config.Config) ([]*string, error) {\n\tresult, err := k.Client.DescribeKeyPairs(&ec2.DescribeKeyPairsInput{})\n\tif err != nil {\n\t\treturn nil, errors.WithStackTrace(err)\n\t}\n\n\tvar ids []*string\n\tfor _, keyPair := range result.KeyPairs {\n\t\tif configObj.EC2KeyPairs.ShouldInclude(config.ResourceValue{\n\t\t\tName: keyPair.KeyName,\n\t\t\tTime: keyPair.CreateTime,\n\t\t}) {\n\t\t\tids = append(ids, keyPair.KeyPairId)\n\t\t}\n\t}\n\n\treturn ids, nil\n}", "title": "" }, { "docid": "0976a811bbb198ce40f20c01f05b8dc5", "score": "0.43951818", "text": "func (t *Template) GetAllAWSEC2VPCDHCPOptionsAssociationResources() map[string]AWSEC2VPCDHCPOptionsAssociation {\n\tresults := map[string]AWSEC2VPCDHCPOptionsAssociation{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSEC2VPCDHCPOptionsAssociation:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::EC2::VPCDHCPOptionsAssociation\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSEC2VPCDHCPOptionsAssociation\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "d85a50155f1d70d3b3dce03ec7247c09", "score": "0.4381372", "text": "func GetResourcesFromPaginator(paginator *cloudformation.ListStackResourcesPaginator) []cloudformation.StackResourceSummary {\n\tresources := make([]cloudformation.StackResourceSummary, 0)\n\n\tfor paginator.Next(context.TODO()) {\n\t\tresources = append(resources, paginator.CurrentPage().StackResourceSummaries...)\n\t}\n\n\treturn resources\n}", "title": "" }, { "docid": "38225a65141b7f98651e3e887e492434", "score": "0.43807876", "text": "func GatewayVpcEndpoint_IsResource(construct awscdk.IConstruct) *bool {\n\t_init_.Initialize()\n\n\tvar returns *bool\n\n\t_jsii_.StaticInvoke(\n\t\t\"monocdk.aws_ec2.GatewayVpcEndpoint\",\n\t\t\"isResource\",\n\t\t[]interface{}{construct},\n\t\t&returns,\n\t)\n\n\treturn returns\n}", "title": "" }, { "docid": "75ede04ce651ed1237ba68ac8ccee1f9", "score": "0.4380469", "text": "func (t *Template) GetAllAWSApiGatewayStageResources() map[string]AWSApiGatewayStage {\n\tresults := map[string]AWSApiGatewayStage{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSApiGatewayStage:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::ApiGateway::Stage\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSApiGatewayStage\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "31f1e58f951dad2031da4a6306b5473a", "score": "0.43791217", "text": "func (client *Client) ListTagResources(request *ListTagResourcesRequest) (_result *ListTagResourcesResponse, _err error) {\n\truntime := &util.RuntimeOptions{}\n\t_result = &ListTagResourcesResponse{}\n\t_body, _err := client.ListTagResourcesWithOptions(request, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_result = _body\n\treturn _result, _err\n}", "title": "" }, { "docid": "31f1e58f951dad2031da4a6306b5473a", "score": "0.43791217", "text": "func (client *Client) ListTagResources(request *ListTagResourcesRequest) (_result *ListTagResourcesResponse, _err error) {\n\truntime := &util.RuntimeOptions{}\n\t_result = &ListTagResourcesResponse{}\n\t_body, _err := client.ListTagResourcesWithOptions(request, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_result = _body\n\treturn _result, _err\n}", "title": "" }, { "docid": "4f6a95de5eef091998771a97357e9e28", "score": "0.4376756", "text": "func (s *ec2TransitGatewayVpcAttachmentLister) List(selector labels.Selector) (ret []*v1alpha1.Ec2TransitGatewayVpcAttachment, err error) {\n\terr = cache.ListAll(s.indexer, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v1alpha1.Ec2TransitGatewayVpcAttachment))\n\t})\n\treturn ret, err\n}", "title": "" }, { "docid": "69b573a85ec2181577b69cf0bfd8e004", "score": "0.43687403", "text": "func (c *EC2) ListVPCSubnets(vpcID string) (*VPCSubnets, error) {\n\tvpcFilter := Filter{\n\t\tName: \"vpc-id\",\n\t\tValues: []string{vpcID},\n\t}\n\trouteTables, err := c.routeTables(vpcFilter)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trtIndex := indexRouteTables(routeTables)\n\n\tvar publicSubnets, privateSubnets []Subnet\n\trespSubnets, err := c.subnets(vpcFilter)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor _, subnet := range respSubnets {\n\t\tvar name string\n\t\tfor _, tag := range subnet.Tags {\n\t\t\tif aws.StringValue(tag.Key) == \"Name\" {\n\t\t\t\tname = aws.StringValue(tag.Value)\n\t\t\t}\n\t\t}\n\t\ts := Subnet{\n\t\t\tResource: Resource{\n\t\t\t\tID: aws.StringValue(subnet.SubnetId),\n\t\t\t\tName: name,\n\t\t\t},\n\t\t\tCIDRBlock: aws.StringValue(subnet.CidrBlock),\n\t\t}\n\t\tif rtIndex.IsPublicSubnet(s.ID) {\n\t\t\tpublicSubnets = append(publicSubnets, s)\n\t\t} else {\n\t\t\tprivateSubnets = append(privateSubnets, s)\n\t\t}\n\t}\n\treturn &VPCSubnets{\n\t\tPublic: publicSubnets,\n\t\tPrivate: privateSubnets,\n\t}, nil\n}", "title": "" }, { "docid": "6fe77d034e3f44132790eba17c94c18c", "score": "0.43672684", "text": "func (client *PublicIPAddressesClient) List(resourceGroupName string, options *PublicIPAddressesListOptions) PublicIPAddressListResultPager {\n\treturn &publicIPAddressListResultPager{\n\t\tpipeline: client.con.Pipeline(),\n\t\trequester: func(ctx context.Context) (*azcore.Request, error) {\n\t\t\treturn client.listCreateRequest(ctx, resourceGroupName, options)\n\t\t},\n\t\tresponder: client.listHandleResponse,\n\t\terrorer: client.listHandleError,\n\t\tadvancer: func(ctx context.Context, resp PublicIPAddressListResultResponse) (*azcore.Request, error) {\n\t\t\treturn azcore.NewRequest(ctx, http.MethodGet, *resp.PublicIPAddressListResult.NextLink)\n\t\t},\n\t\tstatusCodes: []int{http.StatusOK},\n\t}\n}", "title": "" }, { "docid": "62779dc529e0de0ef0a716326fcf9c1f", "score": "0.4357107", "text": "func ExampleVirtualNetworkGatewayConnectionsClient_NewListPager() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armnetwork.NewClientFactory(\"<subscription-id>\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tpager := clientFactory.NewVirtualNetworkGatewayConnectionsClient().NewListPager(\"rg1\", nil)\n\tfor pager.More() {\n\t\tpage, err := pager.NextPage(ctx)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"failed to advance page: %v\", err)\n\t\t}\n\t\tfor _, v := range page.Value {\n\t\t\t// You could use page here. We use blank identifier for just demo purposes.\n\t\t\t_ = v\n\t\t}\n\t\t// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t\t// page.VirtualNetworkGatewayConnectionListResult = armnetwork.VirtualNetworkGatewayConnectionListResult{\n\t\t// \tValue: []*armnetwork.VirtualNetworkGatewayConnection{\n\t\t// \t\t{\n\t\t// \t\t\tName: to.Ptr(\"conn1\"),\n\t\t// \t\t\tType: to.Ptr(\"Microsoft.Network/connections\"),\n\t\t// \t\t\tID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/connections/conn1\"),\n\t\t// \t\t\tLocation: to.Ptr(\"centralus\"),\n\t\t// \t\t\tEtag: to.Ptr(\"W/\\\"00000000-0000-0000-0000-000000000000\\\"\"),\n\t\t// \t\t\tProperties: &armnetwork.VirtualNetworkGatewayConnectionPropertiesFormat{\n\t\t// \t\t\t\tConnectionMode: to.Ptr(armnetwork.VirtualNetworkGatewayConnectionModeDefault),\n\t\t// \t\t\t\tConnectionProtocol: to.Ptr(armnetwork.VirtualNetworkGatewayConnectionProtocolIKEv1),\n\t\t// \t\t\t\tConnectionType: to.Ptr(armnetwork.VirtualNetworkGatewayConnectionTypeIPsec),\n\t\t// \t\t\t\tDpdTimeoutSeconds: to.Ptr[int32](30),\n\t\t// \t\t\t\tEgressBytesTransferred: to.Ptr[int64](0),\n\t\t// \t\t\t\tEgressNatRules: []*armnetwork.SubResource{\n\t\t// \t\t\t\t\t{\n\t\t// \t\t\t\t\t\tID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw1/natRules/natRule2\"),\n\t\t// \t\t\t\t}},\n\t\t// \t\t\t\tEnableBgp: to.Ptr(false),\n\t\t// \t\t\t\tGatewayCustomBgpIPAddresses: []*armnetwork.GatewayCustomBgpIPAddressIPConfiguration{\n\t\t// \t\t\t\t\t{\n\t\t// \t\t\t\t\t\tCustomBgpIPAddress: to.Ptr(\"169.254.21.1\"),\n\t\t// \t\t\t\t\t\tIPConfigurationID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw/ipConfigurations/default\"),\n\t\t// \t\t\t\t\t},\n\t\t// \t\t\t\t\t{\n\t\t// \t\t\t\t\t\tCustomBgpIPAddress: to.Ptr(\"169.254.21.3\"),\n\t\t// \t\t\t\t\t\tIPConfigurationID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw/ipConfigurations/ActiveActive\"),\n\t\t// \t\t\t\t}},\n\t\t// \t\t\t\tIngressBytesTransferred: to.Ptr[int64](0),\n\t\t// \t\t\t\tIngressNatRules: []*armnetwork.SubResource{\n\t\t// \t\t\t\t\t{\n\t\t// \t\t\t\t\t\tID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw1/natRules/natRule1\"),\n\t\t// \t\t\t\t}},\n\t\t// \t\t\t\tIPSecPolicies: []*armnetwork.IPSecPolicy{\n\t\t// \t\t\t\t},\n\t\t// \t\t\t\tLocalNetworkGateway2: &armnetwork.LocalNetworkGateway{\n\t\t// \t\t\t\t\tID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/localNetworkGateways/localgw1\"),\n\t\t// \t\t\t\t\tProperties: &armnetwork.LocalNetworkGatewayPropertiesFormat{\n\t\t// \t\t\t\t\t},\n\t\t// \t\t\t\t},\n\t\t// \t\t\t\tProvisioningState: to.Ptr(armnetwork.ProvisioningStateSucceeded),\n\t\t// \t\t\t\tResourceGUID: to.Ptr(\"00000000-0000-0000-0000-000000000000\"),\n\t\t// \t\t\t\tRoutingWeight: to.Ptr[int32](0),\n\t\t// \t\t\t\tTrafficSelectorPolicies: []*armnetwork.TrafficSelectorPolicy{\n\t\t// \t\t\t\t},\n\t\t// \t\t\t\tUseLocalAzureIPAddress: to.Ptr(false),\n\t\t// \t\t\t\tUsePolicyBasedTrafficSelectors: to.Ptr(false),\n\t\t// \t\t\t\tVirtualNetworkGateway1: &armnetwork.VirtualNetworkGateway{\n\t\t// \t\t\t\t\tID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw1\"),\n\t\t// \t\t\t\t\tProperties: &armnetwork.VirtualNetworkGatewayPropertiesFormat{\n\t\t// \t\t\t\t\t},\n\t\t// \t\t\t\t},\n\t\t// \t\t\t},\n\t\t// \t\t},\n\t\t// \t\t{\n\t\t// \t\t\tName: to.Ptr(\"conn2\"),\n\t\t// \t\t\tType: to.Ptr(\"Microsoft.Network/connections\"),\n\t\t// \t\t\tID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/connections/conn2\"),\n\t\t// \t\t\tLocation: to.Ptr(\"eastus\"),\n\t\t// \t\t\tEtag: to.Ptr(\"W/\\\"00000000-0000-0000-0000-000000000000\\\"\"),\n\t\t// \t\t\tProperties: &armnetwork.VirtualNetworkGatewayConnectionPropertiesFormat{\n\t\t// \t\t\t\tConnectionMode: to.Ptr(armnetwork.VirtualNetworkGatewayConnectionModeDefault),\n\t\t// \t\t\t\tConnectionProtocol: to.Ptr(armnetwork.VirtualNetworkGatewayConnectionProtocolIKEv2),\n\t\t// \t\t\t\tConnectionType: to.Ptr(armnetwork.VirtualNetworkGatewayConnectionTypeIPsec),\n\t\t// \t\t\t\tDpdTimeoutSeconds: to.Ptr[int32](20),\n\t\t// \t\t\t\tEgressBytesTransferred: to.Ptr[int64](0),\n\t\t// \t\t\t\tEgressNatRules: []*armnetwork.SubResource{\n\t\t// \t\t\t\t\t{\n\t\t// \t\t\t\t\t\tID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw2/natRules/natRule2\"),\n\t\t// \t\t\t\t}},\n\t\t// \t\t\t\tEnableBgp: to.Ptr(false),\n\t\t// \t\t\t\tGatewayCustomBgpIPAddresses: []*armnetwork.GatewayCustomBgpIPAddressIPConfiguration{\n\t\t// \t\t\t\t\t{\n\t\t// \t\t\t\t\t\tCustomBgpIPAddress: to.Ptr(\"169.254.21.4\"),\n\t\t// \t\t\t\t\t\tIPConfigurationID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw2/ipConfigurations/default\"),\n\t\t// \t\t\t\t\t},\n\t\t// \t\t\t\t\t{\n\t\t// \t\t\t\t\t\tCustomBgpIPAddress: to.Ptr(\"169.254.21.6\"),\n\t\t// \t\t\t\t\t\tIPConfigurationID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw2/ipConfigurations/ActiveActive\"),\n\t\t// \t\t\t\t}},\n\t\t// \t\t\t\tIngressBytesTransferred: to.Ptr[int64](0),\n\t\t// \t\t\t\tIngressNatRules: []*armnetwork.SubResource{\n\t\t// \t\t\t\t\t{\n\t\t// \t\t\t\t\t\tID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw2/natRules/natRule1\"),\n\t\t// \t\t\t\t}},\n\t\t// \t\t\t\tIPSecPolicies: []*armnetwork.IPSecPolicy{\n\t\t// \t\t\t\t},\n\t\t// \t\t\t\tLocalNetworkGateway2: &armnetwork.LocalNetworkGateway{\n\t\t// \t\t\t\t\tID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/localNetworkGateways/localgw2\"),\n\t\t// \t\t\t\t\tProperties: &armnetwork.LocalNetworkGatewayPropertiesFormat{\n\t\t// \t\t\t\t\t},\n\t\t// \t\t\t\t},\n\t\t// \t\t\t\tProvisioningState: to.Ptr(armnetwork.ProvisioningStateSucceeded),\n\t\t// \t\t\t\tResourceGUID: to.Ptr(\"00000000-0000-0000-0000-000000000000\"),\n\t\t// \t\t\t\tRoutingWeight: to.Ptr[int32](0),\n\t\t// \t\t\t\tTrafficSelectorPolicies: []*armnetwork.TrafficSelectorPolicy{\n\t\t// \t\t\t\t},\n\t\t// \t\t\t\tUseLocalAzureIPAddress: to.Ptr(true),\n\t\t// \t\t\t\tUsePolicyBasedTrafficSelectors: to.Ptr(false),\n\t\t// \t\t\t\tVirtualNetworkGateway1: &armnetwork.VirtualNetworkGateway{\n\t\t// \t\t\t\t\tID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw2\"),\n\t\t// \t\t\t\t\tProperties: &armnetwork.VirtualNetworkGatewayPropertiesFormat{\n\t\t// \t\t\t\t\t},\n\t\t// \t\t\t\t},\n\t\t// \t\t\t},\n\t\t// \t}},\n\t\t// }\n\t}\n}", "title": "" }, { "docid": "62624552f73d62999037ff2572ee95a3", "score": "0.4356901", "text": "func (c *Client) GetVpcsAndSubnets(ctx context.Context) (ipamTypes.VirtualNetworkMap, ipamTypes.SubnetMap, error) {\n\tvpcs := ipamTypes.VirtualNetworkMap{}\n\tsubnets := ipamTypes.SubnetMap{}\n\n\tvpcList, err := c.describeVpcs(ctx)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tfor _, v := range vpcList {\n\t\tif v.ID == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tvpc := &ipamTypes.VirtualNetwork{ID: *v.ID}\n\t\tvpcs[vpc.ID] = vpc\n\n\t\tif v.Subnets != nil {\n\t\t\tfor _, subnet := range *v.Subnets {\n\t\t\t\tif subnet.ID == nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif s := parseSubnet(&subnet); s != nil {\n\t\t\t\t\tsubnets[*subnet.ID] = s\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn vpcs, subnets, nil\n}", "title": "" }, { "docid": "0919516fb0e436fa3ed91b3607e4aece", "score": "0.4356533", "text": "func (t *Template) GetAllAWSIoTCertificateResources() map[string]AWSIoTCertificate {\n\tresults := map[string]AWSIoTCertificate{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSIoTCertificate:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::IoT::Certificate\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSIoTCertificate\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "f1ee2d0e57ef4ce97f028de86fbc72bc", "score": "0.4354926", "text": "func getIPResources(hostID string, ipaddress ...string) ([]HostIPResource, error) {\n\n\t//make a map of all ipaddresses to interface\n\tips, err := getInterfaceMap()\n\tif err != nil {\n\t\treturn []HostIPResource{}, err\n\t}\n\tkeys := make([]string, len(ips))\n\ti := 0\n\tfor key, _ := range ips {\n\t\tkeys[i] = key\n\t\ti += 1\n\t}\n\tglog.V(4).Infof(\"localIPs: %v\", keys)\n\n\tglog.V(4).Infof(\"Interfaces on this host %v\", ips)\n\n\thostIPResources := make([]HostIPResource, 0)\n\n\tfor _, ipaddr := range ipaddress {\n\t\tglog.Infof(\"looking for '%s'\", ipaddr)\n\t\tiface, found := ips[ipaddr]\n\t\tif !found {\n\t\t\treturn []HostIPResource{}, fmt.Errorf(\"IP address %v not valid for this host\", ipaddr)\n\t\t}\n\t\tif isLoopBack(ipaddr) {\n\t\t\treturn []HostIPResource{}, fmt.Errorf(\"loopback address %v cannot be used as an IP Resource\", ipaddr)\n\t\t}\n\t\thostIP := HostIPResource{}\n\t\thostIP.HostID = hostID\n\t\thostIP.IPAddress = ipaddr\n\t\thostIP.InterfaceName = iface.Name\n\t\thostIP.MACAddress = iface.HardwareAddr.String()\n\t\thostIPResources = append(hostIPResources, hostIP)\n\t}\n\treturn hostIPResources, nil\n}", "title": "" }, { "docid": "be9061ba4e7180739bbcc710a05e2e00", "score": "0.43528417", "text": "func (t *Template) GetAllAWSApiGatewayMethodResources() map[string]AWSApiGatewayMethod {\n\tresults := map[string]AWSApiGatewayMethod{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSApiGatewayMethod:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::ApiGateway::Method\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSApiGatewayMethod\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "a4ac07d660f5e29280d32f5a025d83d9", "score": "0.4349029", "text": "func ToVpc(r MappedResource) (*Vpc, error) {\n\tif r.ResourceType() != TypeVPC {\n\t\treturn nil, fmt.Errorf(\"Not of type Vpc\")\n\t}\n\n\treturn r.(*Vpc), nil\n}", "title": "" }, { "docid": "0cc66a9ea76f56950ade17348f724fa9", "score": "0.4339826", "text": "func (v ProfilesResource) List(c buffalo.Context) error {\n\t// Get the DB connection from the context\n\ttx, ok := c.Value(\"tx\").(*pop.Connection)\n\tif !ok {\n\t\treturn errors.WithStack(errors.New(\"no transaction found\"))\n\t}\n\n\tprofiles := &models.Profiles{}\n\n\t// Paginate results. Params \"page\" and \"per_page\" control pagination.\n\t// Default values are \"page=1\" and \"per_page=20\".\n\tq := tx.PaginateFromParams(c.Params())\n\n\t// Retrieve all Profiles from the DB\n\tif err := q.All(profiles); err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\n\t// Add the paginator to the context so it can be used in the template.\n\tc.Set(\"pagination\", q.Paginator)\n\n\treturn c.Render(200, r.Auto(c, profiles))\n}", "title": "" }, { "docid": "dad045028b70577799890f415b4b1029", "score": "0.43316498", "text": "func (tgw *TransitGatewaysVpcAttachment) ResourceIdentifiers() []string {\n\treturn tgw.Ids\n}", "title": "" }, { "docid": "82c0439abaa638a479f5234ca4418f61", "score": "0.43296924", "text": "func (m *IngressGatewayConfig) GetResources() map[string]interface{} {\n\tif m != nil {\n\t\treturn m.Resources\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "82c0439abaa638a479f5234ca4418f61", "score": "0.43296924", "text": "func (m *IngressGatewayConfig) GetResources() map[string]interface{} {\n\tif m != nil {\n\t\treturn m.Resources\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "3d4f8389aefa1e594c958ea4ec1635fd", "score": "0.43287045", "text": "func (t *Template) GetAllAWSApiGatewayDocumentationVersionResources() map[string]AWSApiGatewayDocumentationVersion {\n\tresults := map[string]AWSApiGatewayDocumentationVersion{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSApiGatewayDocumentationVersion:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::ApiGateway::DocumentationVersion\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSApiGatewayDocumentationVersion\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "8bd2e81959e72b0900f255b5383c7aff", "score": "0.43254042", "text": "func ExtractResourcesForPrinting(account *AwsAccountResources) []string {\n\tvar resources []string\n\n\tif len(account.Resources) == 0 {\n\t\tlogging.Logger.Infoln(\"No resources found!\")\n\t\treturn resources\n\t}\n\n\tresources = make([]string, 0)\n\tfor region, resourcesInRegion := range account.Resources {\n\t\tfor _, foundResources := range resourcesInRegion.Resources {\n\t\t\tfor _, identifier := range (*foundResources).ResourceIdentifiers() {\n\t\t\t\tresources = append(resources, fmt.Sprintf(\"%s %s %s\\n\", ui.ResourceHighlightStyle.Render((*foundResources).ResourceName()), identifier, region))\n\t\t\t}\n\t\t}\n\t}\n\n\treturn resources\n}", "title": "" }, { "docid": "5bbe18eabcc32812810b2061bb8fb13d", "score": "0.43188888", "text": "func (v PessoasResource) List(c buffalo.Context) error {\n\t// Get the DB connection from the context\n\ttx, ok := c.Value(\"tx\").(*pop.Connection)\n\tif !ok {\n\t\treturn errors.WithStack(errors.New(\"no transaction found\"))\n\t}\n\n\tpessoas := &models.Pessoas{}\n\n\t// Paginate results. Params \"page\" and \"per_page\" control pagination.\n\t// Default values are \"page=1\" and \"per_page=20\".\n\tq := tx.PaginateFromParams(c.Params())\n\n\t// Retrieve all Pessoas from the DB\n\tif err := q.All(pessoas); err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\n\t// Add the paginator to the context so it can be used in the template.\n\tc.Set(\"pagination\", q.Paginator)\n\n\treturn c.Render(200, r.Auto(c, pessoas))\n}", "title": "" }, { "docid": "8f8a2fef1ed7139f073c017e043a74a8", "score": "0.43101615", "text": "func (t *Template) GetAllAWSEC2RouteResources() map[string]AWSEC2Route {\n\tresults := map[string]AWSEC2Route{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSEC2Route:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::EC2::Route\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSEC2Route\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "ccc590e7e0314d003e3d6093e04dcb4a", "score": "0.43096036", "text": "func (net *GetNetworksInput) GetSubnetsFromVpc(con aws.EstablishConnectionInput) (NetworkResponse, error) {\n\n\tec2, seserr := con.EstablishConnection()\n\tif seserr != nil {\n\t\treturn NetworkResponse{}, seserr\n\t}\n\tresult, err := ec2.DescribeSubnet(\n\t\t&aws.DescribeNetworkInput{\n\t\t\tFilters: aws.Filters{\n\t\t\t\tName: \"vpc-id\",\n\t\t\t\tValue: net.VpcIds,\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn NetworkResponse{}, err\n\t}\n\n\tif net.GetRaw == true {\n\t\treturn NetworkResponse{GetSubnetRaw: result}, nil\n\t}\n\n\tsubnets := make([]SubnetReponse, 0)\n\tfor _, subnet := range result.Subnets {\n\t\tif subnet.Tags != nil {\n\t\t\tsubnets = append(subnets, SubnetReponse{Name: *subnet.Tags[0].Value, Id: *subnet.SubnetId, State: *subnet.State})\n\t\t} else {\n\t\t\tsubnets = append(subnets, SubnetReponse{Id: *subnet.SubnetId, State: *subnet.State})\n\t\t}\n\t}\n\treturn NetworkResponse{VpcId: net.VpcIds[0], Subnets: subnets}, nil\n\n}", "title": "" }, { "docid": "e06837956450d32339df7abcfa616032", "score": "0.43024594", "text": "func (t *Template) GetAllAWSIAMAccessKeyResources() map[string]AWSIAMAccessKey {\n\tresults := map[string]AWSIAMAccessKey{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase AWSIAMAccessKey:\n\t\t\t// We found a strongly typed resource of the correct type; use it\n\t\t\tresults[name] = resource\n\t\tcase map[string]interface{}:\n\t\t\t// We found an untyped resource (likely from JSON) which *might* be\n\t\t\t// the correct type, but we need to check it's 'Type' field\n\t\t\tif resType, ok := resource[\"Type\"]; ok {\n\t\t\t\tif resType == \"AWS::IAM::AccessKey\" {\n\t\t\t\t\t// The resource is correct, unmarshal it into the results\n\t\t\t\t\tif b, err := json.Marshal(resource); err == nil {\n\t\t\t\t\t\tvar result AWSIAMAccessKey\n\t\t\t\t\t\tif err := json.Unmarshal(b, &result); err == nil {\n\t\t\t\t\t\t\tresults[name] = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "9e7ac32ed91a3cfdca2a3f4bbdbe5490", "score": "0.42994943", "text": "func (k Keeper) GetAccountBalanceResources(ctx sdk.Context, addr sdk.AccAddress) (types.Balances, error) {\n\tk.modulePerms.AutoCheck(types.PermRead)\n\n\taddrLibra := common_vm.Bech32ToLibra(addr)\n\tbalances := make(types.Balances, 0)\n\n\tfor _, currency := range k.GetCurrencies(ctx) {\n\t\taccessPath := &vm_grpc.VMAccessPath{\n\t\t\tAddress: addrLibra,\n\t\t\tPath: currency.BalancePath(),\n\t\t}\n\t\tif bz := k.vmKeeper.GetValue(ctx, accessPath); bz != nil {\n\t\t\tbalance, err := types.NewBalance(currency.Denom, accessPath, bz)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"get balance resource for address %q: %w\", addr.String(), err)\n\t\t\t}\n\t\t\tbalances = append(balances, balance)\n\t\t}\n\t}\n\n\treturn balances, nil\n}", "title": "" }, { "docid": "3866214e0e8f181d323e23f6e1a48da0", "score": "0.42981875", "text": "func (c *restClient) ListPrivateConnectionPeeringRoutes(ctx context.Context, req *vmwareenginepb.ListPrivateConnectionPeeringRoutesRequest, opts ...gax.CallOption) *PeeringRouteIterator {\n\tit := &PeeringRouteIterator{}\n\treq = proto.Clone(req).(*vmwareenginepb.ListPrivateConnectionPeeringRoutesRequest)\n\tunm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}\n\tit.InternalFetch = func(pageSize int, pageToken string) ([]*vmwareenginepb.PeeringRoute, string, error) {\n\t\tresp := &vmwareenginepb.ListPrivateConnectionPeeringRoutesResponse{}\n\t\tif pageToken != \"\" {\n\t\t\treq.PageToken = pageToken\n\t\t}\n\t\tif pageSize > math.MaxInt32 {\n\t\t\treq.PageSize = math.MaxInt32\n\t\t} else if pageSize != 0 {\n\t\t\treq.PageSize = int32(pageSize)\n\t\t}\n\t\tbaseUrl, err := url.Parse(c.endpoint)\n\t\tif err != nil {\n\t\t\treturn nil, \"\", err\n\t\t}\n\t\tbaseUrl.Path += fmt.Sprintf(\"/v1/%v/peeringRoutes\", req.GetParent())\n\n\t\tparams := url.Values{}\n\t\tparams.Add(\"$alt\", \"json;enum-encoding=int\")\n\t\tif req.GetPageSize() != 0 {\n\t\t\tparams.Add(\"pageSize\", fmt.Sprintf(\"%v\", req.GetPageSize()))\n\t\t}\n\t\tif req.GetPageToken() != \"\" {\n\t\t\tparams.Add(\"pageToken\", fmt.Sprintf(\"%v\", req.GetPageToken()))\n\t\t}\n\n\t\tbaseUrl.RawQuery = params.Encode()\n\n\t\t// Build HTTP headers from client and context metadata.\n\t\thds := append(c.xGoogHeaders, \"Content-Type\", \"application/json\")\n\t\theaders := gax.BuildHeaders(ctx, hds...)\n\t\te := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {\n\t\t\tif settings.Path != \"\" {\n\t\t\t\tbaseUrl.Path = settings.Path\n\t\t\t}\n\t\t\thttpReq, err := http.NewRequest(\"GET\", baseUrl.String(), nil)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\thttpReq.Header = headers\n\n\t\t\thttpRsp, err := c.httpClient.Do(httpReq)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tdefer httpRsp.Body.Close()\n\n\t\t\tif err = googleapi.CheckResponse(httpRsp); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tbuf, err := io.ReadAll(httpRsp.Body)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif err := unm.Unmarshal(buf, resp); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\treturn nil\n\t\t}, opts...)\n\t\tif e != nil {\n\t\t\treturn nil, \"\", e\n\t\t}\n\t\tit.Response = resp\n\t\treturn resp.GetPeeringRoutes(), resp.GetNextPageToken(), nil\n\t}\n\n\tfetch := func(pageSize int, pageToken string) (string, error) {\n\t\titems, nextPageToken, err := it.InternalFetch(pageSize, pageToken)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tit.items = append(it.items, items...)\n\t\treturn nextPageToken, nil\n\t}\n\n\tit.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)\n\tit.pageInfo.MaxSize = int(req.GetPageSize())\n\tit.pageInfo.Token = req.GetPageToken()\n\n\treturn it\n}", "title": "" }, { "docid": "245135e32c924c8104876626bf2b3d40", "score": "0.42962402", "text": "func (this *SWAPIClient) GetAvailableResources() (*root.Root, int, error) {\n\tresult := &root.Root{}\n\n\tstatus, body, err := this.get(\"/\")\n\tif err != nil {\n\t\treturn result, 0, err\n\t}\n\n\terr = json.Unmarshal(body, result)\n\treturn result, status, err\n}", "title": "" }, { "docid": "78677dd58ebfae507ce2fed98b67f1af", "score": "0.4296131", "text": "func ListVPNGateways(vpcService *vpcv1.VpcV1) (gateways *vpcv1.VPNGatewayCollection, response *core.DetailedResponse, err error) {\n\toptions := &vpcv1.ListVPNGatewaysOptions{}\n\tgateways, response, err = vpcService.ListVPNGateways(options)\n\treturn\n}", "title": "" }, { "docid": "a2ee740f9ffbf251e1518ed017500030", "score": "0.4278814", "text": "func (p *Purge) DeleteVPCs() {\n\tfn := func(svc *ec2.EC2) error {\n\t\tregion := *svc.Config.Region\n\n\t\tresources, ok := p.resources[region]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"Couldn't find resources for region %s\", region)\n\t\t}\n\n\t\tif resources.vpcs == nil {\n\t\t\treturn fmt.Errorf(\"vpcs are not fetched for region %s\", region)\n\t\t}\n\n\t\tvar multiErrors error\n\n\t\tfor _, vpc := range resources.vpcs {\n\t\t\t_, err := svc.DeleteVpc(&ec2.DeleteVpcInput{\n\t\t\t\tVpcId: vpc.VpcId,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\tmultiErrors = multierror.Append(multiErrors, err)\n\t\t\t}\n\t\t}\n\t\treturn multiErrors\n\t}\n\n\tp.terminateEC2Resources(fn)\n}", "title": "" }, { "docid": "c77d7652d1c37a87549d5c468f48ce45", "score": "0.42787087", "text": "func (v ProvidersResource) List(c buffalo.Context) error {\n\ttx, ok := c.Value(\"tx\").(*pop.Connection)\n\tif !ok {\n\t\treturn errors.WithStack(errors.New(\"no transaction found\"))\n\t}\n\n\tproviders := &models.Providers{}\n\tq := tx.PaginateFromParams(c.Params())\n\tif err := q.All(providers); err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\ttx.Load(providers, \"Member\")\n\n\tc.Set(\"pagination\", q.Paginator)\n\treturn c.Render(200, r.Auto(c, providers))\n}", "title": "" }, { "docid": "be5268d3c1b0053aae8f3baec10024e0", "score": "0.4272439", "text": "func (o VpcOutput) TagsAll() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Vpc) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)\n}", "title": "" }, { "docid": "d31e470c3ed4ac3f4654ec6321a989c3", "score": "0.42697147", "text": "func VpcInfoScrape(sess *session.Session) (map[string][]*types.ScrapeResult, error) {\n\tscrapeResults := map[string][]*types.ScrapeResult{}\n\tinfo := []*types.ScrapeResult{}\n\tavailableIps := []*types.ScrapeResult{}\n\ttotalIps := []*types.ScrapeResult{}\n\tclient := ec2.New(sess)\n\n\tvpcs, err := client.DescribeVpcs(&ec2.DescribeVpcsInput{})\n\tif err != nil {\n\t\tmetrics.APICallErrorsTotal.WithLabelValues(\"vpc\", \"DescribeVpcs\").Inc()\n\t\treturn scrapeResults, err\n\t}\n\n\t// Iterate through all VPCs\n\tfor _, v := range vpcs.Vpcs {\n\t\t// Append to the info slice\n\t\tinfo = append(info, &types.ScrapeResult{\n\t\t\tLabels: []string{*v.VpcId, *v.State},\n\t\t\tValue: 1.0,\n\t\t\tType: prometheus.CounterValue,\n\t\t})\n\n\t\t// Query for all the subnets in the same VPC\n\t\tsubs, err := client.DescribeSubnets(&ec2.DescribeSubnetsInput{\n\t\t\tFilters: []*ec2.Filter{\n\t\t\t\t{\n\t\t\t\t\tName: aws.String(\"vpc-id\"),\n\t\t\t\t\tValues: []*string{\n\t\t\t\t\t\tv.VpcId, // Filter by VPC ID\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\tmetrics.APICallErrorsTotal.WithLabelValues(\"vpc\", \"DescribeSubnets\").Inc()\n\t\t\treturn scrapeResults, err\n\t\t}\n\n\t\t// Iterate through all subnets and append results\n\t\tfor _, s := range subs.Subnets {\n\t\t\t// Return the number of available IPs\n\t\t\tavailableIps = append(availableIps, &types.ScrapeResult{\n\t\t\t\tLabels: []string{*s.VpcId, *s.SubnetId},\n\t\t\t\tValue: float64(*s.AvailableIpAddressCount),\n\t\t\t\tType: prometheus.GaugeValue,\n\t\t\t})\n\n\t\t\t// Find the total number of IPs in the subnet CIDR range\n\t\t\ttotalIps = append(totalIps, &types.ScrapeResult{\n\t\t\t\tLabels: []string{*s.VpcId, *s.SubnetId},\n\t\t\t\tValue: float64(getTotalIPCount(*s.CidrBlock)),\n\t\t\t\tType: prometheus.GaugeValue,\n\t\t\t})\n\t\t}\n\t}\n\n\t// Append results\n\tscrapeResults[infoMetric] = info\n\tscrapeResults[subnetAvailableIpsMetric] = availableIps\n\tscrapeResults[subnetTotalIpsMetric] = totalIps\n\n\treturn scrapeResults, nil\n}", "title": "" }, { "docid": "fb1dd34cf070f1464e2b324e0397d93a", "score": "0.4268258", "text": "func (s *PublicRpcAPI) GetContractTemplateList(approved bool, category uint16, pageNo int, pageSize int) (interface{}, error) {\n\n\tblock, stateDB := createTempBlockState(s.cfg)\n\n\tvar getCountFunc string\n\tvar getTempFunc string\n\tif approved {\n\t\tgetCountFunc, getTempFunc = common.ContractTemplateWarehouse_GetApprovedTemplatesCountFunction(),\n\t\t\tcommon.ContractTemplateWarehouse_GetApprovedTemplateFunction()\n\t} else {\n\t\tgetCountFunc, getTempFunc = common.ContractTemplateWarehouse_GetSubmittedTemplatesCountFunction(),\n\t\t\tcommon.ContractTemplateWarehouse_GetSubmittedTemplateFunction()\n\t}\n\ttotalLength, result, err, leftOvergas := s.cfg.ContractMgr.GetTemplates(block,\n\t\tcommon.SystemContractReadOnlyGas, stateDB, chaincfg.ActiveNetParams.FvmParam,\n\t\tgetCountFunc, getTempFunc, category, pageNo, pageSize)\n\tif err != nil {\n\t\treturn nil, internalRPCError(err.Error(), \"GetContractTemplateList leaves\")\n\t}\n\trpcsLog.Debug(\"GetContractTemplateList costs gas \", common.SystemContractReadOnlyGas - leftOvergas)\n\n\treturn ainterface.Page{totalLength, result}, nil\n}", "title": "" } ]
5acdec1ffe9a2f0fe1b42eead47e6084
GetVoteKey "vote substore" + "proposalID" + "voter"
[ { "docid": "2996d2df8719c5e9d65331076c971654", "score": "0.7186952", "text": "func GetVoteKey(proposalID types.ProposalKey, voter types.AccountKey) []byte {\n\treturn append(getVotePrefix(proposalID), voter...)\n}", "title": "" } ]
[ { "docid": "4150a9b84119bea9623f84aa6d41ec9f", "score": "0.7282314", "text": "func KeyVote(proposalID int64, voterAddr sdk.AccAddress) []byte {\n\treturn []byte(fmt.Sprintf(\"votes:%d:%d\", proposalID, voterAddr))\n}", "title": "" }, { "docid": "422fcf48e88abdeaec634690bd0be6c5", "score": "0.7126906", "text": "func KeyVotesSubspace(proposalID int64) []byte {\n\treturn []byte(fmt.Sprintf(\"votes:%d:\", proposalID))\n}", "title": "" }, { "docid": "5a448d6c8c203a53bb2bb0ca999e9a79", "score": "0.67949563", "text": "func GetVoterKey(me types.AccountKey) []byte {\n\treturn append(voterSubstore, me...)\n}", "title": "" }, { "docid": "10769495a33b1867512a9cab06f367ed", "score": "0.6098258", "text": "func upvoteKey(postId string) string {\n\treturn postId + \"-up\"\n}", "title": "" }, { "docid": "c62f430d80909a8fb183584504fc05cd", "score": "0.60824573", "text": "func KeyProposal(proposalID int64) []byte {\n\treturn []byte(fmt.Sprintf(\"proposals:%d\", proposalID))\n}", "title": "" }, { "docid": "732da59ae8a6ec00756d843cea66ed8b", "score": "0.5637789", "text": "func VestingStoreKey(addr sdk.AccAddress) []byte {\n\treturn append(VestingStoreKeyPrefix, addr.Bytes()...)\n}", "title": "" }, { "docid": "105fb32c3c1f808ea67068ccbc747d48", "score": "0.5614242", "text": "func getKeyForGraphDB(skind, dkind, key string) string {\n\treturn skind + \"-\" + dkind + \"-\" + key\n}", "title": "" }, { "docid": "11cd59e6e0abf8f87158a10eacb731c9", "score": "0.556201", "text": "func UpvoteKey(vendorID uint32, postIDBz []byte, curator sdk.AccAddress) []byte {\n\treturn append(UpvotePrefixKey(vendorID, postIDBz), curator.Bytes()...)\n}", "title": "" }, { "docid": "e8189a8eb41a6f907f72c369f9dab424", "score": "0.55619836", "text": "func (query *Query) GetVote(ctx context.Context, proposalID, voter string) (*model.Vote, error) {\n\tresp, err := query.transport.Query(ctx, getVoteKey(proposalID, voter), VoteKVStoreKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvote := new(model.Vote)\n\tif err := query.transport.Cdc.UnmarshalJSON(resp, vote); err != nil {\n\t\treturn nil, err\n\t}\n\treturn vote, nil\n}", "title": "" }, { "docid": "02357f4b7f4df80fd09833d0db45af4e", "score": "0.5553481", "text": "func (keeper Keeper) GetVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) (Vote, bool) {\n\tstore := ctx.KVStore(keeper.storeKey)\n\tbz := store.Get(KeyVote(proposalID, voterAddr))\n\tif bz == nil {\n\t\treturn Vote{}, false\n\t}\n\tvar vote Vote\n\tkeeper.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &vote)\n\treturn vote, true\n}", "title": "" }, { "docid": "afed3b35554e7fe44d8749d785ba5859", "score": "0.549261", "text": "func (keeper Keeper) GetVotes(ctx sdk.Context, proposalID uint64) sdk.Iterator {\n\tstore := ctx.KVStore(keeper.storeKey)\n\treturn sdk.KVStorePrefixIterator(store, KeyVotesSubspace(proposalID))\n}", "title": "" }, { "docid": "0ec1222ac9c193c4b9aaabad2fd195d3", "score": "0.5489173", "text": "func getKey(symID, tgtStorageGroupID string) string {\n\treturn symID + \":\" + tgtStorageGroupID\n}", "title": "" }, { "docid": "ba5e774c887269ce5bb6d506637db91e", "score": "0.5455911", "text": "func getVotedFor(sc *ServerConfig) int {\n\tsc.mutex.RLock()\n\tdefer sc.mutex.RUnlock()\n\treturn sc.votedFor\n}", "title": "" }, { "docid": "eed37e14f73402c25faf47da8fcb8a22", "score": "0.54072744", "text": "func PollAnswersStoreKey(id PostID) []byte {\n\treturn append(PollAnswersStorePrefix, []byte(id)...)\n}", "title": "" }, { "docid": "1c8f48b06a52c11d51364772cc992210", "score": "0.53786904", "text": "func getKey(vec zmath.VecInt) string {\r\n\treturn strconv.Itoa(vec.X) + \".\" + strconv.Itoa(vec.Y)\r\n}", "title": "" }, { "docid": "929b0dd285f10c98169e86928c50dd20", "score": "0.5364695", "text": "func GetProposalIDKey(proposalID uint64) []byte {\n\treturn []byte(fmt.Sprintf(proposalIDKey, uintToHexString(proposalID)))\n}", "title": "" }, { "docid": "9d96530727977dc2f5d1771853d9af98", "score": "0.53474253", "text": "func getPVCKey(ctx context.Context, obj interface{}) (string, error) {\n\tlog := logger.GetLogger(ctx)\n\n\tif unknown, ok := obj.(cache.DeletedFinalStateUnknown); ok && unknown.Obj != nil {\n\t\tobj = unknown.Obj\n\t}\n\tobjKey, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to get key from object: %v\", err)\n\t\treturn \"\", err\n\t}\n\tlog.Infof(\"getPVCKey: PVC key %s\", objKey)\n\treturn objKey, nil\n}", "title": "" }, { "docid": "083b6953bbe65fe808767f49870ca6d0", "score": "0.5345504", "text": "func (p *Protocol) voterVotes(startEpoch uint64, endEpoch uint64, delegateName string) (map[uint64]map[string]*big.Int, error) {\n\tdb := p.indexer.Store.GetDB()\n\tgetQuery := fmt.Sprintf(selectAggregateVoting,\n\t\tvotings.AggregateVotingTableName)\n\tstmt, err := db.Prepare(getQuery)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to prepare get query\")\n\t}\n\tdefer stmt.Close()\n\n\trows, err := stmt.Query(startEpoch, endEpoch, delegateName)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to execute get query\")\n\t}\n\n\tvar aggregateVoting votings.AggregateVoting\n\tparsedRows, err := s.ParseSQLRows(rows, &aggregateVoting)\n\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to parse results\")\n\t}\n\n\tif len(parsedRows) == 0 {\n\t\treturn nil, indexprotocol.ErrNotExist\n\t}\n\n\tepochToVoters := make(map[uint64]map[string]*big.Int)\n\tfor _, parsedRow := range parsedRows {\n\t\tvoting := parsedRow.(*votings.AggregateVoting)\n\n\t\tif _, ok := epochToVoters[voting.EpochNumber]; !ok {\n\t\t\tepochToVoters[voting.EpochNumber] = make(map[string]*big.Int)\n\t\t}\n\t\tweightedVotesInt, errs := stringToBigInt(voting.AggregateVotes)\n\t\tif errs != nil {\n\t\t\treturn nil, errors.Wrap(errs, \"failed to convert to big int\")\n\n\t\t}\n\t\tif val, ok := epochToVoters[voting.EpochNumber][voting.VoterAddress]; !ok {\n\t\t\tepochToVoters[voting.EpochNumber][voting.VoterAddress] = weightedVotesInt\n\t\t} else {\n\t\t\tval.Add(val, weightedVotesInt)\n\t\t}\n\t}\n\n\treturn epochToVoters, nil\n}", "title": "" }, { "docid": "c0dd08616267f62256561ae065e5e393", "score": "0.5310217", "text": "func keyPrivileged(addr common.Address) kv.Key {\n\treturn prefixPrivileged + kv.Key(addr.Bytes())\n}", "title": "" }, { "docid": "0d6b4d1fc7c3e824c8ccee1251667742", "score": "0.5296312", "text": "func GetProposalIDKey() []byte {\n\treturn []byte(proposalIDKey)\n}", "title": "" }, { "docid": "6a0c64fb65790f3955d0c6b2bdeeb97a", "score": "0.5293449", "text": "func VoteIdentifier(ctx context.Context) (voteID []byte) {\n\tif val := ctx.Value(voteIDKey); val != nil {\n\t\tvoteID = val.([]byte)\n\t}\n\treturn\n}", "title": "" }, { "docid": "2d4c4006e45e5e48daa3e795856a48be", "score": "0.5285925", "text": "func (s *Store) vaspKey(id string) (key []byte) {\n\treturn s.makeKey(preVASPs, id)\n}", "title": "" }, { "docid": "c7ef0626a03959bca92247ebdee0b615", "score": "0.5245799", "text": "func ReactionsStoreKey(shortCode, subspace string) []byte {\n\treturn append(ReactionsStorePrefix, []byte(shortCode+subspace)...)\n}", "title": "" }, { "docid": "8596eec5640a5f79d318c7a4c0488ad8", "score": "0.52257115", "text": "func (l *LatestVotes[EntityIndex, VotePowerType]) Voter() identity.ID {\n\tl.m.RLock()\n\tdefer l.m.RUnlock()\n\n\treturn l.voter\n}", "title": "" }, { "docid": "90b89b24422fbe2b49a2cdbd273c6083", "score": "0.5220925", "text": "func (a *Client) GetGovProposalsProposalIDVotesVoter(params *GetGovProposalsProposalIDVotesVoterParams) (*GetGovProposalsProposalIDVotesVoterOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewGetGovProposalsProposalIDVotesVoterParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"GetGovProposalsProposalIDVotesVoter\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/gov/proposals/{proposalId}/votes/{voter}\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &GetGovProposalsProposalIDVotesVoterReader{formats: a.formats},\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*GetGovProposalsProposalIDVotesVoterOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for GetGovProposalsProposalIDVotesVoter: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "title": "" }, { "docid": "f429176aa38b5c5a0fc8c60a3f9749bb", "score": "0.5196792", "text": "func (vs VoteStorage) GetVote(ctx sdk.Context, proposalID types.ProposalKey, voter types.AccountKey) (*Vote, sdk.Error) {\n\tstore := ctx.KVStore(vs.key)\n\tvoteByte := store.Get(GetVoteKey(proposalID, voter))\n\tif voteByte == nil {\n\t\treturn nil, ErrVoteNotFound()\n\t}\n\tvote := new(Vote)\n\tif err := vs.cdc.UnmarshalJSON(voteByte, vote); err != nil {\n\t\treturn nil, ErrFailedToUnmarshalVote(err)\n\t}\n\treturn vote, nil\n}", "title": "" }, { "docid": "68d9f03d89cbcdcab58846f6cb6e8dcc", "score": "0.51550275", "text": "func GenerateVotingKey(kp types.KeyPair, startEpoch, endEpoch uint64) []byte {\n\tvar bs []byte\n\tbs = append(bs, utils.Uint642LittleEndianBytes(startEpoch)...)\n\tbs = append(bs, utils.Uint642LittleEndianBytes(endEpoch)...)\n\tbs = append(bs, utils.Uint642LittleEndianBytes(0xFFFFFFFFFFFFFFFF)...)\n\tbs = append(bs, utils.Uint642LittleEndianBytes(0xFFFFFFFFFFFFFFFF)...)\n\n\tbs = append(bs, []byte(kp.PublicKey)...)\n\tbs = append(bs, utils.Uint642LittleEndianBytes(startEpoch)...)\n\tbs = append(bs, utils.Uint642LittleEndianBytes(endEpoch)...)\n\n\tfor i := endEpoch; i <= startEpoch; i-- {\n\t\tchildPrivateKey := types.NewKeyPair(utils.RandomBytes(types.PrivateKeySize))\n\n\t\tvar parentSignedPayload []byte\n\t\tparentSignedPayload = append(parentSignedPayload, []byte(childPrivateKey.PublicKey)...)\n\t\tparentSignedPayload = append(parentSignedPayload, utils.Uint642LittleEndianBytes(i)...)\n\t\tsignature := kp.Sign(parentSignedPayload)\n\t\tbs = append(bs, []byte(childPrivateKey.PrivateKey)...)\n\t\tbs = append(bs, signature...)\n\t}\n\treturn bs\n}", "title": "" }, { "docid": "f55ef1f1785a2315e03e3770a376fea9", "score": "0.51507866", "text": "func MakeProposalKey(proposalID string) string {\n\treturn proposalID\n}", "title": "" }, { "docid": "d350ead9b7163af9a0f19be3ace32707", "score": "0.5146328", "text": "func getUserPairKey(userA string, userB string) string {\n if userA <= userB {\n return userA + \"$$\" + userB\n }\n return userB + \"$$\" + userA\n}", "title": "" }, { "docid": "137befc8b5b0520bab50103c76ab586f", "score": "0.5138809", "text": "func (gid GoogleID) VAPIkey() (string, error) {\n\tvar v sql.NullString\n\n\terr := db.QueryRow(\"SELECT VAPIkey FROM agentextras WHERE GID = ?\", gid).Scan(&v)\n\tif err != nil {\n\t\tLog.Error(err)\n\t\treturn \"\", nil\n\t}\n\tif !v.Valid {\n\t\treturn \"\", nil\n\t}\n\treturn v.String, nil\n}", "title": "" }, { "docid": "ed46ce6c9ba6f2afa253203401e83202", "score": "0.51168716", "text": "func key(tr Triangle) string {\n\treturn fmt.Sprintf(\"%v\", tr)\n}", "title": "" }, { "docid": "6beac74a9ab997528347a400cedaae8f", "score": "0.5105111", "text": "func KeyFromId(id string) string {\n\treturn strings.Split(id, \"/\")[1]\n}", "title": "" }, { "docid": "5309a079037b8d350db90a47d0c4a60e", "score": "0.5103911", "text": "func (p *PikaEpoch) vidKey(idx int) []byte {\n\tkbuf := make([]byte, 8)\n\tbinary.BigEndian.PutUint64(kbuf, uint64(idx))\n\tkey := make([]byte, len(p.DBPrefix))\n\tcopy(key, p.DBPrefix)\n\tkey = append(key, kbuf...)\n\treturn key\n}", "title": "" }, { "docid": "c05620f722c92f20e21672d27a8817fe", "score": "0.5083725", "text": "func PostReactionsStoreKey(id PostID) []byte {\n\treturn append(PostReactionsStorePrefix, []byte(id)...)\n}", "title": "" }, { "docid": "ebbd2880ecc4c8891df38a90cdfa399c", "score": "0.5075139", "text": "func GetVoteAddress(voteID string) string {\r\n\treturn connector.GetNamespace() + lib.Hexdigest(\"vote\")[:6] + lib.Hexdigest(voteID)[:58]\r\n}", "title": "" }, { "docid": "e5ff71b7e725075e9a45142af67a8def", "score": "0.50741947", "text": "func (u LedgerKey) GetVote() (result LedgerKeyVote, ok bool) {\n\tarmName, _ := u.ArmForSwitch(int32(u.Type))\n\n\tif armName == \"Vote\" {\n\t\tresult = *u.Vote\n\t\tok = true\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "fa738a543a4fcc6cc4aa61b6f66d0c92", "score": "0.506865", "text": "func clientPoolsKey(vscKey, clientID datastore.Key) datastore.Key {\n\treturn vscKey + \":clientvestingpools:\" + clientID\n}", "title": "" }, { "docid": "683fbebd8073a421a46c2483a4532b7d", "score": "0.5024755", "text": "func (watcher Watcher) key() string {\n\treturn fmt.Sprintf(\"%v_lastCheckedBlock\", watcher.selector.String())\n}", "title": "" }, { "docid": "3076f3e7e6183427c9a6bef090c4b4e4", "score": "0.50140804", "text": "func queryVotesOnProposalHandlerFn(cdc *wire.Codec, cliCtx context.CLIContext) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tvars := mux.Vars(r)\n\t\tstrProposalID := vars[RestProposalID]\n\n\t\tif len(strProposalID) == 0 {\n\t\t\tutils.WriteErrorResponse(w, http.StatusBadRequest, \"proposalId required but not specified\")\n\t\t\treturn\n\t\t}\n\n\t\tproposalID, err := strconv.ParseInt(strProposalID, 10, 64)\n\t\tif err != nil {\n\t\t\tutils.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf(\"proposalID [%s] is not positive\", proposalID))\n\t\t\treturn\n\t\t}\n\n\t\tres, err := cliCtx.QueryStore(gov.KeyProposal(proposalID), storeName)\n\t\tif err != nil || len(res) == 0 {\n\t\t\tutils.WriteErrorResponse(w, http.StatusNotFound, fmt.Sprintf(\"proposalID [%d] does not exist\", proposalID))\n\t\t\treturn\n\t\t}\n\n\t\tvar proposal gov.Proposal\n\t\tcdc.MustUnmarshalBinary(res, &proposal)\n\n\t\tif proposal.GetStatus() != gov.StatusVotingPeriod {\n\t\t\tutils.WriteErrorResponse(w, http.StatusNotFound, fmt.Sprintf(\"proposal is not in Voting Period\", proposalID))\n\t\t\treturn\n\t\t}\n\n\t\tres2, err := cliCtx.QuerySubspace(gov.KeyVotesSubspace(proposalID), storeName)\n\t\tif err != nil {\n\t\t\tutils.WriteErrorResponse(w, http.StatusNotFound, \"ProposalID doesn't exist\")\n\t\t\treturn\n\t\t}\n\n\t\tvar votes []gov.Vote\n\n\t\tfor i := 0; i < len(res2); i++ {\n\t\t\tvar vote gov.Vote\n\t\t\tcdc.MustUnmarshalBinary(res2[i].Value, &vote)\n\t\t\tvotes = append(votes, vote)\n\t\t}\n\n\t\toutput, err := wire.MarshalJSONIndent(cdc, votes)\n\t\tif err != nil {\n\t\t\tutils.WriteErrorResponse(w, http.StatusBadRequest, err.Error())\n\t\t\treturn\n\t\t}\n\n\t\tw.Write(output)\n\t}\n}", "title": "" }, { "docid": "431142cbf792202a4a11753c4692a2ae", "score": "0.50051373", "text": "func (tx *TX) transactionKeyForNestedPoint() string {\n\treturn tx.db.GetCore().QuoteWord(transactionPointerPrefix + gconv.String(tx.transactionCount))\n}", "title": "" }, { "docid": "e18b81ae935130618c76e2a53ce231d9", "score": "0.50020313", "text": "func activatedNidKey(mid int64) string {\n\treturn _prefixActivatedNid + strconv.FormatInt(mid, 10)\n}", "title": "" }, { "docid": "f3ea308450cefdd820d7f188e3f4e38e", "score": "0.5001368", "text": "func (c *Client) PrimKey() (string, error) {\n if c.table == \"\" {\n return \"\", errors.New(\"Table wasn't selected\")\n }\n res, err := r.DB(c.db).Table(c.table).Info().Run(c.Session)\n if (err != nil) { return \"\", err }\n\n var primKeyStr struct {\n PrimKey string `gorethink:\"primary_key\"`\n }\n res.One(&primKeyStr)\n\n return primKeyStr.PrimKey, nil\n}", "title": "" }, { "docid": "29a5ae8d18df86817a28791679d17419", "score": "0.49998552", "text": "func (keeper Keeper) GetVotingParams(ctx sdk.Context) VotingParams {\n\tvar votingParams VotingParams\n\tkeeper.paramSpace.Get(ctx, ParamStoreKeyVotingParams, &votingParams)\n\treturn votingParams\n}", "title": "" }, { "docid": "b58182aad24f1332e0774acc20fc3f0a", "score": "0.49868163", "text": "func key(s *library.Secret) string {\n\tswitch s.GetType() {\n\tcase constants.SecretShared:\n\t\treturn fmt.Sprintf(\"%s/%s/%s\", s.GetOrg(), s.GetTeam(), s.GetName())\n\tcase constants.SecretOrg:\n\t\treturn fmt.Sprintf(\"%s/%s\", s.GetOrg(), s.GetName())\n\tcase constants.SecretRepo:\n\t\tfallthrough\n\tdefault:\n\t\treturn fmt.Sprintf(\"%s/%s/%s\", s.GetOrg(), s.GetRepo(), s.GetName())\n\t}\n}", "title": "" }, { "docid": "d26a441ad7145c9d08f3998de4fa4464", "score": "0.49818453", "text": "func (v *AzureKeyVaultSeal) KeyID() string {\n\treturn v.currentKeyID.Load().(string)\n}", "title": "" }, { "docid": "5da3bfc77c3aadc585822f63ecbc1270", "score": "0.49802962", "text": "func GetKVP(key []byte) ValVerPair {\n\tk := string(key)\n\tv := kvStore[k]\n\treturn v\n}", "title": "" }, { "docid": "ca393f37473fd231adfb7935fb137d17", "score": "0.49688554", "text": "func (vg *VLANGroup) key() string {\n\treturn filepath.Join(VLANGroupPath, vg.ID, \"metadata\")\n}", "title": "" }, { "docid": "3be73d914a22e0bf310555e0c667c595", "score": "0.49684042", "text": "func (s *Wrapper) KeyID() string {\n\treturn s.currentKeyID.Load().(string)\n}", "title": "" }, { "docid": "111b63eceadd02db2c00a748246b8b3f", "score": "0.49662575", "text": "func keyName() string {\n\treturn fmt.Sprintf(\"key-%v\", time.Now().UnixNano())\n}", "title": "" }, { "docid": "35b61050a38925371a464694861fc5b3", "score": "0.49610576", "text": "func policyConjKeyFunc(obj interface{}) (string, error) {\n\tconj := obj.(*policyRuleConjunction)\n\treturn fmt.Sprint(conj.id), nil\n}", "title": "" }, { "docid": "3ccc2c0626eb0cbc4deb110a98abcc3f", "score": "0.49526444", "text": "func GetVote(context *gin.Context) {\r\n\t// parse param\r\n\tvoteID := context.Param(\"voteID\")\r\n\r\n\taddress := model.GetVoteAddress(voteID)\r\n\r\n\t// get state data\r\n\tstateResponse, err := connector.GetStates(&connector.StateOptions{Address: address})\r\n\tif err != nil {\r\n\t\tcontext.JSON(http.StatusBadRequest, gin.H{\"error\": \"Failed to get state: \" + err.Error()})\r\n\t\treturn\r\n\t}\r\n\tif len(stateResponse.Data) < 1 {\r\n\t\tcontext.JSON(http.StatusOK, gin.H{\"data\": nil})\r\n\t\treturn\r\n\t}\r\n\r\n\tvote := &voting.Vote{}\r\n\terr = proto.Unmarshal(stateResponse.Data[0], vote)\r\n\tif err != nil {\r\n\t\tcontext.JSON(http.StatusBadRequest, gin.H{\"error\": \"Failed to decode state: \" + err.Error()})\r\n\t\treturn\r\n\t}\r\n\r\n\t// success\r\n\tcontext.JSON(http.StatusOK, gin.H{\r\n\t\t\"data\": vote,\r\n\t})\r\n\treturn\r\n}", "title": "" }, { "docid": "d420d0496d15b1a2ea83e5345179ba47", "score": "0.49488723", "text": "func NodeKey(ticket string) []byte {\n\treturn []byte(nodesTablePrefix + ticket)\n}", "title": "" }, { "docid": "84e929845e33e6e6450960d4906ff891", "score": "0.4946863", "text": "func (k *Wrapper) KeyId(_ context.Context) (string, error) {\n\treturn k.currentKeyId.Load().(string), nil\n}", "title": "" }, { "docid": "cf133a09554fbfea65f63ddc415f77b4", "score": "0.49387985", "text": "func getBGPConfigKey(name, node string) model.Key {\n\tif node == \"\" {\n\t\treturn model.GlobalBGPConfigKey{Name: name}\n\t}\n\treturn model.NodeBGPConfigKey{Nodename: node, Name: name}\n}", "title": "" }, { "docid": "8ab0e699130fa03a4b478fb130296d67", "score": "0.49352357", "text": "func getTagValueFromKey(instance ticket.ComputeInstance, key string) string {\n\tfor _, param := range instance.Tags {\n\t\tif param.Key == key {\n\t\t\treturn param.Value\n\t\t}\n\t}\n\n\t// Throwing a NoSuchKey value is overkill for cases where tag is not added\n\treturn \"\"\n}", "title": "" }, { "docid": "b3d4b67065286f8e1d89db7d9c7c2241", "score": "0.49288484", "text": "func (c *Catalog) routeKey(dbId, tId, gId uint64) []byte {\n\treturn codec.EncodeKey(cPrefix, defaultCatalogId, cRoutePrefix, dbId, tId, gId)\n}", "title": "" }, { "docid": "81faa3c09983abbcfd38aa326d694bca", "score": "0.49235362", "text": "func getNodeKeyFromNodeID(nodeID string) string {\n\tdbg.Assert(len(nodeID) > 0, \"%s\", \"nodeID string can not be empty\")\n\treturn filepath.Join(baseKey, nodeKey, nodeID)\n}", "title": "" }, { "docid": "09cf7ead9b5f51119bc9a7e8a3432da6", "score": "0.49199277", "text": "func (s RS256JWTStrategy) KeyID() (id string) {\n\treturn s.keyID\n}", "title": "" }, { "docid": "6472c55816ee9a9f3228f2c403151309", "score": "0.49172556", "text": "func SPDPolicyKey(spdIndex string, saIndex string) string {\n\tif spdIndex == \"\" {\n\t\tspdIndex = InvalidKeyPart\n\t}\n\tif _, err := strconv.Atoi(spdIndex); err != nil {\n\t\tspdIndex = InvalidKeyPart\n\t}\n\tif saIndex == \"\" {\n\t\tsaIndex = InvalidKeyPart\n\t}\n\tif _, err := strconv.Atoi(saIndex); err != nil {\n\t\tsaIndex = InvalidKeyPart\n\t}\n\tkey := strings.Replace(spdPolicyKeyTemplate, \"{spd}\", spdIndex, 1)\n\tkey = strings.Replace(key, \"{sa}\", saIndex, 1)\n\treturn key\n}", "title": "" }, { "docid": "f71927e190ab78cc31cddc74cfa88030", "score": "0.4904609", "text": "func (kv RawKeyValue) KeyGet() []byte { return kv.Key }", "title": "" }, { "docid": "b43f818571f5c51aa31ea6723f072b7e", "score": "0.49040157", "text": "func taskKey(p peer.ID, k u.Key) string {\n\treturn string(p) + string(k)\n}", "title": "" }, { "docid": "0de5422794dff60826d877c01b60fc33", "score": "0.4891375", "text": "func RedPointKey(mid int64) string {\n\treturn _prefixRedPoint + strconv.FormatInt(mid, 10)\n}", "title": "" }, { "docid": "9b5f674b3317428482bcfdc5ae46b1d5", "score": "0.4885298", "text": "func GetDataPNodeKey(nodeID string) string {\n\treturn fmt.Sprintf(\"%s/%s\", GetDataPNodeBase(), nodeID)\n}", "title": "" }, { "docid": "6275f1887bfc502386bd4b343cf1fefe", "score": "0.48755667", "text": "func contKey(postId string) string {\n\treturn postId + \"-ct\"\n}", "title": "" }, { "docid": "e8c42ce9391e9dddfa76fa2c210c3408", "score": "0.4872389", "text": "func getReplicaKey() string {\n\tnodeID := datanode.NodeInstance().ID\n\treturn fmt.Sprintf(\"DN-%s-replicas\", nodeID)\n\n}", "title": "" }, { "docid": "089dcb4c3dd2dd876a7fa168d70c6600", "score": "0.48707223", "text": "func (job *KeyJob) GetKey() string {\n return job.key\n}", "title": "" }, { "docid": "c9b6fe149ac559f9841350885f37be74", "score": "0.48703444", "text": "func (r *RevisionKey) KeyIDString() string {\n\treturn strconv.FormatInt(r.KeyID, 10)\n}", "title": "" }, { "docid": "177d012c68cb685db0b53d048a9cefe2", "score": "0.486295", "text": "func VoterIdentity(ctx context.Context) (id string) {\n\tif val := ctx.Value(voterIDKey); val != nil {\n\t\tid = val.(string)\n\t}\n\treturn\n}", "title": "" }, { "docid": "48c4c652cd8dfb9db2810839d0ea2d45", "score": "0.48618937", "text": "func GetClaimPrevoteKey(hash tmbytes.HexBytes) []byte {\n\treturn append(PrevoteKey, hash...)\n}", "title": "" }, { "docid": "f1793915c586a601d26beeea08b22efe", "score": "0.48610502", "text": "func GetSubConnKey(clientID string) string {\n\treturn fmt.Sprintf(\"/%s/info/%s/conn_id\", EtcdSubscriberType, clientID)\n}", "title": "" }, { "docid": "50565068614f15535eb94cf4443ba1d9", "score": "0.4850205", "text": "func promisedBallotKey(key []byte) []byte {\n\treturn []byte(fmt.Sprintf(\"__PROMISED__Ballot__KEY__c8c07b0c-3598-11e8-98b8-97a4ad1feb35__d1a0ca9c-3598-11e8-9c5f-c3c66e6b4439.%s\", key))\n}", "title": "" }, { "docid": "2b51ffc9d4f176d91e760d2d41cea1cb", "score": "0.48486555", "text": "func (db *GBucket) getSingleVersionedKey(vctx storage.VersionedCtx, k []byte) ([]byte, error) {\n\t// grab all keys within versioned range\n\tkeys, err := db.getKeysInRange(vctx.(storage.Context), k, k)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif keys == nil || len(keys) == 0 {\n\t\treturn nil, err\n\t}\n\tif len(keys) > 1 {\n\t\treturn nil, fmt.Errorf(\"More than one key found given prefix\")\n\t}\n\n\t// retrieve actual data\n\treturn db.getV(keys[0])\n}", "title": "" }, { "docid": "57300305680766efda8bb7c123edc950", "score": "0.4840915", "text": "func (g *videoGrant) Key() string {\n\treturn \"video\"\n}", "title": "" }, { "docid": "05e6b220f6957744f5ec6880cbdd4c39", "score": "0.4840895", "text": "func (pc PC) getSPSK(primaryContext, secondaryContext, key string) (string, error) {\n\tpc.Logger.Info(\"getSPSK\", \"Scope\", pc.Scope, \"primaryContext\", primaryContext, \"secondaryContext\", secondaryContext, \"Key\", key)\n\t// First we must get the versioned key for the scope.\n\tscopeAlone, err := pc.getVersionedKey(pc.Scope)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tpc.Logger.Debug(\"getSPSK\", \"Scope\", pc.Scope, \"VersionedScope\", scopeAlone)\n\n\t// Then we must get the versioned key for the primary context.\n\tscopeAndPrimary, err := pc.getVersionedKey(pc.ConcatKeys(scopeAlone, primaryContext))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tpc.Logger.Debug(\"getSPSK\", \"scopeAndPrimary\", scopeAndPrimary, \"VersionedScope\", scopeAlone)\n\n\t// Then we must get the versioned key for the secondary context.\n\tprimaryAndSecondary, err := pc.getVersionedKey(pc.ConcatKeys(scopeAndPrimary, secondaryContext))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Finally we must get the NON versioned key for the key.\n\tfullScopeAndKey := pc.HashKey(primaryAndSecondary, key)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn fullScopeAndKey, nil\n\n}", "title": "" }, { "docid": "9b41b469a7096839f0b71216a998faeb", "score": "0.48379222", "text": "func getEventKey(event *v1.Event) string {\n\treturn strings.Join([]string{\n\t\tevent.Source.Component,\n\t\tevent.Source.Host,\n\t\tevent.InvolvedObject.Kind,\n\t\tevent.InvolvedObject.Namespace,\n\t\tevent.InvolvedObject.Name,\n\t\tevent.InvolvedObject.FieldPath,\n\t\tstring(event.InvolvedObject.UID),\n\t\tevent.InvolvedObject.APIVersion,\n\t\tevent.Type,\n\t\tevent.Reason,\n\t\tevent.Message,\n\t},\n\t\t\"\")\n}", "title": "" }, { "docid": "e0d863a8fc25488b362222d366db6331", "score": "0.4829456", "text": "func getClientsKey(client types.RecognizedClient, source types.IssueSource, query string) string {\n\treturn fmt.Sprintf(\"%s > %s > %s\", client, source, query)\n}", "title": "" }, { "docid": "375ffde06b881d5800b5909af8693f80", "score": "0.48277155", "text": "func nodeDBKey(addr common.Address, key []byte) []byte {\n\treturn nodeDBKeyHex(addr, common.Bytes2Hex(key))\n}", "title": "" }, { "docid": "9b4447915696e9349c264f079711aa56", "score": "0.4823132", "text": "func (v *Verifier) Key() (kyber.Scalar, kyber.Point) {\n\treturn v.longterm, v.pub\n}", "title": "" }, { "docid": "e63818b28222e13d8287fe197f8253c6", "score": "0.481919", "text": "func keyFunc(name, namespace string) string {\n\tif len(namespace) == 0 {\n\t\treturn name\n\t}\n\treturn namespace + \"/\" + name\n}", "title": "" }, { "docid": "c64195d702c258e9089dcc1f425d32cb", "score": "0.48173207", "text": "func eventStoredKey(id string) string {\n\treturn CreateKey(EventsCollection, id)\n}", "title": "" }, { "docid": "638be0115c00e57c0d33250f919f86ec", "score": "0.48145568", "text": "func KeyDepositsSubspace(proposalID int64) []byte {\n\treturn []byte(fmt.Sprintf(\"deposits:%d:\", proposalID))\n}", "title": "" }, { "docid": "c3ec86ce84b7abd6b065e808ea97abf6", "score": "0.48098284", "text": "func (query *Query) GetVoter(ctx context.Context, voterName string) (*model.Voter, error) {\n\tresp, err := query.transport.Query(ctx, getVoterKey(voterName), VoteKVStoreKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvoter := new(model.Voter)\n\tif err := query.transport.Cdc.UnmarshalJSON(resp, voter); err != nil {\n\t\treturn nil, err\n\t}\n\treturn voter, nil\n}", "title": "" }, { "docid": "f522431ce766a75a82ef757a05563026", "score": "0.48076206", "text": "func (t *Vote) ID() string {\n\treturn t.VoteID\n}", "title": "" }, { "docid": "590db2d9178f0260588d3ab2c5ad6201", "score": "0.4806992", "text": "func (s *Wrapper) KeyID() string {\n\treturn \"\"\n}", "title": "" }, { "docid": "e7d3561bc2712f5ecc588104b01b578a", "score": "0.4802825", "text": "func (c *Consistent) eltKey(elt string, idx int) string {\n\treturn strconv.Itoa(idx) + elt\n}", "title": "" }, { "docid": "0950f2d96813964ccdf5910315cc3781", "score": "0.4797363", "text": "func key(s string, noPaths bool) string {\n\tsep := \"/\"\n\tif noPaths {\n\t\tsep = \".\"\n\t}\n\ttokens := strings.Split(s, sep)\n\tsecretKey := tokens[len(tokens)-1]\n\treturn secretKey\n}", "title": "" }, { "docid": "86fd54cb58d600b73ff1fea4fe421c1c", "score": "0.4790398", "text": "func (c HashCAS) key(opts CASPutOptions) string {\n\th := c.newHash()\n\th.Write(opts.Data)\n\thash := string(h.Sum(nil))\n\treturn opts.Prefix + hash + opts.Suffix\n}", "title": "" }, { "docid": "1173bd193687b7e27ec6376a53f5c223", "score": "0.47870845", "text": "func GetSignalKey(versionID uint64, switchVoterAddr string) []byte {\n\treturn []byte(fmt.Sprintf(signalKey, uintToHexString(versionID), switchVoterAddr))\n}", "title": "" }, { "docid": "f193a6af4bfca19362a3402dc26dc827", "score": "0.47792253", "text": "func buildKey(key string) string {\n\treturn storePrefix + key\n}", "title": "" }, { "docid": "7da3846db1c602ea8bf9dbd94d2a0df2", "score": "0.47776803", "text": "func getKey(salt []byte, psw []byte, length int) []byte {\n\tdk, err := scrypt.Key(psw, salt, scryptN, scryptR, scryptP,\n\t\tlength)\n\tcheck(err)\n\n\treturn dk\n}", "title": "" }, { "docid": "4c1769e27124cebfc8fb8ebb7c7aaecd", "score": "0.47772178", "text": "func (m *MockProvider) GetVersionGateID(version string, label string) (string, error) {\n\treturn \"\", fmt.Errorf(\"version gates not supported in Mock Provider\")\n}", "title": "" }, { "docid": "9d0d8abe283e9605b7937b4f33673dd3", "score": "0.4771949", "text": "func (e *extraData) storeKey() string {\n\tif e.State == backend.StateUnvetted {\n\t\treturn keyPrefixEncrypted + e.Key\n\t}\n\treturn e.Key\n}", "title": "" }, { "docid": "816a3431f26c869f58194e25127ea63d", "score": "0.47707272", "text": "func KeyPrefixIPSecVpnTunnel() string {\n\treturn ksrkey.KsrK8sPrefix + \"/\" + IPSecVpnTunnelKey + \"/\"\n}", "title": "" }, { "docid": "3c66f86f486976d7c1319b5bf72382f1", "score": "0.47690514", "text": "func voteShow(w http.ResponseWriter, r *http.Request, ps router.Params) {\n\tc := appengine.NewContext(r)\n\n\t//Decode the Key for the show being voted for\n\tkeyStr := ps.ByName(\"key\")\n\tk, err := datastore.DecodeKey(keyStr)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\tlog.Errorf(c, \"DecodeKey: %v\", err)\n\t\treturn\n\t}\n\n\t//Get Show from datastore\n\tvar s Show\n\terr = datastore.Get(c, k, &s)\n\tif err == datastore.ErrNoSuchEntity {\n\t\t//Show not found in the datastore\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t} else if err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\tlog.Errorf(c, \"DecodeKey: %v\", err)\n\t\treturn\n\t}\n\n\t//Check if user has already cast a vote for this show\n\tu := user.Current(c)\n\ti, err := datastore.NewQuery(\"Vote\").Filter(\"Key =\", keyStr).Filter(\"User =\", u.Email).Count(c)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\tlog.Errorf(c, \"Vote Validation: %v\", err)\n\t\treturn\n\t}\n\tif i == 0 {\n\t\t//Put new vote in datastore\n\t\tnewVote := Vote{keyStr, u.Email}\n\t\t_, err = datastore.Put(c, datastore.NewIncompleteKey(c, \"Vote\", nil), &newVote)\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\tlog.Errorf(c, \"Put Vote: %v\", err)\n\t\t\treturn\n\t\t}\n\t}\n\n\t//Count number of Votes and update s.Votes\n\ti, err = datastore.NewQuery(\"Vote\").Filter(\"Key =\", keyStr).Count(c)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\tlog.Errorf(c, \"Vote Count: %v\", err)\n\t\treturn\n\t}\n\ts.Votes = i\n\n\t//Put updated show back in to datastore\n\t_, err = datastore.Put(c, k, &s)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\tlog.Errorf(c, \"Put Updated Show: %v\", err)\n\t\treturn\n\t}\n\n\thttp.Redirect(w, r, \"/\", http.StatusFound)\n}", "title": "" }, { "docid": "ab20249f84ce130839eb044cd88f54df", "score": "0.47651264", "text": "func getKeyValue(args []string, argName string) string {\n\tval := \"\"\n\tfor i, arg := range args {\n\t\tswitch {\n\t\tcase strings.HasPrefix(arg, argName+\"=\"):\n\t\t\ts := strings.Split(arg, \"=\")\n\t\t\tval = s[1]\n\t\tcase arg == argName:\n\t\t\ti++\n\t\t\tval = args[i]\n\t\t}\n\t}\n\treturn val\n}", "title": "" }, { "docid": "c1c6d5d56ae14f46cb2d43776be29736", "score": "0.47628564", "text": "func key(roller string) *datastore.Key {\n\tk := ds.NewKey(ds.KIND_AUTOROLL_UNTHROTTLE)\n\tk.Parent = fakeAncestor()\n\tk.Name = roller + \"_unthrottle\"\n\treturn k\n}", "title": "" }, { "docid": "5c6f5b30c4461af2c3a159f315f06179", "score": "0.47595537", "text": "func proveKey(s *smt.Store, key []byte) (*tmcrypto.ProofOps, error) {\n\tvar ret tmcrypto.ProofOps\n\tkeyProof, err := s.GetProofICS23(key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\thkey := sha256.Sum256(key)\n\tret.Ops = append(ret.Ops, types.NewSmtCommitmentOp(hkey[:], keyProof).ProofOp())\n\treturn &ret, nil\n}", "title": "" }, { "docid": "3319ef7d3904e9fd97c9b584f7346829", "score": "0.4758646", "text": "func (m *Manager) getKey(unverified *jwt.Token) (interface{}, error) {\n\t// require token alg to match the set signing method, do not allow none\n\tif meth := unverified.Method; meth == nil || meth.Alg() != m.method.Alg() {\n\t\treturn nil, jwt.ErrHashUnavailable\n\t}\n\treturn m.key, nil\n}", "title": "" }, { "docid": "88cb739189b43ffe31a4e050a5546263", "score": "0.47529185", "text": "func (vk *VirtualKey) getKeyByAppID(appId string) *keyInst {\n\tfor _, v := range vk.keys {\n\t\tif v.AppID == appId {\n\t\t\treturn &v\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "c700701a0dbd01a1f3cc5ddb31c25faf", "score": "0.47506842", "text": "func (g *voiceGrant) Key() string {\n\treturn \"voice\"\n}", "title": "" } ]
248707e05dcbb26f6e8df91cb533150c
SuffixJobs takes a list of Kubernetes resources and goes over all the jobs. It matches the job's configuration with ConfigMap and Secret objects and calculates a unique hash from all three configurations to determine a unique name for each job. Once done, it replaces all the job names from the input with the newly calculated job name and outputs the data byte slice filled with YAML.
[ { "docid": "209a11141aa45d6de8722cad19f65d32", "score": "0.79883015", "text": "func SuffixJobs(data io.Reader) ([]byte, error) {\n\tresourceList, err := ResourcesFromReader(data)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"Could not read the resources from input\")\n\t}\n\n\tjobs, err := JobSlice(resourceList)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"Could not filter out the jobs\")\n\t}\n\n\t// no jobs in the resource list, return the original\n\tif len(jobs) == 0 {\n\t\treturn marshalUnstructured(resourceList)\n\t}\n\n\tcm, err := HashedConfig(resourceList)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"Could not calculate the config hashes\")\n\t}\n\n\tjobHashes, err := HashedJobs(jobs, cm)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"Could not calculate job hashes\")\n\t}\n\tfor i, rs := range resourceList {\n\t\tif isJobResource(rs) {\n\t\t\tns := rs.GetNamespace()\n\t\t\tif ns == \"\" {\n\t\t\t\tns = \"default\"\n\t\t\t}\n\n\t\t\tkey := fmt.Sprintf(\"%s/%s\", ns, rs.GetName())\n\t\t\tif hash, ok := jobHashes[key]; ok {\n\t\t\t\tresourceList[i].SetName(fmt.Sprintf(\"%s-%s\", rs.GetName(), hash))\n\t\t\t}\n\t\t}\n\t}\n\n\treturn marshalUnstructured(resourceList)\n}", "title": "" } ]
[ { "docid": "4880a703b8950918a39cbdc66393a070", "score": "0.5532861", "text": "func PrintJobs(jobs *v1alpha1.JobList, writer io.Writer) {\n\tmaxLenInfo := getMaxLen(jobs)\n\n\ttitleFormat := \"%%-%ds%%-15s%%-12s%%-12s%%-12s%%-6s%%-10s%%-10s%%-12s%%-10s%%-12s%%-10s\\n\"\n\tcontentFormat := \"%%-%ds%%-15s%%-12s%%-12s%%-12d%%-6d%%-10d%%-10d%%-12d%%-10d%%-12d%%-10d\\n\"\n\n\tvar err error\n\tif listJobFlags.allNamespace {\n\t\t_, err = fmt.Fprintf(writer, fmt.Sprintf(\"%%-%ds\"+titleFormat, maxLenInfo[1], maxLenInfo[0]),\n\t\t\tNamespace, Name, Creation, Phase, JobType, Replicas, Min, Pending, Running, Succeeded, Failed, Unknown, RetryCount)\n\t} else {\n\t\t_, err = fmt.Fprintf(writer, fmt.Sprintf(titleFormat, maxLenInfo[0]),\n\t\t\tName, Creation, Phase, JobType, Replicas, Min, Pending, Running, Succeeded, Failed, Unknown, RetryCount)\n\t}\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to print list command result: %s.\\n\", err)\n\t}\n\n\tfor _, job := range jobs.Items {\n\t\tif listJobFlags.SchedulerName != \"\" && listJobFlags.SchedulerName != job.Spec.SchedulerName {\n\t\t\tcontinue\n\t\t}\n\t\tif !strings.Contains(job.Name, listJobFlags.selector) {\n\t\t\tcontinue\n\t\t}\n\t\treplicas := int32(0)\n\t\tfor _, ts := range job.Spec.Tasks {\n\t\t\treplicas += ts.Replicas\n\t\t}\n\t\tjobType := job.ObjectMeta.Labels[v1alpha1.JobTypeKey]\n\t\tif jobType == \"\" {\n\t\t\tjobType = \"Batch\"\n\t\t}\n\n\t\tif listJobFlags.allNamespace {\n\t\t\t_, err = fmt.Fprintf(writer, fmt.Sprintf(\"%%-%ds\"+contentFormat, maxLenInfo[1], maxLenInfo[0]),\n\t\t\t\tjob.Namespace, job.Name, job.CreationTimestamp.Format(\"2006-01-02\"), job.Status.State.Phase, jobType, replicas,\n\t\t\t\tjob.Status.MinAvailable, job.Status.Pending, job.Status.Running, job.Status.Succeeded, job.Status.Failed, job.Status.Unknown, job.Status.RetryCount)\n\t\t} else {\n\t\t\t_, err = fmt.Fprintf(writer, fmt.Sprintf(contentFormat, maxLenInfo[0]),\n\t\t\t\tjob.Name, job.CreationTimestamp.Format(\"2006-01-02\"), job.Status.State.Phase, jobType, replicas,\n\t\t\t\tjob.Status.MinAvailable, job.Status.Pending, job.Status.Running, job.Status.Succeeded, job.Status.Failed, job.Status.Unknown, job.Status.RetryCount)\n\t\t}\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"Failed to print list command result: %s.\\n\", err)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "e8c9833d40d1bd5ebbef4fb9c9052909", "score": "0.53122264", "text": "func PrintJobs(jobs *v1alpha1.JobList, writer io.Writer) {\n\tmaxLenInfo := getMaxLen(jobs)\n\n\ttitleFormat := \"%%-%ds%%-15s%%-12s%%-12s%%-12s%%-6s%%-10s%%-10s%%-12s%%-10s%%-12s%%-10s\\n\"\n\tcontentFormat := \"%%-%ds%%-15s%%-12s%%-12s%%-12d%%-6d%%-10d%%-10d%%-12d%%-10d%%-12d%%-10d\\n\"\n\n\tvar err error\n\tif viewJobFlags.allNamespace {\n\t\t_, err = fmt.Fprintf(writer, fmt.Sprintf(\"%%-%ds\"+titleFormat, maxLenInfo[1], maxLenInfo[0]),\n\t\t\tNamespace, Name, Creation, Phase, JobType, Replicas, Min, Pending, Running, Succeeded, Failed, Unknown, RetryCount)\n\t} else {\n\t\t_, err = fmt.Fprintf(writer, fmt.Sprintf(titleFormat, maxLenInfo[0]),\n\t\t\tName, Creation, Phase, JobType, Replicas, Min, Pending, Running, Succeeded, Failed, Unknown, RetryCount)\n\t}\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to print list command result: %s.\\n\", err)\n\t}\n\n\tfor _, job := range jobs.Items {\n\t\tif viewJobFlags.SchedulerName != \"\" && viewJobFlags.SchedulerName != job.Spec.SchedulerName {\n\t\t\tcontinue\n\t\t}\n\t\tif !strings.Contains(job.Name, viewJobFlags.selector) {\n\t\t\tcontinue\n\t\t}\n\t\treplicas := int32(0)\n\t\tfor _, ts := range job.Spec.Tasks {\n\t\t\treplicas += ts.Replicas\n\t\t}\n\t\tjobType := job.ObjectMeta.Labels[v1alpha1.JobTypeKey]\n\t\tif jobType == \"\" {\n\t\t\tjobType = \"Batch\"\n\t\t}\n\n\t\tif viewJobFlags.allNamespace {\n\t\t\t_, err = fmt.Fprintf(writer, fmt.Sprintf(\"%%-%ds\"+contentFormat, maxLenInfo[1], maxLenInfo[0]),\n\t\t\t\tjob.Namespace, job.Name, job.CreationTimestamp.Format(\"2006-01-02\"), job.Status.State.Phase, jobType, replicas,\n\t\t\t\tjob.Status.MinAvailable, job.Status.Pending, job.Status.Running, job.Status.Succeeded, job.Status.Failed, job.Status.Unknown, job.Status.RetryCount)\n\t\t} else {\n\t\t\t_, err = fmt.Fprintf(writer, fmt.Sprintf(contentFormat, maxLenInfo[0]),\n\t\t\t\tjob.Name, job.CreationTimestamp.Format(\"2006-01-02\"), job.Status.State.Phase, jobType, replicas,\n\t\t\t\tjob.Status.MinAvailable, job.Status.Pending, job.Status.Running, job.Status.Succeeded, job.Status.Failed, job.Status.Unknown, job.Status.RetryCount)\n\t\t}\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"Failed to print list command result: %s.\\n\", err)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "94e16bdb0b2f10d078e4e814237cfb16", "score": "0.52723706", "text": "func (e *Enforcer) ProcessJobs(jobConfig jobconfig) error {\n\n\tfor _, job := range jobConfig.AllStaticPresubmits(nil) {\n\t\tif err := e.ingest(job.JobBase); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tfor _, job := range jobConfig.AllStaticPostsubmits(nil) {\n\t\tif err := e.ingest(job.JobBase); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tfor _, job := range jobConfig.AllPeriodics() {\n\t\tif err := e.ingest(job.JobBase); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "445034982b1ab415472c49523843864f", "score": "0.49813288", "text": "func (s *JobSuite) TestJobsBasic(c *C) {\n\tnamespace := \"default\"\n\tclientset := NewClient()\n\n\torigJobCount := getK8sJobCount(clientset, namespace, c)\n\n\timages := [2]string{\"ubuntu:latest\", \"perl\"}\n\tfor _, image := range images {\n\t\tjob, err := NewJob(clientset, testJobName, testJobNamespace, testJobServiceAccount, image, \"sleep\", \"2\")\n\n\t\tc.Assert(job, NotNil)\n\t\tc.Assert(err, IsNil)\n\n\t\terr = job.Create()\n\t\tc.Assert(err, IsNil)\n\n\t\tctx := context.Background()\n\t\terr = job.WaitForCompletion(ctx)\n\t\tc.Assert(err, IsNil)\n\n\t\terr = job.Delete()\n\t\tc.Assert(err, IsNil)\n\n\t\terr = waitForJobCount(clientset, namespace, origJobCount, c)\n\t\tif err != nil {\n\t\t\tc.Fail()\n\t\t}\n\t}\n}", "title": "" }, { "docid": "f5fcf8299b3d47b8a334a63d0ba080aa", "score": "0.48698422", "text": "func (c *Client) WatchJobs(namespace string, opts *k8s.WatchOptions, events chan k8s.JobWatchEvent) error {\n\tif events == nil {\n\t\treturn errors.New(\"events must not be nil\")\n\t}\n\trawEvents := make(chan k8s.WatchEvent)\n\tgo func() {\n\t\tfor rawEvent := range rawEvents {\n\t\t\tevents <- &watchEventJob{raw: rawEvent}\n\t\t}\n\t\tclose(events)\n\t}()\n\t_, err := c.doWatch(\"GET\", jobGeneratePath(namespace, \"\")+\"?\"+watchOptionsQuery(opts), nil, rawEvents)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to watch Jobs\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "fa713dbb664e632ddfd2c42d86c67a17", "score": "0.48694107", "text": "func SuffixEach(in []string, prefix string, suffix string) []string {\n\treturn WrapEach(in, ``, suffix)\n}", "title": "" }, { "docid": "9c5c6b035a8bbf1a8051ebe2d9eebfc2", "score": "0.4866608", "text": "func TestPostsubmits(t *testing.T) {\n\tif len(c.PostsubmitsStatic) == 0 {\n\t\tt.Fatalf(\"No jobs found in presubmit.yaml.\")\n\t}\n\n\tfor _, rootJobs := range c.PostsubmitsStatic {\n\t\tfor i, job := range rootJobs {\n\t\t\tif job.Name == \"\" {\n\t\t\t\tt.Errorf(\"Job %v needs a name.\", job)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif !job.SkipReport && job.Context == \"\" {\n\t\t\t\tt.Errorf(\"Job %s needs a context.\", job.Name)\n\t\t\t}\n\n\t\t\tif len(job.Brancher.Branches) > 0 && len(job.Brancher.SkipBranches) > 0 {\n\t\t\t\tt.Errorf(\"Job %s : Cannot have both branches and skip_branches set\", job.Name)\n\t\t\t}\n\t\t\t// Next check that the rerun command doesn't run any other jobs.\n\t\t\tfor _, job2 := range rootJobs[i+1:] {\n\t\t\t\tif job.Name == job2.Name {\n\t\t\t\t\t// Make sure max_concurrency are the same\n\t\t\t\t\tif job.MaxConcurrency != job2.MaxConcurrency {\n\t\t\t\t\t\tt.Errorf(\"Jobs %s share same name but has different max_concurrency\", job.Name)\n\t\t\t\t\t}\n\t\t\t\t\t// Make sure branches are not overlapping\n\t\t\t\t\tif checkOverlapBrancher(job.Brancher, job2.Brancher) {\n\t\t\t\t\t\tt.Errorf(\"Two jobs have the same name: %s, and have conflicting branches\", job.Name)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif job.Context == job2.Context {\n\t\t\t\t\t\tt.Errorf(\"Jobs %s and %s have the same context: %s\", job.Name, job2.Name, job.Context)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "a5f7e454c8a863df431fcf00fa14357e", "score": "0.48635134", "text": "func (d Dispatcher) WriteJobs(jobs []job.Job) {\n\tnodes := []*merkletree.MerkleNode{}\n\tfor _, job := range jobs {\n\t\tnodes = append(nodes, merkletree.NewNode(job, &merkletree.MerkleNode{}, &merkletree.MerkleNode{}))\n\t}\n\tblock := core.NewBlock(*merkletree.NewMerkleTree(nodes), d.GetBC().GetLatestBlock().GetHeader().GetHash(), d.GetBC().GetNextHeight(), uint8(difficulty.Difficulty(d.GetBenchmarks(), *d.GetBC())), d.GetPubString())\n\terr := d.GetBC().AddBlock(block)\n\tif err != nil {\n\t\tglg.Fatal(err)\n\t}\n\td.BroadcastPeers(BlockMessage(block.Serialize(), d.GetPrivByte()))\n}", "title": "" }, { "docid": "f00365d58fe10ddc08a9154193f60cdd", "score": "0.4857443", "text": "func (jobHandler *JobApiHandler) Jobs(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tjobs, err := jobHandler.jobService.Jobs()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\thttp.Error(w, http.StatusText(404), 404)\n\t\treturn\n\t}\n\tresponse, err := json.Marshal(jobs)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\thttp.Error(w, http.StatusText(404), 404)\n\t\treturn\n\t}\n\t_, err = w.Write(response)\n\n}", "title": "" }, { "docid": "f680fad22dd22a37f7a0120df29c9cf0", "score": "0.48433727", "text": "func RenderData(deploymentManifest string, jobsDir string, instanceGroupName string, jobInstance manifest.JobInstance) error {\n\n\t// Loading deployment manifest file\n\tresolvedYML, err := ioutil.ReadFile(deploymentManifest)\n\tif err != nil {\n\t\treturn err\n\t}\n\tmanifestDeployment := manifest.Manifest{}\n\terr = yaml.Unmarshal(resolvedYML, &manifestDeployment)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Loop over instancegroups\n\tfor _, instanceGroup := range manifestDeployment.InstanceGroups {\n\n\t\t// Filter based on the instance group name\n\t\tif instanceGroup.Name != instanceGroupName {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Render all files for all jobs included in this instance_group.\n\t\tfor _, job := range instanceGroup.Jobs {\n\t\t\tjobInstanceLinks := []manifest.Link{}\n\n\t\t\t// Loop over name and link\n\t\t\tfor name, jobConsumersLink := range job.Properties.BOSHContainerization.Consumes {\n\t\t\t\tjobInstances := []manifest.JobInstance{}\n\n\t\t\t\t// Loop over instances of link\n\t\t\t\tfor _, jobConsumerLinkInstance := range jobConsumersLink.Instances {\n\t\t\t\t\tjobInstances = append(jobInstances, manifest.JobInstance{\n\t\t\t\t\t\tAddress: jobConsumerLinkInstance.Address,\n\t\t\t\t\t\tAZ: jobConsumerLinkInstance.AZ,\n\t\t\t\t\t\tID: jobConsumerLinkInstance.ID,\n\t\t\t\t\t\tIndex: jobConsumerLinkInstance.Index,\n\t\t\t\t\t\tName: jobConsumerLinkInstance.Name,\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\t\tjobInstanceLinks = append(jobInstanceLinks, manifest.Link{\n\t\t\t\t\tName: name,\n\t\t\t\t\tInstances: jobInstances,\n\t\t\t\t\tProperties: jobConsumersLink.Properties,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tjobSrcDir := filepath.Join(jobsDir, \"jobs-src\", job.Release, job.Name)\n\t\t\tjobMFFile := filepath.Join(jobSrcDir, \"job.MF\")\n\t\t\tjobMfBytes, err := ioutil.ReadFile(jobMFFile)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tjobSpec := manifest.JobSpec{}\n\t\t\tif err := yaml.Unmarshal([]byte(jobMfBytes), &jobSpec); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t// Loop over templates for rendering files\n\t\t\tfor source, destination := range jobSpec.Templates {\n\t\t\t\tabsDest := filepath.Join(jobsDir, job.Name, destination)\n\t\t\t\tos.MkdirAll(filepath.Dir(absDest), 0755)\n\n\t\t\t\tproperties := job.Properties.ToMap()\n\n\t\t\t\trenderPointer := btg.NewERBRenderer(\n\t\t\t\t\t&btg.EvaluationContext{\n\t\t\t\t\t\tProperties: properties,\n\t\t\t\t\t},\n\n\t\t\t\t\t&btg.InstanceInfo{\n\t\t\t\t\t\tAddress: jobInstance.Address,\n\t\t\t\t\t\tAZ: jobInstance.AZ,\n\t\t\t\t\t\tID: jobInstance.ID,\n\t\t\t\t\t\tIndex: string(jobInstance.Index),\n\t\t\t\t\t\tName: jobInstance.Name,\n\t\t\t\t\t},\n\n\t\t\t\t\tjobMFFile,\n\t\t\t\t)\n\n\t\t\t\t// Create the destination file\n\t\t\t\tabsDestFile, err := os.Create(absDest)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tdefer absDestFile.Close()\n\t\t\t\tif err = renderPointer.Render(filepath.Join(jobSrcDir, \"templates\", source), absDestFile.Name()); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "4c35f2a7938d5926f39b506b9fe32be3", "score": "0.48401082", "text": "func PopulatePodResourceCleanupJobs() amboy.QueueOperation {\n\treturn func(ctx context.Context, queue amboy.Queue) error {\n\t\tcatcher := grip.NewBasicCatcher()\n\t\tcatcher.Wrap(amboy.EnqueueUniqueJob(ctx, queue, NewPodDefinitionCleanupJob(utility.RoundPartOfHour(0).Format(TSFormat))), \"enqueueing pod definition cleanup job\")\n\t\tcatcher.Wrap(amboy.EnqueueUniqueJob(ctx, queue, NewContainerSecretCleanupJob(utility.RoundPartOfHour(0).Format(TSFormat))), \"enqueueing container secret cleanup job\")\n\t\treturn catcher.Resolve()\n\t}\n}", "title": "" }, { "docid": "2cd5f79a8cb19965273e2814becfcfe2", "score": "0.48161274", "text": "func ForJobs() InformerOption {\n\treturn ForGVR(schema.GroupVersionResource{\n\t\tGroup: \"batch\",\n\t\tVersion: \"v1\",\n\t\tResource: \"jobs\",\n\t})\n}", "title": "" }, { "docid": "826482d6b854b3997430959ef9d307df", "score": "0.48002335", "text": "func FormatServingJobs(format string, job printer.ServingJobPrinter) ([]byte, error) {\n\tswitch format {\n\tcase \"json\":\n\t\treturn job.GetJson()\n\tcase \"yaml\":\n\t\treturn job.GetYaml()\n\tdefault:\n\t\treturn []byte(customFormat(job)), nil\n\t}\n}", "title": "" }, { "docid": "065fdfb9d22b28ea9e3f3453439d7012", "score": "0.47920987", "text": "func (s *Submitter) DeployJobs(jobs []*model.Job, highPerformance bool, autoscalingFactor float32) {\n\n\t// Create new cluster\n\tclusterName := fmt.Sprintf(\"obi-%s\", utils.RandomString(10))\n\tcluster, err := newCluster(clusterName, \"dataproc\", highPerformance, autoscalingFactor)\n\n\tif err != nil {\n\t\tfor _, job := range jobs {\n\t\t\t// Update job\n\t\t\tjob.Status = model.JobStatusFailed\n\t\t\tpersistent.Write(job)\n\t\t}\n\t\treturn\n\t}\n\n\tfor _, job := range jobs {\n\t\t// Update job status\n\t\tjob.Cluster = cluster\n\t\tjob.Status = model.JobStatusRunning\n\t\t// Submit job for execution\n\t\tcluster.SubmitJob(job)\n\t\t// Update persistent storage\n\t\tpersistent.Write(job)\n\t}\n}", "title": "" }, { "docid": "1a19c3387c310122e030ba4d582a8873", "score": "0.47883534", "text": "func (s *SmallBen) UpdateJobs(scheduleInfo []UpdateOption) error {\n\ts.lock.Lock()\n\tdefer s.lock.Unlock()\n\n\ts.logger.Info(\"Updating jobs\", \"Progress\", \"InProgress\", \"IDs\", getIdsFromUpdateScheduleList(scheduleInfo))\n\t// first, we grab all the jobs\n\tjobsWithScheduleOld, err := s.repository.GetJobsByIds(getIdsFromUpdateScheduleList(scheduleInfo))\n\tif err != nil {\n\t\ts.logger.Error(err, \"Updating jobs\", \"Progress\", \"Error\", \"Details\", \"RetrievingFromRepository\", \"IDs\", getIdsFromUpdateScheduleList(scheduleInfo))\n\t\treturn err\n\t}\n\n\tjobsWithScheduleNew := make([]JobWithSchedule, len(scheduleInfo))\n\n\t// compute the new schedule\n\t// for the required jobs, making sure the struct is valid.\n\tfor i, job := range jobsWithScheduleOld {\n\t\t// if it is not valid, just return\n\t\tif err := scheduleInfo[i].Valid(); err != nil {\n\t\t\ts.logger.Error(err, \"Updating jobs\", \"Progress\", \"Error\", \"Details\", \"Invalid UpdateOption\", \"ID\", scheduleInfo[i].JobOtherInputs)\n\t\t\treturn err\n\t\t}\n\n\t\tvar newSchedule cron.Schedule\n\t\t// job is a copy of the original job\n\t\t// so it is safe to modify it.\n\t\tnewJobRaw := job.rawJob\n\t\t// if a new schedule has been specified\n\t\t// we need to parse it\n\t\tif scheduleInfo[i].CronExpression != nil {\n\t\t\tvar err error\n\t\t\tnewJobRaw.CronExpression = *scheduleInfo[i].CronExpression\n\t\t\t// build the cron.Schedule object from\n\t\t\tnewSchedule, err = scheduleInfo[i].schedule()\n\t\t\tif err != nil {\n\t\t\t\ts.logger.Error(err, \"Updating jobs\", \"Progress\", \"Error\", \"Details\", \"BuildingJobWithSchedule\", \"ID\", scheduleInfo[i].JobID)\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\t// otherwise, just keep the old one.\n\t\t\tnewSchedule = job.schedule\n\t\t}\n\n\t\t// and now, the JobWithSchedule\n\t\t// with the new inner rawJob.\n\t\tnewJob := JobWithSchedule{\n\t\t\trawJob: newJobRaw,\n\t\t\tschedule: newSchedule,\n\t\t\trun: job.run,\n\t\t\trunInput: job.runInput,\n\t\t}\n\n\t\t// now, set the (new) JobOtherInputs\n\t\t// otherwise, the old has been already set.\n\t\tif scheduleInfo[i].JobOtherInputs != nil {\n\t\t\tnewJob.runInput.OtherInputs = *scheduleInfo[i].JobOtherInputs\n\t\t}\n\n\t\t// now store the new rawJob into the list\n\t\tjobsWithScheduleNew[i] = newJob\n\t}\n\n\t// now, remove the jobsToAdd from the scheduler\n\ts.logger.Info(\"Updating jobs\", \"Progress\", \"InProgress\", \"Details\", \"DeletingFromScheduler\", \"IDs\", getIdsFromUpdateScheduleList(scheduleInfo))\n\ts.scheduler.DeleteJobsWithSchedule(jobsWithScheduleNew)\n\n\t// now, we re-add them to the scheduler\n\ts.logger.Info(\"Updating jobs\", \"Progress\", \"InProgress\", \"Details\", \"AddingToScheduler\", \"IDs\", getIdsFromUpdateScheduleList(scheduleInfo))\n\ts.scheduler.AddJobs(jobsWithScheduleNew)\n\n\t// and update the database\n\ts.logger.Info(\"Updating jobs\", \"Progress\", \"InProgress\", \"Details\", \"UpdatingInRepository\", \"IDs\", getIdsFromUpdateScheduleList(scheduleInfo))\n\tif err = s.repository.SetCronIdAndChangeScheduleAndJobInput(jobsWithScheduleNew); err != nil {\n\t\ts.logger.Error(err, \"Updating jobs\", \"Progress\", \"Error\", \"Details\", \"UpdatingInRepository\", \"IDs\", getIdsFromUpdateScheduleList(scheduleInfo))\n\n\t\t// in case of errors, remove from the scheduler\n\t\ts.logger.Info(\"Updating jobs\", \"Progress\", \"Cleaning\", \"Details\", \"DeleteFromScheduler\", \"IDs\", getIdsFromUpdateScheduleList(scheduleInfo))\n\t\ts.scheduler.DeleteJobsWithSchedule(jobsWithScheduleNew)\n\n\t\t// and update the metrics.\n\t\t// Just need to decrement the number of running\n\t\t// and increment the number of paused.\n\t\t// It is the same as pause()\n\t\ts.metrics.pauseJobs(len(jobsWithScheduleNew))\n\t\treturn err\n\t}\n\t// if everything is fine, no need to\n\t// update the metrics\n\ts.logger.Info(\"Updating jobs\", \"Progress\", \"Done\", \"IDs\", getIdsFromUpdateScheduleList(scheduleInfo))\n\treturn nil\n}", "title": "" }, { "docid": "d4e000d1aead855cb4fd7149b0a74f7c", "score": "0.47516465", "text": "func listJobsHandler(w http.ResponseWriter, r *http.Request) {\n\n\tk8sScheduler, err := createScheduler()\n\tif err != nil {\n\t\tresponseWithError(w, err)\n\t\treturn\n\t}\n\n\tallJobs, err := k8sScheduler.SearchJobs(\"\", CreatedByLabelName, CreatedByLabelValue)\n\tif err != nil {\n\t\tresponseWithError(w, err)\n\t\treturn\n\t}\n\n\tresult := make([]Job, 0)\n\n\tfor _, job := range allJobs.Items {\n\t\tresult = append(result, NewJob(job))\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\terr = json.NewEncoder(w).Encode(result)\n\tif err != nil {\n\t\tresponseWithError(w, err)\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "cfa1867c49bbbc46a7cf3f2cd12b063d", "score": "0.4701328", "text": "func TestAllJobsExecuted(t *testing.T) {\n\ttestingSetUp()\n\tdefer testingTeardown()\n\n\t// Create a pool with 4 workers\n\tpool, err := NewPool(&PoolConfig{\n\t\tNumWorkers: 4,\n\t\tBatchSize: 4,\n\t\tMinWait: 1 * time.Millisecond,\n\t})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer func() {\n\t\t// Close the pool and wait for workers to finish\n\t\tpool.Close()\n\t\tif err := pool.Wait(); err != nil {\n\t\t\tt.Errorf(\"Unexpected error in pool.Wait(): %s\", err.Error())\n\t\t}\n\t}()\n\n\t// Register some jobs which will simply set one of the elements in\n\t// data to \"ok\"\n\tdataMut := sync.Mutex{}\n\tdata := make([]string, 100)\n\tsetStringJob, err := RegisterType(\"setString\", 0, func(i int) error {\n\t\tdataMut.Lock()\n\t\tdata[i] = \"ok\"\n\t\tdataMut.Unlock()\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\tt.Fatalf(\"Unexpected error in RegisterType: %s\", err.Error())\n\t}\n\n\t// Queue up some jobs\n\tfor i := 0; i < len(data); i++ {\n\t\tif _, err := setStringJob.Schedule(100, time.Now(), i); err != nil {\n\t\t\tt.Errorf(\"Unexpected error in Schedule: %s\", err.Error())\n\t\t}\n\t}\n\n\t// Start the pool\n\tif err := pool.Start(); err != nil {\n\t\tt.Errorf(\"Unexpected error in pool.Start(): %s\", err.Error())\n\t}\n\n\t// Continuously check the data every 10 milliseconds. Eventually\n\t// we hope to see that everything was set to \"ok\". If 1 second has\n\t// passed, assume something went wrong.\n\ttimeout := time.After(1 * time.Second)\n\tinterval := time.Tick(10 * time.Millisecond)\n\tremainingJobs := len(data)\n\tfor {\n\t\tselect {\n\t\tcase <-timeout:\n\t\t\t// More than 1 second has passed. Assume something went wrong.\n\t\t\tt.Errorf(\"1 second passed and %d jobs out of %d were not executed.\", remainingJobs, len(data))\n\t\t\tbreak\n\t\tcase <-interval:\n\t\t\t// Count the number of elements in data that equal \"ok\".\n\t\t\t// Anything that doesn't equal ok represents a job that hasn't been executed yet\n\t\t\tremainingJobs = len(data)\n\t\t\tdataMut.Lock()\n\t\t\tfor _, datum := range data {\n\t\t\t\tif datum == \"ok\" {\n\t\t\t\t\tremainingJobs -= 1\n\t\t\t\t}\n\t\t\t}\n\t\t\tdataMut.Unlock()\n\t\t\tif remainingJobs == 0 {\n\t\t\t\t// Each item in data was set to \"ok\", so all the jobs were executed correctly.\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "bdf059640699cf5f8cf823ab97ad8e4f", "score": "0.46652263", "text": "func WithSuffix(suffix string) func(*batchv1.Job) {\n\treturn func(b *batchv1.Job) {\n\t\tb.Name = b.Name + \"-\" + suffix\n\t\tb.Labels[\"jobSuffix\"] = suffix\n\t}\n}", "title": "" }, { "docid": "2d050489181481b569dccc3d1ee1ccc0", "score": "0.46525803", "text": "func newJobConfigMap(mpiJob *training.MPIJob, workerReplicas int32, launcherRunsWorkload bool) *corev1.ConfigMap {\n\tkubexec := fmt.Sprintf(`#!/bin/sh\nset -x\nPOD_NAME=$1\nshift\n%s/kubectl exec ${POD_NAME}`, kubectlMountPath)\n\tif len(mpiJob.Spec.MainContainer) > 0 {\n\t\tkubexec = fmt.Sprintf(\"%s --container %s\", kubexec, mpiJob.Spec.MainContainer)\n\t}\n\tkubexec = fmt.Sprintf(\"%s -- /bin/sh -c \\\"$*\\\"\", kubexec)\n\n\t// If no processing unit is specified, default to 1 slot.\n\tslots := 1\n\tif mpiJob.Spec.SlotsPerWorker != nil {\n\t\tslots = int(*mpiJob.Spec.SlotsPerWorker)\n\t}\n\tvar buffer bytes.Buffer\n\tif launcherRunsWorkload {\n\t\tbuffer.WriteString(fmt.Sprintf(\"%s%s-0 slots=%d\\n\", mpiJob.Name, launcherSuffix, slots))\n\t}\n\tfor i := 0; i < int(workerReplicas); i++ {\n\t\t// If MPIDistributionType specified, the format of the hostfile file is inconsistent as\n\t\t// for different MPI framework.\n\t\t// For Intel MPI and MVAPICH2, use \":\" syntax to indicate how many operating slots the current node has.\n\t\t// But for Open MPI, use \"slots=\" syntax to achieve this function.\n\t\tif mpiJob.Spec.MPIJobLegacySpec != nil && mpiJob.Spec.MPIJobLegacySpec.LegacyV1Alpha2 != nil &&\n\t\t\tmpiJob.Spec.MPIJobLegacySpec.LegacyV1Alpha2.MPIDistribution != nil &&\n\t\t\t(*mpiJob.Spec.MPIJobLegacySpec.LegacyV1Alpha2.MPIDistribution == training.MPIDistributionTypeIntelMPI ||\n\t\t\t\t*mpiJob.Spec.MPIJobLegacySpec.LegacyV1Alpha2.MPIDistribution == training.MPIDistributionTypeMPICH) {\n\t\t\tbuffer.WriteString(fmt.Sprintf(\"%s%s-%d:%d\\n\", mpiJob.Name, workerSuffix, i, slots))\n\t\t} else {\n\t\t\tbuffer.WriteString(fmt.Sprintf(\"%s%s-%d slots=%d\\n\", mpiJob.Name, workerSuffix, i, slots))\n\t\t}\n\t}\n\n\treturn &corev1.ConfigMap{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: jobConfigName(mpiJob),\n\t\t\tNamespace: mpiJob.Namespace,\n\t\t\tLabels: map[string]string{\n\t\t\t\t\"app\": mpiJob.Name,\n\t\t\t},\n\t\t\tOwnerReferences: []metav1.OwnerReference{\n\t\t\t\t*metav1.NewControllerRef(mpiJob, training.SchemeGroupVersion.WithKind(training.MPIJobKind)),\n\t\t\t},\n\t\t},\n\t\tData: map[string]string{\n\t\t\thostfileName: buffer.String(),\n\t\t\tkubexecScriptName: kubexec,\n\t\t},\n\t}\n}", "title": "" }, { "docid": "16779dd87c390626289e6c45e95a6df5", "score": "0.46455494", "text": "func RunServantJobs(cliSet *kubernetes.Clientset, tmplCtx map[string]string, edgeNodeNames []string) error {\n\tvar wg sync.WaitGroup\n\tfor _, nodeName := range edgeNodeNames {\n\t\taction, exist := tmplCtx[\"action\"]\n\t\tif !exist {\n\t\t\treturn errors.New(\"action is not specified\")\n\t\t}\n\n\t\tswitch action {\n\t\tcase \"convert\":\n\t\t\ttmplCtx[\"jobName\"] = ConvertJobNameBase + \"-\" + nodeName\n\t\tcase \"revert\":\n\t\t\ttmplCtx[\"jobName\"] = RevertJobNameBase + \"-\" + nodeName\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unknown action: %s\", action)\n\t\t}\n\t\ttmplCtx[\"nodeName\"] = nodeName\n\n\t\tjobYaml, err := tmplutil.SubsituteTemplate(constants.ServantJobTemplate, tmplCtx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tsrvJobObj, err := YamlToObject([]byte(jobYaml))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tsrvJob, ok := srvJobObj.(*batchv1.Job)\n\t\tif !ok {\n\t\t\treturn errors.New(\"fail to assert yurtctl-servant job\")\n\t\t}\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\tif err := RunJobAndCleanup(cliSet, srvJob,\n\t\t\t\tWaitServantJobTimeout, CheckServantJobPeriod); err != nil {\n\t\t\t\tklog.Errorf(\"fail to run servant job(%s): %s\",\n\t\t\t\t\tsrvJob.GetName(), err)\n\t\t\t} else {\n\t\t\t\tklog.Infof(\"servant job(%s) has succeeded\", srvJob.GetName())\n\t\t\t}\n\t\t}()\n\t}\n\twg.Wait()\n\treturn nil\n}", "title": "" }, { "docid": "d63bc595cf9ad3b8890d8f5b37c43f0e", "score": "0.4637662", "text": "func GetJobs(clientset *kubernetes.Clientset, selector, namespace string) (*v1batch.JobList, error) {\n\tlo := meta_v1.ListOptions{LabelSelector: selector}\n\n\tjobs, err := clientset.Batch().Jobs(namespace).List(lo)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\tlog.Error(\"error getting Job list selector[\" + selector + \"]\")\n\t}\n\treturn jobs, err\n\n}", "title": "" }, { "docid": "c54a741a218c79ac91accf4c337794fb", "score": "0.4636838", "text": "func (d *Driver) Run(image, input, output string) {\n\tclient := getClient()\n\tserviceRes := schema.GroupVersionResource{Group: \"\", Version: \"v1\", Resource: \"services\"}\n\tjobRes := schema.GroupVersionResource{Group: \"batch\", Version: \"v1\", Resource: \"jobs\"}\n\tsvcNames := make([]string, d.NProcs)\n\tjobNames := make([]string, d.NProcs*2)\n\n\twatch, err := client.Resource(jobRes).Namespace(\"default\").Watch(context.TODO(), metav1.ListOptions{})\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\tfor {\n\t\tmjs, rjs, rss := makeJobs(image, input, output, d.NProcs)\n\n\t\tfor i, j := range rss {\n\t\t\tresult, err := client.Resource(serviceRes).Namespace(\"default\").Create(context.TODO(), &j, metav1.CreateOptions{})\n\t\t\tif err != nil {\n\t\t\t\tlog.Panic(err)\n\t\t\t}\n\t\t\tlog.Println(\"Created service: \", result.GetName())\n\t\t\tsvcNames[i] = result.GetName()\n\t\t}\n\n\t\tfor i, j := range rjs {\n\t\t\tresult, err := client.Resource(jobRes).Namespace(\"default\").Create(context.TODO(), &j, metav1.CreateOptions{})\n\t\t\tif err != nil {\n\t\t\t\tlog.Panic(err)\n\t\t\t}\n\t\t\tlog.Println(\"Created job: \", result.GetName())\n\t\t\tjobNames[i] = result.GetName()\n\t\t}\n\n\t\tfor i, j := range mjs {\n\t\t\tresult, err := client.Resource(jobRes).Namespace(\"default\").Create(context.TODO(), &j, metav1.CreateOptions{})\n\t\t\tif err != nil {\n\t\t\t\tlog.Panic(err)\n\t\t\t}\n\t\t\tlog.Println(\"Created job: \", result.GetName())\n\t\t\tjobNames[d.NProcs+i] = result.GetName()\n\t\t}\n\n\t\tsuccess := 0\n\t\tfailure := 0\n\t\tfor success+failure < d.NProcs*2 {\n\t\t\tevent := <-watch.ResultChan()\n\t\t\tjob := event.Object.(*unstructured.Unstructured)\n\t\t\tstatus := job.Object[\"status\"].(map[string]interface{})\n\t\t\tlog.Println(status)\n\t\t\tif _, ok := status[\"succeeded\"]; ok {\n\t\t\t\tsuccess++\n\t\t\t}\n\t\t\tif _, ok := status[\"failed\"]; ok {\n\t\t\t\tfailure++\n\t\t\t}\n\t\t}\n\n\t\tfor _, n := range jobNames {\n\t\t\tcleanupJob(client, n)\n\t\t}\n\t\tfor _, n := range svcNames {\n\t\t\tcleanupSvc(client, n)\n\t\t}\n\n\t\tif success == d.NProcs*2 {\n\t\t\tbreak\n\t\t}\n\t}\n}", "title": "" }, { "docid": "1369d658e67849fbf59f56fe3fbdaafb", "score": "0.4597308", "text": "func (c *Glacier) ListJobs(req *ListJobsInput) (resp *ListJobsOutput, err error) {\n\tresp = &ListJobsOutput{}\n\n\tvar body io.Reader\n\tvar contentType string\n\n\turi := c.client.Endpoint + \"/{accountId}/vaults/{vaultName}/jobs\"\n\n\tif req.AccountID != nil {\n\t\turi = strings.Replace(uri, \"{\"+\"accountId\"+\"}\", aws.EscapePath(*req.AccountID), -1)\n\t\turi = strings.Replace(uri, \"{\"+\"accountId+\"+\"}\", aws.EscapePath(*req.AccountID), -1)\n\t}\n\n\tif req.VaultName != nil {\n\t\turi = strings.Replace(uri, \"{\"+\"vaultName\"+\"}\", aws.EscapePath(*req.VaultName), -1)\n\t\turi = strings.Replace(uri, \"{\"+\"vaultName+\"+\"}\", aws.EscapePath(*req.VaultName), -1)\n\t}\n\n\tq := url.Values{}\n\n\tif req.Completed != nil {\n\t\tq.Set(\"completed\", *req.Completed)\n\t}\n\n\tif req.Limit != nil {\n\t\tq.Set(\"limit\", *req.Limit)\n\t}\n\n\tif req.Marker != nil {\n\t\tq.Set(\"marker\", *req.Marker)\n\t}\n\n\tif req.Statuscode != nil {\n\t\tq.Set(\"statuscode\", *req.Statuscode)\n\t}\n\n\tif len(q) > 0 {\n\t\turi += \"?\" + q.Encode()\n\t}\n\n\thttpReq, err := http.NewRequest(\"GET\", uri, body)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif contentType != \"\" {\n\t\thttpReq.Header.Set(\"Content-Type\", contentType)\n\t}\n\n\thttpResp, err := c.client.Do(httpReq)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tdefer httpResp.Body.Close()\n\n\tif e := json.NewDecoder(httpResp.Body).Decode(resp); e != nil && e != io.EOF {\n\t\terr = e\n\t\treturn\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "5e44790ce526937d8da1ddafc2b88928", "score": "0.4583904", "text": "func BatchStartServers(sc *gophercloud.ServiceClient) {\n\topts := cloudservers.BatchStartOpts{\n\t\tServers: []cloudservers.Server{\n\t\t\t{ID: \"ca5b7bdb-4f3b-494e-8563-018ca0b18c3d\"},\n\t\t\t{ID: \"4c8c776d-050c-4216-950e-c2807666d86c\"},\n\t\t},\n\t}\n\n\tresp, err := cloudservers.BatchStart(sc, opts).ExtractJob()\n\tif err != nil {\n\t\tfmt.Println(\"err:\", err)\n\t\tif ue, ok := err.(*gophercloud.UnifiedError); ok {\n\t\t\tfmt.Println(\"ErrCode:\", ue.ErrorCode())\n\t\t\tfmt.Println(\"Message:\", ue.Message())\n\t\t}\n\t\treturn\n\t}\n\n\tfmt.Println(\"jobID:\", resp.ID)\n\tvar jobObj job.JobResult\n\tfor {\n\t\ttime.Sleep(10 * time.Second)\n\t\tjobRst, jobErr := job.GetJobResult(sc, resp.ID)\n\t\tif jobErr != nil {\n\t\t\tfmt.Println(\"getJobResultErr:\", jobErr)\n\t\t\tif ue, ok := jobErr.(*gophercloud.UnifiedError); ok {\n\t\t\t\tfmt.Println(\"ErrCode:\", ue.ErrorCode())\n\t\t\t\tfmt.Println(\"Message:\", ue.Message())\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tjsJob, _ := json.MarshalIndent(jobRst, \"\", \" \")\n\t\tfmt.Println(string(jsJob))\n\n\t\tif strings.Compare(\"SUCCESS\", jobRst.Status) == 0 {\n\t\t\tjobObj = jobRst\n\t\t\tfmt.Println(\"Servers batch start is success!\")\n\t\t\tbreak\n\t\t} else if strings.Compare(\"FAIL\", jobRst.Status) == 0 {\n\t\t\tjobObj = jobRst\n\t\t\tfmt.Println(\"Servers batch start is failed!\")\n\t\t\tbreak\n\t\t}\n\t}\n\tsubJobs := jobObj.Entities.SubJobs\n\tvar successServers []string\n\tvar failServers []string\n\tfor _, value := range subJobs {\n\t\tif strings.Compare(\"SUCCESS\", value.Status) == 0 {\n\t\t\tsuccessServers = append(successServers, value.Entities.ServerId)\n\t\t} else {\n\t\t\tfailServers = append(failServers, value.Entities.ServerId)\n\t\t}\n\t}\n\tfmt.Println(\"successServers is \", successServers)\n\tfmt.Println(\"failServers is \", failServers)\n}", "title": "" }, { "docid": "7592985a8274ceb01f1728138c7ed7f1", "score": "0.45469588", "text": "func FinalizeLabels(dst, src []prompbmarshal.Label) []prompbmarshal.Label {\n\tfor _, label := range src {\n\t\tname := label.Name\n\t\tif strings.HasPrefix(name, \"__\") && name != \"__name__\" {\n\t\t\tcontinue\n\t\t}\n\t\tdst = append(dst, label)\n\t}\n\treturn dst\n}", "title": "" }, { "docid": "68d3723d8c3d18067c4017a16c6924b1", "score": "0.4543711", "text": "func (client Client) GetAllJobs() (*models.JobList, error) {\n\tfmt.Println(\"Fetching training jobs !!!\")\n\n\tconn := client.Pool.Get()\n\tlist := &models.JobList{}\n\tconst jobsKey = \"jobs\" // demo purpose only\n\tdefer conn.Close()\n\n\tjobs, err := redis.Strings(conn.Do(\"LRANGE\", jobsKey, 0, 24)) // most recent 25\n\tif err != nil {\n\t\tfmt.Println(\"Error retrieving jobs list from cache\")\n\t\treturn list, err\n\t}\n\tfor i, b := range jobs {\n\t\tfmt.Println(i, b)\n\n\t\tjob := models.Job{}\n\t\terr := json.Unmarshal([]byte(b), &job)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"Error unmarshalling json object\")\n\t\t\treturn list, err\n\t\t}\n\n\t\tlist.Jobs = append(list.Jobs, job)\n\t}\n\n\treturn list, nil\n}", "title": "" }, { "docid": "674907cf7bb4e6b655295d4fb70694d0", "score": "0.4537548", "text": "func ListJobs(c *cli.Context) error {\n\trequest, body, errs := gorequest.New().Get(\"http://localhost:3000/api/v1/jobs\").End()\n\tif len(errs) != 0 {\n\t\treturn cli.NewExitError(errs[0].Error(), 1)\n\t}\n\tif request.StatusCode != 200 {\n\t\treturn cli.NewExitError(fmt.Sprintf(\"Something went wrong, status: %d\", request.StatusCode), 1)\n\t}\n\tvar jobs []models.Job\n\tjson.Unmarshal([]byte(body), &jobs)\n\tjobsPretty, _ := json.MarshalIndent(jobs, \"\", \" \")\n\tfmt.Println(string(jobsPretty))\n\treturn nil\n}", "title": "" }, { "docid": "30eef78006001f7e6712f08a40917403", "score": "0.4536639", "text": "func PopulateFallbackGenerateTasksJobs(env evergreen.Environment) amboy.QueueOperation {\n\treturn func(_ context.Context, _ amboy.Queue) error {\n\t\tctx := context.Background()\n\n\t\tcatcher := grip.NewBasicCatcher()\n\t\ttasks, err := task.GenerateNotRun()\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"getting tasks that need generators run\")\n\t\t}\n\n\t\tts := utility.RoundPartOfHour(1).Format(TSFormat)\n\t\tfor _, t := range tasks {\n\t\t\tif _, err = CreateAndEnqueueGenerateTasks(ctx, env, t, ts); err != nil {\n\t\t\t\tcatcher.Add(err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\treturn catcher.Resolve()\n\t}\n}", "title": "" }, { "docid": "d82c8da9d05c6554f528a3771737a7cb", "score": "0.4527021", "text": "func (c *Client) ListJobs(namespace string, opts *k8s.ListOptions) (*k8s.JobList, error) {\n\tvar out k8s.JobList\n\t_, err := c.do(\"GET\", jobGeneratePath(namespace, \"\")+\"?\"+listOptionsQuery(opts, nil), nil, &out)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to list Jobs\")\n\t}\n\treturn &out, nil\n}", "title": "" }, { "docid": "ca1a534ccb3344b7eb2a77aa383fcc14", "score": "0.45207527", "text": "func (s *SmallBen) ListJobs(options *ListJobsOptions) ([]Job, error) {\n\t// grab the list of raw jobs\n\trawJobs, err := s.repository.ListJobs(options)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// the array holding the \"parsed\" jobs\n\tjobs := make([]Job, len(rawJobs))\n\tfor i, rawJob := range rawJobs {\n\t\t// build the parsed job\n\t\tjob, err := rawJob.toJob()\n\t\t// errors in case of deserialization\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\t// otherwise just add it\n\t\tjobs[i] = job\n\t}\n\treturn jobs, nil\n}", "title": "" }, { "docid": "e9af37f9884086ca103fc6f454a40d21", "score": "0.451233", "text": "func TestGetTryJobs(t *testing.T) {\n\tunittest.LargeTest(t)\n\tc, cleanup := ifirestore.NewClientForTesting(context.Background(), t)\n\tdefer cleanup()\n\n\tf := New(c)\n\tctx := context.Background()\n\tconst cis = \"buildbucket\"\n\n\tpsID := tjstore.CombinedPSID{\n\t\tCL: \"1234\",\n\t\tCRS: \"github\",\n\t\tPS: \"abcd\",\n\t}\n\n\t// Should not exist initially\n\txtj, err := f.GetTryJobs(ctx, psID)\n\tassert.NoError(t, err)\n\tassert.Empty(t, xtj)\n\n\t// Put them in backwards to check the order\n\tfor i := 4; i > 0; i-- {\n\t\ttj := ci.TryJob{\n\t\t\tSystem: cis,\n\t\t\tSystemID: \"987654\" + strconv.Itoa(9-i),\n\t\t\tDisplayName: \"My-Test-\" + strconv.Itoa(i),\n\t\t\tUpdated: time.Date(2019, time.August, 13, 12, 11, 50-i, 0, time.UTC),\n\t\t}\n\n\t\terr := f.PutTryJob(ctx, psID, tj)\n\t\tassert.NoError(t, err)\n\t}\n\n\ttj := ci.TryJob{\n\t\tSystem: cis,\n\t\tSystemID: \"ignoreme\",\n\t\tDisplayName: \"Perf-Ignore\",\n\t\tUpdated: time.Date(2019, time.August, 13, 12, 12, 7, 0, time.UTC),\n\t}\n\totherPSID := tjstore.CombinedPSID{\n\t\tCL: \"1234\",\n\t\tCRS: \"github\",\n\t\tPS: \"next\",\n\t}\n\terr = f.PutTryJob(ctx, otherPSID, tj)\n\tassert.NoError(t, err)\n\n\txtj, err = f.GetTryJobs(ctx, psID)\n\tassert.NoError(t, err)\n\tassert.Len(t, xtj, 4)\n\n\tfor i, tj := range xtj {\n\t\tassert.Equal(t, \"My-Test-\"+strconv.Itoa(i+1), tj.DisplayName)\n\t}\n\n\txtj, err = f.GetTryJobs(ctx, otherPSID)\n\tassert.NoError(t, err)\n\tassert.Len(t, xtj, 1)\n\tassert.Equal(t, tj, xtj[0])\n}", "title": "" }, { "docid": "de2db177654b2a25170f2721ba493fb6", "score": "0.4511964", "text": "func PopulatePodDefinitionCreationJobs(env evergreen.Environment) amboy.QueueOperation {\n\treturn func(ctx context.Context, queue amboy.Queue) error {\n\t\tpods, err := pod.FindByInitializing()\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"finding initializing pods\")\n\t\t}\n\n\t\tcatcher := grip.NewBasicCatcher()\n\t\tfor _, p := range pods {\n\t\t\tcatcher.Wrapf(amboy.EnqueueUniqueJob(ctx, queue, NewPodDefinitionCreationJob(env.Settings().Providers.AWS.Pod.ECS, p.TaskContainerCreationOpts, utility.RoundPartOfMinute(15).Format(TSFormat))), \"pod '%s'\", p.ID)\n\t\t}\n\n\t\treturn errors.Wrap(catcher.Resolve(), \"enqueueing pod definition creation jobs\")\n\t}\n}", "title": "" }, { "docid": "1de18407fa1754054dd857845fd040ed", "score": "0.44937137", "text": "func (jc defaultContainer) Jobs() []Job {\n\treturn []Job{\n\t\tNewPullRequestFetcher(jc.storage, jc.client),\n\t\tNewReviewFetcher(jc.storage, jc.client),\n\t\tNewIdlersReminder(jc.storage, jc.slackConfig),\n\t}\n}", "title": "" }, { "docid": "3e0b0169256c7d125c26d83d02fb37de", "score": "0.4491579", "text": "func (kc *KalaClient) GetAllJobs() (map[string]*job.Job, error) {\n\tjobs := &api.ListJobsResponse{}\n\tresp, err := kc.requester.New().Get(api.JobPath).ReceiveSuccess(jobs)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, GenericError\n\t}\n\treturn jobs.Jobs, nil\n}", "title": "" }, { "docid": "d4fd073df33c731b81337e17827a10c9", "score": "0.4487211", "text": "func ValidateUpgradeJobs(t *testing.T) {\n\tvar installerJobObj k8sbatch.Job\n\tvar installerSlice = ReturnJobSlices(t, pegaHelmChartPath, options)\n\tprintln(len(installerSlice))\n\tvar expectedJob pegaJob\n\tfor index, installerInfo := range installerSlice {\n\t\tif index >= 1 && index <= 3 {\n\t\t\tif index == 1 {\n\t\t\t\texpectedJob = pegaJob{\"pega-pre-upgrade\", []string{}, \"pega-upgrade-environment-config\"}\n\t\t\t} else if index == 2 {\n\t\t\t\texpectedJob = pegaJob{\"pega-db-upgrade\", []string{\"wait-for-pre-dbupgrade\"}, \"pega-upgrade-environment-config\"}\n\t\t\t} else if index == 3 {\n\t\t\t\texpectedJob = pegaJob{\"pega-post-upgrade\", []string{\"wait-for-pegaupgrade\", \"wait-for-rolling-updates\"}, \"pega-upgrade-environment-config\"}\n\t\t\t}\n\n\t\t\thelm.UnmarshalK8SYaml(t, installerInfo, &installerJobObj)\n\t\t\tVerifyPegaJob(t, options, &installerJobObj, expectedJob)\n\t\t}\n\n\t}\n}", "title": "" }, { "docid": "6c1e6f8f8e57c5484c7f29a4cba7e40e", "score": "0.44781783", "text": "func BatchStopServers(sc *gophercloud.ServiceClient) {\n\topts := cloudservers.BatchStopOpts{\n\t\tType: cloudservers.Type(cloudservers.Hard),\n\t\tServers: []cloudservers.Server{\n\t\t\t{ID: \"ca5b7bdb-4f3b-494e-8563-018ca0b18c3d\"},\n\t\t\t{ID: \"4c8c776d-050c-4216-950e-c2807666d86c\"},\n\t\t},\n\t}\n\n\tresp, err := cloudservers.BatchStop(sc, opts).ExtractJob()\n\tif err != nil {\n\t\tfmt.Println(\"err:\", err)\n\t\tif ue, ok := err.(*gophercloud.UnifiedError); ok {\n\t\t\tfmt.Println(\"ErrCode:\", ue.ErrorCode())\n\t\t\tfmt.Println(\"Message:\", ue.Message())\n\t\t}\n\t\treturn\n\t}\n\tfmt.Println(\"jobID:\", resp.ID)\n\tvar jobObj job.JobResult\n\tfor {\n\t\ttime.Sleep(10 * time.Second)\n\t\tjobRst, jobErr := job.GetJobResult(sc, resp.ID)\n\t\tif jobErr != nil {\n\t\t\tfmt.Println(\"getJobResultErr:\", jobErr)\n\t\t\tif ue, ok := jobErr.(*gophercloud.UnifiedError); ok {\n\t\t\t\tfmt.Println(\"ErrCode:\", ue.ErrorCode())\n\t\t\t\tfmt.Println(\"Message:\", ue.Message())\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tjsJob, _ := json.MarshalIndent(jobRst, \"\", \" \")\n\t\tfmt.Println(string(jsJob))\n\n\t\tif strings.Compare(\"SUCCESS\", jobRst.Status) == 0 {\n\t\t\tjobObj = jobRst\n\t\t\tfmt.Println(\"Servers batch stop is success!\")\n\t\t\tbreak\n\t\t} else if strings.Compare(\"FAIL\", jobRst.Status) == 0 {\n\t\t\tjobObj = jobRst\n\t\t\tfmt.Println(\"Servers batch stop is failed!\")\n\t\t\tbreak\n\t\t}\n\t}\n\tsubJobs := jobObj.Entities.SubJobs\n\tvar successServers []string\n\tvar failServers []string\n\tfor _, value := range subJobs {\n\t\tif strings.Compare(\"SUCCESS\", value.Status) == 0 {\n\t\t\tsuccessServers = append(successServers, value.Entities.ServerId)\n\t\t} else {\n\t\t\tfailServers = append(failServers, value.Entities.ServerId)\n\t\t}\n\t}\n\tfmt.Println(\"successServers is \", successServers)\n\tfmt.Println(\"failServers is \", failServers)\n}", "title": "" }, { "docid": "bece98f1eb4dcf32c39415fe28f997a8", "score": "0.44725907", "text": "func AppendHistoryToMetronomeFromKubeJobs(metronomeJob *MetronomeJob, kubeJobs []batchv1.Job, pods []corev1.Pod) (*MetronomeJob, error) {\n\tfailureCount := 0\n\tsuccessCount := 0\n\tlastSuccessAtTime := time.Unix(0, 0)\n\tlastFailureAtTime := time.Unix(0, 0)\n\tjobHistory := MetronomeJobHistory{\n\t\tSuccessfulFinishedRuns: []MetronomeJobHistoryEntry{},\n\t\tFailedFinishedRuns: []MetronomeJobHistoryEntry{}}\n\n\tfor _, kubeJob := range kubeJobs {\n\t\tmetronomeJobRun := JobKubernetesToMetronome(&kubeJob)\n\t\tjobHistoryEntry := MetronomeJobHistoryEntry{\n\t\t\tID: metronomeJobRun.Id,\n\t\t\tCreatedAt: metronomeJobRun.CreatedAt,\n\t\t\tFinishedAt: metronomeJobRun.CompletedAt,\n\t\t\tTasks: MatchKubeJobWithPods(metronomeJobRun.Id, pods)}\n\n\t\tswitch metronomeJobRun.Status {\n\t\tcase \"COMPLETED\":\n\t\t\tjobHistory.SuccessfulFinishedRuns = append(jobHistory.SuccessfulFinishedRuns, jobHistoryEntry)\n\t\t\tsuccessCount++\n\t\t\tsuccessAtTime, err := GetMaxTime(lastSuccessAtTime, *jobHistoryEntry.FinishedAt)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tlastSuccessAtTime = *successAtTime\n\t\tcase \"FAILED\":\n\t\t\tjobHistory.FailedFinishedRuns = append(jobHistory.FailedFinishedRuns, jobHistoryEntry)\n\t\t\tfailureCount++\n\t\t\tif anyJobConditionsFailed(kubeJob.Status.Conditions) {\n\t\t\t\tfailureAtTime, err := GetMaxTime(lastFailureAtTime, firstJobConditionFailedTime(kubeJob.Status.Conditions))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tlastFailureAtTime = *failureAtTime\n\t\t\t}\n\t\t}\n\t}\n\n\tjobHistory.SuccessCount = successCount\n\tjobHistory.FailureCount = failureCount\n\tif successCount > 0 {\n\t\tlastSuccessAtString := lastSuccessAtTime.String()\n\t\tjobHistory.LastSuccessAt = &lastSuccessAtString\n\t}\n\tif failureCount > 0 {\n\t\tlastFailureAtString := lastFailureAtTime.String()\n\t\tjobHistory.LastFailureAt = &lastFailureAtString\n\t}\n\tmetronomeJob.History = &jobHistory\n\treturn metronomeJob, nil\n}", "title": "" }, { "docid": "99c923f29875ea59dd65491cfd6b4ce9", "score": "0.44704372", "text": "func Schedules(spec, separator string, job JobItf) error {\n\tif spec == \"\" {\n\t\treturn errors.New(\"invalid specification\")\n\t}\n\tif separator == \"\" {\n\t\treturn errors.New(\"invalid separator\")\n\t}\n\tschedules := strings.Split(spec, separator)\n\tfor k, v := range schedules {\n\t\tif err := schedule(v, job, int64(k+1), int64(len(schedules))); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c597ac4d13b5c2392e73807021bfbb14", "score": "0.4466641", "text": "func (s *Spanner) BatchGetJobs(ctx context.Context, req []*model.DBJobReq) (jobs []engine.Job, err error) {\n\ttxn := s.cli.ReadOnlyTransaction()\n\tnow := time.Now().Unix()\n\tdefer txn.Close()\n\n\tfor _, r := range req {\n\t\titer := txn.Query(ctx, spanner.Statement{\n\t\t\tSQL: \"SELECT pool_name, job_id, namespace, queue, body, ready_time, expired_time, created_time, tries \" +\n\t\t\t\t\"FROM lmstfy_jobs WHERE pool_name = @poolname and namespace = @namespace and queue = @queue and ready_time >= @readytime LIMIT @limit\",\n\t\t\tParams: map[string]interface{}{\n\t\t\t\t\"poolname\": r.PoolName,\n\t\t\t\t\"namespace\": r.Namespace,\n\t\t\t\t\"queue\": r.Queue,\n\t\t\t\t\"readytime\": r.ReadyTime,\n\t\t\t\t\"limit\": r.Count,\n\t\t\t},\n\t\t})\n\t\terr = iter.Do(func(row *spanner.Row) error {\n\t\t\telem := &model.DBJob{}\n\t\t\tif err = row.ToStruct(elem); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tj := engine.NewJob(elem.Namespace, elem.Queue, elem.Body, uint32(elem.ExpiredTime),\n\t\t\t\tuint32(elem.ReadyTime-now), uint16(elem.Tries), elem.JobID)\n\t\t\tjobs = append(jobs, j)\n\t\t\treturn nil\n\t\t})\n\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn jobs, nil\n}", "title": "" }, { "docid": "223e14d3518b3460100bc407f59c82f0", "score": "0.44439852", "text": "func TestListMultipleBlobPrefixes(t *testing.T) {\n\tt.Parallel()\n\n\tfor _, provider := range versionedProviders {\n\t\tenv := providerCreds[provider]\n\n\t\tt.Run(provider, func(t *testing.T) {\n\t\t\tctx := testlogging.Context(t)\n\t\t\ts := getVersionedTestStore(t, env)\n\n\t\t\t// Setup: blobs with different names 2 of them with a common\n\t\t\t// prefix, multiple versions each\n\t\t\tblobsx := makeBlobsWithVersions(t, \"x-\", []int{5, 3})\n\t\t\tblobsy := makeBlobsWithVersions(t, \"y-\", []int{2})\n\n\t\t\tvar bmx, bmy, allMetas []versionMetadata\n\n\t\t\tfor _, b := range blobsx {\n\t\t\t\tbm := putBlobs(ctx, t, s, b)\n\t\t\t\tbmx = append(bmx, bm...)\n\t\t\t}\n\n\t\t\tfor _, b := range blobsy {\n\t\t\t\tbm := putBlobs(ctx, t, s, b)\n\t\t\t\tbmy = append(bmy, bm...)\n\t\t\t}\n\n\t\t\tallMetas = append(allMetas, bmx...)\n\t\t\tallMetas = append(allMetas, bmy...)\n\n\t\t\t// List with no prefix should get all of them\n\t\t\ttestListAllVersions(ctx, t, s, \"\", allMetas)\n\n\t\t\t// List with common prefix should return only include the corresponding blobs\n\t\t\ttestListAllVersions(ctx, t, s, \"x-\", bmx)\n\t\t\ttestListAllVersions(ctx, t, s, \"y-\", bmy)\n\t\t})\n\t}\n}", "title": "" }, { "docid": "ca49707a40a4f9b21ef77b10c7e34d42", "score": "0.4442282", "text": "func BatchRebootServers(sc *gophercloud.ServiceClient) {\n\topts := cloudservers.BatchRebootOpts{\n\t\tType: cloudservers.Type(cloudservers.Soft),\n\t\tServers: []cloudservers.Server{\n\t\t\t{ID: \"ca5b7bdb-4f3b-494e-8563-018ca0b18c3d\"},\n\t\t\t{ID: \"4c8c776d-050c-4216-950e-c2807666d86c\"},\n\t\t},\n\t}\n\n\tresp, err := cloudservers.BatchReboot(sc, opts).ExtractJob()\n\tif err != nil {\n\t\tfmt.Println(\"err:\", err)\n\t\tif ue, ok := err.(*gophercloud.UnifiedError); ok {\n\t\t\tfmt.Println(\"ErrCode:\", ue.ErrorCode())\n\t\t\tfmt.Println(\"Message:\", ue.Message())\n\t\t}\n\t\treturn\n\t}\n\n\tfmt.Println(\"jobID:\", resp.ID)\n\tvar jobObj job.JobResult\n\tfor {\n\t\ttime.Sleep(10 * time.Second)\n\t\tjobRst, jobErr := job.GetJobResult(sc, resp.ID)\n\t\tif jobErr != nil {\n\t\t\tfmt.Println(\"getJobResultErr:\", jobErr)\n\t\t\tif ue, ok := jobErr.(*gophercloud.UnifiedError); ok {\n\t\t\t\tfmt.Println(\"ErrCode:\", ue.ErrorCode())\n\t\t\t\tfmt.Println(\"Message:\", ue.Message())\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tjsJob, _ := json.MarshalIndent(jobRst, \"\", \" \")\n\t\tfmt.Println(string(jsJob))\n\n\t\tif strings.Compare(\"SUCCESS\", jobRst.Status) == 0 {\n\t\t\tjobObj = jobRst\n\t\t\tfmt.Println(\"Servers batch reboot is success!\")\n\t\t\tbreak\n\t\t} else if strings.Compare(\"FAIL\", jobRst.Status) == 0 {\n\t\t\tjobObj = jobRst\n\t\t\tfmt.Println(\"Servers batch reboot is failed!\")\n\t\t\tbreak\n\t\t}\n\t}\n\tsubJobs := jobObj.Entities.SubJobs\n\tvar successServers []string\n\tvar failServers []string\n\tfor _, value := range subJobs {\n\t\tif strings.Compare(\"SUCCESS\", value.Status) == 0 {\n\t\t\tsuccessServers = append(successServers, value.Entities.ServerId)\n\t\t} else {\n\t\t\tfailServers = append(failServers, value.Entities.ServerId)\n\t\t}\n\t}\n\tfmt.Println(\"successServers is \", successServers)\n\tfmt.Println(\"failServers is \", failServers)\n}", "title": "" }, { "docid": "c4b106c4b060a2d3ac7fd36b78336df3", "score": "0.44407892", "text": "func cleanupJobBoundResources(pvcName, namespace string) error {\n\tpvc, err := core.Instance().GetPersistentVolumeClaim(pvcName, namespace)\n\tif err != nil {\n\t\tif k8sErrors.IsNotFound(err) {\n\t\t\tlogrus.Warnf(\"cleaning up of job for pvc %s/%s failed as pvc does not exist\", namespace, pvcName)\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"cleaning up of bound job for pvc %s/%s failed: %v\", pvcName, namespace, err)\n\t}\n\n\tjobName := toBoundJobPVCName(pvc.Name, string(pvc.GetUID()))\n\n\tif err := batch.Instance().DeleteJobWithForce(jobName, namespace); err != nil && !k8sErrors.IsNotFound(err) {\n\t\treturn fmt.Errorf(\"deletion of job %s/%s failed: %v\", namespace, jobName, err)\n\t}\n\tif err := utils.CleanServiceAccount(jobName, namespace); err != nil {\n\t\treturn fmt.Errorf(\"deletion of service account %s/%s failed: %v\", namespace, jobName, err)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "6391f3e401f802d343ad757542561e4f", "score": "0.44328767", "text": "func (p *Printer) Jobs() ([]JobInfo, error) {\n\tvar bytesNeeded, jobsReturned uint32\n\tbuf := make([]byte, 1)\n\tfor {\n\t\terr := EnumJobs(p.h, 0, 255, 1, &buf[0], uint32(len(buf)), &bytesNeeded, &jobsReturned)\n\t\tif err == nil {\n\t\t\tbreak\n\t\t}\n\t\tif err != syscall.ERROR_INSUFFICIENT_BUFFER {\n\t\t\treturn nil, err\n\t\t}\n\t\tif bytesNeeded <= uint32(len(buf)) {\n\t\t\treturn nil, err\n\t\t}\n\t\tbuf = make([]byte, bytesNeeded)\n\t}\n\tif jobsReturned <= 0 {\n\t\treturn nil, nil\n\t}\n\tpjs := make([]JobInfo, 0, jobsReturned)\n\tji := (*[2048]JOB_INFO_1)(unsafe.Pointer(&buf[0]))[:jobsReturned]\n\tfor _, j := range ji {\n\t\tpji := JobInfo{\n\t\t\tJobID: j.JobID,\n\t\t\tStatusCode: j.StatusCode,\n\t\t\tPriority: j.Priority,\n\t\t\tPosition: j.Position,\n\t\t\tTotalPages: j.TotalPages,\n\t\t\tPagesPrinted: j.PagesPrinted,\n\t\t}\n\t\tif j.MachineName != nil {\n\t\t\tpji.UserMachineName = syscall.UTF16ToString((*[2048]uint16)(unsafe.Pointer(j.MachineName))[:])\n\t\t}\n\t\tif j.UserName != nil {\n\t\t\tpji.UserName = syscall.UTF16ToString((*[2048]uint16)(unsafe.Pointer(j.UserName))[:])\n\t\t}\n\t\tif j.Document != nil {\n\t\t\tpji.DocumentName = syscall.UTF16ToString((*[2048]uint16)(unsafe.Pointer(j.Document))[:])\n\t\t}\n\t\tif j.DataType != nil {\n\t\t\tpji.DataType = syscall.UTF16ToString((*[2048]uint16)(unsafe.Pointer(j.DataType))[:])\n\t\t}\n\t\tif j.Status != nil {\n\t\t\tpji.Status = syscall.UTF16ToString((*[2048]uint16)(unsafe.Pointer(j.Status))[:])\n\t\t}\n\t\tif strings.TrimSpace(pji.Status) == \"\" {\n\t\t\tif pji.StatusCode == 0 {\n\t\t\t\tpji.Status += \"Queue Paused, \"\n\t\t\t}\n\t\t\tif pji.StatusCode&JOB_STATUS_PRINTING != 0 {\n\t\t\t\tpji.Status += \"Printing, \"\n\t\t\t}\n\t\t\tif pji.StatusCode&JOB_STATUS_PAUSED != 0 {\n\t\t\t\tpji.Status += \"Paused, \"\n\t\t\t}\n\t\t\tif pji.StatusCode&JOB_STATUS_ERROR != 0 {\n\t\t\t\tpji.Status += \"Error, \"\n\t\t\t}\n\t\t\tif pji.StatusCode&JOB_STATUS_DELETING != 0 {\n\t\t\t\tpji.Status += \"Deleting, \"\n\t\t\t}\n\t\t\tif pji.StatusCode&JOB_STATUS_SPOOLING != 0 {\n\t\t\t\tpji.Status += \"Spooling, \"\n\t\t\t}\n\t\t\tif pji.StatusCode&JOB_STATUS_OFFLINE != 0 {\n\t\t\t\tpji.Status += \"Printer Offline, \"\n\t\t\t}\n\t\t\tif pji.StatusCode&JOB_STATUS_PAPEROUT != 0 {\n\t\t\t\tpji.Status += \"Out of Paper, \"\n\t\t\t}\n\t\t\tif pji.StatusCode&JOB_STATUS_PRINTED != 0 {\n\t\t\t\tpji.Status += \"Printed, \"\n\t\t\t}\n\t\t\tif pji.StatusCode&JOB_STATUS_DELETED != 0 {\n\t\t\t\tpji.Status += \"Deleted, \"\n\t\t\t}\n\t\t\tif pji.StatusCode&JOB_STATUS_BLOCKED_DEVQ != 0 {\n\t\t\t\tpji.Status += \"Driver Error, \"\n\t\t\t}\n\t\t\tif pji.StatusCode&JOB_STATUS_USER_INTERVENTION != 0 {\n\t\t\t\tpji.Status += \"User Action Required, \"\n\t\t\t}\n\t\t\tif pji.StatusCode&JOB_STATUS_RESTART != 0 {\n\t\t\t\tpji.Status += \"Restarted, \"\n\t\t\t}\n\t\t\tif pji.StatusCode&JOB_STATUS_COMPLETE != 0 {\n\t\t\t\tpji.Status += \"Sent to Printer, \"\n\t\t\t}\n\t\t\tif pji.StatusCode&JOB_STATUS_RETAINED != 0 {\n\t\t\t\tpji.Status += \"Retained, \"\n\t\t\t}\n\t\t\tif pji.StatusCode&JOB_STATUS_RENDERING_LOCALLY != 0 {\n\t\t\t\tpji.Status += \"Rendering on Client, \"\n\t\t\t}\n\t\t\tpji.Status = strings.TrimRight(pji.Status, \", \")\n\t\t}\n\t\tpji.Submitted = time.Date(\n\t\t\tint(j.Submitted.Year),\n\t\t\ttime.Month(int(j.Submitted.Month)),\n\t\t\tint(j.Submitted.Day),\n\t\t\tint(j.Submitted.Hour),\n\t\t\tint(j.Submitted.Minute),\n\t\t\tint(j.Submitted.Second),\n\t\t\tint(1000*j.Submitted.Milliseconds),\n\t\t\ttime.Local,\n\t\t).UTC()\n\t\tpjs = append(pjs, pji)\n\t}\n\treturn pjs, nil\n}", "title": "" }, { "docid": "3e95db89a4fee91284e2ca484fc4611a", "score": "0.44317952", "text": "func (jobFinder *JobFinder) List() ([]batchv1.Job, error) {\n\tjobs := make([]batchv1.Job, 0)\n\tfor _, namespace := range jobFinder.GetNamespaces() {\n\t\tnamespaceJobs, err := jobFinder.ListFor(namespace)\n\t\tif err != nil {\n\t\t\treturn jobs, err\n\t\t}\n\t\tjobs = append(jobs, namespaceJobs...)\n\t}\n\treturn jobs, nil\n}", "title": "" }, { "docid": "ce87a70ffc492f085aa672718cddc4cb", "score": "0.44280097", "text": "func main() {\n\tprogramType := flag.String(\"type\", \"\", \"(c) controller, (m) mapper, (s) shuffle, or (r) reducer\")\n\tjob := flag.String(\"job\", \"mapreduce+mapper\", \"job name\")\n\tmapperNum := flag.Int(\"mapperNum\", 5, \"mapperNum\")\n\tWorkerNum := flag.Int(\"WorkerNum\", 5, \"WorkerNum\")\n\treducerNum := flag.Int(\"reducerNum\", 10, \"reducerNum\")\n\t// azureAccountName := flag.String(\"azureAccountName\", \"spluto\", \"azureAccountName\")\n\tazureAccountKey := flag.String(\"azureAccountKey\", \"a\", \"azureAccountKey\")\n\t// outputDir := flag.String(\"outputDir\", \"0newmapreducepathformapreduce000\", \"outputDir\")\n\n\tflag.Parse()\n\tif *job == \"\" {\n\t\tlog.Fatalf(\"Please specify a job name\")\n\t}\n\tif *azureAccountKey == \"\" {\n\t\tlog.Fatalf(\"Please specify azureAccountKey\")\n\t}\n\n\tazureClient := filesystem.NewLocalFSClient()\n\n\tmapperWorkDir := make([]mapreduce.WorkConfig, 0)\n\n\tfor inputM := 1; inputM <= *mapperNum; inputM++ {\n\t\tw := fmt.Sprintf(\"%03d\", inputM+10)\n\t\tinputFile := \"/home/xwu/Desktop/processSentence/mr/example/pagesNew\" + w + \".txt\"\n\t\tnewWork := mapreduce.WorkConfig{}\n\t\tnewWork.InputFilePath = []string{inputFile}\n\t\tnewWork.OutputFilePath = []string{\"./mapreducerprocesstemporaryresult\"}\n\t\tnewWork.UserProgram = []string{\n\t\t\t\"w docker stop mr\" + strconv.Itoa(inputM),\n\t\t\t\"w docker rm mr\" + strconv.Itoa(inputM),\n\t\t\t\"w docker run -d -p \" +\n\t\t\t\tstrconv.Itoa(20000+inputM) +\n\t\t\t\t\":10000 --name=mr\" +\n\t\t\t\tstrconv.Itoa(inputM) +\n\t\t\t\t\" plutoshe/dockerhubautobuild:java\",\n\t\t}\n\n\t\t\n\t\t// newWork.UserProgram = []string{\n\t\t// \t\"b ../sample_user_server_go/processSentence/processSentence_server -type m -port \" + strconv.Itoa(40000+inputM),\n\t\t// }\n\t\t//../sample_mapper_user_program/sample_mapper_server\n\t\t// 192.168.59.103\n\t\tnewWork.UserServerAddress = \"localhost:\" + strconv.Itoa(20000+inputM)\n\t\tnewWork.WorkType = \"Mapper\"\n\t\tnewWork.SupplyContent = []string{\"\"}\n\t\tmapperWorkDir = append(mapperWorkDir, newWork)\n\t}\n\n\tvar ll *log.Logger\n\tll = log.New(os.Stdout, \"\", log.Ldate|log.Ltime|log.Lshortfile)\n\n\tetcdURLs := []string{\"http://localhost:4001\"}\n\n\tmapperConfig := mapreduce.MapreduceConfig{\n\t\tMapperNum: uint64(*mapperNum),\n\t\tReducerNum: uint64(*reducerNum),\n\t\tWorkNum: uint64(*mapperNum),\n\t\tWorkerNum: uint64(*WorkerNum),\n\n\t\tAppName: *job,\n\t\tEtcdURLs: etcdURLs,\n\t\tFilesystemClient: azureClient,\n\t\tWorkDir: mapperWorkDir,\n\t}\n\n\tntask := uint64(*WorkerNum) + 1\n\ttopoMaster := topo.NewFullTopologyOfMaster(uint64(*WorkerNum) + 1)\n\ttopoNeighbors := topo.NewFullTopologyOfNeighbor(uint64(*WorkerNum) + 1)\n\n\tswitch *programType {\n\tcase \"c\":\n\t\tlog.Printf(\"controller\")\n\t\tcontroller := controller.New(mapperConfig.AppName, etcd.NewClient(mapperConfig.EtcdURLs), uint64(ntask), []string{\"Prefix\", \"Suffix\", \"Master\", \"Slave\"})\n\t\tcontroller.Start()\n\t\tcontroller.WaitForJobDone()\n\n\tcase \"t\":\n\t\tlog.Printf(\"mapper task\")\n\t\tbootstrap := framework.NewBootStrap(mapperConfig.AppName, mapperConfig.EtcdURLs, createListener(), ll)\n\t\ttaskBuilder := &mapreduce.MapreduceTaskBuilder{MapreduceConfig: mapperConfig}\n\t\tbootstrap.SetTaskBuilder(taskBuilder)\n\t\tbootstrap.AddLinkage(\"Master\", topoMaster)\n\t\tbootstrap.AddLinkage(\"Neighbors\", topoNeighbors)\n\t\tbootstrap.Start()\n\tdefault:\n\t\tlog.Fatal(\"Please choose a type: (c) controller, (t) task\")\n\t}\n}", "title": "" }, { "docid": "b885feb5d3b8a66dbecf6f279c551f1a", "score": "0.44132614", "text": "func getJibeJobsFor(ctx context.Context, company string) (<-chan *JobPosting, error) {\n\t// Temporarily disable\n\tjobPostings := make(chan *JobPosting)\n\tdefer close(jobPostings)\n\treturn jobPostings, nil\n\n\treq, err := http.NewRequest(\"GET\", fmt.Sprintf(\"https://%s.jibeapply.com/api/jobs\", company), nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create new HTTP request: %w\", err)\n\t}\n\n\treq = req.WithContext(ctx)\n\n\treq.Header.Set(\"Accept-Language\", \"en-US,en;q=0.9\")\n\treq.Header.Set(\"Accept\", \"application/json, text/plain, */*\")\n\n\t// add limit\n\tq := req.URL.Query()\n\t// q.Add(\"limit\", \"100\") no longer respected\n\tq.Add(\"page\", \"1\")\n\treq.URL.RawQuery = q.Encode()\n\n\tresp, err := HTTPClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\tdoc := jibeJobs{}\n\n\terr = json.NewDecoder(resp.Body).Decode(&doc)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tnextBatch := func(doc *jibeJobs, page int) error {\n\t\tq := req.URL.Query()\n\n\t\tq.Set(\"page\", fmt.Sprintf(\"%d\", page))\n\t\treq.URL.RawQuery = q.Encode()\n\n\t\tresp, err := HTTPClient.Do(req)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer resp.Body.Close()\n\n\t\terr = json.NewDecoder(resp.Body).Decode(doc)\n\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t}\n\n\tjobPostings = make(chan *JobPosting)\n\n\tgo func() {\n\t\tdefer close(jobPostings)\n\n\t\tfor _, item := range doc.Jobs {\n\t\t\turl := strings.TrimSpace(strings.Replace(item.Data.ApplyURL, \"http://\", \"https://\", -1))\n\t\t\ttitleStr := strings.TrimSpace(item.Data.Title)\n\t\t\tlocationStr := strings.TrimSpace(item.Data.FullLocation)\n\n\t\t\tif url != \"\" && titleStr != \"\" && locationStr != \"\" {\n\t\t\t\tjobPostings <- &JobPosting{\n\t\t\t\t\tCompany: company,\n\t\t\t\t\tURL: url,\n\t\t\t\t\tTitle: titleStr,\n\t\t\t\t\tLocation: locationStr,\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tfound := len(doc.Jobs)\n\n\t\tfor i := 1; found < doc.TotalCount; i++ {\n\n\t\t\tnextBatch(&doc, i)\n\n\t\t\tfor _, item := range doc.Jobs {\n\t\t\t\turl := strings.TrimSpace(strings.Replace(item.Data.ApplyURL, \"http://\", \"https://\", -1))\n\t\t\t\ttitleStr := strings.TrimSpace(item.Data.Title)\n\t\t\t\tlocationStr := strings.TrimSpace(item.Data.FullLocation)\n\n\t\t\t\tif url != \"\" && titleStr != \"\" && locationStr != \"\" {\n\t\t\t\t\tjobPostings <- &JobPosting{\n\t\t\t\t\t\tCompany: company,\n\t\t\t\t\t\tURL: url,\n\t\t\t\t\t\tTitle: titleStr,\n\t\t\t\t\t\tLocation: locationStr,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfound += len(doc.Jobs)\n\t\t}\n\n\t}()\n\n\treturn jobPostings, nil\n}", "title": "" }, { "docid": "ebcc9e19fc29d12d6a9945b4acc3e23f", "score": "0.44087553", "text": "func CreateOCRKeeperJobs(\n\tt *testing.T,\n\tchainlinkNodes []*client.ChainlinkK8sClient,\n\tregistryAddr string,\n\tchainID int64,\n\tkeyIndex int,\n\tregistryVersion ethereum.KeeperRegistryVersion,\n) {\n\tl := utils.GetTestLogger(t)\n\tbootstrapNode := chainlinkNodes[0]\n\tbootstrapP2PIds, err := bootstrapNode.MustReadP2PKeys()\n\trequire.NoError(t, err, \"Shouldn't fail reading P2P keys from bootstrap node\")\n\tbootstrapP2PId := bootstrapP2PIds.Data[0].Attributes.PeerID\n\n\tvar contractVersion string\n\tif registryVersion == ethereum.RegistryVersion_2_1 {\n\t\tcontractVersion = \"v2.1\"\n\t} else if registryVersion == ethereum.RegistryVersion_2_0 {\n\t\tcontractVersion = \"v2.0\"\n\t} else {\n\t\trequire.FailNow(t, \"v2.0 and v2.1 are the only supported versions\")\n\t}\n\n\tbootstrapSpec := &client.OCR2TaskJobSpec{\n\t\tName: \"ocr2 bootstrap node \" + registryAddr,\n\t\tJobType: \"bootstrap\",\n\t\tOCR2OracleSpec: job.OCR2OracleSpec{\n\t\t\tContractID: registryAddr,\n\t\t\tRelay: \"evm\",\n\t\t\tRelayConfig: map[string]interface{}{\n\t\t\t\t\"chainID\": int(chainID),\n\t\t\t},\n\t\t\tContractConfigTrackerPollInterval: *models.NewInterval(time.Second * 15),\n\t\t},\n\t}\n\t_, err = bootstrapNode.MustCreateJob(bootstrapSpec)\n\trequire.NoError(t, err, \"Shouldn't fail creating bootstrap job on bootstrap node\")\n\tP2Pv2Bootstrapper := fmt.Sprintf(\"%s@%s:%d\", bootstrapP2PId, bootstrapNode.Name(), 6690)\n\n\tfor nodeIndex := 1; nodeIndex < len(chainlinkNodes); nodeIndex++ {\n\t\tnodeTransmitterAddress, err := chainlinkNodes[nodeIndex].EthAddresses()\n\t\trequire.NoError(t, err, \"Shouldn't fail getting primary ETH address from OCR node %d\", nodeIndex+1)\n\t\tnodeOCRKeys, err := chainlinkNodes[nodeIndex].MustReadOCR2Keys()\n\t\trequire.NoError(t, err, \"Shouldn't fail getting OCR keys from OCR node %d\", nodeIndex+1)\n\t\tvar nodeOCRKeyId []string\n\t\tfor _, key := range nodeOCRKeys.Data {\n\t\t\tif key.Attributes.ChainType == string(chaintype.EVM) {\n\t\t\t\tnodeOCRKeyId = append(nodeOCRKeyId, key.ID)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tautoOCR2JobSpec := client.OCR2TaskJobSpec{\n\t\t\tName: \"ocr2 \" + registryAddr,\n\t\t\tJobType: \"offchainreporting2\",\n\t\t\tOCR2OracleSpec: job.OCR2OracleSpec{\n\t\t\t\tPluginType: \"ocr2automation\",\n\t\t\t\tRelay: \"evm\",\n\t\t\t\tRelayConfig: map[string]interface{}{\n\t\t\t\t\t\"chainID\": int(chainID),\n\t\t\t\t},\n\t\t\t\tPluginConfig: map[string]interface{}{\n\t\t\t\t\t\"mercuryCredentialName\": \"\\\"cred1\\\"\",\n\t\t\t\t\t\"contractVersion\": \"\\\"\" + contractVersion + \"\\\"\",\n\t\t\t\t},\n\t\t\t\tContractConfigTrackerPollInterval: *models.NewInterval(time.Second * 15),\n\t\t\t\tContractID: registryAddr, // registryAddr\n\t\t\t\tOCRKeyBundleID: null.StringFrom(nodeOCRKeyId[0]), // get node ocr2config.ID\n\t\t\t\tTransmitterID: null.StringFrom(nodeTransmitterAddress[keyIndex]), // node addr\n\t\t\t\tP2PV2Bootstrappers: pq.StringArray{P2Pv2Bootstrapper}, // bootstrap node key and address <p2p-key>@bootstrap:8000\n\t\t\t},\n\t\t}\n\n\t\t_, err = chainlinkNodes[nodeIndex].MustCreateJob(&autoOCR2JobSpec)\n\t\trequire.NoError(t, err, \"Shouldn't fail creating OCR Task job on OCR node %d err: %+v\", nodeIndex+1, err)\n\t}\n\tl.Info().Msg(\"Done creating OCR automation jobs\")\n}", "title": "" }, { "docid": "a70940f031a71144aab4e97152e72861", "score": "0.44019285", "text": "func (s3Resolver *S3BucketNameToAzureResourcesResolver) addSuffix(name string) string {\n\tsuffixPattern := \"%s-%d\"\n\n\tcount := 2 // start from 2, as there is already an existed resolved name if addSuffix is called\n\tresolvedName := fmt.Sprintf(suffixPattern, name, count)\n\t// S3 has service limitation, that one S3 account can only have 100 buckets, except opening service ticket to increase the number,\n\t// so the loop should finish soon.\n\tfor {\n\t\tif !s3Resolver.hasCollision(resolvedName) {\n\t\t\tbreak\n\t\t}\n\n\t\tif count > 999 {\n\t\t\t// Currently, S3 has 100 for buckets' number per S3 account by default.\n\t\t\t// Considering S3's further extension, adding this defensive logic.\n\t\t\tresolvedName = failToResolveMapValue\n\t\t\tbreak\n\t\t}\n\n\t\tcount++\n\t\tresolvedName = fmt.Sprintf(suffixPattern, name, count)\n\t}\n\treturn resolvedName\n}", "title": "" }, { "docid": "ffd8490867f8c17b46e979f502801fe0", "score": "0.4396234", "text": "func CleanBackupResources(restclient *rest.RESTClient, clientset *kubernetes.Clientset, namespace,\n\tclusterName string) error {\n\n\ttaskName := \"backrest-backup-\" + clusterName\n\t// lookup the pgBackRest backup pgtask for the cluster to determine if it exsits\n\tfound, err := kubeapi.Getpgtask(restclient, &crv1.Pgtask{}, taskName, namespace)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn err\n\t}\n\n\tlog.Debugf(\"pgtask %s found was %t when cleaning backup resources prior to creating a \"+\n\t\t\"new backrest backup pgtask for cluster %s\", taskName, found, clusterName)\n\t// if the pgBackRest backup pgtask was found, then delete it so that a new pgBackRest backup\n\t// pgtask can be created in order to initiate a new backup\n\tif found {\n\t\tlog.Debugf(\"deleting pgtask %s for cluster %s\", taskName, clusterName)\n\t\t// delete the existing pgBackRest backup pgtask\n\t\tif err = kubeapi.Deletepgtask(restclient, taskName, namespace); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t//remove previous backup job\n\tselector := config.LABEL_BACKREST_COMMAND + \"=\" + crv1.PgtaskBackrestBackup + \",\" +\n\t\tconfig.LABEL_PG_CLUSTER + \"=\" + clusterName + \",\" + config.LABEL_BACKREST + \"=true\"\n\terr = kubeapi.DeleteJobs(clientset, selector, namespace)\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n\n\ttimeout := time.After(30 * time.Second)\n\ttick := time.NewTicker(1 * time.Second)\n\tdefer tick.Stop()\n\tfor {\n\t\tselect {\n\t\tcase <-timeout:\n\t\t\treturn fmt.Errorf(\"Timed out waiting for deletion of pgBackRest backup job for \"+\n\t\t\t\t\"cluster %s\", clusterName)\n\t\tcase <-tick.C:\n\t\t\tjobList, err := kubeapi.GetJobs(clientset, selector, namespace)\n\t\t\tif err != nil {\n\t\t\t\tlog.Error(err)\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif len(jobList.Items) == 0 {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "8d16aec9e7afa8fa0cb9dd06659b6887", "score": "0.43858758", "text": "func BatchUpdateServersName(sc *gophercloud.ServiceClient) {\n\topts := cloudservers.BatchUpdateOpts{\n\t\tName: \"test-name\",\n\t\tServers: []cloudservers.Server{\n\t\t\t{ID: \"5a2b0b54-f45f-4144-8ad8-6ccb131b9c57\"},\n\t\t\t{ID: \"b0a9d2b4-2cae-4b66-a6ba-6af70f3bd7f8\"},\n\t\t},\n\t}\n\n\tresp, err := cloudservers.BatchUpdate(sc, opts).ExtractBatchUpdate()\n\tif err != nil {\n\t\tif err1, ok := err.(*cloudservers.BatchOperateError); ok {\n\t\t\tfmt.Println(\"ErrorCode:\", err1.ErrorCode())\n\t\t\tfmt.Println(\"Message:\", err1.Message())\n\t\t\tfmt.Println(\"ErrorInfo:\", err1.Error())\n\t\t}\n\t\tif err2, ok := err.(*gophercloud.UnifiedError); ok {\n\t\t\tfmt.Println(\"ErrorCode:\", err2.ErrorCode())\n\t\t\tfmt.Println(\"Message:\", err2.Message())\n\t\t\tfmt.Println(\"ErrorInfo:\", err2.Error())\n\t\t}\n\t\treturn\n\t}\n\tservers := resp.Response\n\tfor _, server := range servers {\n\t\tfmt.Println(\"the server update name success: \", server.ID)\n\t}\n}", "title": "" }, { "docid": "44bfe59bbe62c6452d799f615efa851e", "score": "0.43845078", "text": "func (s *MSReplicaSet) Delete() error {\n\tselector, err := s.Labels().ToSelector()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfailures := false\n\n\toptions := meta_v1.ListOptions{\n\t\tLabelSelector: selector,\n\t}\n\n\tlog.V(1).Infof(\"Deleting Jobs namespace=%v selector=%v\", s.Job.job.ObjectMeta.Namespace, selector)\n\terr = s.ClientSet.CoreV1().Pods(s.Job.job.ObjectMeta.Namespace).DeleteCollection(&meta_v1.DeleteOptions{}, options)\n\n\tif err != nil {\n\t\tlog.Errorf(\"There was a problem deleting the jobs; %v\", err)\n\t\tfailures = true\n\t}\n\n\t// We need to delete the completed pods.\n\tlog.Infof(\"Deleting Pods namespace=%v selector=%v\", s.Job.job.ObjectMeta.Namespace, selector)\n\terr = s.ClientSet.CoreV1().Pods(s.Job.job.ObjectMeta.Namespace).DeleteCollection(&meta_v1.DeleteOptions{}, options)\n\n\tif err != nil {\n\t\tlog.Errorf(\"There was a problem deleting the pods; %v\", err)\n\t\tfailures = true\n\t}\n\n\t// Services doesn't support DeleteCollection so we delete them individually.\n\tfor index := int32(0); index < *s.Spec.Replicas; index++ {\n\t\tlog.V(1).Infof(\"Deleting Service %v:%v\", s.Job.job.ObjectMeta.Namespace, s.genName((index)))\n\t\terr = s.ClientSet.CoreV1().Services(s.Job.job.ObjectMeta.Namespace).Delete(s.genName(index), &meta_v1.DeleteOptions{})\n\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Error deleting service %v; %v\", s.genName(index), err)\n\t\t\tfailures = true\n\t\t}\n\t}\n\n\t// If the ConfigMap for the default master exists, we delete it\n\tlog.Infof(\"Get ConfigMaps %v:%v\", s.Job.job.ObjectMeta.Namespace, s.defaultMasterConfigMapName())\n\t_, err = s.ClientSet.CoreV1().ConfigMaps(s.Job.job.ObjectMeta.Namespace).Get(s.defaultMasterConfigMapName(), meta_v1.GetOptions{})\n\tif err != nil {\n\t\tif !k8sutil.IsKubernetesResourceNotFoundError(err) {\n\t\t\tlog.Errorf(\"Error deleting ConfigMap %v; %v\", s.defaultMasterConfigMapName(), err)\n\t\t\tfailures = true\n\t\t}\n\t} else {\n\t\tlog.Infof(\"Delete ConfigMaps %v:%v\", s.Job.job.ObjectMeta.Namespace, s.defaultMasterConfigMapName())\n\t\terr = s.ClientSet.CoreV1().ConfigMaps(s.Job.job.ObjectMeta.Namespace).Delete(s.defaultMasterConfigMapName(), &meta_v1.DeleteOptions{})\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"There was a problem deleting the ConfigMaps; %v\", err)\n\t\t\tfailures = true\n\t\t}\n\t}\n\n\tif failures {\n\t\treturn errors.New(\"Some of the replicas resources could not be deleted\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "f60367f957988b631756a533cb2bfb00", "score": "0.43777826", "text": "func PopulatePodHealthCheckJobs() amboy.QueueOperation {\n\treturn func(ctx context.Context, queue amboy.Queue) error {\n\t\tflags, err := evergreen.GetServiceFlags(ctx)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"getting service flags\")\n\t\t}\n\n\t\tif flags.MonitorDisabled {\n\t\t\tgrip.InfoWhen(sometimes.Percent(evergreen.DegradedLoggingPercent), message.Fields{\n\t\t\t\t\"message\": \"monitor is disabled\",\n\t\t\t\t\"impact\": \"not detecting pods that have not communicated recently\",\n\t\t\t\t\"mode\": \"degraded\",\n\t\t\t})\n\t\t\treturn nil\n\t\t}\n\n\t\tpods, err := pod.FindByLastCommunicatedBefore(time.Now().Add(-podReachabilityThreshold))\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"finding pods that have not communicated recently\")\n\t\t}\n\n\t\tcatcher := grip.NewBasicCatcher()\n\t\tfor _, p := range pods {\n\t\t\tj := NewPodHealthCheckJob(p.ID, utility.RoundPartOfMinute(0))\n\t\t\tcatcher.Wrapf(amboy.EnqueueUniqueJob(ctx, queue, j), \"enqueueing pod health check job for pod '%s'\", p.ID)\n\t\t}\n\n\t\treturn catcher.Resolve()\n\t}\n}", "title": "" }, { "docid": "448818a8c7df0bde90ae19e09c77ceee", "score": "0.43743852", "text": "func autofix(*cobra.Command, []string) {\n\tvar toAppend = false\n\n\tresources, err := getKubeResourcesManifest(rootConfig.manifest)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn\n\t}\n\n\tfixedResources, extraResources := fix(resources)\n\n\ttmpFixedFile, err := ioutil.TempFile(\"\", \"kubeaudit_autofix_fixed\")\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n\tdefer os.Remove(tmpFixedFile.Name())\n\ttmpOrigFile, err := ioutil.TempFile(\"\", \"kubeaudit_autofix_orig\")\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n\tdefer os.Remove(tmpOrigFile.Name())\n\tfinalFile, err := ioutil.TempFile(\"\", \"kubeaudit_autofix_final\")\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n\tdefer os.Remove(finalFile.Name())\n\n\tsplitResources, toAppend, err := splitYamlResources(rootConfig.manifest, finalFile.Name())\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n\n\tfor index := range fixedResources {\n\t\terr = WriteToFile(fixedResources[index], tmpFixedFile.Name())\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t}\n\t\terr := ioutil.WriteFile(tmpOrigFile.Name(), splitResources[index], 0644)\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t}\n\t\tfixedYaml, err := mergeYAML(tmpOrigFile.Name(), tmpFixedFile.Name())\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t}\n\n\t\tfixedYaml, err = cleanupManifest(tmpOrigFile.Name(), fixedYaml)\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t}\n\n\t\terr = writeManifestFile(fixedYaml, finalFile.Name(), toAppend)\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t}\n\t\ttoAppend = true\n\t}\n\n\tfor index := range extraResources {\n\t\tinfo, _ := k8sRuntime.SerializerInfoForMediaType(scheme.Codecs.SupportedMediaTypes(), \"application/yaml\")\n\t\tgroupVersion := schema.GroupVersion{Group: extraResources[index].GetObjectKind().GroupVersionKind().Group, Version: extraResources[index].GetObjectKind().GroupVersionKind().Version}\n\t\tencoder := scheme.Codecs.EncoderForVersion(info.Serializer, groupVersion)\n\t\tfixedData, err := k8sRuntime.Encode(encoder, extraResources[index])\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t}\n\t\tfixedData, err = cleanupManifest(\"\", fixedData)\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t}\n\t\terr = writeManifestFile(fixedData, finalFile.Name(), toAppend)\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t}\n\t\ttoAppend = true\n\t}\n\n\tfinalData, err := ioutil.ReadFile(finalFile.Name())\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n\terr = os.Truncate(rootConfig.manifest, 0)\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n\terr = writeManifestFile(finalData, rootConfig.manifest, !isFirstLineSeparatorOrComment(finalFile.Name()))\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n}", "title": "" }, { "docid": "0943914ab70bb61fd16bd4e6645f1b02", "score": "0.43704966", "text": "func TestPatches(t *testing.T) {\n\tf := newKustomizeFixture(t)\n\tkustomizeFile := `# Example configuration for the webserver\n# at https://github.com/monopole/hello\ncommonLabels:\n app: my-hello\n\nresources:\n - deployment.yaml\n - service.yaml\n - configMap.yaml\n\npatches:\n - path: patch.yaml\n target:\n kind: Deployment\n name: foo\n`\n\tf.writeRootKustomize(kustomizeFile)\n\n\texpected := []string{\"kustomization.yaml\", \"deployment.yaml\", \"service.yaml\", \"configMap.yaml\", \"patch.yaml\"}\n\tf.assertDeps(expected)\n}", "title": "" }, { "docid": "4abc26411c47c6d5b6e08fa6a8e67c38", "score": "0.4366075", "text": "func (c *Client) Jobs() (*Jobs, error) {\n\tpayload := &Jobs{}\n\tr, err := c.resty.R().SetResult(&payload).Get(jobs)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif r.IsError() {\n\t\treturn nil, r.Error().(error)\n\t}\n\treturn payload, nil\n}", "title": "" }, { "docid": "9690f55860f2513bc48aa32c4fa3fab6", "score": "0.4358376", "text": "func trainingJobList(client *kubernetes.Clientset) ([]TrainingJob, error) {\n\tuseHelm := true\n\treleaseMap, err := helm.ListReleaseMap()\n\t// log.Printf(\"releaseMap %v\", releaseMap)\n\tif err != nil {\n\t\tlog.Debugf(\"Failed to helm list due to %v\", err)\n\t\tuseHelm = false\n\t}\n\n\ttrainers := NewTrainers(client)\n\tjobs := []TrainingJob{}\n\n\t// 1. search by using helm\n\tif useHelm {\n\t\tfor name, ns := range releaseMap {\n\t\t\tsupportedChart := false\n\t\t\tfor _, trainer := range trainers {\n\t\t\t\tif trainer.IsSupported(name, ns) {\n\t\t\t\t\tjob, err := trainer.GetTrainingJob(name, ns)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Errorf(\"Failed due to %v\", err)\n\t\t\t\t\t\treturn jobs, err\n\t\t\t\t\t}\n\t\t\t\t\tjobs = append(jobs, job)\n\t\t\t\t\tsupportedChart = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif !supportedChart {\n\t\t\t\tlog.Debugf(\"Unknown chart %s\\n\", name)\n\t\t\t}\n\n\t\t}\n\t}\n\n\t// 2. search by using configmap\n\tcms := []types.TrainingJobInfo{}\n\tif allNamespaces {\n\t\tcms, err = kubectl.ListAppConfigMaps(client, metav1.NamespaceAll, knownTrainingTypes)\n\t} else {\n\t\tcms, err = kubectl.ListAppConfigMaps(client, namespace, knownTrainingTypes)\n\t}\n\n\tif err != nil {\n\t\tlog.Errorf(\"Failed due to %v\", err)\n\t\treturn jobs, err\n\t}\n\n\tlog.Debugf(\"job config maps: %v\", cms)\n\n\tfor _, cm := range cms {\n\t\tjob, err := searchTrainingJob(cm.Name, cm.Type, cm.Namespace)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Failed due to %v\", err)\n\t\t\treturn jobs, err\n\t\t}\n\t\tjobs = append(jobs, job)\n\t}\n\n\treturn jobs, nil\n}", "title": "" }, { "docid": "9d64dc86d52475f75da753685799825a", "score": "0.43541694", "text": "func regenJobSummary(fs fileaccess.FileAccess, jobBucket string, jobRootSearchPath string, log logger.ILogger) error {\n\tlog.Printf(logger.LogInfo, \"Fetching objects from %v/%v\", jobBucket, jobRootSearchPath)\n\n\ttheDatasetId, _, err := decodeJobStatusPath(jobRootSearchPath)\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to list jobs in %v/%v: %v\", jobBucket, jobRootSearchPath, err)\n\t\treturn err\n\t}\n\n\tlog.Infof(\"Processing quant jobs for dataset: %v...\", theDatasetId)\n\n\tpaths, err := fs.ListObjects(jobBucket, filepaths.GetJobStatusPath(theDatasetId, \"\")+\"/\")\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to list jobs in %v/%v: %v\", jobBucket, jobRootSearchPath, err)\n\t\treturn err\n\t}\n\n\tallJobs := quantModel.JobSummaryMap{}\n\tnowUnix := time.Now().Unix()\n\n\t// Work out what we need to download to build our summary of all jobs...\n\tconst expEnd = filepaths.JobStatusSuffix\n\n\tstatusPaths := []string{}\n\tparamPaths := []string{}\n\tjobIds := []string{}\n\n\tfor _, thisPath := range paths {\n\t\t// Is this a status file?\n\t\tendBit := thisPath[len(thisPath)-len(expEnd):]\n\t\tif endBit == expEnd {\n\t\t\t// Get job ID\n\t\t\t_, thisJobId, err := decodeJobStatusPath(thisPath)\n\t\t\tif err != nil {\n\t\t\t\tlog.Errorf(\"Error \\\"%v\\\" when decoding path: %v\", err, thisPath)\n\t\t\t} else {\n\t\t\t\t//log.Printf(logger.LogInfo, \"Processing job ID: %v\", thisJobId)\n\n\t\t\t\tstatusPaths = append(statusPaths, thisPath)\n\t\t\t\tparamPaths = append(paramPaths, filepaths.GetJobDataPath(theDatasetId, thisJobId, quantModel.JobParamsFileName))\n\t\t\t\tjobIds = append(jobIds, thisJobId)\n\t\t\t}\n\t\t} else {\n\t\t\tlog.Errorf(\"Unexpected file in status listing: %v. Listing path: %v\", thisPath, \"s3://\"+jobBucket+\"/\"+jobRootSearchPath)\n\t\t}\n\t}\n\n\tvar wg sync.WaitGroup\n\n\t// Functions to download the 2 required files, which get put in their respective channels\n\tstatusCh := make(chan *quantModel.JobStatus, len(statusPaths))\n\tparamCh := make(chan *quantModel.JobStartingParametersWithPMCs, len(paramPaths))\n\n\texpFiles := len(statusPaths) + len(paramPaths)\n\n\twg.Add(expFiles)\n\n\tlog.Printf(logger.LogInfo, \"Fetching %v status files\", len(statusPaths))\n\n\tfor _, item := range statusPaths {\n\t\tfetchStatusFile(&wg, fs, log, jobBucket, item, statusCh)\n\t}\n\n\tlog.Printf(logger.LogInfo, \"Fetching %v param files\", len(paramPaths))\n\n\tfor _, item := range paramPaths {\n\t\tfetchParamFile(&wg, fs, log, jobBucket, item, paramCh)\n\t}\n\n\twg.Wait()\n\tclose(statusCh)\n\tclose(paramCh)\n\n\t// Where we got a pair of non-nils, we can process...\n\tfor c, jobId := range jobIds {\n\t\t// Get each file read...\n\t\tjobStatus := <-statusCh\n\t\tjobParams := <-paramCh\n\n\t\tif jobStatus != nil && jobParams != nil {\n\t\t\tparamPath := paramPaths[c]\n\n\t\t\t// From the params file we should be able to get the dataset path\n\t\t\tif len(jobParams.DatasetPath) <= 0 {\n\t\t\t\tlog.Errorf(\"Found empty dataset path in job params file: %v/%v\", jobBucket, paramPath)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// NOTE: If it's a completed job, and has an output path, and is too old, stop showing it!\n\t\t\t// NOTE2: This is done here and also in the handler for quant job status - because that's used to retrieve quant info from what we generate\n\t\t\t// and if we don't get run, the jobs still sit there... that's the final filter\n\t\t\tif jobStatus.Status == \"complete\" && len(jobStatus.OutputFilePath) > 0 && jobStatus.EndUnixTime != 0 && (nowUnix-jobStatus.EndUnixTime) > maxTimeSecToShowCompleted {\n\t\t\t\tlog.Debugf(\"Skipping completed job id: %v\", jobId)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Store in our list of jobs\n\t\t\t// NOTE: here we're storing a variation of the job starting params... we only store the number of PMCs!\n\t\t\tjobParamSummary := quantModel.MakeJobStartingParametersWithPMCCount(*jobParams)\n\n\t\t\titem := quantModel.JobSummaryItem{\n\t\t\t\tShared: false, // Anything we have here wouldn't be shared!\n\t\t\t\tParams: jobParamSummary,\n\t\t\t\tElements: []string{}, // This job hasn't completed yet, so we don't know what elements it will contain...\n\t\t\t\tJobStatus: jobStatus,\n\t\t\t}\n\n\t\t\tlog.Debugf(\"Found job id: \\\"%v\\\" status is: %v\", jobId, jobStatus.Status)\n\n\t\t\titem = quantModel.SetMissingSummaryFields(item)\n\n\t\t\tallJobs[jobId] = item\n\t\t}\n\t}\n\n\t// Now save the jobs file\n\tsavePath := filepaths.GetJobSummaryPath(theDatasetId)\n\terr = fs.WriteJSON(jobBucket, savePath, allJobs)\n\tif err == nil {\n\t\tlog.Printf(logger.LogInfo, \"Writing %v summary to s3://%v/%v\", len(allJobs), jobBucket, savePath)\n\t}\n\n\treturn err\n}", "title": "" }, { "docid": "ee0066054e1fe9bd70ad89daf26e63e2", "score": "0.43446496", "text": "func (f *Fissile) SerializeJobs() (map[string]interface{}, error) {\n\tif f.Manifest == nil || len(f.Manifest.LoadedReleases) == 0 {\n\t\treturn nil, fmt.Errorf(\"Releases not loaded\")\n\t}\n\n\tjobs := make(map[string]interface{})\n\tfor _, release := range f.Manifest.LoadedReleases {\n\t\tfor _, job := range release.Jobs {\n\t\t\tjobs[job.Fingerprint] = util.NewMarshalAdapter(job)\n\t\t}\n\t}\n\treturn jobs, nil\n}", "title": "" }, { "docid": "12f83819b8d5f7a50b85ebe34c94d75e", "score": "0.43440387", "text": "func ScanAllJobs() error {\n\t// Clean Cron entries\n\tLogger.Println(\"Cleaning all cron entries...\")\n\tfor _, entry := range GlobalCron.Entries() {\n\t\tGlobalCron.Remove(entry.ID)\n\t}\n\tfiles, _ := filepath.Glob(Config.JobDir + \"*\" + Config.jobsExt)\n\tfor _, f := range files {\n\t\tjob, err := CreateJobFromFile(f)\n\t\tif err != nil {\n\t\t\tLogger.Println(err)\n\t\t\tcontinue\n\t\t}\n\t\terr = DB.Update(func(tx *bolt.Tx) error {\n\t\t\tjobsBucket := tx.Bucket(JobsBucket)\n\n\t\t\tjb, err := jobsBucket.CreateBucketIfNotExists([]byte(job.Name))\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tparamsB, err := json.Marshal(job.DefaultParams)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\terr = jb.Put([]byte(\"defaultParams\"), paramsB)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\terr = jb.Put([]byte(\"desc\"), []byte(job.Desc))\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\terr = jb.Put([]byte(\"interval\"), []byte(job.Interval))\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tisActive := jb.Get([]byte(\"active\"))\n\t\t\tif isActive == nil {\n\t\t\t\terr = jb.Put([]byte(\"active\"), []byte(\"true\"))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t\tif err != nil {\n\t\t\tLogger.Println(err)\n\t\t\tcontinue\n\t\t}\n\t\terr = job.AddToCron()\n\t\tif err != nil {\n\t\t\tLogger.Println(err)\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "a0398e98a7ab46fe6534b4e8b229c291", "score": "0.43403354", "text": "func newConfigMapWithSuffix(suffix string, cr *argoprojv1a1.ArgoCD) *corev1.ConfigMap {\n\treturn newConfigMapWithName(fmt.Sprintf(\"%s-%s\", cr.ObjectMeta.Name, suffix), cr)\n}", "title": "" }, { "docid": "37c1cff9ef1b8b18064e5fe21c43b43b", "score": "0.4338874", "text": "func DefaultTagSuffix(ref, suffix string) ([]string, error) {\n\ttags, err := DefaultTags(ref)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(suffix) == 0 {\n\t\treturn tags, nil\n\t}\n\tfor i, tag := range tags {\n\t\tif tag == \"latest\" {\n\t\t\ttags[i] = suffix\n\t\t} else {\n\t\t\ttags[i] = fmt.Sprintf(\"%s-%s\", tag, suffix)\n\t\t}\n\t}\n\treturn tags, nil\n}", "title": "" }, { "docid": "d4d5691128a60d0e78ef1e1994086213", "score": "0.43362787", "text": "func (m *Mockstore) ListJobs(appName string) ([]*config.Workload, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ListJobs\", appName)\n\tret0, _ := ret[0].([]*config.Workload)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "d6df45b87adbe0bc689276e67a0e163d", "score": "0.43336457", "text": "func Example_lookupAllBySuffix() {\n\n\tcfg := Config{\n\t\tIncludes: \".includes\",\n\t\tLayouts: \".layouts\",\n\t\tPages: \"not_used\",\n\t\tExt: \".html\",\n\t\tDefLayout: \"lay\",\n\t\tUseSuffix: true,\n\t}\n\t// Here we create a temporary directory and populate it with our sample\n\t// template definition files; usually the template files would already\n\t// exist in some location known to the program.\n\tdir := createTestDir(cfg.Ext, []templateFile{\n\t\t{[]string{}, \"inc.includes\", `inc1 here`},\n\t\t{[]string{\"subdir1\"}, \"inc.includes\", `inc2 here`},\n\t\t{[]string{}, \"lay.layouts\", `lay1 here`},\n\t\t{[]string{\"subdir2\"}, \"lay.layouts\", `lay2 here`},\n\t\t{[]string{}, \"page\", `page1 here`},\n\t\t{[]string{\"subdir3\"}, \"page\", `page2 here`},\n\t})\n\t// Clean up after the test; another quirk of running as an example.\n\tdefer os.RemoveAll(dir)\n\n\tcfg.Root = dir\n\tfs := New(cfg)\n\terr := fs.LookupAll()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Printf(\"includes: %v\\n\", fs.IncludeNames())\n\tfmt.Printf(\"layouts: %v\\n\", fs.LayoutNames())\n\tfmt.Printf(\"pages: %v\\n\", fs.PageNames(false))\n\t// Output:\n\t// includes: [inc subdir1/inc]\n\t// layouts: [lay subdir2/lay]\n\t// pages: [page subdir3/page]\n}", "title": "" }, { "docid": "5f5cd79ebd561d1ba207d1348b46372e", "score": "0.4327589", "text": "func (c *Client) ListAllJobNames(begin, end time.Time) ([]string, error) {\n\tresults, err := c.issueQuery(\"count by (job) (cicd_jUnitResult)\", begin, end)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing all jobs: %v\", err)\n\t}\n\n\tjobNames := []string{}\n\n\tif matrixResults, ok := results.(model.Matrix); ok {\n\t\tfor _, sample := range matrixResults {\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error getting job name from sample: %v\", err)\n\t\t\t}\n\t\t\tjobNames = append(jobNames, extractMetricFromSample(sample, \"job\"))\n\t\t}\n\t} else {\n\t\treturn nil, fmt.Errorf(\"unrecognized result type: %v\", reflect.TypeOf(results))\n\t}\n\n\treturn sort.StringSlice(jobNames), nil\n}", "title": "" }, { "docid": "53aec297bcdf463d16b9622e44ce129c", "score": "0.4327012", "text": "func (rsc *RunCatalog) updateRunJobs(\n\tjsState JobServiceState,\n\tcomputeState map[string]computeItem,\n\tqueueJobs map[string]queueJobFile,\n\tactiveJobs map[string]runJobFile,\n\thistoryJobs map[string]historyJobFile,\n) *jobControlState {\n\n\trsc.rscLock.Lock()\n\tdefer rsc.rscLock.Unlock()\n\n\tjNextPos := rsc.jobLastPosition\n\n\trsc.JobServiceState = jsState\n\n\tif rsc.jobLastPosition < jNextPos {\n\t\trsc.jobLastPosition = jNextPos\n\t}\n\n\t// copy state of computational resources\n\tfor name := range rsc.computeState {\n\t\t_, ok := computeState[name]\n\t\tif !ok {\n\t\t\tdelete(rsc.computeState, name) // remove: server or cluster not does exist anymore\n\t\t}\n\t}\n\tfor name, cs := range computeState {\n\t\tif cs.lastUsedTs < rsc.computeState[name].lastUsedTs {\n\t\t\tcs.lastUsedTs = rsc.computeState[name].lastUsedTs\n\t\t}\n\t\trsc.computeState[name] = cs\n\t}\n\n\t// update queue jobs and collect all new submission stamps\n\tfor stamp := range rsc.queueJobs {\n\t\tjf, ok := queueJobs[stamp]\n\t\tif !ok || jf.isError {\n\t\t\tdelete(rsc.queueJobs, stamp) // remove: job file not exists\n\t\t}\n\t}\n\n\tfor stamp, jf := range queueJobs {\n\t\tif _, ok := rsc.models[jf.ModelDigest]; !ok {\n\t\t\tcontinue // skip: model digest is not the models list\n\t\t}\n\t\tif jf.isError {\n\t\t\tcontinue // skip: model job error\n\t\t}\n\t\trsc.queueJobs[stamp] = jf\n\t}\n\n\t// remove queue submission stamps which are no longer exists in the queue\n\tn := 0\n\tfor _, stamp := range rsc.queueKeys {\n\t\tif _, ok := queueJobs[stamp]; ok {\n\t\t\trsc.queueKeys[n] = stamp\n\t\t\tn++\n\t\t}\n\t}\n\trsc.queueKeys = rsc.queueKeys[:n]\n\n\t// find new submission stamps from the queue\n\tn = len(queueJobs) - n\n\tif n > 0 {\n\n\t\tqKeys := make([]string, n)\n\t\tk := 0\n\t\tfor stamp := range queueJobs {\n\n\t\t\tisFound := false\n\t\t\tfor j := 0; !isFound && j < len(rsc.queueKeys); j++ {\n\t\t\t\tisFound = rsc.queueKeys[j] == stamp\n\t\t\t}\n\t\t\tif !isFound {\n\t\t\t\tqKeys[k] = stamp\n\t\t\t\tk++\n\t\t\t}\n\t\t}\n\n\t\t// sort new jobs by time stamps: first come first served and append at the end of existing queue\n\t\tsort.Strings(qKeys)\n\t\trsc.queueKeys = append(rsc.queueKeys, qKeys...)\n\t}\n\n\t// update active model run jobs\n\tfor stamp := range rsc.activeJobs {\n\t\tjf, ok := activeJobs[stamp]\n\t\tif !ok || jf.isError {\n\t\t\tdelete(rsc.activeJobs, stamp) // remove: job file not exists\n\t\t}\n\t}\n\n\tfor stamp, jf := range activeJobs {\n\t\tif _, ok := rsc.models[jf.ModelDigest]; !ok {\n\t\t\tcontinue // skip: model digest is not the models list\n\t\t}\n\t\tif jf.isError {\n\t\t\tcontinue // skip: model job error or\n\t\t}\n\t\trsc.activeJobs[stamp] = jf\n\t}\n\n\t// update model run job history\n\tfor stamp := range rsc.historyJobs {\n\t\tjh, ok := historyJobs[stamp]\n\t\tif !ok || jh.isError {\n\t\t\tdelete(rsc.historyJobs, stamp) // remove: job file not exist\n\t\t}\n\t}\n\n\tfor stamp, jh := range historyJobs {\n\t\tif !jh.isError {\n\t\t\trsc.historyJobs[stamp] = jh\n\t\t}\n\t}\n\n\t// cleanup selected to run jobs list: remove if submission stamp not exist in queue files list\n\tn = 0\n\tfor _, stamp := range rsc.selectedKeys {\n\t\tif _, ok := queueJobs[stamp]; ok {\n\t\t\trsc.selectedKeys[n] = stamp // job file still exist in the queue\n\t\t\tn++\n\t\t}\n\t}\n\trsc.selectedKeys = rsc.selectedKeys[:n]\n\n\t// return job control state\n\tjsc := jobControlState{\n\t\tQueue: make([]string, len(rsc.queueKeys)),\n\t}\n\tcopy(jsc.Queue, rsc.queueKeys)\n\n\treturn &jsc\n}", "title": "" }, { "docid": "97dae53a7a742a0a51806f4bf0802ed0", "score": "0.4319854", "text": "func enqueueDemoJobs(payLoad *PayLoad) {\n emailNotifier := Job{Name:\"SendEmailJob\", JobPayload:*payLoad, JobProcessor: SendEmailJob}\n\n updateDatabaseJob := Job{Name:\"UpdateDatabaseJobStatus\", JobPayload:*payLoad, JobProcessor: UpdateDatabaseJobStatus}\n\n workSpaceCleaner := Job{Name:\"CleanUpWorkspace\", JobPayload:*payLoad, JobProcessor: CleanUpWorkspaceJob}\n\n cloudUploader := Job{Name:\"UploadJob\", JobPayload:*payLoad, JobProcessor: S3UploadJob,\n NextParallelJobs: []*Job{&workSpaceCleaner, &updateDatabaseJob, &emailNotifier}}\n\n heavyComputer := Job{Name:\"HeavyComputationJob\", JobPayload:*payLoad, JobProcessor: HeavyComputationJob,\n NextParallelJobs: []*Job{&cloudUploader}}\n\n preProcessor := Job{Name:\"PreProcessor\", JobPayload:*payLoad,\n JobProcessor: PreprocessingJob, NextParallelJobs: []*Job{&heavyComputer} }\n\n JobQueue <- preProcessor\n}", "title": "" }, { "docid": "1611a25f1ace5e5b10772a367353594f", "score": "0.43071115", "text": "func DeleteJobs(clientset *kubernetes.Clientset, selector, namespace string) error {\n\tlog.Debugf(\"deleting Jobs with selector=%s in namespace %s\", selector, namespace)\n\n\t//delete the job\n\tdelOptions := meta_v1.DeleteOptions{}\n\tvar delProp meta_v1.DeletionPropagation\n\tdelProp = meta_v1.DeletePropagationForeground\n\tdelOptions.PropagationPolicy = &delProp\n\n\tlo := meta_v1.ListOptions{LabelSelector: selector}\n\n\terr := clientset.Batch().Jobs(namespace).DeleteCollection(&delOptions, lo)\n\tif err != nil {\n\t\tlog.Error(\"error deleting Jobs \" + selector + err.Error())\n\t\treturn err\n\t}\n\n\treturn err\n}", "title": "" }, { "docid": "96363c8dadf688a692134fefd4ad5ede", "score": "0.43036968", "text": "func DoReduce(job int, fileName string, nmap int,\n\tReduce func(string, *list.List) string) {\n\tkvs := make(map[string]*list.List)\n\tfor i := 0; i < nmap; i++ {\n\t\tname := ReduceName(fileName, i, job)\n\t\tfmt.Printf(\"DoReduce: read %s\\n\", name)\n\t\tfile, err := os.Open(name)\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"DoReduce: \", err)\n\t\t}\n\t\tdec := json.NewDecoder(file)\n\t\tfor {\n\t\t\tvar kv KeyValue\n\t\t\terr = dec.Decode(&kv)\n\t\t\tif err != nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\t_, ok := kvs[kv.Key]\n\t\t\tif !ok {\n\t\t\t\tkvs[kv.Key] = list.New()\n\t\t\t}\n\t\t\tkvs[kv.Key].PushBack(kv.Value)\n\t\t}\n\t\tfile.Close()\n\t}\n\tvar keys []string\n\tfor k := range kvs {\n\t\tkeys = append(keys, k)\n\t}\n\tsort.Strings(keys)\n\tp := MergeName(fileName, job)\n\tfile, err := os.Create(p)\n\tif err != nil {\n\t\tlog.Fatal(\"DoReduce: create \", err)\n\t}\n\tenc := json.NewEncoder(file)\n\tfor _, k := range keys {\n\t\tres := Reduce(k, kvs[k])\n\t\tenc.Encode(KeyValue{k, res})\n\t}\n\tfile.Close()\n}", "title": "" }, { "docid": "9d903e1384c114150c6beb1687d0a5ae", "score": "0.42942697", "text": "func (s *queueJobLister) QueueJobs(namespace string) QueueJobNamespaceLister {\n\treturn queueJobNamespaceLister{indexer: s.indexer, namespace: namespace}\n}", "title": "" }, { "docid": "aedabddab13e9be900739c2329ab2ff9", "score": "0.42872056", "text": "func (d *Dispatcher) deployJobs() {\n\tfor {\n\t\tif d.GetWorkerPQ().getPQ().Empty() == false {\n\t\t\tif d.GetJobPQ().GetPQ().Empty() == false {\n\t\t\t\td.mu.Lock()\n\t\t\t\tw := d.GetWorkerPQ().Pop()\n\t\t\t\tif !d.GetWorker(w).GetShut() {\n\t\t\t\t\tj := d.GetJobPQ().Pop()\n\t\t\t\t\tif j.GetExec().GetStatus() != job.CANCELLED {\n\t\t\t\t\t\tj.GetExec().SetBy(d.GetWorker(w).GetPub())\n\t\t\t\t\t\td.GetWorker(w).Assign(&j)\n\t\t\t\t\t\tglg.Info(\"P2P: dispatched job\")\n\t\t\t\t\t\tw.Write(JobMessage(j.Serialize(), d.GetPrivByte()))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tj.ResultsChan() <- j\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tdelete(d.GetWorkers(), w)\n\t\t\t\t}\n\t\t\t\td.mu.Unlock()\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "f282d4fde44005fadbda0a280e5d3777", "score": "0.42775312", "text": "func (b *DataClassificationServiceRequestBuilder) Jobs() *DataClassificationServiceJobsCollectionRequestBuilder {\n\tbb := &DataClassificationServiceJobsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}\n\tbb.baseURL += \"/jobs\"\n\treturn bb\n}", "title": "" }, { "docid": "dd0d0d7d54f49f39f74f14d6493821bc", "score": "0.4273179", "text": "func TestGetNextJobs(t *testing.T) {\n\ttestingSetUp()\n\tdefer testingTeardown()\n\n\t// Create a test job with high priority\n\thighPriorityJob, err := createTestJob()\n\tif err != nil {\n\t\tt.Fatalf(\"Unexpected error creating test job: %s\", err.Error())\n\t}\n\thighPriorityJob.priority = 1000\n\thighPriorityJob.id = \"highPriorityJob\"\n\tif err := highPriorityJob.save(); err != nil {\n\t\tt.Fatalf(\"Unexpected error saving test job: %s\", err.Error())\n\t}\n\tif err := highPriorityJob.enqueue(); err != nil {\n\t\tt.Fatalf(\"Unexpected error enqueuing test job: %s\", err.Error())\n\t}\n\n\t// Create more tests with lower priorities\n\tfor i := 0; i < 10; i++ {\n\t\tjob, err := createTestJob()\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"Unexpected error creating test job: %s\", err.Error())\n\t\t}\n\t\tjob.priority = 100\n\t\tjob.id = \"lowPriorityJob\" + strconv.Itoa(i)\n\t\tif err := job.save(); err != nil {\n\t\t\tt.Fatalf(\"Unexpected error saving test job: %s\", err.Error())\n\t\t}\n\t\tif err := job.enqueue(); err != nil {\n\t\t\tt.Fatalf(\"Unexpected error enqueuing test job: %s\", err.Error())\n\t\t}\n\t}\n\n\t// Call getNextJobs with n = 1. We expect the one job returned to be the\n\t// highpriority one, but the status should now be executing\n\ttestPoolId := \"testPool\"\n\tjobs, err := getNextJobs(1, testPoolId)\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error from getNextJobs: %s\", err.Error())\n\t}\n\tif len(jobs) != 1 {\n\t\tt.Errorf(\"Length of jobs was incorrect. Expected 1 but got %d\", len(jobs))\n\t} else {\n\t\tgotJob := jobs[0]\n\t\texpectedJob := &Job{}\n\t\t(*expectedJob) = *highPriorityJob\n\t\texpectedJob.status = StatusExecuting\n\t\texpectedJob.poolId = testPoolId\n\t\tif !reflect.DeepEqual(expectedJob, gotJob) {\n\t\t\tt.Errorf(\"Job returned by getNextJobs was incorrect.\\n\\tExpected: %+v\\n\\tBut got: %+v\", expectedJob, gotJob)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "b6424b521eed8d29926f0885a684f5be", "score": "0.4271754", "text": "func (client BatchServiceClient) ListJobs(ctx context.Context, request ListJobsRequest) (response ListJobsResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif client.RetryPolicy() != nil {\n\t\tpolicy = *client.RetryPolicy()\n\t}\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\tociResponse, err = common.Retry(ctx, request, client.listJobs, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = ListJobsResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = ListJobsResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(ListJobsResponse); ok {\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into ListJobsResponse\")\n\t}\n\treturn\n}", "title": "" }, { "docid": "8f33704e5a490d683d527a44533b0272", "score": "0.42589542", "text": "func ReadResources(prefix string, content io.Reader, resLabels map[string]string) ([]v1alpha1.KubernetesApplicationResourceTemplate, error) {\n\tvar result []v1alpha1.KubernetesApplicationResourceTemplate\n\td := kyaml.NewYAMLOrJSONDecoder(content, 4096)\n\tfor {\n\t\tobj := &unstructured.Unstructured{}\n\t\tif err := d.Decode(obj); err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn result, err\n\t\t}\n\t\t// Ignore empty objects\n\t\tif obj.GetName() == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tkart := v1alpha1.KubernetesApplicationResourceTemplate{\n\t\t\tObjectMeta: v1.ObjectMeta{\n\t\t\t\t// Ensure no collisions among templates in KubernetesApplications\n\t\t\t\tName: fmt.Sprintf(\"%s-%s-%s\", prefix, strings.ReplaceAll(obj.GetName(), \":\", \"-\"), strings.ToLower(obj.GetKind())),\n\t\t\t\tLabels: resLabels,\n\t\t\t},\n\t\t\tSpec: v1alpha1.KubernetesApplicationResourceSpec{\n\t\t\t\tTemplate: obj,\n\t\t\t},\n\t\t}\n\t\tresult = append(result, kart)\n\t}\n\treturn result, nil\n}", "title": "" }, { "docid": "376ac38eaff06aec2a2a4019f77ddddd", "score": "0.42588538", "text": "func newConfigMap(mpiJob *kubeflow.MPIJob, workerReplicas int32) *corev1.ConfigMap {\n\t// This part closely related to specific ssh commands.\n\t// It is very likely to fail due to the version change of the MPI framework.\n\t// Attempt to automatically filter prefix parameters by detecting \"-\" matches.\n\t// In order to enable IntelMPI and MVAPICH2 to parse pod names, in the Init container,\n\t// a hosts file containing all workers is generated based on the pods list.\n\t// Will use kubectl to send it to the workers and append it to the end of the original hosts file.\n\tkubexec := fmt.Sprintf(`#!/bin/sh\nset -x\nPOD_NAME=$1\nwhile [ ${POD_NAME%%${POD_NAME#?}} = \"-\" ]\ndo\nshift\nPOD_NAME=$1\ndone\nshift\n%s/kubectl cp %s/hosts ${POD_NAME}:/etc/hosts_of_nodes\n%s/kubectl exec ${POD_NAME}`, kubectlMountPath, kubectlMountPath, kubectlMountPath)\n\tif len(mpiJob.Spec.MainContainer) > 0 {\n\t\tkubexec = fmt.Sprintf(\"%s --container %s\", kubexec, mpiJob.Spec.MainContainer)\n\t}\n\tkubexec = fmt.Sprintf(\"%s -- /bin/sh -c \\\"cat /etc/hosts_of_nodes >> /etc/hosts && $*\\\"\", kubexec)\n\n\t// If no processing unit is specified, default to 1 slot.\n\tslots := 1\n\tif mpiJob.Spec.SlotsPerWorker != nil {\n\t\tslots = int(*mpiJob.Spec.SlotsPerWorker)\n\t}\n\tvar buffer bytes.Buffer\n\t// For the different MPI frameworks, the format of the hostfile file is inconsistent.\n\t// For Intel MPI and MVAPICH2, use \":\" syntax to indicate how many operating slots the current node has.\n\t// But for Open MPI, use \"slots=\" syntax to achieve this function.\n\tfor i := 0; i < int(workerReplicas); i++ {\n\t\tmpiDistribution := mpiJob.Spec.MPIDistribution\n\t\tif mpiDistribution != nil && (*mpiDistribution == kubeflow.MPIDistributionTypeIntelMPI || *mpiDistribution == kubeflow.MPIDistributionTypeMPICH) {\n\t\t\tbuffer.WriteString(fmt.Sprintf(\"%s%s-%d:%d\\n\", mpiJob.Name, workerSuffix, i, slots))\n\t\t} else {\n\t\t\tbuffer.WriteString(fmt.Sprintf(\"%s%s-%d slots=%d\\n\", mpiJob.Name, workerSuffix, i, slots))\n\t\t}\n\t}\n\n\treturn &corev1.ConfigMap{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: mpiJob.Name + configSuffix,\n\t\t\tNamespace: mpiJob.Namespace,\n\t\t\tLabels: map[string]string{\n\t\t\t\t\"app\": mpiJob.Name,\n\t\t\t},\n\t\t\tOwnerReferences: []metav1.OwnerReference{\n\t\t\t\t*metav1.NewControllerRef(mpiJob, kubeflow.SchemeGroupVersionKind),\n\t\t\t},\n\t\t},\n\t\tData: map[string]string{\n\t\t\thostfileName: buffer.String(),\n\t\t\tkubexecScriptName: kubexec,\n\t\t},\n\t}\n}", "title": "" }, { "docid": "862affd77b6e817844a6c7feebeaddae", "score": "0.425779", "text": "func DownloadJobsUpstream(lg *zap.Logger) (dir string, paths []string, err error) {\n\thttp.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}\n\tu := \"https://github.com/kubernetes/test-infra/archive/master.zip\"\n\tlg.Info(\"downloading\", zap.String(\"url\", u))\n\n\tvar resp *http.Response\n\tresp, err = http.Get(u)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\tvar d []byte\n\td, err = ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\tresp.Body.Close()\n\tlg.Info(\"downloaded\", zap.String(\"url\", u))\n\n\tvar f *os.File\n\tf, err = ioutil.TempFile(os.TempDir(), \"git-test-ekstest\")\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\tp := f.Name()\n\tos.RemoveAll(p)\n\tdefer os.RemoveAll(p)\n\tif err = ioutil.WriteFile(p, d, os.ModePerm); err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\tdir, err = ioutil.TempDir(os.TempDir(), \"git-test-dir-ekstest\")\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\tos.RemoveAll(dir)\n\n\tif err = unzip(lg, p, dir); err != nil {\n\t\treturn \"\", nil, err\n\t}\n\tdir = filepath.Join(dir, \"test-infra-master\")\n\n\t// https://github.com/kubernetes/test-infra/blob/master/prow/config.yaml\n\t// but this is being moved to \"config/jobs/*\"\n\t// see https://github.com/kubernetes/test-infra/issues/8485\n\tcp := filepath.Join(dir, \"prow/config.yaml\")\n\tif fileutil.Exist(cp) {\n\t\tpaths = []string{cp}\n\t}\n\n\t// https://github.com/kubernetes/test-infra/tree/master/config/jobs\n\t// ref. https://github.com/kubernetes/test-infra/issues/8485\n\tvisit := func(path string, f os.FileInfo, err error) error {\n\t\tif f == nil {\n\t\t\treturn nil\n\t\t}\n\t\tif f.IsDir() {\n\t\t\treturn nil\n\t\t}\n\t\tif filepath.Ext(path) == \".yaml\" {\n\t\t\tpaths = append(paths, path)\n\t\t}\n\t\treturn nil\n\t}\n\tif err := filepath.Walk(filepath.Join(dir, \"config/jobs\"), visit); err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\tlg.Info(\"fetched all prow config files\", zap.Int(\"jobs\", len(paths)), zap.String(\"dir\", dir))\n\treturn dir, paths, nil\n}", "title": "" }, { "docid": "12b6abf97f5d57db964b27380b7a6a6f", "score": "0.4256494", "text": "func SyncKubeBinaries(runtime connector.Runtime, binariesMap map[string]*files.KubeBinary) error {\n\tif err := utils.ResetTmpDir(runtime); err != nil {\n\t\treturn err\n\t}\n\n\tbinaryList := []string{\"k8e\", \"helm\", \"kubecni\"}\n\tfor _, name := range binaryList {\n\t\tbinary, ok := binariesMap[name]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"get kube binary %s info failed: no such key\", name)\n\t\t}\n\n\t\tfileName := binary.FileName\n\t\tswitch name {\n\t\tcase \"kubecni\":\n\t\t\tdst := filepath.Join(common.TmpDir, fileName)\n\t\t\tif err := runtime.GetRunner().Scp(binary.Path(), dst); err != nil {\n\t\t\t\treturn errors.Wrap(errors.WithStack(err), fmt.Sprintf(\"sync kube binaries failed\"))\n\t\t\t}\n\t\t\tif _, err := runtime.GetRunner().SudoCmd(fmt.Sprintf(\"tar -zxf %s -C /opt/cni/bin\", dst), false); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tdefault:\n\t\t\tdst := filepath.Join(common.BinDir, fileName)\n\t\t\tif err := runtime.GetRunner().SudoScp(binary.Path(), dst); err != nil {\n\t\t\t\treturn errors.Wrap(errors.WithStack(err), fmt.Sprintf(\"sync kube binaries failed\"))\n\t\t\t}\n\t\t\tif _, err := runtime.GetRunner().SudoCmd(fmt.Sprintf(\"chmod +x %s\", dst), false); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tbinaries := []string{\"kubectl\", \"crictl\", \"ctr\"}\n\tvar createLinkCMDs []string\n\tfor _, binary := range binaries {\n\t\tcreateLinkCMDs = append(createLinkCMDs, fmt.Sprintf(\"ln -snf /usr/local/bin/k8e /usr/local/bin/%s\", binary))\n\t}\n\tif _, err := runtime.GetRunner().SudoCmd(strings.Join(createLinkCMDs, \" && \"), false); err != nil {\n\t\treturn errors.Wrap(errors.WithStack(err), \"create ctl tool link failed\")\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "f19a9478f9175a20c333a113c0dafea4", "score": "0.42442596", "text": "func GenerateJobsetInputs(inputs []configuration.Input, branchName string) map[string]JobsetInput {\n\tresult := make(map[string]JobsetInput)\n\n\tfor _, input := range inputs {\n\t\tresult[input.Name] = JobsetInput{\n\t\t\tType: input.Type,\n\t\t\tValue: strings.Replace(input.Value, \"${BRANCH_NAME}\", branchName, 1),\n\t\t}\n\t}\n\n\treturn result\n}", "title": "" }, { "docid": "6d4c917f552f72d6d4fb4decedea3464", "score": "0.42436802", "text": "func (b Bucket) CommonAddressSuffix() string {\n\tinput := []string{}\n\tfor _, n := range b.Nodes() {\n\t\tinput = append(input, n.Hostname)\n\t}\n\treturn FindCommonSuffix(input)\n}", "title": "" }, { "docid": "8f348e91f966b30297d56dc2b55df7a3", "score": "0.42424005", "text": "func (j *JobReference) WriteConfigs(instanceGroup *InstanceGroup, lightOpinionsPath, darkOpinionsPath string) ([]byte, error) {\n\tvar config struct {\n\t\tJob struct {\n\t\t\tName string `json:\"name\"`\n\t\t} `json:\"job\"`\n\t\tParameters map[string]string `json:\"parameters\"`\n\t\tProperties map[string]interface{} `json:\"properties\"`\n\t\tNetworks struct {\n\t\t\tDefault map[string]string `json:\"default\"`\n\t\t} `json:\"networks\"`\n\t\tExportedProperties []string `json:\"exported_properties\"`\n\t\tConsumes map[string]jobLinkInfo `json:\"consumes\"`\n\t}\n\n\tconfig.Parameters = make(map[string]string)\n\tconfig.Properties = make(map[string]interface{})\n\tconfig.Networks.Default = make(map[string]string)\n\tconfig.ExportedProperties = make([]string, 0)\n\tconfig.Consumes = make(map[string]jobLinkInfo)\n\n\tconfig.Job.Name = instanceGroup.Name\n\n\tfor _, consumer := range j.ResolvedConsumers {\n\t\tconfig.Consumes[consumer.Name] = consumer.jobLinkInfo\n\t}\n\n\topinions, err := NewOpinions(lightOpinionsPath, darkOpinionsPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tproperties, err := j.Job.GetPropertiesForJob(opinions)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tconfig.Properties = properties\n\n\tfor _, provider := range j.Job.AvailableProviders {\n\t\tconfig.ExportedProperties = append(config.ExportedProperties, provider.Properties...)\n\t}\n\n\t// Write out the configuration\n\treturn json.MarshalIndent(config, \"\", \" \") // 4-space indent\n}", "title": "" }, { "docid": "77fb0c8dce5474f417023685bbd2696f", "score": "0.42354256", "text": "func Worker(mapf func(string, string) []KeyValue,\n\treducef func(string, []string) string) {\n\n\t// Your worker implementation here.\n\n\tworker_id := os.Getpid()\n\n\ttask := Task{}\n\tnReduce := 0\n\n\tfor {\n\t\tAskForTask(worker_id, &task, &nReduce)\n\t\t// Simulating process\n\t\t//time.Sleep(1 * time.Second)\n\n\t\t// Real execution\n\t\tif task.Type == \"Map\" && len(task.Files) == 1 {\n\t\t\tfile, err := os.Open(task.Files[0])\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatalf(\"cannot open %v\", task.Files[0])\n\t\t\t}\n\t\t\tcontent, err := ioutil.ReadAll(file)\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatalf(\"cannot read %v\", task.Files[0])\n\t\t\t}\n\t\t\tfile.Close()\n\t\t\tkva := mapf(task.Files[0], string(content))\n\n\t\t\tvar out_files []*os.File\n\t\t\tvar encoders []*json.Encoder\n\t\t\tfor i := 0; i < nReduce; i += 1 {\n\t\t\t\t// Leave file name empty here, then rename the whole name afterwards.\n\t\t\t\ttmp_file, err := ioutil.TempFile(\"\", \"\")\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Fatalf(\"cannot create temp file\")\n\t\t\t\t}\n\t\t\t\tout_files = append(out_files, tmp_file)\n\t\t\t\t//out_files[i] = ioutil.TempFile(\"\", filename)\n\t\t\t\tencoders = append(encoders, json.NewEncoder(tmp_file))\n\t\t\t\t//encoders[i] = json.NewEncoder(out_files[i])\n\t\t\t}\n\n\t\t\tfor _, kv := range(kva) {\n\t\t\t\tidx := ihash(kv.Key) % nReduce\n\t\t\t\tif err := encoders[idx].Encode(&kv); err != nil {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Leave temp file renaming for future use.\n\t\t\t// os.File.Name() contains the whole path of the file. \n\n\t\t\tvar results []string\n\t\t\tfor i := 0; i < nReduce; i += 1 {\n\t\t\t\tfilename := fmt.Sprintf(\"%s-%d-%d\", \"mr\", task.Tid, i)\n\t\t\t\tif err := os.Rename(out_files[i].Name(), filename); err != nil {\n\t\t\t\t\tlog.Fatalf(\"cannot rename file %v\", filename)\n\t\t\t\t}\n\t\t\t\tresults = append(results, filename)\n\t\t\t}\n\t\t\tNotifyComplete(worker_id, task.Tid, task.Type, results)\n\n\t\t} else if task.Type == \"Reduce\" {\n\t\t\tintermediate := []KeyValue{}\n\t\t\tfor _,f := range(task.Files) {\n\t\t\t\tfile, err := os.Open(f)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Fatalf(\"cannot open %v\", task.Files[0])\n\t\t\t\t}\n\t\t\t\tdec := json.NewDecoder(file)\n\t\t\t\tfor {\n\t\t\t\t\tvar kv KeyValue\n\t\t\t\t\tif err := dec.Decode(&kv); err != nil {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tintermediate = append(intermediate, kv)\n\t\t\t\t}\n\t\t\t}\n\t\t\tsort.Sort(ByKey(intermediate))\n\n\t\t\tofile, err := ioutil.TempFile(\"\", \"\")\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatalf(\"cannot create temp file\")\n\t\t\t}\n\n\t\t\ti := 0\n\t\t\tfor i < len(intermediate) {\n\t\t\t\tj := i + 1\n\t\t\t\tfor j < len(intermediate) && intermediate[j].Key == intermediate[i].Key {\n\t\t\t\t\tj++\n\t\t\t\t}\n\t\t\t\tvalues := []string{}\n\t\t\t\tfor k := i; k < j; k++ {\n\t\t\t\t\tvalues = append(values, intermediate[k].Value)\n\t\t\t\t}\n\t\t\t\toutput := reducef(intermediate[i].Key, values)\n\n\t\t\t\t// this is the correct format for each line of Reduce output.\n\t\t\t\tfmt.Fprintf(ofile, \"%v %v\\n\", intermediate[i].Key, output)\n\n\t\t\t\ti = j\n\t\t\t}\n\n\t\t\tfilename := fmt.Sprintf(\"mr-out-%d\", task.Tid)\n\t\t\tif err := os.Rename(ofile.Name(), filename); err != nil {\n\t\t\t\tlog.Fatalf(\"cannot rename file %v\", filename)\n\t\t\t}\n\t\t\tofile.Close()\n\n\t\t\tNotifyComplete(worker_id, task.Tid, task.Type, nil)\n\t\t}\n\t\t//NotifyComplete(worker_id, task.Tid, task.Type, []string{\"mr-2-4\", \"mr-3-5\", \"mr-10-5\"})\n\t}\n\n\t// uncomment to send the Example RPC to the master.\n\t// CallExample()\n\t// Test: Complete immediately\n\t//NotifyComplete(worker_id, []string{\"mr-2-4\", \"mr-3-5\", \"mr-10-5\"})\n\n\t// Test: Complete 12s later\n\t//time.Sleep(12 * time.Second)\n\t//NotifyComplete(worker_id, []string{\"mr-2-4\", \"mr-3-5\", \"mr-10-5\"})\n}", "title": "" }, { "docid": "c95422f4e151e592e95a642978f05775", "score": "0.42340866", "text": "func Apply(namespace string, data []byte, clientFunc func(*kmeta.RESTMapping) (*kubectl.RESTHelper, error)) ([]ApplyResult, error) {\n\tconfObj, _, err := DecodeDataToObject(data)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"decoding failed, %s\", err.Error())\n\t}\n\n\tconf, ok := confObj.(*api.Config)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unable to convert object to Config\")\n\t}\n\n\tif len(conf.Items) == 0 {\n\t\treturn nil, fmt.Errorf(\"Config items must be not empty\")\n\t}\n\n\tresult := []ApplyResult{}\n\tfor i, item := range conf.Items {\n\t\titemErrors := errs.ValidationErrorList{}\n\t\tmessage := \"\"\n\n\t\titemBase, mapping, err := DecodeDataToObject(item.RawJSON)\n\t\tif err != nil {\n\t\t\treportError(&itemErrors, i, errs.ValidationError{\n\t\t\t\terrs.ValidationErrorTypeInvalid,\n\t\t\t\t\"decode\",\n\t\t\t\terr,\n\t\t\t})\n\t\t\tresult = append(result, ApplyResult{itemErrors.Prefix(\"Config\"), message})\n\t\t\tcontinue\n\t\t}\n\n\t\tclient, err := clientFunc(mapping)\n\t\tif err != nil {\n\t\t\treportError(&itemErrors, i, errs.NewFieldNotSupported(\"client\", err))\n\t\t\tresult = append(result, ApplyResult{itemErrors.Prefix(\"Config\"), message})\n\t\t\tcontinue\n\t\t}\n\n\t\tjsonResource, err := mapping.Encode(itemBase)\n\t\tif err != nil {\n\t\t\treportError(&itemErrors, i, errs.ValidationError{\n\t\t\t\terrs.ValidationErrorTypeInvalid,\n\t\t\t\t\"encode\",\n\t\t\t\terr,\n\t\t\t})\n\t\t\tresult = append(result, ApplyResult{itemErrors.Prefix(\"Config\"), message})\n\t\t\tcontinue\n\t\t}\n\n\t\tif err := client.Create(namespace, true, jsonResource); err != nil {\n\t\t\treportError(&itemErrors, i, errs.ValidationError{\n\t\t\t\terrs.ValidationErrorTypeInvalid,\n\t\t\t\t\"create\",\n\t\t\t\terr,\n\t\t\t})\n\t\t} else {\n\t\t\titemName, _ := mapping.MetadataAccessor.Name(itemBase)\n\t\t\tmessage = fmt.Sprintf(\"Creation succeeded for %s with name %s\", mapping.Kind, itemName)\n\t\t}\n\t\tresult = append(result, ApplyResult{itemErrors.Prefix(\"Config\"), message})\n\t}\n\treturn result, nil\n}", "title": "" }, { "docid": "c54ef6aa9a1b85580e1f09e3ab68c25c", "score": "0.42284134", "text": "func (c *Controller) handleJobs(ctx context.Context) error {\n\tscans := c.cisFactory.Clusterscanoperator().V1().ClusterScan()\n\tjobs := c.batchFactory.Batch().V1().Job()\n\tconfigmaps := c.coreFactory.Core().V1().ConfigMap()\n\n\tjobs.OnChange(ctx, c.Name, func(key string, obj *batchv1.Job) (*batchv1.Job, error) {\n\t\tif obj == nil || obj.DeletionTimestamp != nil {\n\t\t\treturn obj, nil\n\t\t}\n\t\tjobSelector := labels.SelectorFromSet(labels.Set{\n\t\t\tcisoperatorapi.LabelController: c.Name,\n\t\t})\n\t\t// avoid commandeering jobs from other controllers\n\t\tif obj.Labels == nil || !jobSelector.Matches(labels.Set(obj.Labels)) {\n\t\t\treturn obj, nil\n\t\t}\n\t\t// identify the clusterscan object for this job\n\t\tscanName, ok := obj.Labels[cisoperatorapi.LabelClusterScan]\n\t\tif !ok {\n\t\t\t// malformed, just delete it and move on\n\t\t\tlogrus.Errorf(\"malformed scan, deleting the job %v\", obj.Name)\n\t\t\treturn obj, deleteJob(jobs, obj, metav1.DeletePropagationBackground)\n\t\t}\n\t\t// get the scan being run\n\t\tscan, err := scans.Get(\"default\", scanName, metav1.GetOptions{})\n\t\tswitch {\n\t\t\tcase errors.IsNotFound(err):\n\t\t\t\t// scan is gone, delete\n\t\t\t\tlogrus.Errorf(\"scan gone, deleting the job %v\", obj.Name)\n\t\t\t\treturn obj, deleteJob(jobs, obj, metav1.DeletePropagationBackground)\n\t\t\tcase err != nil:\n\t\t\t\treturn obj, err\n\t\t}\n\n\t\t// if the scan has completed then delete the job\n\t\tif v1.ClusterScanConditionComplete.IsTrue(scan) {\n\t\t\tv1.ClusterScanConditionAlerted.Unknown(scan)\n\t\t\tlogrus.Infof(\"Marking ClusterScanConditionAlerted for clusterscan: %v\", scanName)\n\t\t\t//update scan\n\t\t\t_, err = scans.UpdateStatus(scan)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error updating condition of cluster scan object: %v\", scanName)\n\t\t\t}\n\t\t\treturn obj, deleteJob(jobs, obj, metav1.DeletePropagationBackground)\n\t\t}\n\n\t\tif v1.ClusterScanConditionRunCompleted.IsTrue(scan) {\n\t\t\tscancopy := scan.DeepCopy()\n\t\t\tif !v1.ClusterScanConditionFailed.IsTrue(scan) {\n\t\t\t\t//get the output configmap and create a report\n\t\t\t\toutputConfigName := strings.Join([]string{`cisscan-output-for`,scanName},\"-\")\n\t\t\t\tcm, err := configmaps.Cache().Get(obj.Namespace, outputConfigName)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"cisScanHandler: Updated: error fetching configmap %v: %v\", outputConfigName, err)\n\t\t\t\t}\n\t\t\t\tr, err := report.Get([]byte(cm.Data[v1.DefaultScanOutputFileName]))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"cisScanHandler: Updated: error getting report from configmap %v: %v\", outputConfigName, err)\n\t\t\t\t}\n\t\t\t\tif r == nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"cisScanHandler: Updated: error: got empty report from configmap %v\", outputConfigName)\n\t\t\t\t}\n\t\t\t\tcisScanStatus := &v1.ClusterScanSummary {\n\t\t\t\t\tTotal: r.Total,\n\t\t\t\t\tPass: r.Pass,\n\t\t\t\t\tFail: r.Fail,\n\t\t\t\t\tSkip: r.Skip,\n\t\t\t\t\tNotApplicable: r.NotApplicable,\n\t\t\t\t}\n\t\t\t\tscancopy.Status.Summary = cisScanStatus\n\t\t\t}\n\t\t\tv1.ClusterScanConditionComplete.True(scancopy)\n\t\t\t//update scan\n\t\t\t_, err = scans.UpdateStatus(scancopy)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error updating condition of clusterscan object: %v\", scanName)\n\t\t\t}\n\t\t\tlogrus.Infof(\"Marking ClusterScanConditionComplete for clusterscan: %v\", scanName)\n\t\t\tjobs.Enqueue(obj.Namespace, obj.Name)\n\t\t}\n\t\treturn obj, nil\n\t})\n\treturn nil\n}", "title": "" }, { "docid": "2a242791c6f67d772edabdcd8bba297e", "score": "0.42182037", "text": "func (m *MockjobStore) ListJobs(appName string) ([]*config.Workload, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ListJobs\", appName)\n\tret0, _ := ret[0].([]*config.Workload)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "4ecaea253936841def92e8b7610827cb", "score": "0.42181778", "text": "func performMapWork(mapf func(string, string) []KeyValue, filename string, X int, nReduce int) {\n\t// read each input file\n\t// calculate the intermediate keys.\n\tintermediate := []KeyValue{}\n\n\tfile, err := os.Open(filename)\n\tif err != nil {\n\t\tlog.Fatalf(\"cannot open mapper %v\", filename)\n\t}\n\tcontent, err := ioutil.ReadAll(file)\n\tif err != nil {\n\t\tlog.Fatalf(\"cannot read mapper %v\", filename)\n\t}\n\tfile.Close()\n\tkva := mapf(filename, string(content))\n\tintermediate = append(intermediate, kva...)\n\n\t// partition the keys.\n\tsort.Sort(ByKey(intermediate))\n\n\ttempfiles := []*os.File{}\n\tencs := []*json.Encoder{}\n\n\tfor i := 0; i < nReduce; i++ {\n\t\ttempfile, _ := ioutil.TempFile(\"./\", \"mr-temp-*\")\n\t\ttempfiles = append(tempfiles, tempfile)\n\t\tencs = append(encs, json.NewEncoder(tempfile))\n\t}\n\n\ti := 0\n\tfor i < len(intermediate) {\n\t\tj := i + 1\n\t\tfor j < len(intermediate) && intermediate[j].Key == intermediate[i].Key {\n\t\t\tj++\n\t\t}\n\t\tY := ihash(intermediate[i].Key) % nReduce\n\t\t// use template file to avoid partial write.\n\t\ttempfile := tempfiles[Y]\n\t\tfor k := i; k < j; k++ {\n\t\t\terr := encs[Y].Encode(&intermediate[k])\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatalf(\"encoding error for %v\", tempfile.Name())\n\t\t\t}\n\t\t}\n\t\ti = j\n\t}\n\n\t// atomic rename of the template file here.\n\tfor i := 0; i < nReduce; i++ {\n\t\topath := tempfiles[i].Name()\n\t\terr := os.Rename(opath, \"./\"+\"mr-\"+strconv.Itoa(X)+\"-\"+strconv.Itoa(i))\n\t\ttempfiles[i].Close()\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"cannot rename %v\", opath)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "a9f2b0d21cd76ab64bb7a8ba61b87a57", "score": "0.42153934", "text": "func TestQueueMany(t *testing.T) {\n\tt.Parallel()\n\tnoOfWorkers := runtime.NumCPU()\n\tbufferSize := 50\n\tpool := NewWorkerPool(noOfWorkers, bufferSize, true)\n\tassert.EqualValues(t, noOfWorkers, pool.workersRunning)\n\tfor i := 1; i <= bufferSize; i++ {\n\t\tjob := &WorkPackage{\n\t\t\tjobID: i,\n\t\t\tf: 1000000.0,\n\t\t\tdiv: 1.000001,\n\t\t\tresult: 0,\n\t\t}\n\t\terr := pool.QueueJob(job)\n\t\tif err != nil {\n\t\t\tif debug {\n\t\t\t\tlog.Println(\"could not add job\")\n\t\t\t}\n\t\t}\n\t}\n\t_ = pool.Close()\n\tassert.EqualValues(t, bufferSize, pool.Jobs())\n\tpool.waitGroup.Wait()\n\tassert.EqualValues(t, bufferSize, pool.FinishedJobs())\n}", "title": "" }, { "docid": "5c5b33b7b2c5f272935a41d3f70caabd", "score": "0.42101747", "text": "func handleGetJobs(w http.ResponseWriter, r *http.Request) {\n\tvar jobs []meta.Job\n\tencoder := json.NewEncoder(w)\n\n\tjobs, err := jh.GetExecutingJobs()\n\tif err != nil {\n\t\thandleError(err, w, r)\n\t\treturn\n\t}\n\terr = encoder.Encode(jobs)\n\tif err != nil {\n\t\thandleError(err, w, r)\n\t\treturn\n\t}\n\n}", "title": "" }, { "docid": "ade5d707d670b751187c3818541aa372", "score": "0.4207591", "text": "func PopulatePodAllocatorJobs(env evergreen.Environment) amboy.QueueOperation {\n\treturn func(ctx context.Context, queue amboy.Queue) error {\n\t\tflags, err := evergreen.GetServiceFlags(ctx)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"getting service flags\")\n\t\t}\n\n\t\tif flags.PodAllocatorDisabled {\n\t\t\tgrip.InfoWhen(sometimes.Percent(evergreen.DegradedLoggingPercent), message.Fields{\n\t\t\t\t\"message\": \"pod allocation disabled\",\n\t\t\t\t\"impact\": \"container tasks will not be allocated any pods to run them\",\n\t\t\t\t\"mode\": \"degraded\",\n\t\t\t})\n\t\t\treturn nil\n\t\t}\n\n\t\tif err := model.DisableStaleContainerTasks(evergreen.StaleContainerTaskMonitor); err != nil {\n\t\t\tgrip.Error(message.WrapError(err, message.Fields{\n\t\t\t\t\"message\": \"could not disable stale container tasks\",\n\t\t\t\t\"context\": \"pod allocation\",\n\t\t\t}))\n\t\t}\n\n\t\tnumInitializing, err := pod.CountByInitializing()\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"counting initializing pods\")\n\t\t}\n\n\t\tgrip.Info(message.Fields{\n\t\t\t\"message\": \"tracking statistics for number of parallel pods being requested\",\n\t\t\t\"num_initializing\": numInitializing,\n\t\t})\n\n\t\tsettings, err := evergreen.GetConfig(ctx)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"getting admin settings\")\n\t\t}\n\t\tremaining := settings.PodLifecycle.MaxParallelPodRequests - numInitializing\n\n\t\tctq, err := model.NewContainerTaskQueue()\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"getting container task queue\")\n\t\t}\n\n\t\tcatcher := grip.NewBasicCatcher()\n\n\t\tfor ctq.HasNext() && remaining > 0 {\n\t\t\tt := ctq.Next()\n\t\t\tif t == nil {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tj := NewPodAllocatorJob(t.Id, utility.RoundPartOfMinute(15).Format(TSFormat))\n\t\t\tif err := amboy.EnqueueUniqueJob(ctx, queue, j); err != nil {\n\t\t\t\tcatcher.Wrapf(amboy.EnqueueUniqueJob(ctx, queue, j), \"enqueueing pod allocator job for task '%s'\", t.Id)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tremaining--\n\t\t}\n\n\t\tgrip.InfoWhen(remaining <= 0 && ctq.Len() > 0, message.Fields{\n\t\t\t\"message\": \"reached max parallel pod request limit, not allocating any more\",\n\t\t\t\"included_on\": evergreen.ContainerHealthDashboard,\n\t\t\t\"context\": \"pod allocation\",\n\t\t\t\"num_remaining_tasks\": ctq.Len(),\n\t\t})\n\n\t\treturn catcher.Resolve()\n\t}\n}", "title": "" }, { "docid": "2d3846d4e7bd757c404c8003a2d146a8", "score": "0.42067346", "text": "func updateJobs(s store.Provider, feed <-chan worker.JobUpdate) {\n\tgo func() {\n\t\tfor u := range feed {\n\t\t\tif u.Error != nil {\n\t\t\t\tlog.Printf(\"Job %s encountered an error: %v\", u.JobID, u.Error)\n\t\t\t} else {\n\t\t\t\tlog.Printf(\"Job %s changed to %s\", u.JobID, u.Status)\n\t\t\t}\n\t\t\tstatus := store.JobStatus{\n\t\t\t\tStatus: u.Status,\n\t\t\t\tSecretPaths: u.SecretPaths,\n\t\t\t}\n\t\t\tif err := s.SetStatus(u.JobID, status); err != nil {\n\t\t\t\tlog.Printf(\"Failed to update status for job %s: %v\", u.JobID, err)\n\t\t\t}\n\t\t}\n\t}()\n}", "title": "" }, { "docid": "8f6baba69a5ba36de3328a7f040c7f97", "score": "0.4205367", "text": "func (n *ControlJobs) Format(ctx *FmtCtx) {\n\tctx.WriteString(JobCommandToStatement[n.Command])\n\tctx.WriteString(\" JOBS \")\n\tctx.FormatNode(n.Jobs)\n}", "title": "" }, { "docid": "745d0c615fdc70701ac6fa9eb8e35385", "score": "0.42036545", "text": "func (client BatchServiceClient) listJobs(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) {\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/jobs\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response ListJobsResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "title": "" }, { "docid": "0a2776c35cc9f21ab19fbd0cb17684ee", "score": "0.42029172", "text": "func (c *kuberhealthyJobs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result KuberhealthyJob, err error) {\n\tresult = KuberhealthyJob{}\n\terr = c.client.Patch(pt).\n\t\tNamespace(c.ns).\n\t\tResource(\"khjobs\").\n\t\tSubResource(subresources...).\n\t\tName(name).\n\t\tBody(data).\n\t\tDo(context.TODO()).\n\t\tInto(&result)\n\treturn\n}", "title": "" }, { "docid": "9926e050b560f739466eb130115aaf5d", "score": "0.4197659", "text": "func recursiveNameservers(custom []string) []string {\n\tvar servers []string\n\tif len(custom) == 0 {\n\t\t//servers = systemOrDefaultNameservers(defaultResolvConf, defaultNameservers)\n\t\tservers = defaultNameservers\n\t} else {\n\t\tservers = make([]string, len(custom))\n\t\tcopy(servers, custom)\n\t}\n\tpopulateNameserverPorts(servers)\n\treturn servers\n}", "title": "" }, { "docid": "01bd26a700dd4df04b7d607c70bbb203", "score": "0.4197023", "text": "func ListJobs(ctx context.Context) error {\n\tfmt.Println(\"This command is not supported for your project. Contact support@porter.run for more information.\")\n\treturn nil\n}", "title": "" }, { "docid": "adcd8948c4a9db3411f47013f821160f", "score": "0.4195882", "text": "func (c *Client) Jobs(p *Printer) ([]*Job, error) {\n\tvar mr multipartRequest\n\tmr.init()\n\tif p != nil {\n\t\tmr.WriteField(\"printerid\", p.ID)\n\t}\n\tvar resp jobsResponse\n\terr := jsonRPC(&c.auth, \"POST\", cloudprintURL+\"/jobs\", &mr, &resp)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Jobs: %v\", err)\n\t}\n\tvar jobs []*Job\n\tfor _, desc := range resp.Jobs {\n\t\tjobs = append(jobs, desc.Job())\n\t}\n\treturn jobs, nil\n}", "title": "" }, { "docid": "54dca0aadedbb4b9a39999b6d3702b05", "score": "0.41940412", "text": "func (s *Spanner) BatchGetJobsByID(ctx context.Context, IDs []string) (jobs []engine.Job, err error) {\n\ttxn := s.cli.ReadOnlyTransaction()\n\tnow := time.Now().Unix()\n\tdefer txn.Close()\n\n\titer := txn.Query(ctx, spanner.Statement{\n\t\tSQL: \"SELECT pool_name, job_id, namespace, queue, body, ready_time, expired_time, created_time, tries \" +\n\t\t\t\"FROM lmstfy_jobs WHERE job_id IN UNNEST(@ids) LIMIT @limit\",\n\t\tParams: map[string]interface{}{\n\t\t\t\"ids\": IDs,\n\t\t\t\"limit\": len(IDs),\n\t\t},\n\t})\n\terr = iter.Do(func(row *spanner.Row) error {\n\t\telem := &model.DBJob{}\n\t\tif err = row.ToStruct(elem); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tj := engine.NewJob(elem.Namespace, elem.Queue, elem.Body, uint32(elem.ExpiredTime),\n\t\t\tuint32(elem.ReadyTime-now), uint16(elem.Tries), elem.JobID)\n\t\tjobs = append(jobs, j)\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn jobs, nil\n}", "title": "" }, { "docid": "99fdef8308368cfacd8bde66ad33f290", "score": "0.4193916", "text": "func (qm *ServerMgr) RecoverJobs() (recovered int, total int, err error) {\n\t//Get jobs to be recovered from db whose states are recoverable\n\tdbjobs := new(Jobs)\n\tq := bson.M{}\n\tq[\"state\"] = bson.M{\"$in\": JOB_STATS_TO_RECOVER}\n\tif conf.RECOVER_MAX > 0 {\n\t\tlogger.Info(\"Recover %d jobs...\", conf.RECOVER_MAX)\n\t\tif _, err = dbjobs.GetPaginated(q, conf.RECOVER_MAX, 0, \"info.priority\", \"desc\", true); err != nil {\n\t\t\tlogger.Error(\"(RecoverJobs) (GetPaginated) \" + err.Error())\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tlogger.Info(\"Recover all jobs\")\n\t\tif err = dbjobs.GetAll(q, \"info.submittime\", \"asc\", true); err != nil {\n\t\t\tlogger.Error(\"(RecoverJobs) (GetAll) \" + err.Error())\n\t\t\treturn\n\t\t}\n\t}\n\ttotal = dbjobs.Length()\n\t//Locate the job script and parse tasks for each job\n\tfor _, dbjob := range *dbjobs {\n\t\tpipeline := \"missing\"\n\t\tif dbjob.Info != nil {\n\t\t\tpipeline = dbjob.Info.Pipeline\n\t\t}\n\t\tlogger.Debug(1, \"recovering %d: job=%s, state=%s, pipeline=%s\", recovered+1, dbjob.Id, dbjob.State, pipeline)\n\t\tisRecovered, rerr := qm.RecoverJob(\"\", dbjob)\n\t\tif rerr != nil {\n\t\t\tlogger.Error(fmt.Sprintf(\"(RecoverJobs) job=%s failed: %s\", dbjob.Id, rerr.Error()))\n\t\t\tcontinue\n\t\t}\n\t\tif isRecovered {\n\t\t\trecovered += 1\n\t\t}\n\t}\n\treturn\n}", "title": "" }, { "docid": "83cac47edd788348553574249e580cee", "score": "0.41893858", "text": "func GenerateTemplatedConfiguration(services ...string) {\n\n\tinputYmlName := \"yba-installer-input.yml\"\n\n\tvalidateJSONSchema(inputYmlName)\n\n\toutputYmlList := []string{\"yba-installer-prometheus.yml\",\n\t\t\"yba-installer-platform.yml\", \"yba-installer-postgres.yml\"}\n\n\tif len(services) != 0 {\n\t\toutputYmlList = services\n\t}\n\n\tfor _, outYmlName := range outputYmlList {\n\n\t\tcreatedBytes, _ := readConfigAndTemplate(outYmlName)\n\n\t\tjsonData, _ := readYAMLtoJSON(createdBytes)\n\n\t\tnumberOfServices := len(jsonData[\"services\"].([]interface{}))\n\n\t\tfor i := 0; i < numberOfServices; i++ {\n\n\t\t\tservice := jsonData[\"services\"].([]interface{})[i]\n\t\t\tserviceName := fmt.Sprint(service.(map[string]interface{})[\"name\"])\n\n\t\t\tserviceFileName := fmt.Sprint(service.(map[string]interface{})[\"fileName\"])\n\n\t\t\tserviceContents := fmt.Sprint(service.(map[string]interface{})[\"contents\"])\n\n\t\t\t// Only write the service files to the appropriate file location if we are\n\t\t\t// running as root (since we might not be able to write to /etc/systemd)\n\t\t\t// in the non-root case.\n\n\t\t\tif !hasSudoAccess() {\n\n\t\t\t\tif !strings.Contains(serviceName, \"Service\") {\n\n\t\t\t\t\tWriteBytes([]byte(serviceContents), []byte(serviceFileName))\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tWriteBytes([]byte(serviceContents), []byte(serviceFileName))\n\n\t\t\t}\n\n\t\t\tif strings.Contains(serviceFileName, \"yb-platform.conf\") {\n\n\t\t\t\tfile, err := os.OpenFile(serviceFileName, os.O_APPEND|os.O_WRONLY, 0644)\n\t\t\t\tif err != nil {\n\t\t\t\t\tLogError(\"Error: \" + err.Error() + \".\")\n\t\t\t\t}\n\t\t\t\tdefer file.Close()\n\n\t\t\t\t// Add the additional raw text to yb-platform.conf if it exists.\n\t\t\t\tadditionalEntryString := strings.TrimSuffix(getYamlPathData(\".additional\"), \"\\n\")\n\n\t\t\t\tif _, err := file.WriteString(additionalEntryString); err != nil {\n\t\t\t\t\tLogError(\"Error: \" + err.Error() + \".\")\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tLogDebug(\"Templated configuration for \" + serviceName +\n\t\t\t\t\" succesfully applied.\")\n\n\t\t}\n\t}\n}", "title": "" }, { "docid": "bb213a1add1750cf5224a75b91af2e3d", "score": "0.4176968", "text": "func (j *JobInfo) ListJobs() []string {\n\tklog.Infof(\"Listing jobs in namespace %v\", apiv1.NamespaceDefault)\n\tlist, err := j.jobsClient.List(metav1.ListOptions{})\n\tif err != nil {\n\t\tklog.Errorf(\"List jobs err: %v\", err)\n\t}\n\tklog.Infof(\"Items: %+v\", list.Items)\n\tjobNames := make([]string, 0)\n\tfor _, d := range list.Items {\n\t\tjobNames = append(jobNames, d.Name)\n\t}\n\treturn jobNames\n}", "title": "" }, { "docid": "b5c7a0756877f55d66141a626321581c", "score": "0.4176394", "text": "func (kube *Kube) SetResources(kind string, name string, namespace string, totalResources TotalResources) error {\n\tcontainerSpecs := []map[string]interface{}{}\n\tfor containerIndex := range totalResources.Containers {\n\t\tcontainer := totalResources.Containers[containerIndex]\n\n\t\tvar memoryLimits *string\n\t\tif container.Limits.Memory != nil {\n\t\t\ttmp := fmt.Sprintf(\"%dMi\", *container.Limits.Memory)\n\t\t\tmemoryLimits = &tmp\n\t\t}\n\t\tvar memoryRequests *string\n\t\tif container.Requests.Memory != nil {\n\t\t\ttmp := fmt.Sprintf(\"%dMi\", *container.Requests.Memory)\n\t\t\tmemoryRequests = &tmp\n\t\t}\n\t\tvar cpuLimits float64\n\t\tif container.Limits.CPU != nil {\n\t\t\tcpuLimits = float64(*container.Limits.CPU) / milliCore\n\t\t}\n\t\tvar cpuRequests float64\n\t\tif container.Requests.CPU != nil {\n\t\t\tcpuRequests = float64(*container.Requests.CPU) / milliCore\n\t\t}\n\t\tlimits := map[string]interface{}{}\n\t\tlimits[\"memory\"] = memoryLimits\n\t\tlimits[\"cpu\"] = cpuLimits\n\t\trequests := map[string]interface{}{}\n\t\trequests[\"memory\"] = memoryRequests\n\t\trequests[\"cpu\"] = cpuRequests\n\n\t\tspec := map[string]interface{}{\n\t\t\t\"name\": container.Name,\n\t\t\t\"resources\": map[string]interface{}{\n\t\t\t\t\"limits\": limits,\n\t\t\t\t\"requests\": requests,\n\t\t\t},\n\t\t}\n\t\tcontainerSpecs = append(containerSpecs, spec)\n\t}\n\n\tbody := map[string]interface{}{\n\t\t\"kind\": kind,\n\t\t\"spec\": map[string]interface{}{\n\t\t\t\"replicas\": totalResources.Replicas,\n\t\t\t\"template\": map[string]interface{}{\n\t\t\t\t\"spec\": map[string]interface{}{\n\t\t\t\t\t\"containers\": containerSpecs,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tb, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq := kube.ClientV1Beta2.RESTClient().Patch(types.StrategicMergePatchType).\n\t\tResource(kind + \"s\").\n\t\tNamespace(namespace).\n\t\tName(name).\n\t\tBody(bytes.NewBuffer(b))\n\n\tres := req.Do()\n\n\t_, err = res.Get()\n\treturn err\n}", "title": "" } ]
4a0a8e134cdf338b20614e22cc73b641
RunResourceConversionTestForSearchService tests if a specific instance of SearchService round trips to the hub storage version and back losslessly
[ { "docid": "650dfc008506cc49395e316d5bd1a2bb", "score": "0.7431308", "text": "func RunResourceConversionTestForSearchService(subject SearchService) string {\n\t// Copy subject to make sure conversion doesn't modify it\n\tcopied := subject.DeepCopy()\n\n\t// Convert to our hub version\n\tvar hub v20220901s.SearchService\n\terr := copied.ConvertTo(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Convert from our hub version\n\tvar actual SearchService\n\terr = actual.ConvertFrom(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Compare actual with what we started with\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" } ]
[ { "docid": "b0be0c618023a25b5747d780878f094d", "score": "0.54895407", "text": "func RunJSONSerializationTestForSearchService(subject SearchService) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual SearchService\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "cc521ec9c02431bc92215a1c98253478", "score": "0.5461477", "text": "func TestService(t *testing.T) {\n\tsearchSvc := New(log)\n\tcxt := context.Background()\n\tconf := db.Configuration{\n\t\tHost: \"172.17.0.2\",\n\t\tPort: 5432,\n\t\tUser: \"postgres\",\n\t\tPassword: \"mysecretpassword\",\n\t\tDbname: \"postgres\",\n\t}\n\n\tbbox := tools.Bbox{\n\t\tLatSW: 43.52,\n\t\tLonSW: 1.32,\n\t\tLatNE: 43.70,\n\t\tLonNE: 1.69,\n\t}\n\n\tfrom := time.Date(2021, 07, 22, 9, 00, 00, 651387237, time.UTC)\n\tto := time.Date(2021, 07, 22, 12, 00, 00, 651387237, time.UTC)\n\n\t_, errSearch := searchSvc.Search(cxt, conf, bbox, 500, from, to)\n\n\tif errSearch != nil {\n\t\tlog.Error(errSearch)\n\t}\n}", "title": "" }, { "docid": "ecd27314a48b96bf54a15bf4f8618bbe", "score": "0.52748054", "text": "func (m *PersistenceStrategy) PrepareSearch(arg0 metadata.Matcher) ([]byte, []interface{}) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"PrepareSearch\", arg0)\n\tret0, _ := ret[0].([]byte)\n\tret1, _ := ret[1].([]interface{})\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "667b5d46ed88ccb46d2508fd457e8a15", "score": "0.5118541", "text": "func RunResourceConversionTestForVirtualMachine(subject VirtualMachine) string {\n\t// Copy subject to make sure conversion doesn't modify it\n\tcopied := subject.DeepCopy()\n\n\t// Convert to our hub version\n\tvar hub v20220301s.VirtualMachine\n\terr := copied.ConvertTo(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Convert from our hub version\n\tvar actual VirtualMachine\n\terr = actual.ConvertFrom(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Compare actual with what we started with\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "68dbe2b584a58f749cb7da7a827b9aa8", "score": "0.5091088", "text": "func TestSearchAPI(t *testing.T) {\n\n\tgin.SetMode(gin.ReleaseMode)\n\trouter := setupRouter()\n\n\tw := httptest.NewRecorder()\n\n\twanted := \"National Veterinary Clinic\"\n\n\treq, _ := http.NewRequest(\"GET\", \"/search?name=\"+url.QueryEscape(wanted), nil)\n\trouter.ServeHTTP(w, req)\n\n\tif w.Code != http.StatusOK {\n\t\tt.Errorf(\"Status got: %v , want: 200\", w.Code)\n\t}\n\n\tvar list []modules.Clinic\n\n\tjson.Unmarshal(w.Body.Bytes(), &list)\n\n\tif len(list) != 1 {\n\t\tt.Errorf(\"Count got: %v , want: 1\", len(list))\n\t\treturn\n\t}\n\n\tif list[0].Name != wanted {\n\t\tt.Errorf(\"Clinic got: %v , want: %v\", list[0].Name, wanted)\n\t}\n\n}", "title": "" }, { "docid": "23e4da72c397c14a732e506af530882d", "score": "0.5046582", "text": "func RunPropertyAssignmentTestForSearchService(subject SearchService) string {\n\t// Copy subject to make sure assignment doesn't modify it\n\tcopied := subject.DeepCopy()\n\n\t// Use AssignPropertiesTo() for the first stage of conversion\n\tvar other v20220901s.SearchService\n\terr := copied.AssignProperties_To_SearchService(&other)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Use AssignPropertiesFrom() to convert back to our original type\n\tvar actual SearchService\n\terr = actual.AssignProperties_From_SearchService(&other)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for a match\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "6caaf8ac4d99e246361bec3f332b8c3e", "score": "0.5043598", "text": "func (me *RESTORETASKS_IMPL) SearchRestoredFiles (\r\n jobIds []int64,\r\n endTimeUsecs *int64,\r\n startIndex *int64,\r\n sourceIds []int64,\r\n startTimeUsecs *int64,\r\n pageCount *int64,\r\n folderOnly *bool,\r\n search *string,\r\n registeredSourceIds []int64,\r\n viewBoxIds []int64,\r\n environments []models.Environments1Enum) (*models.FileFolderSearchResult1, error) {\r\n //the endpoint path uri\r\n _pathUrl := \"/public/restore/files\"\r\n\r\n //variable to hold errors\r\n var err error = nil\r\n //the base uri for api requests\r\n _queryBuilder := configuration.GetBaseURI(configuration.DEFAULT_HOST,me.config);\r\n\r\n //prepare query string for API call\r\n _queryBuilder = _queryBuilder + _pathUrl\r\n\r\n //process optional query parameters\r\n _queryBuilder, err = apihelper.AppendUrlWithQueryParameters(_queryBuilder, map[string]interface{} {\r\n \"jobIds\" : jobIds,\r\n \"endTimeUsecs\" : endTimeUsecs,\r\n \"startIndex\" : startIndex,\r\n \"sourceIds\" : sourceIds,\r\n \"startTimeUsecs\" : startTimeUsecs,\r\n \"pageCount\" : pageCount,\r\n \"folderOnly\" : folderOnly,\r\n \"search\" : search,\r\n \"registeredSourceIds\" : registeredSourceIds,\r\n \"viewBoxIds\" : viewBoxIds,\r\n \"environments\" : models.Environments1EnumArrayToValue(environments),\r\n })\r\n if err != nil {\r\n //error in query param handling\r\n return nil, err\r\n }\r\n\r\n //validate and preprocess url\r\n _queryBuilder, err = apihelper.CleanUrl(_queryBuilder)\r\n if err != nil {\r\n //error in url validation or cleaning\r\n return nil, err\r\n }\r\n if me.config.AccessToken() == nil {\r\n return nil, errors.New(\"Access Token not set. Please authorize the client using client.Authorize()\");\r\n }\r\n //prepare headers for the outgoing request\r\n headers := map[string]interface{} {\r\n \"user-agent\" : \"cohesity-Go-sdk-6.2.0\",\r\n \"accept\" : \"application/json\",\r\n \"Authorization\" : fmt.Sprintf(\"%s %s\",*me.config.AccessToken().TokenType, *me.config.AccessToken().AccessToken),\r\n }\r\n\r\n //prepare API request\r\n _request := unirest.Get(_queryBuilder, headers)\r\n //and invoke the API call request to fetch the response\r\n _response, err := unirest.AsString(_request,me.config.SkipSSL());\r\n if err != nil {\r\n //error in API invocation\r\n return nil, err\r\n }\r\n\r\n //error handling using HTTP status codes\r\n if (_response.Code == 0) {\r\n err = apihelper.NewAPIError(\"Error\", _response.Code, _response.RawBody)\r\n } else if (_response.Code < 200) || (_response.Code > 206) { //[200,206] = HTTP OK\r\n err = apihelper.NewAPIError(\"HTTP Response Not OK\", _response.Code, _response.RawBody)\r\n }\r\n if(err != nil) {\r\n //error detected in status code validation\r\n return nil, err\r\n }\r\n\r\n //returning the response\r\n var retVal *models.FileFolderSearchResult1 = &models.FileFolderSearchResult1{}\r\n err = json.Unmarshal(_response.RawBody, &retVal)\r\n\r\n if err != nil {\r\n //error in parsing\r\n return nil, err\r\n }\r\n return retVal, nil\r\n\r\n}", "title": "" }, { "docid": "c4cdc6ac25d358d4f178b6fba2628248", "score": "0.50312734", "text": "func RunJSONSerializationTestForSearchService_STATUS(subject SearchService_STATUS) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual SearchService_STATUS\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "5a35378212043df84e1de74f5f48c169", "score": "0.5007643", "text": "func (me *RESTORETASKS_IMPL) SearchObjects (\r\n search *string,\r\n jobIds []int64,\r\n registeredSourceIds []int64,\r\n environments []models.Environments1Enum,\r\n startTimeUsecs *int64,\r\n application *string,\r\n ownerEntityId *int64,\r\n viewBoxIds []int64,\r\n endTimeUsecs *int64,\r\n startIndex *int64,\r\n pageCount *int64,\r\n operatingSystems []string) (*models.ObjectSearchResults, error) {\r\n //the endpoint path uri\r\n _pathUrl := \"/public/restore/objects\"\r\n\r\n //variable to hold errors\r\n var err error = nil\r\n //the base uri for api requests\r\n _queryBuilder := configuration.GetBaseURI(configuration.DEFAULT_HOST,me.config);\r\n\r\n //prepare query string for API call\r\n _queryBuilder = _queryBuilder + _pathUrl\r\n\r\n //process optional query parameters\r\n _queryBuilder, err = apihelper.AppendUrlWithQueryParameters(_queryBuilder, map[string]interface{} {\r\n \"search\" : search,\r\n \"jobIds\" : jobIds,\r\n \"registeredSourceIds\" : registeredSourceIds,\r\n \"environments\" : models.Environments1EnumArrayToValue(environments),\r\n \"startTimeUsecs\" : startTimeUsecs,\r\n \"application\" : application,\r\n \"ownerEntityId\" : ownerEntityId,\r\n \"viewBoxIds\" : viewBoxIds,\r\n \"endTimeUsecs\" : endTimeUsecs,\r\n \"startIndex\" : startIndex,\r\n \"pageCount\" : pageCount,\r\n \"operatingSystems\" : operatingSystems,\r\n })\r\n if err != nil {\r\n //error in query param handling\r\n return nil, err\r\n }\r\n\r\n //validate and preprocess url\r\n _queryBuilder, err = apihelper.CleanUrl(_queryBuilder)\r\n if err != nil {\r\n //error in url validation or cleaning\r\n return nil, err\r\n }\r\n if me.config.AccessToken() == nil {\r\n return nil, errors.New(\"Access Token not set. Please authorize the client using client.Authorize()\");\r\n }\r\n //prepare headers for the outgoing request\r\n headers := map[string]interface{} {\r\n \"user-agent\" : \"cohesity-Go-sdk-6.2.0\",\r\n \"accept\" : \"application/json\",\r\n \"Authorization\" : fmt.Sprintf(\"%s %s\",*me.config.AccessToken().TokenType, *me.config.AccessToken().AccessToken),\r\n }\r\n\r\n //prepare API request\r\n _request := unirest.Get(_queryBuilder, headers)\r\n //and invoke the API call request to fetch the response\r\n _response, err := unirest.AsString(_request,me.config.SkipSSL());\r\n if err != nil {\r\n //error in API invocation\r\n return nil, err\r\n }\r\n\r\n //error handling using HTTP status codes\r\n if (_response.Code == 0) {\r\n err = apihelper.NewAPIError(\"Error\", _response.Code, _response.RawBody)\r\n } else if (_response.Code < 200) || (_response.Code > 206) { //[200,206] = HTTP OK\r\n err = apihelper.NewAPIError(\"HTTP Response Not OK\", _response.Code, _response.RawBody)\r\n }\r\n if(err != nil) {\r\n //error detected in status code validation\r\n return nil, err\r\n }\r\n\r\n //returning the response\r\n var retVal *models.ObjectSearchResults = &models.ObjectSearchResults{}\r\n err = json.Unmarshal(_response.RawBody, &retVal)\r\n\r\n if err != nil {\r\n //error in parsing\r\n return nil, err\r\n }\r\n return retVal, nil\r\n\r\n}", "title": "" }, { "docid": "afa2d5e1ea4c7cdf18729b1102be0e38", "score": "0.49907574", "text": "func RunJSONSerializationTestForSearchService_Spec(subject SearchService_Spec) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual SearchService_Spec\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "48042c3e068534e606fca1d2936086da", "score": "0.4949242", "text": "func RunJSONSerializationTestForSearchService_STATUS_ARM(subject SearchService_STATUS_ARM) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual SearchService_STATUS_ARM\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "36b0098719cf904640e1af479bfb9c7b", "score": "0.49451494", "text": "func (c *Client) Search(ctx context.Context, p *SearchPayload) (res *SearchResult, err error) {\n\tvar ires interface{}\n\tires, err = c.SearchEndpoint(ctx, p)\n\tif err != nil {\n\t\treturn\n\t}\n\treturn ires.(*SearchResult), nil\n}", "title": "" }, { "docid": "5199a0e289284779253b256ce8aa907e", "score": "0.48826358", "text": "func RunResourceConversionTestForWorkspacesCompute(subject WorkspacesCompute) string {\n\t// Copy subject to make sure conversion doesn't modify it\n\tcopied := subject.DeepCopy()\n\n\t// Convert to our hub version\n\tvar hub v20210701s.WorkspacesCompute\n\terr := copied.ConvertTo(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Convert from our hub version\n\tvar actual WorkspacesCompute\n\terr = actual.ConvertFrom(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Compare actual with what we started with\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "700911acef2013f93689f535ea9e4b6a", "score": "0.4881756", "text": "func RunJSONSerializationTestForSearchServiceOperatorSpec(subject SearchServiceOperatorSpec) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual SearchServiceOperatorSpec\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "dc7652056b48192b106ef5e6d39e46ea", "score": "0.48746645", "text": "func TestSearch(t *testing.T) {\r\n\tresp, err := http.Get(\"127.0.0.1:8080/entriesfn\")\r\n\tif err != nil {\r\n\t\tt.Fatalf(\"Get entries error = %v\", err)\r\n\t}\r\n\tdefer resp.Body.Close()\r\n}", "title": "" }, { "docid": "d53244775cb3570623e14d33dbcc0189", "score": "0.48561367", "text": "func TestOpenSearch_GetAll(t *testing.T) {\n\ttelemetry.InitTelemetry(\"cloud-nuke\", \"\")\n\tt.Parallel()\n\n\ttestName1 := \"test-domain1\"\n\ttestName2 := \"test-domain2\"\n\tnow := time.Now()\n\tosd := OpenSearchDomains{\n\t\tClient: mockedOpenSearch{\n\t\t\tListDomainNamesOutput: opensearchservice.ListDomainNamesOutput{\n\t\t\t\tDomainNames: []*opensearchservice.DomainInfo{\n\t\t\t\t\t{DomainName: aws.String(testName1)},\n\t\t\t\t\t{DomainName: aws.String(testName2)},\n\t\t\t\t},\n\t\t\t},\n\n\t\t\tListTagsOutput: opensearchservice.ListTagsOutput{\n\t\t\t\tTagList: []*opensearchservice.Tag{\n\t\t\t\t\t{\n\t\t\t\t\t\tKey: aws.String(firstSeenTagKey),\n\t\t\t\t\t\tValue: aws.String(util.FormatTimestampTag(now)),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tKey: aws.String(firstSeenTagKey),\n\t\t\t\t\t\tValue: aws.String(util.FormatTimestampTag(now.Add(1))),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\n\t\t\tDescribeDomainsOutput: opensearchservice.DescribeDomainsOutput{\n\t\t\t\tDomainStatusList: []*opensearchservice.DomainStatus{\n\t\t\t\t\t{\n\t\t\t\t\t\tDomainName: aws.String(testName1),\n\t\t\t\t\t\tCreated: aws.Bool(true),\n\t\t\t\t\t\tDeleted: aws.Bool(false),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tDomainName: aws.String(testName2),\n\t\t\t\t\t\tCreated: aws.Bool(true),\n\t\t\t\t\t\tDeleted: aws.Bool(false),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\ttests := map[string]struct {\n\t\tconfigObj config.ResourceType\n\t\texpected []string\n\t}{\n\t\t\"emptyFilter\": {\n\t\t\tconfigObj: config.ResourceType{},\n\t\t\texpected: []string{testName1, testName2},\n\t\t},\n\t\t\"nameExclusionFilter\": {\n\t\t\tconfigObj: config.ResourceType{\n\t\t\t\tExcludeRule: config.FilterRule{\n\t\t\t\t\tNamesRegExp: []config.Expression{{\n\t\t\t\t\t\tRE: *regexp.MustCompile(testName1),\n\t\t\t\t\t}}},\n\t\t\t},\n\t\t\texpected: []string{testName2},\n\t\t},\n\t\t\"timeAfterExclusionFilter\": {\n\t\t\tconfigObj: config.ResourceType{\n\t\t\t\tExcludeRule: config.FilterRule{\n\t\t\t\t\tTimeAfter: aws.Time(now.Add(-1 * time.Hour)),\n\t\t\t\t}},\n\t\t\texpected: []string{},\n\t\t},\n\t}\n\tfor name, tc := range tests {\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\tnames, err := osd.getAll(config.Config{\n\t\t\t\tOpenSearchDomain: tc.configObj,\n\t\t\t})\n\t\t\trequire.NoError(t, err)\n\t\t\trequire.Equal(t, tc.expected, aws.StringValueSlice(names))\n\t\t})\n\t}\n}", "title": "" }, { "docid": "a0e9302faafe7d78fddaa021eeb45391", "score": "0.48545748", "text": "func publishSearch(msg []byte) []byte {\n\tchannels := make([]chan []byte, len(workers))\n\ti := 0\n\tfor _, w := range workers {\n\t\t//log.Println(\"Waiting godot\")\n\t\tchannels[i] = w.DoRequest(msg)\n\t\ti++\n\t}\n\tsearchResults := &model.SearchResults{\n\t\tHashes: []uint64{},\n\t}\n\n\tfor _, c := range channels {\n\n\t\tresultBytes := <- c\n\n\t\tresp := &model.Response{}\n\t\tproto.Unmarshal(resultBytes, resp)\n\t\tworkerResult := &model.SearchResults{}\n\t\terr := proto.Unmarshal(resp.Payload, workerResult)\n\t\tif err != nil {log.Fatal(err)}\n\n\t\tsearchResults.Hashes = append(searchResults.Hashes, workerResult.Hashes...)\n\t}\n\n\tresultBytes, _ := proto.Marshal(searchResults)\n\trespBytes, _ := proto.Marshal(&model.Response{\n\t\tType: model.ResponseType_SUCCESS,\n\t\tPayload: resultBytes,\n\t})\n\n\treturn respBytes\n}", "title": "" }, { "docid": "2a6fe169e9d6fdce9f9ab6145f0bd894", "score": "0.48445156", "text": "func (db *DB) LegacySearch(ctx context.Context, opts *LegacySearchOptions) ([]Service, error) {\n\tif opts == nil {\n\t\topts = &LegacySearchOptions{}\n\t}\n\n\tuserCheck := permission.User\n\tif opts.FavoritesUserID != \"\" {\n\t\tuserCheck = permission.MatchUser(opts.FavoritesUserID)\n\t}\n\n\terr := permission.LimitCheckAny(ctx, permission.System, userCheck)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = validate.Text(\"Search\", opts.Search, 0, 250)\n\tif opts.FavoritesOnly || opts.FavoritesFirst || opts.FavoritesUserID != \"\" {\n\t\terr = validate.Many(err, validate.UUID(\"FavoritesUserID\", opts.FavoritesUserID))\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar renderContext struct {\n\t\tLegacySearchOptions\n\n\t\tOrderBy string\n\n\t\tLabelKey string\n\t\tLabelValue string\n\t\tLabelNegate bool\n\n\t\tLimit int\n\t}\n\trenderContext.LegacySearchOptions = *opts\n\n\tvar parts []string\n\tif opts.FavoritesFirst {\n\t\tparts = append(parts, \"fav\")\n\t}\n\tparts = append(parts,\n\t\t\"lower(svc.name)\", // use lower because we already have a unique index that does this\n\t\t\"svc.name\",\n\t)\n\trenderContext.OrderBy = strings.Join(parts, \",\")\n\n\tqueryArgs := []interface{}{\n\t\topts.FavoritesUserID,\n\t}\n\n\t// case sensitive searching for labels\n\tif idx := strings.Index(opts.Search, \"=\"); idx > -1 {\n\t\trenderContext.LabelKey = opts.Search[:idx]\n\t\tif strings.HasSuffix(renderContext.LabelKey, \"!\") {\n\t\t\trenderContext.LabelNegate = true\n\t\t\trenderContext.LabelKey = strings.TrimSuffix(renderContext.LabelKey, \"!\")\n\t\t}\n\t\trenderContext.LabelValue = opts.Search[idx+1:]\n\t\tif renderContext.LabelValue == \"\" {\n\t\t\trenderContext.LabelValue = \"*\"\n\t\t}\n\t\t// skip validating LabelValue if search wildcard character or < 3 characters\n\t\tif renderContext.LabelValue == \"*\" || len(renderContext.LabelValue) < 3 {\n\t\t\terr = validate.LabelKey(\"LabelKey\", renderContext.LabelKey)\n\t\t} else {\n\t\t\terr = validate.Many(\n\t\t\t\tvalidate.LabelKey(\"LabelKey\", renderContext.LabelKey),\n\t\t\t\tvalidate.LabelValue(\"LabelValue\", renderContext.LabelValue),\n\t\t\t)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tqueryArgs = append(queryArgs, renderContext.LabelKey)\n\t\tif renderContext.LabelValue != \"*\" {\n\t\t\tqueryArgs = append(queryArgs, renderContext.LabelValue)\n\t\t}\n\n\t} else {\n\t\topts.Search = \"%\" + search.Escape(opts.Search) + \"%\"\n\t\tqueryArgs = append(queryArgs, opts.Search)\n\t}\n\n\tbuf := new(bytes.Buffer)\n\terr = legacySearchTemplate.Execute(buf, renderContext)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"render query\")\n\t}\n\n\trows, err := db.db.QueryContext(ctx, buf.String(), queryArgs...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\n\tvar result []Service\n\tfor rows.Next() {\n\t\tvar s Service\n\t\terr = rows.Scan(&s.ID, &s.Name, &s.Description, &s.epName, &s.isUserFavorite)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tresult = append(result, s)\n\t}\n\n\treturn result, nil\n}", "title": "" }, { "docid": "f620cd0e784c1394e143356fca1ef4ae", "score": "0.4839148", "text": "func RunSearch(ctx CommandContext, args SearchArgs) error {\n\t// FIXME: parallelize API calls\n\n\tterm := strings.ToLower(args.Term)\n\tw := tabwriter.NewWriter(ctx.Stdout, 10, 1, 3, ' ', 0)\n\tdefer w.Flush()\n\tfmt.Fprintf(w, \"NAME\\tDESCRIPTION\\tSTARS\\tOFFICIAL\\tAUTOMATED\\n\")\n\n\tvar entries = []api.ScalewayImageInterface{}\n\n\timages, err := ctx.API.GetImages()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to fetch images from the Scaleway API: %v\", err)\n\t}\n\tfor _, val := range *images {\n\t\tif fuzzy.Match(term, strings.ToLower(val.Name)) {\n\t\t\tentries = append(entries, api.ScalewayImageInterface{\n\t\t\t\tType: \"image\",\n\t\t\t\tName: val.Name,\n\t\t\t\tPublic: val.Public,\n\t\t\t})\n\t\t}\n\t}\n\n\tsnapshots, err := ctx.API.GetSnapshots()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to fetch snapshots from the Scaleway API: %v\", err)\n\t}\n\tfor _, val := range *snapshots {\n\t\tif fuzzy.Match(term, strings.ToLower(val.Name)) {\n\t\t\tentries = append(entries, api.ScalewayImageInterface{\n\t\t\t\tType: \"snapshot\",\n\t\t\t\tName: val.Name,\n\t\t\t\tPublic: false,\n\t\t\t})\n\t\t}\n\t}\n\n\tfor _, image := range entries {\n\t\t// name field\n\t\tname := utils.TruncIf(utils.Wordify(image.Name), 45, !args.NoTrunc)\n\n\t\t// description field\n\t\tvar description string\n\t\tswitch image.Type {\n\t\tcase \"image\":\n\t\t\tif image.Public {\n\t\t\t\tdescription = \"public image\"\n\t\t\t} else {\n\t\t\t\tdescription = \"user image\"\n\t\t\t}\n\n\t\tcase \"snapshot\":\n\t\t\tdescription = \"user snapshot\"\n\t\t}\n\t\tdescription = utils.TruncIf(utils.Wordify(description), 45, !args.NoTrunc)\n\n\t\t// official field\n\t\tvar official string\n\t\tif image.Public {\n\t\t\tofficial = \"[OK]\"\n\t\t} else {\n\t\t\tofficial = \"\"\n\t\t}\n\n\t\tfmt.Fprintf(w, \"%s\\t%s\\t%d\\t%s\\t%s\\n\", name, description, 0, official, \"\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "24a39f203f5fa8f8b4f3200c9b485a32", "score": "0.48207408", "text": "func RunResourceConversionTestForDatabase(subject Database) string {\n\t// Copy subject to make sure conversion doesn't modify it\n\tcopied := subject.DeepCopy()\n\n\t// Convert to our hub version\n\tvar hub v20180601s.Database\n\terr := copied.ConvertTo(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Convert from our hub version\n\tvar actual Database\n\terr = actual.ConvertFrom(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Compare actual with what we started with\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "b7539ab57fc7351b441092e3d761f929", "score": "0.48146817", "text": "func (sq *SingleQuery) searchSingleResource(query, content, resource string, wg *sync.WaitGroup, out chan<- searchItem) {\n\tqi := newSearchItem(query, content, resource)\n\tqi.execQuery()\n\tout <- *qi\n\twg.Done()\n}", "title": "" }, { "docid": "15a134e245de99b92b8ebb7cb4dfb398", "score": "0.48089945", "text": "func (client *Client) SearchTestCase(request *SearchTestCaseRequest) (response *SearchTestCaseResponse, err error) {\n\tresponse = CreateSearchTestCaseResponse()\n\terr = client.DoAction(request, response)\n\treturn\n}", "title": "" }, { "docid": "ff79cd2478b07f51e8217b2570d0a109", "score": "0.47939625", "text": "func (c *Client) runSearchOnly(ts TestStats, Conn *net.UDPConn) (TestStats, error) {\n\t// First run smallest packet size.\n\tts.TotalBytesSent += c.Params.PhaseOneNumPackets * c.Params.StartSize\n\t// Wait 10 seconds per packet initially.\n\tps, err := runPing(c.Params.PhaseOneNumPackets, c.Params.StartSize, initialProbeTimeout, Conn)\n\tts.TotalBytesDropped += int(ps.loss * 0.01 * float64(c.Params.PhaseOneNumPackets) *\n\t\tfloat64(c.Params.StartSize))\n\tif err != nil {\n\t\tlog.Println(\"failed to ping host: %v\", err)\n\t\treturn TestStats{}, err\n\t}\n\t// TODO(jvesuna): add some sanity checks\n\ttimeoutLen := int(math.Max(ps.max, 1)) * timeoutMultiplier\n\t// Then run largest packet size.\n\tts.TotalBytesSent += c.Params.PhaseOneNumPackets * c.Params.MaxSize\n\tps, err = runPing(c.Params.PhaseOneNumPackets, c.Params.MaxSize, timeoutLen, Conn)\n\tts.TotalBytesDropped += int(ps.loss * 0.01 * float64(c.Params.PhaseOneNumPackets) *\n\t\tfloat64(c.Params.MaxSize))\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to ping host: %v\", err)\n\t\treturn TestStats{}, err\n\t}\n\n\tif ps.loss < float64(c.Params.LossRate) {\n\t\t// Pingtest passed. Need to run more tests.\n\t\tlog.Printf(\"Completed Ping Test\")\n\t\tlog.Printf(\"Total bytes *attempted* to send: %d\", ts.TotalBytesSent)\n\t\tlog.Printf(\"Total MB *attempted* to send: %f\", float64(ts.TotalBytesSent)/float64(1000000))\n\t\tlog.Printf(\"Total bytes dropped: %d\", ts.TotalBytesDropped)\n\t\tlog.Printf(\"Net megabytes that made it: %f\", float64(ts.TotalBytesSent-ts.TotalBytesDropped)/\n\t\t\tfloat64(1000000))\n\t\tts.EstimatedMB, ts.EstimatedKb = bandwidth(c.Params.MaxSize, ps.mean)\n\t\treturn ts, nil\n\t}\n\t// Else if largest packet size fails, then run binary search.\n\tpktSize, ts, err := c.binarySearch(ts, c.Params.StartSize, c.Params.MaxSize,\n\t\tc.Params.DecreaseFactor, Conn)\n\tif err != nil {\n\t\treturn ts, err\n\t}\n\tif pktSize == 0 {\n\t\treturn TestStats{}, errors.New(\"pingtest: unexpected error in binary search\")\n\t}\n\treturn ts, nil\n}", "title": "" }, { "docid": "5117013fc5f04482ff8c93f3eca58147", "score": "0.47817135", "text": "func (rs apiResource) Search(w http.ResponseWriter, r *http.Request) {\n\tw.Write([]byte(\"not implemented\"))\n}", "title": "" }, { "docid": "7c2c62739709586b4ac9327828dd0b7a", "score": "0.47792172", "text": "func RunResourceConversionTestForVirtualMachineScaleSet(subject VirtualMachineScaleSet) string {\n\t// Copy subject to make sure conversion doesn't modify it\n\tcopied := subject.DeepCopy()\n\n\t// Convert to our hub version\n\tvar hub v20220301s.VirtualMachineScaleSet\n\terr := copied.ConvertTo(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Convert from our hub version\n\tvar actual VirtualMachineScaleSet\n\terr = actual.ConvertFrom(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Compare actual with what we started with\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "b55b485398d34e6e7bb69ef98c0e9059", "score": "0.47772726", "text": "func RunResourceConversionTestForWorkspacesBigDataPool(subject WorkspacesBigDataPool) string {\n\t// Copy subject to make sure conversion doesn't modify it\n\tcopied := subject.DeepCopy()\n\n\t// Convert to our hub version\n\tvar hub v20210601s.WorkspacesBigDataPool\n\terr := copied.ConvertTo(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Convert from our hub version\n\tvar actual WorkspacesBigDataPool\n\terr = actual.ConvertFrom(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Compare actual with what we started with\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "e103b0e157c63673969fe04d9f246135", "score": "0.47650957", "text": "func RunResourceConversionTestForFederatedIdentityCredential(subject FederatedIdentityCredential) string {\n\t// Copy subject to make sure conversion doesn't modify it\n\tcopied := subject.DeepCopy()\n\n\t// Convert to our hub version\n\tvar hub v20220131ps.FederatedIdentityCredential\n\terr := copied.ConvertTo(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Convert from our hub version\n\tvar actual FederatedIdentityCredential\n\terr = actual.ConvertFrom(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Compare actual with what we started with\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "18d587b4d034d051c13a4900317b63ea", "score": "0.47492036", "text": "func RunJSONSerializationTestForSearchServiceProperties_STATUS_ARM(subject SearchServiceProperties_STATUS_ARM) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual SearchServiceProperties_STATUS_ARM\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "3d6249f5bfe333f8d713cdcb17006780", "score": "0.47455966", "text": "func RegisterSearchService(e *echo.Echo, srv SearchService) {\n\t// switch to strict JSONAPIBinder, if using echo's DefaultBinder\n\tif _, ok := e.Binder.(*echo.DefaultBinder); ok {\n\t\te.Binder = new(protoapigo.JSONAPIBinder)\n\t}\n\te.POST(\"/SearchService.serach\", _serach_Handler(srv))\n}", "title": "" }, { "docid": "efde74aef3c529f4130819128ce7034f", "score": "0.47381034", "text": "func TestResilienceService(t *testing.T) {\n\tlongOrSkip(t)\n\tc := client.MustNewInCluster()\n\tkubecli := mustNewKubeClient(t)\n\tns := getNamespace(t)\n\n\t// Prepare deployment config\n\tdepl := newDeployment(\"test-service-resilience\" + uniuri.NewLen(4))\n\tdepl.Spec.Mode = api.NewMode(api.DeploymentModeCluster)\n\tdepl.Spec.SetDefaults(depl.GetName()) // this must be last\n\n\t// Create deployment\n\tapiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl)\n\tif err != nil {\n\t\tt.Fatalf(\"Create deployment failed: %v\", err)\n\t}\n\n\t// Wait for deployment to be ready\n\tif _, err = waitUntilDeployment(c, depl.GetName(), ns, deploymentIsReady()); err != nil {\n\t\tt.Fatalf(\"Deployment not running in time: %v\", err)\n\t}\n\n\t// Create a database client\n\tctx := context.Background()\n\tclient := mustNewArangodDatabaseClient(ctx, kubecli, apiObject, t)\n\n\t// Wait for cluster to be completely ready\n\tif err := waitUntilClusterHealth(client, func(h driver.ClusterHealth) error {\n\t\treturn clusterHealthEqualsSpec(h, apiObject.Spec)\n\t}); err != nil {\n\t\tt.Fatalf(\"Cluster not running in expected health in time: %v\", err)\n\t}\n\n\t// Fetch latest status so we know all member details\n\tapiObject, err = c.DatabaseV1alpha().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{})\n\tif err != nil {\n\t\tt.Fatalf(\"Failed to get deployment: %v\", err)\n\t}\n\n\t// Delete database service\n\t// Get current pod so we can compare UID later\n\tserviceName := apiObject.Status.ServiceName\n\toriginalService, err := kubecli.CoreV1().Services(ns).Get(serviceName, metav1.GetOptions{})\n\tif err != nil {\n\t\tt.Fatalf(\"Failed to get service %s: %v\", serviceName, err)\n\t}\n\tif err := kubecli.CoreV1().Services(ns).Delete(serviceName, &metav1.DeleteOptions{}); err != nil {\n\t\tt.Fatalf(\"Failed to delete service %s: %v\", serviceName, err)\n\t}\n\t// Wait for service to return with different UID\n\top := func() error {\n\t\tservice, err := kubecli.CoreV1().Services(ns).Get(serviceName, metav1.GetOptions{})\n\t\tif err != nil {\n\t\t\treturn maskAny(err)\n\t\t}\n\t\tif service.GetUID() == originalService.GetUID() {\n\t\t\treturn fmt.Errorf(\"Still original service\")\n\t\t}\n\t\treturn nil\n\t}\n\tif err := retry.Retry(op, time.Minute); err != nil {\n\t\tt.Fatalf(\"PVC did not restart: %v\", err)\n\t}\n\t// Wait for cluster to be completely ready\n\tif err := waitUntilClusterHealth(client, func(h driver.ClusterHealth) error {\n\t\treturn clusterHealthEqualsSpec(h, apiObject.Spec)\n\t}); err != nil {\n\t\tt.Fatalf(\"Cluster not running in expected health in time: %v\", err)\n\t}\n\n\t// Cleanup\n\tremoveDeployment(c, depl.GetName(), ns)\n}", "title": "" }, { "docid": "4613c571f079b066b6a236640bf71221", "score": "0.4725245", "text": "func (suite *APIImageSearchSuite) TestImageSearchOk(c *check.C) {\n\t// TODO\n\t// path := \"/images/search\"\n}", "title": "" }, { "docid": "12fdac746aa2cbf271331b30192bec7f", "score": "0.47006547", "text": "func (r *RequestDriverTask) doSearch(done chan struct{}) {\n\trClient := storages.GetRedisClient()\n\tdrivers := rClient.SearchDrivers(1, r.Lat, r.Lon, 2000)\n\tif len(drivers) == 1 {\n\t\t// Driver found\n\t\t// we can throw a found event\n\t\tpublisher := events.GetPublisher()\n\t\tpublisher <- govent.EventObject{\n\t\t\tEventType: events.Search,\n\t\t\tEvent: events.FoundEvent{\n\t\t\t\tID: r.ID,\n\t\t\t\tUserID: fmt.Sprintf(\"requestor_%s\", r.ID),\n\t\t\t\tLat: r.Lat,\n\t\t\t\tLon: r.Lon,\n\t\t\t\tDriverID: drivers[0].Name,\n\t\t\t},\n\t\t}\n\t\t// Remove driver location from redis\n\t\trClient.RemoveDriverLocation(drivers[0].Name)\n\t\tr.DriverID = drivers[0].Name\n\t\tclose(done)\n\t}\n\treturn\n}", "title": "" }, { "docid": "7af97bd336426f28514c28caff4b398f", "score": "0.46701583", "text": "func TestSearch(t *testing.T) {\n\tteardown := setup(t, getReadTestConfig(gitdb.RecVersion))\n\tdefer teardown(t)\n\n\tcount := 10\n\tsp := &gitdb.SearchParam{\n\t\tIndex: \"From\",\n\t\tValue: \"alice@example.com\",\n\t}\n\n\tresults, err := testDb.Search(\"Message\", []*gitdb.SearchParam{sp}, gitdb.SearchEquals)\n\tif err != nil {\n\t\tt.Errorf(\"search failed with error - %s\", err)\n\t}\n\n\tif len(results) != count {\n\t\tt.Errorf(\"search result count wrong. want: %d, got: %d\", count, len(results))\n\t}\n\n}", "title": "" }, { "docid": "d62ce47ec6e5b3b689ef81d87fe9b92f", "score": "0.46663025", "text": "func RunJSONSerializationTestForSearchServiceOperatorSecrets(subject SearchServiceOperatorSecrets) string {\n\t// Serialize to JSON\n\tbin, err := json.Marshal(subject)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Deserialize back into memory\n\tvar actual SearchServiceOperatorSecrets\n\terr = json.Unmarshal(bin, &actual)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for outcome\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "2fe757ad853a4f2f3b8808841c15e12e", "score": "0.46514097", "text": "func failoverPVCTest(t *testing.T, f *framework.Framework, ctx *framework.TestCtx) error {\n\tnamespace, err := ctx.GetNamespace()\n\tif err != nil {\n\t\tt.Fatalf(\"could not get namespace: %v\", err)\n\t}\n\n\tstandardStorageClass := \"standard\"\n\t// create SiddhiProcess custom resource\n\texampleSiddhi := &siddhiv1alpha2.SiddhiProcess{\n\t\tTypeMeta: metav1.TypeMeta{\n\t\t\tKind: \"SiddhiProcess\",\n\t\t\tAPIVersion: \"siddhi.io/v1alpha2\",\n\t\t},\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: \"failover-app-pvc\",\n\t\t\tNamespace: namespace,\n\t\t},\n\t\tSpec: siddhiv1alpha2.SiddhiProcessSpec{\n\t\t\tApps: []siddhiv1alpha2.Apps{\n\t\t\t\tsiddhiv1alpha2.Apps{\n\t\t\t\t\tScript: script2,\n\t\t\t\t},\n\t\t\t},\n\t\t\tContainer: corev1.Container{\n\t\t\t\tEnv: []corev1.EnvVar{\n\t\t\t\t\tcorev1.EnvVar{\n\t\t\t\t\t\tName: \"RECEIVER_URL\",\n\t\t\t\t\t\tValue: \"http://0.0.0.0:8280/example\",\n\t\t\t\t\t},\n\t\t\t\t\tcorev1.EnvVar{\n\t\t\t\t\t\tName: \"BASIC_AUTH_ENABLED\",\n\t\t\t\t\t\tValue: \"false\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tMessagingSystem: siddhiv1alpha2.MessagingSystem{\n\t\t\t\tType: \"nats\",\n\t\t\t},\n\t\t\tPVC: corev1.PersistentVolumeClaimSpec{\n\t\t\t\tAccessModes: []corev1.PersistentVolumeAccessMode{\n\t\t\t\t\tcorev1.ReadWriteOnce,\n\t\t\t\t},\n\t\t\t\tResources: corev1.ResourceRequirements{\n\t\t\t\t\tRequests: corev1.ResourceList{\n\t\t\t\t\t\tcorev1.ResourceStorage: *resource.NewQuantity(1*GigaByte, resource.BinarySI),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tStorageClassName: &standardStorageClass,\n\t\t\t},\n\t\t},\n\t}\n\n\terr = f.Client.Create(goctx.TODO(), exampleSiddhi, &framework.CleanupOptions{TestContext: ctx, Timeout: cleanupTimeout, RetryInterval: cleanupRetryInterval})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = e2eutil.WaitForDeployment(t, f.KubeClient, namespace, \"failover-app-pvc-0\", 1, retryInterval, maxTimeout)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = e2eutil.WaitForDeployment(t, f.KubeClient, namespace, \"failover-app-pvc-1\", 1, retryInterval, maxTimeout)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = f.KubeClient.CoreV1().PersistentVolumeClaims(namespace).Get(\"failover-app-pvc-1-pvc\", metav1.GetOptions{IncludeUninitialized: true})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = f.Client.Delete(goctx.TODO(), exampleSiddhi)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "280ab6572afd061c87f40011b3ad9cf4", "score": "0.4629655", "text": "func TestSearch(t *testing.T) {\n\tp := Playback{\n\t\tDevices: []onewire.Address{\n\t\t\t0x0000000000000000,\n\t\t\t0x0000000000000001,\n\t\t\t0x0010000000000000,\n\t\t\t0x0000100000000000,\n\t\t\t0xffffffffffffffff,\n\t\t\t0xfc0000013199a928,\n\t\t\t0xf100000131856328,\n\t\t},\n\t}\n\t// Fix-up the CRC byte for each device.\n\tvar buf [8]byte\n\tfor i := range p.Devices {\n\t\tbinary.LittleEndian.PutUint64(buf[:], uint64(p.Devices[i]))\n\t\tcrc := onewire.CalcCRC(buf[:7])\n\t\tp.Devices[i] = (onewire.Address(crc) << 56) | (p.Devices[i] & 0x00ffffffffffffff)\n\t}\n\n\t// We're doing one search operation per device, plus a last one.\n\tp.Ops = make([]IO, len(p.Devices)+1)\n\tfor i := 0; i < len(p.Ops); i++ {\n\t\tp.Ops[i] = IO{W: []byte{0xf0}, Pull: onewire.WeakPullup}\n\t}\n\n\t// Start search.\n\tif err := p.Tx([]byte{0xf0}, nil, onewire.WeakPullup); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Perform search.\n\taddrs, err := p.Search(false)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Verify we got all devices.\n\tif len(addrs) != len(p.Devices) {\n\t\tt.Fatalf(\"expected %d devices, got %d\", len(p.Devices), len(addrs))\n\t}\nmatch:\n\tfor _, ai := range p.Devices {\n\t\tfor _, aj := range addrs {\n\t\t\tif ai == aj {\n\t\t\t\tcontinue match\n\t\t\t}\n\t\t}\n\t\tt.Errorf(\"expected to find %#x but didn't\", ai)\n\t}\n\tif err := p.Close(); err != nil {\n\t\tt.Fatal(err)\n\t}\n}", "title": "" }, { "docid": "b324733f41d96c76981e255322cdde18", "score": "0.4616938", "text": "func (c *testContext) openSearchClient(ctx context.Context, teleportUser, dbService, dbUser string) (*opensearchclt.Client, *alpnproxy.LocalProxy, error) {\n\troute := tlsca.RouteToDatabase{\n\t\tServiceName: dbService,\n\t\tProtocol: defaults.ProtocolOpenSearch,\n\t\tUsername: dbUser,\n\t}\n\n\tproxy, err := c.startLocalALPNProxy(ctx, c.webListener.Addr().String(), teleportUser, route)\n\tif err != nil {\n\t\treturn nil, nil, trace.Wrap(err)\n\t}\n\n\tdb, err := opensearch.MakeTestClient(ctx, common.TestClientConfig{\n\t\tAuthClient: c.authClient,\n\t\tAuthServer: c.authServer,\n\t\tAddress: proxy.GetAddr(),\n\t\tCluster: c.clusterName,\n\t\tUsername: teleportUser,\n\t\tRouteToDatabase: route,\n\t})\n\tif err != nil {\n\t\treturn nil, nil, trace.Wrap(err)\n\t}\n\n\treturn db, proxy, nil\n}", "title": "" }, { "docid": "85141e8a2837f4107899dc65b86f0f85", "score": "0.46062213", "text": "func (r *Registry) Search(ctx context.Context, in gsvc.SearchInput) ([]gsvc.Service, error) {\n\tif in.Prefix == \"\" && in.Name != \"\" {\n\t\tservice := &Service{\n\t\t\tService: gsvc.NewServiceWithName(in.Name),\n\t\t}\n\t\tin.Prefix = service.GetPrefix()\n\t}\n\t// get all instances\n\tinstancesResponse, err := r.consumer.GetAllInstances(&polaris.GetAllInstancesRequest{\n\t\tGetAllInstancesRequest: model.GetAllInstancesRequest{\n\t\t\tService: in.Prefix,\n\t\t\tNamespace: r.opt.Namespace,\n\t\t\tTimeout: &r.opt.Timeout,\n\t\t\tRetryCount: &r.opt.RetryCount,\n\t\t},\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tserviceInstances := instancesToServiceInstances(instancesResponse.GetInstances())\n\treturn serviceInstances, nil\n}", "title": "" }, { "docid": "f64681a8a14b32b6d1666e8bd255b852", "score": "0.46053082", "text": "func TestRegistryUpdateRead(t *testing.T) {\n\tif testing.Short() {\n\t\tt.SkipNow()\n\t}\n\tt.Parallel()\n\ttestDir := renterTestDir(t.Name())\n\n\t// Create a testgroup.\n\tgroupParams := siatest.GroupParams{\n\t\tRenters: 1,\n\t\tMiners: 1,\n\t}\n\ttg, err := siatest.NewGroupFromTemplate(testDir, groupParams)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer func() {\n\t\tif err := tg.Close(); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}()\n\tr := tg.Renters()[0]\n\n\t// Add hosts with a latency dependency.\n\tdeps := dependencies.NewDependencyHostBlockRPC()\n\tdeps.Disable()\n\thost := node.HostTemplate\n\thost.HostDeps = deps\n\t_, err = tg.AddNodeN(host, renter.MinUpdateRegistrySuccesses)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Create some random skylinks to use later.\n\tskylink1, err := modules.NewSkylinkV1(crypto.HashBytes(fastrand.Bytes(100)), 0, 100)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tskylink2, err := modules.NewSkylinkV1(crypto.HashBytes(fastrand.Bytes(100)), 0, 100)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tskylink3, err := modules.NewSkylinkV1(crypto.HashBytes(fastrand.Bytes(100)), 0, 100)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Create a signed registry value.\n\tsk, pk := crypto.GenerateKeyPair()\n\tvar dataKey crypto.Hash\n\tfastrand.Read(dataKey[:])\n\tdata1 := skylink1.Bytes()\n\tdata2 := skylink2.Bytes()\n\tdata3 := skylink3.Bytes()\n\tsrv1 := modules.NewRegistryValue(dataKey, data1, 0).Sign(sk) // rev 0\n\tsrv2 := modules.NewRegistryValue(dataKey, data2, 1).Sign(sk) // rev 1\n\tsrv3 := modules.NewRegistryValue(dataKey, data3, 0).Sign(sk) // rev 0\n\tspk := types.SiaPublicKey{\n\t\tAlgorithm: types.SignatureEd25519,\n\t\tKey: pk[:],\n\t}\n\n\t// Force a refresh of the worker pool for testing.\n\t_, err = r.RenterWorkersGet()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Try to read it from the host. Shouldn't work.\n\t_, err = r.RegistryRead(spk, dataKey)\n\tif err == nil || !strings.Contains(err.Error(), renter.ErrRegistryEntryNotFound.Error()) {\n\t\tt.Fatal(err)\n\t}\n\n\t// Update the regisry.\n\terr = r.RegistryUpdate(spk, dataKey, srv1.Revision, srv1.Signature, skylink1)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Read it again. This should work.\n\treadSRV, err := r.RegistryRead(spk, dataKey)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif !reflect.DeepEqual(srv1, readSRV) {\n\t\tt.Log(srv1)\n\t\tt.Log(readSRV)\n\t\tt.Fatal(\"srvs don't match\")\n\t}\n\n\t// Update the registry again, with a higher revision.\n\terr = r.RegistryUpdate(spk, dataKey, srv2.Revision, srv2.Signature, skylink2)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Read it again. This should work.\n\treadSRV, err = r.RegistryRead(spk, dataKey)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif !reflect.DeepEqual(srv2, readSRV) {\n\t\tt.Log(srv2)\n\t\tt.Log(readSRV)\n\t\tt.Fatal(\"srvs don't match\")\n\t}\n\n\t// Read it again with a almost zero timeout. This should time out.\n\tdeps.Enable()\n\tstart := time.Now()\n\treadSRV, err = r.RegistryReadWithTimeout(spk, dataKey, time.Second)\n\tdeps.Disable()\n\tif err == nil || !strings.Contains(err.Error(), renter.ErrRegistryLookupTimeout.Error()) {\n\t\tt.Fatal(err)\n\t}\n\n\t// Make sure it didn't take too long and timed out.\n\tif time.Since(start) > 2*time.Second {\n\t\tt.Fatalf(\"read took too long to time out %v > %v\", time.Since(start), 2*time.Second)\n\t}\n\n\t// Update the registry again, with the same revision. Shouldn't work.\n\terr = r.RegistryUpdate(spk, dataKey, srv2.Revision, srv2.Signature, skylink2)\n\tif err == nil || !strings.Contains(err.Error(), renter.ErrRegistryUpdateNoSuccessfulUpdates.Error()) {\n\t\tt.Fatal(err)\n\t}\n\tif err == nil || !strings.Contains(err.Error(), registry.ErrSameRevNum.Error()) {\n\t\tt.Fatal(err)\n\t}\n\n\t// Update the registry again, with a lower revision. Shouldn't work.\n\terr = r.RegistryUpdate(spk, dataKey, srv3.Revision, srv3.Signature, skylink3)\n\tif err == nil || !strings.Contains(err.Error(), renter.ErrRegistryUpdateNoSuccessfulUpdates.Error()) {\n\t\tt.Fatal(err)\n\t}\n\tif err == nil || !strings.Contains(err.Error(), registry.ErrLowerRevNum.Error()) {\n\t\tt.Fatal(err)\n\t}\n\n\t// Update the registry again, with an invalid sig. Shouldn't work.\n\tvar invalidSig crypto.Signature\n\tfastrand.Read(invalidSig[:])\n\terr = r.RegistryUpdate(spk, dataKey, srv3.Revision, invalidSig, skylink3)\n\tif err == nil || !strings.Contains(err.Error(), crypto.ErrInvalidSignature.Error()) {\n\t\tt.Fatal(err)\n\t}\n}", "title": "" }, { "docid": "167b1d85cd795f3589bf2ff21d039060", "score": "0.45866323", "text": "func (s *DockerSuite) TestSearchOnCentralRegistry(c *check.C) {\n\ttestRequires(c, Network)\n\n\tout, exitCode := dockerCmd(c, \"search\", \"busybox\")\n\tif exitCode != 0 {\n\t\tc.Fatalf(\"failed to search on the central registry: %s\", out)\n\t}\n\n\tif !strings.Contains(out, \"Busybox base image.\") {\n\t\tc.Fatal(\"couldn't find any repository named (or containing) 'Busybox base image.'\")\n\t}\n}", "title": "" }, { "docid": "b2713f8faf79e58fd2e09d227e05a32c", "score": "0.45801112", "text": "func RunResourceConversionTestForPrivateEndpoint(subject PrivateEndpoint) string {\n\t// Copy subject to make sure conversion doesn't modify it\n\tcopied := subject.DeepCopy()\n\n\t// Convert to our hub version\n\tvar hub v20220701s.PrivateEndpoint\n\terr := copied.ConvertTo(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Convert from our hub version\n\tvar actual PrivateEndpoint\n\terr = actual.ConvertFrom(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Compare actual with what we started with\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "bd1fe964c7e259ada486e8a721d3f79d", "score": "0.45770118", "text": "func (r *GormSearchRepository) search(ctx context.Context, sqlSearchQueryParameter string, workItemTypes []uuid.UUID, start *int, limit *int, spaceID *string) ([]workitem.WorkItemStorage, uint64, error) {\n\tdb := r.db.Model(workitem.WorkItemStorage{}).Where(\"tsv @@ query\")\n\tif start != nil {\n\t\tif *start < 0 {\n\t\t\treturn nil, 0, errors.NewBadParameterError(\"start\", *start)\n\t\t}\n\t\tdb = db.Offset(*start)\n\t}\n\tif limit != nil {\n\t\tif *limit <= 0 {\n\t\t\treturn nil, 0, errors.NewBadParameterError(\"limit\", *limit)\n\t\t}\n\t\tdb = db.Limit(*limit)\n\t}\n\tif len(workItemTypes) > 0 {\n\t\t// restrict to all given types and their subtypes\n\t\tquery := fmt.Sprintf(\"%[1]s.type in (\"+\n\t\t\t\"select distinct subtype.id from %[2]s subtype \"+\n\t\t\t\"join %[2]s supertype on subtype.path <@ supertype.path \"+\n\t\t\t\"where supertype.id in (?))\", workitem.WorkItemStorage{}.TableName(), workitem.WorkItemType{}.TableName())\n\t\tdb = db.Where(query, workItemTypes)\n\t}\n\n\tdb = db.Select(\"count(*) over () as cnt2 , *\")\n\tdb = db.Joins(\", to_tsquery('english', ?) as query, ts_rank(tsv, query) as rank\", sqlSearchQueryParameter)\n\tif spaceID != nil {\n\t\tdb = db.Where(\"space_id=?\", *spaceID)\n\t}\n\tdb = db.Order(fmt.Sprintf(\"rank desc,%s.updated_at desc\", workitem.WorkItemStorage{}.TableName()))\n\n\trows, err := db.Rows()\n\tif err != nil {\n\t\treturn nil, 0, errs.WithStack(err)\n\t}\n\tdefer rows.Close()\n\n\tresult := []workitem.WorkItemStorage{}\n\tvalue := workitem.WorkItemStorage{}\n\tcolumns, err := rows.Columns()\n\tif err != nil {\n\t\tlog.Error(ctx, map[string]interface{}{\n\t\t\t\"err\": err,\n\t\t}, \"failed to get column names\")\n\t\treturn nil, 0, errors.NewInternalError(ctx, errs.Wrap(err, \"failed to get column names\"))\n\t}\n\n\t// need to set up a result for Scan() in order to extract total count.\n\tvar count uint64\n\tvar ignore interface{}\n\tcolumnValues := make([]interface{}, len(columns))\n\n\tfor index := range columnValues {\n\t\tcolumnValues[index] = &ignore\n\t}\n\tcolumnValues[0] = &count\n\tfirst := true\n\n\tfor rows.Next() {\n\t\tdb.ScanRows(rows, &value)\n\t\tif first {\n\t\t\tfirst = false\n\t\t\tif err = rows.Scan(columnValues...); err != nil {\n\t\t\t\tlog.Error(ctx, map[string]interface{}{\n\t\t\t\t\t\"err\": err,\n\t\t\t\t}, \"failed to scan rows\")\n\t\t\t\treturn nil, 0, errors.NewInternalError(ctx, errs.Wrap(err, \"failed to scan rows\"))\n\t\t\t}\n\t\t}\n\t\tresult = append(result, value)\n\n\t}\n\tif first {\n\t\t// means 0 rows were returned from the first query,\n\t\tcount = 0\n\t}\n\tlog.Info(ctx, nil, \"Search results: %d matches\", count)\n\treturn result, count, nil\n\t//*/\n}", "title": "" }, { "docid": "f9529ffde56fa66f3e981f7c08142f28", "score": "0.4558768", "text": "func (c Client) Search(req *SearchReq) (*SearchRes, error) {\n\tconst path = \"/release/main/search_order\"\n\treq.AppID = c.id\n\thashString := c.sign(req.toParams())\n\treq.Sign = hashString\n\tres := new(SearchRes)\n\tcli := fetch.DefaultClient(context.Background())\n\terr := cli.Post(apiAddress+path, req, res)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif res.Error != \"\" {\n\t\treturn nil, errors.New(res.Error)\n\t}\n\treturn res, nil\n}", "title": "" }, { "docid": "789301169e8b4356cf68c7a56d8771a7", "score": "0.45545384", "text": "func TestService(t Tester, svc Service) {\n\t/* nil handle */\n\n\tlength, err := uploadFrom(svc, nil, Info{\n\t\tSize: 12,\n\t\tMediaType: \"foo/bar\",\n\t}, strings.NewReader(\"Hello World!\"))\n\tassert.Error(t, err)\n\tassert.True(t, ErrInvalidHandle.Is(err))\n\tassert.Zero(t, length)\n\n\tinfo, err := svc.Lookup(nil, nil)\n\tassert.Error(t, err)\n\tassert.Empty(t, info)\n\tassert.True(t, ErrInvalidHandle.Is(err))\n\n\terr = downloadTo(svc, nil, nil)\n\tassert.Error(t, err)\n\tassert.True(t, ErrInvalidHandle.Is(err))\n\n\terr = svc.Delete(nil, nil)\n\tassert.Error(t, err)\n\tassert.True(t, ErrInvalidHandle.Is(err))\n\n\t/* correct handle */\n\n\thandle, err := svc.Prepare(nil)\n\tassert.NoError(t, err)\n\tassert.NotEmpty(t, handle)\n\n\tinfo, err = svc.Lookup(nil, handle)\n\tassert.Error(t, err)\n\tassert.Empty(t, info)\n\tassert.True(t, ErrNotFound.Is(err))\n\n\terr = downloadTo(svc, handle, new(bytes.Buffer))\n\tassert.Error(t, err)\n\tassert.True(t, ErrNotFound.Is(err))\n\n\tlength, err = uploadFrom(svc, handle, Info{\n\t\tSize: 12,\n\t\tMediaType: \"foo/bar\",\n\t}, strings.NewReader(\"Hello World!\"))\n\tassert.NoError(t, err)\n\tassert.Equal(t, int64(12), length)\n\n\tlength, err = uploadFrom(svc, handle, Info{\n\t\tSize: 12,\n\t\tMediaType: \"foo/bar\",\n\t}, strings.NewReader(\"Hello World!\"))\n\tassert.Error(t, err)\n\tassert.True(t, ErrUsedHandle.Is(err))\n\tassert.Zero(t, length)\n\n\tinfo, err = svc.Lookup(nil, handle)\n\tassert.NoError(t, err)\n\tassert.Equal(t, int64(12), info.Size)\n\t// MediaType is optional\n\n\tvar buf bytes.Buffer\n\terr = downloadTo(svc, handle, &buf)\n\tassert.NoError(t, err)\n\tassert.Equal(t, \"Hello World!\", buf.String())\n\n\terr = svc.Delete(nil, handle)\n\tassert.NoError(t, err)\n\n\terr = svc.Delete(nil, handle)\n\tassert.Error(t, err)\n\tassert.True(t, ErrNotFound.Is(err))\n\n\tinfo, err = svc.Lookup(nil, handle)\n\tassert.Error(t, err)\n\tassert.Empty(t, info)\n\tassert.True(t, ErrNotFound.Is(err))\n\n\terr = downloadTo(svc, handle, new(bytes.Buffer))\n\tassert.Error(t, err)\n\tassert.True(t, ErrNotFound.Is(err))\n}", "title": "" }, { "docid": "49c483216d0611dc997040d6124a2280", "score": "0.45542097", "text": "func failoverDeploymentTest(t *testing.T, f *framework.Framework, ctx *framework.TestCtx) error {\n\tnamespace, err := ctx.GetNamespace()\n\tif err != nil {\n\t\tt.Fatalf(\"could not get namespace: %v\", err)\n\t}\n\tstandardStorageClass := \"standard\"\n\t// create SiddhiProcess custom resource\n\texampleSiddhi := &siddhiv1alpha2.SiddhiProcess{\n\t\tTypeMeta: metav1.TypeMeta{\n\t\t\tKind: \"SiddhiProcess\",\n\t\t\tAPIVersion: \"siddhi.io/v1alpha2\",\n\t\t},\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: \"failover-app-dep\",\n\t\t\tNamespace: namespace,\n\t\t},\n\t\tSpec: siddhiv1alpha2.SiddhiProcessSpec{\n\t\t\tApps: []siddhiv1alpha2.Apps{\n\t\t\t\tsiddhiv1alpha2.Apps{\n\t\t\t\t\tScript: script2,\n\t\t\t\t},\n\t\t\t},\n\t\t\tContainer: corev1.Container{\n\t\t\t\tEnv: []corev1.EnvVar{\n\t\t\t\t\tcorev1.EnvVar{\n\t\t\t\t\t\tName: \"RECEIVER_URL\",\n\t\t\t\t\t\tValue: \"http://0.0.0.0:8280/example\",\n\t\t\t\t\t},\n\t\t\t\t\tcorev1.EnvVar{\n\t\t\t\t\t\tName: \"BASIC_AUTH_ENABLED\",\n\t\t\t\t\t\tValue: \"false\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tMessagingSystem: siddhiv1alpha2.MessagingSystem{\n\t\t\t\tType: \"nats\",\n\t\t\t},\n\t\t\tPVC: corev1.PersistentVolumeClaimSpec{\n\t\t\t\tAccessModes: []corev1.PersistentVolumeAccessMode{\n\t\t\t\t\tcorev1.ReadWriteOnce,\n\t\t\t\t},\n\t\t\t\tResources: corev1.ResourceRequirements{\n\t\t\t\t\tRequests: corev1.ResourceList{\n\t\t\t\t\t\tcorev1.ResourceStorage: *resource.NewQuantity(1*GigaByte, resource.BinarySI),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tStorageClassName: &standardStorageClass,\n\t\t\t},\n\t\t},\n\t}\n\n\terr = f.Client.Create(goctx.TODO(), exampleSiddhi, &framework.CleanupOptions{TestContext: ctx, Timeout: cleanupTimeout, RetryInterval: cleanupRetryInterval})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = e2eutil.WaitForDeployment(t, f.KubeClient, namespace, \"failover-app-dep-0\", 1, retryInterval, maxTimeout)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = e2eutil.WaitForDeployment(t, f.KubeClient, namespace, \"failover-app-dep-1\", 1, retryInterval, maxTimeout)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = f.KubeClient.CoreV1().Services(namespace).Get(\"siddhi-nats\", metav1.GetOptions{IncludeUninitialized: true})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = f.KubeClient.CoreV1().Services(namespace).Get(\"failover-app-dep-0\", metav1.GetOptions{IncludeUninitialized: true})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = f.KubeClient.ExtensionsV1beta1().Ingresses(namespace).Get(\"siddhi\", metav1.GetOptions{IncludeUninitialized: true})\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = f.Client.Delete(goctx.TODO(), exampleSiddhi)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "12a4a1209ea460974f4f16d837388054", "score": "0.4550271", "text": "func Service_IsResource(construct awscdk.IConstruct) *bool {\n\t_init_.Initialize()\n\n\tvar returns *bool\n\n\t_jsii_.StaticInvoke(\n\t\t\"monocdk.aws_servicediscovery.Service\",\n\t\t\"isResource\",\n\t\t[]interface{}{construct},\n\t\t&returns,\n\t)\n\n\treturn returns\n}", "title": "" }, { "docid": "5ce2a63c229b9c525eea6ab28d30dbd3", "score": "0.45400771", "text": "func MythicRPCTaskSearch(input MythicRPCTaskSearchMessage) MythicRPCTaskSearchMessageResponse {\n\tresponse := MythicRPCTaskSearchMessageResponse{\n\t\tSuccess: false,\n\t}\n\tparamDict := make(map[string]interface{})\n\tsetAnySearchValues := false\n\tsearchString := `SELECT task.id FROM task `\n\tif input.SearchHost != nil {\n\t\tsearchString += `JOIN callback ON task.callback_id = callback.id WHERE task.id=:id `\n\t\tsearchString += `AND callback.host=:host `\n\t\tparamDict[\"host\"] = *input.SearchHost\n\t\tparamDict[\"id\"] = input.TaskID\n\t\tsetAnySearchValues = true\n\t}\n\tif input.SearchAgentTaskID != nil {\n\t\tif !setAnySearchValues {\n\t\t\tsearchString += `WHERE task.agent_task_id=:agent_task_id `\n\t\t} else {\n\t\t\tsearchString += `AND task.agent_task_id=:agent_task_id `\n\t\t}\n\t\tparamDict[\"agent_task_id\"] = *input.SearchAgentTaskID\n\t\tsetAnySearchValues = true\n\t}\n\tif input.SearchCallbackID != nil {\n\t\tif !setAnySearchValues {\n\t\t\tsearchString += `WHERE task.callback_id=:callback_id `\n\t\t} else {\n\t\t\tsearchString += `AND task.callback_id=:callback_id `\n\t\t}\n\t\tparamDict[\"callback_id\"] = *input.SearchCallbackID\n\t\tsetAnySearchValues = true\n\t}\n\tif input.SearchCommandNames != nil {\n\t\tif !setAnySearchValues {\n\t\t\tsearchString += `WHERE task.command_name IN (:command_names) `\n\t\t} else {\n\t\t\tsearchString += `AND task.command_name IN (:command_names) `\n\t\t}\n\t\tparamDict[\"command_names\"] = *input.SearchCommandNames\n\t\tsetAnySearchValues = true\n\t}\n\tif input.SearchCompleted != nil {\n\t\tif !setAnySearchValues {\n\t\t\tsearchString += `WHERE task.completed=:completed `\n\t\t} else {\n\t\t\tsearchString += `AND task.completed=:completed `\n\t\t}\n\t\tparamDict[\"completed\"] = *input.SearchCompleted\n\t\tsetAnySearchValues = true\n\t}\n\tif input.SearchParams != nil {\n\t\tif !setAnySearchValues {\n\t\t\tsearchString += `WHERE task.original_params ILIKE %:params% `\n\t\t} else {\n\t\t\tsearchString += `AND task.original_params ILIKE %:params% `\n\t\t}\n\t\tparamDict[\"params\"] = *input.SearchParams\n\t\tsetAnySearchValues = true\n\t}\n\tif input.SearchTaskID != nil {\n\t\tif !setAnySearchValues {\n\t\t\tsearchString += `WHERE task.id=:search_id `\n\t\t} else {\n\t\t\tsearchString += `AND task.id=:search_id `\n\t\t}\n\t\tparamDict[\"search_id\"] = *input.SearchTaskID\n\t}\n\tif input.SearchTaskDisplayID != nil {\n\t\tif !setAnySearchValues {\n\t\t\tsearchString += `WHERE task.display_id=:search_display_id `\n\t\t} else {\n\t\t\tsearchString += `AND task.display_id=:search_display_id `\n\t\t}\n\t\tparamDict[\"search_display_id\"] = *input.SearchTaskDisplayID\n\t}\n\tif !setAnySearchValues {\n\t\tsearchString += `WHERE task.id=:id`\n\t\tparamDict[\"id\"] = input.TaskID\n\t}\n\tif query, args, err := sqlx.Named(searchString, paramDict); err != nil {\n\t\tlogging.LogError(err, \"Failed to make named statement when searching for tasks\")\n\t\tresponse.Error = err.Error()\n\t\treturn response\n\t} else if query, args, err := sqlx.In(query, args...); err != nil {\n\t\tlogging.LogError(err, \"Failed to do sqlx.In\")\n\t\tresponse.Error = err.Error()\n\t\treturn response\n\t} else {\n\t\tquery = database.DB.Rebind(query)\n\t\ttasks := []databaseStructs.Task{}\n\t\tif err := database.DB.Select(&tasks, query, args...); err != nil {\n\t\t\tlogging.LogError(err, \"Failed to exec sqlx.IN modified statement\")\n\t\t\tresponse.Error = err.Error()\n\t\t\treturn response\n\t\t} else {\n\t\t\tfor _, task := range tasks {\n\t\t\t\tresponse.Tasks = append(response.Tasks, GetTaskMessageTaskInformation(task.ID))\n\t\t\t}\n\t\t}\n\t\tresponse.Success = true\n\t\treturn response\n\t}\n}", "title": "" }, { "docid": "5955af058974d937f57064803a99ce2a", "score": "0.45398605", "text": "func (cli *Client) callSearchAPI(ctx context.Context, path, method string, headers http.Header, payload []byte) (*ResponseInfo, apiError.Error) {\n\tURL, err := url.Parse(path)\n\tif err != nil {\n\t\treturn nil, apiError.StatusError{\n\t\t\tErr: fmt.Errorf(\"failed to parse path: \\\"%v\\\" error is: %v\", path, err),\n\t\t}\n\t}\n\n\tpath = URL.String()\n\n\tvar req *http.Request\n\n\tif payload != nil {\n\t\treq, err = http.NewRequest(method, path, bytes.NewReader(payload))\n\t} else {\n\t\treq, err = http.NewRequest(method, path, http.NoBody)\n\t}\n\n\t// check req, above, didn't error\n\tif err != nil {\n\t\treturn nil, apiError.StatusError{\n\t\t\tErr: fmt.Errorf(\"failed to create request for call to search api, error is: %v\", err),\n\t\t}\n\t}\n\n\t// set any headers against request\n\tsetHeaders(req, headers)\n\n\tif payload != nil {\n\t\treq.Header.Add(\"Content-type\", \"application/json\")\n\t}\n\n\tresp, err := cli.hcCli.Client.Do(ctx, req)\n\tif err != nil {\n\t\treturn nil, apiError.StatusError{\n\t\t\tErr: fmt.Errorf(\"failed to call search api, error is: %v\", err),\n\t\t\tCode: http.StatusInternalServerError,\n\t\t}\n\t}\n\tdefer func() {\n\t\terr = closeResponseBody(resp)\n\t}()\n\n\trespInfo := &ResponseInfo{\n\t\tHeaders: resp.Header.Clone(),\n\t\tStatus: resp.StatusCode,\n\t}\n\n\tif resp.StatusCode < http.StatusOK || resp.StatusCode >= 400 {\n\t\treturn respInfo, apiError.StatusError{\n\t\t\tErr: fmt.Errorf(\"failed as unexpected code from search api: %v\", resp.StatusCode),\n\t\t\tCode: resp.StatusCode,\n\t\t}\n\t}\n\n\tif resp.Body == nil {\n\t\treturn respInfo, nil\n\t}\n\n\trespInfo.Body, err = io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn respInfo, apiError.StatusError{\n\t\t\tErr: fmt.Errorf(\"failed to read response body from call to search api, error is: %v\", err),\n\t\t\tCode: resp.StatusCode,\n\t\t}\n\t}\n\treturn respInfo, nil\n}", "title": "" }, { "docid": "5a277dc7ca90095022eb0792099b8149", "score": "0.453367", "text": "func (orcheEngine *orcheImpl) RequestService(serviceInfo ReqeustService) ResponseService {\n\tlog.Printf(\"[RequestService] %s: %v\\n\", logmgr.SanitizeUserInput(serviceInfo.ServiceName), serviceInfo.ServiceInfo) // lgtm [go/log-injection]\n\n\tif !orcheEngine.Ready {\n\t\treturn ResponseService{\n\t\t\tMessage: InternalServerError,\n\t\t\tServiceName: serviceInfo.ServiceName,\n\t\t\tRemoteTargetInfo: TargetInfo{},\n\t\t}\n\t}\n\n\tatomic.AddInt32(&orchClientID, 1)\n\n\thandle := int(orchClientID)\n\n\tserviceClient := addServiceClient(handle, serviceInfo.ServiceName)\n\tgo serviceClient.listenNotify()\n\n\texecutionTypes := make([]string, 0)\n\tvar scoringType string\n\tinstalled := true\n\tfor _, info := range serviceInfo.ServiceInfo {\n\t\texecutionTypes = append(executionTypes, info.ExecutionType)\n\t\tscoringType, _ = info.ExeOption[\"scoringType\"].(string)\n\t\tif len(info.ExeCmd) > 0 {\n\t\t\tinstalled = false\n\t\t}\n\t}\n\n\tcandidates, err := orcheEngine.getCandidate(serviceInfo.ServiceName, executionTypes, installed)\n\n\tlog.Printf(\"[RequestService] getCandidate\")\n\tfor index, candidate := range candidates {\n\t\tlog.Printf(\"[%d] ID : %v\", index, candidate.ID)\n\t\tlog.Printf(\"[%d] ExecType : %v\", index, candidate.ExecType)\n\t\tlog.Printf(\"[%d] Endpoint : %v\", index, candidate.Endpoint)\n\t\tlog.Printf(\"\")\n\t}\n\n\tif err != nil {\n\t\treturn ResponseService{\n\t\t\tMessage: err.Error(),\n\t\t\tServiceName: serviceInfo.ServiceName,\n\t\t\tRemoteTargetInfo: TargetInfo{},\n\t\t}\n\t}\n\n\terrorResp := ResponseService{\n\t\tMessage: ServiceNotFound,\n\t\tServiceName: serviceInfo.ServiceName,\n\t\tRemoteTargetInfo: TargetInfo{},\n\t}\n\n\tvar deviceScores []deviceInfo\n\n\tif scoringType == \"resource\" {\n\t\tdeviceResources := orcheEngine.gatherDevicesResource(candidates, serviceInfo.SelfSelection)\n\t\tif len(deviceResources) <= 0 {\n\t\t\treturn errorResp\n\t\t}\n\t\tfor i, dev := range deviceResources {\n\t\t\tdeviceResources[i].score, _ = orcheEngine.GetScoreWithResource(dev.resource)\n\t\t}\n\t\tdeviceScores = sortByScore(deviceResources)\n\t} else {\n\t\tdeviceScores = sortByScore(orcheEngine.gatherDevicesScore(candidates, serviceInfo.SelfSelection))\n\t}\n\n\tif len(deviceScores) <= 0 {\n\t\treturn errorResp\n\t} else if deviceScores[0].score == scoringmgr.InvalidScore {\n\t\treturn errorResp\n\t}\n\n\targs, err := getExecCmds(deviceScores[0].execType, serviceInfo.ServiceInfo)\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\terrorResp.Message = err.Error()\n\t\treturn errorResp\n\t}\n\targs = append(args, deviceScores[0].execType)\n\n\tlocalhosts, err := orcheEngine.networkhelper.GetIPs()\n\tif err != nil {\n\t\tlog.Println(\"[orchestrationapi] localhost ip gettering fail. maybe skipped localhost\")\n\t}\n\n\tif common.HasElem(localhosts, deviceScores[0].endpoint) {\n\t\tvalidator := commandvalidator.CommandValidator{}\n\t\tfor _, info := range serviceInfo.ServiceInfo {\n\t\t\tif info.ExecutionType == \"native\" || info.ExecutionType == \"android\" {\n\t\t\t\tif err := validator.CheckCommand(serviceInfo.ServiceName, info.ExeCmd); err != nil {\n\t\t\t\t\tlog.Println(err.Error())\n\t\t\t\t\treturn ResponseService{\n\t\t\t\t\t\tMessage: err.Error(),\n\t\t\t\t\t\tServiceName: serviceInfo.ServiceName,\n\t\t\t\t\t\tRemoteTargetInfo: TargetInfo{},\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tvRequester := requestervalidator.RequesterValidator{}\n\t\tif err := vRequester.CheckRequester(serviceInfo.ServiceName, serviceInfo.ServiceRequester); err != nil &&\n\t\t\t(deviceScores[0].execType == \"native\" || deviceScores[0].execType == \"android\") {\n\t\t\tlog.Println(err.Error())\n\t\t\treturn ResponseService{\n\t\t\t\tMessage: err.Error(),\n\t\t\t\tServiceName: serviceInfo.ServiceName,\n\t\t\t\tRemoteTargetInfo: TargetInfo{},\n\t\t\t}\n\t\t}\n\t}\n\n\torcheEngine.executeApp(\n\t\tdeviceScores[0].endpoint,\n\t\tserviceInfo.ServiceName,\n\t\tserviceInfo.ServiceRequester,\n\t\targs,\n\t\tserviceClient.notiChan,\n\t)\n\tlog.Println(\"[orchestrationapi] \", deviceScores)\n\n\treturn ResponseService{\n\t\tMessage: ErrorNone,\n\t\tServiceName: serviceInfo.ServiceName,\n\t\tRemoteTargetInfo: TargetInfo{\n\t\t\tExecutionType: deviceScores[0].execType,\n\t\t\tTarget: deviceScores[0].endpoint,\n\t\t},\n\t}\n}", "title": "" }, { "docid": "239081785e1c0c5ef0f33b82d9d138e0", "score": "0.45157126", "text": "func (client EventClient) SearchEventCountSender(req *http.Request) (*http.Response, error) {\n\treturn client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))\n}", "title": "" }, { "docid": "9cafee23e35c9a25db14c8edca829e99", "score": "0.4514012", "text": "func TestSearchEvents(t *testing.T) {\n\tsearchJSON := `{\"latitude\":\"100.2\", \"longitude\":\"127.2\", \"radius\": \"5\"}`\n\n\treader = strings.NewReader(searchJSON) //Convert string to reader\n\n\trequest, err := http.NewRequest(\"GET\", searcheventsURL, reader) //Create request with JSON body\n\n\tres, err := http.DefaultClient.Do(request)\n\n\tif err != nil {\n\t\tt.Error(err) //Something is wrong while sending request\n\t}\n\n\tif res.StatusCode != 200 {\n\t\tt.Errorf(\"Success expected: %d\", res.StatusCode) //Uh-oh this means our test failed\n\t}\n}", "title": "" }, { "docid": "f8cfb0879c541f5bdbaf5bdcfc6035ba", "score": "0.45049152", "text": "func (m *AppCreateAvailabilityMonitor) runTest(namespace string) error {\n\ttemplate, err := m.Client.TemplateClient.Templates(m.Config.Template.Namespace).Get(m.Config.Template.Name, metav1.GetOptions{})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error getting template %q: %v\", m.Config.Template.Name, err)\n\t}\n\n\t// The template parameters for a TemplateInstance come from a secret, but\n\t// we'll create an empty one since we're fine with all the defaults\n\tsecret, err := m.Client.CoreClient.Secrets(namespace).Create(&corev1.Secret{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: \"template-parameters\",\n\t\t},\n\t\t//StringData: templateParams,\n\t\tStringData: m.Config.Template.Parameters,\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error creating template parameter secret: %v\", err)\n\t}\n\n\t// Create a TemplateInstance object, linking the Template and a reference to\n\t// the Secret object created above.\n\t_, err = m.Client.TemplateClient.TemplateInstances(namespace).Create(\n\t\t&templatev1.TemplateInstance{\n\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\tName: m.Config.Template.Name,\n\t\t\t},\n\t\t\tSpec: templatev1.TemplateInstanceSpec{\n\t\t\t\tTemplate: *template,\n\t\t\t\tSecret: &corev1.LocalObjectReference{\n\t\t\t\t\tName: secret.Name,\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error instantiating template %q: %v\", m.Config.Template.Name, err)\n\t}\n\n\t// Wait for the route to exist.\n\trouteName := m.Config.Template.AvailabilityRoute\n\tglog.V(2).Infof(\"waiting for route %q to exist\", routeName)\n\tvar route *routev1.Route\n\terr = wait.Poll(50*time.Millisecond, m.Config.AvailabilityTimeout.Duration, wait.ConditionFunc(func() (done bool, err error) {\n\t\tr, err := m.Client.RouteClient.Routes(namespace).Get(routeName, metav1.GetOptions{})\n\t\tif err != nil {\n\t\t\tif kerrors.IsNotFound(err) {\n\t\t\t\treturn false, nil\n\t\t\t}\n\t\t\treturn true, fmt.Errorf(\"error getting route %q: %v\", routeName, err)\n\t\t}\n\t\troute = r\n\t\treturn true, nil\n\t}))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"timed out waiting for route %q to be created\", routeName)\n\t}\n\n\t// Wait for the route to become responsive.\n\turl := &url.URL{\n\t\tHost: route.Spec.Host,\n\t\tScheme: \"http\",\n\t}\n\tglog.V(2).Infof(\"waiting for good response from %s\", url.String())\n\terr = wait.Poll(1*time.Second, m.Config.AvailabilityTimeout.Duration, wait.ConditionFunc(func() (done bool, err error) {\n\t\tclient := http.Client{Timeout: 1 * time.Second}\n\t\tresp, err := client.Get(url.String())\n\t\tif err != nil {\n\t\t\tglog.V(3).Infof(\"received error response from %q: %v\", url.String(), err)\n\t\t\treturn false, nil\n\t\t}\n\t\tif e, a := 200, resp.StatusCode; e != a {\n\t\t\tglog.V(3).Infof(\"expected status code %d from %q, got %d\", e, url.String(), a)\n\t\t\treturn false, nil\n\t\t}\n\t\treturn true, nil\n\t}))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"timed out waiting for app route %q to become availabile at %q: %v\", routeName, url.String(), err)\n\t}\n\tglog.V(2).Infof(\"got success response from %s\", url.String())\n\treturn nil\n}", "title": "" }, { "docid": "203be6117cc87737daf3e997d49bb2b7", "score": "0.45038274", "text": "func RunResourceConversionTestForSqlDatabaseContainer(subject SqlDatabaseContainer) string {\n\t// Copy subject to make sure conversion doesn't modify it\n\tcopied := subject.DeepCopy()\n\n\t// Convert to our hub version\n\tvar hub v20210515s.SqlDatabaseContainer\n\terr := copied.ConvertTo(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Convert from our hub version\n\tvar actual SqlDatabaseContainer\n\terr = actual.ConvertFrom(&hub)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Compare actual with what we started with\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "84bb5a6aaed258a3a8b5ee93db2c1300", "score": "0.45018002", "text": "func Search(c *rpc.Client, req *SearchReq) (*SearchRes, error) {\n\tres := &SearchRes{}\n\tif err := c.Call(\"Search.Search\", req, res); err != nil {\n\t\treturn nil, err\n\t}\n\treturn res, nil\n}", "title": "" }, { "docid": "928ae598f2c1527aaa03b86341a657a9", "score": "0.44989896", "text": "func TestShardObjectsForEvh(t *testing.T) {\n\t// checks naming convention of all generated nodes\n\n\tg := gomega.NewGomegaWithT(t)\n\n\tmodelName, vsName := GetModelName(\"foo.com\", \"default\")\n\tSetUpTestForIngress(t, modelName)\n\tintegrationtest.AddSecret(\"my-secret\", \"default\", \"tlsCert\", \"tlsKey\")\n\n\t// foo.com and noo.com compute the same hashed shard vs num\n\tingrFake := (integrationtest.FakeIngress{\n\t\tName: \"foo-with-targets\",\n\t\tNamespace: \"default\",\n\t\tDnsNames: []string{\"foo.com\", \"noo.com\"},\n\t\tIps: []string{\"8.8.8.8\"},\n\t\tPaths: []string{\"/foo/bar\"},\n\t\tHostNames: []string{\"v1\"},\n\t\tTlsSecretDNS: map[string][]string{\n\t\t\t\"my-secret\": {\"foo.com\"},\n\t\t},\n\t\tServiceName: \"avisvc\",\n\t}).IngressMultiPath()\n\n\t_, err := KubeClient.NetworkingV1().Ingresses(\"default\").Create(context.TODO(), ingrFake, metav1.CreateOptions{})\n\tif err != nil {\n\t\tt.Fatalf(\"error in adding Ingress: %v\", err)\n\t}\n\tintegrationtest.PollForCompletion(t, modelName, 5)\n\n\tverifyIng, _ := KubeClient.NetworkingV1().Ingresses(\"default\").Get(context.TODO(), \"foo-with-targets\", metav1.GetOptions{})\n\tfor i, host := range []string{\"foo.com\", \"noo.com\"} {\n\t\tif verifyIng.Spec.Rules[i].Host == host {\n\t\t\tg.Expect(verifyIng.Spec.Rules[i].Host).To(gomega.Equal(host))\n\t\t\tg.Expect(verifyIng.Spec.Rules[i].HTTP.Paths[0].Path).To(gomega.Equal(\"/foo/bar\"))\n\t\t}\n\t}\n\n\ttime.Sleep(10 * time.Second)\n\tg.Eventually(func() bool {\n\t\tfound, _ := objects.SharedAviGraphLister().Get(modelName)\n\t\treturn found\n\t}, 5*time.Second).Should(gomega.Equal(true))\n\t_, aviModel := objects.SharedAviGraphLister().Get(modelName)\n\tnodes := aviModel.(*avinodes.AviObjectGraph).GetAviEvhVS()\n\tg.Expect(nodes[0].Name).To(gomega.Equal(vsName))\n\t// Shared VS in EVH will not have any pool or pool group unlike the normal VS\n\tg.Expect(len(nodes[0].PoolGroupRefs)).To(gomega.Equal(0))\n\tg.Expect(len(nodes[0].PoolRefs)).To(gomega.Equal(0))\n\tg.Expect(nodes[0].HTTPDSrefs).Should(gomega.HaveLen(0))\n\tg.Expect(nodes[0].VSVIPRefs[0].Name).To(gomega.Equal(vsName))\n\t// the certs will be associated to parent evh vs\n\tg.Expect(nodes[0].SSLKeyCertRefs).Should(gomega.HaveLen(1))\n\t// There will be 2 evh node one for each host\n\tg.Expect(nodes[0].EvhNodes).Should(gomega.HaveLen(2))\n\tg.Expect(nodes[0].EvhNodes[0].Name).To(gomega.Equal(lib.Encode(\"cluster--noo.com\", lib.EVHVS)))\n\tg.Expect(nodes[0].EvhNodes[0].PoolGroupRefs[0].Name).To(gomega.Equal(lib.Encode(\"cluster--default-noo.com_foo_bar-foo-with-targets\", lib.PG)))\n\tg.Expect(nodes[0].EvhNodes[0].PoolRefs[0].Name).To(gomega.Equal(lib.Encode(\"cluster--default-noo.com_foo_bar-foo-with-targets-avisvc\", lib.Pool)))\n\t// Shared VS in EVH will not have any certificates and httppolicy\n\tg.Expect(nodes[0].EvhNodes[0].SSLKeyCertRefs).Should(gomega.HaveLen(0))\n\tg.Expect(nodes[0].EvhNodes[0].HttpPolicyRefs).Should(gomega.HaveLen(1))\n\tg.Expect(nodes[0].EvhNodes[0].HttpPolicyRefs[0].Name).To(gomega.Equal(lib.Encode(\"cluster--default-noo.com\", lib.HTTPPS)))\n\tg.Expect(nodes[0].EvhNodes[0].HttpPolicyRefs[0].HppMap[0].Name).To(gomega.Equal(lib.Encode(\"cluster--default-noo.com_foo_bar-foo-with-targets\", lib.HPPMAP)))\n\n\tg.Expect(nodes[0].EvhNodes[1].Name).To(gomega.Equal(lib.Encode(\"cluster--foo.com\", lib.EVHVS)))\n\tg.Expect(nodes[0].EvhNodes[1].PoolGroupRefs[0].Name).To(gomega.Equal(lib.Encode(\"cluster--default-foo.com_foo_bar-foo-with-targets\", lib.PG)))\n\tg.Expect(nodes[0].EvhNodes[1].PoolRefs[0].Name).To(gomega.Equal(lib.Encode(\"cluster--default-foo.com_foo_bar-foo-with-targets-avisvc\", lib.Pool)))\n\t// since foo is bound with cert this node will have the cert bound to it\n\tg.Expect(nodes[0].EvhNodes[1].SSLKeyCertRefs).Should(gomega.HaveLen(0))\n\tg.Expect(nodes[0].EvhNodes[1].HttpPolicyRefs).Should(gomega.HaveLen(2))\n\tg.Expect(nodes[0].EvhNodes[1].HttpPolicyRefs[0].Name).To(gomega.Equal(lib.Encode(\"cluster--default-foo.com\", lib.HTTPPS)))\n\tg.Expect(nodes[0].EvhNodes[1].HttpPolicyRefs[0].HppMap[0].Name).To(gomega.Equal(lib.Encode(\"cluster--default-foo.com_foo_bar-foo-with-targets\", lib.HPPMAP)))\n\tg.Expect(nodes[0].EvhNodes[1].HttpPolicyRefs[1].Name).To(gomega.Equal(lib.Encode(\"cluster--foo.com\", lib.HTTPPS)))\n\n\terr = KubeClient.NetworkingV1().Ingresses(\"default\").Delete(context.TODO(), \"foo-with-targets\", metav1.DeleteOptions{})\n\tif err != nil {\n\t\tt.Fatalf(\"Couldn't DELETE the Ingress %v\", err)\n\t}\n\tVerifyEvhVsCacheChildDeletion(t, g, cache.NamespaceName{Namespace: \"admin\", Name: modelName})\n\tTearDownTestForIngress(t, modelName)\n}", "title": "" }, { "docid": "3bbfc0c1f4451d3ee597a1a92a263b16", "score": "0.44960624", "text": "func TestVolumeStatus(t *testing.T) {\n\ttestPoolResource := map[string]struct {\n\t\t// cvrName holds the name of zfs volume(not the cvr object name).\n\t\tvolumeName string\n\t\t// MockedOutputType holds the type for which the mocked output should be taken e.g.\n\t\t// for 'ZfsStatusHealthy' type a mocked output of `zfs stats` command for Healthy type is taken.\n\t\tmockedOutputType string\n\t\t// expectedStatus is the status that is expected for the test case.\n\t\texpectedStatus apis.CStorVolumeReplicaPhase\n\t}{\n\t\t// ToDo : Test case for error status.\n\t\t\"#1 OnlineVolumeStatus\": {\n\t\t\tvolumeName: \"cstor-183f17c6-ed8b-11e8-87fd-42010a800087/pvc-9e91f938-ee23-11e8-87fd-42010a800087\",\n\t\t\tmockedOutputType: ZfsStatusHealthy,\n\t\t\texpectedStatus: apis.CVRStatusOnline,\n\t\t},\n\t\t\"#2 OfflineVolumeStatus\": {\n\t\t\tvolumeName: \"cstor-183f17c6-ed8b-11e8-87fd-42010a800087/pvc-9e91f938-ee23-11e8-87fd-42010a800087\",\n\t\t\tmockedOutputType: ZfsStatusOffline,\n\t\t\texpectedStatus: apis.CVRStatusOffline,\n\t\t},\n\t\t\"#3 DegradedVolumeStatus\": {\n\t\t\tvolumeName: \"cstor-183f17c6-ed8b-11e8-87fd-42010a800087/pvc-9e91f938-ee23-11e8-87fd-42010a800087\",\n\t\t\tmockedOutputType: ZfsStatusDegraded,\n\t\t\texpectedStatus: apis.CVRStatusDegraded,\n\t\t},\n\t\t\"#4 RebuildingVolumeStatus\": {\n\t\t\tvolumeName: \"cstor-183f17c6-ed8b-11e8-87fd-42010a800087/pvc-9e91f938-ee23-11e8-87fd-42010a800087\",\n\t\t\tmockedOutputType: ZfsStatusRebuilding,\n\t\t\texpectedStatus: apis.CVRStatusRebuilding,\n\t\t},\n\t\t\"#5 ErrorVolumeStatus\": {\n\t\t\tvolumeName: \"cstor-183f17c6-ed8b-11e8-87fd-42010a800087/pvc-9e91f938-ee23-11e8-87fd-42010a800087\",\n\t\t\tmockedOutputType: testZfsStatusUnknown,\n\t\t\texpectedStatus: apis.CVRStatusError,\n\t\t},\n\t\t\"#6 ReconstructingVolumeStatus\": {\n\t\t\tvolumeName: \"cstor-183f17c6-ed8b-11e8-87fd-42010a800087/pvc-9e91f938-ee23-11e8-87fd-42010a800087\",\n\t\t\tmockedOutputType: testZfsReconstructing,\n\t\t\texpectedStatus: apis.CVRStatusReconstructingNewReplica,\n\t\t},\n\t\t\"#7 NonQuorumDegradedStatus\": {\n\t\t\tvolumeName: \"cstor-183f17c6-ed8b-11e8-87fd-42010a800087/pvc-9e91f938-ee23-11e8-87fd-42010a800087\",\n\t\t\tmockedOutputType: testNonQuorumDegraded,\n\t\t\texpectedStatus: apis.CVRStatusNewReplicaDegraded,\n\t\t},\n\t}\n\tfor name, test := range testPoolResource {\n\t\ttest := test\n\t\tname := name\n\t\tt.Run(name, func(t *testing.T) {\n\t\t\t// Set env variable \"StatusType\" to \"mockedOutputType\"\n\t\t\t// It will help to decide which mocked output should be considered as a std output.\n\t\t\tos.Setenv(testStatusType, test.mockedOutputType)\n\t\t\tRunnerVar = TestRunner{}\n\t\t\tgotStatus, err := Status(test.volumeName)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(\"Some error occured in getting volume status:\", err)\n\t\t\t}\n\t\t\tif string(test.expectedStatus) != gotStatus {\n\t\t\t\tt.Errorf(\"Test case failed as expected status '%s' but got '%s'\", test.expectedStatus, gotStatus)\n\t\t\t}\n\t\t\t// Unset the \"StatusType\" env variable\n\t\t\tos.Unsetenv(\"StatusType\")\n\t\t})\n\t}\n}", "title": "" }, { "docid": "606dbe434e62f50e06223fb02b5fd42e", "score": "0.44956648", "text": "func testIngest(logger log.Logger, opts *opts) error {\n\t// Create k8s client.\n\tk8sConfig, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(\n\t\t&clientcmd.ClientConfigLoadingRules{ExplicitPath: *opts.kubeConfig},\n\t\t&clientcmd.ConfigOverrides{CurrentContext: *opts.cluster},\n\t).ClientConfig()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to create client config for cluster\")\n\t}\n\tk8sClient, err := kubernetes.NewForConfig(k8sConfig)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to create client set\")\n\t}\n\n\t// Remove any resources in the cluster.\n\tif err := cleanCluster(logger, k8sClient); err != nil {\n\t\treturn err\n\t}\n\n\t// Create resources.\n\tif err := bootstrapIngestCluster(logger, opts, k8sClient); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "3ff221a9d65d09349461823997191d1f", "score": "0.44954428", "text": "func (asls AzureStorageLinkedService) AsAzureSearchLinkedService() (*AzureSearchLinkedService, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "8019867eac646aceff14d7a8907dd3be", "score": "0.4494172", "text": "func RegisterSearchService(server *grpc.Server, gs store.GraphStoreClient) {\n\ttracker.RegisterSearchServiceServer(server, &searchService{\n\t\tgs: gs,\n\t\tss: &sourceService{gs: gs},\n\t\tms: &moduleService{gs: gs},\n\t\tds: &dependencyService{gs: gs},\n\t})\n}", "title": "" }, { "docid": "150da8c89509759ec553a736f722d27e", "score": "0.4478188", "text": "func (a *Handler) handleSearch(w http.ResponseWriter, r *http.Request) {\n\tif r.Method != http.MethodPost {\n\t\tcamhttputil.BadRequestError(w, camhttputil.InvalidMethodError{}.Error())\n\t\treturn\n\t}\n\tif a.sh == nil {\n\t\thttp.Error(w, \"app proxy has no search handler\", 500)\n\t\treturn\n\t}\n\ta.masterQueryMu.RLock()\n\tif a.masterQuery == nil {\n\t\thttp.Error(w, \"search is not allowed\", http.StatusForbidden)\n\t\ta.masterQueryMu.RUnlock()\n\t\treturn\n\t}\n\ta.masterQueryMu.RUnlock()\n\tvar sq search.SearchQuery\n\tif err := sq.FromHTTP(r); err != nil {\n\t\tcamhttputil.ServeJSONError(w, err)\n\t\treturn\n\t}\n\tsr, err := a.sh.Query(&sq)\n\tif err != nil {\n\t\tcamhttputil.ServeJSONError(w, err)\n\t\treturn\n\t}\n\t// check this search is in the allowed domain\n\tif !a.allowProxySearchResponse(sr) {\n\t\t// there's a chance our domainBlobs cache is expired so let's\n\t\t// refresh it and retry, but no more than once per minute.\n\t\tif err := a.refreshDomainBlobs(); err != nil {\n\t\t\thttp.Error(w, \"search scope is forbidden\", http.StatusForbidden)\n\t\t\treturn\n\t\t}\n\t\tif !a.allowProxySearchResponse(sr) {\n\t\t\thttp.Error(w, \"search scope is forbidden\", http.StatusForbidden)\n\t\t\treturn\n\t\t}\n\t}\n\tcamhttputil.ReturnJSON(w, sr)\n}", "title": "" }, { "docid": "d833c59f13b427ef8884ff218ad01399", "score": "0.44728562", "text": "func (r *ExactMatchDockerSearcher) Search(precise bool, terms ...string) (app.ComponentMatches, []error) {\n\tmatches := app.ComponentMatches{}\n\tfor _, value := range terms {\n\t\tmatches = append(matches, &app.ComponentMatch{\n\t\t\tValue: value,\n\t\t\tName: value,\n\t\t\tArgument: fmt.Sprintf(\"--image=%q\", value),\n\t\t\tDescription: fmt.Sprintf(\"Container image %q\", value),\n\t\t\tScore: 0.0,\n\t\t})\n\t}\n\treturn matches, r.Errs\n}", "title": "" }, { "docid": "674cf23a6af8e8453ea8043d4752ad3c", "score": "0.44720852", "text": "func MicroserviceReadyForUpgrade(msdef *persistence.MicroserviceDefinition, db *bolt.DB) bool {\n\tglog.V(5).Infof(\"Check if service %v/%v is available for a upgrade.\", msdef.Org, msdef.SpecRef)\n\n\tif msdef.Archived {\n\t\treturn false\n\t}\n\n\t// user does not want upgrade\n\tif !msdef.AutoUpgrade {\n\t\treturn false\n\t}\n\n\t// in the middle of a upgrade, do not disturb\n\tif msdef.UpgradeStartTime != 0 && msdef.UpgradeMsReregisteredTime == 0 && msdef.UpgradeFailedTime == 0 {\n\t\treturn false\n\t}\n\n\t// For inactive upgrade, make sure there are no agreements associated with the service instances. If there are,\n\t// the upgrade cannot proceed.\n\t//\n\t// For agreement-less services, never upgrade. The agreement-less indicator is only in the instance object\n\t// (not in the def object) because an agreement-less service is defined by the node's pattern which can\n\t// change on a lifecycle boundary that is different from the lifecycle of the service definition itself.\n\t//\n\t// For top level service, never initiate upgrade from the agent.\n\t//\n\t// Service's that are managed by an agreement do not have a record in the microservice instance table, so they\n\t// will never be found by this function and will therefore never be upgraded (which is the behavior we want).\n\n\t// Use a filter that only returns unarchived, non-terminating instances that match the input service definition.\n\tif ms_insts, err := persistence.GetAllMicroserviceInstancesWithDefId(db, msdef.Id, false, false); err != nil {\n\t\tglog.Errorf(\"Error retrieving all the service instances from db for %v/%v version %v. %v\", msdef.Org, msdef.SpecRef, msdef.Version, err)\n\t\treturn false\n\t} else if ms_insts != nil && len(ms_insts) > 0 {\n\t\tfor _, msi := range ms_insts {\n\t\t\t// Agreement-less services are never upgraded.\n\t\t\tif msi.IsAgreementLess() {\n\t\t\t\treturn false\n\t\t\t\t// never upgrade top level services, they are controlled by the agbot.\n\t\t\t} else if msi.IsTopLevelService() {\n\t\t\t\treturn false\n\t\t\t} else if !msdef.ActiveUpgrade && msi.GetServiceDefId() == msdef.Id && msi.GetCleanupStartTime() == 0 {\n\t\t\t\t// If the service can only be upgraded when there are no agreements, check for agreements.\n\t\t\t\tif ags := msi.GetAssociatedAgreements(); ags != nil && len(ags) > 0 {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tglog.V(5).Infof(\"Service is available for a upgrade.\")\n\treturn true\n}", "title": "" }, { "docid": "f1e22c1bad08914c7588da374d2bb7b8", "score": "0.44718245", "text": "func TestSonarQubeService(t *testing.T) {\n\t// Set the logger to development mode for verbose logs.\n\tlogf.SetLogger(logf.ZapLogger(true))\n\n\tvar (\n\t\tnamespace = \"sonarqube\"\n\t)\n\n\t// A SonarQube resource with metadata and spec.\n\tsonarqubeList := []*sonarsourcev1alpha1.SonarQube{\n\t\t{\n\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\tName: \"server1\",\n\t\t\t\tNamespace: namespace,\n\t\t\t},\n\t\t\tSpec: sonarsourcev1alpha1.SonarQubeSpec{},\n\t\t},\n\t\t{\n\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\tName: \"server2\",\n\t\t\t\tNamespace: namespace,\n\t\t\t},\n\t\t\tSpec: sonarsourcev1alpha1.SonarQubeSpec{\n\t\t\t\tType: &[]sonarsourcev1alpha1.ServerType{sonarsourcev1alpha1.Application}[0],\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\tName: \"server3\",\n\t\t\t\tNamespace: namespace,\n\t\t\t},\n\t\t\tSpec: sonarsourcev1alpha1.SonarQubeSpec{\n\t\t\t\tType: &[]sonarsourcev1alpha1.ServerType{sonarsourcev1alpha1.Search}[0],\n\t\t\t},\n\t\t},\n\t}\n\t// Objects to track in the fake client.\n\tobjs := []runtime.Object{}\n\tfor _, v := range sonarqubeList {\n\t\tobjs = append(objs, v)\n\t}\n\n\t// Register operator types with the runtime scheme.\n\ts := scheme.Scheme\n\ts.AddKnownTypes(sonarsourcev1alpha1.SchemeGroupVersion, sonarqubeList[0])\n\t// Create a fake client to mock API calls.\n\tcl := fake.NewFakeClientWithScheme(s, objs...)\n\t// Create a ReconcileSonarQube object with the scheme and fake client.\n\tapiMock := &api_client.APIClientMock{}\n\tr := &ReconcileSonarQube{client: cl, scheme: s, apiClient: apiMock}\n\n\tfor _, sonarqube := range sonarqubeList {\n\n\t\t_, err := r.ReconcileService(sonarqube)\n\t\tif utils.ReasonForError(err) != utils.ErrorReasonResourceCreate {\n\t\t\tt.Error(\"reconcileService: resource created error not thrown when creating Service\")\n\t\t}\n\t\tService := &corev1.Service{}\n\t\terr = r.client.Get(context.TODO(), types.NamespacedName{Name: sonarqube.Name, Namespace: sonarqube.Namespace}, Service)\n\t\tif err != nil && errors.IsNotFound(err) {\n\t\t\tt.Error(\"reconcileService: Service not created\")\n\t\t} else if err != nil {\n\t\t\tt.Fatalf(\"reconcileService: (%v)\", err)\n\t\t}\n\n\t\tService, err = r.ReconcileService(sonarqube)\n\t\tif err != nil {\n\t\t\tt.Error(\"reconcileService: returned error even though Service is in expected state\")\n\t\t}\n\t}\n}", "title": "" }, { "docid": "a44d11be640d1834350911db1beb3f53", "score": "0.44712916", "text": "func (s *DiscoveryService) Search(params DiscoverySearchParams) (*DiscoveryResults, *http.Response, error) {\n\titem := new(DiscoveryResults)\n\tae := new(apiError)\n\tresp, err := s.sling.New().Get(\"search\").QueryStruct(params).Receive(item, ae)\n\treturn item, resp, relevantError(err, *ae)\n}", "title": "" }, { "docid": "e74c664ddfeff9a917b3617fe97df9db", "score": "0.44691548", "text": "func (api *API) Search(query Search) (result SearchResult, err error) {\n\n\tvar serverDefinition Server\n\n\terr = ParseConnectionString(&serverDefinition, api.ConnectionString)\n\tif err != nil {\n\t\treturn result, err\n\t}\n\n\t// use ticket if already logged in\n\tif api.Ticket.SessionID != \"\" {\n\t\tserverDefinition.Username = api.Ticket.SessionID\n\t\tserverDefinition.Password = \"Session\"\n\t}\n\n\tsearchOperation := fmt.Sprintf(\"%s%s\", serverDefinition.GetURL(), relativeSearchUniversalAPI)\n\n\tsearchRequest := rest.Request{\n\t\tURL: searchOperation,\n\t\tPayload: query,\n\t\tUsername: serverDefinition.Username,\n\t\tPassword: serverDefinition.Password,\n\t}\n\n\tresponse, err := rest.Get(searchRequest, &result)\n\n\tif err != nil {\n\t\treturn result, err\n\t}\n\n\tif response.StatusCode >= 400 {\n\t\treturn result, fmt.Errorf(\"search operation returned %s\", response.Status)\n\t}\n\n\tlog.DebugWith(\"search response from Graylog server\",\n\t\tlog.Data(\"response\", result))\n\n\treturn result, nil\n\n}", "title": "" }, { "docid": "4d514cce1301515c7c373271e0fbc571", "score": "0.44616893", "text": "func (a *Server) SearchOperationReferences(ctx context.Context, req *scdpb.SearchOperationReferencesRequest) (*scdpb.SearchOperationReferenceResponse, error) {\n\t// Retrieve the area of interest parameter\n\taoi := req.GetParams().AreaOfInterest\n\tif aoi == nil {\n\t\treturn nil, stacktrace.NewErrorWithCode(dsserr.BadRequest, \"Missing area_of_interest\")\n\t}\n\n\t// Parse area of interest to common Volume4D\n\tvol4, err := dssmodels.Volume4DFromSCDProto(aoi)\n\tif err != nil {\n\t\treturn nil, stacktrace.PropagateWithCode(err, dsserr.BadRequest, \"Error parsing geometry\")\n\t}\n\n\t// Retrieve ID of client making call\n\towner, ok := auth.OwnerFromContext(ctx)\n\tif !ok {\n\t\treturn nil, stacktrace.NewErrorWithCode(dsserr.PermissionDenied, \"Missing owner from context\")\n\t}\n\n\tvar response *scdpb.SearchOperationReferenceResponse\n\taction := func(ctx context.Context, r repos.Repository) (err error) {\n\t\t// Perform search query on Store\n\t\tops, err := r.SearchOperations(ctx, vol4)\n\t\tif err != nil {\n\t\t\treturn stacktrace.Propagate(err, \"Unable to search for Operations in repo\")\n\t\t}\n\n\t\t// Create response for client\n\t\tresponse = &scdpb.SearchOperationReferenceResponse{}\n\t\tfor _, op := range ops {\n\t\t\tp, err := op.ToProto()\n\t\t\tif err != nil {\n\t\t\t\treturn stacktrace.Propagate(err, \"Could not convert Operation model to proto\")\n\t\t\t}\n\t\t\tif op.Owner != owner {\n\t\t\t\tp.Ovn = \"\"\n\t\t\t}\n\t\t\tresponse.OperationReferences = append(response.OperationReferences, p)\n\t\t}\n\n\t\treturn nil\n\t}\n\n\terr = a.Store.Transact(ctx, action)\n\tif err != nil {\n\t\treturn nil, err // No need to Propagate this error as this is not a useful stacktrace line\n\t}\n\n\treturn response, nil\n}", "title": "" }, { "docid": "cfcc936895b83355013af3733f1f3936", "score": "0.445857", "text": "func (a *Client) SearchAvailability(params *SearchAvailabilityParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*SearchAvailabilityOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewSearchAvailabilityParams()\n\t}\n\top := &runtime.ClientOperation{\n\t\tID: \"SearchAvailability\",\n\t\tMethod: \"POST\",\n\t\tPathPattern: \"/v2/bookings/availability/search\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &SearchAvailabilityReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t}\n\tfor _, opt := range opts {\n\t\topt(op)\n\t}\n\n\tresult, err := a.transport.Submit(op)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*SearchAvailabilityOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for SearchAvailability: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "title": "" }, { "docid": "adfef4beddccf382652a0efc408c7d0b", "score": "0.44522873", "text": "func (searchService *SearchService) CustomSearch (ctx context.Context, searchRequest *service.CustomSearchRequest) (*service.SearchResponse, error) {\r\n\tlog.Println(\"Request::CustomSearch\")\r\n\r\n\tvar result map[string]interface{}\r\n\t\r\n\t// Es search request\r\n\tres, err := searchService.esClient.Search(\r\n\t\tsearchService.esClient.Search.WithContext(context.Background()),\r\n\t\tsearchService.esClient.Search.WithIndex(searchRequest.Indexes),\r\n\t\tsearchService.esClient.Search.WithBody(bytes.NewBuffer(searchRequest.Query)),\r\n\t\tsearchService.esClient.Search.WithTrackTotalHits(true),\r\n\t\tsearchService.esClient.Search.WithPretty(),\r\n\t)\r\n\r\n\tif err != nil {\r\n\t\tlog.Fatalf(\"Failed to fetch response from elasticsearch : %s\", err)\r\n\t}\r\n\r\n\tdefer res.Body.Close()\r\n\r\n\tif res.IsError() {\r\n\t\tvar e map[string]interface{}\r\n\t\tif err := json.NewDecoder(res.Body).Decode(&e); err != nil {\r\n\t\t\tlog.Fatalf(\"Error parsing the response body: %s\", err)\r\n\t\t} else {\r\n\t\t\t// Print the response status and error information.\r\n\t\t\tlog.Fatalf(\r\n\t\t\t\t\"Elasticsearch::[%s] %s: %s\",\r\n\t\t\t\tres.Status(),\r\n\t\t\t\te[\"error\"].(map[string]interface{})[\"type\"],\r\n\t\t\t\te[\"error\"].(map[string]interface{})[\"reason\"],\r\n\t\t\t)\r\n\t\t}\r\n\t}\r\n\r\n\tif err := json.NewDecoder(res.Body).Decode(&result); err != nil {\r\n\t\tlog.Fatalf(\"Error parsing the response body: %s\", err)\r\n\t}\r\n\r\n\tlog.Printf(\r\n\t\t\"[%s] %d hits; took: %dms\",\r\n\t\tres.Status(),\r\n\t\tint(result[\"hits\"].(map[string]interface{})[\"total\"].(map[string]interface{})[\"value\"].(float64)),\r\n\t\tint(result[\"took\"].(float64)),\r\n\t)\r\n\r\n\tvar hitDocList []*domain.Document\r\n\t// Print the ID and document source for each hit.\r\n\tfor _, hit := range result[\"hits\"].(map[string]interface{})[\"hits\"].([]interface{}) {\r\n\t\tdocBody, _ := json.Marshal(hit.(map[string]interface{})[\"_source\"])\r\n\r\n\t\tdoc := domain.Document{\r\n\t\t\tIndex: hit.(map[string]interface{})[\"_index\"].(string),\r\n\t\t\tDocumentID: hit.(map[string]interface{})[\"_id\"].(string),\r\n\t\t\tBody: string(docBody),\r\n\t\t}\r\n\t\thitDocList = append(hitDocList, &doc)\r\n\r\n\t\tlog.Printf(\" * ID=%s, %s\", hit.(map[string]interface{})[\"_id\"], hit.(map[string]interface{})[\"_source\"])\r\n\t}\r\n\r\n\treturn &service.SearchResponse{\r\n\t\tTotalHits: int32(result[\"hits\"].(map[string]interface{})[\"total\"].(map[string]interface{})[\"value\"].(float64)),\r\n\t\tHits: hitDocList,\r\n\t}, nil\r\n}", "title": "" }, { "docid": "6b350f9ce37c9429ea1ef41175fc495b", "score": "0.44518262", "text": "func ExampleSavedSearchesClient_CreateOrUpdate() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armoperationalinsights.NewClientFactory(\"<subscription-id>\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tres, err := clientFactory.NewSavedSearchesClient().CreateOrUpdate(ctx, \"TestRG\", \"TestWS\", \"00000000-0000-0000-0000-00000000000\", armoperationalinsights.SavedSearch{\n\t\tProperties: &armoperationalinsights.SavedSearchProperties{\n\t\t\tCategory: to.Ptr(\"Saved Search Test Category\"),\n\t\t\tDisplayName: to.Ptr(\"Create or Update Saved Search Test\"),\n\t\t\tFunctionAlias: to.Ptr(\"heartbeat_func\"),\n\t\t\tFunctionParameters: to.Ptr(\"a:int=1\"),\n\t\t\tQuery: to.Ptr(\"Heartbeat | summarize Count() by Computer | take a\"),\n\t\t\tTags: []*armoperationalinsights.Tag{\n\t\t\t\t{\n\t\t\t\t\tName: to.Ptr(\"Group\"),\n\t\t\t\t\tValue: to.Ptr(\"Computer\"),\n\t\t\t\t}},\n\t\t\tVersion: to.Ptr[int64](2),\n\t\t},\n\t}, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\t// You could use response here. We use blank identifier for just demo purposes.\n\t_ = res\n\t// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t// res.SavedSearch = armoperationalinsights.SavedSearch{\n\t// \tID: to.Ptr(\"subscriptions/00000000-0000-0000-0000-000000000005/resourceGroups/mms-eus/providers/Microsoft.OperationalInsights/workspaces/AtlantisDemo/savedSearches/test-new-saved-search-id-2015\"),\n\t// \tEtag: to.Ptr(\"W/\\\"datetime'2017-10-02T23%3A15%3A41.0709875Z'\\\"\"),\n\t// \tProperties: &armoperationalinsights.SavedSearchProperties{\n\t// \t\tCategory: to.Ptr(\"Saved Search Test Category\"),\n\t// \t\tDisplayName: to.Ptr(\"Create or Update Saved Search Test\"),\n\t// \t\tFunctionAlias: to.Ptr(\"heartbeat_func\"),\n\t// \t\tFunctionParameters: to.Ptr(\"a:int=1\"),\n\t// \t\tQuery: to.Ptr(\"Heartbeat | summarize Count() by Computer | take a\"),\n\t// \t\tVersion: to.Ptr[int64](2),\n\t// \t},\n\t// }\n}", "title": "" }, { "docid": "d3e480d5019a2c21f1bd6cb3a4163cdc", "score": "0.44508532", "text": "func (mdls MongoDbLinkedService) AsAzureSearchLinkedService() (*AzureSearchLinkedService, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "be1e9c291c631cb035be09eb444a2eab", "score": "0.44480276", "text": "func RunPropertyAssignmentTestForSearchService_STATUS(subject SearchService_STATUS) string {\n\t// Copy subject to make sure assignment doesn't modify it\n\tcopied := subject.DeepCopy()\n\n\t// Use AssignPropertiesTo() for the first stage of conversion\n\tvar other v20220901s.SearchService_STATUS\n\terr := copied.AssignProperties_To_SearchService_STATUS(&other)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Use AssignPropertiesFrom() to convert back to our original type\n\tvar actual SearchService_STATUS\n\terr = actual.AssignProperties_From_SearchService_STATUS(&other)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for a match\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "848730afcca9053154b7834a1ed8913d", "score": "0.4436619", "text": "func (a *App) Search(ds *document.Service, ss *store.Service) func(http.ResponseWriter, *http.Request, httprouter.Params) {\n\treturn func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\t\tvar b struct {\n\t\t\tText string `json:\"text\"`\n\t\t}\n\n\t\tif err := json.NewDecoder(r.Body).Decode(&b); err != nil {\n\t\t\terr = errors.Wrap(err, \"decode request body\")\n\t\t\tweb.RespondError(w, r, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\n\t\t// validation\n\t\tif len(b.Text) == 0 {\n\t\t\terr := errors.New(\"text field is required and must not be empty\")\n\t\t\tweb.RespondError(w, r, http.StatusBadRequest, err)\n\t\t\treturn\n\t\t}\n\n\t\t// generate word embeddings from given text\n\t\tsearchText := []string{strings.ToLower(b.Text)}\n\n\t\t// ml model api should follow tensorflow serving conventions which is where :predict comes form\n\t\tes, err := embedding.Generate(searchText, a.ModelURL, a.HTTPClient)\n\t\tif err != nil {\n\t\t\terr = errors.New(\"cannot generate embeddings from text\")\n\t\t\tweb.RespondError(w, r, http.StatusServiceUnavailable, err)\n\t\t\treturn\n\t\t}\n\n\t\ts, err := ss.GetStore()\n\t\tif err != nil {\n\t\t\tif err := errors.Cause(err); err == sql.ErrNoRows {\n\t\t\t\terr = errors.Wrap(err, \"no documents indexed\")\n\t\t\t\tweb.Respond(w, r, http.StatusOK, SearchResponse{})\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\terr = errors.Wrap(err, \"get store\")\n\t\t\tweb.RespondError(w, r, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\n\t\t// check if file exists at store location\n\t\tif _, err := os.Stat(s.Location); os.IsNotExist(err) {\n\t\t\terr := errors.Errorf(\"index file `%v` does not exist, content must be re indexed\", s.Location)\n\t\t\tweb.RespondError(w, r, http.StatusBadRequest, err)\n\t\t\treturn\n\t\t}\n\n\t\t// create and load index on disk into memory\n\t\tt := annoyindex.NewAnnoyIndexAngular(a.ModelVectorDims)\n\t\tdefer t.Unload()\n\n\t\tif success := t.Load(s.Location); !success {\n\t\t\terr := errors.Errorf(\"could not load file %v\", s.Location)\n\t\t\tweb.RespondError(w, r, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\n\t\t// perform KNN search on embedding for store. annoy index ids are mapped to sentence ids\n\t\tvar sIDs []int\n\t\tvar distances []float32\n\t\tt.GetNnsByVector(es[0], 20, 1, &sIDs, &distances) // embedding, # items, bool distances?, annoykeys, distances\n\n\t\t// sort sIDs by closest distance\n\t\tsort.Slice(sIDs, func(i, j int) bool {\n\t\t\treturn distances[i] < distances[j]\n\t\t})\n\n\t\t// sort distance to match order of sIDs\n\t\tsort.Slice(distances, func(i, j int) bool {\n\t\t\treturn distances[i] < distances[j]\n\t\t})\n\n\t\t// get documents and sentences from above IDs\n\t\tdocs, err := ds.GetSearchResults(sIDs)\n\t\tif err != nil {\n\t\t\terr = errors.Wrap(err, \"get search results\")\n\t\t\tweb.RespondError(w, r, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\n\t\t// sort docs in order of best match\n\t\tvar docsSorted []document.SearchResult\n\t\tfor i, sid := range sIDs {\n\t\t\tfor _, d := range docs {\n\t\t\t\tif d.AnnoyID == sid {\n\t\t\t\t\td.Rank = distances[i] // set rank to distance\n\t\t\t\t\tdocsSorted = append(docsSorted, d)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tftsDocs, err := ds.FullTextSearch(b.Text)\n\t\tif err != nil {\n\t\t\terr = errors.Wrap(err, \"get search results\")\n\t\t\tweb.RespondError(w, r, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\n\t\t// Ranking System Process\n\t\t// ======================\n\n\t\t// 1. Start with distance from searchtext for annoy search results (set above when creating docsSorted)\n\t\t// ultimately combine fts results and annoy search results\n\t\tuniqResults := map[string]bool{}\n\t\tdocs = []document.SearchResult{}\n\n\t\t// 2. If sentence_id or document_id exists in fts subtract the relevancy in fts from distance\n\t\tfor _, d := range docsSorted {\n\t\t\tfor _, f := range ftsDocs {\n\t\t\t\tif d.SentenceID.String() == f.SentenceID.String() || d.DocumentID.String() == f.DocumentID.String() {\n\t\t\t\t\tif _, ok := uniqResults[d.SentenceID.String()]; ok {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t} else {\n\t\t\t\t\t\tuniqResults[d.SentenceID.String()] = true\n\t\t\t\t\t}\n\n\t\t\t\t\td.Rank = d.Rank - f.Rank\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdocs = append(docs, d)\n\t\t}\n\n\t\t// 3. use .8 - relevancy as rank for fts results, this ensures that by default fts results are ranked slightly better than semantic results\n\t\tfor _, f := range ftsDocs {\n\t\t\tif _, ok := uniqResults[f.SentenceID.String()]; ok {\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\tuniqResults[f.SentenceID.String()] = true\n\t\t\t}\n\n\t\t\tf.Rank = float32(math.Abs(float64(.8 - f.Rank)))\n\t\t\tdocs = append(docs, f)\n\t\t}\n\n\t\t// Finally, order by lowest rank first - rank is distance from current search\n\t\t// lower is better\n\t\tsort.Slice(docs, func(i, j int) bool {\n\t\t\treturn docs[i].Rank < docs[j].Rank\n\t\t})\n\n\t\tresult := SearchResponse{\n\t\t\tDistances: distances,\n\t\t\tDocuments: docs,\n\t\t}\n\n\t\tweb.Respond(w, r, http.StatusOK, result)\n\t}\n}", "title": "" }, { "docid": "5683e3ee2d2301625b5e154f1989a532", "score": "0.44230008", "text": "func (d *Dao) SearchSpecial(c context.Context, mid int64, arg *model.SearchTypeArg, buvid, ua string) (res *model.SearchTypeRes, err error) {\n\tvar (\n\t\tparams = url.Values{}\n\t\tip = metadata.String(c, metadata.RemoteIP)\n\t)\n\tparams = setSearchTypeParam(params, mid, model.SearchTypeSpecial, buvid, ip, arg)\n\tparams.Set(\"page\", strconv.Itoa(arg.Pn))\n\tparams.Set(\"vp_num\", strconv.Itoa(arg.VpNum))\n\tfor k, v := range model.SearchDefaultArg[model.SearchTypeSpecial] {\n\t\tparams.Set(k, strconv.Itoa(v))\n\t}\n\tvar req *http.Request\n\tif req, err = d.httpSearch.NewRequest(http.MethodGet, d.searchURL, ip, params); err != nil {\n\t\treturn\n\t}\n\treq.Header.Set(\"browser-info\", ua)\n\tres = new(model.SearchTypeRes)\n\tif err = d.httpSearch.Do(c, req, &res); err != nil {\n\t\tlog.Error(\"SearchSpecial d.httpSearch.Get(%s) error(%v)\", d.searchURL, err)\n\t\treturn\n\t}\n\tif res.Code != ecode.OK.Code() {\n\t\tlog.Error(\"SearchSpecial d.httpSearch.Get(%s) code(%d) error\", d.searchURL, res.Code)\n\t\terr = ecode.Int(res.Code)\n\t}\n\treturn\n}", "title": "" }, { "docid": "09c579659ca4fbdb6a27680a20d9fd0a", "score": "0.4422185", "text": "func (handler *DocumentHandler) handleSearchDoc(ctx context.Context, w http.ResponseWriter, r *http.Request, params netutil.UriParams) (context.Context, bool) {\n\tstartTime := time.Now()\n\toperateName := \"handleSearchDoc\"\n\tdefer monitor.Profiler(operateName, startTime)\n\tspan, ctx := opentracing.StartSpanFromContext(ctx, operateName)\n\tdefer span.Finish()\n\targs := &vearchpb.SearchRequest{}\n\targs.Head = setRequestHead(params, r)\n\tif args.Head.Params == nil {\n\t\tparams := make(map[string]string)\n\t\targs.Head.Params = params\n\t}\n\tspace, err := handler.docService.getSpace(ctx, args.Head.DbName, args.Head.SpaceName)\n\tif space == nil {\n\t\tresp.SendErrorRootCause(ctx, w, http.StatusBadRequest, \"\", \"dbName or spaceName param not build db or space\")\n\t\treturn ctx, true\n\t}\n\tif err != nil {\n\t\tresp.SendErrorRootCause(ctx, w, http.StatusBadRequest, \"\", \"query Cache space null\")\n\t\treturn ctx, false\n\t}\n\terr = docSearchParse(r, space, args)\n\tif err != nil {\n\t\tresp.SendErrorRootCause(ctx, w, http.StatusBadRequest, \"\", err.Error())\n\t\treturn ctx, false\n\t}\n\tserviceStart := time.Now()\n\tsearchResp := handler.docService.search(ctx, args)\n\tserviceCost := time.Now().Sub(serviceStart)\n\n\tvar bs []byte\n\tif searchResp.Results == nil || len(searchResp.Results) == 0 {\n\t\tsearchStatus := vearchpb.SearchStatus{Failed: 0, Successful: 0, Total: 0}\n\t\tbs, err = SearchNullToContent(searchStatus, serviceCost)\n\t} else {\n\t\tbs, err = ToContent(searchResp.Results[0], args.Head, serviceCost, space)\n\t}\n\n\tif err != nil {\n\t\tresp.SendErrorRootCause(ctx, w, http.StatusBadRequest, \"\", err.Error())\n\t\treturn ctx, true\n\t}\n\tresp.SendJsonBytes(ctx, w, bs)\n\tendTime := time.Now()\n\tlog.Debug(\"search total use :[%f] service use :[%f]\",\n\t\t(endTime.Sub(startTime).Seconds())*1000, serviceCost.Seconds()*1000)\n\treturn ctx, true\n}", "title": "" }, { "docid": "6119fd1dd191ea2fa2202d2375d7a46a", "score": "0.44202808", "text": "func TestSearch(t *testing.T) {\n\tdatastore, bookTable, deferFn := testhelper.SearchIn(t)\n\tdefer deferFn()\n\n\tserver := New(nil, &SearchIn{\n\t\tDatastore: datastore,\n\t\tBookTable: bookTable,\n\t})\n\n\tfor _, test := range []struct {\n\t\tqueryParams string\n\t\tresponse string\n\t\tstatus int\n\t}{\n\t\t{\n\t\t\tqueryParams: \"Wrong=10\",\n\t\t\tresponse: \"Unable to decode search query.\\n\",\n\t\t\tstatus: 400,\n\t\t},\n\t\t{\n\t\t\tqueryParams: \"Authors=Arthur&RatingFloor=4.3\",\n\t\t\tresponse: fmt.Sprint(\n\t\t\t\t\"[\\n\",\n\t\t\t\t\"\\t{\\n\",\n\t\t\t\t\"\\t\\t\\\"ID\\\": 3588,\\n\",\n\t\t\t\t\"\\t\\t\\\"Title\\\": \\\"The Adventures of Sherlock Holmes\\\",\\n\",\n\t\t\t\t\"\\t\\t\\\"Authors\\\": \\\"Arthur Conan Doyle-Eoin Colfer\\\",\\n\",\n\t\t\t\t\"\\t\\t\\\"AverageRating\\\": 4.31,\\n\",\n\t\t\t\t\"\\t\\t\\\"ISBN\\\": \\\"439574285\\\",\\n\",\n\t\t\t\t\"\\t\\t\\\"ISBN13\\\": \\\"9780439574280\\\",\\n\",\n\t\t\t\t\"\\t\\t\\\"LanguageCode\\\": \\\"eng\\\",\\n\",\n\t\t\t\t\"\\t\\t\\\"Pages\\\": 336,\\n\",\n\t\t\t\t\"\\t\\t\\\"RatingsCount\\\": 811,\\n\",\n\t\t\t\t\"\\t\\t\\\"ReviewsCount\\\": 86\\n\",\n\t\t\t\t\"\\t}\\n\",\n\t\t\t\t\"]\",\n\t\t\t),\n\t\t\tstatus: 200,\n\t\t},\n\t} {\n\t\tt.Run(\n\t\t\tfmt.Sprintf(\"title:%s\", test.queryParams),\n\t\t\tfunc(*testing.T) {\n\t\t\t\trecorder := recordResponse(t, fmt.Sprintf(\"/books?%s\", test.queryParams), \"/books\", server.search)\n\t\t\t\tif recorder.Code != test.status {\n\t\t\t\t\tt.Errorf(\"incorrect status, want: %d, got: %d\", test.status, recorder.Code)\n\t\t\t\t}\n\t\t\t\tif recorder.Body.String() != test.response {\n\t\t\t\t\tt.Errorf(\"incorrect response, want: %s, got: %s\", test.response, recorder.Body.String())\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\t}\n}", "title": "" }, { "docid": "285c9fec0b0d579aabb45890443b942d", "score": "0.44195178", "text": "func (hls HdfsLinkedService) AsAzureSearchLinkedService() (*AzureSearchLinkedService, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "83b12f5f55275026e7c224fee6323d16", "score": "0.44130158", "text": "func RunSearchEvent(e govent.Event) {\n\tif e, ok := e.(events.SearchEvent); ok {\n\t\trTask := NewRequestDriverTask(e.ID, e.UserID, e.Lat, e.Lon)\n\t\tgo rTask.Run()\n\t}\n}", "title": "" }, { "docid": "301d06c1350d0343179dd625c35c22b3", "score": "0.4404565", "text": "func TestEPToGateway(t *testing.T) {\n\tg := gomega.NewGomegaWithT(t)\n\tv := vsLister.VirtualService(\"default\")\n\tsvcs := v.GetVSToSVC(\"vs_1\")\n\n\t// Testing whether or not the EPToGateway() method works when we iterate over all the EP's and access the associated gateways\n\tfor _, ep := range svcs {\n\t\tgateways, _ := EPToGateway(ep, \"default\")\n\t\tflag, vs := istio_objs.SharedSvcLister().Service(\"default\").GetSvcToVS(ep)\n\t\tif flag {\n\t\t\tfor _, vsName := range vs {\n\t\t\t\tcheck, gateway := v.GetGatewaysForVS(vsName)\n\t\t\t\tif check {\n\t\t\t\t\tfor _, gw := range gateway {\n\t\t\t\t\t\t// Checking if each gateway(gw) element is in the gateways object obtained from the EPToGateway() method\n\t\t\t\t\t\tg.Expect(gateways).To(gomega.ContainElement(gw))\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// If there are no associated VS's to the Endpoint then there is an error\n\t\t\tt.Error(\"Error occurred\")\n\t\t}\n\t}\n\n\tsvcs = v.GetVSToSVC(\"vs_5\")\n\n\tif len(svcs) == 0 {\n\t\t_, found := EPToGateway(\"\", \"default\")\n\t\tg.Expect(found).To(gomega.Equal(false))\n\t} else {\n\t\tfor _, ep := range svcs {\n\t\t\tgateways, _ := EPToGateway(ep, \"default\")\n\t\t\tflag, vs := istio_objs.SharedSvcLister().Service(\"default\").GetSvcToVS(ep)\n\t\t\tif flag {\n\t\t\t\tfor _, vsName := range vs {\n\t\t\t\t\tcheck, gateway := v.GetGatewaysForVS(vsName)\n\t\t\t\t\tif check {\n\t\t\t\t\t\tfor _, gw := range gateway {\n\t\t\t\t\t\t\t// Checking if each gateway(gw) element is in the gateways object obtained from the EPToGateway() method\n\t\t\t\t\t\t\tg.Expect(gateways).To(gomega.ContainElement(gw))\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// If there are no associated VS's to the Endpoint then there is an error\n\t\t\t\tt.Error(\"Error occurred\")\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "21a90b20be444d62748a0d3b3a5f9f5a", "score": "0.44031188", "text": "func TestSpecialLearnRSearch(t *testing.T) {\n\ttestNum := 0 //Used for incrementing\n\tfor _, test := range LearnRSearchCrudCreators {\n\t\t//Go to special LearRs\n\t\tarrayOLearnRs, goodGet, message := getSpecialLearnRs(test.LearnRSearches.TheCases,\n\t\t\ttest.LearnRSearches.TheTag, test.LearnRSearches.LearnRName,\n\t\t\ttest.LearnRSearches.EntryFrom, test.LearnRSearches.EntryTo)\n\t\tif !goodGet {\n\t\t\tt.Fatal(\"Error from getSpecialLearnRs: \" + message)\n\t\t}\n\t\t//Check to see if returned Array matches test case size\n\t\tif len(arrayOLearnRs) != len(test.ExpectedLearnRID) {\n\t\t\tt.Fatal(\"Test case \" + strconv.Itoa(testNum) + \" failed, \" + \"Our array of LearnRs returned does not match our test case: \" + strconv.Itoa(len(arrayOLearnRs)) +\n\t\t\t\t\"TestNum: \" + strconv.Itoa(testNum) + \"\\n The test case was: \" + test.LearnRSearches.LearnRName + \" \" +\n\t\t\t\ttest.LearnRSearches.TheTag)\n\t\t}\n\t\tfor n := 0; n < len(arrayOLearnRs); n++ {\n\t\t\tif _, ok := test.ExpectedLearnRID[strconv.Itoa(arrayOLearnRs[n].ID)]; ok {\n\t\t\t\t//We have the ID we need\n\t\t\t} else {\n\t\t\t\tt.Fatal(\"The LearnRID is not found in our returned LearnRs: \" + strconv.Itoa(arrayOLearnRs[n].ID) +\n\t\t\t\t\tstrconv.Itoa(testNum))\n\t\t\t}\n\t\t}\n\t\ttestNum = testNum + 1\n\t}\n}", "title": "" }, { "docid": "bea5fdc300f2ee220aa2b1338382aa26", "score": "0.44026625", "text": "func (hls HTTPLinkedService) AsAzureSearchLinkedService() (*AzureSearchLinkedService, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "a57ab90bba41a539d06e724760a976ff", "score": "0.43975005", "text": "func (s *ServiceAPI) MonitorService(ctx context.Context, url string) (entity.ServiceResponse, error) {\n\tstartTime := time.Now()\n\n\t_, statusCode, err := s.restSvc.Do(ctx, http.MethodGet, url, nil, nil)\n\tif err != nil {\n\t\treturn entity.ServiceResponse{}, err\n\t}\n\n\telapsed := time.Since(startTime).Milliseconds()\n\n\treturn entity.ServiceResponse{\n\t\tStatusCode: statusCode,\n\t\tResponseTime: elapsed,\n\t}, nil\n}", "title": "" }, { "docid": "76e6666e71a7f8d3ec77a72d6a573628", "score": "0.43972796", "text": "func (r *WorkflowRead) search(q *msg.Request, mr *msg.Result) {\n\tvar (\n\t\terr error\n\t\tstatus, instanceID, checkID, repoID, configID string\n\t\tinstanceConfigID string\n\t\tversion int64\n\t\trows *sql.Rows\n\t\tactivatedNull, deprovisionedNull pq.NullTime\n\t\tupdatedNull, notifiedNull pq.NullTime\n\t\tcreated time.Time\n\t\tisInherited bool\n\t)\n\n\tworkflow := proto.Workflow{\n\t\tInstances: &[]proto.Instance{},\n\t}\n\n\tif rows, err = r.stmtSearch.Query(\n\t\tq.Workflow.Status,\n\t); err != nil {\n\t\tmr.ServerError(err, q.Section)\n\t\treturn\n\t}\n\tfor rows.Next() {\n\t\tif err = rows.Scan(\n\t\t\t&instanceID,\n\t\t\t&checkID,\n\t\t\t&repoID,\n\t\t\t&configID,\n\t\t\t&instanceConfigID,\n\t\t\t&version,\n\t\t\t&status,\n\t\t\t&created,\n\t\t\t&activatedNull,\n\t\t\t&deprovisionedNull,\n\t\t\t&updatedNull,\n\t\t\t&notifiedNull,\n\t\t\t&isInherited,\n\t\t); err != nil {\n\t\t\trows.Close()\n\t\t\tmr.ServerError(err, q.Section)\n\t\t\treturn\n\t\t}\n\t\tinstance := proto.Instance{\n\t\t\tID: instanceID,\n\t\t\tCheckID: checkID,\n\t\t\tRepositoryID: repoID,\n\t\t\tConfigID: configID,\n\t\t\tInstanceConfigID: instanceConfigID,\n\t\t\tVersion: uint64(version),\n\t\t\tCurrentStatus: status,\n\t\t\tIsInherited: isInherited,\n\t\t\tInfo: &proto.InstanceVersionInfo{\n\t\t\t\tCreatedAt: created.UTC().Format(msg.RFC3339Milli),\n\t\t\t},\n\t\t}\n\t\tif activatedNull.Valid {\n\t\t\tinstance.Info.ActivatedAt = activatedNull.\n\t\t\t\tTime.UTC().Format(msg.RFC3339Milli)\n\t\t}\n\t\tif deprovisionedNull.Valid {\n\t\t\tinstance.Info.DeprovisionedAt = deprovisionedNull.\n\t\t\t\tTime.UTC().Format(msg.RFC3339Milli)\n\t\t}\n\t\tif updatedNull.Valid {\n\t\t\tinstance.Info.StatusLastUpdatedAt = updatedNull.\n\t\t\t\tTime.UTC().Format(msg.RFC3339Milli)\n\t\t}\n\t\tif notifiedNull.Valid {\n\t\t\tinstance.Info.NotifiedAt = notifiedNull.\n\t\t\t\tTime.UTC().Format(msg.RFC3339Milli)\n\t\t}\n\t\t*workflow.Instances = append(*workflow.Instances,\n\t\t\tinstance)\n\t}\n\tif err = rows.Err(); err != nil {\n\t\tmr.ServerError(err, q.Section)\n\t\treturn\n\t}\n\tmr.Workflow = append(mr.Workflow, workflow)\n\tmr.OK()\n}", "title": "" }, { "docid": "9fea9f8f02d97e7ff6300de35875369e", "score": "0.43959105", "text": "func EqualServiceMonitor(found, desired *unstructured.Unstructured) bool {\n\treturn reflect.DeepEqual(found.GetLabels(), desired.GetLabels()) && reflect.DeepEqual(found.Object[\"spec\"], desired.Object[\"spec\"])\n}", "title": "" }, { "docid": "e4ffa14434c95cc24b12871d3a3665d2", "score": "0.43872702", "text": "func TestEnsureSVMWithRest(t *testing.T) {\n\tctx := context.Background()\n\n\t// create a config that is missing an SVM\n\tontapConfig := newOntapStorageDriverConfig()\n\tontapConfig.SVM = \"\"\n\n\t// ////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\t// negative case: no SVM set && we CANNOT derive an SVM because of a nil result\n\tmockRestClient := newMockRestClient(t)\n\tmockRestClient.EXPECT().SvmGetByName(ctx, gomock.Any()).AnyTimes()\n\tmockRestClient.EXPECT().SvmList(ctx, gomock.Any()).AnyTimes()\n\terr := api.EnsureSVMWithRest(ctx, ontapConfig, mockRestClient)\n\tassert.Equal(t, \"cannot derive SVM to use; please specify SVM in config file; result was nil\", err.Error())\n\n\t// ////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\t// negative case: no SVM set && we CANNOT derive an SVM because there are no matching records\n\tmockRestClient = newMockRestClient(t)\n\tmockRestClient.EXPECT().SvmGetByName(ctx, gomock.Any()).AnyTimes()\n\tmockRestClient.EXPECT().SvmList(ctx, gomock.Any()).DoAndReturn(\n\t\tfunc(ctx context.Context, pattern string) (*svm.SvmCollectionGetOK, error) {\n\t\t\tresult := &svm.SvmCollectionGetOK{\n\t\t\t\tPayload: &models.SvmResponse{},\n\t\t\t}\n\t\t\treturn result, nil\n\t\t},\n\t).AnyTimes()\n\terr = api.EnsureSVMWithRest(ctx, ontapConfig, mockRestClient)\n\tassert.Equal(t, \"cannot derive SVM to use; please specify SVM in config file\", err.Error())\n\n\t// ////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\t// positive case: no SVM set && we CAN derive an SVM\n\tsvmName := \"mySVM\"\n\tsvmUUID := svmName + \"U-U-I-D\"\n\tmockRestClient = newMockRestClient(t)\n\tmockRestClient.EXPECT().SvmList(ctx, gomock.Any()).DoAndReturn(\n\t\tfunc(ctx context.Context, pattern string) (*svm.SvmCollectionGetOK, error) {\n\t\t\tvar records []*models.Svm\n\t\t\trecords = append(records, &models.Svm{Name: utils.Ptr(svmName), UUID: utils.Ptr(svmUUID)})\n\t\t\tresult := &svm.SvmCollectionGetOK{\n\t\t\t\tPayload: &models.SvmResponse{\n\t\t\t\t\tNumRecords: utils.Ptr(int64((len(records)))),\n\t\t\t\t\tSvmResponseInlineRecords: records,\n\t\t\t\t},\n\t\t\t}\n\t\t\treturn result, nil\n\t\t},\n\t).AnyTimes()\n\tmockRestClient.EXPECT().SetSVMUUID(gomock.Any()).DoAndReturn(\n\t\tfunc(newUUID string) {\n\t\t\tassert.Equal(t, svmUUID, newUUID) // extra validation that it is set to the new value\n\t\t},\n\t).AnyTimes()\n\tmockRestClient.EXPECT().SetSVMName(gomock.Any()).DoAndReturn(\n\t\tfunc(newSvmName string) {\n\t\t\tassert.Equal(t, svmName, newSvmName) // extra validation that it is set to the new value\n\t\t},\n\t).AnyTimes()\n\terr = api.EnsureSVMWithRest(ctx, ontapConfig, mockRestClient)\n\tassert.Nil(t, err)\n}", "title": "" }, { "docid": "f1f31f0ab0b510e42f785d6816e34e3d", "score": "0.43870783", "text": "func TestVirtualMedia(t *testing.T) {\n\tvar result VirtualMedia\n\terr := json.NewDecoder(strings.NewReader(vmBody)).Decode(&result)\n\n\tif err != nil {\n\t\tt.Errorf(\"Error decoding JSON: %s\", err)\n\t}\n\n\tif result.ID != \"1\" {\n\t\tt.Errorf(\"Received invalid ID: %s\", result.ID)\n\t}\n\n\tif result.Name != \"VirtualMedia\" {\n\t\tt.Errorf(\"Received invalid name: %s\", result.Name)\n\t}\n\n\tif result.ejectMediaTarget != \"/redfish/v1/Managers/1/VirtualMedia/1/Actions/VirtualMedia.EjectMedia\" {\n\t\tt.Errorf(\"Received invalid EjectMedia Action target: %s\", result.ejectMediaTarget)\n\t}\n\n\tif result.insertMediaTarget != \"/redfish/v1/Managers/1/VirtualMedia/1/Actions/VirtualMedia.InsertMedia\" {\n\t\tt.Errorf(\"Received invalid InsertMedaiaAction target: %s\", result.insertMediaTarget)\n\t}\n\n\tif result.Inserted == true {\n\t\tt.Error(\"Expected Inserted to be false\")\n\t}\n\n\tif result.WriteProtected == false {\n\t\tt.Error(\"Expected WriteProtected to be true\")\n\t}\n\n\tif result.Image != \"https://example.com/mygoldimage.iso\" {\n\t\tt.Errorf(\"Expected Image to be 'https://example.com/mygoldimage.iso', got %s\", result.Image)\n\t}\n\n\tif result.ImageName != \"mygoldimage.iso\" {\n\t\tt.Errorf(\"Expected ImageName to be 'mygoldimage.iso', got %s\", result.ImageName)\n\t}\n\n\tif result.SupportsMediaInsert == false {\n\t\tt.Error(\"Expected SupportsMediaInsert to be true since target is set\")\n\t}\n}", "title": "" }, { "docid": "74164e1e3ef4d00db31dbab8c2f872ad", "score": "0.4381302", "text": "func (handler *GrpcHandler) SearchVehicles(query *proto.VehicleQuery, stream proto.VehicleStore_SearchVehiclesServer) error {\n\tqueryValues, err := url.ParseQuery(query.Query)\n\tif err != nil {\n\t\treturn status.Error(codes.InvalidArgument, err.Error())\n\t}\n\tresources, sErr := handler.Resource.Search(queryValues)\n\tif sErr != nil {\n\t\tcode := codes.Internal\n\t\tif sErr.StatusCode == http.StatusBadRequest {\n\t\t\tcode = codes.InvalidArgument\n\t\t}\n\t\treturn status.Error(code, sErr.Error.Error())\n\t}\n\tfor _, resource := range resources {\n\t\tv := resource.(proto.Vehicle)\n\t\tif err = stream.Send(&v); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "0499558446ed1cc51ed684ad0c499de4", "score": "0.43723276", "text": "func TestServiceMethod(t *testing.T) {\n\tvar service *res.Service\n\trunTest(t, func(s *Session) {\n\t\tservice = s.Service\n\t\ts.Handle(\"model\", res.GetModel(func(r res.ModelRequest) {\n\t\t\tif r.Service() != service {\n\t\t\t\tt.Errorf(\"expected resource request Service() to return the service instance, but it didn't\")\n\t\t\t}\n\t\t\tr.NotFound()\n\t\t}))\n\t}, func(s *Session) {\n\t\t// Test getting the model\n\t\t// TODO: This should be broken because of .foo. Why isn't it?\n\t\ts.Request(\"get.test.model.foo\", nil)\n\t\ts.GetMsg(t)\n\t})\n}", "title": "" }, { "docid": "015fd0f623e3df41ac6dd5a7ef90be61", "score": "0.43717024", "text": "func (fsls FileServerLinkedService) AsAzureSearchLinkedService() (*AzureSearchLinkedService, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "625c8087eaf17cf17d08e8c04a9d8c7b", "score": "0.43659937", "text": "func RunPropertyAssignmentTestForSearchService_Spec(subject SearchService_Spec) string {\n\t// Copy subject to make sure assignment doesn't modify it\n\tcopied := subject.DeepCopy()\n\n\t// Use AssignPropertiesTo() for the first stage of conversion\n\tvar other v20220901s.SearchService_Spec\n\terr := copied.AssignProperties_To_SearchService_Spec(&other)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Use AssignPropertiesFrom() to convert back to our original type\n\tvar actual SearchService_Spec\n\terr = actual.AssignProperties_From_SearchService_Spec(&other)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// Check for a match\n\tmatch := cmp.Equal(subject, actual, cmpopts.EquateEmpty())\n\tif !match {\n\t\tactualFmt := pretty.Sprint(actual)\n\t\tsubjectFmt := pretty.Sprint(subject)\n\t\tresult := diff.Diff(subjectFmt, actualFmt)\n\t\treturn result\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "bcd62555e257ae700bab7665bef73a87", "score": "0.43646368", "text": "func (conn Connection) SearchSync(searchString string, outputMode string) (string, error) {\n\tdata := make(url.Values)\n\tdata.Add(\"search\", searchString)\n\tdata.Add(\"max_time\", \"30\")\n\tdata.Add(\"earliest_time\", \"-10m\")\n\tdata.Add(\"latest_time\", \"now\")\n\tdata.Add(\"output_mode\", outputMode)\n\n\tresponse, err := conn.httpPost(fmt.Sprintf(\"%s/services/search/jobs/export\", conn.BaseURL), &data)\n\treturn response, err\n}", "title": "" }, { "docid": "8727b41186d73d28b69de52ca843e52f", "score": "0.43631867", "text": "func (s *LightService) Search(ctx context.Context) (*Response, error) {\n\treq, err := s.client.newRequest(http.MethodPost, s.lightServicePath(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar apiResponses []ApiResponse\n\tresp, err := s.client.do(ctx, req, &apiResponses)\n\tif err != nil {\n\t\treturn resp, err\n\t}\n\n\tif len(apiResponses) == 0 || (apiResponses)[0].Error != nil {\n\t\treturn resp, errors.New((apiResponses)[0].Error.Description)\n\t}\n\n\treturn resp, nil\n}", "title": "" }, { "docid": "6bff51d35f6fae6038378260b7a6f6e7", "score": "0.4362421", "text": "func (req SearchRequest) PerformSearch() (*SearchResult, error) {\n\n\tpage := SearchResult{}\n\n\tredirect := DetectBang(req.Query, req.Lang)\n\n\tif redirect != \"\" {\n\t\tpage.Redirect = redirect\n\t\treturn &page, nil\n\t}\n\n\tif Config.TestData {\n\t\treturn req.GenerateTestData(), nil\n\t}\n\n\ttextEsBody, err := req.BuildTextRequest()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// fmt.Println(textEsBody)\n\n\ttextSearchResult, textRequestTime, err := ElasticsearchRequest(\n\t\tElasticsearchTextClient,\n\t\t\"/text/page/_search\",\n\t\ttextEsBody)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tpage.Timing.TextRequest = uint32(textRequestTime.Seconds() * 1000000)\n\tpage.Timing.TextQuery = uint32(textSearchResult.TookInMillis * 1000)\n\n\t// No results!\n\tif textSearchResult.Hits == nil || len(textSearchResult.Hits.Hits) == 0 {\n\t\treturn &page, nil\n\t}\n\n\t// TODO: use ES count to determine that\n\t// TODO: also return textSearchResult.Hits.TotalHits\n\tpage.HasMore = (len(textSearchResult.Hits.Hits) >= Config.ResultPageSize)\n\tpage.TotalCount = textSearchResult.Hits.TotalHits\n\tdocsEsBody := BuildDocsRequest(textSearchResult)\n\n\tdocsSearchResult, docsRequestTime, err := ElasticsearchRequest(\n\t\tElasticsearchDocsClient,\n\t\t\"/docs/page/_search?fields=title,summary,url&size=100\",\n\t\tdocsEsBody)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tpage.Timing.DocsRequest = uint32(docsRequestTime.Seconds() * 1000000)\n\tpage.Timing.DocsQuery = uint32(docsSearchResult.TookInMillis * 1000)\n\n\t// No results! This shouldn't happen, are we missing documents?\n\tif docsSearchResult.Hits == nil {\n\t\treturn &page, nil\n\t}\n\n\thitsByIds := make(map[string]*Hit, len(docsSearchResult.Hits.Hits))\n\n\t// Iterate through results and convert them in their final struct\n\tfor _, hit := range docsSearchResult.Hits.Hits {\n\t\thitsByIds[hit.Id] = &Hit{\n\t\t\tID: hit.Id,\n\t\t\tURL: hit.Fields[\"url\"].([]interface{})[0].(string),\n\t\t\tTitle: hit.Fields[\"title\"].([]interface{})[0].(string),\n\t\t\tSummary: hit.Fields[\"summary\"].([]interface{})[0].(string)}\n\n\t\thitsByIds[hit.Id].Title = AddHighlighting(hitsByIds[hit.Id].Title, req.Query)\n\t\thitsByIds[hit.Id].Summary = AddHighlighting(hitsByIds[hit.Id].Summary, req.Query)\n\n\t}\n\n\t// Restore the original order of the text results.\n\tfor _, hit := range textSearchResult.Hits.Hits {\n\t\tif hitsByIds[hit.Id] != nil {\n\t\t\tpage.Hits = append(page.Hits, *hitsByIds[hit.Id])\n\t\t}\n\t}\n\n\treturn &page, nil\n}", "title": "" }, { "docid": "193d13b7dfa9012b020f291e21f467eb", "score": "0.43618128", "text": "func TestInvokeNetService_happy(t *testing.T) {\n\tsetupServices(t)\n\tl, err := net.Listen(\"tcp\", \"127.0.0.1:0\")\n\tif err != nil {\n\t\tt.Fatal(\"Oops\", err)\n\t}\n\tdefer l.Close()\n\taddr := l.Addr()\n\tt.Log(\"Address: \", addr)\n\n\tservice, _ := ServiceRegister.FindService(\"net\", \"-addr\", addr.String())\n\tt.Log(\"Service: \", service)\n\n\ttestFn := func(in []byte) {\n\t\tgo func() {\n\t\t\tcon, err := l.Accept()\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(err)\n\t\t\t}\n\t\t\tt.Log(\"Got connection: \", con)\n\t\t\tdefer con.Close()\n\t\t\tcon.SetReadDeadline(time.Now().Add(time.Millisecond * 10))\n\n\t\t\tret, err := readAvailable(con)\n\t\t\tt.Log(\"Read \", len(ret), \"b :\", string(ret), \" with Err: \", err)\n\t\t\treverseBytes(ret)\n\t\t\ti, _ := con.Write(ret)\n\t\t\tt.Log(\"Wrote \", i, \"b\")\n\t\t}()\n\t\tres, err := service.Invoke(in)\n\t\tresb := res.([]byte) // Evil convert\n\t\tt.Log(\"Got \", len(resb), \"b: \", string(resb), \": \", err)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\n\t\treverseBytes(resb)\n\t\tif string(resb) != string(in) {\n\t\t\tt.Error(\"Expected '\", len(string(in)), \"', but got '\", len(string(resb)), \"'\")\n\t\t}\n\t}\n\n\ttestFn([]byte(\"This is just a test\"))\n\ttestFn([]byte(\"This is a really really long test. it needs to be exactly 1024 bytes to make sure that we handle buffers right 降告済南務国上初座役財暮表送合。注大受現情観梨国中諸組分旧負愛。言本近替栄信義生極上検掲効。際転武述郎料作感力務庭図男稿。聞査井半准平全要捕駆千場。板佐動歳家対馬更市残機一。購最見大倍失断全子謙実持車写連成銀傘経各財。択平苦金載天然元化中異話報夜比。療索東多亡時載予天図職東民案話記避。演提止次者志歳企額住更札止団。署民非載惜球変料覚芸部総議影球上鶏。具民患報演甲金訳済社公階送速彼写学。返記規対本委観横戦能爆初問代野。将新紙第綸定目鍋旅乗住期前改院学内断失断全子謙実持車写連成銀傘経各財。択平苦金載天然元化中異話報夜比。療索東多亡時載予天図職東民案話記避。演提止次者志歳企額住更札止団。署民非載惜球and some more\"))\n\n\ttestFn([]byte(\"This is a really really long test. it needs to be over 1024 bytes to make sure that we handle buffers right\" +\n\t\t\"降告済南務国上初座役財暮表送合。注大受現情観梨国中諸組分旧負愛。言本近替栄信義生極上検掲効。際転武述郎料作感力務庭図男稿。聞査井半准平全要捕駆千場。板佐動歳家対馬更市残機一。購最見大倍果行果彦円使何。創選安朝実応避味作力念媛竹損村米需日楽。路岡形範供体定合無不軽利動。投子改空航強予理豊産以蹊点利戦海検。\" +\n\t\t\"失断全子謙実持車写連成銀傘経各財。択平苦金載天然元化中異話報夜比。療索東多亡時載予天図職東民案話記避。演提止次者志歳企額住更札止団。署民非載惜球変料覚芸部総議影球上鶏。具民患報演甲金訳済社公階送速彼写学。返記規対本委観横戦能爆初問代野。将新紙第綸定目鍋旅乗住期前改院学内断。資法知海戦載見得幸都伊追試週統。Did we get it?\"))\n}", "title": "" }, { "docid": "d6f3a6667e3af79947918a7b624d52b4", "score": "0.43599552", "text": "func ExecuteServiceTest(testDefinition *TestDefinition, loadPerUser int, remainder int, configurationSettings *perfTestUtils.Config, mode int) int64 {\n\n\taverageResponseTime := int64(0)\n\tresponseTimes := make([]int64, 0)\n\tsubsetOfResponseTimesChan := make(chan perfTestUtils.RspTimes, 1)\n\n\ttargetHost, targetPort := determineHostandPortforRequest(testDefinition, configurationSettings)\n\n\tvar wg sync.WaitGroup\n\twg.Add(configurationSettings.ConcurrentUsers)\n\tfor i := 0; i < configurationSettings.ConcurrentUsers; i++ {\n\t\tgo buildAndSendUserRequests(subsetOfResponseTimesChan, loadPerUser, testDefinition, configurationSettings.RequestDelay, targetHost, targetPort)\n\t\tgo aggregateResponseTimes(&responseTimes, subsetOfResponseTimesChan, &wg)\n\t}\n\tif remainder > 0 {\n\t\twg.Add(1)\n\t\tgo buildAndSendUserRequests(subsetOfResponseTimesChan, remainder, testDefinition, configurationSettings.RequestDelay, targetHost, targetPort)\n\t\tgo aggregateResponseTimes(&responseTimes, subsetOfResponseTimesChan, &wg)\n\t}\n\n\twg.Wait()\n\n\tif len(responseTimes) == configurationSettings.NumIterations {\n\t\taverageResponseTime = perfTestUtils.CalcAverageResponseTime(responseTimes, mode)\n\t}\n\treturn averageResponseTime\n}", "title": "" }, { "docid": "fd84835ba48c2e15c3ac319bb47886c0", "score": "0.43470988", "text": "func (sq *SingleQuery) QuerySearch() (containResources []string, err error) {\n\t// validate request\n\tif len(sq.Sites) == 0 {\n\t\terr = fmt.Errorf(\"Empty list of resources\")\n\t\treturn containResources, err\n\t}\n\t// define resources\n\tresources := newResources(sq.Sites)\n\tvar wg sync.WaitGroup\n\tchResults := make(chan searchItem, len(sq.Sites))\n\t// process seasrch by resources\n\tfor _, res := range resources {\n\t\twg.Add(1)\n\t\tgo func(ch chan searchItem, res resource) {\n\t\t\tcontent, err := res.getContent()\n\t\t\tif err != nil {\n\t\t\t\tresult := searchItem{\n\t\t\t\t\tquery: sq.Search,\n\t\t\t\t\tresourceHref: res.string(),\n\t\t\t\t\terr: err,\n\t\t\t\t}\n\t\t\t\tch <- result\n\t\t\t\twg.Done()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsq.searchSingleResource(sq.Search, content, res.string(), &wg, ch)\n\t\t}(chResults, res)\n\n\t}\n\tgo func() {\n\t\twg.Wait()\n\t\tclose(chResults)\n\t}()\n\tvar errSearch searchErrors\n\thasSuccessResponse := false\n\tfor result := range chResults {\n\t\t//fmt.Printf(\">>>GOT RESULT: %s\\t%s\\t%t\\t%v\\n\", result.query, result.resourceHref, result.searchResult, result.err)\n\t\tif result.err != nil {\n\t\t\terrSearch.addError(result.resourceHref, result.err)\n\t\t\tcontinue\n\t\t}\n\t\thasSuccessResponse = true\n\t\tif result.searchResult {\n\t\t\tcontainResources = append(containResources, result.resourceHref)\n\t\t\tcontinue\n\t\t}\n\t\ter := fmt.Errorf(\"resource does not contains [%s]\", result.query)\n\t\terrSearch.addError(result.resourceHref, er)\n\t}\n\tif len(containResources) == 0 && !hasSuccessResponse { // for case when no one resource doesn't containr search string\n\t\terr = fmt.Errorf(\"Search result error, %s\", errSearch.string())\n\t}\n\treturn containResources, nil\n}", "title": "" }, { "docid": "f200cbab6f52ae7e362a845d42bfc7af", "score": "0.4344838", "text": "func NewProductSearchService(t interface {\n\tmock.TestingT\n\tCleanup(func())\n}) *ProductSearchService {\n\tmock := &ProductSearchService{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "title": "" }, { "docid": "f87ec40097fb29ddbf3f86e148644f67", "score": "0.43390924", "text": "func TestDBES_find(t *testing.T) {\n\tsv := new(ElasticSearchDB)\n\tsv.NewAdapter()\n\tif sv.Client == nil {\n\t\tlog.Println(\"client nil\")\n\t\treturn\n\t}\n\ttotal, list, err := sv.Search(\"test\", `{\"query\" : { \"match\" : { \"title\" : \"test\" } }}`)\n\tlog.Println(\"total=\", total)\n\tlog.Println(\"err=\", err)\n\tif total > 0 {\n\t\tfor _, v := range list {\n\t\t\tlog.Printf(\"v=%+v\\n\", v)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "a40c3bd15ffc7281a454b7fc76af600c", "score": "0.4336616", "text": "func (odls ODataLinkedService) AsAzureSearchLinkedService() (*AzureSearchLinkedService, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "7957fa4bbd49d1ebe1105f2535da9cbe", "score": "0.43353185", "text": "func (cdls CosmosDbLinkedService) AsAzureSearchLinkedService() (*AzureSearchLinkedService, bool) {\n\treturn nil, false\n}", "title": "" }, { "docid": "16e81f267958bcf1a25ed9abb462597a", "score": "0.43249115", "text": "func main() {\n\tvar esURL = os.Getenv(\"ELASTIC_URL\")\n\tQueryEndpoint = os.Getenv(\"QUERY_SERVICE_ENDPOINT\")\n\tif esURL == \"\" {\n\t\t//esURL = \"http://elasticsearch-discovery.foremast.svc.cluster.local:9200/\"\n\t\tesURL = \"http://localhost:9200/\"\n\t}\n\tif QueryEndpoint == \"\" {\n\t\t// QueryEndpoint = \"http://prometheus-k8s.monitoring.svc.cluster.local:9090/\"\n\t\tQueryEndpoint = \"http://loalhost:9090/\"\n\t}\n\n\tvar err error\n\t// Create Elastic client and wait for Elasticsearch to be ready\n\tfor {\n\t\telasticClient, err = elastic.NewClient(\n\t\t\telastic.SetURL(esURL),\n\t\t\telastic.SetSniff(false),\n\t\t)\n\t\tif err != nil {\n\t\t\tlog.Println(\"failed to reach elasticsearch endpoint \", err)\n\t\t\t// Retry every 3 seconds\n\t\t\ttime.Sleep(3 * time.Second)\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\t// fill up queue\n\tfillQueueFromES()\n\n\trouter := gin.Default()\n\tv1 := router.Group(\"/v1/healthcheck\")\n\t{\n\t\t//search by id\n\t\tv1.GET(\"/id/:id\", SearchByID)\n\t\t//create request\n\t\tv1.POST(\"/create\", RegisterEntry)\n\n\t\t//v1.POST(\"/proxyquery\", ProxyQuery)\n\t}\n\tv2 := router.Group(\"/api/\")\n\t{\n\t\t//find open request\n\t\tv2.GET(\"/v1/getrequest\", GetOpenRequest)\n\t}\n\n\tv3 := router.Group(\"/alert\")\n\t{\n\t\t// get hpa info for namespace/app\n\t\tv3.GET(\"/:appName/:namespace/:strategy\", HpaAlert)\n\t}\n\n\tif err = router.Run(\":8099\"); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "title": "" } ]
306cd6caa9d13243e43dd492c289c35f
SetTimeout adds the timeout to the find git branch params
[ { "docid": "1a0dccaebc061eb79e1d092ba5809fde", "score": "0.82649225", "text": "func (o *FindGitBranchParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" } ]
[ { "docid": "eb4d61fa206320ce3efcde6749e8eb11", "score": "0.75898784", "text": "func (o *FindGitBranchParams) WithTimeout(timeout time.Duration) *FindGitBranchParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "title": "" }, { "docid": "a4b255f69c6152a5ce938d076c364c1a", "score": "0.68710476", "text": "func (o *RunGitConnectionTestParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "0eb430f2dc34bb24f6c8b6bccd6aa248", "score": "0.66988593", "text": "func (o *AllGitConnectionTestsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "64cc1f6b80bc6cda332d9ead0f952c39", "score": "0.6505223", "text": "func (o *GetGerritProjectsByIDUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "5908f4427d69e9c26c9377f0d050fd1e", "score": "0.64855945", "text": "func (o *GetBuildChangesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "2e85d88e87d42a24709bb2d2246a613e", "score": "0.6443317", "text": "func NewFindGitBranchParamsWithTimeout(timeout time.Duration) *FindGitBranchParams {\n\tvar ()\n\treturn &FindGitBranchParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "title": "" }, { "docid": "3880c8640ddb9ec16fe63beef5d022ae", "score": "0.6422462", "text": "func (o *LinkGithubAccountParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "d31a28791baf428da0094a8f4fb31985", "score": "0.6314695", "text": "func (o *ConductRepoSearchParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "cd1589deabddd52871fe3941e9cdac2f", "score": "0.6125325", "text": "func (o *GetCurrentByZIPCodeParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "3eabaf8f55325a9a8d11cf7576979693", "score": "0.6061878", "text": "func (o *ResumeOrRerunGitEventUsingPOSTParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "a8605628ed9f1e201fc63c12cde9f3bd", "score": "0.6026154", "text": "func (o *GetBlobParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "8293e7f06779508d0d018655bf26327f", "score": "0.59911", "text": "func (o *PostChartrepoRepoChartsNameVersionLabelsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "10b09982aeefe72e1302797dca3dbaac", "score": "0.5985031", "text": "func (o *SearchRelativeChunkedParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "cd88ac25d1a2af65cf49dc0cd1ea1c75", "score": "0.5982585", "text": "func (o *PostChartrepoRepoProvParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "d1d79812b313c246ff4c4b43691a590b", "score": "0.5937182", "text": "func (o *GetDeploymentsUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "c957ce78a7456ed459a2dc7fc82c1e35", "score": "0.5928144", "text": "func (o *GetConsoleHistoryContentParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "adbdbc371df1c5e67c942578e274658f", "score": "0.5919774", "text": "func (o *OrderStatusFeedUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "a69f9231186442b457fbe8e11dd35d5e", "score": "0.5908537", "text": "func (o *DeleteChartrepoRepoChartsNameVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "f28b1eff8fc4ffb416321779683ae243", "score": "0.58786064", "text": "func (o *GetDeploymentExpenseHistoryByIDUsingGET2Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "42e86edb5555fc3eeb119c34fec66495", "score": "0.5866873", "text": "func (o *ListRepoTokensParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "8d37b33f01bef2e2b8f1def0fc401390", "score": "0.5857274", "text": "func (o *RepoCreateReleaseParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "b61becfd032428bc56eacff2af1b4819", "score": "0.5852648", "text": "func (o *RunGitConnectionTestParams) WithTimeout(timeout time.Duration) *RunGitConnectionTestParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "title": "" }, { "docid": "0d5abdfc5339c7aee2a636d536eac6b1", "score": "0.5849507", "text": "func (o *GetCurrentByCityNameParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "ebda0eda589a1786d8fc13824f685e83", "score": "0.584567", "text": "func (o *GetComponentByIDUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "65df2ccbda34cddcf04957e7519d86fd", "score": "0.58324337", "text": "func (o *SnitchRackGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "81a5dd3822b35a2bcac47aea40a4fe3a", "score": "0.5831785", "text": "func (o *GetLolClashV1ScoutingMatchhistoryParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "24b1726c7ad8ce8b6a9dd4d64a1862d8", "score": "0.581471", "text": "func (o *ForumGetPostAndParentAwaitingApprovalParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "e571669324bff827a82fcadf0af1c848", "score": "0.57983154", "text": "func (o *GetPackageVersionSearchParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "b5d0fad50d418da48f06019b23a2350d", "score": "0.5763068", "text": "func (o *GetBulletinBoardParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "ed83050efd6df68a2240511a64302f2d", "score": "0.57384694", "text": "func (o *GetEventsByStackNameInWorkspaceParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "ba0642c9a757f903170c86d97bd7efa3", "score": "0.573073", "text": "func (o *GetDomainZoneZoneNameHistoryParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "aad59ee7a5996f4d3ca2677bd5858380", "score": "0.5724896", "text": "func (o *TeamSearchParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "71497118ca07ee825de2bb58b538eaac", "score": "0.5723594", "text": "func (o *FindParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "5ca00b395ee5f56b9387b81ddf9cce2d", "score": "0.5716675", "text": "func (o *SearchRelativeParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "8cc73437000f9018c46a7f9bc5c58c86", "score": "0.5679027", "text": "func (o *GetBundleAuditLogsWithHistoryParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "79ff4e379146a44a25ee4b2fd78ab427", "score": "0.567619", "text": "func (o *PullImageParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "17de66af8fe3fed109a662628dbdb488", "score": "0.5675907", "text": "func (o *GetSuggestionsUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "1828aa6fe7ad16f4d79f4499265c480f", "score": "0.56620586", "text": "func (o *PatchHclHyperflexSoftwareCompatibilityInfosMoidParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "4e7e7c52ac3a627b8ce9a1e58c70235c", "score": "0.5652094", "text": "func (o *GetLibraryAPIVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "f2002a864047e9e724db716a06cfe584", "score": "0.56473124", "text": "func (o *GetTestRunCodeCoverageParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "951efe766faff109f235eb2ab54cc788", "score": "0.5641819", "text": "func (o *GetDatabasesDatabaseIDDependentsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "e22e34bf8ae58eb9e75b2d951da193ee", "score": "0.56375015", "text": "func (o *GetSmbShareParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "3822a5effdf0e4397fc8d9d4332e9513", "score": "0.5615496", "text": "func (o *NetworkInspectParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "8dbb19f2b838636711afb327fdcc8218", "score": "0.56034654", "text": "func (o *PostChartrepoChartsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "e281656bf729c22767ac104361ce255b", "score": "0.55979013", "text": "func (o *PatchWorkflowLinkParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "411056cea434bcd683cf664bfa48437d", "score": "0.55915755", "text": "func (o *GetUserIssueSearchOptionsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "4096f3fab00668443cbc3ad277f17a5e", "score": "0.5590102", "text": "func (o *GetSubaccountParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "0091acd9075645a500dfca2d945f5243", "score": "0.55777997", "text": "func (o *PostLolEndOfGameV2PlayerComplaintsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "39f712a5acde0bdf22b5bb1d279ef8a3", "score": "0.55708164", "text": "func (o *GetContentSelectorParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "20f4bb934e8fec625e1167152ea2d70c", "score": "0.5566222", "text": "func (o *GetLolLobbyV1CustomGamesByIDParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "efbc5757d8093cdb58b4b7e08cdf6cde", "score": "0.55627376", "text": "func (o *GetPrivateGetOrderHistoryByInstrumentParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "d3e4a351a15272c7c4bdecc72ff35134", "score": "0.5559523", "text": "func (o *GetProjectByIDParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "53e8f62b7171c17daebd9b5912298ef8", "score": "0.555184", "text": "func (o *AllGitConnectionTestsParams) WithTimeout(timeout time.Duration) *AllGitConnectionTestsParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "title": "" }, { "docid": "2e7a0e21b820b233aa2b235f1ce8f152", "score": "0.55494493", "text": "func (o *GetForSubcategoryParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "bba5dd696bafeb87de04f500dc06f648", "score": "0.5542947", "text": "func (o *GetLolMatchHistoryV2MatchlistParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "b649fb4bdc10d1e8aa381f9b64fa40ee", "score": "0.5539413", "text": "func (o *DeletePackageVersionFromRecycleBinParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "2a5ff1914a96c214d632ea3a4899002b", "score": "0.55384415", "text": "func (o *GetBasketsByIDPaymentMethodsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "a674b202b185131d20472b1be6213d67", "score": "0.55371684", "text": "func (o *fetchOpts) setTimeout() {\n\tif o.timeout != 0 {\n\t\tif o.verbose {\n\t\t\tfmt.Printf(\"... setting download timeout to %d seconds\", o.timeout)\n\t\t}\n\t\tcl.Timeout = time.Second * time.Duration(o.timeout)\n\t}\n}", "title": "" }, { "docid": "a6522cf5b78ac366d5348d229f6af95c", "score": "0.5534461", "text": "func (o *RegisterBareMetalHostParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "78be738a4e71be373f7004337d15a5c7", "score": "0.5523893", "text": "func (o *GetDeploymentsByProjectReportParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "21dd3f54ff415796a9656f785e433ece", "score": "0.5515732", "text": "func (o *VoucherStatusSearchParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "4c38b80c83092e2c76c2b7305aea7b2e", "score": "0.55147237", "text": "func (o *GetAPIV3MachinesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "41a0351ba43943a45eab57756c2f1712", "score": "0.5509928", "text": "func (o *SetRefereeParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "ccfa9d6d8993037146000699560a091f", "score": "0.550867", "text": "func (o *GetFegNetworkIDClusterStatusParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "ccd9066c3398989817680b1a8f0e96e6", "score": "0.550859", "text": "func (o *DownloadInfraEnvDiscoveryImageParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "bd0d91a64d239426f13819fd33054712", "score": "0.55081534", "text": "func (o *GetChannelSiteParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "6e5f6dc976a362da86cbc15d31463cb5", "score": "0.5500552", "text": "func (o *GetFlowChainsStatusesByChainIdsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "38777d297dfd5c4f853872392d6b91e5", "score": "0.549739", "text": "func (o *GetStackMatrixUtilParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "588d1a38529d2cfce272fd57692ffd1c", "score": "0.5493647", "text": "func (o *CreateDefectReportedParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "cf2b7c179e0d5c14467e3606f5bfc9fe", "score": "0.5485556", "text": "func (o *GetSnapshotRepstateParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "4c91f5566a173f3bcc7e4e2f6b6398ae", "score": "0.54843056", "text": "func (o *BatchGetCmdParams) SetTimeout(timeout *int64) {\n\to.Timeout = timeout\n}", "title": "" }, { "docid": "52d2bb4b0bf4d11130e2c60d5fefadb8", "score": "0.5478338", "text": "func (o *DownloadInfraEnvDiscoveryImageHeadersParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "9839574dad6af5a08a53b2ac9ba1f237", "score": "0.5467772", "text": "func (o *AddLibraryAPIVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "372da0ac1d9257d9ab91be6cf7bcf435", "score": "0.5464065", "text": "func (o *GetVrackServiceNameTaskTaskIDParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "4fde53c0f2efb58a71f3394b2b0be306", "score": "0.5463798", "text": "func (o *StatusGetMonitorStatusParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "672b290eb2ff7386426e429e4fc30f2e", "score": "0.54621506", "text": "func (o *GetAPIV3MachinesRfqdnNicsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "0b425f72ece5cb3eaa004dfb7dd60993", "score": "0.54559344", "text": "func (o *PatchSepaddIDParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "389ddf5fc9b459335e31f41831713aeb", "score": "0.5455006", "text": "func (o *PatchAllowedRegistryParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "b836b251511a6c1bf2be1135c032e850", "score": "0.54536366", "text": "func (o *NearestUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "5fd821faa4354bada4ab43f7aceff3ca", "score": "0.5450947", "text": "func (o *GetAcrV1NameTagsReferenceMetadataMetadataParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "49dc6ce24e8f3919ff6e8c164dcefa6a", "score": "0.54501504", "text": "func (o *GetCloudTowerApplicationPackagesConnectionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "3df682c6ce80288ae28b17863eb2b15f", "score": "0.5442336", "text": "func (o *GetRealBrowserCheckRunParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "c3f6517a706de098255b6a8e586573e8", "score": "0.5439087", "text": "func (o *GetIconParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "a109a9f39bc8bd55689982f87f74b957", "score": "0.54323834", "text": "func (o *GetDeploymentActionUsingGET2Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "912ecf833d29b342319d50d03694780f", "score": "0.54285055", "text": "func (o *UpdateCustomTagOfIssueTemplateParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "866553c776e86a72103d53fc47ae9ff1", "score": "0.5427711", "text": "func (o *GetPtzStatusParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "54d64333f3442a5db4915303acf4e7c9", "score": "0.54273206", "text": "func (o *ReimportRealBrowserCheckParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "0a5c7e66775da6df03ca0c975fcbd178", "score": "0.54237664", "text": "func (o *DomainModelLevelFindListParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "26a19dc0a10639b2851b1ac5e59eb876", "score": "0.54223496", "text": "func (o *GetNetworksNetworkIDTiersTierIDParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "23a86dcc11df9ce54471653f9e6a4f71", "score": "0.5422243", "text": "func (o *LineGetByModeParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "2f6eecd89b3c8ee18d750ac56ba9d0e4", "score": "0.5419468", "text": "func (o *GetBackendParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "5ed834b1652b68efd605bd8f72c3c51e", "score": "0.54184955", "text": "func (o *HooksGetByIDParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "51cd52be4a20b5742a55a06fc278ad2f", "score": "0.5413474", "text": "func (o *GetVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "64048582f5087ee5847e9b6b94a7b110", "score": "0.5411714", "text": "func (o *PutLolHighlightsV1HighlightsByIDParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "3ed0e2b04fa724396257181943ee8202", "score": "0.54093724", "text": "func (o *GetNfsSettingsZoneParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "335d76a7bab79b618eb2256c14b2705c", "score": "0.54090774", "text": "func (o *ChangeTagImageParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "7d1e400c4f3af764372f2a114c534636", "score": "0.5408961", "text": "func (o *GetPrivateTradehistoryParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "2d2c2b4cee2d3c6f27b7bb75a936c42b", "score": "0.5408324", "text": "func (o *MultiDeleteProjectVersionOfAuthEntityParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "059978ccecd66d903a881e0ce71d321d", "score": "0.54048806", "text": "func (o *GetLolClashV1TournamentByTournamentIDParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" }, { "docid": "3e1fb4863ba1d7baf6790e2e85811588", "score": "0.5401544", "text": "func (o *ImportSpecificationFromURLParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "title": "" } ]
8d433f4de04a95a34cba9eba80020ae7
InetSameFamily calls the stored procedure 'pg_catalog.inet_same_family(inet, inet) boolean' on db.
[ { "docid": "69707d0637da932733dca0fbf9719bd4", "score": "0.8664996", "text": "func InetSameFamily(db XODB, v0 string, v1 string) (bool, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.inet_same_family($1, $2)`\n\n\t// run query\n\tvar ret bool\n\tXOLog(sqlstr, v0, v1)\n\terr = db.QueryRow(sqlstr, v0, v1).Scan(&ret)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn ret, nil\n}", "title": "" } ]
[ { "docid": "b1fee4b0f2728f0f8259596585a3493c", "score": "0.6703359", "text": "func InetGistSame(db XODB, v0 string, v1 string, v2 pgtypes.Internal) (pgtypes.Internal, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.inet_gist_same($1, $2, $3)`\n\n\t// run query\n\tvar ret pgtypes.Internal\n\tXOLog(sqlstr, v0, v1, v2)\n\terr = db.QueryRow(sqlstr, v0, v1, v2).Scan(&ret)\n\tif err != nil {\n\t\treturn pgtypes.Internal{}, err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "1f6ac56af6527991447ff506160890e7", "score": "0.6171668", "text": "func TestIsSameAddressFamily(t *testing.T) {\n\thostAddress := \"192.168.1.8/32\"\n\tnetwork := \"192.168.1.0/24\"\n\t_, cidr, err := net.ParseCIDR(network)\n\tif err != nil {\n\t\tt.Errorf(\"could not parse network\")\n\t}\n\tpref, _, err := net.ParseCIDR(hostAddress)\n\tif err != nil {\n\t\tt.Errorf(\"could not parse host address\")\n\t}\n\tif cidr.Contains(pref) != true {\n\t\tt.Errorf(\"the host address is not apart of the network address\")\n\t}\n}", "title": "" }, { "docid": "6fa4343163f9d0d7d35facb3f044e34f", "score": "0.56149495", "text": "func InetGistConsistent(db XODB, v0 pgtypes.Internal, v1 string, v2 int, v3 pgtypes.Oid, v4 pgtypes.Internal) (bool, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.inet_gist_consistent($1, $2, $3, $4, $5)`\n\n\t// run query\n\tvar ret bool\n\tXOLog(sqlstr, v0, v1, v2, v3, v4)\n\terr = db.QueryRow(sqlstr, v0, v1, v2, v3, v4).Scan(&ret)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "25fb405462409498f150f1dd9c78a79a", "score": "0.5591103", "text": "func matchesFamily(ip net.IP, ipFamily string) bool {\n\tif ipFamily == vcfg.IPv6Family {\n\t\treturn ip.To4() == nil && ip.To16() != nil\n\t}\n\n\tif ipFamily == vcfg.IPv4Family {\n\t\treturn ip.To4() != nil\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "48b3f800202f4ab2f789b1078ba4d0ed", "score": "0.55829686", "text": "func favoriteAddrFamily(net string, laddr, raddr sockaddr, mode string) (family int, ipv6only bool) {\n\tswitch net[len(net)-1] {\n\tcase '4':\n\t\treturn syscall.AF_INET, false\n\tcase '6':\n\t\treturn syscall.AF_INET6, true\n\t}\n\n\tif mode == \"listen\" && (laddr == nil || laddr.isWildcard()) {\n\t\tif supportsIPv4map || !supportsIPv4 {\n\t\t\treturn syscall.AF_INET6, false\n\t\t}\n\t\tif laddr == nil {\n\t\t\treturn syscall.AF_INET, false\n\t\t}\n\t\treturn laddr.family(), false\n\t}\n\n\tif (laddr == nil || laddr.family() == syscall.AF_INET) &&\n\t\t(raddr == nil || raddr.family() == syscall.AF_INET) {\n\t\treturn syscall.AF_INET, false\n\t}\n\treturn syscall.AF_INET6, false\n}", "title": "" }, { "docid": "a163920fec8bd76bbaeebebfb89f0c2e", "score": "0.54188186", "text": "func InetServerAddr(db XODB) (string, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.inet_server_addr()`\n\n\t// run query\n\tvar ret string\n\tXOLog(sqlstr)\n\terr = db.QueryRow(sqlstr).Scan(&ret)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "e2057802bc3bdc3a5158d13ea57cb381", "score": "0.5376537", "text": "func toNetFamily(ip net.IP) (int, error) {\n\tif len(ip) == net.IPv4len {\n\t\treturn TOX_AF_INET, nil\n\t} else if len(ip) == net.IPv6len {\n\t\treturn TOX_AF_INET6, nil\n\t}\n\n\treturn 0, &NetError{\"Wrong ip length\", ip, 0}\n}", "title": "" }, { "docid": "76514e2fd238897588b094cd9f717d02", "score": "0.52735734", "text": "func InetMerge(db XODB, v0 string, v1 string) (pgtypes.Cidr, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.inet_merge($1, $2)`\n\n\t// run query\n\tvar ret pgtypes.Cidr\n\tXOLog(sqlstr, v0, v1)\n\terr = db.QueryRow(sqlstr, v0, v1).Scan(&ret)\n\tif err != nil {\n\t\treturn pgtypes.Cidr{}, err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "c59e5ec551ca3403a65647e1b71c01da", "score": "0.51904625", "text": "func IpAddressEqualFold(v string) predicate.Machine {\n\treturn predicate.Machine(func(s *sql.Selector) {\n\t\ts.Where(sql.EqualFold(s.C(FieldIpAddress), v))\n\t})\n}", "title": "" }, { "docid": "c54cabae1b45ce4b6fc3a1cd18abc57d", "score": "0.51813215", "text": "func Int8plInet(db XODB, v0 int64, v1 string) (string, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.int8pl_inet($1, $2)`\n\n\t// run query\n\tvar ret string\n\tXOLog(sqlstr, v0, v1)\n\terr = db.QueryRow(sqlstr, v0, v1).Scan(&ret)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "02a0e060c47c1d6dec43f934dcd8c2eb", "score": "0.5164967", "text": "func Inetand(db XODB, v0 string, v1 string) (string, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.inetand($1, $2)`\n\n\t// run query\n\tvar ret string\n\tXOLog(sqlstr, v0, v1)\n\terr = db.QueryRow(sqlstr, v0, v1).Scan(&ret)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "728f5a31af8ecc46d9f7768b0b8480c5", "score": "0.51516205", "text": "func InetClientAddr(db XODB) (string, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.inet_client_addr()`\n\n\t// run query\n\tvar ret string\n\tXOLog(sqlstr)\n\terr = db.QueryRow(sqlstr).Scan(&ret)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "ec1230612b49879f6a5dee028f361a3b", "score": "0.5096373", "text": "func InetIn(db XODB, v0 pgtypes.Cstring) (string, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.inet_in($1)`\n\n\t// run query\n\tvar ret string\n\tXOLog(sqlstr, v0)\n\terr = db.QueryRow(sqlstr, v0).Scan(&ret)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "0fc1199617628a717d5e4c6193157ec7", "score": "0.4989879", "text": "func Inetor(db XODB, v0 string, v1 string) (string, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.inetor($1, $2)`\n\n\t// run query\n\tvar ret string\n\tXOLog(sqlstr, v0, v1)\n\terr = db.QueryRow(sqlstr, v0, v1).Scan(&ret)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "8e18fe18cf262cd0c4effc9fa66dfdfa", "score": "0.49647757", "text": "func AddressAndFamily(addr []byte) (tcpip.FullAddress, uint16, *syserr.Error) {\n\t// Make sure we have at least 2 bytes for the address family.\n\tif len(addr) < 2 {\n\t\treturn tcpip.FullAddress{}, 0, syserr.ErrInvalidArgument\n\t}\n\n\t// Get the rest of the fields based on the address family.\n\tswitch family := hostarch.ByteOrder.Uint16(addr); family {\n\tcase linux.AF_INET:\n\t\tvar a linux.SockAddrInet\n\t\tif len(addr) < sockAddrInetSize {\n\t\t\treturn tcpip.FullAddress{}, family, syserr.ErrInvalidArgument\n\t\t}\n\t\ta.UnmarshalUnsafe(addr)\n\n\t\tout := tcpip.FullAddress{\n\t\t\tAddr: BytesToIPAddress(a.Addr[:]),\n\t\t\tPort: Ntohs(a.Port),\n\t\t}\n\t\treturn out, family, nil\n\n\tcase linux.AF_INET6:\n\t\tvar a linux.SockAddrInet6\n\t\tif len(addr) < sockAddrInet6Size {\n\t\t\treturn tcpip.FullAddress{}, family, syserr.ErrInvalidArgument\n\t\t}\n\t\ta.UnmarshalUnsafe(addr)\n\n\t\tout := tcpip.FullAddress{\n\t\t\tAddr: BytesToIPAddress(a.Addr[:]),\n\t\t\tPort: Ntohs(a.Port),\n\t\t}\n\t\tif isLinkLocal(out.Addr) {\n\t\t\tout.NIC = tcpip.NICID(a.Scope_id)\n\t\t}\n\t\treturn out, family, nil\n\n\tcase linux.AF_PACKET:\n\t\tvar a linux.SockAddrLink\n\t\tif len(addr) < sockAddrLinkSize {\n\t\t\treturn tcpip.FullAddress{}, family, syserr.ErrInvalidArgument\n\t\t}\n\t\ta.UnmarshalUnsafe(addr)\n\t\t// TODO(https://gvisor.dev/issue/6530): Do not assume all interfaces have\n\t\t// an ethernet address.\n\t\tif a.Family != linux.AF_PACKET || a.HardwareAddrLen != header.EthernetAddressSize {\n\t\t\treturn tcpip.FullAddress{}, family, syserr.ErrInvalidArgument\n\t\t}\n\n\t\treturn tcpip.FullAddress{\n\t\t\tNIC: tcpip.NICID(a.InterfaceIndex),\n\t\t\tLinkAddr: tcpip.LinkAddress(a.HardwareAddr[:a.HardwareAddrLen]),\n\t\t\tPort: Ntohs(a.Protocol),\n\t\t}, family, nil\n\n\tcase linux.AF_UNSPEC:\n\t\treturn tcpip.FullAddress{}, family, nil\n\n\tdefault:\n\t\treturn tcpip.FullAddress{}, 0, syserr.ErrAddressFamilyNotSupported\n\t}\n}", "title": "" }, { "docid": "d6001d8ee6ff70f8cfc9ebe9a47f2eda", "score": "0.4955993", "text": "func NetworkSup(db XODB, v0 string, v1 string) (bool, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.network_sup($1, $2)`\n\n\t// run query\n\tvar ret bool\n\tXOLog(sqlstr, v0, v1)\n\terr = db.QueryRow(sqlstr, v0, v1).Scan(&ret)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "1d20200dba90a98d7b93d4818ba643f1", "score": "0.4949243", "text": "func TestV4tov6Check(t *testing.T) {\n\tip1 := \"192.168.1.1\"\n\tip2 := \"172.16.16.1\"\n\tvar is1Ipv4, is2Ipv4 bool\n\tif strings.Contains(ip1, \".\") {\n\t\tis1Ipv4 = true\n\t}\n\tif strings.Contains(ip2, \".\") {\n\t\tis2Ipv4 = true\n\t}\n\tif is1Ipv4 != is2Ipv4 {\n\t\tt.Errorf(\"the two ip addresses are not in the same family\")\n\t}\n}", "title": "" }, { "docid": "7d289a02619d4d86f1bedbc8dee5726e", "score": "0.49327993", "text": "func Inetpl(db XODB, v0 string, v1 int64) (string, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.inetpl($1, $2)`\n\n\t// run query\n\tvar ret string\n\tXOLog(sqlstr, v0, v1)\n\terr = db.QueryRow(sqlstr, v0, v1).Scan(&ret)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "a345204147e52dee68e1594e52a1da8b", "score": "0.4927182", "text": "func NetworkOverlap(db XODB, v0 string, v1 string) (bool, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.network_overlap($1, $2)`\n\n\t// run query\n\tvar ret bool\n\tXOLog(sqlstr, v0, v1)\n\terr = db.QueryRow(sqlstr, v0, v1).Scan(&ret)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "c322fb6784a16c46d216f9898eb441ac", "score": "0.49196205", "text": "func IPAddressEqualFold(v string) predicate.IPAddress {\n\treturn predicate.IPAddress(func(s *sql.Selector) {\n\t\ts.Where(sql.EqualFold(s.C(FieldIPAddress), v))\n\t})\n}", "title": "" }, { "docid": "f35f017a8cc47b435bcbddf1e5ad7d8e", "score": "0.49074772", "text": "func ConvertAddress(family int, addr tcpip.FullAddress) (linux.SockAddr, uint32) {\n\tswitch family {\n\tcase linux.AF_INET:\n\t\tvar out linux.SockAddrInet\n\t\tcopy(out.Addr[:], addr.Addr.AsSlice())\n\t\tout.Family = linux.AF_INET\n\t\tout.Port = Htons(addr.Port)\n\t\treturn &out, uint32(sockAddrInetSize)\n\n\tcase linux.AF_INET6:\n\t\tvar out linux.SockAddrInet6\n\t\taddrBytes := addr.Addr.AsSlice()\n\t\tif len(addrBytes) == header.IPv4AddressSize {\n\t\t\t// Copy address in v4-mapped format.\n\t\t\tcopy(out.Addr[12:], addrBytes)\n\t\t\tout.Addr[10] = 0xff\n\t\t\tout.Addr[11] = 0xff\n\t\t} else {\n\t\t\tcopy(out.Addr[:], addrBytes)\n\t\t}\n\t\tout.Family = linux.AF_INET6\n\t\tout.Port = Htons(addr.Port)\n\t\tif isLinkLocal(addr.Addr) {\n\t\t\tout.Scope_id = uint32(addr.NIC)\n\t\t}\n\t\treturn &out, uint32(sockAddrInet6Size)\n\n\tcase linux.AF_PACKET:\n\t\tvar out linux.SockAddrLink\n\t\tout.Family = linux.AF_PACKET\n\t\tout.InterfaceIndex = int32(addr.NIC)\n\t\tout.HardwareAddrLen = header.EthernetAddressSize\n\t\tcopy(out.HardwareAddr[:], addr.LinkAddr)\n\t\treturn &out, uint32(sockAddrLinkSize)\n\n\tdefault:\n\t\treturn nil, 0\n\t}\n}", "title": "" }, { "docid": "d4a13b3276c0f6104c4f97e8612f552e", "score": "0.48705298", "text": "func Inetmi(db XODB, v0 string, v1 string) (int64, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.inetmi($1, $2)`\n\n\t// run query\n\tvar ret int64\n\tXOLog(sqlstr, v0, v1)\n\terr = db.QueryRow(sqlstr, v0, v1).Scan(&ret)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "fa1f201ee3ed3a47471826ecf6dd07dd", "score": "0.48568505", "text": "func NetworkSupeq(db XODB, v0 string, v1 string) (bool, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.network_supeq($1, $2)`\n\n\t// run query\n\tvar ret bool\n\tXOLog(sqlstr, v0, v1)\n\terr = db.QueryRow(sqlstr, v0, v1).Scan(&ret)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "7d4e2b51e915fec5e2dd3821b66ab301", "score": "0.48562536", "text": "func IsSameHost(service string) bool {\n\tif ForceRemote {\n\t\treturn true\n\t}\n\tif ipList == nil {\n\t\tipList = getIPList()\n\t}\n\tserviceIP := strings.Split(service, \":\")[0]\n\t_, ok := ipList[serviceIP]\n\treturn ok\n}", "title": "" }, { "docid": "c478a6fd2177f3cff168f69a2adcd080", "score": "0.48406276", "text": "func InetSend(db XODB, v0 string) ([]byte, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.inet_send($1)`\n\n\t// run query\n\tvar ret []byte\n\tXOLog(sqlstr, v0)\n\terr = db.QueryRow(sqlstr, v0).Scan(&ret)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "ccfa29492f370a90dc453aff5d34d724", "score": "0.48396912", "text": "func (a Address) Family() uint8 {\n\n\tif a.Info == nil || a.Info.Address == nil {\n\t\treturn unix.AF_UNSPEC\n\t}\n\n\ti4 := a.Info.Address.IP.To4()\n\tif i4 != nil {\n\t\ta.Info.Address.IP = i4\n\t\treturn unix.AF_INET\n\t}\n\n\treturn unix.AF_INET6\n\n}", "title": "" }, { "docid": "74ee598b6c8588b7e917a27337f1f71a", "score": "0.48360667", "text": "func Hashinet(db XODB, v0 string) (int, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.hashinet($1)`\n\n\t// run query\n\tvar ret int\n\tXOLog(sqlstr, v0)\n\terr = db.QueryRow(sqlstr, v0).Scan(&ret)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "92b68c4bfe9c455d39f1b112085a8049", "score": "0.47663507", "text": "func TestIsLoopback(t *testing.T) {\n\tt.Parallel()\n\n\ttestSet := []struct {\n\t\tquery NetAddress\n\t\tdesiredResponse bool\n\t}{\n\t\t// Localhost tests.\n\t\t{\"localhost\", false},\n\t\t{\"localhost:1234\", true},\n\t\t{\"127.0.0.1\", false},\n\t\t{\"127.0.0.1:6723\", true},\n\t\t{\"::1\", false},\n\t\t{\"[::1]:7124\", true},\n\n\t\t// Local network tests.\n\t\t{\"10.0.0.0\", false},\n\t\t{\"10.0.0.0:1234\", false},\n\t\t{\"10.2.2.5\", false},\n\t\t{\"10.2.2.5:16432\", false},\n\t\t{\"10.255.255.255\", false},\n\t\t{\"10.255.255.255:16432\", false},\n\t\t{\"172.16.0.0\", false},\n\t\t{\"172.16.0.0:1234\", false},\n\t\t{\"172.26.2.5\", false},\n\t\t{\"172.26.2.5:16432\", false},\n\t\t{\"172.31.255.255\", false},\n\t\t{\"172.31.255.255:16432\", false},\n\t\t{\"192.168.0.0\", false},\n\t\t{\"192.168.0.0:1234\", false},\n\t\t{\"192.168.2.5\", false},\n\t\t{\"192.168.2.5:16432\", false},\n\t\t{\"192.168.255.255\", false},\n\t\t{\"192.168.255.255:16432\", false},\n\t\t{\"1234:0000:0000:0000:0000:0000:0000:0000\", false},\n\t\t{\"[1234:0000:0000:0000:0000:0000:0000:0000]:1234\", false},\n\t\t{\"fc00:0000:0000:0000:0000:0000:0000:0000\", false},\n\t\t{\"[fc00:0000:0000:0000:0000:0000:0000:0000]:1234\", false},\n\t\t{\"fd00:0000:0000:0000:0000:0000:0000:0000\", false},\n\t\t{\"[fd00:0000:0000:0000:0000:0000:0000:0000]:1234\", false},\n\t\t{\"fd30:0000:0000:0000:0000:0000:0000:0000\", false},\n\t\t{\"[fd30:0000:0000:0000:0000:0000:0000:0000]:1234\", false},\n\t\t{\"fd00:0000:0030:0000:0000:0000:0000:0000\", false},\n\t\t{\"[fd00:0000:0030:0000:0000:0000:0000:0000]:1234\", false},\n\t\t{\"fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff\", false},\n\t\t{\"[fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]:1234\", false},\n\t\t{\"fe00:0000:0000:0000:0000:0000:0000:0000\", false},\n\t\t{\"[fe00:0000:0000:0000:0000:0000:0000:0000]:1234\", false},\n\n\t\t// Unspecified address tests.\n\t\t{\"0.0.0.0:1234\", false},\n\t\t{\"[::]:1234\", false},\n\n\t\t// Public name tests.\n\t\t{\"hn.com\", false},\n\t\t{\"hn.com:8811\", false},\n\t\t{\"2.34.45.64\", false},\n\t\t{\"2.34.45.64:7777\", false},\n\t\t{\"12.34.45.64\", false},\n\t\t{\"12.34.45.64:7777\", false},\n\t\t{\"122.34.45.64\", false},\n\t\t{\"122.34.45.64:7777\", false},\n\t\t{\"197.34.45.64\", false},\n\t\t{\"197.34.45.64:7777\", false},\n\t\t{\"222.34.45.64\", false},\n\t\t{\"222.34.45.64:7777\", false},\n\n\t\t// Garbage name tests.\n\t\t{\"\", false},\n\t\t{\"garbage\", false},\n\t\t{\"garbage:6432\", false},\n\t\t{\"garbage:6146:616\", false},\n\t\t{\"::1:4646\", false},\n\t\t{\"[::1]\", false},\n\t}\n\tfor _, test := range testSet {\n\t\tif test.query.IsLoopback() != test.desiredResponse {\n\t\t\tt.Error(\"test failed:\", test, test.query.IsLoopback())\n\t\t}\n\t}\n}", "title": "" }, { "docid": "483ae68a502702a0ab05fb310c6b9d95", "score": "0.47255236", "text": "func Inetnot(db XODB, v0 string) (string, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.inetnot($1)`\n\n\t// run query\n\tvar ret string\n\tXOLog(sqlstr, v0)\n\terr = db.QueryRow(sqlstr, v0).Scan(&ret)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "5270da4ac20e1e8c99a9cce916cf401f", "score": "0.47027162", "text": "func TestIsLocal(t *testing.T) {\n\tt.Parallel()\n\n\ttestSet := []struct {\n\t\tquery NetAddress\n\t\tdesiredResponse bool\n\t}{\n\t\t// Localhost tests.\n\t\t{\"localhost\", false},\n\t\t{\"localhost:1234\", true},\n\t\t{\"127.0.0.1\", false},\n\t\t{\"127.0.0.1:6723\", true},\n\t\t{\"::1\", false},\n\t\t{\"[::1]:7124\", true},\n\n\t\t// Local network tests.\n\t\t{\"10.0.0.0\", false},\n\t\t{\"10.0.0.0:1234\", true},\n\t\t{\"10.2.2.5\", false},\n\t\t{\"10.2.2.5:16432\", true},\n\t\t{\"10.255.255.255\", false},\n\t\t{\"10.255.255.255:16432\", true},\n\t\t{\"172.16.0.0\", false},\n\t\t{\"172.16.0.0:1234\", true},\n\t\t{\"172.26.2.5\", false},\n\t\t{\"172.26.2.5:16432\", true},\n\t\t{\"172.31.255.255\", false},\n\t\t{\"172.31.255.255:16432\", true},\n\t\t{\"192.168.0.0\", false},\n\t\t{\"192.168.0.0:1234\", true},\n\t\t{\"192.168.2.5\", false},\n\t\t{\"192.168.2.5:16432\", true},\n\t\t{\"192.168.255.255\", false},\n\t\t{\"192.168.255.255:16432\", true},\n\t\t{\"1234:0000:0000:0000:0000:0000:0000:0000\", false},\n\t\t{\"[1234:0000:0000:0000:0000:0000:0000:0000]:1234\", false},\n\t\t{\"fc00:0000:0000:0000:0000:0000:0000:0000\", false},\n\t\t{\"[fc00:0000:0000:0000:0000:0000:0000:0000]:1234\", false},\n\t\t{\"fd00:0000:0000:0000:0000:0000:0000:0000\", false},\n\t\t{\"[fd00:0000:0000:0000:0000:0000:0000:0000]:1234\", true},\n\t\t{\"fd30:0000:0000:0000:0000:0000:0000:0000\", false},\n\t\t{\"[fd30:0000:0000:0000:0000:0000:0000:0000]:1234\", true},\n\t\t{\"fd00:0000:0030:0000:0000:0000:0000:0000\", false},\n\t\t{\"[fd00:0000:0030:0000:0000:0000:0000:0000]:1234\", true},\n\t\t{\"fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff\", false},\n\t\t{\"[fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]:1234\", true},\n\t\t{\"fe00:0000:0000:0000:0000:0000:0000:0000\", false},\n\t\t{\"[fe00:0000:0000:0000:0000:0000:0000:0000]:1234\", false},\n\n\t\t// Unspecified address tests.\n\t\t{\"0.0.0.0:1234\", false},\n\t\t{\"[::]:1234\", false},\n\n\t\t// Public name tests.\n\t\t{\"hn.com\", false},\n\t\t{\"hn.com:8811\", false},\n\t\t{\"2.34.45.64\", false},\n\t\t{\"2.34.45.64:7777\", false},\n\t\t{\"12.34.45.64\", false},\n\t\t{\"12.34.45.64:7777\", false},\n\t\t{\"122.34.45.64\", false},\n\t\t{\"122.34.45.64:7777\", false},\n\t\t{\"197.34.45.64\", false},\n\t\t{\"197.34.45.64:7777\", false},\n\t\t{\"222.34.45.64\", false},\n\t\t{\"222.34.45.64:7777\", false},\n\n\t\t// Garbage name tests.\n\t\t{\"\", false},\n\t\t{\"garbage\", false},\n\t\t{\"garbage:6432\", false},\n\t\t{\"garbage:6146:616\", false},\n\t\t{\"::1:4646\", false},\n\t\t{\"[::1]\", false},\n\t}\n\tfor _, test := range testSet {\n\t\tif test.query.IsLocal() != test.desiredResponse {\n\t\t\tt.Error(\"test failed:\", test, test.query.IsLocal())\n\t\t}\n\t}\n}", "title": "" }, { "docid": "66c48157851c08bcb66c68fa58552dce", "score": "0.46986777", "text": "func Family(db XODB, v0 string) (int, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.family($1)`\n\n\t// run query\n\tvar ret int\n\tXOLog(sqlstr, v0)\n\terr = db.QueryRow(sqlstr, v0).Scan(&ret)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "b391ef28f0f026cd204f0af3abf49753", "score": "0.46611068", "text": "func NetworkEq(db XODB, v0 string, v1 string) (bool, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.network_eq($1, $2)`\n\n\t// run query\n\tvar ret bool\n\tXOLog(sqlstr, v0, v1)\n\terr = db.QueryRow(sqlstr, v0, v1).Scan(&ret)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "9c7669dd654fdec96f87bf9c118adbec", "score": "0.46442842", "text": "func InetClientPort(db XODB) (int, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.inet_client_port()`\n\n\t// run query\n\tvar ret int\n\tXOLog(sqlstr)\n\terr = db.QueryRow(sqlstr).Scan(&ret)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "c948285d094847939f71b5e2c4b9fb86", "score": "0.46190995", "text": "func InetServerPort(db XODB) (int, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.inet_server_port()`\n\n\t// run query\n\tvar ret int\n\tXOLog(sqlstr)\n\terr = db.QueryRow(sqlstr).Scan(&ret)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "b52ea01535d40c78c42aff3425274bfd", "score": "0.46157026", "text": "func isSameHost(root *url.URL, other *url.URL) bool {\n\treturn other.Host == root.Host\n}", "title": "" }, { "docid": "378cfa8c61680bd5e674a4e4ba120258", "score": "0.46024403", "text": "func IsIpv4Net(host string) bool {\r\n return net.ParseIP(host) != nil\r\n}", "title": "" }, { "docid": "4463f1d1e63411a7d8ecf17efb2dcff1", "score": "0.4600951", "text": "func getSockaddr(proto, addr string) (sa syscall.Sockaddr, soType int, err error) {\n\tvar (\n\t\taddr4 [4]byte\n\t\taddr6 [16]byte\n\t\ttcpAddr *net.TCPAddr\n\t\tudpAddr *net.UDPAddr\n\t)\n\n\tif proto == \"tcp\" || proto == \"tcp4\" || proto == \"tcp6\" {\n\t\ttcpAddr, err = net.ResolveTCPAddr(proto, addr)\n\t\tif err != nil {\n\t\t\treturn nil, -1, err\n\t\t}\n\t} else {\n\t\tudpAddr, err = net.ResolveUDPAddr(proto, addr)\n\t\tif err != nil {\n\t\t\treturn nil, -1, err\n\t\t}\n\t}\n\n\tswitch proto {\n\tdefault:\n\t\treturn nil, -1, errors.New(unsupportedProtoError)\n\tcase \"tcp4\":\n\t\tif tcpAddr.IP != nil {\n\t\t\tcopy(addr4[:], tcpAddr.IP[12:16]) // copy last 4 bytes of slice to array\n\t\t}\n\t\treturn &syscall.SockaddrInet4{Port: tcpAddr.Port, Addr: addr4}, syscall.AF_INET, nil\n\tcase \"tcp\", \"tcp6\":\n\t\tif tcpAddr.IP != nil {\n\t\t\tcopy(addr6[:], tcpAddr.IP) // copy all bytes of slice to array\n\t\t}\n\t\treturn &syscall.SockaddrInet6{Port: tcpAddr.Port, Addr: addr6}, syscall.AF_INET6, nil\n\tcase \"udp4\":\n\t\tif udpAddr.IP != nil {\n\t\t\tcopy(addr4[:], udpAddr.IP[12:16]) // copy last 4 bytes of slice to array\n\t\t}\n\t\treturn &syscall.SockaddrInet4{Port: udpAddr.Port, Addr: addr4}, syscall.AF_INET, nil\n\tcase \"udp\", \"udp6\":\n\t\tif udpAddr.IP != nil {\n\t\t\tcopy(addr6[:], udpAddr.IP) // copy all bytes of slice to array\n\t\t}\n\t\treturn &syscall.SockaddrInet6{Port: udpAddr.Port, Addr: addr6}, syscall.AF_INET6, nil\n\t}\n\treturn nil, -1, errors.New(unsupportedProtoError)\n}", "title": "" }, { "docid": "4b0756c14795626a56192c5f095fbb3c", "score": "0.45935643", "text": "func TestGetIfAddrs(t *testing.T) {\n\tifAddrs, err := sockaddr.GetAllInterfaces()\n\tif err != nil {\n\t\tt.Fatalf(\"Unable to proceed: %v\", err)\n\t}\n\tif len(ifAddrs) == 0 {\n\t\tt.Skip()\n\t}\n\n\tvar loInt *sockaddr.IfAddr\n\tfor _, ifAddr := range ifAddrs {\n\t\tval := sockaddr.IfAddrAttr(ifAddr, \"name\")\n\t\tif val == \"\" {\n\t\t\tt.Fatalf(\"name failed\")\n\t\t} else if val == \"lo0\" || val == \"lo\" || val == \"Loopback Pseudo-Interface 1\" {\n\t\t\tloInt = &ifAddr\n\t\t\tbreak\n\t\t}\n\t}\n\tif loInt == nil {\n\t\tt.Fatalf(\"No loopback interfaces found, loInt nil\")\n\t}\n\n\tif val := sockaddr.IfAddrAttr(*loInt, \"flags\"); !(val == \"up|loopback|multicast\" || val == \"up|loopback\") {\n\t\tt.Fatalf(\"expected different flags from loopback: %q\", val)\n\t}\n\n\tif loInt == nil {\n\t\tt.Fatalf(\"Expected to find an lo0 interface, didn't find any\")\n\t}\n\n\thaveIPv4, foundIPv4lo := false, false\n\thaveIPv6, foundIPv6lo := false, false\n\tswitch loInt.SockAddr.(type) {\n\tcase sockaddr.IPv4Addr:\n\t\thaveIPv4 = true\n\n\t\t// Make the semi-brittle assumption that if we have\n\t\t// IPv4, we also have an address at 127.0.0.1 available\n\t\t// to us.\n\t\tif loInt.SockAddr.String() == \"127.0.0.1/8\" {\n\t\t\tfoundIPv4lo = true\n\t\t}\n\tcase sockaddr.IPv6Addr:\n\t\thaveIPv6 = true\n\t\tif loInt.SockAddr.String() == \"::1\" {\n\t\t\tfoundIPv6lo = true\n\t\t}\n\tdefault:\n\t\tt.Fatalf(\"Unsupported type %v for address %v\", loInt.Type(), loInt)\n\t}\n\n\t// While not wise, it's entirely possible a host doesn't have IPv4\n\t// enabled.\n\tif haveIPv4 && !foundIPv4lo {\n\t\tt.Fatalf(\"Had an IPv4 w/o an expected IPv4 loopback addresses\")\n\t}\n\n\t// While prudent to run without, a sane environment may still contain an\n\t// IPv6 loopback address.\n\tif haveIPv6 && !foundIPv6lo {\n\t\tt.Fatalf(\"Had an IPv6 w/o an expected IPv6 loopback addresses\")\n\t}\n}", "title": "" }, { "docid": "c16074e0cb75420008a70a4cf0331733", "score": "0.45764932", "text": "func GetIPFamily(ip net.IP) int {\n\tif len(ip) <= net.IPv4len {\n\t\treturn FAMILY_V4\n\t}\n\tif ip.To4() != nil {\n\t\treturn FAMILY_V4\n\t}\n\treturn FAMILY_V6\n}", "title": "" }, { "docid": "63aeb2e3d8c0ef15670c83fec6967a84", "score": "0.45708114", "text": "func TestCmpIfAddrFunc(t *testing.T) {\n\ttests := []struct {\n\t\tname string\n\t\tt1 sockaddr.IfAddr // must come before t2 according to the ascOp\n\t\tt2 sockaddr.IfAddr\n\t\tascOp sockaddr.CmpIfAddrFunc\n\t\tascResult int\n\t\tdescOp sockaddr.CmpIfAddrFunc\n\t\tdescResult int\n\t}{\n\t\t{\n\t\t\tname: \"empty test\",\n\t\t\tt1: sockaddr.IfAddr{},\n\t\t\tt2: sockaddr.IfAddr{},\n\t\t\tascOp: sockaddr.AscIfAddress,\n\t\t\tdescOp: sockaddr.DescIfAddress,\n\t\t\tascResult: 0,\n\t\t\tdescResult: 0,\n\t\t},\n\t\t{\n\t\t\tname: \"ipv4 address less\",\n\t\t\tt1: sockaddr.IfAddr{\n\t\t\t\tSockAddr: sockaddr.MustIPv4Addr(\"1.2.3.3\"),\n\t\t\t},\n\t\t\tt2: sockaddr.IfAddr{\n\t\t\t\tSockAddr: sockaddr.MustIPv4Addr(\"1.2.3.4\"),\n\t\t\t},\n\t\t\tascOp: sockaddr.AscIfAddress,\n\t\t\tdescOp: sockaddr.DescIfAddress,\n\t\t\tascResult: -1,\n\t\t\tdescResult: -1,\n\t\t},\n\t\t{\n\t\t\tname: \"ipv4 private\",\n\t\t\tt1: sockaddr.IfAddr{\n\t\t\t\tSockAddr: sockaddr.MustIPv4Addr(\"10.1.2.3\"),\n\t\t\t},\n\t\t\tt2: sockaddr.IfAddr{\n\t\t\t\tSockAddr: sockaddr.MustIPv4Addr(\"203.0.113.3\"),\n\t\t\t},\n\t\t\tascOp: sockaddr.AscIfPrivate,\n\t\t\tdescOp: sockaddr.DescIfPrivate,\n\t\t\tascResult: 0, // not both private, can't complete the test\n\t\t\tdescResult: 0,\n\t\t},\n\t\t{\n\t\t\tname: \"IfAddr name\",\n\t\t\tt1: sockaddr.IfAddr{\n\t\t\t\tSockAddr: sockaddr.MustIPv4Addr(\"10.1.2.3\"),\n\t\t\t\tInterface: net.Interface{\n\t\t\t\t\tName: \"abc0\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tt2: sockaddr.IfAddr{\n\t\t\t\tSockAddr: sockaddr.MustIPv4Addr(\"203.0.113.3\"),\n\t\t\t\tInterface: net.Interface{\n\t\t\t\t\tName: \"xyz0\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tascOp: sockaddr.AscIfName,\n\t\t\tdescOp: sockaddr.DescIfName,\n\t\t\tascResult: -1,\n\t\t\tdescResult: -1,\n\t\t},\n\t\t{\n\t\t\tname: \"IfAddr network size\",\n\t\t\tt1: sockaddr.IfAddr{\n\t\t\t\tSockAddr: sockaddr.MustIPv4Addr(\"10.0.0.0/8\"),\n\t\t\t},\n\t\t\tt2: sockaddr.IfAddr{\n\t\t\t\tSockAddr: sockaddr.MustIPv4Addr(\"127.0.0.0/24\"),\n\t\t\t},\n\t\t\tascOp: sockaddr.AscIfNetworkSize,\n\t\t\tdescOp: sockaddr.DescIfNetworkSize,\n\t\t\tascResult: -1,\n\t\t\tdescResult: -1,\n\t\t},\n\t\t{\n\t\t\tname: \"IfAddr port\",\n\t\t\tt1: sockaddr.IfAddr{\n\t\t\t\tSockAddr: sockaddr.MustIPv4Addr(\"10.0.0.0:80\"),\n\t\t\t},\n\t\t\tt2: sockaddr.IfAddr{\n\t\t\t\tSockAddr: sockaddr.MustIPv4Addr(\"127.0.0.0:8600\"),\n\t\t\t},\n\t\t\tascOp: sockaddr.AscIfPort,\n\t\t\tdescOp: sockaddr.DescIfPort,\n\t\t\tascResult: -1,\n\t\t\tdescResult: -1,\n\t\t},\n\t\t{\n\t\t\tname: \"IfAddr type\",\n\t\t\tt1: sockaddr.IfAddr{\n\t\t\t\tSockAddr: sockaddr.MustIPv4Addr(\"10.0.0.0:80\"),\n\t\t\t},\n\t\t\tt2: sockaddr.IfAddr{\n\t\t\t\tSockAddr: sockaddr.MustIPv6Addr(\"[::1]:80\"),\n\t\t\t},\n\t\t\tascOp: sockaddr.AscIfType,\n\t\t\tdescOp: sockaddr.DescIfType,\n\t\t\tascResult: -1,\n\t\t\tdescResult: -1,\n\t\t},\n\t}\n\n\tfor i, test := range tests {\n\t\tif test.name == \"\" {\n\t\t\tt.Fatalf(\"test %d must have a name\", i)\n\t\t}\n\n\t\t// Test ascending operation\n\t\tascExpected := test.ascResult\n\t\tascResult := test.ascOp(&test.t1, &test.t2)\n\t\tif ascResult != ascExpected {\n\t\t\tt.Errorf(\"%s: Unexpected result %d, expected %d when comparing %v and %v using %v\", test.name, ascResult, ascExpected, test.t1, test.t2, test.ascOp)\n\t\t}\n\n\t\t// Test descending operation\n\t\tdescExpected := test.descResult\n\t\tdescResult := test.descOp(&test.t2, &test.t1)\n\t\tif descResult != descExpected {\n\t\t\tt.Errorf(\"%s: Unexpected result %d, expected %d when comparing %v and %v using %v\", test.name, descResult, descExpected, test.t1, test.t2, test.descOp)\n\t\t}\n\n\t\tif ascResult != descResult {\n\t\t\tt.Fatalf(\"bad\")\n\t\t}\n\n\t\t// Reverse the args\n\t\tascExpected = -1 * test.ascResult\n\t\tascResult = test.ascOp(&test.t2, &test.t1)\n\t\tif ascResult != ascExpected {\n\t\t\tt.Errorf(\"%s: Unexpected result %d, expected %d when comparing %v and %v using %v\", test.name, ascResult, ascExpected, test.t1, test.t2, test.ascOp)\n\t\t}\n\n\t\tdescExpected = -1 * test.descResult\n\t\tdescResult = test.descOp(&test.t1, &test.t2)\n\t\tif descResult != descExpected {\n\t\t\tt.Errorf(\"%s: Unexpected result %d, expected %d when comparing %v and %v using %v\", test.name, descResult, descExpected, test.t1, test.t2, test.descOp)\n\t\t}\n\n\t\tif ascResult != descResult {\n\t\t\tt.Fatalf(\"bad\")\n\t\t}\n\n\t\t// Test equality\n\t\tascExpected = 0\n\t\tascResult = test.ascOp(&test.t1, &test.t1)\n\t\tif ascResult != ascExpected {\n\t\t\tt.Errorf(\"%s: Unexpected result %d, expected %d when comparing %v and %v using %v\", test.name, ascResult, ascExpected, test.t1, test.t2, test.ascOp)\n\t\t}\n\n\t\tdescExpected = 0\n\t\tdescResult = test.descOp(&test.t1, &test.t1)\n\t\tif descResult != descExpected {\n\t\t\tt.Errorf(\"%s: Unexpected result %d, expected %d when comparing %v and %v using %v\", test.name, descResult, descExpected, test.t1, test.t2, test.descOp)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "39c09d7aa53227697357e985696bcbcd", "score": "0.45648107", "text": "func newIP(ip string) bool {\n\tpeersMutex.Lock()\n\tdefer peersMutex.Unlock()\n\tfor _, peer := range peers {\n\t\tif peer == ip {\n\t\t\treturn false\n\t\t}\n\t}\n\t//Check if own ip\n\tif ip == peers[0] {\n\t\treturn false\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "be44ba0f8668f491de424ae23df2a790", "score": "0.45364854", "text": "func IpAddressEQ(v string) predicate.Machine {\n\treturn predicate.Machine(func(s *sql.Selector) {\n\t\ts.Where(sql.EQ(s.C(FieldIpAddress), v))\n\t})\n}", "title": "" }, { "docid": "26743fbab515c50e9da1d01befa0b6c5", "score": "0.45273435", "text": "func NetworkGe(db XODB, v0 string, v1 string) (bool, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.network_ge($1, $2)`\n\n\t// run query\n\tvar ret bool\n\tXOLog(sqlstr, v0, v1)\n\terr = db.QueryRow(sqlstr, v0, v1).Scan(&ret)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "2a921d91dae9a586e21e3855b8d8f27e", "score": "0.45124355", "text": "func RangeGistSame(db XODB, v0 pgtypes.Anyrange, v1 pgtypes.Anyrange, v2 pgtypes.Internal) (pgtypes.Internal, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.range_gist_same($1, $2, $3)`\n\n\t// run query\n\tvar ret pgtypes.Internal\n\tXOLog(sqlstr, v0, v1, v2)\n\terr = db.QueryRow(sqlstr, v0, v1, v2).Scan(&ret)\n\tif err != nil {\n\t\treturn pgtypes.Internal{}, err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "a14c8b28cb1f00fa1acc7ab5ac73dd5d", "score": "0.4504637", "text": "func (ipam *LBIPAM) serviceIPFamilyRequest(svc *slim_core_v1.Service) (IPv4Requested, IPv6Requested bool) {\n\tif svc.Spec.IPFamilyPolicy != nil {\n\t\tswitch *svc.Spec.IPFamilyPolicy {\n\t\tcase slim_core_v1.IPFamilyPolicySingleStack:\n\t\t\tif len(svc.Spec.IPFamilies) > 0 {\n\t\t\t\tif svc.Spec.IPFamilies[0] == slim_core_v1.IPFamily(IPv4Family) {\n\t\t\t\t\tIPv4Requested = true\n\t\t\t\t} else {\n\t\t\t\t\tIPv6Requested = true\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ipam.ipv4Enabled {\n\t\t\t\t\tIPv4Requested = true\n\t\t\t\t} else if ipam.ipv6Enabled {\n\t\t\t\t\tIPv6Requested = true\n\t\t\t\t}\n\t\t\t}\n\n\t\tcase slim_core_v1.IPFamilyPolicyPreferDualStack:\n\t\t\tif len(svc.Spec.IPFamilies) > 0 {\n\t\t\t\tfor _, family := range svc.Spec.IPFamilies {\n\t\t\t\t\tif family == slim_core_v1.IPFamily(IPv4Family) {\n\t\t\t\t\t\tIPv4Requested = ipam.ipv4Enabled\n\t\t\t\t\t}\n\t\t\t\t\tif family == slim_core_v1.IPFamily(IPv6Family) {\n\t\t\t\t\t\tIPv6Requested = ipam.ipv6Enabled\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// If no IPFamilies are specified\n\n\t\t\t\tIPv4Requested = ipam.ipv4Enabled\n\t\t\t\tIPv6Requested = ipam.ipv6Enabled\n\t\t\t}\n\n\t\tcase slim_core_v1.IPFamilyPolicyRequireDualStack:\n\t\t\tIPv4Requested = ipam.ipv4Enabled\n\t\t\tIPv6Requested = ipam.ipv6Enabled\n\t\t}\n\t} else {\n\t\tif len(svc.Spec.IPFamilies) > 0 {\n\t\t\tif svc.Spec.IPFamilies[0] == slim_core_v1.IPFamily(IPv4Family) {\n\t\t\t\tIPv4Requested = true\n\t\t\t} else {\n\t\t\t\tIPv6Requested = true\n\t\t\t}\n\t\t} else {\n\t\t\tif ipam.ipv4Enabled {\n\t\t\t\tIPv4Requested = true\n\t\t\t} else if ipam.ipv6Enabled {\n\t\t\t\tIPv6Requested = true\n\t\t\t}\n\t\t}\n\t}\n\n\treturn IPv4Requested, IPv6Requested\n}", "title": "" }, { "docid": "d50adb902f89f3b70b9f8ac6b233e0f9", "score": "0.45008165", "text": "func isSelf(ipport string) bool {\n\tipArr := getLocalIP()\n\n\tfor _, ip := range ipArr {\n\t\tif ipport == ip+\":\"+port {\n\t\t\treturn true\n\t\t}\n\t}\n\tif ipport == \"127.0.0.1\"+\":\"+port || ipport == \"localhost\"+\":\"+port {\n\t\treturn true\n\t}\n\treturn false\n}", "title": "" }, { "docid": "f4dd23400a94e7686c6338ed901bc3f5", "score": "0.44931912", "text": "func samePrefix(a, b *net.IPNet) bool {\n\tif a == nil || b == nil {\n\t\treturn false\n\t}\n\treturn a.IP.Equal(b.IP) && bytes.Equal(a.Mask, b.Mask)\n}", "title": "" }, { "docid": "93f54567c9fc27ea94eeca4c3b04ad7e", "score": "0.44875884", "text": "func InetGistUnion(db XODB, v0 pgtypes.Internal, v1 pgtypes.Internal) (pgtypes.Internal, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.inet_gist_union($1, $2)`\n\n\t// run query\n\tvar ret pgtypes.Internal\n\tXOLog(sqlstr, v0, v1)\n\terr = db.QueryRow(sqlstr, v0, v1).Scan(&ret)\n\tif err != nil {\n\t\treturn pgtypes.Internal{}, err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "22adc4ccf6b72729e741699fc17db0e2", "score": "0.4485527", "text": "func IsVipInSameSubnet(vip, target string, mask string) (b bool) {\n\tvipNet := strings.Split(vip, \".\")\n\ttargetNet := strings.Split(target, \".\")\n\tmaskNet := strings.Split(mask, \".\")\n\n\tfor i := 0; i < len(maskNet); i++ {\n\t\tm, _ := strconv.Atoi(maskNet[i])\n\t\tt, _ := strconv.Atoi(targetNet[i])\n\t\tv, _ := strconv.Atoi(vipNet[i])\n\t\tif (t & m) != (v & m) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "title": "" }, { "docid": "ab5705a93c222500d3c1733c632be4d2", "score": "0.4481319", "text": "func HostnameEqualFold(v string) predicate.Referrer {\n\treturn predicate.Referrer(func(s *sql.Selector) {\n\t\ts.Where(sql.EqualFold(s.C(FieldHostname), v))\n\t})\n}", "title": "" }, { "docid": "b61a35339bbb6c7ea88269650443ee50", "score": "0.44746828", "text": "func getSockaddr(proto, addr string) (sa syscall.Sockaddr, soType int, err error) {\n\tvar (\n\t\taddr4 [4]byte\n\t\taddr6 [16]byte\n\t\tip *net.TCPAddr\n\t)\n\n\tip, err = net.ResolveTCPAddr(proto, addr)\n\tif err != nil {\n\t\treturn nil, -1, err\n\t}\n\n\tswitch proto[len(proto)-1] {\n\tdefault:\n\t\treturn nil, -1, errors.New(unsupportedProtoError)\n\tcase tcp4:\n\t\tif ip.IP != nil {\n\t\t\tcopy(addr4[:], ip.IP[12:16]) // copy last 4 bytes of slice to array\n\t\t}\n\t\treturn &syscall.SockaddrInet4{Port: ip.Port, Addr: addr4}, syscall.AF_INET, nil\n\tcase tcp6:\n\t\tif ip.IP != nil {\n\t\t\tcopy(addr6[:], ip.IP) // copy all bytes of slice to array\n\t\t}\n\t\treturn &syscall.SockaddrInet6{Port: ip.Port, Addr: addr6}, syscall.AF_INET6, nil\n\t}\n}", "title": "" }, { "docid": "f10ad4f06a4e39b90f3f25c35daf36eb", "score": "0.44745076", "text": "func (o ScaleSetNetworkProfileOutput) IpForwarding() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v ScaleSetNetworkProfile) *bool { return v.IpForwarding }).(pulumi.BoolPtrOutput)\n}", "title": "" }, { "docid": "ec7954ef032a7bb50a3dacb98b9eb493", "score": "0.4461117", "text": "func TestIsLoopback(t *testing.T) {\n\ttestSet := []struct {\n\t\tquery NetAddress\n\t\tdesiredResponse bool\n\t}{\n\t\t// Networks such as 10.0.0.x have been omitted from testing - behavior\n\t\t// for these networks is currently undefined.\n\n\t\t// Localhost tests.\n\t\t{\"localhost\", false},\n\t\t{\"localhost:1234\", true},\n\t\t{\"127.0.0.1\", false},\n\t\t{\"127.0.0.1:6723\", true},\n\t\t{\"0.0.0.0:1234\", true},\n\t\t{\"[::]:1234\", true},\n\t\t{\"::1\", false},\n\t\t{\"[::1]:7124\", true},\n\n\t\t// Public name tests.\n\t\t{\"hn.com\", false},\n\t\t{\"hn.com:8811\", false},\n\t\t{\"12.34.45.64\", false},\n\t\t{\"12.34.45.64:7777\", false},\n\n\t\t// Garbage name tests.\n\t\t{\"\", false},\n\t\t{\"garbage\", false},\n\t\t{\"garbage:6432\", false},\n\t\t{\"garbage:6146:616\", false},\n\t\t{\"::1:4646\", false},\n\t\t{\"[::1]\", false},\n\t}\n\tfor _, test := range testSet {\n\t\tif test.query.IsLoopback() != test.desiredResponse {\n\t\t\tt.Error(\"test failed:\", test, test.query.IsLoopback())\n\t\t}\n\t}\n}", "title": "" }, { "docid": "570c53394dff0d0c848e42c544e6e435", "score": "0.44590187", "text": "func (*Bgp_Neighbor_AfiSafi_Ipv4Unicast) IsYANGGoStruct() {}", "title": "" }, { "docid": "4ca86e18cc21d8ab3a0ba5c481cfda2e", "score": "0.44539726", "text": "func InetAton(ipAddr string) (uint32, error) {\n\n\tip := net.ParseIP(ipAddr)\n\tif ip == nil {\n\t\treturn 0, errors.New(\"Wrong IP address format\")\n\t}\n\n\tif ip.To4() == nil {\n\t\treturn 0, errors.New(\"Wrong IP address format (IPv6\")\n\t}\n\n\treturn binary.BigEndian.Uint32(ip), nil\n}", "title": "" }, { "docid": "7ccc40616d23691faf9276e5e7b3a4df", "score": "0.4453876", "text": "func (E_OpenconfigOspfv2_ExtendedPrefix_AddressFamily) IsYANGGoEnum() {}", "title": "" }, { "docid": "316425af39f9cb17bedeed71379c0735", "score": "0.44389874", "text": "func checkForNewAddress(addr string) bool {\n\n\tr, _ := regexp.Compile(\"[0-9]*\\\\.[0-9]*\\\\.[0-9]*\\\\.[0-9]*\")\n\tnewAddr := r.FindString(addr)\n\tfor _, cp := range chatPeers {\n\t\toldAddr := cp.Address\n\t\tif oldAddr == newAddr {\n\t\t\treturn false\n\t\t}\n\t}\n\n\taddPeerToList(defaultName, newAddr)\n\n\treturn true\n}", "title": "" }, { "docid": "388cddf49963e70d4a40217e8c32e022", "score": "0.44350627", "text": "func ipNetEqual(a, b net.IPNet) bool {\n\treturn a.IP.Equal(b.IP) && bytes.Equal(a.Mask, b.Mask)\n}", "title": "" }, { "docid": "b0f18514f532304b27fce899d73159e4", "score": "0.44332987", "text": "func NetworkSmaller(db XODB, v0 string, v1 string) (string, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.network_smaller($1, $2)`\n\n\t// run query\n\tvar ret string\n\tXOLog(sqlstr, v0, v1)\n\terr = db.QueryRow(sqlstr, v0, v1).Scan(&ret)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "b4bc5dfdce5644d2b974bead3e775c9f", "score": "0.44294325", "text": "func probeIPv6Stack() (supportsIPv6, supportsIPv4map bool) {\n\tvar probes = []struct {\n\t\tladdr TCPAddr\n\t\tvalue int\n\t}{\n\t\t// IPv6 communication capability\n\t\t{laddr: TCPAddr{IP: ParseIP(\"::1\")}, value: 1},\n\t\t// IPv4-mapped IPv6 address communication capability\n\t\t{laddr: TCPAddr{IP: IPv4(127, 0, 0, 1)}, value: 0},\n\t}\n\tvar supps [2]bool\n\tswitch runtime.GOOS {\n\tcase \"dragonfly\", \"openbsd\":\n\t\t// Some released versions of DragonFly BSD pretend to\n\t\t// accept IPV6_V6ONLY=0 successfully, but the state\n\t\t// still stays IPV6_V6ONLY=1. Eventually DragonFly BSD\n\t\t// stops pretending, but the transition period would\n\t\t// cause unpredictable behavior and we need to avoid\n\t\t// it.\n\t\t//\n\t\t// OpenBSD also doesn't support IPV6_V6ONLY=0 but it\n\t\t// never pretends to accept IPV6_V6OLY=0. It always\n\t\t// returns an error and we don't need to probe the\n\t\t// capability.\n\t\tprobes = probes[:1]\n\t}\n\n\tfor i := range probes {\n\t\ts, err := socketFunc(syscall.AF_INET6, syscall.SOCK_STREAM, syscall.IPPROTO_TCP)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tdefer closeFunc(s)\n\t\tsyscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, probes[i].value)\n\t\tsa, err := probes[i].laddr.sockaddr(syscall.AF_INET6)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tif err := syscall.Bind(s, sa); err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tsupps[i] = true\n\t}\n\n\treturn supps[0], supps[1]\n}", "title": "" }, { "docid": "65ce0a0deafaef75030e37847b0c5a10", "score": "0.44241154", "text": "func (s *RoundRobinSuite) TestFailoverAvoidsSameEndpoint(c *C) {\n\tr := s.newRR()\n\n\tuA := MustParseUrl(\"http://localhost:5000\")\n\tuB := MustParseUrl(\"http://localhost:5001\")\n\tr.AddEndpoint(uA)\n\tr.AddEndpoint(uB)\n\n\tfailedRequest := &BaseRequest{\n\t\tAttempts: []Attempt{\n\t\t\t&BaseAttempt{\n\t\t\t\tEndpoint: uA,\n\t\t\t\tError: fmt.Errorf(\"Something failed\"),\n\t\t\t},\n\t\t},\n\t}\n\n\tu, err := r.NextEndpoint(failedRequest)\n\tc.Assert(err, IsNil)\n\tc.Assert(u, Equals, uB)\n}", "title": "" }, { "docid": "e5ed829f2c5a93bfd8948a6167440ac0", "score": "0.442275", "text": "func sameOrigin(u1, u2 *url.URL) bool {\n\t// we take pointers, as url.Parse() returns a pointer\n\t// and http.Request.URL is a pointer as well\n\n\t// Host is either host or host:port\n\treturn (u1.Scheme == u2.Scheme && u1.Host == u2.Host)\n}", "title": "" }, { "docid": "ad04d59b42f292dcb9c58563ee6212d9", "score": "0.44209418", "text": "func isIPv4(addr string) bool {\n\ttcpAddr, err := net.ResolveTCPAddr(\"tcp\", addr)\n\treturn err == nil && tcpAddr.IP.To4() != nil\n}", "title": "" }, { "docid": "56075d137e6d20857e45d04f5b681535", "score": "0.4410307", "text": "func (*Bgp_Neighbor_AfiSafi_Ipv6Unicast) IsYANGGoStruct() {}", "title": "" }, { "docid": "98671f1438c8dcf616e25fb64bc113d5", "score": "0.44004616", "text": "func EnsureAddrWithPrefix(link netlink.Link, ipNetSet *terwayTypes.IPNetSet, prefixRoute bool) (bool, error) {\n\tvar changed bool\n\n\tif ipNetSet.IPv4 != nil {\n\t\tnewAddr := &netlink.Addr{IPNet: ipNetSet.IPv4}\n\t\tif !prefixRoute {\n\t\t\tnewAddr.Flags = unix.IFA_F_NOPREFIXROUTE\n\t\t}\n\t\tc, err := EnsureAddr(link, newAddr)\n\t\tif err != nil {\n\t\t\treturn c, err\n\t\t}\n\t\tif c {\n\t\t\tchanged = true\n\t\t}\n\t}\n\tif ipNetSet.IPv6 != nil {\n\t\tnewAddr := &netlink.Addr{IPNet: ipNetSet.IPv6}\n\t\tif !prefixRoute {\n\t\t\tnewAddr.Flags = unix.IFA_F_NOPREFIXROUTE\n\t\t}\n\t\tc, err := EnsureAddr(link, newAddr)\n\t\tif err != nil {\n\t\t\treturn c, err\n\t\t}\n\t\tif c {\n\t\t\tchanged = true\n\t\t}\n\t}\n\treturn changed, nil\n}", "title": "" }, { "docid": "a6d42bed73fd09046e4134664193f2cb", "score": "0.43986675", "text": "func EnsureAddr(link netlink.Link, expect *netlink.Addr) (bool, error) {\n\tvar changed bool\n\n\taddrList, err := netlink.AddrList(link, NetlinkFamily(expect.IP))\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"error list address from if %s, %w\", link.Attrs().Name, err)\n\t}\n\n\tfound := false\n\tfor _, addr := range addrList {\n\t\tif !addr.IP.IsGlobalUnicast() {\n\t\t\tcontinue\n\t\t}\n\n\t\tif (addr.IPNet.String() == expect.IPNet.String()) && (addr.Scope == expect.Scope) {\n\t\t\tfound = true\n\t\t\tcontinue\n\t\t}\n\n\t\terr := AddrDel(link, &addr)\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\t\tchanged = true\n\t}\n\tif found {\n\t\treturn changed, nil\n\t}\n\treturn true, AddrReplace(link, expect)\n}", "title": "" }, { "docid": "9e81386c63b89abea6150e9742cc2e3f", "score": "0.43966833", "text": "func isLinkLocal(addr tcpip.Address) bool {\n\taddrBytes := addr.AsSlice()\n\treturn len(addrBytes) >= 2 && addrBytes[0] == 0xfe && addrBytes[1]&0xc0 == 0x80\n}", "title": "" }, { "docid": "e83151501a5113f7d71d9b6da291f859", "score": "0.43944892", "text": "func (r upstreamResolver) LookupNetIP(\n\t_ context.Context,\n\tnetwork string,\n\thost string,\n) (ipAddrs []netip.Addr, err error) {\n\t// TODO(e.burkov): Investigate when [r.Upstream] is nil and why.\n\tif r.Upstream == nil || host == \"\" {\n\t\treturn []netip.Addr{}, nil\n\t}\n\n\thost = dns.Fqdn(host)\n\n\tanswers := make([][]dns.RR, 1, 2)\n\tvar errs []error\n\tswitch network {\n\tcase \"ip4\", \"ip6\":\n\t\tqtype := dns.TypeA\n\t\tif network == \"ip6\" {\n\t\t\tqtype = dns.TypeAAAA\n\t\t}\n\n\t\tvar resp *dns.Msg\n\t\tresp, err = r.resolve(host, qtype)\n\t\tif err != nil {\n\t\t\treturn []netip.Addr{}, err\n\t\t}\n\n\t\tanswers[0] = resp.Answer\n\tcase \"ip\":\n\t\tresCh := make(chan *resolveResult, 2)\n\n\t\tgo r.resolveAsync(resCh, host, dns.TypeA)\n\t\tgo r.resolveAsync(resCh, host, dns.TypeAAAA)\n\n\t\tanswers = answers[:0:cap(answers)]\n\t\tfor i := 0; i < 2; i++ {\n\t\t\tres := <-resCh\n\t\t\tif res.err != nil {\n\t\t\t\terrs = append(errs, res.err)\n\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tanswers = append(answers, res.resp.Answer)\n\t\t}\n\tdefault:\n\t\treturn []netip.Addr{}, fmt.Errorf(\"unsupported network %s\", network)\n\t}\n\n\tfor _, ans := range answers {\n\t\tfor _, rr := range ans {\n\t\t\tif addr, ok := netip.AddrFromSlice(proxyutil.IPFromRR(rr)); ok {\n\t\t\t\tipAddrs = append(ipAddrs, addr)\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO(e.burkov): Use [errors.Join] in Go 1.20.\n\tif len(ipAddrs) == 0 && len(errs) > 0 {\n\t\treturn []netip.Addr{}, errs[0]\n\t}\n\n\t// Use the previous dnsproxy behavior: prefer IPv4 by default.\n\t//\n\t// TODO(a.garipov): Consider unexporting this entire method or\n\t// documenting that the order of addrs is undefined.\n\tproxynetutil.SortNetIPAddrs(ipAddrs, false)\n\n\treturn ipAddrs, nil\n}", "title": "" }, { "docid": "abafb30dcc949cab7be4784ee8ee5ca9", "score": "0.43882325", "text": "func useProxy(pair *ice.CandidatePair) bool {\n\tremoteIP := net.ParseIP(pair.Remote.Address())\n\tmyIp := net.ParseIP(pair.Local.Address())\n\tremoteIsPublic := isPublicIP(remoteIP)\n\tmyIsPublic := isPublicIP(myIp)\n\n\t//one of the hosts has a public IP\n\tif remoteIsPublic && pair.Remote.Type() == ice.CandidateTypeHost {\n\t\treturn false\n\t}\n\tif myIsPublic && pair.Local.Type() == ice.CandidateTypeHost {\n\t\treturn false\n\t}\n\n\tif pair.Local.Type() == ice.CandidateTypeHost && pair.Remote.Type() == ice.CandidateTypeHost {\n\t\tif !remoteIsPublic && !myIsPublic {\n\t\t\t//both hosts are in the same private network\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "2a37dbc2283ded4946b468ae11a2f1be", "score": "0.43863156", "text": "func probeIPv4Stack() bool {\n\ts, err := socketFunc(syscall.AF_INET, syscall.SOCK_STREAM, syscall.IPPROTO_TCP)\n\tswitch err {\n\tcase syscall.EAFNOSUPPORT, syscall.EPROTONOSUPPORT:\n\t\treturn false\n\tcase nil:\n\t\tcloseFunc(s)\n\t}\n\treturn true\n}", "title": "" }, { "docid": "b54248079b9b21a0b964b28174c14c74", "score": "0.43845025", "text": "func (*Bgp_Global_AfiSafi_Ipv4Unicast) IsYANGGoStruct() {}", "title": "" }, { "docid": "e3ac1b663d6f4abee010834085813e83", "score": "0.43779463", "text": "func (*Bgp_Global_AfiSafi_Ipv6Unicast) IsYANGGoStruct() {}", "title": "" }, { "docid": "ec56489c0b0aec40ad5f25e30aaae7e4", "score": "0.4371414", "text": "func (b Binding) EqualIP(x net.IP) bool {\n\treturn b.IP.Equal(x)\n}", "title": "" }, { "docid": "a20a02f555a80f82f6c929e0f71e314e", "score": "0.43706656", "text": "func (me TbulkobservableTypeType) IsDomainToIpv6() bool { return me.String() == \"domain-to-ipv6\" }", "title": "" }, { "docid": "17e38ebdfdd62a1641d567c298c8c76c", "score": "0.4370385", "text": "func doIpAddrCheck(ip string, netInterface string) bool {\n\tcmdName := \"ip\"\n\tcmdArgs := []string{\"-o\", \"-4\", \"addr\", \"show\", \"dev\", netInterface}\n\tout, err := util.DoCmd(cmdName, cmdArgs)\n\tif err != nil {\n\t\tlog.Error(out.String())\n\t\tlog.Fatal(err)\n\t}\n\tif !strings.Contains(out.String(), fmt.Sprintf(\"%s/32\", ip)) {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "6bb77c48c77b3104da604d493bdd2c79", "score": "0.43480447", "text": "func GeomEqualFold(v string) predicate.Address {\n\treturn predicate.Address(func(s *sql.Selector) {\n\t\ts.Where(sql.EqualFold(s.C(FieldGeom), v))\n\t})\n}", "title": "" }, { "docid": "771d9f78aee633a464ede28fed93139a", "score": "0.43462998", "text": "func execResolveTCPAddr(_ int, p *gop.Context) {\n\targs := p.GetArgs(2)\n\tret, ret1 := net.ResolveTCPAddr(args[0].(string), args[1].(string))\n\tp.Ret(2, ret, ret1)\n}", "title": "" }, { "docid": "a448297199cb2b6b8959113697ba235c", "score": "0.43460888", "text": "func IPAddressEQ(v string) predicate.IPAddress {\n\treturn predicate.IPAddress(func(s *sql.Selector) {\n\t\ts.Where(sql.EQ(s.C(FieldIPAddress), v))\n\t})\n}", "title": "" }, { "docid": "7fc4e93b8f07ae58c7880391e00b4608", "score": "0.43460852", "text": "func (c *IPHAConn) af() int {\n\tif c.laddr.To4() != nil {\n\t\treturn syscall.AF_INET\n\t}\n\treturn syscall.AF_INET6\n}", "title": "" }, { "docid": "a6af6c36f4a5ae609c0369a4c7ada27c", "score": "0.43384665", "text": "func ByFamily(f ConnectionFamily) ConnectionFilterFunc {\n\treturn func(c ConnectionStats) bool {\n\t\treturn c.Family == f\n\t}\n}", "title": "" }, { "docid": "77b98dcdd2772e1611081a9e3d6314e2", "score": "0.43362546", "text": "func matchGateway(a string, m int, g string) bool {\n\tip := net.ParseIP(a)\n\tgw := net.ParseIP(g)\n\tvar mask net.IPMask\n\tif ip.To4() != nil {\n\t\tmask = net.CIDRMask(m, 32)\n\t} else {\n\t\tmask = net.CIDRMask(m, 128)\n\t}\n\tif ip.Mask(mask).Equal(gw.Mask(mask)) {\n\t\treturn true\n\t}\n\treturn false\n}", "title": "" }, { "docid": "0d67cebbbc8ef8a72cdd378e509965f6", "score": "0.4331158", "text": "func (*Bgp_Neighbor_AfiSafi_L3VpnIpv6Unicast) IsYANGGoStruct() {}", "title": "" }, { "docid": "c0b4cccafa5d8bf9ae6d06f9b8ab6762", "score": "0.43285242", "text": "func (*Bgp_Neighbor_AfiSafi_L3VpnIpv4Unicast) IsYANGGoStruct() {}", "title": "" }, { "docid": "55c034865a299996b8c217b64508ede3", "score": "0.43231934", "text": "func (ni *NetInfo) local_host(ip net.IP) bool {\n for _, f := range(ni.IPS) {\n if f.Contains(ip) == true {\n return true\n }\n }\n return false\n}", "title": "" }, { "docid": "3d3de5b5412fcbc4d29a92f0272a71a1", "score": "0.43196732", "text": "func Xinet_ntoa(tls TLS, in struct{ Xs_addr uint32 }) uintptr {\n\tpanic(\"TODO\")\n}", "title": "" }, { "docid": "92c5033b374f51f0cb5e4013513d5e75", "score": "0.43187958", "text": "func LoopbackIP(ip cue.Value) bool {\n\treturn netGetIP(ip).IsLoopback()\n}", "title": "" }, { "docid": "5590bbda70d82f999e2a594aac6ffe43", "score": "0.43106514", "text": "func equalSpiffeID(existing, current *common.RegistrationEntry) bool {\n\texistingSet := selector.NewSetFromRaw(existing.Selectors)\n\tcurrentSet := selector.NewSetFromRaw(current.Selectors)\n\n\treturn equalStringSlice(existing.DnsNames, current.DnsNames) &&\n\t\texistingSet.Equal(currentSet) &&\n\t\texisting.SpiffeId == current.SpiffeId &&\n\t\texisting.ParentId == current.ParentId\n}", "title": "" }, { "docid": "5c609c128bb815da3949ce88d724d75c", "score": "0.4308496", "text": "func InetRecv(db XODB, v0 pgtypes.Internal) (string, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.inet_recv($1)`\n\n\t// run query\n\tvar ret string\n\tXOLog(sqlstr, v0)\n\terr = db.QueryRow(sqlstr, v0).Scan(&ret)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn ret, nil\n}", "title": "" }, { "docid": "2d6361f845b913e235b097db27ec55ab", "score": "0.43030006", "text": "func (m *EdgeManager) verifyConflict(cidr1, cidr2 string) bool {\n\tsp := strings.Split(cidr1, \"/\")\n\tif len(sp) != 2 {\n\t\tlog.Error(\"invalid cidr format: %s\", cidr1)\n\t\treturn false\n\t}\n\n\tip1, sprefix1 := sp[0], sp[1]\n\tprefix1, err := strconv.Atoi(sprefix1)\n\tif err != nil {\n\t\tlog.Error(\"invalid cidr format: %s\", cidr1)\n\t\treturn false\n\t}\n\n\tipv41, err := ip.ParseIP4(ip1)\n\tif err != nil {\n\t\tlog.Error(\"invalid cidr format: %s\", cidr1)\n\t\treturn false\n\t}\n\n\tsp = strings.Split(cidr2, \"/\")\n\tif len(sp) != 2 {\n\t\tlog.Error(\"invalid cidr format: %s\", cidr2)\n\t\treturn false\n\t}\n\n\tip2, sprefix2 := sp[0], sp[1]\n\tprefix2, err := strconv.Atoi(sprefix2)\n\tif err != nil {\n\t\tlog.Error(\"invalid cidr format: %s\", cidr2)\n\t\treturn false\n\t}\n\n\tipv42, err := ip.ParseIP4(ip2)\n\tif err != nil {\n\t\tlog.Error(\"invalid cidr format: %s\", cidr2)\n\t\treturn false\n\t}\n\n\tipn1 := ip.IP4Net{\n\t\tIP: ipv41,\n\t\tPrefixLen: uint(prefix1),\n\t}\n\tipn2 := ip.IP4Net{\n\t\tIP: ipv42,\n\t\tPrefixLen: uint(prefix2),\n\t}\n\n\treturn !ipn1.Overlaps(ipn2)\n}", "title": "" }, { "docid": "df9ffe6d36f7942218f07117638aebaf", "score": "0.43009913", "text": "func (*Bgp_Global_AfiSafi_L3VpnIpv6Unicast) IsYANGGoStruct() {}", "title": "" }, { "docid": "ce9bbaf5b2959f3f28e14fd89ca6be12", "score": "0.42976677", "text": "func (a *TCPAddr) Network() string { return \"tcp\" }", "title": "" }, { "docid": "a86cd5afa9000f4a748e04a9ef97e749", "score": "0.42896858", "text": "func (s *PeerServer) checkPeerAddressNonconflict() bool {\n\t// there exists the (name, peer address) pair\n\tif peerURL, ok := s.registry.PeerURL(s.Config.Name); ok {\n\t\tif peerURL == s.Config.URL {\n\t\t\treturn true\n\t\t}\n\t}\n\n\t// check all existing peer addresses\n\tpeerURLs := s.registry.PeerURLs(s.raftServer.Leader(), s.Config.Name)\n\tfor _, peerURL := range peerURLs {\n\t\tif peerURL == s.Config.URL {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "title": "" }, { "docid": "03a273b4b2a19ed1a1fdc67e81eef251", "score": "0.4288402", "text": "func ExchangeGossip(bd1, bd2 *BusDriver) {\n giveGossip := func(src, dst *BusDriver) {\n for sg := range src.Gossips {\n var known bool\n for dg := range dst.Gossips {\n if src.Gossips[sg] == dst.Gossips[dg] {\n known = true\n }\n }\n if !known {\n dst.Gossips = append(dst.Gossips, src.Gossips[sg])\n }\n }\n }\n giveGossip(bd1, bd2)\n giveGossip(bd2, bd1)\n}", "title": "" }, { "docid": "868ffbddb10f94511aca6a304b887f77", "score": "0.42735648", "text": "func autoNetworkAddress(goplsPath, id string) (network string, address string) {\n\tif id != \"\" {\n\t\tpanic(\"identified remotes are not supported on windows\")\n\t}\n\treturn \"tcp\", \":37374\"\n}", "title": "" }, { "docid": "fe10cbaabe9eea4590e4e512244750d8", "score": "0.42728168", "text": "func (*Bgp_Global_AfiSafi_L3VpnIpv4Unicast) IsYANGGoStruct() {}", "title": "" }, { "docid": "6df196748b297e47ad33ebba8da4633c", "score": "0.42672354", "text": "func getNextIP(originalIP net.IP, mask net.IPMask) (net.IP, bool) {\n\tisIpv4 := originalIP.To4() != nil\n\n\tfixArraySize := func(ip net.IP) net.IP {\n\t\tif isIpv4 {\n\t\t\treturn utils.TakeLastNItemsFromByteArray(ip, net.IPv4len)\n\t\t}\n\t\treturn utils.TakeLastNItemsFromByteArray(ip, net.IPv6len)\n\t}\n\n\t// for ipv4 take last 4 bytes because IPv4 can be represented as IPv6 internally\n\toriginalIP = fixArraySize(originalIP)\n\n\tintValue := big.NewInt(0)\n\n\tfor byteIndex, byteValue := range originalIP {\n\t\tshiftTo := uint((len(originalIP) - byteIndex - 1) * 8)\n\t\tintValue = intValue.Or(\n\t\t\tintValue, big.NewInt(0).Lsh(big.NewInt(int64(byteValue)), shiftTo),\n\t\t)\n\t}\n\n\tintValue = intValue.Add(intValue, big.NewInt(1))\n\n\tresultIP := net.IP(intValue.Bytes())\n\n\t// adding one can overflow the value leading to an array of 5 or 17 elements\n\t// and there is an options where we don't have enough leading zeros\n\tresultIP = fixArraySize(resultIP)\n\n\toriginalIPNetwork := originalIP.Mask(mask)\n\tresultIPNetwork := resultIP.Mask(mask)\n\n\tif !originalIPNetwork.Equal(resultIPNetwork) {\n\t\t// network differs, there was an overflow\n\t\t// we still want networks to be the same\n\t\tvar invertedMask net.IPMask\n\t\tfor _, maskByte := range mask {\n\t\t\tinvertedMask = append(invertedMask, maskByte^255)\n\t\t}\n\n\t\tresultHostIP := resultIP.Mask(invertedMask)\n\n\t\t// combine original IP's network part and result IP's host part\n\t\tintValue := big.NewInt(0).SetBytes(originalIPNetwork)\n\t\tintValue = intValue.Or(intValue, big.NewInt(0).SetBytes(resultHostIP))\n\n\t\treturn intValue.Bytes(), true\n\t}\n\n\treturn resultIP, false\n}", "title": "" }, { "docid": "6df196748b297e47ad33ebba8da4633c", "score": "0.42672354", "text": "func getNextIP(originalIP net.IP, mask net.IPMask) (net.IP, bool) {\n\tisIpv4 := originalIP.To4() != nil\n\n\tfixArraySize := func(ip net.IP) net.IP {\n\t\tif isIpv4 {\n\t\t\treturn utils.TakeLastNItemsFromByteArray(ip, net.IPv4len)\n\t\t}\n\t\treturn utils.TakeLastNItemsFromByteArray(ip, net.IPv6len)\n\t}\n\n\t// for ipv4 take last 4 bytes because IPv4 can be represented as IPv6 internally\n\toriginalIP = fixArraySize(originalIP)\n\n\tintValue := big.NewInt(0)\n\n\tfor byteIndex, byteValue := range originalIP {\n\t\tshiftTo := uint((len(originalIP) - byteIndex - 1) * 8)\n\t\tintValue = intValue.Or(\n\t\t\tintValue, big.NewInt(0).Lsh(big.NewInt(int64(byteValue)), shiftTo),\n\t\t)\n\t}\n\n\tintValue = intValue.Add(intValue, big.NewInt(1))\n\n\tresultIP := net.IP(intValue.Bytes())\n\n\t// adding one can overflow the value leading to an array of 5 or 17 elements\n\t// and there is an options where we don't have enough leading zeros\n\tresultIP = fixArraySize(resultIP)\n\n\toriginalIPNetwork := originalIP.Mask(mask)\n\tresultIPNetwork := resultIP.Mask(mask)\n\n\tif !originalIPNetwork.Equal(resultIPNetwork) {\n\t\t// network differs, there was an overflow\n\t\t// we still want networks to be the same\n\t\tvar invertedMask net.IPMask\n\t\tfor _, maskByte := range mask {\n\t\t\tinvertedMask = append(invertedMask, maskByte^255)\n\t\t}\n\n\t\tresultHostIP := resultIP.Mask(invertedMask)\n\n\t\t// combine original IP's network part and result IP's host part\n\t\tintValue := big.NewInt(0).SetBytes(originalIPNetwork)\n\t\tintValue = intValue.Or(intValue, big.NewInt(0).SetBytes(resultHostIP))\n\n\t\treturn intValue.Bytes(), true\n\t}\n\n\treturn resultIP, false\n}", "title": "" }, { "docid": "6be956e455aa8fda4105b92925d9a071", "score": "0.42631632", "text": "func execmIPEqual(_ int, p *gop.Context) {\n\targs := p.GetArgs(2)\n\tret := args[0].(net.IP).Equal(args[1].(net.IP))\n\tp.Ret(2, ret)\n}", "title": "" }, { "docid": "624e1ce2f55ca489780044641b3fe9e6", "score": "0.42552033", "text": "func TestAnycastHost() Host {\n\treturn testAnycastHost\n}", "title": "" }, { "docid": "bd473342f21881a9af042790d11174b7", "score": "0.42484063", "text": "func BoxSame(db XODB, v0 pgtypes.Box, v1 pgtypes.Box) (bool, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT pg_catalog.box_same($1, $2)`\n\n\t// run query\n\tvar ret bool\n\tXOLog(sqlstr, v0, v1)\n\terr = db.QueryRow(sqlstr, v0, v1).Scan(&ret)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn ret, nil\n}", "title": "" } ]
e62496d8aa0a0cb5a228b1e82630deb2
GetOrderIDsMapCopy returns a new copy of OrderIDsMap
[ { "docid": "24d8911324ddb53f457f8107cc7838e5", "score": "0.8882172", "text": "func (c *DiskCache) GetOrderIDsMapCopy() *OrderIDsMap {\n\tif c.orderIDsMap == nil {\n\t\treturn nil\n\t}\n\tret := make(map[string][]string)\n\tfor k, v := range c.orderIDsMap.Data {\n\t\tif len(v) == 0 {\n\t\t\tret[k] = []string{}\n\t\t}\n\t\tret[k] = append(ret[k], v...)\n\t}\n\treturn &OrderIDsMap{Data: ret}\n}", "title": "" } ]
[ { "docid": "e4aec1347b9ad406978b8a5cbacd7637", "score": "0.6552473", "text": "func copyMap(orig map[uint8]int) map[uint8]int {\n\tclone := make(map[uint8]int, len(orig))\n\tfor k, v := range orig {\n\t\tclone[k] = v\n\t}\n\treturn clone\n}", "title": "" }, { "docid": "1f650100cdf82f2d48edeed8fdd598a0", "score": "0.6327858", "text": "func copyMap(m map[string]int) map[string]int {\n\tnewM := make(map[string] int)\n\tfor k,v := range m {\n\t\tnewM[k]=v\n\t}\n\treturn newM\n}", "title": "" }, { "docid": "a5006adc7a81a27078d83ff71b9ca679", "score": "0.6308566", "text": "func copy(originalMap map[string]*proccessor) map[string]*proccessor {\n\tnewMap := make(map[string]*proccessor)\n\tfor key, value := range originalMap {\n\t\tnewMap[key] = value\n\t}\n\treturn newMap\n}", "title": "" }, { "docid": "7ec830460f495fc5b1555d617b89db54", "score": "0.61346364", "text": "func copyMap(srcMap map[string]string) map[string]string {\n\tresultMap := make(map[string]string, len(srcMap))\n\tfor key, value := range srcMap {\n\t\tresultMap[key] = value\n\t}\n\treturn resultMap\n}", "title": "" }, { "docid": "f9429844ec71bbdcf44fd9d8da15f081", "score": "0.60664326", "text": "func (o *OrderedMap[K, V]) Clone() (cloned *OrderedMap[K, V]) {\n\tcloned = New[K, V]()\n\to.ForEach(func(key K, value V) bool {\n\t\tcloned.Set(key, value)\n\n\t\treturn true\n\t})\n\n\treturn\n}", "title": "" }, { "docid": "4d26e31c6d3c6e6399ac74777bd96e69", "score": "0.5895347", "text": "func (onMap *OneToNStringMap) CopyMap() map[string]mapset.Set {\n\tonMap.TraceableLock()\n\tdefer onMap.TraceableUnlock()\n\tcopy := make(map[string]mapset.Set)\n\tfor key, childSet := range onMap.oneToNStringMap {\n\t\tcopy[key] = childSet.Clone()\n\t}\n\treturn copy\n}", "title": "" }, { "docid": "7e7f5293d86ecded0f692b5439901c48", "score": "0.5847779", "text": "func (peers *PeerList) Copy() map[string]int32 {\n\tpeers.mux.Lock()\n\tdefer peers.mux.Unlock()\n\tnewPeerMap := make(map[string]int32)\n\tfor key, value := range peers.peerMap {\n\t\tnewPeerMap[key] = value\n\t}\n\treturn newPeerMap\n}", "title": "" }, { "docid": "d45d9caefc199e5445eee283f0157c8f", "score": "0.57440025", "text": "func CopyStringIntMap(originalMap map[string]int) map[string]int {\n\tnewMap := make(map[string]int, len(originalMap))\n\tfor k, v := range originalMap {\n\t\tnewMap[k] = v\n\t}\n\treturn newMap\n}", "title": "" }, { "docid": "19f58b4806d5a2589f145b6b8b5167e1", "score": "0.5692553", "text": "func (m ImportDeclMap) Clone() ImportDeclMap {\n\tcloned := make(ImportDeclMap)\n\n\tfor key, value := range m {\n\t\tcloned[key] = value\n\t}\n\n\treturn cloned\n}", "title": "" }, { "docid": "6e54b11f92fae9c7a6258d3535ba0370", "score": "0.5663295", "text": "func (peers *PeerList) Copy() map[string]int32 {\n\tpeers.mux.Lock()\n\tdefer peers.mux.Unlock()\n\treturn peers.peerMap\n}", "title": "" }, { "docid": "95a29766da745a5e5fb879c17ce960fd", "score": "0.56379294", "text": "func CopySIMap(src map[string]int) map[string]int {\n\tdst := make(map[string]int)\n\tif src != nil {\n\t\tfor key, value := range src {\n\t\t\tdst[key] = value\n\t\t}\n\t}\n\treturn dst\n}", "title": "" }, { "docid": "c1233b8d3d319492a90f41d76ae295be", "score": "0.5622625", "text": "func copyMap(m map[string]string) map[string]string {\n\tif m == nil {\n\t\treturn nil\n\t}\n\tcpy := make(map[string]string)\n\tfor k, v := range m {\n\t\tcpy[k] = v\n\t}\n\treturn cpy\n}", "title": "" }, { "docid": "fff0c142d889e7418df1751fb34bb7d9", "score": "0.55976796", "text": "func (m *memoryCache) copy() map[string]interface{} {\n\tcp := make(map[string]interface{}, cap(m.keys))\n\n\tm.mutex.Lock()\n\tdefer m.mutex.Unlock()\n\n\tfor k, v := range m.cache {\n\t\tcp[k] = v\n\t}\n\treturn cp\n}", "title": "" }, { "docid": "83939f54b9ccb25f2cc5b81e1aff2a2a", "score": "0.5596563", "text": "func (m ResMap) DeepCopy(rf *resource.Factory) ResMap {\n\tmcopy := make(ResMap)\n\tfor id, obj := range m {\n\t\tmcopy[id] = obj.DeepCopy()\n\t}\n\treturn mcopy\n}", "title": "" }, { "docid": "a3cd8efc5391a03aeb09e18c8f1c62f3", "score": "0.5578773", "text": "func mapCopy(to, from map[string]interface{}) {\n\tfor key, value := range from {\n\t\tswitch value.(type) {\n\t\tcase bson.M:\n\t\t\tmn := make(map[string]interface{})\n\t\t\tbsonCopy(mn, value.(bson.M))\n\t\t\tto[key] = mn\n\t\t\tcontinue\n\t\tcase map[string]interface{}:\n\t\t\tmn := make(map[string]interface{})\n\t\t\tmapCopy(mn, value.(map[string]interface{}))\n\t\t\tto[key] = mn\n\t\t\tcontinue\n\t\tdefault:\n\t\t\tto[key] = value\n\t\t\tcontinue\n\t\t}\n\t}\n}", "title": "" }, { "docid": "3ad3ca41561053db194a7d29b0e1656b", "score": "0.55684435", "text": "func (m InterfaceMap) Clone() InterfaceMap {\n\tcloned := make(InterfaceMap)\n\n\tfor key, value := range m {\n\t\tcloned[key] = value\n\t}\n\n\treturn cloned\n}", "title": "" }, { "docid": "744369b36d122bad9d484e23a71c5e67", "score": "0.5545492", "text": "func (partyIDs IDSlice) Copy() IDSlice {\n\ta := make(IDSlice, len(partyIDs))\n\tcopy(a, partyIDs)\n\treturn a\n}", "title": "" }, { "docid": "4949aec6a4a83bd2ab92f20dd5e99b6b", "score": "0.55404204", "text": "func (pm *PartitionMap) Copy() *PartitionMap {\n\tcpy := NewPartitionMap()\n\tcpy.Partitions = make(PartitionList, 0, cap(pm.Partitions))\n\n\tfor _, p := range pm.Partitions {\n\t\tpart := Partition{\n\t\t\tTopic: p.Topic,\n\t\t\tPartition: p.Partition,\n\t\t\tReplicas: make([]int, len(p.Replicas)),\n\t\t}\n\n\t\tcopy(part.Replicas, p.Replicas)\n\t\tcpy.Partitions = append(cpy.Partitions, part)\n\t}\n\n\treturn cpy\n}", "title": "" }, { "docid": "4ee7193fa517d4c2db4e11440e6fdae3", "score": "0.55221844", "text": "func (pm *PartitionMap) Copy() *PartitionMap {\n\tcpy := NewPartitionMap()\n\n\tfor _, p := range pm.Partitions {\n\t\tpart := Partition{\n\t\t\tTopic: p.Topic,\n\t\t\tPartition: p.Partition,\n\t\t\tReplicas: make([]int, len(p.Replicas)),\n\t\t}\n\n\t\tcopy(part.Replicas, p.Replicas)\n\t\tcpy.Partitions = append(cpy.Partitions, part)\n\t}\n\n\treturn cpy\n}", "title": "" }, { "docid": "85a3060c96b813c6b4ce1e9d5e5f37d7", "score": "0.54947174", "text": "func (m Map) Copy(min, max VecInt) Map {\r\n\tvar dim = VecInt{}\r\n\tif max.X > min.X && max.Y > min.Y {\r\n\t\tdim = VecInt{\r\n\t\t\tX: max.X - min.X,\r\n\t\t\tY: max.Y - min.Y,\r\n\t\t}\r\n\t}\r\n\r\n\tcopyMap := NewMap(dim, 0)\r\n\tfor x := 0; x < dim.X; x++ {\r\n\t\tfor y := 0; y < dim.Y; y++ {\r\n\t\t\tpos := VecInt{\r\n\t\t\t\tX: min.X + x,\r\n\t\t\t\tY: min.Y + y,\r\n\t\t\t}\r\n\t\t\tif m.ContainsCoord(pos) {\r\n\t\t\t\tcopyMap[x][y] = m.At(pos)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn copyMap\r\n}", "title": "" }, { "docid": "3aff0f4bff0263e39cf031501e494600", "score": "0.54616344", "text": "func (m *StringInterfaceMap) Clone() map[string]interface{} {\n\tdst := make(map[string]interface{}, len(m.data))\n\tm.mutex.RLock()\n\tfor k, v := range m.data {\n\t\tdst[k] = v\n\t}\n\tm.mutex.RUnlock()\n\treturn dst\n}", "title": "" }, { "docid": "23f2e6bb678c4fa77748b28bf27b211d", "score": "0.54161966", "text": "func CopyMap(m map[string]interface{}) map[string]interface{} {\n\tto := make(map[string]interface{})\n\tmapCopy(to, m)\n\treturn to\n}", "title": "" }, { "docid": "26369744d9002e2234de2f9b1662a3aa", "score": "0.5395519", "text": "func CopyExpiringBytesMap(src map[string]ExpiringValue) map[string]ExpiringValue {\n\tvar dest = make(map[string]ExpiringValue, len(src))\n\tfor key, value := range src {\n\t\tif value.Expired() {\n\t\t\tcontinue\n\t\t}\n\t\tdest[key] = value\n\t}\n\treturn dest\n}", "title": "" }, { "docid": "3394fdf60130c5852819bc61a522946d", "score": "0.5369505", "text": "func (c *DiskCache) setOrderIDs(key string, orderIDs []string) {\n\n\tif len(orderIDs) == 0 {\n\t\t// remove empty element immediately, not do it by the end of endblock\n\t\tdelete(c.orderIDsMap.Data, key)\n\t} else {\n\t\tc.orderIDsMap.Data[key] = orderIDs\n\t}\n\tc.orderIDsMap.updatedItems[key] = struct{}{}\n}", "title": "" }, { "docid": "822418409f465433e1c979ab432eda60", "score": "0.5349819", "text": "func (m ConstDeclMap) Clone() ConstDeclMap {\n\tcloned := make(ConstDeclMap)\n\n\tfor key, value := range m {\n\t\tcloned[key] = value\n\t}\n\n\treturn cloned\n}", "title": "" }, { "docid": "4c7260a52689f53ec3c6cfa0217bb3cd", "score": "0.5338347", "text": "func CopyMapKeys(m any, typeHint any) any {\n\tmapVal := reflect.ValueOf(m)\n\tkeys := reflect.MakeSlice(reflect.TypeOf(typeHint), 0, mapVal.Len())\n\tfor _, k := range mapVal.MapKeys() {\n\t\tkeys = reflect.Append(keys, k)\n\t}\n\treturn keys.Interface()\n}", "title": "" }, { "docid": "1dd2def291030a25fc3d29fca6c61206", "score": "0.53342956", "text": "func (m VarDeclMap) Clone() VarDeclMap {\n\tcloned := make(VarDeclMap)\n\n\tfor key, value := range m {\n\t\tcloned[key] = value\n\t}\n\n\treturn cloned\n}", "title": "" }, { "docid": "f2aecdda23e538f46229d69d686a0836", "score": "0.5305281", "text": "func bsonCopy(to map[string]interface{}, from bson.M) {\n\tfor key, value := range from {\n\t\tswitch value.(type) {\n\t\tcase bson.M:\n\t\t\tmn := make(map[string]interface{})\n\t\t\tbsonCopy(mn, value.(bson.M))\n\t\t\tto[key] = mn\n\t\t\tcontinue\n\t\tcase map[string]interface{}:\n\t\t\tmapCopy(to, value.(map[string]interface{}))\n\t\t\tcontinue\n\t\tdefault:\n\t\t\tto[key] = value\n\t\t\tcontinue\n\t\t}\n\t}\n}", "title": "" }, { "docid": "0e8ad9f26b65e6510278af266cb9268c", "score": "0.52945155", "text": "func (os OrderingSet) Copy() OrderingSet {\n\tres := make(OrderingSet, len(os))\n\tcopy(res, os)\n\treturn res\n}", "title": "" }, { "docid": "e78cad2a035a231ea94d8a6aee15c591", "score": "0.52899975", "text": "func (m FuncDeclMap) Clone() FuncDeclMap {\n\tcloned := make(FuncDeclMap)\n\n\tfor key, value := range m {\n\t\tcloned[key] = value\n\t}\n\n\treturn cloned\n}", "title": "" }, { "docid": "1a8c903b2292fda4308600a4c5e50303", "score": "0.5269456", "text": "func MapCopy(m map[string]any) map[string]any {\n\tnewMap := make(map[string]any, len(m))\n\tfor k, v := range m {\n\t\tswitch typedVal := v.(type) {\n\t\tcase map[string]any:\n\t\t\tnewMap[k] = MapCopy(typedVal)\n\t\tdefault:\n\t\t\t// Assume any other values are safe to directly copy.\n\t\t\t// Struct types and slice types shouldn't appear in attribute maps from pipelines\n\t\t\tnewMap[k] = v\n\t\t}\n\t}\n\treturn newMap\n}", "title": "" }, { "docid": "71259a96e54014e3ba9c2db0c4a66e9c", "score": "0.5194882", "text": "func (m genericMap) Copy() Mapper {\n\tdst := reflect.New(reflect.TypeOf(m.v))\n\n\tfor _, k := range m.v.MapKeys() {\n\t\tov := m.v.MapIndex(k)\n\t\tdst.SetMapIndex(k, ov)\n\t}\n\treturn &genericMap{dst}\n}", "title": "" }, { "docid": "40f1162e82b969471b1c3bcfb5baa8dd", "score": "0.51896155", "text": "func (m TypeDeclMap) Clone() TypeDeclMap {\n\tcloned := make(TypeDeclMap)\n\n\tfor key, value := range m {\n\t\tcloned[key] = value\n\t}\n\n\treturn cloned\n}", "title": "" }, { "docid": "d80ff88d30342b1fa8d5cad357cdd105", "score": "0.5188736", "text": "func toMap(keys []*datastore.Key) map[int64]*datastore.Key {\n\tret := make(map[int64]*datastore.Key, len(keys))\n\tfor _, k := range keys {\n\t\tret[k.ID] = k\n\t}\n\treturn ret\n}", "title": "" }, { "docid": "5c5d01f75ee69c59d5141d6e8b6f32d6", "score": "0.5153456", "text": "func CopyIndexInstMap2(inMap IndexInstMap) IndexInstMap {\n\n\toutMap := make(IndexInstMap)\n\tfor k, v := range inMap {\n\t\tvv := v\n\t\tvv.Pc = v.Pc.Clone()\n\t\tvv.Defn.Immutable = GetImmutableFlag(v.Defn)\n\t\toutMap[k] = vv\n\t}\n\treturn outMap\n}", "title": "" }, { "docid": "d457f814da0d92edbab2f84a78eaaa56", "score": "0.5151012", "text": "func CopyArgs(m map[string]interface{}) map[string]interface{} {\n\tother := make(map[string]interface{}, len(m))\n\tfor k, v := range m {\n\t\tother[k] = v\n\t}\n\treturn other\n}", "title": "" }, { "docid": "75394dba5f0559400a47cbba5b955126", "score": "0.51454294", "text": "func CopyStringMap(src map[string]string) map[string]string {\n\tvar dest = make(map[string]string, len(src))\n\tfor key, value := range src {\n\t\tdest[key] = value\n\t}\n\treturn dest\n}", "title": "" }, { "docid": "a72504cbba6c744c38122257a132c4b9", "score": "0.5127855", "text": "func (i *instance) copyDep() (dep map[idservice.ID]int) {\n\tdep = make(map[idservice.ID]int)\n\tfor id, d := range i.dep {\n\t\tdep[id] = d\n\t}\n\treturn dep\n}", "title": "" }, { "docid": "dfd6e3b77fdeb4bafae0a0a8b0d21584", "score": "0.5111454", "text": "func (tm TrickMap) Copy() TrickMap {\n\tin := reflect.Value(tm)\n\tout := reflect.MakeMap(in.Type())\n\tkeys := in.MapKeys()\n\tfor i := 0; i < len(keys); i++ {\n\t\tkey := keys[i]\n\t\tout.SetMapIndex(key, in.MapIndex(key))\n\t}\n\treturn TrickMap(out)\n}", "title": "" }, { "docid": "c2af6e8cb5f11d798144f4da2194a33a", "score": "0.5089216", "text": "func CloneStringMap(m map[string]string) map[string]string {\n\tm2 := make(map[string]string, len(m))\n\tfor k, v := range m {\n\t\tm2[k] = v\n\t}\n\treturn m2\n}", "title": "" }, { "docid": "33d9e49cd73ea25e31954753620aa812", "score": "0.5083365", "text": "func Int64Map(src map[string]int64) map[string]*int64 {\n\tdst := make(map[string]*int64, len(src))\n\tfor k, val := range src {\n\t\tv := val\n\t\tdst[k] = &v\n\t}\n\treturn dst\n}", "title": "" }, { "docid": "2044b70f145eebbcf74623af7cb48e76", "score": "0.5064877", "text": "func (this *Int2ByteHashMap) Clone() *Int2ByteHashMap {\n c := &Int2ByteHashMap{}\n\n c.f = this.f\n c.n = this.n\n c.mask = this.mask\n c.maxFill = this.maxFill\n c.size = this.size\n c.key = make([]uint32, c.n)\n copy(c.key, this.key)\n c.value = make([]byte, c.n)\n copy(c.value, this.value)\n c.used = make([]bool, c.n)\n copy(c.used, this.used)\n\n return c;\n}", "title": "" }, { "docid": "71b1d560a9084e5362edf6cbb641c4fa", "score": "0.50637496", "text": "func Copy(s []map[string][]string) []map[string][]string {\n\tn := make([]map[string][]string, len(s))\n\tcopy(n, s)\n\treturn n\n}", "title": "" }, { "docid": "2f9a58f2edb1b271ecc64fdd88c666fd", "score": "0.5048009", "text": "func (m StructMap) Clone() StructMap {\n\tcloned := make(StructMap)\n\n\tfor key, value := range m {\n\t\tcloned[key] = value\n\t}\n\n\treturn cloned\n}", "title": "" }, { "docid": "af5b9a3dbc572341f6363c0f0589d344", "score": "0.5044959", "text": "func (l *ListenerOptions) CloneMap() map[string]string {\n\tl.muOptions.RLock()\n\tdefer l.muOptions.RUnlock()\n\tr := make(map[string]string)\n\tfor x := range l.options {\n\t\tr[x] = l.options[x]\n\t}\n\treturn r\n}", "title": "" }, { "docid": "163d4df95d9869a9d0fc54da0742fefa", "score": "0.50444025", "text": "func CopyMap(m map[string]interface{}) map[string]interface{} {\n\treturn maphelpers.CopyMap(m)\n}", "title": "" }, { "docid": "c6622937131bda8b6f4317abb204c35d", "score": "0.50243765", "text": "func deepcopy(m map[string]interface{}) (map[string]interface{}, error) {\n\tvar buf bytes.Buffer\n\tenc := gob.NewEncoder(&buf)\n\tdec := gob.NewDecoder(&buf)\n\terr := enc.Encode(m)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar copy map[string]interface{}\n\terr = dec.Decode(&copy)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn copy, nil\n}", "title": "" }, { "docid": "18edaf8a6c3bd09e6bb78ccd5af723b2", "score": "0.50083643", "text": "func (pm *PeerMap) DeepCopy() PeerMap {\n\tpm.mut.RLock()\n\tnewCopy := PeerMap{mut: new(sync.RWMutex), internal: pm.internal}\n\tpm.mut.RUnlock()\n\treturn newCopy\n}", "title": "" }, { "docid": "059105b2a222a9a23596b753bafcabcc", "score": "0.49846733", "text": "func DeepCopy(m map[string]interface{}) (map[string]interface{}, error) {\n\tvar buf bytes.Buffer\n\tenc := gob.NewEncoder(&buf)\n\tdec := gob.NewDecoder(&buf)\n\terr := enc.Encode(m)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar copy map[string]interface{}\n\terr = dec.Decode(&copy)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn copy, nil\n}", "title": "" }, { "docid": "f7e32af145dc3e6bee7ec1c0b35b6412", "score": "0.49750358", "text": "func (s BotAppClassArray) FillModifiedMap(to map[int64]*BotApp) {\n\tfor _, elem := range s {\n\t\tvalue, ok := elem.AsModified()\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\t\tto[value.GetID()] = value\n\t}\n}", "title": "" }, { "docid": "1327ad538d8e2f71dab51198b35c3e3b", "score": "0.4966631", "text": "func (c *TruthMap) Copy(m map[string]bool) {\n\tc.rw.Lock()\n\tfor v, k := range m {\n\t\tif k {\n\t\t\tc.c.Set(v)\n\t\t}\n\t}\n\tc.rw.Unlock()\n}", "title": "" }, { "docid": "291ed0495ef7949255da9b3d3d479ef1", "score": "0.49513295", "text": "func CloneStringMap(mapToClone map[string]string) map[string]string {\n\tout := map[string]string{}\n\tfor key, value := range mapToClone {\n\t\tout[key] = value\n\t}\n\treturn out\n}", "title": "" }, { "docid": "6bc7b4471b6c51a36e9f83c1f9e3234c", "score": "0.49421135", "text": "func (s *Map) Clone() Map {\n\tvar result = NewMap()\n\tfor key, value := range *s {\n\t\tif aMap, casted := value.(Map); casted {\n\t\t\tresult[key] = aMap.Clone()\n\t\t} else {\n\t\t\tresult[key] = value\n\t\t}\n\t}\n\treturn result\n}", "title": "" }, { "docid": "54385ed1a864a234998cced082bef7c2", "score": "0.4910951", "text": "func sortedKeysToID(m map[ToID]uint64) []ToID {\n\t// Copy map keys to slice\n\tkeys := make([]ToID, len(m))\n\ti := 0\n\tfor k := range m {\n\t\tkeys[i] = k\n\t\ti++\n\t}\n\t// Sort the slice first according to ID if equal then sort by recipient (\"To\" field)\n\tsort.Slice(keys, func(i, j int) bool {\n\t\tif keys[i].ID != keys[j].ID {\n\t\t\treturn keys[i].To < keys[j].To\n\t\t}\n\t\treturn keys[i].ID < keys[j].ID\n\t})\n\treturn keys\n}", "title": "" }, { "docid": "7edfdffd95d34023a18c54a0d4ab40f3", "score": "0.49076584", "text": "func CopyMapValues(m any, typeHint any) any {\n\tmapVal := reflect.ValueOf(m)\n\tvals := reflect.MakeSlice(reflect.TypeOf(typeHint), 0, mapVal.Len())\n\tfor _, k := range mapVal.MapKeys() {\n\t\tvals = reflect.Append(vals, mapVal.MapIndex(k))\n\t}\n\treturn vals.Interface()\n}", "title": "" }, { "docid": "cfe9f2e5a744527309c70c0a34751353", "score": "0.486868", "text": "func (onMap *OneToNStringMap) getMappedValuesNoLock(key string) mapset.Set {\n\tif onMap.oneToNStringMap[key] == nil {\n\t\tonMap.oneToNStringMap[key] = mapset.NewSet()\n\t}\n\treturn onMap.oneToNStringMap[key].Clone()\n}", "title": "" }, { "docid": "4ac0846a205b8fab59ce0ed4d20091d1", "score": "0.48647127", "text": "func (cache *multiCache) copyPairs() map[string]Pair {\n\tpairs, _ := cache.load().(map[string]Pair)\n\n\t// make the capacity 1 larger, since this method is almost always\n\t// going to be invoked prior to doing a copy-on-write update.\n\tnewPairs := make(map[string]Pair, len(pairs)+1)\n\n\tfor keyID, pair := range pairs {\n\t\tnewPairs[keyID] = pair\n\t}\n\n\treturn newPairs\n}", "title": "" }, { "docid": "2293c867d183bfa6adb473f6bc76373c", "score": "0.48637506", "text": "func (r *Record) Copy() map[string]interface{} {\n\tr.mutex.Lock()\n\tdefer r.mutex.Unlock()\n\n\tdupe := map[string]interface{}{}\n\tfor k, v := range r.content {\n\t\tdupe[k] = v\n\t}\n\treturn dupe\n}", "title": "" }, { "docid": "b45e34cbcb3c245791c1047b9c48dc94", "score": "0.48337823", "text": "func CopyInterfaceKeyMap(src map[interface{}]interface{}) map[interface{}]interface{} {\n\tvar dest = make(map[interface{}]interface{}, len(src))\n\tfor key, value := range src {\n\t\tdest[key] = value\n\t}\n\treturn dest\n}", "title": "" }, { "docid": "b8f0b13b0ca498022875523e005689b5", "score": "0.48236755", "text": "func (c *Commit) GetMapIDs(filter *store.MapFilter) ([]string, error) {\n\treturn c.adapter.GetMapIDs(filter)\n}", "title": "" }, { "docid": "f6488179091188ddbd0866642e3384ae", "score": "0.47974637", "text": "func (_ExchangeData *ExchangeDataCaller) RollbackOrderMap(opts *bind.CallOpts, arg0 uint64) (struct {\n\tOrderId uint64\n\tTo common.Address\n\tSellAmount *big.Int\n\tBuyAmount *big.Int\n\tFee *big.Int\n}, error) {\n\tret := new(struct {\n\t\tOrderId uint64\n\t\tTo common.Address\n\t\tSellAmount *big.Int\n\t\tBuyAmount *big.Int\n\t\tFee *big.Int\n\t})\n\tout := ret\n\terr := _ExchangeData.contract.Call(opts, out, \"rollbackOrderMap\", arg0)\n\treturn *ret, err\n}", "title": "" }, { "docid": "d90f9b2f74c381f3276bc7ba0621bb52", "score": "0.4796306", "text": "func (al *accessList) Copy() *accessList {\n\tcp := newAccessList()\n\tfor k, v := range al.addresses {\n\t\tcp.addresses[k] = v\n\t}\n\tcp.slots = make([]map[common.Hash]struct{}, len(al.slots))\n\tfor i, slotMap := range al.slots {\n\t\tnewSlotmap := make(map[common.Hash]struct{}, len(slotMap))\n\t\tfor k := range slotMap {\n\t\t\tnewSlotmap[k] = struct{}{}\n\t\t}\n\t\tcp.slots[i] = newSlotmap\n\t}\n\treturn cp\n}", "title": "" }, { "docid": "9ffb4f56f74ba07e6e8ad6205c4dccf2", "score": "0.47888136", "text": "func (b BigMapDiff) ToCopy() BigMapDiffCopy {\n\treturn BigMapDiffCopy{\n\t\tAction: b.Action,\n\t\tSourceBigMap: b.SourceBigMap,\n\t\tDestinationBigMap: b.DestinationBigMap,\n\t}\n}", "title": "" }, { "docid": "2b0143999fd5b090f6416b3b2d394efa", "score": "0.47859576", "text": "func (p *OrderedMap) RawMap() map[interface{}]interface{} {\n\treturn p.m\n}", "title": "" }, { "docid": "0126060c7bfa91a72f1d3e62f568698b", "score": "0.47468364", "text": "func (m Map) CopyAll() Map {\r\n\treturn m.Copy(ZVI, m.Bounds())\r\n}", "title": "" }, { "docid": "5f840509b4e9ff9f3a4972a157a8272a", "score": "0.47248253", "text": "func (c *CherrypickQueue) copyQueue(queue map[int]*github.MungeObject) map[int]*github.MungeObject {\n\tc.Lock()\n\tdefer c.Unlock()\n\n\tout := map[int]*github.MungeObject{}\n\tfor i, v := range queue {\n\t\tout[i] = v\n\t}\n\treturn out\n}", "title": "" }, { "docid": "fbedc517527be50b36d4986247aba619", "score": "0.4718917", "text": "func (g *Graph) copy() *Graph {\n\t// Copy nodes\n\tnodes := make([]Keyer, 0, len(g.NodeMap))\n\tfor _, node := range g.NodeMap {\n\t\tnodes = append(nodes, node.Value)\n\t}\n\tother := New(nodes)\n\n\t// Copy edges\n\tfor fromId, node := range g.NodeMap {\n\t\tfor toId := range node.EdgesOut {\n\t\t\tother.addEdge(other.NodeMap[fromId], other.NodeMap[toId])\n\t\t}\n\t}\n\n\treturn other\n}", "title": "" }, { "docid": "b34f10de5f6b0236a051acb50fbf1d15", "score": "0.47175375", "text": "func (self *CDictionaryValueT) Copy(\n\texclude_empty_children int,\n) (ret *CDictionaryValueT) {\n\n\tcRet := C.cefingo_dictionary_value_copy((*C.cef_dictionary_value_t)(self.pc_dictionary_value), (C.int)(exclude_empty_children))\n\n\tret = newCDictionaryValueT(cRet, byApp) // return GoObj\n\treturn ret\n}", "title": "" }, { "docid": "90cd06cc4c89f7ffb1aec9f345c7d408", "score": "0.47163945", "text": "func (m *StringInterfaceMap) CopyFrom(src map[string]interface{}) {\n\tm.mutex.Lock()\n\tfor k, v := range src {\n\t\tm.data[k] = v\n\t}\n\tm.mutex.Unlock()\n}", "title": "" }, { "docid": "c82ebc422e2d8d5fb3734baff237e9fd", "score": "0.4698255", "text": "func (os K8sObjects) ToMap() map[string]*K8sObject {\n\tret := make(map[string]*K8sObject)\n\tfor _, oo := range os {\n\t\tif oo.Valid() {\n\t\t\tret[oo.Hash()] = oo\n\t\t}\n\t}\n\treturn ret\n}", "title": "" }, { "docid": "001a03d37b82002f8ca27bac1f3496a2", "score": "0.46951488", "text": "func sortMapIntoSlice(m map[int]int) []int {\n\t// order map\n\t// To store the keys in slice in sorted order\n\tvar keys []int\n\tfor k := range m {\n\t\tkeys = append(keys, k)\n\t}\n\tsort.Ints(keys)\n\n\treturn keys\n}", "title": "" }, { "docid": "05dfd0d502cf5d4d045603cad17579b2", "score": "0.46831664", "text": "func (d Dict) Copy(keys ...string) Dict {\n\tnv := make(DictValues)\n\tfor _, key := range keys {\n\t\tif value, ok := d.values[key]; ok {\n\t\t\tnv[key] = value\n\t\t}\n\t}\n\tnd, _ := NewDict(nv)\n\treturn nd\n}", "title": "" }, { "docid": "2c629a97d61a4a415fb380170acb9e18", "score": "0.46815577", "text": "func (r *PendingStorage) GetRequests() map[core.RecordID]map[core.RecordID]struct{} {\n\tr.lock.RLock()\n\tdefer r.lock.RUnlock()\n\n\trequestsClone := make(map[core.RecordID]map[core.RecordID]struct{})\n\tfor objID, objRequests := range r.requests {\n\t\tobjRequestsClone := make(map[core.RecordID]struct{}, len(objRequests))\n\t\tfor reqID, v := range objRequests {\n\t\t\tobjRequestsClone[reqID] = v\n\t\t}\n\t\trequestsClone[objID] = objRequestsClone\n\t}\n\n\treturn requestsClone\n}", "title": "" }, { "docid": "e4a3877e35a6ef7ae436da8748da933e", "score": "0.46800858", "text": "func duckCopy(d map[string][]v1alpha1.ResourceMeta) map[string][]v1alpha1.ResourceMeta {\n\tducks := make(map[string][]v1alpha1.ResourceMeta, len(d))\n\tfor k, v := range d {\n\t\tvc := make([]v1alpha1.ResourceMeta, len(v))\n\t\tcopy(vc, v)\n\t\tducks[k] = vc\n\t}\n\treturn ducks\n}", "title": "" }, { "docid": "d2f3ed664e0b48661270b86ddc035d81", "score": "0.46702957", "text": "func IntMap(src map[string]int) map[string]*int {\n\tdst := make(map[string]*int, len(src))\n\tfor k, val := range src {\n\t\tv := val\n\t\tdst[k] = &v\n\t}\n\treturn dst\n}", "title": "" }, { "docid": "a40adb3166a1d27b079ac35d88c22e1b", "score": "0.46673882", "text": "func (backupClient *ServerBackupClient) ToMap() map[string]interface{} {\n\tdata := make(map[string]interface{})\n\tbackupClient.UpdateMap(data)\n\n\treturn data\n}", "title": "" }, { "docid": "cf5ba9dd3acc5b0aa968e9593ed37d16", "score": "0.46552595", "text": "func ChangeMapID(l *cs.Link) *cs.Link {\n\tclone := Clone(l)\n\tclone.Meta[\"mapId\"] = testutil.RandomString(24)\n\treturn clone\n}", "title": "" }, { "docid": "cbf4b21b9bc170873d3eb339d3ec4902", "score": "0.46528488", "text": "func (s BotAppClassArray) ModifiedToMap() map[int64]*BotApp {\n\tr := make(map[int64]*BotApp, len(s))\n\ts.FillModifiedMap(r)\n\treturn r\n}", "title": "" }, { "docid": "4fe430571347da475c6ecc12b1f0ca31", "score": "0.4643561", "text": "func (_ExchangeData *ExchangeDataCallerSession) RollbackOrderMap(arg0 uint64) (struct {\n\tOrderId uint64\n\tTo common.Address\n\tSellAmount *big.Int\n\tBuyAmount *big.Int\n\tFee *big.Int\n}, error) {\n\treturn _ExchangeData.Contract.RollbackOrderMap(&_ExchangeData.CallOpts, arg0)\n}", "title": "" }, { "docid": "7bf02fa96af88c56b610e32e8981d31c", "score": "0.46376455", "text": "func CopyStringKeyMap(src map[string]interface{}) map[string]interface{} {\n\tvar dest = make(map[string]interface{}, len(src))\n\tfor key, value := range src {\n\t\tdest[key] = value\n\t}\n\treturn dest\n}", "title": "" }, { "docid": "fa5613061b01946fdfc1051805eddf92", "score": "0.462973", "text": "func reversedMap(original_map map[string]string) map[string]string {\n reversed_map := make(map[string]string)\n for key, value := range original_map {\n reversed_map[value] = key\n }\n return reversed_map\n}", "title": "" }, { "docid": "9d6764c1211abb1ee5a3c33d72fefffd", "score": "0.4615801", "text": "func MapCopy(in map[string]interface{}, pairs ...interface{}) error {\n\tmr := &mapCopier{\n\t\tInput: in,\n\t\tAllowMissingKey: true,\n\t}\n\treturn mr.Copy(pairs...)\n}", "title": "" }, { "docid": "7f00eac687b0741c99ffacf768ef81a0", "score": "0.46090364", "text": "func main() {\n\n\ta := []int{10,20,30}\n\tb := make([]int,10)\n\tcount :=copy(b, a)\n\tprintln(\"the number of elements copied \" ,count) //3\n\tprintln(\"the first element of new slice \" ,b[0])\n\n\tvar c []int //only declared\n\tcountCopy :=copy(c, a)\n\tprintln(\"the number of elements copied \" ,countCopy) //0\n\t//so we cannot copy when it is not initialized\n\n\t//change the data of the b[0 ] to 100\n\tb[0]=100\n\tprintln(\"the first element of a slice after change to b \" ,a[0]) // 10\n\tprintln(\"the first element of b slice after change to b \" ,b[0]) //100\n\t//so copy also create new one and not the same reference copy\n\n\n\t// here is just assignment\n\tmap1 := map[string]bool{\"A\": true, \"B\": true}\n\tmap2 := make(map[string]bool)\n\n\tmap2 = map1\n\n\tprintln(len(map2))\n\n\tmap2[\"B\"]= false\n\tprintln(\"the first element of a map1 after change to map2 \" ,map1[\"B\"]) // false\n\tprintln(\"the first element of a map2 after change to map2 \" ,map2[\"B\"]) // false\n\n\t// here it is just an assignment so reference is copied\n\n\n\n\n\n\n\n}", "title": "" }, { "docid": "a39a1ebf7e21916b95fbeaee5044d7a0", "score": "0.46067068", "text": "func New() *OrderedMap {\n\tom := OrderedMap{\n\t\tMap: make(map[string]*Link),\n\t}\n\treturn &om\n}", "title": "" }, { "docid": "aff5095d77b189faefccc277d1ce3d81", "score": "0.46047714", "text": "func MergeMapInPlaceWithoutRemovalKeys(required map[string]string, existing map[string]string) {\n\tfor existingKey, existingValue := range existing {\n\t\t// Don't copy removed keys.\n\t\t_, isRemoved := required[toRemovalKey(existingKey)]\n\t\tif isRemoved {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Copy only keys not present in the required object.\n\t\t_, found := required[existingKey]\n\t\tif !found {\n\t\t\trequired[existingKey] = existingValue\n\t\t}\n\t}\n\n\tcleanRemovalKeys(required)\n}", "title": "" }, { "docid": "e8c656da77e61b6d5c28efcd63630b9f", "score": "0.4604765", "text": "func CloneSet(in map[string]struct{}) map[string]struct{} {\n\tout := make(map[string]struct{}, len(in))\n\tfor k, v := range in {\n\t\tout[k] = v\n\t}\n\treturn out\n}", "title": "" }, { "docid": "f4934e3676b543ac6e2d7f9b8f2e8131", "score": "0.46032828", "text": "func (ps PermissionSet) Copy() PermissionSet {\n\tps2 := PermissionSet{}\n\tfor k, v := range ps {\n\t\tps2[k] = v\n\t}\n\treturn ps2\n}", "title": "" }, { "docid": "3e264f30ac935332cef59a1318652eca", "score": "0.46013886", "text": "func MapDelete(m *sync.Map, match DeleteMatch) []interface{} {\n\tresult := make([]interface{}, 0)\n\t// m.Range中是先复制了仅读,因此可以直接在此处删除\n\tm.Range(func(k, _ interface{}) bool {\n\t\tkey, ok := k.(string)\n\t\tif !ok {\n\t\t\treturn true\n\t\t}\n\t\t// 如果不匹配,则不需要删除\n\t\tif !match(key) {\n\t\t\treturn true\n\t\t}\n\n\t\tvalue, loaded := m.LoadAndDelete(key)\n\t\tif loaded {\n\t\t\tresult = append(result, value)\n\t\t}\n\t\treturn true\n\t})\n\n\treturn result\n}", "title": "" }, { "docid": "b991c09117d4341615ae5e2db06ae96e", "score": "0.46011284", "text": "func getPartMap() (map[string]int, error) {\n\tpartmap := make(map[string]int)\n\terr := database.Init()\n\tif err != nil {\n\t\treturn partmap, err\n\t}\n\n\tstmt, err := database.DB.Prepare(`select partId, oldPartNumber from Part`)\n\tif err != nil {\n\t\treturn partmap, err\n\t}\n\tdefer stmt.Close()\n\trows, err := stmt.Query()\n\tif err != nil {\n\t\treturn partmap, err\n\t}\n\tdefer rows.Close()\n\n\tfor rows.Next() {\n\t\tvar num *string\n\t\tvar id *int\n\t\terr = rows.Scan(&id, &num)\n\t\tif err != nil {\n\t\t\treturn partmap, err\n\t\t}\n\t\tif id != nil && num != nil {\n\t\t\tpartmap[*num] = *id\n\t\t}\n\t}\n\treturn partmap, nil\n}", "title": "" }, { "docid": "b4405016462347b3326c947dd314886e", "score": "0.46009302", "text": "func newPendingMap() *pendingMap {\n\treturn &pendingMap{\n\t\tdata: map[string][]byte{},\n\t\tpending: map[string]chan struct{}{},\n\t}\n}", "title": "" }, { "docid": "603e594a15d812da0a4b63e19412f8a2", "score": "0.4594061", "text": "func (r *AMD64Registers) Copy() (proc.Registers, error) {\n\tvar rr AMD64Registers\n\trr = *r\n\trr.Context = NewAMD64CONTEXT()\n\t*(rr.Context) = *(r.Context)\n\trr.fltSave = &rr.Context.FltSave\n\treturn &rr, nil\n}", "title": "" }, { "docid": "32b6c94e94340f09a32b70063c565961", "score": "0.45847967", "text": "func CopySessionKeys(pb *ttnpb.SessionKeys) *ttnpb.SessionKeys {\n\treturn deepcopy.Copy(pb).(*ttnpb.SessionKeys)\n}", "title": "" }, { "docid": "60d7c180248d17a25dc9ea92aa660f2a", "score": "0.45839387", "text": "func (a *AllocRegistration) Copy() *AllocRegistration {\n\tc := &AllocRegistration{\n\t\tTasks: make(map[string]*ServiceRegistrations, len(a.Tasks)),\n\t}\n\n\tfor k, v := range a.Tasks {\n\t\tc.Tasks[k] = v.copy()\n\t}\n\n\treturn c\n}", "title": "" }, { "docid": "d660ad621c95d1a843b49f891cbe1c5e", "score": "0.45822537", "text": "func (c *clusterService) dumpClientIdMaps() {\n\tfor id, _ := range c.clientIdMaps {\n\t\tInfo(\"[%s] is contained in rpc client list\", id)\n\t}\n}", "title": "" }, { "docid": "02a15342d99634eb79a377f6216f9f56", "score": "0.45756778", "text": "func (o PasswordResetsList) Copy() elemental.Identifiables {\n\n\tcopy := append(PasswordResetsList{}, o...)\n\treturn &copy\n}", "title": "" }, { "docid": "80c2fa3e3684975e642f991666903cff", "score": "0.45747522", "text": "func NewOrderedMap() *OrderedMap {\n\treturn &OrderedMap{\n\t\tkeys: make([]interface{}, 0),\n\t\tm: make(map[interface{}]interface{}),\n\t}\n}", "title": "" }, { "docid": "7693502dc70813e537e031aaea29e158", "score": "0.4573637", "text": "func cloneDocIDValuesTo(src docIDValues, target *docIDValues) {\n\ttarget.DocID = src.DocID\n\tfor i := 0; i < len(src.Values); i++ {\n\t\tcloned := src.Values[i].Clone(field.ValueCloneOptions{DeepCloneBytes: true})\n\t\ttarget.Values[i] = cloned\n\t}\n}", "title": "" }, { "docid": "5393a94bca204483bb7210bbefa3d006", "score": "0.4568126", "text": "func (s *IntSet) Copy() *IntSet {\n\ttmp := make([]uint64, len(s.words))\n\tcopy(tmp, s.words)\n\treturn &IntSet{words: tmp}\n}", "title": "" }, { "docid": "3c4b415d1967d3676ce1a749ee460932", "score": "0.45619702", "text": "func (s *IntSet) Copy() *IntSet {\n\tvar n IntSet\n\tn.words = make([]uint64, len(s.words))\n\tcopy(n.words, s.words)\n\treturn &n\n}", "title": "" }, { "docid": "88bce0c4114b83c57dd6ad1f6f62d38b", "score": "0.45592523", "text": "func (_ExchangeData *ExchangeDataSession) RollbackOrderMap(arg0 uint64) (struct {\n\tOrderId uint64\n\tTo common.Address\n\tSellAmount *big.Int\n\tBuyAmount *big.Int\n\tFee *big.Int\n}, error) {\n\treturn _ExchangeData.Contract.RollbackOrderMap(&_ExchangeData.CallOpts, arg0)\n}", "title": "" } ]
f7f7c6ac21ace147a476cc47ebf53d44
DestroyService cleans up services after execution.
[ { "docid": "ed89db1d84890a5afecb079ee51d5a39", "score": "0.6368795", "text": "func (c *client) DestroyService(ctx context.Context, ctn *pipeline.Container) error {\n\t// update engine logger with service metadata\n\t//\n\t// https://pkg.go.dev/github.com/sirupsen/logrus?tab=doc#Entry.WithField\n\tlogger := c.logger.WithField(\"service\", ctn.Name)\n\n\t// load the service from the client\n\tservice, err := c.loadService(ctn.ID)\n\tif err != nil {\n\t\t// create the service from the container\n\t\tservice = new(library.Service)\n\t\tservice.SetName(ctn.Name)\n\t\tservice.SetNumber(ctn.Number)\n\t\tservice.SetStatus(constants.StatusPending)\n\t\tservice.SetHost(ctn.Environment[\"VELA_HOST\"])\n\t\tservice.SetRuntime(ctn.Environment[\"VELA_RUNTIME\"])\n\t\tservice.SetDistribution(ctn.Environment[\"VELA_DISTRIBUTION\"])\n\t}\n\n\tdefer func() {\n\t\tlogger.Info(\"uploading service snapshot\")\n\t\t// send API call to update the step\n\t\t//\n\t\t// https://pkg.go.dev/github.com/go-vela/sdk-go/vela?tab=doc#SvcService.Update\n\t\t_, _, err := c.Vela.Svc.Update(c.repo.GetOrg(), c.repo.GetName(), c.build.GetNumber(), service)\n\t\tif err != nil {\n\t\t\tlogger.Errorf(\"unable to upload service snapshot: %v\", err)\n\t\t}\n\t}()\n\n\t// check if the service is in a pending state\n\tif service.GetStatus() == constants.StatusPending {\n\t\t// update the service fields\n\t\tservice.SetExitCode(137)\n\t\tservice.SetFinished(time.Now().UTC().Unix())\n\t\tservice.SetStatus(constants.StatusKilled)\n\n\t\t// check if the service was not started\n\t\tif service.GetStarted() == 0 {\n\t\t\t// set the started time to the finished time\n\t\t\tservice.SetStarted(service.GetFinished())\n\t\t}\n\t}\n\n\tlogger.Debug(\"inspecting container\")\n\t// inspect the runtime container\n\terr = c.Runtime.InspectContainer(ctx, ctn)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// check if the service finished\n\tif service.GetFinished() == 0 {\n\t\t// update the service fields\n\t\tservice.SetFinished(time.Now().UTC().Unix())\n\t\tservice.SetStatus(constants.StatusSuccess)\n\n\t\t// check the container for an unsuccessful exit code\n\t\tif ctn.ExitCode > 0 {\n\t\t\t// update the service fields\n\t\t\tservice.SetExitCode(ctn.ExitCode)\n\t\t\tservice.SetStatus(constants.StatusFailure)\n\t\t}\n\t}\n\n\tlogger.Debug(\"removing container\")\n\t// remove the runtime container\n\terr = c.Runtime.RemoveContainer(ctx, ctn)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" } ]
[ { "docid": "30ec16467aecc0008f948eae8ba0b3ca", "score": "0.7041224", "text": "func (s *BaseService) Destroy() {\n\ts.Log.Infof(\"Destroying '%s' service...\", s.name)\n\ts.Session.Close()\n}", "title": "" }, { "docid": "cd8fd742de7b0a8ae5580e43644ebcb9", "score": "0.63831735", "text": "func (c *Client) Destroy(timeout time.Duration, services ...string) error {\n\tif len(services) == 0 {\n\t\treturn nil\n\t}\n\n\tif err := c.StopMultiple(timeout, services...); err != nil {\n\t\treturn err\n\t}\n\n\t// all is stopped now, we need to forget and remove\n\tfor _, name := range services {\n\t\tif err := c.Forget(name); err != nil && !errors.Is(err, ErrUnknownService) {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := RemoveService(name); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "6c70c315be1f50309d74cda49aa3f4dd", "score": "0.6280956", "text": "func (c *Manager) Stop() {\n\tfor _, d := range c.services {\n\t\td.stop()\n\t}\n\tc.services = map[string]*liveService{}\n}", "title": "" }, { "docid": "ca287792b0067735382f09e69bb067df", "score": "0.60925496", "text": "func (k8s *K8s) CleanupServices(services ...string) {\n\tfor _, s := range services {\n\t\t_ = k8s.clientset.CoreV1().Services(k8s.namespace).Delete(context.TODO(), s, metaV1.DeleteOptions{})\n\t}\n}", "title": "" }, { "docid": "a1d0586f38f38f720e1b880e830728f9", "score": "0.6086932", "text": "func (s *DockerService) Destroy() error {\n\tjson, err := s.Inspect()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn docker.RemoveContainer(json.Name)\n}", "title": "" }, { "docid": "c129155f6cbe2f00655313816c72bb6a", "score": "0.6078134", "text": "func CloseService() {\n\tlikeSvc.Close()\n\tbnjSvc.Close()\n\tkfcSvc.Close()\n}", "title": "" }, { "docid": "e56cca513104626bb3ab58026a20dcd0", "score": "0.6070045", "text": "func (c *Client) DelService(inputs []string) error {\n\n\tsvcs, err := c.retrieveServices()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, input := range inputs {\n\t\tid, err := c.getResourceID(input, serviceGeneralizer(svcs))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t_, err = c.Delete(servicePath + id + \"/\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfmt.Println(id)\n\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "071698ddc01c4ebea8c061623d337d2b", "score": "0.6020835", "text": "func (svr *Server) ServiceCleanup() {\n}", "title": "" }, { "docid": "4e6deedebee7abb4ef08af818aebbb19", "score": "0.59817517", "text": "func RemoveService(name string) error {\n\tpath := filepath.Join(\"/etc/zinit\", fmt.Sprintf(\"%s.yaml\", name))\n\treturn os.RemoveAll(path)\n}", "title": "" }, { "docid": "85adad678572663c08dc1dd4a6d66da5", "score": "0.59459674", "text": "func (s *Service) StopService() {\n\tutils.Logger().Info().Msg(\"Stopping random generation service\")\n\ts.stopChan <- struct{}{}\n\t<-s.stoppedChan\n\tutils.Logger().Info().Msg(\"Random generation stopped\")\n}", "title": "" }, { "docid": "be23f336ce668e1558ecdebea6e5b526", "score": "0.59158164", "text": "func (u teamHandler) deleteService(req *restful.Request, resp *restful.Response) {\n\thandleErrors(req, resp, func() error {\n\t\tctx := req.Request.Context()\n\t\tname := req.PathParameter(\"name\")\n\t\tteam := req.PathParameter(\"team\")\n\n\t\tobject, err := u.Teams().Team(team).Services().Delete(ctx, name)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn resp.WriteHeaderAndEntity(http.StatusOK, object)\n\t})\n}", "title": "" }, { "docid": "6d8a833487281704c32d001aeec23b86", "score": "0.5906458", "text": "func (s *API) TokensCleanupService() {\n\tlogger.Printf(\"starting token cleanup service\")\n\tticker := time.NewTicker(tokenCleanupSvcInterval)\n\n\tfor {\n\t\t// Execute the tokens cleanup command and log the results\n\t\trows, err := TokensCleanup(s.db)\n\t\tif err != nil {\n\t\t\tlogger.Printf(\"cleaned up %d rows from tokens before error: %s\", rows, err)\n\t\t} else if rows > 0 {\n\t\t\tlogger.Printf(\"cleaned up %d expired tokens from the database\", rows)\n\t\t} else {\n\t\t\t// TODO: make this a lower log level when log leveling is a thing.\n\t\t\tlogger.Printf(\"no expired tokens to clean up\")\n\t\t}\n\n\t\t// Block until the next scheduled service run\n\t\t<-ticker.C\n\t}\n}", "title": "" }, { "docid": "fa68ea49ce9012db9b029d4c2cd4f4d3", "score": "0.58949524", "text": "func (svr *Service) Close() {\n\tlog.Infof(\"stop scheduler service\")\n\tsvr.blobDeleteMgr.Close()\n\tsvr.shardRepairMgr.Close()\n\tif !svr.leader {\n\t\treturn\n\t}\n\tsvr.CloseKafkaMonitors()\n\tsvr.balanceMgr.Close()\n\tsvr.diskRepairMgr.Close()\n\tsvr.diskDropMgr.Close()\n\tsvr.manualMigMgr.Close()\n\tsvr.inspectMgr.Close()\n}", "title": "" }, { "docid": "0d2df77498dfc70cf7811e5c6f782ab0", "score": "0.5830606", "text": "func (l *Log) DeleteService(name string) error {\n\tl.logLock.Lock()\n\tdefer l.logLock.Unlock()\n\tif _, ok := l.perService[name]; !ok {\n\t\treturn errors.New(\"no such service: \" + name)\n\t}\n\tdelete(l.perService, name)\n\tnewLen := 0\n\tfor _, x := range l.allRecords {\n\t\tif x.Service != name {\n\t\t\tl.allRecords[newLen] = x\n\t\t\tnewLen++\n\t\t}\n\t}\n\tl.allRecords = l.allRecords[:newLen]\n\tl.wakeListeners(name)\n\treturn nil\n}", "title": "" }, { "docid": "bf7022feaef206e2b558274dfda37ace", "score": "0.5814888", "text": "func ReqToDestroy(host string, svcs []april.Service, token string) error {\n\t// Create http body request\n\tsvcsBody := make([]requestbody.ServiceBodyJSON, len(svcs))\n\tfor i, svc := range svcs {\n\t\tsvcsBody[i].Name = svc.Name\n\t\tsvcsBody[i].Selector = svc.Selector\n\t}\n\tbody := requestbody.ShutdownBodyJSON{Services: svcsBody}\n\treqBody, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\turl := fmt.Sprintf(\"http://%v/shutdown\", host)\n\treq, err := http.NewRequest(\"POST\", url, bytes.NewBuffer(reqBody))\n\tif err != nil {\n\t\treturn err\n\t}\n\treq.AddCookie(&http.Cookie{Name: \"token\", Value: token})\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode == 500 {\n\t\tbody, err := ioutil.ReadAll(resp.Body)\n\t\tif err != nil {\n\t\t\treturn errors.New(\"Fail to destroy services or read response body\")\n\t\t}\n\t\tresMsg := requestbody.ResponseMessage{}\n\t\tjson.Unmarshal(body, &resMsg)\n\t\treturn errors.New(resMsg.Message)\n\t} else if resp.StatusCode == 401 {\n\t\treturn ErrUnauthorized\n\t} else if resp.StatusCode > 401 {\n\t\treturn errors.New(\"Fail to communicate with chaos server\")\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "d1eba871163d1ca4852dfc6cef82ad12", "score": "0.58138555", "text": "func (svc *V2Service) Destroy(id int32) error {\n\tif _, err := svc.Repository.Destroy(olhttp.OLHTTPRequest{\n\t\tURL: fmt.Sprintf(\"%s/%d\", svc.Endpoint, id),\n\t\tHeaders: map[string]string{\"Content-Type\": \"application/json\"},\n\t\tAuthMethod: \"bearer\",\n\t}); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "cb5b6b8dab2a143261ecda1da04c7f1b", "score": "0.5813129", "text": "func (c *Cleanup) CleanShadowServices() error {\n\tserviceList, err := c.client.GetKubernetesClient().CoreV1().Services(c.namespace).List(metav1.ListOptions{\n\t\tLabelSelector: \"app=maesh,type=shadow\",\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, s := range serviceList.Items {\n\t\tif err := c.client.GetKubernetesClient().CoreV1().Services(s.Namespace).Delete(s.Name, &metav1.DeleteOptions{}); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "aa2ff0eb89ec2b7054a5026a403613ea", "score": "0.57620263", "text": "func unregisterService(appInstanceId string, serviceId string) error {\n\tresp, err := srvMgmtClient.MecServiceMgmtApi.AppServicesServiceIdDELETE(context.TODO(), appInstanceId, serviceId)\n\tstatus := strconv.Itoa(resp.StatusCode)\n\tif err != nil {\n\t\tlog.Error(\"Failed to send request to delete service resource on mec platform \", err)\n\n\t\tappActivityLogs = append(appActivityLogs, \"Delete Demo3 service [\"+status+\"]\")\n\n\t\treturn err\n\t}\n\n\tappActivityLogs = append(appActivityLogs, \"Delete Demo3 service [\"+status+\"]\")\n\treturn nil\n}", "title": "" }, { "docid": "cccd4e24d20db1d8cf7a3305d53f1399", "score": "0.57514226", "text": "func (d *Destroyer) Shutdown(svcs []april.Service) error {\n\tinstances, err := d.ChaosSrv.ListInstances(Up)\n\tif err != nil {\n\t\treturn err\n\t}\n\titcs := d.getInstancesFromSvcs(instances, svcs)\n\tif len(svcs) > len(itcs) {\n\t\treturn ErrNotMatchingService\n\t}\n\tfor _, instance := range itcs {\n\t\tif err = d.ChaosSrv.Shutdown(instance); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "b1bd0b4a6d8790952441d696b0769e11", "score": "0.5726819", "text": "func Service(context *cli.Context) {\n\tuuid := serviceOpts(context)\n\terr := manage.UninstallService(&manage.UninstallServiceOptions{UUID: uuid})\n\tdie(err)\n}", "title": "" }, { "docid": "ba68059683a3ba7394de021c4ba030b7", "score": "0.5722381", "text": "func (s *Service) Close() {\n\tfor appID, svc := range s.sm {\n\t\ts.kong.DelService(appID)\n\t\tsvc.Cancel()\n\t\tlog.Info(\"Service %s canceled from discovery\", appID)\n\t}\n}", "title": "" }, { "docid": "582f9464799f89d6c5d820214fbdc424", "score": "0.57091045", "text": "func (s *ServiceClient) DeleteAll(ctx context.Context, namespace string) error {\n\tservices, err := s.kubeClient.Kubectl.CoreV1().Secrets(namespace).List(ctx, metav1.ListOptions{\n\t\tLabelSelector: fmt.Sprintf(\n\t\t\t\"%s,%s\",\n\t\t\tServiceNameLabelKey,\n\t\t\tCatalogServiceLabelKey,\n\t\t),\n\t})\n\n\tif err != nil {\n\t\tif apierrors.IsNotFound(err) {\n\t\t\treturn nil\n\t\t}\n\t\treturn errors.Wrap(err, \"listing the service instances\")\n\t}\n\n\tfor _, srv := range services.Items {\n\t\t// Inlined Delete() ... Avoids back and forth conversion between service and secret names\n\t\tservice := srv.GetLabels()[ServiceNameLabelKey]\n\n\t\terr = helm.RemoveService(requestctx.Logger(ctx),\n\t\t\ts.kubeClient,\n\t\t\tmodels.NewAppRef(service, srv.ObjectMeta.Namespace))\n\t\tif err != nil {\n\t\t\t// See [NF] for details\n\t\t\tif !strings.Contains(err.Error(), \"not found\") {\n\t\t\t\treturn errors.Wrap(err, \"error deleting service helm release\")\n\t\t\t}\n\t\t}\n\t\terr := s.kubeClient.DeleteSecret(ctx, srv.ObjectMeta.Namespace, srv.ObjectMeta.Name)\n\t\tif err != nil {\n\t\t\tif apierrors.IsNotFound(err) {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn errors.Wrap(err, \"error deleting service secret\")\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "d260f1d3c940b84211a4f58ffa4043d3", "score": "0.5704792", "text": "func (ms *Microservice) Cleanup() error {\n\treturn nil\n}", "title": "" }, { "docid": "cf61d01cf269df57427b84d8d8d65b9f", "score": "0.5675474", "text": "func Unregister(srv *Service) error {\n\n\tlog.Printf(\"%+v\\n\", srv)\n\n\tif err := db.Stor.Db().Unscoped().Where(\"token = ?\", srv.Token).Delete(Service{}).Error; err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "d3438e3c24736fedb0605e78402cc286", "score": "0.5671911", "text": "func (*GRPCServiceHandler) Kill(ctx context.Context, _ *api.Empty) (*api.Empty, error) {\n\tp, err := os.FindProcess(os.Getpid())\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"find localizer process\")\n\t}\n\n\tgo func(process *os.Process) {\n\t\t// Give the RPC time to respond. It doesn't need much time, because it is using the local network.\n\t\ttime.Sleep(time.Second * 1)\n\n\t\t_ = os.Remove(localizer.Socket) //nolint:errcheck // Why: We can't do anything about this error, it's best effort.\n\t\t_ = process.Kill() //nolint:errcheck // Why: We can't do anything about this error, it's best effort.\n\t}(p)\n\n\treturn &api.Empty{}, nil\n}", "title": "" }, { "docid": "1d8b51f5b43c9f04168d5cdb57efd740", "score": "0.5671003", "text": "func (m *Monocular) Destroy() {\n\tlog.Debug(\"Monocular plugin .. destroy\")\n\tif m.devSyncPID != 0 {\n\t\tlog.Info(\"... Stopping chart sync tool\")\n\t\tif p, err := os.FindProcess(m.devSyncPID); err == nil {\n\t\t\tp.Kill()\n\t\t} else {\n\t\t\tlog.Error(\"Could not find process for the chart sync tool\")\n\t\t}\n\t}\n}", "title": "" }, { "docid": "395d1802c143858091cfda68a7b62e1a", "score": "0.5667772", "text": "func DestroyDev(dev *model.Dev, c *kubernetes.Clientset) error {\n\tlog.Infof(\"deleting service '%s'...\", dev.Name)\n\tsClient := c.CoreV1().Services(dev.Namespace)\n\terr := sClient.Delete(dev.Name, &metav1.DeleteOptions{})\n\tif err != nil {\n\t\tif strings.Contains(err.Error(), \"not found\") {\n\t\t\tlog.Infof(\"service '%s' was already deleted.\", dev.Name)\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"error deleting kubernetes service: %s\", err)\n\t}\n\tlog.Infof(\"service '%s' deleted\", dev.Name)\n\treturn nil\n}", "title": "" }, { "docid": "738fe816db6d52cfd1f5fa72253a06d8", "score": "0.56612223", "text": "func (c *Client) DeleteAllService(ctx context.Context, project, location string, filter func(*Service) bool) error {\n\tlistObj, err := c.ListService(ctx, project, location)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = c.deleteAllService(ctx, filter, listObj.Items)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor listObj.HasNext() {\n\t\terr = listObj.Next(ctx, c)\n\t\tif err != nil {\n\t\t\treturn nil\n\t\t}\n\t\terr = c.deleteAllService(ctx, filter, listObj.Items)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "9f8ee38e51e82e295e8ebc90d4c01b76", "score": "0.564522", "text": "func (h *Handler) DeleteService(c *gin.Context) {\n\tnamespace := c.Param(\"namespace\")\n\tname := c.Param(\"name\")\n\n\tif err := h.kubeClient.CoreV1().Services(namespace).Delete(c, name, metav1.DeleteOptions{}); err != nil {\n\t\th.handleError(c, err)\n\t\treturn\n\t}\n\n\tc.JSON(200, gin.H{})\n}", "title": "" }, { "docid": "9ee90cbc6c1e9f757e8e2d3d56312d48", "score": "0.55883807", "text": "func deleteServiceFinalizer(instance *ibmcloudv1.Service) []string {\n\tvar result []string\n\tfor _, finalizer := range instance.ObjectMeta.Finalizers {\n\t\tif finalizer == serviceFinalizer {\n\t\t\tcontinue\n\t\t}\n\t\tresult = append(result, finalizer)\n\t}\n\treturn result\n}", "title": "" }, { "docid": "51a3af0a79a7314fc6ffbf3d6688d807", "score": "0.55856574", "text": "func Destroy(ctx context.Context) (e error) {\n\twg := sync.WaitGroup{}\n\n\tfor _, es := range workers {\n\t\tfor _, ws := range es {\n\t\t\tfor _, w := range ws {\n\t\t\t\twg.Add(1)\n\t\t\t\tgo func(w worker.Worker) {\n\t\t\t\t\tdefer wg.Done()\n\t\t\t\t\tw.RemoveDetach(ctx)\n\t\t\t\t}(w)\n\t\t\t}\n\t\t}\n\t}\n\n\twg.Wait()\n\n\treturn\n}", "title": "" }, { "docid": "79dc015da485b1139fa0f0358fb1fda7", "score": "0.5572968", "text": "func HandleDeleteService(adminMan *admin.Manager, syncMan *syncman.Manager) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\n\t\t// Get the JWT token from header\n\t\ttoken := utils.GetTokenFromHeader(r)\n\t\tdefer utils.CloseTheCloser(r.Body)\n\n\t\t// Check if the request is authorised\n\t\tif err := adminMan.IsTokenValid(token); err != nil {\n\t\t\t_ = utils.SendErrorResponse(w, http.StatusUnauthorized, err.Error())\n\t\t\treturn\n\t\t}\n\t\tctx, cancel := context.WithTimeout(r.Context(), 10*time.Second)\n\t\tdefer cancel()\n\n\t\tvars := mux.Vars(r)\n\t\tservice := vars[\"id\"]\n\t\tprojectID := vars[\"project\"]\n\n\t\tif err := syncMan.DeleteService(ctx, projectID, service); err != nil {\n\t\t\t_ = utils.SendErrorResponse(w, http.StatusInternalServerError, err.Error())\n\t\t\treturn\n\t\t}\n\n\t\t_ = utils.SendOkayResponse(w)\n\t}\n}", "title": "" }, { "docid": "9e6e41aee1358ff93ff3d7fc6ec9b29a", "score": "0.5568641", "text": "func (c *Client) ServiceDelete(id string) error {\n\treturn c.send(\"DELETE\", \"/api/v2/system/service/\"+id, 200, nil, nil)\n}", "title": "" }, { "docid": "2a9d532f35f2fae75ed911357bfcdec1", "score": "0.5557361", "text": "func (p *PaloAlto) DeleteService(name string, devicegroup ...string) error {\n\tvar xpath string\n\tvar reqError requestError\n\tr := rested.NewRequest()\n\n\tif p.DeviceType == \"panos\" {\n\t\txpath = fmt.Sprintf(\"/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/service/entry[@name='%s']\", name)\n\t}\n\n\tif p.DeviceType == \"panorama\" && len(devicegroup) > 0 {\n\t\txpath = fmt.Sprintf(\"/config/devices/entry[@name='localhost.localdomain']/device-group/entry[@name='%s']/service/entry[@name='%s']\", devicegroup[0], name)\n\t}\n\n\tif p.DeviceType == \"panorama\" && len(devicegroup) <= 0 {\n\t\treturn errors.New(\"you must specify a device-group when connected to a Panorama device\")\n\t}\n\n\tquery := map[string]string{\n\t\t\"type\": \"config\",\n\t\t\"action\": \"delete\",\n\t\t\"xpath\": xpath,\n\t\t\"key\": p.Key,\n\t}\n\n\tresp := r.Send(\"get\", p.URI, nil, nil, query)\n\tif resp.Error != nil {\n\t\treturn resp.Error\n\t}\n\n\tif err := xml.Unmarshal(resp.Body, &reqError); err != nil {\n\t\treturn err\n\t}\n\n\tif reqError.Status != \"success\" {\n\t\treturn fmt.Errorf(\"error code %s: %s\", reqError.Code, errorCodes[reqError.Code])\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "b607d4cb23d5839ae218cbf8e6810260", "score": "0.55567026", "text": "func (ac *AutoConfig) processDelService(ctx context.Context, svc listeners.Service) {\n\tac.store.removeServiceForEntity(svc.GetServiceID())\n\tchanges := ac.cfgMgr.processDelService(ctx, svc)\n\tac.store.removeTagsHashForService(svc.GetTaggerEntity())\n\tac.applyChanges(changes)\n}", "title": "" }, { "docid": "bf5a68d623920f09636ae5409d479317", "score": "0.5551993", "text": "func deleteService(name string) error {\n\tsvcClient := framework.K8sclientset.CoreV1().Services(v1.NamespaceDefault)\n\treturn svcClient.Delete(context.TODO(), name, metav1.DeleteOptions{})\n}", "title": "" }, { "docid": "ab0899dd6e2a5b719335cb69f9e5f29c", "score": "0.55492747", "text": "func (cli *CLI) RemoveService() {\n\tcmd := exec.Command(\"systemctl\", \"stop\", \"autobackup.service\")\n\tvar stderr bytes.Buffer\n\tcmd.Stderr = &stderr\n\t_, err := cmd.Output()\n\tif err != nil {\n\t\tif stderr.String() == \"\" {\n\t\t\tfmt.Println(err)\n\t\t} else {\n\t\t\tfmt.Println(stderr.String())\n\t\t}\n\t\treturn\n\t}\n\n\tcmd = exec.Command(\"systemctl\", \"disable\", \"autobackup.service\")\n\tcmd.Stderr = &stderr\n\t_, err = cmd.Output()\n\tif err != nil {\n\t\tif stderr.String() == \"\" {\n\t\t\tfmt.Println(err)\n\t\t} else {\n\t\t\tfmt.Println(stderr.String())\n\t\t}\n\t\treturn\n\t}\n\n\tcmd = exec.Command(\"rm\", \"/etc/systemd/system/autobackup.service\")\n\tcmd.Stderr = &stderr\n\t_, err = cmd.Output()\n\tif err != nil {\n\t\tif stderr.String() == \"\" {\n\t\t\tfmt.Println(err)\n\t\t} else {\n\t\t\tfmt.Println(stderr.String())\n\t\t}\n\t\treturn\n\t}\n\n\tfmt.Println(\"AutoBackup service has been removed\")\n}", "title": "" }, { "docid": "f24804d2e8574115a6f642829853bde4", "score": "0.55454236", "text": "func (es *etcdStorage) DeleteService(domain string, msgs []msg.Service) error {\n\t//just delete\n\tcxt, _ := context.WithTimeout(context.Background(), time.Second*10)\n\tetcdPath := msg.Path(domain, defaultPrefix)\n\tif _, err := es.client.Delete(cxt, etcdPath, etcdcv3.WithPrefix()); err != nil {\n\t\tlog.Printf(\"[ERROR] etcdStorage clean %s err, %s\", etcdPath, err.Error())\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "36969c9cfe6b906f14bfc3edfac97670", "score": "0.55415016", "text": "func (ds *Debug) Destroy() error {\n\tds.DeleteMetricObj()\n\terr := ds.StopServer()\n\treturn err\n}", "title": "" }, { "docid": "4f7a7c52e585dae5e093346d3ce2d776", "score": "0.5534321", "text": "func (s *Service) Delete() error {\n\treturn s.eachContainer(func(c *Container) error {\n\t\treturn c.Delete()\n\t})\n}", "title": "" }, { "docid": "3f7b1aa1abc2b4ca3487ca190a7aeea4", "score": "0.55220413", "text": "func (c *container) Stop() {\n\tfor _, e := range c.services {\n\t\tif e.hasStatus(StatusServing) {\n\t\t\te.svc.Stop()\n\t\t\te.setStatus(StatusStopped)\n\t\t\tc.log.Debugf(\"[%s]: stopped\", e.name)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "088d0308fad11c1a0c7d031b2d7b4b29", "score": "0.5507611", "text": "func (s *Swarm) Destroy() error {\n\treturn s.provider.Destroy()\n}", "title": "" }, { "docid": "4e7c272dda574c890b39cb96ea4943df", "score": "0.55033845", "text": "func (c ServiceController) DeleteService(key string) error {\n\terr := c.serviceRepository.ExistService(key)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = c.serviceRepository.DeleteService(key)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn c.cacheConfigRepository.DeleteConfig(key)\n}", "title": "" }, { "docid": "8c1574876b28ca323ff01d0077dd1f23", "score": "0.549752", "text": "func (c *Client) DeleteService(ivn *api.IdVerName) error {\n\treturn api.DeleteService(c, ivn)\n}", "title": "" }, { "docid": "81e4bfc2f19049f7313cc2b8d379661b", "score": "0.54930097", "text": "func (tc *topologies) Destroy(rw web.ResponseWriter, req *web.Request) {\n\ttb, err := tc.topologies.Unregister(tc.topologyName)\n\tisNotExist := core.IsNotExist(err)\n\tif err != nil && !isNotExist {\n\t\ttc.ErrLog(err).Error(\"Cannot unregister the topology\")\n\t\ttc.RenderError(jasco.NewInternalServerError(err))\n\t\treturn\n\t}\n\tstopped := true\n\tif tb != nil {\n\t\tif err := tb.Topology().Stop(); err != nil {\n\t\t\tstopped = false\n\t\t\ttc.ErrLog(err).Error(\"Cannot stop the topology\")\n\t\t}\n\t}\n\n\tif stopped {\n\t\t// TODO: return 204 when the topology didn't exist.\n\t\ttc.Render(map[string]interface{}{})\n\t} else {\n\t\ttc.Render(map[string]interface{}{\n\t\t\t\"warning\": map[string]interface{}{\n\t\t\t\t\"message\": \"the topology wasn't stopped correctly\",\n\t\t\t},\n\t\t})\n\t}\n}", "title": "" }, { "docid": "866fbdfc4a069a861006b0e13732bc5f", "score": "0.5483142", "text": "func (s *Service) Close() {}", "title": "" }, { "docid": "87fd3af6c2067e2f167e71962dae118c", "score": "0.54590297", "text": "func delAmsService(serviceId string) error {\n\tresp, err := amsClient.AmsiApi.AppMobilityServiceByIdDELETE(context.TODO(), serviceId)\n\tstatus := strconv.Itoa(resp.StatusCode)\n\tif err != nil {\n\t\tappActivityLogs = append(appActivityLogs, \"Delete AMS resource [\"+status+\"]\")\n\t\tlog.Error(\"Failed to cleared ams service \", resp.Status)\n\t\treturn err\n\t}\n\tappActivityLogs = append(appActivityLogs, \"Delete AMS resource [\"+status+\"]\")\n\treturn nil\n}", "title": "" }, { "docid": "2263f91bbbaa8527dfa40dbcdfd7fdee", "score": "0.544195", "text": "func (k *kubeletService) stopAndRemove() error {\n\tif k.obj == nil {\n\t\treturn nil\n\t}\n\tif err := k.stop(); err != nil {\n\t\treturn fmt.Errorf(\"failed to stop kubelet service: %v\", err)\n\t}\n\treturn k.obj.Delete()\n}", "title": "" }, { "docid": "62ff7656ac1a07cd9ec9fcd920e76bad", "score": "0.5431133", "text": "func (googlecontainer *Googlecontainer) Deleteservice(request interface{}) (resp interface{}, err error) {\n\n\toptions := request.(map[string]string)\n\n\turl := \"https://container.googleapis.com/v1/projects/\" + options[\"Project\"] + \"/zones/\" + options[\"Zone\"] + \"/clusters/\" + options[\"clusterId\"] + \"/nodePools/\" + options[\"nodePoolId\"]\n\n\tclient := googleauth.SignJWT()\n\n\tDeleteservicerequest, err := http.NewRequest(\"DELETE\", url, nil)\n\tDeleteservicerequest.Header.Set(\"Content-Type\", \"application/json\")\n\n\tDeleteserviceresp, err := client.Do(Deleteservicerequest)\n\n\tdefer Deleteserviceresp.Body.Close()\n\n\tbody, err := ioutil.ReadAll(Deleteserviceresp.Body)\n\n\tDeleteserviceresponse := make(map[string]interface{})\n\tDeleteserviceresponse[\"status\"] = Deleteserviceresp.StatusCode\n\tDeleteserviceresponse[\"body\"] = string(body)\n\tresp = Deleteserviceresponse\n\treturn resp, err\n}", "title": "" }, { "docid": "aa661941ee04f456c9d6d2b6c0f08b9b", "score": "0.54269356", "text": "func Delete(c *drycc.Client, appID string, procfileType string) error {\n\tu := fmt.Sprintf(\"/v2/apps/%s/services/\", appID)\n\n\treq := api.ServiceDeleteRequest{ProcfileType: procfileType}\n\n\tbody, err := json.Marshal(req)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = c.Request(\"DELETE\", u, body)\n\n\treturn err\n}", "title": "" }, { "docid": "cdb7ec66e6ad660bf5be689494aa7c03", "score": "0.5419597", "text": "func DeleteServiceType(serviceType ServiceType, store stores.Store) error {\n\n\tvar err error\n\n\t// first delete all the bindings associated with the service type\n\tif err = store.DeleteBindingByServiceUUID(serviceType.UUID); err != nil {\n\t\treturn err\n\t}\n\n\t// delete all the auth methods associated with the service type\n\tif err = store.DeleteAuthMethodByServiceUUID(serviceType.UUID); err != nil {\n\t\treturn err\n\t}\n\n\t// finally delete the service type\n\tif err = store.DeleteServiceTypeByUUID(serviceType.UUID); err != nil {\n\t\treturn err\n\t}\n\n\treturn err\n}", "title": "" }, { "docid": "e570f8821e005ad81da2855807230019", "score": "0.5414282", "text": "func (s *Service) StopService() {\n\ts.grpcServer.Stop()\n}", "title": "" }, { "docid": "30c79695db1e2796880290df76edd97d", "score": "0.54059565", "text": "func (m *intelRdtManager) Destroy() error {\n\t// Don't remove resctrl group if closid has been explicitly specified. The\n\t// group is likely externally managed, i.e. by some other entity than us.\n\t// There are probably other containers/tasks sharing the same group.\n\tif m.config.IntelRdt == nil || m.config.IntelRdt.ClosID == \"\" {\n\t\tm.mu.Lock()\n\t\tdefer m.mu.Unlock()\n\t\tif err := os.RemoveAll(m.GetPath()); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tm.path = \"\"\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "cc9981a7d92b38af4b377a8f63f6158e", "score": "0.5402251", "text": "func DeleteService(db *sql.DB, id int) (bool, error) {\n\treturn DATABASE.DeleteService(db, id)\n}", "title": "" }, { "docid": "6f5e9c05b90dea8d741786bb0c7e13d0", "score": "0.53990215", "text": "func (svc *Service) Stop() {\n\tsvc.listener.Close()\n}", "title": "" }, { "docid": "65764a82262268c455027c2063b47722", "score": "0.539352", "text": "func (e *E2EServices) Stop() error {\n\tdefer func() {\n\t\t// Cleanup the manifest path for kubelet.\n\t\tmanifestPath := framework.TestContext.ManifestPath\n\t\tif manifestPath != \"\" {\n\t\t\terr := os.RemoveAll(manifestPath)\n\t\t\tif err != nil {\n\t\t\t\tglog.Errorf(\"Failed to delete static pod manifest directory %s.\\n%v\", manifestPath, err)\n\t\t\t}\n\t\t}\n\t}()\n\tif e.services == nil {\n\t\tglog.Errorf(\"can't stop e2e services, because `services` is nil\")\n\t}\n\treturn e.services.kill()\n}", "title": "" }, { "docid": "1c13405050e3933c843921709f24bbf5", "score": "0.5373983", "text": "func (s *GenericAPIServer) Destroy() {\n\tfor _, destroyFn := range s.destroyFns {\n\t\tdestroyFn()\n\t}\n\tif s.delegationTarget != nil {\n\t\ts.delegationTarget.Destroy()\n\t}\n}", "title": "" }, { "docid": "739ea0d8bf04260fb7e3d359cfd8fa39", "score": "0.5372018", "text": "func (k8s *K8s) DeleteService(service *v1.Service, namespace string) error {\n\treturn k8s.clientset.CoreV1().Services(namespace).Delete(context.TODO(), service.GetName(), metaV1.DeleteOptions{})\n}", "title": "" }, { "docid": "df58625c48d87577d4d4bec4a88ea053", "score": "0.5350441", "text": "func DeleteService(req *models.Delete) (int, error) { // just require req.Name(service name)\n\tlog := models.Log{}\n\tserviceclient := models.GetClientset().CoreV1().Services(apiv1.NamespaceDefault)\n\tserviceimp, err := serviceclient.Get(req.Name, metav1.GetOptions{})\n\tif err != nil {\n\t\tlog.Time = models.Gettime()\n\t\tlog.Etype = \"error\"\n\t\tlog.Event = \"Failed to get latest version of service \" + err.Error()\n\t\tgo models.Insertlog(&log)\n\t\treturn http.StatusInternalServerError, err\n\t}\n\t// delete service\n\tif serviceimp.Name != \" \" {\n\t\tif err := models.GetClientset().CoreV1().Services(req.Namespace).Delete(req.Name, &metav1.DeleteOptions{}); err != nil {\n\t\t\tlog.Time = models.Gettime()\n\t\t\tlog.Etype = \"error\"\n\t\t\tlog.Event = \"Failed to delete service \" + req.Name + \" \" + err.Error()\n\t\t\tgo models.Insertlog(&log)\n\t\t\treturn http.StatusInternalServerError, err\n\t\t}\n\t}\n\tlog.Time = models.Gettime()\n\tlog.Etype = \"info\"\n\tlog.Event = \"Delete service \" + req.Name + \" success\"\n\tgo models.Insertlog(&log)\n\treturn http.StatusOK, nil\n}", "title": "" }, { "docid": "e810cb85b33c2add18535778ce5c7c58", "score": "0.5349356", "text": "func (mv *MongoDBProjectMVRepo) DeleteService(project string, stage string, service string) error {\n\texistingProject, err := mv.GetProject(project)\n\tif err != nil {\n\t\tlog.Errorf(\"Could not delete service %s from stage %s in project %s. Could not load project: %s\", service, stage, project, err.Error())\n\t\treturn err\n\t}\n\n\tfor _, stg := range existingProject.Stages {\n\t\tif stg.StageName == stage {\n\t\t\tserviceIndex := -1\n\t\t\tfor idx, svc := range stg.Services {\n\t\t\t\tif svc.ServiceName == service {\n\t\t\t\t\tserviceIndex = idx\n\t\t\t\t}\n\t\t\t}\n\t\t\tif serviceIndex < 0 {\n\t\t\t\tlog.Infof(\"Could not delete service %s from stage %s in project %s. Service not found in database\", service, stage, project)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tcopy(stg.Services[serviceIndex:], stg.Services[serviceIndex+1:])\n\t\t\tstg.Services[len(stg.Services)-1] = nil\n\t\t\tstg.Services = stg.Services[:len(stg.Services)-1]\n\t\t\tbreak\n\t\t}\n\t}\n\terr = mv.projectRepo.UpdateProject(existingProject)\n\tif err != nil {\n\t\tlog.Errorf(\"Could not delete service %s from stage %s in project %s: %s\", service, stage, project, err.Error())\n\t\treturn err\n\t}\n\tlog.Infof(\"Deleted service %s from stage %s in project %s\", service, stage, project)\n\treturn nil\n}", "title": "" }, { "docid": "5f86956ec66371375cac2ab23bb83779", "score": "0.5349199", "text": "func (ang *Angine) Destroy() {\n\tfor _, p := range ang.plugins {\n\t\tp.Stop()\n\t}\n\n\tif ang.refuseList != nil {\n\t\tang.refuseList.Stop()\n\t}\n\tang.dataArchive.Close()\n\tcloseDBs(ang)\n}", "title": "" }, { "docid": "977f1bbbb572c82957b52bb5233adae5", "score": "0.53433526", "text": "func Destroy(s *service.Service, e *environment.Environment, log *logger.Logger) error {\n\tconfig, err := getAWSConfig(e)\n\tif err != nil {\n\t\treturn err\n\t}\n\tlog.Printf(\"Destroying the stack '%s'...\", s.Name)\n\tstack, err := cf.Get(s.Name, config)\n\tif stack == nil {\n\t\tlog.Printf(\"Stack '%s' doesn't exist.\", s.Name)\n\t\treturn nil\n\t}\n\tconsumed := cf.NumEvents(s.Name, config)\n\tif err = cf.Delete(s.Name, config); err != nil {\n\t\treturn err\n\t}\n\tstartTime := new(int64)\n\t*startTime = -1\n\treturn cf.Watch(*stack.StackId, consumed, s, startTime, config, log)\n}", "title": "" }, { "docid": "7a96da124cd33be6d1463af04e097282", "score": "0.53367597", "text": "func DeleteServiceConnections(execer exec.Interface, svcIPs []string) {\n\tfor _, ip := range svcIPs {\n\t\tglog.V(2).Infof(\"Deleting connection tracking state for service IP %s\", ip)\n\t\terr := ExecConntrackTool(execer, \"-D\", \"--orig-dst\", ip, \"-p\", \"udp\")\n\t\tif err != nil && !strings.Contains(err.Error(), noConnectionToDelete) {\n\t\t\t// TODO: Better handling for deletion failure. When failure occur, stale udp connection may not get flushed.\n\t\t\t// These stale udp connection will keep black hole traffic. Making this a best effort operation for now, since it\n\t\t\t// is expensive to baby-sit all udp connections to kubernetes services.\n\t\t\tglog.Errorf(\"conntrack returned error: %v\", err)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "18dffcde7be35e0b04e57960d77b0d8a", "score": "0.53301173", "text": "func (l *ServiceChain) OnDeleteService(svc *slim_corev1.Service) error {\n\tl.RLock()\n\tdefer l.RUnlock()\n\terrs := []error{}\n\tfor _, s := range l.subs {\n\t\tif err := s.OnDeleteService(svc); err != nil {\n\t\t\terrs = append(errs, err)\n\t\t}\n\t}\n\tif len(errs) > 0 {\n\t\treturn fmt.Errorf(\"Errors: %v\", errs)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "dda8770712347b2817f283703c2beeca", "score": "0.5326886", "text": "func (zk *zkf) StopServiceInstances(ctx datastore.Context, poolID, serviceID string) error {\n\tdefer ctx.Metrics().Stop(ctx.Metrics().Start(fmt.Sprintf(\"zzk.StopServiceInstances\")))\n\tlogger := plog.WithFields(log.Fields{\n\t\t\"poolid\": poolID,\n\t\t\"serviceid\": serviceID,\n\t})\n\n\t// get the root-based connection to stop the service instance\n\tconn, err := getLocalConnection(ctx, \"/\")\n\tif err != nil {\n\t\tlogger.WithError(err).Debug(\"Could not acquire root-based connection\")\n\t\treturn err\n\t}\n\n\t// keep track of host online states\n\tonlineHosts := make(map[string]bool)\n\n\t// get all the state ids of the service\n\treqs, err := zks.GetServiceStateIDs(conn, poolID, serviceID)\n\tif err != nil {\n\t\tlogger.WithError(err).Debug(\"Could not get service state ids\")\n\t\treturn err\n\t}\n\n\t// for each state, if the host is online, stop the service;\n\t// if the host is offline delete the service.\n\tfor _, req := range reqs {\n\t\tst8log := logger.WithField(\"instanceid\", req.InstanceID)\n\n\t\t// check the host\n\t\tisOnline, ok := onlineHosts[req.HostID]\n\t\tif !ok {\n\t\t\tisOnline, err = zks.IsHostOnline(conn, poolID, req.HostID)\n\t\t\tif err != nil {\n\t\t\t\tlogger.WithField(\"hostid\", req.HostID).WithError(err).Warn(\"Could not check if host is online\")\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tonlineHosts[req.HostID] = isOnline\n\t\t}\n\n\t\t// manage the service\n\t\tif isOnline {\n\t\t\tif err := zks.UpdateState(conn, req, func(s *zks.State) bool {\n\t\t\t\tif s.DesiredState != service.SVCStop {\n\t\t\t\t\ts.DesiredState = service.SVCStop\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\treturn false\n\t\t\t}); err != nil {\n\t\t\t\tst8log.WithError(err).Warn(\"Could not stop service instance\")\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tst8log.Debug(\"Set service instance to stopped\")\n\t\t} else {\n\t\t\tif err := zks.DeleteState(conn, req); err != nil {\n\t\t\t\tst8log.WithError(err).Warn(\"Could not delete service instance\")\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tst8log.Debug(\"Deleted service instance\")\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "97d4e2e2d0199a3036ec14b1e4264091", "score": "0.53181475", "text": "func (service *Service) Stop() {\n\tservice.quit <- true\n}", "title": "" }, { "docid": "dd8c6d4ab4cf5bb3fc167cc0ce266cb6", "score": "0.5314794", "text": "func (c *ConsulBackend) UnregisterService(env, pool, hostIP, name, containerID string) (*ServiceRegistration, error) {\n\tkey := path.Join(\"galaxy\", \"services\", env, pool, hostIP, name, containerID[0:12])\n\n\tregistration, err := c.GetServiceRegistration(env, pool, hostIP, name, containerID)\n\tif err != nil || registration == nil {\n\t\treturn registration, err\n\t}\n\n\tif registration.ContainerID != containerID {\n\t\treturn nil, nil\n\t}\n\n\t_, err = c.client.KV().Delete(key, nil)\n\tif err != nil {\n\t\treturn registration, err\n\t}\n\n\treturn registration, nil\n}", "title": "" }, { "docid": "cdffaef4ef1b4399ad2b2a263354aadf", "score": "0.5312573", "text": "func (d *Direct) Destroy(ctx context.Context) error {\n\treturn d.Stop(ctx)\n}", "title": "" }, { "docid": "92fe2926196c8b4cac1115997acef7ca", "score": "0.5305538", "text": "func (s *jsonService) Stop() error {\n\tif s.file != nil {\n\t\tlog.Printf(\"Populating service: Closing '%s' file...\", s.fileName)\n\t\terr := s.file.Close()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\ts.file = nil\n\t\tlog.Print(\"Populating service stopped\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "ede1dd503ab417e6be5d1c5e794fdc19", "score": "0.5300894", "text": "func (s *Service) Cleanup(t message.AbsoluteTick) {\n\ts.actions.Cleanup(t)\n}", "title": "" }, { "docid": "3889e063b91f5f9b46e4560e35ca5969", "score": "0.5294071", "text": "func (i *Impl) HandleDestroyOne(param services.DeleteServiceParams) middleware.Responder {\n\ti.Lock()\n\tdefer i.Unlock()\n\tdelete(i.services, param.Name)\n\treturn services.NewDeleteServiceNoContent()\n}", "title": "" }, { "docid": "79466f74736d66fb98c616108b6efd2a", "score": "0.52920246", "text": "func ClearDeadRequestedService() {\n\tfor {\n\t\ttime.Sleep(time.Second * time.Duration(mathrand.Int31n(globalPkg.GlobalObj.DeleteAccountLoopTimeInseacond)))\n\t\tt := globalPkg.UTCtime()\n\t\tfor index, serviceobj := range serviceTemp {\n\t\t\tt2 := serviceobj.Time\n\t\t\tSubtime := (t.Sub(t2)).Seconds()\n\t\t\tif Subtime > 3600 { ///globalPkg.GlobalObj.DeleteAccountTimeInseacond {\n\t\t\t\tserviceTemp = append(serviceTemp[:index], serviceTemp[index+1:]...)\n\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "dbc41d4e68897bce581419c33d7a713f", "score": "0.5289192", "text": "func destroyManager() {\n\tC.manager_destroy()\n}", "title": "" }, { "docid": "3c25303ead20bb30433bdd1798bef856", "score": "0.52860695", "text": "func (app *P2PApp) Cleanup() {\n\tfor _, c := range app.closers {\n\t\tif err := c.Close(); err != nil {\n\t\t\tlog.With().Warning(\"error closing service\", log.Err(err))\n\t\t}\n\t}\n\t// TODO: move to array of cleanup functions and execute all here\n}", "title": "" }, { "docid": "10db36f13765d5f33c1315ac89bc7a47", "score": "0.5265585", "text": "func (s *services) Stop(repoURL string, limit int) {\n\ts.Lock()\n\tdefer s.Unlock()\n\n\t// locate repos\n\tfor i, j := 0, 0; i < len(s.services) && ((limit >= 0 && j < limit) || limit < 0); i++ {\n\t\tservice := s.services[i]\n\t\tif string(service.repo.URL) == repoURL {\n\t\t\t// send halt signal\n\t\t\tservice.halt <- struct{}{}\n\t\t\ts.services[i] = nil\n\t\t\tj++\n\t\t}\n\t}\n\n\t// remove them from repos list\n\tservices := s.services[:0]\n\tfor _, s := range s.services {\n\t\tif s != nil {\n\t\t\tservices = append(services, s)\n\t\t}\n\t}\n\ts.services = services\n}", "title": "" }, { "docid": "94f520042d7d2749706bf4afaed4eb19", "score": "0.5262996", "text": "func (b *FusisBalancer) cleanup() error {\n\tfor _, svc := range b.GetServices() {\n\t\tb.state.DeleteService(&svc)\n\n\t\tfor _, dst := range b.GetDestinations(&svc) {\n\t\t\tb.state.DeleteDestination(&dst)\n\t\t}\n\t}\n\n\tkv := b.store.GetKV()\n\tkv.DeleteTree(b.config.StorePrefix)\n\n\treturn nil\n}", "title": "" }, { "docid": "e48f51ddd4ee9a701e8aae597f23b201", "score": "0.5253691", "text": "func deleteServiceAndWait(t *testing.T, p *Proxier, svcInfo *ServiceInfo, service *v1.Service, waitFunc func(*Proxier, int) error) {\n\tp.OnServiceDelete(service)\n\t// Wait for the port to really close.\n\tif err := waitFunc(p, svcInfo.proxyPort); err != nil {\n\t\tt.Fatalf(err.Error())\n\t}\n\twaitForProxyFinished(t, svcInfo)\n\tif svcInfo.IsAlive() {\n\t\tt.Fatalf(\"wrong value for IsAlive(): expected false\")\n\t}\n}", "title": "" }, { "docid": "cf938e6b805fd022986daffa3ba28e56", "score": "0.52507776", "text": "func (s Server) StopService() {\n\ts.Server.Stop()\n}", "title": "" }, { "docid": "28d9d5c98c59831d959b3834701720f6", "score": "0.52480847", "text": "func (c *Client) DeleteService(spec *client.Service) error {\n\terr := c.rancherClient.Service.Delete(spec)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "f69dec6edc2c66ef9aa7921d180f06d0", "score": "0.5242163", "text": "func RemoveAllServices() error {\n\tif defaultDevice == nil {\n\t\treturn ErrDefaultDevice\n\t}\n\treturn defaultDevice.RemoveAllServices()\n}", "title": "" }, { "docid": "3c5d1729eb37b4c698d86399e3a4f34f", "score": "0.52406055", "text": "func (s serviceService) Delete(name string) (*api.RevokeRepoResponse, error) {\n\terr := api.ValidateServiceID(name)\n\tif err != nil {\n\t\treturn nil, errio.Error(err)\n\t}\n\n\tresp, err := s.client.httpClient.DeleteService(name)\n\tif err != nil {\n\t\treturn nil, errio.Error(err)\n\t}\n\n\treturn resp, nil\n}", "title": "" }, { "docid": "48e6c0c6cb0a7f5b1c3f7beb07350565", "score": "0.52332014", "text": "func (s *DataStore) DeleteService(namespace, name string) error {\n\treturn s.kubeClient.CoreV1().Services(namespace).Delete(context.TODO(), name, metav1.DeleteOptions{})\n}", "title": "" }, { "docid": "eab7905667d8d0fd8b7856f87a8f88af", "score": "0.52242434", "text": "func (c *Client) DeleteService(spec *client.Service) error {\n\terr := c.rancherClient.Service.Delete(spec)\n\tif err != nil {\n\t\treturn errors.Annotate(err, \"Delete\")\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "30d5636228a6af3aadcbee256fed108e", "score": "0.52238613", "text": "func Stop(ctx context.Context, startedServices []IService, verbose bool) {\n\tif verbose {\n\t\tlogln(\"Stopping...\")\n\t}\n\tfor i := len(startedServices) - 1; i >= 0; i-- {\n\t\tservice := startedServices[i]\n\t\tserviceName := reflect.TypeOf(service).String()\n\t\tif verbose {\n\t\t\tlogln(\"Stopping \" + serviceName + \"...\")\n\t\t}\n\t\tservice.Stop(ctx)\n\t}\n\tif verbose {\n\t\tlogln(\"All services stopped\")\n\t}\n}", "title": "" }, { "docid": "e760f679acb9fa9738cab573fce21c37", "score": "0.52229977", "text": "func (d *Daemon) stopMacaroonService() error {\n\treturn d.macaroonService.Close()\n}", "title": "" }, { "docid": "19ee3899c6176e910dcb89a18bc1b408", "score": "0.5222113", "text": "func (d *HephyCmd) ServicesRemove(appID, procfileType string) error {\n\ts, appID, err := load(d.ConfigFile, appID)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\td.Printf(\"Removing %s from %s... \", procfileType, appID)\n\n\tquit := progress(d.WOut)\n\terr = services.Delete(s.Client, appID, procfileType)\n\tquit <- true\n\t<-quit\n\tif d.checkAPICompatibility(s.Client, err) != nil {\n\t\treturn err\n\t}\n\n\td.Println(\"done\")\n\treturn nil\n}", "title": "" }, { "docid": "6990e8c51827170b0558a2a7f56ae327", "score": "0.5219922", "text": "func (c *K8sClient) DeleteService(namespace, name string, options *v1.DeleteOptions) error {\n\n\terr := c.clientSet.Core().Services(namespace).Delete(name, options)\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "e92fe1e2e87e31d6262d45051ac2cc3d", "score": "0.5201471", "text": "func (cf CloudFormation) DeleteService(in deploy.DeleteServiceInput) error {\n\treturn cf.cfnClient.DeleteAndWait(fmt.Sprintf(\"%s-%s-%s\", in.AppName, in.EnvName, in.Name))\n}", "title": "" }, { "docid": "f98b3aa86b296d499786d8c52f9bead2", "score": "0.5192768", "text": "func (h Service) Remove(name string) error {\n\treturn os.Remove(name)\n}", "title": "" }, { "docid": "69b8e8ecccf1fb7c312d8dc6685cfd53", "score": "0.51898116", "text": "func (p *GraphicsApp) Destroy() {\n\n\tvk.DeviceWaitIdle(p.Device.VKDevice)\n\n\tp.destroyGraphicsPipelines()\n\n\tfor _, g := range p.GraphicsPipelineConfigs {\n\t\tg.Destroy()\n\t}\n\n\tif p.PipelineCache != nil {\n\t\tp.PipelineCache.Destroy()\n\t}\n\n\tp.ResourceManager.Destroy()\n\n\tp.destroyDepthImage()\n\n\tp.destroySwapchainAndImages()\n\n\tp.destroySyncObjects()\n\n\tp.GraphicsCommandPool.Destroy()\n\n\tvk.DestroySurface(p.Instance.VKInstance, p.VKSurface, nil)\n\n\tp.Device.Destroy()\n\n\tp.Instance.Destroy()\n\n}", "title": "" }, { "docid": "b629876f870672c499be34ceec828ad0", "score": "0.5185416", "text": "func (im *ControllerMetrics) DeleteL4ILBService(svcKey string) {\n\tim.Lock()\n\tdefer im.Unlock()\n\n\tdelete(im.l4ILBServiceMap, svcKey)\n}", "title": "" }, { "docid": "1be58aa84c94c226919135f177749f62", "score": "0.51842123", "text": "func (k *Kubernetes) Destroy(ctx context.Context, specObj interface{}) error {\n\truntime, err := ValidateRuntime(specObj, \"Destroy\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\toperator, ok := runtime.Labels[\"USE_OPERATOR\"]\n\tif ok {\n\t\top, err := k.whichOperator(operator)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"not found addonoperator: %v\", operator)\n\t\t}\n\t\t// If it fails, try to delete it as a normal runtime\n\t\tif err := addon.Remove(op, runtime); err == nil {\n\t\t\treturn nil\n\t\t}\n\t}\n\tvar ns = MakeNamespace(runtime)\n\tif !IsGroupStateful(runtime) && runtime.ProjectNamespace != \"\" {\n\t\tns = runtime.ProjectNamespace\n\t\tk.setProjectServiceName(runtime)\n\t}\n\tif runtime.ProjectNamespace == \"\" {\n\t\tlogrus.Infof(\"delete runtime %s on namespace %s\", runtime.ID, runtime.Type)\n\t\tif err := k.destroyRuntime(ns); err != nil {\n\t\t\tif k8serror.NotFound(err) {\n\t\t\t\tlogrus.Debugf(\"k8s namespace not found or already deleted, namespace: %s\", ns)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t\t// Delete the local pv of the stateful service\n\t\tif err := k.DeletePV(runtime); err != nil {\n\t\t\tlogrus.Errorf(\"failed to delete pv, namespace: %s, name: %s, (%v)\", runtime.Type, runtime.ID, err)\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t} else {\n\t\tif value, ok := runtime.Labels[pstypes.ErdaPALabelKey]; ok && value == pstypes.ErdaHPALabelValueCancel {\n\t\t\tlogrus.Infof(\"delete pod autoscaler objects in runtime %s on namespace %s\", runtime.ID, runtime.ProjectNamespace)\n\t\t\terr = k.cancelErdaPARules(*runtime)\n\t\t\tif err != nil {\n\t\t\t\tlogrus.Errorf(\"failed to delete runtime resource, delete runtime's pod autoscaler objects error: %v\", err)\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\tlogrus.Infof(\"delete runtime %s on namespace %s\", runtime.ID, runtime.ProjectNamespace)\n\t\terr = k.destroyRuntimeByProjectNamespace(ns, runtime)\n\t\tif err != nil {\n\t\t\tlogrus.Errorf(\"failed to delete runtime resource %v\", err)\n\t\t\treturn err\n\t\t}\n\t}\n\tlogrus.Infof(\"delete runtime %s finished\", runtime.ID)\n\treturn nil\n}", "title": "" }, { "docid": "46cde8dd447e2ff6db78a0aae54818ff", "score": "0.5181466", "text": "func (r *Runner) Stop(ctx context.Context, config Config, services ...Service) {\n\tfor _, service := range services {\n\t\tservice.Stop(ctx)\n\t}\n}", "title": "" }, { "docid": "a0cbaa60aa2ee28090ec588aeb87905e", "score": "0.5178607", "text": "func (p *Provisioner) deleteService(nfsServerOpts *KernelNFSServerOptions) error {\n\tklog.V(4).Infof(\"Deleting Service\")\n\tif err := nfsServerOpts.validate(); err != nil {\n\t\treturn err\n\t}\n\n\tsvcName := \"nfs-\" + nfsServerOpts.pvName\n\tklog.V(4).Infof(\"Verifying if Service(%v) for NFS storage exists.\", svcName)\n\n\t//Check if the Service still exists. It could have been removed\n\t// or never created due to a provisioning create failure.\n\t_, err := p.kubeClient.CoreV1().\n\t\tServices(p.serverNamespace).\n\t\tGet(nfsServerOpts.ctx, svcName, metav1.GetOptions{})\n\tif err == nil {\n\t\tnfsServerOpts.serviceName = svcName\n\t\tklog.Infof(\"Volume %s has been initialized with Service {%s/%s}. Initiating delete...\", nfsServerOpts.pvName, p.serverNamespace, svcName)\n\t} else if err != nil && k8serrors.IsNotFound(err) {\n\t\treturn nil\n\t}\n\n\t//TODO\n\t// remove finalizer\n\n\t// Delete Service\n\terr = p.kubeClient.CoreV1().\n\t\tServices(p.serverNamespace).\n\t\tDelete(nfsServerOpts.ctx, svcName, metav1.DeleteOptions{})\n\tif err != nil && !k8serrors.IsNotFound(err) {\n\t\treturn errors.Wrapf(err, \"failed to delete NFS service %s/%s associated with PV:%s\", p.serverNamespace, svcName, nfsServerOpts.pvName)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "59a3ea699342acc784c18fd3058a4699", "score": "0.5176671", "text": "func (m *AppManager) DeleteService(ignoreNotFound bool) error {\n\tserviceClient := m.client.Services(m.namespace)\n\tdeletePolicy := metav1.DeletePropagationForeground\n\n\tctx, cancel := context.WithTimeout(m.ctx, 30*time.Second)\n\tdefer cancel()\n\tif err := serviceClient.Delete(ctx, m.app.AppName, metav1.DeleteOptions{\n\t\tPropagationPolicy: &deletePolicy,\n\t}); err != nil && (ignoreNotFound && !errors.IsNotFound(err)) {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "8f97ded3b42dc62014b30b4a8e3b0c27", "score": "0.5172953", "text": "func (s *APIServer) Destroy() error {\n\tshutdownCtx, shutdownCancelFunc := context.WithTimeout(context.Background(), 1*time.Second)\n\tdefer shutdownCancelFunc()\n\tlogrus.WithFields(logrus.Fields{\n\t\tlogfield.Component: apiServer,\n\t\tlogfield.Event: \"DESTROY\",\n\t}).Debugf(\"shutting down REST server\")\n\treturn s.Server.Shutdown(shutdownCtx)\n}", "title": "" }, { "docid": "3d88d1bf32df5e302fc269029bc385c0", "score": "0.5169688", "text": "func ResetService() {\n\tRepositoryService = &reposService{}\n}", "title": "" }, { "docid": "3faa969ce1acd090da6a7e230a35f7a0", "score": "0.51671934", "text": "func (service *CameraService) Free() error {\n\tif service.Context != nil {\n\t\tservice.Context.Free()\n\t}\n\tif service.Ports != nil {\n\t\terr := service.Ports.Free()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif service.Abilities != nil {\n\t\terr := service.Abilities.Free()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "c91bd0a5ed73c02f328ca0329b9e564e", "score": "0.5163001", "text": "func DeleteService(\n\tk8sClient client.Client,\n\tname, namespace string,\n\towners ...metav1.OwnerReference,\n) error {\n\tresource := types.NamespacedName{\n\t\tName: name,\n\t\tNamespace: namespace,\n\t}\n\n\tservice := &v1.Service{}\n\terr := k8sClient.Get(context.TODO(), resource, service)\n\tif errors.IsNotFound(err) {\n\t\treturn nil\n\t} else if err != nil {\n\t\treturn err\n\t}\n\n\tnewOwners := removeOwners(service.OwnerReferences, owners)\n\n\t// Do not delete the object if it does not have the owner that was passed;\n\t// even if the object has no owner\n\tif (len(service.OwnerReferences) == 0 && len(owners) > 0) ||\n\t\t(len(service.OwnerReferences) > 0 && len(service.OwnerReferences) == len(newOwners)) {\n\t\tlogrus.Infof(\"Cannot delete Service %s/%s as it is not owned\",\n\t\t\tnamespace, name)\n\t\treturn nil\n\t}\n\n\tif len(newOwners) == 0 {\n\t\tlogrus.Infof(\"Deleting %s/%s Service\", namespace, name)\n\t\treturn k8sClient.Delete(context.TODO(), service)\n\t}\n\tservice.OwnerReferences = newOwners\n\tlogrus.Infof(\"Disowning %s/%s Service\", namespace, name)\n\treturn k8sClient.Update(context.TODO(), service)\n}", "title": "" }, { "docid": "88c0c93c3a51aaf8f0364d2c8a443988", "score": "0.51468277", "text": "func DeleteService(clientset *kubernetes.Clientset, name, namespace string) error {\n\terr := clientset.CoreV1().Services(namespace).Delete(name, &meta_v1.DeleteOptions{})\n\tif err != nil {\n\t\tlog.Error(err)\n\t\tlog.Error(\"error deleting Service \" + name)\n\t}\n\tlog.Info(\"delete service \" + name)\n\treturn err\n}", "title": "" } ]
b1ec9e310b2b2abf6c9924e4af8f0218
/ NewSemita wraps the supplied 'data' inside a Semita instance and returns pointer to the Semita instance. data must be either array, slice, map or struct (or pointer fo them).
[ { "docid": "c1ea389093e680adc6d9a90df8236d5f", "score": "0.82899", "text": "func NewSemita(data interface{}) *Semita {\n\tv := reflect.ValueOf(data)\n\tswitch v.Kind() {\n\tcase reflect.Array, reflect.Slice, reflect.Map, reflect.Struct:\n\t\tv := reflect.ValueOf(data)\n\t\treturn &Semita{\n\t\t\t&node{\n\t\t\t\tprev: nil,\n\t\t\t\tprevType: nil,\n\t\t\t\tkey: \"\",\n\t\t\t\tvalue: v,\n\t\t\t},\n\t\t}\n\tcase reflect.Ptr:\n\t\tswitch v.Elem().Kind() {\n\t\tcase reflect.Array, reflect.Slice, reflect.Map, reflect.Struct:\n\t\t\tp := unsafe.Pointer(v.Pointer())\n\t\t\tr := reflect.NewAt(v.Elem().Type(), p)\n\t\t\tv := r.Elem()\n\t\t\treturn &Semita{\n\t\t\t\t&node{\n\t\t\t\t\tprev: nil,\n\t\t\t\t\tprevType: nil,\n\t\t\t\t\tkey: \"\",\n\t\t\t\t\tvalue: v,\n\t\t\t\t},\n\t\t\t}\n\t\tcase reflect.Interface:\n\t\t\treturn NewSemita(v.Elem().Interface())\n\t\t}\n\t}\n\treturn nil\n}", "title": "" } ]
[ { "docid": "30a685b8c158ab8f08aefdc283107686", "score": "0.5749692", "text": "func New(a []byte) SWrap {\n\treturn SWrap(a)\n}", "title": "" }, { "docid": "edf8ffacdfae47b7a9ad295dd7048350", "score": "0.5276254", "text": "func NewData(code int, data []byte, contentType []string) *Render {\n\treturn &Render{\n\t\tRenderer: render.Data{\n\t\t\tData: data,\n\t\t\tCType: contentType,\n\t\t},\n\t\tcode: code,\n\t}\n}", "title": "" }, { "docid": "a563d28f5d6cba6cc922f4fbbbfefad9", "score": "0.5274832", "text": "func NewSignedData(data []byte) (*SignedData, error) {\n\tcontent, err := asn1.Marshal(data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tci := contentInfo{\n\t\tContentType: OIDData,\n\t\tContent: asn1.RawValue{Class: 2, Tag: 0, Bytes: content, IsCompound: true},\n\t}\n\tsd := signedData{\n\t\tContentInfo: ci,\n\t\tVersion: 1,\n\t}\n\treturn &SignedData{sd: sd, data: data, digestOid: OIDDigestAlgorithmSHA1}, nil\n}", "title": "" }, { "docid": "4c00e021f88b3f42cb09013b03a45acc", "score": "0.51766145", "text": "func (self *act_t) NewSvrData() interface{} {\n\treturn &data_svr_t{}\n}", "title": "" }, { "docid": "782584f608288f531e7ea470bd2071c3", "score": "0.5095584", "text": "func NewData(value Value) Payload {\n\treturn &data{value}\n}", "title": "" }, { "docid": "095830aa5bf94656edd23e87f8b7b27a", "score": "0.50524473", "text": "func New(data interface{}, config ...Config) (*Series, error) {\n\tvar idx index.Index\n\tconfiguration := index.Config{} // Series config\n\n\tif data == nil {\n\t\treturn newEmptySeries(), nil\n\t}\n\n\t// Handling config\n\tif config != nil {\n\t\tif len(config) > 1 {\n\t\t\treturn newEmptySeries(), fmt.Errorf(\"series.New(): can supply at most one Config (%d > 1)\", len(config))\n\t\t}\n\t\ttmp := config[0]\n\t\tconfiguration = index.Config{\n\t\t\tName: tmp.Name, DataType: tmp.DataType,\n\t\t\tIndex: tmp.Index, IndexName: tmp.IndexName,\n\t\t\tMultiIndex: tmp.MultiIndex, MultiIndexNames: tmp.MultiIndexNames,\n\t\t}\n\t}\n\n\t// Handling values\n\tcontainer, err := values.InterfaceFactory(data)\n\tif err != nil {\n\t\treturn newEmptySeries(), fmt.Errorf(\"series.New(): %v\", err)\n\t}\n\n\t// Handling index\n\t// empty data: return empty index\n\tif lenValues := container.Values.Len(); lenValues == 0 {\n\t\tidx = index.New()\n\t\t// not empty data: use config\n\t} else {\n\t\tidx, err = index.NewFromConfig(configuration, lenValues)\n\t\tif err != nil {\n\t\t\treturn newEmptySeries(), fmt.Errorf(\"series.New(): %v\", err)\n\t\t}\n\t}\n\n\ts := &Series{\n\t\tvalues: container.Values,\n\t\tindex: idx,\n\t\tdatatype: container.DataType,\n\t\tname: configuration.Name,\n\t}\n\n\t// Optional datatype conversion\n\tif configuration.DataType != options.None {\n\t\ts.values, err = values.Convert(s.values, configuration.DataType)\n\t\tif err != nil {\n\t\t\treturn newEmptySeries(), fmt.Errorf(\"series.New(): %v\", err)\n\t\t}\n\t\ts.datatype = configuration.DataType\n\t}\n\n\ts.Index = Index{s: s}\n\ts.InPlace = InPlace{s: s}\n\n\t// Alignment check\n\tif err := s.ensureAlignment(); err != nil {\n\t\treturn newEmptySeries(), fmt.Errorf(\"series.New(): %v\", err)\n\t}\n\n\treturn s, err\n}", "title": "" }, { "docid": "b196f731ec33f13d4de4e65181ee97d3", "score": "0.5008371", "text": "func New(data interface{}, unsafe...bool) *Json {\n j := (*Json)(nil)\n switch data.(type) {\n case map[string]interface{}, []interface{}, nil:\n j = &Json {\n p : &data,\n c : byte(gDEFAULT_SPLIT_CHAR),\n vc : false ,\n }\n case string, []byte:\n j, _ = LoadContent(gconv.Bytes(data))\n default:\n v := (interface{})(nil)\n if m := gconv.Map(data); m != nil {\n v = m\n j = &Json {\n p : &v,\n c : byte(gDEFAULT_SPLIT_CHAR),\n vc : false,\n }\n } else {\n v = gconv.Interfaces(data)\n j = &Json {\n p : &v,\n c : byte(gDEFAULT_SPLIT_CHAR),\n vc : false,\n }\n }\n }\n j.mu = rwmutex.New(unsafe...)\n return j\n}", "title": "" }, { "docid": "29e8337a2fc04d316c91b3329942485b", "score": "0.49965426", "text": "func New(name string, data []byte) Script {\n\treturn Script{\n\t\tdata: data,\n\t\tname: name,\n\t}\n}", "title": "" }, { "docid": "10daddc2afbfc45572929504fe728bec", "score": "0.49682873", "text": "func NewData(t string, p Hash) *Data {\n\treturn &Data{\n\t\tid: rand.Uint64(),\n\t\ttext: t,\n\t\tpreviousHash: p,\n\t\ttimestamp: time.Now().Unix(),\n\t}\n}", "title": "" }, { "docid": "03fad570ebc2516c3dc14492b21bb4d1", "score": "0.49440867", "text": "func (s Scheduler_Flow) NewData() (Scheduler_SchInfo, error) {\n\tss, err := NewScheduler_SchInfo(s.Struct.Segment())\n\tif err != nil {\n\t\treturn Scheduler_SchInfo{}, err\n\t}\n\terr = s.Struct.SetPtr(0, ss.Struct.ToPtr())\n\treturn ss, err\n}", "title": "" }, { "docid": "2bb14d58e16f516b9ff2f5fddcadba8c", "score": "0.49279225", "text": "func NewWithDataSpan(data []byte) (swarm.Chunk, error) {\n\tdataLength := len(data)\n\n\tif err := validateDataLength(dataLength - swarm.SpanSize); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn newWithSpan(data[swarm.SpanSize:], data[:swarm.SpanSize])\n}", "title": "" }, { "docid": "3091c7f1f300e5b08250c261a6b2dcab", "score": "0.49088466", "text": "func (s Receiver_send_Params) NewData() (Receiver_SndInfo, error) {\n\tss, err := NewReceiver_SndInfo(s.Struct.Segment())\n\tif err != nil {\n\t\treturn Receiver_SndInfo{}, err\n\t}\n\terr = s.Struct.SetPtr(0, ss.Struct.ToPtr())\n\treturn ss, err\n}", "title": "" }, { "docid": "9fd7733bd26f98d66f43d5e1c0e83741", "score": "0.49014977", "text": "func New(data []byte) (swarm.Chunk, error) {\n\tdataLength := len(data)\n\n\tif err := validateDataLength(dataLength); err != nil {\n\t\treturn nil, err\n\t}\n\n\tspan := make([]byte, swarm.SpanSize)\n\tbinary.LittleEndian.PutUint64(span, uint64(dataLength))\n\n\treturn newWithSpan(data, span)\n}", "title": "" }, { "docid": "084f18d455de3a2bfe9408ef8c4cb0a8", "score": "0.48693365", "text": "func newAWSSQSSpanData(span *spanS) AWSSQSSpanData {\n\tdata := AWSSQSSpanData{\n\t\tSpanData: NewSpanData(span, AWSSQSSpanType),\n\t\tTags: newAWSSQSSpanTags(span),\n\t}\n\n\treturn data\n}", "title": "" }, { "docid": "0c1edf051c7d68a7f67416bc48db28f7", "score": "0.48381397", "text": "func NewData(b []byte) *Data {\n\treturn &Data{\n\t\thash: md5.Sum(b),\n\t\tstep: 5,\n\t\twidth: 50,\n\t\theight: 50,\n\t}\n}", "title": "" }, { "docid": "66b3d0301330acc3a58ff17ef8685412", "score": "0.47932163", "text": "func New(abbrev, aranges, frame, info, line, pubnames, ranges, str []byte) (*Data, error)", "title": "" }, { "docid": "fe16fd15dd4d5f079cf909fc8898fc2d", "score": "0.47677043", "text": "func NewFromData(data, sign []byte, compressor ICompresser) Packet {\n\tvar compressed bool\n\tdata, compressed = compressor.Compress(data)\n\tif signSize := len(sign); signSize > 0 {\n\t\tpacket := New(uint16(OptSizeData + 1 + signSize + len(data)))\n\t\tpacket.SetZlibCompressed(compressed)\n\t\tpacket.SetDataFlag(FlagHMACSha1)\n\t\tpacket.SetDataSign(sign)\n\t\tpacket.SetDataLoad(data)\n\t\tcompressor.Close()\n\t\treturn packet\n\t}\n\tpacket := New(uint16(OptSizeData + len(data)))\n\tpacket.SetZlibCompressed(compressed)\n\tpacket.SetDataLoad(data)\n\tcompressor.Close()\n\treturn packet\n}", "title": "" }, { "docid": "25c5b6d2a691fc5c4262701f50b6fd05", "score": "0.47650707", "text": "func NewRawData(data []byte) *RawData {\n\treturn &RawData{\n\t\tentry: entry{\n\t\t\teType: ETypeRawData,\n\t\t},\n\t\tdata: data,\n\t}\n}", "title": "" }, { "docid": "83a74c445fda81de05bc559d64e5d239", "score": "0.47650427", "text": "func NewODSAData() Data {\n\tdata := new(ODSAData)\n\tdata.lPosition = 0\n\tdata.pMap = make(map[byte]int)\n\treturn data\n}", "title": "" }, { "docid": "473893d3f3bc2abf5cbd0844c730e3b4", "score": "0.4750923", "text": "func NewData() *Data {\n\treturn new(Data)\n}", "title": "" }, { "docid": "09e41313582af7b74b06d57ae0255692", "score": "0.47434992", "text": "func NewSAA(srv *HomeSubscriberServer, msg *diam.Message) (*diam.Message, error) {\n\terr := ValidateSAR(msg)\n\tif err != nil {\n\t\treturn msg.Answer(diam.MissingAVP), err\n\t}\n\n\tvar sar servicers.SAR\n\tif err := msg.Unmarshal(&sar); err != nil {\n\t\treturn msg.Answer(diam.UnableToComply), fmt.Errorf(\"SAR Unmarshal failed for message: %v failed: %v\", msg, err)\n\t}\n\n\t// TODO(vikg): Actually handle the SAR here\n\treturn ConstructSuccessAnswer(msg, sar.SessionID, srv.Config.Server), nil\n}", "title": "" }, { "docid": "4403f863e6853a3c4aae28354c07e862", "score": "0.47432163", "text": "func newData() *data {\n\treturn &data{\n\t\tvars: []string{},\n\t\tmethods: make(map[string]HandlerFunc),\n\t}\n}", "title": "" }, { "docid": "a7ec86793f1f8a12c5569cb20b5e1551", "score": "0.4736934", "text": "func initStreamData(data *MethodData, m *expr.MethodExpr, vname, rname, resultRef string, scope *codegen.NameScope) {\n\tvar (\n\t\tspayloadName string\n\t\tspayloadRef string\n\t\tspayloadDef string\n\t\tspayloadDesc string\n\t\tspayloadEx any\n\t)\n\tif m.StreamingPayload.Type != expr.Empty {\n\t\tspayloadName = scope.GoTypeName(m.StreamingPayload)\n\t\tspayloadRef = scope.GoTypeRef(m.StreamingPayload)\n\t\tif dt, ok := m.StreamingPayload.Type.(expr.UserType); ok {\n\t\t\tspayloadDef = scope.GoTypeDef(dt.Attribute(), false, true)\n\t\t}\n\t\tspayloadDesc = m.StreamingPayload.Description\n\t\tif spayloadDesc == \"\" {\n\t\t\tspayloadDesc = fmt.Sprintf(\"%s is the streaming payload type of the %s service %s method.\",\n\t\t\t\tspayloadName, m.Service.Name, m.Name)\n\t\t}\n\t\tspayloadEx = m.StreamingPayload.Example(expr.Root.API.ExampleGenerator)\n\t}\n\tsvrStream := &StreamData{\n\t\tInterface: vname + \"ServerStream\",\n\t\tVarName: scope.Unique(codegen.Goify(m.Name, true), \"ServerStream\"),\n\t\tEndpointStruct: vname + \"EndpointInput\",\n\t\tKind: m.Stream,\n\t\tSendName: \"Send\",\n\t\tSendDesc: fmt.Sprintf(\"Send streams instances of %q.\", rname),\n\t\tSendTypeName: rname,\n\t\tSendTypeRef: resultRef,\n\t\tMustClose: true,\n\t}\n\tcliStream := &StreamData{\n\t\tInterface: vname + \"ClientStream\",\n\t\tVarName: scope.Unique(codegen.Goify(m.Name, true), \"ClientStream\"),\n\t\tKind: m.Stream,\n\t\tRecvName: \"Recv\",\n\t\tRecvDesc: fmt.Sprintf(\"Recv reads instances of %q from the stream.\", rname),\n\t\tRecvTypeName: rname,\n\t\tRecvTypeRef: resultRef,\n\t}\n\tif m.Stream == expr.ClientStreamKind || m.Stream == expr.BidirectionalStreamKind {\n\t\tswitch m.Stream {\n\t\tcase expr.ClientStreamKind:\n\t\t\tif resultRef != \"\" {\n\t\t\t\tsvrStream.SendName = \"SendAndClose\"\n\t\t\t\tsvrStream.SendDesc = fmt.Sprintf(\"SendAndClose streams instances of %q and closes the stream.\", rname)\n\t\t\t\tsvrStream.MustClose = false\n\t\t\t\tcliStream.RecvName = \"CloseAndRecv\"\n\t\t\t\tcliStream.RecvDesc = fmt.Sprintf(\"CloseAndRecv stops sending messages to the stream and reads instances of %q from the stream.\", rname)\n\t\t\t} else {\n\t\t\t\tcliStream.MustClose = true\n\t\t\t}\n\t\tcase expr.BidirectionalStreamKind:\n\t\t\tcliStream.MustClose = true\n\t\t}\n\t\tsvrStream.RecvName = \"Recv\"\n\t\tsvrStream.RecvDesc = fmt.Sprintf(\"Recv reads instances of %q from the stream.\", spayloadName)\n\t\tsvrStream.RecvTypeName = spayloadName\n\t\tsvrStream.RecvTypeRef = spayloadRef\n\t\tcliStream.SendName = \"Send\"\n\t\tcliStream.SendDesc = fmt.Sprintf(\"Send streams instances of %q.\", spayloadName)\n\t\tcliStream.SendTypeName = spayloadName\n\t\tcliStream.SendTypeRef = spayloadRef\n\t}\n\tdata.ClientStream = cliStream\n\tdata.ServerStream = svrStream\n\tdata.StreamingPayload = spayloadName\n\tdata.StreamingPayloadDef = spayloadDef\n\tdata.StreamingPayloadRef = spayloadDef\n\tdata.StreamingPayloadDesc = spayloadDesc\n\tdata.StreamingPayloadEx = spayloadEx\n}", "title": "" }, { "docid": "badaaeab849647cc8870318986ec851e", "score": "0.47349447", "text": "func New(data interface{}) (*Linq, error) {\n\tkind := getKind(data)\n\tok := isSliceType(kind)\n\tif !ok {\n\t\treturn nil, errNoSlice\n\t}\n\treturn &Linq{\n\t\tcoll: data,\n\t\tresult: makeData(data),\n\t}, nil\n}", "title": "" }, { "docid": "f0ad8d187d11d5c483510606379feb73", "score": "0.4732799", "text": "func Make(a []byte) *SWrap {\n\tsw := SWrap(a)\n\treturn &sw\n}", "title": "" }, { "docid": "79c7ac21d32fdb0dfa4294492f7f98d5", "score": "0.4726814", "text": "func NewUnsafe(data...interface{}) *Json {\n if len(data) > 0 {\n return New(data[0], true)\n }\n return New(nil, true)\n}", "title": "" }, { "docid": "3fb47b83237ff3336e1b649507108b00", "score": "0.47220224", "text": "func New() *Data {\n\tdata := &Data{\n\t\tTags: make(map[int]Tag),\n\t}\n\treturn data\n}", "title": "" }, { "docid": "7af650f19237802aaeda3c09562b3de3", "score": "0.47116497", "text": "func (sr StreamRecord) WithNewData(data interface{}) StreamRecord {\n\treturn StreamRecord{\n\t\tts: sr.ts,\n\t\tdata: data,\n\t}\n}", "title": "" }, { "docid": "42eeb38ee8e6af371e4c2df1943e9e74", "score": "0.46859515", "text": "func New(data []byte, metadata []byte) Payload {\n\treturn &rawPayload{\n\t\tdata: data,\n\t\tmetadata: metadata,\n\t}\n}", "title": "" }, { "docid": "d9a754e703fdce9229af5eaf81855ee1", "score": "0.46728012", "text": "func Shallow(data Dstream) Dstream {\n\n\tdata.Reset()\n\tswitch data := data.(type) {\n\tcase *dataArrays:\n\t\tvar dy dataArrays = *data\n\t\treturn &dy\n\tdefault:\n\t\treturn MemCopy(data)\n\t}\n}", "title": "" }, { "docid": "9da858807b21e3ee120b2a32168d5661", "score": "0.46503916", "text": "func WithData(s string) Event {\n\treturn func(w io.Writer) (int, error) {\n\t\treturn sendFields(w, \"data\", s)\n\t}\n}", "title": "" }, { "docid": "d1dee46563f0913caaf731d669471a47", "score": "0.46426666", "text": "func New(data interface{}) Stream {\n\tstream := &startOp{}\n\tsetStreamData(stream, data)\n\tstream.startStage = stream\n\treturn stream\n}", "title": "" }, { "docid": "bb2eb04466dee98d0d521c1e84c9166f", "score": "0.4634903", "text": "func newAWSSNSSpanData(span *spanS) AWSSNSSpanData {\n\tdata := AWSSNSSpanData{\n\t\tSpanData: NewSpanData(span, AWSSNSSpanType),\n\t\tTags: newAWSSNSSpanTags(span),\n\t}\n\n\treturn data\n}", "title": "" }, { "docid": "b5482d96e78c466ce37abd93857501e2", "score": "0.4611989", "text": "func newAWSLambdaInvokeSpanData(span *spanS) AWSLambdaInvokeSpanData {\n\tdata := AWSLambdaInvokeSpanData{\n\t\tSpanData: NewSpanData(span, AWSLambdaInvokeSpanType),\n\t\tTags: newAWSDInvokeSpanTags(span),\n\t}\n\n\treturn data\n}", "title": "" }, { "docid": "64525ca28b9fca87a853ecf94fc84cb5", "score": "0.46091396", "text": "func NewSharedData() *SharedData {\n\td := &SharedData{}\n\td.data = map[string]interface{}{}\n\treturn d\n}", "title": "" }, { "docid": "c202454f2dc975c8fe9a979ec601c1e8", "score": "0.459925", "text": "func New(opcode []byte) *SA2 {\n\treturn &SA2{opcode: opcode}\n}", "title": "" }, { "docid": "a3ba1384c8da42d7f76bd7fe94b2b2c8", "score": "0.45910913", "text": "func New(config *aws.Config) *DataPipeline {\n\tif config == nil {\n\t\tconfig = &aws.Config{}\n\t}\n\n\tservice := &aws.Service{\n\t\tConfig: aws.DefaultConfig.Merge(config),\n\t\tServiceName: \"datapipeline\",\n\t\tAPIVersion: \"2012-10-29\",\n\t\tJSONVersion: \"1.1\",\n\t\tTargetPrefix: \"DataPipeline\",\n\t}\n\tservice.Initialize()\n\n\t// Handlers\n\tservice.Handlers.Sign.PushBack(v4.Sign)\n\tservice.Handlers.Build.PushBack(jsonrpc.Build)\n\tservice.Handlers.Unmarshal.PushBack(jsonrpc.Unmarshal)\n\tservice.Handlers.UnmarshalMeta.PushBack(jsonrpc.UnmarshalMeta)\n\tservice.Handlers.UnmarshalError.PushBack(jsonrpc.UnmarshalError)\n\n\treturn &DataPipeline{service}\n}", "title": "" }, { "docid": "6425cfb432ca4e0278d9b11942dc5995", "score": "0.45833763", "text": "func NewDataHandler(\n\tendpoint goa.Endpoint,\n\tmux goahttp.Muxer,\n\tdecoder func(*http.Request) goahttp.Decoder,\n\tencoder func(context.Context, http.ResponseWriter) goahttp.Encoder,\n\terrhandler func(context.Context, http.ResponseWriter, error),\n\tformatter func(err error) goahttp.Statuser,\n) http.Handler {\n\tvar (\n\t\tdecodeRequest = DecodeDataRequest(mux, decoder)\n\t\tencodeResponse = EncodeDataResponse(encoder)\n\t\tencodeError = EncodeDataError(encoder, formatter)\n\t)\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tctx := context.WithValue(r.Context(), goahttp.AcceptTypeKey, r.Header.Get(\"Accept\"))\n\t\tctx = context.WithValue(ctx, goa.MethodKey, \"data\")\n\t\tctx = context.WithValue(ctx, goa.ServiceKey, \"sensor\")\n\t\tpayload, err := decodeRequest(r)\n\t\tif err != nil {\n\t\t\tif err := encodeError(ctx, w, err); err != nil {\n\t\t\t\terrhandler(ctx, w, err)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tres, err := endpoint(ctx, payload)\n\t\tif err != nil {\n\t\t\tif err := encodeError(ctx, w, err); err != nil {\n\t\t\t\terrhandler(ctx, w, err)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tif err := encodeResponse(ctx, w, res); err != nil {\n\t\t\terrhandler(ctx, w, err)\n\t\t}\n\t})\n}", "title": "" }, { "docid": "ce05b9aa9d3e67a4566d38e16c041d6f", "score": "0.4542908", "text": "func New(beerstore beer.BeerStore) *Syntappd {\n\t// Setup Syntappd object\n\tapp := Syntappd{\n\t\tl: log.New(os.Stdout, \"\", 0),\n\t\td: beerstore,\n\t}\n\n\treturn &app\n}", "title": "" }, { "docid": "d679543781d377c398ee732e078d3b9d", "score": "0.45266145", "text": "func NewDataInstrument(d []byte, err error) DataInstrument {\n\treturn DataInstrument{\n\t\tData: d,\n\t\tError: err,\n\t}\n}", "title": "" }, { "docid": "5754468cf2c8300aa311cb044d876c48", "score": "0.45020503", "text": "func SseData(mods ...qm.QueryMod) sseDatumQuery {\n\tmods = append(mods, qm.From(\"\\\"sse_data\\\"\"))\n\treturn sseDatumQuery{NewQuery(mods...)}\n}", "title": "" }, { "docid": "8d9b74b17a73729dd4267fac71265896", "score": "0.45006302", "text": "func newSilo(offset int64, length int, deps dependencies, f file, dataPath string) (*silo, error) {\n\tif length == 0 {\n\t\tpanic(\"numbers shouldn't be empty\")\n\t}\n\n\ts := &silo{\n\t\toffset: offset,\n\t\tnumbers: make([]uint32, length, length),\n\t\tf: f,\n\t\tdeps: deps,\n\t}\n\n\trandomData := fastrand.Bytes(10 * pageSize)\n\ts.cs = computeChecksum(randomData)\n\n\t// Write initial checksum\n\t_, err := s.f.WriteAt(s.cs[:], s.offset+int64(len(s.numbers)*4))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Do initial setup write\n\tdone := make(chan error)\n\tgo s.threadedSetupWrite(done, dataPath, randomData, s.cs)\n\n\treturn s, <-done\n}", "title": "" }, { "docid": "798498d191e15ac87d92efaabf06922a", "score": "0.44744238", "text": "func newDataStream(p *CandidatePair, dataIn <-chan []byte) *DataStream {\n\tbase := p.local.base\n\treturn &DataStream{\n\t\tconn: base,\n\t\traddr: p.remote.address.netAddr(),\n\t\tin: dataIn,\n\t\tdead: base.dead,\n\t\tcause: func() error {\n\t\t\treturn base.err\n\t\t},\n\t}\n}", "title": "" }, { "docid": "6ce3cc76c90b93900ca0629cbf3721b2", "score": "0.4470228", "text": "func NewPlotData(title string, unitType string, data []interface{}) *PlotData {\n\treturn &PlotData{\n\t\tTitle: title,\n\t\tUnitType: unitType,\n\t\tData: data,\n\t}\n}", "title": "" }, { "docid": "f81cfdc2e94ec128fd8a9cbab990ece9", "score": "0.4465762", "text": "func newAWSLambdaSpanData(span *spanS) AWSLambdaSpanData {\n\td := AWSLambdaSpanData{\n\t\tSnapshot: newAWSLambdaSpanTags(span),\n\t}\n\n\tswitch span.Tags[\"lambda.trigger\"] {\n\tcase \"aws:api.gateway\", \"aws:application.load.balancer\":\n\t\ttags := newHTTPSpanTags(span)\n\t\td.HTTP = &tags\n\t}\n\n\treturn d\n}", "title": "" }, { "docid": "e5cbe605197653054d86a60bdc28c38c", "score": "0.4454194", "text": "func newSUT(writer io.Writer) *publisher {\n\treturn New(writer)\n}", "title": "" }, { "docid": "eb9a49dc1c2de83bc77470eca0c6099f", "score": "0.44517344", "text": "func New(wav *Wav, data []byte) {\n\twav.Bytes = data\n}", "title": "" }, { "docid": "ca70c5ff9f94e093564ebee3007b6bf8", "score": "0.44194555", "text": "func (s StackingRoot) NewA() (StackingA, error) {\n\tss, err := NewStackingA(s.Struct.Segment())\n\tif err != nil {\n\t\treturn StackingA{}, err\n\t}\n\terr = s.Struct.SetPtr(1, ss.Struct.ToPtr())\n\treturn ss, err\n}", "title": "" }, { "docid": "43118f4b210a7e84b1b0297fd888e0d1", "score": "0.44047427", "text": "func (muo *MetadataUpdateOne) SetData(m map[string]interface{}) *MetadataUpdateOne {\n\tmuo.mutation.SetData(m)\n\treturn muo\n}", "title": "" }, { "docid": "7d8e59e06bbdae1a870565fec1af1e1c", "score": "0.44032785", "text": "func newWaveFormulaFromDatastream(data []byte, unmarshal utility.UnmarshalFunc) (*WavePacket, error) {\n\tvar unmarshalError error\n\tvar formulaMarshal Marshal\n\tunmarshalError = unmarshal(data, &formulaMarshal)\n\n\tif unmarshalError != nil {\n\t\treturn nil, unmarshalError\n\t}\n\n\tformulaTerm := NewWaveFormulaFromMarshalObject(formulaMarshal)\n\treturn formulaTerm, nil\n}", "title": "" }, { "docid": "caad2a1d280e542dfd1a86fc791545c2", "score": "0.44030893", "text": "func (s StackingRoot) NewA() (StackingA, error) {\n\n\tss, err := NewStackingA(s.Struct.Segment())\n\tif err != nil {\n\t\treturn StackingA{}, err\n\t}\n\terr = s.Struct.SetPointer(1, ss)\n\treturn ss, err\n}", "title": "" }, { "docid": "05d41c9d492e2c527d9194feccda686f", "score": "0.43937236", "text": "func makeSNode(data interface{}, counter int) Node {\n\t// Assign node id for tracking. Required format is 'Sense' + <int_counter>\n\tid := \"Sense\"\n\tcounter += 1\n\tid += strconv.Itoa(counter)\n\treturn Node{id, data, 3, false}\n}", "title": "" }, { "docid": "5d6a7e63fb36eed8375096ec384b6a81", "score": "0.438839", "text": "func NewMapData(data arrow.ArrayData) *Map {\n\ta := &Map{List: &List{}}\n\ta.refCount = 1\n\ta.setData(data.(*Data))\n\treturn a\n}", "title": "" }, { "docid": "ebd28b70232530b238deaade3cbc0c1f", "score": "0.43865392", "text": "func NewSpanData(span *spanS, st RegisteredSpanType) SpanData {\n\tdata := SpanData{\n\t\tService: span.Service,\n\t\tst: st,\n\t}\n\n\tif customTags := filterCustomSpanTags(span.Tags, st); len(customTags) > 0 {\n\t\tdata.Custom = &CustomSpanData{Tags: customTags}\n\t}\n\n\treturn data\n}", "title": "" }, { "docid": "a5b97987a97aacb9b8d698c16010d254", "score": "0.43809226", "text": "func WrapWithData(e error, message string, data interface{}) error {\n\treturn wrap(e, message, data)\n}", "title": "" }, { "docid": "9f8b579361a0d340e9510ba88a1f49ac", "score": "0.43771085", "text": "func MustNew(data interface{}, config ...Config) *Series {\n\ts, err := New(data, config...)\n\tif err != nil {\n\t\tif options.GetLogWarnings() {\n\t\t\tlog.Printf(\"series.MustNew(): %v\", err)\n\t\t}\n\t\treturn newEmptySeries()\n\t}\n\treturn s\n}", "title": "" }, { "docid": "064079796357e523953615171fd96bc7", "score": "0.435757", "text": "func (c *Client) Data() goa.Endpoint {\n\tvar (\n\t\tencodeRequest = EncodeDataRequest(c.encoder)\n\t\tdecodeResponse = DecodeDataResponse(c.decoder, c.RestoreResponseBody)\n\t)\n\treturn func(ctx context.Context, v interface{}) (interface{}, error) {\n\t\treq, err := c.BuildDataRequest(ctx, v)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\terr = encodeRequest(req, v)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresp, err := c.DataDoer.Do(req)\n\t\tif err != nil {\n\t\t\treturn nil, goahttp.ErrRequestError(\"sensor\", \"data\", err)\n\t\t}\n\t\treturn decodeResponse(resp)\n\t}\n}", "title": "" }, { "docid": "64c1f97685993618057760fa6c375465", "score": "0.43515894", "text": "func (s TXOut) NewDataStore() (DataStore, error) {\n\ts.Struct.SetUint16(0, 0)\n\tss, err := NewDataStore(s.Struct.Segment())\n\tif err != nil {\n\t\treturn DataStore{}, err\n\t}\n\terr = s.Struct.SetPtr(0, ss.Struct.ToPtr())\n\treturn ss, err\n}", "title": "" }, { "docid": "4f74d42970d858950391ecb248a9252b", "score": "0.43459246", "text": "func New(a *thisAWS.AWS) Impl {\n\treturn Impl{\n\t\tClient: kms.New(a.Client, a.Config),\n\t\tLogger: a.Logger,\n\t}\n}", "title": "" }, { "docid": "077e2d80627ec194ad4a5d8affcc94c8", "score": "0.43387985", "text": "func NewData(nwApr, rtCtx, pd, corrID *params.Param) *Data {\n\td := &Data{\n\t\tHeader: &Header{\n\t\t\tVersion: 1,\n\t\t\tReserved: 0,\n\t\t\tClass: MsgClassTransfer,\n\t\t\tType: MsgTypePayloadData,\n\t\t},\n\t\tNetworkAppearance: nwApr,\n\t\tRoutingContext: rtCtx,\n\t\tProtocolData: pd,\n\t\tCorrelationID: corrID,\n\t}\n\td.SetLength()\n\n\treturn d\n}", "title": "" }, { "docid": "e8d7551b2d4bc7b756d3ed1ff33588ca", "score": "0.43331912", "text": "func NewXML(code int, data interface{}) *Render {\n\treturn &Render{\n\t\tRenderer: render.XML{Data: data},\n\t\tcode: code,\n\t}\n}", "title": "" }, { "docid": "0fdf7d18982f96ce2746ecce5be3b811", "score": "0.4328407", "text": "func New(config *aws.Config) *IoTDataPlane {\n\tservice := &service.Service{\n\t\tServiceInfo: serviceinfo.ServiceInfo{\n\t\t\tConfig: defaults.DefaultConfig.Merge(config),\n\t\t\tServiceName: \"data.iot\",\n\t\t\tSigningName: \"iotdata\",\n\t\t\tAPIVersion: \"2015-05-28\",\n\t\t},\n\t}\n\tservice.Initialize()\n\n\t// Handlers\n\tservice.Handlers.Sign.PushBack(v4.Sign)\n\tservice.Handlers.Build.PushBack(restjson.Build)\n\tservice.Handlers.Unmarshal.PushBack(restjson.Unmarshal)\n\tservice.Handlers.UnmarshalMeta.PushBack(restjson.UnmarshalMeta)\n\tservice.Handlers.UnmarshalError.PushBack(restjson.UnmarshalError)\n\n\t// Run custom service initialization if present\n\tif initService != nil {\n\t\tinitService(service)\n\t}\n\n\treturn &IoTDataPlane{service}\n}", "title": "" }, { "docid": "aa0a9962f8478eb7c6ccce15e93a1162", "score": "0.4326845", "text": "func (sc *SettingCreate) SetData(sd structs.SettingData) *SettingCreate {\n\tsc.mutation.SetData(sd)\n\treturn sc\n}", "title": "" }, { "docid": "2f80161d8273f993fd9307e39a4a7e23", "score": "0.43194443", "text": "func NewData(services *[]Service, files *[]FileInfo, envVars map[string]string,\n\twatchedEnvVars []string) (*Data, error) {\n\tcmData := &Data{Services: *services, Files: *files}\n\tif len(envVars) > 0 {\n\t\t// treat the envVars and watchedEnvironmentVars keys as optional\n\t\tcmData.EnvironmentVars = envVars\n\t}\n\tcmData.WatchedEnvironmentVars = watchedEnvVars\n\tif err := cmData.validate(); err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to create services ConfigMap data object: %w\", err)\n\t}\n\treturn cmData, nil\n}", "title": "" }, { "docid": "6479678bc68e2346fbf30b99550d6301", "score": "0.43042123", "text": "func New() *Data {\n\tonce.Do(initDB)\n\n\treturn data\n}", "title": "" }, { "docid": "467045686e0424720b1e0512e43e5fef", "score": "0.43001652", "text": "func DataEvent(data string) *Event {\n\te := &Event{}\n\tio.WriteString(e, data)\n\treturn e\n}", "title": "" }, { "docid": "0df3e5f8a9cb6df6995a6cd64466599d", "score": "0.42908266", "text": "func SensuData(token *jwt.Token, data *structs.Data) *structs.Data {\n\treturn data\n}", "title": "" }, { "docid": "07fcf457d9cb9bfba733ff9f54b2de03", "score": "0.42886004", "text": "func NewFromArrays(data [][]interface{}, names []string) Dstream {\n\n\tif len(data) != len(names) {\n\t\tmsg := fmt.Sprintf(\"NewFromArrays: len(data) = %d != len(names) = %d\",\n\t\t\tlen(data), len(names))\n\t\tpanic(msg)\n\t}\n\n\tda := &dataArrays{\n\t\tarrays: data,\n\t\txform: xform{\n\t\t\tnames: names,\n\t\t},\n\t}\n\n\tda.init()\n\n\treturn da\n}", "title": "" }, { "docid": "acf09c996fdfea26e34feb268c3ef09f", "score": "0.42757636", "text": "func Data(b []byte) *flow.Flow {\n\treturn &flow.Flow{Op: flow.Data, Ident: randString(), Data: b}\n}", "title": "" }, { "docid": "b5a060d1a7c04a9dd5831fa9df979a18", "score": "0.42705798", "text": "func New(channels int, analysisHop int, synthesisHop int, frameLength int, tolerance int) (*tsm.TSM, error) {\n\tconverter := wsolaConverter{\n\t\tframeLength: frameLength,\n\t\tsynthesisHop: synthesisHop,\n\t\ttolerance: tolerance,\n\t\tnaturalProgression: multichannel.NewTSMBuffer(channels, frameLength),\n\t}\n\n\treturn tsm.New(tsm.Settings{\n\t\tChannels: channels,\n\t\tAnalysisHop: analysisHop,\n\t\tSynthesisHop: synthesisHop,\n\t\tFrameLength: frameLength,\n\t\tSynthesisWindow: window.Hanning(frameLength),\n\n\t\tDeltaBefore: tolerance,\n\t\tDeltaAfter: tolerance + synthesisHop,\n\n\t\tConverter: &converter,\n\t})\n}", "title": "" }, { "docid": "c10df2e8cc5050183f99b855edd1c226", "score": "0.42691952", "text": "func NewDataSignerMock(t minimock.Tester) *DataSignerMock {\n\tm := &DataSignerMock{t: t}\n\tif controller, ok := t.(minimock.MockController); ok {\n\t\tcontroller.RegisterMocker(m)\n\t}\n\n\tm.GetDigestMethodMock = mDataSignerMockGetDigestMethod{mock: m}\n\n\tm.GetDigestOfMock = mDataSignerMockGetDigestOf{mock: m}\n\tm.GetDigestOfMock.callArgs = []*DataSignerMockGetDigestOfParams{}\n\n\tm.GetSignMethodMock = mDataSignerMockGetSignMethod{mock: m}\n\n\tm.GetSignatureMethodMock = mDataSignerMockGetSignatureMethod{mock: m}\n\n\tm.SignDataMock = mDataSignerMockSignData{mock: m}\n\tm.SignDataMock.callArgs = []*DataSignerMockSignDataParams{}\n\n\tm.SignDigestMock = mDataSignerMockSignDigest{mock: m}\n\tm.SignDigestMock.callArgs = []*DataSignerMockSignDigestParams{}\n\n\treturn m\n}", "title": "" }, { "docid": "eebdeefe10ec319d0a6ff529b091122e", "score": "0.42614993", "text": "func New(\n\te *userdatas.Endpoints,\n\tmux goahttp.Muxer,\n\tdecoder func(*http.Request) goahttp.Decoder,\n\tencoder func(context.Context, http.ResponseWriter) goahttp.Encoder,\n\terrhandler func(context.Context, http.ResponseWriter, error),\n\tformatter func(err error) goahttp.Statuser,\n\tuserdatasCreateUserdataDecoderFn UserdatasCreateUserdataDecoderFunc,\n\tuserdatasUpdateUserdataDecoderFn UserdatasUpdateUserdataDecoderFunc,\n) *Server {\n\treturn &Server{\n\t\tMounts: []*MountPoint{\n\t\t\t{\"CreateUserdata\", \"POST\", \"/userdatas/create\"},\n\t\t\t{\"UpdateUserdata\", \"POST\", \"/userdatas/update\"},\n\t\t\t{\"GetUserdata\", \"GET\", \"/userdatas/{pastelid}\"},\n\t\t\t{\"CORS\", \"OPTIONS\", \"/userdatas/create\"},\n\t\t\t{\"CORS\", \"OPTIONS\", \"/userdatas/update\"},\n\t\t\t{\"CORS\", \"OPTIONS\", \"/userdatas/{pastelid}\"},\n\t\t},\n\t\tCreateUserdata: NewCreateUserdataHandler(e.CreateUserdata, mux, NewUserdatasCreateUserdataDecoder(mux, userdatasCreateUserdataDecoderFn), encoder, errhandler, formatter),\n\t\tUpdateUserdata: NewUpdateUserdataHandler(e.UpdateUserdata, mux, NewUserdatasUpdateUserdataDecoder(mux, userdatasUpdateUserdataDecoderFn), encoder, errhandler, formatter),\n\t\tGetUserdata: NewGetUserdataHandler(e.GetUserdata, mux, decoder, encoder, errhandler, formatter),\n\t\tCORS: NewCORSHandler(),\n\t}\n}", "title": "" }, { "docid": "2476eded3752b2891b7b6302c2affdfc", "score": "0.4254502", "text": "func (build *signatureBuilder) WithData(data []byte) cryptography.SignatureBuilder {\n\tbuild.data = data\n\treturn build\n}", "title": "" }, { "docid": "b78a34b8ee7be75252375158d3b5a410", "score": "0.42520404", "text": "func NewDataParser(t *TypeDesc, opt *DataParserOptions) (DataParser, error) {\n\treturn newDataParser(t, false, opt)\n}", "title": "" }, { "docid": "22bbd9d4b3c679120ff0ea578cd68f95", "score": "0.42516524", "text": "func New(r string) (routing.DataClient, error) {\n\tparsed, err := eskip.Parse(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &routes{parsed: parsed}, nil\n}", "title": "" }, { "docid": "4b81388e9d1d3338019be5d10d8712d7", "score": "0.42502314", "text": "func (c *Config) SetData(new js.Value) {\n\tif new.Type() != js.TypeObject {\n\t\tpanic(\"SetData must use an object; got \" + new.Type().String() + \", value \" + new.String())\n\t}\n\tc.Set(\"data\", new)\n\tc.DataType = js.TypeObject\n}", "title": "" }, { "docid": "8f33ba249bb136896064dfeba6cdf2fa", "score": "0.4248224", "text": "func NewData(connID, seqNum, size int, payload []byte, checksum uint16) *Message {\n\treturn &Message{\n\t\tType: MsgData,\n\t\tConnID: connID,\n\t\tSeqNum: seqNum,\n\t\tSize: size,\n\t\tPayload: payload,\n\t\tChecksum: checksum,\n\t}\n}", "title": "" }, { "docid": "a8af25e2d6eb5a7d3e79c1a157c4c84e", "score": "0.423246", "text": "func New() *Analysis {\n\treturn &Analysis{\n\t\tID: uuid.New().String(),\n\t}\n}", "title": "" }, { "docid": "8bdf2e7e31877d6b95009f6aa3d48c2c", "score": "0.42290288", "text": "func MakeWithData(b []byte) Buffer {\n\treturn buffer.MakeWithData(b)\n}", "title": "" }, { "docid": "f420805eae665328950222f056f2510c", "score": "0.42273766", "text": "func NewScatter(addr *net.UDPAddr, key xor.Key, payload []byte) *Scatter {\n\treturn &Scatter{\n\t\taddr: addr,\n\t\tkey: key,\n\t\tpayload: payload,\n\t}\n}", "title": "" }, { "docid": "520a1ee60db159a4e4e8144a8bbe878e", "score": "0.4226058", "text": "func (self *Creature) SetDataA(member interface{}) {\n self.Object.Set(\"data\", member)\n}", "title": "" }, { "docid": "343692d3e8754af8eb5d1a576667d28a", "score": "0.4206018", "text": "func NewSnode(id, daeType string, publicNet, intraControlNet, intraDataNet NetInfo) (snode *Snode) {\n\tsnode = &Snode{PubNet: publicNet, ControlNet: intraControlNet, DataNet: intraDataNet}\n\tsnode.Init(id, daeType)\n\treturn\n}", "title": "" }, { "docid": "b7e9ea7183723757a4d21ff3de2c0d3e", "score": "0.4201815", "text": "func newWithSpan(data, span []byte) (swarm.Chunk, error) {\n\thash, err := doHash(data, span)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcacData := make([]byte, len(data)+len(span))\n\tcopy(cacData, span)\n\tcopy(cacData[swarm.SpanSize:], data)\n\n\treturn swarm.NewChunk(swarm.NewAddress(hash), cacData), nil\n}", "title": "" }, { "docid": "553c9ad9bbfadbb65738a9424e967cf7", "score": "0.42005533", "text": "func New() *Data {\n\treturn &Data{\n\t\tPresets: &PresetsOp{},\n\t\tSettings: &SettingsOp{},\n\t\tJobs: &JobsOp{},\n\t\tUsers: &UsersOp{},\n\t}\n}", "title": "" }, { "docid": "44fd4fa4ce1461e35b8bf3d9a98b03ea", "score": "0.41988102", "text": "func NewData(key []byte) *Data {\n\treturn &Data{dict: make(map[string]Pair), key: key, iv: crypto.GenerateIV()}\n}", "title": "" }, { "docid": "19388a5551cdc064a37d93285603446d", "score": "0.4191325", "text": "func NewDataStructure(identifier string) *GenericDataStructure {\n\treturn &GenericDataStructure{\n\t\tIdentifier: identifier,\n\t}\n}", "title": "" }, { "docid": "d5318be8f535c09dd58e35d13cbe3dc2", "score": "0.41900924", "text": "func New(sensor instana.TracerLogger) *echo.Echo {\n\tengine := echo.New()\n\tengine.Use(Middleware(sensor))\n\n\treturn engine\n}", "title": "" }, { "docid": "a186fe10dd11c583955663a910618efd", "score": "0.41867504", "text": "func NewOdata() *Odata {\n\treturn &Odata{properties: make(map[string]interface{}) }\n}", "title": "" }, { "docid": "2921539c4feecabf09d84f9f877ac478", "score": "0.41849297", "text": "func NewChecksumFromData(t ChecksumType, data []byte) *Checksum {\n\tif !t.IsSet() {\n\t\treturn nil\n\t}\n\th := t.Hasher()\n\th.Write(data)\n\traw := h.Sum(nil)\n\tc := Checksum{Type: t, Encoded: base64.StdEncoding.EncodeToString(raw), Raw: raw}\n\tif !c.Valid() {\n\t\treturn nil\n\t}\n\treturn &c\n}", "title": "" }, { "docid": "cecaf22223efb6e3e9c60a73a73c39a9", "score": "0.41820332", "text": "func createPageData(page string, user *users.User, glsa *models.Glsa, glsaCount int64) interface{} {\n\treturn struct {\n\t\tPage string\n\t\tApplication *models.GlobalSettings\n\t\tUser *users.User\n\t\tGlsa *models.Glsa\n\t\tGlsaCount int64\n\t}{\n\t\tPage: page,\n\t\tApplication: models.GetDefaultGlobalSettings(),\n\t\tUser: user,\n\t\tGlsa: glsa,\n\t\tGlsaCount: glsaCount,\n\t}\n}", "title": "" }, { "docid": "0f442d3cd97e1234ababcc6c5b22da18", "score": "0.41768885", "text": "func New(scriptstring string) *js.Object {\n\ts, err := pipescript.Parse(scriptstring)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn js.MakeWrapper(&Script{scriptstring: scriptstring, script: s})\n}", "title": "" }, { "docid": "80a51f2ac4c9e4c655771f6361111e53", "score": "0.41743037", "text": "func NewData(\n\tdbConfig db.Config,\n\tdbConnector db.Connector,\n\tkeyGen keygen.KeyGenerator,\n\tlogger logger.Logger,\n) (Data, error) {\n\tsqlDB, err := dbConnector.Connect(dbConfig)\n\tif err != nil {\n\t\treturn Data{}, err\n\t}\n\treturn Data{\n\t\tkeyGen: keyGen,\n\t\tdb: sqlDB,\n\t\tlogger: logger,\n\t}, nil\n}", "title": "" }, { "docid": "8163db0561901d9ae4c41259ca732c3f", "score": "0.4171663", "text": "func newSUT() *instance {\n\treturn New()\n}", "title": "" }, { "docid": "2b15d410c187fb9f3983022446d7eb15", "score": "0.4171165", "text": "func NewSystemInfoData(version string, apiVersion string, phpVersion string, os string, driver string) *SystemInfoData {\n\tthis := SystemInfoData{}\n\tthis.Version = version\n\tthis.ApiVersion = apiVersion\n\tthis.PhpVersion = phpVersion\n\tthis.Os = os\n\tthis.Driver = driver\n\treturn &this\n}", "title": "" }, { "docid": "2af5fb7a5d5ad308a982f8b4f4799f36", "score": "0.41674373", "text": "func newPageData() *PageData {\n\tpd := PageData{}\n\tpd.LoadStart = time.Now()\n\n\treturn &pd\n}", "title": "" }, { "docid": "5c7dc78afcdf2c3d240a9e3e286a2a1a", "score": "0.4155764", "text": "func data(data interface{}) CommonResp {\n\treturn CommonResp{\n\t\tMessage: \"success\",\n\t\tTimestamp: time.Now().Unix(),\n\t\tData: data,\n\t}\n}", "title": "" }, { "docid": "029de3a0968ca83a033976c9ff3f6e8b", "score": "0.41537502", "text": "func NewDataWeb(value map[string]interface{}, ) *DataWeb {\n\tthis := DataWeb{}\n\tthis.Value = value\n\treturn &this\n}", "title": "" }, { "docid": "49160dad37e8cf133fa502de0622ff14", "score": "0.4144318", "text": "func (r *RouteBuilder) Data(data interface{}) *RouteBuilder {\n\tr.data = data\n\treturn r\n}", "title": "" }, { "docid": "5188ed10e928b453016909bb6ce50961", "score": "0.41431648", "text": "func Data(ctx context.Context, a *device.MemoryLayout, at memory.Pointer, v ...interface{}) (memory.Range, id.ID) {\n\tbuf := &bytes.Buffer{}\n\tw := endian.Writer(buf, a.GetEndian())\n\tif _, err := memory.Write(w, a, v); err != nil {\n\t\tpanic(err)\n\t}\n\tid, err := database.Store(ctx, buf.Bytes())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn at.Range(uint64(len(buf.Bytes()))), id\n}", "title": "" }, { "docid": "862f16bc0fdd52c7782b2b0b9338ab48", "score": "0.41380468", "text": "func createWithData(rows, cols int, data []float64) Matrix {\n\treturn Matrix{\n\t\tNumRows: rows,\n\t\tNumCols: cols,\n\t\tdata: data,\n\t}\n}", "title": "" } ]
de72f4a55f4991c0027357775817f92e
Below samples are using goroutines. And the order that calles to responseSize is not under our control. So if you run the program more times, you may see the requests happen in a different order. We don't directly control when gorountines run. RunRetrievingPagesUsingGoroutinesAndTimeSleep gets pages content length via goroutine, and use time.Sleep to delay the main goroutine to exit, and gives other goroutines more time to finish running. The function takes 5 seconds to complete even if all the sites respond faster than that, so we're still not getting that great a speed gain from the switch to goroutines. Even worse, 5 seconds may not be enough time if the sites takes a long time to respond. Sometimes, you may see the program end before all the responses have arrived.
[ { "docid": "33185d0b1d358317ba75584980ddd468", "score": "0.8091683", "text": "func RunRetrievingPagesUsingGoroutinesAndTimeSleep() {\n\tgo responseSize(\"https://www.qq.com\")\n\tgo responseSize(\"https://www.163.com\")\n\tgo responseSize(\"https://www.baidu.com\")\n\ttime.Sleep(5 * time.Second)\n\tfmt.Println(\"Getting urls done\")\n\trunSimpleChannel()\n}", "title": "" } ]
[ { "docid": "33178675a75a4b9e26333469902e497a", "score": "0.7087118", "text": "func RunRetrievingPagesSync() {\n\tresponseSize(\"https://www.qq.com\")\n\tresponseSize(\"https://www.163.com\")\n\tresponseSize(\"https://www.baidu.com\")\n\tfmt.Println(\"Getting urls done\")\n}", "title": "" }, { "docid": "c562bd065ca67e52145b5f2746497ebb", "score": "0.6754521", "text": "func RunRetrievingPaegsUsingGoroutines() {\n\tgo responseSize(\"https://www.qq.com\")\n\tgo responseSize(\"https://www.163.com\")\n\tgo responseSize(\"https://www.baidu.com\")\n\tfmt.Println(\"Getting urls done\")\n}", "title": "" }, { "docid": "4d209c650794b3e24121baebbce3629c", "score": "0.67388004", "text": "func RunRetrievingPagesUsingChannel() {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlog.Fatal(r)\n\t\t}\n\t}()\n\n\tsizes := make(chan urlsize)\n\turls := []string{\n\t\t\"https://www.qq.com\",\n\t\t\"https://www.163.com\",\n\t\t\"https://www.baidu.com\",\n\t}\n\tfor _, url := range urls {\n\t\tgo responseSizeWithChannel(url, sizes)\n\t}\n\n\tfor i := 0; i < len(urls); i++ {\n\t\tfmt.Println(<-sizes)\n\t}\n}", "title": "" }, { "docid": "d498259a4c4f288571a901f321d856ef", "score": "0.60266095", "text": "func main() {\n\tbenchmark := func(urls []string, concurrency int) string {\n\t\tstartTime := time.Now()\n\t\tresults := boundedParallelGet(urls, concurrency)\n\t\tseconds := time.Since(startTime).Seconds()\n\t\ttmplate := \"%d bounded parallel requests: %d/%d in %v\"\n\t\treturn fmt.Sprintf(tmplate, concurrency, len(results), len(urls), seconds)\n\t}\n\n\t// fmt.Println(benchmark(urls, 10))\n\t// fmt.Println(benchmark(urls, 25))\n\t// fmt.Println(benchmark(urls, 50))\n\tfmt.Println(benchmark(urls, 1000))\n}", "title": "" }, { "docid": "8cb1b157df24389ca475bbb885dddf0c", "score": "0.59396714", "text": "func Example_httpResponseTimeLimitation() {\n\tlimiter := semaphore.New(2)\n\n\t// start http server to handle parallel requests\n\tts := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {\n\t\tdone := make(chan struct{})\n\t\tdeadline := semaphore.WithTimeout(sla)\n\n\t\tgo func() {\n\t\t\trelease, err := limiter.Acquire(deadline)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tdefer release()\n\t\t\tdefer close(done)\n\n\t\t\t// do some heavy work\n\t\t\ttime.Sleep(40 * time.Millisecond)\n\t\t}()\n\n\t\t// wait what happens before\n\t\tselect {\n\t\tcase <-deadline:\n\t\t\thttp.Error(rw, \"operation timeout\", http.StatusGatewayTimeout)\n\t\tcase <-done:\n\t\t\t// send success response\n\t\t\trw.Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\t\t\trw.WriteHeader(http.StatusOK)\n\t\t}\n\t}))\n\tdefer ts.Close()\n\n\tok, fail := sendParallelHTTPRequestsToURL(5, ts.URL)\n\n\tfmt.Printf(\"success: %d, failure: %d \\n\", ok, fail)\n\t// Output: success: 2, failure: 3\n}", "title": "" }, { "docid": "00bfa22ff82e87c59b195a29cba6d99b", "score": "0.5680825", "text": "func getPage(url string) ([]byte, int) {\n client := &http.Client{}\n req, err := http.NewRequest(\"GET\", url, nil)\n checkerr(err)\n req.Header.Set(\"User-Agent\", useragent)\n resp, err := client.Do(req)\n defer resp.Body.Close()\n checkerr(err)\n b, _ := ioutil.ReadAll(resp.Body)\n return b, resp.StatusCode\n}", "title": "" }, { "docid": "3cafc2f661f19852a8cacb02eb2e1d37", "score": "0.5604843", "text": "func main() {\n\n\tstart := time.Now()\n\tflag.Parse()\n\n\tu, err := url.Parse(*seed)\n\tcheck(err, \"Error in parsing the seed url\")\n\tlog.Println(\"The URL: \", u)\n\tbaseurl = u.String()\n\n\tif (*headLess) {\n\t\tlog.Println(\"Headless mode is enabled. CDP will run in Headless mode.\")\n\t}\n\n\turlProcessor\t:= make(chan string)\n\tdone\t\t:= make(chan bool)\n\n\tgo processURL(urlProcessor, done)\n\n\turlProcessor <- u.String()\n\n\t// First mem stat print must be right after creating the fetchbot\n\tif *memStats > 0 {\n\n\t\t// Print starting stats\n\t\tprintMemStats()\n\n\t\t// Run at regular intervals\n\t\trunMemStats(*memStats)\n\n\t\t// On exit, print ending stats after a GC\n\t\tdefer func() {\n\n\t\t\truntime.GC()\n\t\t\tprintMemStats()\n\t\t}()\n\t}\n\n\t// if a stop or cancel is requested after some duration, launch the goroutine\n\t// that will stop or cancel.\n\tif *stopAfter > 0 || *cancelAfter > 0 {\n\n\t\tafter\t\t:= *stopAfter\n\t\tstopFunc\t:= true\n\n\t\tif *cancelAfter != 0 {\n\n\t\t\tafter\t\t= *cancelAfter\n\t\t\tstopFunc\t= true\n\t\t}\n\n\t\tgo func() {\n\n\t\t\tc := time.After(after)\n\t\t\t<-c\n\n\t\t\tlog.Println(\"The given timeout has occured. Exiting the program...\")\n\t\t\tdone <- stopFunc\n\t\t}()\n\t}\n\n\t<-done\n\n\tlog.Println(strings.Repeat(\"=\", 72) + \"\\n\")\n\tlog.Println(\"\\n\\nCompleted Crawling & Scrapping the Domain:\\n\", u.String())\n\n\t// Print the product and URLs file details.\n\toutFileDetails()\n\tlog.Println(strings.Repeat(\"=\", 72) + \"\\n\")\n\n\telapsed := time.Since(start)\n\tlog.Printf(\"Time required to complete: %s\\n\", elapsed)\n}", "title": "" }, { "docid": "627a5c5fbcea9db24e4a4f960a8bec02", "score": "0.5582922", "text": "func race(requestStartString string, requestEndString string) ResultResponse {\n\tstart := time.Now()\n\tvar response ResultResponse\n\t//Map to record visited pages\n\tvar visited = make(map[string]bool)\n\t//Formatted strings to verify the page urls is reachable\n\tformattedStartTitle := strings.ReplaceAll(requestStartString, \" \", \"_\")\n\tformattedEndTitle := strings.ReplaceAll(requestEndString, \" \", \"_\")\n\n\tvar res string = \"\"\n\tpool := make(chan int, 10)\n\tres_chan := make(chan string)\n\n\t//Setting default values to the response fields\n\tresponse.Page = \"null\"\n\tresponse.Error = \"null\"\n\n\tctx, cancel := context.WithCancel(context.Background())\n\n\t//Calling input validation method to verify the request body\n\tif inputValidation(requestStartString).Error != \"\" {\n\t\treturn inputValidation(requestStartString)\n\t} else if inputValidation(requestEndString).Error != \"\" {\n\t\treturn inputValidation(requestEndString)\n\t}\n\t//Checking if the title exists in mediaWiki\n\tresp, _ := http.Get(\"https://en.wikipedia.org/wiki/\" + formattedStartTitle)\n\tif resp.Status != RESP_OK_STATUS {\n\t\tresponse.Error = \"Path not found.\"\n\t\tclose(res_chan)\n\t} else {\n\t\tresp, _ = http.Get(\"https://en.wikipedia.org/wiki/\" + formattedEndTitle)\n\t\tif resp.Status != RESP_OK_STATUS {\n\t\t\tresponse.Error = \"Path not found.\"\n\t\t\tclose(res_chan)\n\t\t} else {\n\t\t\tsearchTitles(pool, res_chan, ctx, requestStartString, requestEndString, requestStartString, visited, 30)\n\t\t\tlog.Println(\"Search started... \")\n\t\t}\n\t}\n\n\tres = <-res_chan\n\tif res != \"\" {\n\t\tresponse.Page = res\n\t}\n\n\tcancel()\n\telapsed := time.Since(start).Milliseconds()\n\tresponse.Time = strconv.FormatInt(elapsed, 10) + \"ms\"\n\treturn response\n}", "title": "" }, { "docid": "88eb7c881010513ab21b2c66fc0301e7", "score": "0.54980063", "text": "func getPageBytes(url string) ([]byte, error) {\n\tresp, err := http.Get(url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif resp.StatusCode != 200 {\n\t\treturn nil, fmt.Errorf(\"StatusCode is %d\", resp.StatusCode)\n\t}\n\n\tbe, err := ioutil.ReadAll(resp.Body) //get byte based entry\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t//-----------------------------------------------------\n\ttime.Sleep(time.Duration(SleepTime) * time.Second)\n\t//-----------------------------------------------------\n\n\treturn be, nil\n}", "title": "" }, { "docid": "d8a56896ebdf11e95366183b89709883", "score": "0.547745", "text": "func Test6() {\n\t// Get beverages from same outlet in parallel with higher number of requests\n\tfor i := 0; i < 20; i++ {\n\t\tgo func() {\n\t\t\thandler.RequestBeverages(2, \"black_tea\")\n\t\t}()\n\t}\n\ttime.Sleep(5 * time.Second)\n}", "title": "" }, { "docid": "32ac2cef095a2b119bd9913eebda8659", "score": "0.54277664", "text": "func waitFor(url string) (resp *http.Response, err error) {\n\tfor i := 0; i < 1000; i++ {\n\t\ttime.Sleep(10 * time.Millisecond)\n\t\tresp, err = http.Get(url)\n\t\tif err == nil {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn resp, err\n}", "title": "" }, { "docid": "0a62d2276f935614a779f024e21f707e", "score": "0.542722", "text": "func connectAndGetData(endpoint string) { // HL\n // Simulate a slow data download or connection\n // ...\n fmt.Println(\"Connecting to\", endpoint, \"...\") // OMIT\n time.Sleep(1 * time.Second) //simulate response time // OMIT\n fmt.Println(\"Connected to\", endpoint) // OMIT\n time.Sleep(1 * time.Second) //simulate response time // OMIT\n fmt.Println(\"Getting data from\", endpoint, \"...\") // OMIT\n time.Sleep(1 * time.Second) //simulate getting slow data // OMIT\n for i := 1; i < 100; i++ { // OMIT\n fmt.Println(\"Downloading from: \", endpoint, \"Percent done:\", i) // OMIT\n } // OMIT\n fmt.Println(\"Done. Closing connection with\", endpoint) \n}", "title": "" }, { "docid": "48c9145bbd009fe87a1e7ebacb195f46", "score": "0.5417405", "text": "func (c Crawler) Crawl(links chan Link, pages chan Page) {\n for link := range links {\n\n if link.Depth == Depth {\n fmt.Printf(\"%d link Depth %d exceed limit\\n\", c.Id, link.Depth)\n fmt.Printf(\"%d total urls: %d\\n\", c.Id, c.SuccessUrlCount)\n c.Done <- c\n close(c.Done)\n return\n }\n\n println(c.Id, \"downloading\", link.Id, link.Url)\n\n resp, err := client.Get(link.Url)\n\n if err != nil {\n println(err.Error())\n c.FailedUrlCount++\n continue\n }\n\n c.SuccessUrlCount++\n\n content := resp.Resp\n\n if string(content) != \"\" {\n println(c.Id, \"downloaded size:\", len(content))\n\n //pages <- Page{link.Depth, string(content)}\n\n filename := GetFileName(link)\n println(\"file\", filename.Name, \"suffix:\", filename.Suffix)\n\n if len(content) > 10*1024 && filename.IsMedia() {\n err1 := ioutil.WriteFile(filename.Name, []byte(string(content)+link.Url), os.ModePerm)\n if err1 != nil {\n println(c.Id, \"error:\", err1.Error())\n continue\n } else {\n println(c.Id, \"save to file\", filename, len(content))\n }\n }\n\n if filename.Suffix == \"/index.html\" {\n if resp.IsRedirected {\n link.Url = resp.FinalUrl\n }\n println(c.Id, \"about send page\", link.Url)\n\n go func(link Link, content []byte) {\n pages <- Page{link.Depth, string(content), link.Url}\n println(\"send page -----> \", link.Url)\n }(link, content)\n }\n }\n }\n}", "title": "" }, { "docid": "909f233e97ff1e4c283878ced10b873a", "score": "0.541502", "text": "func (t *throttler) Run() {\n\tdefer close(t.unprocessedPagesQueue)\n\n\t// MTG API does not supports HEAD requests in order to retrieve meta data\n\t// like number of pages so we could foresee and reserve the exact amount of\n\t// resources we need in a reliable way. This means we have the following\n\t// possible scenarios:\n\t// 1. block previous requests to read the next pages from\n\t// 2. make an initial and separated request to gather all the current meta-data from\n\t//\n\t// Option 2 is faster in performance and easier to implement with the\n\t// inconvenient of loosing a possible new page after the initial meta-data\n\t// gathering.\n\t//\n\t// For the sake of simplicity option 2 is the chosen one.\n\tlog.Print(\"Gathering meta data...\")\n\tt.gatherMetaData()\n\n\tvar wg sync.WaitGroup\n\t// Wait until all the work has been finished before returning.\n\tdefer wg.Wait()\n\t// The timer is going to define when we want to repeat a bursting of requests.\n\ttimer := time.NewTicker(time.Second)\n\tdefer timer.Stop()\n\t// Loop until each page has been processed.\n\tfor {\n\t\tif t.noMorePageToProcess() {\n\t\t\tlog.Print(\"All pages has been processed\")\n\t\t\tbreak\n\t\t}\n\n\t\t// Limit our requests bursting by the defined time.\n\t\t<-timer.C\n\n\t\t// Bursts the maximum amount of requests at a time.\n\t\tn := t.burstRequests()\n\t\tfor i := 0; i < n; i++ {\n\t\t\twg.Add(1)\n\t\t\tgo t.processPage(&wg, <-t.unprocessedPagesQueue)\n\t\t}\n\n\t\t// Here could be implemented a dynamic limiter. A fast idea:\n\t\t// 1. Get the \"Ratelimit-Remaining\" header\n\t\t// 2. If \"Ratelimit-Remaining\" == 0 hold for a while\n\t\t//\n\t\t// Not implemented for simplicity - no much sense for the scope of this\n\t\t// challenge.\n\t}\n}", "title": "" }, { "docid": "84f7b8ec5218360c57cf8b9364460aed", "score": "0.54008317", "text": "func testSlowRequestProcessing(name string, count int, limit, queueLimit uint, queueTimeout time.Duration) *httptest.ResponseRecorder {\n\tpauseCh := make(chan struct{})\n\tdefer close(pauseCh)\n\n\thandler := QueueRequests(\"Slow request processing: \"+name, pausedHttpHandler(pauseCh), limit, queueLimit, queueTimeout)\n\n\trespCh := make(chan *httptest.ResponseRecorder, count)\n\n\t// queue requests to use up the queue\n\tfor i := 0; i < count; i++ {\n\t\tgo func() {\n\t\t\tw := httptest.NewRecorder()\n\t\t\thandler.ServeHTTP(w, nil)\n\t\t\trespCh <- w\n\t\t}()\n\t}\n\n\t// dequeue first request\n\treturn <-respCh\n}", "title": "" }, { "docid": "6a55f500a4852e97e0ba1b07b9a35f55", "score": "0.5400148", "text": "func main() {\n\turl := os.Args[1]\n\tstart := time.Now()\n\n\tresp, err := http.Get(url)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\tif resp.ContentLength <= 0 {\n\t\tpanic(\"ContentLength <= 0\")\n\t}\n\tfile, err := os.Create(path.Base(url))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer file.Close()\n\n\tvar written, recordWritten int64\n\trecordTime := time.Now()\n\tbuf := make([]byte, 64*1024)\n\tfor {\n\t\tn, er := resp.Body.Read(buf)\n\t\tif n > 0 {\n\t\t\tif _, ew := file.Write(buf[:n]); ew != nil {\n\t\t\t\tpanic(ew)\n\t\t\t}\n\t\t\twritten += int64(n)\n\t\t\tnow := time.Now()\n\t\t\telapsed := now.Sub(recordTime).Seconds()\n\t\t\tif elapsed >= 1 {\n\t\t\t\tif resp.ContentLength > 0 {\n\t\t\t\t\tfmt.Printf(\n\t\t\t\t\t\t\"\\rPROGRESS: %.2f %%, SPEED: %.2f KB/s, TOTAL: %d MB \",\n\t\t\t\t\t\tfloat64(written)/float64(resp.ContentLength)*100,\n\t\t\t\t\t\tfloat64(written-recordWritten)/elapsed/1024,\n\t\t\t\t\t\tresp.ContentLength/1024/1024,\n\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Printf(\n\t\t\t\t\t\t\"\\rWRITTEN: %dMB, SPEED: %.2f\",\n\t\t\t\t\t\twritten/1024/1024,\n\t\t\t\t\t\tfloat64(written-recordWritten)/elapsed/1024,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\trecordTime, recordWritten = now, written\n\t\t\t}\n\t\t}\n\t\tif er != nil {\n\t\t\tif er == io.EOF {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tpanic(er)\n\t\t}\n\t}\n\tfmt.Printf(\"\\rAVERAGE_SPEED : %.2f KB/s\", float64(resp.ContentLength)/time.Now().Sub(start).Seconds()/1024)\n}", "title": "" }, { "docid": "2705d060b597d392b8421be073ae402e", "score": "0.5384618", "text": "func main() {\n\trequests := make(chan int, 5)\n\n\tfor i := 1; i <= 5; i++ {\n\t\trequests <- i\n\t}\n\tclose(requests)\n\n\t// This limiter channel will receive a value every 200 milliseconds. This is the regulator in our rate limiting scheme.\n\tlimiter := time.Tick(200 * time.Millisecond)\n\n\tfor req := range requests {\n\t\t// By blocking on a receive from the limiter channel before serving each request,\n\t\t// we limit ourselves to 1 request every 200 milliseconds.\n\t\t<-limiter\n\n\t\tfmt.Println(\"request\", req, time.Now())\n\t}\n}", "title": "" }, { "docid": "08bca57fd67d959812ad39327961af4a", "score": "0.53770185", "text": "func main() {\n\tstart := time.Now()\n\tvar totalRequest = 50000\n\ttestWithWorker(totalRequest)\n\t//testSimple(totalRequest)\n\telapsed := time.Since(start)\n\tlog.Printf(\"Time taken %s for %d requests\", elapsed, totalRequest)\n}", "title": "" }, { "docid": "89ba5adbc78c3d34cb936fb0c82cf900", "score": "0.53723806", "text": "func generateTraffic(t *testing.T, client *spoof.SpoofingClient, url string, concurrency int, duration time.Duration, resChannel chan *spoof.Response) error {\n\tvar group errgroup.Group\n\t// Notify the consumer about the end of the data stream.\n\tdefer close(resChannel)\n\n\tfor i := 0; i < concurrency; i++ {\n\t\tgroup.Go(func() error {\n\t\t\tdone := time.After(duration)\n\t\t\treq, err := http.NewRequest(http.MethodGet, url, nil)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error creating http request: %w\", err)\n\t\t\t}\n\t\t\tfor {\n\t\t\t\tselect {\n\t\t\t\tcase <-done:\n\t\t\t\t\treturn nil\n\t\t\t\tdefault:\n\t\t\t\t\tres, err := client.Do(req)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tt.Log(\"Error sending request:\", err)\n\t\t\t\t\t}\n\t\t\t\t\tresChannel <- res\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\tif err := group.Wait(); err != nil {\n\t\treturn fmt.Errorf(\"error making requests for scale up: %w\", err)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "58035c26448aaebbf973ae901dca51c2", "score": "0.53684396", "text": "func getPageSize(url string) (int, error) {\n\tfmt.Println(\"Getting\", url)\n\tresponse, err := http.Get(url)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tdefer response.Body.Close()\n\n\tbody, err := ioutil.ReadAll(response.Body)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn len(body), nil\n}", "title": "" }, { "docid": "8255b79b2838431c15dec0d64d64fb30", "score": "0.5366153", "text": "func analyzePage(paramURL string, wapp *Wappalyzer, detectedApplications *detected) (links *map[string]struct{}, scrapedURL *scraper.ScrapedURL, err error) {\n\tlog.Printf(\"Analyzing %s\", paramURL)\n\tif !validateURL(paramURL) {\n\t\tlog.Errorf(\"URL not valid : %s\", paramURL)\n\t\treturn nil, &scraper.ScrapedURL{URL: paramURL, Status: 400}, errors.New(\"UrlNotValid\")\n\t}\n\n\tscraped, err := wapp.Scraper.Scrape(paramURL)\n\tif err != nil {\n\t\tlog.Errorf(\"Scraper failed : %v\", err)\n\t\treturn nil, &scraper.ScrapedURL{URL: paramURL, Status: 400}, err\n\t}\n\n\tcanRenderPage := wapp.Scraper.CanRenderPage()\n\treader := strings.NewReader(scraped.HTML)\n\tdoc, err := goquery.NewDocumentFromReader(reader)\n\tif err == nil {\n\t\tlinks = getLinksSlice(doc, paramURL)\n\t}\n\t//Follow redirects\n\tif scraped.URLs.URL != paramURL {\n\t\t(*links)[strings.TrimRight(scraped.URLs.URL, \"/\")] = struct{}{}\n\t\tscraped.URLs.URL = paramURL\n\t}\n\n\tfor _, app := range wapp.Apps {\n\t\twg.Add(1)\n\t\tgo func(app *application) {\n\t\t\tdefer wg.Done()\n\t\t\tanalyzeURL(app, paramURL, detectedApplications)\n\t\t\tif canRenderPage && app.Js != nil {\n\t\t\t\tanalyzeJS(app, wapp.Scraper, detectedApplications)\n\t\t\t}\n\t\t\tif canRenderPage && app.Dom != nil {\n\t\t\t\tanalyzeDom(app, doc, detectedApplications)\n\t\t\t}\n\t\t\tif app.HTML != nil {\n\t\t\t\tanalyzeHTML(app, scraped.HTML, detectedApplications)\n\t\t\t}\n\t\t\tif len(scraped.Headers) > 0 && app.Headers != nil {\n\t\t\t\tanalyzeHeaders(app, scraped.Headers, detectedApplications)\n\t\t\t}\n\t\t\tif len(scraped.Cookies) > 0 && app.Cookies != nil {\n\t\t\t\tanalyzeCookies(app, scraped.Cookies, detectedApplications)\n\t\t\t}\n\t\t\tif len(scraped.Scripts) > 0 && app.Scripts != nil {\n\t\t\t\tanalyzeScripts(app, scraped.Scripts, detectedApplications)\n\t\t\t}\n\t\t\tif len(scraped.Meta) > 0 && app.Meta != nil {\n\t\t\t\tanalyzeMeta(app, scraped.Meta, detectedApplications)\n\t\t\t}\n\t\t\tif len(scraped.DNS) > 0 && app.DNS != nil {\n\t\t\t\tanalyzeDNS(app, scraped.DNS, detectedApplications)\n\t\t\t}\n\t\t\tif len(scraped.CertIssuer) > 0 && app.CertIssuer != \"\" {\n\t\t\t\tanalyzeCertIssuer(app, scraped.CertIssuer, detectedApplications)\n\t\t\t}\n\t\t}(app)\n\t}\n\n\twg.Wait()\n\n\tfor _, app := range detectedApplications.Apps {\n\t\tif app.excludes != nil {\n\t\t\tresolveExcludes(&detectedApplications.Apps, app.excludes)\n\t\t}\n\t\tif app.implies != nil {\n\t\t\tresolveImplies(&wapp.Apps, &detectedApplications.Apps, app.implies)\n\t\t}\n\t}\n\treturn links, &scraped.URLs, nil\n}", "title": "" }, { "docid": "5ea3c6485e96fe54b9e7560e4c2110e7", "score": "0.53653944", "text": "func Test4() {\n\t// Get beverages from same outlet in parallel\n\tgo func() {\n\t\thandler.RequestBeverages(2, \"hot_tea\")\n\t}()\n\n\tgo func() {\n\t\thandler.RequestBeverages(2, \"hot_coffee\")\n\t}()\n\n\tgo func() {\n\t\thandler.RequestBeverages(2, \"black_tea\")\n\t}()\n\n\tgo func() {\n\t\thandler.RequestBeverages(2, \"green_tea\")\n\t}()\n\n\tgo func() {\n\t\thandler.RequestBeverages(2, \"hot_coffee\")\n\t}()\n\ttime.Sleep(5 * time.Second)\n}", "title": "" }, { "docid": "2b0f6e8c1ceb86ebd927a0929304f3fd", "score": "0.53420603", "text": "func getPage(page int, url string, mainC chan<- []extractedJob) {\n\t//create empty jobs\n\tvar jobs []extractedJob\n\t//1. make channel\n\tc := make(chan extractedJob)\n\n\tpageURL := url + \"&start=\" + strconv.Itoa(page * 50)\n\t//page*50 is number so we have to use pacakage\n\t//print its wokring \n\tfmt.Println(\"Resuqesiting\", pageURL)\n\tres, err := http.Get(pageURL)\n\tcheckErr(err)\n\tcheckCode(res)\n\tdefer res.Body.Close()\n\t//goguery document//resbody is byte so we have to close \n\tdoc, err := goquery.NewDocumentFromReader(res.Body)\n\tcheckErr(err)\n\n\tsearchCards := doc.Find(\".jobsearch-SerpJobCard\")\n\tsearchCards.Each(func(i int, card *goquery.Selection){\n\t\t//each card I want to extract job\n\t\t//s is each card (div)\n\t\t//each card have id(data-jk)\n\t\t//attr return two values, actual value and existence\n\t\t// id, _ := s.Attr(\"data-jk\")\n\t\t// //print all of id\n\t\t// fmt.Println(id)\n\t\t// title := cleanString(s.Find(\".title>a\").Text())\n\t\t\n\t\t// location := cleanString(s.Find(\".sjcl\").Text())\n\t\t// fmt.Println(id, title, location)\n\t\t\n\t\t//separate extractjob function //4. add go \n\t\tgo extractJob(card, c)// 2. add channel\n\t\n\t\t//jobs = append(jobs, job)\n\t})\n\t\t//5. recevie channel message \n\t\tfor i :=0 ; i <searchCards.Length(); i++{\n\t\t\tjob := <-c\n\t\t\tjobs = append(jobs, job)\n\t\t}\n\t\t//4. not retun job we going to send job to main chaneel -main\n\tmainC <- jobs\n}", "title": "" }, { "docid": "ce679bfb55570a9eb2ea2caccfaf46c2", "score": "0.53410596", "text": "func boundedParallelGet(urls []string, concurrencyLimit int) []result {\n\n\t// this buffered channel will block at the concurrency limit\n\tsemaphoreChan := make(chan struct{}, concurrencyLimit)\n\n\t// this channel will not block and collect the http request results\n\tresultsChan := make(chan *result)\n\n\t// make sure we close these channels when we're done with them\n\tdefer func() {\n\t\tclose(semaphoreChan)\n\t\tclose(resultsChan)\n\t}()\n\n\t// keen an index and loop through every url we will send a request to\n\tfor i, url := range urls {\n\n\t\t// start a go routine with the index and url in a closure\n\t\tgo func(i int, url string) {\n\n\t\t\t// this sends an empty struct into the semaphoreChan which\n\t\t\t// is basically saying add one to the limit, but when the\n\t\t\t// limit has been reached block until there is room\n\t\t\tsemaphoreChan <- struct{}{}\n\n\t\t\t// send the request and put the response in a result struct\n\t\t\t// along with the index so we can sort them later along with\n\t\t\t// any error that might have occoured\n\t\t\tres, err := http.Get(url)\n\t\t\tresult := &result{i, *res, err}\n\n\t\t\t// now we can send the result struct through the resultsChan\n\t\t\tresultsChan <- result\n\n\t\t\t// once we're done it's we read from the semaphoreChan which\n\t\t\t// has the effect of removing one from the limit and allowing\n\t\t\t// another goroutine to start\n\t\t\t<-semaphoreChan\n\n\t\t}(i, url)\n\t}\n\n\t// make a slice to hold the results we're expecting\n\tvar results []result\n\n\t// start listening for any results over the resultsChan\n\t// once we get a result append it to the result slice\n\tfor {\n\t\tresult := <-resultsChan\n\t\tresults = append(results, *result)\n\n\t\t// if we've reached the expected amount of urls then stop\n\t\tif len(results) == len(urls) {\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// let's sort these results real quick\n\tsort.Slice(results, func(i, j int) bool {\n\t\treturn results[i].index < results[j].index\n\t})\n\n\t// now we're done we return the results\n\treturn results\n}", "title": "" }, { "docid": "3a2be6b8d1c181355e0a8618df9fe258", "score": "0.5338804", "text": "func checkPagesResponse(chunkSize int, rescan bool) {\n\n\tvar pages = make(map[int]string)\n\n\tif rescan {\n\t\tpages = database.RetrieveAllPages()\n\t} else {\n\t\tpages = database.RetrieveUncheckedPages()\n\t}\n\n\tlog.Info(\"Checking Response Code\", \"pages\", len(pages))\n\n\tif len(pages) == 0 {\n\t\tlog.Warn(\"There are no pages to check\")\n\t\tos.Exit(1)\n\t}\n\n\tpagesToCheck := database.PagesToStruct(pages)\n\n\tchunks := utils.ChunkifyPages(pagesToCheck, chunkSize)\n\n\tfor _, chunk := range chunks {\n\t\tresults := downloader.CheckPageResponseChunk(chunk)\n\n\t\tdatabase.BulkSavePagesResponse(results)\n\t}\n}", "title": "" }, { "docid": "abf05739cf5e83c47cf8dd3f87516be6", "score": "0.53304553", "text": "func main() {\n\t// First we’ll look at basic rate limiting.\n\t// Suppose we want to limit our handling of incoming requests.\n\t// We’ll serve these requests off a channel of the same name.\n\n\trequests := make(chan int, 5)\n\tfor i := 0; i < 5; i++ {\n\t\trequests <- i\n\t}\n\tclose(requests)\n\n\t// This limiter channel will receive a value every 200 milliseconds.\n\t// This is the regulator in our rate limiting scheme.\n\tlimiter := time.Tick(200 * time.Millisecond)\n\n\t// By blocking on a receive from the limiter channel before serving each request,\n\t// we limit ourselves to 1 request every 200 milliseconds.\n\tfor req := range requests {\n\t\t<-limiter\n\t\tfmt.Println(\"Request: \", req, time.Now().UTC())\n\t}\n\n\t// We may want to allow short bursts of requests in our rate limiting scheme\n\t// while preserving the overall rate limit.\n\t// We can accomplish this by buffering our limiter channel.\n\t// This burstyLimiter channel will allow bursts of up to 3 events.\n\tburstyLimiter := make(chan time.Time, 3)\n\n\t// Fill up the channel to represent allowed bursting.\n\tfor i := 0; i < 3; i++ {\n\t\tburstyLimiter <- time.Now().UTC()\n\t}\n\n\t// Every 200 milliseconds we’ll try to add a new value to burstyLimiter,\n\t// up to its limit of 3.\n\tgo func() {\n\t\tfor t := range time.Tick(200 * time.Millisecond) {\n\t\t\tburstyLimiter <- t\n\t\t}\n\t}()\n\n\t// Now simulate 5 more incoming requests.\n\t// The first 3 of these will benefit from the burst capability of burstyLimiter.\n\tburstyRequests := make(chan int, 5)\n\tfor i := 0; i < 5; i++ {\n\t\tburstyRequests <- i\n\t}\n\tclose(burstyRequests)\n\n\tfor req := range burstyRequests {\n\t\t<-burstyLimiter\n\t\tfmt.Println(\"Request: \", req, time.Now().UTC())\n\t}\n\n\t/*\n\n\t\tRunning our program we see the first batch of requests handled once every ~200 milliseconds\n\t\tas desired.\n\n\t\t$ go run rate-limiting.go\n\t\tRequest: 0 2018-08-07 00:54:48.180865275 +0000 UTC\n\t\tRequest: 1 2018-08-07 00:54:48.37815205 +0000 UTC\n\t\tRequest: 2 2018-08-07 00:54:48.576904537 +0000 UTC\n\t\tRequest: 3 2018-08-07 00:54:48.776876722 +0000 UTC\n\t\tRequest: 4 2018-08-07 00:54:48.97633472 +0000 UTC\n\n\t\tFor the second batch of requests we serve the first 3 immediately because\n\t\tof the burstable rate limiting, then serve the remaining 2 with ~200ms delays each.\n\n\t\tRequest: 0 2018-08-07 00:54:48.97644069 +0000 UTC\n\t\tRequest: 1 2018-08-07 00:54:48.9764542 +0000 UTC\n\t\tRequest: 2 2018-08-07 00:54:48.976461597 +0000 UTC\n\t\tRequest: 3 2018-08-07 00:54:49.176973666 +0000 UTC\n\t\tRequest: 4 2018-08-07 00:54:49.376967068 +0000 UTC\n\t*/\n}", "title": "" }, { "docid": "af2bf61b44dc68270198571bc70cbf37", "score": "0.53146577", "text": "func SliceRequestGenerator(dir string, gnb_tenant_dictionary []string, num_slice int, cpu_max int, cpu_lambda int, bandwidthLimit int, bandwidth_lambda int, slice_duration int, slice_duration_random bool, timewindow_duration int, extra_request_num_each_timewindow int) {\n\tvar slice_info_dictionary []SliceList\n\tnum_tenant := len(gnb_tenant_dictionary)\n\tfor i := 0; i < num_tenant; i++ {\n\t\thex_tenant_index := fmt.Sprintf(\"%02x\", i + 1)\n\t\tfor j := 0; j < num_slice; j++ {\n\t\t\tr := rand.New(rand.NewSource(uint64(time.Now().UnixNano())))\n\t\t\tcpu_poisson := distuv.Poisson{float64(cpu_lambda), r}\n\t\t\tbandwidth_poisson := distuv.Poisson{float64(bandwidth_lambda), r}\n\t\t\thex_slice_index := fmt.Sprintf(\"%04x\", j + 515)\n\t\t\tsliceCpu := int(cpu_poisson.Rand()) * Cpu_base\n\t\t\tslicebandwidth := int(bandwidth_poisson.Rand())\n\t\t\tsliceDuration := slice_duration\n\t\t\tif sliceCpu < (Cpu_min * Cpu_base) {\n\t\t\t\tsliceCpu = Cpu_min * Cpu_base\n\t\t\t} else if sliceCpu > (cpu_max * Cpu_base) {\n\t\t\t\tsliceCpu = cpu_max * Cpu_base\n\t\t\t}\n\t\t\tif slicebandwidth < Bandwidth_min {\n\t\t\t\tslicebandwidth = Bandwidth_min\n\t\t\t} else if slicebandwidth > bandwidthLimit {\n\t\t\t\tslicebandwidth = bandwidthLimit\n\t\t\t}\n\t\t\tif slice_duration_random {\n\t\t\t\tduration_lambda := slice_duration / Slice_Duration_base\n\t\t\t\tduration_poisson := distuv.Poisson{float64(duration_lambda), r}\n\t\t\t\tduration := int(duration_poisson.Rand())\n\t\t\t\tif duration < Slice_Duration_min {\n\t\t\t\t\tduration = Slice_Duration_min\n\t\t\t\t} else if duration > timewindow_duration / Slice_Duration_base {\n\t\t\t\t\tduration = timewindow_duration / Slice_Duration_base\n\t\t\t\t}\n\t\t\t\tsliceDuration = duration * Slice_Duration_base\n\t\t\t}\n\n\t\t\ts := SliceList {\n\t\t\t\t// snssai = sst(2bit) + sd(6bit)\n\t\t\t\t// sst = 01\n\t\t\t\t// sd first two bit defined by \"hex_tenant_index\"\n\t\t\t\t// sd last four bit defined by \"hex_slice_index\"\n\t\t\t\t// sd last four bit start by 0203\n\t\t\t\t// hex 0203 = dec 515\n\t\t\t\tSnssai: \"0x01\" + hex_tenant_index + hex_slice_index,\n\t\t\t\tNgci: gnb_tenant_dictionary[i],\n\t\t\t\tDuration: sliceDuration,\n\t\t\t\tCpu: sliceCpu,\n\t\t\t\tBandwidth: slicebandwidth,\n\t\t\t}\n\t\t\tslice_info_dictionary = append(slice_info_dictionary, s)\n\t\t}\n\t}\n\tnsrtoyaml.WriteToXml(\"../slice-requests/\" + dir + \"/\" + \"slice-info-dictionary.yaml\", slice_info_dictionary)\n\tRequsetGenerator(dir, slice_info_dictionary, num_tenant, num_slice, extra_request_num_each_timewindow)\n}", "title": "" }, { "docid": "36f13b38a01c477336e35f1529014b47", "score": "0.5282044", "text": "func getResponseTime(url string) time.Duration {\n req, _ := http.NewRequest(\"GET\", url, nil)\n start := time.Now()\n if _, err := http.DefaultTransport.RoundTrip(req); err != nil {\n fmt.Println(\"Error:\", err)\n return 100*time.Second\n }\n fmt.Printf(\"%v %v\\n\", time.Since(start), url)\n return time.Since(start)\n}", "title": "" }, { "docid": "9ed58a83ec2d26287fa56cdd7b9b32b4", "score": "0.52524364", "text": "func Scrape(term string ){\n\tvar baseURL string = \"https://kr.indeed.com/jobs?q=\"+term+\"&limit=50\"\n\tvar jobs []extractedJob\n\t//1.make channel-main\n\tc := make(chan []extractedJob)\n\ttotalPages := getPages(baseURL)\n\t//fmt.Println(totalPages)//5\n\t//hit the url \n\tfor i := 0; i < totalPages; i++{\n\t\t//2. go routine-main\n\t\tgo getPage(i, baseURL, c)\n\t\t\n\n\t}\n\t//5. recive message of mainc-main\n\tfor i := 0 ; i<totalPages;i++ {\n\t\textractedJobs := <-c\n\t\tjobs = append(jobs, extractedJobs...)\n\t}\n\t//fmt.Println(jobs)\n\twriteJobs(jobs)\n\tfmt.Println(\"Done\")\n}", "title": "" }, { "docid": "087bcae56b9414a3a87bfc496f56e8e8", "score": "0.5242885", "text": "func main() {\n // First we’ll look at basic rate limiting. Suppose we \n // want to limit our handling of incoming requests. We’ll \n // serve these requests off a channel of the same name.\n requests := make(chan int, 5)\n for i := 0; i < 5; i++ {\n requests <- i\n }\n close(requests)\n\n // This limiter channel will receive a value every 200 \n // milliseconds. This is the regulator in our rate limiting \n // scheme.\n limiter := time.Tick(time.Millisecond * 200)\n\n // By blocking on a receive from the limiter channel before \n // serving each request, we limit ourselves to 1 request \n // every 200 milliseconds.\n for req := range requests {\n <-limiter\n fmt.Println(\"request\", req, time.Now())\n }\n\n // We may want to allow short bursts of requests in our rate \n // limiting scheme while preserving the overall rate limit. \n // We can accomplish this by buffering our limiter channel. \n // This burstyLimiter channel will allow bursts of up to 3 \n // events.\n burstyLimiter := make(chan time.Time, 3)\n \n // Fill up the channel to represent allowed bursting.\n for i := 0; i < 3; i++ {\n burstyLimiter <- time.Now()\n }\n\n // Every 200 milliseconds we’ll try to add a new value to \n // burstyLimiter, up to its limit of 3.\n go func() {\n for t := range time.Tick(time.Millisecond * 200) {\n burstyLimiter <- t\n }\n }()\n\n // Now simulate 5 more incoming requests. The first 3 of \n // these will benefit from the burst capability of burstyLimiter.\n burstyRequests := make(chan int, 5)\n for i := 1; i <= 5; i++ {\n burstyRequests <- i\n }\n close(burstyRequests)\n for req := range burstyRequests {\n <-burstyLimiter\n fmt.Println(\"bursty request\", req, time.Now())\n }\n\n // NOTE: Running our program we see the first batch of requests \n // handled once every ~200 milliseconds as desired. For the second \n // batch of requests we serve the first 3 immediately because of \n // the burstable rate limiting, then serve the remaining 2 with \n // ~200ms delays each.\n}", "title": "" }, { "docid": "d28e76462983ad4ac4f6220478f441b7", "score": "0.5229261", "text": "func ScrapeAddress(address string) ([]string, []string) {\n\tpages, srcs := []string{}, []string{}\n\n\t// Instaniate the collector\n\tc := colly.NewCollector(\n\t\t// Limit to only the specific dom\n\t\tcolly.AllowedDomains(address, \"www.\"+address),\n\n\t\t// Limit depth so that only the page and links on that page are\n\t\t// visited in parallel\n\t\tcolly.MaxDepth(1),\n\t\tcolly.Async(true),\n\t)\n\n\t// Rate limit to prevent getting barred\n\t// Parallel limit to control simultaneous requests\n\tc.Limit(&colly.LimitRule{\n\t\tDomainGlob: \"*\",\n\t\t// Nothing seemed to happen here when I increased the number\n\t\tParallelism: 2,\n\t\tDelay: 1 * time.Second,\n\t\tRandomDelay: 1 * time.Second,\n\t})\n\n\t// Print before making a Request\n\tc.OnRequest(func(r *colly.Request) {\n\t\tf.Println(\"Visiting\", r.URL.String())\n\t})\n\n\t// Report found errors\n\tc.OnError(func(r *colly.Response, err error) {\n\t\tf.Println(\"Request URL:\", r.Request.URL, \"failed with response:\", r, \"\\nError:\", err)\n\t})\n\n\t// Get anything with a href\n\tc.OnHTML(\"a[href]\", func(e *colly.HTMLElement) {\n\t\tlink := e.Attr(\"href\")\n\n\t\tc.Visit(e.Request.AbsoluteURL(link))\n\n\t})\n\n\t// Get anything with a src attribute\n\tc.OnHTML(\"[src]\", func(e *colly.HTMLElement) {\n\t\tsrc := string(e.Attr(\"src\"))\n\t\t// Save asset\n\t\tif !inSlice(srcs, src) {\n\t\t\tsrcs = append(srcs, src)\n\t\t}\n\t})\n\n\t// When a response for a visit attempt is recieved\n\tc.OnResponse(func(r *colly.Response) {\n\t\tf.Println(\"Visited\", r.Request.URL)\n\t\tlink := string(r.Request.URL.String())\n\t\tif !inSlice(pages, link) {\n\t\t\tpages = append(pages, link)\n\t\t}\n\t})\n\n\tc.Visit(\"http://\" + address)\n\n\tc.Wait()\n\n\treturn pages, srcs\n}", "title": "" }, { "docid": "3e7655c58310d35e47dbc6786896d5a3", "score": "0.52261305", "text": "func main() {\n\t// limiting incoming requests by serving requests off the requests channel\n\trequests := make(chan int, 5)\n\tfor i := 1; i <= 5; i++ {\n\t\trequests <- i\n\t}\n\tclose(requests)\n\n\t// this channel will receive a value every 200 ms. This is the regulator for rate limiting\n\tlimiter := time.Tick(200 * time.Millisecond)\n\n\t// by blocking the receive on the limiter channel before serving each request, we're limited to 1 request every\n\t// 200ms\n\tfor req := range requests {\n\t\t<-limiter\n\t\tfmt.Println(\"request\", req, time.Now())\n\t}\n\n\t// this scheme is to allow short bursts of requests while preserving the overall rate limit. this is done by\n\t// buffering the limiter channel. the burstyLimiter channel will allow bursts of up to 3 events\n\tburstyLimiter := make(chan time.Time, 3)\n\n\t// filling up the channel to represent allowed bursting\n\tfor i := 0; i < 3; i++ {\n\t\tburstyLimiter <- time.Now()\n\t}\n\n\t// every 200 ms, adding a new value to burstyLimiter, up to its limit of 3\n\tgo func() {\n\t\tfor t := range time.Tick(200 * time.Millisecond) {\n\t\t\tburstyLimiter <- t\n\t\t}\n\t}()\n\n\t// simulating 5 additional requests - the first 3 will benefit from burst capacity\n\tburstyRequests := make(chan int, 5)\n\tfor i := 1; i <= 5; i++ {\n\t\tburstyRequests <- i\n\t}\n\n\tclose(burstyRequests)\n\tfor req := range burstyRequests {\n\t\t<-burstyLimiter\n\t\tfmt.Println(\"request\", req, time.Now())\n\t}\n}", "title": "" }, { "docid": "f2d7700af09f09f57e365ec5e92fc30c", "score": "0.52223897", "text": "func (ind *indeed) scrape(start int, ret chan SearchResult, wg *sync.WaitGroup) {\n\tvar waitGroup sync.WaitGroup\n\n\t// http request\n\turl := fmt.Sprintf(ind.Url+ind.Param, ind.keyword, start)\n\tdoc, err := getHTMLDocs(url)\n\tif err != nil {\n\t\tlg.Errorf(\"[scrape() for indeed] %s\", url)\n\t\tif wg != nil {\n\t\t\twg.Done()\n\t\t}\n\t\treturn\n\t}\n\n\t//debug HTML\n\t//if url == \"https://www.indeed.nl/vacatures?q=golang&start=0\"{\n\t//\tres, _ := doc.Find(\"body\").Html()\n\t//\tlg.Debug(\"[scrapeIndeed]\", res)\n\t//}\n\n\t// paging, call all existing pages by paging information\n\tif start == 0 {\n\t\tsearchCount := []int{}\n\t\tsearchDoc := doc.Find(\"#searchCount\").First()\n\t\ttmp := strings.Split(searchDoc.Text(), \" \")\n\t\tfor _, v := range tmp {\n\t\t\tif i, ok := strconv.Atoi(v); ok == nil {\n\t\t\t\tsearchCount = append(searchCount, i)\n\t\t\t}\n\t\t}\n\t\t//lg.Debug(\"[searchCount]\", searchCount)\n\t\t//[searchCount][1 201]\n\n\t\t// call left pages.\n\t\tif len(searchCount) == 2 {\n\t\t\tfor i := 10; i < searchCount[1]; i += 10 {\n\t\t\t\twaitGroup.Add(1)\n\t\t\t\tgo ind.scrape(i, ret, &waitGroup)\n\t\t\t}\n\t\t}\n\t}\n\n\t// parse html\n\ttitles := SearchResult{Country: ind.Country, BaseUrl: ind.Url}\n\tjobs := []Job{}\n\n\t//analyze title\n\tdoc.Find(\"h2.jobtitle a\").Each(func(_ int, s *goquery.Selection) {\n\t\t//link\n\t\tlink, _ := s.Attr(\"href\")\n\n\t\t//this emement may be changeble\n\t\tcompanyDoc := s.Parent().Next()\n\t\t//companyDoc := s.Parent().Next().Find(\"span\")\n\t\t//companyDoc := s.Parent().Next().Find(\"span\").First()\n\n\t\t//company\n\t\tcompany := getCompanyAndLocation(companyDoc.Text())\n\n\t\tif title, ok := s.Attr(\"title\"); ok {\n\t\t\tlevel := analyzeTitle(title, ind.keyword)\n\t\t\tif level != 0 {\n\t\t\t\tjobs = append(jobs, Job{Title: title, Link: link, Company: company, MachingLevel: level})\n\t\t\t}\n\t\t}\n\t})\n\ttitles.Jobs = jobs\n\tret <- titles\n\n\t//wait until all called\n\tif start == 0 {\n\t\twaitGroup.Wait()\n\t} else {\n\t\twg.Done()\n\t}\n}", "title": "" }, { "docid": "ee6c8396a1df448b477323542e738925", "score": "0.52219594", "text": "func Test7() {\n\t//Get beverages in parallel to random outlets.\n\t// In between add some ingredients\n\t// and again request more beverages\n\n\tfor i := 0; i < 10; i++ {\n\t\ttime.Sleep(500 * time.Millisecond)\n\t\tgo func(i int) {\n\t\t\thandler.RequestBeverages(i, \"latte\")\n\t\t}(i)\n\t}\n\n\thandler.AddIngredient(\"hot_water\", 200)\n\thandler.RequestBeverages(0, \"latte\")\n\thandler.RequestBeverages(0, \"latte\")\n}", "title": "" }, { "docid": "c94b16e415829417697deb518c4c5726", "score": "0.52217185", "text": "func main() {\n\t//http://www.angelfire.com/extreme4/safer_sephiroth/EVERY_WORD_EVER.htm\n\t//http://www.angelfire.com/extreme4/safer_sephiroth/EVERY_WORD_EVER.htm\n\t//http://www.mhhe.com/mayfieldpub/maner/resources/actb.txt\n\t//http://www.mhhe.com/mayfieldpub/maner/resources/actb.txt\n\n\t//response,error := http.Get(\"http://www.mhhe.com/mayfieldpub/maner/resources/actb.txt\")\n\t//http://www-personal.umich.edu/~jlawler/wordlist\n//\tresponse, error := http.Get(\"http://www-personal.umich.edu/~jlawler/wordlist\")\n\n//http://25.io/toau/audio/sample.txt\n\n//response, error := http.Get(\"https://ebooks.adelaide.edu.au/m/melville/herman/m53m/chapter10.html\")\n//https://ocw.mit.edu/ans7870/6/6.006/s08/lecturenotes/files/t8.shakespeare.txt\n//https://ocw.mit.edu/ans7870/6/6.006/s08/lecturenotes/files/t8.shakespeare.txt\n//response, error := http.Get(\"http://25.io/toau/audio/sample.txt\")\nresponse, error := http.Get(\"https://ocw.mit.edu/ans7870/6/6.006/s08/lecturenotes/files/t8.shakespeare.txt\")\n\tif error != nil {\n\t\tlog.Fatalln(error)\n\t}\n\n//scan the page\nscanner := bufio.NewScanner(response.Body)\ndefer response.Body.Close()\n\n//set the split function for the scanning operation\nscanner.Split(bufio.ScanWords)\n\n//create slice to hold counts\nbuckets := make([]int,200)\n//loop over the words\nfor scanner.Scan(){\n\tn:= HashBucket(scanner.Text())\n\tbuckets[n]++\n}\n\n/*\nas can see, for hashing, we need a even distribution to be EFFICIENT\n\n */\nfmt.Println(buckets[65:123])\n\nfmt.Println(\"##############################\")\nfor i:=28; i <=126; i++{\n\tfmt.Printf(\"%v - %c - %v \\n\",i,i,buckets[i])\n}\n}", "title": "" }, { "docid": "87fd2ba403fe30b61b0b31a6f1827cc8", "score": "0.5186459", "text": "func fetchURLB(w http.ResponseWriter, r *http.Request , fURL string) (bodyBytes []byte, err error) {\n //log.Printf(\"fetchURLB()\")\n if fURL == \"\" {\n return nil, fmt.Errorf(\"empty url\")\n }\n //log.Printf(\"fetchURLB()\")\n //log.Printf(\"fURL: %v\", fURL)\n ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\n defer cancel()\n req, err := http.NewRequest(\"GET\", fURL, nil)\n if err != nil {\n //log.Printf(\"ERROR: Request error: %v\", err)\n }\n //log.Printf(\"req: %v\", req)\n values := url.Values{\"test\":{\"1\"},}\n thisLength := strconv.Itoa(len(values))\n req.Header.Set(\"Content-Length\", thisLength)\n req.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n //response, err := client.Do(req)\n response, err := http.DefaultClient.Do(req.WithContext(ctx))\n if err != nil {\n log.Fatalf(\"HTTP request failed: %v\", err)\n }\n defer response.Body.Close()\n //log.Printf(\"response: %v\", response)\n bodyBytes, err = ioutil.ReadAll(response.Body)\n bodyString := string(bodyBytes)\n //log.Printf(\"len(bodyString): %v\", len(bodyString))\n //log.Printf(\"bodyString: %v\", bodyString)\n\tulapphDebug(w,r, \"info\", fmt.Sprintf(\"len(bodyString): %v\", len(bodyString)))\n\treturn bodyBytes, err\n}", "title": "" }, { "docid": "f4746edfa07ec96562672c2c2d12af22", "score": "0.5180761", "text": "func CrawlWebpage(wg *sync.WaitGroup, sitesChannel chan string, crawedLinksChannel chan string, pendingCountChannel chan int) {\n\n\tcrawledSites := 0\n\n\tfor webpageURL := range sitesChannel {\n\t\textractContent(webpageURL, crawedLinksChannel)\n\t\tpendingCountChannel <- -1\n\t\tcrawledSites++\n\t}\n\n\tfmt.Println(\"Crawled \", crawledSites, \" web pages.\")\n\n\twg.Done()\n}", "title": "" }, { "docid": "39e77c9725c5f09d2be2a3fdd8f4410a", "score": "0.5162576", "text": "func CrawlURLs(urls map[string]struct{}, log *logger, httpClient *httpClient,\n crawledURLs *safeMap, maxURLCrawls int, validation bool) {\n // Option 2: Uncomment this to keep the crawl organized in terms of page wise crawling\n //urlMaps := make([]map[string]struct{}, 0)\n for url, _ := range urls {\n crawledURLs.mutex.Lock()\n _, ok := crawledURLs.m[url]\n crawledURLs.mutex.Unlock()\n if ok {\n continue\n }\n\n extractedURLs := ReadAndExtractURLs(url, httpClient)\n\n crawledURLs.mutex.Lock()\n crawledURLs.m[url] = struct{}{}\n\n // Check if the stopping condition has been met\n if len(crawledURLs.m) > maxURLCrawls {\n //for k, _ := range crawledURLs.m {\n // fmt.Println(k)\n //}\n fmt.Println(\"length of map: \",len(crawledURLs.m))\n crawledURLs.mutex.Unlock()\n return\n }\n\n crawledURLs.mutex.Unlock()\n\n log.SafePrint(url, extractedURLs, validation)\n\n // Option 1: Comment this to keep the crawl organized in terms of page wise crawling\n go CrawlURLs(extractedURLs, log, httpClient, crawledURLs, maxURLCrawls, validation)\n\n // Option 2:\n //urlMaps = append(urlMaps, crawledURLs)\n }\n\n // Option 2:\n //for _, m := range urlMaps {\n // CrawlURLs(m, urlsCrawled)\n //}\n}", "title": "" }, { "docid": "bca9b942141f114c4bca7e2ae1260473", "score": "0.5159227", "text": "func Paginate(scan interface{}, uri string, nPages int) error {\n\tt := reflect.TypeOf(scan)\n\tif t.Kind() != reflect.Ptr {\n\t\tpanic(\"hubhub: scan is not a pointer\")\n\t}\n\tt = t.Elem()\n\tif t.Kind() != reflect.Slice {\n\t\tpanic(\"hubhub: scan is not a slice\")\n\t}\n\n\tvar (\n\t\tslice = reflect.Indirect(reflect.ValueOf(scan))\n\t\terrs []error\n\t\tlock sync.Mutex\n\t\twg sync.WaitGroup\n\t)\n\n\tu, err := url.Parse(uri)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tgetPage := func(i int) bool {\n\t\tif nPages > 0 {\n\t\t\tdefer wg.Done()\n\t\t}\n\n\t\ts := reflect.New(t).Interface()\n\n\t\tu.Query().Set(\"page\", strconv.FormatInt(int64(i), 10))\n\t\t_, err = Request(&s, \"GET\", u.String(), nil)\n\t\tif err != nil {\n\t\t\tlock.Lock()\n\t\t\terrs = append(errs, err)\n\t\t\tlock.Unlock()\n\n\t\t\tif nPages == 0 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\n\t\tv := reflect.ValueOf(s).Elem()\n\t\tif v.Len() == 0 {\n\t\t\treturn true\n\t\t}\n\n\t\tlock.Lock()\n\t\tslice.Set(reflect.AppendSlice(slice, v))\n\t\tlock.Unlock()\n\t\treturn false\n\t}\n\n\tif nPages > 0 {\n\t\twg.Add(nPages)\n\t}\n\n\tl := nPages\n\tif l == 0 {\n\t\tl = 999\n\t}\n\tfor i := 1; i <= l; i++ {\n\t\tif nPages == 0 {\n\t\t\tlastPage := getPage(i)\n\t\t\tif lastPage {\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else {\n\t\t\tgo getPage(i)\n\t\t}\n\t}\n\tif nPages > 0 {\n\t\twg.Wait()\n\t}\n\n\tif len(errs) > 0 {\n\t\treturn fmt.Errorf(\"%s\", errs)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "022e309f0538a4190ae1f65ca7776e7a", "score": "0.51590943", "text": "func main() {\n\tstartTime := time.Now()\n\tch := make(chan string)\n\tfor _, url := range os.Args[1:] {\n\t\tgo fetch(url, ch)\n\t}\n\n\tfor range os.Args[1:] {\n\t\tfmt.Println(<-ch)\n\t}\n\tcostTime := time.Since(startTime).Seconds()\n\tfmt.Printf(\"%.2fs elasped\\n\", costTime)\n}", "title": "" }, { "docid": "191e81dded646711205a8ef5dd87e323", "score": "0.51520216", "text": "func downloadPagesContent(chunkSize int, rescan bool) {\n\n\tvar pages = make(map[int]string)\n\tif rescan {\n\t\tpages = database.RetrieveAllPages()\n\t} else {\n\t\tpages = database.RetrievePagesWithoutContent()\n\t}\n\n\tif len(pages) == 0 {\n\t\tlog.Warn(\"There are no pages to check\")\n\t\tos.Exit(1)\n\t}\n\n\tlog.Info(\"Downloading Pages Content\", \"pages\", len(pages))\n\n\tpagesToCheck := database.PagesToStruct(pages)\n\n\tchunks := utils.ChunkifyPages(pagesToCheck, chunkSize)\n\n\tfor _, chunk := range chunks {\n\n\t\tresults := downloader.DownloadPageContentChunk(chunk)\n\n\t\tdatabase.BulkUpdatePagesContent(results)\n\t}\n\n}", "title": "" }, { "docid": "1d4302b5abc7f05c4435d834204bd047", "score": "0.5118521", "text": "func ParseCollection(pages []requester.Page, instr *instrumentator.Instr) []Page {\n\tvar mutex = &sync.Mutex{}\n\tvar wg sync.WaitGroup\n\tvar tokenizedPages []Page\n\n\t// dynamically determine the worker pool size, we'll either set a default or\n\t// use a smaller value if the number of tasks is smaller than the default.\n\ttoProcess := len(pages)\n\tworkerPool := defaultWorkerPool\n\tif toProcess < defaultWorkerPool {\n\t\tworkerPool = toProcess\n\t}\n\n\tstartTime := time.Now()\n\ttasks := make(chan requester.Page, workerPool)\n\n\t// spin up our worker pool as goroutines awaiting tasks to be processed\n\tfor i := 0; i < workerPool; i++ {\n\t\twg.Add(1)\n\n\t\tgo func(i int) {\n\t\t\tdefer wg.Done()\n\n\t\t\tfor page := range tasks {\n\t\t\t\ttokenizedPage := Parse(page, instr)\n\n\t\t\t\t// we use a mutex to ensure thread safety, not only for the correctness\n\t\t\t\t// of the program but also because the Go language can trigger a panic!\n\t\t\t\tmutex.Lock()\n\t\t\t\ttokenizedPages = append(tokenizedPages, tokenizedPage)\n\t\t\t\tmutex.Unlock()\n\t\t\t}\n\t\t}(i)\n\t}\n\n\tfor _, page := range pages {\n\t\tif page.Status != 200 {\n\t\t\tinstr.Logger.Debug(\"non 200 page:\", page.URL)\n\t\t\tcontinue\n\t\t}\n\t\ttasks <- page\n\t}\n\n\tclose(tasks)\n\n\twg.Wait()\n\tinstr.Logger.Debug(\"time spent parsing:\", time.Since(startTime))\n\n\treturn tokenizedPages\n}", "title": "" }, { "docid": "49f5742edebab71e921fd3665c8ffde7", "score": "0.5107915", "text": "func Test2() {\n\t// get some beverages from different outlets in parallel\n\tgo func() {\n\t\thandler.RequestBeverages(0, \"hot_tea\")\n\t}()\n\n\tgo func() {\n\t\thandler.RequestBeverages(1, \"hot_coffee\")\n\t}()\n\n\tgo func() {\n\t\thandler.RequestBeverages(2, \"black_tea\")\n\t}()\n\n\tgo func() {\n\t\thandler.RequestBeverages(6, \"green_tea\")\n\t}()\n\n\tgo func() {\n\t\thandler.RequestBeverages(8, \"hot_coffee\")\n\t}()\n\ttime.Sleep(5 * time.Second)\n}", "title": "" }, { "docid": "558632bc2457ce3a4aaa1e99009d801d", "score": "0.50835913", "text": "func httpFetch(\n\tclient HttpClient,\n\taddress url.URL,\n\toutput chan HtmlPage,\n\twg *sync.WaitGroup,\n) {\n\tdefer wg.Done()\n\n\tlog.Debug(\"Hitting network for \", address)\n\n\t// isolated in order to unify calls to the chan and to eventually\n\t// implement retries\n\tfetch := func() ([]byte, error) {\n\t\tresp, err := client.Get(address)\n\t\tif err != nil {\n\t\t\treturn make([]byte, 0), err\n\t\t}\n\t\t// close the response once we've read and published it\n\t\tdefer resp.Body.Close()\n\n\t\tbody, err := ioutil.ReadAll(resp.Body)\n\t\tif err != nil {\n\t\t\treturn make([]byte, 0), err\n\t\t}\n\n\t\treturn body, nil\n\t}\n\n\thtml, err := fetch()\n\tif err != nil {\n\t\t// currently in case of error we just skip the page\n\t\t// TODO wait & retry\n\t\tlog.Error(\"Could not read \", address.String(), err)\n\t}\n\n\tlog.Debug(\"Page retrieved \", address)\n\toutput <- HtmlPage{ address, html }\n}", "title": "" }, { "docid": "ff4a4d811ca7a8b47ead3587da0f7207", "score": "0.5074482", "text": "func httpGetRequest(url string, ch chan<- string, iteration int, httpBody string, insecure string) {\n\n\t//if insecure flag is true skip ssl verification\n\tif strings.Compare(insecure, \"true\") == 0 {\n\t\thttp.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}\n\t}\n\n\t//Clock the start and finish of each request\n\tstart := time.Now()\n\n\t//default timeout of 5 seconds\n\tdefaultTimeout, _ := strconv.Atoi(GetEnv(\"DEFAULT_TIMEOUT\", \"5\"))\n\tvar netClient = &http.Client{\n\t\tTimeout: time.Second * time.Duration(defaultTimeout),\n\t}\n\t/* #nosec G107 */\n\tresp, err := netClient.Get(url)\n\t//get time stamp of when work completed\n\ttimeStamp := getTimeStamp()\n\n\tsecs := time.Since(start).Seconds()\n\n\tif err != nil {\n\t\tprint(err.Error())\n\t} else {\n\t\tdefer resp.Body.Close()\n\n\t\tbodyBytes, _ := ioutil.ReadAll(resp.Body)\n\t\tbodyString := string(bodyBytes)\n\n\t\thttpBodyStr := httpBody\n\t\tif strings.Compare(httpBodyStr, \"true\") == 0 {\n\t\t\tch <- fmt.Sprintf(\"test: %d, time spent: %.2f seconds, result: %s, http output: %s\", iteration, secs, resp.Status, bodyString)\n\t\t} else {\n\t\t\t//convert secs to type string and then prep result in json format\n\t\t\tsecsStr := fmt.Sprintf(\"%f\", secs)\n\t\t\tresult := `{\"level\": \"INFO\", \"timeStamp\": \"` + timeStamp + `\", \"messageType\": \"test\", \"test\": \"` + strconv.Itoa(iteration) +\n\t\t\t\t`\", \"totalTime\": \"` + secsStr + `\", \"statusCode\": \"` + resp.Status + `\"}`\n\t\t\tch <- result\n\t\t}\n\n\t}\n\n}", "title": "" }, { "docid": "db6bcd88cad67a32f60a4c1fcf9c24cf", "score": "0.50690514", "text": "func webSocketResponseFreqs(t *testing.T, clients *test.Clients, url string, numReqs int) (map[string]int, error) {\n\tt.Helper()\n\tvar g errgroup.Group\n\trespCh := make(chan string, numReqs)\n\tresps := map[string]int{}\n\tfor i := 0; i < numReqs; i++ {\n\t\tg.Go(func() error {\n\t\t\t// Establish the websocket connection. Since they are persistent\n\t\t\t// we can't reuse.\n\t\t\tconn, err := connect(t, clients, url, NoDelay)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tdefer conn.Close()\n\n\t\t\t// Send a message.\n\t\t\tt.Logf(\"Sending message %q to server.\", message)\n\t\t\tif err = conn.WriteMessage(websocket.TextMessage, []byte(message)); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tt.Log(\"Message sent.\")\n\n\t\t\t// Read back the echoed message and put it into the channel.\n\t\t\t_, recv, err := conn.ReadMessage()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\trespCh <- string(recv)\n\t\t\treturn nil\n\t\t})\n\t}\n\tif err := g.Wait(); err != nil {\n\t\treturn nil, err\n\t}\n\tclose(respCh)\n\tfor r := range respCh {\n\t\tresps[r]++\n\t}\n\n\treturn resps, nil\n}", "title": "" }, { "docid": "3e5235dcee56c5a97704a1d8eade00a0", "score": "0.5068588", "text": "func contentsCrawler(wg *sync.WaitGroup, maxPage int, baseURL string) {\n\tqueue := make(chan string, QueueSize)\n\terrCh := make(chan error, QueueSize)\n\tgo func() {\n\t\tvar wg sync.WaitGroup\n\t\tfor i := 0; i < MaxNewContentsPageNum; i++ {\n\t\t\twg.Add(1)\n\t\t\tgo NewContentsPageCrawler(&wg, i, queue, errCh)\n\t\t}\n\t\twg.Wait()\n\t\tclose(queue)\n\t}()\n\nLOOP:\n\tfor {\n\t\tselect {\n\t\tcase s, ok := <-queue:\n\t\t\tif !ok {\n\t\t\t\tbreak LOOP\n\t\t\t}\n\t\t\tp := baseURL + s\n\t\t\tlog.Println(\"Downlaoding from thread:\", p)\n\t\t\tDownloadFile(p, SaveDir)\n\t\t\ttime.Sleep(DownloadInterval)\n\t\tcase err := <-errCh:\n\t\t\tlog.Println(\"Error:\", err)\n\t\t}\n\t}\n\twg.Done()\n}", "title": "" }, { "docid": "bf59c4aeeadf48337bf771bcd2839792", "score": "0.50679773", "text": "func (this *Site) ReadAllPages() {\n\tfor i := 0; i < this.NumOfPages; i++ {\n\t\ttime.Sleep(1000 * time.Millisecond) //wait 1 sec\n\t\tthis.CurrentPage++\n\t\t//fmt.Println(this.Name, \"reading page\", this.CurrentPage, \"out of\", this.NumOfPages)\n\t}\n}", "title": "" }, { "docid": "f70e21814de6daabae558bea198bd99b", "score": "0.50475377", "text": "func (a *shufersalScraper) getPage(n int) ([]byte, error) {\n\tres, err := httpGet(fmt.Sprintf(\"http://prices.shufersal.co.il/?page=%d\",\n\t\tn), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer res.Body.Close()\n\tif res.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"Bad response status: %s\", res.Status)\n\t}\n\n\treturn ioutil.ReadAll(res.Body)\n}", "title": "" }, { "docid": "0e23029eeb66a6db5eb9831c83e0c990", "score": "0.503786", "text": "func work(w http.ResponseWriter, req *http.Request) {\n\tlog.Print(\"starting request…\")\n\trand.Seed(time.Now().UnixNano())\n\tsleepTimeMillis := rand.Intn(5000) + 5000\n\ttime.Sleep(time.Duration(sleepTimeMillis) * time.Millisecond)\n\tfmt.Fprintf(w, \"that took %d ms\", sleepTimeMillis)\n\tlog.Printf(\"request finished in %d ms\", sleepTimeMillis)\n}", "title": "" }, { "docid": "11a7db8b5bf0e12eb294fccfd23d0513", "score": "0.500314", "text": "func httpLoadGen(svcEndpoint string, rps float64) {\n\tif rps <= 0 || svcEndpoint == \"\" {\n\t\treturn\n\t}\n\n\tfmt.Printf(\"HTTP request will be sent to service %s with QPS %f\", svcEndpoint, rps)\n\n\trequestTicker := time.NewTicker(time.Duration(float64(time.Second) / rps))\n\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-requestTicker.C:\n\t\t\t\tgo sendRequest(svcEndpoint)\n\t\t\t}\n\t\t}\n\t}()\n\n}", "title": "" }, { "docid": "e5eb0030cfba3cf552fef419431e0238", "score": "0.5001486", "text": "func testServiceSpeed(service gas.Service, n int, randomData [][]byte) (writeDuration, readDuration time.Duration, err error) {\n\tif n < 500 {\n\t\terr = fmt.Errorf(\"That test isn't worth running: n must be >= 500.\")\n\t\treturn\n\t}\n\n\t// s := len(randomData[0])\n\n\tb, err := service.GetBucket(\"test1\")\n\n\tif err != nil {\n\t\treturn\n\t}\n\n\tb.RemoveAllItems()\n\n\t// r = Number of items we will fetch at a time in read tests.\n\tr := n / 10\n\n\tif r > 500 {\n\t\tr = 500\n\t}\n\n\t// Number of fetch tests to run ( x2 - first and last )\n\tq := 1000\n\n\tstartWriteTime := time.Now()\n\tfor i := 0; i < n; i++ {\n\t\tb.PushItem(randomData[rand.Intn(len(randomData))])\n\t}\n\twriteDuration = time.Since(startWriteTime)\n\n\tstartReadTime := time.Now()\n\tfor i := 0; i < q; i++ {\n\t\t// Offset\n\t\to := i * (n / q)\n\t\t_, _ = b.GetFirstItems(r, o)\n\t\t_, _ = b.GetLastItems(r, o)\n\t}\n\n\treadDuration = time.Since(startReadTime)\n\n\tb.RemoveAllItems()\n\n\treturn\n}", "title": "" }, { "docid": "f9d375b0003d9f7503be7ae0e6c22d82", "score": "0.49986497", "text": "func GetNumberOfPages() int {\n\treturn rand.Intn(5) + 1\n}", "title": "" }, { "docid": "598a3a2d8f4acb3db4984f7f71810885", "score": "0.4985848", "text": "func getPage(url string) (int, error) {\n\tresp, err := http.Get(url)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tdefer resp.Body.Close()\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn len(body), nil\n}", "title": "" }, { "docid": "76325bc17f4477524b6396db75d260e2", "score": "0.4977234", "text": "func Get(urls []*url.URL, concurrencyLimit int) []Result {\n\n\t// this buffered channel will block at the concurrency limit\n\tsemaphoreChan := make(chan struct{}, concurrencyLimit)\n\n\t// this channel will not block and collect the http request results\n\tresultsChan := make(chan *Result)\n\n\t// make sure we close these channels when we're done with them\n\tdefer func() {\n\t\tclose(semaphoreChan)\n\t\tclose(resultsChan)\n\t}()\n\n\t// keen an Index and loop through every url we will send a request to\n\tfor i, u := range urls {\n\n\t\t// start a go routine with the Index and url in a closure\n\t\tgo func(i int, u *url.URL) {\n\n\t\t\t// this sends an empty struct into the semaphoreChan which\n\t\t\t// is basically saying add one to the limit, but when the\n\t\t\t// limit has been reached block until there is room\n\t\t\tsemaphoreChan <- struct{}{}\n\n\t\t\t// send the request and put the response in a result struct\n\t\t\t// along with the Index so we can sort them later along with\n\t\t\t// any error that might have occoured\n\t\t\tres, err := http.Get(u.String())\n\t\t\tresult := &Result{i, res, err}\n\n\t\t\t// now we can send the result struct through the resultsChan\n\t\t\tresultsChan <- result\n\n\t\t\t// once we're done it's we read from the semaphoreChan which\n\t\t\t// has the effect of removing one from the limit and allowing\n\t\t\t// another goroutine to start\n\t\t\t<-semaphoreChan\n\n\t\t}(i, u)\n\t}\n\n\t// make a slice to hold the results we're expecting\n\tvar results []Result\n\n\t// start listening for any results over the resultsChan\n\t// once we get a result append it to the result slice\n\tfor {\n\t\tresult := <-resultsChan\n\t\tresults = append(results, *result)\n\n\t\t// if we've reached the expected amount of urls then stop\n\t\tif len(results) == len(urls) {\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// let's sort these results real quick\n\tsort.Slice(results, func(i, j int) bool {\n\t\treturn results[i].Index < results[j].Index\n\t})\n\n\t// now we're done we return the results\n\treturn results\n}", "title": "" }, { "docid": "e9fca2c59b1a17552a1cdaa4b369fe71", "score": "0.496633", "text": "func (w *Wal) requestPages(data []byte) *page {\n\t// Calculate the number of pages needed for storing the data\n\tnumPages := uint64(len(data) / maxPayloadSize)\n\tif len(data)%maxPayloadSize != 0 {\n\t\tnumPages++\n\t}\n\n\tw.mu.Lock()\n\tdefer w.mu.Unlock()\n\n\tif numPages > uint64(len(w.availablePages)) {\n\t\tw.allocateNewPages(numPages - uint64(len(w.availablePages)))\n\t}\n\tdataPages := w.availablePages[:numPages] // page used to save data\n\tw.availablePages = w.availablePages[numPages:] // rest of the pages\n\n\t// Write data to dataPages\n\tbuf := bytes.NewBuffer(data)\n\tpages := make([]page, numPages)\n\tfor i := range pages {\n\t\tif uint64(i+1) < numPages {\n\t\t\tpages[i].nextPage = &pages[i+1]\n\t\t}\n\t\tpages[i].offset = dataPages[i]\n\t\tpages[i].payload = buf.Next(maxPayloadSize)\n\t}\n\treturn &pages[0]\n}", "title": "" }, { "docid": "6bdc85b9d2c1db7e29e512653e32a315", "score": "0.49663174", "text": "func simulate(\n processing_ns int,\n ctxt_switch_ns int,\n tenants int,\n use_zipf bool,\n num_cores int) int {\n\n cores := make([]Core, num_cores)\n\n for i := 0; i < num_cores; i++ {\n cores[i].initialize(processing_ns, ctxt_switch_ns)\n }\n\n // Simulate the key-value service for 20 million requests.\n requests := 20 * 1000000\n\n // The total amount of time the system takes to service all\n // requests.\n total_ns := 0\n\n // Setup tenant id generator.\n source := rand.NewSource(0)\n rnd := rand.New(source)\n zipf := rand.NewZipf(rnd, 1.01, 1.0, uint64(tenants-1))\n\n // Service requests FIFO in groups of size num_cores. Requests inside a\n // group are effectively serviced in parallel. This is not batching in the\n // conventional sense because the network and dispatch are not simulated.\n for r := 0; r < requests; r += num_cores {\n // Initially, all cores are free to service requests.\n freeCores := make([]int, num_cores)\n\n // Assign each request to a core, and process it.\n for request := 0; request < num_cores; request++ {\n // Pick the tenant sending the request.\n tenant := 0\n if use_zipf {\n tenant = int(zipf.Uint64())\n } else {\n tenant = rnd.Int() % tenants\n }\n\n // Assign this request to a free core.\n core := -1\n for i := 0; i < num_cores; i++ {\n // If there is a free core that last executed a request from\n // the same tenant, then chose it.\n if freeCores[i] == 0 && cores[i].last_tenant == tenant {\n core = i\n break\n }\n\n if freeCores[i] == 0 && core == -1 {\n core = i\n }\n }\n // The assigned core is now busy.\n freeCores[core] = 1\n\n // Process the request.\n cores[core].process(tenant)\n }\n }\n\n // Find the total time taken to process all requests.\n for i := 0; i < num_cores; i++ {\n if total_ns < cores[i].total_ns {\n total_ns = cores[i].total_ns\n }\n }\n\n return int(float64(requests) / (float64(total_ns) / 1e9))\n}", "title": "" }, { "docid": "dc12d2defb99e985c25313bc89bd686a", "score": "0.49629134", "text": "func request(id int) {\n\ti := 0\n\tfor true {\n\t\ti++\n\t\tt0 := time.Now()\n\t\tr, err := http.Get(url)\n\t\tt1 := time.Now()\n\n\t\trs := Summary{\n\t\t\trequesterId: id,\n\t\t\tcount: i,\n\t\t\tresponseTime: t1.Sub(t0).Seconds() * 1000,\n\t\t}\n\t\tif err == nil {\n\t\t\trs.statusCode = r.StatusCode\n\t\t\trs.cacheStatus = r.Header[\"X-Cache-Status\"][0]\n\t\t\trs.contentLength = r.ContentLength\n\t\t\tr.Body.Close()\n\t\t} else {\n\t\t\t// fmt.Println(err.Error())\n\t\t}\n\t\tsummaryChannel <- rs\n\t\ttime.Sleep(request_interval)\n\t}\n}", "title": "" }, { "docid": "ebec8cdc57947353e072e496c785f945", "score": "0.496077", "text": "func main() {\n\t// flag.Parse()\n\tvar wg sync.WaitGroup\n\tstart := time.Now()\n\tfor i := 0; i < 200; i++ {\n\t\twg.Add(1)\n\t\tclient6(&wg, \"POST\", \"/payment\")\n\t}\n\twg.Wait()\n\t// time.Sleep(100 * time.Millisecond)\n\tt := time.Since(start)\n\tfmt.Printf(\"\\n \\nTotal TIME: %v\\n\", t)\n\tfmt.Printf(\"Number Response: %d\\n\", count_Res)\n\tfmt.Printf(\"Number fail: %d\\n\", count_Fail)\n\ttt := float64(t) / 1e6\n\trate := float64(count_Res) / (tt / 1000)\n\tfmt.Printf(\"Rate per Sec: %f\", rate)\n}", "title": "" }, { "docid": "b988445174f7264c7390a0650058e61c", "score": "0.4941379", "text": "func (this *HttpDownloader)printSize() {\n\tfor {\n\t\ttime.Sleep(time.Second)\n\t\tif this.m_finishedThread == this.m_threadNum {\n\t\t\tlog.Println(\"process: \", \"finish\")\n\t\t\treturn\n\t\t} else {\n\t\t\tlog.Println(\"process: \", this.m_downloadedSize, \"/\", this.m_contentLength, \"(bytes)\")\n\t\t}\n\t}\n}", "title": "" }, { "docid": "3516bf1a2a71cb7d848f3c61b341b235", "score": "0.492981", "text": "func runLoadBalancer(nWorkers int, nReq int){\n fmt.Println(\"Running load balancer program\")\n\n // Create channels for creating\n // Requests and Responses\n req := make(chan Work)\n res := make(chan Work)\n\n // Generate workers\n for i := 0; i < nWorkers; i++{\n go worker(req, res, i)\n }\n\n // Generate 100 requests\n go generateReq(req, nReq)\n\n // Process requests\n processRes(res, nReq)\n}", "title": "" }, { "docid": "eaf6d8064fd91d4c1c48620e4266480b", "score": "0.49224532", "text": "func geturl(url string, count int)(res string){\n\ti:=0; e:=0;\n\tvar resp *http.Response;\n\tvar err error;\n\t\n\tif count < 1 {count = 1}\n\tfor(i < count){\n\t\ti++\n\t\tfmt.Printf(\"[geturl(1)] - GET URL: %s\\n\",url)\n\t\tresp, err = http.Get(url)\n\t\tif err != nil {\n\t\t\te++\n\t\t\tfmt.Printf(\"[geturl(2)] - Error GETTING URL: %s\\n\",url)\n\t\t\tcontinue\n\t\t}else {\n\t\t\tbreak\n\t\t}\n\t}\n\tif e >= count {\n\t\tfmt.Printf(\"[geturl(3)] - IMPOSSIBLE GETTING URL(SERVER DOWN): %s\\n\",url)\n\t\tres = \"\"\t\n\t}else{\n\t\tbody, _ := ioutil.ReadAll(resp.Body)\n\t\tres = string(body)\n\t\tresp.Body.Close()\n\t\tif strings.Contains(res,\"</\") || strings.Contains(res,\"404\") {\n\t\t\tfmt.Printf(\"[geturl(5)] - NO EXISTE URL(SERVER UP): %s\\n\",url) \n\t\t\tres = \"\" \n\t\t}else{\n\t\t\tfmt.Printf(\"[geturl(4)] - URL OK %s\\n\",url)\n\t\t}\n\t}\n\treturn res\n}", "title": "" }, { "docid": "5bd6285219d1bd4a5a0d5d1c10914131", "score": "0.4915333", "text": "func (sof *stackoverflow) scrape(start int, ret chan SearchResult, wg *sync.WaitGroup) {\n\tvar waitGroup sync.WaitGroup\n\n\t///jobs/developer-jobs-using-go?pg=2\n\turl := sof.Url + sof.Param\n\tif start != 0 {\n\t\turl = fmt.Sprintf(\"%s?pg=%d\", url, start)\n\t}\n\t//lg.Debug(url)\n\n\t// get body\n\t//doc, err := getHTMLDocs(url)\n\tdoc, err := getHTMLDocsWithCookie(url, stackoverflowCookie)\n\tif err != nil {\n\t\tlg.Errorf(\"[scrape() for stackoverflow]\")\n\t\tif wg != nil {\n\t\t\twg.Done()\n\t\t}\n\t\treturn\n\t}\n\n\t//debug HTML\n\t//res, _ := doc.Find(\"body\").Html()\n\t//lg.Debug(\"[scrape for stackoverflow]\", res)\n\n\t//paging\n\tif start == 0 {\n\t\tsearchCount := []int{}\n\t\tlinkDoc := doc.Find(\"div.pagination a\").First()\n\t\tpage, _ := linkDoc.Attr(\"title\") //page 1 of 12\n\t\ttmp := strings.Split(page, \" \")\n\t\tfor _, v := range tmp {\n\t\t\tif i, ok := strconv.Atoi(v); ok == nil {\n\t\t\t\tsearchCount = append(searchCount, i)\n\t\t\t}\n\t\t}\n\n\t\t//page 1 of 3\n\t\t//lg.Debug(\"[searchCount]\", searchCount)\n\t\t//[1 3]\n\n\t\t// call left pages.\n\t\tif len(searchCount) == 2 {\n\t\t\tfor i := 2; i <= searchCount[1]; i++ {\n\t\t\t\twaitGroup.Add(1)\n\t\t\t\tgo sof.scrape(i, ret, &waitGroup)\n\t\t\t}\n\t\t}\n\t}\n\n\tjobs := []Job{}\n\n\t//analyze title\n\tdoc.Find(\".-job-summary\").Each(func(_ int, s *goquery.Selection) {\n\n\t\t//title object\n\t\ttitleDoc := s.Find(\".-title h2.job-details__spaced a\").First()\n\n\t\t//title\n\t\ttitle := titleDoc.Text()\n\t\t//lg.Debug(title)\n\n\t\t//link\n\t\tlink, _ := titleDoc.Attr(\"href\")\n\t\t//lg.Debug(link)\n\n\t\t//company\n\t\tcompanyDoc := s.Find(\".-company span\")\n\t\tcompany := companyDoc.First().Text()\n\t\tcompany = strings.Trim(company, \" \\n\")\n\t\t//lg.Debug(company)\n\n\t\t//location\n\t\tlocation := companyDoc.First().Next().Text()\n\t\tif len(strings.Split(location, \"-\")) == 2 {\n\t\t\tlocation = strings.Split(location, \"-\")[1]\n\t\t}\n\t\tlocation = strings.Trim(location, \" \\n\")\n\t\t//lg.Debug(location)\n\n\t\tlevel := analyzeTitle(title, sof.keyword)\n\t\tif level != 0 {\n\t\t\tjobs = append(jobs, Job{Title: title, Link: link, Company: company, City: location, MachingLevel: level})\n\t\t}\n\t})\n\n\t//deliver by country\n\tif len(jobs) != 0 {\n\t\tsendJobs(jobs, sof.Url, ret)\n\t}\n\n\t//wait until all called\n\tif start == 0 {\n\t\twaitGroup.Wait()\n\t} else {\n\t\twg.Done()\n\t}\n}", "title": "" }, { "docid": "22cdc0415306d402e84a428393590391", "score": "0.49059758", "text": "func Page(w http.ResponseWriter, r *http.Request) {\n\t//renders the page\n\trenderTemplate(w, formatJson())\n\t//prints to console which API key is being used, #4 is the last one\n\tfmt.Printf(\"Using API Key #%d\\n\", GeoKeysUsed+1)\n\t//sleeps for updatefrequency\n\ttime.Sleep(time.Second * time.Duration(updateFrequency))\n\thttp.ServeFile(w, r, \"empty.html\")\n\tPage(w, r)\n}", "title": "" }, { "docid": "7250f14ceaf4f656e939ec0c1ec519a0", "score": "0.49044454", "text": "func BenchmarkDownloadHTML(b *testing.B) {\n\tfor i := 0; i < b.N; i++ {\n\t\tDownloadHTML(\"http://google.com\")\n\t}\n}", "title": "" }, { "docid": "dcdb67106d07c60adc312276d89dc3ff", "score": "0.48941773", "text": "func longTimeRequest(r chan<- int32) {\n\t// Simulate a workload.\n\ttime.Sleep(time.Second * 3)\n\tr <- rand.Int31n(100)\n}", "title": "" }, { "docid": "4c680557ffe1c9ed702ab102db5c4035", "score": "0.48870254", "text": "func ConcurrentDownload(client *http.Client, headers map[string]string, url string, outFileName string, numOfConn int, fileSize int64, tracing bool) {\r\n\tvar partSize, fileOffset int64\r\n\tpartSize = fileSize / int64(numOfConn)\r\n\tfileOffset = 0\r\n\r\n\tlog.Printf(\"ConcurrentDownload: %s, conn=%d\\n\", outFileName, numOfConn)\r\n\tvar wg sync.WaitGroup\r\n\r\n\tfor i := 1; i <= numOfConn; i++ {\r\n\t\twg.Add(1)\r\n\t\tif i == numOfConn {\r\n\t\t\tlog.Printf(\"Part %d: %d- \\n\", i, fileOffset)\r\n\r\n\t\t\tgo func(filename string, start int64, stop int64) {\r\n\t\t\t\tdefer wg.Done()\r\n\t\t\t\tDownloadFile(client, headers, url, filename, start, stop, tracing)\r\n\t\t\t}(fmt.Sprintf(\"part%d\", i), fileOffset, -1)\r\n\t\t} else {\r\n\t\t\tlog.Printf(\"Part %d: %d - %d\\n\", i, fileOffset, fileOffset+partSize-1)\r\n\r\n\t\t\tgo func(filename string, start int64, stop int64) {\r\n\t\t\t\tdefer wg.Done()\r\n\t\t\t\tDownloadFile(client, headers, url, filename, start, stop, tracing)\r\n\t\t\t}(fmt.Sprintf(\"part%d\", i), fileOffset, fileOffset+partSize-1)\r\n\t\t\tfileOffset = fileOffset + partSize\r\n\t\t}\r\n\t}\r\n\twg.Wait()\r\n\tMergeFile(numOfConn, outFileName)\r\n}", "title": "" }, { "docid": "0a1e083a42fbdaef4338d8bdef5ffc85", "score": "0.48817226", "text": "func RandomURLGenerator(opts RandomURLGeneratorOptions) RequestGenerator {\n\treadiedRequests := make([]Request, len(opts.URLs))\n\tfor i, url := range opts.URLs {\n\t\treq, err := http.NewRequest(\"GET\", url, nil)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\treq.Header = opts.Headers\n\t\treadiedRequests[i] = Request{\n\t\t\tBodyBehavior: opts.BodyBehavior,\n\t\t\tHTTPRequest: req,\n\t\t\tName: opts.Name,\n\t\t\tCallback: opts.Callback,\n\t\t}\n\t}\n\tnum := len(readiedRequests)\n\n\treturn func(hammer *Hammer, requests chan<- Request) {\n\t\tdefer func() { close(requests) }()\n\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-hammer.Exit:\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t\tvar idx int\n\t\t\t\tif num == 1 {\n\t\t\t\t\tidx = 0\n\t\t\t\t} else {\n\t\t\t\t\tidx = rand.Intn(len(readiedRequests))\n\t\t\t\t}\n\t\t\t\trequests <- readiedRequests[idx]\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "c2d14fb6283556ce02f824591fe455c3", "score": "0.4876685", "text": "func main() {\n\tlinks := []string{\n\t\t\"http://google.com\",\n\t\t\"http://facebook.com\",\n\t\t\"http://golang.org\",\n\t\t\"http://amazon.com\",\n\t\t\"http://thalamed.com\",\n\t}\n\n\t//create a channel -- can only be accessed within func main\n\t//need to pass on to checkLink\n\tc := make(chan string)\n\n\t//index not interesting for this exercise\n\tfor _, link := range links {\n\t\t//checkLink(link) //without adding new go routine\n\n\t\t//with new Go Routine\n\t\t//runs the blocking call http.Get(link), do nothing else, then go thru next element in iteration\n\t\t//and launch/spawns another new Go Routine\n\t\t//think of \"go\" as the engine that starts to chump thru code inside of a single func\n\t\tgo checkLink(link, c) //channel passed as argument\n\t}\n\t//receive a value from a channel\n\t//fmt.Println(<-c)\n\t//this routine is waiting for something to happen, so it is put into a pause\n\t//once message is received (blocking call), wakes up then it prints it out.\n\t//No more code to run, then exits\n\n\t//adding a 2nd Println - to show 2 log statements\n\t//repeats same process as first, main wakes up and goes through next blocking call\n\t//if no of Println > than URLs, it will just hang waiting for code to run\n\t//fmt.Println(<-c)\n\n\t//c inspired for loop\n\t//for i := 0; i < len(links); i++ {\n\t//fmt.Println(<-c)\n\n\t// infinite loop\n\t//for {\n\n\t//use range with channel\n\t//range c - wait for channel to return some value\n\t//after channel has returned some value, assign to variable \"l\" (link), then run the body of the for loop\n\tfor l := range c {\n\n\t\t//function literal (lambda in ruby,python, c#) (anonymous func in php, javascript)\n\t\t//function literal is an unnamed function to wrap some code that can be executed later\n\t\t//go func() {\n\n\t\t//pass on link to func (as opposed to above implementation)\n\t\tgo func(link string) {\n\t\t\ttime.Sleep(5 * time.Second)\n\t\t\t//warning expected here as variable l is declared outside of the func literal scope\n\t\t\t//trying to reference a varibale that is being maintained (or used) by another go routine\n\t\t\t//pass on link instead of just l\n\t\t\tcheckLink(link, c)\n\n\t\t}(l) // add () to invoke function literal, pass on the value \"l\" as argument\n\n\t\t//time.Sleep(5 * time.Second) - not a good implementation, messages throttle\n\n\t\t//go checkLink(l, c)\n\n\t\t//receiving value through a channel is a blocking operation\n\t\t//checklink expects two arguments(see func checklink), first arg link as string, 2nd arg chan as string\n\t\t//go checkLink(<-c, c)\n\t}\n}", "title": "" }, { "docid": "6750e92c06adca460e8587408998caef", "score": "0.4872267", "text": "func (n *NewLogger) GetURLResp(rw http.ResponseWriter, r *http.Request) {\n\n\t//track execution time for scan\n\ttimeStart := time.Now()\n\n\t//get the request from middleware\n\treq := r.Context().Value(KeyUser{}).(*MyURLReq)\n\n\t//get the list of links from sitemap\n\tlinks := sitemapbuilder.SiteMap(req.URLFromReq, req.MaxDepth, n.l)\n\tn.l.Println(\"***** site map completed*****\")\n\tvar finalResult []analyzerapp.Response\n\n\t//scan based on depth\n\twg.Add(len(links))\n\tfor i, link := range links {\n\n\t\tgo func(link string) {\n\t\t\tdefer wg.Done()\n\n\t\t\t//setup req object\n\t\t\treqMod := &MyURLReq{}\n\t\t\treqMod.URLFromReq = link\n\t\t\treqMod.MaxDepth = req.MaxDepth\n\n\t\t\tn.l.Printf(\"Link# %v : %v \", i, reqMod.URLFromReq)\n\t\t\t//start scan for url\n\t\t\tresults := startScan(reqMod, n.l, rw)\n\t\t\t//mu.Lock()\n\t\t\tfinalResult = append(finalResult, results)\n\t\t\t//mu.Unlock()\n\n\t\t}(link)\n\n\t}\n\n\twg.Wait()\n\t//print the response\n\tPrintResponse(finalResult, rw, n.l)\n\n\tn.l.Printf(\"Query completed in %v\\n\", time.Since(timeStart))\n\n}", "title": "" }, { "docid": "b3c083f094fa648157b32d37e39d1528", "score": "0.48710036", "text": "func makeRequests() error {\n\tvar wg sync.WaitGroup\n\twg.Add(concurrent)\n\n\t// run <concurrent> workers. each makes n/c requests\n\tfor i := 0; i < concurrent; i++ {\n\t\tgo func() {\n\t\t\trunWorker(requests / concurrent)\n\t\t\twg.Done()\n\t\t}()\n\t}\n\twg.Wait()\n\treturn nil\n}", "title": "" }, { "docid": "aaf55096eb07c15e198e89be8baa6cc0", "score": "0.48702005", "text": "func (a *Adapter) DoMulti(requests []*http.Request, option ...*Option) []*http.Response {\n if num := len(option); num != 0 && num != len(requests) {\n panic(\"http multi request invalid num of options\")\n }\n\n profile := \"Http.DoMulti\"\n a.GetContext().ProfileStart(profile)\n defer a.GetContext().ProfileStop(profile)\n defer a.handlePanic()\n\n lock, wg := new(sync.Mutex), new(sync.WaitGroup)\n responses := make([]*http.Response, len(requests))\n\n fn := func(k int) {\n start, profile := time.Now(), baseUrl(requests[k].URL.String())\n var res *http.Response\n\n defer func() {\n if v := recover(); v != nil {\n a.GetContext().Error(Util.ToString(v))\n }\n\n lock.Lock()\n a.GetContext().ProfileAdd(profile, time.Since(start)/1e6)\n responses[k] = res\n lock.Unlock()\n wg.Done()\n }()\n\n if len(option) > 0 && option[k] != nil {\n res = a.client.Do(requests[k], option[k])\n } else {\n res = a.client.Do(requests[k])\n }\n }\n\n wg.Add(len(requests))\n for k := range requests {\n go fn(k)\n }\n\n wg.Wait()\n return responses\n}", "title": "" }, { "docid": "4695a0dae10cc19304c1b561875a51b1", "score": "0.48589376", "text": "func PageLoad(w http.ResponseWriter, r *http.Request) {\n\tif (r.Method != http.MethodGet) {\n\t\tutils.SpectreLog.Errorln(\"Unsupported Method: %v\", r.Method)\n\t\thttp.Error(w, \"Unsupported Method:\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif !security.ValidateRequest(w, r, constants.SCOPE_READ) {\n\t\treturn\n\t}\n\n\tutils.SpectreLog.Debugln(\"Token is Valid\")\n\tresultsDB, err := persist.NewTestResultDB()\n\tif err != nil {\n\t\tutils.SpectreLog.Errorf(\"Failed to init Test Result DB: %v\", err)\n\t\thttp.Error(w, \"internal error - see logs\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\tctx := context.WithValue(context.TODO(), ctxDBKey, resultsDB)\n\n\tresultsES, err := persist.NewTestResultES()\n\tif err != nil {\n\t\tutils.SpectreLog.Errorf(\"Failed to init Test Result ES: %v\", err)\n\t\thttp.Error(w, \"internal error - see logs\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\tctx = context.WithValue(ctx, CtxESKey, resultsES)\n\n\tcache, errC := helper.FetchRCacheFromContext(ctx)\n\tif errC != nil {\n\t\tutils.SpectreLog.Errorf(\"Failed to init redis Cache: %v\", err)\n\t\thttp.Error(w, \"internal error - see logs\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t//TODO change this to get from RBAC layer\n\trawurl := r.URL.Query().Get(\"url\")\n\turl, parseerr := CanonicalizeUrl(rawurl)\n\tif parseerr != nil {\n\t\tutils.PrintError(w, http.StatusBadRequest, parseerr.Error())\n\t\treturn\n\t}\n\tappId := r.URL.Query().Get(\"applicationId\")\n\tdashboardId := r.URL.Query().Get(\"dashboardId\")\n\t//Insert URL in MongoDB System URLS\n\tinsertSystemUrl(url, appId, dashboardId)\n\t//count is reset with new url. so remove object from cache.\n\tcache.Delete(utils.ApplicationUrlCountCacheKey( appId))\n\twpt := helper.WebPageTester{}\n\n\tvar status int\n\n\tlocation := r.URL.Query().Get(\"location\")\n\tif location == \"\" {\n\t\tlocation = constants.DEFAULT_LOCATION\n\t}\n\tpageLoadTime, err1, status, statusText, lookupUrl := GetPageLoadFromCache(wpt, ctx, url, location, \"\")\n\n\tif(err1 != nil) {\n\t\tutils.PrintError(w, status, err1.Error())\n\t\treturn\n\t}\n\n\tutils.SpectreLog.Debugln(\"Page Load Time: %d\\n \", pageLoadTime)\n\tutils.SpectreLog.Debugln(\"Status: %d\\n \", status)\n\tutils.SpectreLog.Debugln(\"Status Text: %s\\n \", statusText)\n\tutils.SpectreLog.Debugln(\"Lookup Url: %s\\n \", lookupUrl)\n\tresults := new(models.Result)\n\tresults.TestStatusCode = status\n\tresults.StatusText = statusText\n\tresults.LookupUrl = lookupUrl\n\tresults.PageLoadTime = pageLoadTime\n\tresults.AppId = appId\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tif err := json.NewEncoder(w).Encode(results); err != nil {\n\t\tutils.PrintError(w, 500, \"Error processing data.\")\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "0925d6ff8fdb04ec20a4b26babcf2f3b", "score": "0.48585513", "text": "func getFullResponse(chromeContext context.Context, url string, requestHeaders map[string]interface{}, response *string, statusCode *int64, responseHeaders *map[string]interface{}) chromedp.Tasks {\r\n\tchromedp.ListenTarget(chromeContext, func(event interface{}) {\r\n\t\tswitch responseReceivedEvent := event.(type) {\r\n\t\tcase *network.EventResponseReceived:\r\n\t\t\tresponse := responseReceivedEvent.Response\r\n\t\t\tif response.URL == url {\r\n\t\t\t\t*statusCode = response.Status\r\n\t\t\t\t*responseHeaders = response.Headers\r\n\t\t\t}\r\n\t\t}\r\n\t})\r\n\r\n\treturn chromedp.Tasks{\r\n\t\tnetwork.Enable(),\r\n\t\tnetwork.SetExtraHTTPHeaders(network.Headers(requestHeaders)),\r\n\t\tchromedp.Navigate(url),\r\n\t\tchromedp.ActionFunc(func(ctx context.Context) error {\r\n\t\t\tnode, err := dom.GetDocument().Do(ctx)\r\n\t\t\tif err != nil {\r\n\t\t\t\treturn err\r\n\t\t\t}\r\n\t\t\t*response, err = dom.GetOuterHTML().WithNodeID(node.NodeID).Do(ctx)\r\n\r\n\t\t\treturn err\r\n\t\t})}\r\n}", "title": "" }, { "docid": "adbba662c5354ae60e796da4690c000f", "score": "0.48557097", "text": "func runTest(testFunc func([]int, *string, chan int, chan struct{}),\n\timsis []*string, numRequests int, numRequestsPerTest int,\n\tprintReceived bool) (int, int, time.Duration) {\n\tvar startTime, endTime time.Time\n\n\tsuccesses := 0\n\tfailures := 0\n\tsentCount := 0\n\trecCount := 0\n\tcurrIMSIIndex := 0\n\n\tsentIds := make([]int, numRequests*numRequestsPerTest)\n\t// these maps would probably make more sense in a struct instead of 4 individual maps\n\t// sid to time the request was sent\n\tsentTimes := make(map[int]time.Time)\n\t// sid to time the request was received\n\treceivedTimes := make(map[int]time.Duration)\n\t// sid to imsi that was sent in request\n\tsidToImsi := make(map[int]string)\n\t// sid to remote address request was sent to/received from\n\tsidToRemoteAddr := make(map[int]net.Addr)\n\n\tsent := make(chan int)\n\tsentErr := make(chan struct{})\n\n\tstartTime = time.Now()\n\n\tfor i := 0; i < numRequests; i, currIMSIIndex = i+1, currIMSIIndex+1 {\n\t\t// loops through imsi indices with numRequests\n\t\tif currIMSIIndex == len(imsis) {\n\t\t\tcurrIMSIIndex = 0\n\t\t}\n\n\t\t// assign random values to sids for each request for testFunc\n\t\trandomVals := make([]int, numRequestsPerTest)\n\t\tfor j := 0; j < numRequestsPerTest; j++ {\n\t\t\trandomVals[j] = int(rand.Uint32())\n\t\t\t_, ok := sentTimes[randomVals[j]]\n\t\t\tfor ok {\n\t\t\t\trandomVals[j] = int(rand.Uint32())\n\t\t\t\t_, ok = sentTimes[randomVals[j]]\n\t\t\t}\n\t\t\tsidToImsi[randomVals[j]] = *imsis[currIMSIIndex]\n\t\t}\n\n\t\t// start a goroutine for the testFunc\n\t\tgo testFunc(randomVals, imsis[currIMSIIndex], sent, sentErr)\n\t}\n\nWait:\n\t// wait for all of the requests to be sent and\n\t// all of the requests to be answered\n\tfor recCount < numRequests*numRequestsPerTest {\n\t\tvar r int\n\t\tselect {\n\t\tcase r = <-sent:\n\t\t\t// record sent time of request\n\t\t\tcurrTime := time.Now()\n\t\t\tlock.Lock()\n\t\t\tsentTimes[r] = currTime\n\t\t\tsentIds[sentCount] = r\n\t\t\tsentCount++\n\t\t\tlock.Unlock()\n\t\t\t// log.Printf(\"sent %d %v\\n\", sentCount, sentTimes[r])\n\t\tcase r := <-received:\n\t\t\tcurrTime := time.Now()\n\t\t\tlock.Lock()\n\t\t\t// record result\n\t\t\tif r.result == 0 {\n\t\t\t\tsuccesses++\n\t\t\t} else {\n\t\t\t\tfailures++\n\t\t\t}\n\t\t\t// record how long the request took to come back\n\t\t\treceivedTimes[r.sid] = currTime.Sub(sentTimes[r.sid])\n\t\t\tsidToRemoteAddr[r.sid] = r.remoteAddr\n\t\t\trecCount++\n\t\t\tlock.Unlock()\n\t\t\t// log.Printf(\"received %d from %s\\n\", r.sid, r.remoteAddr)\n\t\tcase <-sentErr:\n\t\t\tsentCount++\n\t\t\tlog.Printf(\"sending %d request failed\", sentCount+1)\n\t\t\tbreak Wait\n\t\t// wait 20 seconds for responses to come back\n\t\tcase <-time.After(20 * time.Second):\n\t\t\tlog.Printf(\"timed out waiting for ULR\")\n\t\t\tbreak Wait\n\t\t}\n\t}\n\n\tendTime = time.Now()\n\n\t// if we want to log all stats of each received answer\n\t// log the sid, imsi, remote address, and duration of request\n\tif printReceived {\n\t\tfor i := 0; i < len(sentIds); i++ {\n\t\t\tdur, ok := receivedTimes[sentIds[i]]\n\t\t\tif ok {\n\t\t\t\tlog.Printf(\"received\\t%d of sid\\t%d\\tand imsi\\t%s\\tfrom\\t%s\\tin\\t%v\\n\",\n\t\t\t\t\ti+1, sentIds[i], sidToImsi[sentIds[i]], sidToRemoteAddr[sentIds[i]], dur)\n\t\t\t} else {\n\t\t\t\tlog.Printf(\"failed to receive %d with sid %d\\n\", i+1, sentIds[i])\n\t\t\t}\n\t\t}\n\t}\n\n\treturn successes, failures, endTime.Sub(startTime)\n}", "title": "" }, { "docid": "b4992108d46dbee8eb640fc160cfeb01", "score": "0.4852262", "text": "func httpScan(t zgrab2.ScanTarget, delay_time int) (*HTTPResponseInfo, error) {\n\tclient := &http.Client{\n\t\tTimeout: time.Duration(HTTP_TIMEOUT),\n\t\tCheckRedirect: func(req *http.Request, via []*http.Request) error {\n\t\t\treturn http.ErrUseLastResponse\n\t\t},\n\t\tTransport: &http.Transport{\n\t\t\tIdleConnTimeout: time.Duration(HTTP_TIMEOUT),\n\t\t},\n\t}\n\n\treq, err := http.NewRequest(\"GET\", http_uri(t), nil)\n\tif err != nil {\n\t\treturn nil, errors.New(\"Failed to construct HTTP Request\")\n\t}\n\n\t//Sets Host header to Domain\n\treq.Host = t.Domain\n\treq.Header.Set(\"User-Agent\", \"Mozilla/5.0 zgrab/0.x\")\n\treq.Header.Add(\"Accept-Encoding\", \"gzip;q=1.0, deflate;q=0.9, compress;q=0.8, *;q=0.7\")\n\n\thttpResponseInfo, err := performHTTPRequest(req, client, delay_time)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn httpResponseInfo, err\n}", "title": "" }, { "docid": "2692887411d800c4bb99c4bb3f11bcc1", "score": "0.48474476", "text": "func getPage(values url.Values) (int, int) {\n\tmax := parseInt(values.Get(\"max\"), 1, serverConfig.PageSize*10, serverConfig.PageSize)\n\tskip := parseInt(values.Get(\"skip\"), 0, serverConfig.MaxCapacity, 0)\n\n\treturn max, skip\n}", "title": "" }, { "docid": "e9faa76a9a1029723b89dfcdb1845282", "score": "0.48451778", "text": "func fetchURL(w http.ResponseWriter, r *http.Request , fURL string) string {\n //log.Printf(\"fetchURL()\")\n if fURL == \"\" {\n return \"\"\n }\n //log.Printf(\"fetchURL()\")\n //log.Printf(\"fURL: %v\", fURL)\n ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\n defer cancel()\n req, err := http.NewRequest(\"GET\", fURL, nil)\n if err != nil {\n //log.Printf(\"ERROR: Request error: %v\", err)\n }\n //log.Printf(\"req: %v\", req)\n values := url.Values{\"test\":{\"1\"},}\n thisLength := strconv.Itoa(len(values))\n req.Header.Set(\"Content-Length\", thisLength)\n req.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n response, err := http.DefaultClient.Do(req.WithContext(ctx))\n if err != nil {\n log.Fatalf(\"HTTP request failed: %v\", err)\n }\n defer response.Body.Close()\n //log.Printf(\"response: %v\", response)\n bodyBytes, err := ioutil.ReadAll(response.Body)\n bodyString := string(bodyBytes)\n //log.Printf(\"len(bodyString): %v\", len(bodyString))\n //log.Printf(\"bodyString: %v\", bodyString)\n return bodyString\n}", "title": "" }, { "docid": "a16a492d8ad8ecfaf41d7306793a3ddd", "score": "0.4844163", "text": "func generateReq (req chan Work, n int){\n // create n requests\n i := 0\n for i < n {\n // Create a new request after waiting for some time\n time.Sleep(time.Duration(1 * time.Millisecond))\n\n // Add new request to channel\n req <- Work{rand.Intn(1000), 0, 0}\n }\n\n // No more requests\n close(req)\n}", "title": "" }, { "docid": "f2337dc46039b7c8471a6ce95cad3834", "score": "0.48439974", "text": "func main() {\n\t// Create a Array of API Key\n\tks := []string{\"eh2vk49jvdgmm66dymcre2xy\"}\n\n\t// Create a First request to see the data lenght\n\tf := ypage.NewFetch(\"http://api.sandbox.yellowapi.com\", \"Dev\", ks[0])\n\n\t// Source file to put incoming data\n\tfd := ypage.NewFile(\".\", \"data_1.json\", 0600)\n\n\t// Make the request with the provided infos\n\tres, err := f.FindBusiness(\"Montreal\", \"Restaurant\")\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\t// Make a Payload from the init request\n\tp := ypage.NewLoad(res.Resp)\n\tfmt.Println(p.Summary.PageCount)\n\n\t// Create and start probes\n\tvar wg sync.WaitGroup\n\tprobes, err := ypage.MakeProbe(1, p.Summary.PageCount, f, ks)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t} else {\n\t\tfor _, pr := range probes {\n\t\t\twg.Add(1)\n\t\t\tgo pr.Work(&wg)\n\t\t}\n\t\twg.Wait()\n\t}\n\n\t// For all pages build a payload with the response,\n\t// make the result writable to the source\n\t// and write the content data in the Source file\n\tfor _, p := range probes {\n\t\t// Loop over the response to make a payload with it\n\t\tex := ypage.BuildLoad(p.Extract())\n\t\t// Loop over the Payloads\n\t\t// Insert Data to the source\n\t\tfd.Insert(ex)\n\t\t// Add a comma to make the json format valid in the source\n\t\tfd.Insert([]byte(\",\"))\n\n\t}\n\n}", "title": "" }, { "docid": "a74fa4ed1e512e80a9ee11620eaa77d4", "score": "0.48434544", "text": "func (s *Server) TestDownload(length float64) (float64, time.Duration) {\n\tci := make(chan int)\n\tco := make(chan []int)\n\twg := new(sync.WaitGroup)\n\tsizes := []int{245388, 505544, 1118012, 1986284, 4468241, 7907740, 12407926, 17816816, 24262167, 31625365}\n\tstart := time.Now()\n\n\tfor i := 0; i < 8; i++ {\n\t\twg.Add(1)\n\t\tgo s.Downloader(ci, co, wg, start, length)\n\t}\n\n\tfor _, size := range sizes {\n\t\tfor i := 0; i < 4; i++ {\n\t\t\tci <- size\n\t\t}\n\t}\n\n\tclose(ci)\n\twg.Wait()\n\n\ttotal := time.Since(start)\n\ts.speedtest.Printf(\"\\n\")\n\n\tvar totalSize int\n\tfor i := 0; i < 8; i++ {\n\t\tchunks := <-co\n\t\tfor _, chunk := range chunks {\n\t\t\ttotalSize += chunk\n\t\t}\n\t}\n\n\treturn float64(totalSize) * 8, total\n}", "title": "" }, { "docid": "1ab1122adb2a79b818359de998173ec5", "score": "0.48419625", "text": "func visit(verb, url string, headers *map[string]string, body []byte) (*http.Response, time.Duration) {\n\tclient := http.Client{}\n\n\treq, err := http.NewRequest(verb, url, bytes.NewReader(body))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfor k, v := range *headers {\n\t\treq.Header.Add(k, v)\n\t}\n\n\tstart := time.Now()\n\tresponse, err := client.Do(req)\n\telapsed := time.Since(start)\n\treturn response, elapsed\n}", "title": "" }, { "docid": "de63069b760746f4436be45c773cec79", "score": "0.4841766", "text": "func routineGetDocument(id uint64, docPerLink uint64, links chan string, chanNumNewDoc chan uint64, conn bolt.Conn) {\n\t//misuro il tempo in cui il thread rimane in esecuzione\n\tdefer timeTrack(time.Now(), \"Thread \"+strconv.FormatUint(id, 10)+\" (fine)\")\n\t//creo il web driver personale\n\tservice, wd := webDriver.StartSelenium(structures.ThreadBasePort + int(id))\n\tdefer service.Stop()\n\tdefer wd.Quit()\n\n\tfor iteration := 1; ; iteration++ {\n\t\t//per misurae il tempo trascorso per un singolo link\n\t\tstartIterationTime := time.Now()\n\n\t\tstartLink := <-links\n\t\tfmt.Println(\"--------------URL: \", startLink)\n\t\tnewDocuments, numNewDoc := webDriver.GetCiteDocuments(wd, startLink, docPerLink, 300, 40)\n\t\tlogger.Println(\"Thread \", id, \": doc letti = \", numNewDoc)\n\t\t//creo la lista dei nuovi links ai citedBy\n\t\tnewLinks := make([]string, numNewDoc)\n\t\tfor index, doc := range newDocuments {\n\t\t\tnewLinks[index] = doc.LinkCitations\n\t\t}\n\t\t//chiamo routine che si occupa di aggiungere i nuovi link alla coda\n\t\tgo routineAddLinks(newLinks, links, id)\n\t\t//fase neo4j\n\t\t//ricavo l'URL del documento che ha: LinkCitations = startLink\n\t\trows, err := conn.QueryNeo(\"MATCH (doc:Document {LinkCitations: {LinkCitations}})\"+\n\t\t\t\"RETURN doc.url\", map[string]interface{}{\"LinkCitations\": startLink})\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tURL, _, err := rows.NextNeo()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\t//chiudo lo stream\n\t\terr = rows.Close()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tlogger.Println(\"Thread \", id, \": link = \", URL[0].(string))\n\t\t//aggiungo i nuovi documenti al database\n\t\t//togli la i!!!!!!!!!!!!!!!!!!!!!!!!!\n\t\tfor i, newDoc := range newDocuments {\n\t\t\tdocDatabase.AddDocument(conn, newDoc, URL[0].(string))\n\t\t\tlogger.Println(\"Thread id= \", id, \" ha scritto doc numero \", i)\n\t\t}\n\t\t//aggiungo il numero dei documenti letti al canale\n\t\tchanNumNewDoc <- numNewDoc\n\t\t//stampo il tempo trascorso dall'inizio dell'iterazione\n\t\ttimeTrack(startIterationTime, \"Thread \"+strconv.FormatUint(id, 10)+\" iterazione \"+\n\t\t\tstrconv.FormatInt(int64(iteration), 10))\n\t}\n}", "title": "" }, { "docid": "39863054088551304a1f562a0c95bc68", "score": "0.48341656", "text": "func getURL(callerURL *url.URL, concurrentAttempts int) (responses []CallResponse) {\n\turlResponse := make(chan CallResponse)\n\tvar wg sync.WaitGroup\n\twg.Add(concurrentAttempts)\n\tfor i := 0; i < int(concurrentAttempts); i++ {\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\tbeginning := time.Now()\n\t\t\tresponse, err := http.Get(callerURL.String())\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatalf(\"Something got wrong: %v\", err)\n\t\t\t}\n\t\t\texecutionSecs := time.Since(beginning).Seconds()\n\t\t\tresp := CallResponse{\n\t\t\t\tstatus: response.StatusCode,\n\t\t\t\texecution: executionSecs,\n\t\t\t}\n\t\t\turlResponse <- resp\n\t\t}()\n\t}\n\twg.Add(1)\n\tgo func() {\n\t\tdefer wg.Done()\n\t\tfor i := 0; i < int(concurrentAttempts); i++ {\n\t\t\tresponses = append(responses, <-urlResponse)\n\t\t}\n\t\tclose(urlResponse)\n\t}()\n\twg.Wait()\n\treturn\n}", "title": "" }, { "docid": "efa7bbd3c2226eaf4c597c946232fd87", "score": "0.483128", "text": "func (p *Proxy) requestHandler(w http.ResponseWriter, req *http.Request) {\n\tif p.BlockedSites.IsBlocked(req.URL) {\n\t\tp.serveBlockedSite(w, req)\n\t\treturn\n\t}\n\n\t// Keep track of how long the response takes\n\tstartTime := time.Now()\n\tcached := false\n\tcontentLength := int64(-1)\n\n\t// Perform the request\n\tif exists, x, y := p.CachedSites.GetFromCache(*req.URL); exists {\n\t\tcontentLength = p.handleCachedSite(w, req, x, y)\n\t\tfmt.Println(\" \")\n\t\tlog.Infof(\"HTTP Request Received:\\n%s\", stringifyRequest(req))\n\t\tlog.Infof(\"Used cached response to serve %v\\n\", req.URL)\n\t\tcached = true\n\t} else {\n\t\treq.RequestURI = \"\"\n\t\tif req.Method == http.MethodConnect {\n\t\t\thandleConnection(w, req)\n\t\t} else {\n\t\t\tcontentLength = p.handleHTTP(w, req)\n\t\t}\n\t}\n\n\t// Add the response time to the PerformanceData struct\n\telapsedTime := time.Since(startTime)\n\tif cached && contentLength > 0 {\n\t\tp.PerformanceData.AddCachedTime(*req.URL, elapsedTime, contentLength)\n\t} else if contentLength > 0 {\n\t\tp.PerformanceData.AddUncachedTime(*req.URL, elapsedTime, contentLength)\n\t}\n}", "title": "" }, { "docid": "a6b3ad025366cc538aab5fa2004e7a13", "score": "0.48294407", "text": "func Request(conn *models.WSConn, jobsCh chan models.Job, sleeperChan <-chan time.Duration) error {\n\tjobsEmptyTrigger := cap(jobsCh) / 2\n\t// Request new urls to crawl\n\tfor {\n\t\tselect {\n\t\tcase sleepTime := <-sleeperChan:\n\t\t\t// Sleep\n\t\t\ttime.Sleep(sleepTime)\n\t\tdefault:\n\t\t\t// If we have not enough URL to crawl\n\t\t\tif len(jobsCh) < jobsEmptyTrigger {\n\t\t\t\tmsg := models.WSMessage{\n\t\t\t\t\tType: models.TypeRequestGetUrls,\n\t\t\t\t}\n\t\t\t\tb, err := json.Marshal(msg)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrap(err, \"Request: json.Marshal:\")\n\t\t\t\t}\n\t\t\t\terr = conn.WriteMessage(websocket.BinaryMessage, b)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrap(err, \"Request: write:\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttime.Sleep(WS_BUMP_TIMEOUT)\n\t}\n}", "title": "" }, { "docid": "fbbeb4d1b9a180beafb78d0950960c65", "score": "0.4823476", "text": "func DoRequest(httpClient *http.Client, header map[string]string, method, host, loadUrl, reqBody string) (respSize int, duration time.Duration, body []byte) {\n\trespSize = -1\n\tduration = -1\n\n\tloadUrl = escapeUrlStr(loadUrl)\n\n\tvar buf io.Reader\n\tif len(reqBody) > 0 {\n\t\tbuf = bytes.NewBufferString(reqBody)\n\t}\n\n\treq, err := http.NewRequest(method, loadUrl, buf)\n\tif err != nil {\n\t\tfmt.Println(\"An error occured doing request\", err)\n\t\treturn\n\t}\n\n\tfor hk, hv := range header {\n\t\treq.Header.Add(hk, hv)\n\t}\n\n\treq.Header.Add(\"User-Agent\", USER_AGENT)\n\tif host != \"\" {\n\t\treq.Host = host\n\t}\n\tstart := time.Now()\n\tresp, err := httpClient.Do(req)\n\tif err != nil {\n\t\tfmt.Println(\"redirect?\")\n\t\t//this is a bit weird. When redirection is prevented, a url.Error is retuned. This creates an issue to distinguish\n\t\t//between an invalid URL that was provided and and redirection error.\n\t\trr, ok := err.(*url.Error)\n\t\tif !ok {\n\t\t\tfmt.Println(\"An error occured doing request\", err, rr)\n\t\t\treturn\n\t\t}\n\t\tfmt.Println(\"An error occured doing request\", err)\n\t}\n\tif resp == nil {\n\t\tfmt.Println(\"empty response\")\n\t\treturn\n\t}\n\tdefer func() {\n\t\tif resp != nil && resp.Body != nil {\n\t\t\tresp.Body.Close()\n\t\t}\n\t}()\n\tbody, err = ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tfmt.Println(\"An error occured reading body\", err)\n\t}\n\tif resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusCreated {\n\t\tduration = time.Since(start)\n\t\trespSize = len(body) + int(util.EstimateHttpHeadersSize(resp.Header))\n\t} else if resp.StatusCode == http.StatusMovedPermanently || resp.StatusCode == http.StatusTemporaryRedirect {\n\t\tduration = time.Since(start)\n\t\trespSize = int(resp.ContentLength) + int(util.EstimateHttpHeadersSize(resp.Header))\n\t} else {\n\t\tfmt.Println(\"received status code\", resp.StatusCode, \"from\", resp.Header, \"content\", string(body), req)\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "4a4516f280a6308a2ed7be25246b51ee", "score": "0.48215517", "text": "func executeTwoConcurrentRequests(t *testing.T, query string, firstStatusCode, secondStatusCode int,\n\tfirstBody, secondBody string) {\n\tu := fmt.Sprintf(\"http://127.0.0.1:9090?query=%s&user=concurrent_user\", url.QueryEscape(query))\n\n\tvar wg sync.WaitGroup\n\twg.Add(2)\n\tvar resp1 string\n\tvar resp2 string\n\terrs := make(chan error, 0)\n\tdefer close(errs)\n\terrors := make([]error, 0)\n\tgo func() {\n\t\tfor err := range errs {\n\t\t\terrors = append(errors, err)\n\t\t}\n\t}()\n\tgo func() {\n\t\tdefer wg.Done()\n\t\treq, err := http.NewRequest(\"GET\", u, nil)\n\t\tcheckErr(t, err)\n\t\tresp, err := httpRequest(t, req, firstStatusCode)\n\t\tif err != nil {\n\t\t\terrs <- err\n\t\t\treturn\n\t\t}\n\t\tresp1 = bbToString(t, resp.Body)\n\t}()\n\n\tgo func() {\n\t\tdefer wg.Done()\n\t\ttime.Sleep(20 * time.Millisecond)\n\t\treq, err := http.NewRequest(\"GET\", u, nil)\n\t\tcheckErr(t, err)\n\t\tresp, err := httpRequest(t, req, secondStatusCode)\n\t\tif err != nil {\n\t\t\terrs <- err\n\t\t\treturn\n\t\t}\n\t\tresp2 = bbToString(t, resp.Body)\n\t}()\n\twg.Wait()\n\n\tif len(errors) != 0 {\n\t\tt.Fatalf(\"concurrent test scenario failed due to: %v\", errors)\n\t}\n\n\tif !strings.Contains(resp1, firstBody) {\n\t\tt.Fatalf(\"concurrent test scenario: unexpected resp body: %s, expected : %s\", resp1, firstBody)\n\t}\n\n\tif !strings.Contains(resp2, secondBody) {\n\t\tt.Fatalf(\"concurrent test scenario: unexpected resp body: %s, expected : %s\", resp2, secondBody)\n\t}\n}", "title": "" }, { "docid": "477681099a616bfc2d1c166663433ec2", "score": "0.48211432", "text": "func Crawl(url string, depth int, fetcher Fetcher, finish chan int) {\n defer func() {\n finish <- 1\n }()\n resp := UrlResponse{url, make(chan bool)}\n unique <- resp\n if !<-resp.ans {\n return\n }\n if depth <= 0 {\n return\n }\n body, urls, err := fetcher.Fetch(url)\n if err != nil {\n fmt.Println(err)\n return\n }\n fmt.Printf(\"found: %s %q\\n\", url, body)\n parallel := make(chan int)\n for _, u := range urls {\n go Crawl(u, depth-1, fetcher, parallel)\n }\n for i := 0; i < len(urls); i++ {\n <-parallel\n }\n return\n}", "title": "" }, { "docid": "d4e7f3c65b12617801ebe03d58ee4835", "score": "0.48073405", "text": "func RequestHTTPRepeatWithTimeout(url string, returnEmpty bool, timeoutSeconds time.Duration) (string, error) {\n\tdone := make(chan string)\n\tquit := make(chan struct{})\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-quit:\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t\tbody, err := RequestHTTPWithTimeout(url, 5)\n\t\t\t\tif err == nil {\n\t\t\t\t\tif returnEmpty || body != \"\" {\n\t\t\t\t\t\tdone <- strings.TrimSpace(body)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\tselect {\n\tcase result := <-done:\n\t\treturn result, nil\n\tcase <-time.After(timeoutSeconds * time.Second):\n\t\tclose(quit)\n\t\treturn \"\", errors.New(\"timeout\")\n\t}\n}", "title": "" }, { "docid": "8791750d2e0c7fdd4f92b9bec6d4c109", "score": "0.48055992", "text": "func PercentileResponseTime(responseDuration *prometheus.SummaryVec) gin.HandlerFunc {\n\n\treturn func(c *gin.Context) {\n\t\tstart := time.Now()\n\n\t\tlogrus.Debug(\"--> PercentileResponseTime\")\n\t\tpath := removeParams(c)\n\t\t// before request\n\n\t\tc.Next()\n\t\t// after request\n\n\t\tr := new(big.Int)\n\t\tfmt.Println(r.Binomial(1000, 10))\n\n\t\telapsed := time.Since(start)\n\t\telapsedF := float64(elapsed) / float64(time.Millisecond)\n\n\t\tlabels := prometheus.Labels{}\n\n\t\tlabels[\"handler\"] = path\n\t\tlabels[\"method\"] = strings.ToLower(c.Request.Method)\n\n\t\tresponseDuration.With(labels).Observe(elapsedF)\n\t\tlogrus.Debug(\"<-- PercentileResponseTime\")\n\t}\n}", "title": "" }, { "docid": "728b8c922eb14329d3ad945c815c8a28", "score": "0.48043814", "text": "func findUrls(urls chan string, pages chan *Page) {\n debug(\"crawling urls\")\n for url := range urls {\n pages <- readUrl(url)\n }\n close(pages)\n}", "title": "" }, { "docid": "7cd007191319bb0df258d16e56e5456e", "score": "0.48033798", "text": "func TestWork(t *testing.T) {\n domain, _ := url.Parse(\"http://google.com\")\n \n uList := make( chan string )\n _, err := petitcrawler.Work( \"http://google.com/search\", uList, domain)\n if err == nil {\n t.Fatalf(\"TestWork() failed: %s. Expecting to block on channel and exit\", err)\n }\n\n uList2 := make( chan string, 100)\n _, err = petitcrawler.Work( \"http://google.com/search\", uList2, domain)\n if err != nil {\n t.Fatalf(\"TestWork() failed: %s. Expecting to have enough space\", err)\n }\n}", "title": "" }, { "docid": "1057accf2eb34155c2a5631241c37b34", "score": "0.4791297", "text": "func (wi *WorkerInfo) processRequest(rid int32, account string, token string, nbytes uint64, cbytes uint64, req ztypes.StWbReq) ([]int8, error) {\n\n\tzlog.Info(\"Got request id=%d account=%s Vvar=%d size=%d instances=%d\", rid, account, req.Version, cbytes, req.NInsts)\n\tresp := make([]int8, len(req.IData))\n\tif len(req.IData) == 0 {\n\t\t// This is the health check request from scrapper, report ok.\n\t\treturn resp, nil\n\t}\n\n\tvar nlabels = uint64(0)\n\tfor _, id := range req.IData {\n\t\tzlog.Debug(\" Instance=%s NSamples=%d IsIncr=%v Gen=%d GTs=%d Samples=%d\", id.Instance, id.NSamples, id.IsIncr, id.Gen, id.GTs, len(id.Samples))\n\t}\n\n\tsreq := &InstReq{\n\t\taccount: account,\n\t\tinstances: make([]string, len(req.IData)),\n\t\trespCh: make(chan string, 1),\n\t}\n\tfor i, id := range req.IData {\n\t\tsreq.instances[i] = id.Instance\n\t}\n\n\t// Serialize multiple requests for the same scrape target, if there is any.\n\t// Also limit the number of HTTP requests, that we can simulataniously handle (max queue depth coming from config).\n\twi.getCh <- sreq\n\t<-sreq.respCh\n\n\timap := make(map[string][]*InstReqResp)\n\tfor i, id := range req.IData {\n\t\tirr := &InstReqResp{req: id, res: &resp[i]}\n\t\timap[id.Instance] = append(imap[id.Instance], irr)\n\t}\n\n\tvar wg sync.WaitGroup\n\twg.Add(len(imap))\n\n\t// Process all the targets in this request.\n\tfor _, irrs := range imap {\n\t\tgo wi.doProcessRequests(account, irrs, &wg)\n\t}\n\twg.Wait()\n\twi.updateStatsReq(account, nbytes, cbytes, nlabels)\n\n\t// Release the serializer.\n\twi.putCh <- sreq\n\t<-sreq.respCh\n\n\tzlog.Info(\"Done with request id=%d account=%s\", rid, account)\n\treturn resp, nil\n}", "title": "" }, { "docid": "43b805fc78015adcbfbc4a29553bfd36", "score": "0.47887862", "text": "func BenchmarkGroupcacheRetrieval(b *testing.B) {\n\tb.Run(\"h2c\", func(b *testing.B) {\n\t\tfetcher := galaxyhttp.NewHTTPFetchProtocol(&galaxyhttp.HTTPOptions{\n\t\t\tTransport: &http2.Transport{\n\t\t\t\tAllowHTTP: true,\n\t\t\t\tDialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) {\n\t\t\t\t\treturn net.Dial(network, addr)\n\t\t\t\t},\n\t\t\t},\n\t\t\tBasePath: basePath,\n\t\t})\n\n\t\tf, err := fetcher.NewFetcher(selfURLH2C)\n\t\ttestutil.Ok(b, err)\n\n\t\tb.Run(\"seq\", func(b *testing.B) {\n\t\t\tb.ResetTimer()\n\t\t\tb.ReportAllocs()\n\n\t\t\tfor i := 0; i < b.N; i++ {\n\t\t\t\t_, _, err = f.Fetch(context.Background(), groupName, cachekey.BucketCacheKey{Verb: \"content\", Name: \"test\"}.String())\n\t\t\t\ttestutil.Ok(b, err)\n\t\t\t}\n\t\t})\n\t\tb.Run(\"parallel=500\", func(b *testing.B) {\n\t\t\tb.ResetTimer()\n\t\t\tb.ReportAllocs()\n\n\t\t\tch := make(chan struct{})\n\n\t\t\tfor i := 0; i < 500; i++ {\n\t\t\t\tgo func() {\n\t\t\t\t\tfor range ch {\n\t\t\t\t\t\t_, _, err = f.Fetch(context.Background(), groupName, cachekey.BucketCacheKey{Verb: \"content\", Name: \"test\"}.String())\n\t\t\t\t\t\ttestutil.Ok(b, err)\n\t\t\t\t\t}\n\t\t\t\t}()\n\t\t\t}\n\n\t\t\tfor i := 0; i < b.N; i++ {\n\t\t\t\tch <- struct{}{}\n\t\t\t}\n\t\t\tclose(ch)\n\t\t})\n\t})\n\tb.Run(\"h1, max one TCP connection\", func(b *testing.B) {\n\t\tfetcher := galaxyhttp.NewHTTPFetchProtocol(&galaxyhttp.HTTPOptions{\n\t\t\tBasePath: basePath,\n\t\t\tTransport: &http.Transport{\n\t\t\t\tMaxConnsPerHost: 1,\n\t\t\t\tMaxIdleConnsPerHost: 1,\n\t\t\t},\n\t\t})\n\n\t\tf, err := fetcher.NewFetcher(selfURLH1)\n\t\ttestutil.Ok(b, err)\n\n\t\tb.Run(\"seq\", func(b *testing.B) {\n\t\t\tb.ResetTimer()\n\t\t\tb.ReportAllocs()\n\n\t\t\tfor i := 0; i < b.N; i++ {\n\t\t\t\t_, _, err = f.Fetch(context.Background(), groupName, cachekey.BucketCacheKey{Verb: \"content\", Name: \"test\"}.String())\n\t\t\t\ttestutil.Ok(b, err)\n\t\t\t}\n\t\t})\n\n\t\tb.Run(\"parallel=500\", func(b *testing.B) {\n\t\t\tb.ResetTimer()\n\t\t\tb.ReportAllocs()\n\n\t\t\tch := make(chan struct{})\n\n\t\t\tfor i := 0; i < 500; i++ {\n\t\t\t\tgo func() {\n\t\t\t\t\tfor range ch {\n\t\t\t\t\t\t_, _, err = f.Fetch(context.Background(), groupName, cachekey.BucketCacheKey{Verb: \"content\", Name: \"test\"}.String())\n\t\t\t\t\t\ttestutil.Ok(b, err)\n\t\t\t\t\t}\n\t\t\t\t}()\n\t\t\t}\n\n\t\t\tfor i := 0; i < b.N; i++ {\n\t\t\t\tch <- struct{}{}\n\t\t\t}\n\t\t\tclose(ch)\n\t\t})\n\t})\n\tb.Run(\"h1, unlimited TCP connections\", func(b *testing.B) {\n\t\tfetcher := galaxyhttp.NewHTTPFetchProtocol(&galaxyhttp.HTTPOptions{\n\t\t\tBasePath: basePath,\n\t\t\tTransport: &http.Transport{},\n\t\t})\n\n\t\tf, err := fetcher.NewFetcher(selfURLH1)\n\t\ttestutil.Ok(b, err)\n\n\t\tb.Run(\"seq\", func(b *testing.B) {\n\t\t\tb.ResetTimer()\n\t\t\tb.ReportAllocs()\n\n\t\t\tfor i := 0; i < b.N; i++ {\n\t\t\t\t_, _, err = f.Fetch(context.Background(), groupName, cachekey.BucketCacheKey{Verb: \"content\", Name: \"test\"}.String())\n\t\t\t\ttestutil.Ok(b, err)\n\t\t\t}\n\t\t})\n\n\t\tb.Run(\"parallel=500\", func(b *testing.B) {\n\t\t\tb.ResetTimer()\n\t\t\tb.ReportAllocs()\n\n\t\t\tch := make(chan struct{})\n\n\t\t\tfor i := 0; i < 500; i++ {\n\t\t\t\tgo func() {\n\t\t\t\t\tfor range ch {\n\t\t\t\t\t\t_, _, err = f.Fetch(context.Background(), groupName, cachekey.BucketCacheKey{Verb: \"content\", Name: \"test\"}.String())\n\t\t\t\t\t\ttestutil.Ok(b, err)\n\t\t\t\t\t}\n\t\t\t\t}()\n\t\t\t}\n\n\t\t\tfor i := 0; i < b.N; i++ {\n\t\t\t\tch <- struct{}{}\n\t\t\t}\n\t\t\tclose(ch)\n\t\t})\n\t})\n\n}", "title": "" }, { "docid": "fa2f213c1af5b073a331f776788333dc", "score": "0.477348", "text": "func hho(repResult *reportResult) {\n\trepetitions := []int{50, 100, 200} //4k, 8k, 16k\n\n\tmsg := fmt.Sprintf(\"Testing now HHO with Size Limits of ~80*%d bytes\\n\", repetitions)\n\tPrintVerbose(msg, NoColor, 1)\n\n\tsem := make(chan int, Config.Threads)\n\tvar wg sync.WaitGroup\n\twg.Add(len(repetitions))\n\tvar m sync.Mutex\n\n\tfor _, repetition := range repetitions {\n\t\tgo func(repetition int) {\n\t\t\tdefer wg.Done()\n\t\t\tsem <- 1\n\n\t\t\tlimit := repetition * 8 / 100\n\t\t\t//msg := fmt.Sprintf(\"Testing now HHO with Size Limit %dk bytes\\n\", limit)\n\t\t\t//Print(msg, NoColor)\n\n\t\t\theaders := []string{}\n\t\t\tvalues := []string{}\n\n\t\t\tfor i := 0; i < repetition; i++ {\n\t\t\t\theadername := fmt.Sprintf(\"X-Oversized-Header-%d\", i+1)\n\t\t\t\tvalue := \"Big-Value-000000000000000000000000000000000000000000000000000000000000000000000000000000\"\n\t\t\t\theaders = append(headers, headername)\n\t\t\t\tvalues = append(values, value)\n\t\t\t}\n\n\t\t\trUrl := Config.Website.Url.String()\n\t\t\tcb := randInt()\n\t\t\tidentifier := fmt.Sprintf(\"HHO with limit of %dk bytes\", limit)\n\t\t\trp := requestParams{\n\t\t\t\theaders: headers,\n\t\t\t\tvalues: values,\n\t\t\t\tidentifier: identifier,\n\t\t\t\turl: rUrl,\n\t\t\t\tcb: cb,\n\t\t\t}\n\t\t\t_, statusCode1, request, _, err := firstRequest(rp)\n\t\t\tif err != nil {\n\t\t\t\tif err.Error() != \"stop\" {\n\t\t\t\t\tm.Lock()\n\t\t\t\t\trepResult.HasError = true\n\t\t\t\t\trepResult.ErrorMessages = append(repResult.ErrorMessages, err.Error())\n\t\t\t\t\tm.Unlock()\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// send second request also with cb\n\t\t\t_, statusCode2, respHeader, err := secondRequest(rUrl, identifier, cb)\n\t\t\tif err != nil {\n\t\t\t\tif err.Error() != \"stop\" {\n\t\t\t\t\tm.Lock()\n\t\t\t\t\trepResult.HasError = true\n\t\t\t\t\trepResult.ErrorMessages = append(repResult.ErrorMessages, err.Error())\n\t\t\t\t\tm.Unlock()\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tmsg = fmt.Sprintf(\"------- HHO DOS was successfully poisoned!!! cb: %s -------\\n%s\\n\", cb, request.URL)\n\t\t\tm.Lock()\n\t\t\tvar m2 = &sync.Mutex{}\n\t\t\t_ = checkPoisoningIndicators(repResult, request, msg, \"\", \"\", statusCode1, statusCode2, false, respHeader, &m, m2, false)\n\t\t\tm.Unlock()\n\n\t\t\t<-sem\n\t\t}(repetition)\n\t}\n\n\twg.Wait()\n}", "title": "" }, { "docid": "6f3b1e31f603adb6004236f475a0cbf9", "score": "0.47732458", "text": "func scrapeTeam(teamNums ...string) {\n\tlength := len(teamNums)\n\tresc, errc := make(chan string), make(chan error)\n\tfor _, team := range teamNums {\n\t\tgo getData(teamURL+team, resc, errc)\n\t}\n\tfor i := 0; i < length; i++ { //Loop length amount of times to make sure i have gotten a response from each goroutine before proceeding\n\t\tselect { // Force this for loop to wait for a response from either errc(error channel) or resc (the response channel)\n\t\tcase res := <-resc: // If i get a response status print it out (this also tells me that this particular goroutine is done\n\t\t\tlog.Println(res)\n\t\tcase err := <-errc: // If i get an error print it out along with time and date\n\t\t\tlog.Println(err)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "4d9acefa25b4b4795b5da4520af7c874", "score": "0.47705156", "text": "func GetPagination(from, size, total int, url string, param map[string]interface{}) string {\n\n\t//TODO limit when es is the database driver\n\t//if total > 10000 {\n\t//\ttotal = 10000\n\t//}\n\n\tif total <= size {\n\t\treturn \"\"\n\t}\n\n\tvar cur = from / size\n\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"<ul class=\\\"uk-pagination\\\" data-uk-pagination=\\\"{items:\")\n\tbuffer.WriteString(strconv.Itoa(total))\n\tbuffer.WriteString(\", itemsOnPage:\")\n\tbuffer.WriteString(strconv.Itoa(size))\n\tbuffer.WriteString(\",currentPage:\")\n\tbuffer.WriteString(strconv.Itoa(cur))\n\tbuffer.WriteString(\"}\\\"></ul>\")\n\tbuffer.WriteString(\"<script type=\\\"text/javascript\\\">\")\n\n\t// init args start\n\tvar moreArgs bytes.Buffer\n\tmoreArgs.WriteString(\"var args='\")\n\tif len(param) > 0 {\n\t\tfor k, v := range param {\n\t\t\thostStr := fmt.Sprintf(\"&%s=%v\", k, v)\n\t\t\tmoreArgs.WriteString(hostStr)\n\t\t}\n\t}\n\n\tmoreArgs.WriteString(\"';\")\n\n\tif moreArgs.Len() > 0 {\n\t\tbuffer.Write(moreArgs.Bytes())\n\t}\n\n\tbuffer.WriteString(\"var size=\")\n\tbuffer.WriteString(strconv.Itoa(size))\n\tbuffer.WriteString(\";\")\n\n\t//init args end\n\n\tbuffer.WriteString(\" $(function() {\")\n\n\tbuffer.WriteString(\"$('[data-uk-pagination]').on('select.uk.pagination', function(e, pageIndex){\")\n\n\tbuffer.WriteString(\"var from=pageIndex*size;\")\n\n\tbuffer.WriteString(\"window.location='?from='+from+'&size='+size+args\")\n\n\tbuffer.WriteString(\"});\")\n\n\tbuffer.WriteString(\" });\")\n\n\t//init para for hot key start\n\tbuffer.WriteString(fmt.Sprintf(\"var maxpage = %v;\", total))\n\tif from > 0 && from >= size {\n\t\tbuffer.WriteString(fmt.Sprintf(\"var prev_page='?from=%v&size='+size+args;\", from-size))\n\n\t}\n\tif from+size < total {\n\t\tbuffer.WriteString(fmt.Sprintf(\"var next_page='?from=%v&size='+size+args;\", from+size))\n\t}\n\t//init para for hot key end\n\n\tbuffer.WriteString(\"</script>\")\n\n\treturn buffer.String()\n}", "title": "" }, { "docid": "f7d976eefabb17f9df658d8e5414cbff", "score": "0.47613817", "text": "func testChunkedResponseGo() {\n\treq := &http.Request{}\n\treq.URL, _ = url.Parse(\"https://www.baidu.com\")\n\treq.Header = make(map[string][]string)\n\treq.Header[\"Host\"] = []string{\"www.baidu.com\"}\n\treq.Header[\"Connection\"] = []string{\"keep-alive\"}\n\treq.Header[\"Accept\"] = []string{\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\"}\n\treq.Header[\"Accept-Language\"] = []string{\"zh-CN,zh;q=0.9\"}\n\treq.Header[\"User-Agent\"] = []string{\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36\"}\n\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\tfmt.Println(\"request err:\", err)\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\n\tfmt.Println(resp.StatusCode)\n\tfmt.Println(resp.Header)\n\tfmt.Println(resp.Trailer)\n\tfmt.Println(resp.TransferEncoding)\n}", "title": "" }, { "docid": "81f88e38393652decf68029da274f9fb", "score": "0.4756366", "text": "func getSubPages(d *caching_downloader.Downloader,p *notionapi.Page) []string {\n\troot := p.Root()\n\t//panicIf(!isPageBlock(root))\n\tsubPages := map[string]struct{}{}\n\tseenBlocks := map[string]struct{}{}\n\tblocksToVisit := append([]string{}, root.ContentIDs...)\n\t//log.Println(\"blocksToVisit:\",blocksToVisit)\n\tfor len(blocksToVisit) > 0 {\n\t\tid := notionapi.ToDashID(blocksToVisit[0])\n\t\tblocksToVisit = blocksToVisit[1:]\n\t\tif _, ok := seenBlocks[id]; ok {\n\t\t\tcontinue\n\t\t}\n\t\tseenBlocks[id] = struct{}{}\n\t\tblock := p.BlockByID(id)\n\t\t//if ifQuota(d,id){\n\t\t\t//subPages[id] = struct{}{}\n\t\t//}\n\t\tif p.IsSubPage(block) {\n\t\t\tsubPages[id] = struct{}{}\n\t\t}\n\n\t\t//page, _ := d.DownloadPage(notionapi.ToNoDashID(id))\n\t\t//bblocksToVisit := append([]string{}, page.Root().ContentIDs...)\n\t\t//if len(bblocksToVisit)!=0{\n\t\t//\tsubPages[id] = struct{}{}\n\t\t//}\n\t\t//if p.IsSubPage(block) {\n\t\t//\tsubPages[id] = struct{}{}\n\t\t//}\n\t\t// need to recursively scan blocks with children\n\t\tblocksToVisit = append(blocksToVisit, block.ContentIDs...)\n\t}\n\tres := []string{}\n\tfor id := range subPages {\n\t\tres = append(res, id)\n\t}\n\tsort.Strings(res)\n\treturn res\n}", "title": "" } ]
df8dde42ef0c463571e6e936837a6266
Load a Location from ID. Optionally filtered by scenario.
[ { "docid": "45e52c6f963031d6c3c78b320ac53834", "score": "0.8133826", "text": "func LoadLocationFromID(db *gorp.DbMap, scenar *Scenario, ID int64) (*Location, error) {\n\tif db == nil {\n\t\treturn nil, errors.New(\"Missing db parameter to list locations\")\n\t}\n\n\tselector := sqlgenerator.PGsql.Select(`*`).From(`\"location\"`).Where(\n\t\tsquirrel.Eq{`id`: ID},\n\t)\n\n\tif scenar != nil {\n\t\tselector = selector.Where(squirrel.Eq{`id_scenario`: scenar.ID})\n\t}\n\n\tquery, args, err := selector.ToSql()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar loc Location\n\n\terr = db.SelectOne(&loc, query, args...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &loc, nil\n}", "title": "" } ]
[ { "docid": "4ca15edb092d5bb8f4e3253ecad53d05", "score": "0.6433767", "text": "func (loc *Location) LoadLocationCardFromID(db *gorp.DbMap, ID int64) (*LocationCard, error) {\n\tif db == nil {\n\t\treturn nil, errors.New(\"Missing db parameter to load location card\")\n\t}\n\n\tquery, args, err := sqlgenerator.PGsql.Select(`*`).From(`\"location_card\"`).Where(\n\t\tsquirrel.And{\n\t\t\tsquirrel.Eq{`id`: ID},\n\t\t\tsquirrel.Eq{`id_location`: loc.ID},\n\t\t},\n\t).ToSql()\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar lc LocationCard\n\n\terr = db.SelectOne(&lc, query, args...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &lc, nil\n}", "title": "" }, { "docid": "fdace332f77f114b9146b7e8b0b07160", "score": "0.59965515", "text": "func GetLocationByID(id string) (Location, error) {\n\turl := fmt.Sprintf(locationURL, id, \"\")\n\tdata, err := getDataFromURL(url)\n\tif err != nil {\n\t\treturn Location{}, err\n\t}\n\n\tlocation, err := getFromLocationPage(data)\n\tif err != nil {\n\t\treturn Location{}, err\n\t}\n\treturn location, nil\n}", "title": "" }, { "docid": "0f4f197d4eea89c67b6afcde34d6a3ea", "score": "0.5903004", "text": "func (c *Client) LocationGetById(ctx context.Context, id string) (*qvspot.Location, error) {\n\n\tlocation := new(qvspot.Location)\n\terr := c.db.GetContext(ctx, location, `SELECT * FROM location WHERE id = $1`, id)\n\tif err == sql.ErrNoRows {\n\t\treturn nil, store.ErrNotFound\n\t} else if err != nil {\n\t\treturn nil, err\n\t}\n\treturn location, nil\n\n}", "title": "" }, { "docid": "3cdca28aed15f63d77b9ca224ba815ad", "score": "0.5688554", "text": "func (l *LocationService) Get(locationId int32) (*Location, error) {\n\tvar path strings.Builder\n\tpath.WriteString(\"locations/\")\n\tpath.WriteString(strconv.FormatInt(int64(locationId), 10))\n\n\treq, err := l.client.NewRequest(path.String(), nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error creating new request: %s\", err.Error())\n\t}\n\n\tvar location Location\n\n\t_, err = l.client.Do(req, &location)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not do request: %s\", err.Error())\n\t}\n\n\treturn &location, nil\n}", "title": "" }, { "docid": "98964d7c53741fa269ed2799f897a253", "score": "0.5553831", "text": "func GetLocationById() {\n\tlocationService := location.NewLocationService(os.Getenv(\"MICRO_API_TOKEN\"))\n\trsp, err := locationService.Read(&location.ReadRequest{\n\t\tId: \"1\",\n\t})\n\tfmt.Println(rsp, err)\n}", "title": "" }, { "docid": "36f791faf2dd1f9efcde957a95dbb7ec", "score": "0.5486349", "text": "func withLocationID(id int) locationOption {\n\treturn func(m *LocationMutation) {\n\t\tvar (\n\t\t\terr error\n\t\t\tonce sync.Once\n\t\t\tvalue *Location\n\t\t)\n\t\tm.oldValue = func(ctx context.Context) (*Location, error) {\n\t\t\tonce.Do(func() {\n\t\t\t\tif m.done {\n\t\t\t\t\terr = fmt.Errorf(\"querying old values post mutation is not allowed\")\n\t\t\t\t} else {\n\t\t\t\t\tvalue, err = m.Client().Location.Get(ctx, id)\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn value, err\n\t\t}\n\t\tm.id = &id\n\t}\n}", "title": "" }, { "docid": "13b4ead4c62c32db4de6c856c3b5db31", "score": "0.5387535", "text": "func (c *Client) GetLocation(ctx context.Context, id string) (Location, error) {\n\tif !isValidUUID(id) {\n\t\treturn Location{}, errors.New(\"'id' is invalid\")\n\t}\n\tr := gsRequest{\n\t\turi: path.Join(apiLocationBase, id),\n\t\tmethod: http.MethodGet,\n\t\tskipCheckingRequest: true,\n\t}\n\tvar location Location\n\terr := r.execute(ctx, *c, &location)\n\treturn location, err\n}", "title": "" }, { "docid": "9c1cad5902246dbc9b9ed6cc7e9afaf3", "score": "0.53252167", "text": "func LoadByID(ctx context.Context, db gorp.SqlExecutor, id int64) (*sdk.Service, error) {\n\tquery := gorpmapping.NewQuery(\"SELECT * FROM service WHERE id = $1\").Args(id)\n\treturn get(ctx, db, query)\n}", "title": "" }, { "docid": "0e864a25644c515b29feac439fbad5fe", "score": "0.52924544", "text": "func (c *Client) Location(id string) *LocationService {\n\treturn &LocationService{c, id}\n}", "title": "" }, { "docid": "1b9c0970435a16f38e9858f315a59e41", "score": "0.52799624", "text": "func LoadLocation(name string) (*time.Location, error) {\n\tlocCache.mutex.RLock()\n\tloc, ok := locCache.cache[name]\n\tlocCache.mutex.RUnlock()\n\tif ok {\n\t\treturn loc, nil\n\t}\n\tloc, err := time.LoadLocation(name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlocCache.mutex.Lock()\n\tdefer locCache.mutex.Unlock()\n\tlocCache.cache[name] = loc\n\treturn loc, nil\n}", "title": "" }, { "docid": "6d1de558115084ceed7a270517698753", "score": "0.52009046", "text": "func NewLocation(id int64 ,name string) *Location {\n\treturn &Location{ID: id, Name: name}\n}", "title": "" }, { "docid": "ef4030f83d6c9278e583e9deddcde2bd", "score": "0.518999", "text": "func WithLocationID(s string) Option {\n\treturn func(o *options) {\n\t\to.locationID = s\n\t}\n}", "title": "" }, { "docid": "8668387413ede6856f046e7dd3946e1f", "score": "0.51725394", "text": "func (o *GetRuleParams) SetLocationID(locationID string) {\n\to.LocationID = locationID\n}", "title": "" }, { "docid": "da8adbd87cbde8a7735f7b8c83aa5a39", "score": "0.51368", "text": "func LoadLocation(name string) (*time.Location, error) {\n\tloweredName := strings.ToLower(name)\n\tswitch loweredName {\n\tcase \"local\", \"default\":\n\t\tloweredName = \"utc\"\n\t\tname = \"UTC\"\n\t}\n\t// If we know this is a lowercase name in tzdata, use the uppercase form.\n\tif v, ok := lowercaseTimezones[loweredName]; ok {\n\t\t// If this location is not found, we may have a case where the tzdata names\n\t\t// have different values than the system tz names.\n\t\t// If this is the case, allback onto the default logic, where the name is read\n\t\t// off other sources before tzdata.\n\t\tif loc, err := time.LoadLocation(v); err == nil {\n\t\t\treturn loc, nil\n\t\t}\n\t}\n\treturn time.LoadLocation(name)\n}", "title": "" }, { "docid": "bcc23617f3d630b44bb0d02ea2506340", "score": "0.50998455", "text": "func (t *TripAdvisor) Location(ctx context.Context, locationID int) (*models.LocationResponse, error) {\n\treq, err := http.NewRequest(http.MethodGet, t.endpoint+\"location/\"+strconv.Itoa(locationID)+\"?key=\"+t.key, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\thttpResponse, err := t.client.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer httpResponse.Body.Close()\n\n\t// decode response\n\tdecoder := json.NewDecoder(httpResponse.Body)\n\tresponse := models.LocationResponse{}\n\terr = decoder.Decode(&response)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &response, nil\n}", "title": "" }, { "docid": "5207bfaf6171be16129540a68c17c0b0", "score": "0.50932604", "text": "func (lc LocationController) GetLocation(w http.ResponseWriter, r *http.Request, p httprouter.Params) {\n\t// Grab id\n\tid := p.ByName(\"id\")\n\n\t// Verify id is ObjectId, otherwise bail\n\tif !bson.IsObjectIdHex(id) {\n\t\tw.WriteHeader(404)\n\t\treturn\n\t}\n\n\t// Grab id\n\toid := bson.ObjectIdHex(id)\n\n\t// Stub Location\n\tvar locationObject Location\n\n\t// Fetch user\n\tif err := lc.session.DB(\"go_rest_api_assignment2\").C(\"locations\").FindId(oid).One(&locationObject); err != nil {\n\t\tw.WriteHeader(404)\n\t\treturn\n\t}\n\n\t// Marshal provided interface into JSON structure\n\tuj, _ := json.Marshal(locationObject)\n\n\t// Write content-type, statuscode, payload\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(200)\n\tfmt.Fprintf(w, \"%s\", uj)\n}", "title": "" }, { "docid": "fd70b90db273eb72d75087184157cc71", "score": "0.4989512", "text": "func LoadItemByID(ctx context.Context, m *gorpmapper.Mapper, db gorp.SqlExecutor, id string, opts ...gorpmapper.GetOptionFunc) (*Item, error) {\n\tquery := gorpmapper.NewQuery(\"SELECT * FROM index WHERE id = $1\").Args(id)\n\treturn getItem(ctx, m, db, query, opts...)\n}", "title": "" }, { "docid": "14b73fe5c8ba788bf41e52d2c0ad1074", "score": "0.49297285", "text": "func Load(location string, dpi int, overrideDPI bool) (*atlante.Atlante, error) {\n\n\taURL, err := url.Parse(location)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tconf, err := config.LoadAndValidate(aURL)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn LoadConfig(conf, dpi, overrideDPI)\n}", "title": "" }, { "docid": "893327e8c017aecc77e04be4a84839ac", "score": "0.49122697", "text": "func (i *LocationService) Get() (Location, error) {\n\tpath := \"/v1/locations/%s\"\n\treq, err := i.c.NewRequest(\"GET\", fmt.Sprintf(path, i.id), nil)\n\n\tvar location Location\n\n\tif err == nil {\n\t\t_, err = i.c.Do(req, &location, path)\n\t}\n\n\treturn location, err\n}", "title": "" }, { "docid": "877bd10d1ff9961bfe06f73243014fcc", "score": "0.4905752", "text": "func (f LocationFunc) Location(ctx context.Context, locationID int) (*models.LocationResponse, error) {\n\treturn f(ctx, locationID)\n}", "title": "" }, { "docid": "65565053460252a35662a7a3e9206108", "score": "0.49013937", "text": "func (c Location) ID() string {\n\tswitch int64(c) {\n\tcase int64(Nashville):\n\t\treturn \"Nashville\"\n\t}\n\treturn \"\"\n}", "title": "" }, { "docid": "6e9c8c5448936f99e62592348353d72f", "score": "0.49012733", "text": "func LoadLocation(timezone string) (*time.Location, error) {\n\treturn time.LoadLocation(timezone)\n}", "title": "" }, { "docid": "99689e95864d0469da783df085fc6ee2", "score": "0.4877066", "text": "func GetLocation(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tudid := vars[\"udid\"]\n\tvar location Location\n\terr := dbmap.SelectOne(&location, \"SELECT * FROM locations WHERE udid=?\", udid)\n\tif err != nil {\n\t\tlog.Printf(\"Entry for %s not found\", udid)\n\t}\n\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tjson.NewEncoder(w).Encode(location)\n}", "title": "" }, { "docid": "753ba6c6910cec7a27be0fff6c04f5e7", "score": "0.48672873", "text": "func (f *FileSystem) Load(id string) ([]byte, error) {\n\t// get image file by id. first try permanent location and if not found - staging\n\timg := func(id string) (file string, err error) {\n\t\tfile = f.location(f.Location, id)\n\t\t_, err = os.Stat(file)\n\t\tif err != nil {\n\t\t\tfile = f.location(f.Staging, id)\n\t\t\t_, err = os.Stat(file)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn file, fmt.Errorf(\"can't get image stats for %s: %w\", id, err)\n\t\t}\n\t\treturn file, nil\n\t}\n\n\timgFile, err := img(id)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"can't get image file for %s: %w\", id, err)\n\t}\n\n\tfh, err := os.Open(imgFile) //nolint:gosec // we open file from known location\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"can't load image %s: %w\", id, err)\n\t}\n\treturn io.ReadAll(fh)\n}", "title": "" }, { "docid": "db9fff62ac5be934517698ea6038ea3b", "score": "0.48636985", "text": "func (h *Hosts) Load(location string) int {\n\t// a wrapper to provide a clean loading interface\n\tclean := strings.ToLower(location)\n\tif strings.HasPrefix(clean, \"http\") {\n\t\treturn h.loadURL(location)\n\t}\n\treturn h.Loadfile(location)\n}", "title": "" }, { "docid": "6fa5e6e01f610761b9ef7d2827e48308", "score": "0.4807801", "text": "func (m NoMDEntries) SetLocationID(v string) {\n\tm.Set(field.NewLocationID(v))\n}", "title": "" }, { "docid": "e6b5fe3d3ffe53fb6d57883bc3898d34", "score": "0.4807475", "text": "func (qs *QuestLocationService) Get(campID int, qstID int, qlocID int) (*QuestLocation, error) {\n\tvar err error\n\tend := EndpointCampaign\n\n\tif end, err = end.id(campID); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid Campaign ID: %w\", err)\n\t}\n\tend = end.concat(EndpointQuestLocation)\n\n\tif end, err = end.id(qstID); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid Quest ID: %w\", err)\n\t}\n\tend = end.concat(qs.end)\n\n\tif end, err = end.id(qlocID); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid QuestLocation ID: %w\", err)\n\t}\n\n\tvar wrap struct {\n\t\tData *QuestLocation `json:\"data\"`\n\t}\n\n\tif err = qs.client.get(end, &wrap); err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot get QuestLocation (ID: %d) from Campaign (ID: %d): %w\", qlocID, campID, err)\n\t}\n\n\treturn wrap.Data, nil\n}", "title": "" }, { "docid": "36f8f15265c33ebe77064cebfe606dba", "score": "0.47582772", "text": "func LoadRunByID(ctx context.Context, db gorp.SqlExecutor, id int64, loadOpts LoadRunOptions) (*sdk.WorkflowRun, error) {\n\tctx, end := telemetry.Span(ctx, \"workflow.LoadRunByID\")\n\tdefer end()\n\tquery := fmt.Sprintf(`select %s\n\tfrom workflow_run\n\twhere workflow_run.id = $1`, wfRunfields)\n\treturn loadRun(ctx, db, loadOpts, query, id)\n}", "title": "" }, { "docid": "7e6c084f91a023f133bf4db73a6d07c9", "score": "0.47343844", "text": "func (r *serverRepoImpl) LoadByID(id uint64) (*model.Server, error) {\n\tquery := fmt.Sprintf(selectByIDQuery, \"server\", id)\n\trows, err := r.db.Query(query)\n\tif err != nil {\n\t\tlog.Printf(\"failed to load server %v, err: %v\", id, err)\n\t\treturn nil, err\n\t}\n\n\tservers, err := r.rowsToServerModel(rows)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn servers[0], nil\n}", "title": "" }, { "docid": "a43c97f7464bf429d7fb6f06585a1eae", "score": "0.4731485", "text": "func (m *BookreturnMutation) SetLocationID(id int) {\n\tm.location = &id\n}", "title": "" }, { "docid": "7d3fa3deff32f2e9e142b616e38cfd88", "score": "0.47160852", "text": "func (s *Memory) Load(ctx context.Context, identifier string) ([]domain.Finding, error) {\n\tf, ok := s.Map.Load(identifier)\n\tif ok {\n\t\treturn f.([]domain.Finding), nil\n\t}\n\t_, ok = s.Map.Load(identifier + \"-marker\")\n\tif ok {\n\t\treturn nil, domain.InProgressError{Identifier: identifier}\n\t}\n\treturn nil, domain.NotFoundError{Identifier: identifier}\n}", "title": "" }, { "docid": "b060b4e99c417ac51c419f665c158520", "score": "0.47132096", "text": "func LoadByID(db *sql.DB, id int64) (*sdk.RepositoriesManager, error) {\n\tvar rm *sdk.RepositoriesManager\n\tvar rmid int64\n\tvar t, name, URL, data string\n\n\tquery := `SELECT id, type, name, url, data FROM repositories_manager WHERE id=$1`\n\tif err := db.QueryRow(query, id).Scan(&rmid, &t, &name, &URL, &data); err != nil {\n\t\tlog.Warning(\"LoadByID> Error %s\", err)\n\t\treturn nil, err\n\t}\n\n\trm, err := New(sdk.RepositoriesManagerType(t), rmid, name, URL, map[string]string{}, data)\n\tif err != nil {\n\t\tlog.Warning(\"LoadByID> Error %s\", err)\n\t}\n\treturn rm, nil\n}", "title": "" }, { "docid": "de26a38d2dc39ab3fe97cd2bbce77789", "score": "0.47014967", "text": "func LoadByID(db gorp.SqlExecutor, store cache.Store, id int64, opts ...LoadOptionFunc) (*sdk.Application, error) {\n\tquery := fmt.Sprintf(`\n SELECT %s\n FROM application\n WHERE application.id = $1`, appRows)\n\targs := []interface{}{id}\n\n\treturn load(db, store, \"\", opts, query, args...)\n}", "title": "" }, { "docid": "632b20923bcf269ee38125de470ed9d3", "score": "0.46779522", "text": "func (schools *schools) GetByID(id int) (school School, found bool) {\n\tindex, found := schools.mapSchoolID[id]\n\tif !found {\n\t\treturn\n\t}\n\n\tschool = schools.items[index]\n\n\treturn\n}", "title": "" }, { "docid": "6348155b7df0cd26c9e179447851b13b", "score": "0.4673636", "text": "func (o *ListPaymentsParams) SetLocationID(locationID *string) {\n\to.LocationID = locationID\n}", "title": "" }, { "docid": "26b90e698568e9858d1041b37151f692", "score": "0.466744", "text": "func (o *ListDeviceCodesParams) SetLocationID(locationID *string) {\n\to.LocationID = locationID\n}", "title": "" }, { "docid": "0bdc3f4c4e1dc237441e831ea2d469c8", "score": "0.46266437", "text": "func LoadRoom(id bson.ObjectId) (*Room, error) {\n\tses, c := db.GetCollection(\"rooms\")\n\tdefer ses.Close()\n\tvar room Room\n\terr := c.Find(bson.M{\"_id\": id}).One(&room)\n\treturn &room, err\n}", "title": "" }, { "docid": "1e066a3af29b98f4e359fa3d82e36a0d", "score": "0.45968756", "text": "func (lc LocationController) ModifyLocation(w http.ResponseWriter, r *http.Request, p httprouter.Params) {\n\t// Grab id\n\tid := p.ByName(\"id\")\n\n\t// Verify id is ObjectId, otherwise bail\n\tif !bson.IsObjectIdHex(id) {\n\t\tw.WriteHeader(404)\n\t\treturn\n\t}\n\n\t// Grab id\n\toid := bson.ObjectIdHex(id)\n\t// Stub a location to be populated from the body\n\n\tvar locationObject Location\n\tvar retrivedObject Location\n\n\t//String to store address\n\tvar queryParamBuilder string\n\t// Populate the user data\n\tjson.NewDecoder(r.Body).Decode(&locationObject)\n\n\taddressKeys := strings.Fields(locationObject.Address)\n\tcityKeys := strings.Fields(locationObject.City)\n\tstateKeys := strings.Fields(locationObject.State)\n\tkeys := append(addressKeys, cityKeys...)\n\tlocationKeys := append(keys, stateKeys...)\n\tfor i := 0; i < len(locationKeys); i++ {\n\t\tif i == len(locationKeys)-1 {\n\t\t\tqueryParamBuilder += locationKeys[i]\n\t\t} else {\n\t\t\tqueryParamBuilder += locationKeys[i] + \"+\"\n\t\t}\n\t}\n\turl := fmt.Sprintf(\"http://maps.google.com/maps/api/geocode/json?address=%s&sensor=false\", queryParamBuilder)\n\tresp, err := http.Get(url)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// read json http response\n\tjsonDataFromHTTP, err := ioutil.ReadAll(resp.Body)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tvar coordinates CoordinateResponse\n\n\terr = json.Unmarshal(jsonDataFromHTTP, &coordinates) // here!\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif len(coordinates.Results) == 0 {\n\t\tw.WriteHeader(400)\n\t\treturn\n\t}\n\tlocationObject.Coordinate.Lat = coordinates.Results[0].Geometry.Location.Lat\n\tlocationObject.Coordinate.Lng = coordinates.Results[0].Geometry.Location.Lng\n\n\t//Fetch user\n\tif err := lc.session.DB(\"go_rest_api_assignment2\").C(\"locations\").FindId(oid).One(&retrivedObject); err != nil {\n\t\tw.WriteHeader(404)\n\t\treturn\n\t}\n\tlocationObject.Name = retrivedObject.Name\n\tlocationObject.ID = retrivedObject.ID\n\tif locationObject.City == \"\" {\n\t\tlocationObject.City = retrivedObject.City\n\t}\n\tif locationObject.Address == \"\" {\n\t\tlocationObject.Address = retrivedObject.Address\n\t}\n\tif locationObject.State == \"\" {\n\t\tlocationObject.State = retrivedObject.State\n\t}\n\tif locationObject.Zip == \"\" {\n\t\tlocationObject.Zip = retrivedObject.Zip\n\t}\n\tif err := lc.session.DB(\"go_rest_api_assignment2\").C(\"locations\").RemoveId(oid); err != nil {\n\t\tw.WriteHeader(404)\n\t\treturn\n\t}\n\t// Write the user to mongo\n\tlc.session.DB(\"go_rest_api_assignment2\").C(\"locations\").Insert(locationObject)\n\n\t// Marshal provided interface into JSON structure\n\n\tuj, _ := json.Marshal(locationObject)\n\n\t// Write content-type, statuscode, payload\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(201)\n\tfmt.Fprintf(w, \"%s\", uj)\n\n}", "title": "" }, { "docid": "4318cf430e663effe70354394cb1ed42", "score": "0.45944276", "text": "func (s *Storage) Load(id string) []byte {\n\ts.lock.Lock()\n\tif chunk, exists := s.chunks[id]; exists {\n\t\ts.lock.Unlock()\n\t\ts.stack.Touch(id)\n\t\treturn chunk\n\t}\n\ts.lock.Unlock()\n\treturn nil\n}", "title": "" }, { "docid": "a66c45d04b5732e383918775c97e2b7d", "score": "0.45866716", "text": "func (puo *PropertyUpdateOne) SetLocationID(id int) *PropertyUpdateOne {\n\tpuo.mutation.SetLocationID(id)\n\treturn puo\n}", "title": "" }, { "docid": "8bbc8fc96366453ea248877043c69a21", "score": "0.45678315", "text": "func GetFromID(r *http.Request, data interface{}) error {\n\tid, err := utils.ReadIntURL(r, \"id\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := GetDB().Set(\"gorm:auto_preload\", true).First(data, id).Error; err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "70cca25551eb742731220f79aca240ad", "score": "0.45563015", "text": "func (m *MockTimeAdapter) LoadLocation(arg0 string) (*time.Location, error) {\n\tret := m.ctrl.Call(m, \"LoadLocation\", arg0)\n\tret0, _ := ret[0].(*time.Location)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "91f8f92d0e345186cc9abd5482462c1e", "score": "0.4552589", "text": "func (iuo *ImplementUpdateOne) SetLocationID(id int) *ImplementUpdateOne {\n\tiuo.mutation.SetLocationID(id)\n\treturn iuo\n}", "title": "" }, { "docid": "83f4e2b1953e8e4306ce4d4fc819ea6a", "score": "0.45377934", "text": "func (o *DeleteRoomParams) SetLocationID(locationID string) {\n\to.LocationID = locationID\n}", "title": "" }, { "docid": "4e5a5023bd6a0d7f905c7f86e6fd88a9", "score": "0.45366418", "text": "func (service *LocationService) Get(userID uint) (*models.Location, error) {\n\tvar result models.Location\n\tdb := service.Database.First(&result, \"user_id = ?\", userID)\n\n\tif db.Error != nil {\n\t\treturn nil, db.Error\n\t}\n\n\t// Get location as a geo.Point\n\ttype Location struct {\n\t\tLocation geo.Point `gorm:\"location\"`\n\t}\n\tlocation := Location{}\n\tdb = service.Database.Table(\"mob_locations\").\n\t\tSelect(\"ST_AsBinary(location) as location\").\n\t\tWhere(\"user_id = ?\", userID).\n\t\tScan(&location)\n\tif db.Error != nil {\n\t\treturn nil, db.Error\n\t}\n\n\tresult.Location = location.Location\n\n\treturn &result, nil\n}", "title": "" }, { "docid": "00833921546896fbbcf14b6c35cfe668", "score": "0.45365041", "text": "func (lh *LeaguesHandler) GetById(id string) (*model.LeagueDetails, error) {\n leagueResponse := model.LeagueDetails{}\n\n idInt, err := strconv.Atoi(id)\n\n if err != nil {\n return &leagueResponse, nil\n }\n\n data, err := (*lh.LeagueDetailsRepository).GetById(idInt)\n\n if err != nil {\n return nil, err\n }\n\n return data, nil\n}", "title": "" }, { "docid": "0cfe96bd34f96c1f1d6a9f5ef46f7d71", "score": "0.45294687", "text": "func (s *Store) Load(path string) (*Example, error) {\n\tparts := strings.Split(path, \"/\")\n\tif len(parts) == 2 && parts[1] == \"\" {\n\t\treturn emptyExample, nil\n\t} else if len(parts) != 3 {\n\t\treturn nil, errcode.New(http.StatusNotFound, \"Invalid URL: %s\", path)\n\t}\n\n\tif parts[1] == \"saved\" {\n\t\treturn s.loadFromParse(parts[2])\n\t}\n\tcategory := s.DB.FindCategory(parts[1])\n\tif category == nil {\n\t\treturn nil, errcode.New(http.StatusNotFound, \"Could not find category: %s\", parts[1])\n\t}\n\texample := category.FindExample(parts[2])\n\tif example == nil {\n\t\treturn nil, errcode.New(http.StatusNotFound, \"Could not find example: %s\", parts[2])\n\t}\n\treturn example, nil\n}", "title": "" }, { "docid": "27c7645cc255e03693dfabcdf3838799", "score": "0.4528049", "text": "func (e *Location) Load(m *model.Location) {\n\te.Info = m.Info\n\te.InfoFormat = m.InfoFormat\n\tif m.PostalAddress != nil {\n\t\tpostalAddress := new(PostalAddress)\n\t\tpostalAddress.Country = m.PostalAddress.Country\n\t\tpostalAddress.Territory = m.PostalAddress.Territory\n\t\tpostalAddress.District = m.PostalAddress.District\n\t\tpostalAddress.City = m.PostalAddress.City\n\t\tpostalAddress.Division = m.PostalAddress.Division\n\t\tpostalAddress.Neighborhood = m.PostalAddress.Neighborhood\n\t\tpostalAddress.LeadingStreetDirection = m.PostalAddress.LeadingStreetDirection\n\t\tpostalAddress.Street = m.PostalAddress.Street\n\t\tpostalAddress.TrailingStreetSuffix = m.PostalAddress.TrailingStreetSuffix\n\t\tpostalAddress.StreetSuffix = m.PostalAddress.StreetSuffix\n\t\tpostalAddress.HouseNumber = m.PostalAddress.HouseNumber\n\t\tpostalAddress.HouseNumberSuffix = m.PostalAddress.HouseNumberSuffix\n\t\tpostalAddress.Landmark = m.PostalAddress.Landmark\n\t\tpostalAddress.Location = m.PostalAddress.Location\n\t\tpostalAddress.Floor = m.PostalAddress.Floor\n\t\tpostalAddress.Name = m.PostalAddress.Name\n\t\tpostalAddress.PostalCode = m.PostalAddress.PostalCode\n\t\tpostalAddress.Building = m.PostalAddress.Building\n\t\tpostalAddress.Unit = m.PostalAddress.Unit\n\t\tpostalAddress.Room = m.PostalAddress.Room\n\t\tpostalAddress.Seat = m.PostalAddress.Seat\n\t\tpostalAddress.PlaceType = m.PostalAddress.PlaceType\n\t\tpostalAddress.Community = m.PostalAddress.Community\n\t\tpostalAddress.POBox = m.PostalAddress.POBox\n\t\tpostalAddress.AdditionalCode = m.PostalAddress.AdditionalCode\n\t\tpostalAddress.Road = m.PostalAddress.Road\n\t\tpostalAddress.RoadSection = m.PostalAddress.RoadSection\n\t\tpostalAddress.RoadBranch = m.PostalAddress.RoadBranch\n\t\tpostalAddress.RoadSubBranch = m.PostalAddress.RoadSubBranch\n\t\tpostalAddress.RoadPreModifier = m.PostalAddress.RoadPreModifier\n\t\tpostalAddress.RoadPostModifier = m.PostalAddress.RoadPostModifier\n\t\tpostalAddress.GPSCoords = m.PostalAddress.GPSCoords\n\n\t\te.PostalAddress = postalAddress\n\t}\n\tif m.Placement != nil {\n\t\tplacement := new(Placement)\n\t\tplacement.Row = m.Placement.Row\n\t\tplacement.Rack = m.Placement.Rack\n\t\tplacement.RackOffsetUnits = m.Placement.RackOffsetUnits\n\t\tplacement.RackOffset = m.Placement.RackOffset\n\n\t\te.Placement = placement\n\t}\n}", "title": "" }, { "docid": "6554ba37c32943f61daa61940eceb16d", "score": "0.45268473", "text": "func (r *Reservation) Load(reservId uint) error {\n\tif err := conn.GetDB().Where(\"id = ?\", reservId).First(r).Error; err != nil && err == gorm.ErrRecordNotFound {\n\t\treturn fmt.Errorf(\"Apartment reservation not found\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "a0d538eb63486ab0d0e6e1af61cb7159", "score": "0.4507529", "text": "func LocatorID(id string) Locator {\n\treturn Locator(url.QueryEscape(\"id:\") + id)\n}", "title": "" }, { "docid": "e1ab753a3d6d7c049f3c49c0b528286f", "score": "0.45009986", "text": "func (d *Dao) Load(context *endly.Context, source *url.Resource) (*model.Workflow, error) {\n\tresource, err := context.ExpandResource(source)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresult := &model.Workflow{}\n\tvar state = data.NewMap()\n\terr = d.Dao.Load(state, resource, result)\n\tif err == nil {\n\t\tif err = result.Init(); err == nil {\n\t\t\terr = result.Validate()\n\t\t}\n\t}\n\treturn result, err\n}", "title": "" }, { "docid": "8291ce21e5f37d7e4d92d4f3e4ec735d", "score": "0.44947597", "text": "func loadAsset(id string) image.Image {\n\tasset, _ := imageMap[id]\n\tstream, _ := data.Asset(asset)\n\n\treturn decode(bytes.NewReader(stream))\n}", "title": "" }, { "docid": "082ad33f4fe54b71a1c968e0727e4f78", "score": "0.44749787", "text": "func LoadLocation(name string) (*Location, error) {\n\tif name == \"\" || name == \"UTC\" {\n\t\treturn UTC, nil\n\t}\n\tif containsDotDot(name) || name[0] == '/' || name[0] == '\\\\' {\n\t\t// No valid IANA Time Zone name contains a single dot,\n\t\t// much less dot dot. Likewise, none begin with a slash.\n\t\treturn nil, errLocation\n\t}\n\tzoneinfoOnce.Do(func() {\n\t\tenv, _ := syscall.Getenv(\"ZONEINFO\")\n\t\tzoneinfo = &env\n\t})\n\tvar firstErr error\n\tif *zoneinfo != \"\" {\n\t\tif zoneData, err := loadTzinfoFromDirOrZip(*zoneinfo, name); err == nil {\n\t\t\tif z, err := LoadLocationFromTZData(name, zoneData); err == nil {\n\t\t\t\treturn z, nil\n\t\t\t}\n\t\t\tfirstErr = err\n\t\t} else if !os.IsNotExist(err) {\n\t\t\tfirstErr = err\n\t\t}\n\t}\n\tif z, err := loadLocation(name, zoneSources); err == nil {\n\t\treturn z, nil\n\t} else if firstErr == nil {\n\t\tfirstErr = err\n\t}\n\treturn nil, firstErr\n}", "title": "" }, { "docid": "ee875e051bc89adba39b803654687d73", "score": "0.4474652", "text": "func LoadScenario(scenarioName string) {\n\tloadScenario(scenarioName, true)\n}", "title": "" }, { "docid": "606de86295afb065b546f5f927f0db69", "score": "0.44724235", "text": "func (pu *PropertyUpdate) SetLocationID(id int) *PropertyUpdate {\n\tpu.mutation.SetLocationID(id)\n\treturn pu\n}", "title": "" }, { "docid": "ac536896b1a557d17e577ac7f2a4b90e", "score": "0.44702655", "text": "func (woc *WorkOrderCreate) SetLocationID(id int) *WorkOrderCreate {\n\twoc.mutation.SetLocationID(id)\n\treturn woc\n}", "title": "" }, { "docid": "523f950386337d46c1d9945e8a55850a", "score": "0.4461451", "text": "func (sm *SManager) Load(clid uint64) (manager.Thing, error) {\n\treturn loadSeries(clid, sm.backend.DB)\n}", "title": "" }, { "docid": "bf394de11bff0416f707934021d5d8ce", "score": "0.44602147", "text": "func load_row (id string) {\n fmt.Println (\"Load the row in test_simple_table_1\")\n\ttestutil.Fetch (\"Select Name from test_simple_table_1 where ID = \" + id);\n}", "title": "" }, { "docid": "ea6fbcdec044a30a1f02dc3a0eb2f901", "score": "0.44598454", "text": "func (s *FileSystemStore) Get(id string, dest interface{}) error {\n\tf, err := s.fs.Open(filepath.Join(s.dir, id) + \".json\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\tdec := json.NewDecoder(f)\n\n\treturn dec.Decode(dest)\n}", "title": "" }, { "docid": "a4dd532947793b1183c4c3e0f4a81e7f", "score": "0.4453643", "text": "func (g *Target) ID(id string) *Target {\n\tg.filters = append(g.filters, func(v interface{}) bool {\n\t\ttarget := convert(v)\n\t\tif target == nil {\n\t\t\treturn false\n\t\t}\n\t\tshared.Debugf(\"%s == %s -> %t\\n\", id, aws.StringValue(target.Id), id == aws.StringValue(target.Id))\n\t\treturn id == aws.StringValue(target.Id)\n\t})\n\treturn g\n}", "title": "" }, { "docid": "3e93604171c9bce3f97e6c6e923cf5c9", "score": "0.44328105", "text": "func (t *Traveler) TravelID(ctx context.Context, id int64) error {\n\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn nil\n\tdefault:\n\t\t// pass\n\t}\n\n\topts := t.Options\n\n\tf, err := wof_reader.LoadBytes(ctx, opts.Reader, id)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn t.TravelFeature(ctx, f)\n}", "title": "" }, { "docid": "6024a65d637906c40b7b517c1ff152ee", "score": "0.44323152", "text": "func (m NoMDEntries) HasLocationID() bool {\n\treturn m.Has(tag.LocationID)\n}", "title": "" }, { "docid": "888dddaea47125a386b527259483e699", "score": "0.44290626", "text": "func (m NoMDEntries) GetLocationID() (f field.LocationIDField, err quickfix.MessageRejectError) {\n\terr = m.Get(&f)\n\treturn\n}", "title": "" }, { "docid": "c2789de6a6d466c075bfb247bc30b1d7", "score": "0.44200268", "text": "func (iu *ImplementUpdate) SetLocationID(id int) *ImplementUpdate {\n\tiu.mutation.SetLocationID(id)\n\treturn iu\n}", "title": "" }, { "docid": "d10e98d8c9996e6aa8048b9aa0ccf9e2", "score": "0.44052076", "text": "func LoadOne(l Loader, id ID) (GraphNote, error) {\n\tns, err := l.Load([]ID{id})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ns[0], nil\n}", "title": "" }, { "docid": "63f250cc41e8582c87d7ae5d34018740", "score": "0.44050694", "text": "func IDLT(id int) predicate.InstructorRoom {\n\treturn predicate.InstructorRoom(func(s *sql.Selector) {\n\t\ts.Where(sql.LT(s.C(FieldID), id))\n\t})\n}", "title": "" }, { "docid": "ab29e2cb8bcfebd1fef37ca32706f7a3", "score": "0.43985653", "text": "func (o *SyntheticsPrivateLocation) GetId() string {\n\tif o == nil || o.Id == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Id\n}", "title": "" }, { "docid": "7fcddf09d3c15aab97ed02bd70cd7b25", "score": "0.43971777", "text": "func (g *IngressConverter) getLoadbalanceByID(ns, regionIDPair string) (*cloud.LoadBalanceObject, error) {\n\tvar lbObj *cloud.LoadBalanceObject\n\tvar err error\n\tstrs := g.splitRegionIDPair(regionIDPair)\n\t// only has id\n\tif len(strs) == 1 {\n\t\tobj, ok := g.lbIDCache.Get(g.defaultRegion + \":\" + strs[0])\n\t\tif ok {\n\t\t\tif lbObj, ok = obj.(*cloud.LoadBalanceObject); !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"get obj from lb id cache is not LoadBalanceObject\")\n\t\t\t}\n\t\t\treturn lbObj, nil\n\t\t}\n\t\tif g.lbClient.IsNamespaced() {\n\t\t\tlbObj, err = g.lbClient.DescribeLoadBalancerWithNs(ns, g.defaultRegion, strs[0], \"\")\n\t\t} else {\n\t\t\tlbObj, err = g.lbClient.DescribeLoadBalancer(g.defaultRegion, strs[0], \"\")\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else if len(strs) == 2 {\n\t\t// region and id\n\t\tobj, ok := g.lbIDCache.Get(regionIDPair)\n\t\tif ok {\n\t\t\tif lbObj, ok = obj.(*cloud.LoadBalanceObject); !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"get obj from lb id cache is not LoadBalanceObject\")\n\t\t\t}\n\t\t\treturn lbObj, nil\n\t\t}\n\t\tif g.lbClient.IsNamespaced() {\n\t\t\tlbObj, err = g.lbClient.DescribeLoadBalancerWithNs(ns, strs[0], strs[1], \"\")\n\t\t} else {\n\t\t\tlbObj, err = g.lbClient.DescribeLoadBalancer(strs[0], strs[1], \"\")\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else {\n\t\t// invalid format\n\t\tblog.Warnf(\"lbid %s invalid\", regionIDPair)\n\t\treturn nil, fmt.Errorf(\"lbid %s invalid\", regionIDPair)\n\t}\n\tg.lbIDCache.SetDefault(lbObj.Region+\":\"+lbObj.LbID, lbObj)\n\tg.lbNameCache.SetDefault(lbObj.Region+\":\"+lbObj.Name, lbObj)\n\treturn lbObj, nil\n}", "title": "" }, { "docid": "7e556e33624c7e90da96fcb21159b065", "score": "0.43961248", "text": "func (r *DocumentRepository) LoadByID(ID string) (*document.Document, error) {\n\tv, ok := r.m.Load(ID)\n\tif !ok {\n\t\t// Match upper/db4 db.ErrNoMoreRows\n\t\treturn nil, errors.New(`upper: no more rows in this result set`)\n\t}\n\n\td := v.(document.Document)\n\treturn &d, nil\n}", "title": "" }, { "docid": "3c08cc7db642318baba6f24a8bc0fc35", "score": "0.43778753", "text": "func GetWorkloadByID(id string) (result wltypes.RDTWorkLoad, err error) {\n\tif workloadDatabase == nil {\n\t\treturn result, rmderror.NewAppError(http.StatusInternalServerError, \"Service database not initialized\")\n\t}\n\n\tresult, err = workloadDatabase.GetWorkloadByID(id)\n\tif err != nil {\n\t\te := rmderror.NewAppError(rmderror.NotFound, \"Failed to get workload by ID from database\", err)\n\t\treturn result, e\n\t}\n\treturn result, nil\n}", "title": "" }, { "docid": "12c5d30fcd6848b75fb10c5d0fd18170", "score": "0.43657506", "text": "func (o *GetRuleParams) WithLocationID(locationID string) *GetRuleParams {\n\to.SetLocationID(locationID)\n\treturn o\n}", "title": "" }, { "docid": "e4d27b66ca48285e7a527b4c46d06845", "score": "0.43612683", "text": "func (puo *ProjectUpdateOne) SetLocationID(id int) *ProjectUpdateOne {\n\tpuo.mutation.SetLocationID(id)\n\treturn puo\n}", "title": "" }, { "docid": "9ae635483273c62452a5f073701127e4", "score": "0.43328765", "text": "func (s *StepInstance) Load() error {\n\tif err := db.SelectStruct(constants.TableCoreBPMStepInstances, s, &db.Options{\n\t\tConditions: builder.Equal(\"id\", s.ID),\n\t}); err != nil {\n\t\treturn customerror.New(http.StatusInternalServerError, \"step instance load\", err.Error())\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "5902c8c895a16be70eca7b61e015d452", "score": "0.4317895", "text": "func (fs *FSAvatarStore) location(id string) string {\n\tfs.once.Do(func() { fs.ctcTable = crc64.MakeTable(crc64.ECMA) })\n\tchecksum64 := crc64.Checksum([]byte(id), fs.ctcTable)\n\tpartition := checksum64 % 100\n\treturn path.Join(fs.storePath, fmt.Sprintf(\"%02d\", partition))\n}", "title": "" }, { "docid": "f487227b1e2e74da1545676f6e36b8b7", "score": "0.4312383", "text": "func HandleJobByLocationID(c *gin.Context) {\n\toid := c.Params.ByName(\"oid\")\n\tzipcodeID, err := strconv.Atoi(oid)\n\tif err != nil {\n\t\tlog.Println(\"HandleJobByLocationID: invalid id:\" + oid + \" cannot be converted to int.\")\n\t\treturn\n\t}\n\tsid := 245 // this is harcoded, as it came from the old system.\n\t// jobs/open/%s/%s/%s/%d\n\tzipcodes, err := models.GetZipcodeByID(zipcodeID)\n\tif err != nil {\n\t\tlog.Println(\"HandleJobByLocationID: model problem:\" + oid + \" cannot be converted to int.\")\n\t\treturn\n\t}\n\tif len(zipcodes) == 0 {\n\t\tlog.Printf(\"HandleJobByLocationID: No records found for zipcode:%d\\n\", zipcodeID)\n\t\treturn\n\t}\n\n\tc.Redirect(http.StatusFound, utility.GetCanonicalLink(sid, \"\", zipcodes[0].State, zipcodes[0].CityName, strconv.Itoa(zipcodes[0].ID)))\n\n}", "title": "" }, { "docid": "c1858e26088b7131ce81db858744fdb8", "score": "0.4295132", "text": "func NewResourceLocation(reqURL *url.URL, id string) string {\n\tvar u url.URL\n\tu = *reqURL\n\tu.Path = path.Join(u.Path, id)\n\tu.RawQuery = \"\"\n\tu.Fragment = \"\"\n\treturn u.String()\n}", "title": "" }, { "docid": "e42670175e8432bcf92e1fdec3a2df10", "score": "0.42924225", "text": "func (m *TestIdentityRepository) Load(ctx context.Context, id uuid.UUID) (*account.Identity, error) {\n\tif m.Identity == nil {\n\t\treturn nil, errors.New(\"not found\")\n\t}\n\treturn m.Identity, nil\n}", "title": "" }, { "docid": "93542bc0b130dfdfce8afa0dec2002a5", "score": "0.4281352", "text": "func FromGlobalID(id string) *Local {\n\tbytes, err := base64.StdEncoding.DecodeString(id)\n\tif err != nil {\n\t\treturn nil\n\t}\n\n\ttokens := strings.Split(string(bytes), \":\")\n\tif len(tokens) != 2 {\n\t\treturn nil\n\t}\n\n\treturn &Local{\n\t\tType: tokens[0],\n\t\tID: tokens[1],\n\t}\n}", "title": "" }, { "docid": "7f0799899efcd5725726cd9b49420ed4", "score": "0.42735443", "text": "func LoadExercise(exerciseID string) (shared.Exercise, error) {\n\texercise, err := ExercisesModule.Datastore.QueryExercise(exerciseID)\n\treturn exercise, err\n}", "title": "" }, { "docid": "11c7ee5b92be7a4d6b8e28e0e3405235", "score": "0.42729214", "text": "func LoadAndLockRunByID(ctx context.Context, db gorp.SqlExecutor, id int64, loadOpts LoadRunOptions) (*sdk.WorkflowRun, error) {\n\tctx, end := telemetry.Span(ctx, \"workflow.LoadAndLockRunByID\")\n\tdefer end()\n\tquery := fmt.Sprintf(`select %s\n\tfrom workflow_run\n\twhere workflow_run.id = $1 for update skip locked`, wfRunfields)\n\treturn loadRun(ctx, db, loadOpts, query, id)\n}", "title": "" }, { "docid": "d7702ef3496d167e3216cb1755ca3ae4", "score": "0.427104", "text": "func LoadRunByJobID(ctx context.Context, db gorp.SqlExecutor, id int64, loadOpts LoadRunOptions) (*sdk.WorkflowRun, error) {\n\tctx, end := telemetry.Span(ctx, \"workflow.LoadRunByJobID\")\n\tdefer end()\n\tquery := fmt.Sprintf(`select %s\n\tfrom workflow_run\n\tjoin workflow_node_run on workflow_run.id = workflow_node_run.workflow_run_id\n\tjoin workflow_node_run_job on workflow_node_run.id = workflow_node_run_job.workflow_node_run_id\n\twhere workflow_node_run_job.id = $1`, wfRunfields)\n\treturn loadRun(ctx, db, loadOpts, query, id)\n}", "title": "" }, { "docid": "2b3d765de3293b9d565c9b27aea35631", "score": "0.4263843", "text": "func (gdb *GostDatabase) GetThingsByLocation(id interface{}, qo *odata.QueryOptions) ([]*entities.Thing, int, bool, error) {\n\tintID, ok := ToIntID(id)\n\tif !ok {\n\t\treturn nil, 0, false, gostErrors.NewRequestNotFound(errors.New(\"Location does not exist\"))\n\t}\n\n\tquery, qi := gdb.QueryBuilder.CreateQuery(&entities.Thing{}, &entities.Location{}, intID, qo)\n\tcountSQL := gdb.QueryBuilder.CreateCountQuery(&entities.Thing{}, &entities.Location{}, intID, qo)\n\treturn processThings(gdb.Db, query, qo, qi, countSQL)\n}", "title": "" }, { "docid": "04e8855518374544a6aff2b191b83dcd", "score": "0.42533728", "text": "func (x *indexer) Lookup(id string) (int, bool) {\n\ti, ok := x.ids[id]\n\treturn i, ok\n}", "title": "" }, { "docid": "d18ba8c11c2f009212b392fb1a4c687e", "score": "0.42512035", "text": "func (o *SyntheticsPrivateLocation) HasId() bool {\n\tif o != nil && o.Id != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "ea263f68d06b2e0223c9eb5aa03d7bf3", "score": "0.4244041", "text": "func loadAthlete(w http.ResponseWriter, r *http.Request) {\n\t w.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\") \n\t\n\t/**\n\tGet athlete if passed in\n\t*/\n\tvars := mux.Vars(r)\n athleteIdStr := vars[\"athleteId\"]\n\tathleteId, _ := strconv.ParseInt(athleteIdStr, 0, 64)\n\tfmt.Printf(\"iddd is\")\n\tfmt.Printf(athleteIdStr)\n\t\n\taccessToken, _ := getStravaConfig()\n\tclient := strava.NewClient(accessToken)\n\t\n\n\t// returns a AthleteDetailed object, the second variable I think is errors\n\tif(athleteId != 0){\n\t\tservice := strava.NewAthletesService(client)\n\t\tathlete, _ := service.Get(athleteId).Do()\n\t\t\n\t\tif err := json.NewEncoder(w).Encode(athlete); err != nil {\n panic(err)\n }\n\t}else{\n\t\tservice := strava.NewCurrentAthleteService(client)\n\t\tathlete, _ := service.Get().Do()\n\t\t\n\t\tif err := json.NewEncoder(w).Encode(athlete); err != nil {\n panic(err)\n }\n\t}\n\t\n\t\n\t\n\t\n\t\n\t\n}", "title": "" }, { "docid": "d93206a6e893fb6c4484a18971679555", "score": "0.4243638", "text": "func loadIds(ids []string) (loadResult, error) {\n\troutes := make(routeList, len(ids))\n\tfor i, id := range ids {\n\t\troutes[i] = &eskip.Route{Id: id}\n\t}\n\n\treturn loadResult{routes: routes}, nil\n}", "title": "" }, { "docid": "39b2351b850620519b679fdfd05327d2", "score": "0.42419022", "text": "func (m *GormResourceRepository) Load(ctx context.Context, id string) (*Resource, error) {\n\tdefer goa.MeasureSince([]string{\"goa\", \"db\", \"resource\", \"load\"}, time.Now())\n\n\tvar native Resource\n\terr := m.db.Table(m.TableName()).Preload(\"ResourceType\").Where(\"resource_id = ?\", id).Find(&native).Error\n\tif err == gorm.ErrRecordNotFound {\n\t\treturn nil, errs.WithStack(errors.NewNotFoundError(\"resource\", id))\n\t}\n\n\treturn &native, errs.WithStack(err)\n}", "title": "" }, { "docid": "e7e083bf7dea939607d075a005523303", "score": "0.4238561", "text": "func (eq *eventQueryImpl) LoadEventByID(id uint64) (*model.Event, error) {\n\tlogCtx := fmt.Sprintf(\"%T.LoadEventByID\", *eq)\n\n\tvar (\n\t\tresp model.Event\n\t\tticketIds pq.Int64Array\n\t)\n\n\tsq := `SELECT id, \"title\", \"locationId\", \n\t\t\t\t\"description\", \"startDate\", \n\t\t\t\t\"endDate\", \"ticketId\", \n\t\t\t\t\"createdAt\", \"updatedAt\", \"deletedAt\"\n\t\t FROM \"events\"\n\t\t WHERE \"id\"=$1 AND \"deletedAt\" ISNULL`\n\n\tstmt, err := eq.dbRead.Prepare(sq)\n\tif err != nil {\n\t\thelper.Log(logrus.ErrorLevel, err.Error(), logCtx, \"error_prepare_database\")\n\t\treturn nil, err\n\t}\n\n\tif err := stmt.QueryRow(id).Scan(\n\t\t&resp.ID, &resp.Title, &resp.LocationID,\n\t\t&resp.Description, &resp.StartDate, &resp.EndDate, &ticketIds,\n\t\t&resp.CreatedAt, &resp.UpdatedAt, &resp.DeletedAt,\n\t); err != nil {\n\t\thelper.Log(logrus.ErrorLevel, err.Error(), logCtx, \"error_exec_database\")\n\t\treturn nil, err\n\t}\n\n\ttemp := []int64(ticketIds)\n\tticketIDs := make([]uint64, 0)\n\tfor _, i := range temp {\n\t\tticketIDs = append(ticketIDs, uint64(i))\n\t}\n\tresp.TicketID = ticketIDs\n\n\treturn &resp, nil\n}", "title": "" }, { "docid": "8d9a028c0b19658e1c14a3992a78fa8a", "score": "0.42377895", "text": "func (mml *MaxmindLocator) load(ctx context.Context) (*geoip2.Reader, error) {\n\ttgz, err := mml.dataSource.Get(ctx)\n\tif err == content.ErrNoChange {\n\t\treturn mml.maxmind, nil\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdata, err := tarreader.FromTarGZ(tgz, \"GeoLite2-City.mmdb\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn geoip2.FromBytes(data)\n}", "title": "" }, { "docid": "02ec6f5e4a37630b14b7290d57c3832a", "score": "0.4235773", "text": "func (_m *MockClusterRepo) LoadByID(id uint64) (*Cluster, error) {\n\tret := _m.Called(id)\n\n\tvar r0 *Cluster\n\tif rf, ok := ret.Get(0).(func(uint64) *Cluster); ok {\n\t\tr0 = rf(id)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(*Cluster)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(uint64) error); ok {\n\t\tr1 = rf(id)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "title": "" }, { "docid": "b7b58ddc4d2ce52163641db32cb37620", "score": "0.4233581", "text": "func (b *Block) loadBlock(ID string, labels []string) (block *Block, err error) {\n\tvar u *url.URL\n\n\tif u, err = url.Parse(ID); err != nil {\n\t\tlog.Fatalf(\"Failed to parse ID (%s) error (%v)\\n\", ID, err)\n\t}\n\n\tswitch u.Scheme {\n\tcase \"cache\":\n\t\treturn b.loadBlockFromCache(u, labels)\n\tcase \"http\", \"https\":\n\t\treturn b.loadBlockFromNetwork(ID, labels)\n\t}\n\n\t// TODO: fix this hack\n\tswitch ID {\n\tcase \"io.pavedroad.core.loggers.application\":\n\t\tb = &PRApplicationLogger\n\t\tbreak\n\t}\n\n\treturn b, nil\n}", "title": "" }, { "docid": "fdafad034d2a9241663d9d9688033048", "score": "0.42258272", "text": "func (ims Stories) WithID(id string) (*entities.Story, error) {\n\tif _, ok := ims.Collection[id]; !ok {\n\t\treturn nil, fmt.Errorf(\"Cannot find story with ID: %s\", id)\n\t}\n\treturn ims.Collection[id], nil\n}", "title": "" }, { "docid": "34e8ccb116932ed1f0776263fabc8b7b", "score": "0.4225462", "text": "func GetLocation(c *gin.Context) {\n\tid := c.Param(\"id\")\n\tlocation := new(Location)\n\tresult := location.GetRedisCache(id)\n\tif result.Key == \"\" {\n\t\tstatus := http.StatusNotFound\n\t\tc.JSON(status, http.StatusText(status))\n\t\treturn\n\t}\n\tc.JSON(http.StatusOK, result)\n}", "title": "" }, { "docid": "b9a908eeca9acf8858ef9658894d6740", "score": "0.42212483", "text": "func (c *Client) LocationDeleteById(ctx context.Context, id string) error {\n\n\t_, err := c.db.ExecContext(ctx, `DELETE FROM location WHERE id = $1`, id)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n\n}", "title": "" }, { "docid": "27af9da48d162679c576ef750edccacc", "score": "0.42200276", "text": "func (t *T) LoadDetails(c context.Context) error {\n\tvar d detail.D\n\n\tclient, err := datastore.NewClient(c, \"kids-192720\")\n\tif err != nil {\n\t\treturn err\n\t\t// log.Fatal(err)\n\t}\n\n\terr = client.Get(c, getDetailsKey(c), &d)\n\tif err != nil || d.FinalistCount == 0 {\n\t\treturn err\n\t}\n\tmylogging.AddLog(\"got details!: \", d)\n\tt.Details = d\n\treturn nil\n}", "title": "" }, { "docid": "03f3f6bdb949f7820c16be3d298ba538", "score": "0.4217234", "text": "func getStoreByID(id uint) (*Store, bool) {\n\tsto := &Store{}\n\terr := GetDB().Table(\"stores\").Where(\"id = ?\", id).First(sto).Error\n\tif err != nil {\n\t\tif err == gorm.ErrRecordNotFound {\n\t\t\treturn nil, true\n\t\t}\n\t\treturn nil, false\n\t}\n\treturn sto, true\n}", "title": "" }, { "docid": "4d5646c4982356d70d9e9e4ae2b9b232", "score": "0.42168704", "text": "func (o *SyntheticsPrivateLocation) GetIdOk() (*string, bool) {\n\tif o == nil || o.Id == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Id, true\n}", "title": "" }, { "docid": "d452665aed2712df2871c87ac7887061", "score": "0.42139938", "text": "func getRecordFromID(id string) schema.Record {\n\tif id[:2] == \"lc\" {\n\t\treturn localRecordList[id]\n\t} else {\n\t\treturn sourcesRecordList[id]\n\t}\n}", "title": "" }, { "docid": "2bad342e0029263190c3667e66e578a5", "score": "0.42129192", "text": "func LoadByID(db gorp.SqlExecutor, id int64, clearPassword bool) (*sdk.ProjectPlatform, error) {\n\tvar pp dbProjectPlatform\n\tif err := db.SelectOne(&pp, \"SELECT * from project_platform WHERE id = $1\", id); err != nil {\n\t\tif err == sql.ErrNoRows {\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn nil, err\n\t}\n\tfor k, v := range pp.Config {\n\t\tif v.Type == sdk.PlatformConfigTypePassword {\n\t\t\tif clearPassword {\n\t\t\t\tsecret, errD := decryptPlatformValue(v.Value)\n\t\t\t\tif errD != nil {\n\t\t\t\t\treturn nil, sdk.WrapError(errD, \"LoadPlatformByID> Cannot decrypt password\")\n\t\t\t\t}\n\t\t\t\tv.Value = string(secret)\n\t\t\t\tpp.Config[k] = v\n\t\t\t} else {\n\t\t\t\tv.Value = sdk.PasswordPlaceholder\n\t\t\t\tpp.Config[k] = v\n\t\t\t}\n\t\t}\n\t}\n\tres := sdk.ProjectPlatform(pp)\n\treturn &res, nil\n}", "title": "" }, { "docid": "6a3818f7265817064167e7066738ef5c", "score": "0.4211178", "text": "func (pu *ProjectUpdate) SetLocationID(id int) *ProjectUpdate {\n\tpu.mutation.SetLocationID(id)\n\treturn pu\n}", "title": "" } ]
5b7d21c4525247f29016135846ce51f0
NewStatusEvent send node state event after node is successful accepted and each hour
[ { "docid": "7a8fb116623ee070a4b34c2423d10f20", "score": "0.58722925", "text": "func NewStatusEvent(ctx context.Context) error {\n\tvar (\n\t\te = envs.Get().GetExporter()\n\t)\n\n\te.Resources(envs.Get().GetState().Node().Status)\n\treturn nil\n}", "title": "" } ]
[ { "docid": "7b49c95ec66931fa30a56c519b236b97", "score": "0.64050853", "text": "func (uc *UpstreamController) updateNodeStatus() {\n\tfor {\n\t\tselect {\n\t\tcase <-beehiveContext.Done():\n\t\t\tklog.Warning(\"stop updateNodeStatus\")\n\t\t\treturn\n\t\tcase msg := <-uc.nodeStatusChan:\n\t\t\tklog.V(5).Infof(\"message: %s, operation is: %s, and resource is %s\", msg.GetID(), msg.GetOperation(), msg.GetResource())\n\n\t\t\tdata, err := msg.GetContentData()\n\t\t\tif err != nil {\n\t\t\t\tklog.Warningf(\"message: %s process failure, get content data failed with error: %s\", msg.GetID(), err)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tnamespace, err := messagelayer.GetNamespace(msg)\n\t\t\tif err != nil {\n\t\t\t\tklog.Warningf(\"message: %s process failure, get namespace failed with error: %s\", msg.GetID(), err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tname, err := messagelayer.GetResourceName(msg)\n\t\t\tif err != nil {\n\t\t\t\tklog.Warningf(\"message: %s process failure, get resource name failed with error: %s\", msg.GetID(), err)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tswitch msg.GetOperation() {\n\t\t\tcase model.InsertOperation:\n\t\t\t\t_, err := uc.kubeClient.CoreV1().Nodes().Get(context.Background(), name, metaV1.GetOptions{})\n\t\t\t\tif err == nil {\n\t\t\t\t\tklog.Infof(\"node: %s already exists, do nothing\", name)\n\t\t\t\t\tuc.nodeMsgResponse(name, namespace, common.MessageSuccessfulContent, msg)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tif !errors.IsNotFound(err) {\n\t\t\t\t\terrLog := fmt.Sprintf(\"get node %s info error: %v , register node failed\", name, err)\n\t\t\t\t\tklog.Error(errLog)\n\t\t\t\t\tuc.nodeMsgResponse(name, namespace, errLog, msg)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tnode := &v1.Node{}\n\t\t\t\terr = json.Unmarshal(data, node)\n\t\t\t\tif err != nil {\n\t\t\t\t\terrLog := fmt.Sprintf(\"message: %s process failure, unmarshal marshaled message content with error: %s\", msg.GetID(), err)\n\t\t\t\t\tklog.Error(errLog)\n\t\t\t\t\tuc.nodeMsgResponse(name, namespace, errLog, msg)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tif _, err = uc.createNode(name, node); err != nil {\n\t\t\t\t\terrLog := fmt.Sprintf(\"create node %s error: %v , register node failed\", name, err)\n\t\t\t\t\tklog.Error(errLog)\n\t\t\t\t\tuc.nodeMsgResponse(name, namespace, errLog, msg)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tuc.nodeMsgResponse(name, namespace, common.MessageSuccessfulContent, msg)\n\n\t\t\tcase model.UpdateOperation:\n\t\t\t\tnodeStatusRequest := &edgeapi.NodeStatusRequest{}\n\t\t\t\terr := json.Unmarshal(data, nodeStatusRequest)\n\t\t\t\tif err != nil {\n\t\t\t\t\tklog.Warningf(\"message: %s process failure, unmarshal marshaled message content with error: %s\", msg.GetID(), err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tgetNode, err := uc.kubeClient.CoreV1().Nodes().Get(context.Background(), name, metaV1.GetOptions{})\n\t\t\t\tif errors.IsNotFound(err) {\n\t\t\t\t\tklog.Warningf(\"message: %s process failure, node %s not found\", msg.GetID(), name)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tif err != nil {\n\t\t\t\t\tklog.Warningf(\"message: %s process failure with error: %s, namespaces: %s name: %s\", msg.GetID(), err, namespace, name)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\t// TODO: comment below for test failure. Needs to decide whether to keep post troubleshoot\n\t\t\t\t// In case the status stored at metadata service is outdated, update the heartbeat automatically\n\t\t\t\tfor i := range nodeStatusRequest.Status.Conditions {\n\t\t\t\t\tif time.Since(nodeStatusRequest.Status.Conditions[i].LastHeartbeatTime.Time) > time.Duration(uc.config.NodeUpdateFrequency)*time.Second {\n\t\t\t\t\t\tnodeStatusRequest.Status.Conditions[i].LastHeartbeatTime = metaV1.NewTime(time.Now())\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif getNode.Annotations == nil {\n\t\t\t\t\tgetNode.Annotations = make(map[string]string)\n\t\t\t\t}\n\t\t\t\tfor name, v := range nodeStatusRequest.ExtendResources {\n\t\t\t\t\tif name == constants.NvidiaGPUScalarResourceName {\n\t\t\t\t\t\tvar gpuStatus []types.NvidiaGPUStatus\n\t\t\t\t\t\tfor _, er := range v {\n\t\t\t\t\t\t\tgpuStatus = append(gpuStatus, types.NvidiaGPUStatus{ID: er.Name, Healthy: true})\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif len(gpuStatus) > 0 {\n\t\t\t\t\t\t\tdata, _ := json.Marshal(gpuStatus)\n\t\t\t\t\t\t\tgetNode.Annotations[constants.NvidiaGPUStatusAnnotationKey] = string(data)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdata, err := json.Marshal(v)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tklog.Warningf(\"message: %s process failure, extend resource list marshal with error: %s\", msg.GetID(), err)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tgetNode.Annotations[string(name)] = string(data)\n\t\t\t\t}\n\n\t\t\t\t// Keep the same \"VolumesAttached\" attribute with upstream,\n\t\t\t\t// since this value is maintained by kube-controller-manager.\n\t\t\t\tnodeStatusRequest.Status.VolumesAttached = getNode.Status.VolumesAttached\n\t\t\t\tif getNode.Status.DaemonEndpoints.KubeletEndpoint.Port != 0 {\n\t\t\t\t\tnodeStatusRequest.Status.DaemonEndpoints.KubeletEndpoint.Port = getNode.Status.DaemonEndpoints.KubeletEndpoint.Port\n\t\t\t\t}\n\n\t\t\t\tgetNode.Status = nodeStatusRequest.Status\n\n\t\t\t\tnode, err := uc.kubeClient.CoreV1().Nodes().UpdateStatus(context.Background(), getNode, metaV1.UpdateOptions{})\n\t\t\t\tif err != nil {\n\t\t\t\t\tklog.Warningf(\"message: %s process failure, update node failed with error: %s, namespace: %s, name: %s\", msg.GetID(), err, getNode.Namespace, getNode.Name)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tnodeID, err := messagelayer.GetNodeID(msg)\n\t\t\t\tif err != nil {\n\t\t\t\t\tklog.Warningf(\"Message: %s process failure, get node id failed with error: %s\", msg.GetID(), err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tresource, err := messagelayer.BuildResource(nodeID, namespace, model.ResourceTypeNode, name)\n\t\t\t\tif err != nil {\n\t\t\t\t\tklog.Warningf(\"Message: %s process failure, build message resource failed with error: %s\", msg.GetID(), err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tresMsg := model.NewMessage(msg.GetID()).\n\t\t\t\t\tSetResourceVersion(node.ResourceVersion).\n\t\t\t\t\tFillBody(common.MessageSuccessfulContent).\n\t\t\t\t\tBuildRouter(modules.EdgeControllerModuleName, constants.GroupResource, resource, model.ResponseOperation)\n\t\t\t\tif err = uc.messageLayer.Response(*resMsg); err != nil {\n\t\t\t\t\tklog.Warningf(\"Message: %s process failure, response failed with error: %s\", msg.GetID(), err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tklog.V(4).Infof(\"message: %s, update node status successfully, namespace: %s, name: %s\", msg.GetID(), getNode.Namespace, getNode.Name)\n\n\t\t\tdefault:\n\t\t\t\tklog.Warningf(\"message: %s process failure, node status operation: %s unsupported\", msg.GetID(), msg.GetOperation())\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tklog.V(4).Infof(\"message: %s process successfully\", msg.GetID())\n\t\t}\n\t}\n}", "title": "" }, { "docid": "e62333022ac1671284a3e17bd10dd5a9", "score": "0.6016251", "text": "func (e *Engine) nodeStatusReport() {\n\tlog.Debug(\"[nodeStatusReport] report begins\")\n\tdefer log.Debug(\"[nodeStatusReport] report ends\")\n\n\tctx, cancel := context.WithTimeout(context.Background(), time.Duration(e.config.HealthCheck.Timeout)*time.Second)\n\tdefer cancel()\n\n\tttl := int64(e.config.HeartbeatInterval * 2)\n\tif err := e.store.SetNodeStatus(ctx, ttl); err != nil {\n\t\tlog.Errorf(\"[nodeStatusReport] error when set node status: %v\", err)\n\t}\n}", "title": "" }, { "docid": "02801a21fe556f11a5f2ededbab2a0ba", "score": "0.59022903", "text": "func ReportNodeStatusUpdate() {\n\tmu.RLock()\n\tdefer mu.RUnlock()\n\n\tif reporter != nil {\n\t\tif err := reporter.statusEmitter.Emit(Status{}); err != nil {\n\t\t\t// TODO(nkryuchkov): consider returning an error and log outside the function\n\t\t\tlog.With().Error(\"Failed to emit status update\", log.Err(err))\n\t\t} else {\n\t\t\tlog.Debug(\"reported status update\")\n\t\t}\n\t}\n}", "title": "" }, { "docid": "bcbb015e43d6c640ceab81ab2a230304", "score": "0.58903897", "text": "func (m *NodeHealthManager) setNewStatus(pattern string, org string, lastCall string, nhs *exchange.NodeHealthStatus) {\n\n\tkey := getKey(pattern, org)\n\n\t// Create the pattern entry if needed\n\tpe, ok := m.Patterns[key]\n\tif !ok {\n\t\tpe = NewNHPatternEntry()\n\t\tm.Patterns[key] = pe\n\t}\n\n\t// Save cache update metadata\n\tpe.LastCallTime = lastCall\n\tpe.Updated = true\n\n\t// Cache new status if there is any\n\tif nhs != nil {\n\t\tglog.V(5).Infof(\"Node Health Manager: consuming new status: %v\", nhs)\n\t\tif pe.Nodes == nil || pe.Nodes.Nodes == nil {\n\t\t\tpe.Nodes = nhs\n\t\t} else {\n\t\t\tfor nodeid, status := range nhs.Nodes {\n\t\t\t\tpe.Nodes.Nodes[nodeid] = status\n\t\t\t}\n\t\t}\n\t}\n\n}", "title": "" }, { "docid": "50d3eb25365292cc0dab60686fe49d2e", "score": "0.56707644", "text": "func UpdateNodeStatus(c client.Client, nodeIds []string, cluster *v1alpha1.NifiCluster, state interface{}, logger logr.Logger) error {\n\ttypeMeta := cluster.TypeMeta\n\n\tfor _, nodeId := range nodeIds {\n\n\t\tif cluster.Status.NodesState == nil {\n\t\t\tswitch s := state.(type) {\n\t\t\tcase v1alpha1.GracefulActionState:\n\t\t\t\tcluster.Status.NodesState = map[string]v1alpha1.NodeState{nodeId: {GracefulActionState: s}}\n\t\t\tcase v1alpha1.ConfigurationState:\n\t\t\t\tcluster.Status.NodesState = map[string]v1alpha1.NodeState{nodeId: {ConfigurationState: s}}\n\t\t\tcase v1alpha1.InitClusterNode:\n\t\t\t\tcluster.Status.NodesState = map[string]v1alpha1.NodeState{nodeId: {InitClusterNode: s}}\n\t\t\tcase bool:\n\t\t\t\tcluster.Status.NodesState = map[string]v1alpha1.NodeState{nodeId: {PodIsReady: s}}\n\t\t\t}\n\t\t} else if val, ok := cluster.Status.NodesState[nodeId]; ok {\n\t\t\tswitch s := state.(type) {\n\t\t\tcase v1alpha1.GracefulActionState:\n\t\t\t\tval.GracefulActionState = s\n\t\t\tcase v1alpha1.ConfigurationState:\n\t\t\t\tval.ConfigurationState = s\n\t\t\tcase v1alpha1.InitClusterNode:\n\t\t\t\tval.InitClusterNode = s\n\t\t\tcase bool:\n\t\t\t\tval.PodIsReady = s\n\t\t\t}\n\t\t\tcluster.Status.NodesState[nodeId] = val\n\t\t} else {\n\t\t\tswitch s := state.(type) {\n\t\t\tcase v1alpha1.GracefulActionState:\n\t\t\t\tcluster.Status.NodesState[nodeId] = v1alpha1.NodeState{GracefulActionState: s}\n\t\t\tcase v1alpha1.ConfigurationState:\n\t\t\t\tcluster.Status.NodesState[nodeId] = v1alpha1.NodeState{ConfigurationState: s}\n\t\t\tcase v1alpha1.InitClusterNode:\n\t\t\t\tcluster.Status.NodesState[nodeId] = v1alpha1.NodeState{InitClusterNode: s}\n\t\t\tcase bool:\n\t\t\t\tcluster.Status.NodesState[nodeId] = v1alpha1.NodeState{PodIsReady: s}\n\t\t\t}\n\t\t}\n\t}\n\n\terr := c.Status().Update(context.Background(), cluster)\n\tif apierrors.IsNotFound(err) {\n\t\terr = c.Update(context.Background(), cluster)\n\t}\n\tif err != nil {\n\t\tif !apierrors.IsConflict(err) {\n\t\t\treturn errors.WrapIff(err, \"could not update Nifi node(s) %s state\", strings.Join(nodeIds, \",\"))\n\t\t}\n\t\terr := c.Get(context.TODO(), types.NamespacedName{\n\t\t\tNamespace: cluster.Namespace,\n\t\t\tName: cluster.Name,\n\t\t}, cluster)\n\t\tif err != nil {\n\t\t\treturn errors.WrapIf(err, \"could not get config for updating status\")\n\t\t}\n\n\t\tfor _, nodeId := range nodeIds {\n\n\t\t\tif cluster.Status.NodesState == nil {\n\t\t\t\tswitch s := state.(type) {\n\t\t\t\tcase v1alpha1.GracefulActionState:\n\t\t\t\t\tcluster.Status.NodesState = map[string]v1alpha1.NodeState{nodeId: {GracefulActionState: s}}\n\t\t\t\tcase v1alpha1.ConfigurationState:\n\t\t\t\t\tcluster.Status.NodesState = map[string]v1alpha1.NodeState{nodeId: {ConfigurationState: s}}\n\t\t\t\tcase v1alpha1.InitClusterNode:\n\t\t\t\t\tcluster.Status.NodesState = map[string]v1alpha1.NodeState{nodeId: {InitClusterNode: s}}\n\t\t\t\tcase bool:\n\t\t\t\t\tcluster.Status.NodesState = map[string]v1alpha1.NodeState{nodeId: {PodIsReady: s}}\n\t\t\t\t}\n\t\t\t} else if val, ok := cluster.Status.NodesState[nodeId]; ok {\n\t\t\t\tswitch s := state.(type) {\n\t\t\t\tcase v1alpha1.GracefulActionState:\n\t\t\t\t\tval.GracefulActionState = s\n\t\t\t\tcase v1alpha1.ConfigurationState:\n\t\t\t\t\tval.ConfigurationState = s\n\t\t\t\tcase v1alpha1.InitClusterNode:\n\t\t\t\t\tval.InitClusterNode = s\n\t\t\t\tcase bool:\n\t\t\t\t\tval.PodIsReady = s\n\t\t\t\t}\n\t\t\t\tcluster.Status.NodesState[nodeId] = val\n\t\t\t} else {\n\t\t\t\tswitch s := state.(type) {\n\t\t\t\tcase v1alpha1.GracefulActionState:\n\t\t\t\t\tcluster.Status.NodesState[nodeId] = v1alpha1.NodeState{GracefulActionState: s}\n\t\t\t\tcase v1alpha1.ConfigurationState:\n\t\t\t\t\tcluster.Status.NodesState[nodeId] = v1alpha1.NodeState{ConfigurationState: s}\n\t\t\t\tcase v1alpha1.InitClusterNode:\n\t\t\t\t\tcluster.Status.NodesState[nodeId] = v1alpha1.NodeState{InitClusterNode: s}\n\t\t\t\tcase bool:\n\t\t\t\t\tcluster.Status.NodesState[nodeId] = v1alpha1.NodeState{PodIsReady: s}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\terr = updateClusterStatus(c, cluster)\n\t\tif err != nil {\n\t\t\treturn errors.WrapIff(err, \"could not update Nifi clusters node(s) %s state\", strings.Join(nodeIds, \",\"))\n\t\t}\n\t}\n\t// update loses the typeMeta of the config that's used later when setting ownerrefs\n\tcluster.TypeMeta = typeMeta\n\tlogger.Info(\"Nifi cluster state updated\")\n\treturn nil\n}", "title": "" }, { "docid": "adf7561db4972d837fa4c09e0a3d7ddc", "score": "0.56303346", "text": "func notifyServersOfNewNode(newNode NewNodeSetup) {\n\n\tnext := serverList\n\n\tfor next != nil {\n\t\tsystemService, err := rpc.Dial(\"tcp\", (*next).RPC_SERVER_IPPORT)\n\t\t//checkError(err)\n\t\tif err != nil {\n\t\t\tprintln(\"Notfifying nodes of new node: Node \", (*next).UDP_IPPORT, \" isn't accepting tcp conns so skip it...\")\n\t\t\t//it's dead but the ping will eventually take care of it\n\t\t} else {\n\t\t\tvar reply ServerReply\n\n\t\t\toutbuf := Logger.PrepareSend(\"notification: new server node online\", newNode)\n\t\t\terr = systemService.Call(\"NodeService.NewStorageNode\", outbuf, &reply)\n\t\t\tcheckError(err)\n\t\t\tif err == nil {\n\t\t\t\tfmt.Println(\"we received a reply from the server: \", reply.Message)\n\t\t\t}\n\t\t\tsystemService.Close()\n\t\t}\n\t\tnext = (*next).NextServer\n\t}\n}", "title": "" }, { "docid": "d7e3304a8df4b8c01d40418b5752693b", "score": "0.55982184", "text": "func (c *Client) updateStatus(ctx context.Context, ty string, nodeID string, state string) error {\n\tkey := fmt.Sprintf(\"/tidb-binlog/v1/%s/%s\", ty, nodeID)\n\n\tctx, cancel := context.WithTimeout(ctx, c.timeout)\n\tdefer cancel()\n\tresp, err := c.etcdClient.KV.Get(ctx, key)\n\tif err != nil {\n\t\treturn errors.AddStack(err)\n\t}\n\n\tif len(resp.Kvs) == 0 {\n\t\treturn errors.Errorf(\"no %s with node id: %v\", ty, nodeID)\n\t}\n\n\tvar nodeStatus v1alpha1.PumpNodeStatus\n\terr = json.Unmarshal(resp.Kvs[0].Value, &nodeStatus)\n\tif err != nil {\n\t\treturn errors.AddStack(err)\n\t}\n\n\tif nodeStatus.State == state {\n\t\treturn nil\n\t}\n\n\tnodeStatus.State = state\n\n\tdata, err := json.Marshal(&nodeStatus)\n\tif err != nil {\n\t\treturn errors.AddStack(err)\n\t}\n\n\t_, err = c.etcdClient.Put(ctx, key, string(data))\n\tif err != nil {\n\t\treturn errors.AddStack(err)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "73e69648e279df73164a10db65e69a63", "score": "0.55440193", "text": "func (m *Mercury) NodeStatusStream(ctx context.Context) chan *types.NodeStatus {\n\tch := make(chan *types.NodeStatus)\n\tlogger := log.WithFunc(\"store.etcdv3.NodeStatusStream\")\n\t_ = m.pool.Invoke(func() {\n\t\tdefer func() {\n\t\t\tlogger.Info(ctx, \"close NodeStatusStream channel\")\n\t\t\tclose(ch)\n\t\t}()\n\n\t\tlogger.Infof(ctx, \"watch on %s\", nodeStatusPrefix)\n\t\tfor resp := range m.Watch(ctx, nodeStatusPrefix, clientv3.WithPrefix()) {\n\t\t\tif resp.Err() != nil {\n\t\t\t\tif !resp.Canceled {\n\t\t\t\t\tlogger.Error(ctx, resp.Err(), \"watch failed\")\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t\tfor _, event := range resp.Events {\n\t\t\t\tnodename := extractNodename(string(event.Kv.Key))\n\t\t\t\tstatus := &types.NodeStatus{\n\t\t\t\t\tNodename: nodename,\n\t\t\t\t\tAlive: event.Type != clientv3.EventTypeDelete,\n\t\t\t\t}\n\t\t\t\tnode, err := m.GetNode(ctx, nodename)\n\t\t\t\tif err != nil {\n\t\t\t\t\tstatus.Error = err\n\t\t\t\t} else {\n\t\t\t\t\tstatus.Podname = node.Podname\n\t\t\t\t}\n\t\t\t\tch <- status\n\t\t\t}\n\t\t}\n\t})\n\treturn ch\n}", "title": "" }, { "docid": "230e8150d6157b2da62f2eb337d8559b", "score": "0.5493371", "text": "func (b *bot) ready(s *discordgo.Session, event *discordgo.Ready) {\n\tif err := s.UpdateStatus(0, \"powering \"+string(len(event.Guilds))+\" nodes\"); err != nil {\n\t\tprintln(\"update status error\", err.Error())\n\t}\n}", "title": "" }, { "docid": "06124d0e5425c5c3a637818b6f38ae50", "score": "0.53952634", "text": "func (c *NodeController) syncNode(event EventData) error {\n\tif event.EventType == \"Create\" {\n\t\tfor _, value := range event.Data.Status.Addresses {\n\t\t\tif value.Type == \"InternalIP\" {\n\t\t\t\tif _,ok := c.NodeList[value.Address]; !ok {\n\t\t\t\t\tc.SyncNodeData()\n\t\t\t\t\tc.LBChannel <- 1\n\n\t\t\t\t\tfmt.Printf(\"%s for Node %s\\n\", event.EventType, event.Data.GetName())\n\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tc.SyncNodeData()\n\t\tc.LBChannel <- 1\n\t}\n\n\tfmt.Printf(\"%s for Node %s\\n\", event.EventType, event.Data.GetName())\n\n\treturn nil\n}", "title": "" }, { "docid": "f53bd7e45f9d6761bb310a6971bb074d", "score": "0.5345175", "text": "func updateStatusHandler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"record status\")\n\tdevicesNotHeardFrom := make(map[string]time.Time)\n\n\tfor _, dev := range deviceCenter.Devices {\n\t\tif !dev.IsCheckedIn {\n\t\t\tdeviceCenter.Lock()\n\t\t\tdevicesNotHeardFrom[dev.Name] = dev.LatestCheckInTime\n\t\t\tdeviceCenter.Unlock()\n\t\t}\n\t}\n\n\tsendPayload(w, devicesNotHeardFrom)\n\n\treturn\n}", "title": "" }, { "docid": "1c3d54cce35bdfce0a360d3c4296ed5a", "score": "0.53431565", "text": "func monitorStatus() {\n\tfor {\n\t\tsxutil.SetNodeStatus(int32(pctCount), \"PC-Bar\")\n\t\ttime.Sleep(time.Second * 3)\n\t}\n}", "title": "" }, { "docid": "7e9dd5077a94efdb68fb90a0d6e9cebd", "score": "0.5331267", "text": "func (node *node) updateNodeInfo() {\n\tperiodUpdateTime := config.DefaultGenBlockTime / TimesOfUpdateTime\n\tticker := time.NewTicker(time.Second * (time.Duration(periodUpdateTime)) * 2)\n\tfor {\n\t\tselect {\n\t\tcase <-ticker.C:\n\t\t\tnode.SendPingToNbr()\n\t\t\tnode.SyncBlocks()\n\t\t\tnode.HeartBeatMonitor()\n\t\t}\n\t}\n\t// TODO when to close the timer\n\t//close(quit)\n}", "title": "" }, { "docid": "6739e1cfbe64bc73e5fa786e630da1b9", "score": "0.5307008", "text": "func (s *mySqlState) processNodeStatusMessage(m *messages.InternalMessage) {\n\tstatus := m.Payload[0].(*node.Status)\n\t_, err := s.addNodeStatus.Exec(status.Identifier, status.Timestamp, status.Ip, status.Nickname, status.Version, status.MeshTotal, status.MeshCycle, status.CycleLength, status.Transactions, status.RetentionEdge, status.TrailingEdge, status.FrozenEdge, status.OpenEdge, status.BlocksTransmitted, status.BlocksCreated, status.VoteStats, status.LastJoinHeight, status.LastRemovalHeight, status.ReceivingUDP)\n\tif err != nil {\n\t\t// We do not make this fatal as it is not consensus relevant.\n\t\tlogging.ErrorLog.Print(err)\n\t}\n}", "title": "" }, { "docid": "0fa5171c75dc788991e1d08bc98cef6a", "score": "0.53045565", "text": "func (h *Handler) PostStatus(nodeName, clientIP string, status types.NodeStatus) (types.StatusResponse, error) {\n\tupToDate, err := h.dispatcher.processNodeStatus(nodeName, clientIP, status)\n\tresponse := types.StatusResponse{\n\t\tIsUpToDate: upToDate,\n\t}\n\treturn response, err\n}", "title": "" }, { "docid": "6f9fa7469193656e64a820701af8b97d", "score": "0.52858317", "text": "func (m *NodeHealthManager) getNewStatus(pattern string, org string, lastCall string, nhHandler NodeHealthHandler) (*exchange.NodeHealthStatus, error) {\n\t//get the node orgs for the pattern\n\tpatternKey := getKey(pattern, org)\n\tnodeOrgs := []string{}\n\tif v, found := m.NodeOrgs[patternKey]; found {\n\t\tnodeOrgs = v\n\t}\n\tglog.V(5).Infof(\"Node Health Manager: node orgs for pattern %v or org %v: %v\", pattern, org, nodeOrgs)\n\n\treturn nhHandler(pattern, org, nodeOrgs, lastCall)\n}", "title": "" }, { "docid": "436b00565f9b86443c96eeef415ce720", "score": "0.52726996", "text": "func (fm *FeslManager) Status(event network.EventClientCommand) {\n\tgameID := matchmaking.FindGIDs()\n\n\tans := ansStatus{\n\t\tTaxon: pnowStatus,\n\t\tID: stPartition{1, event.Command.Message[\"partition.partition\"]},\n\t\tSessionState: \"COMPLETE\",\n\t\tProperties: map[string]interface{}{\n\t\t\t\"resultType\": \"JOIN\",\n\t\t\t\"games\": []statusGame{\n\t\t\t\t{\n\t\t\t\t\tLobbyID: 1,\n\t\t\t\t\tFit: 1001,\n\t\t\t\t\tGameID: gameID,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tevent.Client.WriteEncode(&codec.Packet{\n\t\tPayload: ans,\n\t\tStep: 0x80000000,\n\t\tType: pnow,\n\t})\n}", "title": "" }, { "docid": "84463596faeffc3d3146b977f934e4a6", "score": "0.5270782", "text": "func UpdateNodeStatus(uuid string, online bool, synced bool) {\n\tnode := GetNodeByUUID(uuid)\n\tif online == true {\n\t\tnode.LastOnline = time.Now().Format(time.RFC850)\n\t}\n\tnode.IsOnline = online\n\tnode.Synced = synced\n}", "title": "" }, { "docid": "c9b1aa913e15a45598336cab5e9becd6", "score": "0.52617246", "text": "func nodeReadyStatus(ready bool) func() (corev1.ConditionStatus, string, string) {\n\treturn func() (status corev1.ConditionStatus, reason, message string) {\n\t\tif ready {\n\t\t\treturn corev1.ConditionTrue, \"KubeletReady\", \"The Liqo Virtual Kubelet is posting ready status\"\n\t\t}\n\t\treturn corev1.ConditionFalse, \"KubeletNotReady\", \"The Liqo Virtual Kubelet is currently not ready\"\n\t}\n}", "title": "" }, { "docid": "f21ddfe14ade35bc41e5f9871446b5d8", "score": "0.52582794", "text": "func (n *NodeManagementWorker) CollectStatus(workingFolderPath string, policyName string, dbStatus *exchangecommon.NodeManagementPolicyStatus) error {\n\tfilePath := path.Join(workingFolderPath, policyName, STATUS_FILE_NAME)\n\t// Read in the status file\n\tif _, err := os.Stat(filePath); err != nil {\n\t\treturn fmt.Errorf(\"Failed to open status file %v for management job %v. Error was: %v\", filePath, policyName, err)\n\t}\n\tif openPath, err := os.Open(filePath); err != nil {\n\t\treturn fmt.Errorf(\"Failed to open status file %v for management job %v. Errorf was: %v\", filePath, policyName, err)\n\t} else {\n\t\tcontents := exchangecommon.NodeManagementPolicyStatus{}\n\t\terr = json.NewDecoder(openPath).Decode(&contents)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to decode status file %v for management job %v. Error was %v.\", filePath, policyName, err)\n\t\t}\n\n\t\texchDev, err := persistence.FindExchangeDevice(n.db)\n\t\tif err != nil {\n\t\t\tglog.Errorf(nmwlog(fmt.Sprintf(\"Error getting device from database: %v\", err)))\n\t\t\texchDev = nil\n\t\t}\n\n\t\tstatus_changed, err := common.SetNodeManagementPolicyStatus(n.db, exchDev, policyName, &contents, dbStatus,\n\t\t\texchange.GetPutNodeManagementPolicyStatusHandler(n),\n\t\t\texchange.GetHTTPDeviceHandler(n),\n\t\t\texchange.GetHTTPPatchDeviceHandler(n))\n\t\tif err != nil {\n\t\t\tglog.Errorf(nmwlog(fmt.Sprintf(\"Error saving nmp status for %v: %v\", policyName, err)))\n\t\t\treturn err\n\t\t} else {\n\t\t\t// log the event\n\t\t\tif status_changed {\n\t\t\t\tpattern := \"\"\n\t\t\t\tconfigState := \"\"\n\t\t\t\tif exchDev != nil {\n\t\t\t\t\tpattern = exchDev.Pattern\n\t\t\t\t\tconfigState = exchDev.Config.State\n\t\t\t\t}\n\t\t\t\tstatus_string := contents.AgentUpgrade.Status\n\t\t\t\tif status_string == \"\" {\n\t\t\t\t\tstatus_string = exchangecommon.STATUS_UNKNOWN\n\t\t\t\t}\n\t\t\t\tif contents.AgentUpgrade.ErrorMessage != \"\" {\n\t\t\t\t\tstatus_string += fmt.Sprintf(\", ErrorMessage: %v\", contents.AgentUpgrade.ErrorMessage)\n\t\t\t\t}\n\t\t\t\teventlog.LogNodeEvent(n.db, persistence.SEVERITY_INFO, persistence.NewMessageMeta(EL_NMP_STATUS_CHANGED, policyName, status_string), persistence.EC_NMP_STATUS_CHANGED, exchange.GetId(n.GetExchangeId()), exchange.GetOrg(n.GetExchangeId()), pattern, configState)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "7b60c2a1ac868932c871bd0d060685a0", "score": "0.52559215", "text": "func (w *GovernanceWorker) writeStatusToExchange(device_status *exchange.DeviceStatus) error {\n\tvar resp interface{}\n\tresp = new(exchange.PostDeviceResponse)\n\n\ttargetURL := w.Config.Edge.ExchangeURL + \"orgs/\" + exchange.GetOrg(w.GetExchangeId()) + \"/nodes/\" + exchange.GetId(w.GetExchangeId()) + \"/status\"\n\n\thttpClientFactory := w.limitedRetryEC.GetHTTPFactory()\n\tretryCount := httpClientFactory.RetryCount\n\tretryInterval := httpClientFactory.GetRetryInterval()\n\n\tfor {\n\t\tif err, tpErr := exchange.InvokeExchange(httpClientFactory.NewHTTPClient(nil), \"PUT\", targetURL, w.GetExchangeId(), w.GetExchangeToken(), device_status, &resp); err != nil {\n\t\t\tglog.Errorf(logString(fmt.Sprintf(err.Error())))\n\t\t\treturn err\n\t\t} else if tpErr != nil {\n\t\t\tglog.Warningf(tpErr.Error())\n\t\t\tif httpClientFactory.RetryCount == 0 {\n\t\t\t\ttime.Sleep(time.Duration(retryInterval) * time.Second)\n\t\t\t\tcontinue\n\t\t\t} else if retryCount == 0 {\n\t\t\t\treturn fmt.Errorf(logString(fmt.Sprintf(\"exceeded %v retries trying to write node status for %v\", httpClientFactory.RetryCount, tpErr)))\n\t\t\t} else {\n\t\t\t\tretryCount--\n\t\t\t\ttime.Sleep(time.Duration(retryInterval) * time.Second)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t} else {\n\t\t\tglog.V(5).Infof(logString(fmt.Sprintf(\"saved device status to the exchange\")))\n\t\t\treturn nil\n\t\t}\n\t}\n}", "title": "" }, { "docid": "e2d44b8831a1e0c6c04766b51ad03172", "score": "0.52322036", "text": "func (e *Engine) heartbeat(ctx context.Context) {\n\ttick := time.NewTicker(time.Duration(e.config.HeartbeatInterval) * time.Second)\n\tdefer tick.Stop()\n\n\tfor {\n\t\tselect {\n\t\tcase <-tick.C:\n\t\t\tgo e.nodeStatusReport()\n\t\tcase <-ctx.Done():\n\t\t\treturn\n\t\t}\n\t}\n}", "title": "" }, { "docid": "d21d7fac64e2a5d97230f2f45e606d33", "score": "0.52097154", "text": "func (fM *FeslManager) Status(event GameSpy.EventClientTLSCommand) {\n\tif !event.Client.IsActive {\n\t\tlog.Noteln(\"Client left\")\n\t\treturn\n\t}\n\n\tlog.Noteln(\"STATUS CALLED\")\n\n\tanswer := make(map[string]string)\n\tanswer[\"TXN\"] = \"Status\"\n\tanswer[\"id.id\"] = \"1\"\n\tanswer[\"id.partition\"] = event.Command.Message[\"partition.partition\"]\n\tanswer[\"sessionState\"] = \"COMPLETE\"\n\tanswer[\"props.{}.[]\"] = \"2\"\n\tanswer[\"props.{resultType}\"] = \"JOIN\"\n\n\t// Find latest game (do better later)\n\tgameID := matchmaking.FindAvailableGID()\n\n\tanswer[\"props.{games}.0.lid\"] = \"1\"\n\tanswer[\"props.{games}.0.fit\"] = \"1001\"\n\tanswer[\"props.{games}.0.gid\"] = gameID\n\tanswer[\"props.{games}.[]\"] = \"1\"\n\n\tevent.Client.WriteFESL(\"pnow\", answer, 0x80000000)\n\tfM.logAnswer(\"pnow\", answer, 0x80000000)\n}", "title": "" }, { "docid": "fcb838dde708d49da75fbf22209bdf92", "score": "0.520841", "text": "func (hr *homieMeter) status(online bool) {\n\tif hr.online != online {\n\t\tsubTopic := mqttDeviceTopic(hr.meter)\n\t\tmsg := \"alert\"\n\t\tif online {\n\t\t\tmsg = \"ready\"\n\t\t}\n\t\thr.publish(subTopic+\"/$state\", msg)\n\t\thr.online = online\n\t}\n}", "title": "" }, { "docid": "18e13be0dd4abcae1ca7164babfd8dd4", "score": "0.52006626", "text": "func (r *NodeReconciler) updateStatus(ctx context.Context, node *ethereumv1alpha1.Node, enodeURL string) error {\n\n\tvar consensus, network string\n\n\tif node.Spec.Genesis == nil {\n\t\tswitch node.Spec.Network {\n\t\tcase ethereumv1alpha1.MainNetwork, ethereumv1alpha1.RopstenNetwork:\n\t\t\tconsensus = \"pow\"\n\t\tcase ethereumv1alpha1.RinkebyNetwork, ethereumv1alpha1.GoerliNetwork:\n\t\t\tconsensus = \"poa\"\n\t\tcase ethereumv1alpha1.XDaiNetwork:\n\t\t\tconsensus = \"pos\"\n\t\t}\n\t} else {\n\t\tif node.Spec.Genesis.Ethash != nil {\n\t\t\tconsensus = \"pow\"\n\t\t} else if node.Spec.Genesis.Clique != nil {\n\t\t\tconsensus = \"poa\"\n\t\t} else if node.Spec.Genesis.IBFT2 != nil {\n\t\t\tconsensus = \"ibft2\"\n\t\t}\n\t}\n\n\tnode.Status.Consensus = consensus\n\n\tif network = node.Spec.Network; network == \"\" {\n\t\tnetwork = \"private\"\n\t}\n\n\tnode.Status.Network = network\n\n\tif node.Spec.NodePrivatekeySecretName == \"\" {\n\t\tswitch node.Spec.Client {\n\t\tcase ethereumv1alpha1.BesuClient:\n\t\t\tenodeURL = \"call net_enode JSON-RPC method\"\n\t\tcase ethereumv1alpha1.GethClient:\n\t\t\tenodeURL = \"call admin_nodeInfo JSON-RPC method\"\n\t\tcase ethereumv1alpha1.ParityClient:\n\t\t\tenodeURL = \"call parity_enode JSON-RPC method\"\n\t\tcase ethereumv1alpha1.NethermindClient:\n\t\t\tenodeURL = \"call net_localEnode JSON-RPC method\"\n\t\t}\n\t}\n\n\tnode.Status.EnodeURL = enodeURL\n\n\tif err := r.Status().Update(ctx, node); err != nil {\n\t\tr.Log.Error(err, \"unable to update node status\")\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "5f018072033ed4bc18c9c645267c30c2", "score": "0.5175229", "text": "func listenForTestStatus(conf map[string]string) error {\n\tretries := 0\n\tconn, err := net.Dial(\"tcp\", fmt.Sprintf(\"%s:8081\", conf[\"host\"]))\n\n\t// If the call to net.Dial produces an error, this loop will execute the call again\n\t// until \"retries\" reaches it's configured limit\n\tfor err != nil {\n\t\tif retries > 5 {\n\t\t\treturn errors.New(\"Failed to subscribe to test event stream after several retries.\")\n\t\t}\n\n\t\tretries++\n\t\ttime.Sleep(1 * time.Second)\n\t\tfmt.Println(\"Failed to subscribe to test event stream. Retrying...\")\n\t\tconn, err = net.Dial(\"tcp\", fmt.Sprintf(\"%s:8081\", conf[\"host\"]))\n\t}\n\tdefer conn.Close()\n\n\tvar recordCount int\n\tfirstMessage := false\n\tfor {\n\n\t\t// listen for reply\n\t\tmessage, err := bufio.NewReader(conn).ReadString('\\n')\n\t\t// If an error is raised, it's probably because the server killed the connection\n\t\tif err != nil {\n\t\t\t// TODO(mierdin): This doesn't really tell us if the connection died because of an error or not\n\t\t\treturn errors.New(\"Disconnected from testrun status stream\")\n\t\t}\n\n\t\tvar statuses map[string]string\n\t\terr = json.Unmarshal([]byte(message), &statuses)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Invalid status from server %q: %v\", message, err)\n\t\t}\n\n\t\tif !firstMessage {\n\t\t\trecordCount = len(statuses)\n\t\t\tfirstMessage = true\n\t\t}\n\n\t\tinit, ready, inTest, finished := 0, 0, 0, 0\n\t\tfor _, status := range statuses {\n\n\t\t\tswitch status {\n\t\t\tcase testing.StatusInit:\n\t\t\t\tinit++\n\t\t\tcase testing.StatusReady:\n\t\t\t\tready++\n\t\t\tcase testing.StatusTesting:\n\t\t\t\tinTest++\n\t\t\tcase testing.StatusFinished:\n\t\t\t\tfinished++\n\t\t\tdefault:\n\t\t\t\treturn errors.New(\"Invalid status received.\")\n\t\t\t}\n\t\t}\n\n\t\t// Print the status line (note the \\r which keeps the same line in place on the terminal)\n\t\tfmt.Printf(\n\t\t\t\"\\r %[1]s INIT: (%[3]d/%[2]d) READY: (%[4]d/%[2]d) TESTING: (%[5]d/%[2]d) FINISHED: (%[6]d/%[2]d)\",\n\t\t\ttime.Now(),\n\t\t\trecordCount,\n\t\t\tinit,\n\t\t\tready,\n\t\t\tinTest,\n\t\t\tfinished,\n\t\t)\n\n\t\tif finished == recordCount {\n\t\t\tbreak\n\t\t}\n\n\t\t// Send an ack back to the server to let it know we're alive\n\t\tfmt.Fprintf(conn, \"ack\\n\")\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "f6d2557b85c739ff48dd1a825dbfc463", "score": "0.5170203", "text": "func newStatusInfo(node *core.Node) *statusInfo {\n\tout := statusInfo{\n\t\tnode: node,\n\t\twatches: make(map[int64]ResponseWatch),\n\t}\n\treturn &out\n}", "title": "" }, { "docid": "4d770bbad049ffe581d9e179d0e8e306", "score": "0.51679206", "text": "func (a *Agent) PollClusterStatus() {\n\tticker := time.NewTicker(pingRate)\n\tfor {\n\t\tselect {\n\t\tcase <-ticker.C:\n\t\t\tif err := pingServer(a.Config); err != nil {\n\t\t\t\ta.Config.logger.WithError(err).Error(\"could not register agent\")\n\t\t\t}\n\n\t\tcase cs := <-a.ClusterMember.Change():\n\t\t\ta.Config.logger.WithFields(log.Fields{\n\t\t\t\t\"leader\": cs.Leader,\n\t\t\t\t\"node-count\": cs.NodeCount,\n\t\t\t}).Info(\"cluster changed\")\n\t\t\ta.Config.Lock()\n\t\t\ta.Config.ClusterStatus = cs\n\n\t\t\tnode, err := a.Config.KVS.Get(fipKey, nil)\n\t\t\tif err == nil {\n\t\t\t\ta.Config.ClusterStatus.FloatingIP = node.Value\n\t\t\t}\n\n\t\t\ta.Config.Unlock()\n\n\t\t\ta.Config.logger.WithFields(log.Fields{\n\t\t\t\t\"is-leader\": cs.IsLeader,\n\t\t\t}).Info(\"leader check\")\n\n\t\t\tif cs.IsLeader {\n\t\t\t\thkvs := kvs.NewLiveHaproxy(a.Config.KVS, a.Config.IDGen, a.Config.GetLogger())\n\n\t\t\t\terr := hkvs.Init()\n\t\t\t\tif err != nil {\n\t\t\t\t\ta.Config.logger.WithError(err).Error(\"could not create haproxy keys\")\n\t\t\t\t}\n\n\t\t\t\thandleLeaderElection(a)\n\t\t\t}\n\n\t\t}\n\t}\n}", "title": "" }, { "docid": "31ef9fa3b157bab1286f32e38ce1985c", "score": "0.51602924", "text": "func (msg *StatusPacket) Exec(g *Gossiper, addr *net.UDPAddr) error {\n\tsrc := addr.String()\n\t//log.Lvlf1(\"STATUS from %s %s\\n\", src, statusString(msg.Want))\n\n\t// update new peer\n\terr := g.AddAddresses(src)\n\tg.nodes.print()\n\n\t// compare status with my status\n\tupToDate, sendStatus, rumorsToSend := g.vc.compareStatus(g, msg.Want)\n\n\t// check if it's an ACK\n\tackedRumor, isAck := g.pm.ackPendingForPeer(msg, src)\n\n\tif upToDate {\n\t\t//log.Lvlf1(\"IN SYNC WITH %s\\n\", src)\n\t\tif isAck && rand.Int()%2 == 0 { // continue rumermongering if it was an ACK with proba 0.5\n\t\t\tif dst, ok := g.sendToRandomExcept(GossipPacket{Rumor: &ackedRumor}, src); ok {\n\t\t\t\t//log.Lvlf1(\"FLIPPED COIN sending rumor to %s\\n\", dst)\n\t\t\t\tg.pm.add(g, PendingMessage{dst, ackedRumor})\n\t\t\t}\n\t\t}\n\t}\n\t// if newer rumors, send them one by one\n\tfor _, rumor := range rumorsToSend {\n\t\tpkt := GossipPacket{Rumor: &rumor}\n\t\tg.sendPacket(pkt, src)\n\t}\n\n\t// if not up to date, send own status\n\tif sendStatus {\n\t\tg.sendStatus(addr)\n\t}\n\n\treturn err\n}", "title": "" }, { "docid": "65b158f9f4bb2c67d9558bad052c9673", "score": "0.51423395", "text": "func (c *Auto) sendStatus(who string, err error, url string, nm *netmap.NetworkMap) {\n\tc.mu.Lock()\n\tif c.closed {\n\t\tc.mu.Unlock()\n\t\treturn\n\t}\n\tstate := c.state\n\tloggedIn := c.loggedIn\n\tinMapPoll := c.inMapPoll\n\tc.mu.Unlock()\n\n\tc.logf(\"[v1] sendStatus: %s: %v\", who, state)\n\n\tvar p persist.PersistView\n\tif nm != nil && loggedIn && inMapPoll {\n\t\tp = c.direct.GetPersist()\n\t} else {\n\t\t// don't send netmap status, as it's misleading when we're\n\t\t// not logged in.\n\t\tnm = nil\n\t}\n\tnew := Status{\n\t\tURL: url,\n\t\tPersist: p,\n\t\tNetMap: nm,\n\t\tErr: err,\n\t\tstate: state,\n\t}\n\n\t// Launch a new goroutine to avoid blocking the caller while the observer\n\t// does its thing, which may result in a call back into the client.\n\tc.observerQueue.Add(func() {\n\t\tc.observer.SetControlClientStatus(c, new)\n\t})\n}", "title": "" }, { "docid": "7e9ba12d9060fc693207effc49e69a27", "score": "0.51374143", "text": "func (er *endpointRef) updateStatus(now nowFunc, err error) {\n\tmint, maxt := er.timeRange()\n\tif er.status == nil {\n\t\ter.status = &EndpointStatus{Name: er.addr}\n\t}\n\n\tif err == nil {\n\t\ter.status.LastCheck = now()\n\t\ter.status.LabelSets = er.labelSets()\n\t\ter.status.ComponentType = er.componentType()\n\t\ter.status.MinTime = mint\n\t\ter.status.MaxTime = maxt\n\t\ter.status.LastError = nil\n\t} else {\n\t\ter.status.LastError = &stringError{originalErr: err}\n\t}\n}", "title": "" }, { "docid": "c2647d6c86f4ee508655d3493d13fb90", "score": "0.5124425", "text": "func (s *TestHttpService) handleNodeWatch(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tio.WriteString(w, <-s.NodeChannel)\n}", "title": "" }, { "docid": "6ef110b14b0a50f4ba5b81600193650a", "score": "0.5124326", "text": "func listenerNodeToNode() {\r\n\tl, err := net.Listen(\"tcp\", \":\"+Port[jsonId])\r\n\tif err != nil {\r\n\t\tfmt.Println(err)\r\n\t\treturn\r\n\t}\r\n\trand.Seed(time.Now().Unix())\r\n\tfmt.Println(\"Listen to node to node connection\")\r\n\tdefer l.Close()\r\n\tfor {\r\n\r\n\t\tc, err := l.Accept()\r\n\t\tif err != nil {\r\n\t\t\tcheck(err)\r\n\t\t\tfmt.Println(err)\r\n\t\t\treturn\r\n\t\t}\r\n\t\tgo handleConnection_server(c)\r\n\t}\r\n}", "title": "" }, { "docid": "2f75bde97f68b45186ec27b6e9ff5095", "score": "0.511792", "text": "func (w *Worker) checkNode(n *Node) error {\n\tdefer n.free()\n\n\tc := w.soterd.Client()\n\n\tinfo, err := c.GetInfo()\n\tn.updateLock.Lock()\n\tif err != nil {\n\t\tn.Online = false\n\t\tn.updateLock.Unlock()\n\t\treturn err\n\t}\n\tn.Version = fmt.Sprintf(\"%d\", info.Version)\n\tn.updateLock.Unlock()\n\n\tconnected, err := w.soterd.IsConnectedTo(n.Address)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !connected {\n\t\terr = c.AddNode(n.Address, rpcclient.ANAdd)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t_, peers, err := w.soterd.Addrs()\n\tif err != nil {\n\t\tn.updateLock.Lock()\n\t\tn.Online = false\n\t\tn.updateLock.Unlock()\n\t\treturn err\n\t}\n\n\tconns := make([]*Node, 0)\n\tfor _, p := range peers {\n\t\tpn := Node{Address: p}\n\t\tconns = append(conns, &pn)\n\n\t\t// Add the node's peers to the survey for future polls, if they haven't been added already\n\t\tw.e.AddToCensus(&pn)\n\t}\n\n\tn.updateLock.Lock()\n\tn.connections = conns\n\tn.Online = true\n\tn.LastChecked = time.Now()\n\tn.updateLock.Unlock()\n\n\t// Add the node to the survey for future polls, if it hasn't already\n\tw.e.AddToCensus(n)\n\n\treturn nil\n}", "title": "" }, { "docid": "2b4714c9b8ae592367de08435c12870b", "score": "0.51008236", "text": "func (gc *GatewayConfig) initializeNode(nodeID string, nodeName string, timeID string, messages string) v1alpha1.NodeStatus {\n\tif gc.gw.Status.Nodes == nil {\n\t\tgc.gw.Status.Nodes = make(map[string]v1alpha1.NodeStatus)\n\t}\n\tgc.Log.Info().Str(\"node-id\", nodeID).Str(\"node-name\", nodeName).Str(\"time-id\", timeID).Msg(\"node\")\n\toldNode, ok := gc.gw.Status.Nodes[nodeID]\n\tif ok {\n\t\tgc.Log.Info().Str(\"node-name\", nodeName).Msg(\"node already initialized\")\n\t\treturn oldNode\n\t}\n\n\tnode := v1alpha1.NodeStatus{\n\t\tID: nodeID,\n\t\tTimeID: timeID,\n\t\tName: nodeName,\n\t\tDisplayName: nodeName,\n\t\tPhase: v1alpha1.NodePhaseInitialized,\n\t\tStartedAt: metav1.MicroTime{Time: time.Now().UTC()},\n\t}\n\tnode.Message = messages\n\tgc.gw.Status.Nodes[nodeID] = node\n\tgc.Log.Info().Str(\"node-name\", node.DisplayName).Str(\"node-message\", node.Message).Msg(\"node is initialized\")\n\treturn node\n}", "title": "" }, { "docid": "eea851c535bbc62b554a40e2ad6c6d88", "score": "0.51004535", "text": "func writeStatus(c riemanner.RaidmanClient, status gearadmin.Status, tags []string) error {\n\tif err := c.Send(&raidman.Event{\n\t\tTtl: 10,\n\t\tTags: tags,\n\t\tService: fmt.Sprintf(\"gearmand.status.%s.total\", status.Function),\n\t\tMetric: status.Total,\n\t}); err != nil {\n\t\treturn err\n\t}\n\tif err := c.Send(&raidman.Event{\n\t\tTtl: 10,\n\t\tTags: tags,\n\t\tService: fmt.Sprintf(\"gearmand.status.%s.running\", status.Function),\n\t\tMetric: status.Running,\n\t}); err != nil {\n\t\treturn err\n\t}\n\treturn c.Send(&raidman.Event{\n\t\tTtl: 10,\n\t\tTags: tags,\n\t\tService: fmt.Sprintf(\"gearmand.status.%s.available\", status.Function),\n\t\tMetric: status.AvailableWorkers,\n\t})\n}", "title": "" }, { "docid": "e8b30653293d8af7d72218db4959ac8d", "score": "0.5099788", "text": "func (m *ClusterInfo) processNodeUpdate(request *si.UpdateRequest) {\n // Process add node\n if len(request.NewSchedulableNodes) == 0 {\n return\n }\n acceptedNodes := make([]*si.AcceptedNode, 0)\n rejectedNodes := make([]*si.RejectedNode, 0)\n existingAllocations := make([]*si.Allocation, 0)\n for _, node := range request.NewSchedulableNodes {\n nodeInfo, err := NewNodeInfo(node)\n if err != nil {\n msg := fmt.Sprintf(\"Failed to create node info from request, nodeId %s, error %s\", node.NodeId, err.Error())\n log.Logger().Info(msg)\n // TODO assess impact of partition metrics (this never hit the partition)\n m.metrics.IncFailedNodes()\n rejectedNodes = append(rejectedNodes,\n &si.RejectedNode{\n NodeId: node.NodeId,\n Reason: msg,\n })\n continue\n }\n partition := m.GetPartition(nodeInfo.Partition)\n if partition == nil {\n msg := fmt.Sprintf(\"Failed to find partition %s for new node %s\", nodeInfo.Partition, node.NodeId)\n log.Logger().Info(msg)\n // TODO assess impact of partition metrics (this never hit the partition)\n m.metrics.IncFailedNodes()\n rejectedNodes = append(rejectedNodes,\n &si.RejectedNode{\n NodeId: node.NodeId,\n Reason: msg,\n })\n continue\n }\n err = partition.addNewNode(nodeInfo, node.ExistingAllocations)\n if err != nil {\n msg := fmt.Sprintf(\"Failure while adding new node, node rejectd with error %s\", err.Error())\n log.Logger().Warn(msg)\n rejectedNodes = append(rejectedNodes,\n &si.RejectedNode{\n NodeId: node.NodeId,\n Reason: msg,\n })\n continue\n }\n log.Logger().Info(\"successfully added node\",\n zap.String(\"nodeId\", node.NodeId),\n zap.String(\"partition\", nodeInfo.Partition))\n acceptedNodes = append(acceptedNodes, &si.AcceptedNode{NodeId: node.NodeId})\n existingAllocations = append(existingAllocations, node.ExistingAllocations...)\n }\n\n m.EventHandlers.RMProxyEventHandler.HandleEvent(&rmevent.RMNodeUpdateEvent{\n RMId: request.RmId,\n AcceptedNodes: acceptedNodes,\n RejectedNodes: rejectedNodes,\n })\n\n // notify the scheduler to recover existing allocations\n m.EventHandlers.SchedulerEventHandler.HandleEvent(&schedulerevent.SchedulerAllocationUpdatesEvent{\n ExistingAllocations: existingAllocations,\n RMId: request.RmId,\n })\n}", "title": "" }, { "docid": "fc7cf0ec8f0b57e9cc090cd929d64af7", "score": "0.50976104", "text": "func (s *ArgosNotificationServer) PushArgosStatus() {\n\tfor {\n\t\ts.pruneStaleNotifications()\n\t\tif err := s.writeNotificationStatus(); err != nil {\n\t\t\tlog.Println(\"error writing notification status:\", err)\n\t\t}\n\t\ttime.Sleep(4700 * time.Millisecond)\n\t}\n}", "title": "" }, { "docid": "d71f167142fae169598000a04bee2974", "score": "0.50933754", "text": "func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) {\n\tctxb := context.Background()\n\n\t// Create two fresh nodes and open a channel between them.\n\talice := net.NewNode(t.t, \"Alice\", []string{\n\t\t\"--minbackoff=10s\",\n\t\t\"--chan-enable-timeout=1.5s\",\n\t\t\"--chan-disable-timeout=3s\",\n\t\t\"--chan-status-sample-interval=.5s\",\n\t})\n\tdefer shutdownAndAssert(net, t, alice)\n\n\tbob := net.NewNode(t.t, \"Bob\", []string{\n\t\t\"--minbackoff=10s\",\n\t\t\"--chan-enable-timeout=1.5s\",\n\t\t\"--chan-disable-timeout=3s\",\n\t\t\"--chan-status-sample-interval=.5s\",\n\t})\n\tdefer shutdownAndAssert(net, t, bob)\n\n\t// Connect Alice to Bob.\n\tnet.ConnectNodes(t.t, alice, bob)\n\n\t// Give Alice some coins so she can fund a channel.\n\tnet.SendCoins(t.t, btcutil.SatoshiPerBitcoin, alice)\n\n\t// Open a channel with 100k satoshis between Alice and Bob with Alice\n\t// being the sole funder of the channel.\n\tchanAmt := btcutil.Amount(100000)\n\tchanPoint := openChannelAndAssert(\n\t\tt, net, alice, bob, lntest.OpenChannelParams{\n\t\t\tAmt: chanAmt,\n\t\t},\n\t)\n\n\t// Wait for Alice and Bob to receive the channel edge from the\n\t// funding manager.\n\terr := alice.WaitForNetworkChannelOpen(chanPoint)\n\trequire.NoError(t.t, err, \"alice didn't see the alice->bob channel\")\n\n\terr = bob.WaitForNetworkChannelOpen(chanPoint)\n\trequire.NoError(t.t, err, \"bob didn't see the alice->bob channel\")\n\n\t// Launch a node for Carol which will connect to Alice and Bob in order\n\t// to receive graph updates. This will ensure that the channel updates\n\t// are propagated throughout the network.\n\tcarol := net.NewNode(t.t, \"Carol\", nil)\n\tdefer shutdownAndAssert(net, t, carol)\n\n\t// Connect both Alice and Bob to the new node Carol, so she can sync her\n\t// graph.\n\tnet.ConnectNodes(t.t, alice, carol)\n\tnet.ConnectNodes(t.t, bob, carol)\n\twaitForGraphSync(t, carol)\n\n\t// assertChannelUpdate checks that the required policy update has\n\t// happened on the given node.\n\tassertChannelUpdate := func(node *lntest.HarnessNode,\n\t\tpolicy *lnrpc.RoutingPolicy) {\n\n\t\trequire.NoError(\n\t\t\tt.t, carol.WaitForChannelPolicyUpdate(\n\t\t\t\tnode.PubKeyStr, policy, chanPoint, false,\n\t\t\t), \"error while waiting for channel update\",\n\t\t)\n\t}\n\n\t// sendReq sends an UpdateChanStatus request to the given node.\n\tsendReq := func(node *lntest.HarnessNode, chanPoint *lnrpc.ChannelPoint,\n\t\taction routerrpc.ChanStatusAction) {\n\n\t\treq := &routerrpc.UpdateChanStatusRequest{\n\t\t\tChanPoint: chanPoint,\n\t\t\tAction: action,\n\t\t}\n\t\tctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)\n\t\tdefer cancel()\n\n\t\t_, err = node.RouterClient.UpdateChanStatus(ctxt, req)\n\t\trequire.NoErrorf(t.t, err, \"UpdateChanStatus\")\n\t}\n\n\t// assertEdgeDisabled ensures that a given node has the correct\n\t// Disabled state for a channel.\n\tassertEdgeDisabled := func(node *lntest.HarnessNode,\n\t\tchanPoint *lnrpc.ChannelPoint, disabled bool) {\n\n\t\toutPoint, err := lntest.MakeOutpoint(chanPoint)\n\t\trequire.NoError(t.t, err)\n\n\t\terr = wait.NoError(func() error {\n\t\t\treq := &lnrpc.ChannelGraphRequest{\n\t\t\t\tIncludeUnannounced: true,\n\t\t\t}\n\t\t\tctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)\n\t\t\tdefer cancel()\n\n\t\t\tchanGraph, err := node.DescribeGraph(ctxt, req)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"unable to query node %v's \"+\n\t\t\t\t\t\"graph: %v\", node, err)\n\t\t\t}\n\t\t\tnumEdges := len(chanGraph.Edges)\n\t\t\tif numEdges != 1 {\n\t\t\t\treturn fmt.Errorf(\"expected to find 1 edge in \"+\n\t\t\t\t\t\"the graph, found %d\", numEdges)\n\t\t\t}\n\t\t\tedge := chanGraph.Edges[0]\n\t\t\tif edge.ChanPoint != outPoint.String() {\n\t\t\t\treturn fmt.Errorf(\"expected chan_point %v, \"+\n\t\t\t\t\t\"got %v\", outPoint, edge.ChanPoint)\n\t\t\t}\n\t\t\tvar policy *lnrpc.RoutingPolicy\n\t\t\tif node.PubKeyStr == edge.Node1Pub {\n\t\t\t\tpolicy = edge.Node1Policy\n\t\t\t} else {\n\t\t\t\tpolicy = edge.Node2Policy\n\t\t\t}\n\t\t\tif disabled != policy.Disabled {\n\t\t\t\treturn fmt.Errorf(\"expected policy.Disabled \"+\n\t\t\t\t\t\"to be %v, but policy was %v\", disabled,\n\t\t\t\t\tpolicy)\n\t\t\t}\n\n\t\t\treturn nil\n\t\t}, defaultTimeout)\n\t\trequire.NoError(t.t, err)\n\t}\n\n\t// When updating the state of the channel between Alice and Bob, we\n\t// should expect to see channel updates with the default routing\n\t// policy. The value of \"Disabled\" will depend on the specific\n\t// scenario being tested.\n\texpectedPolicy := &lnrpc.RoutingPolicy{\n\t\tFeeBaseMsat: int64(chainreg.DefaultBitcoinBaseFeeMSat),\n\t\tFeeRateMilliMsat: int64(chainreg.DefaultBitcoinFeeRate),\n\t\tTimeLockDelta: chainreg.DefaultBitcoinTimeLockDelta,\n\t\tMinHtlc: 1000, // default value\n\t\tMaxHtlcMsat: calculateMaxHtlc(chanAmt),\n\t}\n\n\t// Initially, the channel between Alice and Bob should not be\n\t// disabled.\n\tassertEdgeDisabled(alice, chanPoint, false)\n\n\t// Manually disable the channel and ensure that a \"Disabled = true\"\n\t// update is propagated.\n\tsendReq(alice, chanPoint, routerrpc.ChanStatusAction_DISABLE)\n\texpectedPolicy.Disabled = true\n\tassertChannelUpdate(alice, expectedPolicy)\n\n\t// Re-enable the channel and ensure that a \"Disabled = false\" update\n\t// is propagated.\n\tsendReq(alice, chanPoint, routerrpc.ChanStatusAction_ENABLE)\n\texpectedPolicy.Disabled = false\n\tassertChannelUpdate(alice, expectedPolicy)\n\n\t// Manually enabling a channel should NOT prevent subsequent\n\t// disconnections from automatically disabling the channel again\n\t// (we don't want to clutter the network with channels that are\n\t// falsely advertised as enabled when they don't work).\n\trequire.NoError(t.t, net.DisconnectNodes(alice, bob))\n\texpectedPolicy.Disabled = true\n\tassertChannelUpdate(alice, expectedPolicy)\n\tassertChannelUpdate(bob, expectedPolicy)\n\n\t// Reconnecting the nodes should propagate a \"Disabled = false\" update.\n\tnet.EnsureConnected(t.t, alice, bob)\n\texpectedPolicy.Disabled = false\n\tassertChannelUpdate(alice, expectedPolicy)\n\tassertChannelUpdate(bob, expectedPolicy)\n\n\t// Manually disabling the channel should prevent a subsequent\n\t// disconnect / reconnect from re-enabling the channel on\n\t// Alice's end. Note the asymmetry between manual enable and\n\t// manual disable!\n\tsendReq(alice, chanPoint, routerrpc.ChanStatusAction_DISABLE)\n\n\t// Alice sends out the \"Disabled = true\" update in response to\n\t// the ChanStatusAction_DISABLE request.\n\texpectedPolicy.Disabled = true\n\tassertChannelUpdate(alice, expectedPolicy)\n\n\trequire.NoError(t.t, net.DisconnectNodes(alice, bob))\n\n\t// Bob sends a \"Disabled = true\" update upon detecting the\n\t// disconnect.\n\texpectedPolicy.Disabled = true\n\tassertChannelUpdate(bob, expectedPolicy)\n\n\t// Bob sends a \"Disabled = false\" update upon detecting the\n\t// reconnect.\n\tnet.EnsureConnected(t.t, alice, bob)\n\texpectedPolicy.Disabled = false\n\tassertChannelUpdate(bob, expectedPolicy)\n\n\t// However, since we manually disabled the channel on Alice's end,\n\t// the policy on Alice's end should still be \"Disabled = true\". Again,\n\t// note the asymmetry between manual enable and manual disable!\n\tassertEdgeDisabled(alice, chanPoint, true)\n\n\trequire.NoError(t.t, net.DisconnectNodes(alice, bob))\n\n\t// Bob sends a \"Disabled = true\" update upon detecting the\n\t// disconnect.\n\texpectedPolicy.Disabled = true\n\tassertChannelUpdate(bob, expectedPolicy)\n\n\t// After restoring automatic channel state management on Alice's end,\n\t// BOTH Alice and Bob should set the channel state back to \"enabled\"\n\t// on reconnect.\n\tsendReq(alice, chanPoint, routerrpc.ChanStatusAction_AUTO)\n\tnet.EnsureConnected(t.t, alice, bob)\n\n\texpectedPolicy.Disabled = false\n\tassertChannelUpdate(alice, expectedPolicy)\n\tassertChannelUpdate(bob, expectedPolicy)\n\tassertEdgeDisabled(alice, chanPoint, false)\n}", "title": "" }, { "docid": "1006499038a9225b98fb57f388d74d98", "score": "0.508076", "text": "func SuricataNodesStatus(uuid string, username string) (data map[string]map[string]string, err error) {\n data, err = group.SuricataNodesStatus(uuid)\n changecontrol.ChangeControlInsertData(err, \"SuricataNodesStatus\", username)\n return data, err\n}", "title": "" }, { "docid": "9728815f9dcfb501a3ad840f097438e8", "score": "0.5080007", "text": "func (s *nodeStateMachine) OnCreate(key string, resource []byte) {\n\tnode := models.ActiveNode{}\n\tif err := json.Unmarshal(resource, &node); err != nil {\n\t\ts.log.Error(\"discovery node online but unmarshal error\",\n\t\t\tlogger.String(\"data\", string(resource)), logger.Error(err))\n\t\treturn\n\t}\n\t_, fileName := filepath.Split(key)\n\tnodeID := fileName\n\ts.mutex.Lock()\n\tdefer s.mutex.Unlock()\n\ts.nodes[nodeID] = node\n}", "title": "" }, { "docid": "1b5a101ff7e3af4b85b812128a1368d3", "score": "0.50778043", "text": "func (n *node) heartbeat(done chan string) {\n\t// log.Printf(\"heartbeat:%d\\n\", n.CurrentTerm)\n\n\tresponses := make(chan rf.AppendEntriesResponse, len(n.ServersAddr))\n\n\tfor i, _ := range n.ServersAddr {\n\t\t// skip self\n\t\tif i == (int)(n.ID) {\n\t\t\tcontinue\n\t\t}\n\n\t\t// responses stores each go routine value\n\t\tgo n.runAppendEntries(i, responses)\n\t}\n\n\t// collect all responses as they come in\n\tfor {\n\t\tselect {\n\t\tcase val := <-responses:\n\t\t\t// on success, we update the match index to the point we found a match\n\t\t\t// then reset nextIndex so the next heartbeat will match farther\n\t\t\tif val.Success {\n\t\t\t\tn.MatchIndex[val.Id] = n.NextIndex[val.Id] - 1\n\t\t\t\tn.NextIndex[val.Id] = (int32)(len(n.Log))\n\t\t\t} else if val.Reason == rf.ErrorCode_AE_OLDTERM { // we have been demoted, exit and become follower\n\t\t\t\tn.State = \"follower\"\n\t\t\t\tn.CurrentTerm = val.Term\n\t\t\t\tn.resetTimer(\"AE term mismatch\")\n\t\t\t\treturn\n\t\t\t} else if val.Reason == rf.ErrorCode_AE_LOGMISMATCH { // this node ID is out of date, attempt to find earliest matching point\n\t\t\t\tn.NextIndex[val.Id]--\n\t\t\t}\n\n\t\t\tn.updateCommitIndex()\n\t\t// check for timeout, if so, exit and restart\n\t\tcase message := <-done:\n\t\t\tif message == \"timeout\" {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "f0f7305ba7e34bf239072194b500eb8e", "score": "0.50758505", "text": "func (fm *Fesl) Status(event network.EvProcess) {\n\tlogrus.Println(\"--Status--\")\t\n\t\t\n\t// var gid string\t\n\t// var err error\n\n\t// err = fm.db.stmtGetBookmark.QueryRow(event.Client.HashState.Get(\"uID\")).Scan(&gid)\n\t// if err != nil {\t\n \t// \tlogrus.Println(\"no game found for player\")\n\t// }\t\n\n\n\tvar gid string\t\n\tvar err error\n\n\terr = fm.db.stmtGetBookmark.QueryRow(event.Client.HashState.Get(\"uID\")).Scan(&gid)\n\tif err != nil {\t\n \t\tlogrus.Println(\"no game found for player\")\n\t }\t\n\n\n\t// continuos search\n\tfor search := range mm.Games {\n\tgid := search\n\tgamesArray := []stGame{\n\t\t{\n\t\t\tGID: gid,\n\t\t\tFit: 1001,\n\t\t\tLobbyID: 1,\n\t\t},\n\t}\t\t\n\n\t//todo if joined = true ( do nothing)\n\t//if joined = false ( send canceled STATE)\n\n\tevent.Client.Answer(&codec.Packet{\n\t\tContent: Status{\n\t\t\tTXN: \"Status\",\n\t\t\tState: \"COMPLETE\",\n\t\t\tID: \"1\",\n\t\t\tPartition: \"eagames/bfwest-dedicated\",\n\t\t\tProperties: map[string]interface{}{\n\t\t\t\t\"resultType\": \"JOIN\",\n\t\t\t\t\"sessionType\": \"findServer\",\n\t\t\t\t\"games\": gamesArray},\n\t\t},\n\t\tSend: 0x80000000,\n\t\tMessage: pnow,\n\t})\n}}", "title": "" }, { "docid": "1a6b17657255023d2bde34101bdb4a75", "score": "0.5072219", "text": "func nodeReadyStatus(conditions []v1.NodeCondition) (v1.ConditionStatus, error) {\n\tfor _, c := range conditions {\n\t\tif c.Type != v1.NodeReady {\n\t\t\tcontinue\n\t\t}\n\t\t// Just return the first condition with type NodeReady\n\t\treturn c.Status, nil\n\t}\n\treturn v1.ConditionFalse, errors.New(\"None of the conditions is of type NodeReady\")\n}", "title": "" }, { "docid": "c0361e80b7d3fef021277bbc9745e58e", "score": "0.50638354", "text": "func newStreamStatus(onStale func() error,\n\tstaleTimeout time.Duration) *streamStatus {\n\n\tif staleTimeout < 0 {\n\t\treturn &streamStatus{\n\t\t\tdisabled: true,\n\t\t}\n\t}\n\n\tstaleTimer := time.AfterFunc(staleTimeout, func() {\n\t\tif err := onStale(); err != nil {\n\t\t\tlog.Errorf(\"error in onStale callback: %v\", err)\n\t\t}\n\t})\n\n\treturn &streamStatus{\n\t\tstaleTimer: staleTimer,\n\t\tstaleTimeout: staleTimeout,\n\t}\n}", "title": "" }, { "docid": "988ce3062290925fb464648670ff262a", "score": "0.50526005", "text": "func (c *Store) SetNodeStatus(ctx context.Context, ttl int64) error {\n\topts := &pb.SetNodeStatusOptions{\n\t\tNodename: c.config.HostName,\n\t\tTtl: ttl,\n\t}\n\tvar err error\n\tutils.WithTimeout(ctx, c.config.GlobalConnectionTimeout, func(ctx context.Context) {\n\t\t_, err = c.GetClient().SetNodeStatus(ctx, opts)\n\t})\n\n\treturn err\n}", "title": "" }, { "docid": "e2a4ae09edd963790995eeec204102ba", "score": "0.5046727", "text": "func SendStatus(statusUpdate status.StatusStruct) {\n\t_mtx.Lock()\n\tdefer _mtx.Unlock()\n\tseqNo += 1\n\tstatusMessageToSend.Message = statusUpdate\n\tstatusMessageToSend.SeqNo = seqNo\n\tTXstate <- statusMessageToSend\n\n\tif len(peerlist.Peers) != 0 {\n\t\tsentMessages.StatusMessages[seqNo] = statusMessageToSend.Message\n\t\tsentMessages.NumberOfTimesSent[seqNo] = 1\n\t\tsentMessages.NotRecFromPeer[seqNo] = peerlist.Peers\n\n\t\tnewAckStruct := AckStruct{\n\t\t\tAckMessage: AckMsg{\n\t\t\t\tId: ID,\n\t\t\t\tSeqNo: seqNo,\n\t\t\t\tMsgType: 1,\n\t\t\t},\n\t\t\tAckTimer: time.NewTimer(15 * time.Millisecond),\n\t\t}\n\t\tgo ackTimer(TimeoutAckChan, newAckStruct)\n\t}\n}", "title": "" }, { "docid": "9e3be28bb86cd3b27a9aaab5ae1972ec", "score": "0.5035908", "text": "func AllManagementNodeReady(client *rancher.Client, ClusterID string) error {\n\terr := wait.Poll(1*time.Second, 30*time.Minute, func() (bool, error) {\n\t\tnodes, err := client.Management.Node.ListAll(&types.ListOpts{\n\t\t\tFilters: map[string]interface{}{\n\t\t\t\t\"clusterId\": ClusterID,\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\n\t\tfor _, node := range nodes.Data {\n\t\t\tnode, err := client.Management.Node.ByID(node.ID)\n\t\t\tif err != nil {\n\t\t\t\treturn false, nil\n\t\t\t}\n\t\t\tif node.State == errorState {\n\t\t\t\tlogrus.Warnf(\"node %s is in error state\", node.Name)\n\t\t\t\treturn false, nil\n\t\t\t}\n\t\t\tif node.State != activeState {\n\t\t\t\treturn false, nil\n\t\t\t}\n\t\t}\n\t\tlogrus.Infof(\"All nodes in the cluster are in an active state!\")\n\t\treturn true, nil\n\t})\n\n\treturn err\n}", "title": "" }, { "docid": "3ccb7abe3f0d8a0273e9033b6c727bdb", "score": "0.503238", "text": "func watchFirstServer(node string) {\n\tpath := fmt.Sprintf(\"%s/%s\", Conf.Zookeeper.RootPath, node)\n\tfor {\n\t\tsubNodes, watch, err := getNodesW(path)\n\t\tif err != nil {\n\t\t\tLog.Error(\"watch node:%s error (%v)\", node, err)\n\t\t\ttime.Sleep(10 * time.Second)\n\t\t\tcontinue\n\t\t}\n\n\t\t// If exist server then set it into NodeInfoMap\n\t\tif len(subNodes) != 0 {\n\t\t\tsort.Strings(subNodes)\n\t\t\tdata, _, err := zk.Get(fmt.Sprintf(\"%s/%s\", path, subNodes[0]))\n\t\t\tif err != nil {\n\t\t\t\tLog.Error(\"watch node:%s, subNode:%s, error (%v)\", node, subNodes[0], err)\n\t\t\t\ttime.Sleep(10 * time.Second)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Fecth push server info\n\t\t\tdatas := strings.Split(data, \",\")\n\t\t\tif len(datas) < 2 {\n\t\t\t\tLog.Error(\"get subNode data error node:%s, subNode:%s, data:%s\", node, subNodes[0], data)\n\t\t\t\ttime.Sleep(10 * time.Second)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tNodeInfoMapLock.RLock()\n\t\t\tinfo, ok := NodeInfoMap[node]\n\t\t\tif ok {\n\t\t\t\tinfo.SubAddr = datas[0]\n\t\t\t\tif info.PubRPC != nil {\n\t\t\t\t\tinfo.PubRPC.Close()\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tinfo = &NodeInfo{SubAddr: datas[0]}\n\t\t\t}\n\t\t\tNodeInfoMapLock.RUnlock()\n\n\t\t\t// ReDial RPC\n\t\t\tr, err := rpc.Dial(Conf.Push.Network, datas[1])\n\t\t\tif err != nil {\n\t\t\t\tLog.Error(\"rpc.Dial(%s, %s) error node:%s, subNode:%s\", Conf.Push.Network, datas[1], node, subNodes[0])\n\t\t\t\ttime.Sleep(10 * time.Second)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tinfo.PubRPC = r\n\t\t\tNodeInfoMapLock.Lock()\n\t\t\tNodeInfoMap[node] = info\n\t\t\tNodeInfoMapLock.Unlock()\n\t\t} else {\n\t\t\tNodeInfoMapLock.Lock()\n\t\t\tNodeInfoMap[node] = nil\n\t\t\tNodeInfoMapLock.Unlock()\n\t\t}\n\n\t\tLog.Warn(\"begin to watch node:%s\", node)\n\t\tevent := <-watch\n\t\tif event.Type == zookeeper.EVENT_DELETED {\n\t\t\tLog.Warn(\"stop to watch node:%s\", node)\n\t\t\tDelNode(node)\n\t\t\tbreak\n\t\t}\n\n\t\tLog.Warn(\"end to watch node:%s event:%v, try to watch repeated\", node, event)\n\t}\n}", "title": "" }, { "docid": "19232c82f9ab60ea4f6d31dcf5727da6", "score": "0.50308216", "text": "func (node *raftNode) sendHeartbeat() bool {\n\tnode.network.Broadcast(node.id, node.createHeartBeatMessage())\n\treturn true\n}", "title": "" }, { "docid": "a508b4c88eb3fd17155288d9a30374b9", "score": "0.50190765", "text": "func nodeIsReady(n *corev1.Node) bool {\n\tfor _, condition := range n.Status.Conditions {\n\t\tif condition.Type == corev1.NodeReady && condition.Status == corev1.ConditionTrue {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "b49249966ff60b178823357cb9ea699f", "score": "0.500775", "text": "func TestKubernetes10182(t *testing.T) {\n\ts := &statusManager{\n\t\tpodStatusChannel: make(chan bool),\n\t}\n\tgo s.Start()\n\tgo s.SetPodStatus() // G2\n\tgo s.SetPodStatus() // G3\n}", "title": "" }, { "docid": "841b304f8e5052ca07fd2fe3e5222b72", "score": "0.500525", "text": "func (r *ReconcileAppNode) onAdd(node *meshv1.AppNode) {\n\tinstance := &meshv1.AppNode{}\n\tkey, kerr := client.ObjectKeyFromObject(node)\n\tif kerr != nil {\n\t\tblog.Errorf(\"ReconcileAppNode formate %s/%s to Object key failed, %s\", node.GetNamespace(), node.GetName(), kerr.Error())\n\t\treturn\n\t}\n\tif err := ns.CheckNamespace(r.localCache, r, node.GetNamespace()); err != nil {\n\t\tblog.Errorf(\"ReconcileAppNode checks namespace %s failed, %s\", node.GetNamespace(), err.Error())\n\t\treturn\n\t}\n\terr := r.Get(context.TODO(), key, instance)\n\tif err != nil {\n\t\tif errors.IsNotFound(err) {\n\t\t\t// Object not found, create new one directly\n\t\t\tif err := r.Create(context.TODO(), node); err != nil {\n\t\t\t\tblog.Errorf(\"ReconcileAppNode create new AppNode %s failed, %s\", key.String(), err.Error())\n\t\t\t\treturn\n\t\t\t}\n\t\t\tblog.Infof(\"ReconcileAppNode creat new AppNode %s on EventAdded successfully\", key.String())\n\t\t\treturn\n\t\t}\n\t\t// Error reading the object\n\t\tblog.Errorf(\"AppNode reads local cache %s failed, %s\", key.String(), err.Error())\n\t\treturn\n\t}\n\t//get exist data, ready to update\n\tif reflect.DeepEqual(instance.Spec, node.Spec) {\n\t\tblog.Warnf(\"ReconcileAppNode get deepEqual in EventAdded, key: %s\", key.String())\n\t\treturn\n\t}\n\t//fix(DeveloperJim): change Spec data & Status\n\tinstance.Spec = node.Spec\n\tinstance.Status.LastUpdateTime = metav1.Now()\n\t//ready to Udpate\n\tif err := r.Update(context.TODO(), instance); err != nil {\n\t\tblog.Errorf(\"ReconcileAppNode update %s in EventAdded failed, %s\", key.String(), err.Error())\n\t\treturn\n\t}\n\tif err := r.Status().Update(context.TODO(), instance); err != nil {\n\t\tblog.Errorf(\"ReconcileAppNode update %s Status in EventAdded failed, %s\", key.String(), err.Error())\n\t\treturn\n\t}\n\tblog.Warnf(\"ReconcileAppNode update %s successfully in EventAdded, maybe TaskGroup cache lost in cluster\", key.String())\n}", "title": "" }, { "docid": "7b184cd0d4e0987c677cddb3b7ae0ee5", "score": "0.49882686", "text": "func HeartBeat(ev cellnet.Event) {\n\tfor {\n\t\tev.Session().Send(message.NewPing())\n\t\ttime.Sleep(5 * time.Second)\n\t}\n}", "title": "" }, { "docid": "5b0948cc55ec979fb1666f64d718a357", "score": "0.49878255", "text": "func (n *NodeManagementWorker) UpdateStatus(policyName string, status *exchangecommon.NodeManagementPolicyStatus, putStatusHandler exchange.PutNodeManagementPolicyStatusHandler, eventLogMessageMeta *persistence.MessageMeta, eventCode string) error {\n\torg, nodeId := cutil.SplitOrgSpecUrl(n.GetExchangeId())\n\tpattern := \"\"\n\tconfigState := \"\"\n\texchDev, err := persistence.FindExchangeDevice(n.db)\n\tif err != nil {\n\t\tglog.Errorf(nmwlog(fmt.Sprintf(\"Error getting device from database: %v\", err)))\n\t} else if exchDev != nil {\n\t\tpattern = exchDev.Pattern\n\t\tconfigState = exchDev.Config.State\n\t}\n\teventlog.LogNodeEvent(n.db, persistence.SEVERITY_INFO, eventLogMessageMeta, eventCode, nodeId, org, pattern, configState)\n\tif err := persistence.SaveOrUpdateNMPStatus(n.db, policyName, *status); err != nil {\n\t\treturn err\n\t}\n\tif _, err := putStatusHandler(org, nodeId, policyName, status); err != nil {\n\t\treturn fmt.Errorf(\"Failed to put node management policy status for policy %v to the exchange: %v\", policyName, err)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "3894b7ab30189789e98167b33074c8c3", "score": "0.49839592", "text": "func (s *Scheduler) processNodeEvent(event *schedulerevent.SchedulerNodeEvent) {\n\t// process the node addition (one per event)\n\tif event.AddedNode != nil {\n\t\tnodeInfo, ok := event.AddedNode.(*cache.NodeInfo)\n\t\tif !ok {\n\t\t\tlog.Logger().Debug(\"cast failed unexpected object in node add event\",\n\t\t\t\tzap.Any(\"NodeInfo\", event.AddedNode))\n\t\t}\n\t\ts.clusterSchedulingContext.addSchedulingNode(nodeInfo)\n\t}\n\t// process the node deletion (one per event)\n\tif event.RemovedNode != nil {\n\t\tnodeInfo, ok := event.RemovedNode.(*cache.NodeInfo)\n\t\tif !ok {\n\t\t\tlog.Logger().Debug(\"cast failed unexpected object in node remove event\",\n\t\t\t\tzap.Any(\"NodeInfo\", event.RemovedNode))\n\t\t}\n\t\ts.clusterSchedulingContext.removeSchedulingNode(nodeInfo)\n\t}\n\t// preempted resources have now been released update the node\n\tif event.PreemptedNodeResources != nil {\n\t\ts.clusterSchedulingContext.releasePreemptedResources(event.PreemptedNodeResources)\n\t}\n\t// update node resources\n\tif event.UpdateNode != nil {\n\t\tnodeInfo, ok := event.UpdateNode.(*cache.NodeInfo)\n\t\tif !ok {\n\t\t\tlog.Logger().Debug(\"cast failed unexpected object in node update event\",\n\t\t\t\tzap.Any(\"NodeInfo\", event.UpdateNode))\n\t\t}\n\t\ts.clusterSchedulingContext.updateSchedulingNode(nodeInfo)\n\t}\n}", "title": "" }, { "docid": "ac5e71c1ee231f2f823f20656a9884b7", "score": "0.49795645", "text": "func monitorNodesStatusGlobalConsistently(ctx context.Context, c client.Client, namespace string, names []string, status v1.ConditionStatus, specName string) {\n\tByf(\"Ensuring Nodes %v consistently have ready=%s status\", names, status)\n\tConsistently(\n\t\tfunc() error {\n\t\t\tfor _, node := range names {\n\t\t\t\tif err := assertNodeStatus(ctx, c, client.ObjectKey{Namespace: namespace, Name: node}, status); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn nil\n\t\t}, e2eConfig.GetIntervals(specName, \"monitor-vm-state\")...).Should(Succeed())\n}", "title": "" }, { "docid": "7410775051961bfbac8ba3f6d3f3abd2", "score": "0.49751312", "text": "func (sm *State_Machine) EventProcess() {\n\tvar msg Message\n\tfor {\n\t\t//fmt.Println(\"In EventProcess\")\n\t\tselect {\n\n\t\t//Timeout Event.\n\t\tcase <-sm.CommMedium.timeoutCh:\n\t\t\t//Generate corrosponding response to the request.\n\t\t\tswitch sm.status {\n\t\t\tcase FOLL:\n\t\t\t\t//fmt.Println(\"***>>\", sm.currTerm)\n\t\t\t\t//Change state to CandIdate.\n\t\t\t\t//fmt.Println(\"--->>\", sm.id, \" : \", time.Now())\n\t\t\t\tsm.candSys()\n\n\t\t\tcase CAND:\n\t\t\t\t//Start election for next Term again.\n\t\t\t\tsm.candSys()\n\n\t\t\tcase LEAD:\n\t\t\t\t//fmt.Println(\"Heartbeat-\", len(sm.Logg.Logg))\n\t\t\t\t//Commit the Logg and send heartbeat msg to all other servers.\n\t\t\t\tsm.commitLogg()\n\t\t\t\tif len(sm.Logg.Logg) == 0 {\n\t\t\t\t\trespp := Send{PeerId: 0, Event: AppEntrReq{Term: sm.currTerm, LeaderId: sm.id, PreLoggInd: 0, PreLoggTerm: 0, LeaderCom: 0}}\n\t\t\t\t\t//fmt.Println(\"--->>\", sm.currTerm, \" : \", time.Now())\n\t\t\t\t\tsm.CommMedium.actionCh <- respp\n\t\t\t\t\tresp := Alarm{T: LTO} //175\n\t\t\t\t\t//Set heartbeat timeout\n\t\t\t\t\tsm.CommMedium.actionCh <- resp\n\t\t\t\t} else {\n\t\t\t\t\trespp := Send{PeerId: 0, Event: AppEntrReq{Term: sm.currTerm, LeaderId: sm.id, PreLoggInd: sm.LoggInd - 1, PreLoggTerm: sm.Logg.Logg[sm.LoggInd-1].Term, LeaderCom: sm.CommitIndex}}\n\t\t\t\t\tsm.CommMedium.actionCh <- respp\n\t\t\t\t\tresp := Alarm{T: LTO} //175\n\t\t\t\t\t//Set heartbeat timeout\n\t\t\t\t\tsm.CommMedium.actionCh <- resp\n\t\t\t\t}\n\t\t\t}\n\n\t\t//Requests from client machine.\n\t\tcase appendMsg := <-sm.CommMedium.clientCh:\n\t\t\tmsg = appendMsg.(Append)\n\t\t\tmsg.commit(sm)\n\n\t\t//Request from PEERS in the cluster.\n\t\tcase PeerMsg := <-sm.CommMedium.netCh:\n\t\t\t//Generate corrosponding response to the request.\n\t\t\tswitch PeerMsg.(type) {\n\t\t\tcase AppEntrReq:\n\t\t\t\tmsg = PeerMsg.(AppEntrReq)\n\t\t\t\tmsg.send(sm)\n\t\t\tcase AppEntrResp:\n\t\t\t\tmsg = PeerMsg.(AppEntrResp)\n\t\t\t\tmsg.send(sm)\n\t\t\tcase VoteReq:\n\t\t\t\tmsg = PeerMsg.(VoteReq)\n\t\t\t\tmsg.send(sm)\n\t\t\tcase VoteResp:\n\t\t\t\t//fmt.Println(\"<<<IN<<<\")\n\t\t\t\tmsg = PeerMsg.(VoteResp)\n\t\t\t\tmsg.send(sm)\n\t\t\t}\n\n\t\t}\n\t}\n}", "title": "" }, { "docid": "60f5dc252980f2e270415ad5d4852601", "score": "0.49707732", "text": "func (s *ClusterListener) StateNode(ctx context.Context, in *protocol.ClusterNodeRequest) (_ *protocol.HostStatus, err error) {\n\tdefer fail.OnExitConvertToGRPCStatus(&err)\n\tdefer fail.OnExitWrapError(&err, \"cannot get cluster node state\")\n\n\tif s == nil {\n\t\treturn nil, fail.InvalidInstanceError()\n\t}\n\tif in == nil {\n\t\treturn nil, fail.InvalidParameterCannotBeNilError(\"in\")\n\t}\n\tif ctx == nil {\n\t\treturn nil, fail.InvalidParameterCannotBeNilError(\"ctx\")\n\t}\n\n\tif ok, err := govalidator.ValidateStruct(in); err != nil || !ok {\n\t\tlogrus.Warnf(\"Structure validation failure: %v\", in) // FIXME: Generate json tags in protobuf\n\t}\n\n\tclusterName := in.GetName()\n\tif clusterName == \"\" {\n\t\treturn nil, fail.InvalidRequestError(\"cluster name is missing\")\n\t}\n\tnodeRef, nodeRefLabel := srvutils.GetReference(in.GetHost())\n\tif nodeRef == \"\" {\n\t\treturn nil, fail.InvalidRequestError(\"neither name nor id of node is provided\")\n\t}\n\n\tjob, err := PrepareJob(ctx, in.GetHost().GetTenantId(), fmt.Sprintf(\"/cluster/%s/node/%s/state\", clusterName, nodeRef))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer job.Close()\n\n\ttracer := debug.NewTracer(job.Task(), tracing.ShouldTrace(\"listeners.cluster\"), \"('%s', %s)\", clusterName, nodeRefLabel).WithStopwatch().Entering()\n\tdefer tracer.Exiting()\n\tdefer fail.OnExitLogError(&err, tracer.TraceMessage())\n\n\tclusterInstance, xerr := clusterfactory.Load(job.Service(), clusterName)\n\tif xerr != nil {\n\t\treturn nil, xerr\n\t}\n\tdefer clusterInstance.Released()\n\n\tnodeList, xerr := clusterInstance.ListNodes(job.Context())\n\tif xerr != nil {\n\t\treturn nil, xerr\n\t}\n\n\tid := idOfClusterMember(nodeList, nodeRef)\n\tif id == \"\" {\n\t\treturn nil, fail.NotFoundError(\"failed to find node %s in Cluster\", nodeRefLabel)\n\t}\n\n\thostInstance, xerr := hostfactory.Load(job.Service(), id)\n\tif xerr != nil {\n\t\treturn nil, xerr\n\t}\n\tdefer hostInstance.Released()\n\n\tstate, xerr := hostInstance.ForceGetState(job.Context())\n\tif xerr != nil {\n\t\treturn nil, xerr\n\t}\n\n\treturn converters.HostStatusFromAbstractToProtocol(hostInstance.GetName(), state), nil\n}", "title": "" }, { "docid": "7aa6ed7cde827a8771ea27ce8a090e92", "score": "0.49634337", "text": "func NodeIsAlive(endpoint string) bool {\n\tmessage, err := MakeRequest(endpoint, IsAlive)\n\tif err != nil {\n\t\treturn false\n\t}\n\treturn message == \"Yes\"\n}", "title": "" }, { "docid": "f977730e9ca7d5ffdd2c2e7ad70ba0da", "score": "0.49615043", "text": "func (tn *TreeNode) processWatchEvent(evt *zk.Event) {\n\ttn.tree.logger.Debugf(\"ProcessWatchEvent: %v\", evt)\n\tswitch evt.Type {\n\tcase zk.EventNodeCreated:\n\t\tif tn.parent != nil {\n\t\t\ttn.tree.handleException(errors.New(\"unexpected NodeCreated on non-root node\"))\n\t\t\treturn\n\t\t}\n\t\ttn.wasCreated()\n\tcase zk.EventNodeChildrenChanged:\n\t\ttn.refreshChildren()\n\tcase zk.EventNodeDataChanged:\n\t\ttn.refreshData()\n\tcase zk.EventNodeDeleted:\n\t\ttn.wasDeleted()\n\tdefault:\n\t\t// Leave other type of events unhandled\n\t\t// tn.tree.logger.Printf(\"Event received: %v\", evt)\n\t}\n}", "title": "" }, { "docid": "1b6049db56ec7559df40a1d29edfecf9", "score": "0.49591514", "text": "func ready(s *discordgo.Session, event *discordgo.Ready) {\n\tgo func() {\n\t\tvar statuses = []string{\n\t\t\t\"Hades' Star\",\n\t\t\t\"RS with bots\",\n\t\t\t\"RS, killing cerb\",\n\t\t\t\"cards with colossi\",\n\t\t\t\"shipments delivery\",\n\t\t\t\"shipments delivery\",\n\t\t\t\"shipments delivery\",\n\t\t\t\"but low on hydro\",\n\t\t\t\"with TM variations\",\n\t\t\t\"with sand on Mars\",\n\t\t}\n\t\trand.Seed(time.Now().Unix())\n\t\tfor {\n\t\t\terr := s.UpdateStatus(0, statuses[rand.Intn(len(statuses))])\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"%#v\\n\", err)\n\t\t\t}\n\t\t\ttime.Sleep(20 * time.Minute)\n\t\t}\n\t}()\n}", "title": "" }, { "docid": "f966e1791f398c77bbc27bbdd146e047", "score": "0.4957158", "text": "func (cnc *CloudNodeController) UpdateNodeStatus(ctx context.Context) error {\n\tstart := time.Now()\n\tnodes, err := cnc.nodesLister.List(labels.Everything())\n\tif err != nil {\n\t\tklog.Errorf(\"Error monitoring node status: %v\", err)\n\t\treturn err\n\t}\n\tdefer func() {\n\t\tklog.V(2).Infof(\"Update %d nodes status took %v.\", len(nodes), time.Since(start))\n\t}()\n\n\tupdateNodeFunc := func(piece int) {\n\t\tnode := nodes[piece].DeepCopy()\n\t\t// Do not process nodes that are still tainted, those will be processed by syncNode()\n\t\tcloudTaint := getCloudTaint(node.Spec.Taints)\n\t\tif cloudTaint != nil {\n\t\t\tklog.V(5).Infof(\"This node %s is still tainted. Will not process.\", node.Name)\n\t\t\treturn\n\t\t}\n\n\t\tinstanceMetadata, err := cnc.getInstanceNodeAddresses(ctx, node)\n\t\tif err != nil {\n\t\t\tklog.Errorf(\"Error getting instance metadata for node addresses: %v\", err)\n\t\t\treturn\n\t\t}\n\n\t\tcnc.updateNodeAddress(ctx, node, instanceMetadata)\n\n\t\terr = cnc.reconcileNodeLabels(node.Name)\n\t\tif err != nil {\n\t\t\tklog.Errorf(\"Error reconciling node labels for node %q, err: %v\", node.Name, err)\n\t\t}\n\t}\n\n\tworkqueue.ParallelizeUntil(ctx, int(cnc.workerCount), len(nodes), updateNodeFunc)\n\treturn nil\n}", "title": "" }, { "docid": "2ed8c01af85f86fc8db644b579c92d31", "score": "0.49546278", "text": "func StartStatusUpdate(elevators int){\n\tstatus := make([]int, elevators-1)\n\tstatusChan := make(chan []int)\n\trecieveChan := make(chan []int)\n\tc := make(chan int)\n\tgo statusUpdate(elevators, recieveChan, statusChan)\n\tfor{\n\t\tstatus = <- recieveChan\n\t\tselect{\n\t\tcase v:= <- c:\n\t\t\tstatus[v]=1\n\t\t}\n\t\tstatusChan <- status\n\t}\n\n}", "title": "" }, { "docid": "09a866606dc470886213cb42990ec882", "score": "0.4953308", "text": "func listenerMasterToNode() {\r\n\tport, _ := strconv.Atoi(Port[jsonId])\r\n\tM2Nport := strconv.Itoa(port + 2)\r\n\tPORT := \":\" + M2Nport\r\n\tl, err := net.Listen(\"tcp\", PORT)\r\n\tif err != nil {\r\n\t\tfmt.Println(err)\r\n\t\treturn\r\n\t}\r\n\tdefer l.Close()\r\n\trand.Seed(time.Now().Unix())\r\n\tfmt.Println(\"Node starts to listen to master\")\r\n\tfor {\r\n\r\n\t\tc, err := l.Accept()\r\n\t\tif err != nil {\r\n\t\t\tfmt.Println(err)\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tgo handleConnection_fromMaster(c)\r\n\t}\r\n}", "title": "" }, { "docid": "e087fe036204f2158b4680b6bc4e3bb3", "score": "0.49526313", "text": "func TestMemberList_AliveNode_ChangeMeta(t *testing.T) {\n\tch := make(chan NodeEvent, 1)\n\tm := GetMemberlist(t)\n\n\ta := alive{\n\t\tNode: \"test\",\n\t\tAddr: []byte{127, 0, 0, 1},\n\t\tMeta: []byte(\"val1\"),\n\t\tIncarnation: 1}\n\tm.aliveNode(&a, nil, false)\n\n\t// Listen only after first join\n\tm.config.Events = &ChannelEventDelegate{ch}\n\n\t// Make suspect\n\tstate := m.nodeMap[\"test\"]\n\n\t// Should reset to alive now\n\ta.Incarnation = 2\n\ta.Meta = []byte(\"val2\")\n\tm.aliveNode(&a, nil, false)\n\n\t// Check updates\n\tif bytes.Compare(state.Meta, a.Meta) != 0 {\n\t\tt.Fatalf(\"meta did not update\")\n\t}\n\n\t// Check for a NotifyUpdate\n\tselect {\n\tcase e := <-ch:\n\t\tif e.Event != NodeUpdate {\n\t\t\tt.Fatalf(\"bad event: %v\", e)\n\t\t}\n\t\tif e.Node != &state.Node {\n\t\t\tt.Fatalf(\"bad event: %v\", e)\n\t\t}\n\t\tif bytes.Compare(e.Node.Meta, a.Meta) != 0 {\n\t\t\tt.Fatalf(\"meta did not update\")\n\t\t}\n\tdefault:\n\t\tt.Fatalf(\"missing event!\")\n\t}\n\n}", "title": "" }, { "docid": "ec930dca0e3e64b8da607280f144edda", "score": "0.49506462", "text": "func (dhtNode *DHTNode) stabilize(){\n\tnodeAddress := dhtNode.contact.ip + \":\" + dhtNode.contact.port\n\tgetSuccPred := createGetNodeMsg(\"pred\", nodeAddress, dhtNode.successor[0])\n\tgo func () { dhtNode.transport.send(getSuccPred)} () \n\t//send msg\n\twaitResponse := time.NewTimer(time.Millisecond*5000)\n\tfor {\n\t\tselect {\n\t\t\tcase r := <- dhtNode.responseQueue:\n\t\t\t\tif ((between([]byte(dhtNode.nodeId), []byte(dhtNode.successor[1]), []byte(r.LightNode[1]))) && r.LightNode[1] != \"\" ){\n\t\t\t\t\tdhtNode.successor[0] = r.LightNode[0]\n\t\t\t\t\tdhtNode.successor[1] = r.LightNode[1]\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tnotify := createNotifyMsg(nodeAddress, dhtNode.successor[0], [2]string{nodeAddress, dhtNode.nodeId})\n\t\t\t\tgo func () { dhtNode.transport.send(notify)} () \n\t\t\t\treturn\n\n\t\t\tcase t := <- waitResponse.C: //if timer is greater than 2000ms\n\t\t\t\t//check if alive\n\t\t\t\tfmt.Println(t, \"successor timeout\")\n\t\t\t\treturn\n\t\t}\n\t}\n\n}", "title": "" }, { "docid": "2d191ccfd6bcb2f67530df9b908c2f27", "score": "0.49501324", "text": "func (r *ReconcileOpctlNode) updateOpctlNodeStatus(opctlNode *opctlv1beta1.OpctlNode, deployment *appsv1.Deployment, service *corev1.Service) error {\n\t// func (r *ReconcileOpctlNode) updateOpctlNodeStatus(opctlNode *opctlv1beta1.OpctlNode) error {\n\t// NEVER modify objects from the store. It's a read-only, local cache.\n\t// You can use DeepCopy() to make a deep copy of original object and modify this copy\n\t// Or create a copy manually for better performance\n\topctlNodeCopy := opctlNode.DeepCopy()\n\n\t// TODO: update other status fields (ex: apiEndpoint)\n\topctlNodeCopy.Status.Phase = \"Ready\"\n\n\t// update the Status block of the OpctlNode resource\n\tvar err error\n\terr = r.Client.Update(context.TODO(), opctlNodeCopy)\n\treturn err\n}", "title": "" }, { "docid": "936166c911061be5f56702c66c271c3a", "score": "0.4949644", "text": "func (room *Room) sendStatus(predicate SendPredicate) {\n\tif room.done() {\n\t\treturn\n\t}\n\troom.wGroup.Add(1)\n\tdefer func() {\n\t\troom.wGroup.Done()\n\t\tutils.CatchPanic(\"room_send.go RoomStatus()\")\n\t}()\n\n\tvar leftTime int\n\tfmt.Println(\" stat:\", room.Settings.TimeToPrepare, room.Settings.TimeToPlay, int(time.Since(room.Date).Seconds()))\n\tif room.Status == StatusFlagPlacing {\n\t\tleftTime = room.Settings.TimeToPrepare - int(time.Since(room.Date).Seconds())\n\n\t\tfmt.Println(\" StatusFlagPlacing leftTime:\", leftTime)\n\t}\n\tif room.Status == StatusRunning {\n\t\tleftTime = room.Settings.TimeToPlay - int(time.Since(room.Date).Seconds())\n\t\tfmt.Println(\" StatusRunning leftTime:\", leftTime)\n\t}\n\tresponse := models.Response{\n\t\tType: \"RoomStatus\",\n\t\tValue: struct {\n\t\t\tID string `json:\"id\"`\n\t\t\tStatus int `json:\"status\"`\n\t\t\tTime int `json:\"time\"`\n\t\t}{\n\t\t\tID: room.ID,\n\t\t\tStatus: room.Status,\n\t\t\tTime: leftTime,\n\t\t},\n\t}\n\troom.send(response, predicate)\n}", "title": "" }, { "docid": "85cb2f7068d60939e18a00565dd79def", "score": "0.4946359", "text": "func (c *ClusterClient) NodeStatus() (api.Status, error) {\n\tvar resp api.Status\n\trequest := c.c.Get().Resource(clusterPath + \"/nodestatus\")\n\tif err := request.Do().Unmarshal(&resp); err != nil {\n\t\treturn api.Status_STATUS_NONE, err\n\t}\n\treturn resp, nil\n}", "title": "" }, { "docid": "dd5aa359c8022791c6739558120e3389", "score": "0.49335065", "text": "func (w *Worker) Status(agent, message string) {\n\tw.Transmit(agent, \"/status\", message, true)\n}", "title": "" }, { "docid": "58afdf0ec458b7977c55847dc3deb9db", "score": "0.4915479", "text": "func RPCNodeStatus(m *monitor.Monitor) interface{} {\n\treturn func(name string) (*monitor.Node, error) {\n\t\tif i, n := m.NodeByName(name); i != -1 {\n\t\t\treturn n, nil\n\t\t}\n\t\treturn nil, errors.New(\"Cannot find node with that name\")\n\t}\n}", "title": "" }, { "docid": "1e356db09ef093ffdb74e4ff5068f71a", "score": "0.491405", "text": "func (n *Node) setStatus(status NodeStatus) {\n\tn.status.Set(status)\n}", "title": "" }, { "docid": "49af52af689379ff9cc756d25d514e4c", "score": "0.49100795", "text": "func (n *NameServiceCache) RequestNodeStatus(nodeID fred.NodeID) []fred.Item {\n\treturn n.regularNase.RequestNodeStatus(nodeID)\n}", "title": "" }, { "docid": "68150748ccc394053cc0dd992b92bfb8", "score": "0.48922694", "text": "func waitForStatusTransition(ctx context.Context, u string, c *okta.Client) error {\n\tuser, _, err := c.User.GetUser(ctx, u)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get user: %v\", err)\n\t}\n\tfor {\n\t\tif user.TransitioningToStatus == \"\" {\n\t\t\treturn nil\n\t\t}\n\n\t\tlog.Printf(\"[INFO] Transitioning to status = %v; waiting for 5 more seconds...\", user.TransitioningToStatus)\n\t\ttime.Sleep(5 * time.Second)\n\t\tuser, _, err = c.User.GetUser(ctx, u)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get user: %v\", err)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "87f3a37daf0114eace8f4e38796c4855", "score": "0.48906943", "text": "func (node *NodeMonitor) Poll(discover chan string, checkShards bool) (*status.ServerStatus, error) {\n\tstat := &status.ServerStatus{}\n\tlog.Logvf(log.DebugHigh, \"getting session on server: %v\", node.host)\n\tsession, err := node.sessionProvider.GetSession()\n\tif err != nil {\n\t\tlog.Logvf(log.DebugLow, \"got error getting session to server %v\", node.host)\n\t\treturn nil, err\n\t}\n\tlog.Logvf(log.DebugHigh, \"got session on server: %v\", node.host)\n\n\tresult := session.Database(\"admin\").RunCommand(nil, bson.D{{\"serverStatus\", 1}, {\"recordStats\", 0}})\n\terr = result.Err()\n\tif err != nil {\n\t\tlog.Logvf(log.DebugLow, \"got error calling serverStatus against server %v\", node.host)\n\t\treturn nil, err\n\t}\n\ttempBson, err := result.DecodeBytes()\n\tif err != nil {\n\t\tlog.Logvf(log.Always, \"Encountered error decoding serverStatus: %v\\n\", err)\n\t\treturn nil, fmt.Errorf(\"Error decoding serverStatus: %v\\n\", err)\n\t}\n\terr = bson.Unmarshal(tempBson, &stat)\n\tif err != nil {\n\t\tlog.Logvf(log.Always, \"Encountered error reading serverStatus: %v\\n\", err)\n\t\treturn nil, fmt.Errorf(\"Error reading serverStatus: %v\\n\", err)\n\t}\n\t// The flattened version is required by some lookup functions\n\tstatMap := make(map[string]interface{})\n\terr = result.Decode(&statMap)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Error flattening serverStatus: %v\\n\", err)\n\t}\n\tstat.Flattened = status.Flatten(statMap)\n\n\tnode.Err = nil\n\tstat.SampleTime = time.Now()\n\n\tif stat.Repl != nil && discover != nil {\n\t\tfor _, host := range stat.Repl.Hosts {\n\t\t\tdiscover <- host\n\t\t}\n\t\tfor _, host := range stat.Repl.Passives {\n\t\t\tdiscover <- host\n\t\t}\n\t}\n\tnode.alias = stat.Host\n\tstat.Host = node.host\n\tif discover != nil && stat != nil && status.IsMongos(stat) && checkShards {\n\t\tlog.Logvf(log.DebugLow, \"checking config database to discover shards\")\n\t\tshardCursor, err := session.Database(\"config\").Collection(\"shards\").Find(nil, bson.M{}, nil)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error discovering shards: %v\", err)\n\t\t}\n\t\tshard := ConfigShard{}\n\t\tfor shardCursor.Next(nil) {\n\t\t\tif cursorErr := shardCursor.Decode(&shard); cursorErr != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error decoding shard info: %v\", err)\n\t\t\t}\n\t\t\tshardHosts := strings.Split(shard.Host, \",\")\n\t\t\tfor _, shardHost := range shardHosts {\n\t\t\t\tdiscover <- shardHost\n\t\t\t}\n\t\t}\n\t\tshardCursor.Close(nil)\n\t}\n\n\treturn stat, nil\n}", "title": "" }, { "docid": "70d938124d26519c4380e0a982a27277", "score": "0.48898825", "text": "func (mgr *AdminMgr) StreamStatus(ctx context.Context, out chan bool) error {\n\n\t// Create DBus watcher for nfsd heartbeats.\n\tmatch := \"type='signal',path='/org/ganesha/nfsd/heartbeat',interface='org.ganesha.nfsd.admin',member='heartbeat'\"\n\tmgr.conn.BusObject().Call(\"org.freedesktop.DBus.AddMatch\", 0, match)\n\n\tin := make(chan *dbus.Signal)\n\tmgr.conn.Signal(in)\n\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tmgr.conn.BusObject().Call(\"org.freedesktop.DBus.RemoveMatch\", 0, match)\n\t\t\treturn ctx.Err()\n\t\tcase hb := <-in:\n\t\t\tout <- hb.Body[0].(bool)\n\t\t}\n\t}\n\n}", "title": "" }, { "docid": "216368b12e034083ecda4715e9ec74dc", "score": "0.48891896", "text": "func (client *PascalClient) NodeStatus() (nodeStatus *models.NodeStatus, err error) {\n\tresp, err := client.rpcClient.Call(\"nodestatus\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = resp.GetObject(&nodeStatus)\n\treturn nodeStatus, nil\n}", "title": "" }, { "docid": "ec40096fb8f9efe8940ecffffc2498e2", "score": "0.4889114", "text": "func NodeReadyStatus(conditions []v1.NodeCondition) (v1.ConditionStatus, error) {\n\tfor _, c := range conditions {\n\t\tif c.Type != v1.NodeReady {\n\t\t\tcontinue\n\t\t}\n\t\t// Just return the first condition with type NodeReady\n\t\treturn c.Status, nil\n\t}\n\treturn v1.ConditionFalse, errors.New(\"None of the conditions is of type NodeReady\")\n}", "title": "" }, { "docid": "0238a7682d085ea7bf7a0e15eeafd1e4", "score": "0.48840284", "text": "func isNodeReady(node *apiv1.Node) bool {\n\tfor _, cond := range node.Status.Conditions {\n\t\tif cond.Type == apiv1.NodeReady {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "9013deb570dc125411ee400237b149cd", "score": "0.48775795", "text": "func (ou *orcUpdater) updateNodeCondition(host string, cType api.NodeConditionType, status core.ConditionStatus) {\n\tou.cluster.UpdateNodeConditionStatus(host, cType, status)\n}", "title": "" }, { "docid": "99aeef5e573ed0b55313a16b3679b07e", "score": "0.4873464", "text": "func (dh *deviceHandler) sendOnuOperStateEvent(aOperState vc.OperStatus_Types, aDeviceID string, raisedTs int64) {\n\tvar de voltha.DeviceEvent\n\teventContext := make(map[string]string)\n\tparentDevice, err := dh.coreProxy.GetDevice(context.TODO(), dh.parentID, dh.parentID)\n\tif err != nil || parentDevice == nil {\n\t\tlogger.Errorw(\"Failed to fetch parent device for OnuEvent\",\n\t\t\tlog.Fields{\"parentID\": dh.parentID, \"err\": err})\n\t}\n\toltSerialNumber := parentDevice.SerialNumber\n\n\teventContext[\"pon-id\"] = strconv.FormatUint(uint64(dh.pOnuIndication.IntfId), 10)\n\teventContext[\"onu-id\"] = strconv.FormatUint(uint64(dh.pOnuIndication.OnuId), 10)\n\teventContext[\"serial-number\"] = dh.device.SerialNumber\n\teventContext[\"olt_serial_number\"] = oltSerialNumber\n\teventContext[\"device_id\"] = aDeviceID\n\teventContext[\"registration_id\"] = aDeviceID //py: string(device_id)??\n\tlogger.Debugw(\"prepare ONU_ACTIVATED event\",\n\t\tlog.Fields{\"DeviceId\": aDeviceID, \"EventContext\": eventContext})\n\n\t/* Populating device event body */\n\tde.Context = eventContext\n\tde.ResourceId = aDeviceID\n\tif aOperState == voltha.OperStatus_ACTIVE {\n\t\tde.DeviceEventName = fmt.Sprintf(\"%s_%s\", cOnuActivatedEvent, \"RAISE_EVENT\")\n\t\tde.Description = fmt.Sprintf(\"%s Event - %s - %s\",\n\t\t\tcEventObjectType, cOnuActivatedEvent, \"Raised\")\n\t} else {\n\t\tde.DeviceEventName = fmt.Sprintf(\"%s_%s\", cOnuActivatedEvent, \"CLEAR_EVENT\")\n\t\tde.Description = fmt.Sprintf(\"%s Event - %s - %s\",\n\t\t\tcEventObjectType, cOnuActivatedEvent, \"Cleared\")\n\t}\n\t/* Send event to KAFKA */\n\tif err := dh.EventProxy.SendDeviceEvent(&de, equipment, pon, raisedTs); err != nil {\n\t\tlogger.Warnw(\"could not send ONU_ACTIVATED event\",\n\t\t\tlog.Fields{\"device-id\": aDeviceID, \"error\": err})\n\t}\n\tlogger.Debugw(\"ONU_ACTIVATED event sent to KAFKA\",\n\t\tlog.Fields{\"device-id\": aDeviceID, \"with-EventName\": de.DeviceEventName})\n}", "title": "" }, { "docid": "6dd64ac67b5dd3babc8e1235de6fb689", "score": "0.4873206", "text": "func statusUpdate(elevators int, rChan chan []int, sChan chan []int){\n\tstatus := make([]int, elevators)\n\talert := make([]int, elevators)\n\talertChan := make(chan []int)\n\n\tfor index, _ := range alert{\n\t\talert[index] = 0\n\t}\n\n\tfor {\n\t\ttime.Sleep(10 *time.Second)\n\t\tstatus = <- sChan\n\t\tfmt.Println(status)\n\t\tfor index, _ := range status {\n\t\t\tif status[index] == 0 {\n\t\t\t\talert[index] += 1\n\t\t\t\tfmt.Println(alert)\n\t\t\t}\n\t\t\tif status[index] == 1{\n\t\t\t\talert[index] == 0\n\t\t\t}\n\t\t\tif alert[index] == 2{\n\t\t\t\talertChan <- alert\n\t\t\t\tfmt.Println(alert)\n\t\t\t\ttime.Sleep(time.Second)\n\t\t\t\talert = <- alertChan\n\t\t\t}\n\t\t}\n\n\t}\n}", "title": "" }, { "docid": "b2e39d52d028c87381656dcbb2ac21e8", "score": "0.48660895", "text": "func handleNewStatus(status *bepb.PlayerControl, remote *Remote) {\n\tfmt.Printf(\"Received: %v\\n\", status)\n\n\tswitch status.GetCommand() {\n\tcase bepb.CommandType_Play:\n\t\tlink, ok := buildSongLink(status.GetSong())\n\t\tif ok {\n\t\t\tremote.LoadSong(link, true)\n\t\t\tremote.ShowText(status.GetSong().GetTitle(), \"8000\")\n\t\t}\n\n\tcase bepb.CommandType_Next:\n\t\t// link can be an empty string. We still want to stop the player even\n\t\t// if there are no more songs in the playlist\n\t\tlink, _ := buildSongLink(status.GetSong())\n\t\tremote.Next(link)\n\t\tremote.ShowText(status.GetSong().GetTitle(), \"8000\")\n\n\tcase bepb.CommandType_Pause:\n\t\tremote.TogglePause()\n\t\tremote.ShowText(\"Player is paused\", \"600000\")\n\t}\n}", "title": "" }, { "docid": "8771ab0050004a376c99ff91f78c769d", "score": "0.48632228", "text": "func main() {\n\tvar call = \"\"\n\tc, err := eventsocket.Dial(\"localhost:8021\", \"ClueCon\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tc.Send(\"events json ALL\")\n\tc.Send(fmt.Sprintf(\"bgapi originate %s 9196 xml default\", dest))\n\tfor {\n\t\tev, err := c.ReadEvent()\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tfmt.Println(\"\\nNew event\")\n\t\tev.PrettyPrint()\n\t\tif ev.Get(\"Answer-State\") == \"hangup\" {\n\t\tlog.Fatal(\"Not working\")\n\t\t\tbreak\n\t\t}\n\t\tif ev.Get(\"Answer-State\") == \"answered\" {\n\t\tfmt.Println(\"We got the call: \", ev.Get(\"Unique-Id\"))\n\t\tcall = ev.Get(\"Unique-Id\")\n\t\t}\n\t\tif ev.Get(\"Session-Count\") >= \"1\" {\n\t\tfmt.Println(\"Call in progress: \", ev.Get(\"Session-Count\"))\n\t\t//time.Sleep(3000 * time.Millisecond)\n\t\tfmt.Println(\"Bye bye: \", call)\n\t\tc.SendMsg(eventsocket.MSG{\"call-command\": \"hangup\", \"hangup-cause\": \"we're done!\", }, call, \"\")\n\t\t\tbreak\n\t\t}\n\t}\n\tfmt.Println(\"Closing socker\")\n\tc.Close()\n}", "title": "" }, { "docid": "6f03993651067e0720e0c56329df4add", "score": "0.48616084", "text": "func (mcli *MatrixClient) NodesStatus(address []string) (map[string]string, error) {\n\tnumaddrs := len(address)\n\tif numaddrs > 10 {\n\t\treturn nil, nil\n\t}\n\tvar askwho []string\n\tfor _, dwho := range address {\n\t\tuserID := \"@\" + dwho + \":cy\"\n\t\taskwho = append(askwho, userID)\n\t}\n\terr0 := mcli.PostPresenceList(&ReqPresenceList{\n\t\tDrop: askwho,\n\t})\n\tif err0 != nil {\n\t}\n\ttime.Sleep(time.Millisecond * 5)\n\t//DROP all\n\terr1 := mcli.PostPresenceList(&ReqPresenceList{\n\t\tInvite: askwho,\n\t})\n\tif err1 != nil {\n\t\t//return nil, err1\n\t}\n\trespl, err := mcli.GetPresenceList(mcli.UserID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trx := make(map[string]string)\n\tfor i, x := range respl {\n\t\txuserID := x.UserID\n\t\txuserID = strings.Split(xuserID, \"@\")[1]\n\t\txuserID = strings.Split(xuserID, \":\")[0]\n\t\trtnpresence := x.Presence\n\t\trtnaddr := xuserID\n\t\trx[rtnaddr] = rtnpresence\n\t\tprintln(i, \":\", xuserID, \"---\", rtnpresence)\n\t}\n\treturn rx, nil\n}", "title": "" }, { "docid": "9cf9bd0241df677f9eeaa95865a451e9", "score": "0.4848504", "text": "func (c *Store) NodeStatusStream(ctx context.Context) (<-chan *types.NodeStatus, <-chan error) {\n\tmsgChan := make(chan *types.NodeStatus)\n\terrChan := make(chan error)\n\n\tgo func() {\n\t\tdefer close(msgChan)\n\t\tdefer close(errChan)\n\n\t\tclient, err := c.GetClient().NodeStatusStream(ctx, &pb.Empty{})\n\t\tif err != nil {\n\t\t\terrChan <- err\n\t\t\treturn\n\t\t}\n\n\t\tfor {\n\t\t\tmessage, err := client.Recv()\n\t\t\tif err != nil {\n\t\t\t\terrChan <- err\n\t\t\t\treturn\n\t\t\t}\n\t\t\tnodeStatus := &types.NodeStatus{\n\t\t\t\tNodename: message.Nodename,\n\t\t\t\tPodname: message.Podname,\n\t\t\t\tAlive: message.Alive,\n\t\t\t\tError: nil,\n\t\t\t}\n\t\t\tif message.Error != \"\" {\n\t\t\t\tnodeStatus.Error = errors.New(message.Error)\n\t\t\t}\n\t\t\tmsgChan <- nodeStatus\n\t\t}\n\t}()\n\n\treturn msgChan, errChan\n}", "title": "" }, { "docid": "bfae5c37692093381e5e7a3c5e2302ab", "score": "0.48443073", "text": "func TestNodeIsLiveCallback(t *testing.T) {\n\tdefer leaktest.AfterTest(t)()\n\tdefer log.Scope(t).Close(t)\n\n\tctx := context.Background()\n\tmanualClock := hlc.NewHybridManualClock()\n\ttc := testcluster.StartTestCluster(t, 3,\n\t\tbase.TestClusterArgs{\n\t\t\tReplicationMode: base.ReplicationManual,\n\t\t\tServerArgs: base.TestServerArgs{\n\t\t\t\tKnobs: base.TestingKnobs{\n\t\t\t\t\tServer: &server.TestingKnobs{\n\t\t\t\t\t\tClockSource: manualClock.UnixNano,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\tdefer tc.Stopper().Stop(ctx)\n\n\t// Verify liveness of all nodes for all nodes.\n\tverifyLiveness(t, tc)\n\tpauseNodeLivenessHeartbeatLoops(tc)\n\n\tvar cbMu syncutil.Mutex\n\tcbs := map[roachpb.NodeID]struct{}{}\n\ttc.Servers[0].NodeLiveness().(*liveness.NodeLiveness).RegisterCallback(func(l livenesspb.Liveness) {\n\t\tcbMu.Lock()\n\t\tdefer cbMu.Unlock()\n\t\tcbs[l.NodeID] = struct{}{}\n\t})\n\n\t// Advance clock past the liveness threshold.\n\tmanualClock.Increment(tc.Servers[0].NodeLiveness().(*liveness.NodeLiveness).GetLivenessThreshold().Nanoseconds() + 1)\n\n\t// Trigger a manual heartbeat and verify callbacks for each node ID are invoked.\n\tfor _, s := range tc.Servers {\n\t\tnl := s.NodeLiveness().(*liveness.NodeLiveness)\n\t\tl, ok := nl.Self()\n\t\tassert.True(t, ok)\n\t\tif err := nl.Heartbeat(context.Background(), l); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}\n\n\ttestutils.SucceedsSoon(t, func() error {\n\t\tcbMu.Lock()\n\t\tdefer cbMu.Unlock()\n\t\tfor _, s := range tc.Servers {\n\t\t\tnodeID := s.Gossip().NodeID.Get()\n\t\t\tif _, ok := cbs[nodeID]; !ok {\n\t\t\t\treturn errors.Errorf(\"expected IsLive callback for node %d\", nodeID)\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n}", "title": "" }, { "docid": "957cb50fd7a5b6c66f85a36488a9d1f1", "score": "0.48417148", "text": "func adminReporter(s *sseserver.Server) {\n\tticker := time.NewTicker(5 * time.Second)\n\tfor {\n\t\t// block waiting for ticker\n\t\t<-ticker.C\n\n\t\t// get redis conn from pool\n\t\trc := redisPool.Get()\n\n\t\t// report to redis\n\t\treport, _ := json.Marshal(s.Status())\n\t\tserverNode := s.Status().Node\n\t\trc.Do(\"HSET\", \"admin_stream_status\", serverNode, report)\n\n\t\t// release redis conn\n\t\trc.Close()\n\t}\n}", "title": "" }, { "docid": "19b0001a1a481bafda9da8da63800329", "score": "0.4836877", "text": "func (r *raft) serverEvents() {\n\tr.Lock()\n\tr.setRoleAndWatchdogTimer(RoleFollower)\n\tr.Unlock()\n\tfor {\n\t\tselect {\n\t\tcase <-r.stop:\n\t\t\t// Terminate.\n\t\t\tclose(r.stopped)\n\t\t\treturn\n\t\tcase <-r.timer.C:\n\t\t\t// Start an election whenever either:\n\t\t\t// (1) a follower hasn't heard from the leader in a random interval > 2 * heartbeat.\n\t\t\t// (2) a candidate hasn't won an election or been told anyone else has after hearbeat.\n\t\t\tr.Lock()\n\t\t\tswitch r.role {\n\t\t\tcase RoleCandidate:\n\t\t\t\tr.startElection()\n\t\t\tcase RoleFollower:\n\t\t\t\tr.startElection()\n\t\t\t}\n\t\t\tr.Unlock()\n\t\tcase <-r.newMatch:\n\t\t\t// Soak up any queued requests.\n\t\t\temptyChan(r.newMatch)\n\n\t\t\t// This happens whenever we have gotten a reply from a follower. We do it\n\t\t\t// here rather than in perFollower solely as a matter of taste.\n\t\t\t// Update the commitIndex if needed and apply any newly committed entries.\n\t\t\tr.Lock()\n\t\t\tif r.role != RoleLeader {\n\t\t\t\tr.Unlock()\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tsort.Sort(r.memberSet)\n\t\t\tci := r.memberSet[r.quorum-1].matchIndex\n\t\t\tif ci <= r.commitIndex {\n\t\t\t\tr.Unlock()\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tr.commitIndex = ci\n\t\t\tr.Unlock()\n\t\t\tr.applyCommits(ci)\n\t\t\tr.ccv.Broadcast()\n\t\t\tr.kickFollowers()\n\t\tcase i := <-r.newCommit:\n\t\t\t// Get highest queued up commit.\n\t\t\ti = highestFromChan(i, r.newCommit)\n\n\t\t\t// Update the commitIndex if needed and apply any newly committed entries.\n\t\t\tr.Lock()\n\t\t\tif r.role != RoleFollower {\n\t\t\t\tr.Unlock()\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif i > r.commitIndex {\n\t\t\t\tr.commitIndex = i\n\t\t\t}\n\t\t\tci := r.commitIndex\n\t\t\tr.Unlock()\n\t\t\tr.applyCommits(ci)\n\t\t\tr.ccv.Broadcast()\n\t\t}\n\t}\n}", "title": "" }, { "docid": "97eb54641dfb70af38370750bf4febe3", "score": "0.48306295", "text": "func (w *NodeManagementWorker) HandleNmpStatusReset() {\n\tglog.V(3).Infof(nmwlog(fmt.Sprintf(\"HandleNmpStatusReset re-evaluating NMPs that has the status 'reset'.\")))\n\n\t// get all the nmps that applies to this node from the exchange\n\tallNmpStatus, err := exchange.GetNodeManagementAllStatuses(w, exchange.GetOrg(w.GetExchangeId()), exchange.GetId(w.GetExchangeId()))\n\tif err != nil {\n\t\tglog.Errorf(nmwlog(fmt.Sprintf(\"Error getting all nmp statuses for node %v from the exchange. %v\", w.GetExchangeId(), err)))\n\t} else {\n\t\tglog.V(5).Infof(nmwlog(fmt.Sprintf(\"GetNodeManagementAllStatuses returns: %v\", allNmpStatus)))\n\t}\n\n\t// find all nmp status from local db\n\tallLocalStatuses, err := persistence.FindAllNMPStatus(w.db)\n\tif err != nil {\n\t\tglog.Errorf(nmwlog(fmt.Sprintf(\"Error getting all nmp statuses from the local database. %v\", err)))\n\t}\n\n\t// change the status to 'waiting'\n\tif allNmpStatus != nil {\n\t\tfor nmp_name, nmp_status := range allNmpStatus.PolicyStatuses {\n\t\t\tif nmp_status.Status() == exchangecommon.STATUS_RESET {\n\t\t\t\tif local_status, ok := allLocalStatuses[nmp_name]; ok {\n\t\t\t\t\tglog.V(3).Infof(nmwlog(fmt.Sprintf(\"Change status from \\\"reset\\\" to \\\"waiting\\\" for the nmp %v\", nmp_name)))\n\n\t\t\t\t\tlocal_status.AgentUpgrade.Status = exchangecommon.STATUS_NEW\n\t\t\t\t\tif local_status.AgentUpgradeInternal != nil {\n\t\t\t\t\t\tlocal_status.AgentUpgradeInternal.DownloadAttempts = 0\n\t\t\t\t\t}\n\n\t\t\t\t\terr = w.UpdateStatus(nmp_name, local_status, exchange.GetPutNodeManagementPolicyStatusHandler(w), persistence.NewMessageMeta(EL_NMP_STATUS_CHANGED, nmp_name, exchangecommon.STATUS_NEW), persistence.EC_NMP_STATUS_UPDATE_NEW)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tglog.Errorf(nmwlog(fmt.Sprintf(\"Error changing nmp status for %v from \\\"reset\\\" to \\\"waiting\\\". Error was %v.\", nmp_name, err)))\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tglog.V(3).Infof(nmwlog(fmt.Sprintf(\"node management status for nmp %v for node %v is set to \\\"reset\\\" but the status cannot be found from the local db. Skiping it.\", nmp_name, w.GetExchangeId())))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "1d2e22579468d9d8bff9854dc5d450d6", "score": "0.4830544", "text": "func (*NoopNodeHandler) OnNodeSynced() {}", "title": "" }, { "docid": "6f4b04bd197a833eb57e5334c04dfd83", "score": "0.4827016", "text": "func testMonitor(cfg config.Config, testUUID string, leash *chan bool) {\n\n\t// I implemented this retry functionality as a temporary fix for an issue that came up only once in a while, where\n\t// the net.Listen would throw an error indicating the port was already in use. Not sure why this happens yet, as I\n\t// am not running multiple instance of testMonitor at a time. TODO(mierdin): need to revisit this and perhaps\n\t// replace this retry with a Mutex.\n\tretries := 0\n\nretrytcpserver:\n\n\tif retries > 5 {\n\t\tlog.Error(\"TCP Server for testrun status failed to initialize.\")\n\t\treturn\n\t}\n\n\t// listen on all interfaces\n\tln, err := net.Listen(\"tcp\", \":8081\")\n\tif err != nil {\n\t\tretries = retries + 1\n\t\ttime.Sleep(1000 * time.Millisecond)\n\t\tgoto retrytcpserver\n\t}\n\tdefer ln.Close()\n\n\t// accept connection on port\n\tconn, err := ln.Accept()\n\tif err != nil {\n\t\tretries = retries + 1\n\t\ttime.Sleep(1000 * time.Millisecond)\n\t\tgoto retrytcpserver\n\t}\n\tdefer conn.Close()\n\n\ttdb, err := db.NewToddDB(cfg)\n\tif err != nil {\n\t\tlog.Fatalf(\"Error opening database: %v\", err)\n\t}\n\n\t// Constantly poll for test status, and send statuses to client\n\tfor {\n\t\ttime.Sleep(1000 * time.Millisecond)\n\n\t\ttestStatuses, err := tdb.GetTestStatus(testUUID)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Error retrieving test status: %v\", err)\n\t\t}\n\n\t\tstatusesJSON, err := json.Marshal(testStatuses)\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"Failed to marshal agent test status message\")\n\t\t\tos.Exit(1)\n\t\t}\n\n\t\t// Send status to client\n\t\tnewMessage := string(statusesJSON)\n\t\tconn.Write([]byte(newMessage + \"\\n\")) // TODO: Append '\\n` to statusesJSON instead of converting to string`\n\n\t\t// Detect a client disconnect\n\t\t_, err = bufio.NewReader(conn).ReadString('\\n')\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\n\t\t// TODO(mierdin): Need to add failure notification (status of \"fail\" for any one agent)\n\n\t\t// Check to see if the calling function has asked that we shut down\n\t\t// Because of the presence of the default statement, this select statement will not block. It will allow the\n\t\t// loop to repeat if the channel does not contain data, and if it does this function will return.\n\t\tselect {\n\t\tcase _, _ = <-*leash:\n\t\t\tlog.Debug(\"Killed testrun monitoring goroutine\")\n\t\t\treturn\n\t\tdefault:\n\t\t}\n\t}\n}", "title": "" }, { "docid": "be3fbcee71d66161f56a555956ceb7f9", "score": "0.48243505", "text": "func (s *TriggerScheduler) StatusUpdate(driver sched.SchedulerDriver, status *mesos.TaskStatus) {\n\tlog.Infoln(\"Status update: task\", status.TaskId.GetValue(), \" is in state \", status.State.Enum().String())\n\tif status.Message != nil {\n\t\tlog.Infoln(\"Status update message : \", *status.Message)\n\t}\n\n\tswitch status.GetState() {\n\tcase mesos.TaskState_TASK_RUNNING:\n\t\tgo func() {\n\t\t\ts.setRunning(status.GetTaskId().GetValue())\n\t\t}()\n\n\tcase mesos.TaskState_TASK_FINISHED:\n\t\tgo func() {\n\t\t\ts.setFinished(status.GetTaskId().GetValue())\n\t\t\t// pause cleanState() job to avoid race condition (otherwise one task may be launched twice)\n\t\t\ts.cleanLock.Lock()\n\t\t\ts.deleteOrRepeat(status.GetTaskId().GetValue()) // duplicate messages are NOT handled\n\t\t\ts.cleanLock.Unlock()\n\t\t}()\n\n\tcase mesos.TaskState_TASK_FAILED:\n\t\tgo func() {\n\t\t\ts.setFailed(status.GetTaskId().GetValue())\n\t\t\ts.cleanLock.Lock()\n\t\t\ts.deleteOrRetry(status.GetTaskId().GetValue()) // duplicate messages are handled properly\n\t\t\ts.cleanLock.Unlock()\n\t\t}()\n\t}\n}", "title": "" }, { "docid": "291f964c5066e58e3415046ba980afe6", "score": "0.48228514", "text": "func (np *Pool) OneTimeStatusMonitor(ctx context.Context, startRound int64) {\n\tnp.statusMonitor(ctx, startRound)\n}", "title": "" }, { "docid": "c8442597cb3af3b4b9d0d2b6c78f2084", "score": "0.48184672", "text": "func (w *NodeManagementWorker) checkNMPTimeToRun() int {\n\tglog.Infof(nmwlog(\"Starting run of node management policy monitoring subworker.\"))\n\tstatusUpdateLock.Lock()\n\tdefer statusUpdateLock.Unlock()\n\n\texchDev, err := persistence.FindExchangeDevice(w.db)\n\tif err != nil {\n\t\tglog.Errorf(nmwlog(fmt.Sprintf(\"Error getting device from database: %v\", err)))\n\t\treturn 60\n\t}\n\n\tif exchDev == nil || exchDev.Config.State != persistence.CONFIGSTATE_CONFIGURED {\n\t\tglog.Infof(nmwlog(fmt.Sprintf(\"Node is not configured.\")))\n\t\treturn 60\n\t}\n\n\tdev, err := exchange.GetExchangeDevice(w.GetHTTPFactory(), w.GetExchangeId(), w.GetExchangeId(), w.GetExchangeToken(), w.GetExchangeURL())\n\tif err != nil {\n\t\tglog.Errorf(nmwlog(fmt.Sprintf(\"Failed to get device from exchange: %v\", err)))\n\t\treturn 60\n\t}\n\tgroupName := dev.HAGroup\n\tif haWaitingNMPs, err := persistence.FindHAWaitingNMPStatuses(w.db); err != nil {\n\t\tglog.Errorf(nmwlog(fmt.Sprintf(\"Failed to get nmp statuses waiting on ha upgrade permission: %v\", err)))\n\t} else {\n\t\tfor haWaitingStatusName, status := range haWaitingNMPs {\n\t\t\tchangeToDownloaded := false\n\t\t\tif groupName == \"\" {\n\t\t\t\tchangeToDownloaded = true\n\t\t\t} else if yes, err := exchange.HANodeCanExecuteNMP(w, w.GetAgbotURL(), groupName, exchange.GetId(haWaitingStatusName)); err != nil {\n\t\t\t\tglog.Errorf(nmwlog(fmt.Sprintf(\"Error calling agbot to check if nmp %v can be executed: %v\", haWaitingStatusName, err)))\n\t\t\t} else if yes {\n\t\t\t\tchangeToDownloaded = true\n\t\t\t}\n\t\t\tif changeToDownloaded {\n\t\t\t\tstatus.SetStatus(exchangecommon.STATUS_DOWNLOADED)\n\t\t\t\tmsgMeta := persistence.NewMessageMeta(EL_NMP_STATUS_CHANGED, haWaitingStatusName, exchangecommon.STATUS_DOWNLOADED)\n\t\t\t\teventCode := persistence.EC_NMP_STATUS_DOWNLOAD_SUCCESSFUL\n\n\t\t\t\terr = w.UpdateStatus(haWaitingStatusName, status, exchange.GetPutNodeManagementPolicyStatusHandler(w), msgMeta, eventCode)\n\t\t\t\tif err != nil {\n\t\t\t\t\tglog.Errorf(nmwlog(fmt.Sprintf(\"Failed to update nmp status %v: %v\", haWaitingStatusName, err)))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif len(haWaitingNMPs) > 0 {\n\t\t\treturn 60\n\t\t}\n\t}\n\n\tif downloadedInitiatedStatuses, err := persistence.FindNMPSWithStatuses(w.db, []string{exchangecommon.STATUS_DOWNLOADED, exchangecommon.STATUS_INITIATED, exchangecommon.STATUS_DOWNLOAD_STARTED, exchangecommon.STATUS_HA_WAITING}); err != nil {\n\t\tglog.Errorf(nmwlog(fmt.Sprintf(\"Failed to get nmp statuses from the database. Error was %v\", err)))\n\t} else if len(downloadedInitiatedStatuses) > 0 {\n\t\tglog.Infof(nmwlog(\"There is an nmp currently being executed or downloaded. Exiting without looking for the next nmp to run.\"))\n\t\treturn 60\n\t}\n\n\tif waitingNMPs, err := persistence.FindWaitingNMPStatuses(w.db); err != nil {\n\t\tglog.Errorf(nmwlog(fmt.Sprintf(\"Failed to get nmp statuses from the database. Error was %v\", err)))\n\t} else {\n\t\tearliestNmpName := \"initial\"\n\t\tearliestNmpStatus := &exchangecommon.NodeManagementPolicyStatus{}\n\t\tfor earliestNmpName != \"\" {\n\t\t\tearliestNmpName, earliestNmpStatus = getLatest(&waitingNMPs)\n\t\t\tif earliestNmpName != \"\" {\n\t\t\t\tglog.Infof(nmwlog(fmt.Sprintf(\"Time to start nmp %v\", earliestNmpName)))\n\t\t\t\tearliestNmpStatus.AgentUpgrade.Status = exchangecommon.STATUS_DOWNLOAD_STARTED\n\t\t\t\terr = w.UpdateStatus(earliestNmpName, earliestNmpStatus, exchange.GetPutNodeManagementPolicyStatusHandler(w), persistence.NewMessageMeta(EL_NMP_STATUS_CHANGED, earliestNmpName, exchangecommon.STATUS_DOWNLOAD_STARTED), persistence.EC_NMP_STATUS_UPDATE_NEW)\n\t\t\t\tif err != nil {\n\t\t\t\t\tglog.Errorf(nmwlog(fmt.Sprintf(\"Failed to update nmp status %v: %v\", earliestNmpName, err)))\n\t\t\t\t}\n\t\t\t\tw.Messages() <- events.NewNMPStartDownloadMessage(events.NMP_START_DOWNLOAD, events.StartDownloadMessage{NMPStatus: earliestNmpStatus, NMPName: earliestNmpName})\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn 60\n}", "title": "" }, { "docid": "5dd60b9c2d2bb664ce52f7bf56c2eea8", "score": "0.48101404", "text": "func TestNodeHeartbeatCallback(t *testing.T) {\n\tdefer leaktest.AfterTest(t)()\n\tdefer log.Scope(t).Close(t)\n\n\tctx := context.Background()\n\tmanualClock := hlc.NewHybridManualClock()\n\texpected := manualClock.UnixNano()\n\ttc := testcluster.StartTestCluster(t, 3,\n\t\tbase.TestClusterArgs{\n\t\t\tReplicationMode: base.ReplicationManual,\n\t\t\tServerArgs: base.TestServerArgs{\n\t\t\t\tKnobs: base.TestingKnobs{\n\t\t\t\t\tServer: &server.TestingKnobs{\n\t\t\t\t\t\tClockSource: manualClock.UnixNano,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\tdefer tc.Stopper().Stop(ctx)\n\n\t// Verify liveness of all nodes for all nodes.\n\tverifyLiveness(t, tc)\n\tpauseNodeLivenessHeartbeatLoops(tc)\n\n\t// Verify that last update time has been set for all nodes.\n\tverifyUptimes := func() error {\n\t\tfor i := range tc.Servers {\n\t\t\ts := tc.GetFirstStoreFromServer(t, i)\n\t\t\tuptm, err := s.ReadLastUpTimestamp(context.Background())\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"error reading last up time from store %d\", i)\n\t\t\t}\n\t\t\tif a, e := uptm.WallTime, expected; a < e {\n\t\t\t\treturn errors.Errorf(\"store %d last uptime = %d; wanted %d\", i, a, e)\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\n\tif err := verifyUptimes(); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Advance clock past the liveness threshold and force a manual heartbeat on\n\t// all node liveness objects, which should update the last up time for each\n\t// store.\n\tmanualClock.Increment(tc.Servers[0].NodeLiveness().(*liveness.NodeLiveness).GetLivenessThreshold().Nanoseconds() + 1)\n\texpected = manualClock.UnixNano()\n\tfor _, s := range tc.Servers {\n\t\tnl := s.NodeLiveness().(*liveness.NodeLiveness)\n\t\tl, ok := nl.Self()\n\t\tassert.True(t, ok)\n\t\tif err := nl.Heartbeat(context.Background(), l); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}\n\t// NB: since the heartbeat callback is invoked synchronously in\n\t// `Heartbeat()` which this goroutine invoked, we don't need to wrap this in\n\t// a retry.\n\tif err := verifyUptimes(); err != nil {\n\t\tt.Fatal(err)\n\t}\n}", "title": "" }, { "docid": "9cffeb82cb4fa62d97be2d788acb5dfb", "score": "0.48086408", "text": "func TestNodes(t *testing.T) {\n\tt.Parallel()\n\n\tctx := context.Background()\n\n\tp := newPackForProxy(t)\n\tt.Cleanup(p.Close)\n\n\tserver := suite.NewServer(types.KindNode, \"srv1\", \"127.0.0.1:2022\", apidefaults.Namespace)\n\t_, err := p.presenceS.UpsertNode(ctx, server)\n\trequire.NoError(t, err)\n\n\tout, err := p.presenceS.GetNodes(ctx, apidefaults.Namespace)\n\trequire.NoError(t, err)\n\trequire.Len(t, out, 1)\n\tsrv := out[0]\n\n\tselect {\n\tcase event := <-p.eventsC:\n\t\trequire.Equal(t, EventProcessed, event.Type)\n\tcase <-time.After(time.Second):\n\t\tt.Fatalf(\"timeout waiting for event\")\n\t}\n\n\tout, err = p.cache.GetNodes(ctx, apidefaults.Namespace)\n\trequire.NoError(t, err)\n\trequire.Len(t, out, 1)\n\n\tsrv.SetResourceID(out[0].GetResourceID())\n\trequire.Empty(t, cmp.Diff(srv, out[0]))\n\n\t// update srv parameters\n\tsrv.SetExpiry(time.Now().Add(30 * time.Minute).UTC())\n\tsrv.SetAddr(\"127.0.0.2:2033\")\n\n\tlease, err := p.presenceS.UpsertNode(ctx, srv)\n\trequire.NoError(t, err)\n\n\tout, err = p.presenceS.GetNodes(ctx, apidefaults.Namespace)\n\trequire.NoError(t, err)\n\trequire.Len(t, out, 1)\n\tsrv = out[0]\n\n\tselect {\n\tcase event := <-p.eventsC:\n\t\trequire.Equal(t, EventProcessed, event.Type)\n\tcase <-time.After(time.Second):\n\t\tt.Fatalf(\"timeout waiting for event\")\n\t}\n\n\tout, err = p.cache.GetNodes(ctx, apidefaults.Namespace)\n\trequire.NoError(t, err)\n\trequire.Len(t, out, 1)\n\n\tsrv.SetResourceID(out[0].GetResourceID())\n\trequire.Empty(t, cmp.Diff(srv, out[0]))\n\n\t// update keep alive on the node and make sure\n\t// it propagates\n\tlease.Expires = time.Now().UTC().Add(time.Hour)\n\terr = p.presenceS.KeepAliveNode(ctx, *lease)\n\trequire.NoError(t, err)\n\n\tselect {\n\tcase event := <-p.eventsC:\n\t\trequire.Equal(t, EventProcessed, event.Type)\n\tcase <-time.After(time.Second):\n\t\tt.Fatalf(\"timeout waiting for event\")\n\t}\n\n\tout, err = p.cache.GetNodes(ctx, apidefaults.Namespace)\n\trequire.NoError(t, err)\n\trequire.Len(t, out, 1)\n\n\tsrv.SetResourceID(out[0].GetResourceID())\n\tsrv.SetExpiry(lease.Expires)\n\trequire.Empty(t, cmp.Diff(srv, out[0]))\n\n\terr = p.presenceS.DeleteAllNodes(ctx, apidefaults.Namespace)\n\trequire.NoError(t, err)\n\n\tselect {\n\tcase <-p.eventsC:\n\tcase <-time.After(time.Second):\n\t\tt.Fatalf(\"timeout waiting for event\")\n\t}\n\n\tout, err = p.cache.GetNodes(ctx, apidefaults.Namespace)\n\trequire.NoError(t, err)\n\trequire.Empty(t, out)\n}", "title": "" }, { "docid": "f58b1f1e236bcc5f946d2f27d195a906", "score": "0.48034948", "text": "func (fd *Fdlib) sendHeartbeatMsg(remoteIpPort string, info *RemoteNodeMonitorInfo, hb *Heartbeats, hbeatNum uint64) (keepMonitoring bool) {\n\tinfo.Lock()\n\tdefer info.Unlock()\n\n\t// Locate info about remote node\n\tif !info.ShouldMonitor {\n\t\tfd.Println(\"HBEAT: Don't need to monitor the node anymore\")\n\t\treturn false\n\t}\n\n\t// Generate random UUID for the heartbeat\n\thbeatUUID := hbeatNum\n\n\t// Create a heartbeat message\n\thbeatMsg := HBeatMessage{\n\t\tEpochNonce: fd.EpochNonce,\n\t\tSeqNum: hbeatUUID,\n\t}\n\n\t// Encode heart beat message\n\tvar buffer bytes.Buffer\n\tencoder := gob.NewEncoder(&buffer)\n\terr := encoder.Encode(hbeatMsg)\n\tif err != nil {\n\t\t// Should not happen\n\t\tfd.Println(\"HBEAT: Error: Failed to marshall heartbeat message\")\n\t\treturn true\n\t}\n\n\t// Start timing\n\thbeatSent := time.Now()\n\n\t// Add to heartbeats map\n\t(*hb.hbeats)[hbeatUUID] = &HeartbeatInfo{\n\t\tTimeSent: hbeatSent,\n\t}\n\n\tfd.Println(\"HBEAT: Sending\", hbeatUUID, \"at\", hbeatSent, \"to\", remoteIpPort)\n\n\thbeatAcked := false\n\n\t// Send heartbeat message\n\t_, err = info.Conn.Write(buffer.Bytes())\n\tif err == nil {\n\t\t// Set the deadline for read\n\t\tinfo.Conn.SetReadDeadline(time.Now().Add(info.AvgRTT))\n\t\t// Receive any pending ACKs\n\t\tvar buf [PKT_SIZE]byte\n\t\tbytesRead, err := info.Conn.Read(buf[:])\n\t\tif err == nil {\n\t\t\tfd.Println(\"Read\", bytesRead, \"bytes\")\n\t\t\t// Decode the ACK message\n\t\t\tackMsg, ok := fd.decodeAckMessage(buf, bytesRead)\n\t\t\tif ok {\n\t\t\t\t// Note the time when we received the ACK\n\t\t\t\tackRecvedTime := time.Now()\n\t\t\t\thbeat, found := (*hb.hbeats)[ackMsg.HBEatSeqNum]\n\t\t\t\tif found {\n\t\t\t\t\thbeatAcked = true\n\t\t\t\t\tfd.updateRTT(info, hbeat.TimeSent, ackRecvedTime, ackMsg.HBEatSeqNum, hb.hbeats)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// See if we need to catch up on any other ACKs\n\tfor {\n\t\tinfo.Conn.SetReadDeadline(time.Now().Add(1 * time.Nanosecond))\n\t\tvar buf [PKT_SIZE]byte\n\t\tbytesRead, err := info.Conn.Read(buf[:])\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\t// Decode the ACK message\n\t\tackMsg, ok := fd.decodeAckMessage(buf, bytesRead)\n\t\tif !ok {\n\t\t\tfd.Println(\"Err trying to decode ack message\")\n\t\t\tcontinue\n\t\t}\n\n\t\t// Note the time when we received the ACK\n\t\tackRecvedTime := time.Now()\n\t\thbeat, found := (*hb.hbeats)[ackMsg.HBEatSeqNum]\n\t\tif found {\n\t\t\tfd.Println(\"Receiving older ACKs\", ackMsg.HBEatSeqNum)\n\t\t\tfd.updateRTT(info, hbeat.TimeSent, ackRecvedTime, ackMsg.HBEatSeqNum, hb.hbeats)\n\t\t\thbeatAcked = true\n\t\t}\n\t}\n\n\tif !hbeatAcked {\n\t\tinfo.NumFailedAcks++\n\t\tfd.Println(\"HBEAT: Did not get any new ACKs :( just sent out\", hbeatUUID, \". Num lost ACKs so far: \", info.NumFailedAcks)\n\t\tif info.NumFailedAcks == info.LostMsgThresh {\n\t\t\t// Stop monitoring this node\n\t\t\tfd.Println(\"Num failed acks\", info.NumFailedAcks)\n\t\t\tfd.Println(\"Error: Lets stop monitoring this node\", remoteIpPort)\n\t\t\tfd.NotifyCh <- FailureDetected{\n\t\t\t\tUDPIpPort: remoteIpPort,\n\t\t\t\tTimestamp: time.Now(),\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}\n\treturn true\n}", "title": "" }, { "docid": "a613c4996053813d1cc3837ad7a10739", "score": "0.4802524", "text": "func (s *session) newEvent(ev *spindump_event, obs string) {\r\n _, ok := s.Observers[obs]\r\n if !ok {\r\n s.Observers[obs] = &observer{}\r\n }\r\n if ev.Event == \"measurement\" {\r\n var rs rtt_sample\r\n rs.FullRtt = ev.Full_rtt_initiator\r\n rs.LeftRtt = ev.Left_rtt\r\n rs.RightRtt = ev.Right_rtt\r\n s.Observers[obs].addSample(rs)\r\n log.Printf(\"New measurement event %+v\", rs)\r\n }\r\n}", "title": "" } ]
1fb2ed59bf0d5ff024e2a296e2b6a9c4
SetBootstrapBrokerStringSaslScram sets the BootstrapBrokerStringSaslScram field's value.
[ { "docid": "283c1f9a31b6753492b718b7c6831ecd", "score": "0.8589594", "text": "func (s *GetBootstrapBrokersOutput) SetBootstrapBrokerStringSaslScram(v string) *GetBootstrapBrokersOutput {\n\ts.BootstrapBrokerStringSaslScram = &v\n\treturn s\n}", "title": "" } ]
[ { "docid": "71b0edf5f243b8048beb200c4730b293", "score": "0.7834576", "text": "func (s *GetBootstrapBrokersOutput) SetBootstrapBrokerStringPublicSaslScram(v string) *GetBootstrapBrokersOutput {\n\ts.BootstrapBrokerStringPublicSaslScram = &v\n\treturn s\n}", "title": "" }, { "docid": "20a2ba029a68f5a480011690d6dabb1a", "score": "0.7325919", "text": "func (s *Sasl) SetScram(v *Scram) *Sasl {\n\ts.Scram = v\n\treturn s\n}", "title": "" }, { "docid": "4f96cdce475124f9af2f3085995c3a18", "score": "0.7161755", "text": "func (s *GetBootstrapBrokersOutput) SetBootstrapBrokerStringVpcConnectivitySaslScram(v string) *GetBootstrapBrokersOutput {\n\ts.BootstrapBrokerStringVpcConnectivitySaslScram = &v\n\treturn s\n}", "title": "" }, { "docid": "f5331f1424790bff8d88345e26196794", "score": "0.6878157", "text": "func (s *VpcConnectivitySasl) SetScram(v *VpcConnectivityScram) *VpcConnectivitySasl {\n\ts.Scram = v\n\treturn s\n}", "title": "" }, { "docid": "2a18a452ddb3082648d06cfce4a89d8c", "score": "0.62688535", "text": "func (s *GetBootstrapBrokersOutput) SetBootstrapBrokerStringSaslIam(v string) *GetBootstrapBrokersOutput {\n\ts.BootstrapBrokerStringSaslIam = &v\n\treturn s\n}", "title": "" }, { "docid": "2ea80d02b1360569b40a7ef3973d964e", "score": "0.6007709", "text": "func (s *VpcConnectivityClientAuthentication) SetSasl(v *VpcConnectivitySasl) *VpcConnectivityClientAuthentication {\n\ts.Sasl = v\n\treturn s\n}", "title": "" }, { "docid": "e081e3eca107db9698e3598a345c8fc7", "score": "0.59066945", "text": "func (s *ServerlessClientAuthentication) SetSasl(v *ServerlessSasl) *ServerlessClientAuthentication {\n\ts.Sasl = v\n\treturn s\n}", "title": "" }, { "docid": "b9a489070ecbd4806443e34d3449d09d", "score": "0.5892144", "text": "func (s *ClientAuthentication) SetSasl(v *Sasl) *ClientAuthentication {\n\ts.Sasl = v\n\treturn s\n}", "title": "" }, { "docid": "4a29c8669cea7f2effc60c08391461ea", "score": "0.56563616", "text": "func (s *GetBootstrapBrokersOutput) SetBootstrapBrokerStringPublicSaslIam(v string) *GetBootstrapBrokersOutput {\n\ts.BootstrapBrokerStringPublicSaslIam = &v\n\treturn s\n}", "title": "" }, { "docid": "393e5786a4f9df018a859af13c8ec524", "score": "0.52143776", "text": "func ConfigureScramCredentials(user *opsmngr.MongoDBUser, password string) error {\n\tscram256Creds, err := newScramSha256Creds(user, password)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tscram1Creds, err := newScramSha1Creds(user, password)\n\tif err != nil {\n\t\treturn err\n\t}\n\tuser.ScramSha256Creds = scram256Creds\n\tuser.ScramSha1Creds = scram1Creds\n\treturn nil\n}", "title": "" }, { "docid": "3d8f63b175e443bdf3322c1802aa2bb0", "score": "0.51546", "text": "func (s *GetBootstrapBrokersOutput) SetBootstrapBrokerStringTls(v string) *GetBootstrapBrokersOutput {\n\ts.BootstrapBrokerStringTls = &v\n\treturn s\n}", "title": "" }, { "docid": "18b27e389a68bb6c428e9688283abeb5", "score": "0.49808514", "text": "func NewSaslClient(host string, mechanism Mechanism) *Client {\n\tmech, ok := mechanism.(*GSSAPIMechanism)\n\tif ok {\n\t\tmech.host = host\n\t}\n\treturn &Client{\n\t\thost: host,\n\t\tmechanism: mechanism,\n\t}\n}", "title": "" }, { "docid": "8e9c569ccb5ed998aceb61b9814f0df5", "score": "0.49407953", "text": "func (s *GetBootstrapBrokersOutput) SetBootstrapBrokerStringVpcConnectivitySaslIam(v string) *GetBootstrapBrokersOutput {\n\ts.BootstrapBrokerStringVpcConnectivitySaslIam = &v\n\treturn s\n}", "title": "" }, { "docid": "36e5e523697bf6e71bec7f1d1bd65ed8", "score": "0.477164", "text": "func (s *GetBootstrapBrokersOutput) SetBootstrapBrokerStringPublicTls(v string) *GetBootstrapBrokersOutput {\n\ts.BootstrapBrokerStringPublicTls = &v\n\treturn s\n}", "title": "" }, { "docid": "e634c643a7b523a314582a769ce1ebab", "score": "0.47259527", "text": "func KafkaSASLMechanism(m string) func(*sarama.Config) {\n\treturn func(cfg *sarama.Config) {\n\t\tcfg.Net.SASL.Enable = true\n\t\tcfg.Net.SASL.Mechanism = sarama.SASLMechanism(m)\n\t}\n}", "title": "" }, { "docid": "be416da0ecb6889951700aeba2499330", "score": "0.4627916", "text": "func WithScram(username, password string) OptionApplier {\n\treturn clientOptionAdder{\n\t\toption: &options.ClientOptions{\n\t\t\tAuth: &options.Credential{\n\t\t\t\tAuthMechanism: \"SCRAM-SHA-256\",\n\t\t\t\tAuthSource: \"admin\",\n\t\t\t\tUsername: username,\n\t\t\t\tPassword: password,\n\t\t\t},\n\t\t},\n\t}\n}", "title": "" }, { "docid": "d01d2c63675164d6405710ec32bf6522", "score": "0.46156076", "text": "func (r *setSaslResponse) Decode(buf []byte) (int, error) {\n\n\t// Discard the first 4 bytes, they are not used here.\n\t// According to RFC, the payload is inform of k1=v,k2=v, some of the values maybe enclosure with double quote(\").\n\tpayload := string(buf[4:])\n\n\tsplitPayload := strings.Split(payload, \",\")\n\n\tif len(splitPayload) == 0 {\n\t\treturn 0, errors.New(\"invalid sasl payload\")\n\t}\n\n\tr.Nonce = \"\"\n\tr.Realm = \"\"\n\tr.RspAuth = \"\"\n\n\tfor _, item := range splitPayload {\n\t\tkv := strings.SplitN(item, \"=\", 2)\n\t\tif len(kv) != 2 {\n\t\t\treturn 0, errors.New(\"invalid sasl payload format\")\n\t\t}\n\n\t\tkey := strings.ToLower(kv[0])\n\t\tif key == \"nonce\" {\n\t\t\tr.Nonce = rmDoubleQuote(kv[1])\n\t\t} else if key == \"realm\" {\n\t\t\tr.Realm = rmDoubleQuote(kv[1])\n\t\t} else if key == \"rspauth\" {\n\t\t\tr.RspAuth = kv[1]\n\t\t}\n\t}\n\n\treturn len(buf), nil\n}", "title": "" }, { "docid": "632763b6b38b71bb09be1fce0009b84f", "score": "0.45882314", "text": "func (r *random) SetString(s string) {\n\tr.randBStr = []byte(s)\n\tr.randBStrSize = len(r.randBStr)\n}", "title": "" }, { "docid": "03723fbd067e3baf4afce096c8a48d01", "score": "0.45595992", "text": "func newScramShaCreds(salt []byte, username, password, mechanism string) (*opsmngr.ScramShaCreds, error) {\n\tif mechanism != scramSha256 && mechanism != mongoCR {\n\t\treturn nil, fmt.Errorf(\"%w %s\", ErrUnsupportedMechanism, mechanism)\n\t}\n\tvar hashConstructor hashingFunc\n\titerations := 0\n\tif mechanism == scramSha256 {\n\t\thashConstructor = sha256.New\n\t\titerations = scramSha256Iterations\n\t} else if mechanism == mongoCR {\n\t\thashConstructor = sha1.New\n\t\titerations = scramSha1Iterations\n\n\t\t// MONGODB-CR/SCRAM-SHA-1 requires the hash of the password being passed computeScramCredentials\n\t\t// instead of the plain text password.\n\t\tvar err error\n\t\tpassword, err = md5Hex(username + \":mongo:\" + password)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tbase64EncodedSalt := base64.StdEncoding.EncodeToString(salt)\n\treturn computeScramCredentials(hashConstructor, iterations, base64EncodedSalt, password)\n}", "title": "" }, { "docid": "7dcdd80ea8588ddbdfc7f7d1998e1e33", "score": "0.44893202", "text": "func (s Sasl) String() string {\n\treturn awsutil.Prettify(s)\n}", "title": "" }, { "docid": "3358022c1e48d89858dbd38a34a8ed26", "score": "0.44274116", "text": "func NewSASLConfig() SASLConfig {\n\treturn SASLConfig{\n\t\tMechanism: \"none\",\n\t}\n}", "title": "" }, { "docid": "97823ba80e4f35e2530a800d433d7d31", "score": "0.4382895", "text": "func (r setSaslResponse) GenSaslChallenge(auth []byte, cnonce string) (string, error) {\n\n\tuser, password := r.getUserPassword(auth)\n\tif user == \"\" || password == \"\" {\n\t\treturn \"\", errors.New(\"found invalid user&password\")\n\t}\n\n\tch := make(map[string]string, 20)\n\n\tch[\"digest-uri\"] = doubleQuote(zkSaslMd5Uri)\n\n\t// Only \"auth\" qop supports so far.\n\tqop := zkSaslAuthQop\n\tch[\"qop\"] = qop\n\n\tnc := 1\n\tch[\"nc\"] = fmt.Sprintf(\"%08x\", nc)\n\n\tch[\"realm\"] = doubleQuote(r.Realm)\n\tch[\"username\"] = doubleQuote(user)\n\n\t// for unittest.\n\tif cnonce == \"\" {\n\t\tn, err := rand.Int(rand.Reader, big.NewInt(65535))\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tcnonce = fmt.Sprintf(\"%s\", n)\n\t}\n\tch[\"cnonce\"] = doubleQuote(cnonce)\n\tch[\"nonce\"] = doubleQuote(r.Nonce)\n\n\tch[\"response\"] = r.genChallenge(user, password, cnonce, qop, nc)\n\n\titems := make([]string, 0, len(ch))\n\n\tfor k, v := range ch {\n\t\titems = append(items, fmt.Sprintf(\"%s=%s\", k, v))\n\t}\n\n\treturn strings.Join(items, \",\"), nil\n}", "title": "" }, { "docid": "602987faa974f5613a91340cba34460d", "score": "0.4382746", "text": "func (bot *Bot) SASLAuthenticate(user, pass string) {\n\tbot.sasl.SetAuth(user, pass)\n\tbot.addSASL.Do(func() { bot.AddTrigger(bot.sasl) })\n\tbot.Debug(\"Beginning SASL Authentication\")\n\tbot.Send(\"CAP REQ :sasl\")\n\tbot.SetNick(bot.Nick)\n\tbot.sendUserCommand(bot.Nick, bot.Nick)\n}", "title": "" }, { "docid": "6ed7bbad7138323f88f675210b6d987b", "score": "0.43767026", "text": "func (s *GetBootstrapBrokersOutput) SetBootstrapBrokerString(v string) *GetBootstrapBrokersOutput {\n\ts.BootstrapBrokerString = &v\n\treturn s\n}", "title": "" }, { "docid": "6ed7bbad7138323f88f675210b6d987b", "score": "0.43767026", "text": "func (s *GetBootstrapBrokersOutput) SetBootstrapBrokerString(v string) *GetBootstrapBrokersOutput {\n\ts.BootstrapBrokerString = &v\n\treturn s\n}", "title": "" }, { "docid": "aefbf9697c05cd5d1360bcd2714d7c57", "score": "0.4328416", "text": "func WithSASL(mechanism, username, password, handshakeVersion string) Option {\n\treturn func(options *Options) {\n\t\toptions.sasl = newSASL(mechanism, username, password, SASLHandshakeVersion(handshakeVersion))\n\t}\n}", "title": "" }, { "docid": "5e6bfd8a62764678cef54fe9fa7dd995", "score": "0.43022066", "text": "func scram(conn net.Conn, cipher anubis.Cipher) error {\n\tcdata, _, err := hermes.DecRead(conn, cipher) // read client nonce and username\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tuname, cnonce, err := seshat.ExtractDataNonce(cdata, 32)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Printf(\"\\n[+] Initiating auth sequence with %s...\\n\", string(uname))\n\n\t// suppose client and server agree on the KDF parameters already\n\tsalt, storedKey, servKey, err := coeus.GetCorrespondingInfo(string(uname))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tclientProof, nonce, err := doChallenge(conn, cnonce, salt, cipher)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Printf(\"[+] (%s) Challenge successful...\\n\", string(uname))\n\n\terr = cipher.UpdateNonce(nonce)\n\t// notify the client of how the challenge went\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = authClient(clientProof, cipher.Nonce(), storedKey)\n\tif err != nil {\n\t\t_, err = hermes.FullWrite(conn, []byte(\"SERVER_FAIL\"), cipher)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn err\n\t} else {\n\t\t_, err = hermes.FullWrite(conn, []byte(\"SERVER_OK\"), cipher)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tfmt.Printf(\"[+] (%s) Client authentication successful...\\n\", string(uname))\n\n\terr = authServer(conn, clientProof, servKey, cipher)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Printf(\"[+] (%s) Server authentication successful...\\n\", string(uname))\n\n\treturn nil\n}", "title": "" }, { "docid": "a90a349f99f5fc14b7517f0b67e8cf82", "score": "0.4292128", "text": "func isScramble(s1 string, s2 string) bool {\n\tif s1 == s2 {\n\t\t// Ok, All done!\n\t\treturn true\n\t}\n\tif len(s1) != len(s2) {\n\t\t// Needn't try!\n\t\treturn false\n\t}\n\tif !anagram(s1, s2) {\n\t\t// Needn't try!\n\t\treturn false\n\t}\n\tn := len(s1)\n\t// Split into two parts\n\tfor i := 1; i < n; i++ {\n\t\t// Remain not Exchange\n\t\tif isScramble(s1[:i], s2[:i]) &&\n\t\t\tisScramble(s1[i:], s2[i:]) {\n\t\t\treturn true\n\t\t}\n\t\t// Exchange two children\n\t\tif isScramble(s1[:i], s2[n-i:]) &&\n\t\t\tisScramble(s1[i:], s2[:n-i]) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "60284534daaa7376248e67e11903e32b", "score": "0.42839187", "text": "func (its *IntegrationTestSuite) TestAdminClient_UserScramCredentials() {\n\tt := its.T()\n\tac, err := NewAdminClient(&ConfigMap{\n\t\t\"bootstrap.servers\": testconf.Brokers,\n\t})\n\tif err != nil {\n\t\tt.Fatalf(\"Failed to create Admin Client: %s\\n\", err)\n\t}\n\tdefer ac.Close()\n\n\tusers := []string{\"non-existent\"}\n\n\t// Call DescribeUserScramCredentials\n\tctx, cancel := context.WithTimeout(context.Background(), time.Second*30)\n\tdefer cancel()\n\tdescribeRes, describeErr := ac.DescribeUserScramCredentials(ctx, users)\n\tif describeErr != nil {\n\t\tt.Fatalf(\"Failed to Describe the User Scram Credentials: %s\\n\", describeErr)\n\t}\n\n\t// Check Describe result\n\tif len(describeRes.Descriptions) != 1 {\n\t\tt.Fatalf(\"Expected 1 user in Describe Result, got %d\\n\", len(describeRes.Descriptions))\n\t}\n\tdescription, ok := describeRes.Descriptions[users[0]]\n\tif !ok {\n\t\tt.Fatalf(\"Did not find expected user %s in results\\n\", users[0])\n\t}\n\n\tif description.Error.Code() != ErrResourceNotFound {\n\t\tt.Fatalf(\"Error should be ErrResourceNotFound instead it is %s\", description.Error.Code())\n\t}\n\n\t// Call AlterUserScramCredentials for Upsert\n\tupsertions := []UserScramCredentialUpsertion{\n\t\t{\n\t\t\tUser: \"non-existent\",\n\t\t\tScramCredentialInfo: ScramCredentialInfo{\n\t\t\t\tMechanism: ScramMechanismSHA256, Iterations: 10000},\n\t\t\tPassword: []byte(\"password\"),\n\t\t\tSalt: []byte(\"salt\"),\n\t\t}}\n\n\tctx, cancel = context.WithTimeout(context.Background(), time.Second*30)\n\tdefer cancel()\n\talterRes, alterErr := ac.AlterUserScramCredentials(ctx, upsertions, nil)\n\n\t// Check Upsert result\n\tif alterErr != nil {\n\t\tt.Fatalf(\"Failed to Alter the User Scram Credentials: %s\\n\", alterErr)\n\t}\n\tif len(alterRes.Errors) != 1 {\n\t\tt.Fatalf(\"Expected 1 user in Alter Result, got %d\\n\", len(alterRes.Errors))\n\t}\n\tkErr, ok := alterRes.Errors[upsertions[0].User]\n\tif !ok {\n\t\tt.Fatalf(\"Did not find expected user %s in results\\n\", users[0])\n\t}\n\tif kErr.Code() != ErrNoError {\n\t\tt.Fatalf(\"Error code should be ErrNoError instead it is %d\", kErr.Code())\n\t}\n\n\t// Call DescribeUserScramCredentials to verify upsert\n\tctx, cancel = context.WithTimeout(context.Background(), time.Second*30)\n\tdefer cancel()\n\tdescribeRes, describeErr = ac.DescribeUserScramCredentials(ctx, users)\n\n\t// Check Describe result\n\tif describeErr != nil {\n\t\tt.Fatalf(\"Failed to Describe the User Scram Credentials: %s\\n\", describeErr)\n\t}\n\tdescription, ok = describeRes.Descriptions[users[0]]\n\tif !ok {\n\t\tt.Fatalf(\"Did not find expected user %s in results\\n\", users[0])\n\t}\n\tif description.Error.Code() != ErrNoError {\n\t\tt.Fatalf(\"Error code should be ErrNoError instead it is %s\", description.Error.Code())\n\t}\n\tif description.ScramCredentialInfos[0].Iterations != 10000 {\n\t\tt.Fatalf(\"Iterations field doesn't match the upserted value. Expected 10000, got %d\",\n\t\t\tdescription.ScramCredentialInfos[0].Iterations)\n\t}\n\tif description.ScramCredentialInfos[0].Mechanism != ScramMechanismSHA256 {\n\t\tt.Fatalf(\"Mechanism field doesn't match the upserted value. Expected %s, got %s\",\n\t\t\tScramMechanismSHA256, description.ScramCredentialInfos[0].Mechanism)\n\t}\n\n\t// Call AlterUserScramCredentials for Delete\n\tdeletions := []UserScramCredentialDeletion{\n\t\t{User: \"non-existent\", Mechanism: ScramMechanismSHA256}}\n\tctx, cancel = context.WithTimeout(context.Background(), time.Second*30)\n\tdefer cancel()\n\talterRes, alterErr = ac.AlterUserScramCredentials(ctx, nil, deletions)\n\n\t// Check Delete result\n\tif alterErr != nil {\n\t\tt.Fatalf(\"Failed to alter user scram credentials: %s\\n\", alterErr)\n\t}\n\tkErr, ok = alterRes.Errors[upsertions[0].User]\n\tif !ok {\n\t\tt.Fatalf(\"Did not find expected user %s in results\\n\", users[0])\n\t}\n\tif kErr.Code() != ErrNoError {\n\t\tt.Fatalf(\"Error code should be ErrNoError instead it is %d\", kErr.Code())\n\t}\n\n\t// Call DescribeUserScramCredentials to verify delete\n\tctx, cancel = context.WithTimeout(context.Background(), time.Second*30)\n\tdefer cancel()\n\tdescribeRes, describeErr = ac.DescribeUserScramCredentials(ctx, users)\n\n\t// Check Describe result\n\tif describeErr != nil {\n\t\tt.Fatalf(\"Failed to Describe the User Scram Credentials: %s\\n\", describeErr)\n\t}\n\tdescription, ok = describeRes.Descriptions[users[0]]\n\tif !ok {\n\t\tt.Fatalf(\"Did not find expected user %s in results\\n\", users[0])\n\t}\n\n\tif description.Error.Code() != ErrResourceNotFound {\n\t\tt.Fatalf(\"Error should be ErrResourceNotFound instead it is %s\", description.Error.Code())\n\t}\n}", "title": "" }, { "docid": "0c81a5f1d1c50e5079b3f6a5d502b9d0", "score": "0.42411324", "text": "func SetPSM(psm_ string) {\n\tpsm = psm_\n}", "title": "" }, { "docid": "bfdaf4c0034f29de14c06512e8071264", "score": "0.423542", "text": "func (o *PostAutoDiscoveryBladeDiscParams) SetSnmpString(snmpString *string) {\n\to.SnmpString = snmpString\n}", "title": "" }, { "docid": "97be46e82eae48a8e21a32bd59a6dd9a", "score": "0.4217805", "text": "func (s *BatchAssociateScramSecretOutput) SetUnprocessedScramSecrets(v []*UnprocessedScramSecret) *BatchAssociateScramSecretOutput {\n\ts.UnprocessedScramSecrets = v\n\treturn s\n}", "title": "" }, { "docid": "a2ee4a4a3f807c5ba75d1e4e07d10bde", "score": "0.4217194", "text": "func configureSASLAuth(conf *Config, header http.Header) error {\n\tmech := conf.SaslMechanism\n\tif strings.ToUpper(mech) == \"GSSAPI\" {\n\t\treturn fmt.Errorf(\"SASL_INHERIT support PLAIN and SCRAM SASL mechanisms only\")\n\t}\n\n\tuser := conf.SaslUsername\n\tpass := conf.SaslPassword\n\tif user == \"\" || pass == \"\" {\n\t\treturn fmt.Errorf(\"SASL_INHERIT requires both sasl.username and sasl.password be set\")\n\t}\n\n\theader.Add(\"Authorization\", fmt.Sprintf(\"Basic %s\", encodeBasicAuth(fmt.Sprintf(\"%s:%s\", user, pass))))\n\treturn nil\n}", "title": "" }, { "docid": "f8bd78c3ba5a93395c55fd698ec37b29", "score": "0.42106807", "text": "func CramAuth(username, password string) imap.SASL {\n\treturn cramAuth{username: username, password: password}\n}", "title": "" }, { "docid": "20ee3d6c625ac314c8d34802aa951ab6", "score": "0.42089626", "text": "func SASLFieldSpec() docs.FieldSpec {\n\treturn docs.FieldObject(\"sasl\", \"Enables SASL authentication.\").WithChildren(\n\t\tdocs.FieldString(\"mechanism\", \"The SASL authentication mechanism to use.\").HasAnnotatedOptions(\n\t\t\t\"none\", \"No SASL based authentication.\",\n\t\t\t\"plain\", \"Plain text SASL authentication.\",\n\t\t).HasDefault(\"none\"),\n\t\tdocs.FieldString(\"user\", \"A SASL plain text username. It is recommended that you use environment variables to populate this field.\", \"${USER}\").HasDefault(\"\"),\n\t\tdocs.FieldString(\"password\", \"A SASL plain text password. It is recommended that you use environment variables to populate this field.\", \"${PASSWORD}\").HasDefault(\"\"),\n\t).Advanced().HasDefault(map[string]interface{}{})\n}", "title": "" }, { "docid": "82e07630e331a179ba6666610ef8203a", "score": "0.41897804", "text": "func isScramble(s1 string, s2 string) bool {\n\tif len(s1) != len(s2) {\n\t\treturn false\n\t}\n\treturn solve(s1,s2)\n}", "title": "" }, { "docid": "f04d08a1c995bd4753e1898e5599042a", "score": "0.41868025", "text": "func (s ServerlessSasl) String() string {\n\treturn awsutil.Prettify(s)\n}", "title": "" }, { "docid": "ba71f238152cbb032e17ea39b4c949b6", "score": "0.4186651", "text": "func (this *JSONLDTypePropertyIterator) SetXMLSchemaString(v string) {\n\tthis.clear()\n\tthis.xmlschemaStringMember = v\n\tthis.hasStringMember = true\n}", "title": "" }, { "docid": "31a3c6c2d99360ed5e98b5901ebc81c2", "score": "0.41353676", "text": "func (s *BatchDisassociateScramSecretOutput) SetUnprocessedScramSecrets(v []*UnprocessedScramSecret) *BatchDisassociateScramSecretOutput {\n\ts.UnprocessedScramSecrets = v\n\treturn s\n}", "title": "" }, { "docid": "3378a4ba5ce8c9d3360afd33924c5b91", "score": "0.40344983", "text": "func (c *SASLConfig) Validate() error {\n\tif !c.Enabled {\n\t\treturn nil\n\t}\n\n\tswitch c.Mechanism {\n\tcase SASLMechanismPlain, SASLMechanismScramSHA256, SASLMechanismScramSHA512, SASLMechanismGSSAPI:\n\t\t// Valid and supported\n\tcase SASLMechanismOAuthBearer:\n\t\treturn fmt.Errorf(\"sasl mechanism '%v' is valid but not yet supported. Please submit an issue if you need it\", c.Mechanism)\n\tdefault:\n\t\treturn fmt.Errorf(\"given sasl mechanism '%v' is invalid\", c.Mechanism)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "0c237748707c75a34d0fb3271c39e168", "score": "0.4024109", "text": "func (this *ActivityStreamsContentPropertyIterator) SetXMLSchemaString(v string) {\n\tthis.clear()\n\tthis.xmlschemaStringMember = v\n\tthis.hasStringMember = true\n}", "title": "" }, { "docid": "f117b82472e12908ba6cb1f9881dab6d", "score": "0.39933926", "text": "func (mc *MYSQLConn) scrambleClear() []byte {\n\treturn append([]byte(mc.password), '\\x00')\n}", "title": "" }, { "docid": "53fc52f5e73409df93ad982fb3470a34", "score": "0.396234", "text": "func (mc *MYSQLConn) scrambleRSA() ([]byte, error) {\n\tscramble := make([]byte, len(mc.password)+1)\n\tcopy(scramble, mc.password)\n\tfor i := range scramble {\n\t\tscramble[i] ^= mc.authdata[i%20]\n\t}\n\treturn rsa.EncryptOAEP(sha1.New(), rand.Reader, mc.publickey, scramble, nil)\n}", "title": "" }, { "docid": "d0f667988f7abebf2b9d40d2a7c96a81", "score": "0.39601204", "text": "func (in *SASLConfig) DeepCopy() *SASLConfig {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(SASLConfig)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "2092505e13e77f1f6c7bced1f10ed3ab", "score": "0.39018595", "text": "func (o *PayloadConfig) SetInitramfs(v string) {\n\to.Initramfs = &v\n}", "title": "" }, { "docid": "2c431771110a068363379bc058f03bdb", "score": "0.3900209", "text": "func (sec *SecretKey) SetStr(s string) error {\n\tbuf := []byte(s)\n\t// #nosec\n\terr := C.blsSecretKeySetStr(sec.getPointer(), (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf)))\n\tif err > 0 {\n\t\treturn fmt.Errorf(\"bad string:%s\", s)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "cf168dfd1c8be05d9b2b2df8cfb3c34e", "score": "0.38735703", "text": "func SetRandomStringLength(size int) error {\n\tif size < 0 {\n\t\treturn fmt.Errorf(ErrSmallerThanZero, size)\n\t}\n\trandomStringLen = size\n\treturn nil\n}", "title": "" }, { "docid": "a4bd2af19345f1fa94b5da8f699aa838", "score": "0.38661405", "text": "func SetSalt(salt string) {\n\tHashData.Salt = salt\n}", "title": "" }, { "docid": "4a850c598c0bde410f2ff07c0fde8d9a", "score": "0.38628474", "text": "func GramSchmidt(m *linalg.Matrix) (q, r *linalg.Matrix) {\n\tq = m.Copy()\n\tr = linalg.NewMatrix(m.Cols, m.Cols)\n\n\tfor step := 0; step < q.Cols; step++ {\n\t\tfor projCol := 0; projCol < step; projCol++ {\n\t\t\tdot := dotColumns(q, step, projCol)\n\t\t\tfor row := 0; row < q.Rows; row++ {\n\t\t\t\tval := q.Get(row, step)\n\t\t\t\tval -= dot * q.Get(row, projCol)\n\t\t\t\tq.Set(row, step, val)\n\t\t\t}\n\t\t\tr.Set(projCol, step, dot)\n\t\t}\n\t\tmag := math.Sqrt(dotColumns(q, step, step))\n\t\tscaler := 1.0 / mag\n\t\tr.Set(step, step, mag)\n\t\tfor row := 0; row < q.Rows; row++ {\n\t\t\tval := q.Get(row, step)\n\t\t\tq.Set(row, step, val*scaler)\n\t\t}\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "0b682daa52b246a8050ba9ee7114b656", "score": "0.38531047", "text": "func (h *Hash) SetString(s string) { h.SetBytes([]byte(s)) }", "title": "" }, { "docid": "0b682daa52b246a8050ba9ee7114b656", "score": "0.38531047", "text": "func (h *Hash) SetString(s string) { h.SetBytes([]byte(s)) }", "title": "" }, { "docid": "599a90fc059f778fd73048f99566ddd3", "score": "0.38284978", "text": "func (lsms *LineStringMS) SetSRID(srid uint32, lsm LineStringM) (err error) {\n\tif lsms == nil {\n\t\treturn ErrNilLineStringMS\n\t}\n\n\tlsms.Srid = srid\n\tlsms.Lsm = lsm\n\treturn\n}", "title": "" }, { "docid": "253372743f8109f216ea8ef9c9d641a3", "score": "0.3827173", "text": "func NewRsaSha512Message(text string) *RSAMessage {\n\treturn &RSAMessage{\n\t\tAsymmetricMessage{\n\t\t\tEncMessage: EncMessage{\n\t\t\t\tAlgorithm: AlgRsaSha512,\n\t\t\t},\n\t\t\trawMessage: []byte(text),\n\t\t\thash: crypto.SHA512,\n\t\t},\n\t}\n}", "title": "" }, { "docid": "294631ce560855b1aef0c825d2e26dab", "score": "0.37769747", "text": "func (mc *MYSQLConn) scrambleSHA2() []byte {\n\tif len(mc.password) == 0 {\n\t\treturn nil\n\t}\n\n\t/* LHS of XOR */\n\thash := sha256.New()\n\thash.Write([]byte(mc.password))\n\tscramble := hash.Sum(nil)\n\n\t/* RHS of XOR */\n\thash.Reset()\n\thash.Write(scramble)\n\ttemp := hash.Sum(nil)\n\n\thash.Reset()\n\thash.Write(temp)\n\thash.Write(mc.authdata[:20])\n\ttemp = hash.Sum(nil)\n\n\t/* XOR */\n\tfor i := range scramble {\n\t\tscramble[i] ^= temp[i]\n\t}\n\n\treturn scramble\n}", "title": "" }, { "docid": "4ea0f7f68e38f0101a2718cd5af4b3c9", "score": "0.377468", "text": "func (s *Settings) SetSmsMessage(v string) *Settings {\n\ts.SmsMessage = &v\n\treturn s\n}", "title": "" }, { "docid": "6451bf33eac8ab93989afb900fbca4f7", "score": "0.37373415", "text": "func (_m *Fpdf) SetSubject(subjectStr string, isUTF8 bool) {\n\t_m.Called(subjectStr, isUTF8)\n}", "title": "" }, { "docid": "1267b5289102ee5285805dbef90f6937", "score": "0.37155816", "text": "func (response *Response) SetReprompt(text string) *Response {\n\tresponse.Reprompt = &Reprompt{\n\t\tOutputSpeech: &OutputSpeech{\n\t\t\tType: \"SSML\",\n\t\t\tSsml: \"<speak> \" + text + \" </speak>\",\n\t\t},\n\t}\n\treturn response\n}", "title": "" }, { "docid": "e1e0bc971934e02c14ee479a1db99d18", "score": "0.37120512", "text": "func (this *JSONLDTypeProperty) SetXMLSchemaString(idx int, v string) {\n\t(this.properties)[idx].parent = nil\n\t(this.properties)[idx] = &JSONLDTypePropertyIterator{\n\t\talias: this.alias,\n\t\thasStringMember: true,\n\t\tmyIdx: idx,\n\t\tparent: this,\n\t\txmlschemaStringMember: v,\n\t}\n}", "title": "" }, { "docid": "07dde28d43801a08af6262eb4c2a95d5", "score": "0.37076813", "text": "func IsPangram(s string) bool {\n\n\tseen := make(map[rune]struct{})\n\n\tfor _, r := range s {\n\t\tr = unicode.ToLower(r)\n\t\tif 'a' <= r && r <= 'z' {\n\t\t\tif _, ok := seen[r]; !ok {\n\t\t\t\tseen[r] = struct{}{}\n\t\t\t}\n\t\t}\n\t}\n\tif len(seen) == 26 {\n\t\treturn true\n\t}\n\treturn false\n}", "title": "" }, { "docid": "d07dd89a564425bcb5751642d0dbd5e6", "score": "0.36964592", "text": "func (k *PubKey) SetString(str string) *PubKey {\n\tcopy(k[:], Base58Decode(str))\n\treturn k\n}", "title": "" }, { "docid": "760165af4970b8dee1ca9becbbc46e85", "score": "0.36891234", "text": "func (s *ServerConnection) InitSetMessageStorePath(path string) error {\n\tparams := struct {\n\t\tPath string `json:\"path\"`\n\t}{path}\n\t_, err := s.CallRaw(\"Init.setMessageStorePath\", params)\n\treturn err\n}", "title": "" }, { "docid": "58ac57eaf8d8811c24c9f03ec90b6f34", "score": "0.36743918", "text": "func (tu *TransportUpdate) SetSymptom(s string) *TransportUpdate {\n\ttu.mutation.SetSymptom(s)\n\treturn tu\n}", "title": "" }, { "docid": "5520260a31cd98050b21b7fd24f2ef26", "score": "0.36703277", "text": "func (m *MessageSecurityState) SetMessageSubject(value *string)() {\n err := m.GetBackingStore().Set(\"messageSubject\", value)\n if err != nil {\n panic(err)\n }\n}", "title": "" }, { "docid": "18646cffcbddd4590751cb90e8c30d1c", "score": "0.36690652", "text": "func InitMQSCom() MQBusCommunicator {\n\treturn MQBusCommunicator{\n\t\tCommunicator: dc.Communicator,\n\t}\n}", "title": "" }, { "docid": "eb4d9658f2862bbb5dc9a3deb2c82952", "score": "0.36670715", "text": "func (db *Database) SetString(key string, value []byte) error {\n\treturn db.SetSA(key, value)\n}", "title": "" }, { "docid": "03745ba8d2966ff09669f1f20b273229", "score": "0.36653084", "text": "func (s *GetBootstrapBrokersOutput) SetBootstrapBrokerStringVpcConnectivityTls(v string) *GetBootstrapBrokersOutput {\n\ts.BootstrapBrokerStringVpcConnectivityTls = &v\n\treturn s\n}", "title": "" }, { "docid": "3c133109294f10403d4618aff9021aa3", "score": "0.36587375", "text": "func (args SASLArguments) Convert() kafkaexporter.SASLConfig {\n\treturn kafkaexporter.SASLConfig{\n\t\tUsername: args.Username,\n\t\tPassword: string(args.Password),\n\t\tMechanism: args.Mechanism,\n\t\tAWSMSK: args.AWSMSK.Convert(),\n\t}\n}", "title": "" }, { "docid": "94a960b9891d58393a879d899481c56b", "score": "0.36569846", "text": "func (n *NetworkInstance_SegmentRouting) Srlb(LocalId string) *NetworkInstance_SegmentRouting_Srlb {\n\treturn &NetworkInstance_SegmentRouting_Srlb{\n\t\tNodePath: ygot.NewNodePath(\n\t\t\t[]string{\"srlbs\", \"srlb\"},\n\t\t\tmap[string]interface{}{\"local-id\": LocalId},\n\t\t\tn,\n\t\t),\n\t}\n}", "title": "" }, { "docid": "94a960b9891d58393a879d899481c56b", "score": "0.36564678", "text": "func (n *NetworkInstance_SegmentRouting) Srlb(LocalId string) *NetworkInstance_SegmentRouting_Srlb {\n\treturn &NetworkInstance_SegmentRouting_Srlb{\n\t\tNodePath: ygot.NewNodePath(\n\t\t\t[]string{\"srlbs\", \"srlb\"},\n\t\t\tmap[string]interface{}{\"local-id\": LocalId},\n\t\t\tn,\n\t\t),\n\t}\n}", "title": "" }, { "docid": "58b52c77dcc07cb93eedefb6850030e3", "score": "0.3655407", "text": "func (o MachineConfigV2VsphereConfigOutput) SshUserGroup() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v MachineConfigV2VsphereConfig) *string { return v.SshUserGroup }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "8999c07e2e95e61ddd90f4beb8049298", "score": "0.36356214", "text": "func (c *SharedAccessKeyCredentials) GetSAK() string {\n\treturn \"\"\n}", "title": "" }, { "docid": "5fc9b73be9e1fb99dc3964f42f3d6dd7", "score": "0.3631122", "text": "func (a *Account) SetSalt(salt []byte) {\n\ta.PasswordSalt = salt\n}", "title": "" }, { "docid": "9ce95d13a06b40dd806e5c807887192a", "score": "0.362786", "text": "func IsPangram(s string) bool {\n\tvar letters [26]bool\n\n\ts = strings.ToUpper(s)\n\n\tfor _, w := range s {\n\t\ti := int(w) - 65\n\t\tif i >= 0 && i <= 25 {\n\t\t\tletters[i] = true\n\t\t}\n\t}\n\n\tfor i := 0; i <= 25; i++ {\n\t\tif !letters[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "cb3de8dbc3c1fc7e3667a9cd67eb803c", "score": "0.3621835", "text": "func (su *StudentUpdate) SetLname(s string) *StudentUpdate {\n\tsu.mutation.SetLname(s)\n\treturn su\n}", "title": "" }, { "docid": "5f0037816f8f75d54987533b13b60ae2", "score": "0.3608949", "text": "func StringSecureShuffle(sp []string) error {\n\tvar i int64\n\tsize := int64(len(sp)) - 1\n\tfor i = 0; i < size+1; i++ {\n\t\tbigRandI, err := crypto.Int(crypto.Reader, big.NewInt(size))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\trandI := bigRandI.Int64()\n\t\tsp[size-i], sp[randI] = sp[randI], sp[size-i]\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "5d20affbf23cb1b6231e25daf1c786e3", "score": "0.35924295", "text": "func (s *SmsSettings) SetSmsMessage(v string) *SmsSettings {\n\ts.SmsMessage = &v\n\treturn s\n}", "title": "" }, { "docid": "588750ea3a8b4caec93a03dda158bab8", "score": "0.35805425", "text": "func SetStockfishPath(path string) {\n\tstockfishPath = path\n}", "title": "" }, { "docid": "e12b3f9a4d7881012ca693394949e0d0", "score": "0.35671785", "text": "func LoadRsaMessage(emsg MessageEncrypter) *RSAMessage {\n\thash := crypto.SHA256\n\tif emsg.Alg() == AlgRsaSha512 {\n\t\thash = crypto.SHA512\n\t}\n\n\treturn &RSAMessage{\n\t\tAsymmetricMessage{\n\t\t\tEncMessage: EncMessage{\n\t\t\t\tAlgorithm: emsg.Alg(),\n\t\t\t\tMessage: emsg.EncryptedMessage(),\n\t\t\t\tSig: emsg.Signature(),\n\t\t\t},\n\t\t\thash: hash,\n\t\t},\n\t}\n}", "title": "" }, { "docid": "aedb8e76d8e36d0bb881c5c4dc43675c", "score": "0.35652226", "text": "func (m *Application) SetSpa(value SpaApplicationable)() {\n err := m.GetBackingStore().Set(\"spa\", value)\n if err != nil {\n panic(err)\n }\n}", "title": "" }, { "docid": "0cd8ed1da182c4f95c1cd02c889079b8", "score": "0.35630107", "text": "func (s *Service) SetRebootMessage(msg string) error {\n\trActions := windows.SERVICE_FAILURE_ACTIONS{\n\t\tRebootMsg: syscall.StringToUTF16Ptr(msg),\n\t}\n\treturn windows.ChangeServiceConfig2(s.Handle, windows.SERVICE_CONFIG_FAILURE_ACTIONS, (*byte)(unsafe.Pointer(&rActions)))\n}", "title": "" }, { "docid": "10ec97f90e76b5fdd17106088f8da2cc", "score": "0.35621068", "text": "func (b *Builder) SetSubject(text string) {\n\tb.Subject = text\n}", "title": "" }, { "docid": "bf997dd40c21e57086328cfdeebbea2f", "score": "0.3559144", "text": "func (o *KafkaConnectionSettings) SetBootstrapServer(v string) {\n\to.BootstrapServer = &v\n}", "title": "" }, { "docid": "fecbc4044f42232eb381eaa522b5e170", "score": "0.35518712", "text": "func (r *Request) SetStringBody(s string) {\n\tr.SetReaderBody(strings.NewReader(s))\n}", "title": "" }, { "docid": "0a5af6a4397651df8526b0b80d0e1065", "score": "0.35490677", "text": "func (o *SearchAssetsParams) SetSha512(sha512 *string) {\n\to.Sha512 = sha512\n}", "title": "" }, { "docid": "1bcd055a6beaa02d094243a2fcbac760", "score": "0.35403478", "text": "func (r *RandomStr) SetPrefix(prefix []rune) {\n\tr.Prefix = prefix\n}", "title": "" }, { "docid": "d38cfb82da9b4dd75a5bf2e5cb6e1ae8", "score": "0.35401165", "text": "func (server Server) SetSuperUserPassword(password string) {\n\tsaltBytes := make([]byte, 24)\n\t_, err := rand.Read(saltBytes)\n\tif err != nil {\n\t\tserver.Panic(err)\n\t}\n\n\tsalt := hex.EncodeToString(saltBytes)\n\thasher := sha1.New()\n\thasher.Write(saltBytes)\n\thasher.Write([]byte(password))\n\tdigest := hex.EncodeToString(hasher.Sum(nil))\n\n\t// Could be racy, but shouldn't really matter...\n\t// TODO: No this does matter, jesus fucking christ, it fucking matters!\n\t// TODO: Also don't use sha1, come on, its 2017\n\tkey := \"SuperUserPassword\"\n\tvalue := \"sha1$\" + salt + \"$\" + digest\n\tserver.Config.Set(key, value)\n\tserver.ConfigUpdate <- &KeyValuePair{Key: key, Value: value}\n}", "title": "" }, { "docid": "f17dec0f5a564ce5bdccf50d8cedb6f3", "score": "0.35333508", "text": "func (i *ImageConfig) SetRabbitMQ(image string) {\n\ti.RabbitMQ = image\n}", "title": "" }, { "docid": "dede2587ee00aa3747b790fbe33023ef", "score": "0.3532701", "text": "func ShlexFromString(s string) *Shlex {\n\treturn &Shlex{\n\t\tr: strings.NewReader(s),\n\t\tstate: ' ',\n\t}\n}", "title": "" }, { "docid": "607bae89d838199c613b4c9db41a262b", "score": "0.35320902", "text": "func (cli *HostWrapper) SetSLA(sla string) error {\n\treturn cli.host.SetValue(fieldSLA, sla)\n}", "title": "" }, { "docid": "70354822b43ff0bb5cdedbb0c425c48f", "score": "0.35302186", "text": "func IsPangram(s string) bool {\n\tf := uint32(0x3ffffff) // one bit for each alphabet\n\tfor _, c := range s {\n\t\tif unicode.IsLetter(c) {\n\t\t\tc = unicode.ToLower(c) - 'a'\n\t\t\tf &^= (1 << uint(c))\n\t\t}\n\t}\n\treturn f == 0\n}", "title": "" }, { "docid": "40de7e61d5c7b4e43717bf04fd24d068", "score": "0.35245976", "text": "func (c *X509Credentials) GetSAK() string {\n\treturn \"\"\n}", "title": "" }, { "docid": "2a601d58378753054c7b47b0bd12d234", "score": "0.35236242", "text": "func SetRandomizer(g random.Generator) {\n\trandomizer = g\n}", "title": "" }, { "docid": "cc87f4955fab55cf779c6711daa5a70e", "score": "0.35221285", "text": "func NewScrambler8() *Scrambler8 {\n\tsalt, inv := GenRandomSalt8()\n\n\treturn &Scrambler8{\n\t\tsalt: salt,\n\t\tinv: inv,\n\t}\n}", "title": "" }, { "docid": "9ed8ae90827f6dc90dbac9b6348c2a68", "score": "0.35193667", "text": "func GetSASLConfiguration(username string, password string) (string, string, error) {\n\tif username == \"\" || password == \"\" {\n\t\treturn \"\", \"\", ErrorUsernameOrPasswordMandatory\n\t}\n\treturn username, password, nil\n}", "title": "" }, { "docid": "3eb3bcc8b4e07a291beec45d2643e938", "score": "0.35093868", "text": "func (o NodeTemplateVsphereConfigOutput) SshUserGroup() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v NodeTemplateVsphereConfig) *string { return v.SshUserGroup }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "32d11d8153a99365042710ca61c4e3db", "score": "0.35040668", "text": "func (sasl *SASLPlain) Method() string {\n\treturn \"PLAIN\"\n}", "title": "" }, { "docid": "fd80f0c86146594d2cf277e36d5d0d1c", "score": "0.34963554", "text": "func (t MultiLineStringType) SetSRID(v uint32) sql.Type {\n\tt.SRID = v\n\tt.DefinedSRID = true\n\treturn t\n}", "title": "" }, { "docid": "4b6edaa5f7d01b26fac82b859dc1186e", "score": "0.34950772", "text": "func SetBBSHOME(bbshome string) string {\n\torigBBSHome := BBSHOME\n\tlog.Debugf(\"SetBBSHOME: %v\", bbshome)\n\n\t// config.go\n\tBBSHOME = bbshome\n\tBBSPROG = BBSHOME + BBSPROGPOSTFIX\n\n\t//common.go\n\tFN_CONF_BANIP = BBSHOME + FN_CONF_BANIP_POSTFIX // 禁止連線的 IP 列表\n\tFN_PASSWD = BBSHOME + FN_PASSWD_POSTFIX /* User records */\n\n\treturn origBBSHome\n}", "title": "" }, { "docid": "40c9704cb99e772a6f641cb8803efe22", "score": "0.34806994", "text": "func (hdc *HTTPDetectorCreate) SetRandomQueryString(i int8) *HTTPDetectorCreate {\n\thdc.mutation.SetRandomQueryString(i)\n\treturn hdc\n}", "title": "" }, { "docid": "f14d1c8185504a7e982f4e37207e051a", "score": "0.3480652", "text": "func (k *SigData) SetString(str string) *SigData {\n\tcopy(k[:], Base58Decode(str))\n\treturn k\n}", "title": "" } ]
36fdff16fcf13cf23b49fdb5a4d6defe
/////////////////////////////////////////////////////////////// Implement functions from Interface ==> encoding/BinaryMarshaller ///////////////////////////////////////////////////////////////
[ { "docid": "2fc8bed09825e4b2cc066883e484ec87", "score": "0.0", "text": "func (msg *TraverseResponseMessage) MarshalBinary() ([]byte, error) {\n\t// A simple encoding: plain text.\n\tvar b bytes.Buffer\n\t_, err := fmt.Fprintln(&b, msg.BufLength, msg.verbId, msg.sequenceNo, msg.timestamp,\n\t\tmsg.requestId, msg.dataOffset, msg.authToken, msg.sessionId, msg.isUpdatable)\n\tif err != nil {\n\t\tlogger.Error(fmt.Sprintf(\"ERROR: Returning TraverseResponseMessage:MarshalBinary w/ Error: '%+v'\", err.Error()))\n\t\treturn nil, err\n\t}\n\treturn b.Bytes(), nil\n}", "title": "" } ]
[ { "docid": "4c7bcf5497cd32382fbbef3dcca2500b", "score": "0.61034906", "text": "func Marshal(i interface{}) ([]byte, error) {\n\te := newEncodeState()\n\n\terr := e.marshal(i)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn append([]byte(nil), e.Bytes()...), nil\n}", "title": "" }, { "docid": "ba3d47176c0b79cfe7e27d81a4628ba6", "score": "0.60947126", "text": "func encodeTransactionToBuffer(buf []byte, obj *Transaction) error {\n\tif uint64(len(buf)) < encodeSizeTransaction(obj) {\n\t\treturn encoder.ErrBufferUnderflow\n\t}\n\n\te := &encoder.Encoder{\n\t\tBuffer: buf[:],\n\t}\n\n\t// obj.Length\n\te.Uint32(obj.Length)\n\n\t// obj.Type\n\te.Uint8(obj.Type)\n\n\t// obj.InnerHash\n\te.CopyBytes(obj.InnerHash[:])\n\n\t// obj.Sigs maxlen check\n\tif len(obj.Sigs) > 65535 {\n\t\treturn encoder.ErrMaxLenExceeded\n\t}\n\n\t// obj.Sigs length check\n\tif uint64(len(obj.Sigs)) > math.MaxUint32 {\n\t\treturn errors.New(\"obj.Sigs length exceeds math.MaxUint32\")\n\t}\n\n\t// obj.Sigs length\n\te.Uint32(uint32(len(obj.Sigs)))\n\n\t// obj.Sigs\n\tfor _, x := range obj.Sigs {\n\n\t\t// x\n\t\te.CopyBytes(x[:])\n\n\t}\n\n\t// obj.In maxlen check\n\tif len(obj.In) > 65535 {\n\t\treturn encoder.ErrMaxLenExceeded\n\t}\n\n\t// obj.In length check\n\tif uint64(len(obj.In)) > math.MaxUint32 {\n\t\treturn errors.New(\"obj.In length exceeds math.MaxUint32\")\n\t}\n\n\t// obj.In length\n\te.Uint32(uint32(len(obj.In)))\n\n\t// obj.In\n\tfor _, x := range obj.In {\n\n\t\t// x\n\t\te.CopyBytes(x[:])\n\n\t}\n\n\t// obj.Out maxlen check\n\tif len(obj.Out) > 65535 {\n\t\treturn encoder.ErrMaxLenExceeded\n\t}\n\n\t// obj.Out length check\n\tif uint64(len(obj.Out)) > math.MaxUint32 {\n\t\treturn errors.New(\"obj.Out length exceeds math.MaxUint32\")\n\t}\n\n\t// obj.Out length\n\te.Uint32(uint32(len(obj.Out)))\n\n\t// obj.Out\n\tfor _, x := range obj.Out {\n\n\t\t// x.Address.Version\n\t\te.Uint8(x.Address.Version)\n\n\t\t// x.Address.Key\n\t\te.CopyBytes(x.Address.Key[:])\n\n\t\t// x.Coins\n\t\te.Uint64(x.Coins)\n\n\t\t// x.Hours\n\t\te.Uint64(x.Hours)\n\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "ac3f175bc3187781ff3ac0f0710ce9ef", "score": "0.5987506", "text": "func (binaryEncoder) Encode(str []byte) ([]byte, bool) {\n\treturn str, true\n}", "title": "" }, { "docid": "39583304d841bb36ddd74aa6b9a13f8d", "score": "0.59861237", "text": "func (o *Object) Marshal(buf []byte) ([]byte, error) {\n\tvar size uint64\n\tsize += code.MaxVarintBytes(uint64(o.A)) + 1\n\tsize += code.MaxVarintBytes(o.B) + 1\n\tsize += code.MaxFloat32Bytes(o.C) + 1\n\tsize += code.MaxFloat64Bytes(o.D) + 1\n\tsize += code.MaxStringBytes(o.E) + 1\n\tsize += code.MaxBoolBytes(o.F) + 1\n\tsize += code.MaxBytesBytes(o.G) + 1\n\tsize += code.MaxBytesSliceBytes(o.H) + 1\n\tif uint64(cap(buf)) >= size {\n\t\tbuf = buf[:size]\n\t} else {\n\t\tbuf = make([]byte, size)\n\t}\n\tvar offset uint64\n\tvar n uint64\n\tif o.A != 0 {\n\t\tbuf[offset] = 1<<3 | 0\n\t\toffset++\n\t\tn = code.EncodeVarint(buf[offset:], uint64(o.A))\n\t\toffset += n\n\t}\n\tif o.B != 0 {\n\t\tbuf[offset] = 2<<3 | 0\n\t\toffset++\n\t\tn = code.EncodeVarint(buf[offset:], o.B)\n\t\toffset += n\n\t}\n\tif o.C != 0 {\n\t\tbuf[offset] = 3<<3 | 5\n\t\toffset++\n\t\tn = code.EncodeFloat32(buf[offset:], o.C)\n\t\toffset += n\n\t}\n\tif o.D != 0 {\n\t\tbuf[offset] = 4<<3 | 1\n\t\toffset++\n\t\tn = code.EncodeFloat64(buf[offset:], o.D)\n\t\toffset += n\n\t}\n\tif len(o.E) > 0 {\n\t\tbuf[offset] = 5<<3 | 2\n\t\toffset++\n\t\tn = code.EncodeString(buf[offset:], o.E)\n\t\toffset += n\n\t}\n\tif o.F == true {\n\t\tbuf[offset] = 6<<3 | 0\n\t\toffset++\n\t\tn = code.EncodeBool(buf[offset:], o.F)\n\t\toffset += n\n\t}\n\tif len(o.G) > 0 {\n\t\tbuf[offset] = 7<<3 | 2\n\t\toffset++\n\t\tn = code.EncodeBytes(buf[offset:], o.G)\n\t\toffset += n\n\t}\n\tif len(o.H) > 0 {\n\t\ttag := byte(8<<3 | 2)\n\t\tfor _, v := range o.H {\n\t\t\tbuf[offset] = tag\n\t\t\toffset++\n\t\t\tn = code.EncodeBytes(buf[offset:], v)\n\t\t\toffset += n\n\t\t}\n\t}\n\treturn buf[:offset], nil\n}", "title": "" }, { "docid": "29eb781760d39b34239fff9000f7a504", "score": "0.5917643", "text": "func Serialize(c interface{}) []byte {\n // define your serialization strategy\n // ...\n}", "title": "" }, { "docid": "9ccdb221ad634e8d8b2911e55f9e08c1", "score": "0.59158033", "text": "func (enc *Encoder) Encode(e interface{}) error", "title": "" }, { "docid": "572af5cadc41bf156a1bb2210479dcea", "score": "0.5874986", "text": "func Encode(buffer *Buffer, thing interface{}) error {\r\n\tswitch i := thing.(type) {\r\n\tcase nil:\r\n\t\tbuffer.WriteByte('N')\r\n\tcase string:\r\n\t\tbuffer.WriteByte('s')\r\n\t\twriteSz(buffer, len(i))\r\n\t\tbuffer.WriteString(i)\r\n\tcase ChannelCreate:\r\n\t\tbuffer.WriteByte('c')\r\n\t\tbuffer.Write([]byte(i.ChannelId))\r\n\t\tswitch i.Type {\r\n\t\tcase CallChan:\r\n\t\t\tbuffer.WriteByte('C')\r\n\t\tcase SubChan:\r\n\t\t\tbuffer.WriteByte('S')\r\n\t\tdefault:\r\n\t\t\treturn fmt.Errorf(\"Unknown type: %v\", i.Type)\r\n\t\t}\r\n\t\tbuffer.WriteByte(byte(len(i.Service)))\r\n\t\tbuffer.WriteString(i.Service)\r\n\t\tta := make([]byte, 2)\r\n\t\tbinary.BigEndian.PutUint16(ta, uint16(i.Timeout))\r\n\t\tbuffer.Write(ta)\r\n\t\tbuffer.Write([]byte(i.AuthToken))\r\n\t\tEncode(buffer, i.Body)\r\n\tcase ChannelClose:\r\n\t\tbuffer.WriteByte('X')\r\n\t\tbuffer.Write([]byte(i.ChannelId))\r\n\t\tEncode(buffer, i.Body)\r\n\tcase ChannelMsg:\r\n\t\tif i.IsClose {\r\n\t\t\tbuffer.WriteByte('X')\r\n\t\t} else {\r\n\t\t\tbuffer.WriteByte('M')\r\n\t\t}\r\n\t\tbuffer.Write([]byte(i.Channel))\r\n\t\tEncode(buffer, i.Body)\r\n\tcase float32:\r\n\t\tbuffer.WriteByte('d')\r\n\t\tbuffer.WriteFloat32(i)\r\n\tcase float64:\r\n\t\tbuffer.WriteByte('D')\r\n\t\tbuffer.WriteFloat64(i)\r\n\tcase int:\r\n\t\treturn encodeInt(buffer, int64(i))\r\n\tcase uint:\r\n\t\treturn encodeUint(buffer, uint64(i))\r\n\tcase time.Time:\r\n\t\tbuffer.WriteByte('z')\r\n\t\tbuffer.WriteInt64(int64(i.UnixNano() / 1000))\r\n\tcase []byte:\r\n\t\tbuffer.WriteByte('q')\r\n\t\twriteSz(buffer, len(i))\r\n\t\tbuffer.Write(i)\r\n\tcase []interface{}: // common case, don't reflect\r\n\t\tbuffer.WriteByte('a')\r\n\t\twriteSz(buffer, len(i))\r\n\t\tfor _, item := range i {\r\n\t\t\terr := Encode(buffer, item)\r\n\t\t\tif err != nil {\r\n\t\t\t\treturn fmt.Errorf(\"Error encoding: %v - %v\", item, err)\r\n\t\t\t}\r\n\t\t}\r\n\tcase net.IPAddr:\r\n\t\treturn Encode(buffer, i.String())\r\n\tcase bool:\r\n\t\tif i {\r\n\t\t\tbuffer.WriteByte('T')\r\n\t\t} else {\r\n\t\t\tbuffer.WriteByte('F')\r\n\t\t}\r\n\tdefault:\r\n\t\treturn reflectEncode(thing, buffer)\r\n\t}\r\n\treturn nil\r\n}", "title": "" }, { "docid": "c88b6470f884f53a36a4f54b6990d70c", "score": "0.5803861", "text": "func toMarshaller(ext string) func(interface{}) ([]byte, error) {\n\treturn ext2EncFormat(ext).Marshal\n}", "title": "" }, { "docid": "7de7b83a7538b9e69ff3d9e4a6e7218f", "score": "0.57624483", "text": "func (e *Encoder) Encode(v interface{}) error {\n //Check for base type encoding\n switch val := v.(type) {\n\n //Integer\n case int64:\n return EncodeInt(e.wtr, val, 64)\n case int32:\n return EncodeInt(e.wtr, int64(val), 32)\n case int16:\n return EncodeInt(e.wtr, int64(val), 16)\n case int8:\n return EncodeInt(e.wtr, int64(val), 8)\n case int:\n return EncodeInt(e.wtr, int64(val), int(reflect.TypeOf(v).Size())*8)\n\n //Unsigned integer\n case uint64:\n return EncodeUint(e.wtr, val, 64)\n case uint32:\n return EncodeUint(e.wtr, uint64(val), 32)\n case uint16:\n return EncodeUint(e.wtr, uint64(val), 16)\n case uint8:\n return EncodeUint(e.wtr, uint64(val), 8)\n case uint:\n return EncodeUint(e.wtr, uint64(val), int(reflect.TypeOf(v).Size())*8)\n\n //Float\n case float64:\n return EncodeFloat64(e.wtr, float64(val))\n\n case float32:\n return EncodeFloat32(e.wtr, float32(val))\n\n //Boolean\n case bool:\n return EncodeBool(e.wtr, val)\n\n //String\n case string:\n return EncodeString(e.wtr, val)\n\n //Byte (binary)\n case []byte:\n return EncodeBin(e.wtr, val)\n\n //Nil case\n case nil:\n return EncodeNil(e.wtr)\n }\n\n //More complicated type discovery\n typ := reflect.TypeOf(v)\n switch typ.Kind() {\n //Array/slice type\n case reflect.Slice:\n fallthrough\n case reflect.Array:\n return e.encodeArray(typ, reflect.ValueOf(v))\n\n case reflect.Map:\n return e.encodeMap(typ, reflect.ValueOf(v))\n\n case reflect.Struct:\n return e.encodeStruct(typ, reflect.ValueOf(v))\n\n case reflect.Ptr:\n vptr := reflect.ValueOf(v)\n if vptr.IsNil() {\n return e.Encode(nil)\n }\n\n return e.Encode(reflect.Indirect(vptr).Interface())\n }\n\n //TODO: Encode ext\n log.Panicf(\"Unhandled type %T\", v)\n return nil\n}", "title": "" }, { "docid": "0b6625bcae4a063029b92c8138a51773", "score": "0.57374525", "text": "func Marshal(x interface{}) ([]byte, error) {\n\tif x, ok := x.(Marshaler); ok {\n\t\tvar wBuffer xrdenc.WBuffer\n\t\terr := x.MarshalXrd(&wBuffer)\n\t\treturn wBuffer.Bytes(), err\n\t}\n\n\tv := reflect.ValueOf(x)\n\n\tv = reflect.Indirect(v)\n\n\tif v.Kind() != reflect.Struct {\n\t\treturn nil, errors.Errorf(\"encoder: cannot Marshal invalid type %T\", x)\n\t}\n\n\tdataSize, err := sizeOf(v)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdata := make([]byte, dataSize)\n\tpos := 0\n\tfor i := 0; i < v.NumField(); i++ {\n\t\tfield := v.Field(i)\n\t\tfieldSize := 0\n\t\tswitch field.Kind() {\n\t\tcase reflect.Uint8:\n\t\t\tfieldSize = 1\n\t\t\tdata[pos] = uint8(field.Uint())\n\t\tcase reflect.Uint16:\n\t\t\tfieldSize = 2\n\t\t\tbinary.BigEndian.PutUint16(data[pos:pos+fieldSize], uint16(field.Uint()))\n\t\tcase reflect.Int32:\n\t\t\tfieldSize = 4\n\t\t\tbinary.BigEndian.PutUint32(data[pos:pos+fieldSize], uint32(field.Int()))\n\t\tcase reflect.Int64:\n\t\t\tfieldSize = 8\n\t\t\tbinary.BigEndian.PutUint64(data[pos:pos+fieldSize], uint64(field.Int()))\n\t\tcase reflect.Array, reflect.Slice:\n\t\t\telementKind := field.Type().Elem().Kind()\n\t\t\tif elementKind != reflect.Uint8 {\n\t\t\t\treturn nil, errors.Errorf(\"encoder: cannot Marshal array or slice of %s, only arrays / slices of uint8 are supported\", elementKind)\n\t\t\t}\n\n\t\t\tfieldSize = field.Len()\n\t\t\treflect.Copy(reflect.ValueOf(data[pos:pos+fieldSize]), field)\n\t\tdefault:\n\t\t\treturn nil, errors.Errorf(\"encoder: cannot Marshal kind %s\", field.Kind())\n\t\t}\n\t\tpos += fieldSize\n\t}\n\n\treturn data, nil\n}", "title": "" }, { "docid": "b6b778636d7bce190f7c557fa08a3c66", "score": "0.5689281", "text": "func (n PkgNode) MarshalBinary() (data []byte, err error) {\n\tvar outBuffer bytes.Buffer\n\tencoder := gob.NewEncoder(&outBuffer)\n\thasPkgPtr := (n.VersionedPkg != nil)\n\terr = encoder.Encode(hasPkgPtr)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"encoding hasPkgPtr: %s\", err.Error())\n\t\treturn\n\t}\n\tif hasPkgPtr {\n\t\terr = encoder.Encode(n.VersionedPkg)\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"encoding VersionedPkg: %s\", err.Error())\n\t\t\treturn\n\t\t}\n\t}\n\terr = encoder.Encode(n.State)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"encoding State: %s\", err.Error())\n\t\treturn\n\t}\n\terr = encoder.Encode(n.Type)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"encoding Type: %s\", err.Error())\n\t\treturn\n\t}\n\terr = encoder.Encode(n.SrpmPath)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"encoding SrpmPath: %s\", err.Error())\n\t\treturn\n\t}\n\terr = encoder.Encode(n.SpecPath)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"encoding SpecPath: %s\", err.Error())\n\t\treturn\n\t}\n\terr = encoder.Encode(n.SourceDir)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"encoding SourceDir: %s\", err.Error())\n\t\treturn\n\t}\n\terr = encoder.Encode(n.Architecture)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"encoding Architecture: %s\", err.Error())\n\t\treturn\n\t}\n\terr = encoder.Encode(n.SourceRepo)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"encoding SourceRepo: %s\", err.Error())\n\t\treturn\n\t}\n\terr = encoder.Encode(n.GoalName)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"encoding GoalName: %s\", err.Error())\n\t\treturn\n\t}\n\treturn outBuffer.Bytes(), err\n}", "title": "" }, { "docid": "fff5d8e01627ca33f8f56d07badcdfc3", "score": "0.5684009", "text": "func (o *O) Encode() []byte {\n\tvar r R\n\tb := make([]byte, unsafe.Sizeof(r), int(unsafe.Sizeof(r))+len(o.MyString1)+len(o.MyString2))\n\tr.MyString1.Encode(o.MyString1, &b)\n\tr.MyInt = int64(o.MyInt)\n\tr.MyString2.Encode(o.MyString2, &b)\n\tcopy(b, (*[unsafe.Sizeof(r)]byte)(unsafe.Pointer(&r))[:])\n\treturn b\n}", "title": "" }, { "docid": "fbf6caa7b35848c9bba075d16ded7a3d", "score": "0.5660815", "text": "func encodeWithFlagAndLength(e *hessian.Encoder, flag byte, obj interface{}) []byte {\n\tvar bytes []byte\n\tbytes = append(bytes, flag)\n\n\te.Clean()\n\t_ = e.Encode(obj)\n\tdataBytes := e.Buffer()\n\n\tlength := len(dataBytes)\n\n\te.Clean()\n\t_ = e.Encode(length)\n\tlengthBytes := e.Buffer()\n\n\tbytes = append(bytes, lengthBytes...)\n\tbytes = append(bytes, dataBytes...)\n\n\treturn bytes\n}", "title": "" }, { "docid": "a63b119a1196a9a62a02d79df191a0bb", "score": "0.56538486", "text": "func (e *Encoder) Encode(v interface{}) error {\n\tvar b []byte\n\trv := reflect.ValueOf(v)\n\tswitch rv.Kind() {\n\tcase reflect.String:\n\t\tif rv.Type() == typeOfSymbol {\n\t\t\tb = e.enc.fmtSymbol(rv.String())\n\t\t} else {\n\t\t\tb = e.enc.fmtString(rv.String())\n\t\t}\n\tcase reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:\n\t\tb = e.enc.fmtInt(rv.Int())\n\tcase reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:\n\t\tb = e.enc.fmtUint(rv.Uint())\n\tcase reflect.Bool:\n\t\tb = e.enc.fmtBool(rv.Bool())\n\tcase reflect.Float32:\n\t\tb = e.enc.fmtFloat32(float32(rv.Float()))\n\tcase reflect.Float64:\n\t\tb = e.enc.fmtFloat64(rv.Float())\n\tcase reflect.Slice:\n\t\tif rv.IsNil() {\n\t\t\treturn fmt.Errorf(\"cannot encode nil pointer: %T\", v)\n\t\t}\n\t\tif rv.Type() == typeOfByteSlice {\n\t\t\tb = e.enc.fmtBytes(rv.Bytes())\n\t\t\tbreak\n\t\t\t// b is used, break out\n\t\t} else if rv.Type() == typeOfSet {\n\t\t\tif err := e.write(e.enc.setOpen()); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tfor idx := 0; idx < rv.Len(); idx++ {\n\t\t\t\tval := rv.Index(idx).Interface()\n\t\t\t\tif err := e.Encode(val); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn e.write(e.enc.setClose())\n\t\t\t// b is unused, return before leaving statement\n\t\t} else {\n\t\t\tif err := e.write(e.enc.listOpen()); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tfor idx := 0; idx < rv.Len(); idx++ {\n\t\t\t\tval := rv.Index(idx).Interface()\n\t\t\t\tif err := e.Encode(val); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn e.write(e.enc.listClose())\n\t\t\t// b is unused, return before leaving statement\n\t\t}\n\tcase reflect.Ptr:\n\t\tif rv.IsNil() {\n\t\t\treturn fmt.Errorf(\"cannot encode nil pointer: %T\", v)\n\t\t}\n\t\tif rv.Type() == typeOfBigInt {\n\t\t\t// Encode as big int\n\t\t\tb = e.enc.fmtBigInt(rv.Interface().(*big.Int))\n\t\t} else {\n\t\t\treturn e.Encode(rv.Elem().Interface())\n\t\t}\n\t\t// b is unused, return before leaving statement\n\tcase reflect.Map:\n\t\tif rv.IsNil() {\n\t\t\treturn fmt.Errorf(\"cannot encode nil pointer: %T\", v)\n\t\t}\n\t\tif err := e.write(e.enc.dictOpen()); err != nil {\n\t\t\treturn err\n\t\t}\n\t\titer := rv.MapRange()\n\t\tfor iter.Next() {\n\t\t\tk := iter.Key()\n\t\t\tif err := e.Encode(k.Interface()); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tv := iter.Value()\n\t\t\tif err := e.Encode(v.Interface()); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn e.write(e.enc.dictClose())\n\t\t// b is unused, return before leaving statement\n\tcase reflect.Struct:\n\t\tif rv.Type() == typeOfRecord {\n\t\t\t// Encode as record\n\t\t\trecord := rv.Interface().(Record)\n\t\t\tif err := e.write(e.enc.recordOpen()); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif err := e.Encode(record.Label); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tfor _, val := range record.Values {\n\t\t\t\tif err := e.Encode(val); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn e.write(e.enc.recordClose())\n\t\t} else {\n\t\t\t// Encode as dictionary\n\t\t\tif err := e.write(e.enc.dictOpen()); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tn := rv.NumField()\n\t\t\trvt := rv.Type()\n\t\t\tfor i := 0; i < n; i++ {\n\t\t\t\tk := rvt.Field(i)\n\t\t\t\tif len(k.PkgPath) > 0 {\n\t\t\t\t\t// Skip unexported fields\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tname := k.Name\n\t\t\t\tif tname, ok := k.Tag.Lookup(kSyrupStructTag); ok {\n\t\t\t\t\tname = tname\n\t\t\t\t}\n\t\t\t\tif err := e.Encode(name); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tv := rv.Field(i)\n\t\t\t\tif err := e.Encode(v.Interface()); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn e.write(e.enc.dictClose())\n\t\t}\n\t\t// b is unused, return before leaving statement\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown type: %T\", v)\n\t}\n\treturn e.write(b)\n}", "title": "" }, { "docid": "db069c0c97e98c49d9390d701a668895", "score": "0.56149334", "text": "func (b BytesResponse) encode() ([]byte, error) {\n\treturn b, nil\n}", "title": "" }, { "docid": "886086d680f49af5180fdb90b03be8c0", "score": "0.5611662", "text": "func (r *codec) Encode(value map[string]interface{}) ([]byte, error) {\n\tvar payload = make([]byte, 0)\n\tvar binaryValue []byte\n\tvar binarySchemaId = make([]byte, 4)\n\n\tbinary.BigEndian.PutUint32(binarySchemaId, uint32(r.latest))\n\n\tbinaryPayload, err := r.codecs[r.latest].BinaryFromNative(payload, value)\n\n\tbinaryValue = append(binaryValue, byte(0))\n\tbinaryValue = append(binaryValue, binarySchemaId...)\n\tbinaryValue = append(binaryValue, binaryPayload...)\n\n\treturn binaryValue, err\n}", "title": "" }, { "docid": "67a329b8c8a617c65576ec1930d56ca2", "score": "0.56090707", "text": "func (input *Data) Serialize() {\n\n}", "title": "" }, { "docid": "a54054fcc135b3d0ac389f6ee4063800", "score": "0.56012774", "text": "func (o *employeeInfoBase) MarshalBinary() ([]byte, error) {\n\tbuf := new(bytes.Buffer)\n\tencoder := gob.NewEncoder(buf)\n\n\tif err := encoder.Encode(o.id); err != nil {\n\t\treturn nil, err\n\t}\n\tif err := encoder.Encode(o.idIsValid); err != nil {\n\t\treturn nil, err\n\t}\n\tif err := encoder.Encode(o.idIsDirty); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := encoder.Encode(o.personID); err != nil {\n\t\treturn nil, err\n\t}\n\tif err := encoder.Encode(o.personIDIsValid); err != nil {\n\t\treturn nil, err\n\t}\n\tif err := encoder.Encode(o.personIDIsDirty); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif o.oPerson == nil {\n\t\tif err := encoder.Encode(false); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else {\n\t\tif err := encoder.Encode(true); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif err := encoder.Encode(o.oPerson); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tif err := encoder.Encode(o.employeeNumber); err != nil {\n\t\treturn nil, err\n\t}\n\tif err := encoder.Encode(o.employeeNumberIsValid); err != nil {\n\t\treturn nil, err\n\t}\n\tif err := encoder.Encode(o.employeeNumberIsDirty); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif o._aliases == nil {\n\t\tif err := encoder.Encode(false); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else {\n\t\tif err := encoder.Encode(true); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif err := encoder.Encode(o._aliases); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif err := encoder.Encode(o._restored); err != nil {\n\t\treturn nil, err\n\t}\n\tif err := encoder.Encode(o._originalPK); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn buf.Bytes(), nil\n}", "title": "" }, { "docid": "2072ff5fc6e7e496a6201f2c3468cb2b", "score": "0.55942273", "text": "func (c *Codec) Marshal(st interface{}) ([]byte, error) {\n\treturn c.marshal(&c.Codec, st)\n}", "title": "" }, { "docid": "3a422f511ad450958c8abf3bf31a55ad", "score": "0.55929905", "text": "func encodeTransaction(obj *Transaction) ([]byte, error) {\n\tn := encodeSizeTransaction(obj)\n\tbuf := make([]byte, n)\n\n\tif err := encodeTransactionToBuffer(buf, obj); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn buf, nil\n}", "title": "" }, { "docid": "55d4fa7e3c5e535a4097f2d4814989f0", "score": "0.5591776", "text": "func (w *encbuf) toBytes() []byte {\n\t// create an empty byte array with size encoded data length + number of encoded list headers\n\t// which is equal to the actual size of encoded data because Actual Encoded Data = List Headers + Actual Encoded Data\n\tout := make([]byte, w.size())\n\tstrpos := 0\n\tpos := 0\n\tfor _, head := range w.lheads {\n\t\tn := copy(out[pos:], w.str[strpos:head.offset])\n\t\tpos += n\n\t\tstrpos += n\n\n\t\tenc := head.encode(out[pos:])\n\t\tpos += len(enc)\n\t}\n\tcopy(out[pos:], w.str[strpos:])\n\treturn out\n}", "title": "" }, { "docid": "1b1bed07be46ee2549fcdd31c0d91311", "score": "0.5586657", "text": "func (o setConfigEncodedComponents) encode() []byte {\n\trv, err := encoding.Pack(o.serializationRepresentation())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif len(rv) > configSizeBound {\n\t\tpanic(\"config serialization too large\")\n\t}\n\treturn rv\n}", "title": "" }, { "docid": "dfb8ada231d7b6c5bf17544687fd3daa", "score": "0.55806255", "text": "func (bin *Gobin) Encode(v interface{}) (id int, err error) {\n\tbin.maxId++\n\tid = bin.maxId\n\treturn id, bin.EncodeId(v, id)\n}", "title": "" }, { "docid": "3259fac9763ea6d58fae224ea6fe1269", "score": "0.5578941", "text": "func (t txdata) MarshalJSON() ([]byte, error) {\n\ttype txdata struct {\n\t\tRecipient *bgmcommon.Address `json:\"to\" rlp:\"nil\"`\n\t\tAmount *hexutil.Big `json:\"value\" gencodec:\"required\"`\n\t\tPayload hexutil.Bytes `json:\"input\" gencodec:\"required\"`\n\t\tV *hexutil.Big `json:\"v\" gencodec:\"required\"`\n\t\tR *hexutil.Big `json:\"r\" gencodec:\"required\"`\n\t\tS *hexutil.Big `json:\"s\" gencodec:\"required\"`\n\t\tHash *bgmcommon.Hash `json:\"hash\" rlp:\"-\"`\n\t\tType TxType `json:\"type\" gencodec:\"required\"`\n\t\tAccountNonce hexutil.Uint64 `json:\"nonce\" gencodec:\"required\"`\n\t\tPrice *hexutil.Big `json:\"gasPrice\" gencodec:\"required\"`\n\t\tGasLimit *hexutil.Big `json:\"gas\" gencodec:\"required\"`\n\t\t\n\t}\n\tvar enc txdata\n\tencPtr.R = (*hexutil.Big)(tPtr.R)\n\tencPtr.S = (*hexutil.Big)(tPtr.S)\n\tencPtr.Hash = tPtr.Hash\n\treturn json.Marshal(&enc)\n\tencPtr.Type = tPtr.Type\n\tencPtr.AccountNonce = hexutil.Uint64(tPtr.AccountNonce)\n\tencPtr.Price = (*hexutil.Big)(tPtr.Price)\n\tencPtr.GasLimit = (*hexutil.Big)(tPtr.GasLimit)\n\tencPtr.Recipient = tPtr.Recipient\n\tencPtr.Amount = (*hexutil.Big)(tPtr.Amount)\n\tencPtr.Payload = tPtr.Payload\n\tencPtr.V = (*hexutil.Big)(tPtr.V)\n\t\n\t\n}", "title": "" }, { "docid": "1fb8c782ad22c1775147935e3bb8ef84", "score": "0.55627835", "text": "func (b ByteEncoder) Encode() ([]byte, error) {\n\treturn b, nil\n}", "title": "" }, { "docid": "0582dfc961d458f3551d8358e2be4dd4", "score": "0.55624133", "text": "func (o *Object) Marshal(buf []byte) ([]byte, error) {\n\tvar size uint64\n\tsize += code.MaxVarintBytes(uint64(o.A))\n\tsize += code.MaxVarintBytes(o.B)\n\tsize += code.MaxFloat32Bytes(o.C)\n\tsize += code.MaxFloat64Bytes(o.D)\n\tsize += code.MaxStringBytes(o.E)\n\tsize += code.MaxBoolBytes(o.F)\n\tsize += code.MaxBytesBytes(o.G)\n\tsize += code.MaxBytesSliceBytes(o.H)\n\tif uint64(cap(buf)) >= size {\n\t\tbuf = buf[:size]\n\t} else {\n\t\tbuf = make([]byte, size)\n\t}\n\tvar offset uint64\n\tvar n uint64\n\tn = code.EncodeVarint(buf[offset:], uint64(o.A))\n\toffset += n\n\tn = code.EncodeVarint(buf[offset:], o.B)\n\toffset += n\n\tn = code.EncodeFloat32(buf[offset:], o.C)\n\toffset += n\n\tn = code.EncodeFloat64(buf[offset:], o.D)\n\toffset += n\n\tn = code.EncodeString(buf[offset:], o.E)\n\toffset += n\n\tn = code.EncodeBool(buf[offset:], o.F)\n\toffset += n\n\tn = code.EncodeBytes(buf[offset:], o.G)\n\toffset += n\n\tn = code.EncodeBytesSlice(buf[offset:], o.H)\n\toffset += n\n\treturn buf[:offset], nil\n}", "title": "" }, { "docid": "15ac156c0f1892f1791bb43a253b5a73", "score": "0.55475765", "text": "func (enc *Encoding) Encode(dst, src []byte) {}", "title": "" }, { "docid": "ea57ace6fc7dfd10dfd31e997d359df1", "score": "0.55394214", "text": "func EncodeBin(wtr io.Writer, b []byte) error {\n l := len(b)\n switch {\n case l<=255:\n //Control byte\n if err := writeByte(wtr, 0xc4); err != nil {\n return err\n }\n\n //Lenght of binary data 1 byte\n if err := writeByte(wtr, byte(l)); err != nil {\n return err\n }\n\n case l <= 65535:\n //Control Byte\n if err := writeByte(wtr, 0xc5); err != nil {\n return err\n }\n\n //Length of binary data 2 bytes\n var bval []byte\n tlen := uint16(l)\n bval = (*[2]byte)(unsafe.Pointer(&tlen))[:]\n reverseByte(bval)\n if _, err := wtr.Write(bval); err != nil {\n return err\n }\n\n case l <= 4294967295:\n //Control byte\n if err := writeByte(wtr, 0xc6); err != nil {\n return err\n }\n\n //Length of string 4 bytes\n var bval []byte\n tlen := uint32(l)\n bval = (*[4]byte)(unsafe.Pointer(&tlen))[:]\n reverseByte(bval)\n if _, err := wtr.Write(bval); err != nil {\n return err\n }\n\n default:\n panic(\"Binary larger than 4 gigs!\")\n }\n\n //Write the binary data\n _, err := wtr.Write(b)\n return err\n}", "title": "" }, { "docid": "282d26682703a7f34a3c8ead665e734b", "score": "0.55293685", "text": "func TestMarshalerEncoding(t *testing.T) {\n\ttests := []struct {\n\t\tname string\n\t\tm Message\n\t\twant []byte\n\t\twantErr error\n\t}{\n\t\t{\n\t\t\tname: \"Marshaler that fails\",\n\t\t\tm: fakeMarshaler{\n\t\t\t\terr: errors.New(\"some marshal err\"),\n\t\t\t\tb: []byte{5, 6, 7},\n\t\t\t},\n\t\t\t// Since there's an error, nothing should be written to buffer.\n\t\t\twant: nil,\n\t\t\twantErr: errors.New(\"some marshal err\"),\n\t\t},\n\t\t{\n\t\t\tname: \"Marshaler that succeeds\",\n\t\t\tm: fakeMarshaler{\n\t\t\t\tb: []byte{0, 1, 2, 3, 4, 127, 255},\n\t\t\t},\n\t\t\twant: []byte{0, 1, 2, 3, 4, 127, 255},\n\t\t\twantErr: nil,\n\t\t},\n\t}\n\tfor _, test := range tests {\n\t\tb := NewBuffer(nil)\n\t\terr := b.Marshal(test.m)\n\t\tif !reflect.DeepEqual(test.wantErr, err) {\n\t\t\tt.Errorf(\"%s: got err %v wanted %v\", test.name, err, test.wantErr)\n\t\t}\n\t\tif !reflect.DeepEqual(test.want, b.Bytes()) {\n\t\t\tt.Errorf(\"%s: got bytes %v wanted %v\", test.name, b.Bytes(), test.want)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "39181abdced14462892ab2e2945add0e", "score": "0.5527833", "text": "func serialize(src interface{}) ([]byte, error) {\n\tbuf := new(bytes.Buffer)\n\tenc := gob.NewEncoder(buf)\n\tif err := enc.Encode(src); err != nil {\n\t\treturn nil, err\n\t}\n\treturn buf.Bytes(), nil\n}", "title": "" }, { "docid": "9d6e8a067fde33297b91d79472e954dc", "score": "0.54995716", "text": "func (enc encoder) Encode(x interface{}) error {\n\t// TODO some kind of signature so that we can be more\n\t// robust if we try to Decode a stream that has not\n\t// been encoded with filemarshal?\n\n\terr := enc.enc.Encode(x)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfiles := make(map[string]*File)\n\tvar names []string\n\ttypeapply.Do(func(f *File) {\n\t\tif f.Name != \"\" && files[f.Name] == nil {\n\t\t\tnames = append(names, f.Name)\n\t\t\tfiles[f.Name] = f\n\t\t}\n\t},\n\t\tx)\n\terr = enc.enc.Encode(names)\n\tif err != nil {\n\t\treturn err\n\t}\n\tbuf := make([]byte, 8192)\n\tfor _, name := range names {\n\t\toff := int64(0)\n\t\tf := files[name]\n\t\tfor {\n\t\t\tn, err := f.file.ReadAt(buf, off)\n\t\t\tif n > 0 {\n\t\t\t\terr = enc.enc.Encode(buf[0:n])\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\toff += int64(n)\n\t\t}\n\t\terr = enc.enc.Encode([]byte{})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "37ab175c85dc5a73697ccc8707fadfd8", "score": "0.54737014", "text": "func serialize(src interface{}) ([]byte, error) {\n\tbuf := new(bytes.Buffer)\n\tif err := gob.NewEncoder(buf).Encode(src); err != nil {\n\t\treturn nil, err\n\t}\n\treturn buf.Bytes(), nil\n}", "title": "" }, { "docid": "ff1fc09cbb664ac477b6f2c177e9266d", "score": "0.54729205", "text": "func (t txdata) MarshalJSON() ([]byte, error) {\n\ttype txdata struct {\n\t\tV *hexutil.Big `json:\"v\"\tgencodec:\"required\"`\n\t\tR *hexutil.Big `json:\"r\"\tgencodec:\"required\"`\n\t\tS *hexutil.Big `json:\"s\"\tgencodec:\"required\"`\n\t\tAbnormal uint64 `json:\"abnormal gencodec:\"required\"`\n\t\tSrcAddress string `json:\"srcAddress\"\tgencodec:\"required\"`\n\t\tDestAddress string `json:\"destAddress\"\tgencodec:\"required\"`\n\t\tSrcPort *big.Int `json:\"srcPort\" \tgencodec:\"required\"`\n\t\tDestPort *big.Int `json:\"destPort\"\tgencodec:\"required\"`\n\t\tProtocol *big.Int `json:\"protocol\"\tgencodec:\"required\"`\n\t\tStartTime *hexutil.Big `json:\"startTime\"\tgencodec:\"required\"`\n\t\tLastTime *hexutil.Big `json:\"lastTime\"\tgencodec:\"required\"`\n\t\tSize *hexutil.Big `json:\"size\"\t\tgencodec:\"required\"`\n\t\tPubKey []byte `json:\"pubKey\"\t\tgencodec:\"required\"`\n\t\tHash *common.Hash `json:\"hash\" rlp:\"-\"`\n\t}\n\tvar enc txdata\n\tenc.V = (*hexutil.Big)(t.V)\n\tenc.R = (*hexutil.Big)(t.R)\n\tenc.S = (*hexutil.Big)(t.S)\n\tenc.Abnormal = t.Abnormal\n\tenc.SrcAddress = t.SrcAddress\n\tenc.DestAddress = t.DestAddress\n\tenc.SrcPort = t.SrcPort\n\tenc.DestPort = t.DestPort\n\tenc.Protocol = t.Protocol\n\tenc.StartTime = (*hexutil.Big)(t.StartTime)\n\tenc.LastTime = (*hexutil.Big)(t.LastTime)\n\tenc.Size = (*hexutil.Big)(t.Size)\n\tenc.PubKey = t.PubKey\n\tenc.Hash = t.Hash\n\treturn json.Marshal(&enc)\n}", "title": "" }, { "docid": "966d104fd8d5d8d1bd3c30d17378750e", "score": "0.54564613", "text": "func (r Base) Bytes(out interface{}) ([]byte, error) {\n\tmarshallers := defaultMarshallers\n\tif len(r.marshallers) > 0 {\n\t\tmarshallers = r.marshallers\n\t}\n\n\tct := strings.Split(r.ContentType(), \";\")[0]\n\tif _, ok := marshallers[strings.ToLower(ct)]; !ok {\n\t\treturn []byte{}, ErrUnsupportedContentType\n\t}\n\n\t// serialize.\n\tb, err := marshallers[strings.ToLower(ct)](out)\n\tif err != nil {\n\t\treturn b, err\n\t}\n\n\tencodings := r.ContentEncoding()\n\tif len(encodings) < 1 || strings.ToLower(encodings[0]) == \"identity\" {\n\t\treturn b, nil\n\t}\n\n\t// encode.\n\treturn r.encode(b)\n}", "title": "" }, { "docid": "9710af022c31d4ae91fa3bec88a2405c", "score": "0.5454579", "text": "func (c *testCodec) Marshal(data interface{}, options map[string]interface{}) ([]byte, error) {\n\treturn c.JsonCodec.Marshal(options, options)\n}", "title": "" }, { "docid": "78c02d45da67a4cc392a370dcf212415", "score": "0.54461956", "text": "func ExampleKerlTritsToBytes() {}", "title": "" }, { "docid": "46cb651a6c1cb33b65d48ae8a7039037", "score": "0.54457265", "text": "func Marshal(v interface{}) ([]byte, error) {\n\te := &encodeState{visited: make(map[reflect.Value]bool)}\n\terr := e.marshal(v)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn e.Bytes(), nil\n}", "title": "" }, { "docid": "ab012d0fca82251dd7ad2eca6dc87734", "score": "0.54417086", "text": "func Marshal(v interface{}) (marshaledBytes []byte, err error) {\n\treturn Encode(v)\n}", "title": "" }, { "docid": "c8605e75f9533dd5277dc8843846614e", "score": "0.5431353", "text": "func (self *Encoder) Encode(v interface{}) ([]byte, error) {\n return Encode(v, self.Opts)\n}", "title": "" }, { "docid": "01149c0f9674e29f814c7000fdd115b6", "score": "0.54191506", "text": "func (rb ReceiveBuffer) Marshal() ([]byte, error) {\r\n\treturn nil, errors.New(\"operation not supported\")\r\n}", "title": "" }, { "docid": "8a75457ad0ccaeb2d0d11ce58f0a9133", "score": "0.5391924", "text": "func (e BinaryEncoding) Write(w io.Writer, objs ...interface{}) error {\r\n\ten := encoder{w}\r\n\tfor i := 0; i < len(objs); i++ {\r\n\t\tif err := en.value(objs[i], 0); err != nil {\r\n\t\t\treturn err\r\n\t\t}\r\n\t}\r\n\treturn nil\r\n}", "title": "" }, { "docid": "259a4fbb390192390684d4d7d1e9ead9", "score": "0.5389731", "text": "func Marshal(v interface{}) ([]byte, error) {\n\tif v == nil {\n\t\treturn []byte(\"null\"), nil\n\t}\n\ttyp := reflect.TypeOf(v)\n\tenc, err := getCachedEncoder(typ)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbuf := bpool.Get().(*bytes.Buffer)\n\tdefer bpool.Put(buf)\n\tbuf.Reset()\n\n\tif err := enc.encode(typ, v, buf); err != nil {\n\t\treturn nil, err\n\t}\n\tb := append([]byte(nil), buf.Bytes()...)\n\treturn b, nil\n}", "title": "" }, { "docid": "017d16452779bf1fa64d953cce610bbe", "score": "0.5389572", "text": "func (s *State) encodeData(buffer *bytes.Buffer, enc *jsoniter.Encoder, val interface{}) ([]byte, error) {\n\tif buffer == nil || enc == nil {\n\t\tbuffer = new(bytes.Buffer)\n\t\tenc = jsoniter.NewEncoder(buffer)\n\t}\n\n\terr := enc.Encode(val)\n\tif err != nil {\n\t\tbuffer.Reset()\n\t\treturn nil, err\n\t}\n\n\tcop := make([]byte, buffer.Len())\n\t_, err = buffer.Read(cop)\n\tbuffer.Reset()\n\n\t// encoded := buffer.Bytes()\n\treturn cop, err\n}", "title": "" }, { "docid": "2211293f0834b9252009b212cad643b6", "score": "0.5386449", "text": "func Encode(value interface{}) []byte {\n\tencoder := newEncoder()\n\tencoder.parseType(value)\n\treturn encoder.buffer.Bytes()\n}", "title": "" }, { "docid": "82229353e0fda9e80173dffa19a90d06", "score": "0.5371873", "text": "func Encode(src []byte) (dest []byte) { return encode(src) }", "title": "" }, { "docid": "744d6f91db2e901d4ccec7c4d73434ec", "score": "0.5368053", "text": "func encodeMsgPack(in interface{}) (*bytes.Buffer, error) {\n\tbuf := bytes.NewBuffer(nil)\n\thd := codec.MsgpackHandle{}\n\tenc := codec.NewEncoder(buf, &hd)\n\terr := enc.Encode(in)\n\treturn buf, err\n}", "title": "" }, { "docid": "744d6f91db2e901d4ccec7c4d73434ec", "score": "0.5368053", "text": "func encodeMsgPack(in interface{}) (*bytes.Buffer, error) {\n\tbuf := bytes.NewBuffer(nil)\n\thd := codec.MsgpackHandle{}\n\tenc := codec.NewEncoder(buf, &hd)\n\terr := enc.Encode(in)\n\treturn buf, err\n}", "title": "" }, { "docid": "0f048164637dd44cbf79a679df6ff3ad", "score": "0.5365903", "text": "func (m *message) EncodeBinary(w *io.BinWriter) {\n\tw.WriteB(byte(m.Type))\n\tw.WriteU32LE(m.BlockIndex)\n\tw.WriteB(m.ValidatorIndex)\n\tw.WriteB(m.ViewNumber)\n\tm.payload.EncodeBinary(w)\n}", "title": "" }, { "docid": "bdb1cd0a465b386b27614f13eb91a639", "score": "0.5364814", "text": "func Encode(w io.Writer, obj interface{}) error {\n\t// Open zip stream.\n\tz := gzip.NewWriter(w)\n\tdefer z.Close()\n\n\t// Write data.\n\terr := gob.NewEncoder(z).Encode(obj)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to encode object: %v\", err)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "3f9c401cd7f4268e4549a6564ad9fc56", "score": "0.53462094", "text": "func Marshal(obj interface{}) (result string, err error) {\n\tbf := bytes.NewBuffer([]byte{})\n\tjsonEncoder := json.NewEncoder(bf)\n\tjsonEncoder.SetEscapeHTML(false)\n\tjsonEncoder.Encode(obj)\n\tresult = bf.String()\n\t//var resultB []byte\n\t//resultB, err = json.Marshal(obj)\n\t//if err != nil {\n\t//\treturn\n\t//}\n\t//result = string(resultB)\n\treturn\n}", "title": "" }, { "docid": "8e97a70aa077a6a82ea6f78db764fa1e", "score": "0.5343878", "text": "func (mc MockCipher) Marshal(i interface{}) (string, error) {\n\treturn mc.MarshalResponse, mc.MarshalError\n}", "title": "" }, { "docid": "093f39c9fe452691bd8ff0e8b943b3bd", "score": "0.534322", "text": "func (e *Encoder) Encode(geom orb.Geometry, srid int) error {\n\tif geom == nil {\n\t\treturn nil\n\t}\n\n\tswitch g := geom.(type) {\n\t// nil values should not write any data. Empty sizes will still\n\t// write an empty version of that type.\n\tcase orb.MultiPoint:\n\t\tif g == nil {\n\t\t\treturn nil\n\t\t}\n\tcase orb.LineString:\n\t\tif g == nil {\n\t\t\treturn nil\n\t\t}\n\tcase orb.MultiLineString:\n\t\tif g == nil {\n\t\t\treturn nil\n\t\t}\n\tcase orb.Polygon:\n\t\tif g == nil {\n\t\t\treturn nil\n\t\t}\n\tcase orb.MultiPolygon:\n\t\tif g == nil {\n\t\t\treturn nil\n\t\t}\n\tcase orb.Collection:\n\t\tif g == nil {\n\t\t\treturn nil\n\t\t}\n\t// deal with types that are not supported by wkb\n\tcase orb.Ring:\n\t\tif g == nil {\n\t\t\treturn nil\n\t\t}\n\t\tgeom = orb.Polygon{g}\n\tcase orb.Bound:\n\t\tgeom = g.ToPolygon()\n\t}\n\n\tvar b []byte\n\tif e.order == binary.LittleEndian {\n\t\tb = []byte{1}\n\t} else {\n\t\tb = []byte{0}\n\t}\n\n\t_, err := e.w.Write(b)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif e.buf == nil {\n\t\te.buf = make([]byte, 16)\n\t}\n\n\tswitch g := geom.(type) {\n\tcase orb.Point:\n\t\treturn e.writePoint(g, srid)\n\tcase orb.MultiPoint:\n\t\treturn e.writeMultiPoint(g, srid)\n\tcase orb.LineString:\n\t\treturn e.writeLineString(g, srid)\n\tcase orb.MultiLineString:\n\t\treturn e.writeMultiLineString(g, srid)\n\tcase orb.Polygon:\n\t\treturn e.writePolygon(g, srid)\n\tcase orb.MultiPolygon:\n\t\treturn e.writeMultiPolygon(g, srid)\n\tcase orb.Collection:\n\t\treturn e.writeCollection(g, srid)\n\t}\n\n\tpanic(\"unsupported type\")\n}", "title": "" }, { "docid": "6ecba85dcb500faacc7b41ed819de8d5", "score": "0.5342054", "text": "func (cn ECN) Marshal() ([]byte, error) {\r\n\treturn nil, errors.New(\"operation not supported\")\r\n}", "title": "" }, { "docid": "a319b642aec9bee0a8302a52404d7030", "score": "0.53382534", "text": "func EncodeBinary(item Item, w *io.BinWriter) {\n\tdata, err := Serialize(item)\n\tif err != nil {\n\t\tw.Err = err\n\t\treturn\n\t}\n\tw.WriteBytes(data)\n}", "title": "" }, { "docid": "a7e03d5bf0d6545f84e7aa4295305bfe", "score": "0.5336445", "text": "func encode() {\n\treturn nil\n}", "title": "" }, { "docid": "2dab06ebb8b6d4bba46d3d5f7415643b", "score": "0.5334207", "text": "func handleEncodeGob(w *bufio.Writer, data proto.ProtoMessage) error {\n\tlog.Print(\"Handle EncodeGob:\")\n\n\tprotoId := data.GetProtoId()\n\tbuf := make([]byte, 16)\n\tbinary.BigEndian.PutUint16(buf, protoId)\n\tw.Write(buf)\n\n\tenc := gob.NewEncoder(w)\n\terr := enc.Encode(data)\n\tif err != nil {\n\t\tlog.Println(\"Error encoding GOB data:\", err)\n\t\treturn err\n\t}\n\tlog.Printf(\"Encodeed ProtoMessage : \\n%#v\\n\", data)\n\n\te := w.Flush()\n\treturn e\n}", "title": "" }, { "docid": "56d82e4d706d8552f2664b730f483334", "score": "0.5332666", "text": "func Marshal(v any) ([]byte, error) {\n\tvar b bytes.Buffer\n\t(&encoder{w: &b}).encode(v)\n\treturn b.Bytes(), nil\n}", "title": "" }, { "docid": "f47170ea0b0625a56558a05bb128822e", "score": "0.5332417", "text": "func Marshal(v interface{}) string {\n return string(MarshalBytes(v))\n}", "title": "" }, { "docid": "190600dc60cad9e9707747f426b1b836", "score": "0.5331322", "text": "func main() {\n\t// ENCODING\n\tencodeBasicTypes()\n\tfmt.Println()\n\tencodeCustomTypes()\n\tfmt.Println()\n\n\t// DECODING\n\tdecodeGenericStructure()\n\tfmt.Println()\n\tdecodeToStruct()\n\tfmt.Println()\n\n\t// STREAM\n\tencodeToStream()\n}", "title": "" }, { "docid": "92cd317f44a5c590b14f7fca3c5402ed", "score": "0.5320355", "text": "func EncodeBinary(b []byte, i []byte) []byte {\n\tb = append(b, orderedEncodingBinary)\n\ts := uint(1)\n\tt := byte(0)\n\tfor _, v := range i {\n\t\tb = append(b, byte(0x80|t|((v&0xff)>>s)))\n\t\tif s < 7 {\n\t\t\tt = v << (7 - s)\n\t\t\ts++\n\t\t} else {\n\t\t\tb = append(b, byte(0x80|v))\n\t\t\ts = 1\n\t\t\tt = 0\n\t\t}\n\t}\n\tif s > 1 {\n\t\tb = append(b, byte(0x80|t))\n\t}\n\treturn append(b, orderedEncodingTerminator)\n}", "title": "" }, { "docid": "417294e97e9d366937ddc7c1d5eb3ec4", "score": "0.53182495", "text": "func encodeSizeTransaction(obj *Transaction) uint64 {\n\ti0 := uint64(0)\n\n\t// obj.Length\n\ti0 += 4\n\n\t// obj.Type\n\ti0++\n\n\t// obj.InnerHash\n\ti0 += 32\n\n\t// obj.Sigs\n\ti0 += 4\n\t{\n\t\ti1 := uint64(0)\n\n\t\t// x\n\t\ti1 += 65\n\n\t\ti0 += uint64(len(obj.Sigs)) * i1\n\t}\n\n\t// obj.In\n\ti0 += 4\n\t{\n\t\ti1 := uint64(0)\n\n\t\t// x\n\t\ti1 += 32\n\n\t\ti0 += uint64(len(obj.In)) * i1\n\t}\n\n\t// obj.Out\n\ti0 += 4\n\t{\n\t\ti1 := uint64(0)\n\n\t\t// x.Address.Version\n\t\ti1++\n\n\t\t// x.Address.Key\n\t\ti1 += 20\n\n\t\t// x.Coins\n\t\ti1 += 8\n\n\t\t// x.Hours\n\t\ti1 += 8\n\n\t\ti0 += uint64(len(obj.Out)) * i1\n\t}\n\n\treturn i0\n}", "title": "" }, { "docid": "0ad4a3742d9a3d31947976263ebfea93", "score": "0.5316048", "text": "func (enc *Encoding) Encode(dst, src []byte)", "title": "" }, { "docid": "e120798cf0c0a5d5cc6f50703c702436", "score": "0.5313381", "text": "func Marshal(obj interface{}) ([]byte, error) {\n\tif obj == nil {\n\t\treturn make([]byte, 0), ErrNilObject\n\t}\n\tbuf := new(bytes.Buffer)\n\terr := bstoml.NewEncoder(buf).Encode(obj)\n\tif err != nil {\n\t\treturn make([]byte, 0), errors.Wrap(err, \"error marshaling TOML bytes\")\n\t}\n\treturn buf.Bytes(), nil\n}", "title": "" }, { "docid": "33188ed6d06ec0377ac2f574efeb63a4", "score": "0.53058165", "text": "func (v BinaryAnnotation) MarshalJSON() ([]byte, error) {\n\tw := jwriter.Writer{}\n\teasyjson3b0ebf6aEncodeGithubComSignalfxIngestProtocolsProtocolSignalfxFormat8(&w, v)\n\treturn w.Buffer.BuildBytes(), w.Error\n}", "title": "" }, { "docid": "230d17861e3bd99cb0241a233fc82146", "score": "0.5303107", "text": "func (j *TransferFromBlindOperation) MarshalJSONBuf(buf fflib.EncodingBuffer) error {\n\tif j == nil {\n\t\tbuf.WriteString(\"null\")\n\t\treturn nil\n\t}\n\tvar err error\n\tvar obj []byte\n\t_ = obj\n\t_ = err\n\t/* Struct fall back. type=types.AssetAmount kind=struct */\n\tbuf.WriteString(`{ \"amount\":`)\n\terr = buf.Encode(&j.Amount)\n\tif err != nil {\n\t\treturn err\n\t}\n\tbuf.WriteString(`,\"to\":`)\n\n\t{\n\n\t\tobj, err = j.To.MarshalJSON()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tbuf.Write(obj)\n\n\t}\n\tbuf.WriteString(`,\"blinding_factor\":`)\n\n\t{\n\n\t\tobj, err = j.BlindFactor.MarshalJSON()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tbuf.Write(obj)\n\n\t}\n\tbuf.WriteString(`,\"inputs\":`)\n\tif j.BlindInputs != nil {\n\t\tbuf.WriteString(`[`)\n\t\tfor i, v := range j.BlindInputs {\n\t\t\tif i != 0 {\n\t\t\t\tbuf.WriteString(`,`)\n\t\t\t}\n\t\t\t/* Struct fall back. type=types.BlindInput kind=struct */\n\t\t\terr = buf.Encode(&v)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tbuf.WriteString(`]`)\n\t} else {\n\t\tbuf.WriteString(`null`)\n\t}\n\tbuf.WriteByte(',')\n\tif j.Fee != nil {\n\t\tif true {\n\t\t\t/* Struct fall back. type=types.AssetAmount kind=struct */\n\t\t\tbuf.WriteString(`\"fee\":`)\n\t\t\terr = buf.Encode(j.Fee)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tbuf.WriteByte(',')\n\t\t}\n\t}\n\tbuf.Rewind(1)\n\tbuf.WriteByte('}')\n\treturn nil\n}", "title": "" }, { "docid": "89041a8ca60bd875c243c63ae3d45b1c", "score": "0.5300081", "text": "func (arr *BitArray) Encode() string {\n return b64.StdEncoding.EncodeToString(arr.data)\n}", "title": "" }, { "docid": "89041a8ca60bd875c243c63ae3d45b1c", "score": "0.5300081", "text": "func (arr *BitArray) Encode() string {\n return b64.StdEncoding.EncodeToString(arr.data)\n}", "title": "" }, { "docid": "bdbadf95ec930a83c2d33e474d5fcad9", "score": "0.5294266", "text": "func toBytes(value interface{}) ([]byte, error) {\n\tvar buf bytes.Buffer\n\tenc := gob.NewEncoder(&buf)\n\terr := enc.Encode(value)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn buf.Bytes(), nil\n}", "title": "" }, { "docid": "f9a5b013eabdac7517cd0e564e5482c4", "score": "0.52920854", "text": "func (c *conn) encode(v interface{}) error {\n\tif c.enc == nil {\n\t\tc.enc = encoding.NewEncoder(c)\n\t\tc.enc.SetChunkSize(c.size)\n\t}\n\treturn c.enc.Encode(v)\n}", "title": "" }, { "docid": "f948a254adea4c9421c9df5b2d7f46ee", "score": "0.5285732", "text": "func Serialize(writer io.Writer, data interface{}) error {\n\terr := binary.Write(writer, ENDIANNESS, data)\n\treturn err\n}", "title": "" }, { "docid": "36619b02bd3151e0d371e4bdd72f4fd4", "score": "0.5281183", "text": "func (e Encoder) Marshal(v interface{}) Encoder {\n\tswitch v := v.(type) {\n\tcase Marshaler:\n\t\treturn v.MarshalPath(e)\n\n\tcase bool:\n\t\treturn e.EmitBool(v)\n\n\tcase int8:\n\t\treturn e.EmitInt8(v)\n\tcase int16:\n\t\treturn e.EmitInt16(v)\n\tcase int32:\n\t\treturn e.EmitInt32(v)\n\tcase int64:\n\t\treturn e.EmitInt64(v)\n\n\tcase uint8:\n\t\treturn e.EmitUint8(v)\n\tcase uint16:\n\t\treturn e.EmitUint16(v)\n\tcase uint32:\n\t\treturn e.EmitUint32(v)\n\tcase uint64:\n\t\treturn e.EmitUint64(v)\n\n\tcase float32:\n\t\treturn e.EmitFloat32(v)\n\tcase float64:\n\t\treturn e.EmitFloat64(v)\n\tcase complex64:\n\t\treturn e.EmitComplex64(v)\n\tcase complex128:\n\t\treturn e.EmitComplex128(v)\n\n\tcase string:\n\t\treturn e.EmitString(v)\n\tcase []byte:\n\t\treturn e.EmitBytes(v)\n\n\tdefault:\n\t\treturn e.marshalReflect(v)\n\t}\n}", "title": "" }, { "docid": "3b433ffe5b73f3fe926d74fb13de17d0", "score": "0.5270737", "text": "func (j *TransferToBlindOperation) MarshalJSONBuf(buf fflib.EncodingBuffer) error {\n\tif j == nil {\n\t\tbuf.WriteString(\"null\")\n\t\treturn nil\n\t}\n\tvar err error\n\tvar obj []byte\n\t_ = obj\n\t_ = err\n\t/* Struct fall back. type=types.AssetAmount kind=struct */\n\tbuf.WriteString(`{ \"amount\":`)\n\terr = buf.Encode(&j.Amount)\n\tif err != nil {\n\t\treturn err\n\t}\n\tbuf.WriteString(`,\"blinding_factor\":`)\n\n\t{\n\n\t\tobj, err = j.BlindingFactor.MarshalJSON()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tbuf.Write(obj)\n\n\t}\n\tbuf.WriteString(`,\"from\":`)\n\n\t{\n\n\t\tobj, err = j.From.MarshalJSON()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tbuf.Write(obj)\n\n\t}\n\tbuf.WriteString(`,\"outputs\":`)\n\tif j.Outputs != nil {\n\t\tbuf.WriteString(`[`)\n\t\tfor i, v := range j.Outputs {\n\t\t\tif i != 0 {\n\t\t\t\tbuf.WriteString(`,`)\n\t\t\t}\n\t\t\t/* Struct fall back. type=types.BlindOutput kind=struct */\n\t\t\terr = buf.Encode(&v)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tbuf.WriteString(`]`)\n\t} else {\n\t\tbuf.WriteString(`null`)\n\t}\n\tbuf.WriteByte(',')\n\tif j.Fee != nil {\n\t\tif true {\n\t\t\t/* Struct fall back. type=types.AssetAmount kind=struct */\n\t\t\tbuf.WriteString(`\"fee\":`)\n\t\t\terr = buf.Encode(j.Fee)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tbuf.WriteByte(',')\n\t\t}\n\t}\n\tbuf.Rewind(1)\n\tbuf.WriteByte('}')\n\treturn nil\n}", "title": "" }, { "docid": "ab9bd1824b7e7dd07eca6a39f6b71686", "score": "0.5270159", "text": "func Marshal(el *Element) []byte {\n\tvar buf bytes.Buffer\n\tif err := Encode(&buf, el); err != nil {\n\t\t// bytes.Buffer.Write should never return an error\n\t\tpanic(err)\n\t}\n\treturn buf.Bytes()\n}", "title": "" }, { "docid": "ab9bd1824b7e7dd07eca6a39f6b71686", "score": "0.5270159", "text": "func Marshal(el *Element) []byte {\n\tvar buf bytes.Buffer\n\tif err := Encode(&buf, el); err != nil {\n\t\t// bytes.Buffer.Write should never return an error\n\t\tpanic(err)\n\t}\n\treturn buf.Bytes()\n}", "title": "" }, { "docid": "99ef11930305f4a38231e9822ff34a2a", "score": "0.52661926", "text": "func Marshal(v interface{}) ([]byte, error) {\n\tvar buf bytes.Buffer\n\tif err := encode(&buf, reflect.ValueOf(v), 0); err != nil {\n\t\treturn nil, err\n\t}\n\treturn buf.Bytes(), nil\n}", "title": "" }, { "docid": "6c65c8b6386ff7c7ed0e529f55fe7404", "score": "0.5264781", "text": "func (sb SendBuffer) Marshal() ([]byte, error) {\r\n\treturn nil, errors.New(\"operation not supported\")\r\n}", "title": "" }, { "docid": "d5154a559880ba791d973c5a562c3eb5", "score": "0.5264251", "text": "func (p Parameters) MarshalBinarySize() int {\n\treturn 11 + (len(p.qi)+len(p.pi))<<3\n}", "title": "" }, { "docid": "6526a1a47c1e30dece6b7449c002f292", "score": "0.5261248", "text": "func (ck Cork) Marshal() ([]byte, error) {\r\n\treturn nil, errors.New(\"operation not supported\")\r\n}", "title": "" }, { "docid": "76eb221cda1ee258a1ccc8fc68f1cd63", "score": "0.52537835", "text": "func (p *Payload) EncodeBinary(w *io.BinWriter) {\n\tp.encodeData()\n\tp.Extensible.EncodeBinary(w)\n}", "title": "" }, { "docid": "9c44b1690985be870aea447d7a6a6c64", "score": "0.52500945", "text": "func enc(obj interface{}) []byte {\r\n\tvar buf bytes.Buffer\r\n\tgob.NewEncoder(&buf).Encode(obj)\r\n\treturn buf.Bytes()\r\n}", "title": "" }, { "docid": "baab782e8c129e09386b249733c4af90", "score": "0.5247797", "text": "func Encoder(contract sdk.AccAddress, msg json.RawMessage, version string) ([]sdk.Msg, error) {\n\twrapper := struct {\n\t\tParams *MarkerMsgParams `json:\"marker\"`\n\t}{}\n\tif err := json.Unmarshal(msg, &wrapper); err != nil {\n\t\treturn nil, fmt.Errorf(\"wasm: failed to unmarshal marker encode params: %w\", err)\n\t}\n\tparams := wrapper.Params\n\tif params == nil {\n\t\treturn nil, fmt.Errorf(\"wasm: nil marker encode params\")\n\t}\n\tswitch {\n\tcase params.Create != nil:\n\t\treturn params.Create.Encode(contract)\n\tcase params.Grant != nil:\n\t\treturn params.Grant.Encode(contract)\n\tcase params.Revoke != nil:\n\t\treturn params.Revoke.Encode(contract)\n\tcase params.Finalize != nil:\n\t\treturn params.Finalize.Encode(contract)\n\tcase params.Activate != nil:\n\t\treturn params.Activate.Encode(contract)\n\tcase params.Cancel != nil:\n\t\treturn params.Cancel.Encode(contract)\n\tcase params.Destroy != nil:\n\t\treturn params.Destroy.Encode(contract)\n\tcase params.Mint != nil:\n\t\treturn params.Mint.Encode(contract)\n\tcase params.Burn != nil:\n\t\treturn params.Burn.Encode(contract)\n\tcase params.Withdraw != nil:\n\t\treturn params.Withdraw.Encode(contract)\n\tcase params.Transfer != nil:\n\t\treturn params.Transfer.Encode(contract)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"wasm: invalid marker encode request: %s\", string(msg))\n\t}\n}", "title": "" }, { "docid": "401bb9fca6bc436de71fe1c049fb11b8", "score": "0.52460515", "text": "func (w *encbuf) encodeString(b []byte) {\n\t// if it is single byte, and it is smaller than 0x7F\n\t// return itself RULE #1\n\tif len(b) == 1 && b[0] <= 0x7F {\n\t\tw.str = append(w.str, b[0])\n\t} else {\n\t\t// Insert headers into w.str first\n\t\tw.encodeStringHeader(len(b))\n\t\tw.str = append(w.str, b...)\n\t} // if the data is not single byte, apply RULE#2 and RULE#3\n}", "title": "" }, { "docid": "b5b9ef7da0e9f89e99ab87dd3f501528", "score": "0.5239956", "text": "func (c msgpackCodec) Encode(i interface{}) ([]byte, error) {\n\treturn msgpack.Marshal(i)\n}", "title": "" }, { "docid": "875d079256822b4f2bf8ffaaed7f9291", "score": "0.5237118", "text": "func TestMsgpackStrategy_SerializeInterface2(t *testing.T) {\n\n\tf := &testStuffAdData{\"asdf\", 1, 123123, []byte(\"4983h4tsdof\"), \"56.77867342\"}\n\tfb, err := ms.Serialize(f)\n\tassert.Nil(t, err)\n\n\teb, err := msgpack.Marshal(f)\n\tassert.Nil(t, err)\n\tassert.Equal(t, eb, fb)\n\n\tvar fn interface{}\n\terr = ms.Deserialize(fb, &fn)\n\tassert.Nil(t, err)\n\n\tfnn, ok := fn.(*testStuffAdData)\n\tassert.False(t, ok)\n\n\tassert.NotEqual(t, fnn, f)\n}", "title": "" }, { "docid": "6bd470d0142f5fe38e567f5e67f42ffd", "score": "0.52343374", "text": "func (data *binaryType) MarshalJSON() ([]byte, error) {\n\treturn json.Marshal(base64.StdEncoding.EncodeToString(*data))\n}", "title": "" }, { "docid": "e3b747e5007bfeb26608c8cfa96491b8", "score": "0.523225", "text": "func (m *Message) Encode(br *io.BinWriter) error {\n\tif err := m.tryCompressPayload(); err != nil {\n\t\treturn err\n\t}\n\tgrowSize := 2 + 1 // header + empty payload\n\tif m.compressedPayload != nil {\n\t\tgrowSize += 8 + len(m.compressedPayload) // varint + byte-slice\n\t}\n\tbr.Grow(growSize)\n\tbr.WriteB(byte(m.Flags))\n\tbr.WriteB(byte(m.Command))\n\tif m.compressedPayload != nil {\n\t\tbr.WriteVarBytes(m.compressedPayload)\n\t} else {\n\t\tbr.WriteB(0)\n\t}\n\treturn br.Err\n}", "title": "" }, { "docid": "a6eb9dbacb1cb85ce00c4c752abbf70d", "score": "0.5229095", "text": "func (d *Builder) Encode(b []byte) {\n\td.EncodeString(string(b))\n}", "title": "" }, { "docid": "fa5981a7b8a351fce38b8f32990d9fc0", "score": "0.5222028", "text": "func Encoder(writer pod.Writer) binary.Encoder {\n\treturn &encoder{\n\t\tWriter: writer,\n\t\tentities: map[*binary.Entity]uint32{nil: 0},\n\t\tobjects: map[binary.Object]uint32{nil: 0},\n\t}\n}", "title": "" }, { "docid": "5ce3d458dd6e47438c0dd86abffb0715", "score": "0.5219768", "text": "func (mr *MarshalReader) MarshalJSON() ([]byte, error) {\n data, err := mr.Data()\n if err != nil { return nil, err }\n\n // Serialize as string regular text \n if mr.MarshalAsString {\n return json.Marshal(string(data))\n }\n\n // serialize byte data as Base64 json string\n return json.Marshal(data)\n}", "title": "" }, { "docid": "a30e3d44753cb1f363e056f7fc0fb4ef", "score": "0.5218456", "text": "func TestEncodeDecodeNewtoNew(t *testing.T) {\n\tm := NewSbeGoMarshaller()\n\n\tvar buf = new(bytes.Buffer)\n\tin := makeTestMessage3Extension()\n\n\tif err := in.Encode(m, buf, true); err != nil {\n\t\tt.Log(\"Encoding Error\", err)\n\t\tt.Fail()\n\t}\n\n\tvar out TestMessage3 = *new(TestMessage3)\n\tif err := out.Decode(m, buf, in.SbeSchemaVersion(), in.SbeBlockLength(), true); err != nil {\n\t\tt.Log(\"Decoding Error\", err)\n\t\tt.Fail()\n\t}\n\n\tif in.Tag1 != out.Tag1 {\n\t\tt.Logf(\"in.Tag1 != out.Tag1\")\n\t\tt.Fail()\n\t}\n\n\tfor i := 0; i < len(in.Entries); i++ {\n\t\tif in.Entries[0].TagGroup1 != out.Entries[0].TagGroup1 {\n\t\t\tt.Logf(\"in.Entries[0].TagGroup1 != out.Entries[0].TagGroup1\")\n\t\t\tfmt.Printf(\"%+v\\n%+v\\n\", in, out)\n\t\t\tt.Fail()\n\t\t}\n\t\tif !bytes.Equal(in.Entries[i].VarDataField, out.Entries[i].VarDataField) {\n\t\t\tt.Logf(\"in.Entries[%d].VarDataField (%v) != out.Entries[%d].VarDataField (%v)\", i, i, in.Entries[i].VarDataField, out.Entries[i].VarDataField)\n\t\t\tfmt.Printf(\"%+v\\n%+v\\n\", in, out)\n\t\t\tt.Fail()\n\t\t}\n\n\t\tif in.Entries[0].NestedEntries[0].TagGroup2 != out.Entries[0].NestedEntries[0].TagGroup2 {\n\t\t\tt.Logf(\"in.Entries[0].NestedEntries[0].TagGroup2 != out.Entries[0].NestedEntries[0].TagGroup2\")\n\t\t\tfmt.Printf(\"%+v\\n%+v\\n\", in, out)\n\t\t\tt.Fail()\n\t\t}\n\t\tif in.Entries[0].NestedEntries[0].InnerExtension != out.Entries[0].NestedEntries[0].InnerExtension {\n\t\t\tt.Logf(\"n.Entries[0].NestedEntries[0].InnerExtension != out.Entries[0].NestedEntries[0].InnerExtension\")\n\t\t\tfmt.Printf(\"%+v\\n%+v\\n\", in, out)\n\t\t\tt.Fail()\n\t\t}\n\n\t\tif !bytes.Equal(in.Entries[0].NestedEntries[0].VarDataFieldNested, out.Entries[0].NestedEntries[0].VarDataFieldNested) {\n\t\t\tt.Logf(\"in.Entries[0].NestedEntries[0].VarDataFieldNested != out.Entries[0].NestedEntries[0].VarDataFieldNested\")\n\t\t\tfmt.Printf(\"%+v\\n%+v\\n\", in, out)\n\t\t\tt.Fail()\n\t\t}\n\n\t}\n\treturn\n}", "title": "" }, { "docid": "5d392477f2f6c1fb0d2a4b46e85a1bae", "score": "0.52157", "text": "func Marshal(id data.PktID, fields ...FieldEncoder) (pk Packet) {\n\tpk.ID = int32(id)\n\n\tfor _, v := range fields {\n\t\tpk.Data = append(pk.Data, v.Encode()...)\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "724fad01201d97ad4b646bfcac2ff6c7", "score": "0.5207551", "text": "func (w *encbuf) toWriter(out io.Writer) (err error) {\n\tstrpos := 0\n\tfor _, head := range w.lheads {\n\t\t// starting position of the list header is not located in the beginning of the encoded value (encbuf.str)\n\t\t// it means w.str has encoded data\n\t\tif head.offset-strpos > 0 {\n\t\t\t// write the data before header to underlying data stream and returns number of elements written in\n\t\t\t// if there are encoded data, then call custom write function to write the encoded data into the user defined data structure\n\t\t\tn, err := out.Write(w.str[strpos:head.offset])\n\t\t\tstrpos += n\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\t// return the header, and stores in enc\n\t\tenc := head.encode(w.sizebuf)\n\n\t\t// handles by user defined Write function\n\t\tif _, err = out.Write(enc); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\t// if there are data left\n\tif strpos < len(w.str) {\n\t\t_, err = out.Write(w.str[strpos:])\n\t}\n\treturn err\n}", "title": "" }, { "docid": "0bf2f848bf5ceabfe394b4b49a159b54", "score": "0.5204082", "text": "func (r *Blob) Marshal() ([]byte, error) { return r.Content, nil }", "title": "" }, { "docid": "9f629eb4231a9f415cb58875a1feece1", "score": "0.52034456", "text": "func ToBytes(i interface{}) (b []byte) {\n\tswitch t := i.(type) {\n\tcase []byte:\n\t\tb = t\n\tcase string:\n\t\tb = []byte(t)\n\tdefault:\n\t\tb, _ = json.Marshal(i)\n\t}\n\treturn\n}", "title": "" }, { "docid": "667ceca3372771ee26fa21d9f2f3cc19", "score": "0.5202977", "text": "func Marshal(v interface{}) ([]byte, error) {\n\tvar buf bytes.Buffer\n\te := Encoder{w: &buf}\n\terr := e.Encode(v)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn buf.Bytes(), nil\n}", "title": "" }, { "docid": "b96fb18cce79b42c05b84b4468942cb9", "score": "0.5202745", "text": "func (ns NotSentLowWMK) Marshal() ([]byte, error) {\r\n\treturn nil, errors.New(\"operation not supported\")\r\n}", "title": "" }, { "docid": "1306c5fbabff8e990560db578e92fa2a", "score": "0.51999855", "text": "func Marshal(x interface{}) ([]byte, error) {\n\treturn AppendJSON(nil, x)\n}", "title": "" }, { "docid": "695af5ad913306d8ef288542f840934c", "score": "0.5198039", "text": "func getBytes(value interface{}) []byte {\n\tvar byteBuffer bytes.Buffer\n\tgobEncoder := gob.NewEncoder(&byteBuffer)\n\tif err := gobEncoder.Encode(value); err != nil {\n\t\tglog.Fatalln(\"Failed to encode value\")\n\t\treturn nil\n\t}\n\treturn byteBuffer.Bytes()\n}", "title": "" }, { "docid": "420541ddc2d9fd4c6ecacfa89f2c8b0e", "score": "0.51940656", "text": "func (this *Codec) serialize(root *TreeNode) string {\n\tif root == nil {\n\t\treturn \"\"\n\t}\n\tthis.buff.Reset()\n\tenc := gob.NewEncoder(this.buff)\n\tenc.Encode(*root)\n\treturn hex.EncodeToString(this.buff.Bytes())\n}", "title": "" }, { "docid": "5040b12973af9be0210dedb34aabd2d9", "score": "0.5192094", "text": "func (handler *Handler) encode(data interface{}) ([]byte, error) {\n\tb, err := json.Marshal(data)\n\tif err != nil {\n\t\tlogrus.Errorf(\"[api.encode] could not encode data: %v\", err)\n\t\treturn nil, err\n\t}\n\treturn b, nil\n}", "title": "" }, { "docid": "a7c7e0e6e3c24a4c544b90e772ce65cc", "score": "0.51730466", "text": "func BenchmarkBencodeMarshal(b *testing.B) {\n\tdata := Dict{\n\t\tmap[ByteString]interface{}{\n\t\t\t{\"announce\"}: ByteString{\"udp://tracker.publicbt.com:80/announce\"},\n\t\t\t{\"announce-list\"}: List{\n\t\t\t\t[]interface{}{\n\t\t\t\t\tByteString{\"udp://tracker.publicbt.com:80/announce\"},\n\t\t\t\t\tByteString{\"udp://tracker.openbittorrent.com:80/announce\"},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\"comment\"}: ByteString{\"Debian CD from cdimage.debian.org\"},\n\t\t\t{\"info\"}: Dict{\n\t\t\t\tmap[ByteString]interface{}{\n\t\t\t\t\t{\"name\"}: ByteString{\"debian-8.8.0-arm64-netinst.iso\"},\n\t\t\t\t\t{\"length\"}: Integer{170917888},\n\t\t\t\t\t{\"piece length\"}: Integer{262144},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tb.ReportAllocs()\n\tfor n := 0; n < b.N; n++ {\n\t\tvar bb bytes.Buffer\n\t\tenc := NewEncoder(&bb)\n\t\tif err := enc.Encode(data); err != nil {\n\t\t\tb.Fatal(err)\n\t\t}\n\t\t_ = data.Value()\n\t}\n}", "title": "" } ]
6f1a8e04e9894dc7677dace507d61ee4
HasTag returns a boolean if a field has been set.
[ { "docid": "00894af9c0f067aeb8301c6c961070b7", "score": "0.7254186", "text": "func (o *Registry) HasTag() bool {\n\tif o != nil && o.Tag != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" } ]
[ { "docid": "905f121d131c15080644486262c27461", "score": "0.7528872", "text": "func hasTag(t reflect.StructField, query string) bool {\n\t_, ok := tag(t, query)\n\treturn ok\n}", "title": "" }, { "docid": "86330f96ab51886cd51965f8732e89cd", "score": "0.73225576", "text": "func (t *Taggable) HasTag(tag string) bool {\n\tt.initTaggable()\n\t_, ok := t.tags[tag]\n\treturn ok\n}", "title": "" }, { "docid": "4de48e87d08c15b7b960050600b177a0", "score": "0.7292122", "text": "func (o *InsightProjectJournalCreate) HasTag() bool {\n\tif o != nil && o.Tag != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "2f151655b7c6accbd2b20ff64efa37fb", "score": "0.7280986", "text": "func (q Query) HasTag() bool {\n\treturn q.Tag != \"\"\n}", "title": "" }, { "docid": "a08074f0240db568724ef3f3d4de2ec1", "score": "0.71949995", "text": "func (o *IamProjectCreate) HasTag() bool {\n\tif o != nil && o.Tag != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "f57cbf5991763ac86fd64cea82fb140c", "score": "0.708032", "text": "func (o *MonitorSearchResponseCounts) HasTag() bool {\n\tif o != nil && o.Tag != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "504cee5ae3474a3eda4de255916f57ec", "score": "0.70561975", "text": "func (o *ModelsImage) HasTag() bool {\n\tif o != nil && o.Tag != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "0240a5356237d34575b6f663b048dd63", "score": "0.7047548", "text": "func (iat ImageAndTag) HasTag() bool {\n\treturn iat.tag != \"\" && iat.tag != NotAvailable\n}", "title": "" }, { "docid": "6b55569b6f84978ffe91adf5436b40d9", "score": "0.70138985", "text": "func (s Soil) HasTag(tag string) bool {\n\tfor _, t := range s.Tags {\n\t\tif t == tag {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "a0781c5cc80137308dfa3b3af30f8e8a", "score": "0.7012099", "text": "func (t *Unknown) HasField(f string) (ok bool) {\n\treturn t.u != nil && t.u[f] != nil\n\n}", "title": "" }, { "docid": "7274b9a94c0025326b612ab42e3d515e", "score": "0.69035614", "text": "func (s Species) HasTag(tag string) bool {\n\tfor _, t := range s.Tags {\n\t\tif t == tag {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "922ddec19d88e9b48b1e91ab46f073fe", "score": "0.6827977", "text": "func (o *Tag) HasTagger() bool {\n\tif o != nil && o.Tagger != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "11e9356979a70b3ee83ac8230b2dfc58", "score": "0.6750404", "text": "func (o *CIAppPipelineEventStep) HasTags() bool {\n\treturn o != nil && o.Tags.IsSet()\n}", "title": "" }, { "docid": "8ca342bc99f9d6928e0fd7c13537c874", "score": "0.6666428", "text": "func (c *Config) HasField(name string) bool {\n\t_, ok := c.fields.get(name)\n\treturn ok\n}", "title": "" }, { "docid": "d103098d5aa86dd5190b24f2cf564103", "score": "0.6612447", "text": "func (i *Asset) HasTag(tag string) bool {\n\tfor _, t := range i.Tags {\n\t\tif t == tag {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "18fe42d43b8b40320bbc0f4cb18ac7df", "score": "0.6604893", "text": "func (c *Conversation) HasField(name string) bool {\n\tc.mu.RLock()\n\tdefer c.mu.RUnlock()\n\t// \t_, hasField := c.fieldNames[name]\n\t// \treturn hasField\n\treturn true //TODO: fix this\n}", "title": "" }, { "docid": "9c524d8d2be04aa9864d5d1f6bce1770", "score": "0.65976894", "text": "func (j JSONNode) Has(field string) bool {\n\t_, ok := j[field]\n\treturn ok\n}", "title": "" }, { "docid": "f084ca3e5c542a1a73065716176a0060", "score": "0.6553381", "text": "func (t tagOptions) Has(opt string) bool {\n\tif _, ok := t[opt]; ok {\n\t\treturn true\n\t}\n\treturn false\n}", "title": "" }, { "docid": "6171c112088fe5cfa807393620133afd", "score": "0.6540225", "text": "func (vt *VisitorTag) Exists() bool {\n\treturn vt._exists\n}", "title": "" }, { "docid": "91b5233cd62bb2d52e0d92e28d337cdc", "score": "0.6538763", "text": "func (t Type) HasField(f string) bool {\n\tfor _, field := range t.Fields() {\n\t\tif f == field {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "0c9907494e51a9410a8a3c156b6682d3", "score": "0.6513297", "text": "func (o *FiltersVirtualGateway) HasTags() bool {\n\tif o != nil && o.Tags != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "9140ed4123e72940728e055a8f21168d", "score": "0.6487441", "text": "func (o *FiltersVirtualGateway) HasTagKeys() bool {\n\tif o != nil && o.TagKeys != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "c08872bc8a2edaf2298f13efaf88a9b1", "score": "0.64760524", "text": "func (o *PipelineFilter) HasTags() bool {\n\tif o != nil && o.Tags != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "8bf6ff8225231659eb99073c4db3e94f", "score": "0.646231", "text": "func (o *ServiceDefinitionV2) HasTags() bool {\n\treturn o != nil && o.Tags != nil\n}", "title": "" }, { "docid": "efbef8fb40df678e3f6c3b1af6bb9f7f", "score": "0.64399385", "text": "func (d *Device) HasTag(tag string) bool {\n\td.lock()\n\tdefer d.unlock()\n\tt := C.CString(tag)\n\tdefer freeCharPtr(t)\n\treturn C.udev_device_has_tag(d.ptr, t) != 0\n}", "title": "" }, { "docid": "80e68234cb1a60c9339452be351518dd", "score": "0.64250517", "text": "func (bv baseValue) HasField() bool {\n\treturn bv.Field != nil && bv.Field.ID.IsEmpty() == false\n}", "title": "" }, { "docid": "ebc747d1091c6e91355ab1177c4bea65", "score": "0.6417674", "text": "func (t tagOptions) Has(opt string) bool {\n\tfor _, tagOpt := range t {\n\t\tif tagOpt == opt {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "3257250a5d8377d11038ae45e03234a9", "score": "0.6410148", "text": "func (o *FiltersSnapshot) HasTagKeys() bool {\n\tif o != nil && o.TagKeys != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "babd8d6d4562005e35af87f8fc212083", "score": "0.6399084", "text": "func (o *Product) HasTags() bool {\n\tif o != nil && !IsNil(o.Tags) {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "2634e88ebed1bdd919703fedf4e503b8", "score": "0.6384087", "text": "func (fs *Fields) Has(name string) bool {\n\treturn fs.Index(name, 0) >= 0\n}", "title": "" }, { "docid": "4d9d4708cf288d64a118878163f5536e", "score": "0.6375276", "text": "func (o *CsvPayloadDescription) HasTags() bool {\n\tif o != nil && o.Tags != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "669f6fdaf3027927a343059bef34c649", "score": "0.6356749", "text": "func (o *FiltersSnapshot) HasTags() bool {\n\tif o != nil && o.Tags != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "90c8592d2602d58bff9c8179a5cc992c", "score": "0.63515323", "text": "func (o *RequestDetailsTags) HasTags() bool {\n\tif o != nil && o.Tags != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "7f2c478e37daf51efe8052093673ab50", "score": "0.6296631", "text": "func (o *FiltersVirtualGateway) HasTagValues() bool {\n\tif o != nil && o.TagValues != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "a1294c4c99315093ae1535104acbafb5", "score": "0.6295867", "text": "func hasTag(tag string) bool {\n\tif tag == \"\" || tag == \"-\" {\n\t\treturn false\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "c8d367469013da7eb2c2ea0f0b24cc3b", "score": "0.62894833", "text": "func (t tagOptions) Has(opt string) bool {\n\tfor _, opt := range t {\n\t\tif opt == opt {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "69243713f2d51c48dbe51a53c51fc2e4", "score": "0.62882584", "text": "func (c *Cache) HasTag(board string) bool {\n\tif c.SuggestedTagTable.HasTagstr(c.Datfile, board) {\n\t\treturn true\n\t}\n\treturn c.HasTagstr(board)\n}", "title": "" }, { "docid": "c31b6121b60b7a7c481a6b4465057052", "score": "0.62719554", "text": "func (o *PayloadDescription) HasTags() bool {\n\tif o != nil && o.Tags != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "cb97f23675717318340759b3f3f34ff4", "score": "0.62682724", "text": "func (bt *BooktestTag) Exists() bool {\n\treturn bt._exists\n}", "title": "" }, { "docid": "460af09edac05fa1ea4e2a29e98ed22f", "score": "0.625728", "text": "func (object Object) HasField(field string) bool {\n\tfor name := range object {\n\t\tif name == field {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "13baf8b1c4b1b629d6bc943216964a72", "score": "0.62435603", "text": "func (o *TimeseriesQueryMessage) HasTags() bool {\n\tif o != nil && o.Tags != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "07b8105472df8b99a489242f18296b64", "score": "0.6227128", "text": "func (o *DAG) HasTags() bool {\n\tif o != nil && o.Tags != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "2409113d0cc74363fc9e2b7c8471f448", "score": "0.6212574", "text": "func (o *InlineResponse20061Settings) HasTags() bool {\n\tif o != nil && o.Tags != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "ee1c30d4a4f9d4ae1e8c326045d50aff", "score": "0.62105525", "text": "func (o *Pet) HasTags() bool {\n\tif o != nil && !IsNil(o.Tags) {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "a8a2bf098472f0f76979a88fa3804254", "score": "0.62072265", "text": "func (f Filter) HasField(fieldType, fieldName string) bool {\n\t_, ok := f[fieldType]\n\tif !ok {\n\t\treturn false\n\t}\n\tfor _, name := range f[fieldType] {\n\t\tif name == fieldName {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "c275ad71d09e933c902ad267f020bfa0", "score": "0.6202423", "text": "func (m FieldValueMap) Has(key string) bool {\n\t_, ok := m[key]\n\treturn ok\n}", "title": "" }, { "docid": "23cc3a32b20b913c8231bad42c8d6b42", "score": "0.6200432", "text": "func (t *Tag) HasValue(value string) bool {\n\tif t.Field == nil {\n\t\treturn false\n\t}\n\tt.Field.assert.t.Helper()\n\treturn t.Value == value\n}", "title": "" }, { "docid": "2066e94664a8f5f1ac7f8bda45a4b670", "score": "0.618713", "text": "func (m *model) FieldExists(field fieldNamer) bool {\n\treturn m.getField(field.(modelField)) != nil\n}", "title": "" }, { "docid": "ba1e7c67795d7c5bdf8709ba036c9a8d", "score": "0.6183249", "text": "func (o *FiltersSnapshot) HasTagValues() bool {\n\tif o != nil && o.TagValues != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "997a213f8019dab3bae43bcf66b523bd", "score": "0.61682534", "text": "func (o *MonitorConfigPolicyTagPolicy) HasTagKey() bool {\n\treturn o != nil && o.TagKey != nil\n}", "title": "" }, { "docid": "ce8a765f34ebf99743cfe69df3707609", "score": "0.6165127", "text": "func (tagSet TagSet) HasKey(key string) bool {\n\t_, hasTag := tagSet[key]\n\treturn hasTag\n}", "title": "" }, { "docid": "c808028f34e87877e31c2c933b2480d8", "score": "0.6161646", "text": "func (o *UsageAttributionBody) HasTags() bool {\n\tif o != nil && o.Tags != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "4ea911c4c3cc1de56e134fe907699daf", "score": "0.61581737", "text": "func (m *MicroServiceInstance) Has(tags map[string]string) bool {\n\tfor k, v := range tags {\n\t\tif mt, ok := m.Metadata[k]; !ok || mt != v {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "title": "" }, { "docid": "177d38f60ca977e1634bbe88839157f8", "score": "0.61524534", "text": "func (o *CampaignTemplate) HasTags() bool {\n\tif o != nil && o.Tags != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "4b4bcf7f1251a2b290b643454a6c678a", "score": "0.61484575", "text": "func (o *WhitelistlistRuleResponse) HasField() bool {\n\tif o != nil && !IsNil(o.Field) {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "0956bc784ae213a0b7dfcf0b4ee99fea", "score": "0.61284757", "text": "func (x *fastReflection_VoteInfo) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"tendermint.abci.VoteInfo.validator\":\n\t\treturn x.Validator != nil\n\tcase \"tendermint.abci.VoteInfo.block_id_flag\":\n\t\treturn x.BlockIdFlag != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: tendermint.abci.VoteInfo\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message tendermint.abci.VoteInfo does not contain field %s\", fd.FullName()))\n\t}\n}", "title": "" }, { "docid": "4747d21688905c33f9784cc6394de30e", "score": "0.61184025", "text": "func (o *SpansMetricGroupBy) HasTagName() bool {\n\treturn o != nil && o.TagName != nil\n}", "title": "" }, { "docid": "8bd4371a07d6065b905a819d69c787ee", "score": "0.60965073", "text": "func HasTag(image string) bool {\n\ttagRegex := regexp.MustCompile(tagRegexStr)\n\treturn tagRegex.MatchString(image)\n}", "title": "" }, { "docid": "5d3aa0b8d2e4da7ac509183f6c4e8e92", "score": "0.60952896", "text": "func (o *InlineResponse20079TimeEntries) HasTags() bool {\n\tif o != nil && o.Tags != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "d47fa1aaa640871a534040c32fe70e2e", "score": "0.60778147", "text": "func (o *RouteTable) HasTags() bool {\n\tif o != nil && o.Tags != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "eb76d0f8d35d3a02126570bc7a6cd070", "score": "0.60764337", "text": "func (fs *FileSet) HasTagValue(name, key, value []byte) bool {\n\tfor _, f := range fs.files {\n\t\tif e := f.TagValue(name, key, value); e != nil {\n\t\t\treturn !e.Deleted()\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "ac3906d5ff86d4f8a7d97fbcb735269d", "score": "0.6035286", "text": "func hasTag(tags []*ec2.Tag, tag *ec2.Tag) bool {\n\tfor _, t := range tags {\n\t\tif aws.StringValue(t.Key) == aws.StringValue(tag.Key) &&\n\t\t\taws.StringValue(t.Value) == aws.StringValue(tag.Value) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "ac3906d5ff86d4f8a7d97fbcb735269d", "score": "0.6035286", "text": "func hasTag(tags []*ec2.Tag, tag *ec2.Tag) bool {\n\tfor _, t := range tags {\n\t\tif aws.StringValue(t.Key) == aws.StringValue(tag.Key) &&\n\t\t\taws.StringValue(t.Value) == aws.StringValue(tag.Value) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "8596d7e461444910f7444c6870c65abb", "score": "0.60276693", "text": "func (o *DecisionRequestPayloadAllOf) HasTags() bool {\n\tif o != nil && o.Tags != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "de5929319d1cb86f33765226dd968074", "score": "0.60245043", "text": "func (flags FieldFlags) Has(flagName string) bool {\n\tfor _, flag := range flags {\n\t\tif flag == flagName {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "301378860c72b75316d562130e49406d", "score": "0.6012716", "text": "func (x *fastReflection_ExtendedVoteInfo) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"tendermint.abci.ExtendedVoteInfo.validator\":\n\t\treturn x.Validator != nil\n\tcase \"tendermint.abci.ExtendedVoteInfo.vote_extension\":\n\t\treturn len(x.VoteExtension) != 0\n\tcase \"tendermint.abci.ExtendedVoteInfo.extension_signature\":\n\t\treturn len(x.ExtensionSignature) != 0\n\tcase \"tendermint.abci.ExtendedVoteInfo.block_id_flag\":\n\t\treturn x.BlockIdFlag != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: tendermint.abci.ExtendedVoteInfo\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message tendermint.abci.ExtendedVoteInfo does not contain field %s\", fd.FullName()))\n\t}\n}", "title": "" }, { "docid": "cfd0f040dca17cb55ad4b7a370fe15e7", "score": "0.5996195", "text": "func (o *SecurityMonitoringSignalAttributes) HasTags() bool {\n\treturn o != nil && o.Tags != nil\n}", "title": "" }, { "docid": "e0b77b9eaf2ec53ea93cfb06a193d9a0", "score": "0.5991435", "text": "func (o *Tag) HasDate() bool {\n\tif o != nil && o.Date != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "9741969272a290da0272b49803df6a8e", "score": "0.592405", "text": "func (tags Tags) HasKey(name string, key string) bool {\n\ttag := tags.Get(name)\n\tif tag != nil {\n\t\treturn tag.Get(key) != \"\"\n\t}\n\treturn false\n}", "title": "" }, { "docid": "4893750a820072bf6527a05494dd96d2", "score": "0.5919284", "text": "func (o *ExpenseApplicationCreateParams) HasTagIds() bool {\n\tif o != nil && o.TagIds != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "ca85fe18f2ba880ce9045e17991fe517", "score": "0.5910198", "text": "func (x *fastReflection_RequestExtendVote) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"tendermint.abci.RequestExtendVote.hash\":\n\t\treturn len(x.Hash) != 0\n\tcase \"tendermint.abci.RequestExtendVote.height\":\n\t\treturn x.Height != int64(0)\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: tendermint.abci.RequestExtendVote\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message tendermint.abci.RequestExtendVote does not contain field %s\", fd.FullName()))\n\t}\n}", "title": "" }, { "docid": "e091c3e7e2dedaa7809b3dd877d00e65", "score": "0.590868", "text": "func (p Protected) Has(key string) bool {\n\t_, ok := p[key]\n\treturn ok\n}", "title": "" }, { "docid": "4dbb208b44ad6ef48cc23a2848dd3020", "score": "0.5894894", "text": "func (m *Module) HasStructTag(name string) bool {\n\tfor _, s := range m.Structs {\n\t\tresult := s.Tags.Get(name)\n\t\tif result != \"\" {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "21696c21c5738dd8fce16512d925045c", "score": "0.589162", "text": "func (c *Conversation) HasTagKey(k string) bool {\n\tc.mu.RLock()\n\tdefer c.mu.RUnlock()\n\t// _, hasTag := m.seriesByTagKeyValue[k]\n\t// return hasTag\n\treturn false // TODO: Fix this\n}", "title": "" }, { "docid": "4cb0885f6480cd536c72909ee24cbbdc", "score": "0.58823216", "text": "func (x *fastReflection_ResponseExtendVote) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"tendermint.abci.ResponseExtendVote.vote_extension\":\n\t\treturn len(x.VoteExtension) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: tendermint.abci.ResponseExtendVote\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message tendermint.abci.ResponseExtendVote does not contain field %s\", fd.FullName()))\n\t}\n}", "title": "" }, { "docid": "14dc042be8bf574cef57c840f12057e7", "score": "0.5877193", "text": "func TagExists(ctx context.Context, exec boil.ContextExecutor, tagId int) (bool, error) {\n\tvar exists bool\n\tsql := \"select exists(select 1 from \\\"Tags\\\" where \\\"TagId\\\"=$1 limit 1)\"\n\n\tif boil.IsDebug(ctx) {\n\t\twriter := boil.DebugWriterFrom(ctx)\n\t\tfmt.Fprintln(writer, sql)\n\t\tfmt.Fprintln(writer, tagId)\n\t}\n\trow := exec.QueryRowContext(ctx, sql, tagId)\n\n\terr := row.Scan(&exists)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"models: unable to check if Tags exists\")\n\t}\n\n\treturn exists, nil\n}", "title": "" }, { "docid": "117633d1c6088f421eb43f5910e6ce11", "score": "0.5876824", "text": "func (o *ProductOrderResponse) HasTags() bool {\n\tif o != nil && !IsNil(o.Tags) {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "1f3614ba7839b1c110945a4884a82627", "score": "0.5861201", "text": "func (t *Tags) TagExists(name string) bool {\n\t_, ok := t.TagMap[strings.ToLower(name)]\n\treturn ok\n}", "title": "" }, { "docid": "ef3cac5eafaa026a710cfdd3fe476206", "score": "0.58480096", "text": "func (o *Tag) HasMessage() bool {\n\tif o != nil && o.Message != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "378d4260fdd26b589626e19ce23670d6", "score": "0.58457726", "text": "func HasTags() predicate.Application {\n\treturn predicate.Application(func(s *sql.Selector) {\n\t\tstep := sqlgraph.NewStep(\n\t\t\tsqlgraph.From(Table, FieldID),\n\t\t\tsqlgraph.To(TagsTable, FieldID),\n\t\t\tsqlgraph.Edge(sqlgraph.O2M, false, TagsTable, TagsColumn),\n\t\t)\n\t\tsqlgraph.HasNeighbors(s, step)\n\t})\n}", "title": "" }, { "docid": "32815f4ac70930850fd21bfac9e64f80", "score": "0.58387035", "text": "func (o *TagTag) HasColor() bool {\n\tif o != nil && o.Color != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "3e4dc62d496ba4c96dd11525737ec3b4", "score": "0.58374465", "text": "func (x *fastReflection_EventAttribute) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"tendermint.abci.EventAttribute.key\":\n\t\treturn x.Key != \"\"\n\tcase \"tendermint.abci.EventAttribute.value\":\n\t\treturn x.Value != \"\"\n\tcase \"tendermint.abci.EventAttribute.index\":\n\t\treturn x.Index != false\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: tendermint.abci.EventAttribute\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message tendermint.abci.EventAttribute does not contain field %s\", fd.FullName()))\n\t}\n}", "title": "" }, { "docid": "4e7382a68d1a99c2907f21db2f4d9746", "score": "0.58305234", "text": "func (wf *WarcFields) Has(name string) bool {\n\tname, _ = normalizeName(name)\n\tfor _, nv := range *wf {\n\t\tif nv.Name == name {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "f4aff081ebcb28da844e49147e7ef5c0", "score": "0.5828372", "text": "func (o *IncidentSearchResponseFacetsData) HasFields() bool {\n\treturn o != nil && o.Fields != nil\n}", "title": "" }, { "docid": "1d52375e749f267bb0dabc30d314ecd2", "score": "0.5814877", "text": "func (o *ComputePhysicalAllOf) HasAssetTag() bool {\n\tif o != nil && o.AssetTag != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "a81b7fa7043fe8a2ba06311e3f705243", "score": "0.5804331", "text": "func HasField(name string, objtype *TypeDesc) uint64 {\n var tmpObj *ObjectDesc;\n var retVal uint64 = 0;\n tmpObj = GetField(name, objtype);\n if tmpObj != nil {\n retVal = 1;\n }\n return retVal;\n}", "title": "" }, { "docid": "e8f648bb2049a0a2336649f8e9cfeeef", "score": "0.5797075", "text": "func (x *fastReflection_Bar) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"Bar.bar_id\":\n\t\treturn x.BarId != \"\"\n\tcase \"Bar.data\":\n\t\treturn len(x.Data) != 0\n\tcase \"Bar.payload\":\n\t\treturn x.Payload != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: Bar\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message Bar does not contain field %s\", fd.FullName()))\n\t}\n}", "title": "" }, { "docid": "f82cd73a02b8bb474dc35c2b91ced6c1", "score": "0.5784029", "text": "func isFieldOptional(f reflect.StructField) (bool, error) {\n\ttag := f.Tag.Get(_optionalTag)\n\tif tag == \"\" {\n\t\treturn false, nil\n\t}\n\n\toptional, err := strconv.ParseBool(tag)\n\tif err != nil {\n\t\terr = errWrapf(err,\n\t\t\t\"invalid value %q for %q tag on field %v\",\n\t\t\ttag, _optionalTag, f.Name)\n\t}\n\n\treturn optional, err\n}", "title": "" }, { "docid": "ad7ec0ab824ad8a7d3183dd8a6be90cd", "score": "0.5762984", "text": "func (t Section) Has(k string) bool {\n\t_, ok := t.values[k]\n\treturn ok\n}", "title": "" }, { "docid": "dc6e150e0a2531d3dd5062e14b5fc5d7", "score": "0.5754356", "text": "func (s Set[T]) Has(val T) bool {\n\treturn s.tree.Get(val) != nil\n}", "title": "" }, { "docid": "cacfbd8ee22ed7226a2b6fed7aaa1535", "score": "0.57377684", "text": "func (o *MonitorConfigPolicyTagPolicy) HasTagKeyRequired() bool {\n\treturn o != nil && o.TagKeyRequired != nil\n}", "title": "" }, { "docid": "517dbce69431b9aa9d372878ea699c85", "score": "0.5734036", "text": "func (a *analysis) hasTag() func(byte, ref) {\n\twarm, hot := false, true\n\treturn func(c byte, r ref) {\n\t\tswitch {\n\t\tcase (c == ':' || c == '[' || c == '{' || c == ','):\n\t\t\twarm, hot = true, false\n\t\tcase c == '\\n':\n\t\t\thot = true\n\t\tcase !(warm || hot):\n\n\t\tcase c == ' ':\n\t\t\thot = true\n\t\tcase !hot:\n\n\t\tcase c == '!':\n\t\t\ta.errs = append(a.errs, &tagErr{r: r})\n\t\tdefault:\n\t\t\twarm, hot = false, false\n\t\t}\n\t}\n}", "title": "" }, { "docid": "e5a5a329ead7a2ed9efe2d06500f421c", "score": "0.57274747", "text": "func (o object) HasAttr(name string) bool {\n\t_, ok := o[name]\n\treturn ok\n}", "title": "" }, { "docid": "f23e18e50ecb68ba9e599ef5b51b0dbe", "score": "0.5723183", "text": "func (o *BackupOperationResponse) HasSnapshotTag() bool {\n\tif o != nil && o.SnapshotTag != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "4a01ea405cab1a9b1b665d8aaaae5e1a", "score": "0.5717775", "text": "func (x *fastReflection_WeightedBallotOption) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"WeightedBallotOption.option\":\n\t\treturn x.Option != \"\"\n\tcase \"WeightedBallotOption.weight\":\n\t\treturn x.Weight != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: WeightedBallotOption\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message WeightedBallotOption does not contain field %s\", fd.FullName()))\n\t}\n}", "title": "" }, { "docid": "9a3ba022e60245545cc09c0705b542b6", "score": "0.57092845", "text": "func (f Flag) Has(v Flag) bool {\n\treturn (f & v) == v\n}", "title": "" }, { "docid": "68344f0eeec4942ea0fc8230d31ef529", "score": "0.57081336", "text": "func (fs *FileSet) HasTagKey(name, key []byte) bool {\n\tfor _, f := range fs.files {\n\t\tif e := f.TagKey(name, key); e != nil {\n\t\t\treturn !e.Deleted()\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "10d04226d3aa4f0b717d4b8e907e5858", "score": "0.5702767", "text": "func (s *Tikv) Has(k []byte) (bool, error) {\n\td, err := s.Get(k)\n\n\tif err != nil || len(d) == 0 {\n\t\treturn false, err\n\t}\n\treturn true, nil\n}", "title": "" }, { "docid": "d96734240c1b0fd26f6a21f8c20b1d85", "score": "0.5696482", "text": "func (collectors MultiCollector) HasTagKey(tagKey string) bool {\n\tvar key, value string\n\tfor _, collector := range collectors {\n\t\tfor _, tag := range collector.DefaultTags() {\n\t\t\tkey, value = SplitTag(tag)\n\t\t\tif strings.EqualFold(tagKey, key) && value != \"\" {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "6deebf138fc65758ca60c6a30b1beb1e", "score": "0.56943524", "text": "func (q tagQuery) Exists(ctx context.Context, exec boil.ContextExecutor) (bool, error) {\n\tvar count int64\n\n\tqueries.SetSelect(q.Query, nil)\n\tqueries.SetCount(q.Query)\n\tqueries.SetLimit(q.Query, 1)\n\n\terr := q.Query.QueryRowContext(ctx, exec).Scan(&count)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"models: failed to check if Tags exists\")\n\t}\n\n\treturn count > 0, nil\n}", "title": "" } ]
bfa3c827bb0dd637a6defee1834c158f
MarshalLogObject implements zapcore.ObjectMarshaler, enabling fast logging of AdminService_DescribeCluster_Args.
[ { "docid": "f0ead651a8fb9ed241b1fbeecb762f7e", "score": "0.84582907", "text": "func (v *AdminService_DescribeCluster_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\treturn err\n}", "title": "" } ]
[ { "docid": "21f5355bfe395904690f242d50af523c", "score": "0.69382834", "text": "func (v *AdminService_GetCrossClusterTasks_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "12870a6a2f16356cd89fbedcd644c1cc", "score": "0.6914744", "text": "func (v *AdminService_DescribeCluster_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Success != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"success\", v.Success))\n\t}\n\tif v.InternalServiceError != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"internalServiceError\", v.InternalServiceError))\n\t}\n\tif v.ServiceBusyError != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"serviceBusyError\", v.ServiceBusyError))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "7e68539daa4808d7a21400c2ff95cf87", "score": "0.6820692", "text": "func (v *DescribeClusterResponse) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.SupportedClientVersions != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"supportedClientVersions\", v.SupportedClientVersions))\n\t}\n\tif v.MembershipInfo != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"membershipInfo\", v.MembershipInfo))\n\t}\n\tif v.PersistenceInfo != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"persistenceInfo\", (_Map_String_PersistenceInfo_Zapper)(v.PersistenceInfo)))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "f52fddd43f24b5b1d2735f7035bd00d5", "score": "0.66300017", "text": "func (v *AdminService_DescribeCluster_Args) String() string {\n\tif v == nil {\n\t\treturn \"<nil>\"\n\t}\n\n\tvar fields [0]string\n\ti := 0\n\n\treturn fmt.Sprintf(\"AdminService_DescribeCluster_Args{%v}\", strings.Join(fields[:i], \", \"))\n}", "title": "" }, { "docid": "bc2f310f186ba0a84021a75527f27640", "score": "0.6207207", "text": "func (v *AdminService_DescribeShardDistribution_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "4b2302aca2459d56de200033d3589326", "score": "0.59103936", "text": "func (v *AdminService_GetCrossClusterTasks_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Success != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"success\", v.Success))\n\t}\n\tif v.BadRequestError != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"badRequestError\", v.BadRequestError))\n\t}\n\tif v.InternalServiceError != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"internalServiceError\", v.InternalServiceError))\n\t}\n\tif v.ServiceBusyError != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"serviceBusyError\", v.ServiceBusyError))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "ff0e5a8d9ea11e1501a9de184a8753ac", "score": "0.5905855", "text": "func (v *AdminService_DescribeHistoryHost_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "780e10acef0df421b520ea17ab34e3ab", "score": "0.58537185", "text": "func (v *AdminService_AddSearchAttribute_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "244923e2d5e4f4979c38da299f1e3854", "score": "0.5752977", "text": "func (v *AdminService_CloseShard_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "8ad129f16649c8f58880c2c0dd054f03", "score": "0.56719416", "text": "func (v *AdminService_GetDynamicConfig_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "748b2cd63b6b083cd341aebf2c351db4", "score": "0.5665081", "text": "func (*ListClusterLogsRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{22}\n}", "title": "" }, { "docid": "a6ab597ae99363ec8d8c36177f1e1dee", "score": "0.55313843", "text": "func (v *AdminService_ListDynamicConfig_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "6cbff37fae139842ecb0d8b402309488", "score": "0.5505107", "text": "func (v *Cache_Clear_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\treturn err\n}", "title": "" }, { "docid": "622a10289b5c533c0e96903b8774b7ce", "score": "0.5493935", "text": "func (v *AdminService_DescribeQueue_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "8ee35123d9ac96c453a90bf592cb43d0", "score": "0.54661053", "text": "func (v *AdminService_GetReplicationMessages_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "e8d13c7e5076d3933f49ebbeec291ea3", "score": "0.5465497", "text": "func (v *AdminService_DescribeCluster_Args) Equals(rhs *AdminService_DescribeCluster_Args) bool {\n\tif v == nil {\n\t\treturn rhs == nil\n\t} else if rhs == nil {\n\t\treturn false\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "80cf71e2130fec529d618627fcd9c810", "score": "0.53839064", "text": "func flattenCluster(c *Client, i interface{}, res *Cluster) *Cluster {\n\tm, ok := i.(map[string]interface{})\n\tif !ok {\n\t\treturn nil\n\t}\n\tif len(m) == 0 {\n\t\treturn nil\n\t}\n\n\tresultRes := &Cluster{}\n\tresultRes.Project = dcl.FlattenString(m[\"projectId\"])\n\tresultRes.Name = dcl.FlattenString(m[\"clusterName\"])\n\tresultRes.Config = flattenClusterConfig(c, m[\"config\"], res)\n\tresultRes.Labels = dcl.FlattenKeyValuePairs(m[\"labels\"])\n\tresultRes.Status = flattenClusterStatus(c, m[\"status\"], res)\n\tresultRes.StatusHistory = flattenClusterStatusHistorySlice(c, m[\"statusHistory\"], res)\n\tresultRes.ClusterUuid = dcl.FlattenString(m[\"clusterUuid\"])\n\tresultRes.Metrics = flattenClusterMetrics(c, m[\"metrics\"], res)\n\tresultRes.Location = dcl.FlattenString(m[\"location\"])\n\tresultRes.VirtualClusterConfig = flattenClusterVirtualClusterConfig(c, m[\"virtualClusterConfig\"], res)\n\n\treturn resultRes\n}", "title": "" }, { "docid": "a1aa92d5b4b828867fdebb3a2acc25e6", "score": "0.5341925", "text": "func (v *NonStandardServiceName_NonStandardFunctionName_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\treturn err\n}", "title": "" }, { "docid": "4dfc6ad1dce5d465ae9141d358fb8ea5", "score": "0.5333332", "text": "func WithCluster(logger log.FieldLogger, cluster *clusterapi.Cluster) log.FieldLogger {\n\treturn WithGenericObject(logger, \"cluster\", cluster)\n}", "title": "" }, { "docid": "428b29cbb583d98df37ef3d58e391003", "score": "0.53248715", "text": "func (sc serviceContext) MarshalLogObject(enc zapcore.ObjectEncoder) error {\n\tenc.AddString(\"service\", sc.Name)\n\tenc.AddString(\"version\", sc.Version)\n\treturn nil\n}", "title": "" }, { "docid": "96931703ecc06fd09ea2f916f536736f", "score": "0.53202987", "text": "func (*StreamClusterLogsRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{25}\n}", "title": "" }, { "docid": "fadf360e6c4fab18c702140814a73c0c", "score": "0.53057027", "text": "func MarshalCluster(l *v2.Cluster) []byte {\n\n\tm, err := prot.Marshal(l)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn m\n\n}", "title": "" }, { "docid": "d7cb8437256c48f3279de30cf9c44b7f", "score": "0.5283604", "text": "func (v *AdminService_DescribeCluster_Args) MethodName() string {\n\treturn \"DescribeCluster\"\n}", "title": "" }, { "docid": "4772d6343db3f44ae00470150cc7ec5d", "score": "0.52628183", "text": "func (v *AdminService_UpdateDynamicConfig_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "5e5e1d9be1b121becaf37d6ac237932b", "score": "0.5256077", "text": "func (*ListClusterLogsResponse) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{23}\n}", "title": "" }, { "docid": "aeab4570765509a4a361fee53e4b80f7", "score": "0.5246204", "text": "func (v *HostInfo) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Identity != nil {\n\t\tenc.AddString(\"Identity\", *v.Identity)\n\t}\n\treturn err\n}", "title": "" }, { "docid": "fefb9ad993e0f233e74324490d74ba98", "score": "0.5245419", "text": "func describeCluster(o options) (*describe, error) {\n\tif o.account != \"\" {\n\t\tact, err := getAccount()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"get current account: %v\", err)\n\t\t}\n\t\tdefer setAccount(act)\n\t\tif err = setAccount(o.account); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"set account %s: %v\", o.account, err)\n\t\t}\n\t}\n\targs, cmd := command(\n\t\t\"gcloud\", \"container\", \"clusters\", \"describe\", o.cluster,\n\t\t\"--project\", o.project,\n\t\t\"--zone\", o.zone,\n\t\t\"--format=yaml\",\n\t)\n\tdata, err := cmd.Output()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %v\", strings.Join(args, \" \"), err)\n\t}\n\tvar d describe\n\tif yaml.Unmarshal(data, &d); err != nil {\n\t\treturn nil, fmt.Errorf(\"unmarshal gcloud: %v\", err)\n\t}\n\n\tif d.Endpoint == \"\" {\n\t\treturn nil, errors.New(\"empty endpoint\")\n\t}\n\tif len(d.Auth.ClusterCACertificate) == 0 {\n\t\treturn nil, errors.New(\"empty clusterCaCertificate\")\n\t}\n\n\tif len(d.Auth.ClientKey) == 0 {\n\t\treturn nil, errors.New(\"empty clientKey, consider running with --get-client-cert\")\n\t}\n\tif len(d.Auth.ClientCertificate) == 0 {\n\t\treturn nil, errors.New(\"empty clientCertificate, consider running with --get-client-cert\")\n\t}\n\n\treturn &d, nil\n}", "title": "" }, { "docid": "322ea82fb0c66628bcb0e904ae4ed5c1", "score": "0.5238335", "text": "func (adh *AdminHandler) DescribeCluster(ctx context.Context, _ *adminservice.DescribeClusterRequest) (_ *adminservice.DescribeClusterResponse, retError error) {\n\tdefer log.CapturePanic(adh.GetLogger(), &retError)\n\n\tscope, sw := adh.startRequestProfile(metrics.AdminGetWorkflowExecutionRawHistoryV2Scope)\n\tdefer sw.Stop()\n\n\tmembershipInfo := &clusterspb.MembershipInfo{}\n\tif monitor := adh.GetMembershipMonitor(); monitor != nil {\n\t\tcurrentHost, err := monitor.WhoAmI()\n\t\tif err != nil {\n\t\t\treturn nil, adh.error(err, scope)\n\t\t}\n\n\t\tmembershipInfo.CurrentHost = &clusterspb.HostInfo{\n\t\t\tIdentity: currentHost.Identity(),\n\t\t}\n\n\t\tmembers, err := monitor.GetReachableMembers()\n\t\tif err != nil {\n\t\t\treturn nil, adh.error(err, scope)\n\t\t}\n\n\t\tmembershipInfo.ReachableMembers = members\n\n\t\tvar rings []*clusterspb.RingInfo\n\t\tfor _, role := range []string{common.FrontendServiceName, common.HistoryServiceName, common.MatchingServiceName, common.WorkerServiceName} {\n\t\t\tresolver, err := monitor.GetResolver(role)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, adh.error(err, scope)\n\t\t\t}\n\n\t\t\tvar servers []*clusterspb.HostInfo\n\t\t\tfor _, server := range resolver.Members() {\n\t\t\t\tservers = append(servers, &clusterspb.HostInfo{\n\t\t\t\t\tIdentity: server.Identity(),\n\t\t\t\t})\n\t\t\t}\n\n\t\t\trings = append(rings, &clusterspb.RingInfo{\n\t\t\t\tRole: role,\n\t\t\t\tMemberCount: int32(resolver.MemberCount()),\n\t\t\t\tMembers: servers,\n\t\t\t})\n\t\t}\n\t\tmembershipInfo.Rings = rings\n\t}\n\n\treturn &adminservice.DescribeClusterResponse{\n\t\tSupportedClients: headers.SupportedClients,\n\t\tServerVersion: headers.ServerVersion,\n\t\tMembershipInfo: membershipInfo,\n\t}, nil\n}", "title": "" }, { "docid": "94cd6a668b0b3a7d3718eb887dec568e", "score": "0.52008504", "text": "func marshalUpdateClusterUpdateClusterRequest(c *Client, m map[string]interface{}) ([]byte, error) {\n\n\treturn json.Marshal(m)\n}", "title": "" }, { "docid": "d851f916ead18ba20a022763ff0b9d9a", "score": "0.51942927", "text": "func (v *AdminService_GetDLQReplicationMessages_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "c6437affcfd1e026b9d9de19ff3043b5", "score": "0.5193842", "text": "func (v *AdminService_GetDomainReplicationMessages_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "12b26806b79055e30f164f3f76094734", "score": "0.5187258", "text": "func (v *KeyValue_GetManyValues_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Range != nil {\n\t\terr = multierr.Append(err, enc.AddArray(\"range\", (_List_Key_Zapper)(v.Range)))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "28b15d6ea847d568d323b6e0fc403381", "score": "0.518194", "text": "func MarshalClusterAuthorizationRequest(object *ClusterAuthorizationRequest, target interface{}) error {\n\tencoder, err := helpers.NewEncoder(target)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdata, err := object.wrap()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn encoder.Encode(data)\n}", "title": "" }, { "docid": "d4738ba2017e231f69ca9d5b0784ce99", "score": "0.51689535", "text": "func (v *AdminService_DescribeShardDistribution_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Success != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"success\", v.Success))\n\t}\n\tif v.InternalServiceError != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"internalServiceError\", v.InternalServiceError))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "ffe25e82517affc08da7ee07321591be", "score": "0.51548743", "text": "func (v *Bar_ArgWithNestedQueryParams_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\tif v.Opt != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"opt\", v.Opt))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "318f02285831561e4d35276eac74ec20", "score": "0.5136751", "text": "func (v *AdminService_DescribeWorkflowExecution_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "830e00a2047a2c6a3611b1138ec31bce", "score": "0.51096714", "text": "func (v *AdminService_RemoveTask_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "756bdcf5e87497a53869029ede1d37b3", "score": "0.5101067", "text": "func (ac *awsCli) DumpClusterLogs(artifactDir, _ string) error {\n\tpanic(\"TODO\")\n}", "title": "" }, { "docid": "065bd9e8353ad6ef4580e42c1f17b331", "score": "0.5100222", "text": "func logsClusterAutoscaler() {\n\tlogPod(\"cluster-autoscaler\", \"seed\", \"cluster-autoscaler\")\n}", "title": "" }, { "docid": "89d618799dfa5fcb64bb4f09cfeea3f9", "score": "0.5098268", "text": "func (v *AdminService_AddSearchAttribute_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.BadRequestError != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"badRequestError\", v.BadRequestError))\n\t}\n\tif v.InternalServiceError != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"internalServiceError\", v.InternalServiceError))\n\t}\n\tif v.ServiceBusyError != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"serviceBusyError\", v.ServiceBusyError))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "ded31df62e74c5e97490efc82c76261d", "score": "0.5060905", "text": "func (v *AdminService_ResetQueue_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "16c0a5e208b54abb60f7086956c31d1a", "score": "0.5054282", "text": "func (v *AdminService_RestoreDynamicConfig_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "ef36bbdec680d417359f9f0c43c72b84", "score": "0.5052123", "text": "func (v *Cache_ClearAfter_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.DurationMS != nil {\n\t\tenc.AddInt64(\"durationMS\", *v.DurationMS)\n\t}\n\treturn err\n}", "title": "" }, { "docid": "3896c65c049bc939ab26465e352f5066", "score": "0.5027052", "text": "func (m _Map_String_PersistenceInfo_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tfor k, v := range m {\n\t\terr = multierr.Append(err, enc.AddObject((string)(k), v))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "cb1b543aeb56b5bcb5d5a1a243288405", "score": "0.5020628", "text": "func (v *AdminService_ReadDLQMessages_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "2b21c425b194725669ddc8ba11a41ddb", "score": "0.50114375", "text": "func (v *AdminService_RefreshWorkflowTasks_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "3b8e03448d22b2d644631e54c4d5c0a1", "score": "0.50083125", "text": "func (r *Cluster) marshal(c *Client) ([]byte, error) {\n\tm, err := expandCluster(c, r)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error marshalling Cluster: %w\", err)\n\t}\n\n\treturn json.Marshal(m)\n}", "title": "" }, { "docid": "efaa54dfd40c83fc91a2fe3945c5a9be", "score": "0.4996807", "text": "func (v *KeyValue_DeleteValue_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Key != nil {\n\t\tenc.AddString(\"key\", (string)(*v.Key))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "28679d6f23df0f6dc18a3f20c28902ac", "score": "0.4988901", "text": "func UnmarshalCluster(m map[string]json.RawMessage, result interface{}) (err error) {\n\tobj := new(Cluster)\n\terr = core.UnmarshalModel(m, \"addons\", &obj.Addons, UnmarshalAddon)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"apiUser\", &obj.ApiUser)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"createdDate\", &obj.CreatedDate)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"crn\", &obj.Crn)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"dataCenter\", &obj.DataCenter)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"disableAutoUpdate\", &obj.DisableAutoUpdate)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"etcdPort\", &obj.EtcdPort)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"id\", &obj.ID)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"imageSecurityEnabled\", &obj.ImageSecurityEnabled)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"ingressHostname\", &obj.IngressHostname)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"ingressMessage\", &obj.IngressMessage)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"ingressSecretName\", &obj.IngressSecretName)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"ingressStatus\", &obj.IngressStatus)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"isPaid\", &obj.IsPaid)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"keyProtectEnabled\", &obj.KeyProtectEnabled)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"location\", &obj.Location)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"logOrg\", &obj.LogOrg)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"logOrgName\", &obj.LogOrgName)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"logSpace\", &obj.LogSpace)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"logSpaceName\", &obj.LogSpaceName)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"masterHealth\", &obj.MasterHealth)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"masterKubeVersion\", &obj.MasterKubeVersion)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"masterState\", &obj.MasterState)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"masterStatus\", &obj.MasterStatus)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"masterStatusModifiedDate\", &obj.MasterStatusModifiedDate)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"modifiedDate\", &obj.ModifiedDate)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"monitoringURL\", &obj.MonitoringURL)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"multiAzCapable\", &obj.MultiAzCapable)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"name\", &obj.Name)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"podSubnet\", &obj.PodSubnet)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"privateServiceEndpointEnabled\", &obj.PrivateServiceEndpointEnabled)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"privateServiceEndpointURL\", &obj.PrivateServiceEndpointURL)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"publicServiceEndpointEnabled\", &obj.PublicServiceEndpointEnabled)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"publicServiceEndpointURL\", &obj.PublicServiceEndpointURL)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"pullSecretApplied\", &obj.PullSecretApplied)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"region\", &obj.Region)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"resourceGroup\", &obj.ResourceGroup)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"resourceGroupName\", &obj.ResourceGroupName)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"serverURL\", &obj.ServerURL)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"serviceSubnet\", &obj.ServiceSubnet)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"state\", &obj.State)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"status\", &obj.Status)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"targetVersion\", &obj.TargetVersion)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"type\", &obj.Type)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"versionEOS\", &obj.VersionEOS)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalModel(m, \"vlans\", &obj.Vlans, UnmarshalVlanConfigField)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"workerCount\", &obj.WorkerCount)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"workerZones\", &obj.WorkerZones)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalModel(m, \"worker_vlans\", &obj.WorkerVlans, UnmarshalVLAN)\n\tif err != nil {\n\t\treturn\n\t}\n\treflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))\n\treturn\n}", "title": "" }, { "docid": "4ce779047053ae34ba8f0646b307d932", "score": "0.49876013", "text": "func (v *KeyValue_GetValue_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Key != nil {\n\t\tenc.AddString(\"key\", (string)(*v.Key))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "df1e0d1f906c97eec8b43fa3afe77b80", "score": "0.49806383", "text": "func (v *KeyValue_SetValue_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Key != nil {\n\t\tenc.AddString(\"key\", (string)(*v.Key))\n\t}\n\tif v.Value != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"value\", v.Value))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "1496a51cc771e3dc9d72e104d9c890fb", "score": "0.4980393", "text": "func (*BackupClusterRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{15}\n}", "title": "" }, { "docid": "65993c373cf55805b23af6da3b6820ed", "score": "0.49692798", "text": "func (v *AdminService_PurgeDLQMessages_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "8c7847dc5719bac3dd48722bb1eb77fe", "score": "0.4968692", "text": "func (*GetClusterRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "4875bcfb44b678331b1906508c929967", "score": "0.49686188", "text": "func (c Cluster) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\tpopulate(objectMap, \"etag\", c.Etag)\n\tpopulate(objectMap, \"id\", c.ID)\n\tpopulate(objectMap, \"identity\", c.Identity)\n\tpopulate(objectMap, \"location\", c.Location)\n\tpopulate(objectMap, \"name\", c.Name)\n\tpopulate(objectMap, \"properties\", c.Properties)\n\tpopulate(objectMap, \"systemData\", c.SystemData)\n\tpopulate(objectMap, \"tags\", c.Tags)\n\tpopulate(objectMap, \"type\", c.Type)\n\tpopulate(objectMap, \"zones\", c.Zones)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "18c616ec357e868fb1afce34e44fe22b", "score": "0.4951074", "text": "func (v *Oneway_Echo_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Token != nil {\n\t\tenc.AddString(\"token\", *v.Token)\n\t}\n\treturn err\n}", "title": "" }, { "docid": "d9700104f9cc67f51bb0600e69a36fcd", "score": "0.4950205", "text": "func (v *KeyValue_SetValueV2_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tenc.AddString(\"key\", (string)(v.Key))\n\terr = multierr.Append(err, enc.AddObject(\"value\", v.Value))\n\treturn err\n}", "title": "" }, { "docid": "252e67a5125f514c4d17b3b691fd9cc3", "score": "0.4937055", "text": "func (mc ManagedCluster) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\tif mc.Sku != nil {\n\t\tobjectMap[\"sku\"] = mc.Sku\n\t}\n\tif mc.ExtendedLocation != nil {\n\t\tobjectMap[\"extendedLocation\"] = mc.ExtendedLocation\n\t}\n\tif mc.Identity != nil {\n\t\tobjectMap[\"identity\"] = mc.Identity\n\t}\n\tif mc.ManagedClusterProperties != nil {\n\t\tobjectMap[\"properties\"] = mc.ManagedClusterProperties\n\t}\n\tif mc.Location != nil {\n\t\tobjectMap[\"location\"] = mc.Location\n\t}\n\tif mc.Tags != nil {\n\t\tobjectMap[\"tags\"] = mc.Tags\n\t}\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "e261175b47a2d746d8eb86fa4315a4b1", "score": "0.4916439", "text": "func PrintCluster(business, app string, cluster *common.Cluster) {\n\t//format output\n\tlineColor := color.New(color.FgYellow)\n\tlineColor.Print(\"Name: \")\n\tfmt.Printf(\"\\t\\t%s\\n\", cluster.Name)\n\tlineColor.Print(\"ClusterID: \")\n\tfmt.Printf(\"\\t%s\\n\", cluster.Clusterid)\n\tlineColor.Print(\"Business: \")\n\tfmt.Printf(\"\\t%s - %s\\n\", cluster.Bid, business)\n\tlineColor.Print(\"Application: \")\n\tfmt.Printf(\"\\t%s - %s\\n\", cluster.Appid, app)\n\tlineColor.Print(\"RClusterid: \")\n\tfmt.Printf(\"\\t%s\\n\", cluster.RClusterid)\n\tlineColor.Print(\"State:\\t\\t\")\n\tif cluster.State == 0 {\n\t\tcolor.Cyan(\"Affectived\\n\")\n\t} else {\n\t\tcolor.Red(\"Deleted\\n\")\n\t}\n\tlineColor.Print(\"Memo: \")\n\tfmt.Printf(\"\\t\\t%s\\n\", cluster.Memo)\n\tlineColor.Print(\"Creator: \")\n\tfmt.Printf(\"\\t%s\\n\", cluster.Creator)\n\tlineColor.Print(\"LastModifyBy: \")\n\tfmt.Printf(\"\\t%s\\n\", cluster.LastModifyBy)\n\tlineColor.Print(\"CreatedAt: \")\n\tfmt.Printf(\"\\t%s\\n\", cluster.CreatedAt)\n\tlineColor.Print(\"UpdatedAt: \")\n\tfmt.Printf(\"\\t%s\\n\\n\", cluster.UpdatedAt)\n}", "title": "" }, { "docid": "6fcea6ff5dc8444402cdd0034052862f", "score": "0.49075916", "text": "func (c *Cluster) Serialize() ([]byte, error) {\n\tb, err := json.Marshal(c)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn b, nil\n}", "title": "" }, { "docid": "9bd00aad9e92e372f0fa80625396fbc8", "score": "0.49041468", "text": "func (v *AdminService_DescribeHistoryHost_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Success != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"success\", v.Success))\n\t}\n\tif v.BadRequestError != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"badRequestError\", v.BadRequestError))\n\t}\n\tif v.InternalServiceError != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"internalServiceError\", v.InternalServiceError))\n\t}\n\tif v.AccessDeniedError != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"accessDeniedError\", v.AccessDeniedError))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "045d23da860a6cd17200824b2898e2d2", "score": "0.48882246", "text": "func (v *AdminService_ReapplyEvents_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.ReapplyEventsRequest != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"reapplyEventsRequest\", v.ReapplyEventsRequest))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "eb349f9b50c7e56d9fa9be1a4ff6a3fd", "score": "0.4879449", "text": "func (v *AdminService_DescribeCluster_Args) EnvelopeType() wire.EnvelopeType {\n\treturn wire.Call\n}", "title": "" }, { "docid": "f159dd8b25c7008a818178e5f9910321", "score": "0.48761216", "text": "func cliClusterLogs() *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: \"logs [cluster]\",\n\t\tShort: \"Print an object storage server logs\",\n\t\tArgs: cobra.ExactArgs(1),\n\t\tRun: logsNano,\n\t\tDisableFlagsInUseLine: true,\n\t}\n\n\treturn cmd\n}", "title": "" }, { "docid": "300cbbf91c6d60f9abeaaf8568283476", "score": "0.48606572", "text": "func (c ClusterProperties) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"aadApplicationObjectId\", c.AADApplicationObjectID)\n\tpopulate(objectMap, \"aadClientId\", c.AADClientID)\n\tpopulate(objectMap, \"aadServicePrincipalObjectId\", c.AADServicePrincipalObjectID)\n\tpopulate(objectMap, \"aadTenantId\", c.AADTenantID)\n\tpopulate(objectMap, \"billingModel\", c.BillingModel)\n\tpopulate(objectMap, \"cloudId\", c.CloudID)\n\tpopulate(objectMap, \"cloudManagementEndpoint\", c.CloudManagementEndpoint)\n\tpopulate(objectMap, \"desiredProperties\", c.DesiredProperties)\n\tpopulateTimeRFC3339(objectMap, \"lastBillingTimestamp\", c.LastBillingTimestamp)\n\tpopulateTimeRFC3339(objectMap, \"lastSyncTimestamp\", c.LastSyncTimestamp)\n\tpopulate(objectMap, \"provisioningState\", c.ProvisioningState)\n\tpopulateTimeRFC3339(objectMap, \"registrationTimestamp\", c.RegistrationTimestamp)\n\tpopulate(objectMap, \"reportedProperties\", c.ReportedProperties)\n\tpopulate(objectMap, \"serviceEndpoint\", c.ServiceEndpoint)\n\tpopulate(objectMap, \"status\", c.Status)\n\tpopulate(objectMap, \"trialDaysRemaining\", c.TrialDaysRemaining)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "1cd557e6593e30c828c57f3c93c44fc2", "score": "0.48525804", "text": "func (*CreateClusterRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "c78016a8b98ea690cdece1acfbe2698a", "score": "0.48514563", "text": "func (v *AdminService_MergeDLQMessages_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "b0d7827392b7a4310744876427392301", "score": "0.48490584", "text": "func (v *ConflictingNames_SetValue_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "bcac228d8c60aa2e57f81a7812fa82e1", "score": "0.48471576", "text": "func (*AddClusterShardRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{41}\n}", "title": "" }, { "docid": "4b8122c9f158d32ee82c3834ce870088", "score": "0.4834538", "text": "func (v *KeyValue_Size_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\treturn err\n}", "title": "" }, { "docid": "938081a6b07104d6ca9c5f81d2aae1c2", "score": "0.48168", "text": "func (v *AdminService_CloseShard_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.BadRequestError != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"badRequestError\", v.BadRequestError))\n\t}\n\tif v.InternalServiceError != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"internalServiceError\", v.InternalServiceError))\n\t}\n\tif v.AccessDeniedError != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"accessDeniedError\", v.AccessDeniedError))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "209fbf68bf4ab20d712ed1e096a15fa8", "score": "0.48027197", "text": "func (*UpdateClusterRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "4e4ac500a11f7624848896653ed9fe3e", "score": "0.48023698", "text": "func flattenClusterConfig(c *Client, i interface{}, res *Cluster) *ClusterConfig {\n\tm, ok := i.(map[string]interface{})\n\tif !ok {\n\t\treturn nil\n\t}\n\n\tr := &ClusterConfig{}\n\n\tif dcl.IsEmptyValueIndirect(i) {\n\t\treturn EmptyClusterConfig\n\t}\n\tr.StagingBucket = dcl.FlattenString(m[\"configBucket\"])\n\tr.TempBucket = dcl.FlattenString(m[\"tempBucket\"])\n\tr.GceClusterConfig = flattenClusterConfigGceClusterConfig(c, m[\"gceClusterConfig\"], res)\n\tr.MasterConfig = flattenClusterConfigMasterConfig(c, m[\"masterConfig\"], res)\n\tr.WorkerConfig = flattenClusterConfigWorkerConfig(c, m[\"workerConfig\"], res)\n\tr.SecondaryWorkerConfig = flattenClusterConfigSecondaryWorkerConfig(c, m[\"secondaryWorkerConfig\"], res)\n\tr.SoftwareConfig = flattenClusterConfigSoftwareConfig(c, m[\"softwareConfig\"], res)\n\tr.InitializationActions = flattenClusterConfigInitializationActionsSlice(c, m[\"initializationActions\"], res)\n\tr.EncryptionConfig = flattenClusterConfigEncryptionConfig(c, m[\"encryptionConfig\"], res)\n\tr.AutoscalingConfig = flattenClusterConfigAutoscalingConfig(c, m[\"autoscalingConfig\"], res)\n\tr.SecurityConfig = flattenClusterConfigSecurityConfig(c, m[\"securityConfig\"], res)\n\tr.LifecycleConfig = flattenClusterConfigLifecycleConfig(c, m[\"lifecycleConfig\"], res)\n\tr.EndpointConfig = flattenClusterConfigEndpointConfig(c, m[\"endpointConfig\"], res)\n\tr.MetastoreConfig = flattenClusterConfigMetastoreConfig(c, m[\"metastoreConfig\"], res)\n\tr.DataprocMetricConfig = flattenClusterConfigDataprocMetricConfig(c, m[\"dataprocMetricConfig\"], res)\n\n\treturn r\n}", "title": "" }, { "docid": "c76161e1bdadddc54f3d89b6f022f5b2", "score": "0.48020336", "text": "func (v *AdminService_GetCrossClusterTasks_Args) String() string {\n\tif v == nil {\n\t\treturn \"<nil>\"\n\t}\n\n\tvar fields [1]string\n\ti := 0\n\tif v.Request != nil {\n\t\tfields[i] = fmt.Sprintf(\"Request: %v\", v.Request)\n\t\ti++\n\t}\n\n\treturn fmt.Sprintf(\"AdminService_GetCrossClusterTasks_Args{%v}\", strings.Join(fields[:i], \", \"))\n}", "title": "" }, { "docid": "af12bbda194fb716eaab084ff26c160f", "score": "0.47987798", "text": "func (v *AdminService_ResendReplicationTasks_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Request != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"request\", v.Request))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "84e28225c71172d6eb8109c70fe5e765", "score": "0.47975612", "text": "func (v *AdminService_DescribeCluster_Result) String() string {\n\tif v == nil {\n\t\treturn \"<nil>\"\n\t}\n\n\tvar fields [3]string\n\ti := 0\n\tif v.Success != nil {\n\t\tfields[i] = fmt.Sprintf(\"Success: %v\", v.Success)\n\t\ti++\n\t}\n\tif v.InternalServiceError != nil {\n\t\tfields[i] = fmt.Sprintf(\"InternalServiceError: %v\", v.InternalServiceError)\n\t\ti++\n\t}\n\tif v.ServiceBusyError != nil {\n\t\tfields[i] = fmt.Sprintf(\"ServiceBusyError: %v\", v.ServiceBusyError)\n\t\ti++\n\t}\n\n\treturn fmt.Sprintf(\"AdminService_DescribeCluster_Result{%v}\", strings.Join(fields[:i], \", \"))\n}", "title": "" }, { "docid": "7089ff0f023fd7bf4ef1e8d9206768e1", "score": "0.4780986", "text": "func (*GetClusterShardRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{38}\n}", "title": "" }, { "docid": "aa0b8eb95891f2e63e7555af85a9e125", "score": "0.47796032", "text": "func (c Cluster) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\tpopulate(objectMap, \"id\", c.ID)\n\tpopulate(objectMap, \"location\", c.Location)\n\tpopulate(objectMap, \"name\", c.Name)\n\tpopulate(objectMap, \"properties\", c.Properties)\n\tpopulate(objectMap, \"sku\", c.SKU)\n\tpopulate(objectMap, \"tags\", c.Tags)\n\tpopulate(objectMap, \"type\", c.Type)\n\tpopulate(objectMap, \"zones\", c.Zones)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "49ba3aedf2474e12791c73c0eedc9faf", "score": "0.47791237", "text": "func (c Cluster) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"id\", c.ID)\n\tpopulate(objectMap, \"location\", c.Location)\n\tpopulate(objectMap, \"name\", c.Name)\n\tpopulate(objectMap, \"properties\", c.Properties)\n\tpopulate(objectMap, \"systemData\", c.SystemData)\n\tpopulate(objectMap, \"tags\", c.Tags)\n\tpopulate(objectMap, \"type\", c.Type)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "1b90bb949b9395f22a10c0d3ba186d03", "score": "0.47765428", "text": "func (*ListClusterOperationsRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{26}\n}", "title": "" }, { "docid": "8c7e1db9441dc2d946363190f5674779", "score": "0.47686675", "text": "func (v *Bar_ArgWithNestedQueryParams_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Success != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"success\", v.Success))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "524049fbd7577208bce556914475835b", "score": "0.47622812", "text": "func (m MongoDbClusterInfo) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"databases\", m.Databases)\n\tpopulate(objectMap, \"supportsSharding\", m.SupportsSharding)\n\tpopulate(objectMap, \"type\", m.Type)\n\tpopulate(objectMap, \"version\", m.Version)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "10c06b8dc4081e2d66a73d5facc4d20e", "score": "0.4750757", "text": "func (*ListClustersRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{1}\n}", "title": "" }, { "docid": "5da229d7591afa2f06aca847d4eca0a2", "score": "0.47498348", "text": "func (*MoveClusterRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{13}\n}", "title": "" }, { "docid": "513823683c73be67bf6fc08223da3b6e", "score": "0.474919", "text": "func (*CreateClusterMetadata) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "0d9e0e79a3227fde2f233b1bd3397715", "score": "0.47407192", "text": "func (p *Parameters) MarshalLogObject(oe zapcore.ObjectEncoder) error {\n\toe.AddUint(logNReplicas, p.NReplicas)\n\toe.AddUint(logNMaxErrors, p.NMaxErrors)\n\toe.AddUint(logConcurrency, p.Concurrency)\n\toe.AddDuration(logTimeout, p.Timeout)\n\treturn nil\n}", "title": "" }, { "docid": "df7af97f0396e03ebd87e6cdb4218d54", "score": "0.47336572", "text": "func MarshalCluster(object *Cluster, writer io.Writer) error {\n\tstream := helpers.NewStream(writer)\n\twriteCluster(object, stream)\n\terr := stream.Flush()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn stream.Error\n}", "title": "" }, { "docid": "60e0d546b3a8b91137831ab6fe2c6f96", "score": "0.4733608", "text": "func (*RestoreClusterRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{17}\n}", "title": "" }, { "docid": "5c594fcfa4696a5cd1a044910c99731c", "score": "0.47260785", "text": "func (v *AddSearchAttributeRequest) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.SearchAttribute != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"searchAttribute\", (_Map_String_IndexedValueType_Zapper)(v.SearchAttribute)))\n\t}\n\tif v.SecurityToken != nil {\n\t\tenc.AddString(\"securityToken\", *v.SecurityToken)\n\t}\n\treturn err\n}", "title": "" }, { "docid": "c6cf8013d62f97ef5cea2bd377d59e48", "score": "0.47205508", "text": "func (mr *MockNativelbClientMockRecorder) Cluster(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Cluster\", reflect.TypeOf((*MockNativelbClient)(nil).Cluster), arg0)\n}", "title": "" }, { "docid": "0e209ef935e85d9f02fdee37f546e3ed", "score": "0.47082067", "text": "func (*UpdateClusterMetadata) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{6}\n}", "title": "" }, { "docid": "50199a918fce6e4227aff151b8e7db12", "score": "0.46950862", "text": "func (v *AdminService_GetDynamicConfig_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {\n\tif v == nil {\n\t\treturn nil\n\t}\n\tif v.Success != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"success\", v.Success))\n\t}\n\tif v.BadRequestError != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"badRequestError\", v.BadRequestError))\n\t}\n\tif v.InternalServiceError != nil {\n\t\terr = multierr.Append(err, enc.AddObject(\"internalServiceError\", v.InternalServiceError))\n\t}\n\treturn err\n}", "title": "" }, { "docid": "980ad157b2160a263adce7ef4d48ef8f", "score": "0.46946868", "text": "func (c *jsiiProxy_CfnCluster) ToString() *string {\n\tvar returns *string\n\n\t_jsii_.Invoke(\n\t\tc,\n\t\t\"toString\",\n\t\tnil, // no parameters\n\t\t&returns,\n\t)\n\n\treturn returns\n}", "title": "" }, { "docid": "85489941051ebdb1930a7c7f2bbca71c", "score": "0.46935147", "text": "func (m ManagementCluster) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"clusterId\", m.ClusterID)\n\tpopulate(objectMap, \"clusterSize\", m.ClusterSize)\n\tpopulate(objectMap, \"hosts\", m.Hosts)\n\tpopulate(objectMap, \"provisioningState\", m.ProvisioningState)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "e27fb4b2a26ef72ac9d7ed99a0b3cc29", "score": "0.46847224", "text": "func (b BackendServiceFabricClusterProperties) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"clientCertificateId\", b.ClientCertificateID)\n\tpopulate(objectMap, \"clientCertificatethumbprint\", b.ClientCertificatethumbprint)\n\tpopulate(objectMap, \"managementEndpoints\", b.ManagementEndpoints)\n\tpopulate(objectMap, \"maxPartitionResolutionRetries\", b.MaxPartitionResolutionRetries)\n\tpopulate(objectMap, \"serverCertificateThumbprints\", b.ServerCertificateThumbprints)\n\tpopulate(objectMap, \"serverX509Names\", b.ServerX509Names)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "640e9d9eb0947e582c49f10f215817e5", "score": "0.46841908", "text": "func (*StartClusterRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{9}\n}", "title": "" }, { "docid": "50f4430e823adfc6783cb2f0a279b33c", "score": "0.46777037", "text": "func (*BackupClusterMetadata) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{16}\n}", "title": "" }, { "docid": "cf7d4073ac7750c1669d9299f10045c7", "score": "0.4670122", "text": "func (s KafkaCluster) String() string {\n\treturn awsutil.Prettify(s)\n}", "title": "" }, { "docid": "4406111578e7f4a6c3e38a3ce564a47b", "score": "0.4660672", "text": "func (c Cluster) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"id\", c.ID)\n\tpopulate(objectMap, \"name\", c.Name)\n\tpopulate(objectMap, \"properties\", c.Properties)\n\tpopulate(objectMap, \"sku\", c.SKU)\n\tpopulate(objectMap, \"type\", c.Type)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "8f77d9b628526e0c0a64ea175ac6dc35", "score": "0.46565646", "text": "func (*DeleteClusterRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{7}\n}", "title": "" } ]
e43178cdc43ac69f86e88fd80ec7b570
BitSet.RandChar returns a single randomly chosen BitSet element. Control characters are avoided unless nothing else is available.
[ { "docid": "48d3b6cc4f3cf86c0292eb6a3c84bf2d", "score": "0.8049546", "text": "func (b *BitSet) RandChar() rune {\n\tlow := b.LowBit() // lowest eligible char\n\thigh := b.HighBit() // highest eligible char\n\tif low < ' ' || high > '~' { // if range extends beyond ASCII printables\n\t\tb2 := b.AndNot(CtrlSet) // remove the control characters\n\t\tif !b2.IsEmpty() { // and use that set if non-empty\n\t\t\tlow = b2.LowBit()\n\t\t\thigh = b2.HighBit()\n\t\t}\n\t}\n\t// pick a random char between low and high inclusive.\n\t// if it's part of the set, we're done.\n\tc := low + rand.Intn(high-low+1)\n\tif b.Test(c) {\n\t\treturn rune(c)\n\t}\n\t// otherwise, pick a random stride and find one.\n\tspan := high - low + 1\n\tstride := rand.Intn(span)\n\tfor GCD(stride, span) > 1 {\n\t\tstride--\n\t}\n\tc = low + ((c - low + stride) % span)\n\tfor !b.Test(c) {\n\t\tc = low + ((c - low + stride) % span)\n\t}\n\treturn rune(c)\n}", "title": "" } ]
[ { "docid": "22f9e0b8bede4f305d816a992928c343", "score": "0.5832909", "text": "func Random(availableChars string, length int) (string, error) {\n\tavailableCharLength := len(availableChars)\n\tif availableCharLength == 0 || availableCharLength > 256 {\n\t\tpanic(\"availableChars length must be greater than 0 and less than or equal to 256\")\n\t}\n\n\tvar bitLength byte\n\n\tvar bitMask byte\n\n\tfor bits := availableCharLength - 1; bits != 0; {\n\t\tbits >>= 1\n\t\tbitLength++\n\t}\n\n\tbitMask = 1<<bitLength - 1\n\n\tbufferSize := length + length/3 //nolint:gomnd\n\n\tvar err error\n\n\tresult := make([]byte, length)\n\n\tfor i, j, rb := 0, 0, []byte{}; i < length; j++ { //nolint:varnamelen\n\t\tif j%bufferSize == 0 {\n\t\t\trb, err = randomBytes(bufferSize)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t}\n\n\t\tif idx := int(rb[j%length] & bitMask); idx < availableCharLength {\n\t\t\tresult[i] = availableChars[idx]\n\t\t\ti++\n\t\t}\n\t}\n\n\treturn string(result), nil\n}", "title": "" }, { "docid": "4113ae9ca916a5d3d111e8fe83ee9b75", "score": "0.5820164", "text": "func (b1 *BitSet) CharCompl() *BitSet {\n\tb3 := new(BitSet)\n\tb3.Bits.Xor(&b1.Bits, &AllChars.Bits)\n\treturn b3\n}", "title": "" }, { "docid": "c6ca5c61bd3d9aa28c2548873bd638d3", "score": "0.570591", "text": "func randomKanji() rune {\n\tdist := uint32(0x9faf - 0x4e00)\n\tr := rand.Uint32()\n\treturn rune(0x4e00 + (r % dist))\n}", "title": "" }, { "docid": "3bbf3196b11501ae3efb40007d953349", "score": "0.5684558", "text": "func genChar(minLen int) string {\n\trand.Seed(time.Now().UnixNano())\n\n\tvalidChars := []byte(\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") // 62 uniq chars\n\tvar chars []byte\n\n\tttlValidChars := len(validChars)\n\n\tfor len(chars) < minLen {\n\t\trnum := rand.Intn(ttlValidChars)\n\n\t\tchars = append(chars, validChars[rnum])\n\t}\n\n\treturn string(chars)\n}", "title": "" }, { "docid": "8370350616b125dc5abe64fdbd6736f0", "score": "0.56309724", "text": "func (s WordSet) ChooseOneRandom() Word {\n\tif len(s) == 0 {\n\t\tpanic(\"ChooseOneRandom on empty WordSet\")\n\t}\n\tofs := rand.Int() % len(s)\n\ti := 0\n\tfor w := range s {\n\t\tif i == ofs {\n\t\t\treturn w\n\t\t}\n\t\ti++\n\t}\n\tpanic(\"ChooseOneRandom on empty WordSet\")\n}", "title": "" }, { "docid": "7d70a530656513e1e8cbfa961e59d2fc", "score": "0.5494178", "text": "func getRandomByte() []byte {\n\tconst letterBytes = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\t// seeding the random number generator.\n\trand.Seed(UTCNow().UnixNano())\n\t// pick a character randomly.\n\treturn []byte{letterBytes[rand.Intn(len(letterBytes))]}\n}", "title": "" }, { "docid": "aca17ec82622a6ca30a54aef15125b38", "score": "0.54454803", "text": "func (rs *Set) Random() (string, error) {\n\tconn := rs.pool.Get(rs.dbindex)\n\tresult, err := conn.Do(\"SRANDMEMBER\", rs.id)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn redis.String(result, err)\n}", "title": "" }, { "docid": "e717d7bc53d89f838bc5dd1065726600", "score": "0.5437086", "text": "func R(o, r int) rune {\n\treturn rune(rand.Intn(r) + o)\n}", "title": "" }, { "docid": "f47b3ea1a790d35e8d273e3e107bb6e1", "score": "0.5423879", "text": "func getRandomByte() []byte {\n\tconst letterBytes = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\t// seeding the random number generator.\n\trand.Seed(time.Now().UnixNano())\n\tvar b byte\n\t// pick a character randomly.\n\tb = letterBytes[rand.Intn(len(letterBytes))]\n\treturn []byte{b}\n}", "title": "" }, { "docid": "acfe820b34588bab66d18271141a6f50", "score": "0.53977704", "text": "func randomPassWord() []byte {\n\tpw := make([]byte, pwSize)\n\tfor i := range pw {\n\t\tpw[i] = charSet[rand.Intn(62)]\n\t}\n\treturn pw\n}", "title": "" }, { "docid": "f61c01609bd36d6dc15938502e2b8985", "score": "0.5390211", "text": "func Rand() string {\n\tb := make([]byte, length)\n\tr := make([]byte, length+(length/4)) // storage for random bytes.\n\tclen := byte(len(chars))\n\tmaxrb := byte(256 - (256 % len(chars)))\n\ti := 0\n\tfor {\n\t\tio.ReadFull(rand.Reader, r)\n\t\tfor _, c := range r {\n\t\t\tif c >= maxrb {\n\t\t\t\t// Skip this number to avoid modulo bias.\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tb[i] = chars[c%clen]\n\t\t\ti++\n\t\t\tif i == length {\n\t\t\t\treturn string(b)\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "53ddd339b988a4711debf71e7a137665", "score": "0.5357289", "text": "func RandString(length int, isDigital bool) string {\n var char string\n if isDigital {\n char = Digits\n } else {\n char = AsciiLetters + Digits\n }\n bytes := make([]byte, length)\n for i := 0; i < length; i++ {\n bytes[i] = char[rand.Intn(len(char)-1)]\n }\n return string(bytes)\n}", "title": "" }, { "docid": "35a6fed2d57308991894681d3e0b1023", "score": "0.5347106", "text": "func randomKey() string {\n\trunes := []rune(\"0123456789abcdefghijklmnopqrstuvwxyz\")\n\tb := make([]rune, 16)\n\tfor i := range b {\n\t\tb[i] = runes[rand.Intn(len(runes))]\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "722d64139e5eaf022e005e4d8fa9c382", "score": "0.53395253", "text": "func (c *CHD) GetRandomKey() []byte {\n\tif len(c.keys) == 0 {\n\t\treturn nil\n\t}\n\treturn c.keys[rand.Intn(len(c.keys))]\n}", "title": "" }, { "docid": "077839ec1bf404a45a93bbdbef29ea80", "score": "0.53338146", "text": "func randLetter(pc string) byte {\nL1:\n\tc := (byte)(rand.Uint32() & 0xFF)\n\tif (c < 0x20) || strings.ContainsAny(string(c), pc) {\n\t\tgoto L1\n\t}\n\treturn c\n}", "title": "" }, { "docid": "127964d6f2b38f9b8b0e2e42f729cd07", "score": "0.5275538", "text": "func RandomDnaSymbol() byte {\n\ti := rand.Intn(4) // integer btw 0 and 3 inclusively\n\tsymbols := []byte{'A', 'C', 'G', 'T'}\n\treturn symbols[i]\n}", "title": "" }, { "docid": "17a4ee503a1a2add730c4ea24698c67b", "score": "0.5265459", "text": "func RandomString(n int, symbols bool) (string, error) {\n\tletter := []rune(CharacterSet)\n\tif !symbols {\n\t\tletter = []rune(CharacterSetNoSymbols)\n\t}\n\n\tb := make([]rune, n)\n\tfor i := 0; i < n; i++ {\n\t\tc, err := rand.Int(rand.Reader, big.NewInt(int64(len(letter))))\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tb[i] = letter[c.Int64()]\n\t}\n\treturn string(b), nil\n}", "title": "" }, { "docid": "70bcc074fb07bf4999b5cd233823483c", "score": "0.5264485", "text": "func GenRandomString() string {\n\tresult := make([]byte, answerLength)\n\tfor i := range result {\n\t\tresult[i] = letterBytes[rand.Intn(len(letterBytes))]\n\t}\n\treturn string(result)\n}", "title": "" }, { "docid": "ab87cbfabdd0ced12d4cdaf141a2585c", "score": "0.5261625", "text": "func RandomLabel() string {\n\tnumbers := []rune(\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\")\n\tb := make([]rune, 5)\n\tfor i := range b {\n\t\tb[i] = numbers[rand.Intn(len(numbers))]\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "5e95a967696ed7db80565477f17ca984", "score": "0.52345026", "text": "func Random(n int, a []rune) string {\n\tl := len(a)\n\tb := make([]rune, n)\n\tfor i := range b {\n\t\tb[i] = a[rand.Intn(l)]\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "225ac00e4de03dbab772cf3dc0e9dfb4", "score": "0.5230754", "text": "func (c *Chance) Character() string {\n\tcategories := reflect.ValueOf(data.Characters).MapKeys()\n\tcategory := categories[0].Interface().(string) // Golang natively randomize its key orders, hence simply picking the first item is sufficient.\n\trandomIndex := c.Rand.Intn(len(data.Characters[category]))\n\treturn string(data.Characters[category][randomIndex])\n}", "title": "" }, { "docid": "90eaee276d7c916a21c1ad12008176d7", "score": "0.5222715", "text": "func randomBits(b []byte) {\n\tif _, err := io.ReadFull(rander, b); err != nil {\n\t\tpanic(err.Error()) // rand should never fail\n\t}\n}", "title": "" }, { "docid": "44e7725e1c3069e7ae634fb30b430a63", "score": "0.5220805", "text": "func RandomStr(n int) string {\n\tb := make([]rune, n)\n\tfor i := range b {\n\t\tb[i] = defaultLetters[rand.Intn(defaultLettersLen)]\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "70565d5731b06fc9333638e5e17e7d4a", "score": "0.52124834", "text": "func genRandString(n int) string {\n b := make([]byte, n)\n for i := range b {\n b[i] = letterBytes[rand.Intn(len(letterBytes))]\n }\n return string(b)\n}", "title": "" }, { "docid": "a836b4285de3fa82ea4e61680fd4f1e1", "score": "0.5198016", "text": "func GenerateRandomString(length int) string {\n var charset string\n var bytes []byte\n var i int\n\n charset = \"abcdefghijklmnopqrstuvwxyz\" +\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\n bytes = make([]byte, length)\n\n for i = 0; i < length; i++ {\n bytes[i] = charset[rand.Intn(len(charset))]\n }\n\n return string(bytes)\n}", "title": "" }, { "docid": "f4a370374ff1be662861b5d160cf2546", "score": "0.51933914", "text": "func String(length int) string {\n\tb := make([]byte, length)\n\tfor i := range b {\n\t\tb[i] = charset[seededRand.Intn(len(charset))]\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "ec445a2a5498ea595d5220308a137576", "score": "0.51845735", "text": "func RandomString(length int) string {\n\tconst charset = \"abcdefghijklmnopqrstuvwxyz\"\n\n\tb := make([]byte, length)\n\tfor i := range b {\n\t\tb[i] = charset[seededRand.Intn(len(charset))]\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "d4f32a82226b774a6f2c06c72feed99b", "score": "0.51845115", "text": "func RandomString(n int, allowedChars ...[]rune) string {\n\tvar letters []rune\n\n\tif len(allowedChars) == 0 {\n\t\tletters = defaultLetters\n\t} else {\n\t\tletters = allowedChars[0]\n\t}\n\n\tb := make([]rune, n)\n\tfor i := range b {\n\t\tb[i] = letters[rand.Intn(len(letters))]\n\t}\n\n\treturn string(b)\n}", "title": "" }, { "docid": "a034c4d3eb931c9a7c4b776ec21d9e61", "score": "0.517511", "text": "func RandomString(n int, allowedChars ...[]rune) string {\n\tvar letters []rune\n\tif len(allowedChars) == 0 {\n\t\tletters = defaultLetters\n\t} else {\n\t\tletters = allowedChars[0]\n\t}\n\n\tb := make([]rune, n)\n\tfor i := range b {\n\t\tb[i] = letters[rand.Intn(len(letters))]\n\t}\n\n\treturn string(b)\n}", "title": "" }, { "docid": "816a31249510e7da7efef6a53d68125a", "score": "0.51712817", "text": "func randomString(n int) string {\n\tb := make([]rune, n)\n\tfor i := range b {\n\t\tb[i] = characterRunes[rand.Intn(len(characterRunes))]\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "88720fb1aea374a3460c69a7fca8976c", "score": "0.51634616", "text": "func (l Words) Random() string {\n\treturn l[rand.Intn(len(l))]\n}", "title": "" }, { "docid": "8b5029d3b7ec0d5c03910fb04b03a2cf", "score": "0.5163298", "text": "func Random(n int) string {\n\tsrc := rand.NewSource(time.Now().UnixNano())\n\tb := make([]byte, n)\n\t// A src.Int63() generates 63 random bits,\n\t// enough for letterIdxMax characters!\n\tfor i, cache, remain := n-1, int63(src), letterIdxMax; i >= 0; {\n\t\tif remain == 0 {\n\t\t\tcache, remain = int63(src), letterIdxMax\n\t\t}\n\t\tif idx := int(cache & letterIdxMask); idx < len(letterBytes) {\n\t\t\tb[i] = letterBytes[idx]\n\t\t\ti--\n\t\t}\n\t\tcache >>= letterIdxBits\n\t\tremain--\n\t}\n\n\treturn string(b)\n}", "title": "" }, { "docid": "20f1b9c24375ff55011f313c858ccf9b", "score": "0.5162729", "text": "func RandomAlphaDigitByte() byte {\n\treturn alphaDigits[RandomInt(0, len(alphaDigits)-1)]\n}", "title": "" }, { "docid": "f250f8acd270a4f7b2713bc3047b1ddc", "score": "0.51605475", "text": "func RandomASCII(n int) string {\n\treturn Random(n, Alphabet)\n}", "title": "" }, { "docid": "15865f4714314ac8fd22875f9301eed0", "score": "0.51404804", "text": "func String(l int) string {\n\tvar res string\n\tll := len(chars)\n\tfor i := 0; i < l; i++ {\n\t\tres = res + string(chars[rand.Intn(ll)])\n\t}\n\n\treturn res\n}", "title": "" }, { "docid": "018a0a7924c507b6ba8dfb85e3f0c03a", "score": "0.5140096", "text": "func (rs *RandomizedSet) GetRandom() int {\n\tif len(rs.buff) > 0 {\n\t\treturn rs.buff[rand.Intn(len(rs.buff))]\n\t}\n\treturn 0\n}", "title": "" }, { "docid": "a704fae6eef9e5501b47d4b8ad56e783", "score": "0.5123408", "text": "func String(strlen int) string {\n\tresult := make([]byte, strlen)\n\tfor i := range result {\n\t\tresult[i] = chars[r.Intn(len(chars))]\n\t}\n\treturn string(result)\n}", "title": "" }, { "docid": "685ecd5171d87f7794dc611b11907c18", "score": "0.51156974", "text": "func randChoice(list []string) string {\n\trandIndex := rand.Intn(len(list))\n\treturn list[randIndex]\n}", "title": "" }, { "docid": "d2429352fe9730e7fc3f6d80d4a71c26", "score": "0.5112846", "text": "func RandomString(length int, character ...string) string {\n\trandom := strings.Join([]string(character), \"\")\n\tbytes := []byte(random)\n\tres := []byte{}\n\tr := rand.New(rand.NewSource(time.Now().UnixNano()))\n\tfor i := 0; i < length; i++ {\n\t\tres = append(res, bytes[r.Intn(len(bytes))])\n\t}\n\treturn string(res)\n}", "title": "" }, { "docid": "edb2fcff8cae6374b43416796eac5faa", "score": "0.51112795", "text": "func generateRandomString() string {\n\tletterBytes := \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\tb := make([]byte, 64)\n\tfor i := range b {\n\t\tb[i] = letterBytes[rand.Intn(len(letterBytes))]\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "08d96158c99b1c0a88385f0185b48924", "score": "0.5097148", "text": "func RandomString(length int) string {\r\n\tconst chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\r\n\tresult := \"\"\r\n\tfor i := 0; i < length; i++ {\r\n\t\tindex := r.Intn(len(chars))\r\n\t\tresult += chars[index : index+1]\r\n\t}\r\n\treturn result\r\n}", "title": "" }, { "docid": "20d8b52ccc01af9c404f4e5da8b4b5bc", "score": "0.5094765", "text": "func geraString (tam int) string {\n str := make([]byte, tam)\n for i := range str {\n str[i] = letterBytes[rand.Intn(len(letterBytes))]\n }\n return string(str)\n}", "title": "" }, { "docid": "66deb040147406e8804ef24e367b0b0e", "score": "0.5094681", "text": "func CharSet(s string) *BitSet {\n\tcs := new(BitSet)\n\tfor _, ch := range s {\n\t\tcs.Set(int(ch))\n\t}\n\treturn cs\n}", "title": "" }, { "docid": "7a7866c9e5c4146cc1003e70061fd9f9", "score": "0.5058019", "text": "func randomString(length int) string {\n\tconst charset = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\"\n\trandom := make([]byte, length)\n\tfor i := 0; i < length; i++ {\n\t\trandom[i] = charset[rand.Intn(len(charset))]\n\t}\n\treturn string(random)\n}", "title": "" }, { "docid": "ac1f841d92a641b258f15d9f134b5807", "score": "0.5056628", "text": "func randomName() string {\n\treturn fmt.Sprintf(\"%c%c%03d\",\n\t\trune(random.Intn(26)+int('A')),\n\t\trune(random.Intn(26)+int('A')),\n\t\trandom.Intn(maxNum),\n\t)\n}", "title": "" }, { "docid": "07d27c04be43cc4518d8f9ff16442d3e", "score": "0.50505614", "text": "func randomString(n int) []byte {\r\n\r\n\tletters := defaultLetters\r\n\r\n\tb := make([]byte, n)\r\n\tfor i := range b {\r\n\t\tb[i] = letters[rand.Intn(len(letters))]\r\n\t}\r\n\r\n\treturn b\r\n}", "title": "" }, { "docid": "1b59bd70d0fb085f842fa365ac5ae6b0", "score": "0.50488526", "text": "func (h *Hasher) FindRandom() (string, error) {\n\n\tif h.reverse {\n\t\treturn \"\", fmt.Errorf(\"reverse and random dont mix\")\n\t}\n\n\tif err := h.verify(); err != nil {\n\t\treturn \"\", err\n\t}\n\n\th.buffer = make([]byte, h.minLength)\n\n\tfirstAllowedKey := h.allowedKeys[0]\n\tallowedKeysLen := len(h.allowedKeys)\n\n\t// create initial mutation\n\tfor x := 0; x < h.minLength; x++ {\n\t\th.buffer[x] = firstAllowedKey\n\t}\n\n\th.buffer = append(h.buffer, h.suffix...)\n\n\tbuf := make([]byte, len(h.buffer))\n\tcopy(buf, h.buffer)\n\n\tfor {\n\t\tif h.equals() {\n\t\t\treturn string(buf), nil\n\t\t}\n\n\t\t// update mutation of first letters\n\t\tfor roller := 0; roller < h.minLength; roller++ {\n\t\t\tbuf[roller] = h.allowedKeys[rand.Intn(allowedKeysLen)]\n\t\t}\n\n\t\tmutex.Lock()\n\t\tcopy(h.buffer, buf)\n\t\th.try++\n\t\tmutex.Unlock()\n\t}\n}", "title": "" }, { "docid": "a6e235622548f571ffc04f8a3fb5c1d9", "score": "0.5014311", "text": "func RandomString(n int) string {\n\tb := make([]rune, n)\n\trand.Seed(time.Now().UnixNano())\n\tfor i := range b {\n\t\tb[i] = characterRunes[rand.Intn(len(characterRunes))]\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "405ce62c5274f80a3f2c7a717c68c8af", "score": "0.50124055", "text": "func RandByte(n int) []byte {\n\treturn cipher.RandByte(n)\n}", "title": "" }, { "docid": "d906ba1ab168e1e327c9ece91cb028d3", "score": "0.5008812", "text": "func randomLetter() rune {\n\tn := rand.Intn(100000)\n\n\tvar sum int\n\tfor _, lf := range letterFrequencies {\n\t\tsum = sum + lf.PercentThousandths\n\n\t\tif n < sum {\n\t\t\treturn lf.Letter\n\t\t}\n\t}\n\n\treturn letterFrequencies[len(letterFrequencies)-1].Letter\n}", "title": "" }, { "docid": "6feae6d7ec50ab2d8c011f672056acc9", "score": "0.50035995", "text": "func PickRandomName() string {\n\tarray := strings.Split(cnName, \" \")\n\tr := rand.New(rand.NewSource(time.Now().UnixNano()))\n\ti := r.Intn(len(array) - 1)\n\treturn array[i]\n}", "title": "" }, { "docid": "d4efce532cc772aa06766a24164daa7a", "score": "0.49941346", "text": "func generateRandomString() string {\n\tb := make([]byte, 64)\n\tfor i := range b {\n\t\tb[i] = letterBytes[rand.Intn(len(letterBytes))]\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "81a10181b8283903b20f4167dceaa310", "score": "0.49883872", "text": "func RandomString(n int, allowedChars ...[]rune) string {\r\n\tvar defaultLetters = []rune(\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\")\r\n\tvar letters []rune\r\n\tif len(allowedChars) == 0 {\r\n\t\tletters = defaultLetters\r\n\t} else {\r\n\t\tletters = allowedChars[0]\r\n\t}\r\n\tb := make([]rune, n)\r\n\r\n\trand.Seed(time.Now().UnixNano())\r\n\tfor i := range b {\r\n\t\tb[i] = letters[rand.Intn(len(letters))]\r\n\t}\r\n\treturn string(b)\r\n}", "title": "" }, { "docid": "c0a0b4d8678c26ef54e6691c14431e81", "score": "0.49879378", "text": "func randMsg(m []rune, generator *rand.Rand) string {\n\tfor i := range m {\n\t\tm[i] = chars[generator.Intn(len(chars))]\n\t}\n\treturn string(m)\n}", "title": "" }, { "docid": "768e872d3db759b45dae2228d2557971", "score": "0.49853703", "text": "func GetRandomString(n int) string {\n\tletters := []rune(\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\")\n\n\tb := make([]rune, n)\n\tfor i := range b {\n\t\tb[i] = letters[rand.Intn(len(letters))]\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "8d46541c50f3f34cd0c44cbf52109cda", "score": "0.49850005", "text": "func randToken(len int) string {\n\tb := make([]byte, len)\n\trand.Read(b)\n\treturn fmt.Sprintf(\"%x\", b)\n}", "title": "" }, { "docid": "22cd9a2c5b4c7e7e449b7d545cfcad43", "score": "0.4974478", "text": "func randCode(length int) string {\n\trand.Seed(time.Now().UnixNano())\n\tcode := make([]byte, length)\n\tfor i := range code {\n\t\tcode[i] = chars[rand.Intn(len(chars))]\n\t}\n\treturn string(code)\n}", "title": "" }, { "docid": "cf86b8314fd412c78dc75aaa348e8b5c", "score": "0.4974065", "text": "func RandomCPB() api.CPB {\n\tswitch rand.Intn(3) {\n\tcase 0:\n\t\treturn api.CPBYes\n\tcase 1:\n\t\treturn api.CPBCommunicated\n\tcase 2:\n\t\treturn api.CPBNo\n\tdefault:\n\t\tpanic(\"unmatched\")\n\t}\n}", "title": "" }, { "docid": "f11590cf199ccd3ec65616bb41638486", "score": "0.49685752", "text": "func (entropy *Entropy) Char() uint8 {\n\tif entropy.charp >= CHAR_POOL_SIZE {\n\t\tentropy.refreshCharPool()\n\t}\n\tret := entropy.charpool[entropy.charp]\n\tentropy.charp++\n\treturn ret\n}", "title": "" }, { "docid": "c78ac45c69103e5767039304186e38d7", "score": "0.49679676", "text": "func GenerateChallenge() []byte {\n\tb := make([]byte, 16)\n\t_, err := rand.Read(b)\n\tif err != nil {\n\t\tpanic(\"The universe just collapsed\")\n\t}\n\treturn b\n}", "title": "" }, { "docid": "67b1a7d26190246b9157a4421cec0b28", "score": "0.49526218", "text": "func Random() *GF127 {\n\treturn &GF127{rand.Uint64(), rand.Uint64() >> 1}\n}", "title": "" }, { "docid": "c1059445bf9ad7e86ade4710a29821d2", "score": "0.49518186", "text": "func randomString(strlen int) string {\n\tconst chars = \"abcdefghijklmnopqrstuvwxyz0123456789\"\n\tresult := make([]byte, strlen)\n\tfor i := 0; i < strlen; i++ {\n\t\tresult[i] = chars[rand.Intn(len(chars))]\n\t}\n\treturn string(result)\n}", "title": "" }, { "docid": "c1059445bf9ad7e86ade4710a29821d2", "score": "0.49518186", "text": "func randomString(strlen int) string {\n\tconst chars = \"abcdefghijklmnopqrstuvwxyz0123456789\"\n\tresult := make([]byte, strlen)\n\tfor i := 0; i < strlen; i++ {\n\t\tresult[i] = chars[rand.Intn(len(chars))]\n\t}\n\treturn string(result)\n}", "title": "" }, { "docid": "c1059445bf9ad7e86ade4710a29821d2", "score": "0.49518186", "text": "func randomString(strlen int) string {\n\tconst chars = \"abcdefghijklmnopqrstuvwxyz0123456789\"\n\tresult := make([]byte, strlen)\n\tfor i := 0; i < strlen; i++ {\n\t\tresult[i] = chars[rand.Intn(len(chars))]\n\t}\n\treturn string(result)\n}", "title": "" }, { "docid": "804eee50b07413bf3cb3ef8ddc529765", "score": "0.49448928", "text": "func (this *RandomizedSet) GetRandom() int {\n i := rand.Intn(len(this.a))\n return this.a[i]\n}", "title": "" }, { "docid": "f42e90fa091c589a9c0b0e51fce070ad", "score": "0.49288052", "text": "func RandString(n int) (string, error) {\n\tb := make([]byte, n)\n\n\tfor i := range b {\n\t\tindex, err := rand.Int(rand.Reader, charsetLen)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\n\t\tb[i] = charset[index.Int64()]\n\t}\n\n\treturn string(b), nil\n}", "title": "" }, { "docid": "4adf365cd00b742ca21722422a75f504", "score": "0.4922365", "text": "func Random(rowsNum, colsNum int) (pattern, error) {\n\tif rowsNum == 0 {\n\t\treturn nil, ErrRandomPatternRows\n\t}\n\n\tif colsNum == 0 {\n\t\treturn nil, ErrRandomPatternCols\n\t}\n\n\tmatrix := New(rowsNum, colsNum)\n\n\tfor _, row := range matrix {\n\t\tfor i := range row {\n\t\t\tif rand.Intn(2) == 0 {\n\t\t\t\trow[i] = true\n\t\t\t} else {\n\t\t\t\trow[i] = false\n\t\t\t}\n\t\t}\n\t}\n\n\treturn matrix, nil\n}", "title": "" }, { "docid": "47ded5415275cb52beab846b226c7bab", "score": "0.49216616", "text": "func RandomString(n int) string {\n\tvar letterRunes = []rune(\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\")\n\trand.Seed(time.Now().UnixNano())\n\tb := make([]rune, n)\n\tfor i := range b {\n\t\tb[i] = letterRunes[rand.Intn(len(letterRunes))]\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "462e812f3714ccd342e45ec62e13230f", "score": "0.492099", "text": "func TestGetBitDataSingleChar(t *testing.T) {\n\tconst s1 = \"a\" // 01100001\n\tvar (\n\t\ta = assert.New(t)\n\t\tb1, e1 = bd.GetBitData(s1)\n\t\ts1check = []bool{true, false, false, false, false, true, true} // binary for a (reverse)\n\t)\n\n\ta.Nil(e1, \"Error in conversion 'a'\")\n\ta.Equal(uint64(8), b1.Len, \"Length of 'a' in bits should be 7\")\n\tfor i, bitCheck := range s1check {\n\t\tcheck1bit, _ := b1.GetBit(uint64(i))\n\t\ta.Equal(bitCheck, check1bit, \"Not equals in position: \"+string(i))\n\t}\n}", "title": "" }, { "docid": "88a96d09d16186cc8582b61f278aac87", "score": "0.49147376", "text": "func (c *CHD) GetRandomValue() []byte {\n\tif len(c.keys) == 0 {\n\t\treturn nil\n\t}\n\treturn c.values[rand.Intn(len(c.keys))]\n}", "title": "" }, { "docid": "b9515640287f8a720199ab2c295de2f4", "score": "0.49144807", "text": "func GetRandByte(R *bindings.Rand) (rtn int) {\n\n\trtn = bindings.GetRandByte(R)\n\n\treturn\n}", "title": "" }, { "docid": "117a99c06855c10d032696f5c66332b5", "score": "0.49141628", "text": "func Random(bits int) string {\n\tresult := make([]byte, bits/8)\n\t_, err := io.ReadFull(rand.Reader, result)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Error generating random values: %v\", err))\n\t}\n\n\treturn base64.RawURLEncoding.EncodeToString(result)\n}", "title": "" }, { "docid": "b6dd5a86f38c2b9f2437129b18216e44", "score": "0.49101332", "text": "func (this *RandomizedSet) GetRandom() int {\n return this.nums[rand.Intn(len(this.nums))]\n}", "title": "" }, { "docid": "25f6995419dffceb78e885d74f86284f", "score": "0.49087664", "text": "func Random_string(n int) string {\n\tvar letter = []rune(\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\")\n\n\tb := make([]rune, n)\n\tfor i := range b {\n\t\tb[i] = letter[rand.Intn(len(letter))]\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "16e00aa370475937f1be2819305c2a10", "score": "0.49065033", "text": "func RandomPassword() string {\n\tsize := 10\n\trandom := rand.New(NewCryptoSeededSource())\n\n\tbytes := make([]byte, size)\n\thasNumber := false\n\thasLowercase := false\n\thasUppercase := false\n\tvar last byte = 0\n\tfor i := 0; i < size; i++ {\n\t\tif size > 2 && i == size-1 && hasUppercase == false {\n\t\t\tc := 'B' + uint8(random.Int31n(25))\n\t\t\tif c == 'O' {\n\t\t\t\tc = 'A'\n\t\t\t}\n\t\t\t//fmt.Println(\"Force uppercase\", string(c), \"for\", string(bytes))\n\t\t\tbytes[i] = c\n\t\t\tcontinue\n\t\t}\n\t\tif size > 3 && i == size-2 && hasLowercase == false {\n\t\t\tc := 'b' + uint8(random.Int31n(25))\n\t\t\tif c == 'l' {\n\t\t\t\tc = 'a'\n\t\t\t}\n\t\t\t//fmt.Println(\"Force lowercase\", string(c), \"for\", string(bytes))\n\t\t\tbytes[i] = c\n\t\t\tcontinue\n\t\t}\n\t\tif size > 4 && i == size-3 && hasNumber == false {\n\t\t\tc := '2' + uint8(random.Int31n(8))\n\t\t\t//fmt.Println(\"Force number\", string(c), \"for\", string(bytes))\n\t\t\tbytes[i] = c\n\t\t\tcontinue\n\t\t}\n\n\t\tx := random.Intn(len(rst))\n\t\tc := rst[x]\n\n\t\tif c == last || c == last+1 {\n\t\t\ti = i - 1\n\t\t\t//fmt.Println(\"avoid increment\", last, c)\n\t\t\tcontinue\n\t\t}\n\n\t\tif c <= '9' {\n\t\t\thasNumber = true\n\t\t} else if c <= 'Z' {\n\t\t\thasUppercase = true\n\t\t} else {\n\t\t\thasLowercase = true\n\t\t}\n\n\t\tbytes[i] = c\n\t\tlast = c\n\t}\n\ts := string(bytes)\n\treturn s[0:5] + \"-\" + s[5:]\n}", "title": "" }, { "docid": "5d31e67378966a31e48f81e2f3297376", "score": "0.49032742", "text": "func RandomBuf(size int) ([]byte, error) {\n\tbuf := make([]byte, size)\n\trand.Seed(time.Now().UTC().UnixNano())\n\tmin, max := 30, 127\n\tfor i := 0; i < size; i++ {\n\t\tbuf[i] = byte(min + rand.Intn(max-min))\n\t}\n\treturn buf, nil\n}", "title": "" }, { "docid": "6512c906b3f438ab04a1817713a3af2a", "score": "0.4898314", "text": "func randomString(length int16) string {\n\tvar charset = \"abcdefghijklmnopqrstuvwxyz\" +\n\t\t\"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\"\n\n\tvar seededRand = rand.New(\n\t\trand.NewSource(time.Now().UnixNano()))\n\n\tb := make([]byte, length)\n\tfor i := range b {\n\t\tb[i] = charset[seededRand.Intn(len(charset))]\n\t}\n\n\treturn string(b)\n}", "title": "" }, { "docid": "7dd1af8db6e1fd0c468f6321906588e0", "score": "0.4896202", "text": "func RandomAlphaLowerByte() byte {\n\treturn alphaLower[RandomInt(0, len(alphaLower)-1)]\n}", "title": "" }, { "docid": "284a670eb595aaa6f2856a437ec595af", "score": "0.48901188", "text": "func Random() NBID {\n\tvar id NBID\n\n\trand.Read(id[:]) //nolint:errcheck\n\n\treturn id\n}", "title": "" }, { "docid": "8bb187aba128bee1fe16522bef78c897", "score": "0.4888281", "text": "func (r *RandPacketT) RandByte() byte {\n\n\tnum := r.Rand.Intn(255)\n\tmByte := uint8(num)\n\n\treturn mByte\n}", "title": "" }, { "docid": "ffea406eab135eb6a1bbc46f309edd26", "score": "0.48786166", "text": "func Random(byteCount int) ([]byte, error) {\n\tdata := make([]byte, byteCount)\n\n\tif _, err := rand.Read(data); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn data, nil\n}", "title": "" }, { "docid": "99543d33dcca11d8e629c0cc8295e514", "score": "0.48731366", "text": "func randRegister() uint8 {\n\treturn uint8(rand.Intn(15))\n}", "title": "" }, { "docid": "84a9442ef284eec7b1b0b6292ebda491", "score": "0.48651782", "text": "func getRandom(i int) string {\n\tb := make([]byte, i)\n\tfor {\n\t\t// keep trying till we get it\n\t\tif _, err := rand.Read(b); err != nil {\n\t\t\tcontinue\n\t\t}\n\t\treturn fmt.Sprintf(\"%x\", b)\n\t}\n}", "title": "" }, { "docid": "56a4e6836e24837faf5bd1d430be82fa", "score": "0.48561624", "text": "func RandString(length int) string {\n\tletters := []rune(\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\")\n\n\tb := make([]rune, length)\n\n\tfor i := range b {\n\t\tb[i] = letters[rand.Intn(len(letters))]\n\t}\n\n\treturn string(b)\n}", "title": "" }, { "docid": "47e22e2713702928eb919aa9df670249", "score": "0.485208", "text": "func (r *Redis) RandomKey() ([]byte, error) {\n\trp, err := r.ExecuteCommand(\"RANDOMKEY\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn rp.BytesValue()\n}", "title": "" }, { "docid": "f448bf7a439ac02c58e3cca187b0cd5a", "score": "0.4849287", "text": "func randomLowercase() string {\n\treturn string(lowercaseSet[rand.Intn(lowercaseSetLen)])\n}", "title": "" }, { "docid": "e6ec7a0460dbb2f4feefa9f3f852fb02", "score": "0.48471907", "text": "func get_random_value() string {\n\trand.Seed(time.Now().UnixNano())\n\tc := \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\"\n\tbuf := make([]byte, 40)\n\tfor i := 0; i < 40; i++ {\n\t\tbuf[i] = c[rand.Intn(len(c)-1)]\n\t}\n\treturn string(buf)\n}", "title": "" }, { "docid": "729f0aa805f4f3598d0c3d056fc4dbc6", "score": "0.4833692", "text": "func RandomString(n int) string {\n\tb := make([]byte, n)\n\tfor i := range b {\n\t\tb[i] = letterBytes[GetRand().Intn(len(letterBytes))]\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "229ae9c9ddd705bf0144be582c135f87", "score": "0.48312226", "text": "func RandomString(length int, letter bool, digit bool, special bool) string {\n\tdigits := \"0123456789\"\n\tspecials := \"~=+%^*/()[]{}/!@#$?|\"\n\tletters := \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\n\tchars := \"\"\n\trandomString := make([]byte, length)\n\n\tif letter {\n\t\tchars = chars + letters\n\t}\n\tif digit {\n\t\tchars = chars + digits\n\t}\n\tif special {\n\t\tchars = chars + specials\n\t}\n\tif !letter && !digit && !special {\n\t\tchars = digits + letters\n\t}\n\n\tmrand.Seed(time.Now().UnixNano())\n\tfor i := 0; i < length; i++ {\n\t\trandomString[i] = chars[mrand.Intn(len(chars))]\n\t}\n\n\treturn string(randomString)\n}", "title": "" }, { "docid": "c2b28b50d52237806c2e8c398ab76471", "score": "0.48209217", "text": "func getRandString(n int) string {\n\tletterBytes := \"abcdefghijklmnopqrstuvwxyz\"\n\tb := make([]byte, n)\n\tfor i := range b {\n\t\tb[i] = letterBytes[rand.Intn(len(letterBytes))]\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "be83e6c215f7dfa7770656863f05a4e1", "score": "0.48168153", "text": "func RandomString(t *testing.T, strlen int) string {\n\trand.Seed(time.Now().UTC().UnixNano())\n\tconst chars = \"abcdefghijklmnopqrstuvwxyz0123456789\"\n\tresult := make([]byte, strlen)\n\tfor i := 0; i < strlen; i++ {\n\t\tresult[i] = chars[rand.Intn(len(chars))]\n\t}\n\treturn string(result)\n}", "title": "" }, { "docid": "be83e6c215f7dfa7770656863f05a4e1", "score": "0.48168153", "text": "func RandomString(t *testing.T, strlen int) string {\n\trand.Seed(time.Now().UTC().UnixNano())\n\tconst chars = \"abcdefghijklmnopqrstuvwxyz0123456789\"\n\tresult := make([]byte, strlen)\n\tfor i := 0; i < strlen; i++ {\n\t\tresult[i] = chars[rand.Intn(len(chars))]\n\t}\n\treturn string(result)\n}", "title": "" }, { "docid": "7480343148becc64c71a463fd9ca0ed2", "score": "0.48128432", "text": "func testPassword(length int) string {\n\tif length < 5 {\n\t\tlength = 4\n\t}\n\tresult := make([]byte, length)\n\tresult[0] = charSetAlphaLower[rand.Intn(len(charSetAlphaLower))]\n\tresult[1] = charSetAlphaUpper[rand.Intn(len(charSetAlphaUpper))]\n\tresult[2] = charSetNumeric[rand.Intn(len(charSetNumeric))]\n\tfor i := 3; i < length; i++ {\n\t\tresult[i] = charSetAlpha[rand.Intn(len(charSetAlpha))]\n\t}\n\treturn string(result)\n}", "title": "" }, { "docid": "a24156cb899fedb573adcc6a6f99eff3", "score": "0.48114103", "text": "func RandomKey(length int) (string, error) {\n\tmaxNum := big.NewInt(26)\n\trunes := make([]rune, length)\n\tfor i := 0; i < length; i++ {\n\t\tnBig, err := rand.Int(rand.Reader, maxNum)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\trunes[i] = rune(nBig.Int64()) + 'A'\n\t}\n\treturn string(runes), nil\n}", "title": "" }, { "docid": "db894e59fd89b1482b6d1fe5e4490dc8", "score": "0.4808272", "text": "func NewRandomChallenge() string {\n\trandom := make([]byte, 32)\n\tif _, err := rand.Read(random); err != nil {\n\t\tpanic(err)\n\t}\n\tchallenge := make([]byte, base64.StdEncoding.EncodedLen(len(random)))\n\tbase64.StdEncoding.Encode(challenge, random[:])\n\treturn string(challenge)\n}", "title": "" }, { "docid": "9fda23ac0eb70eedd70522d0a23ed7c3", "score": "0.48048458", "text": "func rand() string {\r\n\treturn strconv.FormatInt(time.Now().UnixNano(), 16)\r\n}", "title": "" }, { "docid": "cab0d6a2e8dd660141c5ee757d9ebf20", "score": "0.480278", "text": "func Chr(ascii int) string {\n\n\tfor ascii < 0 {\n\t\tascii += 256\n\t}\n\tascii %= 256\n\n\treturn string(ascii)\n}", "title": "" }, { "docid": "87534a164b1713a37d8ba08a2e97ad45", "score": "0.48024014", "text": "func RandString(n int) string {\n\tletter := []byte(\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\")\n\tb := make([]byte, n)\n\tfor i := range b {\n\t\tb[i] = letter[rand.Intn(len(letter))]\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "8c0845c8fb0a6bbf5b17d9a98f4377e9", "score": "0.47992423", "text": "func randomString(n int) string {\n\tb := make([]byte, n)\n\tfor i, cache, remain := n-1, rand.Int63(), max; i >= 0; {\n\t\tif remain == 0 {\n\t\t\tcache, remain = rand.Int63(), max\n\t\t}\n\t\tif idx := int(cache & mask); idx < len(chars) {\n\t\t\tb[i] = chars[idx]\n\t\t\ti--\n\t\t}\n\t\tcache >>= bitsNeeded\n\t\tremain--\n\t}\n\n\treturn *(*string)(unsafe.Pointer(&b))\n}", "title": "" }, { "docid": "08474d1c169c7fdad70d582f5b0a8ea7", "score": "0.47962648", "text": "func RandomString(strlen int) string {\n\tr := rand.New(rand.NewSource(time.Now().UnixNano()))\n\tconst chars = \"abcdefghijklmnopqrstuvwxyz0123456789\"\n\tresult := make([]byte, strlen)\n\tfor i := range result {\n\t\tresult[i] = chars[r.Intn(len(chars))]\n\t}\n\treturn string(result)\n}", "title": "" } ]
bdd2f81fa3fdaf1216e439439352365d
A Map of additional metadata to associate with the group.
[ { "docid": "5033a800087f275d838ad5c7c5851898", "score": "0.58503336", "text": "func (o GroupOutput) Metadata() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *Group) pulumi.StringMapOutput { return v.Metadata }).(pulumi.StringMapOutput)\n}", "title": "" } ]
[ { "docid": "45c58e81ba009fc4ab4a4b22faf30a46", "score": "0.65476924", "text": "func (module *OffsetStorage) GroupMetadata() map[string]kafka.ConsumerGroupMetadata {\n\tmodule.groupMetadataLock.RLock()\n\tdefer module.groupMetadataLock.RUnlock()\n\n\tmapCopy := make(map[string]kafka.ConsumerGroupMetadata)\n\tfor key, value := range module.groupMetadata {\n\t\tmapCopy[key] = value\n\t}\n\n\treturn mapCopy\n}", "title": "" }, { "docid": "546fc5aa28b8d99c9749449d3bb51fcd", "score": "0.5765113", "text": "func (c *jsiiProxy_CfnGlobalReplicationGroup) AddMetadata(key *string, value interface{}) {\n\t_jsii_.InvokeVoid(\n\t\tc,\n\t\t\"addMetadata\",\n\t\t[]interface{}{key, value},\n\t)\n}", "title": "" }, { "docid": "389eadf3b2916e5e617dab16e8c073bc", "score": "0.5727213", "text": "func (sink *Sink) Metadata() map[string]string {\n\tr := make(map[string]string, len(sink.metadata))\n\tfor k, v := range sink.metadata {\n\t\tr[k] = v\n\t}\n\treturn r\n}", "title": "" }, { "docid": "23b5427d7ef855b91ad24a1e7c51d704", "score": "0.56910586", "text": "func (l *State) Metadata() map[string]string {\n\tl.RLock()\n\tdefer l.RUnlock()\n\n\tm := make(map[string]string)\n\tfor k, v := range l.metadata {\n\t\tm[k] = v\n\t}\n\treturn m\n}", "title": "" }, { "docid": "430719697bd559a1a0cab74bbc450e50", "score": "0.56478894", "text": "func (kc *KeyCreator) Metadata() map[string]string {\n\treturn map[string]string{}\n}", "title": "" }, { "docid": "14b8189bff330f4488da06a8bb6b49e1", "score": "0.560862", "text": "func (c *jsiiProxy_CfnReplicationGroup) AddMetadata(key *string, value interface{}) {\n\t_jsii_.InvokeVoid(\n\t\tc,\n\t\t\"addMetadata\",\n\t\t[]interface{}{key, value},\n\t)\n}", "title": "" }, { "docid": "e92e6d780a2d08b38b59342aab67ad60", "score": "0.5561867", "text": "func (c *jsiiProxy_CfnUserGroup) AddMetadata(key *string, value interface{}) {\n\t_jsii_.InvokeVoid(\n\t\tc,\n\t\t\"addMetadata\",\n\t\t[]interface{}{key, value},\n\t)\n}", "title": "" }, { "docid": "86fa4b5e9b60d5afce8361912e6a45ea", "score": "0.556105", "text": "func (c *jsiiProxy_CfnSubnetGroup) AddMetadata(key *string, value interface{}) {\n\t_jsii_.InvokeVoid(\n\t\tc,\n\t\t\"addMetadata\",\n\t\t[]interface{}{key, value},\n\t)\n}", "title": "" }, { "docid": "ddbc6f6e4a12c2332740090f31546041", "score": "0.55084103", "text": "func (self Canvas) Metadata() map[string]string {\n\tvar n C.ulong\n\tvar i C.ulong\n\n\tvar value *C.char\n\tvar key *C.char\n\n\tdata := make(map[string]string)\n\n\tproperties := C.MagickGetImageProperties(self.wand, C.CString(\"*\"), &n)\n\n\tfor i = 0; i < n; i++ {\n\t\tkey = C.MagickGetPropertyName(properties, C.size_t(i))\n\t\tvalue = C.MagickGetImageProperty(self.wand, key)\n\n\t\tdata[strings.Trim(C.GoString(key), \" \")] = strings.Trim(C.GoString(value), \" \")\n\n\t\tC.MagickRelinquishMemory(unsafe.Pointer(value))\n\t\tC.MagickRelinquishMemory(unsafe.Pointer(key))\n\t}\n\n\treturn data\n}", "title": "" }, { "docid": "e4875febe4faffee8bb9e718ea31fb3a", "score": "0.54353213", "text": "func (m *ImageInfo) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "67bda5271e04d79bd1e21a423bdfdd76", "score": "0.54110926", "text": "func (op *AddAssetsToGroupOperation) Metadata() (*migrationcenterpb.OperationMetadata, error) {\n\tvar meta migrationcenterpb.OperationMetadata\n\tif err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {\n\t\treturn nil, nil\n\t} else if err != nil {\n\t\treturn nil, err\n\t}\n\treturn &meta, nil\n}", "title": "" }, { "docid": "e5e07934944c619523b56328ce92fa75", "score": "0.5397675", "text": "func (m *ContentLabel) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "af85baef7f06e4a024343470f674013b", "score": "0.5387397", "text": "func (i *Instance) AddMetadata(metadata map[string]string) {\n\tvar md []*compute.MetadataItems\n\tfor k, v := range metadata {\n\t\tmd = append(md, &compute.MetadataItems{Key: k, Value: &v})\n\t}\n\tif i.metadata == nil {\n\t\ti.metadata = &compute.Metadata{Items: md}\n\t} else {\n\t\ti.metadata.Items = append(md, i.metadata.Items...)\n\t}\n}", "title": "" }, { "docid": "b3d8e32f75744b631da2498fb098dc65", "score": "0.53821266", "text": "func (c *jsiiProxy_CfnDBSubnetGroup) AddMetadata(key *string, value interface{}) {\n\t_jsii_.InvokeVoid(\n\t\tc,\n\t\t\"addMetadata\",\n\t\t[]interface{}{key, value},\n\t)\n}", "title": "" }, { "docid": "b3d8e32f75744b631da2498fb098dc65", "score": "0.53821266", "text": "func (c *jsiiProxy_CfnDBSubnetGroup) AddMetadata(key *string, value interface{}) {\n\t_jsii_.InvokeVoid(\n\t\tc,\n\t\t\"addMetadata\",\n\t\t[]interface{}{key, value},\n\t)\n}", "title": "" }, { "docid": "1372de73c6a54bd861f8e9a01e792bbc", "score": "0.53664047", "text": "func (m *Metadata) Assemble() map[string]string {\n\tout := make(map[string]string, 0)\n\tfor _, vals := range m.d {\n\t\tfor _, v := range vals {\n\t\t\tif v.Timestamp != 0 {\n\t\t\t\tout[fmt.Sprintf(\"%s@%d\", v.Key, v.Timestamp)] = v.Value\n\t\t\t} else {\n\t\t\t\tout[v.Key] = v.Value\n\t\t\t}\n\t\t}\n\t}\n\treturn out\n}", "title": "" }, { "docid": "0ef4d7776d784de2545d852b118f39c6", "score": "0.5320873", "text": "func (e Event) Metadata(key string) interface{} {\n\treturn e.Msg.Metadata[key]\n}", "title": "" }, { "docid": "8fdaa06f288a213ee9056d0c970126b7", "score": "0.53025156", "text": "func (r *AWSCloudFrontDistribution_DistributionConfig) Metadata() map[string]interface{} {\n\treturn r._metadata\n}", "title": "" }, { "docid": "ab005e45d43d30e4753fbdd55387b2f8", "score": "0.52620304", "text": "func (op *CreateGroupOperation) Metadata() (*migrationcenterpb.OperationMetadata, error) {\n\tvar meta migrationcenterpb.OperationMetadata\n\tif err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {\n\t\treturn nil, nil\n\t} else if err != nil {\n\t\treturn nil, err\n\t}\n\treturn &meta, nil\n}", "title": "" }, { "docid": "1c2a26dd3ea260ba458970b8cebf8e61", "score": "0.5255266", "text": "func (m *UserSimulationEventInfo) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "2597457927c86f7c280149ff9fa82be3", "score": "0.524891", "text": "func (m *AggregationOption) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "5dbca3ca191bf7636d3108da8a9b0aad", "score": "0.5248748", "text": "func (m *SearchAggregation) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "dce89be8e3dc6fb66ffcf403fef1dce0", "score": "0.52458775", "text": "func (list List) Metadata() Map {\n\treturn list.Meta\n}", "title": "" }, { "docid": "6b9372b6f57377b973e09d9764c1a996", "score": "0.5211794", "text": "func (c *jsiiProxy_CfnSecurityGroup) AddMetadata(key *string, value interface{}) {\n\t_jsii_.InvokeVoid(\n\t\tc,\n\t\t\"addMetadata\",\n\t\t[]interface{}{key, value},\n\t)\n}", "title": "" }, { "docid": "cc35b8d0036e16734a19c05c2e257d46", "score": "0.5204666", "text": "func (r *AWSAppMeshVirtualNode_AwsCloudMapServiceDiscovery) Metadata() map[string]interface{} {\n\treturn r._metadata\n}", "title": "" }, { "docid": "082a1437bb76c04634cabcd929a2b62b", "score": "0.52019507", "text": "func (o InstanceGroupManagerAllInstancesConfigOutput) Metadata() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v InstanceGroupManagerAllInstancesConfig) map[string]string { return v.Metadata }).(pulumi.StringMapOutput)\n}", "title": "" }, { "docid": "58e6f6667df704bedfccbff9584c2071", "score": "0.5195327", "text": "func (c *jsiiProxy_CfnDBParameterGroup) AddMetadata(key *string, value interface{}) {\n\t_jsii_.InvokeVoid(\n\t\tc,\n\t\t\"addMetadata\",\n\t\t[]interface{}{key, value},\n\t)\n}", "title": "" }, { "docid": "894f625acbfa0a3a2de899a12b0021d2", "score": "0.51863295", "text": "func (o RegionInstanceGroupManagerAllInstancesConfigOutput) Metadata() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v RegionInstanceGroupManagerAllInstancesConfig) map[string]string { return v.Metadata }).(pulumi.StringMapOutput)\n}", "title": "" }, { "docid": "54499507743eaf7abcd4a3f29412d146", "score": "0.518467", "text": "func GetMetadata() map[string]interface{} {\n\tresult := make(map[string]interface{})\n\n\tfor _, collector := range collectors {\n\t\tc, err := collector.Collect()\n\t\tif err != nil {\n\t\t\tlog.Warnf(\"[%s] %s\", collector.Name(), err)\n\t\t\tcontinue\n\t\t}\n\t\tresult[collector.Name()] = c\n\t}\n\n\treturn result\n}", "title": "" }, { "docid": "48a191f784d0de7aaba22078960fe8e5", "score": "0.517881", "text": "func (o RegionInstanceGroupManagerAllInstancesConfigPtrOutput) Metadata() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *RegionInstanceGroupManagerAllInstancesConfig) map[string]string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Metadata\n\t}).(pulumi.StringMapOutput)\n}", "title": "" }, { "docid": "ca63016b3fdaabc41bd40d1d1f11c9de", "score": "0.5156869", "text": "func (c *jsiiProxy_CfnParameterGroup) AddMetadata(key *string, value interface{}) {\n\t_jsii_.InvokeVoid(\n\t\tc,\n\t\t\"addMetadata\",\n\t\t[]interface{}{key, value},\n\t)\n}", "title": "" }, { "docid": "623375e6a29890c234cd104e20d6373f", "score": "0.51427835", "text": "func (m *AggregationOption) GetAdditionalData()(map[string]interface{}) {\n return m.additionalData\n}", "title": "" }, { "docid": "e3f0c19fbda26dd061faaed2cf8d7258", "score": "0.513575", "text": "func (m *WindowsPackageInformation) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "fa2d071f06242256ba882b241a0bd536", "score": "0.5125979", "text": "func (op *UpdateGroupOperation) Metadata() (*migrationcenterpb.OperationMetadata, error) {\n\tvar meta migrationcenterpb.OperationMetadata\n\tif err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {\n\t\treturn nil, nil\n\t} else if err != nil {\n\t\treturn nil, err\n\t}\n\treturn &meta, nil\n}", "title": "" }, { "docid": "3b85ef81d545332d3b544836efbec8a0", "score": "0.5124892", "text": "func (r Response) Metadata() map[string]interface{} {\n\treturn r.Meta\n}", "title": "" }, { "docid": "331bed487b34778a8077e795f645b603", "score": "0.5123089", "text": "func (o InstanceGroupManagerAllInstancesConfigPtrOutput) Metadata() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *InstanceGroupManagerAllInstancesConfig) map[string]string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Metadata\n\t}).(pulumi.StringMapOutput)\n}", "title": "" }, { "docid": "44a817e62240f190edfcc07c2408f8b2", "score": "0.5105897", "text": "func (vector Vector) Metadata() Map {\n\treturn vector.Meta\n}", "title": "" }, { "docid": "d690df622e686f5fc6316f4729565c3c", "score": "0.5103865", "text": "func (m *Thumbnail) GetAdditionalData()(map[string]interface{}) {\n return m.additionalData\n}", "title": "" }, { "docid": "c333b53dda6875ef27cccc91aa8da934", "score": "0.50986123", "text": "func (t *TestVM) AddMetadata(key, value string) {\n\tcreateVMStep := t.testWorkflow.wf.Steps[createVMsStepName]\n\tfor _, vm := range createVMStep.CreateInstances.Instances {\n\t\tif vm.Name == t.name {\n\t\t\tif vm.Metadata == nil {\n\t\t\t\tvm.Metadata = make(map[string]string)\n\t\t\t}\n\t\t\tvm.Metadata[key] = value\n\t\t\treturn\n\t\t}\n\t}\n}", "title": "" }, { "docid": "bb61f28594d049cb77a9e2649e98e4e9", "score": "0.5091947", "text": "func (m *AccessPackageAssignmentRequestorSettings) GetAdditionalData()(map[string]interface{}) {\n return m.additionalData\n}", "title": "" }, { "docid": "0a8a9efe8af1ae3a04715d67240095d0", "score": "0.50916743", "text": "func (c *jsiiProxy_CfnDBClusterParameterGroup) AddMetadata(key *string, value interface{}) {\n\t_jsii_.InvokeVoid(\n\t\tc,\n\t\t\"addMetadata\",\n\t\t[]interface{}{key, value},\n\t)\n}", "title": "" }, { "docid": "0a8a9efe8af1ae3a04715d67240095d0", "score": "0.50916743", "text": "func (c *jsiiProxy_CfnDBClusterParameterGroup) AddMetadata(key *string, value interface{}) {\n\t_jsii_.InvokeVoid(\n\t\tc,\n\t\t\"addMetadata\",\n\t\t[]interface{}{key, value},\n\t)\n}", "title": "" }, { "docid": "c9d9a58f85cca6820d878137c9845210", "score": "0.5083974", "text": "func (m *Metadata) ToMap() map[string]interface{} {\n\treturn map[string]interface{}{\n\t\t\"voted_answers\": m.VotedAnswers,\n\t\t\"poll_id\": m.PollID,\n\t\t\"user_id\": m.UserID,\n\t\t\"can_manage_poll\": m.CanManagePoll,\n\t\t\"setting_progress\": m.SettingProgress,\n\t\t\"setting_public_add_option\": m.SettingPublicAddOption,\n\t}\n}", "title": "" }, { "docid": "2da24147b21562d6346fd824042c57a5", "score": "0.50637555", "text": "func (c *jsiiProxy_CfnSecurityGroupIngress) AddMetadata(key *string, value interface{}) {\n\t_jsii_.InvokeVoid(\n\t\tc,\n\t\t\"addMetadata\",\n\t\t[]interface{}{key, value},\n\t)\n}", "title": "" }, { "docid": "25e60e0b69a6eb05980210108e39f4ff", "score": "0.5056892", "text": "func (r *AWSECSTaskDefinition_KernelCapabilities) Metadata() map[string]interface{} {\n\treturn r._metadata\n}", "title": "" }, { "docid": "45249c6f02baa9fe863500a8bc3b7440", "score": "0.50559455", "text": "func (n *node) Metadata() map[string]string {\n\treturn n.metadata\n}", "title": "" }, { "docid": "ee8ea4db56d57d53ae4834f12a0e66c5", "score": "0.5052006", "text": "func (p *SetupIntentPaymentMethodDataParams) AddMetadata(key string, value string) {\n\tif p.Metadata == nil {\n\t\tp.Metadata = make(map[string]string)\n\t}\n\n\tp.Metadata[key] = value\n}", "title": "" }, { "docid": "e1bae164689f7636535e23adb7fe4bc8", "score": "0.50466955", "text": "func (tsr *Int) MetaDataMap() map[string]string {\n\treturn tsr.Meta\n}", "title": "" }, { "docid": "7c4e317bfcfad492d0b8b32c6006476d", "score": "0.50438905", "text": "func (m *SimulationEventsContent) GetAdditionalData()(map[string]interface{}) {\n return m.additionalData\n}", "title": "" }, { "docid": "446ccc4deafc66fcaee8102177edba94", "score": "0.504353", "text": "func (r *AWSAmplifyBranch) Metadata() map[string]interface{} {\n\treturn r._metadata\n}", "title": "" }, { "docid": "d9e45ac876adc5bff33ccd8d3af0ecc9", "score": "0.50359863", "text": "func (c *Cache) Metadata() map[string]*metadata.Metadata {\n\tmd := map[string]*metadata.Metadata{}\n\tdefer c.mu.RUnlock()\n\tc.mu.RLock()\n\tfor target, cache := range c.targets {\n\t\tmd[target] = cache.meta\n\t}\n\treturn md\n}", "title": "" }, { "docid": "288d9d57d16140ad70bc33b26c4efca0", "score": "0.50348634", "text": "func getMetadataOutgoing(request *http.Request, response *http.Response) map[string]interface{} {\n\t\n\tvar innerNestedFields = map[string] interface{} {\n\t\t\"nestedInner\": \"test\",\n\t}\n\n\tvar nestedFields = map[string] interface{} {\n\t\t\"inner\": innerNestedFields,\n\t}\n\t\n\tvar metadata = map[string]interface{} {\n\t\t\"foo\" : \"bar\",\n\t\t\"user\": \"golangapiuser\",\n\t\t\"test\": nestedFields,\n\t}\n\treturn metadata\n}", "title": "" }, { "docid": "5e842eee9fc33001da9bf2b3ade0b460", "score": "0.50306576", "text": "func (r *AWSManagedBlockchainMember_NetworkFrameworkConfiguration) Metadata() map[string]interface{} {\n\treturn r._metadata\n}", "title": "" }, { "docid": "19f7099f5caba1d5e097ee67634c8696", "score": "0.5019244", "text": "func (r *AWSPinpointSegment_SegmentDimensions) Metadata() map[string]interface{} {\n\treturn r._metadata\n}", "title": "" }, { "docid": "7aff73c939078f725962bbb8cb09e784", "score": "0.5017669", "text": "func (m *WhoisContact) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "042f8f76b246192da2a5ab565d0a71fb", "score": "0.5014191", "text": "func (imr *InvokeMethodRequest) AddMetadata(md map[string][]string) {\n\tif imr.r.Metadata == nil {\n\t\timr.WithMetadata(md)\n\t\treturn\n\t}\n\n\tfor key, val := range metadataToInternalMetadata(md) {\n\t\t// We're only adding new values, not overwriting existing\n\t\tif _, ok := imr.r.Metadata[key]; !ok {\n\t\t\timr.r.Metadata[key] = val\n\t\t}\n\t}\n}", "title": "" }, { "docid": "a3970ffb5d0e9214931e85073b6a9a1c", "score": "0.50131", "text": "func (p *SetupIntentParams) AddMetadata(key string, value string) {\n\tif p.Metadata == nil {\n\t\tp.Metadata = make(map[string]string)\n\t}\n\n\tp.Metadata[key] = value\n}", "title": "" }, { "docid": "d44837f3db6d891ad92e2662745b4767", "score": "0.50106776", "text": "func (mrc MQTTRequestContext) Metadata() (md map[string]interface{}) {\n\tmd = map[string]interface{}{}\n\tmd[\"action\"] = mrc.Action()\n\tmd[\"token\"] = mrc.Token()\n\tmd[\"xid\"] = mrc.Xid()\n\treturn\n}", "title": "" }, { "docid": "e9aecaf9ed5f17d504d6586371e79a1f", "score": "0.5005368", "text": "func (m *DeviceManagementConfigurationSettingOccurrence) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "b83f1a6425dde944bf868f9cf6c1ddd9", "score": "0.49981338", "text": "func (m *RoleDefinition) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "03f5389a31e3774a41c0bb4317d3c459", "score": "0.49954325", "text": "func (a *App) Metadata() map[string]string { return a.opts.metadata }", "title": "" }, { "docid": "10ee45f171b8fa47982fbd2b770b6d9e", "score": "0.4994245", "text": "func (m *UserExperienceAnalyticsDeviceScopeSummary) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "05e40efd81a0064c15d43522828c87fd", "score": "0.49938932", "text": "func (m *EducationalActivityDetail) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "2f9effd1b679f9bc19beb50dfc7ec982", "score": "0.4993854", "text": "func (o *Object) Metadata(ctx context.Context) (metadata fs.Metadata, err error) {\n\terr = o.readMetaData(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tmetadata = make(fs.Metadata, len(o.meta)+7)\n\tfor k, v := range o.meta {\n\t\tswitch k {\n\t\tcase metaMtime:\n\t\t\tif modTime, err := swift.FloatStringToTime(v); err == nil {\n\t\t\t\tmetadata[\"mtime\"] = modTime.Format(time.RFC3339Nano)\n\t\t\t}\n\t\tcase metaMD5Hash:\n\t\t\t// don't write hash metadata\n\t\tdefault:\n\t\t\tmetadata[k] = v\n\t\t}\n\t}\n\tif o.mimeType != \"\" {\n\t\tmetadata[\"content-type\"] = o.mimeType\n\t}\n\t// metadata[\"x-amz-tagging\"] = \"\"\n\tif !o.lastModified.IsZero() {\n\t\tmetadata[\"btime\"] = o.lastModified.Format(time.RFC3339Nano)\n\t}\n\n\t// Set system metadata\n\tsetMetadata := func(k string, v *string) {\n\t\tif o.fs.opt.NoSystemMetadata {\n\t\t\treturn\n\t\t}\n\t\tif v == nil || *v == \"\" {\n\t\t\treturn\n\t\t}\n\t\tmetadata[k] = *v\n\t}\n\tsetMetadata(\"cache-control\", o.cacheControl)\n\tsetMetadata(\"content-disposition\", o.contentDisposition)\n\tsetMetadata(\"content-encoding\", o.contentEncoding)\n\tsetMetadata(\"content-language\", o.contentLanguage)\n\tmetadata[\"tier\"] = o.GetTier()\n\n\treturn metadata, nil\n}", "title": "" }, { "docid": "fd3058a49be7399dc765acafd46135ff", "score": "0.49875176", "text": "func (r *DeploymentGroup_RevisionLocation) CoreMetadata() map[string]interface{} {\n\treturn r._metadata\n}", "title": "" }, { "docid": "e552f9b3168617f7706b615accdcdb3e", "score": "0.4984771", "text": "func (r *AWSGluePartition_StorageDescriptor) Metadata() map[string]interface{} {\n\treturn r._metadata\n}", "title": "" }, { "docid": "d845a0410e9965ea7f956d4f254af628", "score": "0.49730614", "text": "func (r *AWSServerlessApi) Metadata() map[string]interface{} {\n\treturn r._metadata\n}", "title": "" }, { "docid": "70e8517df25032e98c10200ff8d38d4b", "score": "0.4972632", "text": "func GetMetadata() (map[string]string, error) {\n\tif !config.IsFeaturePresent(config.Docker) {\n\t\treturn nil, errors.New(\"Docker feature deactivated\")\n\t}\n\n\tdu, err := GetDockerUtil()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// short timeout to minimize metadata collection time\n\tctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)\n\tdefer cancel()\n\n\ti, err := du.cli.Info(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdockerSwarm := \"inactive\"\n\tif i.Swarm.LocalNodeState == swarm.LocalNodeStateActive {\n\t\tdockerSwarm = \"active\"\n\t}\n\n\treturn map[string]string{\n\t\t\"docker_version\": i.ServerVersion,\n\t\t\"docker_swarm\": dockerSwarm,\n\t}, nil\n}", "title": "" }, { "docid": "b5858d49ed51b2301e133071813c20e4", "score": "0.49671727", "text": "func (c *jsiiProxy_CfnGlobalReplicationGroup) GetMetadata(key *string) interface{} {\n\tvar returns interface{}\n\n\t_jsii_.Invoke(\n\t\tc,\n\t\t\"getMetadata\",\n\t\t[]interface{}{key},\n\t\t&returns,\n\t)\n\n\treturn returns\n}", "title": "" }, { "docid": "277c0edecebcc1d9813c97880c553945", "score": "0.49651894", "text": "func (m *FileDetails) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "163c2a1e4d0232122e38dd92ec78b8a5", "score": "0.4957978", "text": "func (p *IssuingCardholderParams) AddMetadata(key string, value string) {\n\tif p.Metadata == nil {\n\t\tp.Metadata = make(map[string]string)\n\t}\n\n\tp.Metadata[key] = value\n}", "title": "" }, { "docid": "07723e3a857d095cc4b2efd437ab9adf", "score": "0.49525416", "text": "func (cmds *cliCommands) Metadata() map[string]cosFlag.Flag {\n\tcommandMetadata := map[string]cosFlag.Flag{}\n\t// we use reflection to get the documentation of each prop from cliCommands\n\tfor cmdName, cmdArgs := range cmds.index() {\n\t\tcommandMetadata[cmdName] = cmdArgs.Documentation()\n\t}\n\treturn commandMetadata\n}", "title": "" }, { "docid": "7c8d1a53a30666dc96cc963affc4ed01", "score": "0.49430704", "text": "func (m *NotificationChannel) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "0276b6e1ffac35cbb6febaa2d23cf13c", "score": "0.49377143", "text": "func (p *CouponParams) AddMetadata(key string, value string) {\n\tif p.Metadata == nil {\n\t\tp.Metadata = make(map[string]string)\n\t}\n\n\tp.Metadata[key] = value\n}", "title": "" }, { "docid": "73b85095164c762df7165970ec66cdc5", "score": "0.49240845", "text": "func dataSourceIdentityGroupV3Attributes(d *schema.ResourceData, config *Config, group *groups.Group) error {\n\tlog.Printf(\"[DEBUG] openstack_identity_group_v3 details: %#v\", group)\n\n\td.SetId(group.ID)\n\td.Set(\"name\", group.Name)\n\td.Set(\"domain_id\", group.DomainID)\n\td.Set(\"region\", GetRegion(d, config))\n\n\treturn nil\n}", "title": "" }, { "docid": "e68e5b192ac8932357bf179061ab93ce", "score": "0.49224305", "text": "func (m *Metadata) Add(name, value string) {\n *m = append(*m, &MetadataField{\n Name: name,\n Value: value,\n })\n}", "title": "" }, { "docid": "ce36d3e3cb3d8501c14a625250a60e24", "score": "0.49187636", "text": "func (m *DataSubject) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "db9d8eaac2e9b20410122828b4481d10", "score": "0.49138126", "text": "func (c *Cepgo) Meta() (map[string]string, error) {\n\trawMeta, err := c.Key(\"/meta/\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn typeAssertToMapOfStrings(rawMeta)\n}", "title": "" }, { "docid": "0b1b268e9842cffe87f3b3a11d6bc235", "score": "0.49125537", "text": "func (a *GeoDistanceAggregation) Meta(metaData map[string]interface{}) *GeoDistanceAggregation {\n\ta.meta = metaData\n\treturn a\n}", "title": "" }, { "docid": "a9aca09844900afdfd068a7597e12903", "score": "0.4901506", "text": "func (*GroupKey) Descriptor() ([]byte, []int) {\n\treturn file_odpf_meta_Group_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "1268a8db8e00da51e90361f2a6531a94", "score": "0.48943862", "text": "func (m *ClassifcationErrorBase) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "2e72b3087f355fcc583e53ec77cf3e79", "score": "0.48839656", "text": "func flattenRoleGroupData(rolegroup *rolegroup.Rolegroup) map[string]interface{} {\n\titem := make(map[string]interface{})\n\n\titem[\"role_group_id\"] = rolegroup.GetRoleGroupId()\n\titem[\"name\"] = rolegroup.GetName()\n\titem[\"external_names\"] = rolegroup.GetExternalNames()\n\titem[\"description\"] = rolegroup.GetDescription()\n\titem[\"org_id\"] = rolegroup.GetOrgId()\n\titem[\"editable\"] = rolegroup.GetEditable()\n\titem[\"created_at\"] = rolegroup.GetCreatedAt()\n\titem[\"updated_at\"] = rolegroup.GetUpdatedAt()\n\n\treturn item\n}", "title": "" }, { "docid": "ddbfc6e40403dca5ea1436543da67239", "score": "0.48830625", "text": "func (p *SetupIntentConfirmPaymentMethodDataParams) AddMetadata(key string, value string) {\n\tif p.Metadata == nil {\n\t\tp.Metadata = make(map[string]string)\n\t}\n\n\tp.Metadata[key] = value\n}", "title": "" }, { "docid": "8103a18f86d239f61a65f9a33f8be7e1", "score": "0.4879916", "text": "func (m *SharepointIds) GetAdditionalData()(map[string]interface{}) {\n return m.additionalData\n}", "title": "" }, { "docid": "2157cc361ae5640173ce92096339805b", "score": "0.48781258", "text": "func (n *DefaultNode) Metadata() map[string]string {\n\treturn n.metadata\n}", "title": "" }, { "docid": "bb2ed6c825b758e7345742aabbbe846f", "score": "0.48762763", "text": "func GRPCMetadata(ctx context.Context) map[string]string {\n\tm := make(map[string]string, 0)\n\n\t// incoming context.\n\tmd, ok := metadata.FromIncomingContext(ctx)\n\tif !ok || len(md) == 0 {\n\t\t// context metadata empty.\n\t\treturn m\n\t}\n\n\tfor key, value := range md {\n\t\tif len(value) != 0 {\n\t\t\t// NOTE: only first value item.\n\t\t\tm[key] = value[0]\n\t\t}\n\t}\n\treturn m\n}", "title": "" }, { "docid": "3b0cad180de4ce830c5d99dfa9e3a13e", "score": "0.48762667", "text": "func (m *ResourceSpecificPermission) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "ae823fd2347f6837f0a40a44a05b2874", "score": "0.48703587", "text": "func (m *Entity) GetAdditionalData()(map[string]interface{}) {\n return m.additionalData\n}", "title": "" }, { "docid": "82f203b34666d74660199e811d9ce05c", "score": "0.48680922", "text": "func (m *ObjectMapping) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "b4b65dc2e8a8ab5dce26309d417199e6", "score": "0.48680374", "text": "func (m *ProvisioningStatusInfo) GetAdditionalData()(map[string]interface{}) {\n return m.additionalData\n}", "title": "" }, { "docid": "5eb10c5a951936f871649560d663241d", "score": "0.48595428", "text": "func (info verKeyInfo) MetaData() []byte {\n\treturn info.OldHeader.UserData\n}", "title": "" }, { "docid": "20ebdf8b5e70feb803ff4ca5fbf24647", "score": "0.48557195", "text": "func (m *Win32LobAppMsiInformation) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "968ddc8ab02bcd07b98bb90fc5717caa", "score": "0.48510805", "text": "func (m *BucketAggregationRange) GetAdditionalData()(map[string]interface{}) {\n return m.additionalData\n}", "title": "" }, { "docid": "8e354ac36107bbc799c53a918c203eff", "score": "0.48487785", "text": "func (m *CustomExtensionCalloutInstance) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "e18efcfe8375d9287e250b423286939d", "score": "0.48398808", "text": "func (m *HardwareInformation) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "ef3afa3dd37c5ec15e2e36052e0e897d", "score": "0.48393252", "text": "func (m *DeviceManagementApplicabilityRuleOsVersion) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "5ed930ef542518475c7bf47e35439f5f", "score": "0.4819691", "text": "func (m *UserExperienceAnalyticsSettings) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "bde933ae57acf07b200b934fde471fa7", "score": "0.48183942", "text": "func (m *Audio) GetAdditionalData()(map[string]interface{}) {\n return m.additionalData\n}", "title": "" }, { "docid": "64913fd69dd544da5a864d765d465804", "score": "0.48163944", "text": "func (m *WindowsMalwareNameCount) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" }, { "docid": "2aef951febcfe01017fb1dd42df39570", "score": "0.4801018", "text": "func (m *ReportSuspiciousActivitySettings) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "title": "" } ]
dee24564b3bf1f5b7c096d6893266d9a
Save executes the query and returns the number of rows/vertices matched by this operation.
[ { "docid": "a6c42b750cdaa826d688a1737c69a8a3", "score": "0.0", "text": "func (cu *CourseclassUpdate) Save(ctx context.Context) (int, error) {\n\tif v, ok := cu.mutation.Tablecode(); ok {\n\t\tif err := courseclass.TablecodeValidator(v); err != nil {\n\t\t\treturn 0, &ValidationError{Name: \"tablecode\", err: fmt.Errorf(\"ent: validator failed for field \\\"tablecode\\\": %w\", err)}\n\t\t}\n\t}\n\tif v, ok := cu.mutation.GroupClass(); ok {\n\t\tif err := courseclass.GroupClassValidator(v); err != nil {\n\t\t\treturn 0, &ValidationError{Name: \"GroupClass\", err: fmt.Errorf(\"ent: validator failed for field \\\"GroupClass\\\": %w\", err)}\n\t\t}\n\t}\n\tif v, ok := cu.mutation.Annotation(); ok {\n\t\tif err := courseclass.AnnotationValidator(v); err != nil {\n\t\t\treturn 0, &ValidationError{Name: \"Annotation\", err: fmt.Errorf(\"ent: validator failed for field \\\"Annotation\\\": %w\", err)}\n\t\t}\n\t}\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(cu.hooks) == 0 {\n\t\taffected, err = cu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*CourseclassMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tcu.mutation = mutation\n\t\t\taffected, err = cu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(cu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = cu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, cu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" } ]
[ { "docid": "2ca4533a292f0ec7837739298587d5b5", "score": "0.6103194", "text": "func (kpu *KqiPerspectiveUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tkpu.defaults()\n\tif len(kpu.hooks) == 0 {\n\t\tif err = kpu.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = kpu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*KqiPerspectiveMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = kpu.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\tkpu.mutation = mutation\n\t\t\taffected, err = kpu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(kpu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = kpu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, kpu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "6d8b2a5b7028613c8925067d176d25e4", "score": "0.6022182", "text": "func (tu *TestUpdate) Save(ctx context.Context) (int, error) {\n\tif len(tu.history) > 1 {\n\t\treturn 0, errors.New(\"ent: multiple assignments on a unique edge \\\"history\\\"\")\n\t}\n\treturn tu.sqlSave(ctx)\n}", "title": "" }, { "docid": "63436d8c439bfb1ae7fbb85340a1a297", "score": "0.5933309", "text": "func (qedu *QccEnterpriseDataUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(qedu.hooks) == 0 {\n\t\taffected, err = qedu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*QccEnterpriseDataMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tqedu.mutation = mutation\n\t\t\taffected, err = qedu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(qedu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = qedu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, qedu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "28ae24da90904b4808162f1423ec709d", "score": "0.58921", "text": "func (otu *ObjectTypeUpdate) Save(ctx context.Context) (int, error) {\n\treturn otu.sqlSave(ctx)\n}", "title": "" }, { "docid": "816b9f3059bd4bf555c02eb8bf2cc1ca", "score": "0.5889082", "text": "func (s *QueryStat) Save() (map[string]bigquery.Value, string, error) {\n\tinsertID, err := s.InsertID()\n\tif err != nil {\n\t\treturn nil, \"\", xerrors.Errorf(\"failed InsertID() : %w\", err)\n\t}\n\treturn map[string]bigquery.Value{\n\t\t\"interval_end\": s.IntervalEnd,\n\t\t\"text\": s.Text,\n\t\t\"text_truncated\": s.TextTruncated,\n\t\t\"text_fingerprint\": s.TextFingerprint,\n\t\t\"execution_count\": s.ExecuteCount,\n\t\t\"avg_latency_seconds\": s.AvgLatencySeconds,\n\t\t\"avg_rows\": s.AvgRows,\n\t\t\"avg_bytes\": s.AvgBytes,\n\t\t\"avg_rows_scanned\": s.AvgRowsScanned,\n\t\t\"avg_cpu_seconds\": s.AvgCPUSeconds,\n\t}, insertID, nil\n}", "title": "" }, { "docid": "ae0983ce34d98706da99c8fa2c153dc3", "score": "0.575307", "text": "func (eru *EpidemiologicResultsUpdate) Save(ctx context.Context) (int, error) {\n\tif eru.fromInfectedPlace != nil {\n\t\tif err := epidemiologicresults.FromInfectedPlaceValidator(*eru.fromInfectedPlace); err != nil {\n\t\t\treturn 0, fmt.Errorf(\"ent: validator failed for field \\\"fromInfectedPlace\\\": %v\", err)\n\t\t}\n\t}\n\tif eru.toInfectedPlace != nil {\n\t\tif err := epidemiologicresults.ToInfectedPlaceValidator(*eru.toInfectedPlace); err != nil {\n\t\t\treturn 0, fmt.Errorf(\"ent: validator failed for field \\\"toInfectedPlace\\\": %v\", err)\n\t\t}\n\t}\n\tif len(eru.test) > 1 {\n\t\treturn 0, errors.New(\"ent: multiple assignments on a unique edge \\\"test\\\"\")\n\t}\n\treturn eru.sqlSave(ctx)\n}", "title": "" }, { "docid": "e9eec70ab398ecde54c2bd20f7aa4865", "score": "0.5750572", "text": "func (tx *LevelDBExecutionTransaction) Save(execution *execution.Execution) error {\n\treturn executionSave(tx.tx, execution)\n}", "title": "" }, { "docid": "202fb692bd4ca4221710638cc65c6cb5", "score": "0.5691326", "text": "func (db *LevelDBExecutionDB) Save(execution *execution.Execution) error {\n\treturn executionSave(db.db, execution)\n}", "title": "" }, { "docid": "35ed6473b6c1daf3ca3c13bd47fba938", "score": "0.56827015", "text": "func (swu *StartWorkUpdate) Save(ctx context.Context) (int, error) {\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(swu.hooks) == 0 {\n\t\taffected, err = swu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*StartWorkMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tswu.mutation = mutation\n\t\t\taffected, err = swu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(swu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = swu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, swu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "abe2ea287eedcde2576d9eeb5df2d6b2", "score": "0.5670427", "text": "func (riu *RoomInfoUpdate) Save(ctx context.Context) (int, error) {\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(riu.hooks) == 0 {\n\t\taffected, err = riu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*RoomInfoMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\triu.mutation = mutation\n\t\t\taffected, err = riu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(riu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = riu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, riu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "ba7c74194e5bfbfe5c4e5cb52cc217b9", "score": "0.56042993", "text": "func (pu *PredicamentUpdate) Save(ctx context.Context) (int, error) {\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(pu.hooks) == 0 {\n\t\taffected, err = pu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*PredicamentMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tpu.mutation = mutation\n\t\t\taffected, err = pu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(pu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = pu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, pu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "eda26cc3698e01748827b23f544e4f56", "score": "0.56018746", "text": "func (r *Entity) Save() (result sql.Result, err error) {\n\treturn Model.Data(r).Save()\n}", "title": "" }, { "docid": "eda26cc3698e01748827b23f544e4f56", "score": "0.56018746", "text": "func (r *Entity) Save() (result sql.Result, err error) {\n\treturn Model.Data(r).Save()\n}", "title": "" }, { "docid": "eda26cc3698e01748827b23f544e4f56", "score": "0.56018746", "text": "func (r *Entity) Save() (result sql.Result, err error) {\n\treturn Model.Data(r).Save()\n}", "title": "" }, { "docid": "652b02be3fd16c52135fb2eedc23ca94", "score": "0.5585714", "text": "func (ju *JobUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(ju.hooks) == 0 {\n\t\tif err = ju.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = ju.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*JobMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = ju.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\tju.mutation = mutation\n\t\t\taffected, err = ju.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(ju.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = ju.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, ju.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "0a2bfbb3f38e24cde0f8bce56d9e857a", "score": "0.55664796", "text": "func (oau *OutcomeAnalysisUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(oau.hooks) == 0 {\n\t\taffected, err = oau.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*OutcomeAnalysisMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\toau.mutation = mutation\n\t\t\taffected, err = oau.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(oau.hooks) - 1; i >= 0; i-- {\n\t\t\tif oau.hooks[i] == nil {\n\t\t\t\treturn 0, fmt.Errorf(\"models: uninitialized hook (forgotten import models/runtime?)\")\n\t\t\t}\n\t\t\tmut = oau.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, oau.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "4422cbb412ec96776552bce79c30ca92", "score": "0.5565186", "text": "func (s *snapshotImpl) Save(data sources.Bag) (int, error) {\n\n\tbytes, err := proto.Marshal(data)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn s.storage.Write(bytes)\n}", "title": "" }, { "docid": "f22ec8750874ad531d457340ffd73174", "score": "0.5551756", "text": "func (ddrc *DatabaseDetectorResultCreate) Save(ctx context.Context) (*DatabaseDetectorResult, error) {\n\tddrc.defaults()\n\treturn withHooks(ctx, ddrc.sqlSave, ddrc.mutation, ddrc.hooks)\n}", "title": "" }, { "docid": "a45b74dba9aa53fbea4a426c6af533aa", "score": "0.5550747", "text": "func (su *SplitUpdate) Save(ctx context.Context) (int, error) {\n\treturn withHooks[int, SplitMutation](ctx, su.sqlSave, su.mutation, su.hooks)\n}", "title": "" }, { "docid": "653c1496366fb4e054cf0621478802fd", "score": "0.5515173", "text": "func (this *Sql) Save(data map[string]interface{}) (int64, error) {\n\tsqlstr := \" UPDATE \" + this.tableName + \" \"\n\tsetsql := \" SET \"\n\tcount := 0\n\tvar pk string\n\tif len(this.pkSql) > 0 {\n\t\tpk = this.pkSql\n\t} else {\n\t\tpk = \"id\"\n\t}\n\tfor k, v := range data {\n\t\tif k == pk {\n\t\t\tcontinue\n\t\t}\n\t\tif count > 0 {\n\t\t\tsetsql += \", \" + k + \"=\\\"\" + this.convertValue2String(v) + \"\\\" \"\n\t\t} else {\n\t\t\tsetsql += \" \" + k + \"=\\\"\" + this.convertValue2String(v) + \"\\\" \"\n\t\t}\n\t\tcount++\n\t}\n\tif len(this.conditionSql) > 0 {\n\t\t//do not need pk\n\n\t} else {\n\t\tthis.conditionSql = pk + \" = \\\"\" + this.convertValue2String(data[pk]) + \"\\\" \"\n\t}\n\tsqlstr += setsql + \" WHERE \" + this.conditionSql\n\t//slimSqlLog(\"Update\", sqlstr)\n\tvar r sql.Result\n\tvar err error\n\tif this.tx != nil {\n\t\tr, err = this.tx.Exec(sqlstr)\n\t} else {\n\t\tr, err = this.getDbW().Exec(sqlstr)\n\t}\n\tif err != nil {\n\t\tslimSqlLog(\"ERROR\", sqlstr)\n\t\treturn 0, err\n\t} else {\n\t\tnum, err := r.RowsAffected()\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t} else {\n\t\t\treturn num, nil\n\t\t}\n\t}\n}", "title": "" }, { "docid": "8b506fd29d5783be91c60382b9e59642", "score": "0.5512663", "text": "func (ru *ReviewUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(ru.hooks) == 0 {\n\t\tif err = ru.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = ru.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*ReviewMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = ru.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\tru.mutation = mutation\n\t\t\taffected, err = ru.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(ru.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = ru.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, ru.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "b2f82f3b58f0c27fde24d4ce109c4529", "score": "0.5511701", "text": "func (fu *FileinsertUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(fu.hooks) == 0 {\n\t\tif err = fu.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = fu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*FileinsertMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = fu.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\tfu.mutation = mutation\n\t\t\taffected, err = fu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(fu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = fu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, fu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "0279b9485fe7f19fcafb45380bfd2d20", "score": "0.54940504", "text": "func (hu *HarborUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(hu.hooks) == 0 {\n\t\tif err = hu.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = hu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*HarborMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = hu.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\thu.mutation = mutation\n\t\t\taffected, err = hu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(hu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = hu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, hu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "853ee0662d7e3041fb0883b2a71a20bd", "score": "0.5486246", "text": "func (rsu *RoomStatusUpdate) Save(ctx context.Context) (int, error) {\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(rsu.hooks) == 0 {\n\t\taffected, err = rsu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*RoomStatusMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\trsu.mutation = mutation\n\t\t\taffected, err = rsu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(rsu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = rsu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, rsu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "300df49d71fa08e3d2f74898c05ba166", "score": "0.54771423", "text": "func (hu *HistoryUpdate) Save(ctx context.Context) (int, error) {\n\tif len(hu.patient) > 1 {\n\t\treturn 0, errors.New(\"ent: multiple assignments on a unique edge \\\"patient\\\"\")\n\t}\n\treturn hu.sqlSave(ctx)\n}", "title": "" }, { "docid": "9156f22ca86d6300746c606a63ee0362", "score": "0.5477106", "text": "func (iu *InsuranceUpdate) Save(ctx context.Context) (int, error) {\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(iu.hooks) == 0 {\n\t\taffected, err = iu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*InsuranceMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tiu.mutation = mutation\n\t\t\taffected, err = iu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(iu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = iu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, iu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "675aabff88de4cd10a89c65fdd652426", "score": "0.54724187", "text": "func (bu *BookUpdate) Save(ctx context.Context) (int, error) {\n\treturn withHooks(ctx, bu.sqlSave, bu.mutation, bu.hooks)\n}", "title": "" }, { "docid": "bfc130ead573277cb0e3868726d979ff", "score": "0.5468118", "text": "func (dog Dog) Save() int64 {\n\tstmt, err := database.Db.Prepare(\"INSERT INTO Dogs(Name,IsGoodBoi) VALUES(?,?)\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tres, err := stmt.Exec(dog.Name, dog.IsGoodBoi)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tid, err := res.LastInsertId()\n\tif err != nil {\n\t\tlog.Fatal(\"Error:\", err.Error())\n\t}\n\tlog.Print(\"Row inserted!\")\n\treturn id\n}", "title": "" }, { "docid": "4956980d5f28563d4e6581b002a5a505", "score": "0.54539794", "text": "func (mu *ModelsUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(mu.hooks) == 0 {\n\t\tif err = mu.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = mu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*ModelsMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = mu.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\tmu.mutation = mutation\n\t\t\taffected, err = mu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(mu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = mu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, mu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "48069e2746a6838901afd917d3966649", "score": "0.54521173", "text": "func (su *ScreenUpdate) Save(ctx context.Context) (int, error) {\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(su.hooks) == 0 {\n\t\taffected, err = su.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*ScreenMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tsu.mutation = mutation\n\t\t\taffected, err = su.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(su.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = su.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, su.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "bbcdcc0730cdbbc7756d4290a22450ff", "score": "0.54476684", "text": "func (pu *ProjectUpdate) Save(ctx context.Context) (int, error) {\n\tif _, ok := pu.mutation.UpdateTime(); !ok {\n\t\tv := project.UpdateDefaultUpdateTime()\n\t\tpu.mutation.SetUpdateTime(v)\n\t}\n\tif v, ok := pu.mutation.Name(); ok {\n\t\tif err := project.NameValidator(v); err != nil {\n\t\t\treturn 0, &ValidationError{Name: \"name\", err: fmt.Errorf(\"ent: validator failed for field \\\"name\\\": %w\", err)}\n\t\t}\n\t}\n\n\tif _, ok := pu.mutation.TypeID(); pu.mutation.TypeCleared() && !ok {\n\t\treturn 0, errors.New(\"ent: clearing a unique edge \\\"type\\\"\")\n\t}\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(pu.hooks) == 0 {\n\t\taffected, err = pu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*ProjectMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tpu.mutation = mutation\n\t\t\taffected, err = pu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(pu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = pu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, pu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "91cbc87f92ba22306c4774402f4a3e73", "score": "0.5440741", "text": "func Save() error { return p.Save() }", "title": "" }, { "docid": "7d296ec5a7165f5b95b2b4614bd50a3a", "score": "0.5435279", "text": "func (ot *OperationTable) Save(obj interface{}) *Result {\n\t// Check for object's primary key field being zero\n\tvar rVal = reflect.ValueOf(obj).Elem()\n\tvar pkValField = rVal.FieldByName(ot.t.primaryKey.Field.Name)\n\n\tif pkValField.Interface() == reflect.Zero(pkValField.Type()).Interface() {\n\t\tvar res = ot.op.Exec(ot.t.InsertSQL(), ot.t.InsertArgs(obj)...)\n\t\tswitch pkValField.Type().Kind() {\n\t\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\t\tpkValField.SetInt(res.LastInsertId())\n\t\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:\n\t\t\tpkValField.SetUint(uint64(res.LastInsertId()))\n\t\t}\n\t\treturn res\n\t}\n\n\treturn ot.op.Exec(ot.t.UpdateSQL(), ot.t.UpdateArgs(obj)...)\n}", "title": "" }, { "docid": "c9994f052bcc7819df8b1951e3439d60", "score": "0.54288965", "text": "func (eu *ExchangeUpdate) Save(ctx context.Context) (int, error) {\n\treturn withHooks[int, ExchangeMutation](ctx, eu.sqlSave, eu.mutation, eu.hooks)\n}", "title": "" }, { "docid": "0669853c213487a83fdcd38128a52d30", "score": "0.5425999", "text": "func (fu *FlowUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tfu.defaults()\n\tif len(fu.hooks) == 0 {\n\t\tif err = fu.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = fu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*FlowMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = fu.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\tfu.mutation = mutation\n\t\t\taffected, err = fu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(fu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = fu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, fu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "17d49cfd514ffdef39d79f7a5de70d66", "score": "0.5420092", "text": "func (vu *VariantUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(vu.hooks) == 0 {\n\t\taffected, err = vu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*VariantMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tvu.mutation = mutation\n\t\t\taffected, err = vu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(vu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = vu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, vu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "2c36782310aca9d0a1c34f7149cf4cfb", "score": "0.54169023", "text": "func Save(person Person) bool {\n\tid := 0\n\tpfdb.WithDb(func(db *sql.DB) {\n\t\tsql := `\n\t\t\tINSERT INTO Person (FirstName, LastName)\n\t\t\tVALUES ($1, $2)\n\t\t\tRETURNING Id`\n\t\terr := db.QueryRow(sql, \"Test\", \"User\").Scan(&id)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t})\n\n\t// If the resulting Id is valid, then the object\n\t// was successfully inserted\n\treturn id > 0\n}", "title": "" }, { "docid": "81b51aebcc18c13d1bc906606f44e46a", "score": "0.54067534", "text": "func (bdu *BankingDataUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(bdu.hooks) == 0 {\n\t\taffected, err = bdu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*BankingDataMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tbdu.mutation = mutation\n\t\t\taffected, err = bdu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(bdu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = bdu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, bdu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "bffb43f1c8178652f3e059f8b9a9747e", "score": "0.5403008", "text": "func (wtu *WorkerTypeUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\twtu.defaults()\n\tif len(wtu.hooks) == 0 {\n\t\taffected, err = wtu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*WorkerTypeMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\twtu.mutation = mutation\n\t\t\taffected, err = wtu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(wtu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = wtu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, wtu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "f96318efffb1ae832a20648d172363a5", "score": "0.5379816", "text": "func (r *replicationStatsReportSaver) Save(\n\tctx context.Context,\n\treport RangeReport,\n\treportTS time.Time,\n\tdb *kv.DB,\n\tex sqlutil.InternalExecutor,\n) error {\n\tr.lastUpdatedRowCount = 0\n\tif err := db.Txn(ctx, func(ctx context.Context, txn *kv.Txn) error {\n\t\terr := r.loadPreviousVersion(ctx, ex, txn)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\terr = r.updateTimestamp(ctx, ex, txn, reportTS)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfor key, status := range report {\n\t\t\tif err := r.upsertStats(ctx, txn, key, status, ex); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\tfor key := range r.previousVersion {\n\t\t\tif _, ok := report[key]; !ok {\n\t\t\t\t_, err := ex.Exec(\n\t\t\t\t\tctx,\n\t\t\t\t\t\"delete-old-replication-stats\",\n\t\t\t\t\ttxn,\n\t\t\t\t\t\"delete from system.replication_stats \"+\n\t\t\t\t\t\t\"where zone_id = $1 and subzone_id = $2\",\n\t\t\t\t\tkey.ZoneID,\n\t\t\t\t\tkey.SubzoneID,\n\t\t\t\t)\n\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tr.lastUpdatedRowCount++\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t}); err != nil {\n\t\treturn err\n\t}\n\n\tr.lastGenerated = reportTS\n\tr.previousVersion = report\n\n\treturn nil\n}", "title": "" }, { "docid": "4871b241f8708720fd5d48344912732d", "score": "0.53793573", "text": "func (pu *ProjectUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(pu.hooks) == 0 {\n\t\taffected, err = pu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*ProjectMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tpu.mutation = mutation\n\t\t\taffected, err = pu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(pu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = pu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, pu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "6b2f641541592aac1b0bde98334be27d", "score": "0.5362488", "text": "func (rsu *RegisterStoreUpdate) Save(ctx context.Context) (int, error) {\n\tif v, ok := rsu.mutation.Name(); ok {\n\t\tif err := registerstore.NameValidator(v); err != nil {\n\t\t\treturn 0, &ValidationError{Name: \"name\", err: fmt.Errorf(\"ent: validator failed for field \\\"name\\\": %w\", err)}\n\t\t}\n\t}\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(rsu.hooks) == 0 {\n\t\taffected, err = rsu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*RegisterStoreMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\trsu.mutation = mutation\n\t\t\taffected, err = rsu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(rsu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = rsu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, rsu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "f03e7cd1739959dcba81dfd80bfa3ebf", "score": "0.53582186", "text": "func (tu *TimesheetUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(tu.hooks) == 0 {\n\t\tif err = tu.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = tu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*TimesheetMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = tu.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\ttu.mutation = mutation\n\t\t\taffected, err = tu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(tu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = tu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, tu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "6a6be9f9f35b01b1e1943d79581d1776", "score": "0.535621", "text": "func (a *Action) Save() error {\n\tvar op = dbi.DB.Operation()\n\top.Dbg = dbi.Debug\n\treturn a.SaveOp(op)\n}", "title": "" }, { "docid": "22acd92674028f0423e81c6c0e287b7b", "score": "0.5352388", "text": "func (eru *EpidemiologicResultsUpdate) SaveX(ctx context.Context) int {\n\taffected, err := eru.Save(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn affected\n}", "title": "" }, { "docid": "f7c4647c1297b32772f5f3bd8fe2344a", "score": "0.5350628", "text": "func (bu *BrowserUpdate) Save(ctx context.Context) (int, error) {\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(bu.hooks) == 0 {\n\t\taffected, err = bu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*BrowserMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tbu.mutation = mutation\n\t\t\taffected, err = bu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(bu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = bu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, bu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "a34355aa519a6ccee2ce5c25cc9e84a7", "score": "0.53496265", "text": "func (uu *UsersUpdate) Save(ctx context.Context) (int, error) {\n\treturn uu.sqlSave(ctx)\n}", "title": "" }, { "docid": "8364b7d67dbdd3c69e0a45c3b828b659", "score": "0.53488106", "text": "func (pu *ProjectUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(pu.hooks) == 0 {\n\t\taffected, err = pu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*ProjectMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tpu.mutation = mutation\n\t\t\taffected, err = pu.sqlSave(ctx)\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(pu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = pu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, pu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "66605b98c79ccb3e761b12fb42e50a68", "score": "0.534162", "text": "func (bu *BookUpdate) Save(ctx context.Context) (int, error) {\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(bu.hooks) == 0 {\n\t\taffected, err = bu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*BookMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tbu.mutation = mutation\n\t\t\taffected, err = bu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(bu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = bu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, bu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "f17ea4f6c1e1d333c802ed6450320225", "score": "0.53396285", "text": "func (au *AgeUpdate) Save(ctx context.Context) (int, error) {\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(au.hooks) == 0 {\n\t\taffected, err = au.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*AgeMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tau.mutation = mutation\n\t\t\taffected, err = au.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(au.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = au.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, au.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "92d53520b144ca278b6ba99196877d8b", "score": "0.53395224", "text": "func (p *PmtRatioBatch) Save(db *sql.DB) error {\n\ttx, err := db.Begin()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"tx begin %v\", err)\n\t}\n\tif _, err = tx.Exec(`DELETE FROM ratio WHERE year=$1`, p.Year); err != nil {\n\t\ttx.Rollback()\n\t\treturn fmt.Errorf(\"delete %v\", err)\n\t}\n\tstmt, err := tx.Prepare(pq.CopyIn(\"ratio\", \"year\", \"index\", \"sector_id\",\n\t\t\"ratio\"))\n\tif err != nil {\n\t\ttx.Rollback()\n\t\treturn fmt.Errorf(\"statement creation %v\", err)\n\t}\n\tdefer stmt.Close()\n\tfor _, r := range p.Ratios {\n\t\tif _, err = stmt.Exec(p.Year, r.Index, r.SectorID, r.Ratio); err != nil {\n\t\t\ttx.Rollback()\n\t\t\treturn fmt.Errorf(\"statement execution %v\", err)\n\t\t}\n\t}\n\tif _, err = stmt.Exec(); err != nil {\n\t\ttx.Rollback()\n\t\treturn fmt.Errorf(\"statement flush exec %v\", err)\n\t}\n\treturn tx.Commit()\n}", "title": "" }, { "docid": "7bbbea144ce36b865caa2e42a983398b", "score": "0.5337531", "text": "func (fu *FileUpdate) Save(ctx context.Context) (int, error) {\n\treturn withHooks[int, FileMutation](ctx, fu.sqlSave, fu.mutation, fu.hooks)\n}", "title": "" }, { "docid": "a5a068fc069eac6fc6a120f384c9dd2e", "score": "0.53215843", "text": "func (fiu *FlowInstanceUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tfiu.defaults()\n\tif len(fiu.hooks) == 0 {\n\t\tif err = fiu.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = fiu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*FlowInstanceMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = fiu.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\tfiu.mutation = mutation\n\t\t\taffected, err = fiu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(fiu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = fiu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, fiu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "77b9c3dba06f705c914bab897575c1eb", "score": "0.5311624", "text": "func (rsu *RequestStatusUpdate) Save(ctx context.Context) (int, error) {\n\treturn withHooks[int, RequestStatusMutation](ctx, rsu.sqlSave, rsu.mutation, rsu.hooks)\n}", "title": "" }, { "docid": "413728bb49dcc990903979951d2cbef9", "score": "0.5304821", "text": "func (mtu *MetaTableUpdate) Save(ctx context.Context) (int, error) {\n\tif len(mtu.schema) > 1 {\n\t\treturn 0, errors.New(\"ent: multiple assignments on a unique edge \\\"schema\\\"\")\n\t}\n\treturn mtu.sqlSave(ctx)\n}", "title": "" }, { "docid": "d46aac0e5b7a84987ec6b741aac4f7cc", "score": "0.5300832", "text": "func (sr *ScRecommend) Save(db XODB) error {\n\tif sr.Exists() {\n\t\treturn sr.Update(db)\n\t}\n\n\treturn sr.Insert(db)\n}", "title": "" }, { "docid": "a70e4de23b62f01a0a7b7d602c6830a9", "score": "0.5293536", "text": "func (r *RPLSBatch) Save(db *sql.DB) error {\n\tfor i, l := range r.Lines {\n\t\tif l.InseeCode == 0 {\n\t\t\treturn fmt.Errorf(\"ligne %d InseeCode null\", i+1)\n\t\t}\n\t\tif l.Year == 0 {\n\t\t\treturn fmt.Errorf(\"ligne %d Year null\", i+1)\n\t\t}\n\t}\n\ttx, err := db.Begin()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"tx begin %v\", err)\n\t}\n\tstmt, err := tx.Prepare(pq.CopyIn(\"temp_rpls\", \"insee_code\", \"year\", \"ratio\"))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"copy in %v\", err)\n\t}\n\tdefer stmt.Close()\n\tfor i, l := range r.Lines {\n\t\tif _, err = stmt.Exec(l.InseeCode, l.Year, l.Ratio); err != nil {\n\t\t\ttx.Rollback()\n\t\t\treturn fmt.Errorf(\"ligne %d %v\", i+1, err)\n\t\t}\n\t}\n\tif _, err = stmt.Exec(); err != nil {\n\t\ttx.Rollback()\n\t\treturn fmt.Errorf(\"statement exec flush %v\", err)\n\t}\n\tqueries := []string{`UPDATE rpls SET ratio=t.ratio FROM temp_rpls t \n\tWHERE t.insee_code=rpls.insee_code AND t.year=rpls.year`,\n\t\t`INSERT INTO rpls (insee_code,year,ratio)\n\tSELECT insee_code,year,ratio from temp_rpls \n\t\tWHERE (insee_code,year) NOT IN (SELECT insee_code,year from rpls)`,\n\t\t`DELETE from temp_rpls`,\n\t}\n\tfor i, q := range queries {\n\t\t_, err = tx.Exec(q)\n\t\tif err != nil {\n\t\t\ttx.Rollback()\n\t\t\treturn fmt.Errorf(\"requête %d : %v\", i, err)\n\t\t}\n\t}\n\treturn tx.Commit()\n}", "title": "" }, { "docid": "bc0774af3948413e5fa7bfc92e9ae9b1", "score": "0.52921027", "text": "func (wu *WalletUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\twu.defaults()\n\tif len(wu.hooks) == 0 {\n\t\tif err = wu.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = wu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*WalletMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = wu.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\twu.mutation = mutation\n\t\t\taffected, err = wu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(wu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = wu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, wu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "4b9616eed7c370081cb40d8d30862cc6", "score": "0.52824247", "text": "func (ru *RevisionUpdate) Save(ctx context.Context) (int, error) {\n\treturn withHooks[int, RevisionMutation](ctx, ru.sqlSave, ru.mutation, ru.hooks)\n}", "title": "" }, { "docid": "25822b758e34a5d8f7666e1a5a413018", "score": "0.52600646", "text": "func (asu *AdminSessionUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(asu.hooks) == 0 {\n\t\tif err = asu.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = asu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*AdminSessionMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = asu.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\tasu.mutation = mutation\n\t\t\taffected, err = asu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(asu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = asu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, asu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "b9e622a00e9201565a55531e5403031d", "score": "0.52547014", "text": "func (au *ArticleUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(au.hooks) == 0 {\n\t\taffected, err = au.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*ArticleMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tau.mutation = mutation\n\t\t\taffected, err = au.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(au.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = au.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, au.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "b9e622a00e9201565a55531e5403031d", "score": "0.52547014", "text": "func (au *ArticleUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(au.hooks) == 0 {\n\t\taffected, err = au.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*ArticleMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tau.mutation = mutation\n\t\t\taffected, err = au.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(au.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = au.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, au.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "5b37a53efa2d7dbd9356f2d8cda36ada", "score": "0.52545303", "text": "func (su *SymptomsUpdate) Save(ctx context.Context) (int, error) {\n\tif v, ok := su.mutation.Manner(); ok {\n\t\tif err := symptoms.MannerValidator(v); err != nil {\n\t\t\treturn 0, &ValidationError{Name: \"Manner\", err: fmt.Errorf(\"ent: validator failed for field \\\"Manner\\\": %w\", err)}\n\t\t}\n\t}\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(su.hooks) == 0 {\n\t\taffected, err = su.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*SymptomsMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tsu.mutation = mutation\n\t\t\taffected, err = su.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(su.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = su.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, su.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "f1be398145aae32646fcd5ce21890c37", "score": "0.52496666", "text": "func (bmu *BaselineMeasureUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(bmu.hooks) == 0 {\n\t\taffected, err = bmu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*BaselineMeasureMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tbmu.mutation = mutation\n\t\t\taffected, err = bmu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(bmu.hooks) - 1; i >= 0; i-- {\n\t\t\tif bmu.hooks[i] == nil {\n\t\t\t\treturn 0, fmt.Errorf(\"models: uninitialized hook (forgotten import models/runtime?)\")\n\t\t\t}\n\t\t\tmut = bmu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, bmu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "946bfefbaac0658bef6cd8ebc2dfe65a", "score": "0.52457726", "text": "func (pu *ProvinceUpdate) Save(ctx context.Context) (int, error) {\n\tif v, ok := pu.mutation.ProvinceName(); ok {\n\t\tif err := province.ProvinceNameValidator(v); err != nil {\n\t\t\treturn 0, &ValidationError{Name: \"Province_Name\", err: fmt.Errorf(\"ent: validator failed for field \\\"Province_Name\\\": %w\", err)}\n\t\t}\n\t}\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(pu.hooks) == 0 {\n\t\taffected, err = pu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*ProvinceMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tpu.mutation = mutation\n\t\t\taffected, err = pu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(pu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = pu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, pu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "b59aa473fe861ed3df7ba75d4676c5c9", "score": "0.52419853", "text": "func (ru *ResourceUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif err := ru.defaults(); err != nil {\n\t\treturn 0, err\n\t}\n\tif len(ru.hooks) == 0 {\n\t\tif err = ru.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = ru.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*ResourceMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = ru.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\tru.mutation = mutation\n\t\t\taffected, err = ru.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(ru.hooks) - 1; i >= 0; i-- {\n\t\t\tif ru.hooks[i] == nil {\n\t\t\t\treturn 0, fmt.Errorf(\"ent: uninitialized hook (forgotten import ent/runtime?)\")\n\t\t\t}\n\t\t\tmut = ru.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, ru.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "fec18765fd232bb6031b3a9d5d809c46", "score": "0.52366656", "text": "func (odu *OutboundDealUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(odu.hooks) == 0 {\n\t\taffected, err = odu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*OutboundDealMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\todu.mutation = mutation\n\t\t\taffected, err = odu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(odu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = odu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, odu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "abbe8f645e22a5cebacf090284daf770", "score": "0.52358276", "text": "func (eu *EmployeeUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\teu.defaults()\n\tif len(eu.hooks) == 0 {\n\t\tif err = eu.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = eu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*EmployeeMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = eu.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\teu.mutation = mutation\n\t\t\taffected, err = eu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(eu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = eu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, eu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "15f5ebcb9ea82382fd7665fbca639aec", "score": "0.52300847", "text": "func (bmdcu *BaselineMeasureDenomCountUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(bmdcu.hooks) == 0 {\n\t\taffected, err = bmdcu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*BaselineMeasureDenomCountMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tbmdcu.mutation = mutation\n\t\t\taffected, err = bmdcu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(bmdcu.hooks) - 1; i >= 0; i-- {\n\t\t\tif bmdcu.hooks[i] == nil {\n\t\t\t\treturn 0, fmt.Errorf(\"models: uninitialized hook (forgotten import models/runtime?)\")\n\t\t\t}\n\t\t\tmut = bmdcu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, bmdcu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "cc1e70181dfefd84a927492c21e05b61", "score": "0.52277493", "text": "func (iu *IPUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(iu.hooks) == 0 {\n\t\taffected, err = iu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*IPMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tiu.mutation = mutation\n\t\t\taffected, err = iu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(iu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = iu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, iu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "f63094eaeb603aa8eb8ee767c89fb343", "score": "0.52210504", "text": "func (gu *GroupUpdate) Save(ctx context.Context) (int, error) {\n\treturn withHooks[int, GroupMutation](ctx, gu.gremlinSave, gu.mutation, gu.hooks)\n}", "title": "" }, { "docid": "9da1af95ba883c59c80dddf2e1ffaf42", "score": "0.5218401", "text": "func (s *Service) Save(ctx context.Context, ds *DataSet) error {\n\tds.Modified = time.Now()\n\treturn s.store.Save(ctx, ds)\n}", "title": "" }, { "docid": "67ff89fa88e85f4d6a9655d9ea7d6c96", "score": "0.52036947", "text": "func (swfsu *SurveyWiFiScanUpdate) Save(ctx context.Context) (int, error) {\n\tif _, ok := swfsu.mutation.UpdateTime(); !ok {\n\t\tv := surveywifiscan.UpdateDefaultUpdateTime()\n\t\tswfsu.mutation.SetUpdateTime(v)\n\t}\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(swfsu.hooks) == 0 {\n\t\taffected, err = swfsu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*SurveyWiFiScanMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tswfsu.mutation = mutation\n\t\t\taffected, err = swfsu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(swfsu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = swfsu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, swfsu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "43e68d03a713912cd58ce48a2d20851f", "score": "0.5183778", "text": "func (tc *TestCreate) Save(ctx context.Context) (*Test, error) {\n\tif len(tc.history) > 1 {\n\t\treturn nil, errors.New(\"ent: multiple assignments on a unique edge \\\"history\\\"\")\n\t}\n\treturn tc.sqlSave(ctx)\n}", "title": "" }, { "docid": "9d6377a9d9f9a96a5841f724dc903ac7", "score": "0.51837593", "text": "func (rou *RestaurantOwnerUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(rou.hooks) == 0 {\n\t\taffected, err = rou.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*RestaurantOwnerMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\trou.mutation = mutation\n\t\t\taffected, err = rou.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(rou.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = rou.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, rou.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "5cbc06fcbd1f326843f36ae18dcc705e", "score": "0.51828724", "text": "func (ou *OrganizationUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tou.defaults()\n\tif len(ou.hooks) == 0 {\n\t\tif err = ou.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = ou.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*OrganizationMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = ou.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\tou.mutation = mutation\n\t\t\taffected, err = ou.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(ou.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = ou.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, ou.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "5823c3a365bc2f589d87b2be0975b6f3", "score": "0.5182748", "text": "func (gsiu *GoodsSpuImgsUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tgsiu.defaults()\n\tif len(gsiu.hooks) == 0 {\n\t\taffected, err = gsiu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*GoodsSpuImgsMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tgsiu.mutation = mutation\n\t\t\taffected, err = gsiu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(gsiu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = gsiu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, gsiu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "aa8bbde9877469192454b7a6bd3173ca", "score": "0.51821095", "text": "func Save(index, _type, id string, data interface{}) (resp elastigo.BaseResponse, err error) {\n\tif err = connect(); err != nil {\n\t\treturn\n\t}\n\n\tvar exists bool\n\tif exists, err = conn.ExistsBool(index, _type, id, nil); err != nil {\n\t\treturn\n\t}\n\n\tif exists {\n\t\t//TODO: idk why this doesn't work as expected\n\t\t//The work around is just to delete it, then re-add it\n\t\tif resp, err = conn.Delete(index, _type, id, nil); err != nil {\n\t\t\treturn\n\t\t}\n\t\tresp, err = conn.Index(index, _type, id, nil, data)\n\t\t//resp, err = conn.Update(index, _type, id, nil, data)\n\t} else {\n\t\tresp, err = conn.Index(index, _type, id, nil, data)\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "c690fcf0b4b8142955c3d77fcf4479d7", "score": "0.5180403", "text": "func Save(a m.Apointment) error {\n\treturn collection().Insert(a)\n}", "title": "" }, { "docid": "5e86472929e6f34329ce672c79e245b2", "score": "0.5177702", "text": "func (mu *MessageUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(mu.hooks) == 0 {\n\t\tif err = mu.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = mu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*MessageMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = mu.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\tmu.mutation = mutation\n\t\t\taffected, err = mu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(mu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = mu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, mu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "e8ecbc693c8284260519ce60437bdf5a", "score": "0.5171268", "text": "func (pu *PatientUpdate) Save(ctx context.Context) (int, error) {\n\tif pu.age != nil {\n\t\tif err := patient.AgeValidator(*pu.age); err != nil {\n\t\t\treturn 0, fmt.Errorf(\"ent: validator failed for field \\\"age\\\": %v\", err)\n\t\t}\n\t}\n\tif pu.password != nil {\n\t\tif err := patient.PasswordValidator(*pu.password); err != nil {\n\t\t\treturn 0, fmt.Errorf(\"ent: validator failed for field \\\"password\\\": %v\", err)\n\t\t}\n\t}\n\tif len(pu.history) > 1 {\n\t\treturn 0, errors.New(\"ent: multiple assignments on a unique edge \\\"history\\\"\")\n\t}\n\tif pu.clearedHistory && pu.history == nil {\n\t\treturn 0, errors.New(\"ent: clearing a unique edge \\\"history\\\"\")\n\t}\n\tif len(pu.schedule) > 1 {\n\t\treturn 0, errors.New(\"ent: multiple assignments on a unique edge \\\"schedule\\\"\")\n\t}\n\tif pu.clearedSchedule && pu.schedule == nil {\n\t\treturn 0, errors.New(\"ent: clearing a unique edge \\\"schedule\\\"\")\n\t}\n\treturn pu.sqlSave(ctx)\n}", "title": "" }, { "docid": "db8d1e5cfce11d4e18039747b3ae4488", "score": "0.5168068", "text": "func (m *Model) Save(vs ...interface{}) error {\n\treturn m.WriteTxn(func(txn *Txn) error {\n\t\treturn txn.Save(vs...)\n\t})\n}", "title": "" }, { "docid": "0041c2b6552a2356fbc9de6e8cce1320", "score": "0.51653117", "text": "func (cu *CleaningroomUpdate) Save(ctx context.Context) (int, error) {\n\tif v, ok := cu.mutation.Note(); ok {\n\t\tif err := cleaningroom.NoteValidator(v); err != nil {\n\t\t\treturn 0, &ValidationError{Name: \"note\", err: fmt.Errorf(\"ent: validator failed for field \\\"note\\\": %w\", err)}\n\t\t}\n\t}\n\tif v, ok := cu.mutation.Phonenumber(); ok {\n\t\tif err := cleaningroom.PhonenumberValidator(v); err != nil {\n\t\t\treturn 0, &ValidationError{Name: \"phonenumber\", err: fmt.Errorf(\"ent: validator failed for field \\\"phonenumber\\\": %w\", err)}\n\t\t}\n\t}\n\tif v, ok := cu.mutation.Numofem(); ok {\n\t\tif err := cleaningroom.NumofemValidator(v); err != nil {\n\t\t\treturn 0, &ValidationError{Name: \"numofem\", err: fmt.Errorf(\"ent: validator failed for field \\\"numofem\\\": %w\", err)}\n\t\t}\n\t}\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(cu.hooks) == 0 {\n\t\taffected, err = cu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*CleaningroomMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tcu.mutation = mutation\n\t\t\taffected, err = cu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(cu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = cu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, cu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "3749a032924d1f35223dd2ba2909412f", "score": "0.5157542", "text": "func (su *StatusUpdate) Save(ctx context.Context) (int, error) {\n\tif v, ok := su.mutation.Description(); ok {\n\t\tif err := status.DescriptionValidator(v); err != nil {\n\t\t\treturn 0, &ValidationError{Name: \"description\", err: fmt.Errorf(\"ent: validator failed for field \\\"description\\\": %w\", err)}\n\t\t}\n\t}\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(su.hooks) == 0 {\n\t\taffected, err = su.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*StatusMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tsu.mutation = mutation\n\t\t\taffected, err = su.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(su.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = su.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, su.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "a4dd205c05cd3c72e6d51872f42fa2a0", "score": "0.5150617", "text": "func (etu *ExportTaskUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(etu.hooks) == 0 {\n\t\tif err = etu.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = etu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*ExportTaskMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = etu.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\tetu.mutation = mutation\n\t\t\taffected, err = etu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(etu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = etu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, etu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "a204460514612beaff1dc76ffe770a2a", "score": "0.5134592", "text": "func (s *savedQueries) Set(ctx context.Context, info *SavedQueryInfo) error {\n\tres, err := dbconn.Global.ExecContext(\n\t\tctx,\n\t\t\"UPDATE saved_queries SET last_executed=$1, latest_result=$2, exec_duration_ns=$3 WHERE query=$4\",\n\t\tinfo.LastExecuted,\n\t\tinfo.LatestResult,\n\t\tint64(info.ExecDuration),\n\t\tinfo.Query,\n\t)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"UPDATE\")\n\t}\n\tupdated, err := res.RowsAffected()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"RowsAffected\")\n\t}\n\tif updated == 0 {\n\t\t// Didn't update any row, so insert a new one.\n\t\t_, err := dbconn.Global.ExecContext(\n\t\t\tctx,\n\t\t\t\"INSERT INTO saved_queries(query, last_executed, latest_result, exec_duration_ns) VALUES($1, $2, $3, $4)\",\n\t\t\tinfo.Query,\n\t\t\tinfo.LastExecuted,\n\t\t\tinfo.LatestResult,\n\t\t\tint64(info.ExecDuration),\n\t\t)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"INSERT\")\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "d966d5875f7124416834072455205dd9", "score": "0.5131565", "text": "func (tuo *TestUpdateOne) Save(ctx context.Context) (*Test, error) {\n\tif len(tuo.history) > 1 {\n\t\treturn nil, errors.New(\"ent: multiple assignments on a unique edge \\\"history\\\"\")\n\t}\n\treturn tuo.sqlSave(ctx)\n}", "title": "" }, { "docid": "a9ee03e39c9086ed4092175b66a3e5f5", "score": "0.5128575", "text": "func (du *DoctorUpdate) Save(ctx context.Context) (int, error) {\n\tif du.state != nil {\n\t\tif err := doctor.StateValidator(*du.state); err != nil {\n\t\t\treturn 0, fmt.Errorf(\"ent: validator failed for field \\\"state\\\": %v\", err)\n\t\t}\n\t}\n\treturn du.sqlSave(ctx)\n}", "title": "" }, { "docid": "70ec89b811c6547de80e9cf122a5be05", "score": "0.5123889", "text": "func (g *Game) Save(db XODB) error {\n\tif g.Exists() {\n\t\treturn g.Update(db)\n\t}\n\n\treturn g.Insert(db)\n}", "title": "" }, { "docid": "be60d9ddbf2f8208d29e6b5f6b593c11", "score": "0.51228005", "text": "func Save(v interface{}) error {\n\treturn WithinTransaction(func(tx *gorm.DB) (err error) {\n\t\t// check new object\n\t\tif cgorm.DBManager().NewRecord(v) {\n\t\t\treturn err\n\t\t}\n\t\tif err = tx.Save(v).Error; err != nil {\n\t\t\ttx.Rollback() // rollback\n\t\t\treturn err\n\t\t}\n\t\treturn err\n\t})\n}", "title": "" }, { "docid": "d26e2c439a85d8b64611ee3f6e3a98e1", "score": "0.5121841", "text": "func (au *AlertUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tau.defaults()\n\tif len(au.hooks) == 0 {\n\t\taffected, err = au.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*AlertMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tau.mutation = mutation\n\t\t\taffected, err = au.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(au.hooks) - 1; i >= 0; i-- {\n\t\t\tif au.hooks[i] == nil {\n\t\t\t\treturn 0, fmt.Errorf(\"ent: uninitialized hook (forgotten import ent/runtime?)\")\n\t\t\t}\n\t\t\tmut = au.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, au.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "54466064a736c99fe12c6d2d3c3196ac", "score": "0.51180714", "text": "func (tu *TokensUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(tu.hooks) == 0 {\n\t\taffected, err = tu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*TokensMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\ttu.mutation = mutation\n\t\t\taffected, err = tu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(tu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = tu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, tu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "b4375d18a96214b803d2fd9ec1eeea01", "score": "0.511798", "text": "func (dtu *DrugTypeUpdate) Save(ctx context.Context) (int, error) {\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(dtu.hooks) == 0 {\n\t\taffected, err = dtu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*DrugTypeMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tdtu.mutation = mutation\n\t\t\taffected, err = dtu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(dtu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = dtu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, dtu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "35e733858d1b915a863ef4b2a32fe35c", "score": "0.51136124", "text": "func (bu *BonediseaseUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(bu.hooks) == 0 {\n\t\tif err = bu.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = bu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*BonediseaseMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = bu.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\tbu.mutation = mutation\n\t\t\taffected, err = bu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(bu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = bu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, bu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "52281b6bab6b7d41ed5ea7f78b3de668", "score": "0.51127416", "text": "func (slu *SysLoggingUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(slu.hooks) == 0 {\n\t\tif err = slu.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = slu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*SysLoggingMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = slu.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\tslu.mutation = mutation\n\t\t\taffected, err = slu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(slu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = slu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, slu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "c057cb9ecd2f50f6c242be2c34b7ade7", "score": "0.50984937", "text": "func (p *PreProgBatch) Save(kind int64, year int64, db *sql.DB) error {\n\tfor i, l := range p.Lines {\n\t\tif l.CommissionID == 0 {\n\t\t\treturn fmt.Errorf(\"ligne %d, CommissionID nul\", i+1)\n\t\t}\n\t\tif l.Value == 0 {\n\t\t\treturn fmt.Errorf(\"ligne %d, Value nul\", i+1)\n\t\t}\n\t\tif l.ActionID == 0 {\n\t\t\treturn fmt.Errorf(\"ligne %d, ActionID nul\", i+1)\n\t\t}\n\t}\n\ttx, err := db.Begin()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"tx begin %v\", err)\n\t}\n\tstmt, err := tx.Prepare(pq.CopyIn(\"temp_pre_prog\", \"commission_id\",\n\t\t\"year\", \"value\", \"kind\", \"kind_id\", \"project\", \"comment\", \"action_id\"))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"copy in %v\", err)\n\t}\n\tdefer stmt.Close()\n\tfor _, l := range p.Lines {\n\t\tif _, err = stmt.Exec(l.CommissionID, year, l.Value, kind, l.KindID,\n\t\t\tl.Project, l.Comment, l.ActionID); err != nil {\n\t\t\ttx.Rollback()\n\t\t\treturn fmt.Errorf(\"statement execution %v\", err)\n\t\t}\n\t}\n\tif _, err = stmt.Exec(); err != nil {\n\t\ttx.Rollback()\n\t\treturn fmt.Errorf(\"statement flush exec %v\", err)\n\t}\n\tif _, err = tx.Exec(`DELETE FROM pre_prog WHERE year=$1 AND kind=$2`,\n\t\tyear, kind); err != nil {\n\t\ttx.Rollback()\n\t\treturn fmt.Errorf(\"delete query %v\", err)\n\t}\n\tqueries := []string{`INSERT INTO pre_prog (commission_id,year,value,kind,kind_id,\n\t\tproject,comment,action_id) SELECT DISTINCT commission_id,year,value,kind,kind_id,\n\t\tproject,comment,action_id FROM temp_pre_prog `,\n\t\t`DELETE from temp_pre_prog`,\n\t}\n\tfor i, q := range queries {\n\t\t_, err = tx.Exec(q)\n\t\tif err != nil {\n\t\t\ttx.Rollback()\n\t\t\treturn fmt.Errorf(\"requête %d : %s\", i, err.Error())\n\t\t}\n\t}\n\treturn tx.Commit()\n}", "title": "" }, { "docid": "4d6e7f7d4c8fdbdbaab798d278fd9427", "score": "0.5097129", "text": "func (wu *WordUpdate) Save(ctx context.Context) (int, error) {\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\twu.defaults()\n\tif len(wu.hooks) == 0 {\n\t\tif err = wu.check(); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\taffected, err = wu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*WordMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tif err = wu.check(); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\twu.mutation = mutation\n\t\t\taffected, err = wu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(wu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = wu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, wu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" }, { "docid": "a539082f51c7b3622efc36d18456ff2e", "score": "0.509686", "text": "func (accessor *JobAccessor) Save(job *Job) error {\n\treturn accessor.DB.Save(job).Error\n}", "title": "" }, { "docid": "302f4fb876970b91f7c29c589e76d524", "score": "0.50961095", "text": "func (vc *ViewportCreate) Save(ctx context.Context) (*Viewport, error) {\n\tif err := vc.preSave(); err != nil {\n\t\treturn nil, err\n\t}\n\tvar (\n\t\terr error\n\t\tnode *Viewport\n\t)\n\tif len(vc.hooks) == 0 {\n\t\tnode, err = vc.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*ViewportMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tvc.mutation = mutation\n\t\t\tnode, err = vc.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn node, err\n\t\t})\n\t\tfor i := len(vc.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = vc.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, vc.mutation); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn node, err\n}", "title": "" }, { "docid": "79a04d561b5aaeed438d9612eb98981f", "score": "0.5096073", "text": "func (db *DB) Write(req *spb.WriteRequest) error {\n\ttx, err := db.Begin()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"sql transaction begin error: %v\", err)\n\t}\n\twriteStmt := tx.Stmt(db.writeStmt)\n\tdefer func() {\n\t\tif err := writeStmt.Close(); err != nil {\n\t\t\tlog.Printf(\"error closing SQL Stmt: %v\", err)\n\t\t}\n\t}()\n\tfor _, update := range req.Update {\n\t\t_, err := writeStmt.Exec(\n\t\t\treq.GetSource().GetSignature(), req.GetSource().GetCorpus(), req.GetSource().GetRoot(), req.GetSource().GetPath(), req.GetSource().GetLanguage(),\n\t\t\tupdate.GetEdgeKind(),\n\t\t\tupdate.GetFactName(),\n\t\t\tupdate.GetTarget().GetSignature(), update.GetTarget().GetCorpus(), update.GetTarget().GetRoot(), update.GetTarget().GetPath(), update.GetTarget().GetLanguage(),\n\t\t\tupdate.FactValue)\n\t\tif err != nil {\n\t\t\ttx.Rollback()\n\t\t\treturn fmt.Errorf(\"sql insertion error: %v\", err)\n\t\t}\n\t}\n\tif err := tx.Commit(); err != nil {\n\t\treturn fmt.Errorf(\"sql commit error: %v\", err)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "87d274f8711ad2a996fb2ab707a1468d", "score": "0.50898665", "text": "func (ptu *PriceTypeUpdate) Save(ctx context.Context) (int, error) {\n\n\tvar (\n\t\terr error\n\t\taffected int\n\t)\n\tif len(ptu.hooks) == 0 {\n\t\taffected, err = ptu.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*PriceTypeMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tptu.mutation = mutation\n\t\t\taffected, err = ptu.sqlSave(ctx)\n\t\t\tmutation.done = true\n\t\t\treturn affected, err\n\t\t})\n\t\tfor i := len(ptu.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = ptu.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, ptu.mutation); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn affected, err\n}", "title": "" } ]
562d99b495bf97aabd8bc204e2372b71
NewBundleIdsCreateInstanceRequestWithBody generates requests for BundleIdsCreateInstance with any type of body
[ { "docid": "e4566ca7b5a0d5c2385561d823fee4e3", "score": "0.7572881", "text": "func NewBundleIdsCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/bundleIds\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" } ]
[ { "docid": "a36f50701a0886d210774dc6fc9f9935", "score": "0.7695645", "text": "func NewBundleIdsCreateInstanceRequest(server string, body BundleIdsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewBundleIdsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "84c9d07e76c4437becc255d00eade56f", "score": "0.7025395", "text": "func (c *ClientWithResponses) BundleIdsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BundleIdsCreateInstanceResponse, error) {\n\trsp, err := c.BundleIdsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseBundleIdsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "ed3c94b4a661412c8d7381eb75583520", "score": "0.64845085", "text": "func NewBundleIdCapabilitiesCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/bundleIdCapabilities\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "5c16e42c8020dbc63cef91bd61141d0d", "score": "0.6305806", "text": "func NewBundleIdCapabilitiesCreateInstanceRequest(server string, body BundleIdCapabilitiesCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewBundleIdCapabilitiesCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "2e1aeefaf185d3e9a0640601ffc8390b", "score": "0.6008245", "text": "func (c *ClientWithResponses) BundleIdCapabilitiesCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BundleIdCapabilitiesCreateInstanceResponse, error) {\n\trsp, err := c.BundleIdCapabilitiesCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseBundleIdCapabilitiesCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "c5f20680688b943b88564c3237e8fea1", "score": "0.5781119", "text": "func NewBundleIdsGetInstanceRequest(server string, id string, params *BundleIdsGetInstanceParams) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"id\", runtime.ParamLocationPath, id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/bundleIds/%s\", pathParam0)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tqueryValues := queryURL.Query()\n\n\tif params.FieldsBundleIds != nil {\n\n\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", false, \"fields[bundleIds]\", runtime.ParamLocationQuery, *params.FieldsBundleIds); err != nil {\n\t\t\treturn nil, err\n\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tfor k, v := range parsed {\n\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif params.Include != nil {\n\n\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", false, \"include\", runtime.ParamLocationQuery, *params.Include); err != nil {\n\t\t\treturn nil, err\n\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tfor k, v := range parsed {\n\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif params.FieldsBundleIdCapabilities != nil {\n\n\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", false, \"fields[bundleIdCapabilities]\", runtime.ParamLocationQuery, *params.FieldsBundleIdCapabilities); err != nil {\n\t\t\treturn nil, err\n\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tfor k, v := range parsed {\n\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif params.FieldsProfiles != nil {\n\n\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", false, \"fields[profiles]\", runtime.ParamLocationQuery, *params.FieldsProfiles); err != nil {\n\t\t\treturn nil, err\n\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tfor k, v := range parsed {\n\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif params.FieldsApps != nil {\n\n\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", false, \"fields[apps]\", runtime.ParamLocationQuery, *params.FieldsApps); err != nil {\n\t\t\treturn nil, err\n\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tfor k, v := range parsed {\n\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif params.LimitBundleIdCapabilities != nil {\n\n\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"limit[bundleIdCapabilities]\", runtime.ParamLocationQuery, *params.LimitBundleIdCapabilities); err != nil {\n\t\t\treturn nil, err\n\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tfor k, v := range parsed {\n\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif params.LimitProfiles != nil {\n\n\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"limit[profiles]\", runtime.ParamLocationQuery, *params.LimitProfiles); err != nil {\n\t\t\treturn nil, err\n\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tfor k, v := range parsed {\n\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tqueryURL.RawQuery = queryValues.Encode()\n\n\treq, err := http.NewRequest(\"GET\", queryURL.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "title": "" }, { "docid": "9d34b49e56eb1721414c221676f539c7", "score": "0.5745458", "text": "func NewAppScreenshotsCreateInstanceRequest(server string, body AppScreenshotsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewAppScreenshotsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "a948e844f2e5cfd50e5ab7852dfd6a16", "score": "0.55159634", "text": "func ParseBundleIdsCreateInstanceResponse(rsp *http.Response) (*BundleIdsCreateInstanceResponse, error) {\n\tbodyBytes, err := ioutil.ReadAll(rsp.Body)\n\tdefer func() { _ = rsp.Body.Close() }()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse := &BundleIdsCreateInstanceResponse{\n\t\tBody: bodyBytes,\n\t\tHTTPResponse: rsp,\n\t}\n\n\tswitch {\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 201:\n\t\tvar dest BundleIdResponse\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON201 = &dest\n\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 400:\n\t\tvar dest ErrorResponse\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON400 = &dest\n\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 403:\n\t\tvar dest ErrorResponse\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON403 = &dest\n\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 409:\n\t\tvar dest ErrorResponse\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON409 = &dest\n\n\t}\n\n\treturn response, nil\n}", "title": "" }, { "docid": "aac548f8f6014b4b30cf903e8ae82e7c", "score": "0.5484217", "text": "func NewBundleIdsUpdateInstanceRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"id\", runtime.ParamLocationPath, id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/bundleIds/%s\", pathParam0)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"PATCH\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "30ea6a33b00b950a7651009fd5e453a5", "score": "0.54715514", "text": "func NewBundleIdsUpdateInstanceRequest(server string, id string, body BundleIdsUpdateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewBundleIdsUpdateInstanceRequestWithBody(server, id, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "c081ffdf56f04b74178beaf6f8599b59", "score": "0.5421038", "text": "func (c *ClientWithResponses) AppStoreVersionReleaseRequestsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AppStoreVersionReleaseRequestsCreateInstanceResponse, error) {\n\trsp, err := c.AppStoreVersionReleaseRequestsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseAppStoreVersionReleaseRequestsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "06274c09de45612002572daf98086d9c", "score": "0.5373773", "text": "func NewCreateInstanceRequestWithBody(server string, params *CreateInstanceParams, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tqueryUrl, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbasePath := fmt.Sprintf(\"/instance\")\n\tif basePath[0] == '/' {\n\t\tbasePath = basePath[1:]\n\t}\n\n\tqueryUrl, err = queryUrl.Parse(basePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tqueryValues := queryUrl.Query()\n\n\tif params.Start != nil {\n\n\t\tif queryFrag, err := runtime.StyleParam(\"form\", true, \"start\", *params.Start); err != nil {\n\t\t\treturn nil, err\n\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tfor k, v := range parsed {\n\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tqueryUrl.RawQuery = queryValues.Encode()\n\n\treq, err := http.NewRequest(\"POST\", queryUrl.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\treturn req, nil\n}", "title": "" }, { "docid": "cde91955428a27507bc5ff4f380dd279", "score": "0.5362091", "text": "func (c *ClientWithResponses) AppStoreVersionSubmissionsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AppStoreVersionSubmissionsCreateInstanceResponse, error) {\n\trsp, err := c.AppStoreVersionSubmissionsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseAppStoreVersionSubmissionsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "3a2556caf52fa7a3866f025e9704fb64", "score": "0.5340862", "text": "func NewAppScreenshotsCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/appScreenshots\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "b77770e632630637a35a7364d888d4d9", "score": "0.5294203", "text": "func NewAppInfoLocalizationsCreateInstanceRequest(server string, body AppInfoLocalizationsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewAppInfoLocalizationsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "88a9619827fb88e7d0a4bd3d96fac167", "score": "0.5291287", "text": "func NewDevicesCreateInstanceRequest(server string, body DevicesCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewDevicesCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "9aa87202453e3d532514bc86f48b6f61", "score": "0.52908784", "text": "func (c *ClientWithResponses) AppScreenshotsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AppScreenshotsCreateInstanceResponse, error) {\n\trsp, err := c.AppScreenshotsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseAppScreenshotsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "6e6ffbb25bfbcd831355a17994c53bfa", "score": "0.52888376", "text": "func NewAppStoreVersionsCreateInstanceRequest(server string, body AppStoreVersionsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewAppStoreVersionsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "b9f0cfcec70154b3e9c77661b4cbd5e9", "score": "0.5254966", "text": "func (c *ClientWithResponses) AppStoreVersionsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AppStoreVersionsCreateInstanceResponse, error) {\n\trsp, err := c.AppStoreVersionsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseAppStoreVersionsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "ba3f3ca09f495a403ff5bca1abd9ae57", "score": "0.524664", "text": "func NewAppStoreVersionSubmissionsCreateInstanceRequest(server string, body AppStoreVersionSubmissionsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewAppStoreVersionSubmissionsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "8fa38dae77b093bfc03494c7fc9ea757", "score": "0.5208055", "text": "func NewAppScreenshotSetsCreateInstanceRequest(server string, body AppScreenshotSetsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewAppScreenshotSetsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "0005562bb41edda1bd50ac52b141d258", "score": "0.5203434", "text": "func NewAppStoreVersionLocalizationsCreateInstanceRequest(server string, body AppStoreVersionLocalizationsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewAppStoreVersionLocalizationsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "03750f11ea39bbac6b908625d242066b", "score": "0.5167397", "text": "func (rm *resourceManager) newCreateRequestPayload(\n\tctx context.Context,\n\tr *resource,\n) (*svcsdk.CreateModelPackageInput, error) {\n\tres := &svcsdk.CreateModelPackageInput{}\n\n\tif r.ko.Spec.CertifyForMarketplace != nil {\n\t\tres.SetCertifyForMarketplace(*r.ko.Spec.CertifyForMarketplace)\n\t}\n\tif r.ko.Spec.ClientToken != nil {\n\t\tres.SetClientToken(*r.ko.Spec.ClientToken)\n\t}\n\tif r.ko.Spec.InferenceSpecification != nil {\n\t\tf2 := &svcsdk.InferenceSpecification{}\n\t\tif r.ko.Spec.InferenceSpecification.Containers != nil {\n\t\t\tf2f0 := []*svcsdk.ModelPackageContainerDefinition{}\n\t\t\tfor _, f2f0iter := range r.ko.Spec.InferenceSpecification.Containers {\n\t\t\t\tf2f0elem := &svcsdk.ModelPackageContainerDefinition{}\n\t\t\t\tif f2f0iter.ContainerHostname != nil {\n\t\t\t\t\tf2f0elem.SetContainerHostname(*f2f0iter.ContainerHostname)\n\t\t\t\t}\n\t\t\t\tif f2f0iter.Image != nil {\n\t\t\t\t\tf2f0elem.SetImage(*f2f0iter.Image)\n\t\t\t\t}\n\t\t\t\tif f2f0iter.ImageDigest != nil {\n\t\t\t\t\tf2f0elem.SetImageDigest(*f2f0iter.ImageDigest)\n\t\t\t\t}\n\t\t\t\tif f2f0iter.ModelDataURL != nil {\n\t\t\t\t\tf2f0elem.SetModelDataUrl(*f2f0iter.ModelDataURL)\n\t\t\t\t}\n\t\t\t\tif f2f0iter.ProductID != nil {\n\t\t\t\t\tf2f0elem.SetProductId(*f2f0iter.ProductID)\n\t\t\t\t}\n\t\t\t\tf2f0 = append(f2f0, f2f0elem)\n\t\t\t}\n\t\t\tf2.SetContainers(f2f0)\n\t\t}\n\t\tif r.ko.Spec.InferenceSpecification.SupportedContentTypes != nil {\n\t\t\tf2f1 := []*string{}\n\t\t\tfor _, f2f1iter := range r.ko.Spec.InferenceSpecification.SupportedContentTypes {\n\t\t\t\tvar f2f1elem string\n\t\t\t\tf2f1elem = *f2f1iter\n\t\t\t\tf2f1 = append(f2f1, &f2f1elem)\n\t\t\t}\n\t\t\tf2.SetSupportedContentTypes(f2f1)\n\t\t}\n\t\tif r.ko.Spec.InferenceSpecification.SupportedRealtimeInferenceInstanceTypes != nil {\n\t\t\tf2f2 := []*string{}\n\t\t\tfor _, f2f2iter := range r.ko.Spec.InferenceSpecification.SupportedRealtimeInferenceInstanceTypes {\n\t\t\t\tvar f2f2elem string\n\t\t\t\tf2f2elem = *f2f2iter\n\t\t\t\tf2f2 = append(f2f2, &f2f2elem)\n\t\t\t}\n\t\t\tf2.SetSupportedRealtimeInferenceInstanceTypes(f2f2)\n\t\t}\n\t\tif r.ko.Spec.InferenceSpecification.SupportedResponseMIMETypes != nil {\n\t\t\tf2f3 := []*string{}\n\t\t\tfor _, f2f3iter := range r.ko.Spec.InferenceSpecification.SupportedResponseMIMETypes {\n\t\t\t\tvar f2f3elem string\n\t\t\t\tf2f3elem = *f2f3iter\n\t\t\t\tf2f3 = append(f2f3, &f2f3elem)\n\t\t\t}\n\t\t\tf2.SetSupportedResponseMIMETypes(f2f3)\n\t\t}\n\t\tif r.ko.Spec.InferenceSpecification.SupportedTransformInstanceTypes != nil {\n\t\t\tf2f4 := []*string{}\n\t\t\tfor _, f2f4iter := range r.ko.Spec.InferenceSpecification.SupportedTransformInstanceTypes {\n\t\t\t\tvar f2f4elem string\n\t\t\t\tf2f4elem = *f2f4iter\n\t\t\t\tf2f4 = append(f2f4, &f2f4elem)\n\t\t\t}\n\t\t\tf2.SetSupportedTransformInstanceTypes(f2f4)\n\t\t}\n\t\tres.SetInferenceSpecification(f2)\n\t}\n\tif r.ko.Spec.MetadataProperties != nil {\n\t\tf3 := &svcsdk.MetadataProperties{}\n\t\tif r.ko.Spec.MetadataProperties.CommitID != nil {\n\t\t\tf3.SetCommitId(*r.ko.Spec.MetadataProperties.CommitID)\n\t\t}\n\t\tif r.ko.Spec.MetadataProperties.GeneratedBy != nil {\n\t\t\tf3.SetGeneratedBy(*r.ko.Spec.MetadataProperties.GeneratedBy)\n\t\t}\n\t\tif r.ko.Spec.MetadataProperties.ProjectID != nil {\n\t\t\tf3.SetProjectId(*r.ko.Spec.MetadataProperties.ProjectID)\n\t\t}\n\t\tif r.ko.Spec.MetadataProperties.Repository != nil {\n\t\t\tf3.SetRepository(*r.ko.Spec.MetadataProperties.Repository)\n\t\t}\n\t\tres.SetMetadataProperties(f3)\n\t}\n\tif r.ko.Spec.ModelApprovalStatus != nil {\n\t\tres.SetModelApprovalStatus(*r.ko.Spec.ModelApprovalStatus)\n\t}\n\tif r.ko.Spec.ModelMetrics != nil {\n\t\tf5 := &svcsdk.ModelMetrics{}\n\t\tif r.ko.Spec.ModelMetrics.Bias != nil {\n\t\t\tf5f0 := &svcsdk.Bias{}\n\t\t\tif r.ko.Spec.ModelMetrics.Bias.Report != nil {\n\t\t\t\tf5f0f0 := &svcsdk.MetricsSource{}\n\t\t\t\tif r.ko.Spec.ModelMetrics.Bias.Report.ContentDigest != nil {\n\t\t\t\t\tf5f0f0.SetContentDigest(*r.ko.Spec.ModelMetrics.Bias.Report.ContentDigest)\n\t\t\t\t}\n\t\t\t\tif r.ko.Spec.ModelMetrics.Bias.Report.ContentType != nil {\n\t\t\t\t\tf5f0f0.SetContentType(*r.ko.Spec.ModelMetrics.Bias.Report.ContentType)\n\t\t\t\t}\n\t\t\t\tif r.ko.Spec.ModelMetrics.Bias.Report.S3URI != nil {\n\t\t\t\t\tf5f0f0.SetS3Uri(*r.ko.Spec.ModelMetrics.Bias.Report.S3URI)\n\t\t\t\t}\n\t\t\t\tf5f0.SetReport(f5f0f0)\n\t\t\t}\n\t\t\tf5.SetBias(f5f0)\n\t\t}\n\t\tif r.ko.Spec.ModelMetrics.Explainability != nil {\n\t\t\tf5f1 := &svcsdk.Explainability{}\n\t\t\tif r.ko.Spec.ModelMetrics.Explainability.Report != nil {\n\t\t\t\tf5f1f0 := &svcsdk.MetricsSource{}\n\t\t\t\tif r.ko.Spec.ModelMetrics.Explainability.Report.ContentDigest != nil {\n\t\t\t\t\tf5f1f0.SetContentDigest(*r.ko.Spec.ModelMetrics.Explainability.Report.ContentDigest)\n\t\t\t\t}\n\t\t\t\tif r.ko.Spec.ModelMetrics.Explainability.Report.ContentType != nil {\n\t\t\t\t\tf5f1f0.SetContentType(*r.ko.Spec.ModelMetrics.Explainability.Report.ContentType)\n\t\t\t\t}\n\t\t\t\tif r.ko.Spec.ModelMetrics.Explainability.Report.S3URI != nil {\n\t\t\t\t\tf5f1f0.SetS3Uri(*r.ko.Spec.ModelMetrics.Explainability.Report.S3URI)\n\t\t\t\t}\n\t\t\t\tf5f1.SetReport(f5f1f0)\n\t\t\t}\n\t\t\tf5.SetExplainability(f5f1)\n\t\t}\n\t\tif r.ko.Spec.ModelMetrics.ModelDataQuality != nil {\n\t\t\tf5f2 := &svcsdk.ModelDataQuality{}\n\t\t\tif r.ko.Spec.ModelMetrics.ModelDataQuality.Constraints != nil {\n\t\t\t\tf5f2f0 := &svcsdk.MetricsSource{}\n\t\t\t\tif r.ko.Spec.ModelMetrics.ModelDataQuality.Constraints.ContentDigest != nil {\n\t\t\t\t\tf5f2f0.SetContentDigest(*r.ko.Spec.ModelMetrics.ModelDataQuality.Constraints.ContentDigest)\n\t\t\t\t}\n\t\t\t\tif r.ko.Spec.ModelMetrics.ModelDataQuality.Constraints.ContentType != nil {\n\t\t\t\t\tf5f2f0.SetContentType(*r.ko.Spec.ModelMetrics.ModelDataQuality.Constraints.ContentType)\n\t\t\t\t}\n\t\t\t\tif r.ko.Spec.ModelMetrics.ModelDataQuality.Constraints.S3URI != nil {\n\t\t\t\t\tf5f2f0.SetS3Uri(*r.ko.Spec.ModelMetrics.ModelDataQuality.Constraints.S3URI)\n\t\t\t\t}\n\t\t\t\tf5f2.SetConstraints(f5f2f0)\n\t\t\t}\n\t\t\tif r.ko.Spec.ModelMetrics.ModelDataQuality.Statistics != nil {\n\t\t\t\tf5f2f1 := &svcsdk.MetricsSource{}\n\t\t\t\tif r.ko.Spec.ModelMetrics.ModelDataQuality.Statistics.ContentDigest != nil {\n\t\t\t\t\tf5f2f1.SetContentDigest(*r.ko.Spec.ModelMetrics.ModelDataQuality.Statistics.ContentDigest)\n\t\t\t\t}\n\t\t\t\tif r.ko.Spec.ModelMetrics.ModelDataQuality.Statistics.ContentType != nil {\n\t\t\t\t\tf5f2f1.SetContentType(*r.ko.Spec.ModelMetrics.ModelDataQuality.Statistics.ContentType)\n\t\t\t\t}\n\t\t\t\tif r.ko.Spec.ModelMetrics.ModelDataQuality.Statistics.S3URI != nil {\n\t\t\t\t\tf5f2f1.SetS3Uri(*r.ko.Spec.ModelMetrics.ModelDataQuality.Statistics.S3URI)\n\t\t\t\t}\n\t\t\t\tf5f2.SetStatistics(f5f2f1)\n\t\t\t}\n\t\t\tf5.SetModelDataQuality(f5f2)\n\t\t}\n\t\tif r.ko.Spec.ModelMetrics.ModelQuality != nil {\n\t\t\tf5f3 := &svcsdk.ModelQuality{}\n\t\t\tif r.ko.Spec.ModelMetrics.ModelQuality.Constraints != nil {\n\t\t\t\tf5f3f0 := &svcsdk.MetricsSource{}\n\t\t\t\tif r.ko.Spec.ModelMetrics.ModelQuality.Constraints.ContentDigest != nil {\n\t\t\t\t\tf5f3f0.SetContentDigest(*r.ko.Spec.ModelMetrics.ModelQuality.Constraints.ContentDigest)\n\t\t\t\t}\n\t\t\t\tif r.ko.Spec.ModelMetrics.ModelQuality.Constraints.ContentType != nil {\n\t\t\t\t\tf5f3f0.SetContentType(*r.ko.Spec.ModelMetrics.ModelQuality.Constraints.ContentType)\n\t\t\t\t}\n\t\t\t\tif r.ko.Spec.ModelMetrics.ModelQuality.Constraints.S3URI != nil {\n\t\t\t\t\tf5f3f0.SetS3Uri(*r.ko.Spec.ModelMetrics.ModelQuality.Constraints.S3URI)\n\t\t\t\t}\n\t\t\t\tf5f3.SetConstraints(f5f3f0)\n\t\t\t}\n\t\t\tif r.ko.Spec.ModelMetrics.ModelQuality.Statistics != nil {\n\t\t\t\tf5f3f1 := &svcsdk.MetricsSource{}\n\t\t\t\tif r.ko.Spec.ModelMetrics.ModelQuality.Statistics.ContentDigest != nil {\n\t\t\t\t\tf5f3f1.SetContentDigest(*r.ko.Spec.ModelMetrics.ModelQuality.Statistics.ContentDigest)\n\t\t\t\t}\n\t\t\t\tif r.ko.Spec.ModelMetrics.ModelQuality.Statistics.ContentType != nil {\n\t\t\t\t\tf5f3f1.SetContentType(*r.ko.Spec.ModelMetrics.ModelQuality.Statistics.ContentType)\n\t\t\t\t}\n\t\t\t\tif r.ko.Spec.ModelMetrics.ModelQuality.Statistics.S3URI != nil {\n\t\t\t\t\tf5f3f1.SetS3Uri(*r.ko.Spec.ModelMetrics.ModelQuality.Statistics.S3URI)\n\t\t\t\t}\n\t\t\t\tf5f3.SetStatistics(f5f3f1)\n\t\t\t}\n\t\t\tf5.SetModelQuality(f5f3)\n\t\t}\n\t\tres.SetModelMetrics(f5)\n\t}\n\tif r.ko.Spec.ModelPackageDescription != nil {\n\t\tres.SetModelPackageDescription(*r.ko.Spec.ModelPackageDescription)\n\t}\n\tif r.ko.Spec.ModelPackageGroupName != nil {\n\t\tres.SetModelPackageGroupName(*r.ko.Spec.ModelPackageGroupName)\n\t}\n\tif r.ko.Spec.ModelPackageName != nil {\n\t\tres.SetModelPackageName(*r.ko.Spec.ModelPackageName)\n\t}\n\tif r.ko.Spec.SourceAlgorithmSpecification != nil {\n\t\tf9 := &svcsdk.SourceAlgorithmSpecification{}\n\t\tif r.ko.Spec.SourceAlgorithmSpecification.SourceAlgorithms != nil {\n\t\t\tf9f0 := []*svcsdk.SourceAlgorithm{}\n\t\t\tfor _, f9f0iter := range r.ko.Spec.SourceAlgorithmSpecification.SourceAlgorithms {\n\t\t\t\tf9f0elem := &svcsdk.SourceAlgorithm{}\n\t\t\t\tif f9f0iter.AlgorithmName != nil {\n\t\t\t\t\tf9f0elem.SetAlgorithmName(*f9f0iter.AlgorithmName)\n\t\t\t\t}\n\t\t\t\tif f9f0iter.ModelDataURL != nil {\n\t\t\t\t\tf9f0elem.SetModelDataUrl(*f9f0iter.ModelDataURL)\n\t\t\t\t}\n\t\t\t\tf9f0 = append(f9f0, f9f0elem)\n\t\t\t}\n\t\t\tf9.SetSourceAlgorithms(f9f0)\n\t\t}\n\t\tres.SetSourceAlgorithmSpecification(f9)\n\t}\n\tif r.ko.Spec.Tags != nil {\n\t\tf10 := []*svcsdk.Tag{}\n\t\tfor _, f10iter := range r.ko.Spec.Tags {\n\t\t\tf10elem := &svcsdk.Tag{}\n\t\t\tif f10iter.Key != nil {\n\t\t\t\tf10elem.SetKey(*f10iter.Key)\n\t\t\t}\n\t\t\tif f10iter.Value != nil {\n\t\t\t\tf10elem.SetValue(*f10iter.Value)\n\t\t\t}\n\t\t\tf10 = append(f10, f10elem)\n\t\t}\n\t\tres.SetTags(f10)\n\t}\n\tif r.ko.Spec.ValidationSpecification != nil {\n\t\tf11 := &svcsdk.ModelPackageValidationSpecification{}\n\t\tif r.ko.Spec.ValidationSpecification.ValidationProfiles != nil {\n\t\t\tf11f0 := []*svcsdk.ModelPackageValidationProfile{}\n\t\t\tfor _, f11f0iter := range r.ko.Spec.ValidationSpecification.ValidationProfiles {\n\t\t\t\tf11f0elem := &svcsdk.ModelPackageValidationProfile{}\n\t\t\t\tif f11f0iter.ProfileName != nil {\n\t\t\t\t\tf11f0elem.SetProfileName(*f11f0iter.ProfileName)\n\t\t\t\t}\n\t\t\t\tif f11f0iter.TransformJobDefinition != nil {\n\t\t\t\t\tf11f0elemf1 := &svcsdk.TransformJobDefinition{}\n\t\t\t\t\tif f11f0iter.TransformJobDefinition.BatchStrategy != nil {\n\t\t\t\t\t\tf11f0elemf1.SetBatchStrategy(*f11f0iter.TransformJobDefinition.BatchStrategy)\n\t\t\t\t\t}\n\t\t\t\t\tif f11f0iter.TransformJobDefinition.Environment != nil {\n\t\t\t\t\t\tf11f0elemf1f1 := map[string]*string{}\n\t\t\t\t\t\tfor f11f0elemf1f1key, f11f0elemf1f1valiter := range f11f0iter.TransformJobDefinition.Environment {\n\t\t\t\t\t\t\tvar f11f0elemf1f1val string\n\t\t\t\t\t\t\tf11f0elemf1f1val = *f11f0elemf1f1valiter\n\t\t\t\t\t\t\tf11f0elemf1f1[f11f0elemf1f1key] = &f11f0elemf1f1val\n\t\t\t\t\t\t}\n\t\t\t\t\t\tf11f0elemf1.SetEnvironment(f11f0elemf1f1)\n\t\t\t\t\t}\n\t\t\t\t\tif f11f0iter.TransformJobDefinition.MaxConcurrentTransforms != nil {\n\t\t\t\t\t\tf11f0elemf1.SetMaxConcurrentTransforms(*f11f0iter.TransformJobDefinition.MaxConcurrentTransforms)\n\t\t\t\t\t}\n\t\t\t\t\tif f11f0iter.TransformJobDefinition.MaxPayloadInMB != nil {\n\t\t\t\t\t\tf11f0elemf1.SetMaxPayloadInMB(*f11f0iter.TransformJobDefinition.MaxPayloadInMB)\n\t\t\t\t\t}\n\t\t\t\t\tif f11f0iter.TransformJobDefinition.TransformInput != nil {\n\t\t\t\t\t\tf11f0elemf1f4 := &svcsdk.TransformInput{}\n\t\t\t\t\t\tif f11f0iter.TransformJobDefinition.TransformInput.CompressionType != nil {\n\t\t\t\t\t\t\tf11f0elemf1f4.SetCompressionType(*f11f0iter.TransformJobDefinition.TransformInput.CompressionType)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif f11f0iter.TransformJobDefinition.TransformInput.ContentType != nil {\n\t\t\t\t\t\t\tf11f0elemf1f4.SetContentType(*f11f0iter.TransformJobDefinition.TransformInput.ContentType)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif f11f0iter.TransformJobDefinition.TransformInput.DataSource != nil {\n\t\t\t\t\t\t\tf11f0elemf1f4f2 := &svcsdk.TransformDataSource{}\n\t\t\t\t\t\t\tif f11f0iter.TransformJobDefinition.TransformInput.DataSource.S3DataSource != nil {\n\t\t\t\t\t\t\t\tf11f0elemf1f4f2f0 := &svcsdk.TransformS3DataSource{}\n\t\t\t\t\t\t\t\tif f11f0iter.TransformJobDefinition.TransformInput.DataSource.S3DataSource.S3DataType != nil {\n\t\t\t\t\t\t\t\t\tf11f0elemf1f4f2f0.SetS3DataType(*f11f0iter.TransformJobDefinition.TransformInput.DataSource.S3DataSource.S3DataType)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif f11f0iter.TransformJobDefinition.TransformInput.DataSource.S3DataSource.S3URI != nil {\n\t\t\t\t\t\t\t\t\tf11f0elemf1f4f2f0.SetS3Uri(*f11f0iter.TransformJobDefinition.TransformInput.DataSource.S3DataSource.S3URI)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tf11f0elemf1f4f2.SetS3DataSource(f11f0elemf1f4f2f0)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tf11f0elemf1f4.SetDataSource(f11f0elemf1f4f2)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif f11f0iter.TransformJobDefinition.TransformInput.SplitType != nil {\n\t\t\t\t\t\t\tf11f0elemf1f4.SetSplitType(*f11f0iter.TransformJobDefinition.TransformInput.SplitType)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tf11f0elemf1.SetTransformInput(f11f0elemf1f4)\n\t\t\t\t\t}\n\t\t\t\t\tif f11f0iter.TransformJobDefinition.TransformOutput != nil {\n\t\t\t\t\t\tf11f0elemf1f5 := &svcsdk.TransformOutput{}\n\t\t\t\t\t\tif f11f0iter.TransformJobDefinition.TransformOutput.Accept != nil {\n\t\t\t\t\t\t\tf11f0elemf1f5.SetAccept(*f11f0iter.TransformJobDefinition.TransformOutput.Accept)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif f11f0iter.TransformJobDefinition.TransformOutput.AssembleWith != nil {\n\t\t\t\t\t\t\tf11f0elemf1f5.SetAssembleWith(*f11f0iter.TransformJobDefinition.TransformOutput.AssembleWith)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif f11f0iter.TransformJobDefinition.TransformOutput.KMSKeyID != nil {\n\t\t\t\t\t\t\tf11f0elemf1f5.SetKmsKeyId(*f11f0iter.TransformJobDefinition.TransformOutput.KMSKeyID)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif f11f0iter.TransformJobDefinition.TransformOutput.S3OutputPath != nil {\n\t\t\t\t\t\t\tf11f0elemf1f5.SetS3OutputPath(*f11f0iter.TransformJobDefinition.TransformOutput.S3OutputPath)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tf11f0elemf1.SetTransformOutput(f11f0elemf1f5)\n\t\t\t\t\t}\n\t\t\t\t\tif f11f0iter.TransformJobDefinition.TransformResources != nil {\n\t\t\t\t\t\tf11f0elemf1f6 := &svcsdk.TransformResources{}\n\t\t\t\t\t\tif f11f0iter.TransformJobDefinition.TransformResources.InstanceCount != nil {\n\t\t\t\t\t\t\tf11f0elemf1f6.SetInstanceCount(*f11f0iter.TransformJobDefinition.TransformResources.InstanceCount)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif f11f0iter.TransformJobDefinition.TransformResources.InstanceType != nil {\n\t\t\t\t\t\t\tf11f0elemf1f6.SetInstanceType(*f11f0iter.TransformJobDefinition.TransformResources.InstanceType)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif f11f0iter.TransformJobDefinition.TransformResources.VolumeKMSKeyID != nil {\n\t\t\t\t\t\t\tf11f0elemf1f6.SetVolumeKmsKeyId(*f11f0iter.TransformJobDefinition.TransformResources.VolumeKMSKeyID)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tf11f0elemf1.SetTransformResources(f11f0elemf1f6)\n\t\t\t\t\t}\n\t\t\t\t\tf11f0elem.SetTransformJobDefinition(f11f0elemf1)\n\t\t\t\t}\n\t\t\t\tf11f0 = append(f11f0, f11f0elem)\n\t\t\t}\n\t\t\tf11.SetValidationProfiles(f11f0)\n\t\t}\n\t\tif r.ko.Spec.ValidationSpecification.ValidationRole != nil {\n\t\t\tf11.SetValidationRole(*r.ko.Spec.ValidationSpecification.ValidationRole)\n\t\t}\n\t\tres.SetValidationSpecification(f11)\n\t}\n\n\treturn res, nil\n}", "title": "" }, { "docid": "f6bb9d2ac27a124f2ed77c1430e0fe0b", "score": "0.51504683", "text": "func NewCreateInstanceRequest(server string, params *CreateInstanceParams, body CreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewCreateInstanceRequestWithBody(server, params, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "3532493ec828cd4eb1faa72717d8bcba", "score": "0.5130672", "text": "func NewAppInfoLocalizationsCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/appInfoLocalizations\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "7b5c24f6b6d83f42f7414209cb858eb4", "score": "0.51284724", "text": "func (c *ClientWithResponses) BuildBetaNotificationsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BuildBetaNotificationsCreateInstanceResponse, error) {\n\trsp, err := c.BuildBetaNotificationsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseBuildBetaNotificationsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "721f6cde6deb4d7674b9685eeae67d2f", "score": "0.51238763", "text": "func (c *ClientWithResponses) CiWorkflowsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CiWorkflowsCreateInstanceResponse, error) {\n\trsp, err := c.CiWorkflowsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseCiWorkflowsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "a8c9eeeda62954ab36693c31a0f0ecd7", "score": "0.510603", "text": "func NewCertificatesCreateInstanceRequest(server string, body CertificatesCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewCertificatesCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "4cc6dfb3dc7b39ffaac81139e4ca52a4", "score": "0.50807476", "text": "func NewAppStoreVersionPhasedReleasesCreateInstanceRequest(server string, body AppStoreVersionPhasedReleasesCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewAppStoreVersionPhasedReleasesCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "c5f8e56229fc1999862664004014cdce", "score": "0.5070063", "text": "func (c *ClientWithResponses) AppStoreVersionPhasedReleasesCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AppStoreVersionPhasedReleasesCreateInstanceResponse, error) {\n\trsp, err := c.AppStoreVersionPhasedReleasesCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseAppStoreVersionPhasedReleasesCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "6541b5e780be60ec2fb76280a4580751", "score": "0.5061206", "text": "func StartCreateFedBundleCall(m telemetry.Metrics) *telemetry.CallCounter {\n\treturn telemetry.StartCall(m, telemetry.RegistrationAPI, telemetry.FederatedBundle, telemetry.Create)\n}", "title": "" }, { "docid": "6286a75ec1b213363b0ed3631bfc1525", "score": "0.50550854", "text": "func NewAppStoreVersionsCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/appStoreVersions\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "e96081efd8ed88ac89aa9125965b793b", "score": "0.50449", "text": "func NewAppStoreVersionSubmissionsCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/appStoreVersionSubmissions\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "dc3d3dbb25a222e38318ed1049493d0d", "score": "0.50404966", "text": "func NewCertificatesCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/certificates\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "0b65f052f19a540e50e90337afd12e3a", "score": "0.50391096", "text": "func NewAppStoreVersionLocalizationsCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/appStoreVersionLocalizations\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "d0bffc9d82a8aa25b5cccfe9c0705f0a", "score": "0.5000571", "text": "func NewBetaAppLocalizationsCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/betaAppLocalizations\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "fb05763a3bac0bce162d89f826643c36", "score": "0.4994397", "text": "func (rm *resourceManager) newCreateRequestPayload(\n\tctx context.Context,\n\tr *resource,\n) (*svcsdk.CreateModelBiasJobDefinitionInput, error) {\n\tres := &svcsdk.CreateModelBiasJobDefinitionInput{}\n\n\tif r.ko.Spec.JobDefinitionName != nil {\n\t\tres.SetJobDefinitionName(*r.ko.Spec.JobDefinitionName)\n\t}\n\tif r.ko.Spec.JobResources != nil {\n\t\tf1 := &svcsdk.MonitoringResources{}\n\t\tif r.ko.Spec.JobResources.ClusterConfig != nil {\n\t\t\tf1f0 := &svcsdk.MonitoringClusterConfig{}\n\t\t\tif r.ko.Spec.JobResources.ClusterConfig.InstanceCount != nil {\n\t\t\t\tf1f0.SetInstanceCount(*r.ko.Spec.JobResources.ClusterConfig.InstanceCount)\n\t\t\t}\n\t\t\tif r.ko.Spec.JobResources.ClusterConfig.InstanceType != nil {\n\t\t\t\tf1f0.SetInstanceType(*r.ko.Spec.JobResources.ClusterConfig.InstanceType)\n\t\t\t}\n\t\t\tif r.ko.Spec.JobResources.ClusterConfig.VolumeKMSKeyID != nil {\n\t\t\t\tf1f0.SetVolumeKmsKeyId(*r.ko.Spec.JobResources.ClusterConfig.VolumeKMSKeyID)\n\t\t\t}\n\t\t\tif r.ko.Spec.JobResources.ClusterConfig.VolumeSizeInGB != nil {\n\t\t\t\tf1f0.SetVolumeSizeInGB(*r.ko.Spec.JobResources.ClusterConfig.VolumeSizeInGB)\n\t\t\t}\n\t\t\tf1.SetClusterConfig(f1f0)\n\t\t}\n\t\tres.SetJobResources(f1)\n\t}\n\tif r.ko.Spec.ModelBiasAppSpecification != nil {\n\t\tf2 := &svcsdk.ModelBiasAppSpecification{}\n\t\tif r.ko.Spec.ModelBiasAppSpecification.ConfigURI != nil {\n\t\t\tf2.SetConfigUri(*r.ko.Spec.ModelBiasAppSpecification.ConfigURI)\n\t\t}\n\t\tif r.ko.Spec.ModelBiasAppSpecification.Environment != nil {\n\t\t\tf2f1 := map[string]*string{}\n\t\t\tfor f2f1key, f2f1valiter := range r.ko.Spec.ModelBiasAppSpecification.Environment {\n\t\t\t\tvar f2f1val string\n\t\t\t\tf2f1val = *f2f1valiter\n\t\t\t\tf2f1[f2f1key] = &f2f1val\n\t\t\t}\n\t\t\tf2.SetEnvironment(f2f1)\n\t\t}\n\t\tif r.ko.Spec.ModelBiasAppSpecification.ImageURI != nil {\n\t\t\tf2.SetImageUri(*r.ko.Spec.ModelBiasAppSpecification.ImageURI)\n\t\t}\n\t\tres.SetModelBiasAppSpecification(f2)\n\t}\n\tif r.ko.Spec.ModelBiasBaselineConfig != nil {\n\t\tf3 := &svcsdk.ModelBiasBaselineConfig{}\n\t\tif r.ko.Spec.ModelBiasBaselineConfig.BaseliningJobName != nil {\n\t\t\tf3.SetBaseliningJobName(*r.ko.Spec.ModelBiasBaselineConfig.BaseliningJobName)\n\t\t}\n\t\tif r.ko.Spec.ModelBiasBaselineConfig.ConstraintsResource != nil {\n\t\t\tf3f1 := &svcsdk.MonitoringConstraintsResource{}\n\t\t\tif r.ko.Spec.ModelBiasBaselineConfig.ConstraintsResource.S3URI != nil {\n\t\t\t\tf3f1.SetS3Uri(*r.ko.Spec.ModelBiasBaselineConfig.ConstraintsResource.S3URI)\n\t\t\t}\n\t\t\tf3.SetConstraintsResource(f3f1)\n\t\t}\n\t\tres.SetModelBiasBaselineConfig(f3)\n\t}\n\tif r.ko.Spec.ModelBiasJobInput != nil {\n\t\tf4 := &svcsdk.ModelBiasJobInput{}\n\t\tif r.ko.Spec.ModelBiasJobInput.EndpointInput != nil {\n\t\t\tf4f0 := &svcsdk.EndpointInput{}\n\t\t\tif r.ko.Spec.ModelBiasJobInput.EndpointInput.EndTimeOffset != nil {\n\t\t\t\tf4f0.SetEndTimeOffset(*r.ko.Spec.ModelBiasJobInput.EndpointInput.EndTimeOffset)\n\t\t\t}\n\t\t\tif r.ko.Spec.ModelBiasJobInput.EndpointInput.EndpointName != nil {\n\t\t\t\tf4f0.SetEndpointName(*r.ko.Spec.ModelBiasJobInput.EndpointInput.EndpointName)\n\t\t\t}\n\t\t\tif r.ko.Spec.ModelBiasJobInput.EndpointInput.FeaturesAttribute != nil {\n\t\t\t\tf4f0.SetFeaturesAttribute(*r.ko.Spec.ModelBiasJobInput.EndpointInput.FeaturesAttribute)\n\t\t\t}\n\t\t\tif r.ko.Spec.ModelBiasJobInput.EndpointInput.InferenceAttribute != nil {\n\t\t\t\tf4f0.SetInferenceAttribute(*r.ko.Spec.ModelBiasJobInput.EndpointInput.InferenceAttribute)\n\t\t\t}\n\t\t\tif r.ko.Spec.ModelBiasJobInput.EndpointInput.LocalPath != nil {\n\t\t\t\tf4f0.SetLocalPath(*r.ko.Spec.ModelBiasJobInput.EndpointInput.LocalPath)\n\t\t\t}\n\t\t\tif r.ko.Spec.ModelBiasJobInput.EndpointInput.ProbabilityAttribute != nil {\n\t\t\t\tf4f0.SetProbabilityAttribute(*r.ko.Spec.ModelBiasJobInput.EndpointInput.ProbabilityAttribute)\n\t\t\t}\n\t\t\tif r.ko.Spec.ModelBiasJobInput.EndpointInput.ProbabilityThresholdAttribute != nil {\n\t\t\t\tf4f0.SetProbabilityThresholdAttribute(*r.ko.Spec.ModelBiasJobInput.EndpointInput.ProbabilityThresholdAttribute)\n\t\t\t}\n\t\t\tif r.ko.Spec.ModelBiasJobInput.EndpointInput.S3DataDistributionType != nil {\n\t\t\t\tf4f0.SetS3DataDistributionType(*r.ko.Spec.ModelBiasJobInput.EndpointInput.S3DataDistributionType)\n\t\t\t}\n\t\t\tif r.ko.Spec.ModelBiasJobInput.EndpointInput.S3InputMode != nil {\n\t\t\t\tf4f0.SetS3InputMode(*r.ko.Spec.ModelBiasJobInput.EndpointInput.S3InputMode)\n\t\t\t}\n\t\t\tif r.ko.Spec.ModelBiasJobInput.EndpointInput.StartTimeOffset != nil {\n\t\t\t\tf4f0.SetStartTimeOffset(*r.ko.Spec.ModelBiasJobInput.EndpointInput.StartTimeOffset)\n\t\t\t}\n\t\t\tf4.SetEndpointInput(f4f0)\n\t\t}\n\t\tif r.ko.Spec.ModelBiasJobInput.GroundTruthS3Input != nil {\n\t\t\tf4f1 := &svcsdk.MonitoringGroundTruthS3Input{}\n\t\t\tif r.ko.Spec.ModelBiasJobInput.GroundTruthS3Input.S3URI != nil {\n\t\t\t\tf4f1.SetS3Uri(*r.ko.Spec.ModelBiasJobInput.GroundTruthS3Input.S3URI)\n\t\t\t}\n\t\t\tf4.SetGroundTruthS3Input(f4f1)\n\t\t}\n\t\tres.SetModelBiasJobInput(f4)\n\t}\n\tif r.ko.Spec.ModelBiasJobOutputConfig != nil {\n\t\tf5 := &svcsdk.MonitoringOutputConfig{}\n\t\tif r.ko.Spec.ModelBiasJobOutputConfig.KMSKeyID != nil {\n\t\t\tf5.SetKmsKeyId(*r.ko.Spec.ModelBiasJobOutputConfig.KMSKeyID)\n\t\t}\n\t\tif r.ko.Spec.ModelBiasJobOutputConfig.MonitoringOutputs != nil {\n\t\t\tf5f1 := []*svcsdk.MonitoringOutput{}\n\t\t\tfor _, f5f1iter := range r.ko.Spec.ModelBiasJobOutputConfig.MonitoringOutputs {\n\t\t\t\tf5f1elem := &svcsdk.MonitoringOutput{}\n\t\t\t\tif f5f1iter.S3Output != nil {\n\t\t\t\t\tf5f1elemf0 := &svcsdk.MonitoringS3Output{}\n\t\t\t\t\tif f5f1iter.S3Output.LocalPath != nil {\n\t\t\t\t\t\tf5f1elemf0.SetLocalPath(*f5f1iter.S3Output.LocalPath)\n\t\t\t\t\t}\n\t\t\t\t\tif f5f1iter.S3Output.S3UploadMode != nil {\n\t\t\t\t\t\tf5f1elemf0.SetS3UploadMode(*f5f1iter.S3Output.S3UploadMode)\n\t\t\t\t\t}\n\t\t\t\t\tif f5f1iter.S3Output.S3URI != nil {\n\t\t\t\t\t\tf5f1elemf0.SetS3Uri(*f5f1iter.S3Output.S3URI)\n\t\t\t\t\t}\n\t\t\t\t\tf5f1elem.SetS3Output(f5f1elemf0)\n\t\t\t\t}\n\t\t\t\tf5f1 = append(f5f1, f5f1elem)\n\t\t\t}\n\t\t\tf5.SetMonitoringOutputs(f5f1)\n\t\t}\n\t\tres.SetModelBiasJobOutputConfig(f5)\n\t}\n\tif r.ko.Spec.NetworkConfig != nil {\n\t\tf6 := &svcsdk.MonitoringNetworkConfig{}\n\t\tif r.ko.Spec.NetworkConfig.EnableInterContainerTrafficEncryption != nil {\n\t\t\tf6.SetEnableInterContainerTrafficEncryption(*r.ko.Spec.NetworkConfig.EnableInterContainerTrafficEncryption)\n\t\t}\n\t\tif r.ko.Spec.NetworkConfig.EnableNetworkIsolation != nil {\n\t\t\tf6.SetEnableNetworkIsolation(*r.ko.Spec.NetworkConfig.EnableNetworkIsolation)\n\t\t}\n\t\tif r.ko.Spec.NetworkConfig.VPCConfig != nil {\n\t\t\tf6f2 := &svcsdk.VpcConfig{}\n\t\t\tif r.ko.Spec.NetworkConfig.VPCConfig.SecurityGroupIDs != nil {\n\t\t\t\tf6f2f0 := []*string{}\n\t\t\t\tfor _, f6f2f0iter := range r.ko.Spec.NetworkConfig.VPCConfig.SecurityGroupIDs {\n\t\t\t\t\tvar f6f2f0elem string\n\t\t\t\t\tf6f2f0elem = *f6f2f0iter\n\t\t\t\t\tf6f2f0 = append(f6f2f0, &f6f2f0elem)\n\t\t\t\t}\n\t\t\t\tf6f2.SetSecurityGroupIds(f6f2f0)\n\t\t\t}\n\t\t\tif r.ko.Spec.NetworkConfig.VPCConfig.Subnets != nil {\n\t\t\t\tf6f2f1 := []*string{}\n\t\t\t\tfor _, f6f2f1iter := range r.ko.Spec.NetworkConfig.VPCConfig.Subnets {\n\t\t\t\t\tvar f6f2f1elem string\n\t\t\t\t\tf6f2f1elem = *f6f2f1iter\n\t\t\t\t\tf6f2f1 = append(f6f2f1, &f6f2f1elem)\n\t\t\t\t}\n\t\t\t\tf6f2.SetSubnets(f6f2f1)\n\t\t\t}\n\t\t\tf6.SetVpcConfig(f6f2)\n\t\t}\n\t\tres.SetNetworkConfig(f6)\n\t}\n\tif r.ko.Spec.RoleARN != nil {\n\t\tres.SetRoleArn(*r.ko.Spec.RoleARN)\n\t}\n\tif r.ko.Spec.StoppingCondition != nil {\n\t\tf8 := &svcsdk.MonitoringStoppingCondition{}\n\t\tif r.ko.Spec.StoppingCondition.MaxRuntimeInSeconds != nil {\n\t\t\tf8.SetMaxRuntimeInSeconds(*r.ko.Spec.StoppingCondition.MaxRuntimeInSeconds)\n\t\t}\n\t\tres.SetStoppingCondition(f8)\n\t}\n\tif r.ko.Spec.Tags != nil {\n\t\tf9 := []*svcsdk.Tag{}\n\t\tfor _, f9iter := range r.ko.Spec.Tags {\n\t\t\tf9elem := &svcsdk.Tag{}\n\t\t\tif f9iter.Key != nil {\n\t\t\t\tf9elem.SetKey(*f9iter.Key)\n\t\t\t}\n\t\t\tif f9iter.Value != nil {\n\t\t\t\tf9elem.SetValue(*f9iter.Value)\n\t\t\t}\n\t\t\tf9 = append(f9, f9elem)\n\t\t}\n\t\tres.SetTags(f9)\n\t}\n\n\treturn res, nil\n}", "title": "" }, { "docid": "62ea5889becb7c9034cd257f74a15ecb", "score": "0.498887", "text": "func (c *ClientWithResponses) DevicesCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DevicesCreateInstanceResponse, error) {\n\trsp, err := c.DevicesCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseDevicesCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "cd80b475cf9d76e6118c46fade4c1223", "score": "0.498752", "text": "func NewBetaAppLocalizationsCreateInstanceRequest(server string, body BetaAppLocalizationsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewBetaAppLocalizationsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "07a4079667a7b66d7e0f6c2a95a1d580", "score": "0.49848753", "text": "func (c *ClientWithResponses) CiBuildRunsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CiBuildRunsCreateInstanceResponse, error) {\n\trsp, err := c.CiBuildRunsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseCiBuildRunsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "60d28e89edd2c85a3df5f276b7f16967", "score": "0.49801448", "text": "func NewCreateInstancePoolRequest(server string, body CreateInstancePoolJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewCreateInstancePoolRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "cda77f7822f2a31666b82f0711db2414", "score": "0.49317965", "text": "func NewProfilesCreateInstanceRequest(server string, body ProfilesCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewProfilesCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "373e2ab447e0971917f640e120114f6c", "score": "0.49241212", "text": "func NewAppScreenshotSetsCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/appScreenshotSets\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "8406e3d5d4449710cff5c0ef26963542", "score": "0.49052387", "text": "func (c *ClientWithResponses) RoutingAppCoveragesCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RoutingAppCoveragesCreateInstanceResponse, error) {\n\trsp, err := c.RoutingAppCoveragesCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseRoutingAppCoveragesCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "9704a6654f79dc62e94b7045e75f3b55", "score": "0.48903054", "text": "func (c *ClientWithResponses) UserInvitationsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UserInvitationsCreateInstanceResponse, error) {\n\trsp, err := c.UserInvitationsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseUserInvitationsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "5ad18b14e79e1d2a87d1ee03fbc37a75", "score": "0.48873517", "text": "func NewAppStoreVersionReleaseRequestsCreateInstanceRequest(server string, body AppStoreVersionReleaseRequestsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewAppStoreVersionReleaseRequestsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "2dcb3c63b1dc418810388b424fe63041", "score": "0.48848078", "text": "func NewBetaBuildLocalizationsCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/betaBuildLocalizations\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "d244df0daf0bab3a314183626735b7c4", "score": "0.48820966", "text": "func NewAppStoreVersionPhasedReleasesCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/appStoreVersionPhasedReleases\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "0ffebcee80177d829df8756190210846", "score": "0.488029", "text": "func NewBuildBetaNotificationsCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/buildBetaNotifications\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "8640355e9289722c317baaaa678788d5", "score": "0.48527974", "text": "func NewBuildBetaNotificationsCreateInstanceRequest(server string, body BuildBetaNotificationsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewBuildBetaNotificationsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "af326313d6cc9a7355592509abbd2998", "score": "0.48512536", "text": "func NewDevicesCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/devices\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "11c49a91d844d9b32f56a11c2b276d25", "score": "0.48508546", "text": "func NewCreateInstancePoolRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tqueryUrl, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbasePath := fmt.Sprintf(\"/instance-pool\")\n\tif basePath[0] == '/' {\n\t\tbasePath = basePath[1:]\n\t}\n\n\tqueryUrl, err = queryUrl.Parse(basePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryUrl.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\treturn req, nil\n}", "title": "" }, { "docid": "4402d6958c4adbf4456ce40d327034f3", "score": "0.48241782", "text": "func ParseBundleIdCapabilitiesCreateInstanceResponse(rsp *http.Response) (*BundleIdCapabilitiesCreateInstanceResponse, error) {\n\tbodyBytes, err := ioutil.ReadAll(rsp.Body)\n\tdefer func() { _ = rsp.Body.Close() }()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse := &BundleIdCapabilitiesCreateInstanceResponse{\n\t\tBody: bodyBytes,\n\t\tHTTPResponse: rsp,\n\t}\n\n\tswitch {\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 201:\n\t\tvar dest BundleIdCapabilityResponse\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON201 = &dest\n\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 400:\n\t\tvar dest ErrorResponse\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON400 = &dest\n\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 403:\n\t\tvar dest ErrorResponse\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON403 = &dest\n\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 409:\n\t\tvar dest ErrorResponse\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON409 = &dest\n\n\t}\n\n\treturn response, nil\n}", "title": "" }, { "docid": "062f25ca70aa6f7fc9d444badce46b17", "score": "0.4822622", "text": "func NewRoutingAppCoveragesCreateInstanceRequest(server string, body RoutingAppCoveragesCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewRoutingAppCoveragesCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "e2bbdcac42ce03a6965a41dc3bd6b10a", "score": "0.4822615", "text": "func NewBetaBuildLocalizationsCreateInstanceRequest(server string, body BetaBuildLocalizationsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewBetaBuildLocalizationsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "be5ad37a32a3ff0f3cadcc2ecfa36b12", "score": "0.4805364", "text": "func (c *ClientWithResponses) CertificatesCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CertificatesCreateInstanceResponse, error) {\n\trsp, err := c.CertificatesCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseCertificatesCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "5c10e17a54682a5d0638efb8f69e8eff", "score": "0.47861803", "text": "func (c *ClientWithResponses) IdfaDeclarationsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*IdfaDeclarationsCreateInstanceResponse, error) {\n\trsp, err := c.IdfaDeclarationsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseIdfaDeclarationsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "29a0b3746de1deec6d6f79a409e61770", "score": "0.4780136", "text": "func CreateBatchRegisterDeviceWithApplyIdRequest() (request *BatchRegisterDeviceWithApplyIdRequest) {\n\trequest = &BatchRegisterDeviceWithApplyIdRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Iot\", \"2018-01-20\", \"BatchRegisterDeviceWithApplyId\", \"iot\", \"openAPI\")\n\treturn\n}", "title": "" }, { "docid": "e2f9ef186cfa25c82b5e3eaea9c40ac2", "score": "0.47761276", "text": "func NewBetaGroupsCreateInstanceRequest(server string, body BetaGroupsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewBetaGroupsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "fbc2a83a78885084f819bb361564c576", "score": "0.47746325", "text": "func (client *LocalRulestacksClient) listAppIDsCreateRequest(ctx context.Context, resourceGroupName string, localRulestackName string, options *LocalRulestacksClientListAppIDsOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/listAppIds\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif localRulestackName == \"\" {\n\t\treturn nil, errors.New(\"parameter localRulestackName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{localRulestackName}\", url.PathEscape(localRulestackName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-29\")\n\tif options != nil && options.AppIDVersion != nil {\n\t\treqQP.Set(\"appIdVersion\", *options.AppIDVersion)\n\t}\n\tif options != nil && options.AppPrefix != nil {\n\t\treqQP.Set(\"appPrefix\", *options.AppPrefix)\n\t}\n\tif options != nil && options.Skip != nil {\n\t\treqQP.Set(\"skip\", *options.Skip)\n\t}\n\tif options != nil && options.Top != nil {\n\t\treqQP.Set(\"top\", strconv.FormatInt(int64(*options.Top), 10))\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "title": "" }, { "docid": "5371338462d8b285a1a800622afd1d3a", "score": "0.4758169", "text": "func (client *WebAppsClient) listInstanceIdentifiersSlotCreateRequest(ctx context.Context, resourceGroupName string, name string, slot string, options *WebAppsListInstanceIdentifiersSlotOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/slots/{slot}/instances\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif slot == \"\" {\n\t\treturn nil, errors.New(\"parameter slot cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{slot}\", url.PathEscape(slot))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-02-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "title": "" }, { "docid": "9d2f79eb69bdb916e635203a4c7c9abd", "score": "0.47517896", "text": "func (r *CreateInstanceRequest) FromJsonString(s string) error {\n\tf := make(map[string]interface{})\n\tif err := json.Unmarshal([]byte(s), &f); err != nil {\n\t\treturn err\n\t}\n\tdelete(f, \"ProductId\")\n\tdelete(f, \"Software\")\n\tdelete(f, \"SupportHA\")\n\tdelete(f, \"InstanceName\")\n\tdelete(f, \"PayMode\")\n\tdelete(f, \"TimeSpan\")\n\tdelete(f, \"TimeUnit\")\n\tdelete(f, \"LoginSettings\")\n\tdelete(f, \"VPCSettings\")\n\tdelete(f, \"ResourceSpec\")\n\tdelete(f, \"COSSettings\")\n\tdelete(f, \"Placement\")\n\tdelete(f, \"SgId\")\n\tdelete(f, \"PreExecutedFileSettings\")\n\tdelete(f, \"AutoRenew\")\n\tdelete(f, \"ClientToken\")\n\tdelete(f, \"NeedMasterWan\")\n\tdelete(f, \"RemoteLoginAtCreate\")\n\tdelete(f, \"CheckSecurity\")\n\tdelete(f, \"ExtendFsField\")\n\tdelete(f, \"Tags\")\n\tdelete(f, \"DisasterRecoverGroupIds\")\n\tdelete(f, \"CbsEncrypt\")\n\tdelete(f, \"MetaType\")\n\tdelete(f, \"UnifyMetaInstanceId\")\n\tdelete(f, \"MetaDBInfo\")\n\tdelete(f, \"ApplicationRole\")\n\tdelete(f, \"SceneName\")\n\tdelete(f, \"ExternalService\")\n\tdelete(f, \"VersionID\")\n\tdelete(f, \"MultiZone\")\n\tdelete(f, \"MultiZoneSettings\")\n\tif len(f) > 0 {\n\t\treturn tcerr.NewTencentCloudSDKError(\"ClientError.BuildRequestError\", \"CreateInstanceRequest has unknown keys!\", \"\")\n\t}\n\treturn json.Unmarshal([]byte(s), &r)\n}", "title": "" }, { "docid": "8bde4074ed75d8842287f62021d524a4", "score": "0.47403425", "text": "func (c *ClientWithResponses) AppStoreVersionLocalizationsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AppStoreVersionLocalizationsCreateInstanceResponse, error) {\n\trsp, err := c.AppStoreVersionLocalizationsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseAppStoreVersionLocalizationsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "33b4f195596f2ab7b22ebb60732ab862", "score": "0.4733715", "text": "func (c *ClientWithResponses) AppScreenshotSetsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AppScreenshotSetsCreateInstanceResponse, error) {\n\trsp, err := c.AppScreenshotSetsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseAppScreenshotSetsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "9bdba4424177dd1f17e01faf89d36c17", "score": "0.47332102", "text": "func (rm *resourceManager) newCreateRequestPayload(\n\tctx context.Context,\n\tr *resource,\n) (*svcsdk.CreateReservedInstancesListingInput, error) {\n\tres := &svcsdk.CreateReservedInstancesListingInput{}\n\n\tif r.ko.Spec.ClientToken != nil {\n\t\tres.SetClientToken(*r.ko.Spec.ClientToken)\n\t}\n\tif r.ko.Spec.InstanceCount != nil {\n\t\tres.SetInstanceCount(*r.ko.Spec.InstanceCount)\n\t}\n\tif r.ko.Spec.PriceSchedules != nil {\n\t\tf2 := []*svcsdk.PriceScheduleSpecification{}\n\t\tfor _, f2iter := range r.ko.Spec.PriceSchedules {\n\t\t\tf2elem := &svcsdk.PriceScheduleSpecification{}\n\t\t\tif f2iter.CurrencyCode != nil {\n\t\t\t\tf2elem.SetCurrencyCode(*f2iter.CurrencyCode)\n\t\t\t}\n\t\t\tif f2iter.Price != nil {\n\t\t\t\tf2elem.SetPrice(*f2iter.Price)\n\t\t\t}\n\t\t\tif f2iter.Term != nil {\n\t\t\t\tf2elem.SetTerm(*f2iter.Term)\n\t\t\t}\n\t\t\tf2 = append(f2, f2elem)\n\t\t}\n\t\tres.SetPriceSchedules(f2)\n\t}\n\tif r.ko.Spec.ReservedInstancesID != nil {\n\t\tres.SetReservedInstancesId(*r.ko.Spec.ReservedInstancesID)\n\t}\n\n\treturn res, nil\n}", "title": "" }, { "docid": "1d7b5f24c8a91e770c38dcc47a674d7b", "score": "0.47284013", "text": "func NewCiWorkflowsCreateInstanceRequest(server string, body CiWorkflowsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewCiWorkflowsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "4130f6d136551006554bc738147c00b9", "score": "0.47249547", "text": "func NewCiBuildRunsCreateInstanceRequest(server string, body CiBuildRunsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewCiBuildRunsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "09f063f6f521792c14e88a295ac5f3ea", "score": "0.47188213", "text": "func (c *ClientWithResponses) ProfilesCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ProfilesCreateInstanceResponse, error) {\n\trsp, err := c.ProfilesCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseProfilesCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "2c328c12d31a827b4b307e73978461b1", "score": "0.471538", "text": "func NewAppStoreVersionReleaseRequestsCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/appStoreVersionReleaseRequests\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "6a7a1fec0d7e9c6210874abb4aae8f99", "score": "0.47091374", "text": "func NewUserInvitationsCreateInstanceRequest(server string, body UserInvitationsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewUserInvitationsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "8c37f263ff1da7a88e9f24119c6d6836", "score": "0.46944362", "text": "func NewAppPreviewsCreateInstanceRequest(server string, body AppPreviewsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewAppPreviewsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "c0f2e628599cb05edbc5a460cb03c23e", "score": "0.4692825", "text": "func (c *ClientWithResponses) AppPreviewsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AppPreviewsCreateInstanceResponse, error) {\n\trsp, err := c.AppPreviewsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseAppPreviewsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "9f4b3a57067769c8dfc4f2a76ef8923b", "score": "0.46782818", "text": "func NewProfilesCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/profiles\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "b6f9508670b01cb9192748227ede4d6d", "score": "0.46760237", "text": "func (client *WebAppsClient) listInstanceIdentifiersCreateRequest(ctx context.Context, resourceGroupName string, name string, options *WebAppsListInstanceIdentifiersOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/instances\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-02-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "title": "" }, { "docid": "ed50ee1090d045988f9934b601d2a106", "score": "0.4667595", "text": "func NewCiBuildRunsCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/ciBuildRuns\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "fbde2c3a46f0f62fef85769f453f2fb6", "score": "0.46590427", "text": "func NewBundleIdsDeleteInstanceRequest(server string, id string) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"id\", runtime.ParamLocationPath, id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/bundleIds/%s\", pathParam0)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"DELETE\", queryURL.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "title": "" }, { "docid": "d4308d14d1092e1a78a627f7272ec4bb", "score": "0.46515846", "text": "func NewRoutingAppCoveragesCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/routingAppCoverages\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "6595ba9fa055a970e253fd48f44a492f", "score": "0.4650136", "text": "func NewUserInvitationsCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/userInvitations\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "02b6b85cddd18bcc4956c61c3ca95f36", "score": "0.46498117", "text": "func (c *ClientWithResponses) BundleIdsUpdateInstanceWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BundleIdsUpdateInstanceResponse, error) {\n\trsp, err := c.BundleIdsUpdateInstanceWithBody(ctx, id, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseBundleIdsUpdateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "2b91c7b24745975c47d35eee6987a5f8", "score": "0.46329588", "text": "func (c *ClientWithResponses) BetaTesterInvitationsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BetaTesterInvitationsCreateInstanceResponse, error) {\n\trsp, err := c.BetaTesterInvitationsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseBetaTesterInvitationsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "eacfea2665b5dfe35136d6dcb9a775e8", "score": "0.4622579", "text": "func (c *ClientWithResponses) BetaAppReviewSubmissionsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BetaAppReviewSubmissionsCreateInstanceResponse, error) {\n\trsp, err := c.BetaAppReviewSubmissionsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseBetaAppReviewSubmissionsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "8519d53f06be9bbd1616839c7fae80dd", "score": "0.4618412", "text": "func CreateProduct(APIstub shim.ChaincodeStubInterface, args []string) sc.Response {\n /*\n Arguments:\n * ID\n * Name\n * HeatId\n * Quantity\n * Description\n * Organization\n * Unit\n * CreatedAt\n */\n\n ID := \"product-\" + args[0]\n quantity, err := strconv.ParseFloat(args[4], 64)\n if err != nil {\n return shim.Error(err.Error())\n }\n createdAt := time.Now().Format(\"2006-01-02 15:04:05 +0000 UTC\")\n if quantity < 0 {\n return shim.Error(\"Quantity should be positive\")\n }\n\n var product = types.Product{Class: \"Product\", ID: ID, Name: args[1], HeatID: args[2], Quantity: quantity, Description: args[4], Owner: args[5], Unit: args[6], CreatedAt: createdAt, ModifiedAt: createdAt}\n\n CreatedProductBytes, _ := json.Marshal(product)\n APIstub.PutState(ID, CreatedProductBytes)\n\n return shim.Success(CreatedProductBytes)\n}", "title": "" }, { "docid": "2708c0a1857b2369b96f1b29ccb3c7b3", "score": "0.46049607", "text": "func NewIdfaDeclarationsCreateInstanceRequest(server string, body IdfaDeclarationsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewIdfaDeclarationsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "7ae58353307c801e27dc7229bffb5082", "score": "0.4598204", "text": "func (c *ClientWithResponses) AppPreviewSetsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AppPreviewSetsCreateInstanceResponse, error) {\n\trsp, err := c.AppPreviewSetsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseAppPreviewSetsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "6e19340453800e16912d158a5a145402", "score": "0.4593191", "text": "func (c *ClientWithResponses) BetaBuildLocalizationsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BetaBuildLocalizationsCreateInstanceResponse, error) {\n\trsp, err := c.BetaBuildLocalizationsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseBetaBuildLocalizationsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "5cf0b56f5f144f999642f921168a476d", "score": "0.45899603", "text": "func NewBundleIdsAppGetToOneRelatedRequest(server string, id string, params *BundleIdsAppGetToOneRelatedParams) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"id\", runtime.ParamLocationPath, id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/bundleIds/%s/app\", pathParam0)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tqueryValues := queryURL.Query()\n\n\tif params.FieldsApps != nil {\n\n\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", false, \"fields[apps]\", runtime.ParamLocationQuery, *params.FieldsApps); err != nil {\n\t\t\treturn nil, err\n\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tfor k, v := range parsed {\n\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tqueryURL.RawQuery = queryValues.Encode()\n\n\treq, err := http.NewRequest(\"GET\", queryURL.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "title": "" }, { "docid": "99b43e8e63deda1e57c03838a807268a", "score": "0.45746705", "text": "func (c *ClientWithResponses) BetaAppLocalizationsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BetaAppLocalizationsCreateInstanceResponse, error) {\n\trsp, err := c.BetaAppLocalizationsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseBetaAppLocalizationsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "ab2b73572ed1d9100f99743a2e47eb63", "score": "0.45722193", "text": "func (c *ClientWithResponses) AppStoreReviewAttachmentsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AppStoreReviewAttachmentsCreateInstanceResponse, error) {\n\trsp, err := c.AppStoreReviewAttachmentsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseAppStoreReviewAttachmentsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "209860d044285913a1617f2eccea4bb0", "score": "0.45670366", "text": "func (o *ServiceCreateBody) UnmarshalJSON(raw []byte) error {\n\t// ServiceCreateParamsBodyAO0\n\tvar serviceCreateParamsBodyAO0 models.ServiceSpec\n\tif err := swag.ReadJSON(raw, &serviceCreateParamsBodyAO0); err != nil {\n\t\treturn err\n\t}\n\to.ServiceSpec = serviceCreateParamsBodyAO0\n\n\t// ServiceCreateParamsBodyAO1\n\tvar serviceCreateParamsBodyAO1 ServiceCreateParamsBodyAllOf1\n\tif err := swag.ReadJSON(raw, &serviceCreateParamsBodyAO1); err != nil {\n\t\treturn err\n\t}\n\to.ServiceCreateParamsBodyAllOf1 = serviceCreateParamsBodyAO1\n\n\treturn nil\n}", "title": "" }, { "docid": "3190a4ca90655b590a0a90430704eae0", "score": "0.45622593", "text": "func (b *Bundler) createBundle(p *ir.PatientInfo) *r4pb.Bundle {\n\tbundle := &r4pb.Bundle{\n\t\tType: &r4pb.Bundle_TypeCode{\n\t\t\tValue: cpb.BundleTypeCode_BATCH,\n\t\t},\n\t}\n\n\tbundle.Type = &r4pb.Bundle_TypeCode{Value: b.bundleTypeCode}\n\n\tpatient, patientRef := b.patient(p.Person)\n\taddEntry(bundle, patient)\n\n\tallergies := b.allergies(p.Allergies, patientRef)\n\taddEntry(bundle, allergies...)\n\n\tfor _, ec := range p.Encounters {\n\t\tencounter, encounterRef := b.encounter(ec, p.Class)\n\n\t\te := encounter.GetResource().GetEncounter()\n\t\tfor _, lh := range ec.LocationHistory {\n\t\t\tlocation, locationRef := b.location(lh.Location)\n\t\t\taddEntry(bundle, location)\n\t\t\te.Location = append(e.Location, encounterLocation(locationRef, lh.Start, lh.End))\n\t\t}\n\n\t\tfor _, pr := range ec.Procedures {\n\t\t\tpractitioner, practitionerRef := b.practitioner(pr.Clinician)\n\t\t\taddEntry(bundle, practitioner)\n\n\t\t\tprocedure, procedureRef := b.procedure(pr, patientRef, practitionerRef, encounterRef)\n\t\t\taddEntry(bundle, procedure)\n\t\t\te.Diagnosis = append(e.Diagnosis, encounterDiagnosis(procedureRef))\n\t\t}\n\n\t\tfor _, d := range ec.Diagnoses {\n\t\t\tpractitioner, practitionerRef := b.practitioner(d.Clinician)\n\t\t\taddEntry(bundle, practitioner)\n\n\t\t\tcondition, conditionRef := b.condition(d, patientRef, practitionerRef, encounterRef)\n\t\t\taddEntry(bundle, condition)\n\t\t\te.Diagnosis = append(e.Diagnosis, encounterDiagnosis(conditionRef))\n\t\t}\n\t\taddEntry(bundle, encounter)\n\n\t\tfor _, o := range ec.Orders {\n\t\t\tobservations := b.observations(encounterRef, patientRef, o)\n\t\t\taddEntry(bundle, observations...)\n\t\t}\n\t}\n\treturn bundle\n}", "title": "" }, { "docid": "b0ecb48f32b868b4126b7cc8ec4ecf9c", "score": "0.45511398", "text": "func (c *ClientWithResponses) AppInfoLocalizationsCreateInstanceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AppInfoLocalizationsCreateInstanceResponse, error) {\n\trsp, err := c.AppInfoLocalizationsCreateInstanceWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseAppInfoLocalizationsCreateInstanceResponse(rsp)\n}", "title": "" }, { "docid": "75272a7900fd5d195ef17ec0745db7ba", "score": "0.4550438", "text": "func NewBetaTesterInvitationsCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/betaTesterInvitations\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "2cf45fecceb2332d4437071cab747895", "score": "0.45460212", "text": "func NewBetaGroupsCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/betaGroups\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "57b076475bb1b11718f628c09f55e464", "score": "0.4530603", "text": "func NewBetaTesterInvitationsCreateInstanceRequest(server string, body BetaTesterInvitationsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewBetaTesterInvitationsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "07644a184647e7a815b89ed98d320c33", "score": "0.45293805", "text": "func NewAppStoreReviewAttachmentsCreateInstanceRequest(server string, body AppStoreReviewAttachmentsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewAppStoreReviewAttachmentsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "5119368ea5954e4a3b208cc917982a14", "score": "0.45293093", "text": "func NewCiWorkflowsCreateInstanceRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/ciWorkflows\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "87f6db569c02b81c8752bef8662fd050", "score": "0.4527968", "text": "func NewAppPreviewSetsCreateInstanceRequest(server string, body AppPreviewSetsCreateInstanceJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewAppPreviewSetsCreateInstanceRequestWithBody(server, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "6a9351f37ce40027e9b4af27b88fd14b", "score": "0.45119745", "text": "func (rm *resourceManager) newCreateRequestPayload(\n\tr *resource,\n) (*svcsdk.CreateStageInput, error) {\n\tres := &svcsdk.CreateStageInput{}\n\n\tif r.ko.Spec.AccessLogSettings != nil {\n\t\tf0 := &svcsdk.AccessLogSettings{}\n\t\tif r.ko.Spec.AccessLogSettings.DestinationARN != nil {\n\t\t\tf0.SetDestinationArn(*r.ko.Spec.AccessLogSettings.DestinationARN)\n\t\t}\n\t\tif r.ko.Spec.AccessLogSettings.Format != nil {\n\t\t\tf0.SetFormat(*r.ko.Spec.AccessLogSettings.Format)\n\t\t}\n\t\tres.SetAccessLogSettings(f0)\n\t}\n\tif r.ko.Spec.APIID != nil {\n\t\tres.SetApiId(*r.ko.Spec.APIID)\n\t}\n\tif r.ko.Spec.AutoDeploy != nil {\n\t\tres.SetAutoDeploy(*r.ko.Spec.AutoDeploy)\n\t}\n\tif r.ko.Spec.ClientCertificateID != nil {\n\t\tres.SetClientCertificateId(*r.ko.Spec.ClientCertificateID)\n\t}\n\tif r.ko.Spec.DefaultRouteSettings != nil {\n\t\tf4 := &svcsdk.RouteSettings{}\n\t\tif r.ko.Spec.DefaultRouteSettings.DataTraceEnabled != nil {\n\t\t\tf4.SetDataTraceEnabled(*r.ko.Spec.DefaultRouteSettings.DataTraceEnabled)\n\t\t}\n\t\tif r.ko.Spec.DefaultRouteSettings.DetailedMetricsEnabled != nil {\n\t\t\tf4.SetDetailedMetricsEnabled(*r.ko.Spec.DefaultRouteSettings.DetailedMetricsEnabled)\n\t\t}\n\t\tif r.ko.Spec.DefaultRouteSettings.LoggingLevel != nil {\n\t\t\tf4.SetLoggingLevel(*r.ko.Spec.DefaultRouteSettings.LoggingLevel)\n\t\t}\n\t\tif r.ko.Spec.DefaultRouteSettings.ThrottlingBurstLimit != nil {\n\t\t\tf4.SetThrottlingBurstLimit(*r.ko.Spec.DefaultRouteSettings.ThrottlingBurstLimit)\n\t\t}\n\t\tif r.ko.Spec.DefaultRouteSettings.ThrottlingRateLimit != nil {\n\t\t\tf4.SetThrottlingRateLimit(*r.ko.Spec.DefaultRouteSettings.ThrottlingRateLimit)\n\t\t}\n\t\tres.SetDefaultRouteSettings(f4)\n\t}\n\tif r.ko.Spec.DeploymentID != nil {\n\t\tres.SetDeploymentId(*r.ko.Spec.DeploymentID)\n\t}\n\tif r.ko.Spec.Description != nil {\n\t\tres.SetDescription(*r.ko.Spec.Description)\n\t}\n\tif r.ko.Spec.RouteSettings != nil {\n\t\tf7 := map[string]*svcsdk.RouteSettings{}\n\t\tfor f7key, f7valiter := range r.ko.Spec.RouteSettings {\n\t\t\tf7val := &svcsdk.RouteSettings{}\n\t\t\tif f7valiter.DataTraceEnabled != nil {\n\t\t\t\tf7val.SetDataTraceEnabled(*f7valiter.DataTraceEnabled)\n\t\t\t}\n\t\t\tif f7valiter.DetailedMetricsEnabled != nil {\n\t\t\t\tf7val.SetDetailedMetricsEnabled(*f7valiter.DetailedMetricsEnabled)\n\t\t\t}\n\t\t\tif f7valiter.LoggingLevel != nil {\n\t\t\t\tf7val.SetLoggingLevel(*f7valiter.LoggingLevel)\n\t\t\t}\n\t\t\tif f7valiter.ThrottlingBurstLimit != nil {\n\t\t\t\tf7val.SetThrottlingBurstLimit(*f7valiter.ThrottlingBurstLimit)\n\t\t\t}\n\t\t\tif f7valiter.ThrottlingRateLimit != nil {\n\t\t\t\tf7val.SetThrottlingRateLimit(*f7valiter.ThrottlingRateLimit)\n\t\t\t}\n\t\t\tf7[f7key] = f7val\n\t\t}\n\t\tres.SetRouteSettings(f7)\n\t}\n\tif r.ko.Spec.StageName != nil {\n\t\tres.SetStageName(*r.ko.Spec.StageName)\n\t}\n\tif r.ko.Spec.StageVariables != nil {\n\t\tf9 := map[string]*string{}\n\t\tfor f9key, f9valiter := range r.ko.Spec.StageVariables {\n\t\t\tvar f9val string\n\t\t\tf9val = *f9valiter\n\t\t\tf9[f9key] = &f9val\n\t\t}\n\t\tres.SetStageVariables(f9)\n\t}\n\tif r.ko.Spec.Tags != nil {\n\t\tf10 := map[string]*string{}\n\t\tfor f10key, f10valiter := range r.ko.Spec.Tags {\n\t\t\tvar f10val string\n\t\t\tf10val = *f10valiter\n\t\t\tf10[f10key] = &f10val\n\t\t}\n\t\tres.SetTags(f10)\n\t}\n\n\treturn res, nil\n}", "title": "" }, { "docid": "b7ea4ce1347d3cb03adecf216fce66f2", "score": "0.4505477", "text": "func NewBundleIdCapabilitiesUpdateInstanceRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"id\", runtime.ParamLocationPath, id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/bundleIdCapabilities/%s\", pathParam0)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"PATCH\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "56e9b143103015592a7ee96038011a72", "score": "0.44977215", "text": "func BuildCreatePayload(productCreateBody string, productCreateToken string) (*product.CreatePayload, error) {\n\tvar err error\n\tvar body CreateRequestBody\n\t{\n\t\terr = json.Unmarshal([]byte(productCreateBody), &body)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid JSON for body, \\nerror: %s, \\nexample of valid JSON:\\n%s\", err, \"'{\\n \\\"code\\\": \\\"123asd123123asd\\\",\\n \\\"cost_price\\\": 123,\\n \\\"founder_id\\\": \\\"519151ca-6250-4eec-8016-1e14a68dc448\\\",\\n \\\"image\\\": \\\"/images/123.jpg\\\",\\n \\\"is_shelves\\\": false,\\n \\\"market_price\\\": 123,\\n \\\"name\\\": \\\"灌装辣椒\\\",\\n \\\"note\\\": \\\"备注\\\",\\n \\\"size\\\": \\\"瓶\\\",\\n \\\"type\\\": 1,\\n \\\"unit\\\": 1\\n }'\")\n\t\t}\n\t\tif !(body.Unit == 1 || body.Unit == 2 || body.Unit == 3 || body.Unit == 4 || body.Unit == 5 || body.Unit == 6 || body.Unit == 7 || body.Unit == 8) {\n\t\t\terr = goa.MergeErrors(err, goa.InvalidEnumValueError(\"body.unit\", body.Unit, []interface{}{1, 2, 3, 4, 5, 6, 7, 8}))\n\t\t}\n\t\tif !(body.Type == 1 || body.Type == 2 || body.Type == 3 || body.Type == 4 || body.Type == 5 || body.Type == 6 || body.Type == 7 || body.Type == 8) {\n\t\t\terr = goa.MergeErrors(err, goa.InvalidEnumValueError(\"body.type\", body.Type, []interface{}{1, 2, 3, 4, 5, 6, 7, 8}))\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tvar token string\n\t{\n\t\ttoken = productCreateToken\n\t}\n\tv := &product.CreatePayload{\n\t\tName: body.Name,\n\t\tUnit: body.Unit,\n\t\tCostPrice: body.CostPrice,\n\t\tMarketPrice: body.MarketPrice,\n\t\tNote: body.Note,\n\t\tImage: body.Image,\n\t\tCode: body.Code,\n\t\tSize: body.Size,\n\t\tType: body.Type,\n\t\tIsShelves: body.IsShelves,\n\t\tFounderID: body.FounderID,\n\t}\n\tv.Token = token\n\n\treturn v, nil\n}", "title": "" } ]
077e4fe1bd0d6063e9a2b303b9e2c927
write struct to yaml file
[ { "docid": "10064fe7d9571b6a1956de4c9ba5e748", "score": "0.58750075", "text": "func WriteToYml(src string, conf interface{}) {\n\tdata, err := yaml.Marshal(conf)\n\tif err != nil {\n\t\tlog.Errorf(\"Conf转[]byte失败:%s\", err.Error())\n\t}\n\terr = ioutil.WriteFile(src, data, 0777)\n\tif err != nil {\n\t\tlog.Errorf(\"写yml文件失败\", err.Error())\n\t}\n}", "title": "" } ]
[ { "docid": "5124eb54e289b009a45047a43aa139b3", "score": "0.66262907", "text": "func SaveToYamlFile(path string, obj interface{}) error {\n\n\tfile, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, 0)\n\tdefer file.Close()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn yaml.NewEncoder(file).Encode(obj)\n}", "title": "" }, { "docid": "4a0bc30b815d4a21506599fb93eae6d3", "score": "0.65190154", "text": "func (ys *yaml) write(path, fileName string, doc NetworkTrafficDoc) error {\n\t//\n\tisFileEmpty, err := createYamlFile(path, fileName, ys.logger)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfile, err := os.OpenFile(filepath.Join(path, fileName+\".yaml\"), os.O_CREATE|os.O_WRONLY|os.O_APPEND, os.ModePerm)\n\tif err != nil {\n\t\tys.logger.Error(Emoji+\"failed to open the created yaml file\", zap.Error(err), zap.Any(\"yaml file name\", fileName))\n\t\treturn err\n\t}\n\n\tdata := []byte(\"---\\n\")\n\tif isFileEmpty {\n\t\tdata = []byte{}\n\t}\n\td, err := yamlLib.Marshal(&doc)\n\tif err != nil {\n\t\tys.logger.Error(Emoji+\"failed to marshal the recorded calls into yaml\", zap.Error(err), zap.Any(\"yaml file name\", fileName))\n\t\treturn err\n\t}\n\tdata = append(data, d...)\n\n\t_, err = file.Write(data)\n\tif err != nil {\n\t\tys.logger.Error(Emoji+\"failed to write the yaml document\", zap.Error(err), zap.Any(\"yaml file name\", fileName))\n\t\treturn err\n\t}\n\tdefer file.Close()\n\n\treturn nil\n}", "title": "" }, { "docid": "30c5e9330b9d28408411ad717e43f9c3", "score": "0.64758784", "text": "func (c Config) ToYamlFile(p string) {\n\t// TODO handle error\n\tioutil.WriteFile(p, c.ToYaml(), 0600)\n}", "title": "" }, { "docid": "c2fe5b1e409b66bc703c5173b114912a", "score": "0.6231657", "text": "func PersistObjectToYamlFile(fileNameBase string, obj *unstructured.Unstructured, outputDir string, serializer *k8sserial.Serializer) (string, error) {\n\tpath := path.Join(outputDir, fileNameBase+\".yaml\")\n\tf, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tdefer f.Close()\n\n\tif err := PersistObjectToYaml(fileNameBase, obj, f, serializer); err != nil {\n\t\treturn \"\", nil\n\t}\n\n\tif err = f.Sync(); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn path, nil\n}", "title": "" }, { "docid": "69dd79a8ef5e96c99a0751d8433e65b9", "score": "0.6207344", "text": "func saveYAML(stdout io.Writer, object saveObject, out string) error {\n\tbuf, err := yaml.Marshal(object)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"marshalling yaml\")\n\t}\n\n\t// to stdout\n\tif out == \"-\" {\n\t\tfmt.Fprintln(stdout, \"---\")\n\t\tfmt.Fprint(stdout, string(buf))\n\t\treturn nil\n\t}\n\n\t// to a directory\n\tpath, err := outputFile(stdout, object, out)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfile, err := os.Create(path)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"creating yaml file\")\n\t}\n\tdefer file.Close()\n\n\t// We prepend a document separator, because it helps when files\n\t// are cat'd together, and is otherwise harmless.\n\tfmt.Fprintln(file, \"---\")\n\tif _, err := file.Write(buf); err != nil {\n\t\treturn errors.Wrap(err, \"writing yaml file\")\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "5d23fbef6aea62bc34e5ad15a0f563cc", "score": "0.6187019", "text": "func WriteYaml(path string, obj interface{}) error {\n\n\td, err := yaml.Marshal(&obj)\n\tif err != nil {\n\t\treturn errors.New(\"unable to marshal yaml\")\n\t}\n\n\tif err := ioutil.WriteFile(path, d, 0644); err != nil {\n\t\treturn fmt.Errorf(\"Unable to write file at %s: %s\", path, err.Error())\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "b3d847a2bc2a5d86333a14208ac50eac", "score": "0.6167661", "text": "func (configFile *ConfigFile) save() error {\n\tfile, err := os.OpenFile(configFile.FilePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\n\tdata, err := yaml.Marshal(configFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = file.Write(data)\n\treturn err\n}", "title": "" }, { "docid": "de87a75f91026aa8816ce7a7141972d3", "score": "0.5888782", "text": "func WriteNewYaml(path string, obj interface{}) error {\n\n\tif _, err := os.Stat(path); err == nil {\n\t\treturn fmt.Errorf(\"File at %s exists\", path)\n\t}\n\n\tif err := WriteYaml(path, obj); err != nil {\n\t\treturn fmt.Errorf(\"Unable to write file at %s: %s\", path, err.Error())\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "b79f4144644ddde92203b5e24790de6e", "score": "0.5865046", "text": "func Save(title string, v interface{}) error {\n\t// create file path to config file.\n\tfpath := custom_path.Join(title + kToml)\n\n\t// create config file.\n\tf, err := os.Create(fpath)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer f.Close()\n\n\tenc := toml.NewEncoder(f) // create encoder.\n\terr = enc.Encode(v) // write config file.\n\n\t// return error code, nil if successful.\n\treturn err\n}", "title": "" }, { "docid": "fb2702d0ee7de159e0f469e3938b3a75", "score": "0.58200496", "text": "func (f *Funcs) yaml(v interface{}) (string, error) {\n\tbuf, err := yaml.MarshalWithOptions(v, yaml.Indent(2), yaml.IndentSequence(true))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(buf), nil\n}", "title": "" }, { "docid": "af737a617196c632f459909ae2311b41", "score": "0.5754322", "text": "func WriteYAML(path string, in interface{}) error {\n\ty, err := yaml.Marshal(in)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ioutil.WriteFile(path, y, 0644)\n}", "title": "" }, { "docid": "f1982fc6d9c4411e933301d92d38a682", "score": "0.5751728", "text": "func (config Config) WriteYAML(writer io.Writer) error {\n\tencoder := yaml.NewEncoder(writer)\n\treturn encoder.Encode(&C)\n}", "title": "" }, { "docid": "f6ad19afd2f172c0d3d835b28e7e3bd5", "score": "0.5745039", "text": "func Save() {\n\n\tcontent, _ := yaml.Marshal(&m)\n\tioutil.WriteFile(workdir+\"/services/services.yml\", content, 0644)\n}", "title": "" }, { "docid": "038117b287f857d0574a0e55e0b1061a", "score": "0.5725699", "text": "func writeToFile(config runtime.Object, configPath ...string) error {\n\tfPath := PathFromEnv()\n\tif configPath != nil {\n\t\tfPath = configPath[0]\n\t}\n\n\tif config == nil {\n\t\tglog.Errorf(\"could not write to '%s': config can't be nil\", fPath)\n\t}\n\n\t// encode config to YAML\n\tdata, err := runtime.Encode(latest.Codec, config)\n\tif err != nil {\n\t\treturn errors.Errorf(\"could not write to '%s': failed to encode config: %v\", fPath, err)\n\t}\n\n\t// create parent dir if doesn't exist\n\tdir := filepath.Dir(fPath)\n\tif _, err := os.Stat(dir); os.IsNotExist(err) {\n\t\tif err = os.MkdirAll(dir, 0755); err != nil {\n\t\t\treturn errors.Wrapf(err, \"Error creating directory: %s\", dir)\n\t\t}\n\t}\n\n\t// write with restricted permissions\n\tif err := lock.WriteFile(fPath, data, 0600); err != nil {\n\t\treturn errors.Wrapf(err, \"Error writing file %s\", fPath)\n\t}\n\n\tif err := pkgutil.MaybeChownDirRecursiveToMinikubeUser(dir); err != nil {\n\t\treturn errors.Wrapf(err, \"Error recursively changing ownership for dir: %s\", dir)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "248b5fcee95f7b6c02ade4b5a3faa5e7", "score": "0.5723632", "text": "func (gen *generatedStruct) write(w io.Writer) error {\n\tbuf := &bytes.Buffer{} // the formatter uses the entire output, so buffer for that\n\n\tif _, err := buf.Write([]byte(fmt.Sprintf(\"package %s\\n\\n%s\\n\\n\", gen.packageName, disclaimer))); err != nil {\n\t\treturn fmt.Errorf(\"failed writing struct: %v\", err)\n\t}\n\n\tif gen.fields.IncludeTime() {\n\t\tif _, err := buf.Write([]byte(\"import \\\"time\\\"\\n\")); err != nil {\n\t\t\treturn fmt.Errorf(\"failed writing struct: %v\", err)\n\t\t}\n\t}\n\n\tembeds := strings.Join(gen.embededStructs, \"\\n\")\n\tif embeds != \"\" {\n\t\tembeds += \"\\n\"\n\t}\n\tif _, err := buf.Write([]byte(fmt.Sprintf(\"type %s struct {\\n%s\\n\", exportedName(gen.name), embeds))); err != nil {\n\t\treturn fmt.Errorf(\"failed writing struct: %v\", err)\n\t}\n\n\tfor _, field := range gen.fields.Sorted() {\n\t\treq := gen.requiredFields[field.jsonName]\n\t\tif err := field.write(buf, \"\\t\", req); err != nil {\n\t\t\treturn fmt.Errorf(\"failed writing field %q: %v\", field.name, err)\n\t\t}\n\t}\n\n\tif _, err := buf.Write([]byte(\"}\")); err != nil {\n\t\treturn fmt.Errorf(\"failed writing struct: %v\", err)\n\t}\n\n\tfinal, err := format.Source(buf.Bytes())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to format source: %v\", err)\n\t}\n\n\tif _, err := w.Write(final); err != nil {\n\t\treturn fmt.Errorf(\"error writing to io.Writer: %v\", err)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "af8e595755c3ca80e77281dfc13e706d", "score": "0.5702806", "text": "func (s *scaffold) writeYAMLDoc(w io.Writer, data interface{}) {\n\tb, err := gdyaml.Marshal(data)\n\trequire.Nil(s.t, err, \"yaml marshal error: %v\", err)\n\t_, err = io.WriteString(w, \"---\\n\")\n\trequire.Nil(s.t, err, \"i/o error: %v\", err)\n\t_, err = w.Write(b)\n\trequire.Nil(s.t, err, \"i/o error: %v\", err)\n}", "title": "" }, { "docid": "2cb0a84d2ed91313cdf2bafcde11e56b", "score": "0.56710976", "text": "func (_m *IUtil) WriteYml(path string, dataStruct interface{}) {\n\t_m.Called(path, dataStruct)\n}", "title": "" }, { "docid": "9ce3213481a3399badeb894c3664eb9b", "score": "0.5653737", "text": "func SaveYaml(fn string) error {\n\tf, err := os.Create(fn)\n\tif err != nil {\n\t\tlogrus.WithField(\"filename\", fn).Error(\"cannot open configuration file for writing\")\n\t\tlogrus.Error(err)\n\t\treturn err\n\t}\n\tdefer f.Close()\n\n\tconf := map[string]interface{}{}\n\n\tif err = viper.Unmarshal(&conf); err != nil {\n\t\tlogrus.Error(\"cannot dump configuration structure\")\n\t\tlogrus.Error(err)\n\t\treturn err\n\t}\n\n\tbs, err := yaml.Marshal(conf)\n\tif err != nil {\n\t\tlogrus.Error(\"cannot marshal configuration structure to yaml\")\n\t\tlogrus.Error(err)\n\t\treturn err\n\t}\n\n\tn, err := f.Write(bs)\n\tif err != nil {\n\t\tlogrus.WithField(\"filename\", fn).Errorf(\"cannot write to file %s\", fn)\n\t\tlogrus.Error(err)\n\t\treturn err\n\t}\n\tlogrus.WithField(\"filename\", fn).WithField(\"n\", n).Debug(\"configuration saved\")\n\n\treturn nil\n\n}", "title": "" }, { "docid": "4415615ef824d2848af63bdc5d630a42", "score": "0.56469786", "text": "func print(obj interface{}, w io.Writer) error {\n\tif obj == nil {\n\t\treturn nil\n\t}\n\tdata, err := yaml.Marshal(obj)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = w.Write(data)\n\treturn err\n}", "title": "" }, { "docid": "7952ebf75c6260b567c37ba256a81edd", "score": "0.561198", "text": "func writeConfig(f Function) (err error) {\n\tpath := filepath.Join(f.Root, ConfigFile)\n\tc := toConfig(f)\n\tvar bb []byte\n\tif bb, err = yaml.Marshal(&c); err != nil {\n\t\treturn\n\t}\n\treturn ioutil.WriteFile(path, bb, 0644)\n}", "title": "" }, { "docid": "354f5f293a898070790b77265bc734fd", "score": "0.56057966", "text": "func DumpYaml(cfg interface{}) {\n\tout, err := yaml.Marshal(cfg)\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, err)\n\t} else {\n\t\tfmt.Printf(\"%s\\n\", out)\n\t}\n}", "title": "" }, { "docid": "b97670d89db8cd3581d0d89224813f71", "score": "0.5596529", "text": "func PrintAsYAML(writer io.Writer, events interface{}) {\n\teventsYAML, _ := yaml.Marshal(events)\n\tfmt.Fprintf(writer, \"%s\\n\", string(eventsYAML))\n\n}", "title": "" }, { "docid": "93eac1ebf060313238b7db3e802ca928", "score": "0.5592727", "text": "func (fp *FilePlanner) Write(p *Plan) error {\n\t// make a copy of the global comment map\n\toneTimeComments := map[string][]string{}\n\tfor k, v := range commentMap {\n\t\toneTimeComments[k] = v\n\t}\n\tbytez, marshalErr := yaml.Marshal(p)\n\tif marshalErr != nil {\n\t\treturn fmt.Errorf(\"error marshalling plan to yaml: %v\", marshalErr)\n\t}\n\n\tf, err := os.Create(fp.File)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error making plan file: %v\", err)\n\t}\n\tdefer f.Close()\n\n\t// the stack keeps track of the object we are in\n\t// for example, when we are inside cluster.networking, looking at the key 'foo'\n\t// the stack will have [cluster, networking, foo]\n\ts := newStack()\n\tscanner := bufio.NewScanner(bytes.NewReader(bytez))\n\tprevIndent := -1\n\taddNewLineBeforeComment := true\n\tvar etcdBlock bool\n\tfor scanner.Scan() {\n\t\ttext := scanner.Text()\n\t\tmatched := yamlKeyRE.FindStringSubmatch(text)\n\t\tif matched != nil && len(matched) > 1 {\n\t\t\tindent := strings.Count(matched[0], \" \") / 2\n\n\t\t\t// Figure out if we are in the etcd block\n\t\t\tif indent == 0 {\n\t\t\t\tetcdBlock = (text == \"etcd:\")\n\t\t\t}\n\t\t\t// Don't print labels: {} for etcd group\n\t\t\tif etcdBlock && strings.Contains(text, \"labels: {}\") {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Don't print taints: [] for etcd group\n\t\t\tif etcdBlock && strings.Contains(text, \"taints: []\") {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Add a new line if we are leaving a major indentation block\n\t\t\t// (leaving a struct)..\n\t\t\tif indent < prevIndent {\n\t\t\t\tf.WriteString(\"\\n\")\n\t\t\t\t// suppress the new line that would be added if this\n\t\t\t\t// field has a comment\n\t\t\t\taddNewLineBeforeComment = false\n\t\t\t}\n\t\t\tif indent <= prevIndent {\n\t\t\t\tfor i := 0; i <= (prevIndent - indent); i++ {\n\t\t\t\t\t// Pop from the stack when we have left an object\n\t\t\t\t\t// (we know because the indentation level has decreased)\n\t\t\t\t\tif _, err := s.Pop(); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ts.Push(matched[1])\n\t\t\tprevIndent = indent\n\n\t\t\t// Full key match (e.g. \"cluster.networking.pod_cidr\")\n\t\t\tif thiscomment, ok := oneTimeComments[strings.Join(s.s, \".\")]; ok {\n\t\t\t\tif _, err := f.WriteString(getCommentedLine(text, thiscomment, addNewLineBeforeComment)); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tdelete(oneTimeComments, matched[1])\n\t\t\t\taddNewLineBeforeComment = true\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\t// we don't want to comment this line... just print it out\n\t\tif _, err := f.WriteString(text + \"\\n\"); err != nil {\n\t\t\treturn err\n\t\t}\n\t\taddNewLineBeforeComment = true\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "095560032d561e38b6b48f9115629cc5", "score": "0.5573878", "text": "func FPrintYaml(writer io.Writer, value interface{}) {\n\tFInfo(writer, \"---\")\n\tRenderAsYaml(writer, value)\n}", "title": "" }, { "docid": "0979f47959ef3cf3ea9f30364db0d2c1", "score": "0.5552438", "text": "func WriteYamlToFile(yamlData interface{}, filePath string) error {\n\tyamlString, err := yaml.Marshal(yamlData)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = os.MkdirAll(filepath.Dir(filePath), 0755)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn os.WriteFile(filePath, yamlString, os.ModePerm)\n}", "title": "" }, { "docid": "2eeb37430f66cc86f94acd64df825c9d", "score": "0.55459046", "text": "func WriteYAML(path string, data interface{}) error {\n\tcontents, _ := yaml.Marshal(&data)\n\n\treturn ioutil.WriteFile(path, contents, 0644)\n}", "title": "" }, { "docid": "b84453a8606327c9705e2827ae8d6365", "score": "0.5540527", "text": "func (t *Tombstone) Write() error {\n\t// one write at a time\n\tt.fileLock.Lock()\n\tdefer t.fileLock.Unlock()\n\n\terr := os.MkdirAll(t.Graveyard, os.ModePerm)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// does not exit\n\tfile, err := os.Create(t.Path())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create tombstone file: %v\", err)\n\t}\n\tdefer file.Close()\n\n\tpretty, err := yaml.Marshal(t)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to marshal tombstone yaml: %v\", err)\n\t}\n\tfile.Write(pretty)\n\treturn nil\n}", "title": "" }, { "docid": "24ea966eadd9f9b03872c78c1451c019", "score": "0.5534065", "text": "func (cst *cliStateTelemetry) Write(p string) error {\n\tb, err := yaml.Marshal(cst)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Creates the file since it does not exist.\n\tif err := os.WriteFile(p, b, 0o644); err != nil { //nolint:gas\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "ba987809b75750b8d120aeeae689981f", "score": "0.5528915", "text": "func YamlStore(file string, source interface{}) (err error) {\n\tdata, err := yaml.Marshal(source)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ioutil.WriteFile(file, data, 0664)\n}", "title": "" }, { "docid": "d29577b2247d3361ca90ba2f02d1d4be", "score": "0.5519346", "text": "func ToYamlFile(c Config, path string) error {\n\tb, err := ToYaml(c)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ioutil.WriteFile(path, b, 0600)\n}", "title": "" }, { "docid": "b8098687f80f56656650ad3582d43aab", "score": "0.5514647", "text": "func (m *ManifoldYaml) Save() error {\n\tyml, err := yaml.Marshal(m)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpath := m.Path\n\tif path == \"\" {\n\t\t// Set the yaml in the current directory if path is not known\n\t\twd, err := os.Getwd()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tpath = filepath.Join(wd, YamlFilename)\n\t}\n\terr = ioutil.WriteFile(path, yml, requiredPermissions)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "274dde7cdf1a8591760a4214d9b37c6e", "score": "0.54975754", "text": "func Write2File(path string, data interface{}) error {\n\td, err := yaml.Marshal(&data)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err = ioutil.WriteFile(path, d, 0666); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "0f69f1a939c535a08f1fea644d85c46d", "score": "0.54817826", "text": "func (instance *Instance) Save(filename string) error {\n\treturn util.SaveYAML(filename, instance)\n}", "title": "" }, { "docid": "72342bec4ca8692c25ebef5645c77fb2", "score": "0.5478166", "text": "func ToYaml(values interface{}, file *os.File) error {\n\tlog.V(1).Info(\"create yaml file\", \"values\", values)\n\tdata, err := yaml.Marshal(values)\n\tif err != nil {\n\t\tlog.Error(err, \"failed to marshal value\", \"value\", values)\n\t\treturn err\n\t}\n\n\tdefer file.Close()\n\t_, err = file.Write(data)\n\tif err != nil {\n\t\tlog.Error(err, \"failed to write file\", \"data\", data, \"fileName\", file.Name())\n\t}\n\treturn err\n}", "title": "" }, { "docid": "72b93addfa6da22d665fb035a769968d", "score": "0.54759043", "text": "func ToYAML(data *OpenAPI, w io.Writer) error {\n\td, err := yaml.Marshal(&data)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Fprintf(w, \"%s\", d)\n\treturn nil\n}", "title": "" }, { "docid": "2ba67de8290e8e0f05e3c31ec096938c", "score": "0.5427036", "text": "func PrintYAML(v interface{}, w io.Writer) (err error) {\n\tenc := yaml.NewEncoder(w)\n\tvar close = true\n\tdefer func() {\n\t\tif err == nil && close {\n\t\t\terr = enc.Close()\n\t\t}\n\t}()\n\tif resources, ok := v.([]types.Resource); ok {\n\t\tif len(resources) == 0 {\n\t\t\tclose = false\n\t\t\treturn nil\n\t\t}\n\t\tfor _, r := range resources {\n\t\t\tif err := enc.Encode(wrapResource(r)); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\tif r, ok := v.(types.Resource); ok {\n\t\tv = wrapResource(r)\n\t}\n\n\treturn enc.Encode(v)\n}", "title": "" }, { "docid": "fed52b56cde1ffc45e078982b300ea64", "score": "0.5425348", "text": "func (o *Output) yaml(data interface{}) error {\n\tvar (\n\t\tformatted []byte\n\t\terr error\n\t)\n\n\t// Early quit on no data\n\tif data == nil {\n\t\treturn nil\n\t}\n\n\tif o == nil || o.jsonFormatter == nil {\n\t\treturn errors.New(\"invalid output formatter\")\n\t}\n\n\t// Let's see what they sent us\n\tswitch d := data.(type) {\n\t//case *bytes.Buffer:\n\t//\tformatted, err = o.jsonFormatter.Format(d.Bytes())\n\t//case []byte:\n\t//\tformatted, err = o.jsonFormatter.Format(d)\n\tdefault:\n\t\tformatted, err = yaml.Marshal(d)\n\t}\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Println(string(formatted))\n\n\treturn nil\n}", "title": "" }, { "docid": "c5be3eb40bd9852d8419b3c6a4492f52", "score": "0.54204553", "text": "func setYamlStruct(\n\tvars map[string]string,\n\tprefix string,\n\tm map[interface{}]interface{}) {\n\tfor k, v := range m {\n\t\tkey := prefix + k.(string)\n\t\tsetYamlVar(vars, key, v)\n\t}\n}", "title": "" }, { "docid": "70f924d7d8de3f85e3637e0c15f454c2", "score": "0.53970224", "text": "func writeConfig(path string, c Config) {\n\tfor _, gallery := range c.Galleries {\n\t\tif gallery.Link == \"\" {\n\t\t\tgallery.Link = getCrypto(32)\n\t\t}\n\t\tif gallery.Password == \"\" {\n\t\t\tgallery.Password = getCrypto(16)\n\t\t}\n\t\tlog.Print(\"Gallery \" + gallery.Title + \" is reachable via http://localhost:\" + c.Port + \"/\" + gallery.Link + \" - gollery/\" + gallery.Password)\n\t}\n\td, err := yaml.Marshal(&c)\n\tcheck(err)\n\n\terr = ioutil.WriteFile(path+\"/config.yaml\", d, 0644)\n\tcheck(err)\n}", "title": "" }, { "docid": "c4066da258630d3d2746b71b5734d856", "score": "0.53958654", "text": "func (c *Chartfile) Save(filename string) error {\n\tb, err := yaml.Marshal(c)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn ioutil.WriteFile(filename, b, 0644)\n}", "title": "" }, { "docid": "494da00b5368eeebcc4b8a808efa64b9", "score": "0.537826", "text": "func Save(truncate bool) error {\n\tconf, err := yaml.Marshal(&Config)\n\tif err != nil {\n\t\tlog.Printf(\"Could not Marshal the configuration to yaml : %v\", err)\n\t\treturn err\n\t}\n\n\tconfPath := *ConfPath\n\tif !truncate {\n\t\tconfPath += \".new\"\n\t}\n\n\terr = ioutil.WriteFile(confPath, conf, 0644)\n\tif err != nil {\n\t\tlog.Printf(\"Error saving config to %s : %v\", confPath, err)\n\t}\n\treturn err\n}", "title": "" }, { "docid": "8fbc6e2496da5b1a6b435b32d94c1a3c", "score": "0.5354015", "text": "func toYAML(v interface{}) string {\n\tdata, err := yaml.Marshal(v)\n\tif err != nil {\n\t\t// Swallow errors inside of a template.\n\t\treturn \"\"\n\t}\n\treturn strings.TrimSuffix(string(data), \"\\n\")\n}", "title": "" }, { "docid": "8fbc6e2496da5b1a6b435b32d94c1a3c", "score": "0.5354015", "text": "func toYAML(v interface{}) string {\n\tdata, err := yaml.Marshal(v)\n\tif err != nil {\n\t\t// Swallow errors inside of a template.\n\t\treturn \"\"\n\t}\n\treturn strings.TrimSuffix(string(data), \"\\n\")\n}", "title": "" }, { "docid": "0a3e0c6dc5ee692adcd8a2dcfdb254a5", "score": "0.53504574", "text": "func WriteEdgeYamlFile(path string, modifiedEdgeYaml *EdgeYamlSt) error {\n\n\tedgeID := \"fb4ebb70-2783-42b8-b3ef-63e2fd6d242e\"\n\turl := fmt.Sprintf(\"wss://0.0.0.0:10000/%s/fb4ebb70-2783-42b8-b3ef-63e2fd6d242e/events\", DefaultProjectID)\n\tversion := \"2.0.0\"\n\truntimeType := \"docker\"\n\n\tif nil != modifiedEdgeYaml {\n\t\tif \"\" != modifiedEdgeYaml.EdgeHub.WebSocket.URL {\n\t\t\turl = modifiedEdgeYaml.EdgeHub.WebSocket.URL\n\t\t\tedgeID = strings.Split(modifiedEdgeYaml.EdgeHub.WebSocket.URL, \"/\")[4]\n\t\t}\n\t\tif \"\" != modifiedEdgeYaml.EdgeD.Version {\n\t\t\tversion = modifiedEdgeYaml.EdgeD.Version\n\t\t}\n\t\tif \"\" != modifiedEdgeYaml.EdgeD.RuntimeType {\n\t\t\truntimeType = modifiedEdgeYaml.EdgeD.RuntimeType\n\t\t}\n\t}\n\n\tedgeData := EdgeYamlSt{MQTT: MQTTConfig{Server: \"tcp://127.0.0.1:1883\", InternalServer: \"tcp://127.0.0.1:1884\", Mode: MQTTInternalMode, QOS: MQTTQoSAtMostOnce,\n\t\tRetain: false, SessionQueueSize: 100},\n\t\tEdgeHub: EdgeHubSt{WebSocket: WebSocketSt{URL: url, CertFile: \"/etc/kubeedge/certs/edge.crt\", KeyFile: \"/etc/kubeedge/certs/edge.key\",\n\t\t\tHandshakeTimeout: 30, WriteDeadline: 15, ReadDeadline: 15},\n\t\t\tController: ControllerSt{Placement: false, Heartbeat: 15, RefreshAKSKInterval: 10, AuthInfoFilesPath: \"/var/IEF/secret\",\n\t\t\t\tPlacementURL: \"https://10.154.193.32:7444/v1/placement_external/message_queue\", ProjectID: DefaultProjectID,\n\t\t\t\tNodeID: edgeID}},\n\t\tEdgeD: EdgeDSt{RegisterNodeNamespace: \"default\", HostnameOverride: edgeID, InterfaceName: \"eth0\",\n\t\t\tNodeStatusUpdateFrequency: 10, DevicePluginEnabled: false, GPUPluginEnabled: false, ImageGCHighThreshold: 80, ImageGCLowThreshold: 40,\n\t\t\tMaximumDeadContainersPerContainer: 1, DockerAddress: \"unix:///var/run/docker.sock\", Version: version, RuntimeType: runtimeType, RuntimeEndpoint: \"/var/run/containerd/containerd.sock\", ImageEndpoint: \"/var/run/containerd/containerd.sock\", RequestTimeout: 2, PodSandboxImage: \"k8s.gcr.io/pause\"},\n\t\tMesh: Mesh{LB: LoadBalance{StrategyName: \"RoundRobin\"}},\n\t}\n\tif err := Write2File(path, edgeData); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "2db9e67de348d751113c303c37454fcd", "score": "0.5349787", "text": "func (cc *configContainer) Write(data interface{}, path string) error {\n\t// If a serializer hasn't been set we can use the default Toml serializer.\n\tif cc.serializer == nil {\n\t\tcc.serializer = serializer.NewTomlSerializer()\n\t}\n\n\tbytes, err := cc.serializer.Serialize(data)\n\tif err != nil {\n\t\treturn errors.New(fmt.Sprintf(\"unable to serialize into byte array: %s\", err.Error()))\n\t}\n\n\terr = ioutil.WriteFile(path, bytes, os.ModePerm)\n\tif err != nil {\n\t\treturn errors.New(fmt.Sprintf(\"unable to write config file at location <%s>: %s\", path, err.Error()))\n\t}\n\n\tcc.actualConfig = data\n\n\treturn nil\n}", "title": "" }, { "docid": "cc0e23a15c5d34caa7c2d04588221f4e", "score": "0.5336052", "text": "func writeConfig(staticConfigs []*types.StaticConfig) {\n\tmarshalled, err := yaml.Marshal(staticConfigs)\n\tif err != nil {\n\t\tlogger.Log.Fatal().Err(err).Msg(\"Unable to marshal StaticConfig to yaml\")\n\t}\n\n\t// get path from env if it's set\n\tvar path = DefaultStaticTargetsPath\n\tif v, ok := os.LookupEnv(EnvStaticTargetsPath); ok {\n\t\tpath = v\n\t}\n\n\terr = ioutil.WriteFile(path, marshalled, 0644)\n\tif err != nil {\n\t\tlogger.Log.Fatal().Err(err).Msg(\"Unable to write StaticConfig out to file\")\n\t}\n}", "title": "" }, { "docid": "1111fa66589b051538008a594b8fb229", "score": "0.53284585", "text": "func WriteYAML(obj runtime.Object) ([]byte, error) {\n\tjson, err := runtime.Encode(Codec, obj)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcontent, err := yaml.JSONToYAML(json)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn content, err\n}", "title": "" }, { "docid": "afd259e63b62e8e5da95cf2b20afa073", "score": "0.5311595", "text": "func (c *Templates) YAML(w io.Writer, listView bool) error {\n\tif !listView && len(c.items) == 1 {\n\t\treturn displayYAML(w, c.items[0])\n\t}\n\n\treturn displayYAML(w, c.items)\n}", "title": "" }, { "docid": "7dc61ab6a7bf3f8ef08ab2cb9ea7d8ca", "score": "0.5299968", "text": "func (config Config) WriteToFile(filename string) error {\n\tfile, err := os.Create(filename)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\n\treturn config.WriteYAML(file)\n}", "title": "" }, { "docid": "2a59acb1c67e094c7b13012ad72d0581", "score": "0.52656543", "text": "func PrintYaml(value interface{}) {\n\tInfo(\"---\")\n\tRenderAsYaml(OutputStream(), value)\n}", "title": "" }, { "docid": "0d39889b1bfe6a25174ab5c5bb79495c", "score": "0.52551633", "text": "func MarshalYaml(v interface{}) []byte {\n\tdata, err := yaml.Marshal(v)\n\tPanicIf(err)\n\treturn data\n}", "title": "" }, { "docid": "9a9b66159e98ff72195cb150b75fae89", "score": "0.5251314", "text": "func YAMLString(v interface{}) string { return marshalString(yaml.Marshal(v)) }", "title": "" }, { "docid": "45e122e1c03de093e6c3a3f3d2d5cc2c", "score": "0.52478546", "text": "func WriteControllerYamlFile(path, kubeConfig string) error {\n\tcontrollerData := ControllerYaml{Controller: CloudControllerSt{Kube: KubeEdgeControllerConfig{Master: \"http://localhost:8080\", Namespace: constants.DefaultKubeNamespace,\n\t\tContentType: constants.DefaultKubeContentType,\n\t\tQPS: constants.DefaultKubeQPS, Burst: constants.DefaultKubeBurst, NodeUpdateFrequency: constants.DefaultKubeUpdateNodeFrequency * time.Second,\n\t\tKubeConfig: kubeConfig}},\n\t\tCloudHub: CloudHubSt{IPAddress: \"0.0.0.0\", Port: 10000, CA: \"/etc/kubeedge/ca/rootCA.crt\", Cert: \"/etc/kubeedge/certs/edge.crt\",\n\t\t\tKey: \"/etc/kubeedge/certs/edge.key\", KeepAliveInterval: 30, WriteTimeout: 30, NodeLimit: 10},\n\t\tDeviceController: DeviceControllerSt{Kube: KubeEdgeControllerConfig{Master: \"http://localhost:8080\", Namespace: constants.DefaultKubeNamespace,\n\t\t\tContentType: constants.DefaultKubeContentType,\n\t\t\tQPS: constants.DefaultKubeQPS, Burst: constants.DefaultKubeBurst, KubeConfig: \"\"}},\n\t}\n\tif err := Write2File(path, controllerData); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "b7b6e81077f2d702a47335cb082d4f14", "score": "0.52438724", "text": "func writeConf() (string, error) {\r\n\titem := HealthConfig{}\r\n\titem.MonitorName = \"test monitor name\"\r\n\titem.MonitorType.Type = \"ping\"\r\n\tvar uris [2]string\r\n\turis[0] = \"test\"\r\n\turis[1] = \"other\"\r\n\titem.MonitorType.URI = uris[:]\r\n\r\n\titem2 := HealthConfig{}\r\n\titem2.MonitorName = \"othername\"\r\n\titem2.MonitorType.Type = \"ping\"\r\n\tvar uris2 [1]string\r\n\turis2[0] = \"first\"\r\n\titem2.MonitorType.URI = uris2[:]\r\n\r\n\tvar configs [2]*HealthConfig\r\n\tconfigs[0] = &item\r\n\tconfigs[1] = &item2\r\n\r\n\tconfig := Config{}\r\n\tconfig.GlobalConfig.ScrapeInterval = 10\r\n\tconfig.GlobalConfig.ScrapeTimeout = 60\r\n\r\n\tconfig.HealthConfigs = configs[:]\r\n\r\n\tdata, err := yaml.Marshal(config)\r\n\r\n\tif err != nil {\r\n\t\tfmt.Printf(\"ERROR: %s\\n\", err)\r\n\t} else {\r\n\t\treturn string(data), nil\r\n\t}\r\n\treturn \"\", nil\r\n}", "title": "" }, { "docid": "2434b2f31a25ecbcf55647be412ae019", "score": "0.5235671", "text": "func toYaml(v interface{}) string {\n\tdata, err := yaml.Marshal(v)\n\tif err != nil {\n\t\tif Strict {\n\t\t\tpanic(err.Error())\n\t\t}\n\t\treturn \"\"\n\t}\n\treturn string(data)\n}", "title": "" }, { "docid": "002bfaf347b7dabf92d0c4a7f52a01f3", "score": "0.5227677", "text": "func (c *Config) Save() error {\n\tb, err := yaml.Marshal(cfg)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = ioutil.WriteFile(viper.ConfigFileUsed(), b, 0600)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "8dcb8a2ec92a96246f597df6d51b3356", "score": "0.52222264", "text": "func (cfg *ConfigurationManager) Write(config *CliConfig) error {\n\tdata, err := yaml.Marshal(config)\n\tif err != nil {\n\t\treturn errors.Wrapf(err,\n\t\t\t\"Couldn't marshal config %s\",\n\t\t\tspew.Sdump(config))\n\t}\n\n\treturn ioutil.WriteFile(cfg.FilePath, data, 0644)\n}", "title": "" }, { "docid": "25ad7133a87b3db66e11ad3ed5f6a71d", "score": "0.5221466", "text": "func Save(v interface{}, fname string) error {\n\tif fname == \"\" {\n\t\tfname = getConfName()\n\t}\n\n\ttxtBytes, _ := json.MarshalIndent(v, \"\", \"\\t\")\n\treturn ioutil.WriteFile(fname, txtBytes, 0644)\n}", "title": "" }, { "docid": "67bc18d15849e3bca4a364c9d325f57e", "score": "0.5193746", "text": "func (p *PantheonProvider) Write(configPath string) error {\n\terr := PrepDdevDirectory(filepath.Dir(configPath))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcfgbytes, err := yaml.Marshal(p)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = ioutil.WriteFile(configPath, cfgbytes, 0644)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "2ec3971e42e627d0e89c6b10a40e6841", "score": "0.5190459", "text": "func (i *InputDefinition) saveMeta() error {\n\tif err := os.MkdirAll(i.path, 0777); err != nil {\n\t\treturn err\n\t}\n\n\tvar frames []*internal.Frame\n\tfor _, fr := range i.frames {\n\t\tframes = append(frames, fr.Encode())\n\t}\n\n\tvar fields []*internal.InputDefinitionField\n\tfor _, field := range i.fields {\n\t\tfields = append(fields, field.Encode())\n\t}\n\n\t// Marshal input definition.\n\tbuf, err := proto.Marshal(&internal.InputDefinition{\n\t\tName: i.name,\n\t\tFrames: frames,\n\t\tFields: fields,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Write to meta file.\n\tif err := ioutil.WriteFile(filepath.Join(i.path, i.name), buf, 0666); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "7c135f8f7816c73ab6ce713cdc06adc9", "score": "0.51809096", "text": "func Marshal(in interface{}) ([]byte, error) {\n\tb := new(bytes.Buffer)\n\tencoder := yaml.NewEncoder(b)\n\tencoder.SetIndent(2) // default is 4\n\n\tif err := encoder.Encode(in); err != nil {\n\t\tencoder.Close()\n\n\t\treturn nil, err\n\t}\n\n\tencoder.Close()\n\n\treturn b.Bytes(), nil\n}", "title": "" }, { "docid": "b0798f2f1cb2b3c6fd884f8bfd18d7f6", "score": "0.5178559", "text": "func (config *Config) Write(out io.Writer, emitDefaults bool) {\n\tfor k, v := range config.structure {\n\t\tif !v.IsDefault() || emitDefaults {\n\t\t\t// non-default value, must write!\n\t\t\tline := fmt.Sprintf(\"%s=%s\\n\", k, v)\n\t\t\tio.WriteString(out, line)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "cb71d863ad01d8be06d9430fb0435fbb", "score": "0.5166409", "text": "func (c ChartOptions) WriteToFile(fs billy.Filesystem, path string) error {\n\tchartOptionsBytes, err := yaml.Marshal(c)\n\tif err != nil {\n\t\treturn err\n\t}\n\texists, err := filesystem.PathExists(fs, path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar file billy.File\n\tif !exists {\n\t\tfile, err = filesystem.CreateFileAndDirs(fs, path)\n\t} else {\n\t\tfile, err = fs.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, os.ModePerm)\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\t_, err = file.Write(chartOptionsBytes)\n\treturn err\n}", "title": "" }, { "docid": "31c880a7bebbf4b595e4ec812d009570", "score": "0.515341", "text": "func buildStructFile(schemaPath, childPath, name, packageName string, embeds []string, outputDir string, fieldNameMap map[string]string) error {\n\tif !filepath.IsAbs(childPath) {\n\t\tchildPath = filepath.Join(filepath.Dir(schemaPath), childPath)\n\t}\n\tschema, err := jsonschema.SchemaFromFile(childPath, name)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tgenerated, err := newGeneratedStruct(schema, name, packageName, embeds, fieldNameMap)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to build generated struct: %v\", err)\n\t}\n\n\toutPath := filepath.Join(outputDir, strings.Split(filepath.Base(childPath), \".\")[0]+\".go\")\n\tgfile, err := os.Create(outPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to open file %q: %v\", outPath, err)\n\t}\n\tdefer gfile.Close()\n\n\treturn generated.write(gfile)\n}", "title": "" }, { "docid": "2c9e66e59097e054ef47912357cc4651", "score": "0.5146206", "text": "func writeOut(nodes []Node, out io.Writer) error {\n\n\tfor k, node := range nodes {\n\t\ts, err := yaml.Marshal(&node)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"marshaling error: %s\", err)\n\t\t}\n\n\t\t// line feed between nodes\n\t\tif k > 0 {\n\t\t\t_, err = out.Write([]byte{'\\n'})\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"write output error: %s\", err)\n\t\t\t}\n\t\t}\n\n\t\t// write data\n\t\tn, err := out.Write(s)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"write output error: %s\", err)\n\t\t}\n\n\t\t// TODO: may be repeat write?\n\t\tif n < len(s) {\n\t\t\treturn fmt.Errorf(\"write data error: want=%d bytes real write=%d bytes\", len(s), n)\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "6152e931269b4f4f7dec2b6713b877e8", "score": "0.5141589", "text": "func (this *Report) Save() {\n\n\treportFileName := filepath.Join(this.outputDir, \"defectReport.yaml\")\n\tyaml, err := yaml.Marshal(this)\n\tif err != nil {\n\t\tlog.Fatal(err.Error())\n\t\treturn\n\t}\n\n\tif err := ioutil.WriteFile(reportFileName, yaml, 0644); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "title": "" }, { "docid": "7b32d045882e0968abbd7f70743537ae", "score": "0.51337075", "text": "func (c Config) ToYaml() []byte {\n\t// TODO handle error\n\tyamlstr, _ := yaml.Marshal(c)\n\treturn yamlstr\n}", "title": "" }, { "docid": "eba7a386761c671ef83b4a7221cbef77", "score": "0.5127661", "text": "func (s *Secret) YAML() string {\n\tb, err := yaml.Marshal(s.data)\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\treturn string(b)\n}", "title": "" }, { "docid": "2f07a69fed4c5515eff5f2dc6b3e1271", "score": "0.5123787", "text": "func SaveStruct(src interface{}) ([]Property, error) {\n\tx, err := newStructPLS(src)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn x.Save()\n}", "title": "" }, { "docid": "fc1b69538fd352dd11db7833844c2d39", "score": "0.5121181", "text": "func Save() error {\n\tbytes, err := yaml.Marshal(I)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ioutil.WriteFile(settingsPath, bytes, os.ModePerm)\n}", "title": "" }, { "docid": "4f6b915d00bbfe6c9073d565c2b47ae8", "score": "0.51194835", "text": "func (solution *Solution) Save(filename string) error {\n\treturn util.SaveYAML(filename, solution)\n}", "title": "" }, { "docid": "ad2ec27c4a391946b014c459b42ef64d", "score": "0.5105223", "text": "func WriteObjectToYAML(obj interface{}, yamlFile string) error {\n\tbytes, err := yaml.Marshal(obj)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ioutil.WriteFile(yamlFile, bytes, 0644)\n}", "title": "" }, { "docid": "d0239941526b9efef8528a3b4e381c4f", "score": "0.50996083", "text": "func (c *Cluster) save() (err error) {\n\tb, err := json.MarshalIndent(c, \"\", \" \")\n\tif isError(err) {\n\t\treturn\n\t}\n\treturn ioutil.WriteFile(c.name+\".config\", b, 0777)\n}", "title": "" }, { "docid": "438c8e23b19c927124afe12087824967", "score": "0.5093086", "text": "func MarshalYAML(resource Resource, filename string) error {\n\ty, err := resource.YAML()\n\tif err != nil {\n\t\treturn err\n\t}\n\tdir := filepath.Dir(filename)\n\terr = os.MkdirAll(dir, 0755)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = os.WriteFile(filename, []byte(y), 0644)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "9031858edf0027b37cbae2848142f966", "score": "0.50906336", "text": "func (element *Element) Save(filename string) error {\n\treturn util.SaveYAML(filename, element)\n}", "title": "" }, { "docid": "20194d213bd1f634beb068dd9639db96", "score": "0.5081956", "text": "func (st Struct) Generate(w io.Writer, settings GenerateSettings) {\n\texposedName := exposeName(st.Name)\n\tif st.OpCode != 0 {\n\t\twriteLine(w, \"const %sOpCode = 0x%x\", exposedName, st.OpCode)\n\t\twriteLine(w, \"\")\n\t}\n\twriteLine(w, \"var _ bebop.Record = &%s{}\", exposedName)\n\twriteLine(w, \"\")\n\twriteComment(w, 0, st.Comment)\n\twriteLine(w, \"type %s struct {\", exposedName)\n\tfor _, fd := range st.Fields {\n\t\twriteFieldDefinition(fd, w, st.ReadOnly, false)\n\t}\n\twriteLine(w, \"}\")\n\twriteLine(w, \"\")\n\twriteLine(w, \"func (bbp %s) MarshalBebop() []byte {\", exposedName)\n\twriteLine(w, \"\\tbuf := make([]byte, bbp.bodyLen())\")\n\twriteLine(w, \"\\tbbp.MarshalBebopTo(buf)\")\n\twriteLine(w, \"\\treturn buf\")\n\twriteLine(w, \"}\")\n\twriteLine(w, \"\")\n\twriteLine(w, \"func (bbp %s) MarshalBebopTo(buf []byte) {\", exposedName)\n\tif st.OpCode != 0 {\n\t\twriteLine(w, \"\\tiohelp.WriteUint32Bytes(buf, uint32(%sOpCode))\", exposedName)\n\t\twriteLine(w, \"\\tat := 4\")\n\t} else {\n\t\twriteLine(w, \"\\tat := 0\")\n\t}\n\tfor _, fd := range st.Fields {\n\t\tname := exposeName(fd.Name)\n\t\tif st.ReadOnly {\n\t\t\tname = unexposeName(fd.Name)\n\t\t}\n\t\twriteFieldByter(\"bbp.\"+name, fd.FieldType, w, settings, 1)\n\t}\n\twriteLine(w, \"}\")\n\twriteLine(w, \"\")\n\twriteLine(w, \"func (bbp *%s) UnmarshalBebop(buf []byte) (err error) {\", exposedName)\n\tif st.OpCode != 0 {\n\t\twriteLine(w, \"\\tat := 4\")\n\t} else {\n\t\twriteLine(w, \"\\tat := 0\")\n\t}\n\tfor _, fd := range st.Fields {\n\t\tname := exposeName(fd.Name)\n\t\tif st.ReadOnly {\n\t\t\tname = unexposeName(fd.Name)\n\t\t}\n\t\twriteFieldReadByter(\"bbp.\"+name, fd.FieldType, w, settings, 1, true)\n\t}\n\twriteLine(w, \"\\treturn nil\")\n\twriteLine(w, \"}\")\n\twriteLine(w, \"\")\n\tif settings.GenerateUnsafeMethods {\n\t\twriteLine(w, \"func (bbp *%s) MustUnmarshalBebop(buf []byte) {\", exposedName)\n\t\tif st.OpCode != 0 {\n\t\t\twriteLine(w, \"\\tat := 4\")\n\t\t} else {\n\t\t\twriteLine(w, \"\\tat := 0\")\n\t\t}\n\t\tfor _, fd := range st.Fields {\n\t\t\tname := exposeName(fd.Name)\n\t\t\tif st.ReadOnly {\n\t\t\t\tname = unexposeName(fd.Name)\n\t\t\t}\n\t\t\twriteFieldReadByter(\"bbp.\"+name, fd.FieldType, w, settings, 1, false)\n\t\t}\n\t\twriteLine(w, \"}\")\n\t\twriteLine(w, \"\")\n\t}\n\tisFirstTopLength = true\n\twriteLine(w, \"func (bbp %s) EncodeBebop(iow io.Writer) (err error) {\", exposedName)\n\twriteLine(w, \"\\tw := iohelp.NewErrorWriter(iow)\")\n\tif st.OpCode != 0 {\n\t\twriteLine(w, \"\\tiohelp.WriteUint32(w, uint32(%sOpCode))\", exposedName)\n\t}\n\tfor _, fd := range st.Fields {\n\t\tname := exposeName(fd.Name)\n\t\tif st.ReadOnly {\n\t\t\tname = unexposeName(fd.Name)\n\t\t}\n\t\twriteFieldMarshaller(\"bbp.\"+name, fd.FieldType, w, settings, 1)\n\t}\n\twriteLine(w, \"\\treturn w.Err\")\n\twriteLine(w, \"}\")\n\twriteLine(w, \"\")\n\tisFirstTopLength = true\n\twriteLine(w, \"func (bbp *%s) DecodeBebop(ior io.Reader) (err error) {\", exposedName)\n\twriteLine(w, \"\\tr := iohelp.NewErrorReader(ior)\")\n\tif st.OpCode != 0 {\n\t\twriteLine(w, \"\\tr.Read(make([]byte, 4))\")\n\t}\n\tfor _, fd := range st.Fields {\n\t\tname := exposeName(fd.Name)\n\t\tif st.ReadOnly {\n\t\t\tname = unexposeName(fd.Name)\n\t\t}\n\t\twriteStructFieldUnmarshaller(\"&bbp.\"+name, fd.FieldType, w, settings, 1)\n\t}\n\twriteLine(w, \"\\treturn r.Err\")\n\twriteLine(w, \"}\")\n\twriteLine(w, \"\")\n\twriteLine(w, \"func (bbp %s) bodyLen() int {\", exposedName)\n\twriteLine(w, \"\\tbodyLen := 0\")\n\tif st.OpCode != 0 {\n\t\twriteLine(w, \"\\tbodyLen += 4\")\n\t}\n\tfor _, fd := range st.Fields {\n\t\tname := exposeName(fd.Name)\n\t\tif st.ReadOnly {\n\t\t\tname = unexposeName(fd.Name)\n\t\t}\n\t\tname = \"bbp.\" + name\n\t\twriteMessageFieldBodyCount(name, fd.FieldType, w, settings, 1)\n\t}\n\twriteLine(w, \"\\treturn bodyLen\")\n\twriteLine(w, \"}\")\n\twriteLine(w, \"\")\n\twriteLine(w, \"func make%[1]s(r iohelp.ErrorReader) (%[1]s, error) {\", exposedName)\n\twriteLine(w, \"\\tv := %s{}\", exposedName)\n\twriteLine(w, \"\\terr := v.DecodeBebop(r)\")\n\twriteLine(w, \"\\treturn v, err\")\n\twriteLine(w, \"}\")\n\twriteLine(w, \"\")\n\twriteLine(w, \"func make%[1]sFromBytes(buf []byte) (%[1]s, error) {\", exposedName)\n\twriteLine(w, \"\\tv := %s{}\", exposedName)\n\twriteLine(w, \"\\terr := v.UnmarshalBebop(buf)\")\n\twriteLine(w, \"\\treturn v, err\")\n\twriteLine(w, \"}\")\n\twriteLine(w, \"\")\n\tif settings.GenerateUnsafeMethods {\n\t\twriteLine(w, \"func mustMake%[1]sFromBytes(buf []byte) %[1]s {\", exposedName)\n\t\twriteLine(w, \"\\tv := %s{}\", exposedName)\n\t\twriteLine(w, \"\\tv.MustUnmarshalBebop(buf)\")\n\t\twriteLine(w, \"\\treturn v\")\n\t\twriteLine(w, \"}\")\n\t\twriteLine(w, \"\")\n\t}\n\t// TODO: slices are not really readonly, we need to return a copy.\n\tif st.ReadOnly {\n\t\tfor _, fd := range st.Fields {\n\t\t\twriteLine(w, \"func (bbp %s) Get%s() %s {\", exposedName, exposeName(fd.Name), fd.FieldType.goString())\n\t\t\twriteLine(w, \"\\treturn bbp.%s\", unexposeName(fd.Name))\n\t\t\twriteLine(w, \"}\")\n\t\t\twriteLine(w, \"\")\n\t\t}\n\t\twriteLine(w, \"func New%s(\", exposedName)\n\t\tfor _, fd := range st.Fields {\n\t\t\twriteLine(w, \"\\t\\t%s %s,\", unexposeName(fd.Name), fd.FieldType.goString())\n\t\t}\n\t\twriteLine(w, \"\\t) %s {\", exposedName)\n\t\twriteLine(w, \"\\treturn %s{\", exposedName)\n\t\tfor _, fd := range st.Fields {\n\t\t\twriteLine(w, \"\\t\\t%s: %s,\", unexposeName(fd.Name), unexposeName(fd.Name))\n\t\t}\n\t\twriteLine(w, \"\\t}\")\n\t\twriteLine(w, \"}\")\n\t\twriteLine(w, \"\")\n\t}\n}", "title": "" }, { "docid": "4deda5f1b23fe5acc92ac53adae271fd", "score": "0.50752205", "text": "func (t *Target) Save() error {\n\tif err := t.basePkg.Save(); err != nil {\n\t\treturn err\n\t}\n\n\tfile, err := os.Create(t.TargetYamlPath())\n\tif err != nil {\n\t\treturn util.NewNewtError(err.Error())\n\t}\n\tdefer file.Close()\n\n\ts := t.TargetY.YAML()\n\tfile.WriteString(s)\n\n\tif err := t.basePkg.SaveSyscfg(); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "7c4f53ed98cc6883dcab1de9acabb450", "score": "0.50710374", "text": "func YAML2Struct(name string, data []byte) ([]byte, error) {\n\tvar m map[string]interface{}\n\n\tif err := yaml.Unmarshal(data, &m); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn Map2Struct(name, m), nil\n}", "title": "" }, { "docid": "3c4cbc71d106455daf061e964e7f50c7", "score": "0.5063065", "text": "func (c *FileConfig) Write(data ConfigFileStruct) {\n\twriteFile(getFileString(), data)\n}", "title": "" }, { "docid": "f563ab1f8ffb36e3aefc630c6bf633a3", "score": "0.5063054", "text": "func (cfg *Config) SaveToDisk() error {\n\tbytes, err := yaml.Marshal(cfg)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Unable to marshal config yaml: %s\", err)\n\t}\n\terr = ioutil.WriteFile(cfg.filename, bytes, 0644)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Unable to write config yaml to file %s: %s\", cfg.filename, err)\n\t}\n\tcfg.lastFileInfo, err = os.Stat(cfg.filename)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Unable to stat file %s: %s\", cfg.filename, err)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "9c8a3f66a3ce43c346a195425db66a6c", "score": "0.5056515", "text": "func dump(args ...interface{}) {\n\tvar (\n\t\tprefix string\n\t\tidx int\n\t)\n\n\tif len(args)&0x1 == 1 {\n\t\tprefix = args[0].(string)\n\t\tidx++\n\t}\n\n\tfor ; idx < len(args)-1; idx += 2 {\n\t\ttag, obj := args[idx], args[idx+1]\n\t\tmsg, err := yaml.Marshal(obj)\n\t\tif err != nil {\n\t\t\tlog.Infof(\"%s: %s: failed to dump object: %v\", prefix, tag, err)\n\t\t\tcontinue\n\t\t}\n\n\t\tif prefix != \"\" {\n\t\t\tlog.Infof(\"%s: %s:\", prefix, tag)\n\t\t\tfor _, line := range strings.Split(strings.TrimSpace(string(msg)), \"\\n\") {\n\t\t\t\tlog.Infof(\"%s: %s\", prefix, line)\n\t\t\t}\n\t\t} else {\n\t\t\tlog.Infof(\"%s:\", tag)\n\t\t\tfor _, line := range strings.Split(strings.TrimSpace(string(msg)), \"\\n\") {\n\t\t\t\tlog.Infof(\" %s\", line)\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "fc46d6afde5c516a207f8f0d1dd5bec6", "score": "0.50549763", "text": "func writeNodes(out io.Writer, nodes []*yaml.Node, header string) error {\n\tvar b bytes.Buffer\n\n\tif header := strings.TrimSpace(header); header != \"\" {\n\t\tb.WriteString(header)\n\t\tb.WriteByte('\\n')\n\t\tb.WriteByte('\\n')\n\t}\n\n\te := yaml.NewEncoder(&b)\n\te.SetIndent(2)\n\n\tfor i, n := range nodes {\n\t\tif err := e.Encode(n); err != nil {\n\t\t\treturn fmt.Errorf(\"writing YAML encoding of node %d: %w\", i, err)\n\t\t}\n\t}\n\n\tif _, err := out.Write(b.Bytes()); err != nil {\n\t\treturn fmt.Errorf(\"writing output: %w\", err)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "90849ed4a93bf80bb395dbf3fd24c127", "score": "0.50530887", "text": "func ToYaml(c Config) ([]byte, error) {\n\treturn yaml.Marshal(c)\n}", "title": "" }, { "docid": "163388fd4d9b5c642f2b1147df08dd6a", "score": "0.5050645", "text": "func (k7 *cassette) save() error {\n\t// marshal\n\tdata, err := json.Marshal(k7)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// transform properties known to fail on Unmarshal\n\tdata, err = transformInterfacesInJSON(data)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// beautify JSON (now that the JSON text has been transformed)\n\tvar iData bytes.Buffer\n\n\tif err := json.Indent(&iData, data, \"\", \" \"); err != nil {\n\t\treturn err\n\t}\n\n\t// write cassette to file\n\tfilename := cassetteNameToFilename(k7.Name, k7.Path)\n\tpath := filepath.Dir(filename)\n\tif err := os.MkdirAll(path, 0750); err != nil {\n\t\treturn err\n\t}\n\n\terr = ioutil.WriteFile(filename, iData.Bytes(), 0640)\n\treturn err\n}", "title": "" }, { "docid": "4402751ebc6a9913f5b1e0838d76ab59", "score": "0.50395405", "text": "func (upd *UpdateCheck) WriteToDisk() error {\n\tenc, err := yaml.Marshal(&upd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = ioutil.WriteFile(upd.FileUsed, enc, 0600)\n\treturn err\n}", "title": "" }, { "docid": "a96398ce0625fa66e7ddaa4b22b27ec4", "score": "0.50308776", "text": "func (ts *Timesheet) ToYAML(w io.Writer) error {\n\treturn ts.export(w, yaml.Marshal)\n}", "title": "" }, { "docid": "1ce0e720593d3c574e2059b58a47ad15", "score": "0.5029237", "text": "func API(w http.ResponseWriter, r *http.Request) { w.Write(yml) }", "title": "" }, { "docid": "1ce0e720593d3c574e2059b58a47ad15", "score": "0.5029237", "text": "func API(w http.ResponseWriter, r *http.Request) { w.Write(yml) }", "title": "" }, { "docid": "5b6af65477163e4b304c0e76bc6bfaf6", "score": "0.5022577", "text": "func SaveConfig(c *Config) {\n\tbuf, _ := json.Marshal(c)\n\tioutil.WriteFile(\"config\", buf, 0660)\n\tlog.Printf(\"SAVE: %v\", *c)\n\n}", "title": "" }, { "docid": "3b8e2a7c27dc54cf713308c7fbed94b3", "score": "0.5020236", "text": "func WriteConfigToFile(gc *Config, filename string) (err error) {\n\tdataBytes, err := yaml.Marshal(gc)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = ioutil.WriteFile(filename, dataBytes, 0644)\n\treturn err\n}", "title": "" }, { "docid": "04675c4e1ecf7aebae29fe40c7a2e3b7", "score": "0.50136703", "text": "func (u UnknownStep) MarshalYAML() (any, error) {\n\treturn u.Contents, nil\n}", "title": "" }, { "docid": "3d8597f99f1fb3ea80c7e498e217965e", "score": "0.5006615", "text": "func RenderAsYaml(writer io.Writer, value interface{}) {\n\tbytes, err := yaml.Marshal(value)\n\tif err != nil {\n\t\treturn\n\t}\n\tcontent := string(bytes)\n\t_, _ = fmt.Fprint(writer, content)\n}", "title": "" }, { "docid": "eacd11e22a0256ada4d285ef76147b43", "score": "0.49872404", "text": "func Save(conf TomlConfig, rootless bool) error {\n\tconfigFile, err := DefaultConfigFile(rootless)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err = os.Remove(configFile); !os.IsNotExist(err) && err != nil {\n\t\treturn err\n\t}\n\n\tf, err := os.Create(configFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn toml.NewEncoder(f).Encode(conf)\n}", "title": "" }, { "docid": "b287e86d697b3b5d183996a50959f8e9", "score": "0.49861744", "text": "func (va ValAddress) MarshalYAML() (interface{}, error) {\n\treturn va.String(), nil\n}", "title": "" }, { "docid": "6ae616e33e98b5a66b4190868a3d3304", "score": "0.4982717", "text": "func (release EstafetteRelease) MarshalYAML() (out interface{}, err error) {\n\n\tvar aux struct {\n\t\tName string `yaml:\"-\"`\n\t\tStages yaml.MapSlice `yaml:\"stages\"`\n\t}\n\n\tfor _, stage := range release.Stages {\n\t\taux.Stages = append(aux.Stages, yaml.MapItem{\n\t\t\tKey: stage.Name,\n\t\t\tValue: stage,\n\t\t})\n\t}\n\n\treturn aux, err\n}", "title": "" }, { "docid": "9347a21f826afffc9fb87de678065587", "score": "0.49754438", "text": "func (i ModelFormat) MarshalYAML() (interface{}, error) {\n\treturn i.String(), nil\n}", "title": "" }, { "docid": "25d4cf427162da5fcbb396ec733736c6", "score": "0.4973745", "text": "func (c *Config) YAML() ([]byte, error) {\n\treturn yaml.Marshal(c)\n}", "title": "" }, { "docid": "c8be4c6d1551dc767e1fc1d5f0d74c78", "score": "0.49717593", "text": "func writeConfigToFile(configs []StaticConfig, filename string) error {\n\t// Convert to JSON.\n\tdata, err := json.MarshalIndent(configs, \"\", \" \")\n\trtx.Must(err, \"Failed to marshal StaticConfig\")\n\n\t// Write to file.\n\terr = safefile.WriteFile(filename, data, 0644)\n\tif err != nil {\n\t\tlog.Printf(\"Failed to write %s: %s\", filename, err)\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "5056e7dab298669f1bf26eded73f5293", "score": "0.49687973", "text": "func writeTreeDefinition(directory string, def *dnsDefinition) {\n\tmetaJSON, err := json.MarshalIndent(&def.Meta, \"\", jsonIndent)\n\tif err != nil {\n\t\texit(err)\n\t}\n\t// Convert nodes.\n\tnodes := make(nodeSet, len(def.Nodes))\n\tnodes.add(def.Nodes...)\n\t// Write.\n\tif err := os.Mkdir(directory, 0744); err != nil && !os.IsExist(err) {\n\t\texit(err)\n\t}\n\tmetaFile, nodesFile := treeDefinitionFiles(directory)\n\twriteNodesJSON(nodesFile, nodes)\n\tif err := ioutil.WriteFile(metaFile, metaJSON, 0644); err != nil {\n\t\texit(err)\n\t}\n}", "title": "" }, { "docid": "ca8666a061c920e07752b54aa3c6f159", "score": "0.49658087", "text": "func (prj Project) Marshal() ([]byte, error) {\n\treturn yaml.Marshal(prj)\n}", "title": "" } ]
4f448ba39af84432d6c2331beb742dd1
SvcHandlerPGroup formats a complete data record for an assessment for use with the w2ui Form For this call, we expect the URI to contain the BID and the PID as follows: The server command can be: get save delete
[ { "docid": "806dc0971825be48a2ffabfada50ec4a", "score": "0.61103743", "text": "func SvcHandlerPGroup(w http.ResponseWriter, r *http.Request, d *ServiceData) {\n\tutil.Console(\"Entered SvcHandlerPGroup\\n\")\n\n\tswitch d.wsSearchReq.Cmd {\n\tcase \"get\":\n\t\tif d.ID < 0 {\n\t\t\tSvcGridErrorReturn(w, fmt.Errorf(\"PersonID is required but was not specified\"))\n\t\t\treturn\n\t\t}\n\t\tgetPGroup(w, r, d)\n\tcase \"save\":\n\t\tsavePGroup(w, r, d)\n\tcase \"delete\":\n\t\tdeletePGroup(w, r, d)\n\tdefault:\n\t\terr := fmt.Errorf(\"unhandled command: %s\", d.wsSearchReq.Cmd)\n\t\tSvcGridErrorReturn(w, err)\n\t\treturn\n\t}\n}", "title": "" } ]
[ { "docid": "353436a8d64cc6728d9715a3a6251a81", "score": "0.4770799", "text": "func (ds *DoitServer) apiGroupHandler(w http.ResponseWriter, r *http.Request) {\n\terr := r.ParseForm()\n\tif err != nil {\n\t\tlog.Errorln(\"Unable to parse message\", err)\n\t\tds.ReturnInternalServerError(w, r)\n\t\treturn\n\t}\n\tvars := mux.Vars(r)\n\tdomain := r.Form.Get(\"domain\")\n\treqName := vars[\"name\"]\n\n\td, err := ds.DomainCheck(domain)\n\tif err != nil {\n\t\tds.ReturnBadRequest(w, r)\n\t\treturn\n\t}\n\n\tswitch r.Method {\n\tcase \"GET\":\n\t\tg, err := ds.GetGroupByName(d, reqName)\n\t\tif err != nil {\n\t\t\tds.ReturnNotFound(w, r)\n\t\t\treturn\n\t\t}\n\t\terr = ds.ReturnJSON(g, w, r)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\tcase \"POST\":\n\t\t_, err := ds.AddGroup(d, reqName)\n\t\tif err != nil {\n\t\t\tds.ReturnNotFound(w, r)\n\t\t\treturn\n\t\t}\n\t\tds.ReturnOK(w, r)\n\tcase \"PUT\":\n\t\t//TODO: Add group items here\n\t\tds.ReturnNotFound(w, r)\n\tcase \"DELETE\":\n\t\tg, err := ds.GetGroupByName(d, reqName)\n\t\tif err != nil {\n\t\t\tds.ReturnNotFound(w, r)\n\t\t\treturn\n\t\t}\n\t\terr = ds.RemoveGroup(d, g)\n\t\tif err != nil {\n\t\t\tds.ReturnInternalServerError(w, r)\n\t\t\treturn\n\t\t}\n\t\tds.ReturnOK(w, r)\n\t}\n}", "title": "" }, { "docid": "9ed4f07eb9afda783b31fd5b919d6853", "score": "0.46579278", "text": "func appendToSid(w http.ResponseWriter, r *http.Request, UID, FUNC, SID, TEXT string) (err error){\n //c := appengine.NewContext(r)\n c, cancel := context.WithCancel(context.Background())\n\t defer cancel()\n //D0086\n datastoreClient := createClientDS()\n\tdocID := 0\n\tTARGET := \"\"\n\tBLOB_KEY := \"\"\n\tDOC_STAT := \"\"\n\tFL_SHARED := \"\"\n\tAUTHOR := \"\"\n\tcsn := \"\"\n\tif SID != \"\" {\n\t\tSPL := strings.Split(SID,\"-\")\n\t\tDOC_ID := \"0\"\n\t\tif len(SPL) > 1 {\n\t\t\tTARGET = SPL[0]\n\t\t\tDOC_ID = SPL[1]\n\t\t}\n\t\tdocID = str2int(DOC_ID)\n\t}\n\tswitch TARGET {\n\t\tcase \"TDSSLIDE\":\n\t\t\tBLOB_KEY, DOC_STAT, FL_SHARED, AUTHOR, _, _, _, _, _, _ = getTDSSLIDEBlobKey(w, r, docID)\n\t\t\t//upload url\n\t\t\tcsn = getUpUrlString(w,r,\"/upload-slides\")\n\t\tcase \"TDSARTL\":\n\t\t\tBLOB_KEY, DOC_STAT, FL_SHARED, AUTHOR, _, _, _, _, _ = getTDSARTLBlobKey(w, r, docID)\n\t\t\tcsn = getUpUrlString(w,r,\"/upload-articles\")\n\t\tcase \"TDSMEDIA\":\n\t\t\tBLOB_KEY, _, _, AUTHOR, DOC_STAT, FL_SHARED, _, _, _, _, _ = getTDSMEDIABlobKey(w, r, docID)\n\t\t\tcsn = getUpUrlString(w,r,\"/upload-media\")\n\t}\n\tswitch {\n\t\tcase DOC_STAT == \"Premium\" && UID != AUTHOR:\n\t\t\t//dont process\n\t\t\treturn fmt.Errorf(\"Invalid operation. Author issue.\")\n\t\tcase FL_SHARED == \"N\" || DOC_STAT == \"Personal\" || (FL_SHARED == \"Y\" && DOC_STAT == \"Personal\"):\n\t\t\tFUNC_CODE := \"GET_GRP_ID\"\n\t\t\tFL_VALID_USER, _, _ , _ := usersProcessor(w, r, \"au\", UID, FUNC_CODE)\n\n\t\t\tif FL_VALID_USER != true {\n\t\t\t\t//dont process\n\t\t\t\treturn fmt.Errorf(\"Invalid operation. Invalid user.\")\n\t\t\t}\n\t\t\tif UID != AUTHOR {\n\t\t\t\t//dont process\n\t\t\t\treturn fmt.Errorf(\"Invalid operation. Invalid author.\")\n\t\t\t}\n\t\tcase DOC_STAT == \"ULAPPH Only\":\n\t\t\tFUNC_CODE := \"GET_GRP_ID\"\n\t\t\tFL_VALID_USER, _, _ , _ := usersProcessor(w, r, \"au\", UID, FUNC_CODE)\n\t\t\tif FL_VALID_USER != true {\n\t\t\t\t//dont process\n\t\t\t\treturn fmt.Errorf(\"Invalid operation. Invalid user.\")\n\t\t\t}\n\t\tcase DOC_STAT == \"Worldwide\" && FL_SHARED == \"Y\":\n\t\t\t//allow\n\t}\n\t//current text\n\tblobChan := make(chan string)\n\tgo getBlobTextChan(w, r,blobChan, BLOB_KEY)\n\tthisCont := <- blobChan\n\t//log.Printf(\"getBlobTextChan...\")\n\t//log.Printf(\"thisCont: %v\", thisCont)\n\tvar buf bytes.Buffer\n\tbuf.WriteString(fmt.Sprintf(\"%v\", thisCont))\n\tbuf.WriteString(fmt.Sprintf(\" \\n\"))\n\tFL_PROC_OK := false\n\tswitch {\n\t\tcase FUNC == \"APPEND-UWM\" && TEXT != \"\":\n\t\t\t//log.Printf(\"APPEND-UWM APPEND...\")\n\t\t\t//log.Printf(\"TEXT: %v\", TEXT)\n\t\t\tFL_PROC_OK = true\n\t\t\t//buf.WriteString(fmt.Sprintf(\" %v\\n\", template.HTML(TEXT)))\n\t\t\tbuf.WriteString(fmt.Sprintf(\" %v\\n\", html.UnescapeString(TEXT)))\n\t\t\t//D0057\n\t\t\t//add flag if auto-arrange\n\t\t\tarr := r.FormValue(\"ARR\")\n\t\t\tif arr != \"\" {\n\t\t\t\tthisKey := fmt.Sprintf(\"SYSTEM_UWM_ARR_%v_%v\", SID, UID)\n\t\t\t\tkey := datastore.NameKey(\"TDSCNFG\", thisKey, nil)\n\t\t\t\tg := TDSCNFG{\n\t\t\t\t\t\tSYS_VER: 1,\n\t\t\t\t\t\tUSER: UID,\n\t\t\t\t\t\tCFG_ID: thisKey,\n\t\t\t\t\t\tDAT_TYP: \"TXT\",\n\t\t\t\t\t\tNUM_VAL: 0,\n\t\t\t\t\t\tTXT_VAL: arr,\n\t\t\t\t\t\tCFG_DESC: \"UWM Arrangement\",\n\t\t\t\t}\n\t\t\t\tif _, err := datastoreClient.Put(c, key, &g); err != nil {\n\t\t\t\t\t\tpanic(err)\n }\n //log.Printf(\"datastoreClient.Put() [61066]\")\n\t\t\t}\n\t\t\t//set default wallpaper\n\t\t\twallp := r.FormValue(\"WALLP\")\n\t\t\tif wallp != \"\" {\n\t\t\t\tthisKey := fmt.Sprintf(\"SYSTEM_UWM_WALLP_%v_%v\", SID, UID)\n\t\t\t\tkey := datastore.NameKey(\"TDSCNFG\", thisKey, nil)\n\t\t\t\tg := TDSCNFG{\n\t\t\t\t\t\tSYS_VER: 1,\n\t\t\t\t\t\tUSER: UID,\n\t\t\t\t\t\tCFG_ID: thisKey,\n\t\t\t\t\t\tDAT_TYP: \"TXT\",\n\t\t\t\t\t\tNUM_VAL: 0,\n\t\t\t\t\t\tTXT_VAL: wallp,\n\t\t\t\t\t\tCFG_DESC: \"Default Wallpaper\",\n\t\t\t\t}\n\t\t\t\tif _, err := datastoreClient.Put(c, key, &g); err != nil {\n\t\t\t\t\t\tpanic(err)\n }\n //log.Printf(\"datastoreClient.Put() [61085]\")\n\t\t\t}\n\t\t\t//set shown only uwm wallpapers\n\t\t\twpuwmonly := r.FormValue(\"WPUWMONLY\")\n\t\t\tUWM := r.FormValue(\"UWM\")\n\t\t\tif wpuwmonly == \"true\" || wpuwmonly == \"false\" {\n\t\t\t\t//thisKey := fmt.Sprintf(\"SYSTEM_UWM_WALLP_WPUWMONLY_%v_%v\", SID, UID)\n\t\t\t\tthisKey := fmt.Sprintf(\"SYSTEM_UWM_WALLP_WPUWMONLY_%v_%v\", UWM, UID)\n\t\t\t\tkey := datastore.NameKey(\"TDSCNFG\", thisKey, nil)\n\t\t\t\tg := TDSCNFG{\n\t\t\t\t\t\tSYS_VER: 1,\n\t\t\t\t\t\tUSER: UID,\n\t\t\t\t\t\tCFG_ID: thisKey,\n\t\t\t\t\t\tDAT_TYP: \"TXT\",\n\t\t\t\t\t\tNUM_VAL: 0,\n\t\t\t\t\t\tTXT_VAL: wpuwmonly,\n\t\t\t\t\t\tCFG_DESC: \"Shown UWM Random Wallpaper\",\n\t\t\t\t}\n\t\t\t\tif _, err := datastoreClient.Put(c, key, &g); err != nil {\n\t\t\t\t\t\tpanic(err)\n }\n //log.Printf(\"datastoreClient.Put() [61106]\")\n\t\t\t}\n\n\n\t}\n\tif FL_PROC_OK == true {\n\t\t//log.Printf(\"FL_PROC_OK...\")\n\t\t//update content\n\t\t// Now you can prepare a form that you will submit to that URL.\n\t\tvar m bytes.Buffer\n\t\tfw := multipart.NewWriter(&m)\n\t\t// Do not change the form field, it must be \"file\"!\n\t\t// You are free to change the filename though, it will be stored in the BlobInfo.\n\t\tfile, err := fw.CreateFormFile(\"file\", SID)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif _, err = file.Write(buf.Bytes()); err != nil {\n\t\t\t//http.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\t//log.Panicf(\"%s\", err)\n\t\t\treturn err\n\t\t}\n\t\t_ = fw.WriteField(\"EDIT_FUNC2\", \"SAVE_TEXT\")\n\t\t_ = fw.WriteField(\"SID\", SID)\n\t\t_ = fw.WriteField(\"CATEGORY\", \"desktop0\")\n\t\t_ = fw.WriteField(\"FUNC_CODE\", \"UPD-FROM-EDITOR\")\n\t\t_ = fw.WriteField(\"SPC_OPT\", \"\")\n\t\t_ = fw.WriteField(\"SPC_OPT\", \"\")\n\t\t//_ = fw.WriteField(\"TITLE\", CAPTION)\n\t\t_ = fw.WriteField(\"UID\", UID)\n\t\t// Don't forget to close the multipart writer.\n\t\t// If you don't close it, your request will be missing the terminating boundary.\n\t\tfw.Close()\n\t\t//upload url\n\t\tu := csn\n\t\t// Now that you have a form, you can submit it to your handler.\n\t\treq, err := http.NewRequest(\"POST\", u, &m)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// Don't forget to set the content type, this will contain the boundary.\n\t\treq.Header.Set(\"Content-Type\", fw.FormDataContentType())\n\t\t// Now submit the request.\n //client := urlfetch.Client(c)\n client := &http.Client{}\n\t\t_, err = client.Do(req)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// Check the response status, it should be whatever you return in the `/upload` handler.\n\t\t//if res.StatusCode != http.StatusCreated {\n\t\t//\treturn fmt.Errorf(\"Invalid operation\")\n\t\t//}\t\t\n\t}\n\treturn err\n}", "title": "" }, { "docid": "0584d8e89e50803a79bec3ff94b676f4", "score": "0.45473346", "text": "func (*AaaGroup) PostPath() string {\n\treturn \"/api/objects/aaa/group/\"\n}", "title": "" }, { "docid": "757f43803de53b5de8dd8117d97dbdc1", "score": "0.4529157", "text": "func (ds *DoitServer) apiGroupsHandler(w http.ResponseWriter, r *http.Request) {\n\terr := r.ParseForm()\n\tif err != nil {\n\t\tlog.Errorln(\"Unable to parse message\", err)\n\t\tds.ReturnInternalServerError(w, r)\n\t\treturn\n\t}\n\tdomain := r.Form.Get(\"domain\")\n\n\td, err := ds.DomainCheck(domain)\n\tif err != nil {\n\t\tds.ReturnBadRequest(w, r)\n\t\treturn\n\t}\n\n\tswitch r.Method {\n\tcase \"GET\":\n\t\tg, err := ds.GetGroupsByDomain(d)\n\t\tif err != nil {\n\t\t\tds.ReturnNotFound(w, r)\n\t\t\treturn\n\t\t}\n\t\terr = ds.ReturnJSON(g, w, r)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\tdefault:\n\t\tds.ReturnNotImplemented(w, r)\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "17a636f176dd4dda18cbc31f16c1f37b", "score": "0.44878092", "text": "func (api *API) GetGroupHandler(ctx context.Context, w http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse) {\n\n\tvars := mux.Vars(req)\n\tgroup := models.Group{ID: vars[\"id\"]}\n\tgroupGetRequest := group.BuildGetGroupRequest(api.UserPoolId)\n\tgroupGetResponse, err := api.CognitoClient.GetGroup(groupGetRequest)\n\tif err != nil {\n\n\t\tcognitoErr := models.NewCognitoError(ctx, err, \"Cognito GetGroup request from Get group endpoint\")\n\t\tif cognitoErr.Code == models.NotFoundError {\n\t\t\treturn nil, models.NewErrorResponse(http.StatusNotFound, nil, cognitoErr)\n\t\t}\n\t\treturn nil, models.NewErrorResponse(http.StatusInternalServerError, nil, cognitoErr)\n\t}\n\n\tgroup.MapCognitoDetails(groupGetResponse.Group)\n\n\tjsonResponse, responseErr := group.BuildSuccessfulJsonResponse(ctx)\n\tif responseErr != nil {\n\t\treturn nil, models.NewErrorResponse(http.StatusInternalServerError, nil, responseErr)\n\t}\n\n\treturn models.NewSuccessResponse(jsonResponse, http.StatusOK, nil), nil\n}", "title": "" }, { "docid": "df57cd91c0bf90d43fcb4bfb0738b025", "score": "0.44084233", "text": "func SvcHandlerGroupMembership(w http.ResponseWriter, r *http.Request, d *ServiceData) {\n\tfuncname := \"SvcHandlerGroupMembership\"\n\tvar err error\n\tutil.Console(\"Entered %s\\n\", funcname)\n\tvar a GroupMembership\n\tif err = json.Unmarshal([]byte(d.data), &a); err != nil {\n\t\te := fmt.Errorf(\"%s: Error with json.Unmarshal: %s\", funcname, err.Error())\n\t\tSvcGridErrorReturn(w, e)\n\t\treturn\n\t}\n\tutil.Console(\"Read %d group ids\\n\", len(a.Groups))\n\n\t// to what groups does this person currently belong?\n\tvar gcur PGroupList\n\tif gcur, err = getPGroupList(w, r, d, d.ID, false); err != nil {\n\t\tSvcGridErrorReturn(w, err)\n\t}\n\tutil.Console(\"Current group list for PID %d is:\\n\", d.ID)\n\tfor i := 0; i < len(gcur.Records); i++ {\n\t\tutil.Console(\"%s (%d)\\n\", gcur.Records[i].GroupName, gcur.Records[i].GID)\n\t}\n\n\t//------------------------------------------------------------------------\n\t// which groups do we need to add? If we don't find a.Groups[i].GID in\n\t// the current list, then we need to add it.\n\t//------------------------------------------------------------------------\n\tfor i := 0; i < len(a.Groups); i++ {\n\t\tfound := false\n\t\tfor j := 0; j < len(gcur.Records); j++ {\n\t\t\tif gcur.Records[j].GID == a.Groups[i] {\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\t// util.Console(\"Add to GID: %d\\n\", a.Groups[i])\n\t\t\tif err = mailsend.AddPersonToGroup(d.ID, a.Groups[i]); err != nil {\n\t\t\t\tSvcGridErrorReturn(w, err)\n\t\t\t}\n\t\t}\n\t}\n\n\t//------------------------------------------------------------------------\n\t// Remove the person from any group that does not appear in list...\n\t//------------------------------------------------------------------------\n\tfor i := 0; i < len(gcur.Records); i++ {\n\t\tfound := false\n\t\tfor j := 0; j < len(a.Groups); j++ {\n\t\t\tif gcur.Records[i].GID == a.Groups[j] {\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\tutil.Console(\"Remove from GID: %d\\n\", gcur.Records[i].GID)\n\t\t\tif err = mailsend.RemovePersonFromGroup(d.ID, gcur.Records[i].GID); err != nil {\n\t\t\t\tSvcGridErrorReturn(w, err)\n\t\t\t}\n\t\t}\n\t}\n\tSvcWriteSuccessResponse(w)\n\n}", "title": "" }, { "docid": "09578c869f5508888cb6c55546edf032", "score": "0.4386312", "text": "func (*NotificationGroup) PostPath() string {\n\treturn \"/api/objects/notification/group/\"\n}", "title": "" }, { "docid": "006f469d252bde9624c762dec0affdfb", "score": "0.43857715", "text": "func (*SslVpnGroup) PostPath() string {\n\treturn \"/api/objects/ssl_vpn/group/\"\n}", "title": "" }, { "docid": "4d8fd2ce765c3148ca562c63cbdb9b46", "score": "0.4364989", "text": "func (client BaseClient) GetGroupByIDResponder(resp *http.Response) (result GroupModel, err error) {\n err = autorest.Respond(\n resp,\n client.ByInspecting(),\n azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusForbidden,http.StatusNotFound),\n autorest.ByUnmarshallingJSON(&result),\n autorest.ByClosing())\n result.Response = autorest.Response{Response: resp}\n return\n }", "title": "" }, { "docid": "da58314a89627c765ae622a1b21c6f7a", "score": "0.43574455", "text": "func (a *EndpointGroupsApiService) EndpointGroupDelete(ctx context.Context, id int32) (*http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = strings.ToUpper(\"Delete\")\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/endpoint_groups/{id}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"id\"+\"}\", fmt.Sprintf(\"%v\", id), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tif ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {\n\t\t\tvar key string\n\t\t\tif auth.Prefix != \"\" {\n\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t} else {\n\t\t\t\tkey = auth.Key\n\t\t\t}\n\t\t\tlocalVarHeaderParams[\"Authorization\"] = key\n\n\t\t}\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlocalVarHttpResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHttpResponse == nil {\n\t\treturn localVarHttpResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)\n\tlocalVarHttpResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarHttpResponse, err\n\t}\n\n\tif localVarHttpResponse.StatusCode >= 300 {\n\t\tnewErr := GenericSwaggerError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHttpResponse.Status,\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 400 {\n\t\t\tvar v model.GenericError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 404 {\n\t\t\tvar v model.GenericError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 500 {\n\t\t\tvar v model.GenericError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 503 {\n\t\t\tvar v model.GenericError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHttpResponse, newErr\n\t\t}\n\n\t\treturn localVarHttpResponse, newErr\n\t}\n\n\treturn localVarHttpResponse, nil\n}", "title": "" }, { "docid": "060e6ac269f72644b945368e5fca13bc", "score": "0.43386868", "text": "func splitHandlerByGroup(str string) []string {\n\tmatches := groupSplitRegexp.FindAllStringSubmatch(str, -1)\n\tif len(matches) != 1 {\n\t\treturn []string{str}\n\t}\n\tgroup := matches[0][0]\n\tpart1 := matches[0][2]\n\tpart2 := matches[0][3]\n\treturn []string{strings.Replace(str, group, part1, 1), strings.Replace(str, group, part2, 1)}\n}", "title": "" }, { "docid": "db2260f5d75bfbdabf1bbfd1738e2151", "score": "0.4321135", "text": "func (gm *GMServ) UsrGroupUpdateHandler(ws *websocket.Conn) {\n\tlw.Debug(\"In UsrGroupUpdateHandler()\")\n\n\t// gob decoding\n\tvar ug gmcom.UsrGroupD\n\tvar msg = make([]byte, 1024)\n\tl, err := ws.Read(msg)\n\tif err != nil {\n\t\tlw.ErrorWithPrefixString(\"UsrGroupUpdateHandler() ws.Read() error:\", err)\n\t\treturn\n\t}\n\traw := msg[0:l]\n\tdecBuf := bytes.NewBuffer(raw)\n\terr = gob.NewDecoder(decBuf).Decode(&ug)\n\tif err != nil {\n\t\tlw.ErrorWithPrefixString(\"UsrGroupUpdateHandler() gob.Decode() error:\", err)\n\t\treturn\n\t}\n\n\t// update the local server's UsrGroup cache (map)\n\tswitch ug.Op {\n\tcase gmcom.COpCreate, gmcom.COpUpdate:\n\t\tgm.UsrGroupsH.Lock()\n\t\tgm.UsrGroupsH.GroupNames[ug.ID] = ug.GroupName\n\t\tgm.UsrGroupsH.Unlock()\n\tcase gmcom.COpDelete:\n\t\tgm.UsrGroupsH.Lock()\n\t\tdelete(gm.UsrGroupsH.GroupNames, ug.ID)\n\t\tgm.UsrGroupsH.Unlock()\n\tdefault:\n\t\t// do nothing\n\t}\n\n\t// send to other group members?\n\tif !ug.Forward {\n\t\tws.Write([]byte(\"true\"))\n\t\treturn\n\t}\n\tug.Forward = false\n\n\t// send the update to all non-failed processes in the process group\n\t// get a list of the active processes (this is inherently stale)\n\tm := gm.SendGetLocalDetails()\n\tif m == nil {\n\t\tlw.Warning(\"Failed to read usrgroup cache group server details in SendGetLocalDetails()\")\n\t\tws.Write([]byte(\"false\"))\n\t}\n\n\t// send process-id/article-key to group members\n\tr := m.MemberMap.ReadActiveProcessList()\n\tfor _, g := range r {\n\t\tif g.ID == gm.MyID {\n\t\t\tcontinue\n\t\t}\n\t\tlw.Info(\"CS: SENDING %v to %s\", ug, g.IPAddress)\n\t\terr := gmcl.AddUpdUsrGroupCache(ug, g.IPAddress) //TODO go()\n\t\tif err != nil {\n\t\t\tlw.ErrorWithPrefixString(\"wscl.AddUpdUsrGroupCache() error:\", err)\n\t\t}\n\t}\n\tws.Write([]byte(\"true\"))\n}", "title": "" }, { "docid": "c4f4e88b7ab83005f427f0ff9f046cc5", "score": "0.4314843", "text": "func (state *RuntimeState) deleteGrouphandler(w http.ResponseWriter, r *http.Request) {\n\tif r.Method != postMethod {\n\t\tstate.writeFailureResponse(w, r, \"POST Method is required\", http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\tusername, err := state.GetRemoteUserName(w, r)\n\tif err != nil {\n\t\treturn\n\t}\n\n\terr = r.ParseForm()\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tif err.Error() == \"missing form body\" {\n\t\t\thttp.Error(w, fmt.Sprint(err), http.StatusBadRequest)\n\t\t} else {\n\t\t\tstate.writeFailureResponse(w, r, fmt.Sprintf(\"Something wrong with internal server.\"), http.StatusInternalServerError)\n\t\t}\n\t\treturn\n\t}\n\tvar groupnames []string\n\tgroups := r.PostFormValue(\"groupnames\")\n\t//check if groupnames are valid or not.\n\tfor _, eachGroup := range strings.Split(groups, \",\") {\n\t\tallow, err := state.canPerformAction(username, eachGroup, resourceGroup, permDelete)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\tstate.writeFailureResponse(w, r, fmt.Sprintf(\"Something wrong with internal server.\"), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tif !allow {\n\t\t\tstate.writeFailureResponse(w, r, fmt.Sprintf(\"You don't have permission to delete group %s\", eachGroup), http.StatusForbidden)\n\t\t\treturn\n\t\t}\n\t\tgroupnameExistsorNot, _, err := state.Userinfo.GroupnameExistsornot(eachGroup)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\tstate.writeFailureResponse(w, r, fmt.Sprintf(\"Something wrong with internal server.\"), http.StatusInternalServerError)\n\t\t\treturn\n\n\t\t}\n\t\tif !groupnameExistsorNot {\n\t\t\tstate.writeFailureResponse(w, r, fmt.Sprintf(\"Group %s doesn't exist!\", eachGroup), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\n\t\tfor _, groupname := range state.Config.Base.AutoGroups {\n\t\t\tif eachGroup == groupname {\n\t\t\t\tstate.writeFailureResponse(w, r, groupname+\" is part of auto-added group, you cannot delete it!\", http.StatusBadRequest)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tgroupnames = append(groupnames, eachGroup)\n\t}\n\n\terr = state.Userinfo.DeleteGroup(groupnames)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tstate.writeFailureResponse(w, r, fmt.Sprintf(\"error occurred! May be there is no such group!\"), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tif state.sysLog != nil {\n\t\tfor _, eachGroup := range groupnames {\n\t\t\tstate.sysLog.Write([]byte(fmt.Sprintf(\"Group \"+\"%s\"+\" was deleted by \"+\"%s\", eachGroup, username)))\n\t\t}\n\t}\n\terr = deleteEntryofGroupsInDB(groupnames, state)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tstate.writeFailureResponse(w, r, fmt.Sprintf(\"Something wrong with internal server.\"), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tisAdmin := state.Userinfo.UserisadminOrNot(username)\n\tpageData := simpleMessagePageData{\n\t\tUserName: username,\n\t\tIsAdmin: isAdmin,\n\t\tTitle: \"Group Deletion Suucess\",\n\t\tSuccessMessage: \"Group has been successfully Deleted\",\n\t}\n\tstate.renderTemplateOrReturnJson(w, r, \"simpleMessagePage\", pageData)\n\n}", "title": "" }, { "docid": "99ed792c7ebe1766a860481ffb0bbed5", "score": "0.4306305", "text": "func (api *API) UpdateGroupHandler(ctx context.Context, w http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse) {\n\tvars := mux.Vars(req)\n\n\tid := vars[\"id\"]\n\tupdateGroup := models.CreateUpdateGroup{\n\t\tID: &id,\n\t}\n\n\tbody, err := ioutil.ReadAll(req.Body)\n\tif err != nil {\n\t\treturn nil, handleBodyReadError(ctx, err)\n\t}\n\n\terr = json.Unmarshal(body, &updateGroup)\n\tif err != nil {\n\t\treturn nil, handleBodyUnmarshalError(ctx, err)\n\t}\n\n\tvalidationErrs := updateGroup.ValidateCreateUpdateGroupRequest(ctx)\n\tif len(validationErrs) != 0 {\n\t\treturn nil, models.NewErrorResponse(http.StatusBadRequest, nil, validationErrs...)\n\t}\n\n\tinput := updateGroup.BuildUpdateGroupInput(api.UserPoolId)\n\t_, err = api.CognitoClient.UpdateGroup(input)\n\tif err != nil {\n\t\tcognitoErr := models.NewCognitoError(ctx, err, \"Cognito UpdateGroup request from update a group endpoint\")\n\t\tif cognitoErr.Code == models.NotFoundError {\n\t\t\treturn nil, models.NewErrorResponse(http.StatusNotFound, nil, cognitoErr)\n\t\t}\n\t\treturn nil, models.NewErrorResponse(http.StatusInternalServerError, nil, cognitoErr)\n\t}\n\n\tjsonResponse, responseErr := updateGroup.BuildSuccessfulJsonResponse(ctx)\n\tif responseErr != nil {\n\t\treturn nil, models.NewErrorResponse(http.StatusInternalServerError, nil, responseErr)\n\t}\n\n\treturn updateGroup.NewSuccessResponse(jsonResponse, http.StatusOK, nil), nil\n}", "title": "" }, { "docid": "7daf76585cbd68c1f74ab5adbd693328", "score": "0.430195", "text": "func ToServerGroupURI(id string) string {\n\treturn app.RootURL + ServerGroupBaseURI + \"/\" + id\n}", "title": "" }, { "docid": "a5da96420ee05e24735799346e7a7cc2", "score": "0.42782104", "text": "func (s *Service) HandlerRemoveGroup(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tgName := strings.ToLower(r.FormValue(\"gname\"))\n\tif gName == \"\" {\n\t\tReturnBadRequest(w, ErrInvalidParam)\n\t\treturn\n\t}\n\n\tif err := s.perm.RemoveGroup(gName); err != nil {\n\t\tReturnServerError(w, err)\n\t\treturn\n\t}\n\tReturnJson(w, 200, \"success\")\n}", "title": "" }, { "docid": "a5da96420ee05e24735799346e7a7cc2", "score": "0.42782104", "text": "func (s *Service) HandlerRemoveGroup(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tgName := strings.ToLower(r.FormValue(\"gname\"))\n\tif gName == \"\" {\n\t\tReturnBadRequest(w, ErrInvalidParam)\n\t\treturn\n\t}\n\n\tif err := s.perm.RemoveGroup(gName); err != nil {\n\t\tReturnServerError(w, err)\n\t\treturn\n\t}\n\tReturnJson(w, 200, \"success\")\n}", "title": "" }, { "docid": "488c7cf3bf4871f3923e7aafcaa93843", "score": "0.42770568", "text": "func (*AweNetworkDeviceAssociationGroup) PostPath() string {\n\treturn \"/api/objects/awe_network_device_association/group/\"\n}", "title": "" }, { "docid": "83cf4afd63d0c23b954d8348cffd3bb7", "score": "0.42756358", "text": "func (c *Client) PostDBRP(ctx context.Context, params *PostDBRPAllParams) (*DBRP, error) {\n\tvar err error\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(params.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\n\tserverURL, err := url.Parse(c.APIEndpoint)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"./dbrps\")\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), bodyReader)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\n\tif params.ZapTraceSpan != nil {\n\t\tvar headerParam0 string\n\n\t\theaderParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"Zap-Trace-Span\", runtime.ParamLocationHeader, *params.ZapTraceSpan)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treq.Header.Set(\"Zap-Trace-Span\", headerParam0)\n\t}\n\n\treq = req.WithContext(ctx)\n\trsp, err := c.Client.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyBytes, err := ioutil.ReadAll(rsp.Body)\n\n\tdefer func() { _ = rsp.Body.Close() }()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse := &DBRP{}\n\n\tswitch rsp.StatusCode {\n\tcase 201:\n\t\tif err := unmarshalJSONResponse(bodyBytes, &response); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tdefault:\n\t\treturn nil, decodeError(bodyBytes, rsp)\n\t}\n\treturn response, nil\n\n}", "title": "" }, { "docid": "fb7fbfa2373ea60349ecbe8444923696", "score": "0.42493", "text": "func (s *Service) HandlerGroupGet(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tgName := strings.ToLower(r.FormValue(\"gname\"))\n\tif gName == \"\" {\n\t\tReturnBadRequest(w, ErrInvalidParam)\n\t\treturn\n\t}\n\tg, err := s.perm.GetGroup(gName)\n\tif err != nil || &g == nil {\n\t\tReturnNotFound(w, \"group not found\")\n\t\treturn\n\t}\n\tReturnJson(w, 200, g)\n}", "title": "" }, { "docid": "fb7fbfa2373ea60349ecbe8444923696", "score": "0.42493", "text": "func (s *Service) HandlerGroupGet(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tgName := strings.ToLower(r.FormValue(\"gname\"))\n\tif gName == \"\" {\n\t\tReturnBadRequest(w, ErrInvalidParam)\n\t\treturn\n\t}\n\tg, err := s.perm.GetGroup(gName)\n\tif err != nil || &g == nil {\n\t\tReturnNotFound(w, \"group not found\")\n\t\treturn\n\t}\n\tReturnJson(w, 200, g)\n}", "title": "" }, { "docid": "1fe2be8632368ea54321b30db57505c9", "score": "0.4248719", "text": "func pubRefereeGroup(c *bm.Context) {\n\tp := &model.PublicRefereeGroupParams{}\n\tif err := c.Bind(p); err != nil {\n\t\treturn\n\t}\n\tc.JSON(nil, wkfSvc.PublicRefereeGroup(c, p))\n}", "title": "" }, { "docid": "c5706fba0d220cfccc263b9a30cae397", "score": "0.42457172", "text": "func (*AaaGroups) GetPath() string { return \"/api/objects/aaa/group/\" }", "title": "" }, { "docid": "fa707341720b9a084d6e267c2ea61d9d", "score": "0.42448023", "text": "func (*ReverseProxyGroup) PostPath() string {\n\treturn \"/api/objects/reverse_proxy/group/\"\n}", "title": "" }, { "docid": "302762c63dae828dc41bb4e0fe5fb4f8", "score": "0.4239962", "text": "func (app *Application) handleGroup(d *dict.Parser, gavp *diam.AVP) (failedAVP *diam.AVP, err error) {\n\tgroup, ok := gavp.Data.(*diam.GroupedAVP)\n\tif !ok {\n\t\treturn gavp, &ErrUnexpectedAVP{gavp}\n\t}\n\tfor _, a := range group.AVP {\n\t\tswitch a.Code {\n\t\tcase avp.AcctApplicationID:\n\t\t\tfailedAVP, err = app.validate(d, a.Code, a)\n\t\tcase avp.AuthApplicationID:\n\t\t\tfailedAVP, err = app.validate(d, a.Code, a)\n\t\t}\n\t}\n\treturn failedAVP, err\n}", "title": "" }, { "docid": "fd3c65867b43936db8be7313479e6528", "score": "0.42038947", "text": "func (a *AaaGroup) GetPath() string { return fmt.Sprintf(\"/api/objects/aaa/group/%s\", a.Reference) }", "title": "" }, { "docid": "5c96a5c805e73faad5d03624a367d4c0", "score": "0.41822633", "text": "func (ds *discoverySummarizerServer) summarizeGroupVersionsHandler(path string) func(http.ResponseWriter, *http.Request) {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tvar apiGroupList *metav1.APIGroupList\n\t\t// TODO: We can cache calls to all servers.\n\t\tgroups := make(chan *metav1.APIGroupList)\n\t\terrorChannel := make(chan error)\n\t\tfor _, serverAddress := range ds.groupVersionPaths[path] {\n\t\t\taddr := serverAddress\n\t\t\tgo func(groups chan *metav1.APIGroupList, error_channel chan error) {\n\t\t\t\tgroupList, err := ds.getAPIGroupList(addr + path)\n\t\t\t\tif err != nil {\n\t\t\t\t\terrorChannel <- err\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tgroups <- groupList\n\t\t\t\treturn\n\t\t\t}(groups, errorChannel)\n\t\t}\n\n\t\tvar groupList *metav1.APIGroupList\n\t\tvar err error\n\t\tfor range ds.groupVersionPaths[path] {\n\t\t\tselect {\n\t\t\tcase groupList = <-groups:\n\t\t\t\tif apiGroupList == nil {\n\t\t\t\t\tapiGroupList = &metav1.APIGroupList{}\n\t\t\t\t\t*apiGroupList = *groupList\n\t\t\t\t} else {\n\t\t\t\t\tapiGroupList.Groups = append(apiGroupList.Groups, groupList.Groups...)\n\t\t\t\t}\n\t\t\tcase err = <-errorChannel:\n\t\t\t\tds.writeErr(http.StatusBadGateway, err, w)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tds.writeRawJSON(http.StatusOK, *apiGroupList, w)\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "a6e90923913b6059e1b1d584d73163e4", "score": "0.4167732", "text": "func (a *GroupApiService) GetGroupExecute(r ApiGetGroupRequest) (*Group, *http.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = http.MethodGet\n\t\tlocalVarPostBody interface{}\n\t\tformFiles []formFile\n\t\tlocalVarReturnValue *Group\n\t)\n\n\tlocalBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, \"GroupApiService.GetGroup\")\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}\n\t}\n\n\tlocalVarPath := localBasePath + \"/groups/{group-id}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"group-id\"+\"}\", url.PathEscape(parameterToString(r.groupId, \"\")), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\tif r.select_ != nil {\n\t\tlocalVarQueryParams.Add(\"$select\", parameterToString(*r.select_, \"csv\"))\n\t}\n\tif r.expand != nil {\n\t\tlocalVarQueryParams.Add(\"$expand\", parameterToString(*r.expand, \"csv\"))\n\t}\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)\n\tif localVarHTTPContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHTTPContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHTTPHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\n\tif localVarHTTPHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHTTPHeaderAccept\n\t}\n\treq, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := a.client.callAPI(req)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\n\tlocalVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))\n\tif err != nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tif localVarHTTPResponse.StatusCode >= 300 {\n\t\tnewErr := &GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHTTPResponse.Status,\n\t\t}\n\t\tvar v OdataError\n\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\tif err != nil {\n\t\t\tnewErr.error = err.Error()\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tnewErr.model = v\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\tif err != nil {\n\t\tnewErr := &GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: err.Error(),\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\treturn localVarReturnValue, localVarHTTPResponse, nil\n}", "title": "" }, { "docid": "38c6f8cc27872107598342b458a7128f", "score": "0.4158336", "text": "func (client *DataControllersClient) listInGroupHandleResponse(resp *http.Response) (DataControllersClientListInGroupResponse, error) {\n\tresult := DataControllersClientListInGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PageOfDataControllerResource); err != nil {\n\t\treturn DataControllersClientListInGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "title": "" }, { "docid": "effd3aa39e2877730bbcb81234b99271", "score": "0.415819", "text": "func dNSPodRecordModify(token, domain, sub, rid, nip string) error {\n\ttype RecordModifyStruct struct {\n\t\tStatus `json:\"status\"`\n\t}\n\tv := url.Values{\n\t\t\"domain\": {domain},\n\t\t\"record_id\": {rid},\n\t\t\"sub_domain\": {sub},\n\t\t\"record_type\": {\"A\"},\n\t\t\"record_line\": {\"默认\"},\n\t\t\"record_line_id\": {\"0\"},\n\t\t\"value\": {nip},\n\t\t\"ttl\": {\"600\"},\n\t\t\"format\": {\"json\"},\n\t\t\"login_token\": {token},\n\t}\n\tu := \"https://dnsapi.cn/Record.Modify\"\n\tvar dpr RecordModifyStruct\n\terr := sendPost(u, &v, &dpr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif dpr.Status.Code != \"1\" {\n\t\tfmt.Println(\"status code is\", dpr)\n\t\treturn ErrBadStatus\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "a0479519cf325de4381de93f26c5b83c", "score": "0.41306165", "text": "func (s *Storage) parseFid(recv []byte) (string, *Error) {\n\t// #recv_fmt |-group_name(16)-filename|\n\tif len(recv) < FDFS_GROUP_NAME_MAX_LEN {\n\t\treturn \"\", s.wrapError(unexpectedPkgLenErr(len(recv), FDFS_GROUP_NAME_MAX_LEN))\n\t}\n\tgroup := stripString(string(recv[0:FDFS_GROUP_NAME_MAX_LEN]))\n\tname := string(recv[FDFS_GROUP_NAME_MAX_LEN:])\n\treturn filepath.Join(group, name), nil\n}", "title": "" }, { "docid": "34a45de5e810a0754bcd233751911505", "score": "0.4125111", "text": "func (api *API) DeleteGroupHandler(ctx context.Context, w http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse) {\n\n\tvars := mux.Vars(req)\n\tgroup := models.Group{ID: vars[\"id\"]}\n\tgroupDeleteRequest := group.BuildDeleteGroupRequest(api.UserPoolId)\n\t_, err := api.CognitoClient.DeleteGroup(groupDeleteRequest)\n\tif err != nil {\n\n\t\tcognitoErr := models.NewCognitoError(ctx, err, \"Cognito DeleteGroup request from Delete group endpoint\")\n\t\tif cognitoErr.Code == models.NotFoundError {\n\t\t\treturn nil, models.NewErrorResponse(http.StatusNotFound, nil, cognitoErr)\n\t\t}\n\t\treturn nil, models.NewErrorResponse(http.StatusInternalServerError, nil, cognitoErr)\n\t}\n\n\treturn models.NewSuccessResponse(nil, http.StatusNoContent, nil), nil\n}", "title": "" }, { "docid": "c581edcc02516bdfbad97d3ab1366757", "score": "0.41200683", "text": "func PostScoutingInfoHandler(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\trBody, _ := ioutil.ReadAll(r.Body)\n\t//extract json array and to scoutFormList array\n\tvar newScoutForms []ScoutForm\n\terr := json.Unmarshal(rBody, &newScoutForms)\n\tif err != nil {\n\t\tlog.Println(\"ERROR - PostScoutingInfoHandler: \" + err.Error())\n\t}\n\t//delete existing UID entries from scoutFormList so they can be overwritten later\n\tfor _, item := range newScoutForms {\n\t\tfor i, element := range scoutFormList {\n\t\t\tif item.ID == element.ID {\n\t\t\t\t//delete element from array by subbing it with last element and reducing array length by 1\n\t\t\t\tscoutFormList[i] = scoutFormList[len(scoutFormList)-1]\n\t\t\t\tscoutFormList = scoutFormList[:len(scoutFormList)-1]\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tscoutFormList = append(scoutFormList, newScoutForms...)\n\t//wait for save to disk\n\tsaveFormsToDisk()\n\t// http.Error(w, \"500 Internal Error\", http.StatusInternalServerError)\n\t// returns\t//FIXME remove debug fail lines\n\t// fmt.Println(\"RECEIVED: \" + string(rBody))\n\tfmt.Fprint(w, \"ok - forms received!\")\n}", "title": "" }, { "docid": "3faa1cd859ce13cf7403f594b67146fa", "score": "0.41156295", "text": "func (*GetGroupResp) Descriptor() ([]byte, []int) {\n\treturn file_rpc_proto_rawDescGZIP(), []int{11}\n}", "title": "" }, { "docid": "980d23fa77475cde2ff6e171199d74cf", "score": "0.41150418", "text": "func (client *ServiceEndpointPoliciesClient) listByResourceGroupHandleResponse(resp *http.Response) (ServiceEndpointPoliciesListByResourceGroupResponse, error) {\n\tresult := ServiceEndpointPoliciesListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ServiceEndpointPolicyListResult); err != nil {\n\t\treturn ServiceEndpointPoliciesListByResourceGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "title": "" }, { "docid": "0d93149f51d47e3a5f80a4e8ff269403", "score": "0.4112609", "text": "func (ds *DoitServer) apiGroupHostsHandler(w http.ResponseWriter, r *http.Request) {\n\terr := r.ParseForm()\n\tif err != nil {\n\t\tlog.Errorln(\"Unable to parse message\", err)\n\t\tds.ReturnInternalServerError(w, r)\n\t\treturn\n\t}\n\tvars := mux.Vars(r)\n\tdomain := r.Form.Get(\"domain\")\n\treqName := vars[\"name\"]\n\n\td, err := ds.DomainCheck(domain)\n\tif err != nil {\n\t\tds.ReturnBadRequest(w, r)\n\t\treturn\n\t}\n\n\tswitch r.Method {\n\tcase \"GET\":\n\t\tg, err := ds.GetGroupByName(d, reqName)\n\t\tif err != nil {\n\t\t\tds.ReturnNotFound(w, r)\n\t\t\treturn\n\t\t}\n\t\thv, err := ds.GetGroupHosts(d, g)\n\t\tif err != nil {\n\t\t\tds.ReturnNotFound(w, r)\n\t\t\treturn\n\t\t}\n\t\terr = ds.ReturnJSON(hv, w, r)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\tdefault:\n\t\tds.ReturnNotImplemented(w, r)\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "d25f584ea4d6bfb67c226d9929380740", "score": "0.41090146", "text": "func delReply(c *bm.Context) {\n\tparams := c.Request.Form\n\tmid, _ := c.Get(\"mid\")\n\toidsStr := params.Get(\"oid\")\n\ttpStr := params.Get(\"type\")\n\trpIDsStr := params.Get(\"rpid\")\n\tak := params.Get(\"access_key\")\n\tplatform := params.Get(\"platform\")\n\tbuildStr := params.Get(\"build\")\n\tbuvid := c.Request.Header.Get(\"buvid\")\n\tvar build int64\n\tvar err error\n\t// check params\n\tif buildStr != \"\" {\n\t\tbuild, err = strconv.ParseInt(buildStr, 10, 64)\n\t\tif err != nil {\n\t\t\tlog.Warn(\"strconv.ParseInt(build %s) err(%v)\", buildStr, err)\n\t\t\terr = ecode.RequestErr\n\t\t\tc.JSON(nil, err)\n\t\t\treturn\n\t\t}\n\t}\n\toids, err := xstr.SplitInts(oidsStr)\n\tif err != nil {\n\t\tlog.Warn(\"strconv.ParseInt(%s) error(%v)\", oidsStr, err)\n\t\terr = ecode.RequestErr\n\t\tc.JSON(nil, err)\n\t\treturn\n\t}\n\trpIDs, err := xstr.SplitInts(rpIDsStr)\n\tif err != nil {\n\t\tlog.Warn(\"strconv.ParseInt(%s) error(%v)\", rpIDsStr, err)\n\t\terr = ecode.RequestErr\n\t\tc.JSON(nil, err)\n\t\treturn\n\t}\n\ttp, err := strconv.ParseInt(tpStr, 10, 8)\n\tif err != nil {\n\t\tlog.Warn(\"strconv.ParseInt(%s) error(%v)\", tpStr, err)\n\t\terr = ecode.RequestErr\n\t\tc.JSON(nil, err)\n\t\treturn\n\t}\n\tif len(oids) != len(rpIDs) {\n\t\tlog.Warn(\"miss oid:%s rpid:%s\", oidsStr, rpIDsStr)\n\t\terr = ecode.RequestErr\n\t\tc.JSON(nil, err)\n\t\treturn\n\t}\n\tfor i := 0; i < len(oids); i++ {\n\t\tif oids[i] <= 0 {\n\t\t\terr = ecode.RequestErr\n\t\t\tc.JSON(nil, err)\n\t\t\treturn\n\t\t}\n\t\tif err = rpSvr.Delete(c, mid.(int64), oids[i], rpIDs[i], int8(tp), ak, c.Request.Header.Get(\"Cookie\"), platform, build, buvid); err != nil {\n\t\t\tc.JSON(nil, err)\n\t\t\treturn\n\t\t}\n\t}\n\tc.JSON(nil, nil)\n}", "title": "" }, { "docid": "4c59202b9c287afed5e8726b0f67321a", "score": "0.40946203", "text": "func vgroup(annotation string, port v1.ServicePort) (string, error) {\n\tfor _, v := range strings.Split(annotation, \",\") {\n\t\tpp := strings.Split(v, \":\")\n\t\tif len(pp) < 2 {\n\t\t\treturn \"\", fmt.Errorf(\"vgroupid and \"+\n\t\t\t\t\"protocol format must be like 'vsp-xxx:443' with colon separated. got=[%+v]\", pp)\n\t\t}\n\n\t\tif pp[1] == fmt.Sprintf(\"%d\", port.Port) {\n\t\t\treturn pp[0], nil\n\t\t}\n\t}\n\treturn \"\", nil\n}", "title": "" }, { "docid": "1753385904a179f1bd200caab4bbe2f8", "score": "0.40923455", "text": "func getPGroupList(w http.ResponseWriter, r *http.Request, d *ServiceData, PID int64, lim bool) (PGroupList, error) {\n\tvar g PGroupList\n\n\tq := fmt.Sprintf(`SELECT EGroup.GID,EGroup.GroupName FROM PGroup\nINNER JOIN People ON (People.PID=PGroup.PID AND People.PID=%d)\nINNER JOIN EGroup ON (EGroup.GID = PGroup.GID)\nORDER BY EGroup.GroupName ASC`, PID)\n\n\tif lim {\n\t\tq += fmt.Sprintf(` LIMIT %d OFFSET %d`, d.wsSearchReq.Limit, d.wsSearchReq.Offset)\n\t}\n\n\tq += \";\"\n\n\tutil.Console(\"query = %s\\n\", q)\n\n\trows, err := db.DB.Db.Query(q)\n\tif err != nil {\n\t\treturn g, err\n\t}\n\tdefer rows.Close()\n\n\ti := int64(d.wsSearchReq.Offset)\n\n\tg.Total = 0\n\tfor rows.Next() {\n\t\tvar a PGroupItem\n\t\tif err = rows.Scan(&a.GID, &a.GroupName); err != nil {\n\t\t\treturn g, err\n\t\t}\n\t\ta.Recid = a.GID\n\t\tg.Records = append(g.Records, a)\n\t\tg.Total++ // update the g.Total only after adding the record\n\t\tif int64(d.wsSearchReq.Limit) > 0 && g.Total >= int64(d.wsSearchReq.Limit) {\n\t\t\tbreak // if we've added the max number requested, then exit\n\t\t}\n\t\ti++\n\t}\n\tutil.Console(\"g.Total = %d\\n\", g.Total)\n\tutil.ErrCheck(rows.Err())\n\tg.Status = \"success\"\n\treturn g, nil\n}", "title": "" }, { "docid": "ce8c64d349130d5132b5ab0b08ac018a", "score": "0.40913233", "text": "func (s *Service) HandlerGroupList(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tns := strings.ToLower(r.FormValue(\"ns\"))\n\tif ns == \"\" {\n\t\tReturnBadRequest(w, ErrInvalidParam)\n\t\treturn\n\t}\n\tgList, err := s.perm.ListNsGroup(ns)\n\tif err != nil {\n\t\tReturnNotFound(w, \"group not found\")\n\t\treturn\n\t}\n\tReturnJson(w, 200, gList)\n}", "title": "" }, { "docid": "ce8c64d349130d5132b5ab0b08ac018a", "score": "0.40913233", "text": "func (s *Service) HandlerGroupList(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tns := strings.ToLower(r.FormValue(\"ns\"))\n\tif ns == \"\" {\n\t\tReturnBadRequest(w, ErrInvalidParam)\n\t\treturn\n\t}\n\tgList, err := s.perm.ListNsGroup(ns)\n\tif err != nil {\n\t\tReturnNotFound(w, \"group not found\")\n\t\treturn\n\t}\n\tReturnJson(w, 200, gList)\n}", "title": "" }, { "docid": "1cc8b895df5e872c71d3f0febe7b46df", "score": "0.40857887", "text": "func (client BaseClient) UpdateGroupResponder(resp *http.Response) (result SetObject, err error) {\n err = autorest.Respond(\n resp,\n client.ByInspecting(),\n azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusNoContent,http.StatusForbidden,http.StatusNotFound,http.StatusInternalServerError),\n autorest.ByUnmarshallingJSON(&result.Value),\n autorest.ByClosing())\n result.Response = autorest.Response{Response: resp}\n return\n }", "title": "" }, { "docid": "2faad19c8f36733811bb960f82eb3fe7", "score": "0.40835753", "text": "func (*DeleteGroupResponse) Descriptor() ([]byte, []int) {\n\treturn file_rotation_service_proto_rawDescGZIP(), []int{18}\n}", "title": "" }, { "docid": "bdc37aa814f1796263d838ee728b2448", "score": "0.40816042", "text": "func (*NotificationGroups) GetPath() string { return \"/api/objects/notification/group/\" }", "title": "" }, { "docid": "296e9a93150742af9c5117761683cdaf", "score": "0.40770996", "text": "func (s *Service) HandlerUpdateGroupItem(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tgName := strings.ToLower(r.FormValue(\"gname\"))\n\titemStr := r.FormValue(\"items\")\n\tif gName == \"\" || itemStr == \"\" {\n\t\tReturnBadRequest(w, ErrInvalidParam)\n\t\treturn\n\t}\n\n\terr := s.perm.UpdateItems(gName, strings.Split(itemStr, \",\"))\n\tif err != nil {\n\t\ts.logger.Errorf(\"set group fail: %s\", err.Error())\n\t\tReturnNotFound(w, \"set group fail\")\n\t\treturn\n\t}\n\tReturnOK(w, \"success\")\n}", "title": "" }, { "docid": "296e9a93150742af9c5117761683cdaf", "score": "0.40770996", "text": "func (s *Service) HandlerUpdateGroupItem(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tgName := strings.ToLower(r.FormValue(\"gname\"))\n\titemStr := r.FormValue(\"items\")\n\tif gName == \"\" || itemStr == \"\" {\n\t\tReturnBadRequest(w, ErrInvalidParam)\n\t\treturn\n\t}\n\n\terr := s.perm.UpdateItems(gName, strings.Split(itemStr, \",\"))\n\tif err != nil {\n\t\ts.logger.Errorf(\"set group fail: %s\", err.Error())\n\t\tReturnNotFound(w, \"set group fail\")\n\t\treturn\n\t}\n\tReturnOK(w, \"success\")\n}", "title": "" }, { "docid": "724edf050a3b00dd87b785633b86e073", "score": "0.4076536", "text": "func (client BaseClient) DeleteGroupResponder(resp *http.Response) (result SetObject, err error) {\n err = autorest.Respond(\n resp,\n client.ByInspecting(),\n azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusNoContent,http.StatusForbidden,http.StatusNotFound,http.StatusInternalServerError),\n autorest.ByUnmarshallingJSON(&result.Value),\n autorest.ByClosing())\n result.Response = autorest.Response{Response: resp}\n return\n }", "title": "" }, { "docid": "f55314e8a3522a4808efee4b050bbf1e", "score": "0.40679014", "text": "func (s GroupSvc) WebService() *restful.WebService {\n\tws := new(restful.WebService)\n\tws.Path(\"groups\").\n\t\tProduces(restful.MIME_JSON, restful.MIME_JSON)\n\n\ttags := []string{TR(\"group management\")}\n\n\t// 添加组织\n\tws.Route(ws.POST(\"/\").To(s.createGroup).Doc(TR(\"create group\")).\n\t\tMetadata(api.KeyOpenAPITags, tags).\n\t\tParam(ws.HeaderParameter(\"auth-session\", \"user session\").DataType(\"string\").Required(true)).\n\t\tWrites(CreateGroupResp{}).Reads(CreateGroupReq{}))\n\n\t// 查询组织\n\tws.Route(ws.GET(\"/\").To(s.queryGroups).Doc(TR(\"query groups\")).\n\t\tMetadata(api.KeyOpenAPITags, tags).\n\t\tParam(ws.HeaderParameter(\"auth-session\", \"user session\").DataType(\"string\").Required(true)).\n\t\tWrites(QueryGroupsResp{}))\n\n\t// 修改组织信息\n\tws.Route(ws.PUT(\"/{group-id}\").To(s.updateGroup).Doc(TR(\"update group info\")).\n\t\tMetadata(api.KeyOpenAPITags, tags).\n\t\tParam(ws.HeaderParameter(\"auth-session\", \"user session\").DataType(\"string\").Required(true)).\n\t\tParam(ws.PathParameter(\"group-id\", TR(\"group id\")).DataType(\"string\").Required(true)).\n\t\tReads(UpdateGroupReq{}))\n\n\t// 移除组织\n\tws.Route(ws.DELETE(\"/{group-id}\").To(s.delGroup).Doc(\"delete group\").\n\t\tMetadata(api.KeyOpenAPITags, tags).\n\t\tParam(ws.HeaderParameter(\"auth-session\", \"user session\").DataType(\"string\").Required(true)).\n\t\tParam(ws.PathParameter(\"group-id\", TR(\"group id\")).DataType(\"string\").Required(true)))\n\n\t// 添加组织成员\n\tws.Route(ws.POST(\"/{group-id}/users\").To(s.addGroupUsers).Doc(TR(\"add group users\")).\n\t\tMetadata(api.KeyOpenAPITags, tags).\n\t\tParam(ws.PathParameter(\"group-id\", TR(\"group id\")).DataType(\"string\").Required(true)).\n\t\tWrites(AddGroupUsersResp{}).\n\t\tReads(AddGroupUsersReq{}))\n\n\t// 查询组织成员\n\tws.Route(ws.GET(\"/{group-id}/users\").To(s.queryGroupUsers).Doc(TR(\"query group users\")).\n\t\tMetadata(api.KeyOpenAPITags, tags).\n\t\tParam(ws.PathParameter(\"group-id\", TR(\"group id\")).DataType(\"string\").Required(true)).\n\t\tWrites(QueryGroupUsersResp{}))\n\n\t// 移除组织成员\n\tws.Route(ws.DELETE(\"/{group-id}/users/{user-id}\").To(s.delGroupUsers).Doc(TR(\"delete group users\")).\n\t\tMetadata(api.KeyOpenAPITags, tags).\n\t\tParam(ws.PathParameter(\"group-id\", TR(\"group id\")).DataType(\"string\").Required(true)).\n\t\tParam(ws.PathParameter(\"user-id\", TR(\"user id\")).DataType(\"string\").Required(true)))\n\n\treturn ws\n}", "title": "" }, { "docid": "90625ebbb386a7e8bb34e5176ada15b0", "score": "0.40659305", "text": "func (a *SlingApiService) PostConfigAdobeGraniteSamlAuthenticationHandlerExecute(r ApiPostConfigAdobeGraniteSamlAuthenticationHandlerRequest) (*_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = _nethttp.MethodPost\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t)\n\n\tlocalBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, \"SlingApiService.PostConfigAdobeGraniteSamlAuthenticationHandler\")\n\tif err != nil {\n\t\treturn nil, GenericOpenAPIError{error: err.Error()}\n\t}\n\n\tlocalVarPath := localBasePath + \"/apps/system/config/com.adobe.granite.auth.saml.SamlAuthenticationHandler.config\"\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\tif r.keyStorePassword != nil {\n\t\tlocalVarQueryParams.Add(\"keyStorePassword\", parameterToString(*r.keyStorePassword, \"\"))\n\t}\n\tif r.keyStorePasswordTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"keyStorePassword@TypeHint\", parameterToString(*r.keyStorePasswordTypeHint, \"\"))\n\t}\n\tif r.serviceRanking != nil {\n\t\tlocalVarQueryParams.Add(\"service.ranking\", parameterToString(*r.serviceRanking, \"\"))\n\t}\n\tif r.serviceRankingTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"service.ranking@TypeHint\", parameterToString(*r.serviceRankingTypeHint, \"\"))\n\t}\n\tif r.idpHttpRedirect != nil {\n\t\tlocalVarQueryParams.Add(\"idpHttpRedirect\", parameterToString(*r.idpHttpRedirect, \"\"))\n\t}\n\tif r.idpHttpRedirectTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"idpHttpRedirect@TypeHint\", parameterToString(*r.idpHttpRedirectTypeHint, \"\"))\n\t}\n\tif r.createUser != nil {\n\t\tlocalVarQueryParams.Add(\"createUser\", parameterToString(*r.createUser, \"\"))\n\t}\n\tif r.createUserTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"createUser@TypeHint\", parameterToString(*r.createUserTypeHint, \"\"))\n\t}\n\tif r.defaultRedirectUrl != nil {\n\t\tlocalVarQueryParams.Add(\"defaultRedirectUrl\", parameterToString(*r.defaultRedirectUrl, \"\"))\n\t}\n\tif r.defaultRedirectUrlTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"defaultRedirectUrl@TypeHint\", parameterToString(*r.defaultRedirectUrlTypeHint, \"\"))\n\t}\n\tif r.userIDAttribute != nil {\n\t\tlocalVarQueryParams.Add(\"userIDAttribute\", parameterToString(*r.userIDAttribute, \"\"))\n\t}\n\tif r.userIDAttributeTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"userIDAttribute@TypeHint\", parameterToString(*r.userIDAttributeTypeHint, \"\"))\n\t}\n\tif r.defaultGroups != nil {\n\t\tt := *r.defaultGroups\n\t\tif reflect.TypeOf(t).Kind() == reflect.Slice {\n\t\t\ts := reflect.ValueOf(t)\n\t\t\tfor i := 0; i < s.Len(); i++ {\n\t\t\t\tlocalVarQueryParams.Add(\"defaultGroups\", parameterToString(s.Index(i), \"multi\"))\n\t\t\t}\n\t\t} else {\n\t\t\tlocalVarQueryParams.Add(\"defaultGroups\", parameterToString(t, \"multi\"))\n\t\t}\n\t}\n\tif r.defaultGroupsTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"defaultGroups@TypeHint\", parameterToString(*r.defaultGroupsTypeHint, \"\"))\n\t}\n\tif r.idpCertAlias != nil {\n\t\tlocalVarQueryParams.Add(\"idpCertAlias\", parameterToString(*r.idpCertAlias, \"\"))\n\t}\n\tif r.idpCertAliasTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"idpCertAlias@TypeHint\", parameterToString(*r.idpCertAliasTypeHint, \"\"))\n\t}\n\tif r.addGroupMemberships != nil {\n\t\tlocalVarQueryParams.Add(\"addGroupMemberships\", parameterToString(*r.addGroupMemberships, \"\"))\n\t}\n\tif r.addGroupMembershipsTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"addGroupMemberships@TypeHint\", parameterToString(*r.addGroupMembershipsTypeHint, \"\"))\n\t}\n\tif r.path != nil {\n\t\tt := *r.path\n\t\tif reflect.TypeOf(t).Kind() == reflect.Slice {\n\t\t\ts := reflect.ValueOf(t)\n\t\t\tfor i := 0; i < s.Len(); i++ {\n\t\t\t\tlocalVarQueryParams.Add(\"path\", parameterToString(s.Index(i), \"multi\"))\n\t\t\t}\n\t\t} else {\n\t\t\tlocalVarQueryParams.Add(\"path\", parameterToString(t, \"multi\"))\n\t\t}\n\t}\n\tif r.pathTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"path@TypeHint\", parameterToString(*r.pathTypeHint, \"\"))\n\t}\n\tif r.synchronizeAttributes != nil {\n\t\tt := *r.synchronizeAttributes\n\t\tif reflect.TypeOf(t).Kind() == reflect.Slice {\n\t\t\ts := reflect.ValueOf(t)\n\t\t\tfor i := 0; i < s.Len(); i++ {\n\t\t\t\tlocalVarQueryParams.Add(\"synchronizeAttributes\", parameterToString(s.Index(i), \"multi\"))\n\t\t\t}\n\t\t} else {\n\t\t\tlocalVarQueryParams.Add(\"synchronizeAttributes\", parameterToString(t, \"multi\"))\n\t\t}\n\t}\n\tif r.synchronizeAttributesTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"synchronizeAttributes@TypeHint\", parameterToString(*r.synchronizeAttributesTypeHint, \"\"))\n\t}\n\tif r.clockTolerance != nil {\n\t\tlocalVarQueryParams.Add(\"clockTolerance\", parameterToString(*r.clockTolerance, \"\"))\n\t}\n\tif r.clockToleranceTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"clockTolerance@TypeHint\", parameterToString(*r.clockToleranceTypeHint, \"\"))\n\t}\n\tif r.groupMembershipAttribute != nil {\n\t\tlocalVarQueryParams.Add(\"groupMembershipAttribute\", parameterToString(*r.groupMembershipAttribute, \"\"))\n\t}\n\tif r.groupMembershipAttributeTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"groupMembershipAttribute@TypeHint\", parameterToString(*r.groupMembershipAttributeTypeHint, \"\"))\n\t}\n\tif r.idpUrl != nil {\n\t\tlocalVarQueryParams.Add(\"idpUrl\", parameterToString(*r.idpUrl, \"\"))\n\t}\n\tif r.idpUrlTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"idpUrl@TypeHint\", parameterToString(*r.idpUrlTypeHint, \"\"))\n\t}\n\tif r.logoutUrl != nil {\n\t\tlocalVarQueryParams.Add(\"logoutUrl\", parameterToString(*r.logoutUrl, \"\"))\n\t}\n\tif r.logoutUrlTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"logoutUrl@TypeHint\", parameterToString(*r.logoutUrlTypeHint, \"\"))\n\t}\n\tif r.serviceProviderEntityId != nil {\n\t\tlocalVarQueryParams.Add(\"serviceProviderEntityId\", parameterToString(*r.serviceProviderEntityId, \"\"))\n\t}\n\tif r.serviceProviderEntityIdTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"serviceProviderEntityId@TypeHint\", parameterToString(*r.serviceProviderEntityIdTypeHint, \"\"))\n\t}\n\tif r.assertionConsumerServiceURL != nil {\n\t\tlocalVarQueryParams.Add(\"assertionConsumerServiceURL\", parameterToString(*r.assertionConsumerServiceURL, \"\"))\n\t}\n\tif r.assertionConsumerServiceURLTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"assertionConsumerServiceURL@TypeHint\", parameterToString(*r.assertionConsumerServiceURLTypeHint, \"\"))\n\t}\n\tif r.handleLogout != nil {\n\t\tlocalVarQueryParams.Add(\"handleLogout\", parameterToString(*r.handleLogout, \"\"))\n\t}\n\tif r.handleLogoutTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"handleLogout@TypeHint\", parameterToString(*r.handleLogoutTypeHint, \"\"))\n\t}\n\tif r.spPrivateKeyAlias != nil {\n\t\tlocalVarQueryParams.Add(\"spPrivateKeyAlias\", parameterToString(*r.spPrivateKeyAlias, \"\"))\n\t}\n\tif r.spPrivateKeyAliasTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"spPrivateKeyAlias@TypeHint\", parameterToString(*r.spPrivateKeyAliasTypeHint, \"\"))\n\t}\n\tif r.useEncryption != nil {\n\t\tlocalVarQueryParams.Add(\"useEncryption\", parameterToString(*r.useEncryption, \"\"))\n\t}\n\tif r.useEncryptionTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"useEncryption@TypeHint\", parameterToString(*r.useEncryptionTypeHint, \"\"))\n\t}\n\tif r.nameIdFormat != nil {\n\t\tlocalVarQueryParams.Add(\"nameIdFormat\", parameterToString(*r.nameIdFormat, \"\"))\n\t}\n\tif r.nameIdFormatTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"nameIdFormat@TypeHint\", parameterToString(*r.nameIdFormatTypeHint, \"\"))\n\t}\n\tif r.digestMethod != nil {\n\t\tlocalVarQueryParams.Add(\"digestMethod\", parameterToString(*r.digestMethod, \"\"))\n\t}\n\tif r.digestMethodTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"digestMethod@TypeHint\", parameterToString(*r.digestMethodTypeHint, \"\"))\n\t}\n\tif r.signatureMethod != nil {\n\t\tlocalVarQueryParams.Add(\"signatureMethod\", parameterToString(*r.signatureMethod, \"\"))\n\t}\n\tif r.signatureMethodTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"signatureMethod@TypeHint\", parameterToString(*r.signatureMethodTypeHint, \"\"))\n\t}\n\tif r.userIntermediatePath != nil {\n\t\tlocalVarQueryParams.Add(\"userIntermediatePath\", parameterToString(*r.userIntermediatePath, \"\"))\n\t}\n\tif r.userIntermediatePathTypeHint != nil {\n\t\tlocalVarQueryParams.Add(\"userIntermediatePath@TypeHint\", parameterToString(*r.userIntermediatePathTypeHint, \"\"))\n\t}\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)\n\tif localVarHTTPContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHTTPContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHTTPHeaderAccepts := []string{}\n\n\t// set Accept header\n\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\n\tif localVarHTTPHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHTTPHeaderAccept\n\t}\n\treq, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := a.client.callAPI(req)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\n\tlocalVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody))\n\tif err != nil {\n\t\treturn localVarHTTPResponse, err\n\t}\n\n\tif localVarHTTPResponse.StatusCode >= 300 {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHTTPResponse.Status,\n\t\t}\n\t\treturn localVarHTTPResponse, newErr\n\t}\n\n\treturn localVarHTTPResponse, nil\n}", "title": "" }, { "docid": "415d3b9cd0e28debd0900abbf22c4199", "score": "0.40439528", "text": "func procDiscussions(w http.ResponseWriter, r *http.Request) {\n //c := appengine.NewContext(r)\n c, cancel := context.WithCancel(context.Background())\n\t defer cancel()\n //D0086\n datastoreClient := createClientDS()\n\t// 20170708191743\n\t// 20170708191743\n\t// TDSARTL-4\n\t// 1\n\t// TDSARTL-4\n\t// [\"My\",\"comments\",\"on\",\"your\",\"MIS\",\"UPOU\",\"course\"]\n\t// ulapph@gmail.com\n\t//\tDT_FIRST\tDT_UPDATE\tIID\tNUM_COMMENTS\tSID\tTAGS\tUSERS\n\trt := time.Now().AddDate(0, 0, -30)\n\ttimestamp := fmt.Sprintf(\"%v\", rt.Format(\"20060102150405\"))\n\tq := datastore.NewQuery(\"TDSCOMIDX\").Filter(\"DT_UPDATE > \", timestamp)\n\trecCount, _ := datastoreClient.Count(c,q)\n\t//log.Printf(\"recCount: %v\", recCount)\n\tcidx := make([]TDSCOMIDX, 0, recCount)\n\tif _, err := datastoreClient.GetAll(c,q, &cidx); err != nil {\n\t\t panic(err)\n }\n //log.Printf(\"datastoreClient.Get() [59035]\")\n\t//For each record populate struct\n\tvar cx []Discussions\n\tfor _, p := range cidx{\n\t\t//get content record\n\t\t//D0042\n\t\tSID := p.SID\n\t\tSPL := strings.Split(SID,\"-\")\n\t\tTARGET := SPL[0]\n\t\tDOC_ID := \"0\"\n\t\tif len(SPL) > 1 {\n\t\t\tDOC_ID = SPL[1]\n\t\t}\n\t\tdocID := str2int(DOC_ID)\n\t\tIMAGE := \"\"\n\t\tTITLE := \"\"\n\t\t//AUTHOR := conUidToHTML()\n\t\tvar buf bytes.Buffer\n\t\tcomu := p.USERS\n\t\tfor i:=0; i < len(comu); i++ {\n\t\t\tbuf.WriteString(fmt.Sprintf(\"<a href=\\\"https://www.ulapph.com/social?SO_FUNC=ViewPeople&UID=%v\\\"><img src=\\\"%v\\\" class=\\\"img-circle\\\" width=50 height=50 title=\\\"Chat with %v\\\"> \", comu[i], getProfilePic(w, r, comu[i]), comu[i]))\n\t\t}\n\t\tUSERS := template.HTML(buf.String())\n\t\tACTIVITY := stmpHumanizeStr(p.DT_UPDATE)\n\t\tDT_UPDATE := p.DT_UPDATE\n\t\tCOMMENTS := p.NUM_COMMENTS\n\t\tURL_DIS := \"\"\n\t\tURL_CON := \"\"\n\t\tFL_SHARED := \"\"\n\t\tDOC_STAT := \"\"\n\t\tMUSIC_ID := \"\"\n\t\tGET_NEXT := \"\"\n\t\tswitch TARGET {\n\t\t\tcase \"TDSSLIDE\":\n\t\t\t\t_, DOC_STAT, FL_SHARED, _, _, TITLE, IMAGE, _, MUSIC_ID, GET_NEXT = getTDSSLIDEBlobKey(w, r, docID)\n\t\t\t\tURL_DIS = fmt.Sprintf(\"https://www.ulapph.com/captcha?CC_FUNC=DISP&R=COMMENT&SID=%v&TITLE=%v\", SID, TITLE)\n\t\t\t\tURL_CON = fmt.Sprintf(\"https://www.ulapph.com/slides?TYPE=SLIDE&DOC_ID=%v&SID=%v&FORCE=%v&MODE=%v&PARM=%v&SECS=%v&TITLE=%v&MUSIC_ID=%v&GET_NEXT=%v&SOUND=ON\", DOC_ID, SID, \"N\", \"NORMAL\", \"LOOP\", \"8\", TITLE, MUSIC_ID, GET_NEXT)\n\t\t\tcase \"TDSARTL\":\n\t\t\t\t_, DOC_STAT, FL_SHARED, _, _, TITLE, _, IMAGE, MUSIC_ID = getTDSARTLBlobKey(w, r, docID)\n\t\t\t\tURL_DIS = fmt.Sprintf(\"https://www.ulapph.com/captcha?CC_FUNC=DISP&R=COMMENT&SID=%v&TITLE=%v\", SID, TITLE)\n\t\t\t\tURL_CON = fmt.Sprintf(\"https://www.ulapph.com/articles?TYPE=ARTICLE&DOC_ID=%v&SID=%v&FORCE=%v&TITLE=%v&MUSIC_ID=%v\", DOC_ID, SID, \"N\", TITLE, MUSIC_ID)\n\t\t\tcase \"TDSMEDIA\":\n\t\t\t\t_, _, TITLE, _, DOC_STAT, FL_SHARED, IMAGE, _, _, _, _ = getTDSMEDIABlobKey(w, r, docID)\n\t\t\t\tURL_DIS = fmt.Sprintf(\"https://www.ulapph.com/captcha?CC_FUNC=DISP&R=COMMENT&SID=%v&TITLE=%v\", SID, TITLE)\n\t\t\t\tURL_CON = fmt.Sprintf(\"https://www.ulapph.com/media?FUNC_CODE=PLAY&MEDIA_ID=%v&SID=TDSMEDIA-%v\", docID, docID)\n\t\t}\n\t\tg := Discussions{\n\t\t\tIMAGE: IMAGE,\n\t\t\tTITLE: TITLE,\n\t\t\tUSERS: USERS,\n\t\t\tACTIVITY: ACTIVITY,\n\t\t\tDT_UPDATE: DT_UPDATE,\n\t\t\tCOMMENTS: COMMENTS,\n\t\t\tURL_DIS: URL_DIS,\n\t\t\tURL_CON: URL_CON,\n\t\t\tFL_SHARED: FL_SHARED,\n\t\t\tDOC_STAT: DOC_STAT,\n\t\t}\n\t\tcx = append(cx, g)\n\t}\n\tif err := recentDiscussions.Execute(w, cx); err != nil {\n\t panic(err)\n\t}\n}", "title": "" }, { "docid": "741c447338745940f387585754a02967", "score": "0.40435946", "text": "func (d *Data) ServeHTTP(uuid dvid.UUID, ctx *datastore.VersionedCtx, w http.ResponseWriter, r *http.Request) (activity map[string]interface{}) {\n\t// TODO -- Refactor this method to break it up and make it simpler. Use the web routing for the endpoints.\n\n\ttimedLog := dvid.NewTimeLog()\n\n\t// Get the action (GET, POST)\n\taction := strings.ToLower(r.Method)\n\tswitch action {\n\tcase \"get\":\n\tcase \"post\":\n\tcase \"delete\":\n\tdefault:\n\t\tserver.BadRequest(w, r, \"labelblk only handles GET, POST, and DELETE HTTP verbs\")\n\t\treturn\n\t}\n\n\t// Break URL request into arguments\n\turl := r.URL.Path[len(server.WebAPIPath):]\n\tparts := strings.Split(url, \"/\")\n\tif len(parts[len(parts)-1]) == 0 {\n\t\tparts = parts[:len(parts)-1]\n\t}\n\n\t// Get query strings and possible roi\n\tqueryStrings := r.URL.Query()\n\troiname := dvid.InstanceName(queryStrings.Get(\"roi\"))\n\n\t// Handle POST on data -> setting of configuration\n\tif len(parts) == 3 && action == \"post\" {\n\t\tconfig, err := server.DecodeJSON(r)\n\t\tif err != nil {\n\t\t\tserver.BadRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\t\tif err := d.ModifyConfig(config); err != nil {\n\t\t\tserver.BadRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\t\tif err := datastore.SaveDataByUUID(uuid, d); err != nil {\n\t\t\tserver.BadRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\t\tfmt.Fprintf(w, \"Changed '%s' based on received configuration:\\n%s\\n\", d.DataName(), config)\n\t\treturn\n\t}\n\n\tif len(parts) < 4 {\n\t\tserver.BadRequest(w, r, \"Incomplete API request\")\n\t\treturn\n\t}\n\n\t// Process help and info.\n\tswitch parts[3] {\n\tcase \"help\":\n\t\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\t\tfmt.Fprintln(w, dtype.Help())\n\n\tcase \"metadata\":\n\t\tjsonStr, err := d.NdDataMetadata(ctx)\n\t\tif err != nil {\n\t\t\tserver.BadRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Content-Type\", \"application/vnd.dvid-nd-data+json\")\n\t\tfmt.Fprintln(w, jsonStr)\n\n\tcase \"resolution\":\n\t\tjsonBytes, err := ioutil.ReadAll(r.Body)\n\t\tif err != nil {\n\t\t\tserver.BadRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\t\tif err := d.SetResolution(uuid, jsonBytes); err != nil {\n\t\t\tserver.BadRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\n\tcase \"info\":\n\t\tjsonBytes, err := d.MarshalJSON()\n\t\tif err != nil {\n\t\t\tserver.BadRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tfmt.Fprintf(w, string(jsonBytes))\n\n\tcase \"sync\":\n\t\tif action != \"post\" {\n\t\t\tserver.BadRequest(w, r, \"Only POST allowed to sync endpoint\")\n\t\t\treturn\n\t\t}\n\t\treplace := r.URL.Query().Get(\"replace\") == \"true\"\n\t\tif err := datastore.SetSyncByJSON(d, uuid, replace, r.Body); err != nil {\n\t\t\tserver.BadRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\n\tcase \"label\":\n\t\t// GET <api URL>/node/<UUID>/<data name>/label/<coord>\n\t\tif len(parts) < 5 {\n\t\t\tserver.BadRequest(w, r, \"DVID requires coord to follow 'label' command\")\n\t\t\treturn\n\t\t}\n\t\tcoord, err := dvid.StringToPoint(parts[4], \"_\")\n\t\tif err != nil {\n\t\t\tserver.BadRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\t\tlabel, err := d.GetLabelAtPoint(ctx.VersionID(), coord)\n\t\tif err != nil {\n\t\t\tserver.BadRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Content-type\", \"application/json\")\n\t\tjsonStr := fmt.Sprintf(`{\"Label\": %d}`, label)\n\t\tfmt.Fprintf(w, jsonStr)\n\t\ttimedLog.Infof(\"HTTP %s: label at %s (%s)\", r.Method, coord, r.URL)\n\n\tcase \"labels\":\n\t\t// POST <api URL>/node/<UUID>/<data name>/labels\n\t\tif action != \"get\" {\n\t\t\tserver.BadRequest(w, r, \"Batch labels query must be a GET request\")\n\t\t\treturn\n\t\t}\n\t\tdata, err := ioutil.ReadAll(r.Body)\n\t\tif err != nil {\n\t\t\tserver.BadRequest(w, r, \"Bad GET request body for batch query: %v\", err)\n\t\t\treturn\n\t\t}\n\t\thash := queryStrings.Get(\"hash\")\n\t\tif err := checkContentHash(hash, data); err != nil {\n\t\t\tserver.BadRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\t\tvar coords []dvid.Point3d\n\t\tif err := json.Unmarshal(data, &coords); err != nil {\n\t\t\tserver.BadRequest(w, r, fmt.Sprintf(\"Bad labels request JSON: %v\", err))\n\t\t\treturn\n\t\t}\n\t\tw.Header().Set(\"Content-type\", \"application/json\")\n\t\tfmt.Fprintf(w, \"[\")\n\t\tsep := false\n\t\tfor _, coord := range coords {\n\t\t\tlabel, err := d.GetLabelAtPoint(ctx.VersionID(), coord)\n\t\t\tif err != nil {\n\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif sep {\n\t\t\t\tfmt.Fprintf(w, \",\")\n\t\t\t}\n\t\t\tfmt.Fprintf(w, \"%d\", label)\n\t\t\tsep = true\n\t\t}\n\t\tfmt.Fprintf(w, \"]\")\n\t\ttimedLog.Infof(\"HTTP batch label-at-point query (%d coordinates)\", len(coords))\n\n\tcase \"blocks\":\n\t\t// GET <api URL>/node/<UUID>/<data name>/blocks/<coord>/<offset>[?compression=...]\n\t\tsizeStr, offsetStr := parts[4], parts[5]\n\n\t\tif throttle := queryStrings.Get(\"throttle\"); throttle == \"on\" || throttle == \"true\" {\n\t\t\tif server.ThrottledHTTP(w) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tdefer server.ThrottledOpDone()\n\t\t}\n\t\tcompression := queryStrings.Get(\"compression\")\n\t\tsubvol, err := dvid.NewSubvolumeFromStrings(offsetStr, sizeStr, \"_\")\n\t\tif err != nil {\n\t\t\tserver.BadRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\n\t\tif subvol.StartPoint().NumDims() != 3 || subvol.Size().NumDims() != 3 {\n\t\t\tserver.BadRequest(w, r, \"must specify 3D subvolumes\", subvol.StartPoint(), subvol.EndPoint())\n\t\t\treturn\n\t\t}\n\n\t\t// Make sure subvolume gets align with blocks\n\t\tif !dvid.BlockAligned(subvol, d.BlockSize()) {\n\t\t\tserver.BadRequest(w, r, \"cannot use labels via 'block' endpoint in non-block aligned geometry %s -> %s\", subvol.StartPoint(), subvol.EndPoint())\n\t\t\treturn\n\t\t}\n\n\t\tif action == \"get\" {\n\t\t\tif err := d.SendBlocks(ctx, w, subvol, compression); err != nil {\n\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttimedLog.Infof(\"HTTP %s: %s (%s)\", r.Method, subvol, r.URL)\n\t\t} else {\n\t\t\tserver.BadRequest(w, r, \"DVID does not accept the %s action on the 'blocks' endpoint\", action)\n\t\t\treturn\n\t\t}\n\n\tcase \"pseudocolor\":\n\t\tif len(parts) < 7 {\n\t\t\tserver.BadRequest(w, r, \"'%s' must be followed by shape/size/offset\", parts[3])\n\t\t\treturn\n\t\t}\n\t\tshapeStr, sizeStr, offsetStr := parts[4], parts[5], parts[6]\n\t\tplaneStr := dvid.DataShapeString(shapeStr)\n\t\tplane, err := planeStr.DataShape()\n\t\tif err != nil {\n\t\t\tserver.BadRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\t\tswitch plane.ShapeDimensions() {\n\t\tcase 2:\n\t\t\tslice, err := dvid.NewSliceFromStrings(planeStr, offsetStr, sizeStr, \"_\")\n\t\t\tif err != nil {\n\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif action != \"get\" {\n\t\t\t\tserver.BadRequest(w, r, \"DVID does not permit 2d mutations, only 3d block-aligned stores\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tlbl, err := d.NewLabels(slice, nil)\n\t\t\tif err != nil {\n\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\timg, err := d.GetImage(ctx.VersionID(), lbl, roiname)\n\t\t\tif err != nil {\n\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Convert to pseudocolor\n\t\t\tpseudoColor, err := colorImage(img)\n\t\t\tif err != nil {\n\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t//dvid.ElapsedTime(dvid.Normal, startTime, \"%s %s upto image formatting\", op, slice)\n\t\t\tvar formatStr string\n\t\t\tif len(parts) >= 8 {\n\t\t\t\tformatStr = parts[7]\n\t\t\t}\n\t\t\terr = dvid.WriteImageHttp(w, pseudoColor, formatStr)\n\t\t\tif err != nil {\n\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttimedLog.Infof(\"HTTP %s: %s (%s)\", r.Method, plane, r.URL)\n\t\tdefault:\n\t\t\tserver.BadRequest(w, r, \"DVID currently supports only 2d pseudocolor image requests\")\n\t\t\treturn\n\t\t}\n\n\tcase \"raw\", \"isotropic\":\n\t\tif len(parts) < 7 {\n\t\t\tserver.BadRequest(w, r, \"'%s' must be followed by shape/size/offset\", parts[3])\n\t\t\treturn\n\t\t}\n\t\tvar isotropic bool = (parts[3] == \"isotropic\")\n\t\tshapeStr, sizeStr, offsetStr := parts[4], parts[5], parts[6]\n\t\tplaneStr := dvid.DataShapeString(shapeStr)\n\t\tplane, err := planeStr.DataShape()\n\t\tif err != nil {\n\t\t\tserver.BadRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\t\tswitch plane.ShapeDimensions() {\n\t\tcase 2:\n\t\t\tslice, err := dvid.NewSliceFromStrings(planeStr, offsetStr, sizeStr, \"_\")\n\t\t\tif err != nil {\n\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif action != \"get\" {\n\t\t\t\tserver.BadRequest(w, r, \"DVID does not permit 2d mutations, only 3d block-aligned stores\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\trawSlice, err := dvid.Isotropy2D(d.Properties.VoxelSize, slice, isotropic)\n\t\t\tlbl, err := d.NewLabels(rawSlice, nil)\n\t\t\tif err != nil {\n\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\timg, err := d.GetImage(ctx.VersionID(), lbl, roiname)\n\t\t\tif err != nil {\n\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif isotropic {\n\t\t\t\tdstW := int(slice.Size().Value(0))\n\t\t\t\tdstH := int(slice.Size().Value(1))\n\t\t\t\timg, err = img.ScaleImage(dstW, dstH)\n\t\t\t\tif err != nil {\n\t\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar formatStr string\n\t\t\tif len(parts) >= 8 {\n\t\t\t\tformatStr = parts[7]\n\t\t\t}\n\t\t\t//dvid.ElapsedTime(dvid.Normal, startTime, \"%s %s upto image formatting\", op, slice)\n\t\t\terr = dvid.WriteImageHttp(w, img.Get(), formatStr)\n\t\t\tif err != nil {\n\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttimedLog.Infof(\"HTTP %s: %s (%s)\", r.Method, plane, r.URL)\n\t\tcase 3:\n\t\t\tif throttle := queryStrings.Get(\"throttle\"); throttle == \"on\" || throttle == \"true\" {\n\t\t\t\tif server.ThrottledHTTP(w) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tdefer server.ThrottledOpDone()\n\t\t\t}\n\t\t\tcompression := queryStrings.Get(\"compression\")\n\t\t\tsubvol, err := dvid.NewSubvolumeFromStrings(offsetStr, sizeStr, \"_\")\n\t\t\tif err != nil {\n\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif action == \"get\" {\n\t\t\t\tlbl, err := d.NewLabels(subvol, nil)\n\t\t\t\tif err != nil {\n\t\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tdata, err := d.GetVolume(ctx.VersionID(), lbl, roiname)\n\t\t\t\tif err != nil {\n\t\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif err := sendBinaryData(compression, data, subvol, w); err != nil {\n\t\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif isotropic {\n\t\t\t\t\tserver.BadRequest(w, r, \"can only POST 'raw' not 'isotropic' images\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\testsize := subvol.NumVoxels() * 8\n\t\t\t\tdata, err := getBinaryData(compression, r.Body, estsize)\n\t\t\t\tif err != nil {\n\t\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tlbl, err := d.NewLabels(subvol, data)\n\t\t\t\tif err != nil {\n\t\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tmutID := d.NewMutationID()\n\t\t\t\tif queryStrings.Get(\"mutate\") == \"true\" {\n\t\t\t\t\tif err = d.MutateVoxels(ctx.VersionID(), mutID, lbl.Voxels, roiname); err != nil {\n\t\t\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif err = d.IngestVoxels(ctx.VersionID(), mutID, lbl.Voxels, roiname); err != nil {\n\t\t\t\t\t\tserver.BadRequest(w, r, err)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Let any synced downres instance that we've completed block-level ops.\n\t\t\t\td.publishDownresCommit(ctx.VersionID(), mutID)\n\t\t\t}\n\t\t\ttimedLog.Infof(\"HTTP %s: %s (%s)\", r.Method, subvol, r.URL)\n\t\tdefault:\n\t\t\tserver.BadRequest(w, r, \"DVID currently supports shapes of only 2 and 3 dimensions\")\n\t\t\treturn\n\t\t}\n\n\tdefault:\n\t\tserver.BadAPIRequest(w, r, d)\n\t}\n\treturn\n}", "title": "" }, { "docid": "818c6d1d887f7a84c55fb43ac0715d88", "score": "0.4042484", "text": "func (*AmazonVpcGroup) PostPath() string {\n\treturn \"/api/objects/amazon_vpc/group/\"\n}", "title": "" }, { "docid": "26b08aca2ba117f515fec3381740fb5a", "score": "0.40286702", "text": "func (*GetGroupResponse) Descriptor() ([]byte, []int) {\n\treturn file_proto_user_center_user_center_proto_rawDescGZIP(), []int{21}\n}", "title": "" }, { "docid": "b61a620685fd1e325f2737d723e11f34", "score": "0.4027595", "text": "func (h *Handle) Update(ctx context.Context, group *ofp.OfpGroupEntry) error {\n\tif err := h.loader.dbProxy.Set(ctx, fmt.Sprint(group.Desc.GroupId), group); err != nil {\n\t\treturn status.Errorf(codes.Internal, \"failed-update-group-%v: %s\", group.Desc.GroupId, err)\n\t}\n\th.chunk.group = group\n\treturn nil\n}", "title": "" }, { "docid": "d2baa1ac49208d9047d61fe313a39bd9", "score": "0.40203106", "text": "func (*SaveGroupPropertiesResponse) Descriptor() ([]byte, []int) {\n\treturn file_configcenter_proto_rawDescGZIP(), []int{6}\n}", "title": "" }, { "docid": "db2d85c0b03261a29503ced13246d4c9", "score": "0.40189254", "text": "func (a *EndpointGroupsApiService) EndpointGroupUpdate(ctx context.Context, id int32, body model.EndpointGroupUpdateRequest) (model.EndpointGroup, *http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = strings.ToUpper(\"Put\")\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue model.EndpointGroup\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/endpoint_groups/{id}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"id\"+\"}\", fmt.Sprintf(\"%v\", id), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{\"application/json\"}\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\t// body params\n\tlocalVarPostBody = &body\n\tif ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {\n\t\t\tvar key string\n\t\t\tif auth.Prefix != \"\" {\n\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t} else {\n\t\t\t\tkey = auth.Key\n\t\t\t}\n\t\t\tlocalVarHeaderParams[\"Authorization\"] = key\n\n\t\t}\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHttpResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHttpResponse == nil {\n\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)\n\tlocalVarHttpResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t}\n\n\tif localVarHttpResponse.StatusCode < 300 {\n\t\t// If we succeed, return the data, otherwise pass on to decode error.\n\t\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\tif err == nil {\n\t\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t\t}\n\t}\n\n\tif localVarHttpResponse.StatusCode >= 300 {\n\t\tnewErr := GenericSwaggerError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHttpResponse.Status,\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 200 {\n\t\t\tvar v model.EndpointGroup\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 400 {\n\t\t\tvar v model.GenericError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 404 {\n\t\t\tvar v model.GenericError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 500 {\n\t\t\tvar v model.GenericError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 503 {\n\t\t\tvar v model.GenericError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t}\n\n\treturn localVarReturnValue, localVarHttpResponse, nil\n}", "title": "" }, { "docid": "61b3093d61223f47d9404c923af22f49", "score": "0.40170312", "text": "func ToServerServerGroupURI(id string) string {\n\treturn app.RootURL + ServerServerGroupBaseURI + \"/\" + id\n}", "title": "" }, { "docid": "f092eb8b867c901909862230ea6251ad", "score": "0.4010304", "text": "func handler(res http.ResponseWriter, r *http.Request) {\r\n\thttpd :=new(HttpData)\r\n\t//get current time\r\n\tt:=time.Now().Format(time.RFC1123)\r\n\thttpd.Time = t\r\n\t//get the complete URL including scheme, host, path, and query\r\n\tpathString:=strings.Join([]string {\"http://\",r.Host},\"\")\r\n\tu,err := url.Parse(pathString)\r\n\tif err != nil {\r\n\t\thttp.Error(res, err.Error(), http.StatusInternalServerError)\r\n return\r\n\t}\r\n\t//get the rawquery\r\n\tu.RawQuery = r.URL.RawQuery\r\n\tu.Path = r.URL.Path\r\n\ts:=u.String()\r\n\t//fmt.Printf(\"Reconstructed Path:%s\",s)\r\n\thttpd.URL = s\r\n //get HTTP method\r\n\thttpd.HTTPMethod = r.Method\r\n //Get Remote Client Address\r\n\thttpd.RemoteAddr = r.RemoteAddr\r\n\t//Get All headers\r\n\thttpd.Header = r.Header\r\n\t// Length of the request body\r\n\thttpd.LengthContent = r.ContentLength\r\n\t//Get Protocol\t\r\n\thttpd.Protocol = r.Proto\r\n\t//Call function to write to database\r\n\t//Database is Cloud MongoDB by mlab, You can Create an Account: https://mlab.com/login\r\n\t\r\n\terr = calldb(httpd)\r\n\tif err!=nil{\r\n\t\thttp.Error(res, err.Error(), http.StatusInternalServerError)\r\n\t\treturn\t}\r\n\tm:=new(message)\r\n\tm.Message=\"DB Operation successful\"\r\n\tj , err := json.Marshal(m)\r\n\t\tif err!=nil{\r\n\t\t\thttp.Error(res, err.Error(), http.StatusInternalServerError)\r\n \treturn\r\n\t\t}\r\n\tres.Write(j)\t\r\n}", "title": "" }, { "docid": "af109fa1897acaae30c0d64d8943a2f6", "score": "0.4007475", "text": "func (client *AlertProcessingRulesClient) listByResourceGroupHandleResponse(resp *http.Response) (AlertProcessingRulesClientListByResourceGroupResponse, error) {\n\tresult := AlertProcessingRulesClientListByResourceGroupResponse{}\n\tif val := resp.Header.Get(\"x-ms-request-id\"); val != \"\" {\n\t\tresult.XMSRequestID = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AlertProcessingRulesList); err != nil {\n\t\treturn AlertProcessingRulesClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "title": "" }, { "docid": "74b47bf696ea1e2616fbc57385a17e2c", "score": "0.4006103", "text": "func (state *RuntimeState) createGrouphandler(w http.ResponseWriter, r *http.Request) {\n\n\tif r.Method != postMethod {\n\t\tstate.writeFailureResponse(w, r, \"POST Method is required\", http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\tusername, err := state.GetRemoteUserName(w, r)\n\tif err != nil {\n\t\treturn\n\t}\n\n\terr = r.ParseForm()\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tif err.Error() == \"missing form body\" {\n\t\t\thttp.Error(w, fmt.Sprint(err), http.StatusBadRequest)\n\t\t} else {\n\t\t\tstate.writeFailureResponse(w, r, fmt.Sprintf(\"Something wrong with internal server.\"), http.StatusInternalServerError)\n\t\t}\n\t\treturn\n\t}\n\tvar groupinfo userinfo.GroupInfo\n\tgroupinfo.Groupname = r.PostFormValue(\"groupname\")\n\tgroupinfo.Description = r.PostFormValue(\"description\")\n\tmembers := r.PostFormValue(\"members\")\n\n\t//check whether the user has the ability to create group\n\tallow, err := state.canPerformAction(username, groupinfo.Groupname, resourceGroup, permCreate)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tstate.writeFailureResponse(w, r, fmt.Sprintf(\"Something wrong with internal server.\"), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tif !allow {\n\t\tstate.writeFailureResponse(w, r, fmt.Sprintf(\"You don't have permission to create group %s\", groupinfo.Groupname), http.StatusForbidden)\n\t\treturn\n\t}\n\n\t//check if the group name already exists or not.\n\tgroupExistsorNot, _, err := state.Userinfo.GroupnameExistsornot(groupinfo.Groupname)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tstate.writeFailureResponse(w, r, fmt.Sprintf(\"Something wrong with internal server.\"), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tif groupExistsorNot {\n\t\thttp.Error(w, fmt.Sprint(\"Groupname already exists! Choose a different one!\"), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t//if the group managed attribute (description) isn't self-managed and thus another groupname. check if that group exists or not\n\tif groupinfo.Description != descriptionAttribute {\n\t\tdescriptiongroupExistsorNot, _, err := state.Userinfo.GroupnameExistsornot(groupinfo.Description)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\tstate.writeFailureResponse(w, r, fmt.Sprintf(\"Something wrong with internal server.\"), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tif !descriptiongroupExistsorNot {\n\t\t\thttp.Error(w, fmt.Sprintf(\"Managed by group doesn't exists! managerGroup='%s'\", groupinfo.Description), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t}\n\n\t//check if all the users to be added exists or not.\n\tfor _, member := range strings.Split(members, \",\") {\n\t\tif len(member) < 1 {\n\t\t\tcontinue\n\t\t}\n\t\tuserExistsorNot, err := state.Userinfo.UsernameExistsornot(member)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\tstate.writeFailureResponse(w, r, fmt.Sprintf(\"Something wrong with internal server.\"), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tif !userExistsorNot {\n\t\t\thttp.Error(w, fmt.Sprintf(\"User %s doesn't exist!\", member), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tgroupinfo.MemberUid = append(groupinfo.MemberUid, member)\n\t}\n\n\terr = state.Userinfo.CreateGroup(groupinfo)\n\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tstate.writeFailureResponse(w, r, fmt.Sprintf(\"error occurred! May be group name exists or may be members are not available!\"), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tif state.sysLog != nil {\n\t\tstate.sysLog.Write([]byte(fmt.Sprintf(\"Group \"+\"%s\"+\" was created by \"+\"%s\", groupinfo.Groupname, username)))\n\n\t\tfor _, member := range strings.Split(members, \",\") {\n\t\t\tstate.sysLog.Write([]byte(fmt.Sprintf(\"%s\"+\" was added to Group \"+\"%s\"+\" by \"+\"%s\", member, groupinfo.Groupname, username)))\n\t\t}\n\t}\n\n\tisAdmin := state.Userinfo.UserisadminOrNot(username)\n\tpageData := simpleMessagePageData{\n\t\tUserName: username,\n\t\tIsAdmin: isAdmin,\n\t\tTitle: \"Group Creation Success\",\n\t\tSuccessMessage: \"Group has been successfully Created\",\n\t}\n\tstate.renderTemplateOrReturnJson(w, r, \"simpleMessagePage\", pageData)\n\n}", "title": "" }, { "docid": "9b2f63de09556a0bfa94775781a9f664", "score": "0.39958018", "text": "func (cmd *DeleteServiceProviderIdpCommand) Run(c *client.Client, args []string) error {\n\tvar path string\n\tif len(args) > 0 {\n\t\tpath = args[0]\n\t} else {\n\t\tpath = \"/saml/idp/services\"\n\t}\n\tvar payload client.DeleteSPPayload\n\tif cmd.Payload != \"\" {\n\t\terr := json.Unmarshal([]byte(cmd.Payload), &payload)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to deserialize payload: %s\", err)\n\t\t}\n\t}\n\tlogger := goa.NewLogger(log.New(os.Stderr, \"\", log.LstdFlags))\n\tctx := goa.WithLogger(context.Background(), logger)\n\tresp, err := c.DeleteServiceProviderIdp(ctx, path, &payload, cmd.ContentType)\n\tif err != nil {\n\t\tgoa.LogError(ctx, \"failed\", \"err\", err)\n\t\treturn err\n\t}\n\n\tgoaclient.HandleResponse(c.Client, resp, cmd.PrettyPrint)\n\treturn nil\n}", "title": "" }, { "docid": "f40d6a365d4834b86ba77825287b68a1", "score": "0.39940998", "text": "func (handler *Detail) Parse(event linebot.Event) error {\n\tid, err := primitive.ObjectIDFromHex(strings.Split(event.Postback.Data, \"|\")[1])\n\tif err != nil {\n\t\tlog.Print(err)\n\t} else {\n\t\thandler.objectID = id\n\t}\n\treturn err\n\n}", "title": "" }, { "docid": "dfc12400ca280780d1cf1a955559666b", "score": "0.3979408", "text": "func (b *DeviceManagementGroupPolicyDefinitionsCollectionRequestBuilder) ID(id string) *GroupPolicyDefinitionRequestBuilder {\n\tbb := &GroupPolicyDefinitionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}\n\tbb.baseURL += \"/\" + id\n\treturn bb\n}", "title": "" }, { "docid": "3beab42dce0c19e770380b09e405c431", "score": "0.39757356", "text": "func (c *ContivClient) PostEndpointGroup(obj *EndpointGroup) error {\n\t// build key and URL\n\tkeyStr := obj.TenantName + \":\" + obj.NetworkName + \":\" + obj.GroupName\n\turl := c.baseURL + \"/api/endpointGroups/\" + keyStr + \"/\"\n\n\t// http post the object\n\terr := httpPost(url, obj)\n\tif err != nil {\n\t\tlog.Errorf(\"Error creating endpointGroup %+v. Err: %v\", obj, err)\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "950db489f6506dad866da5ab41f9123f", "score": "0.39648312", "text": "func (api *API) CreateGroupHandler(ctx context.Context, w http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse) {\n\tbody, err := ioutil.ReadAll(req.Body)\n\tif err != nil {\n\t\treturn nil, handleBodyReadError(ctx, err)\n\t}\n\n\tcreateGroup := models.CreateUpdateGroup{}\n\terr = json.Unmarshal(body, &createGroup)\n\tif err != nil {\n\t\treturn nil, handleBodyUnmarshalError(ctx, err)\n\t}\n\n\t// no groupname in body, set UUID\n\tif createGroup.ID == nil {\n\t\tuuid := uuid.NewString()\n\t\tcreateGroup.ID = &uuid\n\t}\n\n\tcreateGroup.GroupsList, err = api.GetListGroups()\n\tif err != nil {\n\t\tcognitoErr := models.NewCognitoError(ctx, err, \"Cognito ListGroups request from update group endpoint\")\n\t\tif cognitoErr.Code == models.NotFoundError {\n\t\t\treturn nil, models.NewErrorResponse(http.StatusNotFound, nil, cognitoErr)\n\t\t}\n\t\treturn nil, models.NewErrorResponse(http.StatusInternalServerError, nil, cognitoErr)\n\t}\n\n\tvalidationErrs := createGroup.ValidateCreateUpdateGroupRequest(ctx)\n\tif len(validationErrs) != 0 {\n\t\treturn nil, models.NewErrorResponse(http.StatusBadRequest, nil, validationErrs...)\n\t}\n\n\t// build create group input\n\tinput := createGroup.BuildCreateGroupInput(&api.UserPoolId)\n\t_, err = api.CognitoClient.CreateGroup(input)\n\tif err != nil {\n\t\tcognitoErr := models.NewCognitoError(ctx, err, \"Cognito CreateGroup request from create a new group endpoint\")\n\t\tif cognitoErr.Code == models.GroupExistsError {\n\t\t\treturn nil, models.NewErrorResponse(http.StatusBadRequest, nil, cognitoErr)\n\t\t}\n\t\treturn nil, models.NewErrorResponse(http.StatusInternalServerError, nil, cognitoErr)\n\t}\n\n\tjsonResponse, responseErr := createGroup.BuildSuccessfulJsonResponse(ctx)\n\tif responseErr != nil {\n\t\treturn nil, models.NewErrorResponse(http.StatusInternalServerError, nil, responseErr)\n\t}\n\n\treturn createGroup.NewSuccessResponse(jsonResponse, http.StatusCreated, nil), nil\n}", "title": "" }, { "docid": "a56794c15d9b41dab7e4cf2f23790919", "score": "0.39625186", "text": "func (*BatchNewX509SVIDResponse) Descriptor() ([]byte, []int) {\n\treturn file_spire_api_server_svid_v1_svid_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "804c300da8e2bcd34971a84a9b8a0482", "score": "0.39621615", "text": "func (*JoinGroup_Response) Descriptor() ([]byte, []int) {\n\treturn file_server_proto_rawDescGZIP(), []int{4, 1}\n}", "title": "" }, { "docid": "dae053046bd20ee1dfd9ccb956bd706d", "score": "0.39582148", "text": "func (client *PrivateLinkServicesForM365ComplianceCenterClient) listByResourceGroupHandleResponse(resp *http.Response) (PrivateLinkServicesForM365ComplianceCenterClientListByResourceGroupResponse, error) {\n\tresult := PrivateLinkServicesForM365ComplianceCenterClientListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PrivateLinkServicesForM365ComplianceCenterDescriptionListResult); err != nil {\n\t\treturn PrivateLinkServicesForM365ComplianceCenterClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "title": "" }, { "docid": "5691c1927c2f5eb0be95644433e118d6", "score": "0.3957036", "text": "func (rv ResourceVersion) Group() string {\n\tparts := strings.SplitN(string(rv), \"/\", 2)\n\tif len(parts) == 1 {\n\t\treturn \"\"\n\t}\n\treturn parts[0]\n}", "title": "" }, { "docid": "e6ba26464e0ae6f522b820b4f958d502", "score": "0.39551657", "text": "func (a *EndpointGroupsApiService) EndpointGroupDeleteEndpoint(ctx context.Context, id int32, endpointId int32) (*http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = strings.ToUpper(\"Delete\")\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/endpoint_groups/{id}/endpoints/{endpointId}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"id\"+\"}\", fmt.Sprintf(\"%v\", id), -1)\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"endpointId\"+\"}\", fmt.Sprintf(\"%v\", endpointId), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tif ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {\n\t\t\tvar key string\n\t\t\tif auth.Prefix != \"\" {\n\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t} else {\n\t\t\t\tkey = auth.Key\n\t\t\t}\n\t\t\tlocalVarHeaderParams[\"Authorization\"] = key\n\n\t\t}\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlocalVarHttpResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHttpResponse == nil {\n\t\treturn localVarHttpResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)\n\tlocalVarHttpResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarHttpResponse, err\n\t}\n\n\tif localVarHttpResponse.StatusCode >= 300 {\n\t\tnewErr := GenericSwaggerError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHttpResponse.Status,\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 400 {\n\t\t\tvar v model.GenericError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 404 {\n\t\t\tvar v model.GenericError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 500 {\n\t\t\tvar v model.GenericError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHttpResponse, newErr\n\t\t}\n\n\t\treturn localVarHttpResponse, newErr\n\t}\n\n\treturn localVarHttpResponse, nil\n}", "title": "" }, { "docid": "27be493f2b1f753bbb67238cf3c3ae22", "score": "0.39532414", "text": "func (b *DeviceManagementGroupPolicyDefinitionFilesCollectionRequestBuilder) ID(id string) *GroupPolicyDefinitionFileRequestBuilder {\n\tbb := &GroupPolicyDefinitionFileRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}\n\tbb.baseURL += \"/\" + id\n\treturn bb\n}", "title": "" }, { "docid": "6ae28bd320c7b49c835f55840f2c508e", "score": "0.3951038", "text": "func (ds *DoitServer) apiGroupHostVarHandler(w http.ResponseWriter, r *http.Request) {\n\terr := r.ParseForm()\n\tif err != nil {\n\t\tlog.Errorln(\"Unable to parse message\", err)\n\t\tds.ReturnInternalServerError(w, r)\n\t\treturn\n\t}\n\tvars := mux.Vars(r)\n\tdomain := r.Form.Get(\"domain\")\n\treqName := vars[\"name\"]\n\thostName := vars[\"hostName\"]\n\tvarName := vars[\"varName\"]\n\tvalue := vars[\"value\"]\n\n\td, err := ds.DomainCheck(domain)\n\tif err != nil {\n\t\tds.ReturnBadRequest(w, r)\n\t\treturn\n\t}\n\n\tswitch r.Method {\n\tcase \"GET\":\n\t\tg, err := ds.GetGroupByName(d, reqName)\n\t\tif err != nil {\n\t\t\tds.ReturnNotFound(w, r)\n\t\t\treturn\n\t\t}\n\t\tgh, err := ds.GetGroupHostByName(d, g, hostName)\n\t\tif err != nil {\n\t\t\tds.ReturnNotFound(w, r)\n\t\t\treturn\n\t\t}\n\t\terr = ds.ReturnJSON(gh, w, r)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\tcase \"POST\":\n\t\tg, err := ds.GetGroupByName(d, reqName)\n\t\tif err != nil {\n\t\t\tds.ReturnNotFound(w, r)\n\t\t\treturn\n\t\t}\n\t\tgh, err := ds.GetGroupHostByName(d, g, hostName)\n\t\tif err != nil {\n\t\t\tds.ReturnNotFound(w, r)\n\t\t\treturn\n\t\t}\n\t\terr = ds.AddGroupHostVars(d, g, gh, &dt.Var{Name: varName, Value: value, Domain: d, Host: gh, Group: g})\n\t\tif err != nil {\n\t\t\t//TODO: What error to throw here?\n\t\t\tds.ReturnNotFound(w, r)\n\t\t\treturn\n\t\t}\n\t\tds.ReturnOK(w, r)\n\tcase \"PUT\":\n\t\t//TODO: Add group items here\n\t\tds.ReturnNotImplemented(w, r)\n\tcase \"DELETE\":\n\t\tg, err := ds.GetGroupByName(d, reqName)\n\t\tif err != nil {\n\t\t\tds.ReturnNotFound(w, r)\n\t\t\treturn\n\t\t}\n\t\terr = ds.RemoveGroupVars(d, g.ID)\n\t\tif err != nil {\n\t\t\tds.ReturnInternalServerError(w, r)\n\t\t\treturn\n\t\t}\n\t\tds.ReturnOK(w, r)\n\tdefault:\n\t\tds.ReturnNotImplemented(w, r)\n\t}\n}", "title": "" }, { "docid": "4a524484866fe27d5e759ce890b1fd19", "score": "0.3949439", "text": "func (*NetworkDnsGroup) PostPath() string {\n\treturn \"/api/objects/network/dns_group/\"\n}", "title": "" }, { "docid": "ce07bf583ab7405ad9f1f152844e40be", "score": "0.39441913", "text": "func (*BoutiqueGroupResp) Descriptor() ([]byte, []int) {\n\treturn file_caoguo_product_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "5dcd653cd2eb7b1a45b05d4ac1ae73ee", "score": "0.39395264", "text": "func Save(w http.ResponseWriter, r *http.Request) {\n\tdefer r.Body.Close()\n\n\t//\n\tvar paper model.Paper\n\n\t//\n\tif err := json.NewDecoder(r.Body).Decode(&paper); err != nil {\n\t\trespondWithERROR(w, http.StatusBadRequest, \"Invalid request payload.\")\n\t\treturn\n\t}\n\n\t//\n\tidR, err := service.Save(paper)\n\n\t//\n\tif err != nil {\n\t\trespondWithERROR(w, http.StatusInternalServerError, err.Error())\n\t\treturn\n\t}\n\n\t//\n\trespondWithJSON(w, http.StatusOK, map[string]string{\"id\": idR.Hex()})\n}", "title": "" }, { "docid": "ef157eb1abe41915ddc116cddd4f645a", "score": "0.39289877", "text": "func SvcFormHandlerAR(w http.ResponseWriter, r *http.Request, d *ServiceData) {\n\tconst funcname = \"SvcFormHandlerAR\"\n\tvar (\n\t\terr error\n\t)\n\tfmt.Printf(\"Entered %s\\n\", funcname)\n\tif d.ARID, err = SvcExtractIDFromURI(r.RequestURI, \"ARID\", 3, w); err != nil {\n\t\tSvcErrorReturn(w, err, funcname)\n\t\treturn\n\t}\n\n\tfmt.Printf(\"Request: %s: BID = %d, ID = %d\\n\", d.wsSearchReq.Cmd, d.BID, d.ARID)\n\n\tswitch d.wsSearchReq.Cmd {\n\tcase \"get\":\n\t\tgetARForm(w, r, d)\n\t\tbreak\n\tcase \"save\":\n\t\tsaveARForm(w, r, d)\n\t\tbreak\n\tcase \"delete\":\n\t\tdeleteARForm(w, r, d)\n\t\tbreak\n\tdefault:\n\t\terr = fmt.Errorf(\"Unhandled command: %s\", d.wsSearchReq.Cmd)\n\t\tSvcErrorReturn(w, err, funcname)\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "93bdc603b8ae00e8e7bf619433dec4ce", "score": "0.3928718", "text": "func (*SslVpnGroups) GetPath() string { return \"/api/objects/ssl_vpn/group/\" }", "title": "" }, { "docid": "f5f536ef18f3c21b9be52fbf1c336e64", "score": "0.39281997", "text": "func (*ReverseProxyGroups) GetPath() string { return \"/api/objects/reverse_proxy/group/\" }", "title": "" }, { "docid": "6e1f92215278ec6a7f2ad00fa10c07e6", "score": "0.39232737", "text": "func (*GetGroupResponse) Descriptor() ([]byte, []int) {\n\treturn file_configcenter_proto_rawDescGZIP(), []int{1}\n}", "title": "" }, { "docid": "68cbf17f3056bfc786c49f01ea240da1", "score": "0.39215982", "text": "func (ds *discoverySummarizerServer) summarizeLegacyVersionsHandler(path string) func(http.ResponseWriter, *http.Request) {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tif len(ds.legacyVersionPaths[path]) > 1 {\n\t\t\terr := fmt.Errorf(\"invalid multiple servers serving legacy group %v\", ds.legacyVersionPaths[path])\n\t\t\tds.writeErr(http.StatusInternalServerError, err, w)\n\t\t}\n\t\tserverAddress := ds.legacyVersionPaths[path][0]\n\t\tapiVersions, err := ds.getAPIVersions(serverAddress + path)\n\t\tif err != nil {\n\t\t\tds.writeErr(http.StatusBadGateway, err, w)\n\t\t\treturn\n\t\t}\n\t\tds.writeRawJSON(http.StatusOK, apiVersions, w)\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "0df2f3f458d3dc68d9014af2a3dbbb8a", "score": "0.39212838", "text": "func (*AddGroupResponse) Descriptor() ([]byte, []int) {\n\treturn file_rotation_service_proto_rawDescGZIP(), []int{16}\n}", "title": "" }, { "docid": "84fb6ed2cb549208f909e4f582c1478d", "score": "0.39209282", "text": "func (a *Apis) handleKind(rootPath string, k kind.Kind) {\n\t//pathWId := joinPath(\"/\", rootPath, \"{id}\")\n\n\t// QUERY\n\t/*a.Handle(rootPath, serve(func(w http.ResponseWriter, r *http.Request) {\n\t\tif ctx, ok := a.NewContext(w, r, k.Scopes(ReadOnly, ReadWrite, FullControl)...); ok {\n\n\t\t}\n\t})).Methods(http.MethodGet, http.MethodOptions)*/\n\n\t// GET\n\t/*a.Handle(pathWId, serve(func(w http.ResponseWriter, r *http.Request) {\n\t\tif ctx, ok := a.NewContext(w, r, k.Scopes(ReadOnly, ReadWrite, FullControl)...); ok {\n\t\t\tif id, ok := mux.Vars(r)[\"id\"]; ok {\n\t\t\t\tkey, err := datastore.DecodeKey(id)\n\t\t\t\tif err != nil {\n\t\t\t\t\tkey = datastore.NewKey(ctx, k.Name(), id, 0, nil)\n\t\t\t\t}\n\t\t\t\tdoc, err := k.Doc(ctx, key).Get()\n\t\t\t\tif err != nil {\n\t\t\t\t\tctx.PrintError(err.Error(), http.StatusInternalServerError)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tctx.PrintJSON(k.Data(doc), http.StatusOK)\n\t\t\t}\n\t\t}\n\t})).Methods(http.MethodGet, http.MethodOptions)\n\n\t// POST\n\ta.Handle(rootPath, serve(func(w http.ResponseWriter, r *http.Request) {\n\t\tif ctx, ok := a.NewContext(w, r, k.Scopes(ReadWrite, FullControl)...); ok {\n\t\t\tdoc, err := k.Doc(ctx, nil).Add(ctx.Body())\n\t\t\tif err != nil {\n\t\t\t\tctx.PrintError(err.Error(), http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tctx.PrintJSON(k.Data(doc), http.StatusOK)\n\t\t}\n\t})).Methods(http.MethodPost, http.MethodOptions)\n\n\t// POST TO GROUP\n\ta.Handle(pathWId, serve(func(w http.ResponseWriter, r *http.Request) {\n\t\tif ctx, ok := a.NewContext(w, r, k.Scopes(ReadWrite, FullControl)...); ok {\n\t\t\tdoc, err := k.Doc(ctx, nil).Add(ctx.Body())\n\t\t\tif err != nil {\n\t\t\t\tctx.PrintError(err.Error(), http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tctx.PrintJSON(k.Data(doc), http.StatusOK)\n\t\t}\n\t})).Methods(http.MethodPost, http.MethodOptions)\n\n\t// PUT\n\ta.Handle(pathWId, serve(func(w http.ResponseWriter, r *http.Request) {\n\t\tif ctx, ok := a.NewContext(w, r, k.Scopes(ReadWrite, FullControl)...); ok {\n\t\t\tif id, ok := mux.Vars(r)[\"id\"]; ok {\n\t\t\t\tkey, err := datastore.DecodeKey(id)\n\t\t\t\tif err != nil {\n\t\t\t\t\tkey = datastore.NewKey(ctx, k.Name(), id, 0, nil)\n\t\t\t\t}\n\t\t\t\tdoc, err := k.Doc(ctx, key).Set(ctx.Body())\n\t\t\t\tif err != nil {\n\t\t\t\t\tctx.PrintError(err.Error(), http.StatusInternalServerError)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tctx.PrintJSON(k.Data(doc), http.StatusOK)\n\t\t\t}\n\t\t}\n\t})).Methods(http.MethodPut, http.MethodOptions)*/\n\n\t/*\n\t\t// GET with path\n\t\ta.Handle(joinPath(k.Path, \"{key}\", `{path:[a-zA-Z0-9=\\-\\/]+}`), serve(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tctx, err := a.NewContext(w, r)\n\t\t\tif err != nil {\n\t\t\t\tctx.PrintError(err.Error(), http.StatusForbidden)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif ok := ctx.HasScope(k.Rules(ReadOnly, ReadWrite, FullControl)...); ok {\n\t\t\t\tvar key *datastore.Key\n\t\t\t\tvar path []string\n\t\t\t\tvars := mux.Vars(r)\n\t\t\t\tif encodedKey, ok := vars[\"key\"]; ok {\n\t\t\t\t\tif key, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif _path, ok := vars[\"path\"]; ok {\n\t\t\t\t\tpath = strings.Split(_path, \"/\")\n\t\t\t\t}\n\t\t\t\tk.GetHandler(ctx, key, path...)\n\t\t\t} else {\n\t\t\t\tctx.PrintError(http.StatusText(http.StatusForbidden), http.StatusForbidden)\n\t\t\t}\n\t\t})).Methods(http.MethodGet, http.MethodOptions)\n\n\t\t// PUT\n\t\ta.Handle(joinPath(k.Path, \"{key}\"), serve(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tctx, err := a.NewContext(w, r)\n\t\t\tif err != nil {\n\t\t\t\tctx.PrintError(err.Error(), http.StatusForbidden)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif ok := ctx.HasScope(k.Rules(ReadWrite, FullControl)...); ok {\n\t\t\t\tvar key *datastore.Key\n\t\t\t\tvars := mux.Vars(r)\n\t\t\t\tif encodedKey, ok := vars[\"key\"]; ok {\n\t\t\t\t\tif key, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tk.PutHandler(ctx, key)\n\t\t\t} else {\n\t\t\t\tctx.PrintError(http.StatusText(http.StatusForbidden), http.StatusForbidden)\n\t\t\t}\n\t\t})).Methods(http.MethodPut, http.MethodOptions)\n\n\t\t// PUT with path\n\t\ta.Handle(joinPath(k.Path, \"{key}\", `{path:[a-zA-Z0-9=\\-\\/]+}`), serve(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tctx, err := a.NewContext(w, r)\n\t\t\tif err != nil {\n\t\t\t\tctx.PrintError(err.Error(), http.StatusForbidden)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif ok := ctx.HasScope(k.Rules(ReadWrite, FullControl)...); ok {\n\t\t\t\tvar key *datastore.Key\n\t\t\t\tvar path []string\n\t\t\t\tvars := mux.Vars(r)\n\t\t\t\tif encodedKey, ok := vars[\"key\"]; ok {\n\t\t\t\t\tif key, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif _path, ok := vars[\"path\"]; ok {\n\t\t\t\t\tpath = strings.Split(_path, \"/\")\n\t\t\t\t}\n\t\t\t\tk.PutHandler(ctx, key, path...)\n\t\t\t} else {\n\t\t\t\tctx.PrintError(http.StatusText(http.StatusForbidden), http.StatusForbidden)\n\t\t\t}\n\t\t})).Methods(http.MethodPut, http.MethodOptions)\n\n\t\t// PATCH\n\t\ta.Handle(joinPath(k.Path, \"{key}\"), serve(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tctx, err := a.NewContext(w, r)\n\t\t\tif err != nil {\n\t\t\t\tctx.PrintError(err.Error(), http.StatusForbidden)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif ok := ctx.HasScope(k.Rules(ReadWrite, FullControl)...); ok {\n\t\t\t\tvar key *datastore.Key\n\t\t\t\tvars := mux.Vars(r)\n\t\t\t\tif encodedKey, ok := vars[\"key\"]; ok {\n\t\t\t\t\tif key, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tk.PatchHandler(ctx, key)\n\t\t\t} else {\n\t\t\t\tctx.PrintError(http.StatusText(http.StatusForbidden), http.StatusForbidden)\n\t\t\t}\n\t\t})).Methods(http.MethodPatch, http.MethodOptions)\n\n\t\t// DELETE\n\t\ta.Handle(joinPath(k.Path, \"{key}\"), serve(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tctx, err := a.NewContext(w, r)\n\t\t\tif err != nil {\n\t\t\t\tctx.PrintError(err.Error(), http.StatusForbidden)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif ok := ctx.HasScope(k.Rules(Delete, FullControl)...); ok {\n\t\t\t\tvar key *datastore.Key\n\t\t\t\tvars := mux.Vars(r)\n\t\t\t\tif encodedKey, ok := vars[\"key\"]; ok {\n\t\t\t\t\tif key, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tk.DeleteHandler(ctx, key)\n\t\t\t} else {\n\t\t\t\tctx.PrintError(http.StatusText(http.StatusForbidden), http.StatusForbidden)\n\t\t\t}\n\t\t})).Methods(http.MethodDelete, http.MethodOptions)\n\n\t\t// DELETE with path\n\t\ta.Handle(joinPath(k.Path, \"{key}\", `{path:[a-zA-Z0-9=\\-\\/]+}`), serve(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tctx, err := a.NewContext(w, r)\n\t\t\tif err != nil {\n\t\t\t\tctx.PrintError(err.Error(), http.StatusForbidden)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif ok := ctx.HasScope(k.Rules(Delete, FullControl)...); ok {\n\t\t\t\tvar key *datastore.Key\n\t\t\t\tvar path []string\n\t\t\t\tvars := mux.Vars(r)\n\t\t\t\tif encodedKey, ok := vars[\"key\"]; ok {\n\t\t\t\t\tif key, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif _path, ok := vars[\"path\"]; ok {\n\t\t\t\t\tpath = strings.Split(_path, \"/\")\n\t\t\t\t}\n\t\t\t\tk.DeleteHandler(ctx, key, path...)\n\t\t\t} else {\n\t\t\t\tctx.PrintError(http.StatusText(http.StatusForbidden), http.StatusForbidden)\n\t\t\t}\n\t\t})).Methods(http.MethodDelete, http.MethodOptions)\n\n\t\t// COLLECTIONS\n\n\t\t// QUERY\n\t\ta.collectionRouter.Handle(joinPath(k.Path), serve(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tctx, err := a.NewContext(w, r)\n\t\t\tif err != nil {\n\t\t\t\tctx.PrintError(err.Error(), http.StatusForbidden)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tvar collectionKey *datastore.Key\n\t\t\tvars := mux.Vars(r)\n\t\t\tif encodedKey, ok := vars[\"collection\"]; ok {\n\t\t\t\tif collectionKey, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ctx, ok := CheckCollectionAccess(ctx, collectionKey, ReadOnly, ReadWrite, FullControl); ok {\n\t\t\t\tgroupKind := a.kinds[collectionKey.Kind()]\n\t\t\t\tif ok := ctx.HasScope(groupKind.Rules(k.Rules(ReadOnly, ReadWrite, FullControl)...)...); ok {\n\t\t\t\t\tk.QueryHandler(ctx)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.PrintError(http.StatusText(http.StatusForbidden), http.StatusForbidden)\n\t\t})).Methods(http.MethodGet, http.MethodOptions)\n\n\t\t// POST\n\t\ta.collectionRouter.Handle(joinPath(k.Path), serve(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tctx, err := a.NewContext(w, r)\n\t\t\tif err != nil {\n\t\t\t\tctx.PrintError(err.Error(), http.StatusForbidden)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tvar collectionKey *datastore.Key\n\t\t\tvars := mux.Vars(r)\n\t\t\tif encodedKey, ok := vars[\"collection\"]; ok {\n\t\t\t\tif collectionKey, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ctx, ok := CheckCollectionAccess(ctx, collectionKey, ReadWrite, FullControl); ok {\n\t\t\t\tgroupKind := a.kinds[collectionKey.Kind()]\n\t\t\t\tif ok := ctx.HasScope(groupKind.Rules(k.Rules(ReadWrite, FullControl)...)...); ok {\n\t\t\t\t\tk.PostHandler(ctx, nil)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.PrintError(http.StatusText(http.StatusForbidden), http.StatusForbidden)\n\t\t})).Methods(http.MethodPost, http.MethodOptions)\n\n\t\t// GET\n\t\ta.collectionRouter.Handle(joinPath(k.Path, \"{key}\"), serve(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tctx, err := a.NewContext(w, r)\n\t\t\tif err != nil {\n\t\t\t\tctx.PrintError(err.Error(), http.StatusForbidden)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tvar collectionKey *datastore.Key\n\t\t\tvars := mux.Vars(r)\n\t\t\tif encodedKey, ok := vars[\"collection\"]; ok {\n\t\t\t\tif collectionKey, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ctx, ok := CheckCollectionAccess(ctx, collectionKey, ReadOnly, ReadWrite, FullControl); ok {\n\t\t\t\tvar key *datastore.Key\n\t\t\t\tvars := mux.Vars(r)\n\t\t\t\tif encodedKey, ok := vars[\"key\"]; ok {\n\t\t\t\t\tif key, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tgroupKind := a.kinds[collectionKey.Kind()]\n\t\t\t\tif ok := ctx.HasScope(groupKind.Rules(k.Rules(ReadOnly, ReadWrite, FullControl)...)...); ok {\n\t\t\t\t\tk.GetHandler(ctx, key)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.PrintError(http.StatusText(http.StatusForbidden), http.StatusForbidden)\n\t\t})).Methods(http.MethodGet, http.MethodOptions)\n\n\t\t// GET with path\n\t\ta.collectionRouter.Handle(joinPath(k.Path, \"{key}\", `{path:[a-zA-Z0-9=\\-\\/]+}`), serve(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tctx, err := a.NewContext(w, r)\n\t\t\tif err != nil {\n\t\t\t\tctx.PrintError(err.Error(), http.StatusForbidden)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tvar collectionKey *datastore.Key\n\t\t\tvars := mux.Vars(r)\n\t\t\tif encodedKey, ok := vars[\"collection\"]; ok {\n\t\t\t\tif collectionKey, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ctx, ok := CheckCollectionAccess(ctx, collectionKey, ReadOnly, ReadWrite, FullControl); ok {\n\t\t\t\tvar key *datastore.Key\n\t\t\t\tvar path []string\n\t\t\t\tvars := mux.Vars(r)\n\t\t\t\tif encodedKey, ok := vars[\"key\"]; ok {\n\t\t\t\t\tif key, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif _path, ok := vars[\"path\"]; ok {\n\t\t\t\t\tpath = strings.Split(_path, \"/\")\n\t\t\t\t}\n\t\t\t\tgroupKind := a.kinds[collectionKey.Kind()]\n\t\t\t\tif ok := ctx.HasScope(groupKind.Rules(k.Rules(ReadOnly, ReadWrite, FullControl)...)...); ok {\n\t\t\t\t\tk.GetHandler(ctx, key, path...)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.PrintError(http.StatusText(http.StatusForbidden), http.StatusForbidden)\n\t\t})).Methods(http.MethodGet, http.MethodOptions)\n\n\t\t// PUT\n\t\ta.collectionRouter.Handle(joinPath(k.Path, \"{key}\"), serve(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tctx, err := a.NewContext(w, r)\n\t\t\tif err != nil {\n\t\t\t\tctx.PrintError(err.Error(), http.StatusForbidden)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tvar collectionKey *datastore.Key\n\t\t\tvars := mux.Vars(r)\n\t\t\tif encodedKey, ok := vars[\"collection\"]; ok {\n\t\t\t\tif collectionKey, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ctx, ok := CheckCollectionAccess(ctx, collectionKey, ReadWrite, FullControl); ok {\n\t\t\t\tvar key *datastore.Key\n\t\t\t\tvars := mux.Vars(r)\n\t\t\t\tif encodedKey, ok := vars[\"key\"]; ok {\n\t\t\t\t\tif key, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tgroupKind := a.kinds[collectionKey.Kind()]\n\t\t\t\tif ok := ctx.HasScope(groupKind.Rules(k.Rules(ReadWrite, FullControl)...)...); ok {\n\t\t\t\t\tk.PutHandler(ctx, key)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.PrintError(http.StatusText(http.StatusForbidden), http.StatusForbidden)\n\t\t})).Methods(http.MethodPut, http.MethodOptions)\n\n\t\t// PUT with path\n\t\ta.collectionRouter.Handle(joinPath(k.Path, \"{key}\", `{path:[a-zA-Z0-9=\\-\\/]+}`), serve(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tctx, err := a.NewContext(w, r)\n\t\t\tif err != nil {\n\t\t\t\tctx.PrintError(err.Error(), http.StatusForbidden)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tvar collectionKey *datastore.Key\n\t\t\tvars := mux.Vars(r)\n\t\t\tif encodedKey, ok := vars[\"collection\"]; ok {\n\t\t\t\tif collectionKey, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ctx, ok := CheckCollectionAccess(ctx, collectionKey, ReadWrite, FullControl); ok {\n\t\t\t\tvar key *datastore.Key\n\t\t\t\tvar path []string\n\t\t\t\tvars := mux.Vars(r)\n\t\t\t\tif encodedKey, ok := vars[\"key\"]; ok {\n\t\t\t\t\tif key, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif _path, ok := vars[\"path\"]; ok {\n\t\t\t\t\tpath = strings.Split(_path, \"/\")\n\t\t\t\t}\n\n\t\t\t\tgroupKind := a.kinds[collectionKey.Kind()]\n\t\t\t\tif ok := ctx.HasScope(groupKind.Rules(k.Rules(ReadWrite, FullControl)...)...); ok {\n\t\t\t\t\tk.PutHandler(ctx, key, path...)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.PrintError(http.StatusText(http.StatusForbidden), http.StatusForbidden)\n\t\t})).Methods(http.MethodPut, http.MethodOptions)\n\n\t\t// DELETE\n\t\ta.collectionRouter.Handle(joinPath(k.Path, \"{key}\"), serve(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tctx, err := a.NewContext(w, r)\n\t\t\tif err != nil {\n\t\t\t\tctx.PrintError(err.Error(), http.StatusForbidden)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tvar collectionKey *datastore.Key\n\t\t\tvars := mux.Vars(r)\n\t\t\tif encodedKey, ok := vars[\"collection\"]; ok {\n\t\t\t\tif collectionKey, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ctx, ok := CheckCollectionAccess(ctx, collectionKey, Delete, FullControl); ok {\n\t\t\t\tvar key *datastore.Key\n\t\t\t\tvars := mux.Vars(r)\n\t\t\t\tif encodedKey, ok := vars[\"key\"]; ok {\n\t\t\t\t\tif key, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tgroupKind := a.kinds[collectionKey.Kind()]\n\t\t\t\tif ok := ctx.HasScope(groupKind.Rules(k.Rules(Delete, FullControl)...)...); ok {\n\t\t\t\t\tk.DeleteHandler(ctx, key)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.PrintError(http.StatusText(http.StatusForbidden), http.StatusForbidden)\n\t\t})).Methods(http.MethodDelete, http.MethodOptions)\n\n\t\t// DELETE with path\n\t\ta.collectionRouter.Handle(joinPath(k.Path, \"{key}\", `{path:[a-zA-Z0-9=\\-\\/]+}`), serve(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tctx, err := a.NewContext(w, r)\n\t\t\tif err != nil {\n\t\t\t\tctx.PrintError(err.Error(), http.StatusForbidden)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tvar collectionKey *datastore.Key\n\t\t\tvars := mux.Vars(r)\n\t\t\tif encodedKey, ok := vars[\"collection\"]; ok {\n\t\t\t\tif collectionKey, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ctx, ok := CheckCollectionAccess(ctx, collectionKey, Delete, FullControl); ok {\n\t\t\t\tvar key *datastore.Key\n\t\t\t\tvar path []string\n\t\t\t\tvars := mux.Vars(r)\n\t\t\t\tif encodedKey, ok := vars[\"key\"]; ok {\n\t\t\t\t\tif key, err = datastore.DecodeKey(encodedKey); err != nil {\n\t\t\t\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif _path, ok := vars[\"path\"]; ok {\n\t\t\t\t\tpath = strings.Split(_path, \"/\")\n\t\t\t\t}\n\n\t\t\t\tgroupKind := a.kinds[collectionKey.Kind()]\n\t\t\t\tif ok := ctx.HasScope(groupKind.Rules(k.Rules(Delete, FullControl)...)...); ok {\n\t\t\t\t\tk.DeleteHandler(ctx, key, path...)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.PrintError(http.StatusText(http.StatusForbidden), http.StatusForbidden)\n\t\t})).Methods(http.MethodDelete, http.MethodOptions)*/\n}", "title": "" }, { "docid": "888e5ec950f5fa45af5a38ebde13c4df", "score": "0.3915709", "text": "func (a *IamApiService) DeleteIamIdpExecute(r ApiDeleteIamIdpRequest) (*http.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = http.MethodDelete\n\t\tlocalVarPostBody interface{}\n\t\tformFiles []formFile\n\t)\n\n\tlocalBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, \"IamApiService.DeleteIamIdp\")\n\tif err != nil {\n\t\treturn nil, &GenericOpenAPIError{error: err.Error()}\n\t}\n\n\tlocalVarPath := localBasePath + \"/api/v1/iam/Idps/{Moid}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"Moid\"+\"}\", url.PathEscape(parameterToString(r.moid, \"\")), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)\n\tif localVarHTTPContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHTTPContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHTTPHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\n\tif localVarHTTPHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHTTPHeaderAccept\n\t}\n\treq, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := a.client.callAPI(req)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\n\tlocalVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))\n\tif err != nil {\n\t\treturn localVarHTTPResponse, err\n\t}\n\n\tif localVarHTTPResponse.StatusCode >= 300 {\n\t\tnewErr := &GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHTTPResponse.Status,\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 400 {\n\t\t\tvar v Error\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 401 {\n\t\t\tvar v Error\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 403 {\n\t\t\tvar v Error\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 404 {\n\t\t\tvar v Error\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHTTPResponse, newErr\n\t\t}\n\t\tvar v Error\n\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\tif err != nil {\n\t\t\tnewErr.error = err.Error()\n\t\t\treturn localVarHTTPResponse, newErr\n\t\t}\n\t\tnewErr.model = v\n\t\treturn localVarHTTPResponse, newErr\n\t}\n\n\treturn localVarHTTPResponse, nil\n}", "title": "" }, { "docid": "6f5fca97dfad1543c9e7e60c2f663d60", "score": "0.38998097", "text": "func (gm *GMServ) GroupAuthUpdateHandler(ws *websocket.Conn) {\n\tlw.Debug(\"In GroupAuthUpdateHandler()\")\n\n\t// gob decoding\n\tvar ga gmcom.GroupAuthD\n\tvar msg = make([]byte, 1024)\n\tl, err := ws.Read(msg)\n\tif err != nil {\n\t\tlw.ErrorWithPrefixString(\"GroupAuthUpdateHandler() ws.Read() error:\", err)\n\t\treturn\n\t}\n\traw := msg[0:l]\n\tdecBuf := bytes.NewBuffer(raw)\n\terr = gob.NewDecoder(decBuf).Decode(&ga)\n\tif err != nil {\n\t\tlw.ErrorWithPrefixString(\"GroupAuthUpdateHandler() gob.Decode() error:\", err)\n\t\treturn\n\t}\n\n\t// lookup the groupName and authName\n\tga.GroupName = gm.UsrGroupsH.GroupNames[ga.GroupID]\n\tga.AuthName = gm.AuthsH.Auths[ga.AuthID]\n\tif ga.GroupName == \"\" || ga.AuthName == \"\" {\n\t\tlw.Warning(\"GroupAuthUpdateHandler() could not update with GroupName: %s and AuthName: %s\", ga.GroupName, ga.AuthName)\n\t\treturn\n\t}\n\n\t// update the local server's GroupAuths cache (map)\n\tswitch ga.Op {\n\tcase gmcom.COpCreate, gmcom.COpUpdate:\n\t\t// do the local cache update\n\t\tgm.GroupAuthsH.Lock()\n\t\tmapAuth := gm.GroupAuthsH.GroupAuths[ga.GroupName]\n\t\tif mapAuth == nil {\n\t\t\tmapAuth = make(map[string]bool)\n\t\t\tmapAuth[ga.AuthName] = true\n\t\t\tgm.GroupAuthsH.GroupAuths[ga.GroupName] = mapAuth\n\t\t} else {\n\t\t\t// if the groupName does exist in the top-level map, add the auth to\n\t\t\t// the group's auth map.\n\t\t\tmapAuth[ga.AuthName] = true\n\t\t}\n\n\t\tgm.GroupAuthsH.GroupAuthsID[ga.ID] = gmcom.GroupAuthNames{GroupName: ga.GroupName, AuthName: ga.AuthName}\n\t\tgm.GroupAuthsH.Unlock()\n\n\tcase gmcom.COpDelete:\n\t\tgm.GroupAuthsH.Lock()\n\t\tmapAuth := gm.GroupAuthsH.GroupAuths[ga.GroupName]\n\t\tif mapAuth != nil {\n\t\t\tdelete(mapAuth, ga.AuthName)\n\t\t}\n\t\tdelete(gm.GroupAuthsH.GroupAuthsID, ga.ID)\n\t\tgm.GroupAuthsH.Unlock()\n\n\tdefault:\n\t\t// do nothing\n\t}\n\n\t// send to other group members?\n\tif !ga.Forward {\n\t\tws.Write([]byte(\"true\"))\n\t\treturn\n\t}\n\tga.Forward = false\n\n\t// send the update to all non-failed processes in the process group\n\t// get a list of the active processes (this is inherently stale)\n\tm := gm.SendGetLocalDetails()\n\tif m == nil {\n\t\tlw.Warning(\"Failed to read groupauth cache group server details in SendGetLocalDetails()\")\n\t\tws.Write([]byte(\"false\"))\n\t}\n\n\t// send process-id/article-key to group members\n\tr := m.MemberMap.ReadActiveProcessList()\n\tfor _, g := range r {\n\t\tif g.ID == gm.MyID {\n\t\t\tcontinue\n\t\t}\n\t\tlw.Info(\"CS: SENDING %v to %s\", ga, g.IPAddress)\n\t\terr := gmcl.AddUpdGroupAuthCache(ga, g.IPAddress) //TODO go()\n\t\tif err != nil {\n\t\t\tlw.ErrorWithPrefixString(\"wscl.AddUpdGroupAuthCache() error:\", err)\n\t\t}\n\t}\n\tws.Write([]byte(\"true\"))\n}", "title": "" }, { "docid": "2d64dec55395f3fbcca9d1b83b4f23b1", "score": "0.38975245", "text": "func getSigsGroup(fimg *sif.FileImage, id uint32) (sigs []*sif.Descriptor, descr []*sif.Descriptor, err error) {\n\t// find descriptors that are part of a signing group\n\tsearch := sif.Descriptor{\n\t\tGroupid: id | sif.DescrGroupMask,\n\t}\n\tdescr, _, err = fimg.GetFromDescr(search)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"no descriptors found for groupid %v\", id)\n\t}\n\n\t// find signature blocks pointing to specified group\n\tsearch = sif.Descriptor{\n\t\tDatatype: sif.DataSignature,\n\t\tLink: id | sif.DescrGroupMask,\n\t}\n\tsigs, _, err = fimg.GetFromDescr(search)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"no signatures found for groupid %v\", id)\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "db646833c950f64a6ffa3bf274bff1d3", "score": "0.3891058", "text": "func queueAddToSid(w http.ResponseWriter, r *http.Request) {\n //c := appengine.NewContext(r)\n c, cancel := context.WithCancel(context.Background())\n defer cancel()\n _, _, val := cloudTaskHandler(w,r)\n //log.Printf(\"queueInsertUnknownRule executed: queueName(%v), taskName(%v)\", queueName, taskName)\n //ATS_FUNC := r.FormValue(\"ATS_FUNC\")\n ATS_FUNC := val[\"ATS_FUNC\"].(string)\n //UID := r.FormValue(\"UID\")\n UID := val[\"UID\"].(string)\n //SID := r.FormValue(\"SID\")\n SID := val[\"SID\"].(string)\n //TYP := r.FormValue(\"TYP\")\n TYP := val[\"TYP\"].(string)\n //SRC := r.FormValue(\"SRC\")\n SRC := val[\"SRC\"].(string)\n //CAPTION := r.FormValue(\"TITLE\")\n CAPTION := val[\"TITLE\"].(string)\n \n\tSPL := strings.Split(SID,\"-\")\n\tTARGET := SPL[0]\n\tDOC_ID := \"0\"\n\tif len(SPL) > 1 {\n\t\tDOC_ID = SPL[1]\n\t}\n\tdocID := str2int(DOC_ID)\n\t\n\tBLOB_KEY := \"\"\n\t//TITLE := \"\"\n \n\tDOC_STAT := \"\"\n\tFL_SHARED := \"\"\n\tAUTHOR := \"\"\n\tcsn := \"\"\n\n\tswitch TARGET {\n\t\tcase \"TDSSLIDE\":\n\t\t\tBLOB_KEY, DOC_STAT, FL_SHARED, AUTHOR, _, _, _, _, _, _ = getTDSSLIDEBlobKey(w, r, docID)\n\t\t\t//upload url\n\t\t\tcsn = getUpUrlString(w,r,\"/upload-slides\")\n\t\t\n\t\tcase \"TDSARTL\":\n\t\t\n\t\t\tBLOB_KEY, DOC_STAT, FL_SHARED, AUTHOR, _, _, _, _, _ = getTDSARTLBlobKey(w, r, docID)\n\t\t\t\n\t\tcase \"TDSMEDIA\":\n\t\t\tBLOB_KEY, _, _, AUTHOR, DOC_STAT, FL_SHARED, _, _, _, _, _ = getTDSMEDIABlobKey(w, r, docID)\n\t}\n \n\tswitch {\n \n\t\tcase DOC_STAT == \"Premium\" && UID != AUTHOR:\n\t\t\t//dont process\n\t\t\treturn\n\t\n\t\tcase FL_SHARED == \"N\" || DOC_STAT == \"Personal\" || (FL_SHARED == \"Y\" && DOC_STAT == \"Personal\"):\n\t\t\tFUNC_CODE := \"GET_GRP_ID\"\n\t\t\tFL_VALID_USER, _, _ , _ := usersProcessor(w, r, \"au\", UID, FUNC_CODE)\n\t\t\t\n \n\t\t\t\n\t\t\tif FL_VALID_USER != true {\n\t\t\t\t//dont process\n\t\t\t\treturn\n\t\t\t}\n\t\t\t\n\t\t\tif UID != AUTHOR {\n\t\t\t\t//dont process\n\t\t\t\treturn\n\t\t\t}\n\t\t\t\n\t\tcase DOC_STAT == \"ULAPPH Only\":\n\t\t\tFUNC_CODE := \"GET_GRP_ID\"\n\t\t\tFL_VALID_USER, _, _ , _ := usersProcessor(w, r, \"au\", UID, FUNC_CODE)\n\t\t\t\n\t\t\tif FL_VALID_USER != true {\n\t\t\t\t//dont process\n\t\t\t\treturn\n\t\t\t}\n \n\t\tcase DOC_STAT == \"Worldwide\" && FL_SHARED == \"Y\":\n\t\t\t//allow\n\t\t\n\t}\n\t\n\t//current text\n\tblobChan := make(chan string)\n\tgo getBlobTextChan(w, r,blobChan, BLOB_KEY)\n\tthisCont := <- blobChan\n \n\tvar buf bytes.Buffer\n\tbuf.WriteString(fmt.Sprintf(\"%v\", thisCont))\n\tbuf.WriteString(fmt.Sprintf(\" \\n\"))\n\tFL_PROC_OK := false\n\tswitch {\n\t\n\t\tcase ATS_FUNC == \"ATS-IMAGE\" && TYP == \"image\":\n\t\t\n\t\t\tupdateUserActiveData(w, r, c, UID, \"queueEmbedImage\")\n\t\t\t\n\t\t\tFL_PROC_OK = true\n\t\t\t//append this image to existing slide\n\t\t\t//.image SRC 600 900\n\t\t\t//buf.WriteString(fmt.Sprintf(\" \\n\"))\n\t\t\tbuf.WriteString(fmt.Sprintf(\"* \\n\"))\n\t\t\t//buf.WriteString(fmt.Sprintf(\" \\n\"))\n\t\t\tbuf.WriteString(fmt.Sprintf(\".image %v 600 900\\n\", SRC))\n\t\t\t//buf.WriteString(fmt.Sprintf(\" \\n\"))\n\t\t\tbuf.WriteString(fmt.Sprintf(\".caption %v\\n\", CAPTION))\n\t\t\tbuf.WriteString(fmt.Sprintf(\" \\n\"))\n\t\t\t//buf.WriteString(fmt.Sprintf(\" \\n\"))\n\t\t\t\t\n\t}\n\t\n\tif FL_PROC_OK == true {\n \n\t\t//update content\n\t\t// Now you can prepare a form that you will submit to that URL.\n\t\tvar m bytes.Buffer\n\t\tfw := multipart.NewWriter(&m)\n\t\t// Do not change the form field, it must be \"file\"!\n\t\t// You are free to change the filename though, it will be stored in the BlobInfo.\n\t\tfile, err := fw.CreateFormFile(\"file\", SID)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n \n\t\tif _, err = file.Write(buf.Bytes()); err != nil {\n\t\t\t//http.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\t//log.Panicf(\"%s\", err)\n \n\t\t\treturn\n\t\t}\n\t\t_ = fw.WriteField(\"EDIT_FUNC2\", \"SAVE_TEXT\")\n\t\t_ = fw.WriteField(\"SID\", SID)\n\t\t_ = fw.WriteField(\"CATEGORY\", \"desktop0\")\n\t\t_ = fw.WriteField(\"FUNC_CODE\", \"UPD-FROM-EDITOR\")\n\t\t_ = fw.WriteField(\"SPC_OPT\", \"\")\n\t\t_ = fw.WriteField(\"SPC_OPT\", \"\")\n\t\t//_ = fw.WriteField(\"TITLE\", CAPTION)\n\t\t_ = fw.WriteField(\"UID\", UID)\n\t\t\n\t\t// Don't forget to close the multipart writer.\n\t\t// If you don't close it, your request will be missing the terminating boundary.\n\t\tfw.Close()\n\t\t\n\t\t//upload url\n\t\tu := csn\n\t\t// Now that you have a form, you can submit it to your handler.\n\t\treq, err := http.NewRequest(\"POST\", u, &m)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\t// Don't forget to set the content type, this will contain the boundary.\n\t\treq.Header.Set(\"Content-Type\", fw.FormDataContentType())\n \n\t\t\n\t\t// Now submit the request.\n //client := urlfetch.Client(c)\n client := &http.Client{}\n\t\tres, err := client.Do(req)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n \n\t\t// Check the response status, it should be whatever you return in the `/upload` handler.\n\t\tif res.StatusCode != http.StatusCreated {\n\t\t\treturn\n\t\t}\t\t\n\t}\n}", "title": "" }, { "docid": "569fd899103bd72dd15faf7d72cde984", "score": "0.3890496", "text": "func (a *GroupApiService) DeleteGroupExecute(r ApiDeleteGroupRequest) (*http.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = http.MethodDelete\n\t\tlocalVarPostBody interface{}\n\t\tformFiles []formFile\n\t)\n\n\tlocalBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, \"GroupApiService.DeleteGroup\")\n\tif err != nil {\n\t\treturn nil, &GenericOpenAPIError{error: err.Error()}\n\t}\n\n\tlocalVarPath := localBasePath + \"/groups/{group-id}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"group-id\"+\"}\", url.PathEscape(parameterToString(r.groupId, \"\")), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)\n\tif localVarHTTPContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHTTPContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHTTPHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\n\tif localVarHTTPHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHTTPHeaderAccept\n\t}\n\tif r.ifMatch != nil {\n\t\tlocalVarHeaderParams[\"If-Match\"] = parameterToString(*r.ifMatch, \"\")\n\t}\n\treq, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := a.client.callAPI(req)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\n\tlocalVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))\n\tif err != nil {\n\t\treturn localVarHTTPResponse, err\n\t}\n\n\tif localVarHTTPResponse.StatusCode >= 300 {\n\t\tnewErr := &GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHTTPResponse.Status,\n\t\t}\n\t\tvar v OdataError\n\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\tif err != nil {\n\t\t\tnewErr.error = err.Error()\n\t\t\treturn localVarHTTPResponse, newErr\n\t\t}\n\t\tnewErr.model = v\n\t\treturn localVarHTTPResponse, newErr\n\t}\n\n\treturn localVarHTTPResponse, nil\n}", "title": "" }, { "docid": "3e1eda4170b25c4eee7820e9a17a57af", "score": "0.38832745", "text": "func DeleteSharedGroup(settings *playfab.Settings, postData *DeleteSharedGroupRequestModel, developerSecretKey string) (*EmptyResponseModel, error) {\r\n if developerSecretKey == \"\" {\n return nil, playfab.NewCustomError(\"developerSecretKey should not be an empty string\", playfab.ErrorGeneric)\n }\r\n b, errMarshal := json.Marshal(postData)\r\n if errMarshal != nil {\r\n return nil, playfab.NewCustomError(errMarshal.Error(), playfab.ErrorMarshal)\r\n }\r\n\r\n sourceMap, err := playfab.Request(settings, b, \"/Server/DeleteSharedGroup\", \"X-SecretKey\", developerSecretKey)\r\n if err != nil {\r\n return nil, err\r\n }\r\n \r\n result := &EmptyResponseModel{}\r\n\r\n config := mapstructure.DecoderConfig{\r\n DecodeHook: playfab.StringToDateTimeHook,\r\n Result: result,\r\n }\r\n \r\n decoder, errDecoding := mapstructure.NewDecoder(&config)\r\n if errDecoding != nil {\r\n return nil, playfab.NewCustomError(errDecoding.Error(), playfab.ErrorDecoding)\r\n }\r\n \r\n errDecoding = decoder.Decode(sourceMap)\r\n if errDecoding != nil {\r\n return nil, playfab.NewCustomError(errDecoding.Error(), playfab.ErrorDecoding)\r\n }\r\n\r\n return result, nil\r\n}", "title": "" }, { "docid": "592bf2519d789228dfd341d42ff1e41a", "score": "0.38797408", "text": "func (a *EndpointGroupsApiService) EndpointGroupCreate(ctx context.Context, body model.EndpointGroupCreateRequest) (model.EndpointGroup, *http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = strings.ToUpper(\"Post\")\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue model.EndpointGroup\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/endpoint_groups\"\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{\"application/json\"}\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\t// body params\n\tlocalVarPostBody = &body\n\tif ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {\n\t\t\tvar key string\n\t\t\tif auth.Prefix != \"\" {\n\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t} else {\n\t\t\t\tkey = auth.Key\n\t\t\t}\n\t\t\tlocalVarHeaderParams[\"Authorization\"] = key\n\n\t\t}\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHttpResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHttpResponse == nil {\n\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)\n\tlocalVarHttpResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t}\n\n\tif localVarHttpResponse.StatusCode < 300 {\n\t\t// If we succeed, return the data, otherwise pass on to decode error.\n\t\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\tif err == nil {\n\t\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t\t}\n\t}\n\n\tif localVarHttpResponse.StatusCode >= 300 {\n\t\tnewErr := GenericSwaggerError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHttpResponse.Status,\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 200 {\n\t\t\tvar v model.EndpointGroup\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 400 {\n\t\t\tvar v model.GenericError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\tif localVarHttpResponse.StatusCode == 500 {\n\t\t\tvar v model.GenericError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\n\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t}\n\n\treturn localVarReturnValue, localVarHttpResponse, nil\n}", "title": "" }, { "docid": "abbb422d3cb532ebf9a5aa34b0de5829", "score": "0.38743466", "text": "func (client *AutomationsClient) listByResourceGroupHandleResponse(resp *http.Response) (AutomationsClientListByResourceGroupResponse, error) {\n\tresult := AutomationsClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AutomationList); err != nil {\n\t\treturn AutomationsClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "title": "" }, { "docid": "1bbc99f4235967ee47d2eb8452ce7dff", "score": "0.38742307", "text": "func mysqlRecID(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\t// Parse each field from the query string\n\tid, ok := r.URL.Query()[\"id\"]\n\ttitle, _ := r.URL.Query()[\"title\"]\n\tdesc, _ := r.URL.Query()[\"desc\"]\n\tif !ok || len(id[0]) < 1 {\n\t\tjson.NewEncoder(w).Encode(\"URL: query is invalid or missing\")\n\t\treturn\n\t}\n\tvar mod Modify\n\tmod.id = id[0]\n\tif title != nil {\n\t\tmod.title = title[0]\n\t}\n\tif desc != nil {\n\t\tmod.desc = desc[0]\n\t}\n\n\t// Choose response based on the request\n\tswitch r.Method {\n\tcase \"GET\":\n\t\treadRecord(w, r, id[0])\n\tcase \"PUT\":\n\t\twriteRecord(w, r, mod)\n\tcase \"PATCH\":\n\t\tupdateRecord(w, r, mod)\n\tcase \"DELETE\":\n\t\tdeleteRecord(w, r, id[0])\n\tdefault:\n\t\tjson.NewEncoder(w).Encode(fmt.Sprintf(\"Invalid Method: %s\", r.Method))\n\t}\n}", "title": "" }, { "docid": "21b4a2e7f28d6054f8a69bcb901562c4", "score": "0.38589728", "text": "func (client *RoutePoliciesClient) listByResourceGroupHandleResponse(resp *http.Response) (RoutePoliciesClientListByResourceGroupResponse, error) {\n\tresult := RoutePoliciesClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RoutePoliciesListResult); err != nil {\n\t\treturn RoutePoliciesClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "title": "" }, { "docid": "6345c7abc3a582783b9530d8062f4736", "score": "0.3854668", "text": "func (client *GroupsClient) createHandleResponse(resp *http.Response) (GroupsClientCreateResponse, error) {\n\tresult := GroupsClientCreateResponse{}\n\tif val := resp.Header.Get(\"x-ms-request-id\"); val != \"\" {\n\t\tresult.XMSRequestID = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Group); err != nil {\n\t\treturn GroupsClientCreateResponse{}, err\n\t}\n\treturn result, nil\n}", "title": "" }, { "docid": "6b6916faa8368401136ee112b267e4b1", "score": "0.38535193", "text": "func PatchHandler(svc service.Patch, log *zerolog.Logger) func(rw http.ResponseWriter, r *http.Request, params httprouter.Params) {\n\treturn func(rw http.ResponseWriter, r *http.Request, params httprouter.Params) {\n\t\tid := params.ByName(\"id\")\n\t\tif len(id) == 0 {\n\t\t\terr := fmt.Errorf(\"%w: id is empty\", spec.ErrInvalidSyntax)\n\t\t\tlog.\n\t\t\t\tErr(err).\n\t\t\t\tMsg(\"error receiving patching request\")\n\t\t\t_ = handlerutil.WriteError(rw, err)\n\t\t\treturn\n\t\t}\n\n\t\treqFunc, closer := handlerutil.PatchRequest(r)\n\t\tdefer closer()\n\n\t\tresp, err := svc.Do(r.Context(), reqFunc(id))\n\t\tif err != nil {\n\t\t\tlog.\n\t\t\t\tErr(err).\n\t\t\t\tMsg(\"error when patching resource\")\n\t\t\t_ = handlerutil.WriteError(rw, err)\n\t\t\treturn\n\t\t}\n\n\t\tif !resp.Patched {\n\t\t\trw.WriteHeader(204)\n\t\t\treturn\n\t\t}\n\n\t\t_ = handlerutil.WriteResourceToResponse(rw, resp.Resource)\n\t}\n}", "title": "" }, { "docid": "08fddaa4325ed4fc5c9c36a32bdb5104", "score": "0.38519183", "text": "func handler(w http.ResponseWriter, r *http.Request) {\n\tmu.Lock()\n\tcount++\n\tmu.Unlock()\n\tfmt.Fprintf(w, \"URL.Path = %q\\n\", r.URL.Path)\n\tfmt.Fprintf(w, \"%s %s %s\\n\", r.Method, r.URL, r.Proto)\n\tfor k, v := range r.Header {\n\t\tfmt.Fprintf(w, \"Header[%q] = %q\\n\", k, v)\n\t}\n\tfmt.Fprintf(w, \"Host = %q\\n\", r.Host)\n\tfmt.Fprintf(w, \"RemoteAddr = %q\\n\", r.RemoteAddr)\n\tif err := r.ParseForm(); err != nil {\n\t\tlog.Print(err)\n\t}\n\tfor k, v := range r.Form {\n\t\tfmt.Fprintf(w, \"Form[%q] = %q\\n\", k, v)\n\t}\n}", "title": "" }, { "docid": "1cb19ee4f21f1749c85aac18e831665a", "score": "0.38487762", "text": "func (h compositeProfileHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tc := vars[\"composite-profile-name\"]\n\tp := vars[\"project-name\"]\n\tca := vars[\"composite-app-name\"]\n\tv := vars[\"composite-app-version\"]\n\n\terr := h.client.DeleteCompositeProfile(c, p, ca, v)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tw.WriteHeader(http.StatusNoContent)\n}", "title": "" }, { "docid": "2335f6e1a4018e3641b7f0049f40503a", "score": "0.38456443", "text": "func (*ListInstanceGroupLogRecordsResponse) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_compute_v1_instancegroup_instance_group_service_proto_rawDescGZIP(), []int{28}\n}", "title": "" }, { "docid": "5b06a2f9def39968d77d223cba10113e", "score": "0.38432458", "text": "func (ds *DoitServer) apiGroupHostVarsHandler(w http.ResponseWriter, r *http.Request) {\n\terr := r.ParseForm()\n\tif err != nil {\n\t\tlog.Errorln(\"Unable to parse message\", err)\n\t\tds.ReturnInternalServerError(w, r)\n\t\treturn\n\t}\n\tvars := mux.Vars(r)\n\tdomain := r.Form.Get(\"domain\")\n\treqName := vars[\"name\"]\n\thostName := vars[\"hostName\"]\n\n\td, err := ds.DomainCheck(domain)\n\tif err != nil {\n\t\tds.ReturnBadRequest(w, r)\n\t\treturn\n\t}\n\n\tswitch r.Method {\n\tcase \"GET\":\n\t\tg, err := ds.GetGroupByName(d, reqName)\n\t\tif err != nil {\n\t\t\tds.ReturnNotFound(w, r)\n\t\t\treturn\n\t\t}\n\t\th, err := ds.GetGroupHostByName(d, g, hostName)\n\t\tif err != nil {\n\t\t\tds.ReturnNotFound(w, r)\n\t\t\treturn\n\t\t}\n\t\tgh, err := ds.GetGroupHostVars(d, g, h)\n\t\tif err != nil {\n\t\t\tds.ReturnNotFound(w, r)\n\t\t\treturn\n\t\t}\n\t\terr = ds.ReturnJSON(gh, w, r)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\tdefault:\n\t\tds.ReturnNotImplemented(w, r)\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "286ac3669e7ee4b632b5eeae26ff2f19", "score": "0.38420463", "text": "func Parse3(w http.ResponseWriter, r *http.Request, blobkey string, name string, mode ParseMode, DESKTOP, SID string, OnOffLine, AUTHOR, PUB_STAT, FL_SHARED string) (string, *Doc, error) {\n\t//c := appengine.NewContext(r)\n\tulapphDebug(w,r, \"info\", fmt.Sprintf(\"Parse3() %v\", \"\"))\n\tdoc := new(Doc)\n\tst, lines, err := readLines3(w, r, blobkey, DESKTOP, SID, OnOffLine, AUTHOR)\n\tulapphDebug(w,r, \"info\", fmt.Sprintf(\"After calling readLines3() %v\", err))\n\tFL_PROC_OK := true\n\tif err != nil {\n\t\t//try to get from SID\n\t\tFL_PROC_OK = false\n\t\tif SID != \"\" {\n\t\t\t//var lines []string\n\t\t\tSPL := strings.Split(SID,\"-\")\n\t\t\tif len(SPL) > 1 {\n\t\t\t\tDOC_ID := SPL[1]\n\t\t\t\tTARGET := SPL[0]\n\t\t\t\tdocID := str2int(DOC_ID)\n\t\t\t\t\n\t\t\t\tswitch TARGET {\n\t\t\t\t\tcase \"TDSSLIDE\":\n\t\t\t\t\t\tblobkey, _, _, _, _, _, _, _, _, _ = getTDSSLIDEBlobKey(w, r, docID)\n\t\t\t\t\t\tFL_PROC_OK = true\n\t\t\t\t\tcase \"TDSARTL\":\n\t\t\t\t\t\tblobkey, _, _, _, _, _, _, _, _ = getTDSARTLBlobKey(w, r, docID)\n\t\t\t\t\t\tFL_PROC_OK = true\n\t\t\t\t}\n\t\t\n\t\t\t}\n\t\t} else {\n\t\t\t//panic(err)\n\t\t\tmsgDtl := fmt.Sprintf(\"[U00146] Critical error. Parse3 error. [ERROR: %v] [KEY: %v] (SID: %v) [S0632]\", err, blobkey, SID)\n\t\t\tmsgTyp := \"error\"\n\t\t\taction := \"U00146\"\n\t\t\tsysReq := fmt.Sprintf(\"/sysmsg?msgTyp=%v&message=%v&msgURL=%v&action=%v\", msgTyp, msgDtl, \"\", action)\n\t\t\thttp.Redirect(w, r, sysReq, http.StatusFound)\n\t\t\treturn st, nil, err\n\t\t}\n\t\t\n\t}\t\n\t//fmt.Fprintf(w, \"lines: %v<br>\", lines)\n\tulapphDebug(w,r, \"info\", fmt.Sprintf(\"lines: %v\", lines))\n\tif FL_PROC_OK == true {\n\t\tif err != nil {\n\t\t\treturn st, nil, err\n\t\t}\t\n\t\tulapphDebug(w,r, \"info\", fmt.Sprintf(\"parseHeader() %v\", \"\"))\n\t\terr = parseHeader(w,r,doc, lines, SID, PUB_STAT, FL_SHARED)\n\t\tif err != nil {\n\t\t\treturn st, nil, err\n\t\t}\n\t\tif mode&TitlesOnly != 0 {\n\t\t\treturn st, doc, nil\n\t\t}\n\t\t// Authors\n\t\tulapphDebug(w,r, \"info\", fmt.Sprintf(\"parseAuthors() %v\", \"\"))\n\t\tif doc.Authors, err = parseAuthors(lines); err != nil {\n\t\t\treturn st, nil, err\n\t\t}\n\t\tulapphDebug(w,r, \"info\", fmt.Sprintf(\"parseSections() %v\", \"\"))\n\t\tif doc.Sections, doc.Images, err = parseSections3(w, r, name, lines, []int{}, doc); err != nil {\n\t\t\treturn st, nil, err\n\t\t}\n\t}\n\treturn st, doc, nil\n}", "title": "" }, { "docid": "c3bdff15a5c10d9d561c74b8600d3aa3", "score": "0.38363993", "text": "func ServiceBindingBinding(w http.ResponseWriter, r *http.Request) {\n\t// check if request header is validated\n\tflag, errFunc := checkRequestHeader(w, r)\n\tif !flag {\n\t\terrFunc(w)\n\t\treturn\n\t}\n\n\tinsID, bidID := mux.Vars(r)[\"instance_id\"], mux.Vars(r)[\"binding_id\"]\n\tqMap := r.URL.Query()\n\t// check if the request support async\n\tif async := qMap.Get(\"accepts_incomplete\"); async != \"true\" {\n\t\terrMsg := fmt.Sprintf(\"accepts_incomplete expected true, got %s\", async)\n\t\tlog.Println(errMsg)\n\t\thandleError(w, 422, \"Unprocessable Entity\", errMsg)\n\t\treturn\n\t}\n\t// validate if request params is validated\n\tvar req openapi.ServiceBindingRequest\n\tif err := json.NewDecoder(r.Body).Decode(&req); err != nil {\n\t\terrMsg := fmt.Sprintf(\"request params validate failed: %v\", err)\n\t\tlog.Println(errMsg)\n\t\thandleError(w, 400, \"Bad Request\", errMsg)\n\t\treturn\n\t}\n\tsvcID, planID := req.ServiceId, req.PlanId\n\tif svcID == \"\" || planID == \"\" {\n\t\terrMsg := fmt.Sprint(\"service_id or plan_id should not be empty\")\n\t\tlog.Println(errMsg)\n\t\thandleError(w, 400, \"Bad Request\", errMsg)\n\t\treturn\n\t}\n\tif !store.CheckIfServiceIDExists(svcID) || !store.CheckIfPlanIDExists(svcID, planID) {\n\t\terrMsg := fmt.Sprint(\"service_id or plan_id doesn't exist\")\n\t\tlog.Println(errMsg)\n\t\thandleError(w, 400, \"Bad Request\", errMsg)\n\t\treturn\n\t}\n\tif err := utils.ParametersSchemaCheck(*store.GetCatalogPayload(), &utils.SchemaOpts{\n\t\tServiceID: svcID,\n\t\tPlanID: planID,\n\t\tParameters: req.Parameters,\n\t\tSchemaType: \"service_binding\",\n\t\tAction: \"create\",\n\t}); err != nil {\n\t\terrMsg := fmt.Sprintf(\"request params validate failed: %v\", err)\n\t\tlog.Println(errMsg)\n\t\thandleError(w, 400, \"Bad Request\", errMsg)\n\t\treturn\n\t}\n\t// return 409 Conflict if find service binding exists with different properties\n\tif store.CheckIfServiceBingdingExistsWithDifferentProperties(svcID, planID, insID, bidID, req.Parameters) {\n\t\terrMsg := fmt.Sprintf(\"service binding (%s) exists with different properties\", bidID)\n\t\tlog.Println(errMsg)\n\t\thandleError(w, 409, \"Conflict\", errMsg)\n\t\treturn\n\t}\n\t// return 200 OK if find service binding exists\n\tif store.CheckIfServiceBindingExists(svcID, planID, insID, bidID) {\n\t\tlog.Printf(\"service binding (%s) already exists\\n\", bidID)\n\t\tpayload, _ := store.FindServiceBindingPayload(insID, bidID)\n\t\thandleResult(w, 200, &openapi.ServiceBindingResponse{\n\t\t\tCredentials: payload.Payload.Credentials,\n\t\t})\n\t\treturn\n\t}\n\t// generate binding payload and store it in store.ServiceBindingPayloadList\n\tbindingPayload := &store.ServiceBindingPayload{\n\t\tServiceID: svcID,\n\t\tPlanID: planID,\n\t\tInstanceID: insID,\n\t\tBindingID: bidID,\n\t\tPayload: &openapi.ServiceBindingResource{\n\t\t\tCredentials: store.CredentialsPayload,\n\t\t\tParameters: req.Parameters,\n\t\t},\n\t}\n\tstore.StoreServiceBindingPayload(bindingPayload)\n\tlog.Printf(\"new service binding (%s) stored successfully\\n\", bidID)\n\n\t// return 202 Accepted after everything done\n\thandleResult(w, 202, &openapi.AsyncOperation{})\n\treturn\n}", "title": "" } ]
fdf96ae241ea99841137f77f98f76bc2
GetClinicianWithResponse request returning GetClinicianResponse
[ { "docid": "9afcbd8d51bafcb266e5fea4c5e71468", "score": "0.7221506", "text": "func (c *ClientWithResponses) GetClinicianWithResponse(ctx context.Context, clinicId ClinicId, clinicianId ClinicianId, reqEditors ...RequestEditorFn) (*GetClinicianResponse, error) {\n\trsp, err := c.GetClinician(ctx, clinicId, clinicianId, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseGetClinicianResponse(rsp)\n}", "title": "" } ]
[ { "docid": "411922fe6ed8a7bbaddca7b826700ec3", "score": "0.6529636", "text": "func (c *ClientWithResponses) ListClinicsForClinicianWithResponse(ctx context.Context, userId UserId, params *ListClinicsForClinicianParams, reqEditors ...RequestEditorFn) (*ListClinicsForClinicianResponse, error) {\n\trsp, err := c.ListClinicsForClinician(ctx, userId, params, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseListClinicsForClinicianResponse(rsp)\n}", "title": "" }, { "docid": "28d9ebe385d8add2ce5791483af3bef9", "score": "0.6439752", "text": "func (c *ClientWithResponses) GetClinicWithResponse(ctx context.Context, clinicId ClinicId, reqEditors ...RequestEditorFn) (*GetClinicResponse, error) {\n\trsp, err := c.GetClinic(ctx, clinicId, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseGetClinicResponse(rsp)\n}", "title": "" }, { "docid": "24cc5c1ffe10a52b82a06c48eaf1ef34", "score": "0.6267252", "text": "func NewGetClinicianRequest(server string, clinicId ClinicId, clinicianId ClinicianId) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"clinicId\", runtime.ParamLocationPath, clinicId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar pathParam1 string\n\n\tpathParam1, err = runtime.StyleParamWithLocation(\"simple\", false, \"clinicianId\", runtime.ParamLocationPath, clinicianId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/clinics/%s/clinicians/%s\", pathParam0, pathParam1)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"GET\", queryURL.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "title": "" }, { "docid": "12656ddde24d5069472da2f754936a7b", "score": "0.6125858", "text": "func (c *ClientWithResponses) GetInvitedClinicianWithResponse(ctx context.Context, clinicId ClinicId, inviteId InviteId, reqEditors ...RequestEditorFn) (*GetInvitedClinicianResponse, error) {\n\trsp, err := c.GetInvitedClinician(ctx, clinicId, inviteId, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseGetInvitedClinicianResponse(rsp)\n}", "title": "" }, { "docid": "44ebb24a13ab7bd2d566366355a41539", "score": "0.5895373", "text": "func (c *ClientWithResponses) CreateClinicianWithBodyWithResponse(ctx context.Context, clinicId ClinicId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateClinicianResponse, error) {\n\trsp, err := c.CreateClinicianWithBody(ctx, clinicId, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseCreateClinicianResponse(rsp)\n}", "title": "" }, { "docid": "569ae29107d611016fa017177c09e87d", "score": "0.5746166", "text": "func ParseGetClinicianResponse(rsp *http.Response) (*GetClinicianResponse, error) {\n\tbodyBytes, err := io.ReadAll(rsp.Body)\n\tdefer func() { _ = rsp.Body.Close() }()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse := &GetClinicianResponse{\n\t\tBody: bodyBytes,\n\t\tHTTPResponse: rsp,\n\t}\n\n\tswitch {\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 200:\n\t\tvar dest Clinician\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON200 = &dest\n\n\t}\n\n\treturn response, nil\n}", "title": "" }, { "docid": "bbb56fb80ede1d162f153c699d1d7fe0", "score": "0.5733294", "text": "func (mr *MockClientMockRecorder) GetClinician(ctx, clinicID, clinicianID interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"GetClinician\", reflect.TypeOf((*MockClient)(nil).GetClinician), ctx, clinicID, clinicianID)\n}", "title": "" }, { "docid": "a8f75ea7b4873c81f3b7ec698ff418a3", "score": "0.5676103", "text": "func NewListClinicsForClinicianRequest(server string, userId UserId, params *ListClinicsForClinicianParams) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"userId\", runtime.ParamLocationPath, userId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/clinicians/%s/clinics\", pathParam0)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif params != nil {\n\t\tqueryValues := queryURL.Query()\n\n\t\tif params.Offset != nil {\n\n\t\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"offset\", runtime.ParamLocationQuery, *params.Offset); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else {\n\t\t\t\tfor k, v := range parsed {\n\t\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif params.Limit != nil {\n\n\t\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"limit\", runtime.ParamLocationQuery, *params.Limit); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else {\n\t\t\t\tfor k, v := range parsed {\n\t\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tqueryURL.RawQuery = queryValues.Encode()\n\t}\n\n\treq, err := http.NewRequest(\"GET\", queryURL.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "title": "" }, { "docid": "a9881dde3a05f1c6b7097bb7852b44fe", "score": "0.5669045", "text": "func (c *ClinicClient) Get(ctx context.Context, id uuid.UUID) (*Clinic, error) {\n\treturn c.Query().Where(clinic.ID(id)).Only(ctx)\n}", "title": "" }, { "docid": "d19f9a233477c68690732ca9fbf12c96", "score": "0.56340307", "text": "func GetClinicDoctors(c *gin.Context) {\n\tlog.Infof(\"Get all doctors registered with specific physical clinic\")\n\taddressID := c.Param(\"addressId\")\n\tif addressID == \"\" {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusBadRequest,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: \"clinic address id not provided\",\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\tctx := c.Request.Context()\n\tuserEmail, userID, gproject, err := getUserDetails(ctx, c.Request)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusInternalServerError,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\tctx, span := trace.StartSpan(ctx, \"Get all doctors registered for a clinic\")\n\tdefer span.End()\n\tclinicMetaDB := datastoredb.NewClinicMetaHandler()\n\terr = clinicMetaDB.InitializeDataBase(ctx, gproject)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusInternalServerError,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\tregisteredDoctors, err := clinicMetaDB.GetClinicDoctors(ctx, userEmail, userID, addressID)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusInternalServerError,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\tc.JSON(http.StatusOK, gin.H{\n\t\tconstants.RESPONSE_JSON_DATA: registeredDoctors,\n\t\tconstants.RESPONSDE_JSON_ERROR: nil,\n\t})\n\tclinicMetaDB.Close()\n}", "title": "" }, { "docid": "2122fb740c88a33cd60d8888f533a16a", "score": "0.56287354", "text": "func (c *VeterinarianClient) QueryClinic(v *Veterinarian) *ClinicQuery {\n\tquery := &ClinicQuery{config: c.config}\n\tquery.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {\n\t\tid := v.ID\n\t\tstep := sqlgraph.NewStep(\n\t\t\tsqlgraph.From(veterinarian.Table, veterinarian.FieldID, id),\n\t\t\tsqlgraph.To(clinic.Table, clinic.FieldID),\n\t\t\tsqlgraph.Edge(sqlgraph.M2O, true, veterinarian.ClinicTable, veterinarian.ClinicColumn),\n\t\t)\n\t\tfromV = sqlgraph.Neighbors(v.driver.Dialect(), step)\n\t\treturn fromV, nil\n\t}\n\treturn query\n}", "title": "" }, { "docid": "06d2c6fc6df2749922e6705032fa8a94", "score": "0.55342495", "text": "func GetPhysicalClinics(c *gin.Context) {\n\tlog.Infof(\"Get all clinics associated with admin\")\n\tctx := c.Request.Context()\n\tuserEmail, _, gproject, err := getUserDetails(ctx, c.Request)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusInternalServerError,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\tctx, span := trace.StartSpan(ctx, \"Get all clinics associated with admin\")\n\tdefer span.End()\n\tclinicMetaDB := datastoredb.NewClinicMetaHandler()\n\terr = clinicMetaDB.InitializeDataBase(ctx, gproject)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusInternalServerError,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\tregisteredClinics, err := clinicMetaDB.GetAllClinicsByEmail(ctx, userEmail)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusInternalServerError,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\tresponseData := contracts.GetClinicAddressResponse{\n\t\tClinicDetails: registeredClinics,\n\t}\n\tc.JSON(http.StatusOK, gin.H{\n\t\tconstants.RESPONSE_JSON_DATA: responseData,\n\t\tconstants.RESPONSDE_JSON_ERROR: nil,\n\t})\n\tclinicMetaDB.Close()\n}", "title": "" }, { "docid": "48ce142e9324a11f158a5c47d83d2524", "score": "0.5492288", "text": "func NewGetInvitedClinicianRequest(server string, clinicId ClinicId, inviteId InviteId) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"clinicId\", runtime.ParamLocationPath, clinicId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar pathParam1 string\n\n\tpathParam1, err = runtime.StyleParamWithLocation(\"simple\", false, \"inviteId\", runtime.ParamLocationPath, inviteId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/clinics/%s/invites/clinicians/%s/clinician\", pathParam0, pathParam1)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"GET\", queryURL.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "title": "" }, { "docid": "46fece03b9a7d8982dfdf89b7a0d6e39", "score": "0.54293525", "text": "func (c *ClientWithResponses) ListClinicsWithResponse(ctx context.Context, params *ListClinicsParams, reqEditors ...RequestEditorFn) (*ListClinicsResponse, error) {\n\trsp, err := c.ListClinics(ctx, params, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseListClinicsResponse(rsp)\n}", "title": "" }, { "docid": "96143119156be8a8aa0a315859a4e2f7", "score": "0.540977", "text": "func ParseListClinicsForClinicianResponse(rsp *http.Response) (*ListClinicsForClinicianResponse, error) {\n\tbodyBytes, err := io.ReadAll(rsp.Body)\n\tdefer func() { _ = rsp.Body.Close() }()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse := &ListClinicsForClinicianResponse{\n\t\tBody: bodyBytes,\n\t\tHTTPResponse: rsp,\n\t}\n\n\tswitch {\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 200:\n\t\tvar dest ClinicianClinicRelationships\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON200 = &dest\n\n\t}\n\n\treturn response, nil\n}", "title": "" }, { "docid": "243ff6a40463f594b3ed5406633d81d7", "score": "0.5388218", "text": "func ParseGetInvitedClinicianResponse(rsp *http.Response) (*GetInvitedClinicianResponse, error) {\n\tbodyBytes, err := io.ReadAll(rsp.Body)\n\tdefer func() { _ = rsp.Body.Close() }()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse := &GetInvitedClinicianResponse{\n\t\tBody: bodyBytes,\n\t\tHTTPResponse: rsp,\n\t}\n\n\tswitch {\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 200:\n\t\tvar dest Clinician\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON200 = &dest\n\n\t}\n\n\treturn response, nil\n}", "title": "" }, { "docid": "9bb19174c70ff0e517c698c4abeb722a", "score": "0.536824", "text": "func (m *MockClient) GetClinician(ctx context.Context, clinicID, clinicianID string) (*api.Clinician, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetClinician\", ctx, clinicID, clinicianID)\n\tret0, _ := ret[0].(*api.Clinician)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "e03ff249d0127257d81b44973b655224", "score": "0.5322507", "text": "func (c *ClientWithResponses) ListClinicsForPatientWithResponse(ctx context.Context, userId UserId, params *ListClinicsForPatientParams, reqEditors ...RequestEditorFn) (*ListClinicsForPatientResponse, error) {\n\trsp, err := c.ListClinicsForPatient(ctx, userId, params, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseListClinicsForPatientResponse(rsp)\n}", "title": "" }, { "docid": "afa2d5aef06fa7a1261d302e2cc6389a", "score": "0.5279402", "text": "func (c *PatientofphysicianClient) Get(ctx context.Context, id int) (*Patientofphysician, error) {\n\treturn c.Query().Where(patientofphysician.ID(id)).Only(ctx)\n}", "title": "" }, { "docid": "6941b5e7126a49e636ed2273c3edbdd1", "score": "0.5242847", "text": "func GetSingleClinicID(c *gin.Context) {\n\tlog.Infof(\"Get all clinics associated with admin\")\n\tctx := c.Request.Context()\n\taddressID := c.Param(\"addressId\")\n\tif addressID == \"\" {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusBadRequest,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: \"clinic address id not provided\",\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\t_, _, gproject, err := getUserDetails(ctx, c.Request)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusInternalServerError,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\tctx, span := trace.StartSpan(ctx, \"Get all clinics associated with admin\")\n\tdefer span.End()\n\tclinicMetaDB := datastoredb.NewClinicMetaHandler()\n\terr = clinicMetaDB.InitializeDataBase(ctx, gproject)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusInternalServerError,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\n\tregisteredClinics, err := clinicMetaDB.GetSingleClinic(ctx, addressID)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusInternalServerError,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\tc.JSON(http.StatusOK, gin.H{\n\t\tconstants.RESPONSE_JSON_DATA: registeredClinics,\n\t\tconstants.RESPONSDE_JSON_ERROR: nil,\n\t})\n\n\tclinicMetaDB.Close()\n}", "title": "" }, { "docid": "fc71f6c1d11b4d59d63ee1b167eb7303", "score": "0.5168793", "text": "func NewGetClinicRequest(server string, clinicId ClinicId) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"clinicId\", runtime.ParamLocationPath, clinicId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/clinics/%s\", pathParam0)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"GET\", queryURL.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "title": "" }, { "docid": "2f11899e480229edcb387063ac4135ca", "score": "0.5159906", "text": "func ParseGetClinicResponse(rsp *http.Response) (*GetClinicResponse, error) {\n\tbodyBytes, err := io.ReadAll(rsp.Body)\n\tdefer func() { _ = rsp.Body.Close() }()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse := &GetClinicResponse{\n\t\tBody: bodyBytes,\n\t\tHTTPResponse: rsp,\n\t}\n\n\tswitch {\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 200:\n\t\tvar dest Clinic\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON200 = &dest\n\n\t}\n\n\treturn response, nil\n}", "title": "" }, { "docid": "acb731af8b8fe11652b94d69b6c89ed5", "score": "0.5133244", "text": "func (c *ClientWithResponses) CreateClinicWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateClinicResponse, error) {\n\trsp, err := c.CreateClinicWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseCreateClinicResponse(rsp)\n}", "title": "" }, { "docid": "7676edd65cdee551a0616d23f77e4d96", "score": "0.511521", "text": "func (c *ClientWithResponses) ListCliniciansWithResponse(ctx context.Context, clinicId ClinicId, params *ListCliniciansParams, reqEditors ...RequestEditorFn) (*ListCliniciansResponse, error) {\n\trsp, err := c.ListClinicians(ctx, clinicId, params, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseListCliniciansResponse(rsp)\n}", "title": "" }, { "docid": "2d99522269b338192adf1e6d4e0a66fd", "score": "0.51116514", "text": "func (c *ClientWithResponses) DeleteClinicianWithResponse(ctx context.Context, clinicId ClinicId, clinicianId ClinicianId, reqEditors ...RequestEditorFn) (*DeleteClinicianResponse, error) {\n\trsp, err := c.DeleteClinician(ctx, clinicId, clinicianId, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseDeleteClinicianResponse(rsp)\n}", "title": "" }, { "docid": "14db0c424a023bf674ef8cf28b0a230a", "score": "0.5058014", "text": "func NewListClinicsForPatientRequest(server string, userId UserId, params *ListClinicsForPatientParams) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"userId\", runtime.ParamLocationPath, userId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/patients/%s/clinics\", pathParam0)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif params != nil {\n\t\tqueryValues := queryURL.Query()\n\n\t\tif params.Offset != nil {\n\n\t\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"offset\", runtime.ParamLocationQuery, *params.Offset); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else {\n\t\t\t\tfor k, v := range parsed {\n\t\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif params.Limit != nil {\n\n\t\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"limit\", runtime.ParamLocationQuery, *params.Limit); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else {\n\t\t\t\tfor k, v := range parsed {\n\t\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tqueryURL.RawQuery = queryValues.Encode()\n\t}\n\n\treq, err := http.NewRequest(\"GET\", queryURL.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "title": "" }, { "docid": "4e70ea738c7651b7aedc13316118ad2a", "score": "0.503204", "text": "func NewDeleteClinicianRequest(server string, clinicId ClinicId, clinicianId ClinicianId) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"clinicId\", runtime.ParamLocationPath, clinicId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar pathParam1 string\n\n\tpathParam1, err = runtime.StyleParamWithLocation(\"simple\", false, \"clinicianId\", runtime.ParamLocationPath, clinicianId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/clinics/%s/clinicians/%s\", pathParam0, pathParam1)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"DELETE\", queryURL.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "title": "" }, { "docid": "14e4a0728340c4c39f8daa41ddb13595", "score": "0.49925107", "text": "func (c *ClientWithResponses) UpdateClinicianWithBodyWithResponse(ctx context.Context, clinicId ClinicId, clinicianId ClinicianId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateClinicianResponse, error) {\n\trsp, err := c.UpdateClinicianWithBody(ctx, clinicId, clinicianId, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseUpdateClinicianResponse(rsp)\n}", "title": "" }, { "docid": "162da7e97aeb67dc1060ab888b6681ed", "score": "0.4980666", "text": "func (c *ClientWithResponses) GetClinicByShareCodeWithResponse(ctx context.Context, shareCode string, reqEditors ...RequestEditorFn) (*GetClinicByShareCodeResponse, error) {\n\trsp, err := c.GetClinicByShareCode(ctx, shareCode, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseGetClinicByShareCodeResponse(rsp)\n}", "title": "" }, { "docid": "9b07786c59a7de5920f9b94d984189ca", "score": "0.49759477", "text": "func (client DatasetClient) GetResponder(resp *http.Response) (result DatasetDetailInfo, err error) {\n err = autorest.Respond(\n resp,\n azure.WithErrorUnlessStatusCode(http.StatusOK),\n autorest.ByUnmarshallingJSON(&result),\n autorest.ByClosing())\n result.Response = autorest.Response{Response: resp}\n return\n }", "title": "" }, { "docid": "278b4fe71674e1a0a811e5265a316e16", "score": "0.49740165", "text": "func (c *PhysicianClient) Get(ctx context.Context, id int) (*Physician, error) {\n\treturn c.Query().Where(physician.ID(id)).Only(ctx)\n}", "title": "" }, { "docid": "278b4fe71674e1a0a811e5265a316e16", "score": "0.49740165", "text": "func (c *PhysicianClient) Get(ctx context.Context, id int) (*Physician, error) {\n\treturn c.Query().Where(physician.ID(id)).Only(ctx)\n}", "title": "" }, { "docid": "363592f90d740875f9f5874df6d4df6e", "score": "0.4952083", "text": "func SearchClinicsByName(c *gin.Context) {\n\tlog.Infof(\"Get all clinics associated with admin\")\n\tctx := c.Request.Context()\n\tsearchString := c.Query(\"searchString\")\n\tif searchString == \"\" {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusBadRequest,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: \"Search string is empty\",\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\n\tclinicNameSearch := strings.Title(strings.ToLower(searchString))\n\tctx, span := trace.StartSpan(ctx, \"Get all clinics search\")\n\tdefer span.End()\n\tclinicMetaDB := datastoredb.NewClinicMetaHandler()\n\terr := clinicMetaDB.InitializeDataBase(ctx, \"superdentist\")\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusInternalServerError,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\tregisteredClinics, err := clinicMetaDB.SearchClinics(ctx, clinicNameSearch)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusInternalServerError,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\tresponseData := contracts.GetClinicAddressResponse{\n\t\tClinicDetails: registeredClinics,\n\t}\n\tc.JSON(http.StatusOK, gin.H{\n\t\tconstants.RESPONSE_JSON_DATA: responseData,\n\t\tconstants.RESPONSDE_JSON_ERROR: nil,\n\t})\n\tclinicMetaDB.Close()\n}", "title": "" }, { "docid": "184683fa782152c253788a53ad234f0e", "score": "0.49491626", "text": "func NewCreateClinicianRequest(server string, clinicId ClinicId, body CreateClinicianJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewCreateClinicianRequestWithBody(server, clinicId, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "eb46efd323833458d7659c10fe555df0", "score": "0.49334392", "text": "func ParseCreateClinicianResponse(rsp *http.Response) (*CreateClinicianResponse, error) {\n\tbodyBytes, err := io.ReadAll(rsp.Body)\n\tdefer func() { _ = rsp.Body.Close() }()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse := &CreateClinicianResponse{\n\t\tBody: bodyBytes,\n\t\tHTTPResponse: rsp,\n\t}\n\n\treturn response, nil\n}", "title": "" }, { "docid": "4dacd74c7076bb659c483c520338b358", "score": "0.48980364", "text": "func NewCreateClinicianRequestWithBody(server string, clinicId ClinicId, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"clinicId\", runtime.ParamLocationPath, clinicId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/clinics/%s/clinicians\", pathParam0)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "b84a79054c4f4f438376c1b0860340c0", "score": "0.48410362", "text": "func (c *ClientWithResponses) GetPatientWithResponse(ctx context.Context, clinicId ClinicId, patientId PatientId, reqEditors ...RequestEditorFn) (*GetPatientResponse, error) {\n\trsp, err := c.GetPatient(ctx, clinicId, patientId, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseGetPatientResponse(rsp)\n}", "title": "" }, { "docid": "edcc83ba4bee81ba5b9678d014f957e6", "score": "0.4828455", "text": "func ExampleAuthorizationsClient_Get() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armavs.NewClientFactory(\"<subscription-id>\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tres, err := clientFactory.NewAuthorizationsClient().Get(ctx, \"group1\", \"cloud1\", \"authorization1\", nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\t// You could use response here. We use blank identifier for just demo purposes.\n\t_ = res\n\t// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t// res.ExpressRouteAuthorization = armavs.ExpressRouteAuthorization{\n\t// \tName: to.Ptr(\"authorization1\"),\n\t// \tType: to.Ptr(\"Microsoft.AVS/privateClouds/authorizations\"),\n\t// \tID: to.Ptr(\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/authorizations/authorization1\"),\n\t// \tProperties: &armavs.ExpressRouteAuthorizationProperties{\n\t// \t\tExpressRouteAuthorizationID: to.Ptr(\"/subscriptions/5206f269-120b-41ef-a95b-0dce7109de61/resourceGroups/tnt34-cust-mockp02-spearj2dev/providers/Microsoft.Network/expressroutecircuits/tnt34-cust-mockp02-spearj2dev-er/authorizations/myauth\"),\n\t// \t\tExpressRouteAuthorizationKey: to.Ptr(\"37b0db3b-3b17-4c7b-bf76-bf13b01bcadc\"),\n\t// \t\tExpressRouteID: to.Ptr(\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/tnt13-41a90db2-9d5e-4bd5-a77a-5ce7b58213d6-eastus2/providers/Microsoft.Network/expressroutecircuits/tnt13-41a90db2-9d5e-4bd5-a77a-5ce7b58213d6-eastus2-xconnect\"),\n\t// \t\tProvisioningState: to.Ptr(armavs.ExpressRouteAuthorizationProvisioningStateSucceeded),\n\t// \t},\n\t// }\n}", "title": "" }, { "docid": "fbbacc59ba4f8a1ed6cbe3bf945a6a13", "score": "0.4752615", "text": "func (_Clinic *ClinicRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {\n\treturn _Clinic.Contract.ClinicCaller.contract.Call(opts, result, method, params...)\n}", "title": "" }, { "docid": "be0b9e7947fda48d8512e8f443277613", "score": "0.4737152", "text": "func Company_get() {\n\n // GET /companies/{company_id}.json\n\n }", "title": "" }, { "docid": "ab8f55ce1494586651dd60d4356a15c8", "score": "0.47353682", "text": "func (c *ClientWithResponses) MatchClinicAndPatientWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*MatchClinicAndPatientResponse, error) {\n\trsp, err := c.MatchClinicAndPatientWithBody(ctx, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseMatchClinicAndPatientResponse(rsp)\n}", "title": "" }, { "docid": "76689be62dff66306a2dcbac25ff1dbc", "score": "0.47193694", "text": "func (ctl *APIController) GetInfo(w http.ResponseWriter, r *http.Request) {\n\n\t// transform\n\ttr := transformers.APITransformer{\n\t\tName: \"Catalyst\",\n\t\tVersion: \"v2.5.1\",\n\t\tPurpose: \"A REST API base written in Golang\",\n\t}\n\n\t// send response\n\tctl.sendResponse(r.Context(), w, http.StatusOK, tr)\n}", "title": "" }, { "docid": "7284cd0f4f0af2aa0c7bdff7f4de2359", "score": "0.47146934", "text": "func clinicaltrialsFetch(w http.ResponseWriter, r *http.Request) {\n\n\t// define the query\n\tquery := `(wuhan AND (coronavirus OR corona virus OR pneumonia virus)) OR COVID19 OR COVID-19 OR COVID 19 OR coronavirus 2019 OR corona virus 2019 OR SARS-CoV-2 OR SARSCoV2 OR SARS2 OR SARS-2 OR 2019 nCoV OR ((novel coronavirus OR novel corona virus) AND 2019)`\n\n\tdta, err := clinicaltrials.Fetch(query)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\thttp.Error(w, \"could not fetch data\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\trender.PlainText(w, r, dta)\n}", "title": "" }, { "docid": "95d4d56bbbd90dd80af85d0568e19a00", "score": "0.47104317", "text": "func (o *GetSearchClinicsParams) WithHTTPClient(client *http.Client) *GetSearchClinicsParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "title": "" }, { "docid": "9ea59693d83074da9dde7e41c46a7670", "score": "0.4709984", "text": "func (client ThreatIntelligenceIndicatorClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, name string) (result ThreatIntelligenceInformationModel, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/ThreatIntelligenceIndicatorClient.Get\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.Response.Response != nil {\n\t\t\t\tsc = result.Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tif err := validation.Validate([]validation.Validation{\n\t\t{TargetValue: client.SubscriptionID,\n\t\t\tConstraints: []validation.Constraint{{Target: \"client.SubscriptionID\", Name: validation.MinLength, Rule: 1, Chain: nil}}},\n\t\t{TargetValue: resourceGroupName,\n\t\t\tConstraints: []validation.Constraint{{Target: \"resourceGroupName\", Name: validation.MaxLength, Rule: 90, Chain: nil},\n\t\t\t\t{Target: \"resourceGroupName\", Name: validation.MinLength, Rule: 1, Chain: nil}}},\n\t\t{TargetValue: workspaceName,\n\t\t\tConstraints: []validation.Constraint{{Target: \"workspaceName\", Name: validation.MaxLength, Rule: 90, Chain: nil},\n\t\t\t\t{Target: \"workspaceName\", Name: validation.MinLength, Rule: 1, Chain: nil},\n\t\t\t\t{Target: \"workspaceName\", Name: validation.Pattern, Rule: `^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$`, Chain: nil}}}}); err != nil {\n\t\treturn result, validation.NewError(\"securityinsight.ThreatIntelligenceIndicatorClient\", \"Get\", err.Error())\n\t}\n\n\treq, err := client.GetPreparer(ctx, resourceGroupName, workspaceName, name)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"securityinsight.ThreatIntelligenceIndicatorClient\", \"Get\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresp, err := client.GetSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\terr = autorest.NewErrorWithError(err, \"securityinsight.ThreatIntelligenceIndicatorClient\", \"Get\", resp, \"Failure sending request\")\n\t\treturn\n\t}\n\n\tresult, err = client.GetResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"securityinsight.ThreatIntelligenceIndicatorClient\", \"Get\", resp, \"Failure responding to request\")\n\t\treturn\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "80370ab66bd5271c0112bd6c5b40c734", "score": "0.47054616", "text": "func NewListCliniciansRequest(server string, clinicId ClinicId, params *ListCliniciansParams) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"clinicId\", runtime.ParamLocationPath, clinicId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/clinics/%s/clinicians\", pathParam0)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif params != nil {\n\t\tqueryValues := queryURL.Query()\n\n\t\tif params.Search != nil {\n\n\t\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"search\", runtime.ParamLocationQuery, *params.Search); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else {\n\t\t\t\tfor k, v := range parsed {\n\t\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif params.Offset != nil {\n\n\t\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"offset\", runtime.ParamLocationQuery, *params.Offset); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else {\n\t\t\t\tfor k, v := range parsed {\n\t\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif params.Limit != nil {\n\n\t\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"limit\", runtime.ParamLocationQuery, *params.Limit); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else {\n\t\t\t\tfor k, v := range parsed {\n\t\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif params.Email != nil {\n\n\t\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"email\", runtime.ParamLocationQuery, *params.Email); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else {\n\t\t\t\tfor k, v := range parsed {\n\t\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif params.Role != nil {\n\n\t\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"role\", runtime.ParamLocationQuery, *params.Role); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else {\n\t\t\t\tfor k, v := range parsed {\n\t\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tqueryURL.RawQuery = queryValues.Encode()\n\t}\n\n\treq, err := http.NewRequest(\"GET\", queryURL.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "title": "" }, { "docid": "04efaca639b82b9268452353440424bc", "score": "0.46997947", "text": "func (client ThreatIntelligenceIndicatorClient) GetResponder(resp *http.Response) (result ThreatIntelligenceInformationModel, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "title": "" }, { "docid": "09f28ed266e24ed1d63f8778ce16d8e2", "score": "0.46918306", "text": "func GetAllClinicNameAddressID(c *gin.Context) {\n\tlog.Infof(\"Get all clinics associated with admin\")\n\tctx := c.Request.Context()\n\tpageSize, err := strconv.Atoi(c.Query(\"pageSize\"))\n\tif err != nil {\n\t\tpageSize = 0\n\t}\n\tcursor := c.Query(\"cursor\")\n\tif cursor != \"\" {\n\t\tcursor, _ = helpers.DecryptAndDecode(cursor)\n\t}\n\t_, _, gproject, err := getUserDetails(ctx, c.Request)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusInternalServerError,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\tctx, span := trace.StartSpan(ctx, \"Get all clinics associated with admin\")\n\tdefer span.End()\n\tclinicMetaDB := datastoredb.NewClinicMetaHandler()\n\terr = clinicMetaDB.InitializeDataBase(ctx, gproject)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusInternalServerError,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\tif pageSize == 0 {\n\t\tregisteredClinics, err := clinicMetaDB.GetAllClinicsMeta(ctx)\n\t\tif err != nil {\n\t\t\tc.AbortWithStatusJSON(\n\t\t\t\thttp.StatusInternalServerError,\n\t\t\t\tgin.H{\n\t\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t\t},\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tc.JSON(http.StatusOK, gin.H{\n\t\t\tconstants.RESPONSE_JSON_DATA: registeredClinics,\n\t\t\tconstants.RESPONSDE_JSON_ERROR: nil,\n\t\t})\n\t} else {\n\t\tregisteredClinics, cursor, err := clinicMetaDB.GetAllClinicsMetaPaginate(ctx, pageSize, cursor)\n\t\tif err != nil {\n\t\t\tc.AbortWithStatusJSON(\n\t\t\t\thttp.StatusInternalServerError,\n\t\t\t\tgin.H{\n\t\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t\t},\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tvar results contracts.ClinicList\n\t\tresults.Clinics = registeredClinics\n\t\tresults.CursorNext, _ = helpers.EncryptAndEncode(cursor)\n\n\t\tc.JSON(http.StatusOK, gin.H{\n\t\t\tconstants.RESPONSE_JSON_DATA: results,\n\t\t\tconstants.RESPONSDE_JSON_ERROR: nil,\n\t\t})\n\t}\n\tclinicMetaDB.Close()\n}", "title": "" }, { "docid": "fe37c5a8280b3ce047caa6f995b4661e", "score": "0.4685476", "text": "func (c *ClientWithResponses) ListAllCliniciansWithResponse(ctx context.Context, params *ListAllCliniciansParams, reqEditors ...RequestEditorFn) (*ListAllCliniciansResponse, error) {\n\trsp, err := c.ListAllClinicians(ctx, params, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseListAllCliniciansResponse(rsp)\n}", "title": "" }, { "docid": "9a0801abd8954d202ef52b70fdc375d6", "score": "0.46840274", "text": "func (c *ClientWithResponses) AssociateClinicianToUserWithBodyWithResponse(ctx context.Context, clinicId ClinicId, inviteId InviteId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AssociateClinicianToUserResponse, error) {\n\trsp, err := c.AssociateClinicianToUserWithBody(ctx, clinicId, inviteId, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseAssociateClinicianToUserResponse(rsp)\n}", "title": "" }, { "docid": "f026cd6fb44addefb07bc149dec309ec", "score": "0.4682697", "text": "func ParseCreateClinicResponse(rsp *http.Response) (*CreateClinicResponse, error) {\n\tbodyBytes, err := io.ReadAll(rsp.Body)\n\tdefer func() { _ = rsp.Body.Close() }()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse := &CreateClinicResponse{\n\t\tBody: bodyBytes,\n\t\tHTTPResponse: rsp,\n\t}\n\n\tswitch {\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 200:\n\t\tvar dest Clinic\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON200 = &dest\n\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"xml\") && rsp.StatusCode == 200:\n\t\tvar dest map[string]interface{}\n\t\tif err := xml.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.XML200 = &dest\n\n\t}\n\n\treturn response, nil\n}", "title": "" }, { "docid": "572654c567943bfab4009fbdbc74f405", "score": "0.4681205", "text": "func (c *ClientWithResponses) DeleteInvitedClinicianWithResponse(ctx context.Context, clinicId ClinicId, inviteId InviteId, reqEditors ...RequestEditorFn) (*DeleteInvitedClinicianResponse, error) {\n\trsp, err := c.DeleteInvitedClinician(ctx, clinicId, inviteId, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseDeleteInvitedClinicianResponse(rsp)\n}", "title": "" }, { "docid": "2241c72c8bb4398f1e14d23c1c5f6316", "score": "0.46774608", "text": "func (*ListClinicResponse_Clinic) Descriptor() ([]byte, []int) {\n\treturn file_src_h4u_proto_rawDescGZIP(), []int{7, 0}\n}", "title": "" }, { "docid": "d0f1140a554c68786ba03257af1055bf", "score": "0.4659376", "text": "func (client IdentityClient) getTenancy(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/tenancies/{tenancyId}\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response GetTenancyResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "title": "" }, { "docid": "16e30346e1d7d519064b2ed223a7d23e", "score": "0.46279818", "text": "func (s *SmartContract) requestConsultant(APIstub shim.ChaincodeStubInterface, args []string) sc.Response {\n\n\tif len(args) != 15 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 15\")\n\t}\n\n\tvar sow = SOW{\n\t\tDateCreated: args[1],\n\t\tTermStartDate: args[2],\n\t\tTermEndDate: args[3],\n\t\tRequireFullTime: args[4],\n\t\tRatePerHour: args[5],\n\t\tStatus: args[6],\n\t\tClientId: args[7],\n\t\tName: args[8],\n\t\tConsultantId: args[9],\n\t\tSOWId: args[10],\n\t\tDescription: args[11],\n\t\tRequirement1: args[12],\n\t\tRequirement2: args[13],\n\t\tRequirement3: args[14],\n\t}\n\n\tsowAsBytes, _ := json.Marshal(sow)\n\terr := APIstub.PutState(args[0], sowAsBytes)\n\n\tif err != nil {\n\t\treturn shim.Error(fmt.Sprintf(\"Failed to request consultant: %s\", args[0]))\n\t}\n\n\treturn shim.Success(sowAsBytes)\n}", "title": "" }, { "docid": "a2024e2ff91d1fa89d3bb7adb380536e", "score": "0.46172565", "text": "func GetNearbySpeialists(c *gin.Context) {\n\tlog.Infof(\"Get specialists clinic in nearby give clinic\")\n\tctx := c.Request.Context()\n\tvar nearbyRequest contracts.GetNearbySpecialists\n\tctx, span := trace.StartSpan(ctx, \"Get all clinics in close proximity to current clinic\")\n\tdefer span.End()\n\tif err := c.ShouldBindWith(&nearbyRequest, binding.JSON); err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusBadRequest,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: fmt.Errorf(\"Bad data sent to backened\"),\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\n\tif nearbyRequest.ClinicAddessID == \"\" {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusBadRequest,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: \"clinic address id not provided\",\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\tdist := 20.0\n\tif nearbyRequest.SearchRadius == \"\" {\n\t\tnearbyRequest.SearchRadius = \"20.0\"\n\t}\n\tcursor := nearbyRequest.Cursor\n\tdist, _ = strconv.ParseFloat(nearbyRequest.SearchRadius, 64)\n\tuserEmail, userID, gproject, err := getUserDetails(ctx, c.Request)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusInternalServerError,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\tdefer span.End()\n\tclinicMetaDB := datastoredb.NewClinicMetaHandler()\n\terr = clinicMetaDB.InitializeDataBase(ctx, gproject)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusInternalServerError,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t},\n\t\t)\n\t\treturn\n\t}\n\tmapClient := gmaps.NewMapsHandler()\n\terr = mapClient.InitializeGoogleMapsAPIClient(ctx, gproject)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusInternalServerError,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t},\n\t\t)\n\t}\n\tcollectClinics := make([]contracts.PhysicalClinicMapDetails, 0)\n\tcurrentClinic, _ := clinicMetaDB.GetSingleClinic(ctx, nearbyRequest.ClinicAddessID)\n\tloc := currentClinic.Location\n\tcurrentVerifiedPlaces := make(map[string]bool)\n\tcurrentFavorites := currentClinic.Favorites\n\tif cursor == \"\" {\n\t\tnearbyClinics := make([]contracts.PhysicalClinicMapLocation, 0)\n\t\tnearbyClinics, err = clinicMetaDB.GetNearbySpecialist(ctx, userEmail, userID, nearbyRequest.ClinicAddessID, dist)\n\t\tif err != nil {\n\t\t\tlog.Infof(\"no nearby clinics found: %v\", err.Error())\n\t\t}\n\t\tfor _, clinicAdd := range nearbyClinics {\n\t\t\tif clinicAdd.AddressID == nearbyRequest.ClinicAddessID || clinicAdd.Type == \"dentist\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif Find(currentFavorites, clinicAdd.PlaceID) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tvar currentReturn contracts.PhysicalClinicMapDetails\n\t\t\tgetClinicSearchLoc, err := mapClient.FindPlaceFromID(clinicAdd.PlaceID)\n\t\t\tif err != nil {\n\t\t\t\tc.AbortWithStatusJSON(\n\t\t\t\t\thttp.StatusInternalServerError,\n\t\t\t\t\tgin.H{\n\t\t\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tcurrentReturn.GeneralDetails = *getClinicSearchLoc\n\t\t\tif clinicAdd.Specialty != nil {\n\t\t\t\tfor _, sp := range clinicAdd.Specialty {\n\t\t\t\t\tcurrentReturn.GeneralDetails.Types = append(currentReturn.GeneralDetails.Types, sp)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcurrentVerifiedPlaces[currentReturn.GeneralDetails.PlaceID] = true\n\t\t\tclinicAdd.IsVerified = true\n\t\t\tcurrentReturn.VerifiedDetails = clinicAdd\n\t\t\tcollectClinics = append(collectClinics, currentReturn)\n\t\t}\n\t}\n\tcurrentMapLocation := maps.LatLng{\n\t\tLat: loc.Lat,\n\t\tLng: loc.Long,\n\t}\n\tcurrentSpeciality := nearbyRequest.Specialties\n\tif currentSpeciality == \"\" {\n\t\tcurrentSpeciality = \"specialist\"\n\t}\n\tcurrentRadius := uint(dist * 1609.34) // in meters\n\tcurrentNonRegisteredNearby, pToken, err := mapClient.FindNearbyPlacesFromLocation(currentMapLocation, currentRadius, currentSpeciality, cursor, currentVerifiedPlaces)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(\n\t\t\thttp.StatusInternalServerError,\n\t\t\tgin.H{\n\t\t\t\tconstants.RESPONSE_JSON_DATA: nil,\n\t\t\t\tconstants.RESPONSDE_JSON_ERROR: err.Error(),\n\t\t\t},\n\t\t)\n\t}\n\tfor _, clinicAdd := range currentNonRegisteredNearby {\n\t\tif Find(currentFavorites, clinicAdd.PlaceID) {\n\t\t\tcontinue\n\t\t}\n\t\tvar currentReturn contracts.PhysicalClinicMapDetails\n\n\t\tcurrentReturn.GeneralDetails = clinicAdd\n\t\tcurrentReturn.VerifiedDetails = contracts.PhysicalClinicMapLocation{}\n\t\tcurrentReturn.VerifiedDetails.IsVerified = false\n\t\tcollectClinics = append(collectClinics, currentReturn)\n\n\t}\n\tvar responseData contracts.GetNearbyClinics\n\tresponseData.ClinicAddresses = collectClinics\n\tfor i, clinic := range collectClinics {\n\t\tfor key, value := range gmaps.SPECIALITYMAP {\n\t\t\tif strings.Contains(strings.ToLower(clinic.GeneralDetails.Name), key) {\n\t\t\t\tclinic.GeneralDetails.Types[0] = value\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tcollectClinics[i] = clinic\n\t}\n\tresponseData.Cursor = pToken\n\tc.JSON(http.StatusOK, gin.H{\n\t\tconstants.RESPONSE_JSON_DATA: responseData,\n\t\tconstants.RESPONSDE_JSON_ERROR: nil,\n\t})\n\tclinicMetaDB.Close()\n}", "title": "" }, { "docid": "ea325c580f9f33f6e7e0504ed3f615ed", "score": "0.4578155", "text": "func CreateGetTaxationInfoRequest() (request *GetTaxationInfoRequest) {\n\trequest = &GetTaxationInfoRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"companyreg\", \"2020-10-22\", \"GetTaxationInfo\", \"companyreg\", \"openAPI\")\n\trequest.Method = requests.GET\n\treturn\n}", "title": "" }, { "docid": "6e82f015db03e2b8a62791bd0617c144", "score": "0.45779604", "text": "func GetCovidData(endpoint string) (*http.Response, error) {\n\tlog.Println(\"GET\", endpoint)\n\n\trequest, _ := http.NewRequest(http.MethodGet, endpoint, nil)\n\n\turl, _ := url.Parse(endpoint)\n\tkey, _ := os.LookupEnv(\"COVID_SERVICE_API_KEY\")\n\n\trequest.Header.Add(\"x-rapidapi-key\", key)\n\trequest.Header.Add(\"x-rapidapi-host\", url.Host)\n\n\treturn Client.Do(request)\n}", "title": "" }, { "docid": "86ff9daa94623f8a74543803ecc88587", "score": "0.45654395", "text": "func NewListClinicsRequest(server string, params *ListClinicsParams) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/clinics\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif params != nil {\n\t\tqueryValues := queryURL.Query()\n\n\t\tif params.Limit != nil {\n\n\t\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"limit\", runtime.ParamLocationQuery, *params.Limit); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else {\n\t\t\t\tfor k, v := range parsed {\n\t\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif params.Offset != nil {\n\n\t\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"offset\", runtime.ParamLocationQuery, *params.Offset); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else {\n\t\t\t\tfor k, v := range parsed {\n\t\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif params.ShareCode != nil {\n\n\t\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"shareCode\", runtime.ParamLocationQuery, *params.ShareCode); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else {\n\t\t\t\tfor k, v := range parsed {\n\t\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif params.CreatedTimeStart != nil {\n\n\t\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"createdTimeStart\", runtime.ParamLocationQuery, *params.CreatedTimeStart); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else {\n\t\t\t\tfor k, v := range parsed {\n\t\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif params.CreatedTimeEnd != nil {\n\n\t\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"createdTimeEnd\", runtime.ParamLocationQuery, *params.CreatedTimeEnd); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else {\n\t\t\t\tfor k, v := range parsed {\n\t\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif params.EhrEnabled != nil {\n\n\t\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"ehrEnabled\", runtime.ParamLocationQuery, *params.EhrEnabled); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else {\n\t\t\t\tfor k, v := range parsed {\n\t\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tqueryURL.RawQuery = queryValues.Encode()\n\t}\n\n\treq, err := http.NewRequest(\"GET\", queryURL.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "title": "" }, { "docid": "ae3c3648fb3eacbe0aee2f4fb63ce6c9", "score": "0.4564414", "text": "func CallFHIREndpoint() {\n\tresp, err := http.Get(\"https://fhir-open.sandboxcerner.com/r4/0b8a0111-e8e6-4c26-a91c-5069cbc6b1ca/Patient?_id=4342009\")\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n\tlog.Println(string(body))\n}", "title": "" }, { "docid": "30a5bb8a772eaad016d35d1cc819caaa", "score": "0.4564226", "text": "func ParseAssociateClinicianToUserResponse(rsp *http.Response) (*AssociateClinicianToUserResponse, error) {\n\tbodyBytes, err := io.ReadAll(rsp.Body)\n\tdefer func() { _ = rsp.Body.Close() }()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse := &AssociateClinicianToUserResponse{\n\t\tBody: bodyBytes,\n\t\tHTTPResponse: rsp,\n\t}\n\n\tswitch {\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 200:\n\t\tvar dest Clinician\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON200 = &dest\n\n\t}\n\n\treturn response, nil\n}", "title": "" }, { "docid": "8c17c89a6773ff4846caa73813dce7ed", "score": "0.45555884", "text": "func (r *CompanyInformationRequest) Get(ctx context.Context) (resObj *CompanyInformation, err error) {\n\tvar query string\n\tif r.query != nil {\n\t\tquery = \"?\" + r.query.Encode()\n\t}\n\terr = r.JSONRequest(ctx, \"GET\", query, nil, &resObj)\n\treturn\n}", "title": "" }, { "docid": "96139f472983c89d2ab0c0b27ec32257", "score": "0.4554615", "text": "func (c *PatientInfoClient) Get(ctx context.Context, id int) (*PatientInfo, error) {\n\treturn c.Query().Where(patientinfo.ID(id)).Only(ctx)\n}", "title": "" }, { "docid": "7b18f189004ab095aeee984bc683341a", "score": "0.45511192", "text": "func (o *GetSearchClinicsParams) WithTimeout(timeout time.Duration) *GetSearchClinicsParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "title": "" }, { "docid": "0d43f4e5b16092820f289e81986e4945", "score": "0.455093", "text": "func ParseListClinicsResponse(rsp *http.Response) (*ListClinicsResponse, error) {\n\tbodyBytes, err := io.ReadAll(rsp.Body)\n\tdefer func() { _ = rsp.Body.Close() }()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse := &ListClinicsResponse{\n\t\tBody: bodyBytes,\n\t\tHTTPResponse: rsp,\n\t}\n\n\tswitch {\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 200:\n\t\tvar dest Clinics\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON200 = &dest\n\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 400:\n\t\tvar dest Error\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON400 = &dest\n\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 403:\n\t\tvar dest Error\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON403 = &dest\n\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 500:\n\t\tvar dest Error\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON500 = &dest\n\n\t}\n\n\treturn response, nil\n}", "title": "" }, { "docid": "fedf4facc4711fb0a1f86938582db754", "score": "0.45415503", "text": "func (r Requester) Call(t *testing.T) {\n\tresp, err := http.DefaultClient.Do(r.httpRequest)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif r.response == nil {\n\t\treturn\n\t}\n\n\tif resp.StatusCode != r.responseStatusCode {\n\t\tb, err := ioutil.ReadAll(resp.Body)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\n\t\tt.Errorf(\"expect: %s %s return status code: %d and response type: %T\", r.httpRequest.Method, r.httpRequest.URL.String(), r.responseStatusCode, r.response)\n\t\tt.Errorf(\"actual: %s %s return status code: %d and response : %s\", r.httpRequest.Method, r.httpRequest.URL.String(), resp.StatusCode, b)\n\t\tt.Fatal()\n\t}\n\n\tif err := json.NewDecoder(resp.Body).Decode(&r.response); err != nil {\n\t\tt.Fatal(err)\n\t}\n}", "title": "" }, { "docid": "05c792a33ea31f230926781b37cb7016", "score": "0.4532861", "text": "func (client *IncidentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, incidentID string, options *IncidentsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/incidents/{incidentId}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif workspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter workspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{workspaceName}\", url.PathEscape(workspaceName))\n\tif incidentID == \"\" {\n\t\treturn nil, errors.New(\"parameter incidentID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{incidentId}\", url.PathEscape(incidentID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-05-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "title": "" }, { "docid": "0ce361e4dc3ed313617e1a9ec18ded9e", "score": "0.45311883", "text": "func (r a) GetSpecific(engagementRef string) (*http.Response, []byte) {\n return r.client.Get(\"/tasks/v2/tasks/contracts/\" + engagementRef, nil)\n}", "title": "" }, { "docid": "c93a6d0c02e5c646db057f1da56ae9f8", "score": "0.45160303", "text": "func (client ViewsClient) GetByScopeResponder(resp *http.Response) (result View, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "title": "" }, { "docid": "8f013cb56a570c2536945d0f272d5b09", "score": "0.44984233", "text": "func (page ServiceCountryListResultPage) Response() ServiceCountryListResult {\n\treturn page.sclr\n}", "title": "" }, { "docid": "c616260eabc7448a3e9128f4c6189692", "score": "0.44970068", "text": "func NewDeleteInvitedClinicianRequest(server string, clinicId ClinicId, inviteId InviteId) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"clinicId\", runtime.ParamLocationPath, clinicId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar pathParam1 string\n\n\tpathParam1, err = runtime.StyleParamWithLocation(\"simple\", false, \"inviteId\", runtime.ParamLocationPath, inviteId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/clinics/%s/invites/clinicians/%s/clinician\", pathParam0, pathParam1)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"DELETE\", queryURL.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "title": "" }, { "docid": "618262e809d41a53bd34bbd245973365", "score": "0.44969353", "text": "func (_Clinic *ClinicCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {\n\treturn _Clinic.Contract.contract.Call(opts, result, method, params...)\n}", "title": "" }, { "docid": "538f06d6ca37ec8c3542c05dd831ad03", "score": "0.4493016", "text": "func ExampleRegulatoryComplianceStandardsClient_Get() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armsecurity.NewClientFactory(\"<subscription-id>\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tres, err := clientFactory.NewRegulatoryComplianceStandardsClient().Get(ctx, \"PCI-DSS-3.2\", nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\t// You could use response here. We use blank identifier for just demo purposes.\n\t_ = res\n\t// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t// res.RegulatoryComplianceStandard = armsecurity.RegulatoryComplianceStandard{\n\t// \tName: to.Ptr(\"PCI-DSS-3.2\"),\n\t// \tType: to.Ptr(\"Microsoft.Security/regulatoryComplianceStandard\"),\n\t// \tID: to.Ptr(\"/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/providers/Microsoft.Security/regulatoryComplianceStandards/PCI-DSS-3.2\"),\n\t// \tProperties: &armsecurity.RegulatoryComplianceStandardProperties{\n\t// \t\tFailedControls: to.Ptr[int32](4),\n\t// \t\tPassedControls: to.Ptr[int32](7),\n\t// \t\tSkippedControls: to.Ptr[int32](0),\n\t// \t\tState: to.Ptr(armsecurity.StateFailed),\n\t// \t\tUnsupportedControls: to.Ptr[int32](0),\n\t// \t},\n\t// }\n}", "title": "" }, { "docid": "adc0eda9a18882107bc9af2ced25a57f", "score": "0.44857743", "text": "func testGetCityReport(t *testing.T, c *TestContext) {\n\ttcc := []TestCase{\n\t\t*c.UserCheckTestCase, // 0 : token empty\n\t\t{\n\t\t\tToken: c.Config.Users.User.Token,\n\t\t\tSent: []byte(`inseeCode=a1&firstYear=2015&lastYear=2019`),\n\t\t\tRespContains: []string{`Rapport par commune, décodage inseeCode :`},\n\t\t\tStatusCode: http.StatusBadRequest}, // 1 : inseeCode not ok\n\t\t{\n\t\t\tToken: c.Config.Users.User.Token,\n\t\t\tSent: []byte(`inseeCode=77001&firstYear=a&lastYear=2019`),\n\t\t\tRespContains: []string{`Rapport par commune, décodage firstYear :`},\n\t\t\tStatusCode: http.StatusBadRequest}, // 2 : firstYear not ok\n\t\t{\n\t\t\tToken: c.Config.Users.User.Token,\n\t\t\tSent: []byte(`inseeCode=77001&firstYear=2015&lastYear=a`),\n\t\t\tRespContains: []string{`Rapport par commune, décodage lastYear :`},\n\t\t\tStatusCode: http.StatusBadRequest}, // 2 : lastYear not ok\n\t\t{Token: c.Config.Users.User.Token,\n\t\t\tSent: []byte(`inseeCode=77001&firstYear=2015&lastYear=2019`),\n\t\t\tRespContains: []string{`\"CityReport\":[`,\n\t\t\t\t`{\"Kind\":1,\"Year\":2015,\"Commitment\":30000000,\"Payment\":0}`},\n\t\t\tStatusCode: http.StatusOK}, // 3 : ok\n\t}\n\tf := func(tc TestCase) *httpexpect.Response {\n\t\treturn c.E.GET(\"/api/city_report\").WithQueryString(string(tc.Sent)).\n\t\t\tWithHeader(\"Authorization\", \"Bearer \"+tc.Token).Expect()\n\t}\n\tfor _, r := range chkFactory(tcc, f, \"GetCityReport\") {\n\t\tt.Error(r)\n\t}\n}", "title": "" }, { "docid": "a713e2856c5b0f40c79b4f088b782037", "score": "0.44843766", "text": "func (s *BBRequestTestSuite) TestGetPatient() {\n\tp, err := s.bbClient.GetPatient(\"012345\", \"543210\", \"A0000\", \"\", now)\n\tassert.Nil(s.T(), err)\n\tassert.Equal(s.T(), 1, len(p.Entries))\n\tassert.Equal(s.T(), \"20000000000001\", p.Entries[0][\"resource\"].(map[string]interface{})[\"id\"])\n}", "title": "" }, { "docid": "bc4c92c9829c5a8e69b03c8d7092182e", "score": "0.44816655", "text": "func NewUpdateClinicianRequest(server string, clinicId ClinicId, clinicianId ClinicianId, body UpdateClinicianJSONRequestBody) (*http.Request, error) {\n\tvar bodyReader io.Reader\n\tbuf, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbodyReader = bytes.NewReader(buf)\n\treturn NewUpdateClinicianRequestWithBody(server, clinicId, clinicianId, \"application/json\", bodyReader)\n}", "title": "" }, { "docid": "f656d1ca606e5ccb1c0eaa6303d38b00", "score": "0.44611377", "text": "func showPersonInfo(r result) {\n\tif r.Error != nil {\n\t\tlog.Printf(\"Response Error because err: %v\\n\", r.Error)\n\t\treturn\n\t}\n\n\tif len(r.Person.Results) == 0 {\n\t\tlog.Printf(\"Response Error: Person info not found\\n\")\n\t\treturn\n\t}\n\n\tinfo := r.Person.Results[0]\n\tfmt.Printf(\"[%v] Email: %v \\n\", r.Latency, info.Email)\n}", "title": "" }, { "docid": "9afc74ba9a9564ad2b670a02c1030ec9", "score": "0.44452384", "text": "func CreateGetOcJusticeTerminalCaseResponse() (response *GetOcJusticeTerminalCaseResponse) {\n\tresponse = &GetOcJusticeTerminalCaseResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "title": "" }, { "docid": "58d81ebc1a2ca4d0301040ff1e5a7b1b", "score": "0.44379413", "text": "func (o *GetSearchClinicsParams) WithName(name *string) *GetSearchClinicsParams {\n\to.SetName(name)\n\treturn o\n}", "title": "" }, { "docid": "d64cb88e105809ec3bfc9c7085566055", "score": "0.44333476", "text": "func (client IdentityClient) GetTenancy(ctx context.Context, request GetTenancyRequest) (response GetTenancyResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif client.RetryPolicy() != nil {\n\t\tpolicy = *client.RetryPolicy()\n\t}\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\tociResponse, err = common.Retry(ctx, request, client.getTenancy, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = GetTenancyResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = GetTenancyResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(GetTenancyResponse); ok {\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into GetTenancyResponse\")\n\t}\n\treturn\n}", "title": "" }, { "docid": "95a85c104b75272eae2ff9e9274a622f", "score": "0.44315615", "text": "func (o *PutClinicsClinicGUIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {\n\tswitch response.Code() {\n\n\tcase 200:\n\t\tresult := NewPutClinicsClinicGUIDOK()\n\t\tif err := result.readResponse(response, consumer, o.formats); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn result, nil\n\n\tcase 400:\n\t\tresult := NewPutClinicsClinicGUIDBadRequest()\n\t\tif err := result.readResponse(response, consumer, o.formats); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn nil, result\n\n\tcase 404:\n\t\tresult := NewPutClinicsClinicGUIDNotFound()\n\t\tif err := result.readResponse(response, consumer, o.formats); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn nil, result\n\n\tcase 405:\n\t\tresult := NewPutClinicsClinicGUIDMethodNotAllowed()\n\t\tif err := result.readResponse(response, consumer, o.formats); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn nil, result\n\n\tdefault:\n\t\treturn nil, runtime.NewAPIError(\"unknown error\", response, response.Code())\n\t}\n}", "title": "" }, { "docid": "82767c19c79325eb2bed0699f225a8d0", "score": "0.4422382", "text": "func (t *InsuranceChaincode) getCustomerByID(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n var customerId, jsonResp string\n\n if len(args) != 1 {\n return shim.Error(\"Incorrect number of arguments. Expecting customerId of the Insurance to query\")\n }\n\n customerId = args[0]\n valAsbytes, err := stub.GetState(customerId) \n if err != nil {\n jsonResp = \"{\\\"Error\\\":\\\"Failed to get state for \" + customerId + \"\\\"}\"\n return shim.Error(jsonResp)\n } else if valAsbytes == nil {\n jsonResp = \"{\\\"CustomerId\\\": \\\"\"+ customerId + \"\\\", \\\"Error\\\":\\\"Customer does not exist.\\\"}\"\n return shim.Error(jsonResp)\n }\n\n return shim.Success(valAsbytes)\n}", "title": "" }, { "docid": "99d4bbf901e4050fd8d098573b33e01a", "score": "0.44202578", "text": "func NewClinic(address common.Address, backend bind.ContractBackend) (*Clinic, error) {\n\tcontract, err := bindClinic(address, backend, backend, backend)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Clinic{ClinicCaller: ClinicCaller{contract: contract}, ClinicTransactor: ClinicTransactor{contract: contract}, ClinicFilterer: ClinicFilterer{contract: contract}}, nil\n}", "title": "" }, { "docid": "71f1db24e34577483d382021262f2018", "score": "0.44179553", "text": "func NewCreateClinicRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/clinics\")\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "92158ddf85db4911a6b3c143ff221da9", "score": "0.44068775", "text": "func ParseListClinicsForPatientResponse(rsp *http.Response) (*ListClinicsForPatientResponse, error) {\n\tbodyBytes, err := io.ReadAll(rsp.Body)\n\tdefer func() { _ = rsp.Body.Close() }()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse := &ListClinicsForPatientResponse{\n\t\tBody: bodyBytes,\n\t\tHTTPResponse: rsp,\n\t}\n\n\tswitch {\n\tcase strings.Contains(rsp.Header.Get(\"Content-Type\"), \"json\") && rsp.StatusCode == 200:\n\t\tvar dest PatientClinicRelationships\n\t\tif err := json.Unmarshal(bodyBytes, &dest); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresponse.JSON200 = &dest\n\n\t}\n\n\treturn response, nil\n}", "title": "" }, { "docid": "9e7aabc2c0593fbf484f64732018a618", "score": "0.44066024", "text": "func (a *ClinicalMetadataServiceApiService) GetPatient(ctx _context.Context, patientId string) (Ga4ghPatient, *_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = _nethttp.MethodGet\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue Ga4ghPatient\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/patients/{patient_id}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"patient_id\"+\"}\", _neturl.QueryEscape(fmt.Sprintf(\"%v\", patientId)), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHttpResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHttpResponse == nil {\n\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t}\n\n\tlocalVarBody, err := _ioutil.ReadAll(localVarHttpResponse.Body)\n\tlocalVarHttpResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t}\n\n\tif localVarHttpResponse.StatusCode >= 300 {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHttpResponse.Status,\n\t\t}\n\t\tif localVarHttpResponse.StatusCode == 200 {\n\t\t\tvar v Ga4ghPatient\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t}\n\n\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\tif err != nil {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: err.Error(),\n\t\t}\n\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t}\n\n\treturn localVarReturnValue, localVarHttpResponse, nil\n}", "title": "" }, { "docid": "7e41301703cd17e93ca6b85f68db69ae", "score": "0.44065183", "text": "func (c *ClinicClient) Query() *ClinicQuery {\n\treturn &ClinicQuery{config: c.config}\n}", "title": "" }, { "docid": "d8dccef7708cc9b6c5c7869e9e249835", "score": "0.44061792", "text": "func getClientInfo(ctx echo.Context) error {\n\tglog.Infof(\"calling getClientInfo from %s\", ctx.Request().RemoteAddr)\n\n\tclientId := ctx.Param(\"clientId\")\n\tif clientId == \"\" {\n\t\treturn ctx.JSON(http.StatusBadRequest,\n\t\t\t&response{\n\t\t\t\tSuccess: false,\n\t\t\t\tMessage: \"Invalid parameter\",\n\t\t\t})\n\t}\n\n\tconfig := ctx.(*apiContext).config\n\thosts := config.MustString(\"condutor\", \"mongo\")\n\tsession, err := mgo.Dial(hosts)\n\tif err != nil {\n\t\tglog.Errorf(\"getClientInfo:%v\", err)\n\t\treturn ctx.JSON(http.StatusInternalServerError,\n\t\t\t&response{\n\t\t\t\tSuccess: false,\n\t\t\t\tMessage: err.Error(),\n\t\t\t})\n\t}\n\tc := session.DB(\"iothub\").C(\"clients\")\n\tdefer session.Close()\n\n\tclients := []collector.Client{}\n\tif err := c.Find(bson.M{\"ClientId\": clientId}).Limit(100).Iter().All(&clients); err != nil {\n\t\tglog.Errorf(\"getClientInfo:%v\", err)\n\t\treturn ctx.JSON(http.StatusNotFound,\n\t\t\t&response{\n\t\t\t\tSuccess: false,\n\t\t\t\tMessage: err.Error(),\n\t\t\t})\n\t}\n\treturn ctx.JSON(http.StatusOK, &response{\n\t\tSuccess: true,\n\t\tResult: clients,\n\t})\n}", "title": "" }, { "docid": "7edb9714ce60091ca4e00c3a7ac2592d", "score": "0.4399709", "text": "func (c *ClientWithResponses) DeleteClinicWithResponse(ctx context.Context, clinicId ClinicId, reqEditors ...RequestEditorFn) (*DeleteClinicResponse, error) {\n\trsp, err := c.DeleteClinic(ctx, clinicId, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseDeleteClinicResponse(rsp)\n}", "title": "" }, { "docid": "466d9204bd1d1405085a2c9accfccf54", "score": "0.4394247", "text": "func NewGetPatientRequest(server string, clinicId ClinicId, patientId PatientId) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"clinicId\", runtime.ParamLocationPath, clinicId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar pathParam1 string\n\n\tpathParam1, err = runtime.StyleParamWithLocation(\"simple\", false, \"patientId\", runtime.ParamLocationPath, patientId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/clinics/%s/patients/%s\", pathParam0, pathParam1)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"GET\", queryURL.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "title": "" }, { "docid": "d86a405e11b6070171ebde4920ec9dea", "score": "0.43867496", "text": "func NewAssociateClinicianToUserRequestWithBody(server string, clinicId ClinicId, inviteId InviteId, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"clinicId\", runtime.ParamLocationPath, clinicId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar pathParam1 string\n\n\tpathParam1, err = runtime.StyleParamWithLocation(\"simple\", false, \"inviteId\", runtime.ParamLocationPath, inviteId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/clinics/%s/invites/clinicians/%s/clinician\", pathParam0, pathParam1)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"PATCH\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "03e56224707854fc48edb0edab038efe", "score": "0.43848827", "text": "func GetCertif(w http.ResponseWriter, r *http.Request) {\r\n\tparams := mux.Vars(r)\r\n\tverifi := \"not ok\"\r\n\t\r\n\t//We verify whether the required certificate exists or not\r\n\tfor _, itemm := range certif {\r\n\t\tif itemm.Id==params[\"id\"] {\r\n\t\t\tverifi=\"ok\"\r\n\t\t}\r\n\t}\r\n\t\r\n\tif verifi==\"ok\" {\r\n\t\tfor _, item := range certif {\r\n\t\t\tif item.Id == params[\"id\"] && item.Ownerid==clientnum { //Display information only if the owner ID of the certificate is the same as the connected user ID\r\n\t\t\t\tjson.NewEncoder(w).Encode(item)\r\n\t\t\t\treturn\r\n\t\t\t}\telse if item.Id == params[\"id\"] && item.Ownerid!=clientnum {\r\n\t\t\t\tfmt.Fprintf(w, \"You can't access this certificate.\") //If the certificate does not belong to the connected user: return this message\r\n\t\t\t}\r\n\t\t}\r\n\t}\telse {\r\n\t\tfmt.Fprintf(w, \"This certificate does not exist.\")\r\n\t}\r\n}", "title": "" }, { "docid": "30ae52b9e58f24011642afa871b51589", "score": "0.43638706", "text": "func NewUpdateClinicianRequestWithBody(server string, clinicId ClinicId, clinicianId ClinicianId, contentType string, body io.Reader) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"clinicId\", runtime.ParamLocationPath, clinicId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar pathParam1 string\n\n\tpathParam1, err = runtime.StyleParamWithLocation(\"simple\", false, \"clinicianId\", runtime.ParamLocationPath, clinicianId)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/clinics/%s/clinicians/%s\", pathParam0, pathParam1)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"PUT\", queryURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", contentType)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "a146c268d061e5628fe9dd7e6497458a", "score": "0.436107", "text": "func (c *TrialController) Get(w http.ResponseWriter, r *http.Request,\n\tp httprouter.Params) {\n\n\tstudy, trial := p.ByName(\"study\"), p.ByName(\"trial\")\n\tid := fmt.Sprintf(\"/studies/%s/trials/%s\", study, trial)\n\tdata, err := c.studies.Get([]byte(id))\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), 500)\n\t\treturn\n\t}\n\tif data == nil {\n\t\thttp.Error(w, id+\" not found\", http.StatusNoContent)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Write(data)\n}", "title": "" }, { "docid": "506e6800cecaa1ddb3f01cc11192bf28", "score": "0.43451878", "text": "func ParseUpdateClinicianResponse(rsp *http.Response) (*UpdateClinicianResponse, error) {\n\tbodyBytes, err := io.ReadAll(rsp.Body)\n\tdefer func() { _ = rsp.Body.Close() }()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse := &UpdateClinicianResponse{\n\t\tBody: bodyBytes,\n\t\tHTTPResponse: rsp,\n\t}\n\n\treturn response, nil\n}", "title": "" }, { "docid": "7415c1019d9587c41d225065c85500bc", "score": "0.433169", "text": "func (r *CompanyRequest) Get(ctx context.Context) (resObj *Company, err error) {\n\tvar query string\n\tif r.query != nil {\n\t\tquery = \"?\" + r.query.Encode()\n\t}\n\terr = r.JSONRequest(ctx, \"GET\", query, nil, &resObj)\n\treturn\n}", "title": "" }, { "docid": "2881db6fc3aec81ac91335bd7cae602f", "score": "0.4325816", "text": "func (c *ClientWithResponses) UpdateClinicWithBodyWithResponse(ctx context.Context, clinicId ClinicId, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateClinicResponse, error) {\n\trsp, err := c.UpdateClinicWithBody(ctx, clinicId, contentType, body, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseUpdateClinicResponse(rsp)\n}", "title": "" }, { "docid": "afce10464aa58939acf6aafb7e00d481", "score": "0.43232456", "text": "func (h HospitalityResource) HospitalityGetByRequest(request *restful.Request, response *restful.Response) {\n\thr := &hospitality.Request{}\n\terr := request.ReadEntity(&hr)\n\n\tif err != nil {\n\t\tresponse.AddHeader(\"Content-Type\", \"text/plain\")\n\t\tresponse.WriteErrorString(http.StatusInternalServerError, err.Error())\n\t\treturn\n\t}\n\n\tlog.Infof(\"Try to get hospitality score by %v\", hr)\n\tscore := &hospitality.Hospitality{}\n\te := score.GetByRequest(hr)\n\tif e != nil {\n\t\terr := e.(*rmderror.AppError)\n\t\tresponse.WriteErrorString(err.Code, err.Error())\n\t\treturn\n\t}\n\tresponse.WriteEntity(score)\n}", "title": "" }, { "docid": "e21ac30dff0d1b9599a73e5cc602235b", "score": "0.43190342", "text": "func (proxy *httpProxy) getCustType(custId string) (custType string, err error) {\n\turl := proxy.urlGetCustType + custId\n\tresponse, err := proxy.requestUrl(url)\n\tif err != nil {\n\t\treturn\n\t}\n\tcustType, err = decodeCustInfo(response)\n\treturn\n}", "title": "" }, { "docid": "0845c0d8f67b8db9dd9cf516d6b8b146", "score": "0.43067482", "text": "func (o *GetSearchClinicsParams) WithContext(ctx context.Context) *GetSearchClinicsParams {\n\to.SetContext(ctx)\n\treturn o\n}", "title": "" } ]
bfb0e40b3f45a33855990a85e28ada17
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomClusterParameters.
[ { "docid": "eb5b3246756ee681c7dbf70b3e4e2b97", "score": "0.87577605", "text": "func (in *CustomClusterParameters) DeepCopy() *CustomClusterParameters {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CustomClusterParameters)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" } ]
[ { "docid": "608bad27615b023b965857a9164e306a", "score": "0.7591617", "text": "func (in *ClusterParameters) DeepCopy() *ClusterParameters {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterParameters)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "608bad27615b023b965857a9164e306a", "score": "0.7591617", "text": "func (in *ClusterParameters) DeepCopy() *ClusterParameters {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterParameters)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "e0b87e2caa9e93e4c43f7e82e33f0a30", "score": "0.6422545", "text": "func (in *CustomKeyParameters) DeepCopy() *CustomKeyParameters {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CustomKeyParameters)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "e65f3a25a0119b4818bf9c55b5ed837a", "score": "0.6360227", "text": "func (in *DocdbClusterParameters) DeepCopy() *DocdbClusterParameters {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(DocdbClusterParameters)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "d1eff86407105da163f7848ca9bbe7e2", "score": "0.63514596", "text": "func (in *ClusterOverrides) DeepCopy() *ClusterOverrides {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterOverrides)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "e0267558eb4f353a532171bab447884d", "score": "0.6330245", "text": "func (in *CustomParameterGroupParameters) DeepCopy() *CustomParameterGroupParameters {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CustomParameterGroupParameters)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "7928592fa8f7f11a14598309643c09d0", "score": "0.63186264", "text": "func (in *CustomServiceParameters) DeepCopy() *CustomServiceParameters {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CustomServiceParameters)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "bce4106f087325dd3f5b07bfc7c489b9", "score": "0.62962145", "text": "func (in *CustomLoadBalancerParameters) DeepCopy() *CustomLoadBalancerParameters {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CustomLoadBalancerParameters)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "937d0180da7df754595f5412d0d31c6c", "score": "0.61273205", "text": "func (in *Cluster) DeepCopy() *Cluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(Cluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "937d0180da7df754595f5412d0d31c6c", "score": "0.61273205", "text": "func (in *Cluster) DeepCopy() *Cluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(Cluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "937d0180da7df754595f5412d0d31c6c", "score": "0.61273205", "text": "func (in *Cluster) DeepCopy() *Cluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(Cluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "937d0180da7df754595f5412d0d31c6c", "score": "0.61273205", "text": "func (in *Cluster) DeepCopy() *Cluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(Cluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "937d0180da7df754595f5412d0d31c6c", "score": "0.61273205", "text": "func (in *Cluster) DeepCopy() *Cluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(Cluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "937d0180da7df754595f5412d0d31c6c", "score": "0.61273205", "text": "func (in *Cluster) DeepCopy() *Cluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(Cluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "937d0180da7df754595f5412d0d31c6c", "score": "0.61273205", "text": "func (in *Cluster) DeepCopy() *Cluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(Cluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "937d0180da7df754595f5412d0d31c6c", "score": "0.61273205", "text": "func (in *Cluster) DeepCopy() *Cluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(Cluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "1c53cf8f3a2bc58d4ba1accf83e76da1", "score": "0.6118021", "text": "func (in *CustomDomainParameters) DeepCopy() *CustomDomainParameters {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CustomDomainParameters)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "e1ae2f0b0437524fd6f9871d6541d7c2", "score": "0.6064561", "text": "func (in *CustomSubnetGroupParameters) DeepCopy() *CustomSubnetGroupParameters {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CustomSubnetGroupParameters)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "d492e0ebf2448017dd1b56bd22f8dfaf", "score": "0.6028716", "text": "func (in *ClusterMetadata) DeepCopy() *ClusterMetadata {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterMetadata)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "8ef66b67b18658d56aebb50dfde05bae", "score": "0.6019678", "text": "func (in *CustomTargetGroupParameters) DeepCopy() *CustomTargetGroupParameters {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CustomTargetGroupParameters)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "a01bd17c2c860c3de047db1c26986df5", "score": "0.5990253", "text": "func (in *KafkaCluster) DeepCopy() *KafkaCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(KafkaCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "a01bd17c2c860c3de047db1c26986df5", "score": "0.5990253", "text": "func (in *KafkaCluster) DeepCopy() *KafkaCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(KafkaCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "69bb0dc39bd79c4edf1698f57fc2f4c5", "score": "0.5988085", "text": "func (in *CustomRouteParameters) DeepCopy() *CustomRouteParameters {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CustomRouteParameters)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "15e5b4d84e6d4d06a7d1ec24fdb416aa", "score": "0.5983913", "text": "func (in *Metal3Cluster) DeepCopy() *Metal3Cluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(Metal3Cluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "3e6545e679e4aff0d273aaa0dbcc5996", "score": "0.5930864", "text": "func (s *ManagedClusterSpec) Parameters(existing interface{}) (params interface{}, err error) {\n\tdecodedSSHPublicKey, err := base64.StdEncoding.DecodeString(s.SSHPublicKey)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to decode SSHPublicKey\")\n\t}\n\tmanagedCluster := containerservice.ManagedCluster{\n\t\tIdentity: &containerservice.ManagedClusterIdentity{\n\t\t\tType: containerservice.ResourceIdentityTypeSystemAssigned,\n\t\t},\n\t\tLocation: &s.Location,\n\t\tManagedClusterProperties: &containerservice.ManagedClusterProperties{\n\t\t\tNodeResourceGroup: &s.NodeResourceGroup,\n\t\t\tEnableRBAC: to.BoolPtr(true),\n\t\t\tDNSPrefix: &s.Name,\n\t\t\tKubernetesVersion: &s.Version,\n\t\t\tLinuxProfile: &containerservice.LinuxProfile{\n\t\t\t\tAdminUsername: to.StringPtr(azure.DefaultAKSUserName),\n\t\t\t\tSSH: &containerservice.SSHConfiguration{\n\t\t\t\t\tPublicKeys: &[]containerservice.SSHPublicKey{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tKeyData: to.StringPtr(string(decodedSSHPublicKey)),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tServicePrincipalProfile: &containerservice.ManagedClusterServicePrincipalProfile{\n\t\t\t\tClientID: to.StringPtr(\"msi\"),\n\t\t\t},\n\t\t\tAgentPoolProfiles: &[]containerservice.ManagedClusterAgentPoolProfile{},\n\t\t\tNetworkProfile: &containerservice.NetworkProfile{\n\t\t\t\tNetworkPlugin: containerservice.NetworkPlugin(s.NetworkPlugin),\n\t\t\t\tLoadBalancerSku: containerservice.LoadBalancerSku(s.LoadBalancerSKU),\n\t\t\t\tNetworkPolicy: containerservice.NetworkPolicy(s.NetworkPolicy),\n\t\t\t},\n\t\t},\n\t}\n\n\tif tags := *to.StringMapPtr(s.Tags); len(tags) != 0 {\n\t\tmanagedCluster.Tags = tags\n\t}\n\n\tif s.PodCIDR != \"\" {\n\t\tmanagedCluster.NetworkProfile.PodCidr = &s.PodCIDR\n\t}\n\n\tif s.ServiceCIDR != \"\" {\n\t\tif s.DNSServiceIP == nil {\n\t\t\tmanagedCluster.NetworkProfile.ServiceCidr = &s.ServiceCIDR\n\t\t\tip, _, err := net.ParseCIDR(s.ServiceCIDR)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to parse service cidr: %w\", err)\n\t\t\t}\n\t\t\t// HACK: set the last octet of the IP to .10\n\t\t\t// This ensures the dns IP is valid in the service cidr without forcing the user\n\t\t\t// to specify it in both the Capi cluster and the Azure control plane.\n\t\t\t// https://golang.org/src/net/ip.go#L48\n\t\t\tip[15] = byte(10)\n\t\t\tdnsIP := ip.String()\n\t\t\tmanagedCluster.NetworkProfile.DNSServiceIP = &dnsIP\n\t\t} else {\n\t\t\tmanagedCluster.NetworkProfile.DNSServiceIP = s.DNSServiceIP\n\t\t}\n\t}\n\n\tif s.AADProfile != nil {\n\t\tmanagedCluster.AadProfile = &containerservice.ManagedClusterAADProfile{\n\t\t\tManaged: &s.AADProfile.Managed,\n\t\t\tEnableAzureRBAC: &s.AADProfile.EnableAzureRBAC,\n\t\t\tAdminGroupObjectIDs: &s.AADProfile.AdminGroupObjectIDs,\n\t\t}\n\t}\n\n\tfor i := range s.AddonProfiles {\n\t\tif managedCluster.AddonProfiles == nil {\n\t\t\tmanagedCluster.AddonProfiles = map[string]*containerservice.ManagedClusterAddonProfile{}\n\t\t}\n\t\titem := s.AddonProfiles[i]\n\t\taddonProfile := &containerservice.ManagedClusterAddonProfile{\n\t\t\tEnabled: &item.Enabled,\n\t\t}\n\t\tif item.Config != nil {\n\t\t\taddonProfile.Config = *to.StringMapPtr(item.Config)\n\t\t}\n\t\tmanagedCluster.AddonProfiles[item.Name] = addonProfile\n\t}\n\n\tif s.SKU != nil {\n\t\ttierName := containerservice.ManagedClusterSKUTier(s.SKU.Tier)\n\t\tmanagedCluster.Sku = &containerservice.ManagedClusterSKU{\n\t\t\tName: containerservice.ManagedClusterSKUNameBasic,\n\t\t\tTier: tierName,\n\t\t}\n\t}\n\n\tif s.LoadBalancerProfile != nil {\n\t\tmanagedCluster.NetworkProfile.LoadBalancerProfile = &containerservice.ManagedClusterLoadBalancerProfile{\n\t\t\tAllocatedOutboundPorts: s.LoadBalancerProfile.AllocatedOutboundPorts,\n\t\t\tIdleTimeoutInMinutes: s.LoadBalancerProfile.IdleTimeoutInMinutes,\n\t\t}\n\t\tif s.LoadBalancerProfile.ManagedOutboundIPs != nil {\n\t\t\tmanagedCluster.NetworkProfile.LoadBalancerProfile.ManagedOutboundIPs = &containerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{Count: s.LoadBalancerProfile.ManagedOutboundIPs}\n\t\t}\n\t\tif len(s.LoadBalancerProfile.OutboundIPPrefixes) > 0 {\n\t\t\tmanagedCluster.NetworkProfile.LoadBalancerProfile.OutboundIPPrefixes = &containerservice.ManagedClusterLoadBalancerProfileOutboundIPPrefixes{\n\t\t\t\tPublicIPPrefixes: convertToResourceReferences(s.LoadBalancerProfile.OutboundIPPrefixes),\n\t\t\t}\n\t\t}\n\t\tif len(s.LoadBalancerProfile.OutboundIPs) > 0 {\n\t\t\tmanagedCluster.NetworkProfile.LoadBalancerProfile.OutboundIPs = &containerservice.ManagedClusterLoadBalancerProfileOutboundIPs{\n\t\t\t\tPublicIPs: convertToResourceReferences(s.LoadBalancerProfile.OutboundIPs),\n\t\t\t}\n\t\t}\n\t}\n\n\tif s.APIServerAccessProfile != nil {\n\t\tmanagedCluster.APIServerAccessProfile = &containerservice.ManagedClusterAPIServerAccessProfile{\n\t\t\tAuthorizedIPRanges: &s.APIServerAccessProfile.AuthorizedIPRanges,\n\t\t\tEnablePrivateCluster: s.APIServerAccessProfile.EnablePrivateCluster,\n\t\t\tPrivateDNSZone: s.APIServerAccessProfile.PrivateDNSZone,\n\t\t\tEnablePrivateClusterPublicFQDN: s.APIServerAccessProfile.EnablePrivateClusterPublicFQDN,\n\t\t}\n\t}\n\n\tif existing != nil {\n\t\texistingMC, ok := existing.(containerservice.ManagedCluster)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"%T is not a containerservice.ManagedCluster\", existing)\n\t\t}\n\t\tps := *existingMC.ManagedClusterProperties.ProvisioningState\n\t\tif ps != string(infrav1.Canceled) && ps != string(infrav1.Failed) && ps != string(infrav1.Succeeded) {\n\t\t\treturn nil, azure.WithTransientError(errors.Errorf(\"Unable to update existing managed cluster in non-terminal state. Managed cluster must be in one of the following provisioning states: Canceled, Failed, or Succeeded. Actual state: %s\", ps), 20*time.Second)\n\t\t}\n\n\t\t// Normalize the LoadBalancerProfile so the diff below doesn't get thrown off by AKS added properties.\n\t\tif managedCluster.NetworkProfile.LoadBalancerProfile == nil {\n\t\t\t// If our LoadBalancerProfile generated by the spec is nil, then don't worry about what AKS has added.\n\t\t\texistingMC.NetworkProfile.LoadBalancerProfile = nil\n\t\t} else {\n\t\t\t// If our LoadBalancerProfile generated by the spec is not nil, then remove the effective outbound IPs from\n\t\t\t// AKS.\n\t\t\texistingMC.NetworkProfile.LoadBalancerProfile.EffectiveOutboundIPs = nil\n\t\t}\n\n\t\t// Avoid changing agent pool profiles through AMCP and just use the existing agent pool profiles\n\t\t// AgentPool changes are managed through AMMP.\n\t\tmanagedCluster.AgentPoolProfiles = existingMC.AgentPoolProfiles\n\n\t\tdiff := computeDiffOfNormalizedClusters(managedCluster, existingMC)\n\t\tif diff == \"\" {\n\t\t\treturn nil, nil\n\t\t}\n\t} else {\n\t\t// Add all agent pools to cluster spec that will be submitted to the API\n\t\tagentPoolSpecs, err := s.GetAllAgentPools()\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to get agent pool specs for managed cluster %s\", s.Name)\n\t\t}\n\n\t\tfor i := range agentPoolSpecs {\n\t\t\tprofile := converters.AgentPoolToManagedClusterAgentPoolProfile(agentPoolSpecs[i])\n\t\t\t*managedCluster.AgentPoolProfiles = append(*managedCluster.AgentPoolProfiles, profile)\n\t\t}\n\t}\n\n\treturn managedCluster, nil\n}", "title": "" }, { "docid": "875f60541c9d9f2f06e6e9930385fc5f", "score": "0.5884903", "text": "func (in *CustomListenerParameters) DeepCopy() *CustomListenerParameters {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CustomListenerParameters)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "62c26e5ba76a98419755c3a5c9846941", "score": "0.5880072", "text": "func (in *ClusterValueFrom) DeepCopy() *ClusterValueFrom {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterValueFrom)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "df0178229cceba14310ac833a367f620", "score": "0.58694524", "text": "func (in *CustomAddonParameters) DeepCopy() *CustomAddonParameters {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CustomAddonParameters)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "74892bab6fcdea91ed2590fee0073be3", "score": "0.5865147", "text": "func (in *ClusterVirtualClusterConfig) DeepCopy() *ClusterVirtualClusterConfig {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterVirtualClusterConfig)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "f0ad42ed9d8c9e1f16c6692f43c3e5bc", "score": "0.58649516", "text": "func (in *ClickHouseCluster) DeepCopy() *ClickHouseCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClickHouseCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "b825169acd71221a37fd527b0237aef0", "score": "0.5855583", "text": "func (in *DataprocCluster) DeepCopy() *DataprocCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(DataprocCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "2dc600a3fd9f26aaa38df2c8183492d4", "score": "0.5847322", "text": "func (in *ClusterKubernetesClusterConfig) DeepCopy() *ClusterKubernetesClusterConfig {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterKubernetesClusterConfig)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "fae6d1eadbe1e8180e3fab1dd6eb4cae", "score": "0.5838166", "text": "func (in *ClusterWorkloadMetadataConfig) DeepCopy() *ClusterWorkloadMetadataConfig {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterWorkloadMetadataConfig)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "dfee1c0d19765b48c7f937b39b897e71", "score": "0.5837529", "text": "func (in *ClusterAttributes) DeepCopy() *ClusterAttributes {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterAttributes)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "be6bcca0258a769d2db1be6c7c284109", "score": "0.5832414", "text": "func (in *ClusterPrivateClusterConfig) DeepCopy() *ClusterPrivateClusterConfig {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterPrivateClusterConfig)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "4ac53f91047ad4d86e93ffc5fc588bcd", "score": "0.5832007", "text": "func (in *ClusterChartPreset) DeepCopy() *ClusterChartPreset {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterChartPreset)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "142702af4766543c5644bbba6ccc45d3", "score": "0.58278865", "text": "func (in *KafkaClusterSpec) DeepCopy() *KafkaClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(KafkaClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "142702af4766543c5644bbba6ccc45d3", "score": "0.58278865", "text": "func (in *KafkaClusterSpec) DeepCopy() *KafkaClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(KafkaClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "2201fb2d1186f2ae08e9193e627cd489", "score": "0.5793577", "text": "func (in *ClusterClusterTelemetry) DeepCopy() *ClusterClusterTelemetry {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterClusterTelemetry)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "cecabc08c1409fe41777fd66fe5fc6fc", "score": "0.5778749", "text": "func (in *ClusterKubeletConfig) DeepCopy() *ClusterKubeletConfig {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterKubeletConfig)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "61643e13031310334a2e7051b3f12a45", "score": "0.5759892", "text": "func (in *ClusterChartPresetSpec) DeepCopy() *ClusterChartPresetSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterChartPresetSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "2aefd9fc3e8f55d66f5d572314909e94", "score": "0.5744121", "text": "func (in *CustomTaskDefinitionParameters) DeepCopy() *CustomTaskDefinitionParameters {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CustomTaskDefinitionParameters)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "42d3bf631938a670765a1c1253b797d0", "score": "0.57380813", "text": "func (in *ClusterWorkloadConfig) DeepCopy() *ClusterWorkloadConfig {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterWorkloadConfig)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "6aacbbc1ff3a57c2d3aa6815bcdf28a6", "score": "0.5716083", "text": "func (in *MembershipGkeCluster) DeepCopy() *MembershipGkeCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(MembershipGkeCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "6aacbbc1ff3a57c2d3aa6815bcdf28a6", "score": "0.5716083", "text": "func (in *MembershipGkeCluster) DeepCopy() *MembershipGkeCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(MembershipGkeCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "7d88d82734ec31efa8ceb57e4e5900db", "score": "0.5709804", "text": "func (in *ClusterInfo) DeepCopy() *ClusterInfo {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterInfo)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "7d88d82734ec31efa8ceb57e4e5900db", "score": "0.5709804", "text": "func (in *ClusterInfo) DeepCopy() *ClusterInfo {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterInfo)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "f360cdfc5af35b4bdb8070f28b8da241", "score": "0.5692516", "text": "func (in *NewCluster) DeepCopy() *NewCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(NewCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "4a95f311939438b6ff5544362f0901f2", "score": "0.5664859", "text": "func (in *KubemqCluster) DeepCopy() *KubemqCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(KubemqCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "41d1ca98d4390a3e1ff255219ffef81f", "score": "0.5625393", "text": "func (in *CustomLifecyclePolicyParameters) DeepCopy() *CustomLifecyclePolicyParameters {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(CustomLifecyclePolicyParameters)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "6b9a85bc0bc4c7c41417164bb908d567", "score": "0.5612948", "text": "func (in *BridgeCluster) DeepCopy() *BridgeCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(BridgeCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "3ced29b62079bab04234495ddc82e19a", "score": "0.5610266", "text": "func (in *VitessCluster) DeepCopy() *VitessCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(VitessCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "60caa6325f40e14aa7660742a2365d6f", "score": "0.5602056", "text": "func (in *ClusterRequirements) DeepCopy() *ClusterRequirements {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterRequirements)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "642af1e870996bb88ba08e230a5ee3d4", "score": "0.5598185", "text": "func (in *ContainerCluster) DeepCopy() *ContainerCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ContainerCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "bc20b150784f5f091993e859cffb7ec7", "score": "0.5597006", "text": "func (in *WorkflowtemplateManagedCluster) DeepCopy() *WorkflowtemplateManagedCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(WorkflowtemplateManagedCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "d0844bddfd4f23766234e00e95e3e823", "score": "0.5581826", "text": "func (in *ClusterDataprocMetricConfig) DeepCopy() *ClusterDataprocMetricConfig {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterDataprocMetricConfig)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "d000cda25ce88fafab654b420ad5ea9f", "score": "0.55741644", "text": "func (in *ClusterBuilder) DeepCopy() *ClusterBuilder {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterBuilder)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "7e516735968de51a73c0588998c604d3", "score": "0.5560392", "text": "func (in *ClusterCondition) DeepCopy() *ClusterCondition {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterCondition)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "7e516735968de51a73c0588998c604d3", "score": "0.5560392", "text": "func (in *ClusterCondition) DeepCopy() *ClusterCondition {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterCondition)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "7e516735968de51a73c0588998c604d3", "score": "0.5560392", "text": "func (in *ClusterCondition) DeepCopy() *ClusterCondition {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterCondition)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "7e516735968de51a73c0588998c604d3", "score": "0.5560392", "text": "func (in *ClusterCondition) DeepCopy() *ClusterCondition {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterCondition)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "7e516735968de51a73c0588998c604d3", "score": "0.5560392", "text": "func (in *ClusterCondition) DeepCopy() *ClusterCondition {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterCondition)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "1b6692c2bad9e6690f03795c18c91175", "score": "0.5560195", "text": "func (in *ClusterConfiguration) DeepCopy() *ClusterConfiguration {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterConfiguration)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "1b6692c2bad9e6690f03795c18c91175", "score": "0.5560195", "text": "func (in *ClusterConfiguration) DeepCopy() *ClusterConfiguration {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterConfiguration)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "b0572731a4230fa805c48547bf559767", "score": "0.5557007", "text": "func (in *ClickHouseClusterSpec) DeepCopy() *ClickHouseClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClickHouseClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "93bd3f5eeeded1f7a8db63546b683106", "score": "0.5551207", "text": "func (in *VitessClusterSpec) DeepCopy() *VitessClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(VitessClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5d5cbe287abeee4ad962345879dcc6df", "score": "0.5547878", "text": "func (in *ClusterSpec) DeepCopy() *ClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5d5cbe287abeee4ad962345879dcc6df", "score": "0.5547878", "text": "func (in *ClusterSpec) DeepCopy() *ClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5d5cbe287abeee4ad962345879dcc6df", "score": "0.5547878", "text": "func (in *ClusterSpec) DeepCopy() *ClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5d5cbe287abeee4ad962345879dcc6df", "score": "0.5547878", "text": "func (in *ClusterSpec) DeepCopy() *ClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5d5cbe287abeee4ad962345879dcc6df", "score": "0.5547878", "text": "func (in *ClusterSpec) DeepCopy() *ClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5d5cbe287abeee4ad962345879dcc6df", "score": "0.5547878", "text": "func (in *ClusterSpec) DeepCopy() *ClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5d5cbe287abeee4ad962345879dcc6df", "score": "0.5547878", "text": "func (in *ClusterSpec) DeepCopy() *ClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5d5cbe287abeee4ad962345879dcc6df", "score": "0.5547878", "text": "func (in *ClusterSpec) DeepCopy() *ClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5d5cbe287abeee4ad962345879dcc6df", "score": "0.5547878", "text": "func (in *ClusterSpec) DeepCopy() *ClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "5d5cbe287abeee4ad962345879dcc6df", "score": "0.5547878", "text": "func (in *ClusterSpec) DeepCopy() *ClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "c90ac54a94824ece9979c5a5ef2b6d2e", "score": "0.55437565", "text": "func (in *ClusterClaimCondition) DeepCopy() *ClusterClaimCondition {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterClaimCondition)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "4f1dedad60537c0312dc617088979328", "score": "0.554339", "text": "func (in *ClusterOpenIDConnectPreset) DeepCopy() *ClusterOpenIDConnectPreset {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterOpenIDConnectPreset)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "4c11560c2372c115c7b933da66d38400", "score": "0.55433565", "text": "func (in *MysqlCluster) DeepCopy() *MysqlCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(MysqlCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "d97018cdf2ab3954d388471117f4fbb9", "score": "0.5541082", "text": "func (in *BridgeClusterSpec) DeepCopy() *BridgeClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(BridgeClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "491f4d56b0ebbcedd1f57a02a4bbf673", "score": "0.55408514", "text": "func (in *ClusterNotificationConfig) DeepCopy() *ClusterNotificationConfig {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterNotificationConfig)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "546d7159654d3593138cfb7154c4a856", "score": "0.5535303", "text": "func (in *FlashSystemCluster) DeepCopy() *FlashSystemCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(FlashSystemCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "0f3616ec3b114454b9e571c8a4c8f6dc", "score": "0.5533785", "text": "func (in *ClusterGkeClusterConfig) DeepCopy() *ClusterGkeClusterConfig {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterGkeClusterConfig)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "a2dbf7d79ec643f03a31e2d08bd87f9e", "score": "0.55270326", "text": "func (in *RemoteCluster) DeepCopy() *RemoteCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(RemoteCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "50a14a709c2b046ac694fc9926396443", "score": "0.5522993", "text": "func (in *TbmCluster) DeepCopy() *TbmCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(TbmCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "c8b2f731178f869716d72cf484c56423", "score": "0.55187744", "text": "func (in *ClusterLoggingConfig) DeepCopy() *ClusterLoggingConfig {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterLoggingConfig)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "3501a2f28ea7d81ae790597b03d23c78", "score": "0.5509346", "text": "func (in *DataprocClusterSpec) DeepCopy() *DataprocClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(DataprocClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "a2c392068372e6fd106e24f50184d27e", "score": "0.5507798", "text": "func (in *ContainerClusterSpec) DeepCopy() *ContainerClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ContainerClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "bf87b5cd2f1114a43d35bd2136c8828f", "score": "0.55046695", "text": "func (k *KubernetesClusterV3) Copy() *KubernetesClusterV3 {\n\treturn proto.Clone(k).(*KubernetesClusterV3)\n}", "title": "" }, { "docid": "c0dd109111981a06e6b6376f7fee1494", "score": "0.5504395", "text": "func (in *Metal3ClusterSpec) DeepCopy() *Metal3ClusterSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(Metal3ClusterSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "8759219a70ff0cc14125cfdfe0cb167b", "score": "0.55040765", "text": "func (in *RedisCluster) DeepCopy() *RedisCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(RedisCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "6d16fc13573429e088089b28196ba362", "score": "0.5497065", "text": "func (in *GitOpsCluster) DeepCopy() *GitOpsCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(GitOpsCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "a60ef9eee5e67750b0656883c037417f", "score": "0.547841", "text": "func (in *ClusterCloudrunConfig) DeepCopy() *ClusterCloudrunConfig {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterCloudrunConfig)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "d0b46450b000350d0965ea00a0062a51", "score": "0.5474161", "text": "func (in *ClusterOpenIDConnectPresetSpec) DeepCopy() *ClusterOpenIDConnectPresetSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterOpenIDConnectPresetSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "17f4322101ffac75a8f7808d666c7618", "score": "0.54704106", "text": "func (in *ClusterPassword) DeepCopy() *ClusterPassword {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterPassword)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "fdc5d33b5ede92f70feb2c5cd8cdbce6", "score": "0.54664516", "text": "func (in *ManagedCluster) DeepCopy() *ManagedCluster {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ManagedCluster)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "7138a8dd6c9701ae1747548959c059af", "score": "0.54614633", "text": "func (in *ClusterClaimSpec) DeepCopy() *ClusterClaimSpec {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterClaimSpec)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "48d695078bd8c6d637f4a6259b5421ed", "score": "0.5455974", "text": "func (in *ClusterClaim) DeepCopy() *ClusterClaim {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ClusterClaim)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "66ad8b89d1bac3a27faaa4e0de589056", "score": "0.54555404", "text": "func (in *KafkaClusterList) DeepCopy() *KafkaClusterList {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(KafkaClusterList)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" } ]
0c9c77d437909e98157725d98c1ec074
NpcBy wraps the given Entity as a Npc.
[ { "docid": "f5447e412265cd911721a91d3ea3ae91", "score": "0.83471155", "text": "func NpcBy(entity *entity.Entity) *Npc {\n\treturn &Npc{entity}\n}", "title": "" } ]
[ { "docid": "40942678f108d3be293cce8eb3e2d6ff", "score": "0.5099121", "text": "func (s *sqlService) Npcs() (npcs []definitions.NpcDefinition) {\n\ts.Lock()\n\tdefer s.Unlock()\n\ts.context = context.Background()\n\trows, err := s.connect(s.context).QueryContext(s.context, \"SELECT id, name, description, command, hits, attack, strength, defense, hostility FROM npcs ORDER BY id\")\n\tif err != nil {\n\t\tlog.Warn(\"Couldn't load entity definitions from sqlService:\", err)\n\t\treturn\n\t}\n\tdefer rows.Close()\n\n\tfor rows.Next() {\n\t\tnextDef := definitions.NpcDefinition{}\n\t\trows.Scan(&nextDef.ID, &nextDef.Name, &nextDef.Description, &nextDef.Command, &nextDef.Hits, &nextDef.Attack, &nextDef.Strength, &nextDef.Defense, &nextDef.Hostility)\n\t\tnpcs = append(npcs, nextDef)\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "5955af8271c80ee0c6b525574df98892", "score": "0.5068174", "text": "func (scnb *SupplyChainNodeBuilder) Entity(entityType proto.EntityDTO_EntityType) *SupplyChainNodeBuilder {\n\tvar commSold []*proto.TemplateCommodity\n\tvar commBought []*proto.TemplateDTO_CommBoughtProviderProp\n\ttemplateType := proto.TemplateDTO_BASE\n\tpriority := int32(0)\n\tscnb.entityTemplate = &proto.TemplateDTO{\n\t\tTemplateClass: &entityType,\n\t\tTemplateType: &templateType,\n\t\tTemplatePriority: &priority,\n\t\tCommoditySold: commSold,\n\t\tCommodityBought: commBought,\n\t}\n\treturn scnb\n}", "title": "" }, { "docid": "b595e7c829da6417abdbde54a0452c21", "score": "0.49344155", "text": "func NewNpcController(\n\tkubeclientset kubernetes.Interface,\n\textclientset clientset.Interface,\n\tkubeInformerFactory kubeinformers.SharedInformerFactory,\n\texternalObjInformerFactory informers.SharedInformerFactory) *NetworkPolicyController {\n\n\tnetworkPolicyInformer := kubeInformerFactory.Networking().V1().NetworkPolicies()\n\tlogicalNwInformer := externalObjInformerFactory.Alpha().V1().LogicalNetworks()\n\n\tnetworkscheme.AddToScheme(scheme.Scheme)\n\teventBroadcaster := record.NewBroadcaster()\n\teventBroadcaster.StartLogging(glog.Infof)\n\teventBroadcaster.StartRecordingToSink(&typedcorev1.EventSinkImpl{Interface: kubeclientset.CoreV1().Events(\"\")})\n\trecorder := eventBroadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: ControllerAgentName})\n\n\tnpcController := &NetworkPolicyController{\n\t\tkubeclientset: kubeclientset,\n\t\textclientset: extclientset,\n\t\tnetworkPoliciesLister: networkPolicyInformer.Lister(),\n\t\tnetworkPoliciesSynced: networkPolicyInformer.Informer().HasSynced,\n\t\tlogicalNwLister: logicalNwInformer.Lister(),\n\t\tlogicalNwSynced: logicalNwInformer.Informer().HasSynced,\n\t\tnpcWorkqueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), \"npc\"),\n\t\trecorder: recorder,\n\t}\n\n\tlogicalNwInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: npcController.addLogicalNetwork,\n\t\tUpdateFunc: npcController.updateLogicalNetwork,\n\t\tDeleteFunc: npcController.deleteLogicalNetwork,\n\t})\n\n\tnetworkPolicyInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: npcController.addPolicy,\n\t\tUpdateFunc: npcController.updatePolicy,\n\t\tDeleteFunc: npcController.deletePolicy,\n\t})\n\n\treturn npcController\n}", "title": "" }, { "docid": "57a05cbcf5507eb3114ec27b4f7395f2", "score": "0.48510897", "text": "func Ent(s *Scope, id ID) Entity { return Entity{s, id} }", "title": "" }, { "docid": "ec88015e15798e0818d792462952bc0e", "score": "0.48485762", "text": "func (es Entities) Entity(i int) Entity { return Entity{es.Scope, es.IDs[i]} }", "title": "" }, { "docid": "1227c978a8b4a0bcc45461f6a93233d4", "score": "0.46702093", "text": "func GetNPC(request *api.GetNPCRequest) (*api.GetNPCResponse, error) {\n\tnpc := &NpcData{request: request, npcLang: []api.Language{api.Language_LANG_COMMON}}\n\tnpc.setRace()\n\tnpc.setName()\n\tnpc.setAge()\n\tnpc.setAlignment()\n\tnpc.setClass()\n\tnpc.setStats()\n\tnpc.setBackground()\n\tnpc.setSkills()\n\tnpc.setPsyche()\n\n\tapiClasses := make([]*api.Class, len(npc.npcClass), len(npc.npcClass))\n\tfor i, class := range npc.npcClass {\n\t\tapiClasses[i] = &api.Class{Name: class.className, Level: class.classLevel}\n\t}\n\n\tnpcResponse := &api.GetNPCResponse{\n\t\tNpcData: &api.NPC{\n\t\t\tFirstName: npc.npcName.firstName,\n\t\t\tLastName: npc.npcName.lastName,\n\t\t\tGender: npc.npcGender,\n\t\t\tAge: npc.npcAge,\n\t\t\tAlignment: npc.npcAlign,\n\t\t\tSpeed: npc.npcRace.raceSpeed,\n\t\t\tLanguage: npc.npcLang,\n\t\t\tClass: apiClasses,\n\t\t\tRace: &api.Race{\n\t\t\t\tRace: npc.npcRace.raceName,\n\t\t\t\tRacialTraits: npc.npcRace.racialTraits,\n\t\t\t},\n\t\t\tPhysicalTraits: &api.PhysicalTraits{\n\t\t\t\tHeightFeet: 4,\n\t\t\t\tHeightInch: 2,\n\t\t\t\tWeight: 160,\n\t\t\t\tSkinTone: api.PhysicalTraits_SKIN_DUSKY,\n\t\t\t\tTraits: []string{},\n\t\t\t},\n\t\t\tStats: &api.Stats{\n\t\t\t\tStr: int32(npc.npcStats.Stats[\"str\"]),\n\t\t\t\tCon: int32(npc.npcStats.Stats[\"con\"]),\n\t\t\t\tDex: int32(npc.npcStats.Stats[\"dex\"]),\n\t\t\t\tInt: int32(npc.npcStats.Stats[\"int\"]),\n\t\t\t\tWis: int32(npc.npcStats.Stats[\"wis\"]),\n\t\t\t\tCha: int32(npc.npcStats.Stats[\"cha\"]),\n\t\t\t},\n\t\t\tSkill: npc.skills,\n\t\t\tPsychologicalTraits: &api.PsychologicalTraits{\n\t\t\t\tTraits: npc.npcPsyche,\n\t\t\t},\n\t\t},\n\t}\n\n\treturn npcResponse, nil\n}", "title": "" }, { "docid": "7e1af4c944f94a9ef38d0bc0e2a39019", "score": "0.4662157", "text": "func (o BucketOwnerPtrOutput) Entity() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *BucketOwner) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Entity\n\t}).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "e1859a5be9099114e7281ecd8b2903ff", "score": "0.462413", "text": "func fakeEntity(pubkey *packet.PublicKey, privkey *packet.PrivateKey) *openpgp.Entity {\n\tcfg := packet.Config{\n\t\tDefaultCipher: packet.CipherAES128,\n\t\tDefaultHash: crypto.SHA384,\n\t\tDefaultCompressionAlgo: packet.CompressionNone,\n\t\tRSABits: 2048,\n\t}\n\n\tentity := openpgp.Entity{\n\t\tPrimaryKey: pubkey,\n\t\tPrivateKey: privkey,\n\t\tIdentities: make(map[string]*openpgp.Identity),\n\t}\n\n\t// Create fake identity\n\t// We need an identity, not because it is used or important in any way but because Sign(...) will use the\n\t// same hash function (hardcoded) or fall back to RIPEMD...\n\ttrueVal := true\n\thid, _ := s2k.HashToHashId(crypto.SHA256)\n\tentity.Identities[\"\"] = &openpgp.Identity{\n\t\tName: \"\",\n\t\tUserId: packet.NewUserId(\"\", \"\", \"\"),\n\t\tSelfSignature: &packet.Signature{\n\t\t\tCreationTime: time.Now(),\n\t\t\tSigType: packet.SigTypePositiveCert,\n\t\t\tPubKeyAlgo: packet.PubKeyAlgoRSA,\n\t\t\tHash: cfg.Hash(),\n\t\t\tIsPrimaryId: &trueVal,\n\t\t\tFlagSign: true,\n\t\t\tFlagsValid: true,\n\t\t\tFlagCertify: true,\n\t\t\tIssuerKeyId: &pubkey.KeyId,\n\t\t\tPreferredHash: []uint8{hid},\n\t\t},\n\t}\n\n\treturn &entity\n}", "title": "" }, { "docid": "6fbc04b0ae173658ef5de5a93f984a01", "score": "0.4608108", "text": "func (o BucketObjectOwnerPtrOutput) Entity() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *BucketObjectOwner) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Entity\n\t}).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "b36afab6995701fa893919ec0b2aea5c", "score": "0.459472", "text": "func (o BucketOwnerOutput) Entity() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v BucketOwner) *string { return v.Entity }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "4ba27190c507194a87f15755dbd73c33", "score": "0.45668468", "text": "func (o BucketObjectOwnerOutput) Entity() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v BucketObjectOwner) *string { return v.Entity }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "c0a46dd4ade70943ae5cd0e5dc7bdf25", "score": "0.44914538", "text": "func GenerateNPC() *NPC {\n\tnpc := NPC{}\n\n\trand.Seed(time.Now().UTC().UnixNano())\n\n\tnpc.genderIsFemale = rand.Int()%2 == 0\n\tnpc.GenName()\n\tnpc.age = lists.Ages[rand.Int()%len(lists.Ages)]\n\tnpc.race = lists.Races[rand.Int()%len(lists.Races)]\n\tnpc.nation = lists.Nations[rand.Int()%len(lists.Nations)]\n\tnpc.voice = lists.Voices[rand.Int()%len(lists.Voices)]\n\tnpc.character = lists.Characters[rand.Int()%len(lists.Characters)]\n\tnpc.GenAspect()\n\tnpc.GenStats()\n\n\treturn &npc\n}", "title": "" }, { "docid": "3189c83f5db471847753849702583d4b", "score": "0.44065577", "text": "func (c *Client) UseEntityAt(entityID int32, x, y, z float32, hand int) error {\n\treturn c.conn.WritePacket(pk.Marshal(\n\t\tdata.UseEntity,\n\t\tpk.VarInt(entityID),\n\t\tpk.VarInt(2),\n\t\tpk.Float(x), pk.Float(y), pk.Float(z),\n\t\tpk.VarInt(hand),\n\t))\n}", "title": "" }, { "docid": "cc1bf0ee8411e5a9f36091d784adf869", "score": "0.43987116", "text": "func (s *Seek) Entity() *Physics {\n\treturn s.entity\n}", "title": "" }, { "docid": "6818a4c1adfd249eaf5129f170121e94", "score": "0.43839464", "text": "func (e *Entity) ToProtobuf() *pb.Entity {\n\tpbEnt := &pb.Entity{}\n\tpbEnt.Name = e.Name\n\tpbEnt.Email = e.Email\n\n\tpbEnt.OwnedOrigins = make([]int32, len(e.OwnedOrigins))\n\tfor i, v := range e.OwnedOrigins {\n\t\tpbEnt.OwnedOrigins[i] = int32(v)\n\t}\n\n\tpbEnt.OwnedPrefixes = util.GetIPNetsAsPrefixList(e.OwnedPrefixes)\n\n\treturn pbEnt\n}", "title": "" }, { "docid": "e2aa5877017b9328620ed639a657737e", "score": "0.43790495", "text": "func (scb *SupplyChainBuilder) Entity(node *SupplyChainNodeBuilder) *SupplyChainBuilder {\n\tif hasTop := scb.hasTopNode(); !hasTop {\n\t\t//TODO should have error\n\t\treturn scb\n\t}\n\tnodeEntityType := node.getEntity()\n\tscb.SupplyChainNodes[&nodeEntityType] = node\n\n\tscb.currentNode = node\n\n\treturn scb\n}", "title": "" }, { "docid": "3a3ad6e616d8c0b34b3f7ff22e1c2701", "score": "0.43738937", "text": "func (o ObjectAccessControlTypeOutput) Entity() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ObjectAccessControlType) *string { return v.Entity }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "f4ad6b62ee44fa2be198a5cc03ceb380", "score": "0.43461502", "text": "func (g *GameSession) MoveEntity(c *Client, tmsg *messages.MovePlayer) {\n\t// TODO: go back in time and apply at tick!\n\tid := g.Clients[c.ID].Accounts[0].Character.ID\n\tent := g.World.Entities[id]\n\tif ent == nil {\n\t\treturn\n\t}\n\tdirVect := physics.Vect2{\n\t\tX: int32(tmsg.X),\n\t\tY: int32(tmsg.Y),\n\t}\n\tent.Body.Angle = physics.AngleVect2(dirVect, physics.Vect2{X: 0, Y: 1})\n\t// TODO: Replace hardcoded 50 with 'speed' setting of the character.\n\tent.Body.Velocity = physics.NormalizeVect2(dirVect, 50)\n}", "title": "" }, { "docid": "f7de90025b5d15777d738f006878d3e3", "score": "0.4295973", "text": "func NewEntity(template *x509.Certificate, privateKey crypto.PrivateKey) (*Entity, error) {\n\tpriv, err := rsa.GenerateKey(randReader, rsaBitSize)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to generate key: %v\", err)\n\t}\n\tif privateKey != nil {\n\t\tpriv = privateKey.(*rsa.PrivateKey)\n\t}\n\tif template.SubjectKeyId, err = keyID(priv.Public()); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to generate Subject Key ID: %v\", err)\n\t}\n\n\tif template.SerialNumber, err = rand.Int(randReader, bigInt); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to randomize a big int: %v\", err)\n\t}\n\n\treturn &Entity{Template: template, PrivateKey: priv, PublicKey: priv.Public(), Certificate: nil}, nil\n}", "title": "" }, { "docid": "9dd76960cdd6523426c4ff0edf57be17", "score": "0.42898694", "text": "func NewEntity(numberGenes int) *Entity {\n\tgenome := make([]int, numberGenes, numberGenes)\n\n\trand.Seed(time.Now().UTC().UnixNano())\n\n\tfor i, _ := range genome {\n\t\tgenome[i] = rand.Intn(numberGeneValues - 1)\n\t}\n\n\te := Entity{genome}\n\n\treturn &e\n}", "title": "" }, { "docid": "eb54e6ec8e7d427836faa7b3dbb3d6a0", "score": "0.42803133", "text": "func (c *Client) UseEntity(entityID int32, hand int) error {\n\treturn c.conn.WritePacket(pk.Marshal(\n\t\tdata.UseEntity,\n\t\tpk.VarInt(entityID),\n\t\tpk.VarInt(0),\n\t\tpk.VarInt(hand),\n\t))\n}", "title": "" }, { "docid": "155ca489f3e9f77fa653d7bf5fbdeb26", "score": "0.42657682", "text": "func EntityContestToRpcContest(contest *entity.Contest) *problempb.Contest {\n\tif contest == nil {\n\t\treturn &problempb.Contest{}\n\t}\n\tstartTime, _ := ptypes.TimestampProto(contest.StartTime)\n\tendTime, _ := ptypes.TimestampProto(contest.EndTime)\n\tproblemIds := make([]uint64, len(contest.ProblemIds))\n\tfor i, p := range contest.ProblemIds {\n\t\tproblemIds[i] = uint64(p)\n\t}\n\treturn &problempb.Contest{\n\t\tContestId: uint64(contest.ContestId),\n\t\tTitle: contest.Title,\n\t\tDescription: contest.Description,\n\t\tStartTime: startTime,\n\t\tEndTime: endTime,\n\t\tCreator: EntityUserToRpcUser(contest.Creator),\n\t\tProblemIds: problemIds,\n\t}\n}", "title": "" }, { "docid": "33eada7723a2602e2731bc8c4f5ec88d", "score": "0.42110547", "text": "func NewNatsPodSpec(clusterName string, cs spec.ClusterSpec, owner metav1.OwnerReference) *v1.Pod {\n\tlabels := map[string]string{\n\t\tLabelAppKey: \"nats\",\n\t\tLabelClusterNameKey: clusterName,\n\t\tLabelClusterVersionKey: cs.Version,\n\t}\n\n\tvolumes := []v1.Volume{}\n\n\tcontainer := natsPodContainer(clusterName, cs.Version)\n\tcontainer = containerWithLivenessProbe(container, natsLivenessProbe(cs.TLS.IsSecureClient()))\n\tcontainer = containerWithReadinessProbe(container, natsReadinessProbe(clusterName))\n\n\tif cs.Pod != nil {\n\t\tcontainer = containerWithRequirements(container, cs.Pod.Resources)\n\t}\n\n\tpod := &v1.Pod{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tLabels: labels,\n\t\t\tGenerateName: fmt.Sprintf(\"nats-%s-\", clusterName),\n\t\t\tAnnotations: map[string]string{},\n\t\t},\n\t\tSpec: v1.PodSpec{\n\t\t\tContainers: []v1.Container{container},\n\t\t\tRestartPolicy: v1.RestartPolicyNever,\n\t\t\tVolumes: volumes,\n\t\t},\n\t}\n\n\tapplyPodPolicy(clusterName, pod, cs.Pod)\n\n\tSetNATSVersion(pod, cs.Version)\n\n\taddOwnerRefToObject(pod.GetObjectMeta(), owner)\n\n\treturn pod\n}", "title": "" }, { "docid": "a0b5e34c739a24f2ccf64899be1c25fe", "score": "0.41957107", "text": "func (b *Broker) Entity(i *integration.Integration) (*integration.Entity, error) {\n\tclusterIDAttr := integration.NewIDAttribute(\"clusterName\", args.GlobalArgs.ClusterName)\n\tbrokerIDAttr := integration.NewIDAttribute(\"brokerID\", string(b.ID))\n\treturn i.Entity(b.Addr(), \"ka-broker\", clusterIDAttr, brokerIDAttr)\n}", "title": "" }, { "docid": "ecae9a8d3a2198013ba019ae6164addb", "score": "0.41951424", "text": "func NewCounterEntity() *CounterEntity {\n\tthis := CounterEntity{}\n\treturn &this\n}", "title": "" }, { "docid": "496ccbfdc0726f1c4a4a96d66bd3fa80", "score": "0.41559884", "text": "func newDiscPeer(addr pot.Address) (*Peer, error) {\n\tpKey, err := ecdsa.GenerateKey(crypto.S256(), crand.Reader)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tpubKey := pKey.PublicKey\n\tnod := enode.NewV4(&pubKey, net.IPv4(127, 0, 0, 1), 0, 0)\n\tbzzAddr := &BzzAddr{OAddr: addr[:], UAddr: []byte(nod.String())}\n\tid := nod.ID()\n\tp2pPeer := p2p.NewPeer(id, id.String(), nil)\n\treturn NewPeer(&BzzPeer{\n\t\tPeer: protocols.NewPeer(p2pPeer, &dummyMsgRW{}, DiscoverySpec),\n\t\tBzzAddr: bzzAddr,\n\t}, nil), nil\n}", "title": "" }, { "docid": "fd92e42118f708dc4014ef008d1692f3", "score": "0.415584", "text": "func NewEntityFromPB(pbEnt *pb.Entity) (e *Entity, err error) {\n\tif pbEnt == nil {\n\t\treturn nil, fmt.Errorf(\"nil pb.Entity\")\n\t}\n\te = &Entity{}\n\te.Name = pbEnt.Name\n\te.Email = pbEnt.Email\n\n\te.OwnedOrigins = make([]int, len(pbEnt.OwnedOrigins))\n\tfor i, v := range pbEnt.OwnedOrigins {\n\t\te.OwnedOrigins[i] = int(v)\n\t}\n\n\te.OwnedPrefixes, err = util.GetPrefixListAsIPNet(pbEnt.OwnedPrefixes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn e, nil\n}", "title": "" }, { "docid": "8111306afd7b8a0eae727cd660425830", "score": "0.413488", "text": "func chanByPosNum(channs []*discordgo.Channel, posNum int) (string, error) {\n\tfor _, chann := range channs {\n\t\tif chann.Type == 2 {\n\t\t\tif chann.Position == posNum {\n\t\t\t\treturn chann.ID, nil\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\", errors.New(\"not nound\")\n}", "title": "" }, { "docid": "2b5b3464eccd46784568ef95c811706a", "score": "0.41234392", "text": "func NewEntityFromPrometheusEntity(e prometheus.Entity) Entity {\n\n\tvar (\n\t\tsamples []metric.Sample\n\t)\n\n\tsamples = make([]metric.Sample, 0)\n\n\tfor _, value := range e.Values {\n\t\tv := \"0\"\n\t\tif s, err := strconv.ParseFloat(value.SampleValue, 64); err == nil {\n\t\t\tv = fmt.Sprintf(\"%d\", int(math.Ceil(s*1000)))\n\t\t\tif v == \"0\" {\n\t\t\t\tv = \"1\"\n\t\t\t}\n\t\t} else {\n\t\t\tscope.Errorf(\"containerCPUUsagePercentage.NewEntityFromPrometheusEntity: %s\", err.Error())\n\t\t}\n\t\tsample := metric.Sample{\n\t\t\tTimestamp: value.UnixTime,\n\t\t\tValue: v,\n\t\t}\n\t\tsamples = append(samples, sample)\n\t}\n\n\treturn Entity{\n\t\tPrometheusEntity: e,\n\t\tNamespace: e.Labels[NamespaceLabel],\n\t\tPodName: e.Labels[PodLabelName],\n\t\tContainerName: e.Labels[ContainerLabel],\n\t\tSamples: samples,\n\t}\n}", "title": "" }, { "docid": "10b1429890b8137858945a6f48b3a494", "score": "0.41098657", "text": "func NewOmniSendCmd(fromAddress string, toAddress string, propertyId int,\n\tamount btcutil.Amount) *OmniSendCmd {\n\n\treturn &OmniSendCmd{\n\t\tFromAddress: fromAddress,\n\t\tToAddress: toAddress,\n\t\tPropertyId: propertyId,\n\t\tAmount: amount,\n\t}\n}", "title": "" }, { "docid": "5fbda1a7e58ceaaa8a9ec5de4e724c66", "score": "0.41086668", "text": "func (this *EntityManager) getCargoEntities() *CargoEntities.Entities {\r\n\tvar cargoEntities *CargoEntities.Entities\r\n\tentities, _ := GetServer().GetEntityManager().getEntityById(\"CargoEntities.Entities\", \"CargoEntities\", []interface{}{\"CARGO_ENTITIES\"})\r\n\tif entities != nil {\r\n\t\tcargoEntities = entities.(*CargoEntities.Entities)\r\n\t} else {\r\n\t\t// I will create the cargo entities if it dosent already exist.\r\n\t\tcargoEntities = new(CargoEntities.Entities)\r\n\t\tcargoEntities.SetId(\"CARGO_ENTITIES\")\r\n\t\tcargoEntities.SetName(\"Cargo entities\")\r\n\t\tcargoEntities.SetVersion(\"1.0\")\r\n\t\tcargoEntities.SetEntityGetter(getEntityFct)\r\n\t\tcargoEntities.SetEntitySetter(setEntityFct)\r\n\t\tcargoEntities.SetUuidGenerator(generateUuidFct)\r\n\t\tthis.saveEntity(cargoEntities)\r\n\t}\r\n\treturn cargoEntities\r\n}", "title": "" }, { "docid": "8f4db7874c2404b5c65fd9edd54abfb5", "score": "0.4100765", "text": "func (o BucketAccessControlTypeOutput) Entity() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v BucketAccessControlType) *string { return v.Entity }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "d889726053acc0c74f3f3b98371df916", "score": "0.40756497", "text": "func (this *EntityManager) createEntity(parent Entity, attributeName string, entity Entity) (Entity, *CargoEntities.Error) {\r\n\r\n\t// Set the entity values here.\r\n\ttypeName := entity.GetTypeName() // Set the type name if not already set...\r\n\tentity.SetParentLnk(attributeName)\r\n\tentity.SetParentUuid(parent.GetUuid())\r\n\r\n\t// Here I will set the entity on the cache...\r\n\tthis.setEntity(entity)\r\n\r\n\tstoreId := typeName[0:strings.Index(typeName, \".\")]\r\n\tprototype, _ := GetServer().GetEntityManager().getEntityPrototype(typeName, storeId)\r\n\r\n\t// Now entity are quadify I will save it in the graph store.\r\n\tstore := GetServer().GetDataManager().getDataStore(storeId)\r\n\r\n\t// I will create the entity.\r\n\t_, err := store.Create(\"\", []interface{}{entity})\r\n\tif err != nil {\r\n\t\tcargoError := NewError(Utility.FileLine(), ENTITY_CREATION_ERROR, SERVER_ERROR_CODE, err)\r\n\t\treturn nil, cargoError\r\n\t}\r\n\r\n\t//LogInfo(\"---> create entity \", entity.GetUuid())\r\n\tentity.SetNeedSave(false)\r\n\r\n\t// also save it parent.\r\n\tif parent != nil {\r\n\t\t// Now I will save it in the datastore.\r\n\t\t// I will set the entity parent.\r\n\t\tcargoError := this.setParent(parent, entity)\r\n\t\tif cargoError != nil {\r\n\t\t\treturn nil, cargoError\r\n\t\t}\r\n\t} else {\r\n\t\tcargoError := NewError(Utility.FileLine(), ENTITY_CREATION_ERROR, SERVER_ERROR_CODE, errors.New(\"parent must not be nil when createEntity is call.\"))\r\n\t\treturn nil, cargoError\r\n\t}\r\n\r\n\t// The event data...\r\n\teventData := make([]*MessageData, 2)\r\n\tmsgData0 := new(MessageData)\r\n\tmsgData0.Name = \"entity\"\r\n\tif reflect.TypeOf(entity).String() == \"*Server.DynamicEntity\" {\r\n\t\tmsgData0.Value = entity.(*DynamicEntity).getValues()\r\n\t} else {\r\n\t\tmsgData0.Value = entity\r\n\t}\r\n\teventData[0] = msgData0\r\n\r\n\tmsgData1 := new(MessageData)\r\n\tmsgData1.Name = \"prototype\"\r\n\tmsgData1.Value = prototype\r\n\teventData[1] = msgData1\r\n\r\n\tevt, _ := NewEvent(NewEntityEvent, EntityEvent, eventData)\r\n\tGetServer().GetEventManager().BroadcastEvent(evt)\r\n\r\n\t// Set it childs...\r\n\tthis.saveChilds(entity, prototype)\r\n\r\n\treturn entity, nil\r\n}", "title": "" }, { "docid": "6c89abb5f862b6a50e3f90603a725e01", "score": "0.4064651", "text": "func (entity_EntityInfo) MakeSlice(capacity int) interface{} {\n\treturn make([]*Entity, 0, capacity)\n}", "title": "" }, { "docid": "f7b0d4a68aabc4025923490deb2bb874", "score": "0.40626264", "text": "func NewEntityFromConfig(ec *config.EntityConfig) (e *Entity, err error) {\n\te = &Entity{}\n\te.Name = ec.Name\n\te.Email = ec.Email\n\te.OwnedOrigins = ec.OwnedOrigins\n\n\te.OwnedPrefixes = make([]*net.IPNet, len(ec.OwnedPrefixes))\n\tfor i := range ec.OwnedPrefixes {\n\t\t_, e.OwnedPrefixes[i], err = net.ParseCIDR(ec.OwnedPrefixes[i])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "b48dd09f23b15bf62c132e0dad39d7ec", "score": "0.40510908", "text": "func NewEntity(aspects ...Assertable) Entity {\n\tvar res Entity = make(map[uintptr]interface{})\n\tfor _, v := range aspects {\n\t\tres.AddAspect(v, v)\n\t\tif ae, ok := v.(AspectExposing); ok {\n\t\t\tl := ae.ExposedAspects()\n\t\t\tfor _, a := range l {\n\t\t\t\tres.AddAspect(a, v)\n\t\t\t}\n\t\t}\n\t}\n\treturn res\n}", "title": "" }, { "docid": "a785446fb6eb93430ebe18d46b495f4a", "score": "0.40499696", "text": "func (c *PagesService) Entity(id int) *Page {\n\tentity := Page{\n\t\tcollection: c,\n\t\tID: id,\n\t}\n\treturn &entity\n}", "title": "" }, { "docid": "188612c58ae64c30a3bc6f192794bef5", "score": "0.40484974", "text": "func (entity *NetworkEntity) ToNetworkEntity() storage.NetworkEntity {\n\treturn storage.NetworkEntity{\n\t\tKey: entity.Id,\n\t\tType: entity.Type,\n\t\tName: entity.Name,\n\t\tDescription: entity.Description,\n\t\tPhysicalID: entity.PhysicalId,\n\t\tConfig: entity.Config,\n\t\tGraphID: entity.GraphID,\n\t\tAssociations: ToTypeAndKeys(entity.Assocs),\n\t\tParentAssociations: ToTypeAndKeys(entity.ParentAssocs),\n\t\tPermissions: toStorageACLs(entity.Permissions),\n\t}\n}", "title": "" }, { "docid": "ce71161c5643fd1bb15210ede6ea3e1f", "score": "0.40469852", "text": "func ClienteByNit(db XODB, nit string) (*Cliente, error) {\n\tvar err error\n\n\t// sql query\n\tconst sqlstr = `SELECT ` +\n\t\t`id, nit, razon_social, nombre_comercial, servicios_prestados, creado_por_id, actualizado_por_id, fecha_creacion, fecha_actualizacion ` +\n\t\t`FROM v1wq1ics1m037sn6.cliente ` +\n\t\t`WHERE nit = ?`\n\n\t// run query\n\tXOLog(sqlstr, nit)\n\tc := Cliente{\n\t\t_exists: true,\n\t}\n\n\terr = db.QueryRow(sqlstr, nit).Scan(&c.ID, &c.Nit, &c.RazonSocial, &c.NombreComercial, &c.ServiciosPrestados, &c.CreadoPorID, &c.ActualizadoPorID, &c.FechaCreacion, &c.FechaActualizacion)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &c, nil\n}", "title": "" }, { "docid": "576e8835f77eae5f0a9e5c8dce607842", "score": "0.40443692", "text": "func Naddr(a *obj.Addr, n *Node)", "title": "" }, { "docid": "667d8b30210c78660842d3190b550003", "score": "0.404382", "text": "func (cli *FakeDatabaseClient) NID(ctx context.Context, in *dbdpb.NIDRequest, opts ...grpc.CallOption) (*dbdpb.NIDResponse, error) {\n\tpanic(\"implement me\")\n}", "title": "" }, { "docid": "55f8df75099f09f821b6e95b712eb3ce", "score": "0.40433952", "text": "func Client(mf *dds.ModelFactory) dds.Model {\n\n\tentityName := mf.EntityName\n\n\tvar nc *nats.Conn\n\tvar err error\n\n\tfor i := 0; i != 3 && nc == nil; i++ {\n\t\t<-time.After(500 * time.Millisecond)\n\t\tnc, err = nats.Connect(nats.DefaultURL)\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"Error connecting to nats: '%v'\\n\", err)\n\t\t}\n\t}\n\n\tif nc == nil {\n\t\tpanic(errors.New(\"Failed to connect to nats, giving up\\n\"))\n\t}\n\n\treturn &natsModel{\n\t\tc: nc,\n\t\tentityName: entityName,\n\t}\n}", "title": "" }, { "docid": "fbd2583858551c448dbc154ec9ec87bd", "score": "0.4025825", "text": "func (o BucketObjectOwnerOutput) EntityId() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v BucketObjectOwner) *string { return v.EntityId }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "c0a6105c47ffe14fc18074e1c6f0f642", "score": "0.39992714", "text": "func (ec *Client) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error) {\n\tec.Send(stateAccessCost)\n\treturn ec.c.NonceAt(ctx, account, blockNumber)\n}", "title": "" }, { "docid": "1efdfd36d5c8d639755d34f4502ccfb1", "score": "0.39989907", "text": "func (impl *ServerServerGroup) NewEntity() base.EntityInterface {\n\treturn new(entity.ServerServerGroup)\n}", "title": "" }, { "docid": "18da9adcfd57999c8741ae3ebd12ab16", "score": "0.39923328", "text": "func (ec *Client) NonceAt(ctx context.Context, account helper.Address, blockNumber *big.Int) (uint64, error) {\n\tvar result rpc.HexNumber\n\terr := ec.c.CallContext(ctx, &result, \"siot_getTransactionCount\", account, toBlockNumArg(blockNumber))\n\treturn result.Uint64(), err\n}", "title": "" }, { "docid": "e73aa0a6d7e2a535ff8b88d7be6251e4", "score": "0.39920086", "text": "func (o BucketObjectOwnerPtrOutput) EntityId() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *BucketObjectOwner) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.EntityId\n\t}).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "53dd5d9c812d19d321e3667541a413e2", "score": "0.3988785", "text": "func (o ObjectAccessControlTypeOutput) EntityId() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ObjectAccessControlType) *string { return v.EntityId }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "a54814bf6b84cb9542e3c34cb194bfae", "score": "0.39816135", "text": "func MockNvmeController(varIdx ...int32) *ctlpb.NvmeController {\n\tnative := storage.MockNvmeController(varIdx...)\n\tpb := new(NvmeController)\n\n\tif err := pb.FromNative(native); err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn pb.AsProto()\n}", "title": "" }, { "docid": "18680f1f1013ef2b292aa13289d6dd48", "score": "0.39779967", "text": "func (r *queryImpl) Entity(p schema.QueryEntityFieldResolverParams) (interface{}, error) {\n\tctx := contextWithNamespace(p.Context, p.Args.Namespace)\n\tres, err := r.svc.EntityClient.FetchEntity(ctx, p.Args.Name)\n\treturn handleFetchResult(res, err)\n}", "title": "" }, { "docid": "15cdffb9ed43f34b5cd91078df942799", "score": "0.39772668", "text": "func (s *Sherlock) Entity(id string) *Entity {\n\ts.lock.Lock()\n\tdefer s.lock.Unlock()\n\n\tif _, exists := s.Entities[id]; !exists {\n\t\t// we need to create a blank entity\n\t\ts.Entities[id] = NewEntity(id, s.maxEvents)\n\t}\n\n\treturn s.Entities[id]\n}", "title": "" }, { "docid": "895b65a650a608e6ad07edbf5efddeaa", "score": "0.39705968", "text": "func (r *queryResolver) Node(ctx context.Context, id int) (ent.Noder, error) {\n\treturn ent.FromContext(ctx).Noder(ctx, id)\n}", "title": "" }, { "docid": "278f3c9c2cae9c72685a84cbc9f4b2d6", "score": "0.39688864", "text": "func (o BucketOwnerOutput) EntityId() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v BucketOwner) *string { return v.EntityId }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "5d1acb882d765304a8074a689afac085", "score": "0.39622968", "text": "func NewEntity(name, comment, email string, config *packet.Config) (*Entity, error) {\n\tcreationTime := config.Now()\n\n\tbits := defaultRSAKeyBits\n\tif config != nil && config.RSABits != 0 {\n\t\tbits = config.RSABits\n\t}\n\n\tuid := packet.NewUserId(name, comment, email)\n\tif uid == nil {\n\t\treturn nil, errors.InvalidArgumentError(\"user id field contained invalid characters\")\n\t}\n\tsigningPriv, err := rsa.GenerateKey(config.Random(), bits)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tencryptingPriv, err := rsa.GenerateKey(config.Random(), bits)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\te := &Entity{\n\t\tPrimaryKey: packet.NewRSAPublicKey(creationTime, &signingPriv.PublicKey),\n\t\tPrivateKey: packet.NewRSAPrivateKey(creationTime, signingPriv),\n\t\tIdentities: make(map[string]*Identity),\n\t}\n\tisPrimaryId := true\n\te.Identities[uid.Id] = &Identity{\n\t\tName: uid.Id,\n\t\tUserId: uid,\n\t\tSelfSignature: &packet.Signature{\n\t\t\tCreationTime: creationTime,\n\t\t\tSigType: packet.SigTypePositiveCert,\n\t\t\tPubKeyAlgo: packet.PubKeyAlgoRSA,\n\t\t\tHash: config.Hash(),\n\t\t\tIsPrimaryId: &isPrimaryId,\n\t\t\tFlagsValid: true,\n\t\t\tFlagSign: true,\n\t\t\tFlagCertify: true,\n\t\t\tIssuerKeyId: &e.PrimaryKey.KeyId,\n\t\t},\n\t}\n\terr = e.Identities[uid.Id].SelfSignature.SignUserId(uid.Id, e.PrimaryKey, e.PrivateKey, config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// If the user passes in a DefaultHash via packet.Config,\n\t// set the PreferredHash for the SelfSignature.\n\tif config != nil && config.DefaultHash != 0 {\n\t\te.Identities[uid.Id].SelfSignature.PreferredHash = []uint8{hashToHashId(config.DefaultHash)}\n\t}\n\n\t// Likewise for DefaultCipher.\n\tif config != nil && config.DefaultCipher != 0 {\n\t\te.Identities[uid.Id].SelfSignature.PreferredSymmetric = []uint8{uint8(config.DefaultCipher)}\n\t}\n\n\te.Subkeys = make([]Subkey, 1)\n\te.Subkeys[0] = Subkey{\n\t\tPublicKey: packet.NewRSAPublicKey(creationTime, &encryptingPriv.PublicKey),\n\t\tPrivateKey: packet.NewRSAPrivateKey(creationTime, encryptingPriv),\n\t\tSig: &packet.Signature{\n\t\t\tCreationTime: creationTime,\n\t\t\tSigType: packet.SigTypeSubkeyBinding,\n\t\t\tPubKeyAlgo: packet.PubKeyAlgoRSA,\n\t\t\tHash: config.Hash(),\n\t\t\tFlagsValid: true,\n\t\t\tFlagEncryptStorage: true,\n\t\t\tFlagEncryptCommunications: true,\n\t\t\tIssuerKeyId: &e.PrimaryKey.KeyId,\n\t\t},\n\t}\n\te.Subkeys[0].PublicKey.IsSubkey = true\n\te.Subkeys[0].PrivateKey.IsSubkey = true\n\terr = e.Subkeys[0].Sig.SignKey(e.Subkeys[0].PublicKey, e.PrivateKey, config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn e, nil\n}", "title": "" }, { "docid": "d180db0d70d243221b99a82e3876aa7c", "score": "0.39509797", "text": "func (o BucketObjectOwnerResponseOutput) Entity() pulumi.StringOutput {\n\treturn o.ApplyT(func(v BucketObjectOwnerResponse) string { return v.Entity }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "b3b8fc01b28ef3eb9132b651d1d035f0", "score": "0.39437708", "text": "func (o BucketOwnerPtrOutput) EntityId() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *BucketOwner) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.EntityId\n\t}).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "48c235a35b9c609701ad2029444932a1", "score": "0.39421532", "text": "func (ec *Client) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error) {\n\tvar result hexutil.Uint64\n\terr := ec.c.CallContext(ctx, &result, \"eth_getTransactionCount\", account, toBlockNumArg(blockNumber))\n\treturn uint64(result), err\n}", "title": "" }, { "docid": "08b06ccf4be3e6a4784e550a67941a66", "score": "0.39402124", "text": "func (o BucketOwnerResponseOutput) Entity() pulumi.StringOutput {\n\treturn o.ApplyT(func(v BucketOwnerResponse) string { return v.Entity }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "68cf2dc2fdecba6cd8327d3428cc9b8e", "score": "0.3939792", "text": "func PodUIDToEntityName(uid string) string {\n\tif uid == \"\" {\n\t\treturn \"\"\n\t}\n\treturn KubePodPrefix + uid\n}", "title": "" }, { "docid": "15fb2349b0c15dd573e18374af7ed1d8", "score": "0.39354205", "text": "func NewEntity(txn *badger.Txn, entType schema.EntityType, ID []byte) (err error) {\n\tentID := entType.EntityID(ID)\n\tif err = item.Create(txn, entID); err != nil {\n\t\treturn\n\t}\n\t// add to index\n\t// index := schema.EntityIndexID(entType.Name)\n\t// evt := schema.NewEntityItemIndex(ID)\n\t// var entIntID uint64\n\t// if entIntID, err = item.Put(txn, index, evt); err != nil {\n\t// \treturn\n\t// }\n\t// TODO: alias the entity instead of adding an event!\n\t// b := make([]byte, 8)\n\t// binary.BigEndian.PutUint64(b, entIntID)\n\t// err = item.Alias(txn, entID, entType.AliasIndexID(entIntID))\n\t// _, err = item.Put(txn, entID, item.NewEvent(2, []byte(\"INDEX\"), b))\n\n\treturn\n}", "title": "" }, { "docid": "8a4c6ddc42c48c0c8d2dd42c0a058391", "score": "0.39273024", "text": "func NewControllerEntity() *ControllerEntity {\n\tthis := ControllerEntity{}\n\treturn &this\n}", "title": "" }, { "docid": "b4a1f09294d6b9c148272a70907c5ded", "score": "0.39115137", "text": "func (c *Client) Noder(ctx context.Context, id int, opts ...NodeOption) (_ Noder, err error) {\n\tdefer func() {\n\t\tif IsNotFound(err) {\n\t\t\terr = multierror.Append(err, entgql.ErrNodeNotFound(id))\n\t\t}\n\t}()\n\ttable, err := c.newNodeOpts(opts).nodeType(ctx, id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn c.noder(ctx, table, id)\n}", "title": "" }, { "docid": "c81bc09c806bacf0e868b4d4686441c3", "score": "0.3908168", "text": "func MakeEntity(Img string, Tags []string, Xposition int32, Yposition int32, Rotation float64,\n\tXsize int32, Ysize int32) Entity {\n\te := Entity{}\n\te.Rectangle = resolv.NewRectangle(Xposition, Yposition, Ysize, Xsize)\n\t//e.Rectangle.SetData(e)\n\t//e.Rectangle.SetTags(Tags...)\n\te.Img = Img\n\te.Speed = 0\n\te.Jump = 0\n\te.Fly = false\n\te.Rotation = Rotation\n\te.Static = true\n\te.Physics = false\n\te.Clickable = false\n\te.ParentEntityID = -1\n\te.CameraChild = false\n\te.CameraParent = false\n\te.Zorder = 0\n\te.ID = 0\n\treturn e\n}", "title": "" }, { "docid": "b77c1f3775b214e3ebc3f470a9d614c3", "score": "0.3905607", "text": "func (o ObjectAccessControlResponseOutput) Entity() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ObjectAccessControlResponse) string { return v.Entity }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "125fab6fb6f5311a47b3c7f94c683ec1", "score": "0.38922617", "text": "func NewEntity() *Entity {\n\treturn &Entity{\n\t\tlock: &sync.Mutex{},\n\t\tAttributes: make(map[string]attribute.Attribute),\n\t}\n}", "title": "" }, { "docid": "1212b0c89d0cb0facacf9e8c6a8a331e", "score": "0.38843495", "text": "func (c *Client) AttackEntity(entityID int32, hand int) error {\n\treturn c.conn.WritePacket(pk.Marshal(\n\t\tdata.UseEntity,\n\t\tpk.VarInt(entityID),\n\t\tpk.VarInt(1),\n\t))\n}", "title": "" }, { "docid": "41d21da1cb7c22102a0e06a12ef657c2", "score": "0.38624558", "text": "func (impl *Server) NewEntity() base.EntityInterface {\n\treturn new(entity.Server)\n}", "title": "" }, { "docid": "59bba3bb3c842bc3151664490d1f6e4a", "score": "0.3851106", "text": "func LoadNpcDefinitions() {\n\tdefinitions.Npcs = DefaultEntityService.Npcs()\n}", "title": "" }, { "docid": "5222593a71678461bc174a8ab8d42e19", "score": "0.38499174", "text": "func (_Aicumen *AicumenSession) GetEntity(name string) (string, error) {\n\treturn _Aicumen.Contract.GetEntity(&_Aicumen.CallOpts, name)\n}", "title": "" }, { "docid": "db6f5da0d4a4dcc60973a25c78e7f6ce", "score": "0.38400447", "text": "func Ns(d daemondefs.Client) *eval.Ns {\n\tgetPid := func() (string, error) {\n\t\tpid, err := d.Pid()\n\t\treturn string(strconv.Itoa(pid)), err\n\t}\n\n\t// TODO: Deprecate the variable in favor of the function.\n\tgetPidVar := func() any {\n\t\tpid, err := getPid()\n\t\tif err != nil {\n\t\t\treturn \"-1\"\n\t\t}\n\t\treturn pid\n\t}\n\n\treturn eval.BuildNsNamed(\"daemon\").\n\t\tAddVars(map[string]vars.Var{\n\t\t\t\"pid\": vars.FromGet(getPidVar),\n\t\t\t\"sock\": vars.NewReadOnly(string(d.SockPath())),\n\t\t}).\n\t\tAddGoFns(map[string]any{\n\t\t\t\"pid\": getPid,\n\t\t}).Ns()\n}", "title": "" }, { "docid": "aca93737ad3901d32a114bac3014e368", "score": "0.3838731", "text": "func (t *SimpleChaincode) getEntity(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tlogger.Debug(\"enter get invoice\")\n\tdefer logger.Debug(\"exited get invoice\")\n\n\tpks, err := buildPK(stub, \"EntityMaster\", args)\n\tif err != nil{\n\t\tlogger.Debug(err.Error())\n\t\treturn shim.Error(err.Error())\n\t}\n\n\tvar entityMaster EntityMaster\n\n\tentityId, err := stub.GetState(pks)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\terr = json.Unmarshal(entityId, &entityMaster)\n\tif err != nil {\n\t\tlogger.Error(err)\n\t\treturn shim.Error(err.Error())\n\t}\n\tlogger.Debug(\"getEntity:\")\n\tlogger.Debug(entityMaster)\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"[\")\n\tbuffer.WriteString(string(entityId))\n\tbuffer.WriteString(\"]\")\n\n\treturn shim.Success([]byte(buffer.Bytes()))\n}", "title": "" }, { "docid": "ec85898c544e71f39f370c0f96dac858", "score": "0.38222134", "text": "func ById(id base.Ider) *Entity {\n\tvar data member.EntityData\n\tif ecol.Find(bson.M{\"_id\": id.Id()}).One(&data) != nil {\n\t\treturn nil\n\t}\n\treturn fromData(&data)\n}", "title": "" }, { "docid": "d8c10b0926f4c771e69633871c7f3570", "score": "0.38204202", "text": "func (network *Network) SendFindNodePacket(contact Contact, target *Contact) {\n\tcreatedPacket := network.CreatePacket(\"find_node\", network.me.Address, network.me.ID.String(), target.ID.String(), nil, nil)\n\tnetwork.SendPacket(createdPacket, contact.Address)\n}", "title": "" }, { "docid": "8758230accd992ae3899a70ce6b778ea", "score": "0.38146618", "text": "func (c *Board) GetEntityAt(row int, col int) engosdl.IEntity {\n\treturn c.Space[row][col]\n}", "title": "" }, { "docid": "ed880bd11d9147125c0b9a27a58eb396", "score": "0.37998262", "text": "func (c *PersistedCommand) EntityID() uuid.UUID {\n\treturn c.ID\n}", "title": "" }, { "docid": "8bb3b327e589c9b1c0d08f44147245b2", "score": "0.3798093", "text": "func NewMockNvmeController(\n\tpciAddr string, fwRev string, model string, serial string,\n\tnss []*ctlpb.NvmeController_Namespace, hs *ctlpb.NvmeController_Health) *ctlpb.NvmeController {\n\n\treturn &ctlpb.NvmeController{\n\t\tModel: model,\n\t\tSerial: serial,\n\t\tPciaddr: pciAddr,\n\t\tFwrev: fwRev,\n\t\tNamespaces: nss,\n\t\tHealthstats: hs,\n\t}\n}", "title": "" }, { "docid": "2a8236c797bfc45d87d72c73b7d93bab", "score": "0.3794755", "text": "func (c *cluster) GenerateNid() Nid {\n c.lock.RLock()\n defer c.lock.RUnlock()\n\n var result Nid = Nid(rand.Uint32())\n for ; c.nodes[result] != nil; result = Nid(rand.Uint32()) {}\n return result\n}", "title": "" }, { "docid": "75823316bbdba978c7db3a56859afc14", "score": "0.37935334", "text": "func NewEntity(typeName string) (Entity, error) {\n\n\t//Big constantly changing switch for now, not sure of a\n\t// better way to handle this for now.\n\tswitch strings.ToLower(typeName) {\n\tcase \"player\":\n\t\treturn new(Player), nil\n\tcase \"audio\":\n\t\treturn new(Audio), nil\n\tcase \"timer\":\n\t\treturn new(Timer), nil\n\tcase \"physicsobject\":\n\t\treturn new(PhysicsObject), nil\n\tcase \"physicsscene\":\n\t\treturn new(PhysicsScene), nil\n\tcase \"physicsbox\":\n\t\treturn new(PhysicsBox), nil\n\n\t}\n\treturn nil, errors.New(\"Entity of type \" + typeName + \" not found.\")\n\n}", "title": "" }, { "docid": "234e29d6636492506c6a9fd225d6868a", "score": "0.37888196", "text": "func (e Account) EntNew() ent.Ent { return &Account{} }", "title": "" }, { "docid": "234e29d6636492506c6a9fd225d6868a", "score": "0.37888196", "text": "func (e Account) EntNew() ent.Ent { return &Account{} }", "title": "" }, { "docid": "2a37816647c68b3b6b92f4e0c49f5aa6", "score": "0.37882623", "text": "func NewVNCCmd(client KubeClient, output io.Writer, waitForInterrupt bool) *cobra.Command {\n\tvnc := &vncCommand{client: client, output: output, waitForInterrupt: waitForInterrupt}\n\tcmd := &cobra.Command{\n\t\tUse: \"vnc pod [port]\",\n\t\tShort: \"Provide access to the VNC console of a VM pod\",\n\t\tLong: dedent.Dedent(`\n\t\t\tThis command forwards a local port to the VNC port used by the\n\t\t\tspecified VM pod. If no local port number is provided, a random\n\t\t\tavailable port is picked instead. The port number is displayed\n\t\t\tafter the forwarding is set up, after which the commands enters\n\t\t\tan endless loop until it's interrupted with Ctrl-C.\n `),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tif len(args) < 1 {\n\t\t\t\treturn errors.New(\"pod name not specified\")\n\t\t\t}\n\t\t\tvnc.podName = args[0]\n\n\t\t\tswitch {\n\t\t\tcase len(args) > 2:\n\t\t\t\treturn errors.New(\"more than 2 options\")\n\t\t\tcase len(args) == 2:\n\t\t\t\t// port should be unprivileged and below the high ports\n\t\t\t\t// range\n\t\t\t\tport, err := strconv.Atoi(args[1])\n\t\t\t\tif err != nil || port < 1024 || port > 61000 {\n\t\t\t\t\treturn errors.New(\"port parameter must be an integer number in range 1000-61000\")\n\t\t\t\t}\n\t\t\t\tvnc.port = uint16(port)\n\t\t\t}\n\t\t\treturn vnc.Run()\n\t\t},\n\t}\n\treturn cmd\n}", "title": "" }, { "docid": "0a8107021251511fe7acd9fd7c8013e1", "score": "0.37760735", "text": "func NewBookingNamedEntity()(*BookingNamedEntity) {\n m := &BookingNamedEntity{\n Entity: *NewEntity(),\n }\n return m\n}", "title": "" }, { "docid": "00d04f2972c35d8290971e2736101bc4", "score": "0.3768736", "text": "func (instance *NDiscovery) sendCommand(conn *lygo_n_net.NConn, command string, params map[string]interface{}) *lygo_n_commons.Response {\n\treturn conn.Send(command, params)\n}", "title": "" }, { "docid": "a7beb7a48815a6745bc3aa8ae4bb0752", "score": "0.3768175", "text": "func (_Aicumen *AicumenCallerSession) GetEntity(name string) (string, error) {\n\treturn _Aicumen.Contract.GetEntity(&_Aicumen.CallOpts, name)\n}", "title": "" }, { "docid": "98f7b88c20f2e112c0eb12070a561f9c", "score": "0.3760302", "text": "func (bse *BaseEvent) Entity(key entity.Key) {\n\tbse.EntityKey = string(key)\n}", "title": "" }, { "docid": "1e3f69f7ffc4d65fc854cb8d790cc720", "score": "0.37601417", "text": "func newEntityMutation(c config, op Op, opts ...entityOption) *EntityMutation {\n\tm := &EntityMutation{\n\t\tconfig: c,\n\t\top: op,\n\t\ttyp: TypeEntity,\n\t\tclearedFields: make(map[string]struct{}),\n\t}\n\tfor _, opt := range opts {\n\t\topt(m)\n\t}\n\treturn m\n}", "title": "" }, { "docid": "bbc65497754155d1c2655862a74391a4", "score": "0.37599084", "text": "func (c *Client) Noder(ctx context.Context, id int, opts ...NodeOption) (_ Noder, err error) {\n\tdefer func() {\n\t\tif IsNotFound(err) {\n\t\t\terr = multierror.Append(err, entgql.ErrNodeNotFound(id))\n\t\t}\n\t}()\n\toptions := &NodeOptions{}\n\tfor _, opt := range opts {\n\t\topt(options)\n\t}\n\tif options.Type == \"\" {\n\t\toptions.Type, err = c.tables.nodeType(ctx, c.driver, id)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn c.noder(ctx, options.Type, id)\n}", "title": "" }, { "docid": "523a6259dc7d8c9a980cfd4cdf4891ef", "score": "0.37471592", "text": "func Atom(i int) Noun { return Noun{atom: &i} }", "title": "" }, { "docid": "1ce898324192166828d2fc88883ea894", "score": "0.37355095", "text": "func (i *GroupIterator) Ent() (interface{}, error) {\n\treturn i.Group()\n}", "title": "" }, { "docid": "f0cc064ff09fc70853fa4b5c79f71748", "score": "0.37337446", "text": "func (_MonsterOwnership *MonsterOwnershipCaller) OwnerOf(opts *bind.CallOpts, _tokenId *big.Int) (common.Address, error) {\n\tvar (\n\t\tret0 = new(common.Address)\n\t)\n\tout := ret0\n\terr := _MonsterOwnership.contract.Call(opts, out, \"ownerOf\", _tokenId)\n\treturn *ret0, err\n}", "title": "" }, { "docid": "fd19afceaf136c445efe944aa4e6a940", "score": "0.37332076", "text": "func (p *Provider) Entity(streamID int, entityID uint64) (*models.Entity, error) {\n\tentityChan := make(chan *models.Entity, 1)\n\tp.internalRequestChan <- entityRequest{\n\t\trespChan: entityChan,\n\t\tstreamID: streamID,\n\t\tentityID: entityID,\n\t}\n\tselect {\n\tcase resp := <-entityChan:\n\t\tif resp == nil {\n\t\t\treturn nil, fmt.Errorf(\"entity ID %d not found in stream %d\", entityID, streamID)\n\t\t}\n\t\treturn resp, nil\n\tcase <-time.After(p.queryTimeout):\n\t\tp.logger.Error(\"Entity()\",\n\t\t\tzap.Error(ErrRequestTimedOut),\n\t\t\tzap.Int(\"streamID\", streamID),\n\t\t\tzap.Uint64(\"entityID\", entityID),\n\t\t\tzap.Duration(\"timeout-duration\", p.queryTimeout),\n\t\t)\n\t\treturn nil, ErrRequestTimedOut\n\t}\n}", "title": "" }, { "docid": "1ec8bfe8a0bef471aea3354597a6ead9", "score": "0.3730793", "text": "func (s Refable) Entity() Entity {\n\treturn ReferenceKind\n}", "title": "" }, { "docid": "4183f24886fc10dc873797e7c8e1e6a3", "score": "0.37210438", "text": "func (*CScenarioEnt_NPC) Descriptor() ([]byte, []int) {\n\treturn file_dota_scenariomessages_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "3be5f1c21a9ba028b86ea402ada84af4", "score": "0.37205485", "text": "func MockNvmeDeviceHealth(varIdx ...int32) *ctlpb.NvmeController_Health {\n\tnative := storage.MockNvmeDeviceHealth(varIdx...)\n\tpb := new(NvmeDeviceHealth)\n\n\tif err := pb.FromNative(native); err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn pb.AsProto()\n}", "title": "" }, { "docid": "a0de9c4ace704119aca89fcff538031c", "score": "0.3719338", "text": "func (f *ClientFD) MknodAt(ctx context.Context, name string, mode linux.FileMode, uid UID, gid GID, minor, major uint32) (*Inode, error) {\n\tvar req MknodAtReq\n\treq.DirFD = f.fd\n\treq.Name = SizedString(name)\n\treq.Mode = mode\n\treq.UID = uid\n\treq.GID = gid\n\treq.Minor = primitive.Uint32(minor)\n\treq.Major = primitive.Uint32(major)\n\n\tvar resp MknodAtResp\n\tctx.UninterruptibleSleepStart(false)\n\terr := f.client.SndRcvMessage(MknodAt, uint32(req.SizeBytes()), req.MarshalBytes, resp.UnmarshalUnsafe, nil)\n\tctx.UninterruptibleSleepFinish(false)\n\treturn &resp.Child, err\n}", "title": "" }, { "docid": "5e7dd88fc69debc9bbdd036d838b51df", "score": "0.3714936", "text": "func NewNatsService(sc stan.Conn, sp string) *NatsService {\n\treturn &NatsService{\n\t\tNatsClient: sc,\n\t\tSubjectPrefix: sp,\n\t}\n}", "title": "" }, { "docid": "34d1cba1f7429a79e204ec50007004e7", "score": "0.37102228", "text": "func (r *Resolver) Entity() generated.EntityResolver { return &entityResolver{r} }", "title": "" }, { "docid": "34d1cba1f7429a79e204ec50007004e7", "score": "0.37102228", "text": "func (r *Resolver) Entity() generated.EntityResolver { return &entityResolver{r} }", "title": "" }, { "docid": "80a56d8cda0af0aba03252876a13682d", "score": "0.37070373", "text": "func ToEntity(om *OrganizationMongo) *Organization {\n\tID := \"\"\n\tif !om.ID.IsZero() {\n\t\tID = om.ID.Hex()\n\t}\n\tIDsCategory := make([]string, 0)\n\tif om.IDsCategory != nil && len(om.IDsCategory) > 0 {\n\t\tfor _, id := range om.IDsCategory {\n\t\t\tIDsCategory = append(IDsCategory, id.Hex())\n\t\t}\n\t}\n\n\treturn &Organization{\n\t\tID: ID,\n\t\tName: om.Name,\n\t\tEmail: om.Email,\n\t\tPhone: om.Phone,\n\t\tStatus: om.Status,\n\t\tIDsCategory: IDsCategory,\n\t}\n}", "title": "" }, { "docid": "2e02acd33edf5d4be7ef809fe7b14c0c", "score": "0.37045318", "text": "func (a Entity) Number() string {\n\treturn a.number\n}", "title": "" } ]
59e892a73719883a50b41001f2457e2c
Recv mocks base method
[ { "docid": "b27c7bc59e110a53219f37c3980f0255", "score": "0.669117", "text": "func (m *MockClient) Recv() (*Packet, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Recv\")\n\tret0, _ := ret[0].(*Packet)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" } ]
[ { "docid": "7cc49be07e6ad31de37cdcf017f74f70", "score": "0.6943123", "text": "func (m *MockWorker_FetchDDLInfoServer) Recv() (*pb.DDLLockInfo, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Recv\")\n\tret0, _ := ret[0].(*pb.DDLLockInfo)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "1c01095873da3c879cae05fe76bfaa4d", "score": "0.6904645", "text": "func (m *MockSerial) Recv() ([]byte, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Recv\")\n\tret0, _ := ret[0].([]byte)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "8c4ba7102088de6d9d90fd3c0b186c8f", "score": "0.68000275", "text": "func (m *MockIngester_IngestServer) Recv() (*protos.Document, error) {\n\tret := m.ctrl.Call(m, \"Recv\")\n\tret0, _ := ret[0].(*protos.Document)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "be9155a9777301f40ffbe3b9faceb3f4", "score": "0.6773839", "text": "func (m *MockWorker_FetchDDLInfoClient) Recv() (*pb.DDLInfo, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Recv\")\n\tret0, _ := ret[0].(*pb.DDLInfo)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "a125f077a69424aa8c5f518daa03e530", "score": "0.67683834", "text": "func (m *MockHistoryService_StreamWorkflowReplicationMessagesServer) Recv() (*historyservice.StreamWorkflowReplicationMessagesRequest, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Recv\")\n\tret0, _ := ret[0].(*historyservice.StreamWorkflowReplicationMessagesRequest)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "5d6a0e7dd2d9df451ec6c614431eb0e0", "score": "0.6712432", "text": "func (m *MockByteStream_ReadClient) Recv() (*bytestream.ReadResponse, error) {\n\tret := m.ctrl.Call(m, \"Recv\")\n\tret0, _ := ret[0].(*bytestream.ReadResponse)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "b76114cd9f85cb3bf3f436faa6e17aee", "score": "0.66515106", "text": "func (mock *Client) Receive(src string) (chat.Message, error) {\n\treturn mock.ReceiveFunc(src)\n}", "title": "" }, { "docid": "81afec76c7b7e9e88c28013dee3a2a28", "score": "0.66281533", "text": "func (m *MockPongService_PingPongRPCClient) Recv() (*pong.PongData, error) {\n\tret := m.ctrl.Call(m, \"Recv\")\n\tret0, _ := ret[0].(*pong.PongData)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "d4526267cd0215fe7e88f8390efda1ea", "score": "0.655213", "text": "func (m *MockReverseTunnel_ConnectServer) Recv() (*rpc.ConnectRequest, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Recv\")\n\tret0, _ := ret[0].(*rpc.ConnectRequest)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "9995800317a77e11adb64d079dfe103c", "score": "0.6518636", "text": "func (m *MockHistoryService_StreamWorkflowReplicationMessagesClient) Recv() (*historyservice.StreamWorkflowReplicationMessagesResponse, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Recv\")\n\tret0, _ := ret[0].(*historyservice.StreamWorkflowReplicationMessagesResponse)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "41b35449cc5ad273f77ae472b6f44dc0", "score": "0.63941467", "text": "func (m *MockGitops_GetObjectsToSynchronizeClient) Recv() (*rpc.ObjectsToSynchronizeResponse, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Recv\")\n\tret0, _ := ret[0].(*rpc.ObjectsToSynchronizeResponse)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "a8f90cb43b6c7dd0d4bacc78d1ed1be7", "score": "0.6372931", "text": "func (m_2 *MockWorker_FetchDDLInfoServer) RecvMsg(m interface{}) error {\n\tm_2.ctrl.T.Helper()\n\tret := m_2.ctrl.Call(m_2, \"RecvMsg\", m)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "ec68a607d9397f0bbe0ccf1167062f59", "score": "0.6330104", "text": "func (m *MockTxEventService_OnConnectedClient) Recv() (*sagagrpc.GrpcCompensateCommand, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Recv\")\n\tret0, _ := ret[0].(*sagagrpc.GrpcCompensateCommand)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "c63567378049e81ae66c879d73724c2b", "score": "0.6317365", "text": "func (m *MockIngester_IngestServer) RecvMsg(arg0 interface{}) error {\n\tret := m.ctrl.Call(m, \"RecvMsg\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "c32ace37cdc3c241ffb97153bcfc17fb", "score": "0.6307603", "text": "func (m *MockPrivateTransactionManager) Receive(arg0 common.EncryptedPayloadHash) (string, []string, []byte, *engine.ExtraMetadata, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Receive\", arg0)\n\tret0, _ := ret[0].(string)\n\tret1, _ := ret[1].([]string)\n\tret2, _ := ret[2].([]byte)\n\tret3, _ := ret[3].(*engine.ExtraMetadata)\n\tret4, _ := ret[4].(error)\n\treturn ret0, ret1, ret2, ret3, ret4\n}", "title": "" }, { "docid": "5223f2e7928a759a641ff6c2a83d6865", "score": "0.630398", "text": "func (m *MockWebsocketConnection) Read() (wspubsub.Message, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Read\")\n\tret0, _ := ret[0].(wspubsub.Message)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "8ab3b33b814d17106bd417db790626a6", "score": "0.6294561", "text": "func (m *MockGitops_GetObjectsToSynchronizeServer) RecvMsg(arg0 interface{}) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"RecvMsg\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "514bd01f5f4b2e61398087b8b9d2e153", "score": "0.6292762", "text": "func (m *MockReverseTunnel_ConnectClient) Recv() (*rpc.ConnectResponse, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Recv\")\n\tret0, _ := ret[0].(*rpc.ConnectResponse)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "0137d4ae2afce0eec7c01fe16ef706bc", "score": "0.6259386", "text": "func (m_2 *MockWorker_FetchDDLInfoClient) RecvMsg(m interface{}) error {\n\tm_2.ctrl.T.Helper()\n\tret := m_2.ctrl.Call(m_2, \"RecvMsg\", m)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "0b7b8ad2ccea32fc5e8b9f5605d5da83", "score": "0.62031233", "text": "func (m *MockServer) Receive(arg0 udp.RequestHandler) error {\n\tret := m.ctrl.Call(m, \"Receive\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "b0f610cc767e4c467c2c02ecdaca31d8", "score": "0.61593103", "text": "func (m *MockGitops_GetObjectsToSynchronizeClient) RecvMsg(arg0 interface{}) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"RecvMsg\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "702837f6c088c564ff8f463f3ce1c052", "score": "0.6068425", "text": "func (m *MockByteStream_ReadClient) RecvMsg(arg0 interface{}) error {\n\tret := m.ctrl.Call(m, \"RecvMsg\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "0cb2a6b7d8ac6bbb856397ea580fda8e", "score": "0.60637856", "text": "func (m_2 *MockHistoryService_StreamWorkflowReplicationMessagesServer) RecvMsg(m interface{}) error {\n\tm_2.ctrl.T.Helper()\n\tret := m_2.ctrl.Call(m_2, \"RecvMsg\", m)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "100cf3eece6e26bd14da281db13feaa8", "score": "0.59899056", "text": "func (s *server) networkRecvTest(w http.ResponseWriter, r *http.Request) {\n\tw.Write(s.recvBuf)\n\n\ts.recvBuf = []byte{}\n}", "title": "" }, { "docid": "a04bc0a0ed749a55cf46c21bc6bf76f0", "score": "0.59837115", "text": "func (m *MockByteStream_WriteClient) RecvMsg(arg0 interface{}) error {\n\tret := m.ctrl.Call(m, \"RecvMsg\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "7a93c41f3fbcdfe6c73ce09a97b0a3a8", "score": "0.59575695", "text": "func (m *MockStream) Receive(ctx context.Context) (interface{}, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Receive\", ctx)\n\tret0, _ := ret[0].(interface{})\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "0ab8911c1f8803432f58926b998d2022", "score": "0.5951611", "text": "func TestConnection_Receiver(t *testing.T) {\n\n\tvar customErr = fmt.Errorf(\"foo\")\n\n\ttestCases := []struct {\n\t\tdescription string\n\t\trecvResp []*testRecvResponse\n\t\twantFinalErr error\n\t\twantTotalAttempts int\n\t}{\n\t\t{\n\t\t\tdescription: \"no errors\",\n\t\t\trecvResp: []*testRecvResponse{\n\t\t\t\t{\n\t\t\t\t\tresp: &storagepb.AppendRowsResponse{},\n\t\t\t\t\terr: nil,\n\t\t\t\t},\n\t\t\t},\n\t\t\twantTotalAttempts: 1,\n\t\t},\n\t\t{\n\t\t\tdescription: \"recv err w/io.EOF\",\n\t\t\trecvResp: []*testRecvResponse{\n\t\t\t\t{\n\t\t\t\t\tresp: nil,\n\t\t\t\t\terr: io.EOF,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tresp: &storagepb.AppendRowsResponse{},\n\t\t\t\t\terr: nil,\n\t\t\t\t},\n\t\t\t},\n\t\t\twantTotalAttempts: 2,\n\t\t},\n\t\t{\n\t\t\tdescription: \"recv err retried and then failed\",\n\t\t\trecvResp: []*testRecvResponse{\n\t\t\t\t{\n\t\t\t\t\tresp: nil,\n\t\t\t\t\terr: io.EOF,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tresp: nil,\n\t\t\t\t\terr: customErr,\n\t\t\t\t},\n\t\t\t},\n\t\t\twantTotalAttempts: 2,\n\t\t\twantFinalErr: customErr,\n\t\t},\n\t\t{\n\t\t\tdescription: \"recv err w/ custom error\",\n\t\t\trecvResp: []*testRecvResponse{\n\t\t\t\t{\n\t\t\t\t\tresp: nil,\n\t\t\t\t\terr: customErr,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tresp: &storagepb.AppendRowsResponse{},\n\t\t\t\t\terr: nil,\n\t\t\t\t},\n\t\t\t},\n\t\t\twantTotalAttempts: 1,\n\t\t\twantFinalErr: customErr,\n\t\t},\n\n\t\t{\n\t\t\tdescription: \"resp embeds Unavailable\",\n\t\t\trecvResp: []*testRecvResponse{\n\t\t\t\t{\n\t\t\t\t\tresp: &storagepb.AppendRowsResponse{\n\t\t\t\t\t\tResponse: &storagepb.AppendRowsResponse_Error{\n\t\t\t\t\t\t\tError: &statuspb.Status{\n\t\t\t\t\t\t\t\tCode: int32(codes.Unavailable),\n\t\t\t\t\t\t\t\tMessage: \"foo\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\terr: nil,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tresp: &storagepb.AppendRowsResponse{},\n\t\t\t\t\terr: nil,\n\t\t\t\t},\n\t\t\t},\n\t\t\twantTotalAttempts: 2,\n\t\t},\n\t\t{\n\t\t\tdescription: \"resp embeds generic ResourceExhausted\",\n\t\t\trecvResp: []*testRecvResponse{\n\t\t\t\t{\n\t\t\t\t\tresp: &storagepb.AppendRowsResponse{\n\t\t\t\t\t\tResponse: &storagepb.AppendRowsResponse_Error{\n\t\t\t\t\t\t\tError: &statuspb.Status{\n\t\t\t\t\t\t\t\tCode: int32(codes.ResourceExhausted),\n\t\t\t\t\t\t\t\tMessage: \"foo\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\terr: nil,\n\t\t\t\t},\n\t\t\t},\n\t\t\twantTotalAttempts: 1,\n\t\t\twantFinalErr: func() error {\n\t\t\t\treturn status.ErrorProto(&statuspb.Status{\n\t\t\t\t\tCode: int32(codes.ResourceExhausted),\n\t\t\t\t\tMessage: \"foo\",\n\t\t\t\t})\n\t\t\t}(),\n\t\t},\n\t\t{\n\t\t\tdescription: \"resp embeds throughput ResourceExhausted\",\n\t\t\trecvResp: []*testRecvResponse{\n\t\t\t\t{\n\t\t\t\t\tresp: &storagepb.AppendRowsResponse{\n\t\t\t\t\t\tResponse: &storagepb.AppendRowsResponse_Error{\n\t\t\t\t\t\t\tError: &statuspb.Status{\n\t\t\t\t\t\t\t\tCode: int32(codes.ResourceExhausted),\n\t\t\t\t\t\t\t\tMessage: \"Exceeds 'AppendRows throughput' quota for stream blah\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\terr: nil,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tresp: &storagepb.AppendRowsResponse{},\n\t\t\t\t\terr: nil,\n\t\t\t\t},\n\t\t\t},\n\t\t\twantTotalAttempts: 2,\n\t\t},\n\t\t{\n\t\t\tdescription: \"retriable failures until max attempts\",\n\t\t\trecvResp: []*testRecvResponse{\n\t\t\t\t{\n\t\t\t\t\terr: io.EOF,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\terr: io.EOF,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\terr: io.EOF,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\terr: io.EOF,\n\t\t\t\t},\n\t\t\t},\n\t\t\twantTotalAttempts: 4,\n\t\t\twantFinalErr: io.EOF,\n\t\t},\n\t}\n\n\tfor _, tc := range testCases {\n\t\tctx, cancel := context.WithCancel(context.Background())\n\n\t\ttestArc := &testAppendRowsClient{\n\t\t\tresponses: tc.recvResp,\n\t\t}\n\n\t\tpool := &connectionPool{\n\t\t\tctx: ctx,\n\t\t\topen: openTestArc(testArc, nil,\n\t\t\t\tfunc() (*storagepb.AppendRowsResponse, error) {\n\t\t\t\t\tif len(testArc.responses) == 0 {\n\t\t\t\t\t\tpanic(\"out of responses\")\n\t\t\t\t\t}\n\t\t\t\t\tcurResp := testArc.responses[0]\n\t\t\t\t\ttestArc.responses = testArc.responses[1:]\n\t\t\t\t\treturn curResp.resp, curResp.err\n\t\t\t\t},\n\t\t\t),\n\t\t\tbaseFlowController: newFlowController(0, 0),\n\t\t}\n\t\trouter := newSimpleRouter(\"\")\n\t\tif err := pool.activateRouter(router); err != nil {\n\t\t\tt.Errorf(\"activateRouter: %v\", err)\n\t\t}\n\n\t\tms := &ManagedStream{\n\t\t\tid: \"foo\",\n\t\t\tctx: ctx,\n\t\t\tretry: newStatelessRetryer(),\n\t\t}\n\t\tif err := pool.addWriter(ms); err != nil {\n\t\t\tt.Errorf(\"addWriter: %v\", err)\n\t\t}\n\t\tconn := router.conn\n\t\t// use openWithRetry to get the reference to the channel and add our test pending write.\n\t\t_, ch, _ := pool.openWithRetry(conn)\n\t\tpw := newPendingWrite(ctx, ms, &storagepb.AppendRowsRequest{}, nil, \"\", \"\")\n\t\tpw.writer = ms\n\t\tpw.attemptCount = 1 // we're injecting directly, but attribute this as a single attempt.\n\t\tch <- pw\n\n\t\t// Wait until the write is marked done.\n\t\t<-pw.result.Ready()\n\n\t\t// Check retry count is as expected.\n\t\tgotTotalAttempts, err := pw.result.TotalAttempts(ctx)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"%s: failed to get total attempts: %v\", tc.description, err)\n\t\t}\n\t\tif gotTotalAttempts != tc.wantTotalAttempts {\n\t\t\tt.Errorf(\"%s: got %d total attempts, want %d attempts\", tc.description, gotTotalAttempts, tc.wantTotalAttempts)\n\t\t}\n\n\t\t// Check that the write got the expected final result.\n\t\tif gotFinalErr := pw.result.err; !errors.Is(gotFinalErr, tc.wantFinalErr) {\n\t\t\tt.Errorf(\"%s: got final error %v, wanted final error %v\", tc.description, gotFinalErr, tc.wantFinalErr)\n\t\t}\n\t\tcancel()\n\t}\n}", "title": "" }, { "docid": "381d6eb53aa55401826d8e8299a48672", "score": "0.59508353", "text": "func (m_2 *MockHistoryService_StreamWorkflowReplicationMessagesClient) RecvMsg(m interface{}) error {\n\tm_2.ctrl.T.Helper()\n\tret := m_2.ctrl.Call(m_2, \"RecvMsg\", m)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "0cc4a0bc128c7ee953454e92fb3401af", "score": "0.5924721", "text": "func (m *MockPrivateTransactionManager) ReceiveRaw(arg0 common.EncryptedPayloadHash) ([]byte, string, *engine.ExtraMetadata, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ReceiveRaw\", arg0)\n\tret0, _ := ret[0].([]byte)\n\tret1, _ := ret[1].(string)\n\tret2, _ := ret[2].(*engine.ExtraMetadata)\n\tret3, _ := ret[3].(error)\n\treturn ret0, ret1, ret2, ret3\n}", "title": "" }, { "docid": "1a663c5480d70af2bf0876276b7ce886", "score": "0.5919187", "text": "func (m *MockTLSExtensionHandler) Receive(arg0 mint.HandshakeType, arg1 *mint.ExtensionList) error {\n\tret := m.ctrl.Call(m, \"Receive\", arg0, arg1)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "24d6f29d742c0b0c19655c7ca1395b23", "score": "0.58347285", "text": "func (m *MockPongService_PingPongRPCClient) RecvMsg(arg0 interface{}) error {\n\tret := m.ctrl.Call(m, \"RecvMsg\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "e0e8eced51c7c0217a159acbd16cd4d6", "score": "0.5815797", "text": "func (_m *ConnWithTimeout) Receive() (interface{}, error) {\n\tret := _m.Called()\n\n\tvar r0 interface{}\n\tif rf, ok := ret.Get(0).(func() interface{}); ok {\n\t\tr0 = rf()\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(interface{})\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func() error); ok {\n\t\tr1 = rf()\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "title": "" }, { "docid": "2e1bf511a6574541526819184b4526df", "score": "0.58064616", "text": "func (m *MockReverseTunnel_ConnectServer) RecvMsg(arg0 interface{}) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"RecvMsg\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "04c00ec9cf4e2bfa5073137860dfb416", "score": "0.57906204", "text": "func (_m *BtcIndexer_SyncStream) Recv() (*btcindexersrv.SyncRequest, error) {\n\tret := _m.Called()\n\n\tvar r0 *btcindexersrv.SyncRequest\n\tif rf, ok := ret.Get(0).(func() *btcindexersrv.SyncRequest); ok {\n\t\tr0 = rf()\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(*btcindexersrv.SyncRequest)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func() error); ok {\n\t\tr1 = rf()\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "title": "" }, { "docid": "9016d91033ceb1226b6d2fa4ac2ea669", "score": "0.5751645", "text": "func (_m *MockCollectionConfigService_GetConfigStreamClient) Recv() (*GetConfigStreamResponse, error) {\n\tret := _m.Called()\n\n\tvar r0 *GetConfigStreamResponse\n\tif rf, ok := ret.Get(0).(func() *GetConfigStreamResponse); ok {\n\t\tr0 = rf()\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(*GetConfigStreamResponse)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func() error); ok {\n\t\tr1 = rf()\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "title": "" }, { "docid": "eb5b983c223184f23e1e276a306a5a5d", "score": "0.5741534", "text": "func TestReceive(t *testing.T) {\n\tconst (\n\t\tkey = \"TEST:RECEIVE\"\n\t\tvalue = key\n\t)\n\t_, e := client.Restore(key, -1, value, true)\n\tif e == nil {\n\t\tt.Errorf(\"Miscellaneous did not work properly.\")\n\t}\n}", "title": "" }, { "docid": "ee03c8a11d84b26a8c7ea43fc7ae5fe8", "score": "0.5730655", "text": "func (m *MockByteStreamClient) Read(arg0 context.Context, arg1 *bytestream.ReadRequest, arg2 ...grpc.CallOption) (bytestream.ByteStream_ReadClient, error) {\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"Read\", varargs...)\n\tret0, _ := ret[0].(bytestream.ByteStream_ReadClient)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "0583708f5e5615c5949dfdb44740c5aa", "score": "0.5730224", "text": "func (m *MockReverseTunnel_ConnectClient) RecvMsg(arg0 interface{}) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"RecvMsg\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "2986651bb4214e2038985e1ec3f090d0", "score": "0.57240474", "text": "func Test_bftDeliveryClient_Recv(t *testing.T) {\n\tflogging.ActivateSpec(\"bftDeliveryClient=DEBUG\")\n\n\tosArray := make([]*mocks.Orderer, 0)\n\tfor port := range endpointMap {\n\t\tosArray = append(osArray, mocks.NewOrderer(port, t))\n\t}\n\tfor _, os := range osArray {\n\t\tos.SetNextExpectedSeek(5)\n\t}\n\n\tgrpcClient, err := comm.NewGRPCClient(comm.ClientConfig{\n\t\tSecOpts: comm.SecureOptions{\n\t\t\tUseTLS: true,\n\t\t},\n\t})\n\trequire.NoError(t, err)\n\n\tfakeOrdererConnectionSource := &fake.OrdererConnectionSource{\n\t\tGetAllEndpointsStub: func() []*orderers.Endpoint { return endpoints },\n\t}\n\n\tfakeLedgerInfo := &fake.LedgerInfo{}\n\tfakeLedgerInfo.LedgerHeightReturns(5, nil)\n\tfakeBlockVerifier := &fake.BlockVerifier{}\n\tmockSignerSerializer := &mocks2.SignerSerializer{}\n\tmockSignerSerializer.On(\"Sign\", mock.Anything).Return([]byte{1, 2, 3}, nil)\n\tmockSignerSerializer.On(\"Serialize\", mock.Anything).Return([]byte{0, 2, 4, 6}, nil)\n\tfakeDialer := &fake.Dialer{}\n\tfakeDialer.DialCalls(func(ep string, cp *x509.CertPool) (*grpc.ClientConn, error) {\n\t\tctx, cancel := context.WithTimeout(context.Background(), getConnectionTimeout())\n\t\tdefer cancel()\n\t\treturn grpc.DialContext(ctx, ep, grpc.WithInsecure(), grpc.WithBlock())\n\t})\n\n\tbc, err := NewBFTDeliveryClient(\"test-chain\", fakeOrdererConnectionSource, fakeLedgerInfo, fakeBlockVerifier, mockSignerSerializer, grpcClient, fakeDialer)\n\trequire.NotNil(t, bc)\n\trequire.Nil(t, err)\n\n\tgo func() {\n\t\tfor {\n\t\t\tresp, err := bc.Recv()\n\t\t\tif err != nil {\n\t\t\t\tassert.EqualError(t, err, errClientClosing.Error())\n\t\t\t\treturn\n\t\t\t}\n\t\t\tblock := resp.GetBlock()\n\t\t\tassert.NotNil(t, block)\n\t\t\tif block == nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tbc.UpdateReceived(block.Header.Number)\n\t\t}\n\t}()\n\n\t// all orderers send something: block/header\n\tbeforeSend := time.Now()\n\tfor seq := uint64(5); seq < uint64(10); seq++ {\n\t\tfor _, os := range osArray {\n\t\t\tos.SendBlock(seq)\n\t\t}\n\t}\n\n\ttime.Sleep(time.Second)\n\tbc.CloseSend()\n\n\tlastN, lastT := bc.GetNextBlockNumTime()\n\tassert.Equal(t, uint64(10), lastN)\n\tassert.True(t, lastT.After(beforeSend))\n\n\theadersNum, headerT, headerErr := bc.GetHeadersBlockNumTime()\n\tfor i, n := range headersNum {\n\t\tassert.Equal(t, uint64(10), n)\n\t\tassert.True(t, headerT[i].After(beforeSend))\n\t\tassert.NoError(t, headerErr[i])\n\t}\n\n\tfor _, os := range osArray {\n\t\tos.Shutdown()\n\t}\n}", "title": "" }, { "docid": "abff871c8c5ac6662221598cf9ad9bea", "score": "0.56865484", "text": "func (m *MockTxEventService_OnConnectedClient) RecvMsg(arg0 interface{}) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"RecvMsg\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "765e4ba4707b84ff93276e79bb6dd3eb", "score": "0.5683916", "text": "func TestInventoryControlStreamPipe(t *testing.T) {\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\n\tupstream, downstream := InventoryControlStreamPipe()\n\tdefer upstream.Close()\n\n\tupMsgs := []proto.UpstreamInventoryMessage{\n\t\tproto.UpstreamInventoryHello{},\n\t\tproto.UpstreamInventoryPong{},\n\t\tproto.InventoryHeartbeat{},\n\t}\n\n\tdownMsgs := []proto.DownstreamInventoryMessage{\n\t\tproto.DownstreamInventoryHello{},\n\t\tproto.DownstreamInventoryPing{},\n\t\tproto.DownstreamInventoryPing{}, // duplicate to pad downMsgs to same length as upMsgs\n\t}\n\n\tgo func() {\n\t\tfor _, m := range upMsgs {\n\t\t\tdownstream.Send(ctx, m)\n\t\t}\n\t}()\n\n\tgo func() {\n\t\tfor _, m := range downMsgs {\n\t\t\tupstream.Send(ctx, m)\n\t\t}\n\t}()\n\n\ttimeout := time.NewTimer(time.Second * 5)\n\tdefer timeout.Stop()\n\tfor i := range upMsgs {\n\t\tif !timeout.Stop() {\n\t\t\t<-timeout.C\n\t\t}\n\t\ttimeout.Reset(time.Second * 5)\n\n\t\t// upstream handle recv\n\t\tselect {\n\t\tcase msg := <-upstream.Recv():\n\t\t\trequire.IsType(t, upMsgs[i], msg)\n\t\tcase <-timeout.C:\n\t\t\tt.Fatalf(\"timeout waiting for message: %T\", upMsgs[i])\n\t\t}\n\n\t\t// downstream handle recv\n\t\tselect {\n\t\tcase msg := <-downstream.Recv():\n\t\t\trequire.IsType(t, downMsgs[i], msg)\n\t\tcase <-timeout.C:\n\t\t\tt.Fatalf(\"timeout waiting for message: %T\", downMsgs[i])\n\t\t}\n\t}\n\n\tupstream.Close()\n\n\tif !timeout.Stop() {\n\t\t<-timeout.C\n\t}\n\ttimeout.Reset(time.Second * 5)\n\n\tselect {\n\tcase <-downstream.Done():\n\tcase <-timeout.C:\n\t\tt.Fatal(\"timeout waiting for close\")\n\t}\n\n\tassert.ErrorIs(t, downstream.Error(), io.EOF)\n}", "title": "" }, { "docid": "6442d2d025c2866d9036d37bde8e8e40", "score": "0.5670343", "text": "func TestParseRecv(t *testing.T) {\n\ttest := TestCases[\"Recv\"]\n\tproc, err := Parse(strings.NewReader(test.Input))\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif strings.TrimSpace(proc.String()) != test.Output {\n\t\tt.Errorf(\"Parse: `%s` not parsed as receive: `%s`\\nparsed: %s\",\n\t\t\ttest.Input, test.Output, proc)\n\t}\n}", "title": "" }, { "docid": "1a5d8035b024b2966dc85a3bf1053a05", "score": "0.56686175", "text": "func (_m *MockStreamI) SentFin() {\n\t_m.ctrl.Call(_m, \"SentFin\")\n}", "title": "" }, { "docid": "88f782954eda2cb46df242cada34af43", "score": "0.5632369", "text": "func (_m *PersonService_StoreServer) Recv() (*api.Person, error) {\n\tret := _m.Called()\n\n\tvar r0 *api.Person\n\tif rf, ok := ret.Get(0).(func() *api.Person); ok {\n\t\tr0 = rf()\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(*api.Person)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func() error); ok {\n\t\tr1 = rf()\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "title": "" }, { "docid": "c162c4db5b63f24ae22e6bb4d266dc2d", "score": "0.56301284", "text": "func (t *TestSvc) TestRequestReceiveReturnsRaw(s *session.Session, in []byte) ([]byte, error) {\n\treturn in, nil\n}", "title": "" }, { "docid": "628efd9d8080e22a07d65a1c998efdc3", "score": "0.56291234", "text": "func (m *MockByteStream_WriteClient) CloseAndRecv() (*bytestream.WriteResponse, error) {\n\tret := m.ctrl.Call(m, \"CloseAndRecv\")\n\tret0, _ := ret[0].(*bytestream.WriteResponse)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "f7b8a50e6daaafb2daa0ea8c0421fcbd", "score": "0.5623761", "text": "func (_m *MockCollectionConfigService_GetConfigStreamServer) RecvMsg(m interface{}) error {\n\tret := _m.Called(m)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(interface{}) error); ok {\n\t\tr0 = rf(m)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "title": "" }, { "docid": "d484e824fc5c6aa05ce7e0a5e0c773a5", "score": "0.5614974", "text": "func (s *streamServerStub) StubRecv() (*apipb.OutputDataMessage, error) {\n\tret, ok := <-s.msgChan\n\tif !ok {\n\t\treturn nil, errors.New(\"eof\")\n\t}\n\treturn ret, nil\n}", "title": "" }, { "docid": "3e77b49198d832ffbd3b64a8e2ebe6fb", "score": "0.55915916", "text": "func (_m *BtcIndexer_SyncStream) RecvMsg(_a0 interface{}) error {\n\tret := _m.Called(_a0)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(interface{}) error); ok {\n\t\tr0 = rf(_a0)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "title": "" }, { "docid": "802b4d62fa4c1a7dfef31881815f276c", "score": "0.55661684", "text": "func (_m *MockCollectionConfigService_GetConfigStreamClient) RecvMsg(m interface{}) error {\n\tret := _m.Called(m)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(interface{}) error); ok {\n\t\tr0 = rf(m)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "title": "" }, { "docid": "ab1d00b2f96d646ed29817f494a0975d", "score": "0.5549921", "text": "func (m *MockRabbitExchange) Receive(arg0 rabbitevents.ExchangeSettings, arg1 rabbitevents.QueueSettings) (func(rabbitevents.MessageHandleFunc) error, func(), error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Receive\", arg0, arg1)\n\tret0, _ := ret[0].(func(rabbitevents.MessageHandleFunc) error)\n\tret1, _ := ret[1].(func())\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}", "title": "" }, { "docid": "d9d60006e3838e7a700f977b111c9d4d", "score": "0.55443424", "text": "func (m *MockConn) Read(b []byte) (int, error) {\n\tret := m.ctrl.Call(m, \"Read\", b)\n\tret0, _ := ret[0].(int)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "b158f9d54202734faa4dcc07a44a317a", "score": "0.55436957", "text": "func (_m *PersonService_StoreServer) RecvMsg(m interface{}) error {\n\tret := _m.Called(m)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(interface{}) error); ok {\n\t\tr0 = rf(m)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "title": "" }, { "docid": "57f3edf60caf08bf678de1730c77455e", "score": "0.55309516", "text": "func (_m *MockStreamI) Read(_param0 []byte) (int, error) {\n\tret := _m.ctrl.Call(_m, \"Read\", _param0)\n\tret0, _ := ret[0].(int)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "a107a4251d0b2ba86ca8ba0ae6774837", "score": "0.5486647", "text": "func (m *MockByteStream_ReadClient) SendMsg(arg0 interface{}) error {\n\tret := m.ctrl.Call(m, \"SendMsg\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "f97736efb76e62f7deb461e1bfee2c68", "score": "0.54829085", "text": "func (m_2 *MockWorker_FetchDDLInfoServer) SendMsg(m interface{}) error {\n\tm_2.ctrl.T.Helper()\n\tret := m_2.ctrl.Call(m_2, \"SendMsg\", m)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "0b6bb5204ee9062cbd3a3846a6db6d48", "score": "0.548116", "text": "func (state *mockComponent) Receive(ctx *network.ComponentContext) error {\n\tswitch msg := ctx.Message().(type) {\n\tcase *messages.BasicMessage:\n\t\tstate.Mailbox <- msg\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "81e012c0ce8abf1bb80016b3a4b7518c", "score": "0.54763883", "text": "func TestMockedConnIsUsable(t *testing.T) {\n\tmc := newMockedConn() // make sure we use it through the interface\n\n\t{\n\t\tdata := make([]byte, 128)\n\t\tcount, err := mc.Read(data)\n\t\tif count != len(data) || err != nil {\n\t\t\tt.Error(\"mockedConn cannot Read()\")\n\t\t}\n\t}\n\n\t{\n\t\tdata := make([]byte, 128)\n\t\tcount, err := mc.Write(data)\n\t\tif count != len(data) || err != nil {\n\t\t\tt.Error(\"mockedConn cannot Write()\")\n\t\t}\n\t}\n\n\t{\n\t\terr := mc.Close()\n\t\tif err != nil {\n\t\t\tt.Error(\"mockedConn cannot Close()\")\n\t\t}\n\t}\n\n\t{\n\t\tlocal := mc.LocalAddr()\n\t\t// the reason why I'm calling Network() and String is to proof that\n\t\t// they are not going to panic, I don't care about values\n\t\tif local == nil || local.Network() == \"\" || local.String() == \"\" {\n\t\t\tt.Error(\"mxockedConn cannot LocalAddr()\")\n\t\t}\n\t}\n\n\t{\n\t\tremote := mc.RemoteAddr()\n\t\tif remote == nil || remote.Network() == \"\" || remote.String() == \"\" {\n\t\t\tt.Error(\"mxockedConn cannot RemoteAddr()\")\n\t\t}\n\t}\n\n\t{\n\t\terr := mc.SetDeadline(time.Time{})\n\t\tif err != nil {\n\t\t\tt.Error(\"mockedConn cannot SetDeadline()\")\n\t\t}\n\t}\n\n\t{\n\t\terr := mc.SetReadDeadline(time.Time{})\n\t\tif err != nil {\n\t\t\tt.Error(\"mockedConn cannot SetReadDeadline()\")\n\t\t}\n\t}\n\n\t{\n\t\terr := mc.SetWriteDeadline(time.Time{})\n\t\tif err != nil {\n\t\t\tt.Error(\"mockedConn cannot SetWriteDeadline()\")\n\t\t}\n\t}\n}", "title": "" }, { "docid": "088a44df5400987d0a8a19987824ec95", "score": "0.5465281", "text": "func TestSendRecv(t *testing.T) {\n\t// TEST_SEND_CHILD indicates that we've been spawned as a child by\n\t// the test suite.\n\tif os.Getenv(\"TEST_SEND_CHILD\") == \"1\" {\n\t\ttestSendRecvChild(t)\n\t} else {\n\t\ttestSendRecvParent(t)\n\t}\n}", "title": "" }, { "docid": "0f806129072871658ddd2944eb8ca51b", "score": "0.5454625", "text": "func (m_2 *MockWorker_FetchDDLInfoClient) SendMsg(m interface{}) error {\n\tm_2.ctrl.T.Helper()\n\tret := m_2.ctrl.Call(m_2, \"SendMsg\", m)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "0b2009fea1ed76eeb42f8c3cbb07d03f", "score": "0.54387915", "text": "func (m *MockHistoryService_StreamWorkflowReplicationMessagesServer) Send(arg0 *historyservice.StreamWorkflowReplicationMessagesResponse) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Send\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "fc55abfffae991a85929a42942bae195", "score": "0.5434891", "text": "func testClient(t *testing.T, cli, srv net.Conn, client *Client, method string, in interface{}, want string, wanterr *Error) {\n\ttype Res struct {\n\t\tgot string\n\t\terr error\n\t}\n\tread := make(chan Res, 1)\n\tdone := make(chan *rpc.Call, 1)\n\tgo func() {\n\t\tbuf := bufio.NewReader(srv)\n\t\tgot, err := buf.ReadString('\\n')\n\t\tread <- Res{got, err}\n\t}()\n\tgo client.Go(method, in, &struct{}{}, done)\n\n\tvar err error\n\tvar got string\n\tselect {\n\tcase call := <-done:\n\t\terr = call.Error\n\t\tcli.Write([]byte(\"\\n\"))\n\tcase res := <-read:\n\t\tif res.err != nil {\n\t\t\tt.Fatalf(\"%ssrv.Read(), err = %v\", caller(), res.err)\n\t\t}\n\t\tgot = strings.TrimRight(res.got, \"\\n\")\n\t}\n\n\tif err == nil && wanterr != nil || err != nil && (wanterr == nil || !reflect.DeepEqual(ServerError(err), wanterr)) {\n\t\tt.Errorf(\"%serr = %v, wanterr = %v\", caller(), err, wanterr)\n\t}\n\tif got == want {\n\t\treturn\n\t}\n\tvar jgot, jwant interface{}\n\tif err := json.Unmarshal([]byte(got), &jgot); err != nil {\n\t\tt.Errorf(\"%s%s(%v), output err = %v\\ngot: %#q\", caller(), method, in, err, got)\n\t}\n\tif err := json.Unmarshal([]byte(want), &jwant); err != nil {\n\t\tt.Errorf(\"%s%s(%v), expect err = %v\\nexp: %#q\", caller(), method, in, err, want)\n\t}\n\tif !reflect.DeepEqual(jgot, jwant) {\n\t\tt.Errorf(\"%s%s(%v)\\nexp: %#q\\ngot: %#q\", caller(), method, in, want, got)\n\t}\n}", "title": "" }, { "docid": "905cab3268afbd3f5e1a4fec94a433fa", "score": "0.541351", "text": "func RTTest(t *testing.T) {\n\t// Make a node.\n\tnode, err := ros.NewNode(\"/rosgo\", os.Args)\n\tif err != nil {\n\t\tt.Error(\"error instantiating node; \", err)\n\t\treturn\n\t}\n\tdefer node.Shutdown()\n\n\t// Make a dynamicMessageType.\n\tmsgType, err := ros.NewDynamicMessageType(\"std_msgs/String\")\n\tif err != nil {\n\t\tt.Error(\"error creating dynamic message type: \", err)\n\t\treturn\n\t}\n\n\t// Make a dynamicMessage with data.\n\tdynamicMsg := msgType.NewMessage().(*ros.DynamicMessage)\n\tdynamicMsg.Data()[\"data\"] = targetMessage\n\n\t// Make a publisher and subscriber.\n\tpub, err := node.NewPublisher(\"/chatter\", dynamicMsg.Type())\n\tif err != nil {\n\t\tt.Error(\"failed to make publisher with dynamic message type\")\n\t\treturn\n\t}\n\tnode.NewSubscriber(\"/chatter\", msgType, callback)\n\n\tchanRx = make(chan string, 1)\n\tchanNodeStop := make(chan struct{})\n\tdefer func() { chanNodeStop <- struct{}{}; <-chanNodeStop }()\n\n\tgo func() {\n\t\tfor node.OK() {\n\t\t\tselect {\n\t\t\tcase <-chanNodeStop:\n\t\t\t\tchanNodeStop <- struct{}{}\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t\t//Publish a message\n\t\t\t\tmsg := ros.Message(dynamicMsg)\n\t\t\t\tpub.Publish(msg)\n\n\t\t\t\t_ = node.SpinOnce()\n\t\t\t}\n\t\t}\n\t}()\n\n\t// Look for the rx callback to report something.\n\tselect {\n\tcase rx := <-chanRx:\n\t\tif rx == targetMessage {\n\t\t\t// Test passes.\n\t\t\treturn\n\t\t}\n\t\tt.Error(\"rx mismatch:\", rx, \"vs\", targetMessage)\n\t\treturn\n\tcase <-time.After(500 * time.Millisecond):\n\t\tt.Error(\"timeout waiting for rx\")\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "fcb5bbaa38edfbe67b4568ef6a99452e", "score": "0.540929", "text": "func testClientNotify(t *testing.T, cli, srv net.Conn, client *Client, method string, in interface{}, want string, wanterr *Error) {\n\ttype Res struct {\n\t\tgot string\n\t\terr error\n\t}\n\tread := make(chan Res, 1)\n\tdone := make(chan error, 1)\n\tgo func() {\n\t\tbuf := bufio.NewReader(srv)\n\t\tgot, err := buf.ReadString('\\n')\n\t\tread <- Res{got, err}\n\t}()\n\tgo func() {\n\t\terr := client.Notify(method, in)\n\t\tif err != nil {\n\t\t\tdone <- err\n\t\t}\n\t}()\n\n\tvar err error\n\tvar got string\n\tselect {\n\tcase err = <-done:\n\t\tcli.Write([]byte(\"\\n\"))\n\tcase res := <-read:\n\t\tif res.err != nil {\n\t\t\tt.Fatalf(\"%ssrv.Read(), err = %v\", caller(), res.err)\n\t\t}\n\t\tgot = strings.TrimRight(res.got, \"\\n\")\n\t}\n\n\tif err == nil && wanterr != nil || err != nil && (wanterr == nil || !reflect.DeepEqual(ServerError(err), wanterr)) {\n\t\tt.Errorf(\"%serr = %v, wanterr = %v\", caller(), err, wanterr)\n\t}\n\tif got == want {\n\t\treturn\n\t}\n\tvar jgot, jwant interface{}\n\tif err := json.Unmarshal([]byte(got), &jgot); err != nil {\n\t\tt.Errorf(\"%s%s(%v), output err = %v\\ngot: %#q\", caller(), method, in, err, got)\n\t}\n\tif err := json.Unmarshal([]byte(want), &jwant); err != nil {\n\t\tt.Errorf(\"%s%s(%v), expect err = %v\\nexp: %#q\", caller(), method, in, err, want)\n\t}\n\tif !reflect.DeepEqual(jgot, jwant) {\n\t\tt.Errorf(\"%s%s(%v)\\nexp: %#q\\ngot: %#q\", caller(), method, in, want, got)\n\t}\n}", "title": "" }, { "docid": "34e0c3c42acf863c53bd82a56ea3239d", "score": "0.54029626", "text": "func (this *ChatTest) OnReceive(msg interface{}, fromId uint32, access byte) {\n chatMsg, ok := msg.(*chat.Msg)\n if !ok {\n log.Error(\"Invalid message type %T\", msg)\n return\n }\n\n chatMsg.FromId = fromId\n chatMsg.Access = access\n\n switch chatMsg.Subtype {\n case chat.MSG_SUB_CHAT:\n this.checkChatMsg(chatMsg)\n case chat.MSG_SUB_CMD:\n return // dont care about commands\n case chat.MSG_SUB_CONNECT:\n this.onConnectMsg(chatMsg)\n case chat.MSG_SUB_JOIN_CHANNEL:\n this.onJoinChannelMsg(chatMsg)\n case chat.MSG_SUB_LEAVE_CHANNEL:\n return // not going to leave the test channel\n case chat.MSG_SUB_SET_NAME:\n this.checkChatName(chatMsg)\n }\n}", "title": "" }, { "docid": "4c04e460f6e504b8335b981bd41262a5", "score": "0.5374905", "text": "func (t *MockSocket) ExpectCall(request string, response string) {\n\tt.expectedRequests <- &mocksocketRequest{sentMessage: json.RawMessage(request), responses: []json.RawMessage{json.RawMessage(response)}}\n}", "title": "" }, { "docid": "b364d0ffe8e4b00c6096e367170e518f", "score": "0.5357221", "text": "func (l *link) recv(m *Message, v interface{}) error {\n\tif m.Header == nil {\n\t\tm.Header = make(map[string]string)\n\t}\n\n\ttm := new(transport.Message)\n\n\t// receive the transport message\n\tif err := l.socket.Recv(tm); err != nil {\n\t\treturn err\n\t}\n\n\tlog.Debugf(\"link %s receiving %+v %+v\\n\", l.id, tm, v)\n\n\t// set the message\n\tm.Header = tm.Header\n\tm.Body = tm.Body\n\n\t// bail early\n\tif v == nil {\n\t\treturn nil\n\t}\n\n\t// try unmarshal the body\n\t// skip if there's no content-type\n\tif tm.Header[\"Content-Type\"] != \"application/protobuf\" {\n\t\treturn nil\n\t}\n\n\t// return unmarshalled\n\treturn l.codec.Unmarshal(m.Body, v.(gproto.Message))\n}", "title": "" }, { "docid": "98c443b781557328f81f7fe16415ee35", "score": "0.53534603", "text": "func (_e *MockCollectionConfigService_GetConfigStreamClient_Expecter) Recv() *MockCollectionConfigService_GetConfigStreamClient_Recv_Call {\n\treturn &MockCollectionConfigService_GetConfigStreamClient_Recv_Call{Call: _e.mock.On(\"Recv\")}\n}", "title": "" }, { "docid": "73a2589f87d0d232789948a484452ce2", "score": "0.5347805", "text": "func testSendRecvParent(t *testing.T) {\n\n\tfds, err := unix.Socketpair(unix.AF_UNIX, unix.SOCK_STREAM, 0)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer unix.Close(fds[1])\n\n\tstdout, stderr, cmd, err := spawnTestChild(t, fds[0])\n\tunix.Close(fds[0])\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer func() {\n\t\ttime.AfterFunc(3*time.Second, func() { cmd.Process.Kill() })\n\t\toutbytes, err := ioutil.ReadAll(stdout)\n\t\tt.Logf(\"output from child (error %v): %s\", err, outbytes)\n\t\terrbytes, err := ioutil.ReadAll(stderr)\n\t\tt.Logf(\"stderr from child (error %v): %s\", err, errbytes)\n\t\tstdout.Close()\n\t\tstderr.Close()\n\t\tif err := cmd.Wait(); err != nil {\n\t\t\tt.Fatal(\"Error from child:\", err)\n\t\t}\n\t}()\n\n\tconn := connFromFd(t, fds[1])\n\tr, w, err := os.Pipe()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer r.Close()\n\terr = conn.send([]byte(testMessage), []int{int(w.Fd())})\n\tw.Close()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\t// Make the buffer a bit bigger, so we can tell if the child writes\n\t// more data than expected.\n\tbuf := make([]byte, len(testMessage)+2)\n\tsz, err := r.Read(buf)\n\tif sz != len(testMessage) || err != nil {\n\t\tt.Fatal(\"Read\", sz, \"bytes with error\", err, \"expected\",\n\t\t\tlen(testMessage), \"bytes and err == nil\")\n\t}\n\treceivedMessage := string(buf[:sz])\n\tif receivedMessage != testMessage {\n\t\tt.Fatal(\"Expected\", testMessage, \"but got\", receivedMessage)\n\t}\n}", "title": "" }, { "docid": "1e8187b45a5138e5b9de786c5ed6b4cb", "score": "0.53477114", "text": "func TestReceiveMessage(t *testing.T) {\n\tvar err error\n\n\tadapter.count = 1\n\t//emsg := createTestBlock()\n\temsg := createTestChaincodeEvent(\"0xffffffff\", \"event1\")\n\tif err = producer.Send(emsg); err != nil {\n\t\tt.Fail()\n\t\tt.Logf(\"Error sending message %s\", err)\n\t}\n\n\tselect {\n\tcase <-adapter.notfy:\n\tcase <-time.After(2 * time.Second):\n\t\tt.Fail()\n\t\tt.Logf(\"timed out on messge\")\n\t}\n}", "title": "" }, { "docid": "c839f2a9cbce32e17e6f76b988fbe165", "score": "0.5346581", "text": "func (m *MockTransportInterface) Listen() {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Listen\")\n}", "title": "" }, { "docid": "d10993954136128c1400a73e618ae120", "score": "0.5343752", "text": "func TestPerformReadRequestProperResponse(t *testing.T) {\n\t// start a local HTTP server\n\tserver := mockedHttpServer(func(responseWriter http.ResponseWriter, request *http.Request) {\n\t\t// send response to be tested later\n\t\t_, err := responseWriter.Write([]byte(`OK`))\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t})\n\t// close the server when test finishes\n\tdefer server.Close()\n\n\t// try to read response from the server\n\tbody, err := restapi.PerformReadRequest(server.URL)\n\tif err != nil {\n\t\tt.Fatal(\"Unable to perform request\", err)\n\t}\n\n\t// check for proper body\n\tif !bytes.Equal(body, []byte(`OK`)) {\n\t\tt.Fatal(\"Improper response body\", err)\n\t}\n}", "title": "" }, { "docid": "07626e6cd186d0735e43dce1a0b51db5", "score": "0.5341829", "text": "func (m *MockWorker_FetchDDLInfoServer) Send(arg0 *pb.DDLInfo) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Send\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "b6656eba738b5747e6049d94bc4ac7c6", "score": "0.5336171", "text": "func (this *NullBehavior) receive(msg Message) {\n\tpanic(\"receive(Message) must be implemented !\")\n}", "title": "" }, { "docid": "8f0935f3b1daca4628d81600ce627cb3", "score": "0.5325375", "text": "func (m *MockGitops_GetObjectsToSynchronizeServer) SendMsg(arg0 interface{}) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"SendMsg\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "f34a540db373e7e80eb5bbb09967f66e", "score": "0.5309924", "text": "func TestConnectionWrapper_Read(t *testing.T) {\n\ttestCases := []struct {\n\t\tdesc string\n\t\tsendData []byte\n\t}{\n\t\t{\n\t\t\tdesc: \"Plain connection without any special headers\",\n\t\t\tsendData: nil,\n\t\t},\n\t\t{\n\t\t\tdesc: \"Sending PROXY header\",\n\t\t\tsendData: getPROXYProtocolPayload(),\n\t\t},\n\t}\n\n\tfor _, tc := range testCases {\n\t\tt.Run(tc.desc, func(t *testing.T) {\n\t\t\tlistener, err := net.Listen(\"tcp\", \"127.0.0.1:0\")\n\t\t\trequire.NoError(t, err)\n\t\t\tt.Cleanup(func() { listener.Close() })\n\n\t\t\tgo startSSHServer(t, listener)\n\n\t\t\tconn, err := net.Dial(\"tcp\", listener.Addr().String())\n\t\t\trequire.NoError(t, err)\n\n\t\t\t_, err = conn.Write(tc.sendData)\n\t\t\trequire.NoError(t, err)\n\n\t\t\tsconn, nc, r, err := ssh.NewClientConn(conn, \"\", &ssh.ClientConfig{\n\t\t\t\tHostKeyCallback: ssh.InsecureIgnoreHostKey(),\n\t\t\t\tTimeout: time.Second,\n\t\t\t})\n\t\t\trequire.NoError(t, err)\n\t\t\trequire.Equal(t, \"SSH-2.0-Go\", string(sconn.ServerVersion()))\n\n\t\t\tclient := ssh.NewClient(sconn, nc, r)\n\t\t\trequire.NoError(t, err)\n\n\t\t\t// Make sure SSH connection works correctly\n\t\t\tok, response, err := client.SendRequest(\"echo\", true, []byte(\"beep\"))\n\t\t\trequire.NoError(t, err)\n\t\t\trequire.True(t, ok)\n\t\t\trequire.Equal(t, \"beep\", string(response))\n\t\t})\n\t}\n}", "title": "" }, { "docid": "4b1428baa2b4a82dc9c7e5169263439a", "score": "0.53093696", "text": "func (m *MockWorker_FetchDDLInfoClient) Send(arg0 *pb.DDLLockInfo) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Send\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "44d2acd300db9f508d2bfe98f247e3aa", "score": "0.52744246", "text": "func GetExchangeMock(t *testing.T) ExchangeMock {\n\n\t// Define the controller of our different package that we're mocking\n\n\t// Receiver\n\treceiverMockCtrl := gomock.NewController(t)\n\t// Sender\n\tsenderMockCtrl := gomock.NewController(t)\n\t// Product\n\tproductMockCtrl := gomock.NewController(t)\n\t// Database\n\tdbMockCtrl := gomock.NewController(t)\n\t// MailSender\n\tmailMockCtrl := gomock.NewController(t)\n\n\treceiverObj := mock_receiver.NewMockuser(receiverMockCtrl)\n\t// Mock the create user constructor\n\treceiverObj.EXPECT().CreateUser(\"joe@doe.com\", \"doe\", \"john\", 10).Return(\"john@gmail.com\", \"doe\", \"john\", 30)\n\treceiverObj.EXPECT().GetEmail().Return(\"angela.zhang@icbc.com\").AnyTimes()\n\t// Define the flow of execution of receiverObj.isValid\n\t// Call x5 times IsValid -> return true\n\t// Then xInfinite times IsValid -> return false\n\tgomock.InOrder(\n\t\treceiverObj.EXPECT().IsValid().Return(true).MaxTimes(5),\n\t\treceiverObj.EXPECT().IsValid().Return(false).AnyTimes(),\n\t)\n\n\t// Define the flow of execution of receiverObj.GetAge\n\tgomock.InOrder(\n\t\treceiverObj.EXPECT().GetAge().Return(21),\n\t\treceiverObj.EXPECT().GetAge().Return(16),\n\t\treceiverObj.EXPECT().GetAge().Return(17),\n\t\treceiverObj.EXPECT().GetAge().Return(19).AnyTimes(),\n\t)\n\n\t// Define the sender\n\tsenderObj := mock_receiver.NewMockuser(senderMockCtrl)\n\tsenderObj.EXPECT().GetEmail().Return(\"jiang.jianqing@icbc.com\").AnyTimes()\n\n\t// Mock a product\n\tpr := mock_product.NewMockP(productMockCtrl)\n\t//mail, firstname, name, age := receiverObj.CreateUser(\"joe@doe.com\", \"doe\", \"john\", 10)\n\t// Creating an empty receiver struct\n\t// We don't need anything as we're mocking it\n\tperson := &receiver.UserStruct{}\n\t// Mocking the create product constructor\n\tpr.EXPECT().CreateProduct(\"chopstick\", 2, person).Return(\"chopstick\", 2, person)\n\n\t// Define the flow of how we're calling our pr.IsValid()\n\tgomock.InOrder(\n\t\tpr.EXPECT().IsValid().Return(true).MaxTimes(4),\n\t\tpr.EXPECT().IsValid().Return(false).AnyTimes(),\n\t)\n\n\t// Mocking the Database\n\tdbObj := mock_db.NewMockdbInterface(dbMockCtrl)\n\t// Set the flow\n\tgomock.InOrder(\n\t\tdbObj.EXPECT().SaveExchange().Return(true, nil).MaxTimes(2),\n\t\tdbObj.EXPECT().SaveExchange().Return(false, errors.New(\"can't save in the database\")).MaxTimes(1),\n\t)\n\n\t// Mocking the SendMail\n\tmailObj := mock_mail.NewMockMail(mailMockCtrl)\n\t// Set the flow\n\tgomock.InOrder(\n\t\tmailObj.EXPECT().SendMail(\"angela.zhang@icbc.com\", \"jiang.jianqing@icbc.com\", \"Please take care of our new chopstick collection\").Return(true, nil).MaxTimes(1),\n\t\tmailObj.EXPECT().SendMail(\"angela.zhang@icbc.com\", \"jiang.jianqing@icbc.com\", \"Please take care of our new chopstick collection\").Return(false, errors.New(\"An error occured while sending the mail\")).AnyTimes(),\n\t)\n\n\t// Now we can test our Exchange Here but we want to avoid the circular depedency..\n\t// Therefore we're creating our save function Here\n\t// It's call SaveMock\n\n\t// Building our ExchangeMock structure\n\tsv := ExchangeMock{\n\t\tReceiverM: receiverObj,\n\t\tSenderM: senderObj,\n\t\tProductM: pr,\n\t\tDbM: dbObj,\n\t\tMailM: mailObj,\n\t\tStartDate: time.Now().AddDate(0, 0, 1),\n\t\tEndDate: time.Now().AddDate(0, 0, 2),\n\t}\n\n\treturn sv\n}", "title": "" }, { "docid": "f52de91216863c0103428063f44da979", "score": "0.52622616", "text": "func (m *MockClient) SendMessage(msg []byte) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"SendMessage\", msg)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "091e744f50b03841105ce094f94bf0f6", "score": "0.5246307", "text": "func (c *StubConsumer) Consume() {}", "title": "" }, { "docid": "e015e5d4888a87d9d34b82d8c19be70a", "score": "0.5241214", "text": "func (m *MockPrivateTransactionManager) Send(arg0 []byte, arg1 string, arg2 []string, arg3 *engine.ExtraMetadata) (string, []string, common.EncryptedPayloadHash, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Send\", arg0, arg1, arg2, arg3)\n\tret0, _ := ret[0].(string)\n\tret1, _ := ret[1].([]string)\n\tret2, _ := ret[2].(common.EncryptedPayloadHash)\n\tret3, _ := ret[3].(error)\n\treturn ret0, ret1, ret2, ret3\n}", "title": "" }, { "docid": "052099a38afe2219fc1fb4e6c0642ed5", "score": "0.52381516", "text": "func (m *MockGitops_GetObjectsToSynchronizeClient) SendMsg(arg0 interface{}) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"SendMsg\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "08d59f12f325e987bc45fcb1ad7bcd5a", "score": "0.52303106", "text": "func TestRetryerSend_ExpectTwoResponse_GotOneError(t *testing.T) {\n\tsender := NewSenderMock(t)\n\tinnerReps := make(chan *message.Message)\n\tsender.SendRoleMock.Set(func(p context.Context, p1 *message.Message, p2 insolar.DynamicRole, p3 insolar.Reference) (r <-chan *message.Message, r1 func()) {\n\t\treturn innerReps, func() { close(innerReps) }\n\t})\n\n\tmsg, err := payload.NewMessage(&payload.State{})\n\trequire.NoError(t, err)\n\tfirstUUID := msg.UUID\n\n\tpa := pulse.NewAccessorMock(t)\n\tpa.LatestMock.Set(accessorMock(t).Latest)\n\tr := NewRetrySender(sender, pa, 3, 2)\n\treps, done := r.SendRole(context.Background(), msg, insolar.DynamicRoleLightExecutor, gen.Reference())\n\n\tisDone := make(chan<- interface{})\n\tgo func() {\n\t\tsendTestReply(&payload.Error{Text: \"object is deactivated\", Code: payload.CodeUnknown}, innerReps, isDone)\n\t}()\n\n\tvar success bool\n\tfor rep := range reps {\n\t\treplyPayload, err := payload.UnmarshalFromMeta(rep.Payload)\n\t\trequire.Nil(t, err)\n\n\t\tswitch p := replyPayload.(type) {\n\t\tcase *payload.Error:\n\t\t\tswitch p.Code {\n\t\t\tcase payload.CodeUnknown:\n\t\t\t\tsuccess = true\n\t\t\t}\n\t\t}\n\n\t\tif success {\n\t\t\tbreak\n\t\t}\n\t}\n\tdone()\n\tlastUUID := msg.UUID\n\trequire.Equal(t, firstUUID, lastUUID)\n\n\trequire.True(t, waitForChannelClosed(innerReps))\n}", "title": "" }, { "docid": "2459f24345cf19ecbae21ca79c0a4b08", "score": "0.5222013", "text": "func (m *MockTelegram) Send(c telegram_bot_api.Chattable) (telegram_bot_api.Message, error) {\n\tret := m.ctrl.Call(m, \"Send\", c)\n\tret0, _ := ret[0].(telegram_bot_api.Message)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "082abfe11b807c64b0cb28c5dbf82f5f", "score": "0.52095467", "text": "func testSendRecvChild(t *testing.T) {\n\tdefer os.Exit(0)\n\n\tdefer unix.Close(3)\n\tconn := connFromFd(t, 3)\n\n\t// Make the buffer a bit bigger than needed, so if we get more data than\n\t// expected we catch it:\n\tbuf := make([]byte, len(testMessage)+2)\n\n\t// make sure that if this is not overwritten, it can't be confused for\n\t// a valid fd:\n\tfds := []int{-1}\n\n\tn, nfd, err := conn.recv(buf, fds)\n\tif err != nil && err != io.EOF {\n\t\tt.Fatal(err)\n\t}\n\tif n != len(testMessage) || nfd != len(fds) {\n\t\tt.Fatalf(\"Wrong read lengths; expected (%d, %d) but got (%d, %d)\",\n\t\t\tlen(testMessage), len(fds), n, nfd)\n\t}\n\tdefer unix.Close(fds[0])\n\tn, err = os.NewFile(uintptr(fds[0]), \"pipe\").Write(buf[:n])\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif n != len(testMessage) {\n\t\tt.Fatal(\"Wrong write length; expected\", len(testMessage), \"but got\", n)\n\t}\n}", "title": "" }, { "docid": "640e85ef48db306b14f3ce60105eef92", "score": "0.52046484", "text": "func TestRetryerSend(t *testing.T) {\n\tsender := NewSenderMock(t)\n\tinnerReps := make(chan *message.Message)\n\tsender.SendRoleMock.Set(func(p context.Context, p1 *message.Message, p2 insolar.DynamicRole, p3 insolar.Reference) (r <-chan *message.Message, r1 func()) {\n\t\treturn innerReps, func() { close(innerReps) }\n\t})\n\n\tmsg, err := payload.NewMessage(&payload.State{})\n\trequire.NoError(t, err)\n\tfirstUUID := msg.UUID\n\n\tpa := pulse.NewAccessorMock(t)\n\tpa.LatestMock.Set(accessorMock(t).Latest)\n\tr := NewRetrySender(sender, pa, 3, 1)\n\treps, done := r.SendRole(context.Background(), msg, insolar.DynamicRoleLightExecutor, gen.Reference())\n\n\tisDone := make(chan<- interface{})\n\tgo sendTestReply(&payload.Error{Text: \"object is deactivated\", Code: payload.CodeUnknown}, innerReps, isDone)\n\n\tvar success bool\n\tfor rep := range reps {\n\t\treplyPayload, err := payload.UnmarshalFromMeta(rep.Payload)\n\t\trequire.Nil(t, err)\n\n\t\tswitch p := replyPayload.(type) {\n\t\tcase *payload.Error:\n\t\t\tswitch p.Code {\n\t\t\tcase payload.CodeUnknown:\n\t\t\t\tsuccess = true\n\t\t\t}\n\t\t}\n\n\t\tif success {\n\t\t\tbreak\n\t\t}\n\t}\n\tdone()\n\tlastUUID := msg.UUID\n\trequire.Equal(t, firstUUID, lastUUID)\n\n\trequire.True(t, waitForChannelClosed(innerReps))\n}", "title": "" }, { "docid": "f4ab5eb42070cf07ea41b820a5ea6dcd", "score": "0.52039844", "text": "func (m *MockGitops_GetObjectsToSynchronizeServer) Send(arg0 *rpc.ObjectsToSynchronizeResponse) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Send\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "45de25192bd926e900aeff99c2e1517e", "score": "0.52037627", "text": "func mockDialWithTimeout(protocol string, address string, timeout time.Duration) (net.Conn, error) {\n\tcli, svr := net.Pipe()\n\tdefer svr.Close()\n\tdefer cli.Close()\n\tif address == \"localhost:33333\" {\n\t\treturn cli, nil\n\t}\n\treturn cli, fmt.Errorf(\"error connecting to %s\", address)\n}", "title": "" }, { "docid": "2cd52d2f010c11599eb4e9e8c9e41ab0", "score": "0.5197271", "text": "func (m *MockReceptor) SelfListener() []byte {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"SelfListener\")\n\tret0, _ := ret[0].([]byte)\n\treturn ret0\n}", "title": "" }, { "docid": "bbdd6b97be0ef823f104c40761a01181", "score": "0.5197028", "text": "func (m *MockService) ReceiveGitEvent(gitEvent *manifest.EstafetteGitEvent) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"ReceiveGitEvent\", gitEvent)\n}", "title": "" }, { "docid": "2d1bc44a09f2d3d5f4698e79bef96572", "score": "0.5196295", "text": "func (m *MockReadWriteCloseFlusher) Read(p []byte) (int, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Read\", p)\n\tret0, _ := ret[0].(int)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "c072454fb39c49fd44e458b1464bfbaa", "score": "0.5196102", "text": "func (m *MockLineService) Send(message string) error {\n\tret := m.ctrl.Call(m, \"Send\", message)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "ee63ccff01047659d3615c8c4052771b", "score": "0.5182041", "text": "func (b *Broker) Read(req *pb.ReadRequest, srv pb.Journal_ReadServer) error {\n\tselect {\n\tcase b.ReadReqCh <- *req:\n\t\t// |req| passed to test.\n\tcase <-time.After(timeout):\n\t\trequire.FailNow(b.t, \"test didn't read from ReadReqCh\")\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase resp := <-b.ReadRespCh:\n\t\t\t// We may be sending into a cancelled context (c.f. TestReaderRetries).\n\t\t\t// Otherwise, we expect to be able to send without error.\n\t\t\tif err := srv.Send(&resp); srv.Context().Err() == nil {\n\t\t\t\tassert.NoError(b.t, err)\n\t\t\t}\n\t\tcase err := <-b.WriteLoopErrCh:\n\t\t\treturn err\n\t\tcase <-time.After(timeout):\n\t\t\trequire.FailNow(b.t, \"test didn't send to ReadRespCh or WriteLoopErrCh\")\n\t\t}\n\t}\n}", "title": "" }, { "docid": "4d7f0c5d2a2b65726c101475f9c225fe", "score": "0.51746106", "text": "func TestUdp(t *testing.T) {\n srvAddr := \"127.0.0.1:8901\"\n cliAddr := \"127.0.0.1:8902\"\n\n srvHandler = new(PPEventSrv)\n srvHandler.t = t\n srvproto = NewProtocol(\"UdpSrvTest\", srvHandler)\n srvproto.AddSignature(pingMsgProc)\n srvproto.AddSignature(pongMsgProc)\n srvproto.SetAccessProvider(new(NoSecurity))\n\n _, err := srvproto.ListenUdp(srvAddr)\n if err != nil {\n t.Fatal(err.Error())\n }\n\n <-time.After(1 * time.Second)\n\n cliHandler = new(PPEventCli)\n cliHandler.t = t\n cliHandler.msgCount = 100\n cliproto = NewProtocol(\"UdpCliTest\", cliHandler)\n cliproto.AddSignature(pingMsgProc)\n cliproto.AddSignature(pongMsgProc)\n cliproto.SetAccessProvider(new(NoSecurity))\n\n cliSock, err := cliproto.ListenUdp(cliAddr)\n if err != nil {\n t.Fatal(err.Error())\n }\n\n <-time.After(1 * time.Second)\n\n waiter.Add(1)\n err = cliproto.DialUdp(srvAddr, cliSock)\n if err != nil {\n waiter.Done()\n t.Fatal(err.Error())\n }\n\n log.Info(\"Transmitting data...\")\n\n waiter.Wait()\n\n <-time.After(1 * time.Second)\n\n srvproto.Shutdown()\n}", "title": "" }, { "docid": "a0b29eb350b88bb8f4e3a63a86bfb4f6", "score": "0.5166049", "text": "func (m *MockHistoryService_StreamWorkflowReplicationMessagesClient) Send(arg0 *historyservice.StreamWorkflowReplicationMessagesRequest) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Send\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "0b09031a0f2e345a370db49f063adb35", "score": "0.51521176", "text": "func (m *MockRedis) Get(key string) {\n m.ctrl.Call(m, \"Get\", key)\n}", "title": "" }, { "docid": "f0ed32401e55fd84476d80ce3a305c12", "score": "0.5150436", "text": "func (_m *MockStreamI) Reset(_param0 error) {\n\t_m.ctrl.Call(_m, \"Reset\", _param0)\n}", "title": "" }, { "docid": "bf30f5487dd8099d3c50a0d2ae9bb6b9", "score": "0.5143883", "text": "func TestMsgReceived(t *testing.T) {\n\treq := discoveryRequestMsg(discTestHost6.P2PHost)\n\thash, err := crypto.HashProtoMsg(req)\n\tif err != nil {\n\t\tt.Errorf(\"Failed to HashProtoMsg\")\n\t}\n\treq.DiscoveryMsgData.InitHash = hex.EncodeToString(hash)\n\t// mock the reception of this discovery message with the specific hash\n\tdiscTestHost5.receivedMsgs[req.DiscoveryMsgData.InitHash] = 0\n\tassert.True(t, discTestHost5.checkMsgReceived(req))\n}", "title": "" }, { "docid": "72c7093cc5cb2a25e29ca5434e29acd3", "score": "0.51431113", "text": "func (m *display) SendRecvCmd(cmd int, data []byte) ([]byte, error) {\n\tm.wmux.Lock()\n\tdefer m.wmux.Unlock()\n\tfmt.Println(\"SendRecvCmd ########\")\n\tdefer fmt.Println(\"end SendRecvCmd ########\")\n\tdat1 := []byte{0xFE, byte(cmd)}\n\tif data != nil {\n\t\tdat1 = append(dat1, data...)\n\t}\n\tvar res []byte\n\n\t//n, res := m.SendRecv(dat1)\n\tif err := m.send(dat1); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif m.status == LISTEN {\n\t\tafter := time.After(timeoutRead)\n\t\ttick := time.NewTicker(10 * time.Millisecond)\n\t\tdefer tick.Stop()\n\t\t// count := 0\n\tfor_src:\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase res = <-m.bufResp:\n\t\t\t\t// fmt.Printf(\"count: %d, %X\\n\", (count), res)\n\t\t\t\t// count++\n\t\t\t\tif len(res) > 1 && res[1] == byte(cmd) {\n\t\t\t\t\tfmt.Printf(\"SendRecvCmd response: %X\\n\", (res))\n\t\t\t\t\tbreak for_src\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\tcase <-after:\n\t\t\t\tlog.Println(\"timeoutRead\")\n\t\t\t\treturn res, ErrorDevTimeout\n\t\t\t}\n\t\t}\n\t} else {\n\t\t/**/\n\t\tres, err := m.recv()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn res, nil\n\t\t/**/\n\t}\n\n\tswitch {\n\tcase len(res) <= 0:\n\t\treturn nil, ErrorDevEmptyRead\n\tcase len(res) < 4:\n\t\treturn nil, errors.New(\"incomplete response\")\n\tcase res[0] != byte(0xFC):\n\t\treturn nil, errors.New(\"wrong response\")\n\tcase res[1] != byte(cmd):\n\t\treturn nil, fmt.Errorf(\"incorrect response, CMD: [%X]\", res[1])\n\t}\n\treturn res[4:], nil\n}", "title": "" }, { "docid": "5ae222d2541bb92372cf06ad6785ea84", "score": "0.5137077", "text": "func (m_2 *MockHistoryService_StreamWorkflowReplicationMessagesServer) SendMsg(m interface{}) error {\n\tm_2.ctrl.T.Helper()\n\tret := m_2.ctrl.Call(m_2, \"SendMsg\", m)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" } ]
38b8ff3de2ff9e27f080c8e517b98619
GetAuthTicket provides a ticket required for joining games in peer/Client.go
[ { "docid": "2e6ea48dad3e6c3c9a78218a8ebcfd8f", "score": "0.64869595", "text": "func GetAuthTicket(username string, password string) (string, error) {\n\tjar, err := cookiejar.New(nil)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tauthTicketClient := &http.Client{Jar: jar}\n\tcsrfRequest, err := http.NewRequest(\"POST\", \"https://auth.roblox.com\", nil)\n\n\tresp, err := authTicketClient.Do(csrfRequest)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tresp.Body.Close()\n\n\tvar csrfToken string\n\tif resp.StatusCode == 403 {\n\t\tcsrfToken = resp.Header.Get(\"X-CSRF-Token\")\n\t\tif csrfToken == \"\" {\n\t\t\treturn \"\", errors.New(\"empty CSRF token while trying to authenticate\")\n\t\t}\n\t} else {\n\t\treturn \"\", fmt.Errorf(\"wrong status code \\\"%d %s\\\" when trying to authenticate\", resp.StatusCode, resp.Status)\n\t}\n\n\tauthCredentials, err := json.Marshal(map[string]string{\n\t\t\"ctype\": \"Username\",\n\t\t\"cvalue\": username,\n\t\t\"password\": password,\n\t})\n\tif err != nil {\n\t\treturn \"\", errors.New(\"failed to construct JSON credentials\")\n\t}\n\n\tloginRequest, err := http.NewRequest(\"POST\", \"https://auth.roblox.com/v2/login\", bytes.NewReader(authCredentials))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tloginRequest.Header.Set(\"X-CSRF-Token\", csrfToken)\n\tloginRequest.Header.Set(\"Content-Type\", \"application/json\")\n\n\tresp, err = authTicketClient.Do(loginRequest)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif resp.StatusCode != 200 {\n\t\tjsonResp, err := ioutil.ReadAll(resp.Body)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tresp.Body.Close()\n\t\tprintln(\"failed to auth: \", string(jsonResp))\n\t\treturn \"\", errors.New(\"failed to authenticate\")\n\t}\n\n\tticketRequest, err := http.NewRequest(\"GET\", \"https://www.roblox.com/game-auth/getauthticket\", nil)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tticketRequest.Header.Set(\"RBX-For-Gameauth\", \"true\")\n\tticketRequest.Header.Set(\"Referer\", \"https://www.roblox.com/home\")\n\n\tresp, err = authTicketClient.Do(ticketRequest)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tticketResp, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tresp.Body.Close()\n\tif resp.StatusCode != 200 {\n\t\tprintln(\"failed to get authticket: \", resp.Status, string(ticketResp))\n\t\treturn \"\", errors.New(\"failed to authenticate\")\n\t}\n\n\treturn string(ticketResp), nil\n}", "title": "" } ]
[ { "docid": "9068fb70c7bc1b3d804ffdec55779c2f", "score": "0.6611796", "text": "func GetAuthSessionTicket() (hAuthTicket uint32, pTicket []byte) {\n\t// Gets the SteamUser\n\tinstancePtr, _, _ := pSteamUser.Call()\n\n\t// Fail if it's nil/null/0\n\tif instancePtr == 0 {\n\t\tlog.Printf(\"Failed on call to SteamUser() [pid is %p]\\n\", instancePtr)\n\t\treturn 0, nil\n\t}\n\n\t// Setup the variables\n\tpTicket = make([]byte, 4096) // buffer (void*)\n\tcbMaxTicket := 4096 // int\n\tvar pcbTicket uint32 // uint32\n\n\t// Make the call (this one's harder)\n\tr1, _, _ := pSteamUserGetAuthSessionTicket.Call(\n\t\tinstancePtr, // instance (SteamUser)\n\t\tuintptr(unsafe.Pointer(&pTicket[0])), // pTicket\n\t\tuintptr(cbMaxTicket), // cbMaxTicket (largest size the ticket can be)\n\t\tuintptr(unsafe.Pointer(&pcbTicket)), // Pointer to max size\n\t)\n\n\t// Return it\n\treturn uint32(r1), pTicket[0:pcbTicket]\n}", "title": "" }, { "docid": "9c5f61f51c24f40b1bfa0094d68e8a30", "score": "0.6011396", "text": "func (s *Service) getTicket(w http.ResponseWriter, r *http.Request) {\n\tid := chi.URLParam(r, \"id\")\n\n\ts.Logger.Infow(\"Received request to fetch ticket\", \"ticket\", id)\n\n\tticket, err := s.Storage.FindTicket(id)\n\tif err != nil {\n\t\ts.handleAPIError(\"Failed to find ticket\", err, w)\n\t\treturn\n\t}\n\n\tbody, err := json.Marshal(ticket)\n\tif err != nil {\n\t\ts.handleAPIError(\"Failed to marshal response\", err, w)\n\t\treturn\n\t}\n\n\tw.Write(body)\n}", "title": "" }, { "docid": "cbfd89df06b94315030c7b9a9c1dfeec", "score": "0.5940144", "text": "func (h *cryptoSetup) GetSessionTicket() ([]byte, error) {\n\tvar appData []byte\n\t// Save transport parameters to the session ticket if we're allowing 0-RTT.\n\tif h.extraConf.MaxEarlyData > 0 {\n\t\tappData = (&sessionTicket{\n\t\t\tParameters: h.ourParams,\n\t\t\tRTT: h.rttStats.SmoothedRTT(),\n\t\t}).Marshal()\n\t}\n\treturn h.conn.GetSessionTicket(appData)\n}", "title": "" }, { "docid": "c9dac73db6651ca2132c103f0e963142", "score": "0.5677984", "text": "func (is *instrumentedService) GetTicket(ctx context.Context, id string) (*pb.Ticket, error) {\n\ttelemetry.IncrementCounter(ctx, mStateStoreGetTicket)\n\treturn is.s.GetTicket(ctx, id)\n}", "title": "" }, { "docid": "090fe3f6f5b72a78b2a99c435b196e53", "score": "0.5621912", "text": "func CheckForTicket(ctx context.Context, ui *uiauto.Context, config *Configuration) error {\n\t// Wait for ticket to appear.\n\ttesting.ContextLog(ctx, \"Waiting for Kerberos ticket to appear\")\n\tif err := ui.WaitUntilExists(nodewith.Name(config.KerberosAccount).Role(role.StaticText).State(state.Editable, false))(ctx); err != nil {\n\t\treturn errors.Wrap(err, \"failed to find Kerberos ticket\")\n\t}\n\n\t// Check that ticket is \"Active\".\n\tif err := ui.WaitUntilExists(nodewith.Name(\"Active\").Role(role.StaticText))(ctx); err != nil {\n\t\treturn errors.Wrap(err, \"Kerberos ticket is not Active\")\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "9470e950ec33082ebd86272f3b09d0fa", "score": "0.5561288", "text": "func getLosingTicket() (t Ticket) {\n\treturn LosingTicket\n}", "title": "" }, { "docid": "5e1fd4a6f83fce6064f6b926f7b511b2", "score": "0.54929745", "text": "func (c *Client) TicketReceived(req *pb.WXTicketReq) (*pb.Resp, error) {\n\tconn, cl, err := dialGrpc(c.Address)\n\tdefer func() {\n\t\tif err := conn.Close(); err != nil {\n\t\t\tlog.Printf(\"conn.Close err : %v\", err)\n\t\t}\n\t}()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn cl.TicketReceived(context.Background(), req)\n}", "title": "" }, { "docid": "1b0698c10cab13929762978e36e8c70a", "score": "0.54764014", "text": "func AddTicket(ctx context.Context, cr *chrome.Chrome, tconn *chrome.TestConn, ui *uiauto.Context, keyboard *input.KeyboardEventWriter, config *Configuration, password string) error {\n\n\t_, err := apps.LaunchOSSettings(ctx, cr, \"chrome://os-settings/kerberos\")\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"could not open kerberos section in OS settings\")\n\t}\n\n\t// Add a Kerberos ticket.\n\tif err := uiauto.Combine(\"add Kerberos ticket\",\n\t\tui.LeftClick(nodewith.Name(\"Kerberos tickets\").Role(role.Link)),\n\t\tui.LeftClick(nodewith.Name(\"Add a ticket\").Role(role.Button)),\n\t\tui.LeftClick(nodewith.Name(\"Kerberos username\").Role(role.TextField)),\n\t\tkeyboard.TypeAction(config.KerberosAccount),\n\t\tui.LeftClick(nodewith.Name(\"Password\").Role(role.TextField)),\n\t\tkeyboard.TypeAction(password),\n\t\tui.LeftClick(nodewith.Name(\"Advanced\").Role(role.Link)),\n\t\tui.LeftClick(nodewith.Role(role.TextField).State(state.Editable, true).State(state.Multiline, true)),\n\t\tkeyboard.TypeAction(config.RealmsConfig),\n\t\tui.LeftClick(nodewith.Name(\"Save\").Role(role.Button)),\n\t\tui.LeftClick(nodewith.Name(\"Add\").HasClass(\"action-button\")),\n\t)(ctx); err != nil {\n\t\treturn errors.Wrap(err, \"failed to add Kerberos ticket\")\n\t}\n\n\tif err := CheckForTicket(ctx, ui, config); err != nil {\n\t\treturn errors.Wrap(err, \"failed to find active ticket\")\n\t}\n\n\tapps.Close(ctx, tconn, apps.Settings.ID)\n\n\t// Wait for OS Setting to close.\n\tif err := ui.WaitUntilGone(nodewith.Name(\"Settings - Kerberos tickets\").Role(role.Window))(ctx); err != nil {\n\t\treturn errors.Wrap(err, \"failed to close os settings\")\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "d31b474d7f418b9e65bae5e84303875f", "score": "0.54522496", "text": "func (gcp *GoogleCloudPrint) Ticket(gcpJobID string) (cdd.CloudJobTicket, error) {\n\tform := url.Values{}\n\tform.Set(\"jobid\", gcpJobID)\n\tform.Set(\"use_cjt\", \"true\")\n\n\tresponseBody, _, httpStatusCode, err := postWithRetry(gcp.robotClient, gcp.baseURL+\"ticket\", form)\n\t// The /ticket API is different than others, because it only returns the\n\t// standard GCP error information on success=false.\n\tif httpStatusCode != 200 {\n\t\treturn cdd.CloudJobTicket{}, err\n\t}\n\n\td := json.NewDecoder(bytes.NewReader(responseBody))\n\td.UseNumber() // Force large numbers not to be formatted with scientific notation.\n\n\tvar ticket cdd.CloudJobTicket\n\terr = d.Decode(&ticket)\n\tif err != nil {\n\t\treturn cdd.CloudJobTicket{}, fmt.Errorf(\"Failed to unmarshal ticket: %s\", err)\n\t}\n\n\treturn ticket, nil\n}", "title": "" }, { "docid": "d19f67d3eeae37da2e10717ff11752cf", "score": "0.5405745", "text": "func Ticket(cfg config.View) *pb.Ticket {\n\tcharacters := cfg.GetStringSlice(\"testConfig.characters\")\n\tregions := cfg.GetStringSlice(\"testConfig.regions\")\n\tmin := cfg.GetFloat64(\"testConfig.minRating\")\n\tmax := cfg.GetFloat64(\"testConfig.maxRating\")\n\tlatencyMap := latency(regions)\n\tticket := &pb.Ticket{\n\t\tSearchFields: &pb.SearchFields{\n\t\t\tDoubleArgs: map[string]float64{\n\t\t\t\te2e.DoubleArgMMR: normalDist(40, min, max, 20),\n\t\t\t},\n\t\t\tStringArgs: map[string]string{\n\t\t\t\te2e.Role: characters[rand.Intn(len(characters))],\n\t\t\t},\n\t\t},\n\t}\n\n\tfor _, r := range regions {\n\t\tticket.SearchFields.DoubleArgs[r] = latencyMap[r]\n\t}\n\n\treturn ticket\n}", "title": "" }, { "docid": "43e69e77f9990a8c109779f3f9fb3e68", "score": "0.53489923", "text": "func (a *SupportProjectTicketApiService) SupportProjectTicketGet(ctx context.Context, projectId string, ticketId string) ApiSupportProjectTicketGetRequest {\n\treturn ApiSupportProjectTicketGetRequest{\n\t\tApiService: a,\n\t\tctx: ctx,\n\t\tprojectId: projectId,\n\t\tticketId: ticketId,\n\t}\n}", "title": "" }, { "docid": "b9a8b9f3a4035b002665f2c0d3a4f0ab", "score": "0.51996994", "text": "func (nalogruClient *Client) GetTicketId(queryString string) (string, error) {\n\tclient := createHttpClient()\n\tpayload := TicketIdRequest{Qr: queryString}\n\n\treq, err := json.Marshal(payload)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treader := bytes.NewReader(req)\n\turl := nalogruClient.BaseAddress + \"/v2/ticket\"\n\trequest, err := http.NewRequest(http.MethodPost, url, reader)\n\taddHeaders(request, nalogruClient.device.Id.Hex())\n\taddAuth(request, nalogruClient.device.SessionId)\n\tres, err := sendRequest(request, client)\n\n\tif err != nil {\n\t\tlog.Printf(\"Can't POST %s\\n\", url)\n\t\treturn \"\", err\n\t}\n\tdefer res.Body.Close()\n\n\tbody, err := readBody(res)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif res.StatusCode == http.StatusTooManyRequests {\n\t\tlog.Printf(\"Too Many Requests : %d\\n\", res.StatusCode)\n\t\treturn \"\", errors.New(DailyLimitReached)\n\t}\n\n\tif res.StatusCode != http.StatusOK {\n\t\tlog.Printf(\"Get ticket id(%s) error: %d\\n\", queryString, res.StatusCode)\n\t\tfile, err := os.CreateTemp(\"/var/lib/receipts/error/\", \"*.err\")\n\t\tif err != nil {\n\t\t\tlog.Println(\"failed to create error response file\")\n\t\t\treturn \"\", err\n\t\t}\n\t\tdefer dispose.Dispose(file.Close, \"failed to close error file.\")\n\t\t_, err = file.Write(body)\n\t\tif err != nil {\n\t\t\tlog.Println(\"failed to write response to file\")\n\t\t\treturn \"\", err\n\t\t}\n\n\t\tif res.StatusCode == http.StatusUnauthorized {\n\t\t\terr = AuthError\n\t\t} else {\n\t\t\terr = InternalError\n\t\t}\n\n\t\treturn \"\", err\n\t}\n\n\tticketIdResp := &TicketIdResponse{}\n\terr = json.Unmarshal(body, ticketIdResp)\n\tif err != nil {\n\t\tlog.Println(\"Can't unmarshal response\")\n\t\treturn \"\", err\n\t}\n\treturn ticketIdResp.Id, nil\n}", "title": "" }, { "docid": "23331636bc69f63df48759ce7f4fef00", "score": "0.51872075", "text": "func (a *Client) CreateTicket(params *CreateTicketParams, authInfo runtime.ClientAuthInfoWriter) (*CreateTicketCreated, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewCreateTicketParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"createTicket\",\n\t\tMethod: \"POST\",\n\t\tPathPattern: \"/oauth/tickets\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &CreateTicketReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*CreateTicketCreated)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\tunexpectedSuccess := result.(*CreateTicketDefault)\n\treturn nil, runtime.NewAPIError(\"unexpected success response: content available as default response in error\", unexpectedSuccess, unexpectedSuccess.Code())\n}", "title": "" }, { "docid": "8b24983fe4bd4eb85ca0f2dcd946168d", "score": "0.51700133", "text": "func (a *Client) ShowTicket(params *ShowTicketParams, authInfo runtime.ClientAuthInfoWriter) (*ShowTicketOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewShowTicketParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"showTicket\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/oauth/tickets/{ticket_id}\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &ShowTicketReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*ShowTicketOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\tunexpectedSuccess := result.(*ShowTicketDefault)\n\treturn nil, runtime.NewAPIError(\"unexpected success response: content available as default response in error\", unexpectedSuccess, unexpectedSuccess.Code())\n}", "title": "" }, { "docid": "baba35c387436628eb1c726fbcfec019", "score": "0.5161947", "text": "func RequestTicketMessage(roomID string, identifier string) string {\n\tticket_link_url := fmt.Sprintf(\"%v/patbot/ticket_link?r=%v&roomID=%v\", redphoneUrl, identifier, roomID)\n\n\tresp, err := http.Get(ticket_link_url)\n\tif err != nil {\n\t\tm := fmt.Sprintf(\"Redphone Ticket %s: %s\", identifier, redphoneEndpoint+identifier)\n\t\treturn fmt.Sprintf(\"%v — Couldn't reach Redphone with error: %v\", m, err)\n\t}\n\tdefer resp.Body.Close()\n\n\treturn \"\"\n}", "title": "" }, { "docid": "59f1ffc72773c5388cf1e42a1c431419", "score": "0.51331687", "text": "func (m *MockSender) CreateTicket(sessionID string) (*Ticket, *big.Int, []byte, error) {\n\targs := m.Called(sessionID)\n\n\tvar ticket *Ticket\n\tvar seed *big.Int\n\tvar sig []byte\n\n\tif args.Get(0) != nil {\n\t\tticket = args.Get(0).(*Ticket)\n\t}\n\n\tif args.Get(1) != nil {\n\t\tseed = args.Get(1).(*big.Int)\n\t}\n\n\tif args.Get(2) != nil {\n\t\tsig = args.Get(2).([]byte)\n\t}\n\n\treturn ticket, seed, sig, args.Error(3)\n}", "title": "" }, { "docid": "278d85c1a221a8c3551a9769aedf0aa3", "score": "0.50805426", "text": "func newTicket(cookieOpts *options.Cookie) (*ticket, error) {\n\trawID := make([]byte, 16)\n\tif _, err := io.ReadFull(rand.Reader, rawID); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create new ticket ID: %v\", err)\n\t}\n\t// ticketID is hex encoded\n\tticketID := fmt.Sprintf(\"%s-%s\", cookieOpts.Name, hex.EncodeToString(rawID))\n\n\tsecret := make([]byte, aes.BlockSize)\n\tif _, err := io.ReadFull(rand.Reader, secret); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create encryption secret: %v\", err)\n\t}\n\n\treturn &ticket{\n\t\tid: ticketID,\n\t\tsecret: secret,\n\t\toptions: cookieOpts,\n\t}, nil\n}", "title": "" }, { "docid": "772939cb4b6336f85c786226d52c142c", "score": "0.50640345", "text": "func (_TicketBroker *TicketBrokerCallerSession) GetTicketHash(_ticket MTicketBrokerCoreTicket) ([32]byte, error) {\n\treturn _TicketBroker.Contract.GetTicketHash(&_TicketBroker.CallOpts, _ticket)\n}", "title": "" }, { "docid": "f4f05ad21d879067ae0023bc1b99c8bb", "score": "0.5041134", "text": "func (t *ticket) encodeTicket() string {\n\treturn fmt.Sprintf(\"%s.%s\", t.id, base64.RawURLEncoding.EncodeToString(t.secret))\n}", "title": "" }, { "docid": "5d072e7a3654c09bae6f06e951eb3ac1", "score": "0.5032077", "text": "func (am *AuthManager) GetAuth(req *http.Request) (*WikifeatAuth, error) {\n\tsessionId, err := am.GetSessionId(req)\n\tif err != nil {\n\t\treturn nil, UnauthenticatedError()\n\t}\n\t//get the session\n\tsession, err := am.ReadSession(sessionId)\n\tif err != nil {\n\t\treturn nil, UnauthenticatedError()\n\t}\n\t//Should we generate a new session token?\n\tttl := time.Duration(config.Auth.SessionTimeout) * time.Second\n\tif session.ExpiresAt.Sub(time.Now()) < ttl/2 {\n\t\t//Ok, generate a new token\n\t\tnextSession, err := am.UpdateSession(sessionId)\n\t\tif err != nil {\n\t\t\treturn nil, UnauthenticatedError()\n\t\t} else {\n\t\t\treturn &WikifeatAuth{\n\t\t\t\tUsername: session.User,\n\t\t\t\tRoles: session.Roles,\n\t\t\t\tNextToken: nextSession.Id,\n\t\t\t}, nil\n\t\t}\n\t} else {\n\t\treturn &WikifeatAuth{\n\t\t\tUsername: session.User,\n\t\t\tRoles: session.Roles,\n\t\t\tNextToken: session.Id,\n\t\t}, nil\n\t}\n}", "title": "" }, { "docid": "6cffaeb558e3eae3ed5f3b46fb07a69e", "score": "0.5031315", "text": "func (c *Client) JoinRealm(ctx context.Context, realm string, details map[string]interface{}) (map[string]interface{}, error) {\n\tif c.Peer.Closed() {\n\t\treturn nil, errors.New(\"client is closed\")\n\t}\n\n\tif details == nil {\n\t\tdetails = map[string]interface{}{}\n\t}\n\n\tdetails[\"roles\"] = clientRoles()\n\n\tif c.Auth != nil && len(c.Auth) > 0 {\n\t\treturn c.joinRealmCRA(ctx, realm, details)\n\t}\n\n\tif err := c.Send(ctx, &HelloMessage{Realm: URI(realm), Details: details}); err != nil {\n\t\tlogErr(c.Close(ctx))\n\t\treturn nil, err\n\t}\n\n\tmsg, err := GetMessageTimeout(c.Peer, c.ReceiveTimeout)\n\tif err != nil {\n\t\tlogErr(c.Close())\n\t\treturn nil, err\n\t}\n\n\twelcome, ok := msg.(*Welcome)\n\tif !ok {\n\t\tc.Send(msgAbortUnexpectedMessageType)\n\t\tlogErr(c.Close())\n\t\treturn nil, fmt.Errorf(formatUnexpectedMessage(msg, MessageTypeWelcome))\n\t}\n\n\tgo c.Receive()\n\n\treturn welcome.Details, nil\n}", "title": "" }, { "docid": "6ac7f58a91f80e48843f0884f84c64b6", "score": "0.50047606", "text": "func (c *Client) JoinRealm(realm string, details map[string]interface{}) (map[string]interface{}, error) {\n\tif details == nil {\n\t\tdetails = map[string]interface{}{}\n\t}\n\tdetails[\"roles\"] = clientRoles()\n\tif c.Auth != nil && len(c.Auth) > 0 {\n\t\treturn c.joinRealmCRA(realm, details)\n\t}\n\tif err := c.Send(&Hello{Realm: URI(realm), Details: details}); err != nil {\n\t\tc.Peer.Close()\n\t\tclose(c.acts)\n\t\treturn nil, err\n\t}\n\tif msg, err := GetMessageTimeout(c.Peer, c.ReceiveTimeout); err != nil {\n\t\tc.Peer.Close()\n\t\tclose(c.acts)\n\t\treturn nil, err\n\t} else if welcome, ok := msg.(*Welcome); !ok {\n\t\tc.Send(abortUnexpectedMsg)\n\t\tc.Peer.Close()\n\t\tclose(c.acts)\n\t\treturn nil, fmt.Errorf(formatUnexpectedMessage(msg, WELCOME))\n\t} else {\n\t\tgo c.Receive()\n\t\treturn welcome.Details, nil\n\t}\n}", "title": "" }, { "docid": "69c87894d3c2e418d0c94c5dfecfe2a1", "score": "0.49862438", "text": "func (service *Service) RegTicket(ctx context.Context, RegTXID string) (*pastel.RegTicket, error) {\n\tregTicket, err := service.pastelClient.RegTicket(ctx, RegTXID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"fetch: %s\", err)\n\t}\n\n\tarticketData, err := pastel.DecodeNFTTicket(regTicket.RegTicketData.NFTTicket)\n\tif err != nil {\n\t\treturn nil, errors.Errorf(\"failed to convert NFT ticket: %w\", err)\n\t}\n\tregTicket.RegTicketData.NFTTicketData = *articketData\n\n\treturn &regTicket, nil\n}", "title": "" }, { "docid": "3493286bf5e0b08c6f7c440b911bc400", "score": "0.49830106", "text": "func (_TicketBroker *TicketBrokerSession) GetTicketHash(_ticket MTicketBrokerCoreTicket) ([32]byte, error) {\n\treturn _TicketBroker.Contract.GetTicketHash(&_TicketBroker.CallOpts, _ticket)\n}", "title": "" }, { "docid": "f517deec005b4e3e834d909d466c5429", "score": "0.49645373", "text": "func (c *Client) joinRealmCRA(ctx context.Context, realm string, details map[string]interface{}) (map[string]interface{}, error) {\n\tauthmethods := []interface{}{}\n\tfor m := range c.Auth {\n\t\tauthmethods = append(authmethods, m)\n\t}\n\tdetails[\"authmethods\"] = authmethods\n\n\terr := c.Send(&HelloMessage{Realm: URI(realm), Details: details})\n\tif err != nil {\n\t\tlogErr(c.Close())\n\t\treturn nil, err\n\t}\n\n\tmsg, err := GetMessageTimeout(c.Peer, c.ReceiveTimeout)\n\tif err != nil {\n\t\tlogErr(c.Close())\n\t\treturn nil, err\n\t}\n\n\tchallenge, ok := msg.(*Challenge)\n\tif !ok {\n\t\tc.Send(msgAbortUnexpectedMessageType)\n\t\tlogErr(c.Close())\n\t\treturn nil, fmt.Errorf(formatUnexpectedMessage(msg, MessageTypeChallenge))\n\t}\n\n\tauthFunc, ok := c.Auth[challenge.AuthMethod]\n\tif !ok {\n\t\tc.Send(msgAbortNoAuthHandler)\n\t\tlogErr(c.Close())\n\t\treturn nil, fmt.Errorf(\"no auth handler for method: %s\", challenge.AuthMethod)\n\t}\n\n\tsignature, authDetails, err := authFunc(details, challenge.Extra)\n\tif err != nil {\n\t\tc.Send(msgAbortAuthFailure)\n\t\tlogErr(c.Close())\n\t\treturn nil, err\n\t}\n\n\terr = c.Send(&Authenticate{Signature: signature, Extra: authDetails})\n\tif err != nil {\n\t\tlogErr(c.Close())\n\t\treturn nil, err\n\t}\n\n\tmsg, err = GetMessageTimeout(c.Peer, c.ReceiveTimeout)\n\tif err != nil {\n\t\tlogErr(c.Close())\n\t\treturn nil, err\n\t}\n\n\twelcome, ok := msg.(*Welcome)\n\tif !ok {\n\t\tc.Send(msgAbortUnexpectedMessageType)\n\t\tlogErr(c.Close())\n\t\treturn nil, fmt.Errorf(formatUnexpectedMessage(msg, MessageTypeWelcome))\n\t}\n\n\tgo c.Receive()\n\n\treturn welcome.Details, nil\n}", "title": "" }, { "docid": "5f2d8c058ca8df18104a6265840d3ccc", "score": "0.49606583", "text": "func (m *MockRecipient) ReceiveTicket(ticket *Ticket, sig []byte, seed *big.Int) (sessionID string, won bool, err error) {\n\targs := m.Called(ticket, sig, seed)\n\treturn args.String(0), args.Bool(1), args.Error(2)\n}", "title": "" }, { "docid": "42ff9db17c47dadbb92323776db3f162", "score": "0.49394333", "text": "func getTickets() *list.List {\n\tdatabase, err := sql.Open(\"sqlite3\", \"./mydb.db\")\n\tcheckErr(err)\n\n\trows, err := database.Query(\"SELECT * FROM ticket\")\n\tcheckErr(err)\n\n\tvar id int\n\tvar clientId int\n\tvar buildingId int\n\tvar floor int\n\tvar orientation string\n\tvar date time.Time\n\tresult := list.New()\n\tfor rows.Next() {\n\t\terr = rows.Scan(&id, &clientId, &buildingId, &floor, &orientation, &date)\n\t\tvar ticket = Ticket{\n\t\t\tID: id, OwnerId: clientId, BuildingId: buildingId, Floor: floor, Orientation: orientation, Date: date,\n\t\t}\n\t\tresult.PushBack(ticket)\n\t}\n\trows.Close()\n\treturn result\n}", "title": "" }, { "docid": "5c76ab6f1971cf6287de6d2d1d452fef", "score": "0.49258542", "text": "func (m *MockRecipient) TicketParams(sender ethcommon.Address) *TicketParams {\n\targs := m.Called(sender)\n\n\tvar params *TicketParams\n\tif args.Get(0) != nil {\n\t\tparams = args.Get(0).(*TicketParams)\n\t}\n\n\treturn params\n}", "title": "" }, { "docid": "938e2ab1c42a2157201963cc84361bb3", "score": "0.4924429", "text": "func GetTicketByToken(token string) map[string]interface{} {\n\t// Get the db connection\n\tdb := GetDB()\n\tticket := &Ticket{}\n\n\t// Lookup the ticket\n\tdb.Table(\"tickets\").Where(\"token = ?\", token).First(ticket)\n\t// If ticket doesn't exist\n\tif ticket.Token == \"\" {\n\t\treturn nil\n\t}\n\n\t// Compose response message\n\tresp := u.Message(true, \"Ticket found\")\n\t// Add ticket to the response\n\tresp[\"ticket\"] = ticket\n\treturn resp\n}", "title": "" }, { "docid": "d18250d126a822ec8bfefc1652e070fa", "score": "0.49194613", "text": "func (_KeepRandomBeaconOperator *KeepRandomBeaconOperatorSession) SubmitTicket(ticket [32]byte) (*types.Transaction, error) {\n\treturn _KeepRandomBeaconOperator.Contract.SubmitTicket(&_KeepRandomBeaconOperator.TransactOpts, ticket)\n}", "title": "" }, { "docid": "b07a7aaf5b21ac765965a4b090b96464", "score": "0.49101093", "text": "func (c *Client) joinRealmCRA(realm string, details map[string]interface{}) (map[string]interface{}, error) {\n\tauthmethods := []interface{}{}\n\tfor m := range c.Auth {\n\t\tauthmethods = append(authmethods, m)\n\t}\n\tdetails[\"authmethods\"] = authmethods\n\tif err := c.Send(&Hello{Realm: URI(realm), Details: details}); err != nil {\n\t\tc.Peer.Close()\n\t\tclose(c.acts)\n\t\treturn nil, err\n\t}\n\tif msg, err := GetMessageTimeout(c.Peer, c.ReceiveTimeout); err != nil {\n\t\tc.Peer.Close()\n\t\tclose(c.acts)\n\t\treturn nil, err\n\t} else if challenge, ok := msg.(*Challenge); !ok {\n\t\tc.Send(abortUnexpectedMsg)\n\t\tc.Peer.Close()\n\t\tclose(c.acts)\n\t\treturn nil, fmt.Errorf(formatUnexpectedMessage(msg, CHALLENGE))\n\t} else if authFunc, ok := c.Auth[challenge.AuthMethod]; !ok {\n\t\tc.Send(abortNoAuthHandler)\n\t\tc.Peer.Close()\n\t\tclose(c.acts)\n\t\treturn nil, fmt.Errorf(\"no auth handler for method: %s\", challenge.AuthMethod)\n\t} else if signature, authDetails, err := authFunc(details, challenge.Extra); err != nil {\n\t\tc.Send(abortAuthFailure)\n\t\tc.Peer.Close()\n\t\tclose(c.acts)\n\t\treturn nil, err\n\t} else if err := c.Send(&Authenticate{Signature: signature, Extra: authDetails}); err != nil {\n\t\tc.Peer.Close()\n\t\tclose(c.acts)\n\t\treturn nil, err\n\t}\n\tif msg, err := GetMessageTimeout(c.Peer, c.ReceiveTimeout); err != nil {\n\t\tc.Peer.Close()\n\t\tclose(c.acts)\n\t\treturn nil, err\n\t} else if welcome, ok := msg.(*Welcome); !ok {\n\t\tc.Send(abortUnexpectedMsg)\n\t\tc.Peer.Close()\n\t\tclose(c.acts)\n\t\treturn nil, fmt.Errorf(formatUnexpectedMessage(msg, WELCOME))\n\t} else {\n\t\tgo c.Receive()\n\t\treturn welcome.Details, nil\n\t}\n}", "title": "" }, { "docid": "7fedfb4f8cd1e462de26e6e01976bd1c", "score": "0.49050555", "text": "func (a *Client) ExchangeTicket(params *ExchangeTicketParams, authInfo runtime.ClientAuthInfoWriter) (*ExchangeTicketCreated, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewExchangeTicketParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"exchangeTicket\",\n\t\tMethod: \"POST\",\n\t\tPathPattern: \"/oauth/tickets/{ticket_id}/exchange\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &ExchangeTicketReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*ExchangeTicketCreated)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\tunexpectedSuccess := result.(*ExchangeTicketDefault)\n\treturn nil, runtime.NewAPIError(\"unexpected success response: content available as default response in error\", unexpectedSuccess, unexpectedSuccess.Code())\n}", "title": "" }, { "docid": "f4005fb67878382c6cebde8a2d7a4ce8", "score": "0.48864046", "text": "func (_TicketBroker *TicketBrokerCaller) GetTicketHash(opts *bind.CallOpts, _ticket MTicketBrokerCoreTicket) ([32]byte, error) {\n\tvar out []interface{}\n\terr := _TicketBroker.contract.Call(opts, &out, \"getTicketHash\", _ticket)\n\n\tif err != nil {\n\t\treturn *new([32]byte), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte)\n\n\treturn out0, err\n\n}", "title": "" }, { "docid": "ba3301a7452b78877977608f984b6057", "score": "0.48844695", "text": "func RandTicket(r *rand.Rand, owner string) types.Ticket {\n\treturn types.NewTicket(\n\t\tRandHexString(r, 20),\n\t\tRandDate(r, time.Now()),\n\t\towner,\n\t)\n}", "title": "" }, { "docid": "d96c77e606b719dc7b89f7b7f3b263c2", "score": "0.4867775", "text": "func (c *CAS) makeNewTicketForService(service *CASService) (string, *CASServerError) {\n\treturn \"123456\", nil\n}", "title": "" }, { "docid": "8e9656596537efd50a8f963d1a877131", "score": "0.485018", "text": "func decodeTicket(encTicket string, cookieOpts *options.Cookie) (*ticket, error) {\n\tticketParts := strings.Split(encTicket, \".\")\n\tif len(ticketParts) != 2 {\n\t\treturn nil, errors.New(\"failed to decode ticket\")\n\t}\n\tticketID, secretBase64 := ticketParts[0], ticketParts[1]\n\n\tsecret, err := base64.RawURLEncoding.DecodeString(secretBase64)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decode encryption secret: %v\", err)\n\t}\n\n\treturn &ticket{\n\t\tid: ticketID,\n\t\tsecret: secret,\n\t\toptions: cookieOpts,\n\t}, nil\n}", "title": "" }, { "docid": "68e6ca72d5aa8762f717f9d45f6a1341", "score": "0.48489207", "text": "func (validator *ServiceTicketValidator) ValidateTicket(serviceURL *url.URL, ticket string) (*AuthenticationResponse, error) {\n\tif validator.validationType == \"CAS1\" {\n\t\treturn validator.validateTicketCas1(serviceURL, ticket)\n\t} else if validator.validationType == \"CAS2\" {\n\t\treturn validator.validateTicketCas2(serviceURL, ticket)\n\t}\n\treturn validator.validateTicketCas3(serviceURL, ticket)\n}", "title": "" }, { "docid": "6a0d18d0c8c558f679fa378cac7c63f5", "score": "0.48360285", "text": "func (b Bottleneck) NewTicket() Ticket {\n\treturn getLosingTicket()\n}", "title": "" }, { "docid": "dfda875bb54918ec3cb2847c4ad450c9", "score": "0.4828315", "text": "func mockAuthGet(mctx libkb.MetaContext, url, authToken string) (int, []byte, error) {\n\tparts := strings.Split(url, \"?\")\n\tswitch parts[0] {\n\tcase \"https://transfer.keybase.io/transfer/deposit\":\n\t\tif authToken == \"\" {\n\t\t\treturn 0, nil, errors.New(\"missing token\")\n\t\t}\n\t\treturn http.StatusForbidden, []byte(authDepositBody), nil\n\tcase \"https://transfer.keybase.io/transfer/withdraw\":\n\t\tif authToken == \"\" {\n\t\t\treturn 0, nil, errors.New(\"missing token\")\n\t\t}\n\t\treturn http.StatusForbidden, []byte(authWithdrawBody), nil\n\tcase \"https://transfer.keybase.io/auth\":\n\t\treturn http.StatusOK, []byte(authChallenge), nil\n\tdefault:\n\t\treturn 0, nil, fmt.Errorf(\"unknown mocked url %q\", url)\n\t}\n}", "title": "" }, { "docid": "b8f8348f8dad830381cda470ee964689", "score": "0.4828266", "text": "func (self *HttpRunner) GetAuthDataTicker() <-chan time.Time {\n\treturn self.aticker\n}", "title": "" }, { "docid": "ac1c771ff9db9e3883412e6d04da75dc", "score": "0.48240364", "text": "func getWebHookAuth(cfg env.Config, credentials *OAuth2ClientCredentials) *types.WebhookAuth {\n\treturn &types.WebhookAuth{\n\t\tClientID: credentials.ClientID,\n\t\tClientSecret: credentials.ClientSecret,\n\t\tTokenURL: cfg.WebhookTokenEndpoint,\n\t\tType: types.AuthTypeClientCredentials,\n\t\tGrantType: types.GrantTypeClientCredentials,\n\t}\n}", "title": "" }, { "docid": "5c15c3947d3672714fb4b0014e0b099f", "score": "0.48165244", "text": "func (api *Tickets) Get(id int64) (interface{}, error) {\n\tresponse, err := api.rest.Get(fmt.Sprintf(\"crm-objects/v1/objects/tickets/%d\", id))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn api.toEntity(response), nil\n}", "title": "" }, { "docid": "a96807b59b142a3b489ae15f6136c3af", "score": "0.47964725", "text": "func (this OrgEnableTwoFactorRequirementAuditEntry) GetActorLogin() *string { return this.ActorLogin }", "title": "" }, { "docid": "c75a53ca653c9a5ea77b2017ca2057b3", "score": "0.4788675", "text": "func (c *CASProxy) ValidateTicket(w http.ResponseWriter, r *http.Request) {\n\tcasURL, err := url.Parse(c.casBase)\n\tif err != nil {\n\t\terr = errors.Wrapf(err, \"failed to parse CAS base URL %s\", c.casBase)\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Make sure the path in the CAS params is the same as the one that was\n\t// requested.\n\tsvcURL, err := url.Parse(c.frontendURL)\n\tif err != nil {\n\t\terr = errors.Wrapf(err, \"failed to parse the frontend URL %s\", c.frontendURL)\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Make sure the serivce path and the query params are set to the incoming\n\t// requests values for those fields.\n\tsvcURL.Path = r.URL.Path\n\tsq := r.URL.Query()\n\tsq.Del(\"ticket\") // Remove the ticket from the service URL. Redirection loops occur otherwise.\n\tsvcURL.RawQuery = sq.Encode()\n\n\t// The request URL for cas validation needs to have the service and ticket in\n\t// it.\n\tcasURL.Path = path.Join(casURL.Path, c.casValidate)\n\tq := casURL.Query()\n\tq.Add(\"service\", svcURL.String())\n\tq.Add(\"ticket\", r.URL.Query().Get(\"ticket\"))\n\tcasURL.RawQuery = q.Encode()\n\n\t// Actually validate the ticket.\n\tresp, err := http.Get(casURL.String())\n\tif err != nil {\n\t\terr = errors.Wrap(err, \"ticket validation error\")\n\t\thttp.Error(w, err.Error(), http.StatusForbidden)\n\t\treturn\n\t}\n\n\t// If this happens then something went wrong on the CAS side of things. Doesn't\n\t// mean the ticket is invalid, just that the CAS server is in a state where\n\t// we can't trust the response.\n\tif resp.StatusCode < 200 || resp.StatusCode > 299 {\n\t\terr = errors.Wrapf(err, \"ticket validation status code was %d\", resp.StatusCode)\n\t\thttp.Error(w, err.Error(), http.StatusForbidden)\n\t\treturn\n\t}\n\n\tb, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\terr = errors.Wrap(err, \"error reading body of CAS response\")\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\n\t// This is where the actual ticket validation happens. If the CAS server\n\t// returns 'no\\n\\n' in the body, then the validation was not successful. The\n\t// HTTP status code will be in the 200 range regardless if the validation\n\t// status.\n\tif bytes.Equal(b, []byte(\"no\\n\\n\")) {\n\t\terr = fmt.Errorf(\"ticket validation response body was %s\", b)\n\t\thttp.Error(w, err.Error(), http.StatusForbidden)\n\t\treturn\n\t}\n\n\t// Store a session, hopefully to short circuit the CAS redirect dance in later\n\t// requests. The max age of the cookie should be less than the lifetime of\n\t// the CAS ticket, which is around 10+ hours. This means that we'll be hitting\n\t// the CAS server fairly often, but it shouldn't be an issue.\n\tsession, err := c.cookies.Get(r, sessionName)\n\tif err != nil {\n\t\terr = errors.Wrapf(err, \"failed get session %s\", sessionName)\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tsession.Values[sessionKey] = 1\n\tsession.Options.MaxAge = c.maxAge\n\tc.cookies.Save(r, w, session)\n\n\thttp.Redirect(w, r, svcURL.String(), http.StatusTemporaryRedirect)\n}", "title": "" }, { "docid": "10798151b6be7d824a887084ecefd8bf", "score": "0.4776733", "text": "func (_KeepRandomBeaconOperator *KeepRandomBeaconOperatorTransactorSession) SubmitTicket(ticket [32]byte) (*types.Transaction, error) {\n\treturn _KeepRandomBeaconOperator.Contract.SubmitTicket(&_KeepRandomBeaconOperator.TransactOpts, ticket)\n}", "title": "" }, { "docid": "ad1e958fbc552e22285d92268a5fd4d0", "score": "0.47665042", "text": "func getPachClientInternal(tb testing.TB, subject string) *client.APIClient {\n\t// copy seed, so caller can safely modify result\n\tresultClient := seedClient.WithCtx(context.Background())\n\tif subject == \"\" {\n\t\treturn resultClient // anonymous client\n\t}\n\tif strings.Index(subject, \":\") < 0 {\n\t\tsubject = auth.GitHubPrefix + subject\n\t}\n\tif _, ok := tokenMap[subject]; !ok {\n\t\tresp, err := seedClient.Authenticate(context.Background(),\n\t\t\t&auth.AuthenticateRequest{\n\t\t\t\t// When Pachyderm is deployed locally, GitHubToken automatically\n\t\t\t\t// authenicates the caller as a GitHub user whose name is equal to the\n\t\t\t\t// provided token\n\t\t\t\tGitHubToken: strings.TrimPrefix(subject, auth.GitHubPrefix),\n\t\t\t})\n\t\trequire.NoError(tb, err)\n\t\ttokenMap[subject] = resp.PachToken\n\t}\n\tresultClient.SetAuthToken(tokenMap[subject])\n\treturn resultClient\n}", "title": "" }, { "docid": "4f26903a5f40f5245095caba6a0fefa9", "score": "0.47661537", "text": "func (this OrgEnableOauthAppRestrictionsAuditEntry) GetActorLogin() *string { return this.ActorLogin }", "title": "" }, { "docid": "b349f853a6840e1e026cceb61e53f63b", "score": "0.47601306", "text": "func (a *Client) GetAuthWellknown(params *GetAuthWellknownParams, authInfo runtime.ClientAuthInfoWriter) (*GetAuthWellknownOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewGetAuthWellknownParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"getAuthWellknown\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/platform/1/auth/wellknowns/{AuthWellknownId}\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &GetAuthWellknownReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.(*GetAuthWellknownOK), nil\n\n}", "title": "" }, { "docid": "19ebd0a57a5537f445c7534e1be2bd8b", "score": "0.47529998", "text": "func (m *EnrollmentManager) CreateTicket(t *CreateEnrollmentTicket, opts ...RequestOption) (EnrollmentTicket, error) {\n\treq, err := m.NewRequest(\"POST\", m.URI(\"guardian\", \"enrollments\", \"ticket\"), t, opts...)\n\tif err != nil {\n\t\treturn EnrollmentTicket{}, err\n\t}\n\n\tres, err := m.Do(req)\n\tif err != nil {\n\t\treturn EnrollmentTicket{}, err\n\t}\n\tdefer res.Body.Close()\n\n\tif res.StatusCode != http.StatusOK {\n\t\treturn EnrollmentTicket{}, newError(res.Body)\n\t}\n\n\tvar out EnrollmentTicket\n\terr = json.NewDecoder(res.Body).Decode(&out)\n\treturn out, err\n}", "title": "" }, { "docid": "1536682f17bb49de7e9d92bc20286fba", "score": "0.4752141", "text": "func getPachClient(tb testing.TB, subject string) *client.APIClient {\n\ttb.Helper()\n\ttokenMapMut.Lock()\n\tdefer tokenMapMut.Unlock()\n\n\t// Check if seed client exists -- if not, create it\n\tif seedClient == nil {\n\t\tinitSeedClient(tb)\n\t}\n\n\t// Activate Pachyderm Enterprise (if it's not already active)\n\trequire.NoError(tb, backoff.Retry(func() error {\n\t\tresp, err := seedClient.Enterprise.GetState(context.Background(),\n\t\t\t&enterprise.GetStateRequest{})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif resp.State == enterprise.State_ACTIVE {\n\t\t\treturn nil\n\t\t}\n\t\t_, err = seedClient.Enterprise.Activate(context.Background(),\n\t\t\t&enterprise.ActivateRequest{\n\t\t\t\tActivationCode: tu.GetTestEnterpriseCode(),\n\t\t\t})\n\t\treturn err\n\t}, backoff.NewTestingBackOff()))\n\n\t// Cluster may be in one of four states:\n\t// 1) Auth is off (=> Activate auth)\n\t// 2) Auth is on, but client tokens have been invalidated (=> Deactivate +\n\t// Reactivate auth)\n\t// 3) Auth is on and client tokens are valid, but the admin isn't \"admin\"\n\t// (=> reset cluster admins to \"admin\")\n\t// 4) Auth is on, client tokens are valid, and the only admin is \"admin\" (do\n\t// nothing)\n\tif !isAuthActive(tb) {\n\t\t// Case 1: auth is off. Activate auth & return a new client\n\t\ttokenMap = make(map[string]string)\n\t\tactivateAuth(tb)\n\t\treturn getPachClientInternal(tb, subject)\n\t}\n\n\tadminClient := getPachClientInternal(tb, admin)\n\tgetAdminsResp, err := adminClient.GetAdmins(adminClient.Ctx(),\n\t\t&auth.GetAdminsRequest{})\n\n\t// Detect case 2: auth was deactivated during previous test. De/Reactivate\n\t// TODO it may may sense to do this between every test, though it would mean\n\t// that we can't run tests in parallel. Currently, only the first test that\n\t// needs to reset auth will run this block\n\tif err != nil && auth.IsErrBadToken(err) {\n\t\t// Don't know which tokens are valid, so clear tokenMap\n\t\ttokenMap = make(map[string]string)\n\t\tadminClient := getPachClientInternal(tb, admin)\n\n\t\t// \"admin\" may no longer be an admin, so get a list of admins, authorize as\n\t\t// the first admin, and deactivate auth\n\t\tgetAdminsResp, err := adminClient.GetAdmins(adminClient.Ctx(),\n\t\t\t&auth.GetAdminsRequest{})\n\t\trequire.NoError(tb, err)\n\t\tif len(getAdminsResp.Admins) == 0 {\n\t\t\tpanic(\"it should not be possible to leave a cluster with no admins\")\n\t\t}\n\t\tadminClient = getPachClientInternal(tb, getAdminsResp.Admins[0])\n\t\t_, err = adminClient.Deactivate(adminClient.Ctx(), &auth.DeactivateRequest{})\n\t\trequire.NoError(tb, err)\n\n\t\t// Just deactivated. *All* tokens are now invalid, so clear the map again\n\t\ttokenMap = make(map[string]string)\n\t\tactivateAuth(tb)\n\t\treturn getPachClientInternal(tb, subject)\n\t}\n\n\t// Detect case 3: previous change shuffled admins. Reset list to just \"admin\"\n\tif len(getAdminsResp.Admins) == 0 {\n\t\tpanic(\"it should not be possible to leave a cluster with no admins\")\n\t}\n\thasExpectedAdmin := len(getAdminsResp.Admins) == 1 && getAdminsResp.Admins[0] == admin\n\tif !hasExpectedAdmin {\n\t\tvar curAdminClient *client.APIClient\n\t\tmodifyRequest := &auth.ModifyAdminsRequest{\n\t\t\tAdd: []string{admin},\n\t\t}\n\t\tfor _, a := range getAdminsResp.Admins {\n\t\t\tif strings.HasPrefix(a, auth.GitHubPrefix) {\n\t\t\t\tcurAdminClient = getPachClientInternal(tb, a) // use first GH admin\n\t\t\t}\n\t\t\tif a == admin {\n\t\t\t\t// nothing to add, just don't remove \"admin\"\n\t\t\t\tmodifyRequest.Add = nil\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tmodifyRequest.Remove = append(modifyRequest.Remove, a)\n\t\t}\n\t\tif curAdminClient == nil {\n\t\t\ttb.Fatal(\"cluster has no GitHub admins; no way for auth test to grant itself admin access\")\n\t\t}\n\t\t_, err := curAdminClient.ModifyAdmins(curAdminClient.Ctx(), modifyRequest)\n\t\trequire.NoError(tb, err)\n\n\t\t// Wait for admin change to take effect\n\t\trequire.NoError(tb, backoff.Retry(func() error {\n\t\t\tgetAdminsResp, err = adminClient.GetAdmins(adminClient.Ctx(),\n\t\t\t\t&auth.GetAdminsRequest{})\n\t\t\thasExpectedAdmin := len(getAdminsResp.Admins) == 1 && getAdminsResp.Admins[0] == admin\n\t\t\tif !hasExpectedAdmin {\n\t\t\t\treturn fmt.Errorf(\"cluster admins haven't yet updated\")\n\t\t\t}\n\t\t\treturn nil\n\t\t}, backoff.NewTestingBackOff()))\n\t}\n\n\treturn getPachClientInternal(tb, subject)\n}", "title": "" }, { "docid": "e24283bfe4cdf36ba70b827ea6f249ec", "score": "0.4728853", "text": "func (c *Client) GetAuthRequired(\n\tparamss ...*GetAuthRequiredParams,\n) (*GetAuthRequiredResponse, error) {\n\tif len(paramss) == 0 {\n\t\tparamss = []*GetAuthRequiredParams{{}}\n\t}\n\tparams := paramss[0]\n\tdata := &GetAuthRequiredResponse{}\n\tif err := c.SendRequest(params, data); err != nil {\n\t\treturn nil, err\n\t}\n\treturn data, nil\n}", "title": "" }, { "docid": "9a73b1ee204f1f42a2eade4c7db8dafd", "score": "0.47224438", "text": "func (_TicketBroker *TicketBrokerSession) RedeemWinningTicket(_ticket MTicketBrokerCoreTicket, _sig []byte, _recipientRand *big.Int) (*types.Transaction, error) {\n\treturn _TicketBroker.Contract.RedeemWinningTicket(&_TicketBroker.TransactOpts, _ticket, _sig, _recipientRand)\n}", "title": "" }, { "docid": "02a266083069e78cfa9211840c8656bc", "score": "0.47082263", "text": "func (_TicketBroker *TicketBrokerTransactorSession) RedeemWinningTicket(_ticket MTicketBrokerCoreTicket, _sig []byte, _recipientRand *big.Int) (*types.Transaction, error) {\n\treturn _TicketBroker.Contract.RedeemWinningTicket(&_TicketBroker.TransactOpts, _ticket, _sig, _recipientRand)\n}", "title": "" }, { "docid": "6955a7e67c61f19d80c32147738a1820", "score": "0.47063994", "text": "func (this OrgOauthAppAccessRequestedAuditEntry) GetActorLogin() *string { return this.ActorLogin }", "title": "" }, { "docid": "684cabdf4a6460ca74cbd3fcc7e79657", "score": "0.46975985", "text": "func (c *CASProxy) ValidateTicket(w http.ResponseWriter, r *http.Request) {\n\tcasURL, err := url.Parse(c.casBase)\n\tif err != nil {\n\t\terr = errors.Wrapf(err, \"failed to parse CAS base URL %s\", c.casBase)\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Make sure the path in the CAS params is the same as the one that was\n\t// requested.\n\tfrontendURL := c.FrontendAddress(r)\n\tsvcURL, err := url.Parse(frontendURL)\n\tif err != nil {\n\t\terr = errors.Wrapf(err, \"failed to parse the frontend URL %s\", frontendURL)\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Ensure that the service path and the query params are set to the incoming\n\t// request's values for those fields.\n\tsvcURL.Path = r.URL.Path\n\tsq := r.URL.Query()\n\tsq.Del(\"ticket\") // Remove the ticket from the service URL. Redirection loops occur otherwise.\n\tsvcURL.RawQuery = sq.Encode()\n\n\t// The request URL for CAS ticket validation needs to have the service and\n\t// ticket in it.\n\tcasURL.Path = path.Join(casURL.Path, c.casValidate)\n\tq := casURL.Query()\n\tq.Add(\"service\", svcURL.String())\n\tq.Add(\"ticket\", r.URL.Query().Get(\"ticket\"))\n\tcasURL.RawQuery = q.Encode()\n\n\t// Actually validate the ticket.\n\tresp, err := http.Get(casURL.String())\n\tif err != nil {\n\t\terr = errors.Wrap(err, \"ticket validation error\")\n\t\thttp.Error(w, err.Error(), http.StatusForbidden)\n\t\treturn\n\t}\n\n\t// If this happens then something went wrong on the CAS side of things. Doesn't\n\t// mean the ticket is invalid, just that the CAS server is in a state where\n\t// we can't trust the response.\n\tif resp.StatusCode < 200 || resp.StatusCode > 299 {\n\t\terr = errors.Wrapf(err, \"ticket validation status code was %d\", resp.StatusCode)\n\t\thttp.Error(w, err.Error(), http.StatusForbidden)\n\t\treturn\n\t}\n\n\tb, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\terr = errors.Wrap(err, \"error reading body of CAS response\")\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\n\t// This is where the actual ticket validation happens. If the CAS server\n\t// returns 'no\\n\\n' in the body, then the validation was not successful. The\n\t// HTTP status code will be in the 200 range regardless of the validation\n\t// status.\n\tif bytes.Equal(b, []byte(\"no\\n\\n\")) {\n\t\terr = fmt.Errorf(\"ticket validation response body was %s\", b)\n\t\thttp.Error(w, err.Error(), http.StatusForbidden)\n\t\treturn\n\t}\n\n\tfields := bytes.Fields(b)\n\tif len(fields) < 2 {\n\t\terr = errors.New(\"not enough fields in ticket validation response body\")\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tusername := string(fields[1])\n\n\t// Store a session, hopefully to short-circuit the CAS redirect dance in later\n\t// requests. The max age of the cookie should be less than the lifetime of\n\t// the CAS ticket, which is around 10+ hours. This means that we'll be hitting\n\t// the CAS server fairly often. Adjust the max age to rate limit requests to\n\t// CAS.\n\tvar s *sessions.Session\n\ts, err = c.sessionStore.Get(r, sessionName)\n\tif err != nil {\n\t\terr = errors.Wrap(err, \"error getting session\")\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\ts.Values[sessionKey] = username\n\ts.Save(r, w)\n\n\thttp.Redirect(w, r, svcURL.String(), http.StatusFound)\n}", "title": "" }, { "docid": "91a35d45efea32a0a4914ce8b3e7e47e", "score": "0.4672615", "text": "func (nalogruClient *Client) GetTicketById(id string) (*TicketDetails, error) {\n\tclient := createHttpClient()\n\n\turl := nalogruClient.BaseAddress + \"/v2/tickets/\" + id\n\trequest, err := http.NewRequest(http.MethodGet, url, nil)\n\taddHeaders(request, nalogruClient.device.Id.Hex())\n\taddAuth(request, nalogruClient.device.SessionId)\n\tres, err := sendRequest(request, client)\n\n\tif err != nil {\n\t\tlog.Printf(\"Can't GET %s\\n\", url)\n\t\treturn nil, err\n\t}\n\tdefer res.Body.Close()\n\n\tall, err := readBody(res)\n\tif err != nil {\n\t\tlog.Printf(\"failed to read response body. status code %d\\n\", res.StatusCode)\n\t\treturn nil, err\n\t}\n\n\tif res.StatusCode == http.StatusUnauthorized {\n\t\treturn nil, AuthError\n\t}\n\n\tif res.StatusCode != http.StatusOK {\n\t\tlog.Printf(\"GET receipt error: %d\\n\", res.StatusCode)\n\t\terr = os.WriteFile(\"/var/lib/receipts/error/\"+id+\".json\", all, 0644)\n\t\treturn nil, err\n\t}\n\n\tdetails := &TicketDetails{}\n\n\terr = os.WriteFile(\"/var/lib/receipts/raw/\"+id+\".json\", all, 0644)\n\n\terr = json.Unmarshal(all, details)\n\tif err != nil {\n\t\tlog.Println(\"Can't decode response body\")\n\n\t\treturn nil, err\n\t}\n\n\treturn details, nil\n}", "title": "" }, { "docid": "7b0131d15c045e16d0dcff2da9c72064", "score": "0.4672458", "text": "func (o *GetUMAGatherClaimsParams) SetTicket(ticket *string) {\n\to.Ticket = ticket\n}", "title": "" }, { "docid": "43ed7c90a41cd2fa6d5a333a2aaa0cea", "score": "0.46720073", "text": "func GetAuth() string {\n\tdebug(\"returns cached credentials\")\n\treturn ctx.proxyauth\n}", "title": "" }, { "docid": "36c087d291fc5acbcf30883040f500f1", "score": "0.46651256", "text": "func (_TicketBroker *TicketBrokerTransactor) RedeemWinningTicket(opts *bind.TransactOpts, _ticket MTicketBrokerCoreTicket, _sig []byte, _recipientRand *big.Int) (*types.Transaction, error) {\n\treturn _TicketBroker.contract.Transact(opts, \"redeemWinningTicket\", _ticket, _sig, _recipientRand)\n}", "title": "" }, { "docid": "ebc5d171df378f4261be22f3d7871bb3", "score": "0.46368253", "text": "func (r PartnerRhccAdapter) getAuthToken() (string, error) {\n\ttype TokenResponse struct {\n\t\tToken string `json:\"token\"`\n\t}\n\tusername := r.Config.User\n\tpassword := r.Config.Pass\n\n\treq, err := http.NewRequest(\"GET\", fmt.Sprintf(\"%v/v2/\", r.Config.URL), nil)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer resp.Body.Close()\n\n\t// Ensure that response holds data we expect\n\tif resp.Header.Get(\"Www-Authenticate\") == \"\" {\n\t\treturn \"\", errors.New(\"failed to find www-authenticate header from response\")\n\t}\n\n\tauthChallenge := resp.Header.Get(\"Www-Authenticate\")\n\tif strings.Index(authChallenge, \"realm=\\\"\") == -1 {\n\t\treturn \"\", errors.New(\"failed to find realm in www-authenticate header\")\n\t}\n\tauthOptions := \"\"\n\tif strings.Index(authChallenge, \",\") != -1 {\n\t\tauthOptions = strings.Split(authChallenge, \",\")[1]\n\t}\n\tauthRealm := strings.Split(strings.Split(authChallenge, \"realm=\\\"\")[1], \"\\\"\")[0]\n\tauthURL := fmt.Sprintf(\"%v?%v\", authRealm, authOptions)\n\t// Replace any quotes that exist in header from authOptions\n\tauthURL = strings.Replace(authURL, \"\\\"\", \"\", -1)\n\n\treq, err = http.NewRequest(\"GET\", authURL, nil)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.SetBasicAuth(username, password)\n\n\tresp, err = http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer resp.Body.Close()\n\n\ttokenResp := TokenResponse{}\n\terr = json.NewDecoder(resp.Body).Decode(&tokenResp)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn tokenResp.Token, nil\n}", "title": "" }, { "docid": "3defbb404960c0e681af7ad21fd9e2b4", "score": "0.4617273", "text": "func (this OrgDisableOauthAppRestrictionsAuditEntry) GetActorLogin() *string { return this.ActorLogin }", "title": "" }, { "docid": "64589a9d15cde22d2a6ae5628dce714a", "score": "0.46075803", "text": "func (mgr *testNtfnManager) RegisterWinningTickets(wsc *wsClient) {}", "title": "" }, { "docid": "b59b6c409588333faad9397498de03f1", "score": "0.4605296", "text": "func RPCAuth() (err error) {\n\n\t//resp, err = client.Do()\n\t//session, err := ntlm.CreateClientSession(ntlm.Version1, ntlm.ConnectionlessMode)\n\t//if err != nil {\n\t//\treturn nil, err\n\t//}\n\t/*\n\t\tsession.SetUserInfo(t.User, t.Password, t.Domain)\n\n\t\t// parse NTLM challenge\n\t\tchallenge, err := ntlm.ParseChallengeMessage(challengeBytes)\n\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\terr = session.ProcessChallengeMessage(challenge)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// authenticate user\n\t\tauthenticate, err := session.GenerateAuthenticateMessage()\n\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// set NTLM Authorization header\n\t\t//req.Header.Set(\"Authorization\", \"NTLM \"+encBase64(authenticate.Bytes()))\n\t\tresp, err = client.Do(req)\n\n\t\treturn resp, err\n\t*/\n\treturn nil\n}", "title": "" }, { "docid": "b095a56058bdbceeb11afaa1c744f793", "score": "0.46047482", "text": "func EncodeTicket(t *schema.UserTicket) (string, error) {\n\tb := bytes.Buffer{}\n\te := gob.NewEncoder(&b)\n\terr := e.Encode(t)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn base64.StdEncoding.EncodeToString(b.Bytes()), nil\n}", "title": "" }, { "docid": "b83642a8c3375a8b2e52a3767df407bd", "score": "0.46028072", "text": "func (c *testRPCChain) CheckLiveTicket(hash chainhash.Hash) bool {\n\treturn c.checkLiveTicket\n}", "title": "" }, { "docid": "85b5964ce28f89f54942bf456cd35a60", "score": "0.4559373", "text": "func (this OrgDisableTwoFactorRequirementAuditEntry) GetActorLogin() *string { return this.ActorLogin }", "title": "" }, { "docid": "47e9e390efa04aff6f6d673275b772da", "score": "0.4550828", "text": "func (_KeepRandomBeaconOperator *KeepRandomBeaconOperatorTransactor) SubmitTicket(opts *bind.TransactOpts, ticket [32]byte) (*types.Transaction, error) {\n\treturn _KeepRandomBeaconOperator.contract.Transact(opts, \"submitTicket\", ticket)\n}", "title": "" }, { "docid": "7e48decc22b9de11ab51fd8d2a9abb6c", "score": "0.45489272", "text": "func IsWinningTicket(ctx context.Context, bs blockstore.Blockstore, ptv PowerTableView, st state.Tree,\n\tticket types.Signature, miner address.Address) (bool, error) {\n\n\ttotalPower, err := ptv.Total(ctx, st, bs)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"Couldn't get totalPower\")\n\t}\n\n\tminerPower, err := ptv.Miner(ctx, st, bs, miner)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"Couldn't get minerPower\")\n\t}\n\n\treturn CompareTicketPower(ticket, minerPower, totalPower), nil\n}", "title": "" }, { "docid": "514e68fabd593e6061afc28a64e95703", "score": "0.45486766", "text": "func (c *testRPCChain) LiveTickets() ([]chainhash.Hash, error) {\n\treturn c.liveTickets, c.liveTicketsErr\n}", "title": "" }, { "docid": "bc1d02ae337ccc13056313f840fa3431", "score": "0.45484805", "text": "func GetPhotonAuthenticationToken(settings *playfab.Settings, postData *GetPhotonAuthenticationTokenRequestModel, clientSessionTicket string) (*GetPhotonAuthenticationTokenResultModel, error) {\r\n if clientSessionTicket == \"\" {\n return nil, playfab.NewCustomError(\"clientSessionTicket should not be an empty string\", playfab.ErrorGeneric)\n }\r\n b, errMarshal := json.Marshal(postData)\r\n if errMarshal != nil {\r\n return nil, playfab.NewCustomError(errMarshal.Error(), playfab.ErrorMarshal)\r\n }\r\n\r\n sourceMap, err := playfab.Request(settings, b, \"/Client/GetPhotonAuthenticationToken\", \"X-Authentication\", clientSessionTicket)\r\n if err != nil {\r\n return nil, err\r\n }\r\n \r\n result := &GetPhotonAuthenticationTokenResultModel{}\r\n\r\n config := mapstructure.DecoderConfig{\r\n DecodeHook: playfab.StringToDateTimeHook,\r\n Result: result,\r\n }\r\n \r\n decoder, errDecoding := mapstructure.NewDecoder(&config)\r\n if errDecoding != nil {\r\n return nil, playfab.NewCustomError(errDecoding.Error(), playfab.ErrorDecoding)\r\n }\r\n \r\n errDecoding = decoder.Decode(sourceMap)\r\n if errDecoding != nil {\r\n return nil, playfab.NewCustomError(errDecoding.Error(), playfab.ErrorDecoding)\r\n }\r\n\r\n return result, nil\r\n}", "title": "" }, { "docid": "ecb1ea3a87f9d2f451176cb46bfd00d2", "score": "0.45409295", "text": "func (_CK *CKCallerSession) GetKitty(_id *big.Int) (struct {\n\tIsGestating bool\n\tIsReady bool\n\tCooldownIndex *big.Int\n\tNextActionAt *big.Int\n\tSiringWithId *big.Int\n\tBirthTime *big.Int\n\tMatronId *big.Int\n\tSireId *big.Int\n\tGeneration *big.Int\n\tGenes *big.Int\n}, error) {\n\treturn _CK.Contract.GetKitty(&_CK.CallOpts, _id)\n}", "title": "" }, { "docid": "79dde9400bc2b6ee257b6d0a275516e7", "score": "0.45325175", "text": "func CreateTicket(ctx *context.Context) {\n\tvar (\n\t\tbody = ctx.Query(\"body\")\n\t\ttitle = ctx.Query(\"title\")\n\t\temail = ctx.Query(\"email\")\n\t\townerIDs []uint\n\t)\n\n\tif ctx.Autorized() {\n\t\townerIDs = append(ownerIDs, ctx.User.ID)\n\t}\n\n\t_, err := models.Tickets.Create(title, body, email, ownerIDs...)\n\tif ctx.HasError(err) {\n\t\treturn\n\t}\n\n\tctx.Flash.Success(\"Тикет успешно создан!\")\n\tctx.Redirect(\"/support\")\n}", "title": "" }, { "docid": "2e2898173edc505855a89f95f411ef76", "score": "0.45257005", "text": "func (system *TicketingSystem) GenerateTicket(car *vehicle.Vehicle) (response string, err error) {\n\tslotNumber := system.Parkinglot.GetEmptySlot()\n\tif slotNumber == -1 {\n\t\treturn \"\", ErrorParkingLotFull\n\t} else {\n\t\tstatus, err := system.Parkinglot.Park(slotNumber, car)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif !status {\n\t\t\treturn \"\", ErrorInProcessing\n\t\t} else {\n\t\t\tnewEntry := ParkingMapEntry{\n\t\t\t\tSlotNumber: slotNumber + 1,\n\t\t\t\tColor: car.Color,\n\t\t\t\tRegistrationNumber: car.RegistrationNumber,\n\t\t\t}\n\t\t\tsystem.ParkingMap.Entry = append(system.ParkingMap.Entry, newEntry)\n\t\t\tsystem.ValidTickets = append(system.ValidTickets, *NewTicket(slotNumber+1, car.RegistrationNumber, car.Color))\n\t\t\treturn fmt.Sprintf(ResponseSlotAllocatedSuccessfully, slotNumber+1), nil\n\t\t}\n\t}\n}", "title": "" }, { "docid": "e2679a05c8d6066a88845b0180628c27", "score": "0.45198274", "text": "func (c *Extractor) GetAuth(req *http.Request) (auth.Subject, *models.Error) {\n\treturn c.RetSubj, c.RetErr\n}", "title": "" }, { "docid": "d03e0bbefe0c0525cdb3f9f29356128a", "score": "0.4490762", "text": "func (r *AccountsService) ProvisionAccountTicket(googleanalyticsadminv1alphaprovisionaccountticketrequest *GoogleAnalyticsAdminV1alphaProvisionAccountTicketRequest) *AccountsProvisionAccountTicketCall {\n\tc := &AccountsProvisionAccountTicketCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.googleanalyticsadminv1alphaprovisionaccountticketrequest = googleanalyticsadminv1alphaprovisionaccountticketrequest\n\treturn c\n}", "title": "" }, { "docid": "f5ba75e4bf9aa5c073f7d4182a222d78", "score": "0.4487892", "text": "func FindTicket(userName string, nonceStr string) error {\n\t_, err := collection().Find(context.Background(), map[string]string{\n \"username\": userName, \n \"nonce_str\": nonceStr,\n })\n return err\n}", "title": "" }, { "docid": "b39b72afd4908f307d8aadd24f38d00d", "score": "0.44870567", "text": "func TestCreateRevocationFromTicket(t *testing.T) {\n\tt.Parallel()\n\n\t// Default network parameters to use for tests.\n\tparams := chaincfg.RegNetParams()\n\n\t// Default header bytes for tests.\n\tprevHeaderBytes := hexToBytes(\"07000000dc02335daa073d293e1b150648f0444a60b9\" +\n\t\t\"c97604abd01e00000000000000003c449b2321c4bd0d1fa76ed59f80ebaf46f16cfb2d17\" +\n\t\t\"ba46948f09f21861095566482410a463ed49473c27278cd7a2a3712a3b19ff1f6225717d\" +\n\t\t\"3eb71cc2b5590100012c7312a3c30500050095a100000cf42418f1820a870300000020a1\" +\n\t\t\"0700091600005b32a55f5bcce31078832100007469943958002e00000000000000000000\" +\n\t\t\"0000000000000000000007000000\")\n\n\t// The following variables are derived from a mainnet ticket that was\n\t// purchased in block 135375 and revoked in block 140709.\n\tticketHash := mustParseHash(\"dad48ac8c59ee97d1a6fd04ad4f1c8392357a6ee78d39f\" +\n\t\t\"fc00fb467a0cdba695\")\n\tticketOut1 := &MinimalOutput{\n\t\tPkScript: hexToBytes(\"ba76a914097e847d49c6806f6933e806a350f43b97ac70d088a\" +\n\t\t\t\"c\"),\n\t\tValue: 4126629682,\n\t\tVersion: 0,\n\t}\n\tticketOut2 := &MinimalOutput{\n\t\tPkScript: hexToBytes(\"6a1e86c6da62556f5e21fbce3564b7374724d65f0cbb51c66d0\" +\n\t\t\t\"0000000800058\"),\n\t\tValue: 0,\n\t\tVersion: 0,\n\t}\n\tticketOut3 := &MinimalOutput{\n\t\tPkScript: hexToBytes(\"bd76a914000000000000000000000000000000000000000088a\" +\n\t\t\t\"c\"),\n\t\tValue: 0,\n\t\tVersion: 0,\n\t}\n\tticketOut4 := &MinimalOutput{\n\t\tPkScript: hexToBytes(\"6a1e7e8efe653b374ba7ad950c873e483fc53c5bafa9c1c439f\" +\n\t\t\t\"8000000000058\"),\n\t\tValue: 0,\n\t\tVersion: 0,\n\t}\n\tticketOut5 := &MinimalOutput{\n\t\tPkScript: hexToBytes(\"bd76a914000000000000000000000000000000000000000088a\" +\n\t\t\t\"c\"),\n\t\tValue: 0,\n\t\tVersion: 0,\n\t}\n\tticketMinOuts := []*MinimalOutput{\n\t\tticketOut1,\n\t\tticketOut2,\n\t\tticketOut3,\n\t\tticketOut4,\n\t\tticketOut5,\n\t}\n\trevocationHash := mustParseHash(\"46ae5f78174c6c6e3675d0bbfec27e25c40f3a119e\" +\n\t\t\"df9183b96261db5cda7a4f\")\n\trevocationTxFee := dcrutil.Amount(285000)\n\trevocationTxVersion := uint16(1)\n\n\t// With auto revocations enabled.\n\tautoRevocationsTxHash := mustParseHash(\"c8999b6e2544f339419cc5416f15e9b942c\" +\n\t\t\"fd6481246012d2da82f4594310e65\")\n\tautoRevocationsTxFee := dcrutil.Amount(0)\n\tautoRevocationsTxVersion := TxVersionAutoRevocations\n\n\t// Invalid script version.\n\tticketOutInvalidScriptVersion := &MinimalOutput{\n\t\tPkScript: hexToBytes(\"6a1e86c6da62556f5e21fbce3564b7374724d65f0cbb51c66d0\" +\n\t\t\t\"0000000800058\"),\n\t\tValue: 0,\n\t\tVersion: 1,\n\t}\n\tticketMinOutsInvalidScriptVersion := []*MinimalOutput{\n\t\tticketOut1,\n\t\tticketOutInvalidScriptVersion,\n\t\tticketOut3,\n\t\tticketOut4,\n\t\tticketOut5,\n\t}\n\n\t// Invalid ticket commitment amount.\n\tticketOutInvalidCommitmentAmt := &MinimalOutput{\n\t\tPkScript: hexToBytes(\"6a1e86c6da62556f5e21fbce3564b7374724d65f0cbbfffffff\" +\n\t\t\t\"fffffffff0058\"),\n\t\tValue: 0,\n\t\tVersion: 0,\n\t}\n\tticketMinOutsInvalidCommitmentAmt := []*MinimalOutput{\n\t\tticketOut1,\n\t\tticketOutInvalidCommitmentAmt,\n\t\tticketOut3,\n\t\tticketOut4,\n\t\tticketOut5,\n\t}\n\n\t// No fee limit.\n\tticketOut2NoFeeLimit := &MinimalOutput{\n\t\tPkScript: hexToBytes(\"6a1e86c6da62556f5e21fbce3564b7374724d65f0cbb51c66d0\" +\n\t\t\t\"0000000800000\"),\n\t\tValue: 0,\n\t\tVersion: 0,\n\t}\n\tticketMinOutsNoFeeLimit := []*MinimalOutput{\n\t\tticketOut1,\n\t\tticketOut2NoFeeLimit,\n\t\tticketOut3,\n\t\tticketOut4,\n\t\tticketOut5,\n\t}\n\n\ttests := []struct {\n\t\tname string\n\t\tticketHash *chainhash.Hash\n\t\tticketMinOuts []*MinimalOutput\n\t\trevocationTxFee dcrutil.Amount\n\t\trevocationTxVersion uint16\n\t\tprevHeaderBytes []byte\n\t\tisAutoRevocationsEnabled bool\n\t\twantTxHash chainhash.Hash\n\t\twantErr error\n\t}{{\n\t\tname: \"valid with P2SH and P2PKH outputs\",\n\t\tticketHash: ticketHash,\n\t\tticketMinOuts: ticketMinOuts,\n\t\trevocationTxFee: revocationTxFee,\n\t\trevocationTxVersion: revocationTxVersion,\n\t\tprevHeaderBytes: prevHeaderBytes,\n\t\twantTxHash: *revocationHash,\n\t}, {\n\t\tname: \"valid with P2SH and P2PKH outputs (auto revocations \" +\n\t\t\t\"enabled\",\n\t\tticketHash: ticketHash,\n\t\tticketMinOuts: ticketMinOuts,\n\t\trevocationTxFee: autoRevocationsTxFee,\n\t\trevocationTxVersion: autoRevocationsTxVersion,\n\t\tprevHeaderBytes: prevHeaderBytes,\n\t\tisAutoRevocationsEnabled: true,\n\t\twantTxHash: *autoRevocationsTxHash,\n\t}, {\n\t\tname: \"invalid ticket minimal outputs\",\n\t\tticketHash: ticketHash,\n\t\tticketMinOuts: nil,\n\t\trevocationTxFee: revocationTxFee,\n\t\trevocationTxVersion: revocationTxVersion,\n\t\twantErr: ErrSStxNoOutputs,\n\t}, {\n\t\tname: \"invalid script version\",\n\t\tticketHash: ticketHash,\n\t\tticketMinOuts: ticketMinOutsInvalidScriptVersion,\n\t\trevocationTxFee: revocationTxFee,\n\t\trevocationTxVersion: revocationTxVersion,\n\t\tprevHeaderBytes: prevHeaderBytes,\n\t\twantErr: ErrSStxInvalidOutputs,\n\t}, {\n\t\tname: \"invalid ticket commitment amount\",\n\t\tticketHash: ticketHash,\n\t\tticketMinOuts: ticketMinOutsInvalidCommitmentAmt,\n\t\trevocationTxFee: revocationTxFee,\n\t\trevocationTxVersion: revocationTxVersion,\n\t\tprevHeaderBytes: prevHeaderBytes,\n\t\twantErr: ErrSStxBadCommitAmount,\n\t}, {\n\t\tname: \"invalid fee\",\n\t\tticketHash: ticketHash,\n\t\tticketMinOuts: ticketMinOuts,\n\t\trevocationTxFee: 16777217,\n\t\trevocationTxVersion: revocationTxVersion,\n\t\twantErr: ErrSSRtxInvalidFee,\n\t}, {\n\t\tname: \"invalid fee (no fee limit)\",\n\t\tticketHash: ticketHash,\n\t\tticketMinOuts: ticketMinOutsNoFeeLimit,\n\t\trevocationTxFee: revocationTxFee,\n\t\trevocationTxVersion: revocationTxVersion,\n\t\twantErr: ErrSSRtxInvalidFee,\n\t}, {\n\t\tname: \"invalid fee (auto revocations enabled)\",\n\t\tticketHash: ticketHash,\n\t\tticketMinOuts: ticketMinOuts,\n\t\trevocationTxFee: revocationTxFee,\n\t\trevocationTxVersion: revocationTxVersion,\n\t\tisAutoRevocationsEnabled: true,\n\t\twantErr: ErrSSRtxInvalidFee,\n\t}, {\n\t\tname: \"invalid tx version (auto revocations enabled)\",\n\t\tticketHash: ticketHash,\n\t\tticketMinOuts: ticketMinOuts,\n\t\trevocationTxFee: autoRevocationsTxFee,\n\t\trevocationTxVersion: revocationTxVersion,\n\t\tisAutoRevocationsEnabled: true,\n\t\twantErr: ErrSSRtxInvalidTxVersion,\n\t}}\n\n\tfor _, test := range tests {\n\t\t// Create a revocation transaction with the given test parameters.\n\t\trevocationTx, err := CreateRevocationFromTicket(test.ticketHash,\n\t\t\ttest.ticketMinOuts, test.revocationTxFee, test.revocationTxVersion,\n\t\t\tparams, test.prevHeaderBytes, test.isAutoRevocationsEnabled)\n\n\t\t// Validate that the expected error was returned for negative tests.\n\t\tif test.wantErr != nil {\n\t\t\tif !errors.Is(err, test.wantErr) {\n\t\t\t\tt.Errorf(\"%q: mismatched error -- got %T, want %T\", test.name, err,\n\t\t\t\t\ttest.wantErr)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\t// Validate that an unexpected error was not returned.\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"%q: unexpected error creating revocation: %v\", test.name, err)\n\t\t}\n\n\t\t// Validate that the revocation transaction was created correctly.\n\t\terr = CheckSSRtx(revocationTx)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"%q: unexpected error checking revocation: %v\", test.name, err)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Validate the revocation transaction version.\n\t\tif revocationTx.Version != test.revocationTxVersion {\n\t\t\tt.Errorf(\"%q: mismatched tx version -- got %d, want %d\", test.name,\n\t\t\t\trevocationTx.Version, test.revocationTxVersion)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Validate that the resulting revocation transaction hash matches what is\n\t\t// expected.\n\t\trevocationTxHash := revocationTx.TxHash()\n\t\tif revocationTxHash != test.wantTxHash {\n\t\t\tt.Errorf(\"%q: mismatched tx hash -- got %v, want %v\", test.name,\n\t\t\t\trevocationTxHash, test.wantTxHash)\n\t\t\tcontinue\n\t\t}\n\t}\n}", "title": "" }, { "docid": "512d462217487d586daff37465684adb", "score": "0.44809118", "text": "func (ec EthChain) buildAuthTransactor() (*bind.TransactOpts, error) {\r\n\tprivKey, err := crypto.HexToECDSA(ec.Key)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\r\n\tauth := bind.NewKeyedTransactor(privKey)\r\n\r\n\tnextNonce, err := ec.Client.PendingNonceAt(context.Background(), auth.From)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\r\n\tauth.GasLimit = ec.GasLimit\r\n\tauth.GasPrice = ec.GasPrice\r\n\tauth.Nonce = big.NewInt(int64(nextNonce))\r\n\r\n\treturn auth, nil\r\n}", "title": "" }, { "docid": "9b1cc298aa2655d3e21579c984f7d48c", "score": "0.4469792", "text": "func (p *dcrdataPlugin) cmdTicketPool(payload string) (string, error) {\n\t// Decode payload\n\tvar tp dcrdata.TicketPool\n\terr := json.Unmarshal([]byte(payload), &tp)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Get the ticket pool\n\ttickets, err := p.ticketPool(tp.BlockHash)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"ticketPool: %v\", err)\n\t}\n\n\t// Prepare reply\n\ttpr := dcrdata.TicketPoolReply{\n\t\tTickets: tickets,\n\t}\n\treply, err := json.Marshal(tpr)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn string(reply), nil\n}", "title": "" }, { "docid": "f19c0f00ecb4a0a93db8236ab1533ca2", "score": "0.4462785", "text": "func (scheme *DefaultURLScheme) RestGrantingTicket() (*url.URL, error) {\n\treturn scheme.createURL(scheme.RestEndpoint)\n}", "title": "" }, { "docid": "b5ff873ef51ce7acccfdcf8ea04717f7", "score": "0.446192", "text": "func (_CK *CKSession) GetKitty(_id *big.Int) (struct {\n\tIsGestating bool\n\tIsReady bool\n\tCooldownIndex *big.Int\n\tNextActionAt *big.Int\n\tSiringWithId *big.Int\n\tBirthTime *big.Int\n\tMatronId *big.Int\n\tSireId *big.Int\n\tGeneration *big.Int\n\tGenes *big.Int\n}, error) {\n\treturn _CK.Contract.GetKitty(&_CK.CallOpts, _id)\n}", "title": "" }, { "docid": "c8158bcb063eda8fd1b52c1f3353bed5", "score": "0.4444682", "text": "func (this OauthApplicationCreateAuditEntry) GetActorLogin() *string { return this.ActorLogin }", "title": "" }, { "docid": "d8c4c9042dff4220a38666cd6f65462d", "score": "0.44359085", "text": "func (auth *Auth) GetAuth() *AuthParameters {\n\thr := md5.New()\n\thr.Write([]byte(auth.ts + auth.privateKey + auth.publicKey))\n\thash := hex.EncodeToString(hr.Sum(nil))\n\n\treturn &AuthParameters{\n\t\tApiKey: auth.publicKey,\n\t\tTs: auth.ts,\n\t\tHash: hash,\n\t}\n}", "title": "" }, { "docid": "63c216088f49da0441154f06a01da1a2", "score": "0.44306517", "text": "func (this OrgInviteToBusinessAuditEntry) GetActorLogin() *string { return this.ActorLogin }", "title": "" }, { "docid": "b2ff610017b72f3434ff8e23cf59b43b", "score": "0.44259202", "text": "func (a *App) mailTicketHdlf(w http.ResponseWriter, r *http.Request) {\n\n\t// Only admin+ are authorized !\n\tss := a.Authorize(w, r, common.RoleAdmin)\n\n\tif ss == nil {\n\t\treturn\n\t}\n\n\tif len(ss.TicketID) == 0 || len(ss.Mail) == 0 {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\ttxt := \"A ticket has been prepared for you, please visit : \"\n\ttxt += a.CreateAbsoluteURL(a.cnf.API.Ticket) +\n\t\t\"?\" + a.cnf.API.QueryParam.Ticket + \"=\" +\n\t\turl.QueryEscape(ss.TicketID)\n\n\thtml := a.textToHTML(txt)\n\n\tgo a.ml.Send(a.cnf.MailSender, ss.Mail, \"Your ticket ...\", txt, html)\n\tfmt.Fprint(w, \"OK, mail sent to \", ss.Mail)\n\treturn\n\n}", "title": "" }, { "docid": "946b67f19bef638c5d7179e7523c8c57", "score": "0.44222048", "text": "func (this OrgOauthAppAccessApprovedAuditEntry) GetActorLogin() *string { return this.ActorLogin }", "title": "" }, { "docid": "3a716614c1c2b139ca982d03ad6eddcd", "score": "0.44150314", "text": "func (this TeamAddMemberAuditEntry) GetActorLogin() *string { return this.ActorLogin }", "title": "" }, { "docid": "23bfb7e8744304fb64e8f8c10b4f23d0", "score": "0.44145387", "text": "func GetAssertion(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tusername := vars[\"name\"]\n\ttimeout := 60000\n\n\tu, err := url.Parse(r.Referer())\n\n\tuser, rp, err := GetUserAndRelyingParty(username, u.Hostname())\n\tif err != nil {\n\t\tfmt.Println(\"Couldn't Find the User or RP, most likely the User:\", err)\n\t\tapi.JSONResponse(w, \"Couldn't Find User\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tsd, err := models.CreateNewSession(&user, &rp, \"att\")\n\tif err != nil {\n\t\tfmt.Println(\"Something went wrong creating session data:\", err)\n\t\tapi.JSONResponse(w, \"Session Data Creation Error\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tcreds, err := models.GetCredentialsForUserAndRelyingParty(&user, &rp)\n\tif err != nil {\n\t\tfmt.Println(\"No Credential Record Found:\", err)\n\t\tapi.JSONResponse(w, \"Session Data Creation Error\", http.StatusNotFound)\n\t\treturn\n\t}\n\n\tsession, _ := store.Get(r, \"assertion-session\")\n\tsession.Values[\"session_id\"] = sd.ID\n\tsession.Save(r, w)\n\n\ttype AllowedCredential struct {\n\t\tCredID string `json:\"id\"`\n\t\tType string `json:\"type\"`\n\t\tTransports []string `json:\"transports\"`\n\t}\n\n\ttype PublicKeyCredentialOptions struct {\n\t\tChallenge []byte `json:\"challenge,omitempty\"`\n\t\tTimeout int `json:\"timeout,omitempty\"`\n\t\tAllowList []AllowedCredential `json:\"allowCredentials,omitempty\"`\n\t\tRPID string `json:\"rpId,omitempty\"`\n\t}\n\n\tif err != nil {\n\t\tfmt.Println(\"Error Decoding Credential ID:\", err)\n\t\tapi.JSONResponse(w, \"Error Decoding Credential ID\", http.StatusNotFound)\n\t\treturn\n\t}\n\n\tvar acs []AllowedCredential\n\n\tfor _, cred := range creds {\n\t\tac := AllowedCredential{\n\t\t\tCredID: cred.CredID,\n\t\t\tType: \"public-key\", // This should always be type 'public-key' for now\n\t\t\tTransports: []string{\"usb\", \"nfc\", \"ble\"},\n\t\t}\n\t\tacs = append(acs, ac)\n\t}\n\n\tassertionResponse := PublicKeyCredentialOptions{\n\t\tChallenge: sd.Challenge,\n\t\tTimeout: timeout,\n\t\tAllowList: acs,\n\t\tRPID: rp.ID,\n\t}\n\n\tapi.JSONResponse(w, assertionResponse, http.StatusOK)\n}", "title": "" }, { "docid": "4ec6a0e6d046016eac9fd48121c00031", "score": "0.4413804", "text": "func (this PrivateRepositoryForkingEnableAuditEntry) GetActorLogin() *string { return this.ActorLogin }", "title": "" }, { "docid": "a30d701a6a9266c767be60de79568c8c", "score": "0.44099656", "text": "func (this TeamAddRepositoryAuditEntry) GetActorLogin() *string { return this.ActorLogin }", "title": "" }, { "docid": "d68d373843a35796240b813fcc202c56", "score": "0.4409762", "text": "func FetchAuth(m IMemCash, authD *AccessDetails) (primitive.ObjectID, error) {\n\tuserid, err := m.GetKey(authD.TokenUUID)\n\tif err != nil {\n\t\treturn primitive.NilObjectID, err\n\t}\n\tuserID, _ := primitive.ObjectIDFromHex(userid)\n\treturn userID, nil\n}", "title": "" }, { "docid": "87e2fceb9f5421efdbbcc306e8e0a77b", "score": "0.44038117", "text": "func (k *KBPKIClient) GetTeamTLFCryptKeys(\n\tctx context.Context, tid keybase1.TeamID, desiredKeyGen kbfsmd.KeyGen,\n\toffline keybase1.OfflineAvailability) (\n\tmap[kbfsmd.KeyGen]kbfscrypto.TLFCryptKey, kbfsmd.KeyGen, error) {\n\tteamInfo, err := k.serviceOwner.KeybaseService().LoadTeamPlusKeys(\n\t\tctx, tid, tlf.Unknown, desiredKeyGen, keybase1.UserVersion{},\n\t\tkbfscrypto.VerifyingKey{}, keybase1.TeamRole_NONE, offline)\n\tif err != nil {\n\t\treturn nil, 0, err\n\t}\n\treturn teamInfo.CryptKeys, teamInfo.LatestKeyGen, nil\n}", "title": "" }, { "docid": "cf5e444eb97959c2ef977726ee5171cd", "score": "0.43950704", "text": "func (h *Handler) Ticketcreate(w http.ResponseWriter, r *http.Request) {\n\n\t//ReadAll reads from response until an error or EOF and returns the data it read.\n\tbodyVal, err := ioutil.ReadAll(r.Body)\n\n\tif err != nil {\n\t\tlogger.Error(\"Error Occured with Reading Body\")\n\t\tlogger.Error(err.Error())\n\t}\n\n\tbodyValStrg := string(bodyVal)\n\n\t//Function call to create ticket and get the response\n\tcreatorOfTickets(bodyValStrg, w, r)\n\n\t/*var jsonReturn = []byte(jsonReturnString)\n\t //Decode JSON response\n\t jsonRetVal, _ := json.Marshal(jsonReturn)\n\t var byteArr []byte\n\t //Display the response\n\t base64.StdEncoding.Decode(byteArr, jsonRetVal)\n\t fmt.Fprintf(w, string(byteArr))\n\t //json.NewEncoder(w).Encode(Tick)*/\n}", "title": "" }, { "docid": "88be19c9da33512addf172bd78144e3c", "score": "0.43929672", "text": "func GetAuthInfo(ctx context.Context, c client.Client, mg resource.Managed) (token string, err error) {\n\tpc := &v1alpha1.ProviderConfig{}\n\tt := resource.NewProviderConfigUsageTracker(c, &v1alpha1.ProviderConfigUsage{})\n\tif err := t.Track(ctx, mg); err != nil {\n\t\treturn \"\", err\n\t}\n\tif err := c.Get(ctx, types.NamespacedName{Name: mg.GetProviderConfigReference().Name}, pc); err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// NOTE(muvaf): When we implement the workload identity, we will only need to\n\t// return a different type of option.ClientOption, which is WithTokenSource().\n\tif s := pc.Spec.Credentials.Source; s != xpv1.CredentialsSourceSecret {\n\t\treturn \"\", errors.Errorf(\"unsupported credentials source %q\", s)\n\t}\n\n\tref := pc.Spec.Credentials.SecretRef\n\tif ref == nil {\n\t\treturn \"\", errors.New(\"no credentials secret reference was provided\")\n\t}\n\n\ts := &v1.Secret{}\n\tif err := c.Get(ctx, types.NamespacedName{Name: ref.Name, Namespace: ref.Namespace}, s); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(s.Data[ref.Key]), nil\n}", "title": "" }, { "docid": "753d2f92f1005fab5ebb77630549fc9e", "score": "0.43928432", "text": "func (p *PCE) getAuthToken(username, password string) (Authentication, APIResponse, error) {\n\n\tvar api APIResponse\n\tvar err error\n\tvar auth Authentication\n\n\t// Build the API URL\n\tfqdn := p.cleanFQDN()\n\tif strings.Contains(p.cleanFQDN(), \"illum.io\") && !strings.Contains(p.cleanFQDN(), \"demo\") {\n\t\tfqdn = \"login.illum.io\"\n\t}\n\tif p.FQDN == \"xpress1.ilabs.io\" {\n\t\tfqdn = \"loginpce-dfdev1.ilabs.io\"\n\t}\n\n\t// If there is an env variable set, use that\n\tif os.Getenv(\"ILLUMIO_LOGIN_SERVER\") != \"\" {\n\t\tfqdn = os.Getenv(\"ILLUMIO_LOGIN_SERVER\")\n\t}\n\n\tapiURL, err := url.Parse(\"https://\" + fqdn + \":\" + strconv.Itoa(p.Port) + \"/api/v2/login_users/authenticate\")\n\tif err != nil {\n\t\treturn auth, api, fmt.Errorf(\"authenticate error - %s\", err)\n\t}\n\tq := apiURL.Query()\n\tq.Set(\"pce_fqdn\", p.FQDN)\n\tapiURL.RawQuery = q.Encode()\n\n\t// Call the API - Use a temp PCE object to leverage http method\n\ttempPCE := PCE{DisableTLSChecking: p.DisableTLSChecking, User: username, Key: password}\n\tapi, err = tempPCE.httpReq(\"POST\", apiURL.String(), nil, false, map[string]string{\"Content-Type\": \"application/json\"})\n\tif err != nil {\n\t\treturn auth, api, fmt.Errorf(\"authenticate error - with login server %s - %s\", fqdn, err)\n\t}\n\n\t// Marshal the response\n\tjson.Unmarshal([]byte(api.RespBody), &auth)\n\n\treturn auth, api, nil\n}", "title": "" }, { "docid": "8e281ebd05180fbd4568a41a034e901f", "score": "0.43915248", "text": "func (_CK *CKCaller) GetKitty(opts *bind.CallOpts, _id *big.Int) (struct {\n\tIsGestating bool\n\tIsReady bool\n\tCooldownIndex *big.Int\n\tNextActionAt *big.Int\n\tSiringWithId *big.Int\n\tBirthTime *big.Int\n\tMatronId *big.Int\n\tSireId *big.Int\n\tGeneration *big.Int\n\tGenes *big.Int\n}, error) {\n\tret := new(struct {\n\t\tIsGestating bool\n\t\tIsReady bool\n\t\tCooldownIndex *big.Int\n\t\tNextActionAt *big.Int\n\t\tSiringWithId *big.Int\n\t\tBirthTime *big.Int\n\t\tMatronId *big.Int\n\t\tSireId *big.Int\n\t\tGeneration *big.Int\n\t\tGenes *big.Int\n\t})\n\tout := ret\n\terr := _CK.contract.Call(opts, out, \"getKitty\", _id)\n\treturn *ret, err\n}", "title": "" }, { "docid": "ea12d5be24167f154d7f651ea7cfa3cd", "score": "0.43798634", "text": "func selectOwnedTickets(w *Wallet, dbtx walletdb.ReadTx, tickets []*chainhash.Hash) []*chainhash.Hash {\n\tvar owned []*chainhash.Hash\n\tfor _, ticketHash := range tickets {\n\t\tif w.txStore.OwnTicket(dbtx, ticketHash) || w.stakeMgr.OwnTicket(ticketHash) {\n\t\t\towned = append(owned, ticketHash)\n\t\t}\n\t}\n\treturn owned\n}", "title": "" }, { "docid": "d2c7ad22c030426aa7558eeabb1d29f7", "score": "0.4377044", "text": "func (pA *TK) GetPlainAuth(identity, username, password, host string) smtp.Auth {\n\treturn &PlainAuth{identity, username, password, host}\n}", "title": "" }, { "docid": "0ddbbfde883c64ce3028f17ad04c0018", "score": "0.43760917", "text": "func stakeTicketHash(purchaseHeight int32, ticketNum uint8) chainhash.Hash {\n\tvar b [8]byte\n\tbinary.LittleEndian.PutUint32(b[:], uint32(purchaseHeight))\n\tbinary.LittleEndian.PutUint32(b[4:], uint32(ticketNum))\n\treturn chainhash.HashH(b[:])\n}", "title": "" }, { "docid": "ad5146a85e68a36c15bbd95f4f7d78c5", "score": "0.4374607", "text": "func (r *CreateTicketRequest) AsTicket() *models.Ticket {\n\treturn &models.Ticket{\n\t\tIssuer: r.Issuer,\n\t\tOwner: r.Owner,\n\t\tSubject: r.Subject,\n\t\tContent: r.Content,\n\t\tMetadata: r.Metadata,\n\t\tImportanceLevel: r.ImportanceLevel,\n\t}\n}", "title": "" } ]
402d03bfea2444aee5ca6ca1955eaf79
Follower follows a followee. If the operation is invalid, it should be a noop.
[ { "docid": "68ad1ba5e4d1768dbc8994314e58461a", "score": "0.6535889", "text": "func (this *Twitter) Follow(followerId int, followeeId int) {\n\tif followerId == followeeId {\n\t\treturn\n\t}\n\tif v, ok := this.followerMap[followerId]; ok {\n\t\tfor i := 0; i < len(v); i++ {\n\t\t\tif followeeId == v[i] {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tthis.followerMap[followerId] = append(v, followeeId)\n\t\treturn\n\t}\n\tthis.followerMap[followerId] = []int{followeeId}\n}", "title": "" } ]
[ { "docid": "a15b847b7355a6e50cb487b991fb90d2", "score": "0.7315632", "text": "func (s *RelationshipsService) Follow(userId string) (*Relationship, error) {\n\treturn relationshipAction(s, userId, \"follow\", \"POST\")\n}", "title": "" }, { "docid": "20f1bdc57ffa8ea96852091218c35ab4", "score": "0.71832544", "text": "func (t *Twitter) Follow(followerId int, followeeId int) {\n\t// 若 follower 不存在则创建\n\tif _, ok := t.idToUser[followerId]; !ok {\n\t\tuser := NewUser(followerId)\n\t\tt.idToUser[followerId] = &user\n\t}\n\t// 若 followee 不存在则创建\n\tif _, ok := t.idToUser[followeeId]; !ok {\n\t\tuser := NewUser(followeeId)\n\t\tt.idToUser[followeeId] = &user\n\t}\n\tt.idToUser[followerId].follow(followeeId)\n}", "title": "" }, { "docid": "515332db985924d7a2dc104825be610d", "score": "0.70765275", "text": "func (this *Twitter) Follow(followerId int, followeeId int) {\n\tif followerId == followeeId {\n\t\treturn\n\t}\n\tfollower, followerExist := this.users[followerId]\n\tfollowee, followeeExist := this.users[followeeId]\n\tif !followerExist {\n\t\tfollower = &user{\n\t\t\tuserId: followerId,\n\t\t\ttweets: []tweet{},\n\t\t\tfollowees: make(map[int]*user),\n\t\t}\n\t\tthis.users[followerId] = follower\n\t}\n\tif !followeeExist {\n\t\tfollowee = &user{\n\t\t\tuserId: followeeId,\n\t\t\ttweets: []tweet{},\n\t\t\tfollowees: make(map[int]*user),\n\t\t}\n\t\tthis.users[followeeId] = followee\n\t}\n\tfollower.followees[followee.userId] = followee\n}", "title": "" }, { "docid": "15c3c23df4185dd02f61a272cda68dac", "score": "0.69767666", "text": "func (this *Twitter1) Follow(followerId int, followeeId int) {\n\tkey:=strconv.Itoa(followerId)+\" \"+strconv.Itoa(followeeId)\n\tif !this.checkFollowed[key]{\n\t\t//关注关系更新\n\t\tthis.checkFollowed[key]=true\n\t\tthis.follower[followerId]=append(this.follower[followerId],followeeId)\n\t}\n\n}", "title": "" }, { "docid": "c42b1e34c09eb9351f35a993d706fb28", "score": "0.6920343", "text": "func (this *Twitter) Follow(followerId int, followeeId int) {\n\tthis.newUser(followerId)\n\tthis.newUser(followeeId)\n\tthis.follow[followerId][followeeId] = struct{}{}\n}", "title": "" }, { "docid": "f47c67e9b4df0c3e02a0fb7cc8c38476", "score": "0.6907447", "text": "func (c *Client) Follow(ctx context.Context, ids []string) error {\n\treturn nil\n}", "title": "" }, { "docid": "183e03a704e5e6cbed45687bac5ed43a", "score": "0.68739873", "text": "func (this *Twitter) Follow(followerId int, followeeId int) {\n\n\tif followerId == followeeId {\n\t\tthis.IsFollowMy[followerId] = true\n\t}\n\n\t// 下面是判断这人是否关注了,如果已经关注了,那么就不再关注了\n\tvar isFed bool\n\n\tfor _,v := range this.Follows[followerId] {\n\t\tif v == followeeId {\n\t\t\tisFed = true\n\t\t}\n\t}\n\tif !isFed {\n\t\tthis.Follows[followerId] = append(this.Follows[followerId],followeeId)\n\t}\n\n}", "title": "" }, { "docid": "1243f885f15e0e7ca9bbc4ee9f3fcbb7", "score": "0.6823522", "text": "func Follow(UserId, FollowedPeerUserId int) int {\n\tif UserId == FollowedPeerUserId || UserId < 1 || FollowedPeerUserId < 1 {\n\t\treturn 0\n\t}\n\n\t//todo add if blocked\n\n\tflm := x.Followed{\n\t\tId: helper.NanoRowIdSeq(),\n\t\tUserId: UserId,\n\t\tFollowedUserId: FollowedPeerUserId,\n\t\tCreatedTime: helper.TimeNow(),\n\t}\n\n\terr := flm.Insert(base.DB)\n\n\tif err == nil {\n\t\tmemcache_service.AddToUserFollwings(UserId, FollowedPeerUserId)\n\t\tCounter.UpdateUserFollowingCounts(UserId, 1)\n\t\tCounter.UpdateUserFollowersCounts(FollowedPeerUserId, 1)\n\n\t\thash := hashFollowed(UserId, FollowedPeerUserId)\n\t\tevent := x.Event{\n\t\t\tByUserId: UserId,\n\t\t\tPeerUserId: FollowedPeerUserId,\n\t\t\tActionId: helper.NextRowsSeqId(),\n\t\t\tMurmur64Hash: hash,\n\t\t}\n\t\tevent_service.SaveEvent(event_service.FOLLOWED_USER_EVENT, event)\n\n\t\t//Notify_OnFollowed(ProfileUserId, FollowedPeerUserId, flm.Id)\n\t\t//Action_OnFollowed(ProfileUserId, FollowedPeerUserId, flm.Id)\n\t\treturn 1\n\t}\n\treturn 0\n}", "title": "" }, { "docid": "53fd16508a54956ac5da1bc6932cd7dd", "score": "0.6818105", "text": "func (f *LogFollower) Follow() error {\n\tf.startOpt = stan.StartAt(pb.StartPosition_NewOnly)\n\n\tif f.StartSeq != 0 {\n\t\tf.startOpt = stan.StartAtSequence(f.StartSeq)\n\t} else if f.DeliverLast == true {\n\t\tlog.Info(\"Subscribing to only most recent\")\n\t\tf.startOpt = stan.StartWithLastReceived()\n\t} else if f.DeliverAll == true {\n\t\tlog.Print(\"subscribing with DeliverAllAvailable\")\n\t\tf.startOpt = stan.DeliverAllAvailable()\n\t} else if f.StartDelta != \"\" {\n\t\tago, err := time.ParseDuration(f.StartDelta)\n\t\tif err != nil {\n\t\t\tf.stanConn.Close()\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tf.startOpt = stan.StartAtTimeDelta(ago)\n\t}\n\n\terr := f.subscribe()\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n\n\tgo f.manageConnection()\n\n\tgo f.reportLag()\n\n\tgo f.manageBatchTimeout()\n\n\treturn nil\n}", "title": "" }, { "docid": "797defb0b839e882030dc52bb7ab963e", "score": "0.6808434", "text": "func (u *User)Follow(p *User){\n\tConn.Do(\"ZADD\",\"followers:\"+p.Id,time.Now().Unix(),u.Id)\n\tConn.Do(\"ZADD\",\"following:\"+u.Id,time.Now().Unix(),p.Id)\n}", "title": "" }, { "docid": "1756889b5438635d157bda1d7f1b61c0", "score": "0.6774473", "text": "func (this *Twitter) Follow(followerId int, followeeId int) {\n \n}", "title": "" }, { "docid": "1756889b5438635d157bda1d7f1b61c0", "score": "0.6774473", "text": "func (this *Twitter) Follow(followerId int, followeeId int) {\n \n}", "title": "" }, { "docid": "de64a4517b4cfcea4272b44995a65899", "score": "0.67640865", "text": "func (s *UserStore) Follow(a *model.User, b *model.User) error {\n\treturn s.db.Model(a).Association(\"Follows\").Append(b).Error\n}", "title": "" }, { "docid": "386ece72a0960792ea63b7efb3cdfa2e", "score": "0.6761294", "text": "func (t *Twitter) Follow(userFollower, userToFollow string) {\n\tw := 0\n\tfor i := 0; i < len(t.users); i++ {\n\t\tif t.users[i].User == userToFollow {\n\t\t\tfor j := 0; j < len(t.users); j++ {\n\t\t\t\tif t.users[j].User == userFollower {\n\t\t\t\t\tfor k := 0; k < len(t.users[j].IFollowThisUsers); k++ {\n\t\t\t\t\t\tif t.users[j].IFollowThisUsers[k].User == t.users[i].User {\n\t\t\t\t\t\t\tw++\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif w == 0 {\n\t\t\t\t\t\tt.users[j].IFollowThisUsers = append(t.users[j].IFollowThisUsers, t.users[i])\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "517d543b8f2a743d71f2819ac1010842", "score": "0.6722382", "text": "func (u Users) Follow(userID, followerID uint64) error {\n\tstatement, err := u.db.Query(\n\t\t\"INSERT INTO followers (user_id, follower_id) VALUES ($1, $2) ON CONFLICT DO NOTHING\",\n\t\tuserID,\n\t\tfollowerID,\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer statement.Close()\n\n\treturn nil\n}", "title": "" }, { "docid": "bb427b1740de60bbad90b56a4ba38c81", "score": "0.668276", "text": "func (user *UserInfo) Follow(newFollow *UserInfo) bool {\n user.mut.Lock()\n newFollow.mut.Lock()\n defer user.mut.Unlock()\n defer newFollow.mut.Unlock()\n if newFollow == nil || user.Following[newFollow.Username] {\n return false\n }\n newFollow.FollowedBy = append(newFollow.FollowedBy, user.Username)\n user.Following[newFollow.Username] = true\n return true\n}", "title": "" }, { "docid": "602a15165c84d5d814ed88e789fcf83b", "score": "0.6679674", "text": "func (uc *UserController) Follow(w http.ResponseWriter, r *http.Request) {\n\tfollowRequest := DecodeFollowRequest(r.Body)\n\tvar user *models.User\n\tif err := uc.users.FindId(followRequest.User1).One(&user); err != nil {\n\t\tlog.Fatal(\"Fatal Error finding user in Follow method\", err.Error())\n\t}\n\tif errors := user.Follow(followRequest.User2, uc.users); errors != nil {\n\t\tSendAsJSON(w, false, errors)\n\t\treturn\n\t}\n\tuser.Populate(uc.users)\n\tSendAsJSON(w, true, user)\n\n}", "title": "" }, { "docid": "36859a1205bef0904a838628be4613d3", "score": "0.6672237", "text": "func follow(user string) {\n\tpreventReachingLimit()\n\t_, _, err := client.Friendships.Create(&twitter.FriendshipCreateParams{\n\t\tScreenName: user,\n\t\tFollow: newTrue(),\n\t})\n\tlogError(err)\n}", "title": "" }, { "docid": "b29435875b258727be0057c6ea105622", "score": "0.6671092", "text": "func (this *Twitter) Follow(followerId int, followeeId int) {\n\tif followeeId == followerId {\n\t\treturn\n\t}\n\tf, ok := this.followers[followerId]\n\tif ok {\n\t\tf[followeeId] = true\n\t} else {\n\t\tthis.followers[followerId] = make(map[int]bool)\n\t\tthis.followers[followerId][followeeId] = true\n\t}\n}", "title": "" }, { "docid": "8025db9d90d07c2ccdad456a1c7e2328", "score": "0.66497064", "text": "func (this *Twitter) Follow(followerId int, followeeId int) {\n\tif followeeId == followerId {\n\t\treturn\n\t}\n\tfollower := this.followMap[followerId]\n\tif follower == nil {\n\t\tthis.followMap[followerId] = make(map[int]bool)\n\t\tfollower = this.followMap[followerId]\n\t}\n\tfollower[followeeId] = true\n}", "title": "" }, { "docid": "b0152f26b3c017dcf9f52da85ebb6af0", "score": "0.6633804", "text": "func (this *Twitter) Follow(followerId int, followeeId int) {\n\tn := len(this.followee[followerId])\n\tif n == 0 {\n\t\tthis.followee[followerId] = []int{followeeId}\n\t\treturn\n\t}\n\tfor i := 0; i < n; i++ {\n\t\tif this.followee[followerId][i] == followeeId {\n\t\t\treturn\n\t\t}\n\t}\n\tthis.followee[followerId] = append(this.followee[followerId], followeeId)\n}", "title": "" }, { "docid": "b721fedd3c10f6a6fc7db14c54060b29", "score": "0.66013104", "text": "func (this *Twitter) Follow(followerId int, followeeId int) {\n\tif followeeId == followerId {\n\t\treturn\n\t}\n\tif _, ok := this.follow[followerId]; !ok {\n\t\tthis.follow[followerId] = map[int]bool{}\n\t}\n\tthis.follow[followerId][followeeId] = true\n}", "title": "" }, { "docid": "a84aa89516e5149e7fd4cf7c5461c6de", "score": "0.6547417", "text": "func (t *Tracker) Follow(id string) error {\n\tlog.Debug(\"attempting to follow \" + id)\n\n\t// We save the current hash\n\t// We need data's hash\n\thash, err := t.sh.Resolve(id)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Now we write it\n\terr = t.meta.Append(id, hash)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn t.sh.Pin(id)\n}", "title": "" }, { "docid": "157ff25f1f613c5258fb38082bd4200c", "score": "0.6537093", "text": "func (this *Twitter) Follow(followerId int, followeeId int) {\n\tthis.checkExist(followeeId)\n\tif followeeId == followerId {\n\t\treturn\n\t}\n\tthis.checkExist(followerId)\n\n\t// 检查是否已在粉丝列表里\n\tlist := this.followers[followeeId]\n\tfor l := list.Front(); l != nil; l = l.Next() {\n\t\tif l.Value.(int) == followerId {\n\t\t\treturn\n\t\t}\n\t}\n\n\tthis.followers[followeeId].PushFront(followerId)\n\n\tlist = this.tweets[followerId]\n\tnewTweet := this.selfTweet[followeeId]\n\tindex := len(newTweet) - 1\n\tif index < 0 {\n\t\treturn\n\t}\n\n\tfor l := list.Front(); l != nil; {\n\t\tif l.Value.(*tweet).time < newTweet[index].time {\n\t\t\tlist.InsertBefore(&tweet{\n\t\t\t\tuserId: newTweet[index].userId,\n\t\t\t\tid: newTweet[index].id,\n\t\t\t\ttime: newTweet[index].time,\n\t\t\t}, l)\n\t\t\tindex--\n\n\t\t\tif index < 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else {\n\t\t\tl = l.Next()\n\t\t}\n\t}\n\n\tfor index >= 0 {\n\t\tlist.PushBack(&tweet{\n\t\t\tuserId: newTweet[index].userId,\n\t\t\tid: newTweet[index].id,\n\t\t\ttime: newTweet[index].time,\n\t\t})\n\t\tindex--\n\t}\n}", "title": "" }, { "docid": "0dbbd43fbf99aaa3fbf989f6a76aabf0", "score": "0.65369284", "text": "func follow(user string) {\n\t_, _, err := client.Friendships.Create(&twitter.FriendshipCreateParams{\n\t\tScreenName: user,\n\t\tFollow: newTrue(),\n\t})\n\tlogError(err)\n}", "title": "" }, { "docid": "dda18155a6510d9484631c83bc17c891", "score": "0.6531701", "text": "func (u *UsersController) Follow(userFromID, userToID int) bool {\n\tvar userFrom models.User\n\tu.db.Table(\"users\").Where(\"id = ?\", userFromID).Find(&userFrom)\n\tif userFrom.ID == 0 {\n\t\treturn false\n\t}\n\n\tvar userTo models.User\n\tu.db.Table(\"users\").Where(\"id = ?\", userToID).Find(&userTo)\n\tif userTo.ID == 0 {\n\t\treturn false\n\t}\n\n\tfollowing := u.GetFollowState(userFromID, userToID)\n\n\tif !following {\n\t\terr := u.db.Model(&userFrom).Association(\"Follow\").Append(&userTo)\n\t\tif err != nil {\n\t\t\treturn false\n\t\t}\n\n\t\tu.db.Exec(`UPDATE \"profiles\" SET followers = followers + 1 WHERE user_id = ?`, userToID)\n\t\treturn true\n\t} else {\n\t\terr := u.db.Model(&userFrom).Association(\"Follow\").Delete(&userTo)\n\t\tif err != nil {\n\t\t\treturn false\n\t\t}\n\n\t\tu.db.Exec(`UPDATE \"profiles\" SET followers = followers - 1 WHERE user_id = ?`, userToID)\n\t\treturn true\n\t}\n}", "title": "" }, { "docid": "fdf3f2005905d776b48e5e9dfa8f6270", "score": "0.65055835", "text": "func (this *Twitter) Follow(followerId int, followeeId int) {\n\tif followerId == followeeId {\n\t\treturn\n\t}\n\tif fs, ok := this.Account[followerId]; !ok {\n\t\tthis.Account[followerId] = []int{followeeId}\n\t} else {\n\t\tfor k := 0; k < len(fs); k++ {\n\t\t\tif followeeId == fs[k] {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\ttmp := append(this.Account[followerId], followeeId)\n\t\tthis.Account[followerId] = tmp\n\t}\n}", "title": "" }, { "docid": "a200c445538c15cafbdaf06ae4a07f58", "score": "0.6460872", "text": "func (mr *MockTwittServiceClientMockRecorder) Follow(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {\n\tvarargs := append([]interface{}{arg0, arg1}, arg2...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Follow\", reflect.TypeOf((*MockTwittServiceClient)(nil).Follow), varargs...)\n}", "title": "" }, { "docid": "ea822368a6ac43eb4c7e14a4f4de2065", "score": "0.6427684", "text": "func (m *MissingMsg) Follower(interfaces.IState) bool {\n\treturn true\n}", "title": "" }, { "docid": "902270a36e34e4a087c0c5d91ee9fabd", "score": "0.6419657", "text": "func (m *DriveItemItemRequestBuilder) Follow()(*ife52184499776c3c829efc37896f9c7578be8da410d81bb1866e5c91e78e9e4c.FollowRequestBuilder) {\n return ife52184499776c3c829efc37896f9c7578be8da410d81bb1866e5c91e78e9e4c.NewFollowRequestBuilderInternal(m.pathParameters, m.requestAdapter);\n}", "title": "" }, { "docid": "0ea70c25fc580a95e2cbeb6dbe4d89fe", "score": "0.64138216", "text": "func (s *Service) Follow(c context.Context, mid int64) (res []string, err error) {\n\tif res, err = s.dao.Follow(c, mid); err != nil {\n\t\tlog.Error(\"s.dao.Follow mid(%d) error(%v)\", mid, err)\n\t}\n\tif len(res) == 0 {\n\t\tres = _emptyFollow\n\t}\n\treturn\n}", "title": "" }, { "docid": "82fdfb6eb35fdfac5973c384cc0965fc", "score": "0.64111924", "text": "func (rf *Raft) beFollower(term int) {\n rf.state = Follower\n rf.votedFor = NULL\n rf.currentTerm = term\n rf.persist()\n}", "title": "" }, { "docid": "f7a612460296d8a32e4e63fd636883a6", "score": "0.6405696", "text": "func (twitter *Twitter) Follow(userID int, followeeID int) {\n\tif userID == followeeID {\n\t\treturn\n\t}\n\tfollower, ok := twitter.followers[userID]\n\tif !ok {\n\t\tfollower = make(map[int]bool)\n\t\ttwitter.followers[userID] = follower\n\t}\n\tfollower[followeeID] = true\n}", "title": "" }, { "docid": "ac009bfc151fb40e70234735857ef872", "score": "0.63666594", "text": "func (t *Twitter) Unfollow(followerId int, followeeId int) {\n\tif _, ok := t.idToUser[followerId]; !ok {\n\t\treturn\n\t}\n\tt.idToUser[followerId].unfollow(followeeId)\n}", "title": "" }, { "docid": "d969307ed210047f63ac5dfebaf5158d", "score": "0.6353404", "text": "func (l *ListingService) FollowPost(follow, fullname string) {\n\tpostdata := PostData{\n\t\t\"follow\": follow,\n\t\t\"fullname\": fullname,\n\t}\n\tresp, err := l.client.Post(API_PATH[\"follow_post\"], postdata)\n\n\tif err != nil {\n\t\tlog.Fatal(\"Error in following post\")\n\t}\n\n\tdefer resp.Body.Close()\n\n}", "title": "" }, { "docid": "1d22ac7e0040762c33f50d258652600a", "score": "0.6349037", "text": "func (s *InMemoryStore) Follow(userID, followeeID string) (*User, error) {\n\tuser, err := s.FindUser(userID)\n\tif err != nil {\n\t\treturn nil, NewEntityNotFound(userID, \"user\")\n\t}\n\n\t// don't follow self\n\tif userID == followeeID {\n\t\treturn user, nil\n\t}\n\n\tfollowee, err := s.FindUser(followeeID)\n\tif err != nil {\n\t\treturn nil, NewEntityNotFound(followeeID, \"user\")\n\t}\n\n\tif err := user.AddFollowees(followee); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn s.UpdateUser(user)\n}", "title": "" }, { "docid": "07f0a49654e1de31e28c692a02e85b72", "score": "0.63046855", "text": "func (s *RelationshipsService) Unfollow(userId string) (*Relationship, error) {\n\treturn relationshipAction(s, userId, \"unfollow\", \"POST\")\n}", "title": "" }, { "docid": "6aa43aaa152b6a35f9657c44f94f5246", "score": "0.6270813", "text": "func Follow(host, path, hash string) {\n\tif history != nil {\n\t\thistory.Follow(host, path, hash)\n\t}\n}", "title": "" }, { "docid": "26b23cf5dd243c141cbca0a2a59fcebf", "score": "0.62606627", "text": "func (this *Twitter) Unfollow(followerId int, followeeId int) {\n\tif followerId == followeeId {\n\t\treturn\n\t}\n\tif fs, ok := this.Account[followerId]; !ok {\n\t\treturn\n\t} else {\n\t\tnewFol := []int{}\n\t\tfor k := 0; k < len(fs); k++ {\n\t\t\tif fs[k] == followeeId {\n\t\t\t\tnewFol = append(newFol, fs[k+1:]...)\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tnewFol = append(newFol, fs[k])\n\t\t\t}\n\t\t}\n\t\tthis.Account[followerId] = newFol\n\t}\n}", "title": "" }, { "docid": "5c4716638058e45eb6bb53ca37e38631", "score": "0.62071425", "text": "func Follow(consumerKey, consumerSecret, accessToken, accessTokenSecret, twitterHandle string) (statusCode int, message string) {\n\tanaconda.SetConsumerKey(consumerKey)\n\tanaconda.SetConsumerSecret(consumerSecret)\n\tapi := anaconda.NewTwitterApi(accessToken, accessTokenSecret)\n\tresp, err := api.FollowUser(twitterHandle)\n\tif err != nil {\n\t\tabc := err.(*anaconda.ApiError)\n\t\treturn abc.StatusCode, abc.Error()\n\t}\n\treturn 200, resp.IdStr\n}", "title": "" }, { "docid": "aac64da88be4b9e7e3ef1d74bfb4ef59", "score": "0.6196426", "text": "func (rf *Raft) beFollower(term int) {\n\tDPrintf(\"raft %v become follower\", rf.me)\n\trf.currentTerm = term\n\trf.votedFor = null\n\trf.state = Follower\n\trf.persist()\n}", "title": "" }, { "docid": "ea36eebab1fa45ddcf1dbc377540360a", "score": "0.618737", "text": "func (r *Raft) becomeFollower(term uint64, lead uint64) {\n\t// Your Code Here (2A).\n\tr.State = StateFollower\n\tr.Lead = lead\n\tr.Vote = None\n\tr.Term = term\n\t//log.Printf(r.nodeInfo() + \"become a follower\\n\")\n}", "title": "" }, { "docid": "e61e445a2a3c29e2dae1fc0ab302dfd5", "score": "0.6146889", "text": "func (this *Twitter1) Unfollow(followerId int, followeeId int) {\n\tkey:=strconv.Itoa(followerId)+\" \"+strconv.Itoa(followeeId)\n\tif this.checkFollowed[key]{\n\t\tthis.checkFollowed[key]=false\n\t\tfor i:=0;i<len(this.follower[followerId]);i++{\n\t\t\tif this.follower[followerId][i]==followeeId{\n\t\t\t\tthis.follower[followerId]=append(this.follower[followerId][:i],this.follower[followerId][i+1:]...)\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "3902a7be93aa950f3b24021e83ff536d", "score": "0.61435384", "text": "func (m *MockTwittServiceClient) Follow(arg0 context.Context, arg1 *rpc.FollowingRequest, arg2 ...grpc.CallOption) (*rpc.SuccessReply, error) {\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"Follow\", varargs...)\n\tret0, _ := ret[0].(*rpc.SuccessReply)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "f46d279ac0f4934a47cff2c57a78c4c9", "score": "0.61398655", "text": "func (n *Node) doFollower() stateFunction {\n\tn.Out(\"Transitioning to FollowerState\")\n\tn.setState(FollowerState)\n\n\t// TODO: Students should implement this method\n\t// Hint: perform any initial work, and then consider what a node in the\n\t// follower state should do when it receives an incoming message on every\n\t// possible channel.\n\tfor {\n\t\tselect {\n\t\tcase shutdown := <-n.gracefulExit:\n\t\t\tif shutdown {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "70362ee89db86c2a8c55b3fd2c5c1711", "score": "0.6104431", "text": "func (m *MsgGetAddr) Follower(interfaces.IState) bool {\n\treturn true\n}", "title": "" }, { "docid": "5b31be61dd4d5ada89b0a85477bc35a3", "score": "0.60837096", "text": "func Action_OnFollowed(UserId, FollowedPeerUserId, FLId int) {\n\n\thash := hashFollowed(UserId, FollowedPeerUserId)\n\tnot := x.Action{\n\t\tActionId: helper.NextRowsSeqId(),\n\t\tActorUserId: UserId,\n\t\tActionTypeEnum: int(x.ActionEnum_ACTION_FOLLOWED_USER),\n\t\tPostId: 0,\n\t\tPeerUserId: FollowedPeerUserId,\n\t\tCommentId: 0,\n\t\tMurmur64Hash: hash,\n\t\tCreatedTime: helper.TimeNow(),\n\t}\n\n\tnot.Save(base.DB)\n\n\tevent := x.Event{\n\t\tByUserId: UserId,\n\t\tPeerUserId: FollowedPeerUserId,\n\t\tPostId: 0,\n\t\tCommentId: 0,\n\t\tActionId: not.ActionId,\n\t\tMurmur64Hash: hash,\n\t}\n\tevent_service.SaveEvent(event_service.FOLLOWED_USER_EVENT, event)\n}", "title": "" }, { "docid": "3ede4144f17a48a4b4b684709adfe11f", "score": "0.6071192", "text": "func transitionToFollower(rf *Raft) {\n\trf.Mu.Lock()\n\tif rf.State == Follower {\n\t\tDPrintf(\"In transitionToFollower: rf.State is %v\", rf.State)\n\t\trf.Mu.Unlock()\n\t\treturn\n\t}\n\tstateTransition(Follower, -1, rf)\n\trf.leaderTriggerTimer.Stop()\n\trf.leaderTriggerTimer.Reset(timeDuration())\n\trf.Mu.Unlock()\n}", "title": "" }, { "docid": "79df98ee2c82872db3b9b22f93f99cfc", "score": "0.60660404", "text": "func (u *UsersMethod) Follow(user uint, target uint) (*twitch.UserFollow, error) {\n\trel := fmt.Sprintf(\"users/%d/follows/channels/%d\", user, target)\n\n\tfollow := new(twitch.UserFollow)\n\t_, err := u.client.GetKraken(rel, follow)\n\treturn follow, err\n}", "title": "" }, { "docid": "eeb591b2992f5dca958e73ee75b13d50", "score": "0.6061436", "text": "func (this *ProfileController) Follow() {\n\tfollows := profile.FindFollowsById(this.getUserId())\n\tjson, err := json.Marshal(follows)\n\tif err == nil {\n\t\tthis.Data[\"follows\"] = string(json)\n\t\tthis.TplName = \"profile/follow.html\"\n\t\treturn\n\t}\n\tthis.Abort(\"404\")\n}", "title": "" }, { "docid": "b4e477921a0b209fc34c5c0bb9f7a9e9", "score": "0.6059231", "text": "func (s *Session) Follow(username string) (proto.User, error) {\n\tuser, err := s.GetUserByName(username)\n\tif err != nil {\n\t\treturn proto.User{}, err\n\t}\n\terr = user.Follow()\n\tif err != nil {\n\t\treturn proto.User{}, err\n\t}\n\treturn ConvertUser(user), nil\n}", "title": "" }, { "docid": "0e9e7d68a85e1a19808bfb01159d50b7", "score": "0.6054127", "text": "func (rf *Raft) do_follower() (nextState RaftState) {\n\tDPrintf(\"Serv[%d], Follower State Enter\\n\", rf.me)\n\trcvAppendEntries := false\n\tfor {\n\t\tselect {\n\t\tcase msg := <-rf.appendEntriesMsgCh:\n\t\t\tDPrintf(\"Serv[%d], Rcv on AppendEntriesMsgCh\\n\", rf.me)\n\t\t\tfallback := rf.handleAppendEntries(msg)\n\t\t\tif fallback != true {\n\t\t\t\tDPrintf(\"Serv[%d], AE from Leader\\n\", rf.me)\n\t\t\t\trcvAppendEntries = true\n\t\t\t}\n\t\tcase msg := <-rf.requestVoteMsgCh:\n\t\t\tDPrintf(\"Serv[%d], Rcv on RequestVoteMsgCh\\n\", rf.me)\n\t\t\trf.handleRequestVote(msg)\n\t\tcase <-rf.appendEntriesReplyCh:\n\t\t\t//Do nothing\n\t\tcase <-rf.requestVoteReplyCh:\n\t\t\t//Do nothing\n\t\tcase <-rf.makeElectionTimeout():\n\t\t\tif rcvAppendEntries == true {\n\t\t\t\tDPrintf(\"Serv[%d], Rcv on ElecTO\\n\", rf.me)\n\t\t\t\trcvAppendEntries = false\n\t\t\t} else {\n\t\t\t\treturn CANDIDATE\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "e5fd577cb78c453f2763c9847f0a210d", "score": "0.60342383", "text": "func (rf *Raft) fallbackToFollower(newTerm int) {\n\t// |rf.mu| is held\n\trf.dcheck(newTerm > rf.currentTerm, \"newTerm=%d is not greater than currentTerm=%d\\n\", newTerm, rf.currentTerm)\n\trf.currentTerm = newTerm\n\trf.votedFor = -1\n\n\trf.becomeFollower()\n}", "title": "" }, { "docid": "61196b981e44708fe1649ec652fe5cce", "score": "0.60334635", "text": "func (d *AltNode) SetFollow(pmap []*MatchNode) {\n}", "title": "" }, { "docid": "36655191e7ef706a18ff575a281e07b7", "score": "0.60221875", "text": "func (this *Twitter) Unfollow(followerId int, followeeId int) {\n\t_, ok := this.followers[followerId]\n\tif ok {\n\t\tdelete(this.followers[followerId], followeeId)\n\t}\n}", "title": "" }, { "docid": "45619e822a353d4096b4c64c7139ef81", "score": "0.60065365", "text": "func (m *RootRequestBuilder) Follow()(*i985d0e8fef0e465708a6633b299f61ed0881a5fcce55307950e3b25d1bd6728b.FollowRequestBuilder) {\n return i985d0e8fef0e465708a6633b299f61ed0881a5fcce55307950e3b25d1bd6728b.NewFollowRequestBuilderInternal(m.pathParameters, m.requestAdapter);\n}", "title": "" }, { "docid": "b243f2387d8f49851f6c373a372af9df", "score": "0.60055226", "text": "func Followed(userID, followID int64) (err error){\n\t// check followID not equal userID and has beed Followed\n\tif userID == followID || IsFollowing(userID, followID) {\n\t\treturn nil\n\t}\n\tsession := engine.NewSession()\n\tdefer session.Close()\n\tif err = session.Begin(); err != nil {\n\t\treturn err\n\t}\n\n\tif _, err = session.Insert(&Follow{UserID: userID, FollowID: followID}); err != nil {\n\t\treturn err\n\t}\n\n\tif _, err = session.Exec(\"UPDATE `user` SET fans_count = fans_count + 1 where id = ?\", followID); err != nil {\n\t\treturn err\n\t}\n\n\tif _, err = session.Exec(\"UPDATE `user` SET friend_count = friend_count + 1 where id = ?\", userID); err != nil {\n\t\treturn err\n\t}\n\n\treturn session.Commit()\n}", "title": "" }, { "docid": "012b89c86487c39e20085591ade94025", "score": "0.599614", "text": "func (this *Twitter) Unfollow(followerId int, followeeId int) {\n\tfollower, followerExist := this.users[followerId]\n\tif followerExist {\n\t\tdelete(follower.followees, followeeId)\n\t}\n}", "title": "" }, { "docid": "3b170dcdf229f7d81f2de21bde9c01ca", "score": "0.59801984", "text": "func RemoteFollow(w http.ResponseWriter, r *http.Request) {\n\ttype followRequest struct {\n\t\tAccount string `json:\"account\"`\n\t}\n\n\ttype followResponse struct {\n\t\tRedirectURL string `json:\"redirectUrl\"`\n\t}\n\n\tvar request followRequest\n\tdecoder := json.NewDecoder(r.Body)\n\tif err := decoder.Decode(&request); err != nil {\n\t\tWriteSimpleResponse(w, false, \"unable to parse request\")\n\t\treturn\n\t}\n\n\tif request.Account == \"\" {\n\t\tWriteSimpleResponse(w, false, \"Remote Fediverse account is required to follow.\")\n\t\treturn\n\t}\n\n\tlocalActorPath, _ := url.Parse(data.GetServerURL())\n\tlocalActorPath.Path = fmt.Sprintf(\"/federation/user/%s\", data.GetDefaultFederationUsername())\n\tvar template string\n\tlinks, err := webfinger.GetWebfingerLinks(request.Account)\n\tif err != nil {\n\t\tWriteSimpleResponse(w, false, err.Error())\n\t\treturn\n\t}\n\n\t// Acquire the remote follow redirect template.\n\tfor _, link := range links {\n\t\tfor k, v := range link {\n\t\t\tif k == \"rel\" && v == \"http://ostatus.org/schema/1.0/subscribe\" && link[\"template\"] != nil {\n\t\t\t\ttemplate = link[\"template\"].(string)\n\t\t\t}\n\t\t}\n\t}\n\n\tif localActorPath.String() == \"\" || template == \"\" {\n\t\tWriteSimpleResponse(w, false, \"unable to determine remote follow information for \"+request.Account)\n\t\treturn\n\t}\n\n\tredirectURL := strings.Replace(template, \"{uri}\", localActorPath.String(), 1)\n\tresponse := followResponse{\n\t\tRedirectURL: redirectURL,\n\t}\n\n\tWriteResponse(w, response)\n}", "title": "" }, { "docid": "97e1fdc52d7193838731916941604d92", "score": "0.5962408", "text": "func (this *Twitter) Unfollow(followerId int, followeeId int) {\n\tthis.newUser(followerId)\n\tdelete(this.follow[followerId], followeeId)\n}", "title": "" }, { "docid": "4aa60c65a69118da47910c17e1841227", "score": "0.59537506", "text": "func (s *RelationshipsService) FollowedBy(userId string) ([]User, *ResponsePagination, error) {\n\tvar u string\n\tif userId != \"\" {\n\t\tu = fmt.Sprintf(\"users/%v/followed-by\", userId)\n\t} else {\n\t\tu = \"users/self/followed-by\"\n\t}\n\n\treq, err := s.client.NewRequest(\"GET\", u, \"\")\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tusers := new([]User)\n\n\t_, err = s.client.Do(req, users)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tpage := new(ResponsePagination)\n\tif s.client.Response.Pagination != nil {\n\t\tpage = s.client.Response.Pagination\n\t}\n\n\treturn *users, page, err\n}", "title": "" }, { "docid": "41a642cce504cad9da6157672b79e7a3", "score": "0.59452534", "text": "func (s *Service) AddFollow(c context.Context, mid int64, teams []string) (err error) {\n\tif err = s.dao.AddFollow(c, mid, teams); err != nil {\n\t\tlog.Error(\"s.dao.AddFollow mid(%d) teams(%v) error(%v)\", mid, teams, err)\n\t}\n\treturn\n}", "title": "" }, { "docid": "fad33639f878007428f9af4fbe5c3c7a", "score": "0.59283966", "text": "func (ds *Datastore) AddFollow(f follow.Follow) error {\n\tif f.FollowerUserID == \"\" || f.FollowerUsername == \"\" || f.FolloweeUserID == \"\" || f.FolloweeUsername == \"\" {\n\t\treturn errors.New(\"Invalid follow\")\n\t}\n\n\tfollowers, ok := ds.Followers[f.FolloweeUserID]\n\tif !ok {\n\t\tfollowers = []follow.Follow{}\n\t}\n\tds.Followers[f.FolloweeUserID] = append(followers, f)\n\n\tfollowees, ok := ds.Followees[f.FollowerUserID]\n\tif !ok {\n\t\tfollowees = []follow.Follow{}\n\t}\n\tds.Followees[f.FollowerUserID] = append(followees, f)\n\n\treturn nil\n}", "title": "" }, { "docid": "843e69c2201e0cea1f6db9b22c053afb", "score": "0.5928054", "text": "func (mr *MockFollowAppInterfaceMockRecorder) Follow(followerID, followedID interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Follow\", reflect.TypeOf((*MockFollowAppInterface)(nil).Follow), followerID, followedID)\n}", "title": "" }, { "docid": "ad33b9a23eaa94c01f619ad0fffe6ccb", "score": "0.5923741", "text": "func (this *Twitter) Unfollow(followerId int, followeeId int) {\n \n}", "title": "" }, { "docid": "ad33b9a23eaa94c01f619ad0fffe6ccb", "score": "0.5923741", "text": "func (this *Twitter) Unfollow(followerId int, followeeId int) {\n \n}", "title": "" }, { "docid": "607b1a73fbd01965e8aba5224eb519b8", "score": "0.59185016", "text": "func FollowUser(w http.ResponseWriter, r *http.Request) {\n\tfollowID, err := authentication.ExtractUserID(r)\n\tif err != nil {\n\t\tresponses.Error(w, http.StatusUnauthorized, err)\n\t\treturn\n\t}\n\n\tparameters := mux.Vars(r)\n\tuserID, err := strconv.ParseUint(parameters[\"id\"], 10, 64)\n\tif err != nil {\n\t\tresponses.Error(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\tif followID == userID {\n\t\tresponses.Error(w, http.StatusForbidden, errors.New(\"You cannot follow yourself\"))\n\t\treturn\n\t}\n\n\tdb, err := database.Connect()\n\tif err != nil {\n\t\tresponses.Error(w, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\tdefer db.Close()\n\n\trepository := repositories.NewUserRepository(db)\n\tif err := repository.FollowUser(userID, followID); err != nil {\n\t\tresponses.Error(w, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\n\tresponses.JSON(w, http.StatusNoContent, nil)\n}", "title": "" }, { "docid": "fccda6f8398ea42851687b80996f46f4", "score": "0.59184176", "text": "func (m *RootRequestBuilder) Follow()(*i90812a66c9855e30e4b6cca138d506affed6dd51888715cd07f5e980a860bebc.FollowRequestBuilder) {\n return i90812a66c9855e30e4b6cca138d506affed6dd51888715cd07f5e980a860bebc.NewFollowRequestBuilderInternal(m.pathParameters, m.requestAdapter);\n}", "title": "" }, { "docid": "1cd2db46b2c68b8fa4f91c6cfcacdd5f", "score": "0.59154046", "text": "func (repository UserRepository) FollowUser(followedId uint64, followerId uint64) error {\n\n\tstmt, error := repository.db.Prepare(\n\t\t\"insert ignore into followers (user_id, follower_id) values (?, ?)\")\n\n\tif error != nil {\n\t\treturn error\n\t}\n\tdefer stmt.Close()\n\n\tinsert, error := stmt.Exec(followedId, followerId)\n\tif error != nil {\n\t\treturn error\n\t}\n\n\t_, error = insert.LastInsertId()\n\tif error != nil {\n\t\treturn error\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "dee3d4376563e315c96d85b5e768fa33", "score": "0.5910817", "text": "func FollowActivity(p P, act *vocab.Activity, receivedIn vocab.IRI) (*vocab.Activity, error) {\n\tif !vocab.IsNil(act.Object) && !act.To.Contains(act.Object.GetLink()) {\n\t\t// TODO(marius): add check if IRI represents an actor (or rely on the collection saver to break if not)\n\t\tact.To.Append(act.Object.GetLink())\n\t}\n\treturn act, nil\n}", "title": "" }, { "docid": "ae9ba4373e5326ad5b154b556128fb7f", "score": "0.5902391", "text": "func (this *Twitter) Unfollow(followerId int, followeeId int) {\n\tthis.checkExist(followeeId)\n\tif followeeId == followerId {\n\t\treturn\n\t}\n\tthis.checkExist(followerId)\n\n\tlist := this.followers[followeeId]\n\tfor l := list.Front(); l != nil; l = l.Next() {\n\t\tif l.Value.(int) == followerId {\n\t\t\tlist.Remove(l)\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// 删除推文\n\tlist = this.tweets[followerId]\n\tfor l := list.Front(); l != nil; {\n\t\ttmp := l.Next()\n\t\tif l.Value.(*tweet).userId == followeeId {\n\t\t\tlist.Remove(l)\n\t\t}\n\t\tl = tmp\n\t}\n}", "title": "" }, { "docid": "69351fbbbde98b189e36045991a6e5ae", "score": "0.5901638", "text": "func (rf *Raft) goBackToFollower(){\n\trf.state = FOLLOWER\n\trf.voteCount = 0\n}", "title": "" }, { "docid": "7dea64fce56f343c7ee4de22c89e9536", "score": "0.5895902", "text": "func (t *Tracker) UnFollow(id string) error {\n\tlog.Debug(\"unfollowing \" + id)\n\n\treturn t.sh.Unpin(id)\n}", "title": "" }, { "docid": "ead5d7188030f5c5aaeff5fab896b519", "score": "0.5894215", "text": "func (rf *Raft) FollowerHandler() {\n\t// The only continuous task for a FOLLOWER is reduce its own timeout\n\ttime.Sleep(1 * time.Millisecond)\n\trf.electionTimeout--\n\n\t// Once the timeout reaches 0, the server becomes a CANDIDATE\n\tif rf.electionTimeout < 0 {\n\t\trf.role = CANDIDATE\n\t}\n}", "title": "" }, { "docid": "d1113dde56444f1c5d9b91b7a2562dda", "score": "0.58867866", "text": "func (s *RelationshipsService) Follows(userId string) ([]User, *ResponsePagination, error) {\n\tvar u string\n\tif userId != \"\" {\n\t\tu = fmt.Sprintf(\"users/%v/follows\", userId)\n\t} else {\n\t\tu = \"users/self/follows\"\n\t}\n\n\treq, err := s.client.NewRequest(\"GET\", u, \"\")\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tusers := new([]User)\n\n\t_, err = s.client.Do(req, users)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tpage := new(ResponsePagination)\n\tif s.client.Response.Pagination != nil {\n\t\tpage = s.client.Response.Pagination\n\t}\n\n\treturn *users, page, err\n}", "title": "" }, { "docid": "ce80ac3a470fb9fa67dbb6fa07ef132c", "score": "0.5863961", "text": "func (this *Twitter) Unfollow(followerId int, followeeId int) {\n\tfollowees := this.followerMap[followerId];\n\tindex := -1\n\tn := len(followees)\n\tfor i := 0; i < n; i++ {\n\t\tif followeeId == followees[i] {\n\t\t\tindex = i\n\t\t}\n\t}\n\tif index == 0 && len(followees) == 1 {\n\t\tfollowees = followees[0:0]\n\t} else if index != -1 {\n\t\tfollowees[index] = followees[n-1]\n\t\tfollowees = followees[0 : n-1]\n\t}\n\tthis.followerMap[followerId] = followees\n}", "title": "" }, { "docid": "988b37a5670b0ab5475ba9af8f0cc57e", "score": "0.5860032", "text": "func (db *RAMdb) FollowUser(actor string, target string) (int, error) {\n\t// Check if target user exists\n\tusr, err := db.LookupUser(actor)\n\tif err != nil {\n\t\treturn len(usr.Following), errors.New(\"db error: user trying to follow does not exist\")\n\t}\n\n\tif _, err := db.LookupUser(target); err != nil {\n\t\treturn len(usr.Following), errors.New(\"db error: user being followed does not exist\")\n\t}\n\n\tusr.Following = append(usr.Following, target)\n\tnumFollowed := len(usr.Following)\n\tfmt.Printf(\"%s follows %s\\n\", actor, target)\n\n\treturn numFollowed, nil\n}", "title": "" }, { "docid": "277e1d18ac0aa35aed1b1ddf07b51228", "score": "0.5850559", "text": "func (this *Twitter) Unfollow(followerId int, followeeId int) {\n\tn := len(this.followee[followerId])\n\tfor i := 0; i < n; i++ {\n\t\tif this.followee[followerId][i] == followeeId {\n\t\t\tthis.followee[followerId] = append(this.followee[followerId][:i],\n\t\t\t\tthis.followee[followerId][i+1:]...)\n\n\t\t\treturn\n\t\t}\n\t}\n}", "title": "" }, { "docid": "82d6e14c01b957b58c75c7b3ba88f5dd", "score": "0.58449453", "text": "func (this *Twitter) Unfollow(followerId int, followeeId int) {\n\tfollower := this.followMap[followerId]\n\tif follower == nil {\n\t\treturn\n\t}\n\n\tdelete(follower, followeeId)\n}", "title": "" }, { "docid": "495b771b5bd963437ef471f959efb315", "score": "0.5821403", "text": "func (c *UserApiController) FollowUser(w http.ResponseWriter, r *http.Request) {\n\tfollowedUsernameParam := chi.URLParam(r, \"followedUsername\")\n\tfollowerUsernameParam := chi.URLParam(r, \"followerUsername\")\n\tresult, err := c.service.FollowUser(r.Context(), followedUsernameParam, followerUsernameParam)\n\t// If an error occurred, encode the error with the status code\n\tif err != nil {\n\t\tc.errorHandler(w, r, err, &result)\n\t\treturn\n\t}\n\t// If no error, encode the body and the result code\n\tEncodeJSONResponse(result.Body, &result.Code, result.Headers, w)\n\n}", "title": "" }, { "docid": "88cd3751c5657bfc73876233a9ad21a7", "score": "0.5817358", "text": "func (d *ConcatNode) SetFollow(pmap []*MatchNode) {\n\tfor _, i := range d.L.lastPos().Members() {\n\t\tfor _, f := range d.R.firstPos().Members() {\n\t\t\tpmap[i].followPos().Set(f)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "3d5c9ae041b51549f01ee54cdb42b275", "score": "0.58069205", "text": "func (l *Leader) AddFollower(fid string,\n\tpeer *common.PeerPipe,\n\to *observer) {\n\n\tnotifyChangeCh := false\n\n\tfunc() {\n\t\tl.mutex.Lock()\n\t\tdefer l.mutex.Unlock()\n\n\t\t// AddFollower requires holding the mutex such that the leader thread\n\t\t// will not be sending new proposal or commit (see sendProposal() and\n\t\t// sendCommit()) to followers. This allow this function to copy the\n\t\t// proposals and commits from the observer queue into the pipe, before\n\t\t// the leader has a chance to send new messages.\n\t\tfor packet := o.getNext(); packet != nil; packet = o.getNext() {\n\n\t\t\tswitch request := packet.(type) {\n\t\t\tcase ProposalMsg:\n\t\t\t\ttxid := common.Txnid(request.GetTxnid())\n\t\t\t\tlog.Current.Debugf(\"Leader.AddFollower() : send observer's packet %s, txid %d\", packet.Name(), txid)\n\t\t\tcase CommitMsg:\n\t\t\t\ttxid := common.Txnid(request.GetTxnid())\n\t\t\t\tlog.Current.Debugf(\"Leader.AddFollower() : send observer's packet %s, txid %d\", packet.Name(), txid)\n\t\t\t}\n\n\t\t\tpeer.Send(packet)\n\t\t}\n\n\t\toldListener, ok := l.followers[fid]\n\t\tlistener := newListener(fid, peer, l, l.idGen.getNextId())\n\t\tl.followers[fid] = listener\n\t\tgo listener.start()\n\n\t\t// kill the old message listener\n\t\tif ok && oldListener != nil {\n\t\t\tlog.Current.Debugf(\"Leader.AddFollower() : old Listener found for follower %s. Terminating old listener\", fid)\n\t\t\toldListener.terminate()\n\n\t\t} else {\n\t\t\t// notify a brand new follower (not just replacing an existing one)\n\t\t\tnotifyChangeCh = true\n\t\t}\n\t}()\n\n\tif notifyChangeCh {\n\t\tl.changech <- true\n\t}\n}", "title": "" }, { "docid": "4aa5b62b260af23d3261cd30843c55c5", "score": "0.5806172", "text": "func (u *User)UnFollow(p *User){\n\tConn.Do(\"ZREM\",\"followers\"+p.Id,u.Id)\n\tConn.Do(\"ZREM\",\"following\"+u.Id,p.Id)\n}", "title": "" }, { "docid": "ee07dab03c7195bb0abeee18f087c613", "score": "0.57931167", "text": "func (m *DirectoryBlockSignature) Follower(interfaces.IState) bool {\n\treturn true\n}", "title": "" }, { "docid": "3de9c895606394d6b344cb1b47af61d8", "score": "0.5775946", "text": "func (rf *Raft) becomeFollower(term int) {\n\tif rf.state != follower || term == 0 {\n\t\tlog.Printf(\"[%d] %v -> %v\\n\", rf.me, rf.state, follower)\n\t\trf.state = follower\n\t\trf.lastRecvHeartBeartTime = time.Now()\n\t\tgo rf.followerLoop()\n\t}\n\n\tif rf.currentTerm != term {\n\t\trf.currentTerm = term\n\t\trf.votedFor = -1\n\t\trf.persist()\n\t}\n}", "title": "" }, { "docid": "48c4b7ec94170ba44b312618a176b0c9", "score": "0.5772508", "text": "func (twitter *Twitter) Unfollow(userID int, followeeID int) {\n\tif follower, ok := twitter.followers[userID]; ok {\n\t\tdelete(follower, followeeID)\n\t}\n}", "title": "" }, { "docid": "049ddc5a9d0628a8687fa75bf3921314", "score": "0.57696915", "text": "func (d *ReplNode) SetFollow(pmap []*MatchNode) {\n\tif d.Max != 1 { // if just 1, self can't follow\n\t\tfor _, i := range d.LastPos.Members() {\n\t\t\tfor _, f := range d.FirstPos.Members() {\n\t\t\t\tpmap[i].followPos().Set(f)\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "e215179a31e1421406e0cf51cb403451", "score": "0.5769024", "text": "func (this *Twitter) Follow(followerId int, followeeId int) {\n if this.FollowedMap[followerId] == nil {\n this.FollowedMap[followerId] = map[int]int{}\n }\n this.FollowedMap[followerId][followeeId] = 1\n}", "title": "" }, { "docid": "dc714163e53233ff92491bd53df24843", "score": "0.57613766", "text": "func (hm *HeartbeatMonitor) StartFollower(view uint64, leaderID uint64) {\n\t//TODO\n}", "title": "" }, { "docid": "4d1c8ae5e74867d0eeb44a6c689748db", "score": "0.57604164", "text": "func (s *UserStore) Unfollow(a *model.User, b *model.User) error {\n\treturn s.db.Model(a).Association(\"Follows\").Delete(b).Error\n}", "title": "" }, { "docid": "aeaef06a123d390b536ffff2f0c523e8", "score": "0.5741069", "text": "func (r *RaftNode) doFollower() state {\n\tr.Out(\"Transitioning to FOLLOWER_STATE\")\n\tr.State = FOLLOWER_STATE\n\telectionTimeout := makeElectionTimeout()\n\tfor {\n\t\tselect {\n\t\tcase shutdown := <-r.gracefulExit:\n\t\t\tif shutdown {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\tcase vote := <-r.requestVote:\n\t\t\tr.Out(\"Request vote received\")\n\t\t\treq := vote.request\n\t\t//rep := vote.reply\n\t\t\tcurrTerm := r.GetCurrentTerm()\n\t\t\tcandidate := req.CandidateId\n\t\t//votedFor := r.GetVotedFor()\n\n\t\t//if votedFor == \"\" || votedFor == candidate.Id {\n\t\t// TODO: Check log to see si el vato la arma.\n\t\t\tif r.handleCompetingRequestVote(vote) {\n\t\t\t\t// return r.doFollower\n\t\t\t\tr.setCurrentTerm(req.Term)\n\t\t\t\t// Set voted for field (already voted)\n\t\t\t\tr.setVotedFor(candidate.Id)\n\n\t\t\t\t// Election in progess. There is no leader\n\t\t\t\t// Set to nil\n\t\t\t\tr.LeaderAddress = nil\n\n\t\t\t\t// Respond true, reset eleciton timeout.\n\t\t\t\t// rep <- RequestVoteReply{currTerm, true}\n\t\t\t\telectionTimeout = makeElectionTimeout()\n\t\t\t} else {\n\t\t\t\t// Other candidate has a less up to date log.\n\t\t\t\tif req.Term > currTerm {\n\t\t\t\t\tr.setCurrentTerm(req.Term)\n\t\t\t\t}\n\t\t\t}\n\n\t\tcase appendEnt := <-r.appendEntries:\n\t\t\treq := appendEnt.request\n\t\t\trep := appendEnt.reply\n\t\t\tcurrTerm := r.GetCurrentTerm()\n\t\t// r.Out(\"Recieved heartbeat from %v\", req.LeaderId.Id)\n\n\t\t\tif req.Term < currTerm {\n\t\t\t\tr.Out(\"Rejected heartbeat from %v because of terms\", req.LeaderId.Id)\n\t\t\t\trep <- AppendEntriesReply{currTerm, false}\n\t\t\t} else {\n\t\t\t\tr.LeaderAddress = &req.LeaderId\n\t\t\t\tr.setCurrentTerm(req.Term)\n\t\t\t\t// Set voted for field\n\t\t\t\tr.setVotedFor(\"\")\n\n\t\t\t\tentry := r.getLogEntry(req.PrevLogIndex)\n\t\t\t\tif entry == nil || entry.TermId != req.PrevLogTerm { //|| req.PrevLogIndex != r.getLastLogIndex() {\n\t\t\t\t\tr.Out(\"Rejected heartbeat from %v because of miss\", req.LeaderId.Id)\n\t\t\t\t\trep <- AppendEntriesReply{currTerm, false}\n\t\t\t\t} else {\n\t\t\t\t\tif req.PrevLogIndex+1 > r.commitIndex {\n\t\t\t\t\t\tr.truncateLog(req.PrevLogIndex + 1)\n\t\t\t\t\t} else {\n\t\t\t\t\t\t///// r.truncateLog(r.commitIndex + 1)\n\t\t\t\t\t\tr.truncateLog(req.PrevLogIndex + 1)\n\t\t\t\t\t\tr.commitIndex = req.PrevLogIndex\n\t\t\t\t\t}\n\n\t\t\t\t\tif len(req.Entries) > 0 {\n\t\t\t\t\t\tfor i := range req.Entries {\n\t\t\t\t\t\t\tr.appendLogEntry(req.Entries[i])\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif req.LeaderCommit > r.commitIndex {\n\t\t\t\t\t\tr.commitIndex = uint64(math.Min(float64(req.LeaderCommit), float64(r.getLastLogIndex())))\n\t\t\t\t\t}\n\n\t\t\t\t\t// Calls process log from lastApplied until commit index.\n\t\t\t\t\tif r.lastApplied < r.commitIndex {\n\t\t\t\t\t\ti := r.lastApplied\n\t\t\t\t\t\tif r.lastApplied != 0 {\n\t\t\t\t\t\t\ti++\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor ; i <= r.commitIndex; i++ {\n\t\t\t\t\t\t\t_ = r.processLog(*r.getLogEntry(i))\n\t\t\t\t\t\t\t//if reply.Status == REQ_FAILED {\n\t\t\t\t\t\t\t//\tpanic(\"This should not happen ever! PLZ FIX\")\n\t\t\t\t\t\t\t//}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tr.lastApplied = r.commitIndex\n\t\t\t\t\t}\n\n\t\t\t\t\trep <- AppendEntriesReply{currTerm, true}\n\t\t\t\t}\n\t\t\t}\n\t\t\telectionTimeout = makeElectionTimeout()\n\t\tcase regClient := <-r.registerClient:\n\t\t// req := regClient.request\n\t\t\trep := regClient.reply\n\t\t\tif r.LeaderAddress != nil {\n\t\t\t\trep <- RegisterClientReply{NOT_LEADER, 0, *r.LeaderAddress}\n\t\t\t} else {\n\t\t\t\t// Return election in progress.\n\t\t\t\trep <- RegisterClientReply{ELECTION_IN_PROGRESS, 0, NodeAddr{\"\", \"\"}}\n\t\t\t}\n\t\tcase <-electionTimeout:\n\t\t\treturn r.doCandidate\n\t\tcase clientReq := <-r.clientRequest:\n\t\t//req := clientReq.request\n\t\t\trep := clientReq.reply\n\t\t// req := regClient.request\n\t\t\tif r.LeaderAddress != nil {\n\t\t\t\trep <- ClientReply{NOT_LEADER, \"Not leader\", *r.LeaderAddress}\n\t\t\t} else {\n\t\t\t\t// Return election in progress.\n\t\t\t\trep <- ClientReply{NOT_LEADER, \"Not leader\", NodeAddr{\"\", \"\"}}\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "be5b83ccc9675df329d5845cb49a76cb", "score": "0.5738597", "text": "func UnFollow(consumerKey, consumerSecret, accessToken, accessTokenSecret, twitterHandle string) (statusCode int, message string) {\n\tanaconda.SetConsumerKey(consumerKey)\n\tanaconda.SetConsumerSecret(consumerSecret)\n\tapi := anaconda.NewTwitterApi(accessToken, accessTokenSecret)\n\tresp, err := api.UnfollowUser(twitterHandle)\n\tif err != nil {\n\t\tabc := err.(*anaconda.ApiError)\n\t\treturn abc.StatusCode, abc.Error()\n\t}\n\treturn 200, resp.IdStr\n}", "title": "" }, { "docid": "6746a8f5dcfb7ddcaa6d58bd684533ba", "score": "0.57374173", "text": "func FollowEvent(_ context.Context, op *core.Operation, event *linebot.Event) *core.TracerResp {\n\tresp := new(core.TracerResp)\n\tname := util.GetCallFuncName()\n\tlog.Println(\"Call:\", name)\n\n\tuid := event.Source.UserID\n\tlog.Println(\"UID:\", uid)\n\n\tprof, err := op.GetProfile(uid).Do()\n\tif err == nil {\n\t\tlog.Println(\"Name:\", prof.DisplayName)\n\t\tlog.Println(\"Picture:\", prof.PictureURL)\n\t\ttext := fmt.Sprintf(\"%s, thanks for following!\", prof.DisplayName)\n\t\tresp.Stack = append(resp.Stack, linebot.NewTextMessage(text))\n\t} else {\n\t\tlog.Println(\"Error:\", err.Error())\n\t}\n\treturn resp\n}", "title": "" }, { "docid": "73fec6c264c9dcbebc053b0441841400", "score": "0.5719565", "text": "func (r *Node) doFollower() stateFunction {\n\tr.Out(\"Transitioning to FollowerState\")\n\tr.State = FollowerState\n\n\tclientReply := rpc.ClientReply{\n\t\tStatus: rpc.ClientStatus_NOT_LEADER,\n\t\tResponse: nil,\n\t\tLeaderHint: r.Leader,\n\t}\n\n\tregisterReply := rpc.RegisterClientReply{\n\t\tStatus: rpc.ClientStatus_NOT_LEADER,\n\t\tClientId: 0,\n\t\tLeaderHint: r.Leader,\n\t}\n\n\tif r.Leader == nil {\n\t\tclientReply.LeaderHint = r.Self\n\t\tregisterReply.LeaderHint = r.Self\n\t}\n\n\tr.requestsMutex.Lock()\n\tfor _, replyToClient := range r.requestsByCacheID {\n\t\treplyToClient <- clientReply\n\t}\n\tr.requestsByCacheID = make(map[string]chan rpc.ClientReply)\n\tr.requestsMutex.Unlock()\n\n\tr.registrationsMutex.Lock()\n\tfor _, replyToClient := range r.registrationsByLogIndex {\n\t\treplyToClient <- registerReply\n\t}\n\tr.registrationsByLogIndex = make(map[uint64]chan rpc.RegisterClientReply)\n\tr.registrationsMutex.Unlock()\n\n\ttimeout := randomTimeout(r.config.ElectionTimeout)\n\n\tfor {\n\t\tselect {\n\t\tcase shutdown := <-r.gracefulExit:\n\t\t\tif shutdown {\n\t\t\t\treturn nil\n\t\t\t}\n\t\tcase clientMsg := <-r.clientRequest:\n\t\t\tclientReply.LeaderHint = r.Leader\n\t\t\tclientMsg.reply <- clientReply\n\n\t\tcase registerMsg := <-r.registerClient:\n\t\t\tregisterReply.LeaderHint = r.Leader\n\t\t\tregisterMsg.reply <- registerReply\n\n\t\tcase voteMsg := <-r.requestVote:\n\t\t\tif r.handleRequestVote(voteMsg) {\n\t\t\t\ttimeout = randomTimeout(r.config.ElectionTimeout)\n\t\t\t}\n\n\t\tcase appendMsg := <-r.appendEntries:\n\t\t\treset, _ := r.handleAppendEntries(appendMsg)\n\t\t\tif reset {\n\t\t\t\ttimeout = randomTimeout(r.config.ElectionTimeout)\n\t\t\t}\n\n\t\tcase <-timeout:\n\t\t\tr.Leader = nil\n\t\t\treturn r.doCandidate\n\t\t}\n\t}\n}", "title": "" }, { "docid": "7236e77a40e1763c4b810a4665104979", "score": "0.5714966", "text": "func (uuo *UserUpdateOne) AddFollowers(u ...*User) *UserUpdateOne {\n\tids := make([]int, len(u))\n\tfor i := range u {\n\t\tids[i] = u[i].ID\n\t}\n\treturn uuo.AddFollowerIDs(ids...)\n}", "title": "" }, { "docid": "50b4167181ac316d687d80defe7350e5", "score": "0.5712466", "text": "func NewFollower(client store.Store, key string) *Follower {\n\treturn &Follower{\n\t\tclient: client,\n\t\tkey: key,\n\t\tstopCh: make(chan struct{}),\n\t}\n}", "title": "" }, { "docid": "2f3ca8bd89f93de23189f1998a3c1080", "score": "0.5710874", "text": "func (o *WorkflowExecutionResult) SetFollowUpRequired(v bool) {\n\to.FollowUpRequired = &v\n}", "title": "" }, { "docid": "e2a34e007560ddd7d9c6890283dd51d8", "score": "0.5698302", "text": "func (this *Twitter) Unfollow(followerId int, followeeId int) {\n\tif followeeId == followerId {\n\t\tthis.IsFollowMy[followerId] = false\n\t}\n\tvar temp []int\n\tfor _,v := range this.Follows[followerId] {\n\t\tif v != followeeId {\n\t\t\ttemp = append(temp,v)\n\t\t}\n\t}\n\tthis.Follows[followerId] = temp\n}", "title": "" }, { "docid": "e181004d1f1aad8c5b7b5e77f0bbaa76", "score": "0.5688891", "text": "func (c *Client) Followed(ctx context.Context) ([]*common.Identity, error) {\n\treturn nil, nil\n}", "title": "" }, { "docid": "538b71749db0d561b67227f9e367c62d", "score": "0.56800985", "text": "func (r *Raft) becomeFollower(term uint64) {\n\tif r.state == Leader {\n\tEMPTYCH:\n\t\tfor {\n\t\t\t// Empty queue.\n\t\t\tselect {\n\t\t\tcase promise := <-r.queue:\n\t\t\t\tpromise.Respond(raft.ErrNotLeader{Leader: r.leader})\n\t\t\tdefault:\n\t\t\t\tbreak EMPTYCH\n\t\t\t}\n\t\t}\n\t}\n\n\tif r.state != Inactive {\n\t\tr.state = Follower\n\t}\n\tr.preElection = true\n\n\tif r.currentTerm != term {\n\t\tr.logger.WithFields(logrus.Fields{\n\t\t\t\"currentterm\": term,\n\t\t\t\"oldterm\": r.currentTerm,\n\t\t}).Infoln(\"Transition to follower\")\n\n\t\tr.currentTerm = term\n\t\tr.votedFor = None\n\n\t\tr.storage.Set(raft.KeyTerm, term)\n\t\tr.storage.Set(raft.KeyVotedFor, None)\n\t}\n\n\t// Reset election and baseline timeouts.\n\tr.resetBaseline = true\n\tr.resetElection = true\n}", "title": "" } ]
69fa438463e5011c5265f876ccd2cc52
================================================== Common Redis GET "X" Operations: Short Hand Conversion for the above HASHES_GET/HASHES_MGET operations: ==================================================
[ { "docid": "d0980416c686e4ab5ddc70e2b46aeda7", "score": "0.68517315", "text": "func Benchmark_RedisDsl_HASHES_GET(b *testing.B) {\n\tlogger := log4go.NewDefaultLogger(log4go.CRITICAL)\n\tserver, err := StartRedisServer(&logger)\n\tif nil != err {\n\t\tpanic(err)\n\t}\n\tdefer server.Close()\n\n\tserver.Connection().Cmd(\"HSET\", \"Hash A\", \"Bob\", \"Hit Bob A\")\n\tserver.Connection().Cmd(\"HSET\", \"Hash B\", \"Bob\", \"Hit Bob B\")\n\tserver.Connection().Cmd(\"HSET\", \"Hash C\", \"Bob\", \"Hit Bob C\")\n\tserver.Connection().Cmd(\"HSET\", \"Hash D\", \"Bob\", \"Hit Bob C\")\n\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tdsl := RedisDsl{server.Connection()}\n\t\tdsl.HASHES_GET([]string{\"Hash A\", \"Hash B\", \"Hash C\", \"Hash D\"}, \"Bob\")\n\t}\n}", "title": "" } ]
[ { "docid": "39c956c17f3735e415a1afb54cb848ab", "score": "0.66920054", "text": "func (l *Hash) MGet(fields ...interface{}) (values []string, err error) {\n\terr = l.cyclone.Raw.Do(radix.FlatCmd(\n\t\t&values,\n\t\t\"HMGET\",\n\t\tl.key,\n\t\tfields...,\n\t))\n\treturn\n}", "title": "" }, { "docid": "6fbc330b3770e8a1712b8eb03db9f06f", "score": "0.65160906", "text": "func (redis *Redis) MGet(key ... interface{}) ([]string, error) {\n\tresult, err := _redis.Strings(redis.conn.Do(\"MGET\", key...))\n\treturn result, err\n}", "title": "" }, { "docid": "e1e7cac8e073aa746f65109617a0bc41", "score": "0.64152306", "text": "func (r Redis) MGet(keys []string) ([]string, error) {\n\tconn := r.Pool.Get()\n\tdefer conn.Close()\n\n\tvar keysItfs []interface{}\n\tfor _, key := range keys {\n\t\tkeysItfs = append(keysItfs, key)\n\t}\n\n\treturn redigo.Strings(conn.Do(\"MGET\", keysItfs...))\n}", "title": "" }, { "docid": "a4725e2c9884a6fdd0dda86fa285b7aa", "score": "0.6400604", "text": "func (r *StateStore) Get(req *state.GetRequest) (*state.GetResponse, error) {\n\tres := r.client.Do(context.Background(), \"HGETALL\", req.Key) // Prefer values with ETags\n\tif err := redis.AsError(res); err != nil {\n\t\treturn r.directGet(req) //Falls back to original get\n\t}\n\tif res == nil {\n\t\treturn &state.GetResponse{}, nil\n\t}\n\tvals := res.([]interface{})\n\tif len(vals) == 0 {\n\t\treturn &state.GetResponse{}, nil\n\t}\n\n\tdata, version, err := r.getKeyVersion(vals)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &state.GetResponse{\n\t\tData: []byte(data),\n\t\tETag: version,\n\t}, nil\n}", "title": "" }, { "docid": "9a49639c78d381bf3cc782a992cefd5e", "score": "0.6379792", "text": "func (h *Handler) MGet(arg0 interface{}, args [][]byte) (redis.Resp, error) {\n\tif len(args) < 1 {\n\t\treturn toRespErrorf(\"len(args) = %d, expect >= 1\", len(args))\n\t}\n\n\ts, err := session(arg0, args)\n\tif err != nil {\n\t\treturn toRespError(err)\n\t}\n\n\tif a, err := s.Binlog().MGet(s.DB(), iconvert(args)...); err != nil {\n\t\treturn toRespError(err)\n\t} else {\n\t\tresp := redis.NewArray()\n\t\tfor _, v := range a {\n\t\t\tresp.AppendBulkBytes(v)\n\t\t}\n\t\treturn resp, nil\n\t}\n}", "title": "" }, { "docid": "5a7dce9f403d9f42a95c2a1612aaf4bc", "score": "0.63701934", "text": "func Benchmark_RedisDsl_HASH_GET(b *testing.B) {\n\tlogger := log4go.NewDefaultLogger(log4go.CRITICAL)\n\tserver, err := StartRedisServer(&logger)\n\tif nil != err {\n\t\tpanic(err)\n\t}\n\tdefer server.Close()\n\n\tserver.Connection().Cmd(\"HSET\", \"Hash Name\", \"Bob\", \"Gary\")\n\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tdsl := RedisDsl{server.Connection()}\n\t\tdsl.HASH_GET(\"Hash Name\", \"Bob\")\n\t}\n}", "title": "" }, { "docid": "2af9b62f2112e187cdcfffb667076885", "score": "0.6307794", "text": "func Benchmark_RedisDsl_GET(b *testing.B) {\n\tlogger := log4go.NewDefaultLogger(log4go.CRITICAL)\n\tserver, err := StartRedisServer(&logger)\n\tif nil != err {\n\t\tpanic(err)\n\t}\n\tdefer server.Close()\n\n\tserver.Connection().Cmd(\"SET\", \"Bob\", \"Gary\")\n\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tdsl := RedisDsl{server.Connection()}\n\t\tdsl.GET(\"Bob\")\n\t}\n}", "title": "" }, { "docid": "5ab0ab31578b17324ff29fbc9467c30a", "score": "0.62555707", "text": "func (self *RedisCache) GetMulti(keys []string) []interface{} {\r\n\tsize := len(keys)\r\n\tvar rv []interface{}\r\n\tc := self.pool.Get()\r\n\tdefer c.Close()\r\n\tvar err error\r\n\tfor _, key := range keys {\r\n\t\terr = c.Send(\"GET\", key)\r\n\t\tif err != nil {\r\n\t\t\tgoto ERROR\r\n\t\t}\r\n\t}\r\n\tif err = c.Flush(); err != nil {\r\n\t\tgoto ERROR\r\n\t}\r\n\tfor i := 0; i < size; i++ {\r\n\t\tif v, err := c.Receive(); err == nil {\r\n\t\t\trv = append(rv, v.([]byte))\r\n\t\t} else {\r\n\t\t\trv = append(rv, err)\r\n\t\t}\r\n\t}\r\n\treturn rv\r\nERROR:\r\n\trv = rv[0:0]\r\n\tfor i := 0; i < size; i++ {\r\n\t\trv = append(rv, nil)\r\n\t}\r\n\r\n\treturn rv\r\n}", "title": "" }, { "docid": "a64f692f307f106ac4cc10da3243a68a", "score": "0.62484944", "text": "func (red *Redius) HMGET(key string, fields []string) (val []string, err error) {\n\tc, err := red._pool.Get()\n\tif err != nil {\n\t\treturn\n\t}\n\tval, err = c.Cmd(\"HMGET\", key, fields).List()\n\tred._pool.Put(c)\n\treturn\n}", "title": "" }, { "docid": "a7f0ddb86ee91c95c4b8fffd90ddca68", "score": "0.62328595", "text": "func (mrc *mockRedisClient) Get(ctx context.Context, key string) (string, error) {\n\treturn \"id\", nil\n}", "title": "" }, { "docid": "9b1d4e5af2c1e4d0c00c2f0bffba30ba", "score": "0.6106892", "text": "func (self *RedisCache) Get(key string) interface{} {\r\n\tif v, err := self.do(\"GET\", key); err == nil {\r\n\t\treturn v\r\n\t}\r\n\treturn nil\r\n}", "title": "" }, { "docid": "f934251bca0307ab42f8b422d093757c", "score": "0.6100112", "text": "func (c *simpleRedis) Get(key string) ([]byte, error) {\n\tbytes, err := redis.Bytes(c.do(\"GET\", key))\n\tif err == redis.ErrNil {\n\t\terr = &dosa.ErrNotFound{}\n\t}\n\treturn bytes, err\n}", "title": "" }, { "docid": "7c4c851df251b92a64f908551d66636c", "score": "0.60576826", "text": "func (r *RedisConn) Get(key string) (interface{}, error) {\n\treturn String(r.conn.Do(\"GET\", key))\n}", "title": "" }, { "docid": "472737b673e6b5b6662eafed34348648", "score": "0.6042212", "text": "func (r *GoRedisDriver) Get(sid, key string) (interface{}, error) {\n\treturn r.Client.HGet(defaultContext, sid, key).Bytes()\n}", "title": "" }, { "docid": "1662eea23c924d2d72651f74b0218317", "score": "0.60187167", "text": "func JSONMGet(conn redis.Conn, path string, keys ...string) (res interface{}, err error) {\n\tif len(keys) == 0 {\n\t\terr = fmt.Errorf(\"Need atlesat one key as an argument\")\n\t\treturn nil, err\n\t}\n\n\targs := make([]interface{}, 0)\n\tfor _, key := range keys {\n\t\targs = append(args, key)\n\t}\n\targs = append(args, path)\n\tname, args, _ := CommandBuilder(\"JSON.MGET\", args...)\n\treturn conn.Do(name, args...)\n}", "title": "" }, { "docid": "fbd569b0e01deb370805da6db6c9904f", "score": "0.6015312", "text": "func (cp *ConnPool) HMGET(key string, fields ...interface{}) (map[string]string, error) {\n\targs := make([]interface{}, 0, len(fields)+1)\n\targs = append(args, key)\n\targs = append(args, fields...)\n\tconn := cp.GetSlaveConn()\n\tt, err := lib.Strings(conn.Do(\"HMGET\", args...))\n\tconn.Close()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(t) != len(fields) {\n\t\treturn nil, lib.ErrNil\n\t}\n\tm := make(map[string]string, len(fields))\n\tfor i, f := range fields {\n\t\tm[fmt.Sprintf(\"%v\", f)] = t[i]\n\t}\n\treturn m, nil\n}", "title": "" }, { "docid": "deafbcf9774b835eb3e3b1bf774f3d28", "score": "0.598023", "text": "func (c *Cache) MGet(ctx context.Context, exp int, keys ...string) ([]StringValue, error) {\n\tvar (\n\t\tgetKeys []interface{} // keys to get from the server\n\t\tgetIndexes []int // index of the key to get from the server\n\t\tresults = make([]StringValue, len(keys))\n\t\ttsExp = time.Duration(exp) * time.Second\n\t)\n\n\t// pick only keys that not exist in the cache\n\tfor i, key := range keys {\n\t\t// check in mem\n\t\tval, ok := c.memGet(key)\n\t\tif ok {\n\t\t\tresults[i] = StringValue{\n\t\t\t\tNil: false,\n\t\t\t\tVal: val,\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tgetKeys = append(getKeys, key)\n\t\tgetIndexes = append(getIndexes, i)\n\t}\n\n\tresp, err := c._do(ctx, cmdMGet, getKeys...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor i, elem := range resp.Elems {\n\t\tstrVal := StringValue{\n\t\t\tNil: c.isNullString(elem),\n\t\t\tVal: elem.Str,\n\t\t}\n\t\tresults[getIndexes[i]] = strVal\n\t\tif !strVal.Nil {\n\t\t\tc.memSet(fmt.Sprintf(\"%s\", (getKeys[i])), strVal.Val, tsExp)\n\t\t}\n\t}\n\treturn results, nil\n}", "title": "" }, { "docid": "8f5a79554793cf09a4bcb02b02671d9a", "score": "0.59582967", "text": "func TestGet(t *testing.T) {\n\n\tt.Run(\"get command using mocked redis\", func(t *testing.T) {\n\t\tt.Parallel()\n\n\t\t// Load redis\n\t\tclient, conn := loadMockRedis()\n\t\tassert.NotNil(t, client)\n\t\tdefer client.CloseAll(conn)\n\n\t\tvar tests = []struct {\n\t\t\ttestCase string\n\t\t\tkey string\n\t\t\tvalue interface{}\n\t\t}{\n\t\t\t{\"valid value\", testHashName, testStringValue},\n\t\t\t{\"new key\", \"test-hash-name1\", testStringValue},\n\t\t\t{\"third key\", \"test-hash-name2\", testStringValue},\n\t\t\t{\"fourth key\", \"test-hash-name3\", \"\"},\n\t\t\t{\"no name\", \"\", \"\"},\n\t\t}\n\t\tfor _, test := range tests {\n\t\t\tt.Run(test.testCase, func(t *testing.T) {\n\t\t\t\tconn.Clear()\n\n\t\t\t\t// The main command to test\n\t\t\t\tgetCmd := conn.Command(GetCommand, test.key).Expect(test.value)\n\n\t\t\t\tval, err := Get(context.Background(), client, test.key)\n\t\t\t\tassert.NoError(t, err)\n\t\t\t\tassert.Equal(t, true, getCmd.Called)\n\t\t\t\tassert.Equal(t, test.value, val)\n\t\t\t})\n\t\t}\n\t})\n\n\tt.Run(\"get command using real redis\", func(t *testing.T) {\n\t\tif testing.Short() {\n\t\t\tt.Skip(\"skipping live local redis tests\")\n\t\t}\n\n\t\t// Load redis\n\t\tclient, conn, err := loadRealRedis()\n\t\tassert.NotNil(t, client)\n\t\tassert.NoError(t, err)\n\t\tdefer client.CloseAll(conn)\n\n\t\t// Start with a fresh db\n\t\terr = clearRealRedis(conn)\n\t\tassert.NoError(t, err)\n\n\t\t// Fire the command\n\t\terr = Set(context.Background(), client, testKey, testStringValue, testDependantKey)\n\t\tassert.NoError(t, err)\n\n\t\t// Check that the command worked\n\t\tvar testVal string\n\t\ttestVal, err = Get(context.Background(), client, testKey)\n\t\tassert.NoError(t, err)\n\t\tassert.Equal(t, testStringValue, testVal)\n\t})\n\n\tt.Run(\"get command using real redis (new relic)\", func(t *testing.T) {\n\t\tif testing.Short() {\n\t\t\tt.Skip(\"skipping live local redis tests\")\n\t\t}\n\n\t\t// Load redis\n\t\tclient, conn, err := loadRealRedisWithNewRelic()\n\t\tassert.NotNil(t, client)\n\t\tassert.NoError(t, err)\n\t\tdefer client.CloseAll(conn)\n\n\t\t// Start with a fresh db\n\t\terr = clearRealRedis(conn)\n\t\tassert.NoError(t, err)\n\n\t\t// Fire the command\n\t\terr = Set(context.Background(), client, testKey, testStringValue, testDependantKey)\n\t\tassert.NoError(t, err)\n\n\t\t// Check that the command worked\n\t\tvar testVal string\n\t\ttestVal, err = Get(context.Background(), client, testKey)\n\t\tassert.NoError(t, err)\n\t\tassert.Equal(t, testStringValue, testVal)\n\t})\n\n\tt.Run(\"get cmd, trigger context err\", func(t *testing.T) {\n\t\tt.Parallel()\n\n\t\t// Load redis\n\t\tclient, conn := loadMockRedis()\n\t\tassert.NotNil(t, client)\n\t\tclient.CloseAll(conn)\n\n\t\tval, err := Get(context.TODO(), client, \"123456\")\n\t\tassert.Error(t, err)\n\t\tassert.Equal(t, \"\", val)\n\t})\n}", "title": "" }, { "docid": "4ed55f6b417e4ca774f37bb1d621c4c8", "score": "0.5954856", "text": "func (rc *RedisC) Get(key string) interface{} {\n\tif v, err := rc.do(\"GET\", key); err == nil {\n\t\treturn v\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "e72af653e32e6319e89df9a9192ff4d5", "score": "0.59486", "text": "func (r Redis) HMGet(key string, childs []string) ([]string, error) {\n\tconn := r.Pool.Get()\n\tdefer conn.Close()\n\n\tvar keyItfs []interface{}\n\tkeyItfs = append(keyItfs, key)\n\tfor _, child := range childs {\n\t\tkeyItfs = append(keyItfs, child)\n\t}\n\treturn redigo.Strings(conn.Do(\"HMGET\", keyItfs...))\n}", "title": "" }, { "docid": "20e4e80ec5ac3af9d72dbf93e70a7868", "score": "0.59048265", "text": "func (rs *redisStore) Get(key string) (value string, index int, found bool) {\n\tresp := rs.client.Cmd(\"GET\", key)\n\tindex = rs.index(0)\n\tif resp.Err != nil {\n\n\t\treturn \"\", index, false\n\t}\n\ts, err := resp.Str()\n\tif err != nil {\n\t\treturn \"\", index, false\n\t}\n\treturn s, index, true\n}", "title": "" }, { "docid": "9b48f0406ffc14667b92897bc8d62f85", "score": "0.5903978", "text": "func (c *Client) HGet(userKey, itemKey string) (interface{}, error) {\n\tconn := c.pool.Get()\n\tdefer conn.Close()\n\n\treturn redis.Values(conn.Do(\"HGET\", userKey, itemKey))\n\n}", "title": "" }, { "docid": "023dce94e0a3fb716f008267a6f583b1", "score": "0.5881679", "text": "func Get(key string) ([]byte, error) {\n\tconn := redisConn.Get()\n\tdefer conn.Close()\n\n\treply, err := redigo.Bytes(conn.Do(\"GET\", key))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn reply, nil\n}", "title": "" }, { "docid": "2ec2b6d9e74e2649bc6c06319256140e", "score": "0.587865", "text": "func (ss *Storageserver) Get(args *storageproto.GetArgs,\n reply *storageproto.GetReply) error {\n //ss.rwlock.RLock()\n fmt.Printf(\"try to GET key %s\\n\", args.Key)\n\n val, present := ss.hash[args.Key]\n if !present {\n //if the whole system only have one storage node\n if ss.numnodes == 1 {\n reply.Status = storageproto.EKEYNOTFOUND\n } else {\n //reply.Status = storageproto.EKEYNOTFOUND\n reply.Status = storageproto.EWRONGSERVER\n }\n\n fmt.Printf(\"storage GET key %s failed, nonexist\\n\", args.Key)\n //ss.rwlock.RUnlock()\n return nil\n }\n\n err := json.Unmarshal([]byte(val), &(reply.Value))\n if err != nil {\n lsplog.Vlogf(0, \"WARNING: unmarshal data generate an error\")\n }\n\n if args.WantLease {\n ss.addLeasePool(args, &(reply.Lease))\n }\n\n fmt.Printf(\"Storage Get key %s, val %s, lease %t\\n\",\n args.Key, reply.Value, reply.Lease.Granted)\n reply.Status = storageproto.OK\n //ss.rwlock.RUnlock()\n\treturn nil\n}", "title": "" }, { "docid": "e54a79acb8cdc9f168876a111754741b", "score": "0.58754104", "text": "func (r *StateStore) Get(req *state.GetRequest) (*state.GetResponse, error) {\n\tres, err := r.client.Do(r.ctx, \"HGETALL\", req.Key).Result() // Prefer values with ETags\n\tif err != nil {\n\t\treturn r.directGet(req) // Falls back to original get for backward compats.\n\t}\n\tif res == nil {\n\t\treturn &state.GetResponse{}, nil\n\t}\n\tvals := res.([]interface{})\n\tif len(vals) == 0 {\n\t\treturn &state.GetResponse{}, nil\n\t}\n\n\tdata, version, err := r.getKeyVersion(vals)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &state.GetResponse{\n\t\tData: []byte(data),\n\t\tETag: version,\n\t}, nil\n}", "title": "" }, { "docid": "13ba6596e6abe877ba06314e4ea3f311", "score": "0.5871351", "text": "func (client *Client) Get(con redis.Conn, key string) (string, error) {\n\treturn redis.String(con.Do(\"GET\", key))\n}", "title": "" }, { "docid": "dea39ed88f01840ed9d4f9024291971f", "score": "0.58491266", "text": "func (c *client) HGet(key, field string) ([]byte, error) {\n\treturn redis.Bytes(c.do(\"HGET\", key, field))\n}", "title": "" }, { "docid": "db5528d1cf4d24f29a30dfdcda556c93", "score": "0.5846224", "text": "func Get(key string) ([]byte, error) {\n\tconn := Pool.Get()\n\tdefer func() {\n\t\terr := conn.Close()\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\t}()\n\tvar data []byte\n\tdata, err := redis.Bytes(conn.Do(cnst.GET, key))\n\tif err != nil {\n\t\treturn data, fmt.Errorf(\"error getting key %s: %v\", key, err)\n\t}\n\treturn data, err\n}", "title": "" }, { "docid": "9c74bb2975e2e76e374aab4006fa04ca", "score": "0.5845354", "text": "func (g *Godis) MGet(keys ...interface{}) []string {\n\treturn g.cmdStrings(\"MGET\", keys...)\n}", "title": "" }, { "docid": "4c366b52f33a14ee348968c0773797ac", "score": "0.5829752", "text": "func (c *GoRedis) GetMulti(keys []string) map[string]any {\n\tpanic(\"implement me\")\n}", "title": "" }, { "docid": "1a3043ccf3c6472d534d86c545d8fce0", "score": "0.5819783", "text": "func (r Redis) Get(key string) (string, error) {\n\treturn r.c.Get(key).Result()\n}", "title": "" }, { "docid": "b666cb1630d9077f11ef57ba4c1d1569", "score": "0.5799547", "text": "func (self *DB) MultiGet(opts *ReadOptions, keys [][]byte) ([]Slice, []error) {\n\tif len(keys) < 1 {\n\t\treturn nil, nil\n\t}\n\n\tn := len(keys)\n\tchars := make([]*C.char, 3*n)\n\tkeys_list := chars[:n]\n\tvals_list := chars[n : 2*n]\n\tc_errs := chars[2*n:]\n\n\tsizes := make([]C.size_t, 2*n)\n\tkeys_sizes_list := sizes[:n]\n\tvals_sizes_list := sizes[n:]\n\tfor i, key := range keys {\n\t\tkeys_list[i] = byteToChar(key)\n\t\tkeys_sizes_list[i] = C.size_t(len(key))\n\t}\n\n\tC.rocksdb_multi_get(self.c, opts.c, C.size_t(n), (**C.char)(unsafe.Pointer(&keys_list[0])),\n\t\t(*C.size_t)(unsafe.Pointer(&keys_sizes_list[0])), (**C.char)(unsafe.Pointer(&vals_list[0])),\n\t\t(*C.size_t)(unsafe.Pointer(&vals_sizes_list[0])), (**C.char)(unsafe.Pointer(&c_errs[0])))\n\n\tslices := make([]Slice, n)\n\tvar errs []error\n\n\tfor i := range keys {\n\t\tslices[i] = Slice{data: vals_list[i], size: vals_sizes_list[i]}\n\t\tif c_errs[i] != nil {\n\t\t\tif errs == nil {\n\t\t\t\terrs = make([]error, n)\n\t\t\t}\n\t\t\terrs[i] = errors.New(C.GoString(c_errs[i]))\n\t\t\tC.free(unsafe.Pointer(c_errs[i]))\n\t\t}\n\t}\n\n\treturn slices, errs\n}", "title": "" }, { "docid": "a426469f6b6e2f48367421d1968bfdf1", "score": "0.579924", "text": "func (c *GoRedis) Get(key string) any {\n\tbts, err := c.rdb.Get(c.ctx, c.Key(key)).Bytes()\n\n\treturn c.Unmarshal(bts, err)\n}", "title": "" }, { "docid": "d70d4315507a6d369f3b44a5af35a982", "score": "0.579873", "text": "func Get(key string) (interface{}, error) {\n\tconn := RedisPool.Get()\n\tdefer conn.Close()\n\n\treply, err := conn.Do(\"GET\", key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn reply, nil\n}", "title": "" }, { "docid": "8d7b8ba3dae1f22fc6c3b9c77f70a8f9", "score": "0.5788545", "text": "func get(c redis.Conn) error {\n\n\tkey := \"news\"\n\ts, err := redis.String(c.Do(\"LPOP\", key))\n\tif err != nil {\n\t\treturn (err)\n\t}\n\tfmt.Printf(\"%s = %s\\n\", key, s)\n\n\treturn nil\n}", "title": "" }, { "docid": "6f3bf8497e131797b99a94ac5eccdeaa", "score": "0.5788302", "text": "func (s *Store) GetMulti(sess *simplesessions.Session, id string, keys ...string) (map[string]interface{}, error) {\n\t// Check if valid session\n\tif !s.isValidSessionID(sess, id) {\n\t\treturn nil, simplesessions.ErrInvalidSession\n\t}\n\n\tconn := s.pool.Get()\n\tdefer conn.Close()\n\n\t// Make list of args for HMGET\n\targs := make([]interface{}, len(keys)+1)\n\targs[0] = s.prefix + id\n\tfor i := range keys {\n\t\targs[i+1] = keys[i]\n\t}\n\n\tv, err := redis.Values(conn.Do(\"HMGET\", args...))\n\t// If field is not found then return map with fields as nil\n\tif len(v) == 0 || err == redis.ErrNil {\n\t\tv = make([]interface{}, len(keys))\n\t}\n\n\t// Form a map with returned results\n\tres := make(map[string]interface{})\n\tfor i, k := range keys {\n\t\tres[k] = v[i]\n\t}\n\n\treturn res, err\n}", "title": "" }, { "docid": "432be7b2108bd9b92008f192c902aa33", "score": "0.5779999", "text": "func (c *Redis) get(key string, v interface{}) error {\n\tb, err := c.client.Get(key).Bytes()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn json.Unmarshal(b, v)\n}", "title": "" }, { "docid": "3645df7368ffacd4dc5c4ee47d288d9c", "score": "0.57744783", "text": "func (db *Redis) Get(key []byte) ([]byte, error) {\n\tlog.Printf(\"[DEBUG] [shiva] Get : %v\", string(key))\n\t// exists, err := redis.Bool(c.Do(\"EXISTS\", \"foo\"))\n\t// if err != nil {\n\t// \treturn nil, err\n\t// }\n\tval, err := db.Pool.Get().Do(\"HGET\", db.Keyprefix, string(key))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdata, err := redis.String(val, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlog.Printf(\"[INFO] [shiva] Find : %s\", data)\n\treturn []byte(data), err\n}", "title": "" }, { "docid": "99b4746206f612c6c0ebe445da6becfe", "score": "0.57727325", "text": "func (m *googleMemcacheClient) MultiGet(ctx context.Context, keys []string) ([][]byte, error) {\n\tcacheItemMap, err := gmemcache.GetMulti(ctx, keys)\n\tif err != nil {\n\t\tlog.Error(ctx, \"failed fetching\", keys, err)\n\t\treturn nil, err\n\t}\n\n\tresult := make([][]byte, len(cacheItemMap))\n\tvar i = 0\n\tlog.Info(ctx, \"cache lookup found\", len(cacheItemMap), \"of\", len(keys))\n\tfor _, cacheItem := range cacheItemMap {\n\t\tresult[i] = cacheItem.Value\n\t\ti++\n\t}\n\n\treturn result, nil\n}", "title": "" }, { "docid": "d358068942e85efad447297e513685d3", "score": "0.57507026", "text": "func (s *RedisSetStore) Get(key string) (res []string, err error) {\n\tif !strings.HasPrefix(key, s.prefix) {\n\t\tkey = s.prefix + key\n\t}\n\tres, err = s.client.SMembers(key).Result()\n\tif err == redis.Nil || len(res) == 0 {\n\t\treturn res, errors.NewErrNotFound(key)\n\t}\n\tsort.Strings(res)\n\treturn res, err\n}", "title": "" }, { "docid": "952664646e87c7e64e99826b50a98ec1", "score": "0.57380205", "text": "func (rc *RedisConnection) Get(hash, stream, substream string) (dpa datastream.DatapointArray, err error) {\n\tsa, err := rc.Redis.LRange(streamKey(hash, stream, substream), 0, -1).Result()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn datastream.DatapointArrayFromDataStrings(sa)\n\n}", "title": "" }, { "docid": "9e824569c1edbbe884ee8e08d6f4d249", "score": "0.5732303", "text": "func (r *Reader) MultiGet(keys [][]byte) ([][]byte, error) {\n\tpanic(\"reader multi get unimplemented\")\n}", "title": "" }, { "docid": "c231414b357fe93443b9cf7764c57378", "score": "0.5730677", "text": "func (mc *Memcache) GetMulti(ctx context.Context, keys []string) (*Replies, error) {\n\tconn := mc.pool.Get(ctx)\n\titems, err := conn.GetMultiContext(ctx, keys)\n\trs := &Replies{err: err, items: items, conn: conn, usedItems: make(map[string]struct{}, len(keys))}\n\tif (err != nil) || (len(items) == 0) {\n\t\trs.Close()\n\t}\n\treturn rs, err\n}", "title": "" }, { "docid": "9a326dbedaa8cb41d86a86576ad8175f", "score": "0.5727354", "text": "func (m *rcache) Get(key string) (rcv []byte, err error) {\n\terr = m.client.Do(radix.Cmd(&rcv, \"GET\", key))\n\tif err != nil {\n\t\tm.logError(fmt.Sprintf(\"%s %s %s\", key, string(rcv), err.Error()))\n\t\treturn\n\t}\n\treturn\n}", "title": "" }, { "docid": "8a6920e5388fcd02751a88107f6d1d04", "score": "0.57243407", "text": "func (store *RedisStore) Get(key string) ([]byte, error) {\n\tcontent, err := store.Client.Get(key).Bytes()\n\treturn content, err\n}", "title": "" }, { "docid": "f3d24c783ebe09d2bfa7322ec8776d72", "score": "0.5702801", "text": "func (cs *CacheServer) get(keyrange rangecache.Keyrange) (interface{}, bool) {\n\tcs.mu.Lock()\n\tdefer cs.mu.Unlock()\n\treturn cs.cache.Get(keyrange)\n}", "title": "" }, { "docid": "6b071e1211c2aaaa906c0a555c3e7fb6", "score": "0.5695465", "text": "func (s *RedisStore) Get(key interface{}) (interface{}, error) {\n\treturn s.client.Get(key.(string)).Result()\n}", "title": "" }, { "docid": "e905fd5e61501c0d7ce2be9c93d7a374", "score": "0.5692433", "text": "func (b *memory) Get(key string) ([]byte, bool, error) {\n\tres, err := b.Client.HGet(b.hkey, key).Result()\n\tswitch {\n\tcase err == redis.Nil:\n\t\treturn nil, false, nil\n\tcase err != nil:\n\t\treturn nil, false, err\n\tdefault:\n\t\treturn []byte(res), true, nil\n\t}\n}", "title": "" }, { "docid": "ae5d5dd1b8aff3820f19e20978a78f00", "score": "0.5685017", "text": "func (rs *RedisStore) Get(key string) ([]byte, error) {\n\tbuf, err := rs.client.Get(rs.getKey(key)).Bytes()\n\tif err == redis.Nil {\n\t\treturn buf, nil\n\t}\n\treturn buf, err\n}", "title": "" }, { "docid": "849782727351e0153b8712f3dc1fd662", "score": "0.5671155", "text": "func (c *Redis) Get(key string, result interface{}) error {\n\tif err := c.codec.Get(key, result); err != nil {\n\t\treturn err\n\t}\n\tcacheGets.Inc()\n\treturn nil\n}", "title": "" }, { "docid": "19e3451a3a49d245b35694f676c2c534", "score": "0.5663845", "text": "func (hash *Hash) HMGet(fields [][]byte) ([][]byte, error) {\n\tvalues := make([][]byte, len(fields))\n\tif !hash.Exists() {\n\t\treturn values, nil\n\t}\n\tikeys := make([][]byte, len(fields))\n\tdkey := DataKey(hash.txn.db, hash.meta.ID)\n\tfor i := range fields {\n\t\tikeys[i] = hashItemKey(dkey, fields[i])\n\t}\n\n\treturn BatchGetValues(hash.txn, ikeys)\n}", "title": "" }, { "docid": "f38e6dc3e38d870e44dd95d628d7a954", "score": "0.56536794", "text": "func (k *KVServer) Get(req GetRequest, res *GetResponse) (err error) {\n\tdebugLog(\"Get: \", req.Key)\n\ttxn := TransactionsMap[req.TransactionId]\n\tval := txn.LocalStore[req.Key]\n\tdebugLog(\"Val: \", val)\n\tres.Value = val\n\tres.Success = true\n\treturn\n}", "title": "" }, { "docid": "85054f5e5f92db9b64c1e415aac86204", "score": "0.56498224", "text": "func (kv *KVPaxos) Get(args *GetArgs, reply *GetReply) error {\n\tfmt.Printf(\"KV Server Get key %s on %d!\\n\", args.Key, kv.me)\n\n\toperation := new(Op)\n\toperation.Cmd = \"Get\"\n\toperation.Key = args.Key\n\toperation.Hash = args.Hash\n\n\tkv.doPaxos(operation)\n\n\t// we should have been updated now\n\n\t// get and return the value\n\tif value, ok := kv.KeyVals[operation.Key]; ok {\n\t\treply.Value = value\n\n\t} else {\n\t\treply.Err = \"KvPaxos Get:\\tValue does not exist! Returning empty.\"\n\t\treply.Value = \"\"\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "c091a144b4a4a8719b057e6f8a6e46c0", "score": "0.56473535", "text": "func (db *DB) MultiGet(opts *ReadOptions, keys ...[]byte) (Slices, error) {\n\tcKeys, cKeySizes := byteSlicesToCSlices(keys)\n\tdefer cKeys.Destroy()\n\tvals := make(charsSlice, len(keys))\n\tvalSizes := make(sizeTSlice, len(keys))\n\trocksErrs := make(charsSlice, len(keys))\n\n\tC.rocksdb_multi_get(\n\t\tdb.c,\n\t\topts.c,\n\t\tC.size_t(len(keys)),\n\t\tcKeys.c(),\n\t\tcKeySizes.c(),\n\t\tvals.c(),\n\t\tvalSizes.c(),\n\t\trocksErrs.c(),\n\t)\n\n\tvar errs []error\n\n\tfor i, rocksErr := range rocksErrs {\n\t\tif rocksErr != nil {\n\t\t\tdefer C.free(unsafe.Pointer(rocksErr))\n\t\t\terr := fmt.Errorf(\"getting %q failed: %v\", string(keys[i]), C.GoString(rocksErr))\n\t\t\terrs = append(errs, err)\n\t\t}\n\t}\n\n\tif len(errs) > 0 {\n\t\treturn nil, fmt.Errorf(\"failed to get %d keys, first error: %v\", len(errs), errs[0])\n\t}\n\n\tslices := make(Slices, len(keys))\n\tfor i, val := range vals {\n\t\tslices[i] = NewSlice(val, valSizes[i])\n\t}\n\n\treturn slices, nil\n}", "title": "" }, { "docid": "e1e9898a9c00ea63566b1c2d0044faf4", "score": "0.56468594", "text": "func (s *RueidisStore) Get(ctx context.Context, key any) (any, error) {\n\tcmd := s.client.B().Get().Key(key.(string)).Cache()\n\tres := s.client.DoCache(ctx, cmd, s.options.ClientSideCacheExpiration)\n\tstr, err := res.ToString()\n\tif rueidis.IsRedisNil(err) {\n\t\terr = lib_store.NotFoundWithCause(err)\n\t}\n\treturn str, err\n}", "title": "" }, { "docid": "2a79d079fbec006a4f937484cc2187ee", "score": "0.5644125", "text": "func (client *ExtendedClient) Retrieve(res http.ResponseWriter, key string, indexOrField string) {\n\n\tvar js []byte\n\tvar index int64\n\tvar field string\n\tvar value interface{}\n\n\tkeyType, err := client.RedisClient.Type(key).Result()\n\n\tif indexOrField == \"\" {\n\t\tswitch keyType {\n\t\tcase \"string\":\n\t\t\tvalue, err = client.RedisClient.Get(key).Result()\n\t\tcase \"list\":\n\t\t\tvalue, err = client.RedisClient.LRange(key, 0, -1).Result()\n\t\tcase \"set\":\n\t\t\tvalue, err = client.RedisClient.SMembers(key).Result()\n\t\tcase \"hash\":\n\t\t\tvalue, err = client.RedisClient.HGetAll(key).Result()\n\t\tcase \"zset\":\n\t\t\t//TODO: a simple implementation given methods on sorted set can be very complicated\n\t\t\tvalue, err = client.RedisClient.ZRange(key, 0, -1).Result()\n\t\tdefault:\n\t\t\terr = errors.New(strNotImplemented)\n\t\t}\n\t} else {\n\t\tif keyType == \"string\" || keyType == \"list\" {\n\t\t\tindex, _ = strconv.ParseInt(indexOrField, 10, 64)\n\t\t} else {\n\t\t\tfield = indexOrField\n\t\t}\n\n\t\tswitch keyType {\n\t\tcase \"string\":\n\t\t\tif index == 0 && indexOrField != \"0\" {\n\t\t\t\terr = errors.New(strWrongTypeForIndexField)\n\t\t\t} else {\n\t\t\t\tvalue, err = client.RedisClient.GetRange(key, index, index).Result()\n\t\t\t}\n\t\tcase \"list\":\n\t\t\tif index == 0 && indexOrField != \"0\" {\n\t\t\t\terr = errors.New(strWrongTypeForIndexField)\n\t\t\t} else {\n\t\t\t\tvalue, err = client.RedisClient.LIndex(key, index).Result()\n\t\t\t}\n\t\tcase \"set\":\n\t\t\tvalue, err = client.RedisClient.SIsMember(key, field).Result()\n\t\tcase \"hash\":\n\t\t\tvalue, err = client.RedisClient.HGet(key, field).Result()\n\t\tcase \"zset\":\n\t\t\tvalue, err = client.RedisClient.ZRank(key, field).Result()\n\t\tdefault:\n\t\t\terr = errors.New(strNotImplemented)\n\t\t}\n\t}\n\n\tif err != nil {\n\t\tif strings.Contains(err.Error(), strNotImplemented) {\n\t\t\tres.WriteHeader(http.StatusNotImplemented)\n\t\t} else if strings.Contains(err.Error(), strWrongTypeForIndexField) {\n\t\t\tres.WriteHeader(http.StatusBadRequest)\n\t\t} else {\n\t\t\tres.WriteHeader(http.StatusNotFound)\n\t\t}\n\t\tjs, _ = json.Marshal(types.ErrorType{Error: err.Error()})\n\t} else {\n\t\tjs, _ = json.Marshal(types.ResponseType{ValueType: keyType, Value: value})\n\t}\n\tres.Write(js)\n}", "title": "" }, { "docid": "12ca670f9583aba9076869ae9bf74c88", "score": "0.5640907", "text": "func TestGetBytes(t *testing.T) {\n\n\tt.Run(\"get bytes command using mocked redis\", func(t *testing.T) {\n\t\tt.Parallel()\n\n\t\t// Load redis\n\t\tclient, conn := loadMockRedis()\n\t\tassert.NotNil(t, client)\n\t\tdefer client.CloseAll(conn)\n\n\t\tvar tests = []struct {\n\t\t\ttestCase string\n\t\t\tkey string\n\t\t\tvalue string\n\t\t}{\n\t\t\t{\"valid value\", testHashName, testStringValue},\n\t\t\t{\"new key\", \"test-hash-name1\", testStringValue},\n\t\t\t{\"third key\", \"test-hash-name2\", testStringValue},\n\t\t\t{\"fourth key\", \"test-hash-name3\", \"\"},\n\t\t\t{\"no name\", \"\", \"\"},\n\t\t}\n\t\tfor _, test := range tests {\n\t\t\tt.Run(test.testCase, func(t *testing.T) {\n\t\t\t\tconn.Clear()\n\n\t\t\t\t// The main command to test\n\t\t\t\tgetCmd := conn.Command(GetCommand, test.key).Expect([]byte(test.value))\n\n\t\t\t\tval, err := GetBytes(context.Background(), client, test.key)\n\t\t\t\tassert.NoError(t, err)\n\t\t\t\tassert.Equal(t, true, getCmd.Called)\n\t\t\t\tassert.Equal(t, []byte(test.value), val)\n\t\t\t})\n\t\t}\n\t})\n\n\tt.Run(\"get bytes command using real redis\", func(t *testing.T) {\n\t\tif testing.Short() {\n\t\t\tt.Skip(\"skipping live local redis tests\")\n\t\t}\n\n\t\t// Load redis\n\t\tclient, conn, err := loadRealRedis()\n\t\tassert.NotNil(t, client)\n\t\tassert.NoError(t, err)\n\t\tdefer client.CloseAll(conn)\n\n\t\t// Start with a fresh db\n\t\terr = clearRealRedis(conn)\n\t\tassert.NoError(t, err)\n\n\t\t// Fire the command\n\t\terr = Set(context.Background(), client, testKey, testStringValue, testDependantKey)\n\t\tassert.NoError(t, err)\n\n\t\t// Check that the command worked\n\t\tvar testVal []byte\n\t\ttestVal, err = GetBytes(context.Background(), client, testKey)\n\t\tassert.NoError(t, err)\n\t\tassert.Equal(t, []byte(testStringValue), testVal)\n\t})\n\n\tt.Run(\"get bytes command using real redis (new relic)\", func(t *testing.T) {\n\t\tif testing.Short() {\n\t\t\tt.Skip(\"skipping live local redis tests\")\n\t\t}\n\n\t\t// Load redis\n\t\tclient, conn, err := loadRealRedisWithNewRelic()\n\t\tassert.NotNil(t, client)\n\t\tassert.NoError(t, err)\n\t\tdefer client.CloseAll(conn)\n\n\t\t// Start with a fresh db\n\t\terr = clearRealRedis(conn)\n\t\tassert.NoError(t, err)\n\n\t\t// Fire the command\n\t\terr = Set(context.Background(), client, testKey, testStringValue, testDependantKey)\n\t\tassert.NoError(t, err)\n\n\t\t// Check that the command worked\n\t\tvar testVal []byte\n\t\ttestVal, err = GetBytes(context.Background(), client, testKey)\n\t\tassert.NoError(t, err)\n\t\tassert.Equal(t, []byte(testStringValue), testVal)\n\t})\n\n\tt.Run(\"get bytes cmd, trigger context err\", func(t *testing.T) {\n\t\tt.Parallel()\n\n\t\t// Load redis\n\t\tclient, conn := loadMockRedis()\n\t\tassert.NotNil(t, client)\n\t\tclient.CloseAll(conn)\n\n\t\tval, err := GetBytes(context.TODO(), client, \"123456\")\n\t\tassert.Error(t, err)\n\t\tassert.Equal(t, []byte(nil), val)\n\t})\n}", "title": "" }, { "docid": "2c9ac855e2b66bb33e5fd194387bbe66", "score": "0.56304777", "text": "func (r redisStore) Get(key string) (string, error) {\n\tresult := r.client.Get(key)\n\tif result.Err() != nil {\n\t\treturn \"\", result.Err()\n\t}\n\n\treturn result.String(), nil\n}", "title": "" }, { "docid": "c8cda09946b6187b6c1690e400e69645", "score": "0.5626482", "text": "func (kv *KVServer) Get(args *GetArgs, reply *GetReply) {\n\t// Your code here.\n\tcommand := Op{\n\t\tType: \"Get\",\n\t\tKey: args.Key,\n\t\tValue: strconv.FormatInt(nrand(), 10),\n\t\tCid: -1,\n\t\tSeqNum: -1,\n\t}\n\t//DPrintf(\"Server: %v, call Get method, command: %+v\", kv.me, command)\n\tindex, _, isLeader := kv.rf.Start(command)\n\treply.WrongLeader = true\n\tif !isLeader {\n\t\treturn\n\t}\n\t// obtain notify channel\n\teleCh := kv.getEleCh(index, true)\n\tnotifyOp := kv.beNotified(eleCh, index)\n\tif isOpEqual(command, notifyOp) {\n\t\treply.WrongLeader = false\n\t\tkv.mu.Lock()\n\t\treply.Value = kv.db[command.Key]\n\t\tkv.mu.Unlock()\n\t}\n\treturn\n}", "title": "" }, { "docid": "35ce27d9bca5d86b81f4d774d078b627", "score": "0.56261086", "text": "func Get(key string) (string, error) {\n\tconn := GetPool().Get()\n\tdefer conn.Close()\n\n\treply, err := redis.String(conn.Do(\"GET\", key))\n\treturn string(reply), err\n}", "title": "" }, { "docid": "1dc24564b63afd0e05d22b67549a61ba", "score": "0.5624983", "text": "func (c *Client) HGetBytes(userKey, itemKey string) ([]byte, error) {\n\tconn := c.pool.Get()\n\tdefer conn.Close()\n\n\treturn redis.Bytes(conn.Do(\"HGET\", userKey, itemKey))\n\n}", "title": "" }, { "docid": "05082263977818c94caeb3d667e1fde1", "score": "0.5608716", "text": "func (rs *RedisStore) Get(token Token, sessionState interface{}) error {\n\tconn := rs.pool.Get()\n\tdefer conn.Close()\n\n\t//pipeline GET and EXPIRE commands\n\t//to get the state and reset its TTL\n\tkey := getRedisKey(token)\n\tconn.Send(\"GET\", key)\n\tconn.Send(\"EXPIRE\", key, rs.SessionDuration.Seconds())\n\tconn.Flush()\n\n\t//GET command reply\n\tgetReply, err := redis.Bytes(conn.Receive())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error executing GET: %v\", err)\n\t}\n\tif err := gob.NewDecoder(bytes.NewBuffer(getReply)).Decode(sessionState); err != nil {\n\t\treturn fmt.Errorf(\"error decoding session state: %v\", err)\n\t}\n\n\t//no need to look at the EXPIRE command reply\n\treturn nil\n}", "title": "" }, { "docid": "3ca21d81b39fba76279b272f5ae2cafa", "score": "0.56072676", "text": "func (c *HTTPClient) Get(key db.Key) (string, error) {\n\tc.CID++\n\t//v, _, err := c.RESTGet(key)\n\t//return v, err\n\treturn \"\", nil\n}", "title": "" }, { "docid": "2a45b52aa62d3ddb6255c1e66971ee54", "score": "0.5603302", "text": "func (db *TransactionDB) MultiGet(opts *ReadOptions, keys ...[]byte) (Slices, error) {\n\t// will destroy `cKeys` before return\n\tcKeys, cKeySizes := byteSlicesToCSlices(keys)\n\n\tvals := make(charsSlice, len(keys))\n\tvalSizes := make(sizeTSlice, len(keys))\n\trocksErrs := make(charsSlice, len(keys))\n\n\tC.rocksdb_transactiondb_multi_get(\n\t\tdb.c,\n\t\topts.c,\n\t\tC.size_t(len(keys)),\n\t\tcKeys.c(),\n\t\tcKeySizes.c(),\n\t\tvals.c(),\n\t\tvalSizes.c(),\n\t\trocksErrs.c(),\n\t)\n\n\tvar errs []error\n\n\tfor i, rocksErr := range rocksErrs {\n\t\tif err := fromCError(rocksErr); err != nil {\n\t\t\terrs = append(errs, fmt.Errorf(\"getting %q failed: %v\", string(keys[i]), err.Error()))\n\t\t}\n\t}\n\n\tif len(errs) > 0 {\n\t\tcKeys.Destroy()\n\t\treturn nil, fmt.Errorf(\"failed to get %d keys, first error: %v\", len(errs), errs[0])\n\t}\n\n\tslices := make(Slices, len(keys))\n\tfor i, val := range vals {\n\t\tslices[i] = NewSlice(val, valSizes[i])\n\t}\n\n\tcKeys.Destroy()\n\treturn slices, nil\n}", "title": "" }, { "docid": "48e96160d06796900cc15c9949d10ccc", "score": "0.5590036", "text": "func (s *InMemoryStorage) GET(key string) interface{} {\n\ts.mu.RLock()\n\tdefer s.mu.RUnlock()\n\n\treturn s.bucket[key]\n}", "title": "" }, { "docid": "b82dacc4f80efa6514459b2907433a3a", "score": "0.55696404", "text": "func Get(c router.Context, query string, message string) ([]byte, string, error) {\n\tstub := c.Stub()\n\t// excecute the query\n\tresultsIterator, err := stub.GetQueryResult(query)\n\n\t// check if the query executed successfully?\n\tif err != nil {\n\t\treturn nil, \"\", status.ErrInternal.WithError(err)\n\t}\n\tdefer resultsIterator.Close()\n\n\t// query has returned the results?\n\tif !resultsIterator.HasNext() {\n\t\treturn nil, \"\", status.ErrNotFound.WithMessage(message)\n\t}\n\n\t// fetch the data and marshal it into struct\n\tqueryResponse, err := resultsIterator.Next()\n\tif err != nil {\n\t\treturn nil, \"\", status.ErrInternal.WithError(err)\n\t}\n\n\treturn queryResponse.Value, queryResponse.Key, nil\n}", "title": "" }, { "docid": "ce0c3e8b19ef85cbbce1e0973738d89f", "score": "0.5567114", "text": "func (c *cache) rawGet(key string) ([]byte, bool) {\n\telt := c.pos[key]\n\tif elt == nil {\n\t\treturn nil, false\n\t} else if elt.link == nil || elt.link.key != key {\n\t\tpanic(\"cache integrity failure: \" + key)\n\t}\n\tdefer c.update(elt)\n\treturn elt.link.val, true\n}", "title": "" }, { "docid": "5d9fb849cc0bbd5cd3fef656ab58f6f6", "score": "0.5562066", "text": "func (r *Client) HMGet(key string, fields ...string) []interface{} {\n\treturn r.cli.HMGet(key, fields...).Val()\n}", "title": "" }, { "docid": "b5bd5bfbead4ca2a97c04f3d84159645", "score": "0.55518574", "text": "func getHandler(w http.ResponseWriter, req *http.Request) {\n\tbody, err := objx.FromURLQuery(req.URL.Query().Encode())\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif !mem.Has(strings.ToLower(body.Get(\"key\").Str())) {\n\t\tw.WriteHeader(http.StatusNotFound)\n\t\treturn\n\t}\n\n\t_, _ = fmt.Fprint(w, mem.Get(strings.ToLower(body.Get(\"key\").Str())))\n}", "title": "" }, { "docid": "55d09cfa5aee0107e25793bf25167b5e", "score": "0.55478424", "text": "func get(w http.ResponseWriter, r *http.Request) {\n\tselfHashNode := configure.DefaultString(\"host\", \"127.0.0.1\") + \":\" +\n\t\tconfigure.DefaultString(\"port\", \"12345\")\n\n\tr.ParseForm()\n\tkey := r.Form.Get(\"key\")\n\n\tnode := distributed.GetHashRing()\n\tif node == nil {\n\t\toutputHttp(w, \"Plz init hash ring first\")\n\t}\n\n\tnodeName := node.Get(key)\n\tif nodeName == \"\" {\n\t\tlogging.ErrorF(\"[http] can not find key(%s)\", key)\n\t}\n\n\tif nodeName == selfHashNode {\n\n\t\t// Current node\n\t\tif value, ok := lru.LRUCache.Get(key); ok {\n\t\t\toutputHttp(w, value)\n\t\t} else {\n\t\t\toutputHttp(w, \"\")\n\t\t}\n\t} else {\n\t\t// Remote node\n\t\tcmdUrl := \"http://\" + nodeName + KGetHttpUrl + \"?key=\" + key\n\t\tresponse, err := sendHttpRemoteNode(cmdUrl)\n\t\tfmt.Println(cmdUrl)\n\t\tfmt.Println(response, err)\n\t\tif err != nil {\n\t\t\tlogging.ErrorF(\"[http] sendHttpRemoteNode error(%s)\", err)\n\t\t\toutputHttp(w, \"0\")\n\t\t}\n\t\toutputHttp(w, response)\n\t}\n}", "title": "" }, { "docid": "46d21f185fb5977b5c47023d65a3f780", "score": "0.5541606", "text": "func Get(key string) string {\n\tconn := Pool.Get()\n\tdefer conn.Close()\n\n\tresp, err := redis.String(conn.Do(\"GET\", key))\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\treturn resp\n}", "title": "" }, { "docid": "1a5ed7493026e316db5c2fda9f00782e", "score": "0.5541277", "text": "func (s *Storage) MGet(keys ...[]byte) ([][]byte, error) {\n\tss, err := s.db.GetSnapshot()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer ss.Release()\n\n\tvals := make([][]byte, len(keys))\n\tfor i, k := range keys {\n\t\tval, err := ss.Get(k, nil)\n\t\tif err == leveldb.ErrNotFound {\n\t\t\tcontinue\n\t\t}\n\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tvals[i] = val\n\t}\n\n\treturn vals, nil\n}", "title": "" }, { "docid": "ffb8499ab17501c10c17097ac499baaa", "score": "0.5539028", "text": "func (c *cache) MGet(keys ...interface{}) map[interface{}]interface{} {\n\tnowNano := time.Now().UnixNano()\n\treturn c.mget(false, nowNano, keys...)\n}", "title": "" }, { "docid": "1de238910b1373561b9f96ff19b7dcaa", "score": "0.5538685", "text": "func (cp *ConnPool) HGET(key string, field interface{}) (v string, err error) {\n\tconn := cp.GetSlaveConn()\n\tv, err = lib.String(conn.Do(\"HGET\", key, field))\n\tconn.Close()\n\tif err == lib.ErrNil {\n\t\terr = ErrNil\n\t}\n\treturn\n}", "title": "" }, { "docid": "7dd497b0eafb37ae583432ddf6eb8b06", "score": "0.5536758", "text": "func (c *BaseClient) RHGet(key string, fields ...string) (valueMap map[string]interface{}, err error) {\n\tvalueMap = make(map[string]interface{})\n\tfor _, field := range fields {\n\t\tvar result interface{}\n\t\tval, err := c.HGet(key, fmt.Sprintf(\"%s\", field)).Result()\n\t\tif err == redis.Nil {\n\t\t\tvalueMap[field] = result\n\t\t\terr = nil\n\t\t} else if err != nil {\n\t\t\tlogger.Errorf(\"get hash record error: %s\", err.Error())\n\t\t\tvalueMap[field] = result\n\t\t}\n\t\tif val != \"\" {\n\t\t\tvalueMap[field] = val\n\t\t} else {\n\t\t\tvalueMap[field] = result\n\t\t}\n\t}\n\treturn valueMap, err\n}", "title": "" }, { "docid": "0046f2bbd3c5ac2b0111ea7ac9f0c364", "score": "0.5535743", "text": "func (kv *RaftKV) Get(args *GetArgs, reply *GetReply) {\n \t// Your code here.\n \t\n\t//To ensure the wrong leader will be commit the op\n\t//want leeader to received our command \n\t\n\tentry := Op{Key: args.Key, Command: \"Get\", ClientID: args.ClientID, Timestamp: args.Timestamp}\n\tisLeader := kv.sendEntryToLog(entry)\n \t\n\t//if correct leader --> return value from index the KV array by the key \n\t//else return WRONG leader!! \n\tif isLeader {\n\t\treply.WrongLeader = false\n\t\tkv.mu.Lock()\n \t\tdefer kv.mu.Unlock()\n \t\tif val, ok := kv.DB[args.Key]; ok {\n \t\t\treply.Err = OK\n \t\t\treply.Value = val\n \t\t} else {\n \t\t\treply.Err = ErrNoKey\n \t\t}\n \t} else {\n \t\treply.WrongLeader = true\n \t}\n }", "title": "" }, { "docid": "9b09501f286cfac4368b1df88001ec6d", "score": "0.55340767", "text": "func (str Strings) MultiGet(ctx context.Context, keys ...string) ([]string, error) {\n\treq := newRequestSize(1+len(keys), \"\\r\\n$4\\r\\nMGET\")\n\treq.addStrings(keys)\n\treturn str.c.cmdStrings(ctx, req)\n}", "title": "" }, { "docid": "ec752f579332dbdce8dc703b4c26fef4", "score": "0.55192006", "text": "func (r *redisRepo) Get(key string) (string, error) {\n\tval, err := r.rdb.Get(r.ctx, key).Result()\n\treturn val, err\n}", "title": "" }, { "docid": "94327fe1ee1fe77b8308502c26b420d4", "score": "0.5517371", "text": "func (b *BBoltDB) MGet(keys []string) [][]byte {\n\tvar data [][]byte\n\tfor _, key := range keys {\n\t\tval, err := b.get(key)\n\t\tif err != nil {\n\t\t\tdata = append(data, []byte{})\n\t\t\tcontinue\n\t\t}\n\t\tdata = append(data, val)\n\t}\n\treturn data\n}", "title": "" }, { "docid": "bb4eb3ebea6cc91b2510bbff6d5cd2dd", "score": "0.54942316", "text": "func (r *redisRepository) Get(key string) (string, error) {\n\treturn r.client.Get(key).Result()\n}", "title": "" }, { "docid": "cea5ceb3e1bc71555cade16d4e7435c8", "score": "0.5486616", "text": "func TestGetList(t *testing.T) {\n\n\tt.Run(\"get list command using mocked redis\", func(t *testing.T) {\n\t\tt.Parallel()\n\n\t\t// Load redis\n\t\tclient, conn := loadMockRedis()\n\t\tassert.NotNil(t, client)\n\t\tdefer client.CloseAll(conn)\n\n\t\tvar tests = []struct {\n\t\t\ttestCase string\n\t\t\tkey string\n\t\t\tinputList []string\n\t\t\texpectedList []interface{}\n\t\t\texpectedStringList []string\n\t\t}{\n\t\t\t{\n\t\t\t\t\"empty list\",\n\t\t\t\t\"test-set\",\n\t\t\t\t[]string{\"\"},\n\t\t\t\t[]interface{}{\"\"},\n\t\t\t\t[]string{\"\"},\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"one item\",\n\t\t\t\t\"test-set\",\n\t\t\t\t[]string{\"1\"},\n\t\t\t\t[]interface{}{[]byte(\"1\")},\n\t\t\t\t[]string{\"1\"},\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"multiple items\",\n\t\t\t\t\"test-set\",\n\t\t\t\t[]string{\"1\", \"1\"},\n\t\t\t\t[]interface{}{[]byte(\"1\"), []byte(\"1\")},\n\t\t\t\t[]string{\"1\", \"1\"},\n\t\t\t},\n\t\t}\n\t\tfor _, test := range tests {\n\t\t\tt.Run(test.testCase, func(t *testing.T) {\n\t\t\t\tconn.Clear()\n\n\t\t\t\t// The main command to test\n\t\t\t\tgetCmd := conn.Command(ListRangeCommand, test.key, 0, -1).Expect(test.expectedList)\n\n\t\t\t\tlist, err := GetList(context.Background(), client, test.key)\n\t\t\t\tassert.NoError(t, err)\n\t\t\t\tassert.Equal(t, true, getCmd.Called)\n\t\t\t\tassert.Equal(t, test.expectedStringList, list)\n\t\t\t})\n\t\t}\n\t})\n\n\tt.Run(\"get list command using real redis\", func(t *testing.T) {\n\t\tif testing.Short() {\n\t\t\tt.Skip(\"skipping live local redis tests\")\n\t\t}\n\n\t\t// Load redis\n\t\tclient, conn, err := loadRealRedis()\n\t\tassert.NotNil(t, client)\n\t\tassert.NoError(t, err)\n\t\tdefer client.CloseAll(conn)\n\n\t\t// Start with a fresh db\n\t\terr = clearRealRedis(conn)\n\t\tassert.NoError(t, err)\n\n\t\t// Fire the command\n\t\terr = SetList(context.Background(), client, testKey, []string{testStringValue})\n\t\tassert.NoError(t, err)\n\n\t\t// Check that the command worked\n\t\tvar list []string\n\t\tlist, err = GetList(context.Background(), client, testKey)\n\t\tassert.NoError(t, err)\n\t\tassert.Equal(t, []string{testStringValue}, list)\n\t})\n\n\tt.Run(\"get list cmd, trigger context err\", func(t *testing.T) {\n\t\tt.Parallel()\n\n\t\t// Load redis\n\t\tclient, conn := loadMockRedis()\n\t\tassert.NotNil(t, client)\n\t\tclient.CloseAll(conn)\n\n\t\tval, err := GetList(context.TODO(), client, \"123456\")\n\t\tassert.Error(t, err)\n\t\tassert.Equal(t, []string(nil), val)\n\t})\n}", "title": "" }, { "docid": "0817d4ad085617303f073a8c86725056", "score": "0.54798734", "text": "func (rc RemoteCache) GetBytes(ctx context.Context, key string) ([]byte, error) {\n\tvar span opentracing.Span\n\tif rc.TracingEnabled {\n\t\tspan, _ = opentracing.StartSpanFromContext(ctx, \"remote-cache-get-bytes\")\n\t\tspan.SetTag(\"command\", \"GET\")\n\t\tspan.SetTag(\"key\", key)\n\t}\n\tconn := rc.cluster.Get()\n\tdefer conn.Close()\n\tdata, err := redis.Bytes(conn.Do(\"GET\", key))\n\tif rc.TracingEnabled {\n\t\tif err != nil {\n\t\t\tspan.SetTag(\"result\", \"miss\")\n\t\t} else {\n\t\t\tspan.SetTag(\"result\", \"hit\")\n\t\t}\n\t\tspan.Finish()\n\t}\n\treturn data, err\n}", "title": "" }, { "docid": "a3fcfddaf411486a3ee74f2e6c3edd3e", "score": "0.54750985", "text": "func (kv *KVServer) Get(args *GetArgs, reply *GetReply) {\n\t// Your code here.\t\n\top := Op{Operation:\"Get\", Key:args.Key, Value:\"\", Id:args.Id, ClientId:args.ClientId}\n\tindex, _, isLeader := kv.rf.Start(op)\n\treply.WrongLeader = !isLeader\n\tif isLeader == false{\n \treply.Err = ErrWrongLeader\n \treply.Value = \"\"\n \tDPrintf(\"Not leader!\")\n \treturn\n }\n\n kv.mu.Lock()\n\n ch,ok := kv.commits[index]\n if !ok{\n \tkv.commits[index] = make(chan bool,1)\n \tch = kv.commits[index]\n }\n\n kv.mu.Unlock()\n\n\tselect{\n\tcase <-ch: // uid := <-kv.commitGet:\n\t\tkv.mu.Lock()\n\t\tvalue, ok := kv.store[args.Key]\n\t\tkv.mu.Unlock()\n \tif ok{\n \t\treply.Value = value\n \t\treply.Err = OK\n \t\tDPrintf(\"Get value:%v\", reply.Value)\n \t}else{\n \t\tDPrintf(\"Key error! No value for key: %v\", args.Key)\n \t\treply.Value = \"\"\n \t\treply.Err = ErrNoKey\n \t}\n \t//kv.mu.Unlock()\n case <-time.After(time.Millisecond*1000):\n \tDPrintf(\"Timeout!\")\n \treply.Value = \"\"\n \treply.Err = ErrTimeOut\n\t}\n\t\n\t\n}", "title": "" }, { "docid": "c5dc8277f32bdd08d52f6d0c5a8f92d6", "score": "0.54750615", "text": "func (h *RedisClient) HGetAll(key string) map[string]string {\n\tresponse, err := h.client.HGetAll(key).Result()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn response\n}", "title": "" }, { "docid": "4042110cee2681cd2827c6738e9467d3", "score": "0.5474524", "text": "func (p *PkgRedis) Get(key string) (value string, err error) {\n\tconn, err := p.rpool.Dial()\n\tif err != nil {\n\t\tlog.Println(\"Failed to dial connection from connection pool. \", err)\n\t\treturn \"\", err\n\t}\n\tdefer conn.Close()\n\n\tval, err := redis.String(conn.Do(\"GET\", key))\n\tif err != nil {\n\t\tlog.Println(\"Failed to send GET command. \", err)\n\t\treturn \"\", err\n\t}\n\treturn val, err\n}", "title": "" }, { "docid": "c90d5b18217894ea11ed5850e20623ae", "score": "0.5456126", "text": "func (c *Cursor) Get(setkey, setval []byte, op uint) (key, val []byte, err error) {\n\tswitch {\n\tcase len(setkey) == 0:\n\t\terr = c.getVal0(op)\n\tcase len(setval) == 0:\n\t\terr = c.getVal1(setkey, op)\n\tdefault:\n\t\terr = c.getVal2(setkey, setval, op)\n\t}\n\tif err != nil {\n\t\t*c.txn.key = C.MDB_val{}\n\t\t*c.txn.val = C.MDB_val{}\n\t\treturn nil, nil, err\n\t}\n\n\t// When MDB_SET is passed to mdb_cursor_get its first argument will be\n\t// returned unchanged. Unfortunately, the normal slice copy/extraction\n\t// routines will be bad for the Go runtime when operating on Go memory\n\t// (panic or potentially garbage memory reference).\n\tif op == Set {\n\t\tif c.txn.RawRead {\n\t\t\tkey = setkey\n\t\t} else {\n\t\t\tp := make([]byte, len(setkey))\n\t\t\tcopy(p, setkey)\n\t\t\tkey = p\n\t\t}\n\t} else {\n\t\tkey = c.txn.bytes(c.txn.key)\n\t}\n\tval = c.txn.bytes(c.txn.val)\n\n\t// Clear transaction storage record storage area for future use and to\n\t// prevent dangling references.\n\t*c.txn.key = C.MDB_val{}\n\t*c.txn.val = C.MDB_val{}\n\n\treturn key, val, nil\n}", "title": "" }, { "docid": "cc0e31a21955038d648f8441e8c918d4", "score": "0.5455648", "text": "func (ss *ServerService) Get(clientReq *cache.Payload, serverResp *cache.Payload) error {\n\tdebug(id, \"Starting get...\")\n\n\t// Clock Update\n\tvClock.Update(&clientReq.Clock)\n\tvClock.Increment(id)\n\tserverResp.Clock = vClock\n\n\t// Probably want to check the sCache first. Remember to update the sCache if query from the DataStore\n\n\t// Check if it exists in data. If not return ERR_KEY\n\tval, ok := data[clientReq.Key]\n\tif ok {\n\t\tserverResp.Key = clientReq.Key\n\t\tserverResp.Val = val.Val\n\t\tserverResp.ValTime = val.Clock\n\t} else {\n\t\tserverResp.Key = clientReq.Key\n\t\tserverResp.Val = \"ERR_KEY\"\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "eb6f171509b2d5abbb337b87bd217408", "score": "0.54542404", "text": "func (self *ConstHasher) GetN(in_key []byte, num int) ([]string, error) {\n\n\tl := len(in_key)\n\t// incoming bytes + \":\" + {2 digit num}\n\tcache_key := utils.GetBytes(l + 1 + 2)\n\tdefer utils.PutBytes(cache_key)\n\n\tcopy(cache_key, in_key)\n\tcache_key[l] = ':'\n\tbinary.LittleEndian.PutUint16(cache_key[l+1:], uint16(num))\n\n\tkey_str := string(in_key)\n\tcache_key_str := string(cache_key)\n\tsrv, ok := self.Cache.Get(cache_key_str)\n\n\tupStatsd := func(items []string) {\n\t\tfor _, useme := range items {\n\t\t\tstats.StatsdClient.Incr(fmt.Sprintf(\"hashserver.%s.used\", self.cleanKey(useme)), 1)\n\t\t}\n\t}\n\n\tif !ok {\n\t\tstats.StatsdClient.Incr(\"lrucache.miss\", 1)\n\t\tsrv, err := self.Hasher.GetN(key_str, num)\n\t\t//find out real server string(s)\n\t\tvar real_servers []string\n\t\tfor _, s := range srv {\n\t\t\treal_servers = append(real_servers, self.HashKeyToServer[s])\n\t\t}\n\n\t\t//log.Println(\"For: \", in_key, \" Got: \", srv, \" ->\", real_servers)\n\n\t\tself.Cache.Set(cache_key_str, MultiServerCacheItem(real_servers))\n\t\tupStatsd(real_servers)\n\t\treturn real_servers, err\n\t}\n\tupStatsd(srv.(MultiServerCacheItem))\n\tstats.StatsdClient.Incr(\"lrucache.hit\", 1)\n\n\treturn srv.(MultiServerCacheItem), nil\n}", "title": "" }, { "docid": "5f0f8b4954189d36166f48f518d489e1", "score": "0.5447688", "text": "func (kv *ShardKV) Get(args *GetArgs, reply *GetReply) error {\n kv.mu.Lock()\n\tdefer kv.mu.Unlock()\n \n\t// use addop to get the latest state\n\tkv.rsm.AddOp(Op{OpId: common.Nrand(),Type: \"Get\"})\n\t\n\tif _, exist := kv.impl.shards[common.Key2Shard(args.Key)]; !exist{\n reply.Err = ErrWrongGroup\n\t\treturn nil\n\t}\n\n\tif _, exist := kv.impl.key2Val[args.Key]; !exist{\n\t\treply.Err = ErrNoKey\n\t\treturn nil\n\t}\n\n\treply.Err = OK\n\treply.Value = kv.impl.key2Val[args.Key]\n\treturn nil\n}", "title": "" }, { "docid": "b931fec97ae2f79192866b1755893885", "score": "0.54444855", "text": "func Get(key string) (interface{}, bool) {\n\tresult, err := r.Get(context.Background(), key).Result()\n\tif err == redis.Nil {\n\t\treturn \"\", false\n\t} else if err != nil {\n\t\treturn \"\", false\n\t}\n\n\treturn result, true\n}", "title": "" }, { "docid": "bb922588df51e3a058e6e92d5ecf5838", "score": "0.54392976", "text": "func (r *Redis) Get(key string) (interface{}, error) {\n\terr := r.checkConnection()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// TODO: check for redis.Nil: if err == redis.Nil {\n\treturn r.client.Get(key).Result()\n}", "title": "" }, { "docid": "a2e05cd6ce5f25e62fdeb9d5c7c7f802", "score": "0.5438176", "text": "func (r Redis) HGet(key, child string) (string, error) {\n\tconn := r.Pool.Get()\n\tdefer conn.Close()\n\treturn redigo.String(conn.Do(\"HGET\", key, child))\n}", "title": "" }, { "docid": "9b8adf6f94f841ece47562e984891a69", "score": "0.54377294", "text": "func (c *Client) HGetString(userKey, itemKey string) (string, error) {\n\tconn := c.pool.Get()\n\tdefer conn.Close()\n\n\treturn redis.String(conn.Do(\"HGET\", userKey, itemKey))\n\n}", "title": "" }, { "docid": "a98e57c70865ab123b0cb942b22db6cb", "score": "0.5435548", "text": "func (r *Rediaron) GetMulti(ctx context.Context, keys []string) (map[string]string, error) {\n\tdata := map[string]string{}\n\tfetch := func(pipe redis.Pipeliner) error {\n\t\tfor _, k := range keys {\n\t\t\t_, err := pipe.Get(ctx, k).Result()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\tcmders, err := r.cli.Pipelined(ctx, fetch)\n\tfor _, cmd := range cmders {\n\t\tc, ok := cmd.(*redis.StringCmd)\n\t\tif !ok {\n\t\t\treturn nil, ErrBadCmdType\n\t\t}\n\n\t\targs := c.Args()\n\t\tif len(args) != 2 {\n\t\t\treturn nil, ErrBadCmdType\n\t\t}\n\n\t\tkey, ok := args[1].(string)\n\t\tif !ok {\n\t\t\treturn nil, ErrBadCmdType\n\t\t}\n\n\t\tif isRedisNoKeyError(c.Err()) {\n\t\t\treturn nil, perrors.WithMessage(err, fmt.Sprintf(\"Key not found: %s\", key))\n\t\t}\n\n\t\tdata[key] = c.Val()\n\t}\n\treturn data, err\n}", "title": "" }, { "docid": "c61fc02267b90da9c531fc2159d4a87d", "score": "0.5435073", "text": "func Get(db DB, key *Key, obj interface{}) error {\n\tresults := make(chan *OpResult)\n\tgo db.GetMulti([]*Key{key}, []interface{}{obj}, results)\n\treturn (<-results).Err\n}", "title": "" }, { "docid": "bf16f3b7e48b0eee026e61868a86f0af", "score": "0.5434054", "text": "func (c *CacheRedis) Get(key string, outVal interface{}) error {\n\n\tbytes, err := c.Client.Get(key).Bytes()\n\tif err != nil {\n\t\tc.logger.Errorf(\"cache: Get %s failed: %s\", key, err)\n\t\treturn err\n\t}\n\n\tif bytes == nil {\n\t\treturn nil\n\t}\n\n\tif err := c.Unmarshal(bytes, outVal); err != nil {\n\t\tc.logger.Errorf(\"cache: Unmarshal failed: %s\", err)\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "3a148daf98fda928347103cb74afba95", "score": "0.5431983", "text": "func (r *Client) Get(key string) ([]byte, error) {\n\tres, err := r.cli.Get(key).Bytes()\n\n\tif err == redis.Nil {\n\t\t// it means that key does not exist in redis\n\t\treturn nil, nil\n\t} else if err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn res, nil\n}", "title": "" }, { "docid": "53550b50542979abe97fb469f945baf8", "score": "0.5431227", "text": "func (db *RedisDB) Get(key string) *KVResult {\n\tdata, err := db.Client.HGet(db.HashKey, key).Bytes()\n\tif err != nil {\n\t\treturn &KVResult{\n\t\t\tResult: false,\n\t\t\tInfo: err.Error(),\n\t\t}\n\t}\n\treturn &KVResult{\n\t\tData: data,\n\t\tResult: true,\n\t\tInfo: \"\",\n\t}\n}", "title": "" }, { "docid": "a9fe851cf3cf1349d451daecdfa5d552", "score": "0.5417256", "text": "func (c *cache) MGetString(keys ...string) map[string]interface{} {\n\tnowNano := time.Now().UnixNano()\n\treturn c.mgetString(false, nowNano, keys...)\n}", "title": "" }, { "docid": "eb3deda016cb9a2c39d51b8c25591459", "score": "0.54139656", "text": "func JSONGet(conn redis.Conn, key string, path string, options ...string) (res interface{}, err error) {\n\targs := make([]interface{}, 0)\n\targs=append(args, key)\n\targs=append(args, path)\n\tfor _, option := range options {\n\t\targs = append(args, option)\n\t}\n\tname, args, _ := CommandBuilder(\"JSON.GET\", args...)\n\treturn conn.Do(name, args...)\n}", "title": "" } ]
670d5285baa3a9999bf197b01b7c862b
layoutFiles returns as slice of strings reprsenting the layout files used in our application
[ { "docid": "4de407e0ac6c6c17f843703aa684aaa6", "score": "0.7387738", "text": "func layoutFiles() []string {\n\n\tfiles, err := filepath.Glob(LayoutDir + \"*\" + TemplateExt)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn files\n}", "title": "" } ]
[ { "docid": "eb6047cd6c2401069794798d081da0e7", "score": "0.7487111", "text": "func layoutFiles(path string) []string {\n\tlayouts, err := filepath.Glob(path)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn layouts\n}", "title": "" }, { "docid": "c7f30741b7bcacafd7897a5b5e0f27b9", "score": "0.59490424", "text": "func (i *Image) getLayout() []byte {\n\tvar data []string\n\tfor name, info := range i.sections {\n\t\tlayoutName, ok := defaultChromeosFmapConversion[name]\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\t\tlayoutStart := info.Start\n\t\tlayoutEnd := layoutStart + info.Length - 1\n\t\t// lines in the layout file look like this: 0x00000001:0x0000000A FV_GBB\n\t\tdata = append(data, fmt.Sprintf(\"0x%08x:0x%08x %s\", layoutStart, layoutEnd, layoutName))\n\t}\n\tsort.Strings(data)\n\treturn []byte(strings.Join(data, \"\\n\") + \"\\n\")\n}", "title": "" }, { "docid": "e06e85dfae89b782d4ba30c03a12bd05", "score": "0.5811393", "text": "func (lfs LookupFileSystem) LayoutNames() []string {\n\treturn mapKeys(lfs.Layouts, \"\", false)\n}", "title": "" }, { "docid": "ebea4146d04ec3cff5eb1dbdf2618788", "score": "0.56718516", "text": "func Strings(ctx context.Context) (file.Path, error) {\n\treturn layout().Strings(ctx)\n}", "title": "" }, { "docid": "fc0f24d178840ba233da750ffd43ab8c", "score": "0.558198", "text": "func (s *Spec) MarshalFiles() (map[string][]byte, error) {\n\tfiles := map[string][]byte{}\n\tvar cjb bytes.Buffer\n\tclusterJinjaTmpl, err := template.New(\"cluster.jinja\").Parse(clusterJinja)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = clusterJinjaTmpl.Execute(&cjb, s)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfiles[\"gke-cluster.jinja\"] = cjb.Bytes()\n\n\tvar cyb bytes.Buffer\n\tclusterYamlTmpl, err := template.New(\"cluster.yaml\").Parse(clusterYaml)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = clusterYamlTmpl.Execute(&cyb, s)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfiles[\"gke-cluster.yaml\"] = cyb.Bytes()\n\n\tvar pdb bytes.Buffer\n\tif len(s.Volumes) != 0 {\n\t\tvolumesTmpl, err := template.New(\"k8s-volumes.yaml\").Funcs(funcMap).Parse(persistentVolumeYaml)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\terr = volumesTmpl.Execute(&pdb, s)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tfiles[\"k8s-volumes.yaml\"] = pdb.Bytes()\n\t}\n\n\treturn files, nil\n}", "title": "" }, { "docid": "8b88a7991deed786b138c1ec3a8ea6a0", "score": "0.5183268", "text": "func templatePaths(name string) []string {\n\tnames := strings.Split(name, \"/\")\n\tpartialName := strings.Join(names[:len(names)-1], \"/\") + \"/_\" + names[len(names)-1]\n\n\treturn []string{\n\t\tTemplatePath + name + TemplateSuffix,\n\t\tTemplatePath + partialName + TemplateSuffix,\n\t\tTemplatePath + \"layout/\" + name + TemplateSuffix,\n\t\tTemplatePath + \"layout/\" + partialName + TemplateSuffix,\n\t}\n}", "title": "" }, { "docid": "a34b674872bd2f2cf829c6075b653749", "score": "0.5166493", "text": "func template_layout_tmpl() ([]byte, error) {\n\treturn bindata_read(\n\t\t\"D:\\\\GoPath\\\\src\\\\letinvr.com\\\\echo-web\\\\template\\\\layout.tmpl\",\n\t\t\"template/layout.tmpl\",\n\t)\n}", "title": "" }, { "docid": "51401d57a3c1fa886af81e1abcf12989", "score": "0.50910646", "text": "func getConfigTemplateList(sessionData *types.Session) []string {\n\n\tvar files []string\n\tfiles = append(files, \"-\")\n\n\troot := \"./config\"\n\terr := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {\n\n\t\tif filepath.Ext(path) == \".yml\" {\n\t\t\tfiles = append(files, info.Name())\n\t\t}\n\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\n\t\tlogger.LogEntry{\n\t\t\tConfig: nil,\n\t\t\tMarket: nil,\n\t\t\tSession: nil,\n\t\t\tOrder: &types.Order{},\n\t\t\tMessage: GetFunctionName() + \" - \" + err.Error(),\n\t\t\tLogLevel: \"DebugLevel\",\n\t\t}.Do()\n\n\t\tos.Exit(1)\n\n\t}\n\n\treturn files\n\n}", "title": "" }, { "docid": "ced43d5c895f067d7c0402d5269bfff9", "score": "0.50783616", "text": "func Files() []string {\n\tnames := make([]string, 0)\n\twalkFsFn(templateDir, func(path string, info os.FileInfo, err error) error {\n\t\tif info != nil && !info.IsDir() {\n\t\t\tnames = append(names, path)\n\t\t}\n\t\treturn nil\n\t})\n\treturn names\n}", "title": "" }, { "docid": "74eaecfcac6903424397fa6b6c7c864d", "score": "0.50749063", "text": "func loadLayout(data interface{}, funcM *template.FuncMap) *map[string]interface{} {\n layoutM := make(map[string]interface{})\n filenames, _ := filepath.Glob(tmplPath + \"layout/*.tmpl\")\n for _, filename := range filenames {\n baseName := filepath.Base(filename)\n if \"layout.tmpl\" != baseName {\n var b bytes.Buffer\n bytes := []byte(baseName)\n name := string(bytes[: len(bytes) - 5])\n if funcM != nil {\n template.Must(template.ParseFiles(filename)).Funcs(*funcM).Execute(&b, &data)\n } else {\n template.Must(template.ParseFiles(filename)).Execute(&b, &data)\n }\n layoutM[strings.ToUpper(name)] = template.HTML(b.String())\n }\n }\n return &layoutM\n}", "title": "" }, { "docid": "5d22fef9495c12a4ff33250965adc4a4", "score": "0.5067388", "text": "func (h *Service) Layouts(w http.ResponseWriter, r *http.Request) {\n\t// Construct a filter sieve for both applications and measurements\n\tfiltered := map[string]bool{}\n\tfor _, a := range r.URL.Query()[\"app\"] {\n\t\tfiltered[a] = true\n\t}\n\n\tfor _, m := range r.URL.Query()[\"measurement\"] {\n\t\tfiltered[m] = true\n\t}\n\n\tctx := r.Context()\n\tlayouts, err := h.LayoutStore.All(ctx)\n\tif err != nil {\n\t\tError(w, http.StatusInternalServerError, \"Error loading layouts\")\n\t\treturn\n\t}\n\n\tfilter := func(layout *chronograf.Layout) bool {\n\t\t// If the length of the filter is zero then all values are acceptable.\n\t\tif len(filtered) == 0 {\n\t\t\treturn true\n\t\t}\n\n\t\t// If filter contains either measurement or application\n\t\treturn filtered[layout.Measurement] || filtered[layout.Application]\n\t}\n\n\tres := getLayoutsResponse{\n\t\tLayouts: []layoutResponse{},\n\t}\n\tfor _, layout := range layouts {\n\t\tif filter(&layout) {\n\t\t\tres.Layouts = append(res.Layouts, newLayoutResponse(layout))\n\t\t}\n\t}\n\tencodeJSON(w, http.StatusOK, res, h.Logger)\n}", "title": "" }, { "docid": "f0646870a582b41c024223405217a7b6", "score": "0.5061195", "text": "func printFiles(pkg *packages.Package) string {\n\tout := &bytes.Buffer{}\n\tfor _, f := range pkg.Syntax {\n\t\t// filter files in dev package that shouldn't be bundled in template_static.go\n\t\tfileName := pkg.Fset.File(f.Pos()).Name()\n\t\tif ignore(fileName) {\n\t\t\tcontinue\n\t\t}\n\n\t\tlast := f.Package\n\t\tif len(f.Imports) > 0 {\n\t\t\timp := f.Imports[len(f.Imports)-1]\n\t\t\tlast = imp.End()\n\t\t\tif imp.Comment != nil {\n\t\t\t\tif e := imp.Comment.End(); e > last {\n\t\t\t\t\tlast = e\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Pretty-print package-level declarations.\n\t\t// but no package or import declarations.\n\t\tvar buf bytes.Buffer\n\t\tfor _, decl := range f.Decls {\n\t\t\tif decl, ok := decl.(*ast.GenDecl); ok && decl.Tok == token.IMPORT {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tbeg, end := sourceRange(decl)\n\t\t\tprintComments(out, f.Comments, last, beg)\n\n\t\t\tbuf.Reset()\n\t\t\terr := format.Node(&buf, pkg.Fset, &printer.CommentedNode{Node: decl, Comments: f.Comments})\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatalf(\"failed to format source AST node: %v\", err)\n\t\t\t}\n\t\t\tout.Write(buf.Bytes())\n\t\t\tlast = printSameLineComment(out, f.Comments, pkg.Fset, end)\n\t\t\tout.WriteString(\"\\n\\n\")\n\t\t}\n\t\tprintLastComments(out, f.Comments, last)\n\t}\n\t// escape backticks\n\treturn strings.ReplaceAll(out.String(), \"`\", \"`+\\\"`\\\"+`\")\n}", "title": "" }, { "docid": "b00849761bd48079092e5daa02f8370f", "score": "0.50352", "text": "func configFiles(options Options) []string {\n\tif len(options.config) > 0 {\n\t\treturn []string{options.config}\n\t} else {\n\t\treturn []string{\"crane.json\", \"crane.yaml\", \"crane.yml\"}\n\t}\n}", "title": "" }, { "docid": "6ecfd195fabc4a3eadb31e80c7de5a9a", "score": "0.5020287", "text": "func listFiles(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\tfiles, _ := ioutil.ReadDir(config[\"projectdir\"])\n\tvar list string\n\tfor _, f := range files {\n\t\tif !f.IsDir() {\n\t\t\tlist += \"\\n\" + f.Name()\n\t\t}\n\t}\n\tif list != \"\" {\n\t\tio.WriteString(w, list[1:])\n\t}\n}", "title": "" }, { "docid": "5da08d911b324b57a5e96ad39dc70bf3", "score": "0.50016457", "text": "func Files(chartDir string) ([]string, error) {\n\tdir := filepath.Join(chartDir, \"manifests\")\n\tfiles := []string{}\n\n\tif _, err := os.Stat(dir); err != nil {\n\t\treturn files, err\n\t}\n\n\t// add manifest files\n\twalker := func(fname string, fi os.FileInfo, e error) error {\n\t\tif e != nil {\n\t\t\tlog.Warn(\"Encountered error walking %q: %s\", fname, e)\n\t\t\treturn nil\n\t\t}\n\n\t\tif fi.IsDir() {\n\t\t\treturn nil\n\t\t}\n\n\t\tif filepath.Ext(fname) == \".yaml\" {\n\t\t\tfiles = append(files, fname)\n\t\t}\n\n\t\treturn nil\n\t}\n\tfilepath.Walk(dir, walker)\n\n\treturn files, nil\n}", "title": "" }, { "docid": "c6a64aa662669022dc398378fc223ce4", "score": "0.499555", "text": "func IsolatedFilesToString(fMap map[string]*pb.Artifact) string {\n\tmsg := make([]string, 0, len(fMap))\n\tfor name, art := range fMap {\n\t\tmsg = append(msg, fmt.Sprintf(\"%s %s\", name, art.FetchUrl))\n\t}\n\treturn strings.Join(msg, \"\\n\")\n}", "title": "" }, { "docid": "c6a64aa662669022dc398378fc223ce4", "score": "0.499555", "text": "func IsolatedFilesToString(fMap map[string]*pb.Artifact) string {\n\tmsg := make([]string, 0, len(fMap))\n\tfor name, art := range fMap {\n\t\tmsg = append(msg, fmt.Sprintf(\"%s %s\", name, art.FetchUrl))\n\t}\n\treturn strings.Join(msg, \"\\n\")\n}", "title": "" }, { "docid": "c0eb7797776fa4e4112f7680e4b68a5c", "score": "0.49688038", "text": "func (m *customModule) OutputFiles(tag string) (android.Paths, error) {\n\treturn android.PathsForTesting(\"path\" + tag), nil\n}", "title": "" }, { "docid": "9f8576c57bf580f877e140a9f0598a24", "score": "0.49555224", "text": "func (b *platformBootclasspathModule) OutputFiles(tag string) (android.Paths, error) {\n\tswitch tag {\n\tcase \"hiddenapi-flags.csv\":\n\t\treturn android.Paths{b.hiddenAPIFlagsCSV}, nil\n\tcase \"hiddenapi-index.csv\":\n\t\treturn android.Paths{b.hiddenAPIIndexCSV}, nil\n\tcase \"hiddenapi-metadata.csv\":\n\t\treturn android.Paths{b.hiddenAPIMetadataCSV}, nil\n\t}\n\n\treturn nil, fmt.Errorf(\"unknown tag %s\", tag)\n}", "title": "" }, { "docid": "dbd95ef242bf1e09dafef2a912eb7c8b", "score": "0.49533623", "text": "func supportedAttachmentLayoutValues() []string {\n\treturn []string{\n\t\tAttachmentLayoutList,\n\t\tAttachmentLayoutCarousel,\n\t}\n}", "title": "" }, { "docid": "cac8688b04ddefb24c45590ada66eddb", "score": "0.4916277", "text": "func dataFiles() map[string]string {\n\tfolder := dataPath()\n\tfiles := make(map[string]string)\n\terr := filepath.Walk(folder, func(path string, info os.FileInfo, err error) error {\n\t\tif !info.IsDir() && strings.HasSuffix(info.Name(), \".yml\") {\n\t\t\tfiles[strings.Replace(info.Name(), \".yml\", \"\", 1)] = path\n\t\t}\n\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn files\n}", "title": "" }, { "docid": "1bb8ff82539d3025d14b49c55c715415", "score": "0.49074724", "text": "func dockerFiles(files []string) ([]string, error) {\n\ts := []string{}\n\tfor _, f := range files {\n\t\tpath, err := filepath.Abs(f)\n\t\tif err != nil {\n\t\t\treturn s, err\n\t\t}\n\t\ts = append(s, path)\n\t}\n\treturn s, nil\n}", "title": "" }, { "docid": "44c496d3f3906b5087dc4fd64a23373d", "score": "0.4866666", "text": "func getFileSegments() [][]string {\r\n\t// Create a slice of ncFiles\r\n\tfileSegments := make([][]string, 0)\r\n\t// Determine the length of the subslices based on amount of files and how many files can be open at the same time in PuTTY\r\n\tincreaseRate := 1000\r\n\t// Add subslices to fileSegments slice\r\n\tfor i := 0; i < len(xmlFiles)-increaseRate; i +=increaseRate {\r\n\tfileSegments = append(fileSegments, xmlFiles[i:i+increaseRate])\r\n\t}\r\n\tfileSegments = append(fileSegments, xmlFiles[len(xmlFiles)-increaseRate:])\r\n\treturn fileSegments\r\n}", "title": "" }, { "docid": "4df981d44560d738dbbd18ab4ea49cf9", "score": "0.48663658", "text": "func formatMultiAppString(runtimesWDuplicates []string) string {\n\n\t// Remove duplicates, such as in cases of a multi-app project with two PHP apps.\n\truntimes := removeDuplicateRuntimeFromSlice(runtimesWDuplicates)\n\n\t// Catch cases where a single app's `.platform.app.yaml` file is not in root.\n\tif len(runtimes) == 1 {\n\t\treturn runtimes[0]\n\t} else {\n\t\t// Join runtime strings for multi-app slice.\n\t\treturn strings.Join(runtimes, \"/\")\n\t}\n}", "title": "" }, { "docid": "a81f1a4d37ef197ff2aca67421152fe2", "score": "0.48574936", "text": "func (f *FileSpec) String() string {\n\tvar buffer bytes.Buffer\n\tdidStartImportBlock := false\n\n\tbuffer.WriteString(\"package \" + f.Package + \"\\n\\n\")\n\tseen := map[string]struct{}{}\n\n\tvar packages []Import\n\tfor _, blk := range f.CodeBlocks {\n\t\tpackages = append(packages, blk.GetImports()...)\n\t}\n\n\tfor _, imp := range f.InitializationPackages {\n\t\tif _, found := seen[imp.GetPackage()]; !found && imp.GetPackage() != \"\" {\n\t\t\tif !didStartImportBlock {\n\t\t\t\tbuffer.WriteString(\"import (\\n\")\n\t\t\t\tdidStartImportBlock = true\n\t\t\t}\n\n\t\t\tbuffer.WriteString(\"\\t_ \")\n\t\t\tbuffer.WriteString(\"\\\"\" + imp.GetPackage() + \"\\\"\\n\")\n\t\t\tseen[imp.GetPackage()] = struct{}{}\n\t\t}\n\t}\n\n\tfor _, imp := range packages {\n\t\tif _, found := seen[imp.GetPackage()]; !found && imp.GetPackage() != \"\" {\n\t\t\tif !didStartImportBlock {\n\t\t\t\tbuffer.WriteString(\"import (\\n\")\n\t\t\t\tdidStartImportBlock = true\n\t\t\t}\n\n\t\t\tbuffer.WriteString(\"\\t\")\n\t\t\tif imp.GetAlias() != \"\" {\n\t\t\t\tbuffer.WriteString(imp.GetAlias())\n\t\t\t\tbuffer.WriteString(\" \")\n\t\t\t}\n\t\t\tbuffer.WriteString(\"\\\"\" + imp.GetPackage() + \"\\\"\\n\")\n\t\t\tseen[imp.GetPackage()] = struct{}{}\n\t\t}\n\t}\n\n\tif didStartImportBlock {\n\t\tbuffer.WriteString(\")\\n\\n\")\n\t}\n\n\t// create a new array with codeBlocks\n\tvar codeBlocks []CodeBlock\n\tif f.Init != nil {\n\t\tcodeBlocks = append([]CodeBlock{f.Init}, f.CodeBlocks...)\n\t} else {\n\t\tcodeBlocks = append([]CodeBlock(nil), f.CodeBlocks...)\n\t}\n\n\tfor _, codeBlk := range codeBlocks {\n\t\tbuffer.WriteString(codeBlk.String())\n\t\tbuffer.WriteString(\"\\n\")\n\t}\n\n\treturn buffer.String()\n}", "title": "" }, { "docid": "894cc7409d826ac5cb277da28a7180ab", "score": "0.48537737", "text": "func listYamlFiles(root string) []string {\n\tvar files []string\n\tregss := regexp.MustCompile(\".*\\\\.(yaml|yml|tmpl)$\")\n\terr := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\treturn nil\n\t\t}\n\t\tif !info.IsDir() && regss.MatchString(info.Name()) && strings.Contains(path, \"deployments\") {\n\t\t\tfiles = append(files, path)\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn files\n}", "title": "" }, { "docid": "bbc32cf322a9212cec53e85751ccc59f", "score": "0.48355067", "text": "func listFiles(fset *token.FileSet, pinfo *loader.PackageInfo) []string {\n\tfiles := make(map[string]struct{})\n\tfor _, f := range pinfo.Files {\n\t\tfiles[filename(fset, f.Package)] = struct{}{}\n\t}\n\n\tret := make([]string, 0, len(files))\n\tfor f := range files {\n\t\tret = append(ret, f)\n\t}\n\tsort.Strings(ret)\n\n\treturn ret\n}", "title": "" }, { "docid": "d7e55fd7f16802d6a245244f688061ac", "score": "0.47988194", "text": "func StructurizeFiles(filesStr [][]string) []File {\n\tvar Files []File\n\tfor _, file := range filesStr {\n\t\tIsDir\t\t:= file[0]\n\t\tLastM \t\t:= file[1]\n\t\tFName\t\t:= file[2]\n\t\tFSize_HR \t:= file[3]\n\n\t\tvar File \t= File{IsDir, LastM, FName, FSize_HR}\n\t\tFiles \t\t= append(Files, File)\n\t}\n\n\treturn Files\n}", "title": "" }, { "docid": "23225d954b819aabfcad14e4791a5360", "score": "0.47788858", "text": "func (p OutputPaths) Strings() []string {\n\tif p == nil {\n\t\treturn nil\n\t}\n\tret := make([]string, len(p))\n\tfor i, path := range p {\n\t\tret[i] = path.String()\n\t}\n\treturn ret\n}", "title": "" }, { "docid": "b94f2cf1480620f43ed3c1f7ddeebb5e", "score": "0.4772539", "text": "func (r Request) LayoutPath(path string) string {\n\tif FindIndex(r.Preferences.ListLayoutPath, path) != -1 {\n\t\treturn \"list\"\n\t}\n\treturn \"grid\"\n}", "title": "" }, { "docid": "1a251e24a731dd6bcd70df99bd65c0fc", "score": "0.4761364", "text": "func LayoutsDir(dir string) Option {\n\treturn func(m *Manager) {\n\t\tm.layoutsDir = dir\n\t}\n}", "title": "" }, { "docid": "9c6a2e1afcba8556118c019bd140d5c6", "score": "0.4745276", "text": "func (e *GenericTemplateBasedEncoder) Files() []*plugin_go.CodeGeneratorResponse_File {\n\ttemplates := AssetNames()\n\n\tlength := len(templates) + len(e.file.Service)\n\tfiles := make([]*plugin_go.CodeGeneratorResponse_File, 0, length)\n\tfor _, tmplFile := range templates {\n\t\tif tmplFile == \"client.go.tmpl\" || tmplFile == \"server/server.go.tmpl\" {\n\t\t\tfor _, service := range e.file.Service {\n\t\t\t\tcopyTmplFile := tmplFile\n\t\t\t\tswitch tmplFile {\n\t\t\t\tcase \"client.go.tmpl\":\n\t\t\t\t\tcopyTmplFile = fmt.Sprintf(\"%s.go\", util.LowerFirst(service.GetName()))\n\t\t\t\tcase \"server/server.go.tmpl\":\n\t\t\t\t\tcopyTmplFile = fmt.Sprintf(\"server/%s.go\", util.LowerFirst(service.GetName()))\n\t\t\t\t}\n\t\t\t\tcontent, err := e.buildContent(tmplFile, service)\n\t\t\t\tif err != nil {\n\t\t\t\t\tpanic(err)\n\t\t\t\t}\n\t\t\t\tcopyTmplFile = strings.TrimSuffix(copyTmplFile, \".tmpl\")\n\t\t\t\tcopyTmplFile = fmt.Sprintf(\"%s/%s\", e.destinationDir, copyTmplFile)\n\t\t\t\tfiles = append(files, &plugin_go.CodeGeneratorResponse_File{\n\t\t\t\t\tContent: &content,\n\t\t\t\t\tName: &copyTmplFile,\n\t\t\t\t})\n\t\t\t}\n\t\t} else {\n\t\t\tcontent, err := e.buildContent(tmplFile, nil)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\tcopyTmplFile := tmplFile\n\t\t\tcopyTmplFile = strings.TrimSuffix(copyTmplFile, \".tmpl\")\n\t\t\tcopyTmplFile = fmt.Sprintf(\"%s/%s\", e.destinationDir, copyTmplFile)\n\t\t\tfiles = append(files, &plugin_go.CodeGeneratorResponse_File{\n\t\t\t\tContent: &content,\n\t\t\t\tName: &copyTmplFile,\n\t\t\t})\n\t\t}\n\t}\n\treturn files\n}", "title": "" }, { "docid": "094f7e061b8069b97b5b2f27f9a0aa82", "score": "0.47371984", "text": "func listThemes(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\tfiles, _ := ioutil.ReadDir(IDE_DIR + \"assets/themes/\")\n\tvar list string\n\tfor _, f := range files {\n\t\tif !f.IsDir() {\n\t\t\tlist += \"\\n\" + f.Name()\n\t\t}\n\t}\n\tif list != \"\" {\n\t\tio.WriteString(w, list[1:])\n\t}\n}", "title": "" }, { "docid": "52309224a592a441be2a61256101f243", "score": "0.4732735", "text": "func (b *Bundle) Files() []string {\n\treturn b.names\n}", "title": "" }, { "docid": "c22c287d967967e2d879cd9047264616", "score": "0.4722446", "text": "func FormatFiles(files []os.FileInfo, path string) ([]FileInfo, []string) {\n\tfilesInfo := make([]FileInfo, len(files))\n\tvar subFolders []string\n\n\tfor k, file := range files {\n\t\tif file.IsDir() == false {\n\t\t\tp := path + \"/\" + file.Name()\n\n\t\t\tfilesInfo[k].Path = p\n\t\t\tfilesInfo[k].Name = file.Name()\n\t\t\tfilesInfo[k].Size = strconv.Itoa(int(file.Size()))\n\t\t\tfilesInfo[k].Modified = file.ModTime().UTC().Format(\"2006-01-02 15:04:05.11\")\n\t\t\tfilesInfo[k].Hash = CreateHash(p)\n\t\t} else {\n\t\t\tsubFolders = append(subFolders, path+\"/\"+file.Name())\n\t\t}\n\t}\n\treturn filesInfo, subFolders\n}", "title": "" }, { "docid": "2e8f430056abbedd2350f5052e65cd29", "score": "0.4699525", "text": "func (client *DockerClient) stackFiles() []string {\n\treturn client.formatServices(\"-c\")\n}", "title": "" }, { "docid": "43840793d5be06efbc2997a8991d7b6c", "score": "0.4698185", "text": "func (g *generator) Resources() string { return g.resources }", "title": "" }, { "docid": "c3e4894682026589b45475e98603dfb9", "score": "0.46824658", "text": "func (blueprintDoc *BlueprintYamlV1) parseFiles() ([]TemplateConfig, error) {\n\tfiles := []FileV1{}\n\ttemplateConfigs := []TemplateConfig{}\n\tif blueprintDoc.Spec.Files != nil {\n\t\tfiles = blueprintDoc.Spec.Files\n\t} else {\n\t\t// for backward compatibility with v8.5\n\t\tfiles = blueprintDoc.Files\n\t}\n\tfor _, m := range files {\n\t\ttemplateConfig, err := parseFileV1(&m)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttemplateConfigs = append(templateConfigs, templateConfig)\n\t}\n\treturn templateConfigs, nil\n}", "title": "" }, { "docid": "b1beecaae563a5967a06798d838d2553", "score": "0.46808523", "text": "func getMinidumps(dirs []string) ([]string, error) {\n\tvar dumps []string\n\tpaths, err := crash.GetCrashes(dirs...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor _, path := range paths {\n\t\tif filepath.Ext(path) == crash.MinidumpExt {\n\t\t\tdumps = append(dumps, path)\n\t\t}\n\t}\n\treturn dumps, nil\n}", "title": "" }, { "docid": "39f695969df270b0c0c568e52f33add5", "score": "0.4648696", "text": "func GetConfigImageFiles() []string {\n\treturn []string{\n\t\t\"/etc/assisted/manifests/pull-secret.yaml\", //nolint:gosec // not hardcoded credentials\n\t\t\"/etc/assisted/manifests/cluster-deployment.yaml\",\n\t\t\"/etc/assisted/manifests/cluster-image-set.yaml\",\n\t\t\"/etc/assisted/manifests/agent-cluster-install.yaml\",\n\t\t\"/etc/assisted/manifests/infraenv.yaml\",\n\t\t\"/etc/assisted/manifests\", // optional nmstateconfig.yaml\n\t\t\"/etc/assisted/extra-manifests\", // all files in directory\n\t\t\"/etc/assisted/hostconfig\", // all files in directory\n\t\t\"/etc/assisted/hostnames\", // all files in directory\n\t\t\"/etc/assisted/network\", // all files in directory\n\t\t\"/etc/NetworkManager/conf.d/clientid.conf\",\n\t\t\"/etc/issue\",\n\t\t\"/etc/systemd/system.conf.d/10-default-env.conf\",\n\t\t\"/root/.docker/config.json\",\n\t\t\"/usr/local/share/start-cluster/start-cluster.env\",\n\t\t\"/usr/local/share/assisted-service/assisted-service.env\",\n\t\t\"/opt/agent/tls/kubeadmin-password.hash\", //nolint:gosec // not hardcoded credentials\n\t\t\"/opt/agent/tls/admin-kubeconfig-signer.key\",\n\t\t\"/opt/agent/tls/admin-kubeconfig-signer.crt\",\n\t\t\"/opt/agent/tls/kube-apiserver-lb-signer.key\",\n\t\t\"/opt/agent/tls/kube-apiserver-lb-signer.crt\",\n\t\t\"/opt/agent/tls/kube-apiserver-localhost-signer.key\",\n\t\t\"/opt/agent/tls/kube-apiserver-localhost-signer.crt\",\n\t\t\"/opt/agent/tls/kube-apiserver-service-network-signer.key\",\n\t\t\"/opt/agent/tls/kube-apiserver-service-network-signer.crt\",\n\t\trendezvousHostEnvPath, // This file must be last in the list\n\t}\n}", "title": "" }, { "docid": "3ea29bd432f64fc7ae2ae405c2b10ab6", "score": "0.46370727", "text": "func (p *Package) List() []string {\n\tpaths := []string{}\n\tfor _, part := range p.parts {\n\t\tpaths = append(paths, part.Path())\n\t}\n\treturn paths\n}", "title": "" }, { "docid": "e3b13fde6779088218c17ab26359207d", "score": "0.46235687", "text": "func (l *L0CompactionFiles) String() string {\n\tif len(l.Files) > 0 {\n\t\treturn fmt.Sprintf(\"First File Address: %p\", &l.Files[0])\n\t}\n\treturn \"\"\n}", "title": "" }, { "docid": "c3d91a651faa71a811e1924381c92f5a", "score": "0.46010542", "text": "func getDirectoryStrings(pf_file *os.File, volinfo_offset uint32, dirstrcnt uint32, dirstroff uint32) []string {\n\tdirstrings := []string{}\n\tcnt := 0\n\tcount := dirstrcnt\n\tdirstr_offset := dirstroff\n\tpf_file.Seek(int64(volinfo_offset), 0)\n\tpf_file.Seek(int64(dirstr_offset), 1)\n\n\tfor cnt < int(count) {\n\t\tstr_len := make([]byte, 2)\n\t\tpf_file.Read(str_len)\n\t\tlen := int(binary.LittleEndian.Uint16(str_len)) * 2\n\t\tdirstr := make([]byte, len)\n\t\tpf_file.Read(dirstr)\n\t\tdata := strings.Replace(string(dirstr), \"\\x00\", \"\", -1)\n\t\tnull := make([]byte, 2)\n\t\tpf_file.Read(null)\n\t\tdirstrings = append(dirstrings, data)\n\t\tcnt += 1\n\t}\n\treturn dirstrings\n}", "title": "" }, { "docid": "082579d706914d64c6a2479c446aebc6", "score": "0.4598283", "text": "func DefaultGetFiles(yamlFile string) ([]string, error) {\n\tvar op errors.Op = \"metadataobject.DefaultGetFiles\"\n\trootFileContents, err := ioutil.ReadFile(yamlFile)\n\tif err != nil {\n\t\tif stderrors.Is(err, os.ErrNotExist) {\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn nil, errors.E(op, err)\n\t}\n\tvar rootIsMapArray []map[string]yaml.Node\n\tfiles := []string{yamlFile}\n\tparentDir := filepath.Dir(yamlFile)\n\terr = yaml.Unmarshal(rootFileContents, &rootIsMapArray)\n\tif err == nil {\n\t\tfor _, item := range rootIsMapArray {\n\t\t\tfor _, node := range item {\n\t\t\t\tnodeFiles, err := metadatautil.GetIncludeTagFiles(&node, parentDir)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, errors.E(op, err)\n\t\t\t\t}\n\t\t\t\tfiles = append(files, nodeFiles...)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tvar rootIsMap map[string]yaml.Node\n\t\terr = yaml.Unmarshal(rootFileContents, &rootIsMap)\n\t\tif err == nil {\n\t\t\tfor _, node := range rootIsMap {\n\t\t\t\tnodeFiles, err := metadatautil.GetIncludeTagFiles(&node, parentDir)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, errors.E(op, err)\n\t\t\t\t}\n\t\t\t\tfiles = append(files, nodeFiles...)\n\t\t\t}\n\t\t} else {\n\t\t\treturn nil, errors.E(op, fmt.Errorf(\"finding child files in failed: %w\", err))\n\t\t}\n\t}\n\n\treturn files, nil\n}", "title": "" }, { "docid": "37b5098fc8679ceb9cc76aae244ece36", "score": "0.45763534", "text": "func dumpStringsSliceToFile(repos []string, filePath string) {\n\tcontent := strings.Join(repos, \"\\n\")\n\tioutil.WriteFile(filePath, []byte(content), 0755)\n}", "title": "" }, { "docid": "5d543463c7d81f20f2d93fb56c51eff2", "score": "0.45684096", "text": "func candidateFiles(stem string) ([]string, error) {\n\tcwd, err := os.Getwd()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tconfDir, err := os.UserConfigDir()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\thomeDir, err := os.UserHomeDir()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar paths []string\n\tpaths = append(paths, filepath.Join(cwd, stem+\".yml\"))\n\tpaths = append(paths, filepath.Join(cwd, stem+\".yaml\"))\n\tpaths = append(paths, filepath.Join(confDir, stem, stem+\".yml\"))\n\tpaths = append(paths, filepath.Join(confDir, stem, stem+\".yaml\"))\n\tif filepath.Clean(confDir) != filepath.Join(homeDir, \".config\") {\n\t\tpaths = append(paths, filepath.Join(homeDir, \".config\", stem, stem+\".yml\"))\n\t\tpaths = append(paths, filepath.Join(homeDir, \".config\", stem, stem+\".yaml\"))\n\t}\n\treturn paths, nil\n}", "title": "" }, { "docid": "f6b84f5c1068c0d0fa37839dbd625d49", "score": "0.45662427", "text": "func (o GetDataCollectionRuleDataSourceLogFileOutput) FilePatterns() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v GetDataCollectionRuleDataSourceLogFile) []string { return v.FilePatterns }).(pulumi.StringArrayOutput)\n}", "title": "" }, { "docid": "57d43155a1308335cac5656c2e00d7f9", "score": "0.45630562", "text": "func GeneratePackFileString(assetBundle *ReferencedAssets, ignoreErrors bool) (string, error) {\n\tvar filesProcessed = make(map[string]bool)\n\tresult := fmt.Sprintf(\"package %s\\n\\n\", assetBundle.PackageName)\n\tif len(assetBundle.Groups) > 0 || len(assetBundle.Assets) > 0 {\n\t\tresult += \"import \\\"github.com/sohaha/zstatic\\\"\\n\\n\"\n\t\tresult += \"func init() {\\n\"\n\t\tfor _, group := range assetBundle.Groups {\n\t\t\t// Read all assets from the directory\n\t\t\tfiles, err := getAllFilesInDirectory(group.FullPath)\n\t\t\tgroupPrefix := filepath.ToSlash(group.FullPath)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\tfor _, file := range files {\n\t\t\t\t// Read in File\n\t\t\t\tpackedData, err := zstatic.CompressFile(file)\n\t\t\t\tif err != nil && !ignoreErrors {\n\t\t\t\t\treturn \"\", err\n\t\t\t\t}\n\t\t\t\tlocalPath := strings.TrimPrefix(file, groupPrefix+\"/\")\n\t\t\t\tresult += fmt.Sprintf(\" zstatic.AddByteAsset(\\\"%s\\\", \\\"%s\\\",%#v)\\n\", group.LocalPath, localPath, packedData)\n\t\t\t\t// result += fmt.Sprintf(\" zstatic.AddAsset(\\\"%s\\\", \\\"%s\\\", \\\"%s\\\")\\n\", groupPrefix, localPath, packedData)\n\t\t\t\tfilesProcessed[file] = true\n\t\t\t\t// fmt.Printf(\"Packed: %s\\n\", file)\n\t\t\t}\n\t\t}\n\t\tfor _, asset := range assetBundle.Assets {\n\t\t\tgroupPath := \".\"\n\t\t\tif asset.Group != nil {\n\t\t\t\tgroupPath = asset.Group.LocalPath\n\t\t\t}\n\t\t\tfullPath, err := filepath.Abs(filepath.Join(groupPath, asset.AssetPath))\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\t// if _, exists := filesProcessed[fullPath]; exists == true {\n\t\t\t// \tcontinue\n\t\t\t// }\n\t\t\tpackedData, err := zstatic.CompressFile(fullPath)\n\t\t\tif err != nil && !ignoreErrors {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\tresult += fmt.Sprintf(\" zstatic.AddByteAsset(\\\".\\\", \\\"%s\\\", %#v)\\n\", asset.Name, packedData)\n\t\t\tfilesProcessed[fullPath] = true\n\t\t}\n\t\tresult += \"}\\n\"\n\t}\n\treturn result, nil\n}", "title": "" }, { "docid": "ae51dc501d281c7d7994bdc50a58a899", "score": "0.45550123", "text": "func dirList(path string) ([]string, error) {\n\tnames := []string{}\n\tfiles, err := ioutil.ReadDir(path)\n\tif err != nil {\n\t\tlog.Printf(\"Template error: %v\", err)\n\t\treturn names, nil\n\t}\n\tfor _, f := range files {\n\t\tnames = append(names, f.Name())\n\t}\n\treturn names, nil\n}", "title": "" }, { "docid": "ae51dc501d281c7d7994bdc50a58a899", "score": "0.45550123", "text": "func dirList(path string) ([]string, error) {\n\tnames := []string{}\n\tfiles, err := ioutil.ReadDir(path)\n\tif err != nil {\n\t\tlog.Printf(\"Template error: %v\", err)\n\t\treturn names, nil\n\t}\n\tfor _, f := range files {\n\t\tnames = append(names, f.Name())\n\t}\n\treturn names, nil\n}", "title": "" }, { "docid": "fca54863bd4555019ec69e088091cac0", "score": "0.4532965", "text": "func getResourceFiles() map[string]bool {\n\tfilesMap := make(map[string]bool)\n\t// Get the mandatory resource files and add to the the map\n\tfor _, file := range viper.GetStringSlice(constant.RESOURCE_FILES_MANDATORY) {\n\t\tfilesMap[file] = true\n\t}\n\t// Get the mandatory optional files and add to the the map\n\tfor _, file := range viper.GetStringSlice(constant.RESOURCE_FILES_OPTIONAL) {\n\t\tfilesMap[file] = false\n\t}\n\treturn filesMap\n}", "title": "" }, { "docid": "0941e07122f9df1eae8de323560ad088", "score": "0.45292193", "text": "func GetStackFiles(cwd string) []string {\n\tresult := []string{}\n\tpaths, err := os.ReadDir(cwd)\n\tif err != nil {\n\t\treturn nil\n\t}\n\tfor _, info := range paths {\n\t\tif info.IsDir() {\n\t\t\tcontinue\n\t\t}\n\t\tif strings.HasPrefix(info.Name(), \"docker-compose\") || strings.HasPrefix(info.Name(), \"okteto-compose\") || strings.HasPrefix(info.Name(), \"okteto-stack\") || strings.HasPrefix(info.Name(), \"stack\") {\n\t\t\tresult = append(result, info.Name())\n\t\t}\n\t}\n\n\tif err != nil {\n\t\tlog.Infof(\"could not get stack files: %s\", err.Error())\n\t}\n\treturn result\n\n}", "title": "" }, { "docid": "b854e368d7524443d30067de5fb483e1", "score": "0.45275164", "text": "func loadResources(rawPaths []string) []resourceHandler {\n\tvar buff []resourceHandler\n\tfor _, pathPattern := range rawPaths {\n\t\tmatches, err := filepath.Glob(pathPattern)\n\t\tif err != nil {\n\t\t\tlog.Println(\"warning: Invalid file path pattern\", pathPattern)\n\t\t\tcontinue\n\t\t}\n\t\tfor _, fp := range matches {\n\t\t\tcontent, err := loadFile(fp)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(\"warning: Unable to load requested file\", fp)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Multiple YAML doc can exist within one file\n\t\t\tdocStrs := strings.Split(content, yamlDelimiter)\n\t\t\tfor _, docStr := range docStrs {\n\t\t\t\tresource, err := loadYAML([]byte(docStr))\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Printf(\"warning: unable to parse YAML [%s]:\\n%s\", err.Error(), docStr)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif err = resource.validate(); err != nil {\n\t\t\t\t\tlog.Printf(\"warning: YAML validation failed [%s]:\\n%s\", err.Error(), docStr)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tbuff = append(buff, resource)\n\t\t\t}\n\t\t}\n\t}\n\treturn buff\n}", "title": "" }, { "docid": "72b90edd6aa57a98e06acef2aa20f828", "score": "0.4522143", "text": "func getFileSegments() [][]string {\n\t// Create a slice of ncFiles\n\tfileSegments := make([][]string, 0)\n\t// Determine the length of the subslices based on amount of files and how many files can be open at the same time in PuTTY\n\tincreaseRate := 250\n\t// Add subslices to fileSegments slice\n\tfor i := 0; i < len(cdlFiles)-increaseRate; i += increaseRate {\n\t\tfileSegments = append(fileSegments, cdlFiles[i:i+increaseRate])\n\t}\n\tfileSegments = append(fileSegments, cdlFiles[len(cdlFiles)-increaseRate:])\n\treturn fileSegments\n}", "title": "" }, { "docid": "092c0d9683391fa300c14106ab047571", "score": "0.45221406", "text": "func getResources(st []helm.KubernetesResourceTemplate) ([]resource, error) {\n\tvar resources []resource\n\tfor _, t := range st {\n\t\tyamlStruct, err := utils.ExtractYamlParameters(t.FilePath)\n\t\tyamlFile, err := ioutil.ReadFile(t.FilePath)\n\t\tif err != nil {\n\t\t\treturn nil, pkgerrors.Wrap(err, \"Failed to get the resources..\")\n\t\t}\n\t\tn := yamlStruct.Metadata.Name + SEPARATOR + yamlStruct.Kind\n\t\t// This might happen when the rendered file just has some comments inside, no real k8s object.\n\t\tif n == SEPARATOR {\n\t\t\tlog.Info(\":: Ignoring, Unable to render the template ::\", log.Fields{\"YAML PATH\": t.FilePath})\n\t\t\tcontinue\n\t\t}\n\n\t\tresources = append(resources, resource{name: n, filecontent: string(yamlFile)})\n\n\t\tlog.Info(\":: Added resource into resource-order ::\", log.Fields{\"ResourceName\": n})\n\t}\n\treturn resources, nil\n}", "title": "" }, { "docid": "5928d4e81a77920756a2bb2562bac78e", "score": "0.45215622", "text": "func GetFiles() *template.Template {\n\tvar templates *template.Template\n\tvar allFiles []string\n\tvar files, err = ioutil.ReadDir(\"./web/templates\")\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tfor _, file := range files {\n\t\tfilename := file.Name()\n\t\tif strings.HasSuffix(filename, \".tmpl\") {\n\t\t\tallFiles = append(allFiles, \"./web/templates/\"+filename)\n\t\t}\n\t}\n\ttemplates, err = template.ParseFiles(allFiles...)\n\treturn templates\n}", "title": "" }, { "docid": "f4da8c2738b94bb71839c832a8b1a0ff", "score": "0.4514132", "text": "func (mo *VirtualMachine) Layout() (*VirtualMachineFileLayout, error) {\n\tp, err := mo.currentProperty(\"layout\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif p != nil {\n\t\treturn p.(*VirtualMachineFileLayout), nil\n\t}\n\treturn nil, nil\n\n}", "title": "" }, { "docid": "b6898ce7e00426da0907c9c5f2f19916", "score": "0.4511257", "text": "func ContainerNames() []string {\n\t// FIXME: Support custom config paths\n\tmatches, err := filepath.Glob(filepath.Join(DefaultConfigPath(), \"/*/config\"))\n\tif err != nil {\n\t\treturn nil\n\t}\n\n\tfor i, v := range matches {\n\t\tmatches[i] = filepath.Base(filepath.Dir(v))\n\t}\n\treturn matches\n}", "title": "" }, { "docid": "6ed5ae55d753dbeb0c1887b13dce8325", "score": "0.45078525", "text": "func LocalizedFiles() []Filename {\n\treturn []Filename{CybStrng, MfdArt, CitALog, CitBark, LowIntr, SvgaIntr}\n}", "title": "" }, { "docid": "f3bb9d54396347d8823f0e22a919bd97", "score": "0.4506178", "text": "func extractAssetsFileNames(jr readJobResponse) []string {\n\tvar files []string\n\n\tif strings.HasSuffix(jr.DeviceLogURL, \"/deviceLogs\") {\n\t\tfiles = append(files, \"device.log\")\n\t}\n\tif strings.HasSuffix(jr.VideoURL, \"/video.mp4\") {\n\t\tfiles = append(files, \"video.mp4\")\n\t}\n\tif len(jr.Screenshots) > 0 {\n\t\tfiles = append(files, \"screenshots.zip\")\n\t}\n\n\t// xcuitest.log is available for espresso according to API, but will always be empty,\n\t// => hiding it until API is fixed.\n\tif jr.AutomationBackend == xcuitest.Kind && strings.HasSuffix(jr.FrameworkLogURL, \"/xcuitestLogs\") {\n\t\tfiles = append(files, \"xcuitest.log\")\n\t}\n\t// junit.xml is available only for native frameworks.\n\tif jr.AutomationBackend == xcuitest.Kind || jr.AutomationBackend == espresso.Kind {\n\t\tfiles = append(files, \"junit.xml\")\n\t}\n\treturn files\n}", "title": "" }, { "docid": "7286d341d372bb654b6ccf4ba4b79ec0", "score": "0.4499786", "text": "func (parser *Parser) LoadSiteLayouts() {\n\tparser.getLayout(parser.Config.Layout)\n\tfiles, _ := parser.Storage.GetAllFiles(parser.prefix(PrefixLayouts))\n\tfor _, file := range files {\n\t\tif file.IsDir {\n\t\t\tcontinue\n\t\t}\n\t\tparser.getLayout(strings.Trim(strings.TrimLeft(file.Path, PrefixLayouts), \"/\"))\n\t}\n}", "title": "" }, { "docid": "628df3fb66adc784e76804a4b091a4ef", "score": "0.4497885", "text": "func GetLayoutTestsHandler(ctx *router.Context) {\n\tc, w := ctx.Context, ctx.Writer\n\tc, cancelFunc := context.WithTimeout(c, 60*time.Second)\n\tdefer cancelFunc()\n\n\tfs, err := te.LoadAll(c)\n\tif err != nil {\n\t\terrStatus(c, w, http.StatusInternalServerError, err.Error())\n\t\treturn\n\t}\n\n\tres := []*shortExp{}\n\tfor _, f := range fs.Files {\n\t\tfor _, e := range f.Expectations {\n\t\t\tif e.TestName != \"\" {\n\t\t\t\tres = append(res, &shortExp{\n\t\t\t\t\tFileName: f.Path,\n\t\t\t\t\tLineNumber: e.LineNumber + 1,\n\t\t\t\t\tBugs: e.Bugs,\n\t\t\t\t\tTestName: e.TestName,\n\t\t\t\t\tModifiers: e.Modifiers,\n\t\t\t\t\tExpectations: e.Expectations,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\tsort.Sort(byTestName(res))\n\n\tb, err := json.Marshal(res)\n\tif err != nil {\n\t\terrStatus(c, w, http.StatusInternalServerError, err.Error())\n\t\treturn\n\t}\n\n\tfmt.Fprintf(w, \"%v\\n\", string(b))\n}", "title": "" }, { "docid": "c7887607e78b3f55f45815a214284521", "score": "0.4496081", "text": "func tplPaths(ska, tpl string) (vp, tp string) {\n\ttplf := fmt.Sprintf(\"%s/%s\", ska, tpl)\n\n\treturn fmt.Sprintf(\"%s/values.toml\", tplf), fmt.Sprintf(\"%s/templates\", tplf)\n}", "title": "" }, { "docid": "7c20736c9d957210bf70ec33ab304e60", "score": "0.44927734", "text": "func GetFilesFromManifestAsStringList(dir string, regex string, packageYaml string) (string, error) {\n\tvar stringList strings.Builder\n\tlibRegEx, e := regexp.Compile(regex)\n\tif e != nil {\n\t\tlog.Fatal(\"Error compiling regex for registry file\", e)\n\t}\n\n\te = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {\n\t\tif packageYaml != \"\" { // PackageYaml would not be empty string if getting CRD - only want to get the CRDs from the package of the currentCSV version\n\t\t\tversion, err := GetCurrentCSVFromManifest(packageYaml)\n\n\t\t\tif err == nil && libRegEx.MatchString(info.Name()) && strings.Contains(path, version) {\n\t\t\t\treturn ProcessYamlFile(path, &stringList)\n\t\t\t}\n\n\t\t\treturn err\n\t\t}\n\t\t// Otherwise find all matching files and process to a string list\n\t\tif err == nil && libRegEx.MatchString(info.Name()) {\n\t\t\treturn ProcessYamlFile(path, &stringList)\n\t\t}\n\n\t\treturn nil\n\t})\n\n\treturn stringList.String(), e\n}", "title": "" }, { "docid": "4538088d3a51caed0abc83b1c58afc75", "score": "0.4490969", "text": "func renderOffers(offers []*Offer, paths ...string) (string, error) {\n\tvar tmpl = template.Must(template.ParseFiles(paths...))\n\tvar out bytes.Buffer\n\terr := tmpl.Execute(&out, offers)\n\treturn out.String(), err\n}", "title": "" }, { "docid": "9550913cbb0c077c0aea4ebae6bd5a97", "score": "0.44897884", "text": "func FileList() map[string]string {\n\tlist := map[string]string{\n\t\t\"rates\": filepath.Join(\".\", \"data\", viper.GetString(\"data.rates\")),\n\t\t\"consultants\": filepath.Join(\".\", \"data\", viper.GetString(\"data.consultants\")),\n\t\t\"projects\": filepath.Join(\".\", \"data\", viper.GetString(\"data.projects\")),\n\t\t\"reported_records\": filepath.Join(\".\", \"data\", viper.GetString(\"data.reportedRecords\")),\n\t\t\"holidays\": filepath.Join(\".\", \"data\", viper.GetString(\"data.holidays\")),\n\t}\n\treturn list\n}", "title": "" }, { "docid": "a6108eb07429d894344ef6dbf562dee5", "score": "0.44866562", "text": "func GetPackagePaths(packages []Package, dirs []string, inputTemplate string,\n\toutputTemplate string) ([]Package, error) {\n\tfilledPackages := []Package{}\n\tfor _, pkg := range packages {\n\t\tfor _, path := range dirs {\n\t\t\tfilledPkg := Package{\n\t\t\t\tDir: filepath.Base(path),\n\t\t\t\tOS: pkg.OS,\n\t\t\t\tArch: pkg.Arch,\n\t\t\t\tArchive: pkg.Archive,\n\t\t\t}\n\n\t\t\tinputTpl, err := template.New(\"input\").Parse(inputTemplate)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Wrap(err, \"input template error\")\n\t\t\t}\n\t\t\tvar inputPath bytes.Buffer\n\t\t\tif err = inputTpl.Execute(&inputPath, &filledPkg); err != nil {\n\t\t\t\treturn nil, errors.Wrap(err, \"error generating input path\")\n\t\t\t}\n\t\t\tfilledPkg.ExePath = inputPath.String()\n\t\t\tif strings.ToLower(filledPkg.OS) == \"windows\" {\n\t\t\t\tfilledPkg.ExePath = fmt.Sprintf(\"%s.exe\", filledPkg.ExePath)\n\t\t\t}\n\n\t\t\toutputTpl, err := template.New(\"output\").Parse(outputTemplate)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Wrap(err, \"output template error\")\n\t\t\t}\n\n\t\t\tvar outputPath bytes.Buffer\n\t\t\tif err := outputTpl.Execute(&outputPath, &filledPkg); err != nil {\n\t\t\t\treturn nil, errors.Wrap(err, \"error generating output path\")\n\t\t\t}\n\t\t\tfilledPkg.ArchivePath = outputPath.String()\n\n\t\t\tfilledPackages = append(filledPackages, filledPkg)\n\t\t}\n\t}\n\treturn filledPackages, nil\n}", "title": "" }, { "docid": "2681e0f62b913076995f769d18441530", "score": "0.44706428", "text": "func generate_markdown(groups map[string][]string,output_dir string){\n\n for full_path, exts := range groups {\n //build markdown content\n md_sb := strings.Builder{}\n sort.Strings(exts)\n\n toc_md := generate_toc(exts,extension_map)\n title_md := generate_title(full_path)\n\n md_sb.WriteString(title_md)\n md_sb.WriteString(toc_md)\n\n for _, ext := range exts {\n if ext_lang,ok := extension_map[ext]; ok {\n complete_path := fmt.Sprintf(\"%v.%v\",full_path,ext)\n content,err := ioutil.ReadFile(complete_path)\n\n if err == nil {\n top_markdown := fmt.Sprintf(\"\\n## %v\\n```%v\\n\",ext_lang,ext)\n bottom_markdown := \"\\n```\\n\"\n md_sb.WriteString(top_markdown)\n md_sb.Write(content)\n md_sb.WriteString(bottom_markdown)\n }\n\n }\n }\n markdown := []byte(md_sb.String())\n fmt.Println(\"full_path=\",full_path)\n markdown_file := filepath.Join(output_dir,full_path+\".md\")\n markdown_dir,_ := filepath.Split(markdown_file)\n os.MkdirAll(markdown_dir,os.ModePerm)\n err := ioutil.WriteFile(markdown_file,markdown,0644) // -rw-rw-r--\n if err != nil {\n log.Fatalf(\"Error with generating %v: %v\",markdown_file,err)\n }\n }\n\n}", "title": "" }, { "docid": "8ef6bc0ec14a62f7b54354df877b8d28", "score": "0.44702104", "text": "func contentiousFilesIn(dir string) (contentious []string, err error) {\n\tfiles, err := ioutil.ReadDir(dir)\n\tfor _, file := range files {\n\t\tfor _, name := range contentiousFiles {\n\t\t\tif file.Name() == name {\n\t\t\t\tcontentious = append(contentious, name)\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "title": "" }, { "docid": "7ca9511c19595f7bbc6fd01041666026", "score": "0.44686136", "text": "func ConfigDerive() []string {\n\n\t//make type lowercase\n\tconfigType := strings.ToLower(os.Getenv(\"BUILDER_PROJECT_TYPE\"))\n\tbuildFile := os.Getenv(\"BUILDER_BUILD_FILE\")\n\n\tvar files []string\n\tif (configType == \"go\") {\n\t\tif (buildFile != \"\") {\n\t\t\t//custom build file from builder.yaml\n\t\t\tfiles = []string{buildFile}\n\t\t} else {\n\t\t\t//default\n\t\t\tfiles = []string{\"main.go\"}\n\t\t}\n\t} else if (configType == \"node\" || configType == \"npm\") {\n\t\tif (buildFile != \"\") {\n\t\t\tfiles = []string{buildFile}\n\t\t} else {\n\t\t\tfiles = []string{\"package.json\"}\n\t\t}\n\t} else if (configType == \"java\") {\n\t\tif (buildFile != \"\") {\n\t\t\tfiles = []string{buildFile}\n\t\t} else {\n\t\t\tfiles = []string{\"pom.xml\"}\n\t\t}\n\t} else if (configType == \"ruby\") {\n\t\tif (buildFile != \"\") {\n\t\t\tfiles = []string{buildFile}\n\t\t} else {\n\t\t\tfiles = []string{\"gemfile.lock\", \"gemfile\"} \n\t\t}\n\t} else if (configType == \"c#\" || configType == \"csharp\") {\n\t\tif (buildFile != \"\") {\n\t\t\tfiles = []string{buildFile}\n\t\t} else {\n\t\t\tfiles = []string{\".csproj\", \".sln\"}\n\t\t}\n\t} else if (configType == \"python\") {\n\t\tif (buildFile != \"\") {\n\t\t\tfiles = []string{buildFile}\n\t\t} else {\n\t\t\tfiles = []string{\"requirements.txt\"}\n\t\t}\n\t}\n\n\treturn files\n}", "title": "" }, { "docid": "59544cae3cb13b7fc9802d0192ff3bb3", "score": "0.44673422", "text": "func getTorrentFilesList(t *torrent.Torrent) *widgets.Table {\n\t// TODO: table headers.\n\tout := widgets.NewTable()\n\tout.Title = \"Files\"\n\tout.RowSeparator = false\n\tout.TextAlignment = ui.AlignLeft\n\tfiles := t.Info().Files\n\tout.Rows = make([][]string, len(files))\n\tfor i, fi := range files {\n\t\tout.Rows[i] = []string{\n\t\t\tfmt.Sprintf(\"%s \", strings.Join(fi.Path, \"/\")),\n\t\t\tfmt.Sprintf(\"%s \", byteLengthToString(fi.Length)),\n\t\t}\n\t}\n\treturn out\n}", "title": "" }, { "docid": "eeaf271d195dbd311c44670f10f64170", "score": "0.4464306", "text": "func (d *Driver) Resources(p ...string) string {\n\tresources := path.Join(p...)\n\tresources = path.Join(\"resources\", resources)\n\treturn resources\n}", "title": "" }, { "docid": "671d14e812969a62eff18bfc2abaec37", "score": "0.44621563", "text": "func parseARJLocalFiles(f *os.File) ([]parse.Layout, error) {\n\tres := []parse.Layout{}\n\tpos, _ := f.Seek(0, os.SEEK_CUR)\n\tentry := 0\n\n\tfor {\n\t\tentry++\n\t\tmagic, _ := parse.ReadUint16le(f, pos)\n\t\tif magic != 0xEA60 {\n\t\t\tlog.Fatalf(\"Unexpected magic %04x at %04x\", magic, pos)\n\t\t}\n\t\tlength, _ := parse.ReadUint16le(f, pos+2)\n\n\t\tlocal := parse.Layout{\n\t\t\tOffset: pos,\n\t\t\tLength: 4,\n\t\t\tType: parse.Group,\n\t\t\tInfo: \"local file header \" + fmt.Sprintf(\"%d\", entry),\n\t\t\tChilds: []parse.Layout{\n\t\t\t\t{Offset: pos, Length: 2, Type: parse.Uint16le, Info: \"magic\"},\n\t\t\t\t{Offset: pos + 2, Length: 2, Type: parse.Uint16le, Info: \"header size\"},\n\t\t\t},\n\t\t}\n\t\tif length == 0 {\n\t\t\tlocal.Info = \"eof marker\"\n\t\t} else {\n\t\t\tlocalHostOSName, _ := parse.ReadToMap(f, parse.Uint8, pos+7, arjHostOS)\n\t\t\tmethodName, _ := parse.ReadToMap(f, parse.Uint8, pos+9, arjMethod)\n\t\t\tfileTypeName, _ := parse.ReadToMap(f, parse.Uint8, pos+10, arjFileType)\n\t\t\tdataLength, _ := parse.ReadUint32le(f, pos+16)\n\t\t\tlocal.Childs = append(local.Childs, []parse.Layout{\n\t\t\t\t{Offset: pos + 4, Length: 1, Type: parse.Uint8, Info: \"size up to and including 'extra data'\"},\n\t\t\t\t{Offset: pos + 5, Length: 1, Type: parse.MinorMajor8Five, Info: \"archiver version\"},\n\t\t\t\t{Offset: pos + 6, Length: 1, Type: parse.MinorMajor8Five, Info: \"minimum archiver version to extract\"},\n\t\t\t\t{Offset: pos + 7, Length: 1, Type: parse.Uint8, Info: \"host OS = \" + localHostOSName},\n\t\t\t\t{Offset: pos + 8, Length: 1, Type: parse.Uint8, Info: \"flags\", Masks: []parse.Mask{\n\t\t\t\t\t{Low: 0, Length: 1, Info: \"garbled\"},\n\t\t\t\t\t{Low: 1, Length: 1, Info: \"reserved\"},\n\t\t\t\t\t{Low: 2, Length: 1, Info: \"volume\"},\n\t\t\t\t\t{Low: 3, Length: 1, Info: \"extfile\"},\n\t\t\t\t\t{Low: 4, Length: 1, Info: \"pathsym\"},\n\t\t\t\t\t{Low: 5, Length: 1, Info: \"backup\"},\n\t\t\t\t\t{Low: 6, Length: 2, Info: \"reserved2\"},\n\t\t\t\t}},\n\t\t\t\t{Offset: pos + 9, Length: 1, Type: parse.Uint8, Info: \"method = \" + methodName},\n\t\t\t\t{Offset: pos + 10, Length: 1, Type: parse.Uint8, Info: \"file type = \" + fileTypeName},\n\t\t\t\t{Offset: pos + 11, Length: 1, Type: parse.Uint8, Info: \"reserved\"},\n\t\t\t\t{Offset: pos + 12, Length: 4, Type: parse.ArjDateTime, Info: \"modified time\"},\n\t\t\t\t{Offset: pos + 16, Length: 4, Type: parse.Uint32le, Info: \"compressed size\"},\n\t\t\t\t{Offset: pos + 20, Length: 4, Type: parse.Uint32le, Info: \"original size\"},\n\t\t\t\t{Offset: pos + 24, Length: 4, Type: parse.Uint32le, Info: \"original file's CRC\"},\n\t\t\t\t{Offset: pos + 28, Length: 2, Type: parse.Uint16le, Info: \"filespec position in filename\"},\n\t\t\t\t{Offset: pos + 30, Length: 2, Type: parse.Uint16le, Info: \"file access mode\"},\n\t\t\t\t{Offset: pos + 32, Length: 1, Type: parse.Uint8, Info: \"first chapter of file's lifespan\"},\n\t\t\t\t{Offset: pos + 33, Length: 1, Type: parse.Uint8, Info: \"last chapter of file's lifespan\"},\n\t\t\t}...)\n\t\t\tlocal.Length += 30\n\n\t\t\twithExtData, _ := parse.ReadUint8(f, pos+4)\n\t\t\tif withExtData == 0x2E {\n\t\t\t\tlocal.Childs = append(local.Childs, []parse.Layout{\n\t\t\t\t\t{Offset: pos + 34, Length: 4, Type: parse.Uint32le, Info: \"extended file position\"},\n\t\t\t\t\t// XXX the following twelve bytes may be present in ARJ 2.62 and above:\n\t\t\t\t\t{Offset: pos + 38, Length: 4, Type: parse.ArjDateTime, Info: \"accessed time\"},\n\t\t\t\t\t{Offset: pos + 42, Length: 4, Type: parse.ArjDateTime, Info: \"created time\"},\n\t\t\t\t\t{Offset: pos + 46, Length: 4, Type: parse.Uint32le, Info: \"original file size\"},\n\t\t\t\t}...)\n\t\t\t\tlocal.Length += 16\n\t\t\t} else if withExtData == 0x1E {\n\t\t\t\t// no ext data\n\t\t\t} else {\n\t\t\t\tlog.Fatalf(\"sample please. local file ext data = %02x\", withExtData)\n\t\t\t}\n\n\t\t\tpos += local.Length\n\n\t\t\t_, fileNameLen, err := parse.ReadZeroTerminatedASCIIUntil(f, pos, arjFileNameMax)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tlocal.Childs = append(local.Childs, []parse.Layout{\n\t\t\t\t{Offset: pos, Length: fileNameLen, Type: parse.ASCIIZ, Info: \"file name\"},\n\t\t\t}...)\n\t\t\tpos += fileNameLen\n\t\t\tlocal.Length += fileNameLen\n\n\t\t\t_, commentLen, err := parse.ReadZeroTerminatedASCIIUntil(f, pos, arjCommentMax)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tlocal.Childs = append(local.Childs, []parse.Layout{\n\t\t\t\t{Offset: pos, Length: commentLen, Type: parse.ASCIIZ, Info: \"file comment\"},\n\t\t\t}...)\n\t\t\tpos += commentLen\n\t\t\tlocal.Length += commentLen\n\n\t\t\tlocal.Childs = append(local.Childs, []parse.Layout{\n\t\t\t\t{Offset: pos, Length: 4, Type: parse.Uint32le, Info: \"basic header crc32\"},\n\t\t\t\t{Offset: pos + 4, Length: 2, Type: parse.Uint16le, Info: \"ext header size\"},\n\t\t\t}...)\n\t\t\tpos += 6\n\t\t\tlocal.Length += 6\n\t\t\t// NOTE: if ext header size > 0, it should follow here. currently unused in file format\n\n\t\t\tlocal.Childs = append(local.Childs, []parse.Layout{\n\t\t\t\t{Offset: pos, Length: int64(dataLength), Type: parse.Bytes, Info: \"compressed data\"},\n\t\t\t}...)\n\t\t\tpos += int64(dataLength)\n\t\t\tlocal.Length += int64(dataLength)\n\t\t}\n\t\tres = append(res, local)\n\t\tif length == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn res, nil\n}", "title": "" }, { "docid": "24ac0544ee83402b6099b62c0adceed5", "score": "0.44586483", "text": "func PackageFiles(pf *packages.Files) (warnings verifier.Warnings, errors verifier.Errors) {\n\tfor _, verifier := range verifiers {\n\t\tws, errs := verifier.Verify(pf)\n\t\twarnings = append(warnings, ws...)\n\t\terrors = append(errors, errs...)\n\t}\n\treturn warnings, errors\n}", "title": "" }, { "docid": "e65df75c3e43a9f60ee450da620e55b0", "score": "0.4453784", "text": "func (fsw *fileSystemWalletStore) List() ([]string, error) {\n\tfiles, err := ioutil.ReadDir(fsw.path)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar labels []string\n\tfor _, file := range files {\n\t\tname := file.Name()\n\t\tif filepath.Ext(name) == dataFileExtension {\n\t\t\tlabels = append(labels, name[:len(name)-extensionLength])\n\t\t}\n\t}\n\n\treturn labels, nil\n}", "title": "" }, { "docid": "1a8a2e2930fe656f3a8807852b76ec65", "score": "0.44411474", "text": "func (ds DataSource) Configs() string {\n\tconfigStr := \"[\"\n\tfor _, cfg := range ds.Config {\n\t\tconfigStr += cfg.RedactedString()\n\t}\n\tconfigStr += \"]\"\n\treturn configStr\n}", "title": "" }, { "docid": "e5d88a55507812483227f57fdc826cfb", "score": "0.44387528", "text": "func filteredReadDir(path string) []dirDisplay {\n\t// Where a .md and an accompanying .md.html exist\n\t// suppress the .md.html output\n\tvar retList []dirDisplay\n\tdlist, err := ioutil.ReadDir(path)\n\tif err != nil {\n\t\treturn nil\n\t}\n\t// remember you can't futz with a map whilst iterating it\n\tdmap := make(map[string]bool) // key on file name, value immaterial\n\tvar mds []string\n\tvar ads []string\n\tfor _, file := range dlist {\n\t\tfname := file.Name()\n\t\tdmap[fname] = true\n\t\tif strings.HasSuffix(fname, \".md\") {\n\t\t\tmds = append(mds, fname)\n\t\t}\n\t\tif strings.HasSuffix(fname, \".ad\") {\n\t\t\tads = append(mds, fname)\n\t\t}\n\t}\n\t// remove the entries for .md.html files where there is a .md source\n\tfor _, md := range mds {\n\t\tdelete(dmap, md+\".html\") // deleting non-existent key is OK\n\t}\n\tfor _, ad := range ads {\n\t\tdelete(dmap, ad+\".html\") // deleting non-existent key is OK\n\t}\n\tfor _, file := range dlist {\n\t\tif _, ok := dmap[file.Name()]; ok {\n\t\t\tvar display dirDisplay\n\t\t\tdisplay.DisplayName = file.Name()\n\t\t\tdisplay.Size = fmt.Sprintf(\"%d\", file.Size())\n\t\t\tdisplay.Modified = tfmt(file.ModTime())\n\t\t\tdisplay.Accessed = accessTime(file)\n\t\t\tif file.IsDir() {\n\t\t\t\tdisplay.Anchor = file.Name() + \"/\" // tell browser to prepend relative URL\n\t\t\t} else {\n\t\t\t\tdisplay.Anchor = file.Name()\n\t\t\t}\n\t\t\tretList = append(retList, display)\n\t\t}\n\t}\n\treturn retList\n}", "title": "" }, { "docid": "4bcb1ede7b00a2803f42dbbd4b05fa89", "score": "0.44360724", "text": "func GenerateSpecFiles() ([]utils.FilesInfo, error) {\n\t// add workload spec file\n\tfileInfo := make([]utils.FilesInfo, 0)\n\tbox := packr.NewBox(\"./../spec/api\")\n\t// Add ebpf kprobe program\n\tksf, err := box.FindString(common.Workload)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"faild to load workload spec file %s\", err.Error())\n\t}\n\tfileInfo = append(fileInfo, utils.FilesInfo{Name: common.Workload, Data: ksf})\n\t// add services spec file\n\tkserv, err := box.FindString(common.Services)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"faild to load services spec file %s\", err.Error())\n\t}\n\tfileInfo = append(fileInfo, utils.FilesInfo{Name: common.Services, Data: kserv})\n\tcns, err := box.FindString(common.ConfigAndStorage)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"faild to load config and storage spec file %s\", err.Error())\n\t}\n\tfileInfo = append(fileInfo, utils.FilesInfo{Name: common.ConfigAndStorage, Data: cns})\n\t// Add config storage spec api\n\tauth, err := box.FindString(common.Authentication)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"faild to load authentication spec file %s\", err.Error())\n\t}\n\tfileInfo = append(fileInfo, utils.FilesInfo{Name: common.Authentication, Data: auth})\n\tauthz, err := box.FindString(common.Authorization)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"faild to load authorization spec file %s\", err.Error())\n\t}\n\tfileInfo = append(fileInfo, utils.FilesInfo{Name: common.Authorization, Data: authz})\n\tpolicy, err := box.FindString(common.Policy)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"faild to load policy spec file %s\", err.Error())\n\t}\n\tfileInfo = append(fileInfo, utils.FilesInfo{Name: common.Policy, Data: policy})\n\textend, err := box.FindString(common.Extend)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"faild to load extend spec file %s\", err.Error())\n\t}\n\tfileInfo = append(fileInfo, utils.FilesInfo{Name: common.Extend, Data: extend})\n\tcluster, err := box.FindString(common.Cluster)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"faild to load cluster spec file %s\", err.Error())\n\t}\n\tfileInfo = append(fileInfo, utils.FilesInfo{Name: common.Cluster, Data: cluster})\n\treturn fileInfo, nil\n}", "title": "" }, { "docid": "c75ba20f8c47a8db4153e230a0d124fc", "score": "0.4428188", "text": "func Assets() map[string]string {\n\tcpy := make(map[string]string, len(files))\n\tfor k, v := range files {\n\t\tcpy[k] = v\n\t}\n\treturn cpy\n}", "title": "" }, { "docid": "c75ba20f8c47a8db4153e230a0d124fc", "score": "0.4428188", "text": "func Assets() map[string]string {\n\tcpy := make(map[string]string, len(files))\n\tfor k, v := range files {\n\t\tcpy[k] = v\n\t}\n\treturn cpy\n}", "title": "" }, { "docid": "f5557e2db7252ebc521c8bf66ce9d535", "score": "0.4426386", "text": "func (lfs LookupFileSystem) DefaultLayout() string {\n\treturn lfs.config.DefLayout\n}", "title": "" }, { "docid": "46361ef3fed2b1ccc6792cc79b48f928", "score": "0.44257754", "text": "func getTestFiles() (string, string) {\n\treturn \"testsystem.db\", \"testtoken.db\"\n}", "title": "" }, { "docid": "b5c130acf20898fb55fef527e6cae9c2", "score": "0.44252658", "text": "func (o DataCollectionRuleDataSourcesLogFileOutput) FilePatterns() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v DataCollectionRuleDataSourcesLogFile) []string { return v.FilePatterns }).(pulumi.StringArrayOutput)\n}", "title": "" }, { "docid": "8d72187496d757898dc4891c6709f2a0", "score": "0.44209465", "text": "func (r *RuleBuilder) DepFiles() WritablePaths {\n\tvar depFiles WritablePaths\n\n\tfor _, c := range r.commands {\n\t\tfor _, depFile := range c.depFiles {\n\t\t\tdepFiles = append(depFiles, depFile)\n\t\t}\n\t}\n\n\treturn depFiles\n}", "title": "" }, { "docid": "5b731edddc127abf0f3c48f62aafb333", "score": "0.4415806", "text": "func getMutableButUnreadablePaths(r *Resource) [][]string {\n\ttfFields := r.ResourceConfig.MutableButUnreadableFields\n\tlowerCamelCasePaths := make([][]string, 0)\n\tfor _, tfField := range tfFields {\n\t\ttfPath := strings.Split(tfField, \".\")\n\t\tlowerCamelCasePaths = append(lowerCamelCasePaths, text.SnakeCaseStrsToLowerCamelCaseStrs(tfPath))\n\t}\n\treturn lowerCamelCasePaths\n}", "title": "" }, { "docid": "afbd9b4380df162d30bd01ff6a84fdb0", "score": "0.4413933", "text": "func getCommitFileDisplayStrings(f *models.CommitFile, diffed bool) []string {\n\tyellow := color.New(color.FgYellow)\n\tgreen := color.New(color.FgGreen)\n\tdefaultColor := color.New(theme.DefaultTextColor)\n\tdiffTerminalColor := color.New(theme.DiffTerminalColor)\n\n\tvar colour *color.Color\n\tswitch f.PatchStatus {\n\tcase patch.UNSELECTED:\n\t\tcolour = defaultColor\n\tcase patch.WHOLE:\n\t\tcolour = green\n\tcase patch.PART:\n\t\tcolour = yellow\n\t}\n\tif diffed {\n\t\tcolour = diffTerminalColor\n\t}\n\treturn []string{utils.ColoredString(f.ChangeStatus, getColorForChangeStatus(f.ChangeStatus)), colour.Sprint(f.Name)}\n}", "title": "" }, { "docid": "d26a86135d89b7f32684fb3838afb6bf", "score": "0.4412545", "text": "func fileList(dir string) []string {\n\tfileList := []string{}\n\terr := filepath.Walk(dir, func(path string, f os.FileInfo, err error) error {\n\t\tif !f.IsDir() && (filepath.Ext(path) == \".js\" || filepath.Ext(path) == \".css\") {\n\t\t\tfileList = append(fileList, path)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\treturn fileList\n}", "title": "" }, { "docid": "135b7c9ea100896c7c0434490db173bb", "score": "0.44123673", "text": "func GetAllResources(configDir string, configurationObject models.Configuration) ([]trivymodels.Image, []models.Resource, error) {\n\timages := make([]trivymodels.Image, 0)\n\tresources := make([]models.Resource, 0)\n\terr := filepath.Walk(configDir, func(path string, info os.FileInfo, err error) error {\n\t\tif !strings.HasSuffix(info.Name(), \".yaml\") && !strings.HasSuffix(info.Name(), \".yml\") {\n\t\t\treturn nil\n\t\t}\n\n\t\tdisplayFilename, err := filepath.Rel(configDir, path)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tvar helmName string\n\t\tfor _, helmObject := range configurationObject.Manifests.Helm {\n\t\t\tif strings.HasPrefix(displayFilename, helmObject.Name+\"/\") {\n\t\t\t\tparts := strings.Split(displayFilename, \"/\")\n\t\t\t\tparts = parts[2:]\n\t\t\t\tdisplayFilename = strings.Join(parts, \"/\")\n\t\t\t\tdisplayFilename = filepath.Join(helmObject.Path, displayFilename)\n\t\t\t\thelmName = helmObject.Name\n\t\t\t}\n\t\t}\n\n\t\tfile, err := os.Open(path)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdecoder := yaml.NewDecoder(file)\n\t\tfor {\n\t\t\t// yaml.Node has access to the comments\n\t\t\t// This allows us to get at the Filename comments that Helm leaves\n\t\t\tyamlNodeOriginal := yaml.Node{}\n\n\t\t\terr = decoder.Decode(&yamlNodeOriginal)\n\t\t\tif err != nil {\n\t\t\t\tif err != io.EOF {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tbreak\n\n\t\t\t}\n\t\t\tyamlNode := map[string]interface{}{}\n\t\t\terr = yamlNodeOriginal.Decode(&yamlNode)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tkind := yamlNode[\"kind\"].(string)\n\t\t\tif kind == \"list\" {\n\t\t\t\tnodes := yamlNode[\"items\"].([]interface{})\n\t\t\t\tfor _, node := range nodes {\n\t\t\t\t\tmetadata := node.(map[string]interface{})[\"metadata\"].(map[string]interface{})\n\t\t\t\t\tnamespace := \"\"\n\t\t\t\t\tif namespaceObj, ok := metadata[\"namespace\"]; ok {\n\t\t\t\t\t\tnamespace = namespaceObj.(string)\n\t\t\t\t\t}\n\t\t\t\t\tnewImages, containers := processYamlNode(node.(map[string]interface{}))\n\t\t\t\t\timages = append(images, newImages...)\n\t\t\t\t\tresources = append(resources, models.Resource{\n\t\t\t\t\t\tKind: node.(map[string]interface{})[\"kind\"].(string),\n\t\t\t\t\t\tName: metadata[\"name\"].(string),\n\t\t\t\t\t\tNamespace: namespace,\n\t\t\t\t\t\tFilename: displayFilename,\n\t\t\t\t\t\tHelmName: helmName,\n\t\t\t\t\t\tContainers: funk.Map(containers, func(c models.Container) string {\n\t\t\t\t\t\t\treturn c.Name\n\t\t\t\t\t\t}).([]string),\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmetadata := yamlNode[\"metadata\"].(map[string]interface{})\n\t\t\t\tnamespace := \"\"\n\t\t\t\tif namespaceObj, ok := metadata[\"namespace\"]; ok {\n\t\t\t\t\tnamespace = namespaceObj.(string)\n\t\t\t\t}\n\t\t\t\tnewImages, containers := processYamlNode(yamlNode)\n\t\t\t\timages = append(images, newImages...)\n\t\t\t\tresources = append(resources, models.Resource{\n\t\t\t\t\tKind: kind,\n\t\t\t\t\tName: metadata[\"name\"].(string),\n\t\t\t\t\tNamespace: namespace,\n\t\t\t\t\tFilename: displayFilename,\n\t\t\t\t\tHelmName: helmName,\n\t\t\t\t\tContainers: funk.Map(containers, func(c models.Container) string {\n\t\t\t\t\t\treturn c.Name\n\t\t\t\t\t}).([]string),\n\t\t\t\t})\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn nil\n\t})\n\treturn images, resources, err\n}", "title": "" }, { "docid": "80dbbc8076700ecedb6c748d982eb62f", "score": "0.44069213", "text": "func ValidateLayout(dir string) error {\n\tfi, err := os.Stat(dir)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error accessing layout: %v\", err)\n\t}\n\tif !fi.IsDir() {\n\t\treturn fmt.Errorf(\"given path %q is not a directory\", dir)\n\t}\n\tvar flist []string\n\tvar imOK, rfsOK bool\n\tvar im io.Reader\n\twalkLayout := func(fpath string, fi os.FileInfo, err error) error {\n\t\trpath, err := filepath.Rel(dir, fpath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tswitch rpath {\n\t\tcase \".\":\n\t\tcase ManifestFile:\n\t\t\tim, err = os.Open(fpath)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\timOK = true\n\t\tcase RootfsDir:\n\t\t\tif !fi.IsDir() {\n\t\t\t\treturn errors.New(\"rootfs is not a directory\")\n\t\t\t}\n\t\t\trfsOK = true\n\t\tdefault:\n\t\t\tflist = append(flist, rpath)\n\t\t}\n\t\treturn nil\n\t}\n\tif err := filepath.Walk(dir, walkLayout); err != nil {\n\t\treturn err\n\t}\n\treturn validate(imOK, im, rfsOK, flist)\n}", "title": "" }, { "docid": "2ef7a4349bab84298d185ce83a3cb954", "score": "0.44048548", "text": "func (a App) ListTemplates() []string {\n\tvar templatesList []string\n\n\tfor _, tpl := range a.tpl.Templates() {\n\t\tif strings.HasSuffix(tpl.Name(), templateExtension) {\n\t\t\ttemplatesList = append(templatesList, strings.TrimSuffix(tpl.Name(), templateExtension))\n\t\t}\n\t}\n\n\treturn templatesList\n}", "title": "" }, { "docid": "fc1ba333b91c40e55ba3154844c1840d", "score": "0.4400172", "text": "func (v *Validation) ChartManifestsPath() string {\n\treturn filepath.Join(v.path, \"manifests\")\n}", "title": "" }, { "docid": "65818ad9c47dcedaeeeb30d350344813", "score": "0.44000047", "text": "func GeneratePaths(attachments []*multipart.FileHeader) []string {\n\tvar pathSlice []string\n\tif len(attachments) > 0 {\n\t\tfor _, attch := range attachments {\n\t\t\tpath := folderName + \"/\" + attch.Filename\n\t\t\tpathSlice = append(pathSlice, path)\n\t\t}\n\t\treturn pathSlice\n\t}\n\treturn pathSlice\n}", "title": "" }, { "docid": "c2136b7135cb1c8badb9ecb8fb5ac0de", "score": "0.4397308", "text": "func getAllCRDsFileNames(box *packr.Box) []string {\n\tvar crds []string\n\tfor _, file := range box.List() {\n\t\tif strings.Contains(file, crdYAMLPattern) {\n\t\t\tcrds = append(crds, file)\n\t\t}\n\t}\n\treturn crds\n}", "title": "" }, { "docid": "ebfc339f15addefe56bb636989e91e9d", "score": "0.43901706", "text": "func displayDataFiles(dirpath string) string {\n\t// Open Directory\n\tdataDir, err := os.Open(dirpath)\n\tdefer dataDir.Close()\n\n\t// File to Load\n\tvar fileToLoad string\n\n\t// If Directory not Found, create one\n\tif err != nil {\n\t\tUtils.Out.Info.Println(\"Data Directory not found, creating one\")\n\t\tos.Mkdir(\"data\", 0755)\n\t} else {\n\t\t// Display which Data to load\n\t\tlist, err := dataDir.Readdirnames(-1)\n\t\tsort.Sort(sort.Reverse(sort.StringSlice(list))) // Sort in Reverse (Latest Year first)\n\n\t\tif err != nil {\n\t\t\tprintln(err.Error())\n\t\t} else {\n\t\t\tif len(list) == 0 { // No Files, load defaul so return nothing\n\t\t\t\treturn \"\"\n\t\t\t} else if len(list) == 1 { // If there is only ONE file, return that\n\t\t\t\treturn list[0]\n\t\t\t}\n\n\t\t\t// Display Prompt to get which Data to Load\n\t\t\tprompt := promptui.Select{\n\t\t\t\tLabel: \"Load Data File\",\n\t\t\t\tItems: list,\n\t\t\t}\n\t\t\t_, fileToLoad, err = prompt.Run()\n\t\t\thandlePromptErr(err)\n\t\t}\n\t}\n\t// Return the Data File to Load\n\treturn fileToLoad\n}", "title": "" }, { "docid": "19e9c747599bc21a096e47a2ca79208d", "score": "0.438401", "text": "func getPatternEntryFiles(files []string) error {\n\tfor _, filename := range files {\n\t\tif _, err := os.Stat(filename); os.IsNotExist(err) {\n\t\t\treturn errors.New(fmt.Sprintf(\"File %v does not exist\", filename))\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "9a94db96244695132ba6eb03e05c4bcb", "score": "0.43836722", "text": "func templates(name string) (files []SourceFile) {\n\terr := fs.WalkDir(content, name, func(path string, d fs.DirEntry, err error) error {\n\t\tif d.IsDir() {\n\t\t\treturn nil\n\t\t}\n\n\t\trelPath, err := filepath.Rel(name, path)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"error removing template prefix\")\n\t\t}\n\n\t\tdata, err := fs.ReadFile(content, path)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tf := SourceFile{\n\t\t\tPath: relPath,\n\t\t\tContents: data,\n\t\t}\n\n\t\tfiles = append(files, f)\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "5dc54c0076663cc97bbfc105c7df3f4b", "score": "0.4370602", "text": "func Dirs(env vos.Env, packagePath string) (map[string]string, error) {\n\twd, err := env.Getwd()\n\tif err != nil {\n\t\treturn nil, errors.WithStack(err)\n\t}\n\n\texe := exec.Command(\"go\", \"list\", \"-f\", \"{{.ImportPath}}:{{.Dir}}\", packagePath)\n\texe.Dir = wd\n\texe.Env = env.Environ()\n\tout, err := exe.CombinedOutput()\n\tif err != nil {\n\t\treturn nil, errors.WithStack(err)\n\t}\n\n\tlines := strings.Split(string(out), \"\\n\")\n\n\tresult := make(map[string]string, len(lines))\n\tfor _, line := range lines {\n\t\tline = strings.TrimSpace(line)\n\t\tif line == \"\" || strings.HasPrefix(line, \"go: warning:\") {\n\t\t\tcontinue\n\t\t}\n\n\t\tchunks := strings.Split(strings.TrimSpace(line), \":\")\n\t\timportPath := chunks[0]\n\t\tdir := chunks[1]\n\n\t\tresult[importPath] = dir\n\t}\n\n\treturn result, nil\n}", "title": "" }, { "docid": "fa06b78cb71c74775a61cb66c0505c7b", "score": "0.43694153", "text": "func LoadDocumentPath(dirpath string) []string {\n\tfilesList := fileutils.ListFile(dirpath)\n\tif filesList == nil {\n\t\tlog.Fatal(\"Unable to load file for directory -> \" + dirpath)\n\t}\n\n\tvar files []string\n\n\tfiles = append(files, filesList...)\n\n\t// for _, item := range filesList {\n\t// \tfiles = append(files, item)\n\t// fileType, err := fileutils.GetFileContentType(item)\n\t// if err != nil {\n\t// \tlog.Println(\"Error for file [\" + item + \"]\")\n\t// } else {\n\t// \tif strings.HasPrefix(fileType, \"text/plain\") {\n\t// \t\tfiles = append(files, item)\n\t// \t} else {\n\t// \t\tlog.Println(\"File type for file [\" + item + \"] -> \" + fileType)\n\t// \t}\n\t// }\n\t// }\n\n\treturn files\n}", "title": "" }, { "docid": "e3e80eded2c26a8537dba6dc35d2226b", "score": "0.43603227", "text": "func (sa *Appender) Layout() driver.Layout {\n\tsa.mu.Lock()\n\tdefer sa.mu.Unlock()\n\treturn sa.layout\n}", "title": "" }, { "docid": "b99e24da83f351c8297c820776586887", "score": "0.43582383", "text": "func getFileSegments(f291Files []string) [][]string {\n\t// Create a slice of ncFiles\n\tfileSegments := make([][]string, 0)\n\t// Determine the length of the subslices based on amount of files and how many files can be open at the same time in PuTTY\n\tincreaseRate := 250\n\t// Add subslices to fileSegments slice\n\tfor i := 0; i < len(f291Files)-increaseRate; i += increaseRate {\n\t\tfileSegments = append(fileSegments, f291Files[i:i+increaseRate])\n\t}\n\tfileSegments = append(fileSegments, f291Files[len(f291Files)-increaseRate:])\n\treturn fileSegments\n}", "title": "" } ]
69014dda4e00acc98df236146f107fec
Simple Cgo to Go Converter
[ { "docid": "af5b846d18a0a8b06dab875ccb334a41", "score": "0.612931", "text": "func SimpleCgoToGo(ti *TypeInfo, arg0, arg1 string, flags ConvFlags) string {\n\tcgotype := CgoType(ti, TypeNone)\n\targ0 = fmt.Sprintf(\"(%s)(%s)\", cgotype, arg0)\n\treturn CgoToGo(ti, arg0, arg1, flags)\n}", "title": "" } ]
[ { "docid": "9652dc283d6aa4daeb74acb3b904703f", "score": "0.61938787", "text": "func (sc *SliceConverter) ConvertCFromGo(varName string) string {\n return varName\n}", "title": "" }, { "docid": "f21827f9e538cafbbcca54728c78f375", "score": "0.6056392", "text": "func c2goPrimitive(ctype string) (string, int) {\n\tswitch ctype {\n\tcase \"uint8_t\", \"uint16_t\", \"uint32_t\", \"uint64_t\",\n\t\t\"int8_t\", \"int16_t\", \"int32_t\", \"int64_t\":\n\t\tif matches := reCType.FindStringSubmatch(ctype); matches != nil {\n\t\t\treturn matches[1] + matches[2], func() int {\n\t\t\t\tv, _ := strconv.Atoi(matches[2])\n\t\t\t\treturn v\n\t\t\t}()\n\t\t}\n\tcase \"char\":\n\t\treturn \"byte\", 8\n\tcase \"float\":\n\t\treturn \"float32\", 32\n\tcase \"double\":\n\t\treturn \"float64\", 64\n\tcase \"uint8_t_mavlink_version\":\n\t\treturn \"uint8\", 8\n\t}\n\tpanic(fmt.Sprintf(\"c2goPrimitive: unhandled primitive type - %s\", ctype))\n}", "title": "" }, { "docid": "2daa4bf0df5c932640689b8fa8636c75", "score": "0.6027055", "text": "func CToGoString(c []byte) string {\n\tn := -1\n\tfor i, b := range c {\n\t\tif b == 0 {\n\t\t\tbreak\n\t\t}\n\t\tn = i\n\t}\n\treturn string(c[:n+1])\n}", "title": "" }, { "docid": "3db70dc832ab2f9a64999d12386a0726", "score": "0.6026587", "text": "func GoToCgoForInterface(bi *BaseInfo, arg0, arg1 string, flags ConvFlags) string {\n\tvar out bytes.Buffer\n\tprintf := PrinterTo(&out)\n\n\tswitch bi.Type() {\n\tcase INFO_TYPE_OBJECT:\n\t\tprefix := DefaultRepository().CPrefix(bi.Namespace())\n\t\tprintf(\"if %s != nil {\\n\", arg0)\n\t\tprintf(\"\\t%s = %s.InheritedFrom%s%s()\\n\",\n\t\t\targ1, arg0, prefix, bi.Name())\n\t\tprintf(\"}\")\n\tcase INFO_TYPE_ENUM, INFO_TYPE_FLAGS:\n\t\tctype := CgoTypeForInterface(bi, TypeNone)\n\t\tprintf(\"%s = %s(%s)\", arg1, ctype, arg0)\n\tcase INFO_TYPE_INTERFACE:\n\t\tprefix := DefaultRepository().CPrefix(bi.Namespace())\n\t\tprintf(\"if %s != nil {\\n\", arg0)\n\t\tprintf(\"\\t%s = %s.Implements%s%s()\",\n\t\t\targ1, arg0, prefix, bi.Name())\n\t\tprintf(\"}\")\n\tcase INFO_TYPE_STRUCT:\n\t\tns := bi.Namespace()\n\t\tif ns == \"cairo\" {\n\t\t\tprintf(CairoGoToCgoForInterface(bi, arg0, arg1, flags))\n\t\t\tbreak\n\t\t}\n\n\t\tfullnm := strings.ToLower(ns) + \".\" + bi.Name()\n\t\tif _, ok := GConfig.Sys.DisguisedTypes[fullnm]; ok {\n\t\t\tflags &^= ConvPointer\n\t\t}\n\t\tctype := CgoTypeForInterface(bi, TypeNone)\n\t\tif flags&ConvPointer != 0 {\n\t\t\tprintf(\"%s = (*%s)(unsafe.Pointer(%s))\",\n\t\t\t\targ1, ctype, arg0)\n\t\t} else {\n\t\t\tprintf(\"%s = *(*%s)(unsafe.Pointer(&%s))\",\n\t\t\t\targ1, ctype, arg0)\n\t\t}\n\tcase INFO_TYPE_CALLBACK:\n\t\tprintf(\"if %s != nil {\\n\", arg0)\n\t\tprintf(\"\\t%s = unsafe.Pointer(&%s)\", arg1, arg0)\n\t\tprintf(\"}\")\n\t}\n\n\treturn out.String()\n}", "title": "" }, { "docid": "9244b7014f53f10413a8f46137dd7e8f", "score": "0.6018996", "text": "func cpp2go(argc C.int, argv_ **C.char) {\n\t//指向一个足够大的数组空间\n argv := (*(*[1 << 30]*C.char)(unsafe.Pointer(argv_)))[:int(argc)];\n args := make([]string, int(argc));//建存放数组的地方\n for i := 0; i < int(argc); i++ {//跌代访问数组个数\n args[i] = C.GoString(argv[i]);//转存到go中\n }\n for i := 0; i < len(args); i++ { //输出各个参数\n fmt.Printf(\"argv[%d]: %s\\n\", i, args[i])\n }\n}", "title": "" }, { "docid": "89d2b9578112d46f03bcbf9f8e171f3f", "score": "0.6003434", "text": "func (sc *SliceConverter) ConvertGoFromC(varName string) string {\n return fmt.Sprintf(\"PyListTo%s(%s)\", sc.SafeName, varName)\n}", "title": "" }, { "docid": "7c58775769cd2bf3c0ce5818bfbb8681", "score": "0.5947989", "text": "func (sc *SliceConverter) ConvertCToGo(varName string) string {\n return varName\n}", "title": "" }, { "docid": "c227e186c974f19712626c4bdacc438c", "score": "0.57576686", "text": "func BuildToCgo(b []byte, out interface{}) {\n\tbuildToInternal(b, out, BuildCgo)\n}", "title": "" }, { "docid": "0f87c9c20192649909810b7290b2be64", "score": "0.57553434", "text": "func cstringtogo(names **C.char, classes int) []string {\n\tout := make([]string, classes)\n\tfor i := 0; i < classes; i++ {\n\t\tn := C.ret_string(names, C.int(i), C.int(classes))\n\t\tout[i] = C.GoString(n)\n\t}\n\treturn out\n}", "title": "" }, { "docid": "5ccb681b5c06d38681c14f244894e8dc", "score": "0.5711888", "text": "func (pr *packageReader) saveCgo(info *fileInfo, cg *ast.CommentGroup) error {\n\ttext := cg.Text()\n\tfor _, line := range strings.Split(text, \"\\n\") {\n\t\torig := line\n\n\t\t// Line is\n\t\t//\t#cgo [GOOS/GOARCH...] LDFLAGS: stuff\n\t\t//\n\t\tline = strings.TrimSpace(line)\n\t\tif len(line) < 5 || line[:4] != \"#cgo\" || (line[4] != ' ' && line[4] != '\\t') {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Split at colon.\n\t\tline = strings.TrimSpace(line[4:])\n\t\ti := strings.Index(line, \":\")\n\t\tif i < 0 {\n\t\t\treturn fmt.Errorf(\"%s: invalid #cgo line: %s\", info.path, orig)\n\t\t}\n\t\tline, optstr := strings.TrimSpace(line[:i]), strings.TrimSpace(line[i+1:])\n\n\t\t// Parse tags and verb.\n\t\tf := strings.Fields(line)\n\t\tif len(f) < 1 {\n\t\t\treturn fmt.Errorf(\"%s: invalid #cgo line: %s\", info.path, orig)\n\t\t}\n\t\tverb := f[len(f)-1]\n\t\ttags := strings.Join(f[:len(f)-1], \" \")\n\n\t\t// Parse options.\n\t\topts, err := splitQuoted(optstr)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"%s: invalid #cgo line: %s\", info.path, orig)\n\t\t}\n\t\tvar ok bool\n\t\tfor i, opt := range opts {\n\t\t\tif opt, ok = expandSrcDir(opt, info.dir); !ok {\n\t\t\t\treturn fmt.Errorf(\"%s: malformed #cgo argument: %s\", info.path, orig)\n\t\t\t}\n\t\t\topts[i] = opt\n\t\t}\n\n\t\t// Add tags to appropriate list.\n\t\tswitch verb {\n\t\tcase \"CFLAGS\", \"CPPFLAGS\", \"CXXFLAGS\":\n\t\t\tinfo.copts = append(info.copts, taggedOpts{tags, opts})\n\t\tcase \"LDFLAGS\":\n\t\t\tinfo.clinkopts = append(info.clinkopts, taggedOpts{tags, opts})\n\t\tcase \"pkg-config\":\n\t\t\tpr.warn(fmt.Errorf(\"%s: pkg-config not supported: %s\", info.path, orig))\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"%s: invalid #cgo verb: %s\", info.path, orig)\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "d751c76af3aa7c1e7813d0c179308cfd", "score": "0.5560612", "text": "func castToC(a argument) (string, string, bool) {\n\tcsname := \"c\" + a.name\n\n\tswitch a.valueType {\n\tdefault:\n\t\tderef := \"*\"\n\t\tif a.HasPointer() {\n\t\t\tderef = \"\"\n\t\t}\n\n\t\tif *functionalConvert {\n\t\t\treturn csname, csname + \" := \" + deref + a.name + \".cptr()\", true\n\t\t}\n\n\t\t//func (v *Vector3) cptr() *C.Vector3 { return (*C.Vector3)(unsafe.Pointer(v)) \t}\n\t\treturn csname, csname + \" := \" + deref + \"( (*C.\" + a.valueType + \")(unsafe.Pointer(&\" + a.name + \")) )\", true\n\tcase \"int\":\n\t\t//WE are unsigned, so do a converntional convert\n\t\tif a.unsigned {\n\t\t\tif a.GetPraticalPointerDepth() == 1 {\n\t\t\t\treturn csname, csname + \" := C.u\" + a.valueType + \"(\" + a.name + \")\", false\n\t\t\t}\n\t\t\treturn \"C.u\" + a.valueType + \"(\" + a.name + \")\", \"\", false\n\t\t}\n\n\t\t//We are not unsigned, so proceed as normal\n\t\tif a.GetPraticalPointerDepth() == 1 {\n\t\t\treturn csname, csname + \" := C.\" + a.valueType + \"(int32(\" + a.name + \"))\", false\n\t\t}\n\t\treturn \"C.\" + a.valueType + \"(int32(\" + a.name + \"))\", \"\", false\n\tcase \"float\":\n\t\tfallthrough\n\tcase \"uint8\":\n\t\tfallthrough\n\tcase \"bool\":\n\t\tif a.GetPraticalPointerDepth() == 1 {\n\t\t\treturn csname, csname + \" := C.\" + a.valueType + \"(\" + a.name + \")\", false\n\t\t}\n\t\treturn \"C.\" + a.valueType + \"(\" + a.name + \")\", \"\", false\n\tcase \"void\":\n\t\treturn a.name, \"\", true\n\tcase \"char\":\n\t\treturn csname, csname + \" := C.CString(\" + a.name + \")\\ndefer C.free(unsafe.Pointer(\" + csname + \"))\", true\n\t}\n}", "title": "" }, { "docid": "135bc5d5dc5aa7a085671ec68eba9db9", "score": "0.5549346", "text": "func (eng *Engine) Go(p0, p1 int) (Result, error) {\n var (\n results Result\n finished bool = false\n )\n\t_, err := eng.stdin.WriteString(fmt.Sprintf(\"go depth %d\\n\", p1))\n\tif err != nil {\n\t\treturn Result{},err\n }\n\n err = eng.stdin.Flush()\n\tif err != nil {\n\t\treturn Result{},err\n\t}\n\n for !finished{\n line, err := eng.stdout.ReadString('\\n')\n\t\tif err != nil {\n\t\t\treturn Result{},err\n\t\t}\n line = strings.Trim(line, \"\\n\")\n\t\ts := string(line)\n\n switch uci_string := ParseLine(s).(type) {\n case Data: {\n if (uci_string.depth==p0){\n results.cp1 = uci_string.cp\n }else if (uci_string.depth==p1){\n results.cp1 = uci_string.cp\n results.variant = uci_string.variant\n }\n }\n case Final: finished=true\n case Neither:\n }\n }\n return results, err\n}", "title": "" }, { "docid": "9b0c7e596723d22156af97b7ae68ac97", "score": "0.54567915", "text": "func CgoC2tpe(tta, ttb, uta, utb, dpsi, deps, xp, yp float64) (\n\trc2t [3][3]float64) {\n\tvar cRc2t [3][3]C.double\n\tC.iauC2tpe(C.double(tta), C.double(ttb), C.double(uta),\n\t\tC.double(utb), C.double(dpsi), C.double(deps),\n\t\tC.double(xp), C.double(yp), &cRc2t[0])\n\treturn v3tC2Go(cRc2t)\n}", "title": "" }, { "docid": "b8aa2d500c7f0ee33e5fb66fa130a705", "score": "0.54528046", "text": "func BuildCgo(b []byte) func() {\n\tdummy := cgocall\n\tfn := &struct {\n\t\ttrampoline uintptr\n\t\tjitcode uintptr\n\t}{**(**uintptr)(unsafe.Pointer(&dummy)), Addr(b)}\n\n\treturn *(*func())(unsafe.Pointer(&fn))\n}", "title": "" }, { "docid": "005db3274baf7a34e137a7b7e02e1ac5", "score": "0.5430833", "text": "func toCodeFile(pkg *cgo.Package) *ast.File {\n\tcImport := cgo.Imports(\"C\")\n\n\tcImport.Doc = &ast.CommentGroup{\n\t\tList: append(cgo.IncludeComments(\"<stdlib.h>\"), cgo.RawComments(pkg.CDefinitions()...)...),\n\t}\n\n\tdeclarations := []ast.Decl{\n\t\tcImport,\n\t\tcgo.Imports(\"fmt\", \"sync\", \"unsafe\", \"github.com/satori/go.uuid\"), //, \"strconv\", \"strings\", \"os\"\n\t\tcgo.ImportsFromMap(pkg.ImportAliases()),\n\t\tcgo.RefsStruct(),\n\t\tcgo.CObjectStruct(),\n\t\tcgo.DecrementRef(),\n\t\tcgo.IncrementRef(),\n\t\tcgo.GetRef(),\n\t\tcgo.GetUuidFromPtr(),\n\t\tcgo.Init(),\n\t\tcgo.ErrorToString(),\n\t\tcgo.CFree(),\n\t\tcgo.IsErrorNil(),\n\t}\n\n\tdeclarations = append(declarations, pkg.ToAst()...)\n\tdeclarations = append(declarations, cgo.MainFunc())\n\tmainFile := &ast.File{\n\t\tName: &ast.Ident{\n\t\t\tName: \"main\",\n\t\t},\n\t\tDecls: declarations,\n\t}\n\n\treturn mainFile\n}", "title": "" }, { "docid": "55896d984551abc75f2bf4c64bfc23d5", "score": "0.539755", "text": "func Go(m *Module, info copyright.Info, gen chan Generate) error {\n\tif len(m.Structs) == 0 {\n\t\treturn nil\n\t}\n\tgen <- Generate{\n\t\tName: \"Go.Binary\",\n\t\tArg: &GoBinary{\n\t\t\tModule: m,\n\t\t\tCopyright: copyright.Build(\"generated_by\", info),\n\t\t},\n\t\tOutput: goFileName(m, m.Name, \"binary\"),\n\t\tIndent: goIndent,\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "4cff7af3575adbb700d66d64e94bfcbb", "score": "0.5380273", "text": "func goTypeToCty(val interface{}) (cty.Value, error) {\n\tctyType, err := gocty.ImpliedType(val)\n\tif err != nil {\n\t\treturn cty.NilVal, errors.WithStackTrace(err)\n\t}\n\tctyOut, err := gocty.ToCtyValue(val, ctyType)\n\tif err != nil {\n\t\treturn cty.NilVal, errors.WithStackTrace(err)\n\t}\n\treturn ctyOut, nil\n}", "title": "" }, { "docid": "596688eb5b6d827baaa60fe78370f710", "score": "0.5362216", "text": "func convert(path string) string {\n\t// open source file\n\tin, err := os.Open(path)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\tdefer close0(in)\n\n\t// create destination file\n\toutName := outPath(path, binExt)\n\tout, err := os.Create(outName)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\tdefer close0(out)\n\n\t// create a new Asm object\n\tasmblr, err := asm.New(in)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// add pre-defined symbols\n\tasmblr.DefineSymbols(preDefSymb)\n\n\t// convert source file to binary file\n\tif e := asmblr.Run(out); e != nil {\n\t\treturn e.Error()\n\t}\n\treturn fmt.Sprintf(\"Successfully converted %s to %s\", path, outName)\n}", "title": "" }, { "docid": "a39d8a7bf17362d063ac31df0e974836", "score": "0.535434", "text": "func _CStringToGoString(s *C.char) string {\n\tif s == nil {\n\t\treturn \"\"\n\t}\n\treturn C.GoString(s)\n}", "title": "" }, { "docid": "a7a55063604e83ba013c30080cddfa74", "score": "0.5347546", "text": "func main() {\n\tmodule := \"functions basics\"\n\tauthor := \"vikash singh\"\n\n\tfmt.Println(converter(module, author))\n}", "title": "" }, { "docid": "b7de6bdaec9dea3d41ba21e660851449", "score": "0.528793", "text": "func castToGo(variable, t string, isPointer bool, unsigned bool) string {\n\taddr := \"\"\n\tif !isPointer {\n\t\taddr = \"&\"\n\t}\n\n\tswitch t {\n\tcase \"int\":\n\t\tif unsigned {\n\t\t\treturn convertType(t, unsigned) + \"(\" + variable + \")\"\n\t\t}\n\t\treturn convertType(t, false) + \"(int32(\" + variable + \"))\"\n\tcase \"float\":\n\t\tfallthrough\n\tcase \"double\":\n\t\tfallthrough\n\tcase \"uint8\":\n\t\tfallthrough\n\tcase \"bool\":\n\t\treturn convertType(t, unsigned) + \"(\" + variable + \")\"\n\tcase \"char\":\n\t\treturn \"C.GoString(\" + variable + \")\"\n\tcase \"void\":\n\t\treturn \"unsafe.Pointer(\" + addr + variable + \")\"\n\tdefault:\n\t\t//func newRectangleFromPointer(ptr unsafe.Pointer) Rectangle { return *(*Rectangle)(ptr) }\n\t\tif *functionalConvert {\n\t\t\treturn \"new\" + convertType(t, unsigned) + \"FromPointer(unsafe.Pointer(\" + addr + variable + \"))\"\n\t\t}\n\n\t\treturn \"*(*\" + convertType(t, unsigned) + \")(unsafe.Pointer(\" + addr + variable + \"))\"\n\t}\n}", "title": "" }, { "docid": "4808b88a9b2998f230a760291dbf7ea4", "score": "0.5234915", "text": "func CgoToGoForInterface(bi *BaseInfo, arg1, arg2 string, flags ConvFlags) string {\n\tvar out bytes.Buffer\n\tprintf := PrinterTo(&out)\n\n\tswitch bi.Type() {\n\tcase INFO_TYPE_OBJECT, INFO_TYPE_INTERFACE:\n\t\tgotype := GoTypeForInterface(bi, TypeReturn)\n\t\tif flags&ConvOwnEverything != 0 {\n\t\t\tprintf(\"%s = (*%s)(%sObjectWrap(unsafe.Pointer(%s), false))\",\n\t\t\t\targ2, gotype, Config.Sys.GNS, arg1)\n\t\t} else {\n\t\t\tprintf(\"%s = (*%s)(%sObjectWrap(unsafe.Pointer(%s), true))\",\n\t\t\t\targ2, gotype, Config.Sys.GNS, arg1)\n\t\t}\n\tcase INFO_TYPE_ENUM, INFO_TYPE_FLAGS:\n\t\tgotype := GoTypeForInterface(bi, TypeReturn)\n\t\tprintf(\"%s = %s(%s)\", arg2, gotype, arg1)\n\tcase INFO_TYPE_STRUCT, INFO_TYPE_UNION:\n\t\tns := bi.Namespace()\n\t\tif ns == \"cairo\" {\n\t\t\tprintf(CairoCgoToGoForInterface(bi, arg1, arg2, flags))\n\t\t\tbreak\n\t\t}\n\n\t\tfullnm := strings.ToLower(ns) + \".\" + bi.Name()\n\t\tgotype := GoTypeForInterface(bi, TypeReturn)\n\n\t\tif flags&ConvListMember != 0 {\n\t\t\tprintf(\"%s = *(*%s)(unsafe.Pointer(%s))\",\n\t\t\t\targ2, gotype, arg1)\n\t\t\tbreak\n\t\t}\n\n\t\tif _, ok := GConfig.Sys.DisguisedTypes[fullnm]; ok {\n\t\t\tprintf(\"%s = %s{unsafe.Pointer(%s)}\",\n\t\t\t\targ2, gotype, arg1)\n\t\t\tbreak\n\t\t}\n\n\t\tif flags&ConvPointer != 0 {\n\t\t\tprintf(\"%s = (*%s)(unsafe.Pointer(%s))\",\n\t\t\t\targ2, gotype, arg1)\n\t\t} else {\n\t\t\tprintf(\"%s = *(*%s)(unsafe.Pointer(&%s))\",\n\t\t\t\targ2, gotype, arg1)\n\t\t}\n\t}\n\treturn out.String()\n}", "title": "" }, { "docid": "92824913ac94694c505f5b679a15cd9f", "score": "0.5202092", "text": "func flacToOpus(path string) ([]byte, error) {\n\tstart := time.Now()\n\topusenc := exec.Command(\"opusenc\", \"--bitrate\", \"256\", path, \"-\")\n\tvar out bytes.Buffer\n\topusenc.Stdout = &out\n\tif err := opusenc.Run(); err != nil {\n\t\treturn nil, err\n\t} else {\n\t\tlog.Printf(\"Encode opus (size %d) from %q in %v\", out.Len(), path, time.Now().Sub(start))\n\t\treturn out.Bytes(), nil\n\t}\n}", "title": "" }, { "docid": "9798dcd52441a50da1f37c53c5c6a007", "score": "0.5161373", "text": "func (t *TypeConverter) ConvertToGolang(vapiValue data.DataValue, bindingType BindingType) (interface{}, []error) {\n\tif bindingType == nil {\n\t\treturn nil, []error{l10n.NewRuntimeErrorNoParam(\"vapi.bindings.typeconverter.nil.type\")}\n\t}\n\tvar nativeConverter = NewDataValueToNativeConverter(vapiValue, t)\n\terr := nativeConverter.visit(bindingType)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn nativeConverter.OutputValue(), nil\n}", "title": "" }, { "docid": "a923a55b3ac12fa4c052b88de814e987", "score": "0.51335216", "text": "func genGo(file io.Writer) error {\n\tt, err := template.ParseFiles(\"yacc2go.tmpl\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err = t.Execute(file, Gen); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "6416757a3b1bef8af04a8a74566c0446", "score": "0.51277727", "text": "func (sc *SliceConverter) ConvertGoToC(varName string) string {\n return fmt.Sprintf(\"%[1]sToPyList(%s)\", sc.SafeName, varName)\n}", "title": "" }, { "docid": "23f96aa7d769464de66fb88c758f7444", "score": "0.51260626", "text": "func main() {\n\tfmt.Println(convert(\"A\", 1))\n}", "title": "" }, { "docid": "52dcb6a9ac19f2cb11ab058a1b819ff1", "score": "0.51141727", "text": "func glval2go(glval string) string {\n\n\tval := glval\n\tif strings.HasSuffix(val, \"u\") {\n\t\tval = strings.TrimSuffix(val, \"u\")\n\t}\n\tif strings.HasSuffix(val, \"ull\") {\n\t\tval = strings.TrimSuffix(val, \"ull\")\n\t}\n\treturn val\n}", "title": "" }, { "docid": "2f196398ac28d483e9ab76ae0ddf9b63", "score": "0.5112107", "text": "func GoGenerateCipd(ctx context.Context, _ []string, client *http.Client, parentRepoDir string, from *revision.Revision, to *revision.Revision) error {\n\t// TODO(borenet): Should we plumb through --local and --workdir?\n\tsklog.Info(\"Installing Go...\")\n\tgoExc, goEnv, err := go_install.EnsureGo(ctx, client, cipdRoot)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Also install the protoc asset. Use a different CIPD root dir to\n\t// prevent conflicts with the Go packages.\n\tprotocRoot := path.Join(os.TempDir(), \"cipd_protoc\")\n\tif err := cipd.Ensure(ctx, client, protocRoot, cipd.PkgProtoc); err != nil {\n\t\treturn err\n\t}\n\n\tenvSlice := make([]string, 0, len(goEnv))\n\tfor k, v := range goEnv {\n\t\tif k == \"PATH\" {\n\t\t\t// Construct PATH by adding protoc and the required PATH\n\t\t\t// entries for Go on to the existing PATH.\n\t\t\tv = path.Join(protocRoot, cipd.PkgProtoc.Path, \"bin\") + \":\" + v + \":\" + os.Getenv(\"PATH\")\n\t\t}\n\t\tenvSlice = append(envSlice, fmt.Sprintf(\"%s=%s\", k, v))\n\t}\n\n\t// Run go generate.\n\tgenerateDir := filepath.Join(parentRepoDir, \"go\", \"cipd\")\n\tsklog.Infof(\"Running 'go generate' in %s\", generateDir)\n\tif _, err := exec.RunCommand(ctx, &exec.Command{\n\t\tName: goExc,\n\t\tArgs: []string{\"generate\"},\n\t\tDir: generateDir,\n\t\tEnv: envSlice,\n\t}); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "52c7fe83ee0ad471ad1e14a4cbaecf0e", "score": "0.50376475", "text": "func goboolToCty(val bool) cty.Value {\n\tctyOut, err := gocty.ToCtyValue(val, cty.Bool)\n\tif err != nil {\n\t\t// Since we are converting primitive bools, we should never get an error in this conversion.\n\t\tpanic(err)\n\t}\n\treturn ctyOut\n}", "title": "" }, { "docid": "55bc73487d8b302f804d68becf22caad", "score": "0.5037589", "text": "func (p *Protoc) BuildGo(pkg *config.Package, files ...string) ([]string, error) {\n\tlog.Println(\"protoc building go\")\n\tcfg, ok := pkg.LanguageConfig.(golang.Config)\n\tif !ok {\n\t\treturn nil, ErrConfigType{pkg.LanguageConfig}\n\t}\n\n\tlang := []string{}\n\tlang = append(lang, fmt.Sprintf(\"%s=\", goFlag))\n\tvar extras = []string{}\n\tif len(cfg.Plugins) > 0 {\n\t\tplugins := []string{}\n\t\tplugins = append(plugins, \"plugins=\")\n\t\tplugins = append(plugins, strings.Join(cfg.Plugins, \"+\"))\n\t\textras = append(extras, strings.Join(plugins, \"\"))\n\t}\n\tif cfg.Paths != \"\" {\n\t\textras = append(extras, fmt.Sprintf(\"paths=%s\", cfg.Paths))\n\t}\n\tif len(extras) > 0 {\n\t\tlang = append(lang, strings.Join(extras, \",\"))\n\t\tlang = append(lang, \":\")\n\t}\n\tlang = append(lang, pkg.Output)\n\n\targs := []string{}\n\targs = append(args, fmt.Sprintf(\"-I%s\", pkg.Root()))\n\targs = append(args, strings.Join(lang, \"\"))\n\targs = append(args, files...)\n\treturn args, nil\n}", "title": "" }, { "docid": "e07a43680aeb2507e65e542bbdf959bd", "score": "0.5029636", "text": "func (p *Package) writeGccgoOutputFunc(fgcc *os.File, n *Name) {\n\tfmt.Fprintf(fgcc, \"CGO_NO_SANITIZE_THREAD\\n\")\n\tif t := n.FuncType.Result; t != nil {\n\t\tfmt.Fprintf(fgcc, \"%s\\n\", t.C.String())\n\t} else {\n\t\tfmt.Fprintf(fgcc, \"void\\n\")\n\t}\n\tfmt.Fprintf(fgcc, \"_cgo%s%s(\", cPrefix, n.Mangle)\n\tfor i, t := range n.FuncType.Params {\n\t\tif i > 0 {\n\t\t\tfmt.Fprintf(fgcc, \", \")\n\t\t}\n\t\tc := t.Typedef\n\t\tif c == \"\" {\n\t\t\tc = t.C.String()\n\t\t}\n\t\tfmt.Fprintf(fgcc, \"%s p%d\", c, i)\n\t}\n\tfmt.Fprintf(fgcc, \")\\n\")\n\tfmt.Fprintf(fgcc, \"{\\n\")\n\tif t := n.FuncType.Result; t != nil {\n\t\tfmt.Fprintf(fgcc, \"\\t%s _cgo_r;\\n\", t.C.String())\n\t}\n\tfmt.Fprintf(fgcc, \"\\t_cgo_tsan_acquire();\\n\")\n\tfmt.Fprintf(fgcc, \"\\t\")\n\tif t := n.FuncType.Result; t != nil {\n\t\tfmt.Fprintf(fgcc, \"_cgo_r = \")\n\t\t// Cast to void* to avoid warnings due to omitted qualifiers.\n\t\tif c := t.C.String(); c[len(c)-1] == '*' {\n\t\t\tfmt.Fprintf(fgcc, \"(void*)\")\n\t\t}\n\t}\n\tif n.Kind == \"macro\" {\n\t\tfmt.Fprintf(fgcc, \"%s;\\n\", n.C)\n\t} else {\n\t\tfmt.Fprintf(fgcc, \"%s(\", n.C)\n\t\tfor i := range n.FuncType.Params {\n\t\t\tif i > 0 {\n\t\t\t\tfmt.Fprintf(fgcc, \", \")\n\t\t\t}\n\t\t\tfmt.Fprintf(fgcc, \"p%d\", i)\n\t\t}\n\t\tfmt.Fprintf(fgcc, \");\\n\")\n\t}\n\tfmt.Fprintf(fgcc, \"\\t_cgo_tsan_release();\\n\")\n\tif t := n.FuncType.Result; t != nil {\n\t\tfmt.Fprintf(fgcc, \"\\treturn \")\n\t\t// Cast to void* to avoid warnings due to omitted qualifiers\n\t\t// and explicit incompatible struct types.\n\t\tif c := t.C.String(); c[len(c)-1] == '*' {\n\t\t\tfmt.Fprintf(fgcc, \"(void*)\")\n\t\t}\n\t\tfmt.Fprintf(fgcc, \"_cgo_r;\\n\")\n\t}\n\tfmt.Fprintf(fgcc, \"}\\n\")\n\tfmt.Fprintf(fgcc, \"\\n\")\n}", "title": "" }, { "docid": "ace987d91d66b6d61921aad1cee2475b", "score": "0.5025889", "text": "func (c *Chain) BuildGo(words []string, inserters int) {\n\tswitch inserters {\n\tcase 0:\n\t\tc.BuildGoLock(words) // Fine-grain locks\n\tcase 1:\n\t\tc.BuildGoChannel(words) // One channel\n\tdefault:\n\t\tc.BuildGoChannels(words, inserters) // \"inserters\" channels\n\t}\n}", "title": "" }, { "docid": "14c039dc419659ce16d8c2082095d7e4", "score": "0.50209737", "text": "func GoC2tpe(tta, ttb, uta, utb, dpsi, deps, xp, yp float64) (\n\trc2t [3][3]float64) {\n\n\tvar epsa, gmst, ee, sp float64\n\tvar rbpn, rpom [3][3]float64\n\n\t// Form the celestial-to-true matrix for this TT. \n\tepsa, _, _, _, _, rbpn = GoPn00(tta, ttb, dpsi, deps)\n\n\t// Predict the Greenwich Mean Sidereal Time for this UT1 and TT. \n\tgmst = GoGmst00(uta, utb, tta, ttb)\n\n\t// Predict the equation of the equinoxes given TT and nutation. \n\tee = GoEe00(tta, ttb, epsa, dpsi)\n\n\t// Estimate s'. \n\tsp = GoSp00(tta, ttb)\n\n\t// Form the polar motion matrix. \n\trpom = GoPom00(xp, yp, sp)\n\n\t// Combine to form the celestial-to-terrestrial matrix. \n\trc2t = GoC2teqx(rbpn, gmst+ee, rpom)\n\treturn\n}", "title": "" }, { "docid": "9a5a2616407ffc15e5b3ad9f5769da0b", "score": "0.50175726", "text": "func ExampleGenerateGo() {\n\tproc, err := Parse(strings.NewReader(\"(new a)(new b)(a<b> | a(x).x<> | b().0)\"))\n\tif err != nil {\n\t\tfmt.Println(err) // Parse failed\n\t}\n\tproc = Bind(proc)\n\tInfer(proc)\n\terr = Unify(proc)\n\tif err != nil {\n\t\tfmt.Println(err) // Unify failed\n\t}\n\tfmt.Println(proc.Golang())\n\t// Output: a := make(chan chan struct{}); b := make(chan struct{}); go func(){ go func(){ a <- b; }()\n\t//x := <-a;x <- struct{}{}; }()\n\t//<-b;/* end */\n}", "title": "" }, { "docid": "d8f02bfcafc76f2ee3ed521984d2b19f", "score": "0.50140727", "text": "func gltypearg2go(gltype, glarg string) (goarg string, gotype string) {\n\n\t// Replace parameter names using Go keywords\n\tgokeys := []string{\"type\", \"func\"}\n\tfor _, k := range gokeys {\n\t\tif strings.HasSuffix(glarg, k) {\n\t\t\tglarg = strings.TrimSuffix(glarg, k) + \"p\" + k\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif gltype == \"void\" {\n\t\tgotype = \"unsafe.Pointer\"\n\t\tif strings.HasPrefix(glarg, \"**\") {\n\t\t\tgoarg = strings.TrimPrefix(glarg, \"**\")\n\t\t\tgotype = \"*\" + gotype\n\t\t\treturn goarg, gotype\n\t\t}\n\t\tif strings.HasPrefix(glarg, \"*\") {\n\t\t\tgoarg = strings.TrimPrefix(glarg, \"*\")\n\t\t\treturn goarg, gotype\n\t\t}\n\t\treturn \"???\", \"???\"\n\t}\n\n\tgoarg = glarg\n\tgotype = mapCType2Go[gltype]\n\tif strings.HasPrefix(glarg, \"*\") {\n\t\tgotype = \"*\" + gotype\n\t\tgoarg = strings.TrimPrefix(goarg, \"*\")\n\t}\n\treturn goarg, gotype\n}", "title": "" }, { "docid": "14cc660b0aa1db0d8f39beaf734a002b", "score": "0.49836373", "text": "func (sc *SliceConverter) ConvertPyFromC(varName string) string {\n return varName\n}", "title": "" }, { "docid": "1e944c68cc53c42d2f38bb0a0167052c", "score": "0.49530283", "text": "func GeneratePBDotGo(protoPaths, gopath []string, outDir string) error {\n\n\tgenGoCode := \"--gogofaster_out=\" +\n\t\t\"Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,\" +\n\t\t\"Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\" +\n\t\t\"Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types,\" +\n\t\t\"Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\" +\n\t\t\"Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,\" +\n\t\t\"paths=source_relative,plugins=grpc:\" + outDir\n\n\t_, err := exec.LookPath(\"protoc-gen-gogo\")\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"cannot find protoc-gen-gogo in PATH\")\n\t}\n\n\terr = protoc(protoPaths, gopath, genGoCode)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"cannot exec protoc with protoc-gen-gogo\")\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "aa4505f4d6db1b1a2519dd4e14730430", "score": "0.4951809", "text": "func gostringToCty(val string) cty.Value {\n\tctyOut, err := gocty.ToCtyValue(val, cty.String)\n\tif err != nil {\n\t\t// Since we are converting primitive strings, we should never get an error in this conversion.\n\t\tpanic(err)\n\t}\n\treturn ctyOut\n}", "title": "" }, { "docid": "8c113f501f2667184c45c1d46aeeda30", "score": "0.49470797", "text": "func Convert(s *seeker.Seeker, in ConvertInput) (out *ConvertOutput, err error) {\n\terr = in.Validate()\n\tif err != nil {\n\t\treturn\n\t}\n\n\tout = &ConvertOutput{}\n\n\tswitch {\n\tcase in.shouldConvGUID():\n\t\tout, err = convGUID(s, in)\n\tcase in.shouldConvOrg():\n\t\tout, err = convOrg(s, in)\n\tcase in.shouldConvSpace():\n\t\tout, err = convSpace(s, in)\n\tcase in.shouldConvApp():\n\t\tout, err = convApp(s, in)\n\tdefault:\n\t\tpanic(\"Validated input did not correspond to a code path in Convert\")\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "cdb4f9f0c24a66101a8afa474166378d", "score": "0.4939651", "text": "func toGoStringArray(c **C.char) []string {\n\tvar strs []string\n\toriginalc := c\n\tdefer C.char_g_strfreev(originalc)\n\n\tfor *c != nil {\n\t\tstrs = append(strs, C.GoString((*C.char)(*c)))\n\t\tc = C.next_charptr(c)\n\t}\n\n\treturn strs\n}", "title": "" }, { "docid": "8128cb2f1599ff4ffecfd2e2503078e5", "score": "0.492832", "text": "func Go() {\n\tInit()\n}", "title": "" }, { "docid": "412c996f9a8acd534aba22d4815da160", "score": "0.49232644", "text": "func runGo(file, subFolder, stdin string, clangFlags, args []string) (string, error) {\n\n\tprogramArgs := DefaultProgramArgs()\n\tprogramArgs.inputFiles = []string{file}\n\tprogramArgs.outputFile = subFolder + \"main.go\"\n\tprogramArgs.clangFlags = clangFlags\n\tprogramArgs.verbose = (flag.CommandLine.Lookup(\"test.v\").Value.String() == \"true\" || strings.Contains(file, \"operators.c\"))\n\tif strings.HasSuffix(file, \"cpp\") {\n\t\tprogramArgs.cppCode = true\n\t}\n\n\t// Compile Go\n\terr := Start(programArgs)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Cannot transpile : %v\", err)\n\t}\n\n\treturn programArgs.runGoTest(stdin, args)\n}", "title": "" }, { "docid": "8bf59295de3e68017a623ec298d9380e", "score": "0.49167207", "text": "func (sc *SliceConverter) GoTransitionType() string {\n return \"*C.PyObject\"\n}", "title": "" }, { "docid": "46cbfc95cdbfd5b9aa1aa38b36d4a835", "score": "0.4907701", "text": "func main() {\n\tprog := intcode.Program(util.MustReadCSInts(\"input\"))\n\t// manual(prog)\n\tauto(prog)\n}", "title": "" }, { "docid": "75f4230b9c611327c15c184edcf1a777", "score": "0.4905377", "text": "func (p *Package) writeGccgoExports(fgo2, fm, fgcc, fgcch io.Writer) {\n\tgccgoSymbolPrefix := p.gccgoSymbolPrefix()\n\n\tp.writeExportHeader(fgcch)\n\n\tfmt.Fprintf(fgcc, \"/* Code generated by cmd/cgo; DO NOT EDIT. */\\n\\n\")\n\tfmt.Fprintf(fgcc, \"#include \\\"_cgo_export.h\\\"\\n\")\n\n\tfmt.Fprintf(fgcc, \"%s\\n\", gccgoExportFileProlog)\n\tfmt.Fprintf(fgcc, \"%s\\n\", tsanProlog)\n\tfmt.Fprintf(fgcc, \"%s\\n\", msanProlog)\n\n\tfor _, exp := range p.ExpFunc {\n\t\tfn := exp.Func\n\t\tfntype := fn.Type\n\n\t\tcdeclBuf := new(bytes.Buffer)\n\t\tresultCount := 0\n\t\tforFieldList(fntype.Results,\n\t\t\tfunc(i int, aname string, atype ast.Expr) { resultCount++ })\n\t\tswitch resultCount {\n\t\tcase 0:\n\t\t\tfmt.Fprintf(cdeclBuf, \"void\")\n\t\tcase 1:\n\t\t\tforFieldList(fntype.Results,\n\t\t\t\tfunc(i int, aname string, atype ast.Expr) {\n\t\t\t\t\tt := p.cgoType(atype)\n\t\t\t\t\tfmt.Fprintf(cdeclBuf, \"%s\", t.C)\n\t\t\t\t})\n\t\tdefault:\n\t\t\t// Declare a result struct.\n\t\t\tfmt.Fprintf(fgcch, \"\\n/* Return type for %s */\\n\", exp.ExpName)\n\t\t\tfmt.Fprintf(fgcch, \"struct %s_return {\\n\", exp.ExpName)\n\t\t\tforFieldList(fntype.Results,\n\t\t\t\tfunc(i int, aname string, atype ast.Expr) {\n\t\t\t\t\tt := p.cgoType(atype)\n\t\t\t\t\tfmt.Fprintf(fgcch, \"\\t%s r%d;\", t.C, i)\n\t\t\t\t\tif len(aname) > 0 {\n\t\t\t\t\t\tfmt.Fprintf(fgcch, \" /* %s */\", aname)\n\t\t\t\t\t}\n\t\t\t\t\tfmt.Fprint(fgcch, \"\\n\")\n\t\t\t\t})\n\t\t\tfmt.Fprintf(fgcch, \"};\\n\")\n\t\t\tfmt.Fprintf(cdeclBuf, \"struct %s_return\", exp.ExpName)\n\t\t}\n\n\t\tcRet := cdeclBuf.String()\n\n\t\tcdeclBuf = new(bytes.Buffer)\n\t\tfmt.Fprintf(cdeclBuf, \"(\")\n\t\tif fn.Recv != nil {\n\t\t\tfmt.Fprintf(cdeclBuf, \"%s recv\", p.cgoType(fn.Recv.List[0].Type).C.String())\n\t\t}\n\t\t// Function parameters.\n\t\tforFieldList(fntype.Params,\n\t\t\tfunc(i int, aname string, atype ast.Expr) {\n\t\t\t\tif i > 0 || fn.Recv != nil {\n\t\t\t\t\tfmt.Fprintf(cdeclBuf, \", \")\n\t\t\t\t}\n\t\t\t\tt := p.cgoType(atype)\n\t\t\t\tfmt.Fprintf(cdeclBuf, \"%s p%d\", t.C, i)\n\t\t\t})\n\t\tfmt.Fprintf(cdeclBuf, \")\")\n\t\tcParams := cdeclBuf.String()\n\n\t\tif len(exp.Doc) > 0 {\n\t\t\tfmt.Fprintf(fgcch, \"\\n%s\", exp.Doc)\n\t\t}\n\n\t\tfmt.Fprintf(fgcch, \"extern %s %s%s;\\n\", cRet, exp.ExpName, cParams)\n\n\t\t// We need to use a name that will be exported by the\n\t\t// Go code; otherwise gccgo will make it static and we\n\t\t// will not be able to link against it from the C\n\t\t// code.\n\t\tgoName := \"Cgoexp_\" + exp.ExpName\n\t\tfmt.Fprintf(fgcc, `extern %s %s %s __asm__(\"%s.%s\");`, cRet, goName, cParams, gccgoSymbolPrefix, goName)\n\t\tfmt.Fprint(fgcc, \"\\n\")\n\n\t\tfmt.Fprint(fgcc, \"\\nCGO_NO_SANITIZE_THREAD\\n\")\n\t\tfmt.Fprintf(fgcc, \"%s %s %s {\\n\", cRet, exp.ExpName, cParams)\n\t\tif resultCount > 0 {\n\t\t\tfmt.Fprintf(fgcc, \"\\t%s r;\\n\", cRet)\n\t\t}\n\t\tfmt.Fprintf(fgcc, \"\\tif(_cgo_wait_runtime_init_done)\\n\")\n\t\tfmt.Fprintf(fgcc, \"\\t\\t_cgo_wait_runtime_init_done();\\n\")\n\t\tfmt.Fprintf(fgcc, \"\\t_cgo_tsan_release();\\n\")\n\t\tfmt.Fprint(fgcc, \"\\t\")\n\t\tif resultCount > 0 {\n\t\t\tfmt.Fprint(fgcc, \"r = \")\n\t\t}\n\t\tfmt.Fprintf(fgcc, \"%s(\", goName)\n\t\tif fn.Recv != nil {\n\t\t\tfmt.Fprint(fgcc, \"recv\")\n\t\t}\n\t\tforFieldList(fntype.Params,\n\t\t\tfunc(i int, aname string, atype ast.Expr) {\n\t\t\t\tif i > 0 || fn.Recv != nil {\n\t\t\t\t\tfmt.Fprintf(fgcc, \", \")\n\t\t\t\t}\n\t\t\t\tfmt.Fprintf(fgcc, \"p%d\", i)\n\t\t\t})\n\t\tfmt.Fprint(fgcc, \");\\n\")\n\t\tfmt.Fprintf(fgcc, \"\\t_cgo_tsan_acquire();\\n\")\n\t\tif resultCount > 0 {\n\t\t\tfmt.Fprint(fgcc, \"\\treturn r;\\n\")\n\t\t}\n\t\tfmt.Fprint(fgcc, \"}\\n\")\n\n\t\t// Dummy declaration for _cgo_main.c\n\t\tfmt.Fprintf(fm, `char %s[1] __asm__(\"%s.%s\");`, goName, gccgoSymbolPrefix, goName)\n\t\tfmt.Fprint(fm, \"\\n\")\n\n\t\t// For gccgo we use a wrapper function in Go, in order\n\t\t// to call CgocallBack and CgocallBackDone.\n\n\t\t// This code uses printer.Fprint, not conf.Fprint,\n\t\t// because we don't want //line comments in the middle\n\t\t// of the function types.\n\t\tfmt.Fprint(fgo2, \"\\n\")\n\t\tfmt.Fprintf(fgo2, \"func %s(\", goName)\n\t\tif fn.Recv != nil {\n\t\t\tfmt.Fprint(fgo2, \"recv \")\n\t\t\tprinter.Fprint(fgo2, fset, fn.Recv.List[0].Type)\n\t\t}\n\t\tforFieldList(fntype.Params,\n\t\t\tfunc(i int, aname string, atype ast.Expr) {\n\t\t\t\tif i > 0 || fn.Recv != nil {\n\t\t\t\t\tfmt.Fprintf(fgo2, \", \")\n\t\t\t\t}\n\t\t\t\tfmt.Fprintf(fgo2, \"p%d \", i)\n\t\t\t\tprinter.Fprint(fgo2, fset, atype)\n\t\t\t})\n\t\tfmt.Fprintf(fgo2, \")\")\n\t\tif resultCount > 0 {\n\t\t\tfmt.Fprintf(fgo2, \" (\")\n\t\t\tforFieldList(fntype.Results,\n\t\t\t\tfunc(i int, aname string, atype ast.Expr) {\n\t\t\t\t\tif i > 0 {\n\t\t\t\t\t\tfmt.Fprint(fgo2, \", \")\n\t\t\t\t\t}\n\t\t\t\t\tprinter.Fprint(fgo2, fset, atype)\n\t\t\t\t})\n\t\t\tfmt.Fprint(fgo2, \")\")\n\t\t}\n\t\tfmt.Fprint(fgo2, \" {\\n\")\n\t\tfmt.Fprint(fgo2, \"\\tsyscall.CgocallBack()\\n\")\n\t\tfmt.Fprint(fgo2, \"\\tdefer syscall.CgocallBackDone()\\n\")\n\t\tfmt.Fprint(fgo2, \"\\t\")\n\t\tif resultCount > 0 {\n\t\t\tfmt.Fprint(fgo2, \"return \")\n\t\t}\n\t\tif fn.Recv != nil {\n\t\t\tfmt.Fprint(fgo2, \"recv.\")\n\t\t}\n\t\tfmt.Fprintf(fgo2, \"%s(\", exp.Func.Name)\n\t\tforFieldList(fntype.Params,\n\t\t\tfunc(i int, aname string, atype ast.Expr) {\n\t\t\t\tif i > 0 {\n\t\t\t\t\tfmt.Fprint(fgo2, \", \")\n\t\t\t\t}\n\t\t\t\tfmt.Fprintf(fgo2, \"p%d\", i)\n\t\t\t})\n\t\tfmt.Fprint(fgo2, \")\\n\")\n\t\tfmt.Fprint(fgo2, \"}\\n\")\n\t}\n\n\tfmt.Fprintf(fgcch, \"%s\", gccExportHeaderEpilog)\n}", "title": "" }, { "docid": "78a8c825cb98e746d457aecd998eb4ee", "score": "0.49046436", "text": "func main() {\n\tfrom, err := os.Open(\"myEbcdicFile.txt\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tif err := cpconv.Convert(from, charmap.CodePage037, os.Stdout, charmap.Windows1252); err != nil {\n\t\tpanic(err)\n\t}\n}", "title": "" }, { "docid": "464250a7ae8efbe51ca5d9dc3f9a6201", "score": "0.48778048", "text": "func genWireToNativeConversion(data *goData, t *vdl.Type) string {\n\tif isNativeType(data.Env, t) {\n\t\twirePkgName, name := wiretypeLocalName(data, t)\n\t\twireType := wirePkgName + name\n\t\treturn fmt.Sprintf(`\n\tif err := %s%sToNative(%s, %s); err != nil {\n\t\treturn err\n\t}`, wirePkgName, wireType, \"t.wireValue\", \"t.Value\")\n\t}\n\treturn \"\"\n}", "title": "" }, { "docid": "440dfdcc80e3d155b73f54f29b6f1770", "score": "0.4877531", "text": "func cStringsToGo(cArray **C.char, n int) []string {\n\ta := make([]string, n)\n\tcPtr := (*[1 << 30]*C.char)(unsafe.Pointer(cArray))[:n:n]\n\tfor i, v := range cPtr {\n\t\ta[i] = C.GoString(v)\n\t}\n\treturn a\n}", "title": "" }, { "docid": "04b4f97cb2f2caae5751efa1e0e1e921", "score": "0.48729697", "text": "func args2Go(args C.SoapySDRKwargs) map[string]string {\n\n\tresults := make(map[string]string, args.size)\n\n\tkeys := (**C.char)(unsafe.Pointer(args.keys))\n\tvals := (**C.char)(unsafe.Pointer(args.vals))\n\n\t// Read all the strings\n\tfor i := 0; i < int(args.size); i++ {\n\t\tkey := (**C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(keys)) + uintptr(i)*unsafe.Sizeof(*keys)))\n\t\tval := (**C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(vals)) + uintptr(i)*unsafe.Sizeof(*vals)))\n\t\tresults[C.GoString(*key)] = C.GoString(*val)\n\t}\n\n\treturn results\n\n}", "title": "" }, { "docid": "8c581e119f8262ba5e2e6f95580dd6b7", "score": "0.48662198", "text": "func CodeGenCouler(stepList []*stepContext, session *pb.Session) (string, error) {\n\tvar workflowResourcesEnv = \"SQLFLOW_WORKFLOW_RESOURCES\"\n\tenvs, err := couler.GetStepEnvs(session)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tsecretName, secretData, err := couler.GetSecret()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif err := couler.VerifyResources(os.Getenv(workflowResourcesEnv)); err != nil {\n\t\treturn \"\", err\n\t}\n\tif os.Getenv(\"SQLFLOW_WORKFLOW_TTL\") != \"\" {\n\t\tworkflowTTL, err = strconv.Atoi(os.Getenv(\"SQLFLOW_WORKFLOW_TTL\"))\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"SQLFLOW_WORKFLOW_TTL: %s should be int\", os.Getenv(\"SQLFLOW_WORKFLOW_TTL\"))\n\t\t}\n\t}\n\n\tfiller := &coulerFiller{\n\t\tStepList: stepList,\n\t\tDataSource: session.DbConnStr,\n\t\tStepEnvs: envs,\n\t\tWorkflowTTL: workflowTTL,\n\t\tSecretName: secretName,\n\t\tSecretData: secretData,\n\t\tResources: os.Getenv(workflowResourcesEnv),\n\t}\n\tvar program bytes.Buffer\n\tif err := coulerTemplate.Execute(&program, filler); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn program.String(), nil\n}", "title": "" }, { "docid": "82e2f6b41eb81ce415b5ddca82342298", "score": "0.48661393", "text": "func (c *Confluence) Convert(input []byte) {\n\toutput := bfconfluence.Run(input)\n\tc.contents = string(output)\n}", "title": "" }, { "docid": "607acab168d665a63f6a2d6f313d0564", "score": "0.48574233", "text": "func doGenerate(ctx *cli.Context, protocCmd string) (err error) {\n\tfiles := ctx.Args().Slice()\n\tif len(files) == 0 {\n\t\tfiles, _ = filepath.Glob(\"*.proto\")\n\t}\n\n\tpwd, _ := os.Getwd()\n\t// case go path\n\tvar contectflag string\n\t// gopath setting could be many params, such as\n\t// {\n\t// \t\twin : \t\"C:\\go\\src;D:\\go\\src\"\n\t// \t\tlinux: \t\"/home/go:/root/go\"\n\t// }\n\tif runtime.GOOS == \"windows\" {\n\t\tcontectflag = \";\"\n\t} else {\n\t\tcontectflag = \":\"\n\t}\n\tgosrcarr := strings.Split(build.Default.GOPATH, contectflag)\n\tif len(gosrcarr) < 1 {\n\t\tfmt.Println(\"gopath directory does not exist, please create it in your GOPATH\")\n\t\treturn nil\n\t}\n\tgosrc := filepath.Join(gosrcarr[0], \"src\")\n\t_, err = os.Stat(gosrc)\n\tif err != nil {\n\t\tfmt.Printf(\"src directory does not exist, please create it in your GOPATH: %v\", gosrcarr[0])\n\t\treturn nil\n\t}\n\n\tcmdLine := fmt.Sprintf(protocCmd, gosrc, pwd)\n\targs := strings.Split(cmdLine, \" \")\n\targs = append(args, files...)\n\tcmd := exec.Command(args[0], args[1:]...)\n\tcmd.Dir = pwd\n\tcmd.Env = os.Environ()\n\tcmd.Stdout = os.Stdout\n\tcmd.Stderr = os.Stderr\n\terr = cmd.Run()\n\n\treturn\n}", "title": "" }, { "docid": "55a33505a32d768c9697e59835054bc7", "score": "0.4853372", "text": "func convert(from, to string) error {\n\t// Windows use \"cmd /c magick convert from to\"\n\t// app := \"cmd\"\n\t// arg0 := \"/c\"\n\tapp := \"convert\"\n\targ1 := from\n\targ2 := to\n\terr := exec.Command(app, arg1, arg2).Run()\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\treturn err\n}", "title": "" }, { "docid": "7726b331c724b15410327c189d777f42", "score": "0.48525804", "text": "func GetCTypeFromGoType(goType string) (string, bool) {\n\tif val, ok := basicTypesMap[goType]; ok {\n\t\treturn val, true\n\t} else {\n\t\treturn goType, false\n\t}\n}", "title": "" }, { "docid": "ff5a65e4698ab2da93a222a708d16eea", "score": "0.48477873", "text": "func genGo(constFile, procFile io.Writer) error {\n\tt, err := template.ParseFiles(\"constants.tmpl\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err = t.Execute(constFile, Gen); err != nil {\n\t\treturn err\n\t}\n\n\tt, err = template.ParseFiles(\"procedures.tmpl\")\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn t.Execute(procFile, Gen)\n}", "title": "" }, { "docid": "861fe05325fbd05ab89961eb501e6b03", "score": "0.4843882", "text": "func protoc(protoPaths, gopath []string, plugin string) error {\n\tvar cmdArgs []string\n\n\tcmdArgs = append(cmdArgs, \"--proto_path=\"+filepath.Dir(protoPaths[0]))\n\n\tfor _, gp := range gopath {\n\t\tcmdArgs = append(cmdArgs, \"-I\"+filepath.Join(gp, \"src\"))\n\t}\n\n\tcmdArgs = append(cmdArgs, plugin)\n\t// Append each definition file path to the end of that command args\n\tcmdArgs = append(cmdArgs, protoPaths...)\n\n\tprotocExec := exec.Command(\n\t\t\"protoc\",\n\t\tcmdArgs...,\n\t)\n\n\toutBytes, err := protocExec.CombinedOutput()\n\tif err != nil {\n\t\treturn errors.Wrapf(err,\n\t\t\t\"protoc exec failed.\\nprotoc output:\\n\\n%v\\nprotoc arguments:\\n\\n%v\\n\\n\",\n\t\t\tstring(outBytes), protocExec.Args)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "ba30f8fb3cedfbae3e51faa4ed95f8e1", "score": "0.4840298", "text": "func CephGoFunctions(source, packageName string, ii *Inspector) error {\n\tp, err := build.Import(\"./\"+packageName, source, 0)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttoCheck := []string{}\n\ttoCheck = append(toCheck, p.GoFiles...)\n\ttoCheck = append(toCheck, p.CgoFiles...)\n\tfor _, fname := range toCheck {\n\t\tlogger.Printf(\"Reading go file: %v\\n\", fname)\n\t\tsrc, err := ioutil.ReadFile(path.Join(p.Dir, fname))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfset := token.NewFileSet()\n\t\tf, err := parser.ParseFile(\n\t\t\tfset,\n\t\t\tfname,\n\t\t\tsrc,\n\t\t\tparser.ParseComments|parser.AllErrors)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tast.Walk(ii.visitor, f)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "7605a4fde500afb7ca58b9792e69af16", "score": "0.48311362", "text": "func GoString(jStr *Object) string {\n\tcharArr := jStr.GetRefVar(\"value\", \"[C\")\n\treturn utf16ToString(charArr.Chars())\n}", "title": "" }, { "docid": "661b76f99c5d4389a6bcbeecd640f1d9", "score": "0.48095256", "text": "func installProtocGenGo() *cli.Command {\n\tcommand := commandDefault(\"protoc-gen-go\")\n\tcommand.Before = beforeDefault\n\tcommand.Action = protocGenGoAction\n\tcommand.After = afterDefault\n\n\treturn command\n}", "title": "" }, { "docid": "1dca842a6d8eb41ec80203130800837c", "score": "0.47907346", "text": "func GenerateGoCode(mod owl.GoModel, path string) (err error) {\n\tfmt.Println(\"Generate Go Code\")\n\n\t// make dirs\n\terr = os.MkdirAll(path+\"/pkg/ontology\", os.ModePerm)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar file *os.File\n\n\t// README\n\t// file, err = os.Create(path + \"/README.md\")\n\t// if err != nil {\n\t// \treturn\n\t// }\n\t// readme := generateReadme(mod[0].Name, mod[0].Description, mod[0].IRI)\n\t// fmt.Fprintln(file, readme)\n\t// file.Close()\n\n\t// module\n\tfile, err = os.Create(path + \"/go.mod\")\n\tif err != nil {\n\t\treturn\n\t}\n\tgomod := generateModule(mod.Module)\n\tfmt.Fprintln(file, gomod)\n\tfile.Close()\n\n\t// model\n\tfile, err = os.Create(path + \"/pkg/ontology/model.go\")\n\tif err != nil {\n\t\treturn\n\t}\n\tmodel := generateModel(&mod)\n\tfmt.Fprintln(file, template.OSSHeader+model)\n\tfile.Close()\n\n\t// individuals\n\tfile, err = os.Create(path + \"/pkg/ontology/individuals.go\")\n\tif err != nil {\n\t\treturn\n\t}\n\tind := generateIndividuals(&mod)\n\tfmt.Fprintln(file, template.OSSHeader+ind)\n\tfile.Close()\n\n\t// Properties struct\n\tfile, err = os.Create(path + \"/pkg/ontology/propstruct.go\")\n\tif err != nil {\n\t\treturn\n\t}\n\tstr, man, ser, ifc := generateProperties(&mod)\n\tfmt.Fprintln(file, template.OSSHeader+str)\n\tfile.Close()\n\n\t// Properties interface\n\tfile, err = os.Create(path + \"/pkg/ontology/propinterface.go\")\n\tif err != nil {\n\t\treturn\n\t}\n\tfmt.Fprintln(file, template.OSSHeader+ifc)\n\tfile.Close()\n\n\t// Properties manipulator\n\tfile, err = os.Create(path + \"/pkg/ontology/propmanipulator.go\")\n\tif err != nil {\n\t\treturn\n\t}\n\tfmt.Fprintln(file, template.OSSHeader+man)\n\tfile.Close()\n\n\t// Properties serializer\n\tfile, err = os.Create(path + \"/pkg/ontology/propserializer.go\")\n\tif err != nil {\n\t\treturn\n\t}\n\tfmt.Fprintln(file, template.OSSHeader+ser)\n\tfile.Close()\n\n\t// Classes\n\tfor j := range mod.Class {\n\t\tfile, err = os.Create(path + \"/pkg/ontology/\" + mod.Class[j].Name + \".go\")\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tclass := generateClass(mod.Class[j], &mod)\n\t\tfmt.Fprintln(file, template.OSSHeader+class)\n\t\tfile.Close()\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "a046df84d0966eeb9c6a47a96737c619", "score": "0.47889644", "text": "func goOpenAPI(root string) {\n\tfmt.Println(\"...compiling OpenAPI specification...\")\n\n\tapi := filepath.Join(root, \"api\")\n\ttemplate := filepath.Join(api, \"oai-template.json\")\n\toutput := filepath.Join(root, \"bin\", \"openapi.json\")\n\n\ttmp := comfiler.Comfile{\n\t\tTemplate: template,\n\t\tResources: api,\n\t}\n\n\terr := tmp.Compile(output)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tprintOk(output, \"created\")\n\n\tcl := filepath.Join(root, \"CHANGELOG.md\")\n\tclBin := filepath.Join(root, \"bin\", \"CHANGELOG.md\")\n\tcopyFile(cl, clBin)\n\tprintOk(clBin, \"copied\")\n}", "title": "" }, { "docid": "4ced1d332ec64e40ea065f45599bea6a", "score": "0.47724622", "text": "func convertToGoType(tip string) string {\n\tif v, ok := typeMap[tip]; ok {\n\t\treturn v\n\t}\n\tgoramlPkgDir := func() string {\n\t\tif globGoramlPkgDir == \"\" {\n\t\t\treturn \"\"\n\t\t}\n\t\treturn globGoramlPkgDir + \".\"\n\t}()\n\tdateMap := map[string]string{\n\t\t\"date\": goramlPkgDir + \"Date\",\n\t\t\"date-only\": goramlPkgDir + \"DateOnly\",\n\t\t\"time-only\": goramlPkgDir + \"TimeOnly\",\n\t\t\"datetime-only\": goramlPkgDir + \"DatetimeOnly\",\n\t\t\"datetime\": goramlPkgDir + \"DateTime\",\n\t}\n\n\tif v, ok := dateMap[tip]; ok {\n\t\treturn v\n\t}\n\n\t// other types that need some processing\n\tswitch {\n\tcase strings.HasSuffix(tip, \"[][]\"): // bidimensional array\n\t\treturn \"[][]\" + convertToGoType(tip[:len(tip)-4])\n\tcase strings.HasSuffix(tip, \"[]\"): // array\n\t\treturn \"[]\" + convertToGoType(tip[:len(tip)-2])\n\tcase strings.HasSuffix(tip, \"{}\"): // map\n\t\treturn \"map[string]\" + convertToGoType(tip[:len(tip)-2])\n\tcase strings.Index(tip, \"|\") > 0:\n\t\treturn convertUnion(tip)\n\t}\n\treturn commons.NormalizePkgName(tip)\n}", "title": "" }, { "docid": "f6ab52160d5f35605b45c52205204233", "score": "0.47693193", "text": "func gldef2go(gldef string) string {\n\n\treturn strings.TrimPrefix(gldef, \"GL_\")\n}", "title": "" }, { "docid": "37716a3231f8fe1ce1f3ab3260443d01", "score": "0.4763225", "text": "func (s *BaseGoParserListener) EnterConversion(ctx *ConversionContext) {}", "title": "" }, { "docid": "f10c9fa197d11116d34337e5fc8866ba", "score": "0.4751583", "text": "func Ck2lc(in string) string { return Ck2lc_.String(in) }", "title": "" }, { "docid": "8cb9004dcc612b3675e15252777ee3b2", "score": "0.4747448", "text": "func (def *Definition) ToCUE() (*cue.Value, string, error) {\n\tannotations := map[string]string{}\n\tfor key, val := range def.GetAnnotations() {\n\t\tif strings.HasPrefix(key, DefinitionUserPrefix) {\n\t\t\tannotations[strings.TrimPrefix(key, DefinitionUserPrefix)] = val\n\t\t}\n\t}\n\tdesc := def.GetAnnotations()[DefinitionDescriptionKey]\n\tlabels := map[string]string{}\n\tfor key, val := range def.GetLabels() {\n\t\tif strings.HasPrefix(key, DefinitionUserPrefix) {\n\t\t\tlabels[strings.TrimPrefix(key, DefinitionUserPrefix)] = val\n\t\t}\n\t}\n\tspec := map[string]interface{}{}\n\tfor key, val := range def.Object[\"spec\"].(map[string]interface{}) {\n\t\tif key != \"schematic\" {\n\t\t\tspec[key] = val\n\t\t}\n\t}\n\tobj := map[string]interface{}{\n\t\tdef.GetName(): map[string]interface{}{\n\t\t\t\"type\": def.GetType(),\n\t\t\t\"description\": desc,\n\t\t\t\"annotations\": annotations,\n\t\t\t\"labels\": labels,\n\t\t\t\"attributes\": spec,\n\t\t},\n\t}\n\tr := &cue.Runtime{}\n\tcodec := gocodec.New(r, &gocodec.Config{})\n\tval, err := codec.Decode(obj)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\n\ttemplateString, _, err := unstructured.NestedString(def.Object, DefinitionTemplateKeys...)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\ttemplateString, err = formatCUEString(templateString)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\treturn &val, templateString, nil\n}", "title": "" }, { "docid": "1b6230b332d4b42b8790da6e11c89310", "score": "0.4747261", "text": "func initGo(classType reflect.Type, fn reflect.Value) MrbFuncT {\n\treturn func(mrb *MrbState, self Value) MrbValue {\n\t\t// fetch args\n\t\targs := mrb.GetArgs()\n\t\targc := args.Len()\n\n\t\t// Special constructor - from go pointer\n\t\tif argc == 1 {\n\t\t\targValue := args.Item(0)\n\t\t\tif argValue.Type() == MrbTTCData {\n\t\t\t\tin := mrb.DataGetInterface(argValue)\n\t\t\t\targType := reflect.TypeOf(in)\n\t\t\t\tif (argType != nil) && (argType == classType) {\n\t\t\t\t\tmrb.DataSetInterface(self, in)\n\t\t\t\t\treturn afterInit(mrb, self)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tresult := mrb.callFunc(fn, args)\n\n\t\t// Check error\n\t\tif len(result) > 0 && result[len(result)-1].Type() == reflect.TypeOf((*error)(nil)).Elem() {\n\t\t\terr := result[len(result)-1].Interface()\n\t\t\tif err != nil {\n\t\t\t\treturn mrb.getErrorKlass(err.(error)).Raisef(\"%v.init_go : %v\", mrb.ClassPtr(self).Name(), err)\n\t\t\t}\n\t\t}\n\n\t\t// Handle results\n\t\tif len(result) == 0 {\n\t\t\treturn mrb.Raise(mrb.ERuntimeError(), \"constructor failed to return Go value\")\n\t\t}\n\n\t\t// Set object as MrbTTCData, with Data reference to Go object interface\n\t\tmrb.DataSetInterface(self, result[0].Interface())\n\t\treturn afterInit(mrb, self)\n\t}\n}", "title": "" }, { "docid": "a547c0f4af7965edd9b19fa8ba04059e", "score": "0.4739779", "text": "func GoGenerateMain(arg []string, imp *Importer) error {\n\tvar pkgpath string\n\tnarg := len(arg)\n\tswitch {\n\tcase narg == 0 || (narg > 0 && arg[0] == \".\"):\n\t\tcwd, err := os.Getwd()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"gomacro -g: error getting current dir: %v\", err)\n\t\t}\n\t\tgopath := build.Default.GOPATH\n\t\tprefix := gopath + sep + \"src\" + sep\n\t\tif strings.HasPrefix(cwd, prefix) {\n\t\t\tpkgpath = cwd[len(prefix):]\n\t\t} else {\n\t\t\t// guess it is after the first `src` in cwd,\n\t\t\t// since traditionally all packages are\n\t\t\t// after $GOPATH/src/\n\t\t\tsplt := strings.SplitN(cwd, sep+\"src\"+sep, 2)\n\t\t\tif len(splt) <= 1 {\n\t\t\t\treturn fmt.Errorf(\"gomacro -g: unable to detect current package, please specify it\")\n\t\t\t}\n\t\t\tpkgpath = splt[1]\n\t\t}\n\tdefault:\n\t\tpkgpath = arg[0]\n\t}\n\t_, err := imp.ImportPackageOrError(\"_i\", pkgpath)\n\treturn err\n}", "title": "" }, { "docid": "6fa848f6b026d4e07c9868005f85949d", "score": "0.47291735", "text": "func op2C(m *M6502) uint {\n\tv, _ := m.readAbsolute()\n\tm.opBit(v)\n\tm.PC += 3\n\treturn 4\n}", "title": "" }, { "docid": "c4b1228d902145e4a39a5a7ab5a75e26", "score": "0.471959", "text": "func Go() error {\n\tfmt.Println(\"\\n=====> Building cve-2018-1002105 binary...\\n\")\n\tstart := time.Now()\n\n\tvolumeMount := fmt.Sprintf(\"--volume=%v:/go/src/github.com/gravitational/cve-2018-1002105:delegated\", srcDir())\n\t//fmt.Println(\"Volume:\", volumeMount)\n\n\terr := trace.Wrap(sh.RunV(\n\t\t\"docker\",\n\t\t\"run\",\n\t\t\"-it\",\n\t\t\"--rm=true\",\n\t\tvolumeMount,\n\t\t`--env=\"GOCACHE=/go/src/github.com/gravitational/cve-2018-1002105/build/cache/go\"`,\n\t\tbuildContainer,\n\t\t\"go\",\n\t\t\"--\",\n\t\t\"build\",\n\t\t\"-o\",\n\t\t\"/go/src/github.com/gravitational/cve-2018-1002105/build/cve-2018-1002105\",\n\t\t\"github.com/gravitational/cve-2018-1002105\",\n\t))\n\n\telapsed := time.Since(start)\n\tfmt.Println(\"Build completed in \", elapsed)\n\n\treturn trace.Wrap(err)\n}", "title": "" }, { "docid": "5bde505c2b372ca980aa88b29df50285", "score": "0.47167715", "text": "func main() {\n\tC.SayHello(C.CString(\"Hello, World\\n\"))\n}", "title": "" }, { "docid": "0054c6bdbd2848f8a0f290e2ac156988", "score": "0.47100717", "text": "func (pgc PgGoConverter) Convert(srcType string, nullable string) (dstType string, err error) {\n\tswitch srcType {\n\tcase \"integer\", \"bigint\", \"smallint\":\n\t\tdstType = \"int\"\n\tcase \"double precision\", \"numeric\", \"real\":\n\t\tdstType = \"float64\"\n\tcase \"text\", \"character\", \"character varying\":\n\t\tdstType = \"string\"\n\tcase \"date\", \"time\", \"timestamp\":\n\t\tdstType = \"time.Time\"\n\tcase \"boolean\":\n\t\tdstType = \"bool\"\n\tcase \"USER-DEFINED\":\n\t\tdstType = \"[]byte\"\n\tdefault:\n\t\t// TODO: implement remaining data types\n\t\tdstType = \"STUB\"\n\t\t// return \"\", fmt.Errorf(\"unknown PostgreSQL datatype: %v\", srcType)\n\t}\n\n\t// TODO: decide about array types\n\tif strings.ToUpper(nullable) == \"YES\" {\n\t\tdstType = \"*\" + dstType\n\t}\n\n\treturn dstType, nil\n}", "title": "" }, { "docid": "5f1b0ef6b2831e7fa0b9e0a8df966115", "score": "0.47091898", "text": "func genNumberConversion(data *goData, targetType *vdl.Type, sourceKind vdl.Kind, valueAssn string) string {\n\ttargetKind := targetType.Kind()\n\ttargetKindName := vdlutil.FirstRuneToUpper(targetKind.String())\n\tif targetKindName == \"Byte\" {\n\t\ttargetKindName = \"Uint8\"\n\t}\n\tsourceKindName := vdlutil.FirstRuneToUpper(sourceKind.String())\n\ttargetTypeName := typeGo(data, targetType)\n\n\tif targetKind == sourceKind {\n\t\treturn fmt.Sprintf(`%s = %s(src)`, valueAssn, targetTypeName)\n\t} else {\n\t\treturn fmt.Sprintf(`val, err := %s%sTo%s(src)\n\tif err != nil {\n\t\treturn err\n\t}\n\t%s = %s(val)`, data.Pkg(\"v.io/v23/vdl/vdlconv\"), sourceKindName, targetKindName, valueAssn, targetTypeName)\n\t}\n}", "title": "" }, { "docid": "74b3183d02a92a63001b438e3bd10df8", "score": "0.47074932", "text": "func NullTypeToGoType(outfile *protogen.GeneratedFile, obj string, name string, field *protogen.Field) (string, error) {\n\t/*kind, err := generator.GoFieldType(outfile, field)\n\tif err != nil {\n\t\treturn \"\", nil\n\t}\n\n\tswitch kind {\n\tcase \"bool\":\n\t\treturn fmt.Sprintf(\"%s%s.Bool\", obj, name), nil\n\tcase \"float64\":\n\t\treturn fmt.Sprintf(\"%s%s.Float64\", obj, name), nil\n\tcase \"float32\":\n\t\treturn fmt.Sprintf(\"float32(%s%s.Float64)\", obj, name), nil\n\tcase \"int32\":\n\t\treturn fmt.Sprintf(\"%s%s.Int32\", obj, name), nil\n\tcase \"int64\":\n\t\treturn fmt.Sprintf(\"%s%s.Int64\", obj, name), nil\n\tcase \"string\":\n\t\treturn fmt.Sprintf(\"%s%s.String\", obj, name), nil\n\tdefault:\n\t\tif field.Enum != nil {\n\t\t\teType, err := generator.GoFieldType(outfile, field)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\treturn fmt.Sprintf(\"%s(%s%s.Int32)\", eType, obj, name), nil\n\t\t}\n\t\treturn fmt.Sprintf(\"%s%s\", obj, name), nil\n\t}\n\t*/\n\treturn \"\", nil\n}", "title": "" }, { "docid": "c8df0bf4fdac6891ad873a9d5f33f82e", "score": "0.47057086", "text": "func getProtocOutput(protoPaths, gopath []string) ([]byte, error) {\n\t_, err := exec.LookPath(\"protoc-gen-truss-protocast\")\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"protoc-gen-truss-protocast does not exist in $PATH\")\n\t}\n\n\tprotocOutDir, err := ioutil.TempDir(\"\", \"truss-\")\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"cannot create temp directory\")\n\t}\n\tdefer os.RemoveAll(protocOutDir)\n\n\tpluginCall := \"--truss-protocast_out=\" + protocOutDir\n\n\terr = protoc(protoPaths, gopath, pluginCall)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"protoc failed\")\n\t}\n\n\tfileInfo, err := ioutil.ReadDir(protocOutDir)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"cannot read directory: %v\", protocOutDir)\n\t}\n\n\tfor _, f := range fileInfo {\n\t\tif f.IsDir() {\n\t\t\tcontinue\n\t\t}\n\t\tfPath := filepath.Join(protocOutDir, f.Name())\n\t\tprotocOut, err := ioutil.ReadFile(fPath)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"cannot read file: %v\", fPath)\n\t\t}\n\t\treturn protocOut, nil\n\t}\n\n\treturn nil, errors.Errorf(\"no protoc output file found in: %v\", protocOutDir)\n}", "title": "" }, { "docid": "b3ffa1e11a079c94804aded8d081e5cf", "score": "0.46998325", "text": "func (sc *SliceConverter) CTransitionType() string {\n return \"PyObject*\"\n}", "title": "" }, { "docid": "7fd5296a96c70cdbbdeef148fad6d53e", "score": "0.46890685", "text": "func main() {\n\tapp := cli.NewApp()\n\tapp.Name = \"oci-convert\"\n\tapp.Usage = \"Tools for convert between different container bundle/image\"\n\tapp.Version = \"1.0.0\"\n\tapp.Commands = []cli.Command{\n\t\t{\n\t\t\tName: \"aci2oci\",\n\t\t\tAliases: []string{\"a2o\"},\n\t\t\tUsage: \"convert container formats from aci to oci: config and bundle\",\n\n\t\t\tAction: convertProcess,\n\t\t},\n\t}\n\n\tapp.Run(os.Args)\n\n\treturn\n}", "title": "" }, { "docid": "3732699822a586c4cc6405e7f157307d", "score": "0.46880358", "text": "func parse (c byte) byte {\n\tswitch c {\n\tcase 'a','A','e','E','i','I','o','O','u','U','y','Y':\n\t\treturn 'v'\n\tcase 'h','H','w','W':\n\t\treturn 'c'\n\tcase 'b','B','f','F','p','P','v','V':\n\t\treturn '1'\n\tcase 'c','C','g','G','j','J','k','K','q','Q','s','S','x','X','z','Z':\n\t\treturn '2'\n\tcase 'd', 'D', 't', 'T':\n\t\treturn '3'\n\tcase 'l', 'L':\n\t\treturn '4'\n\tcase 'm', 'M', 'n', 'N':\n\t\treturn '5'\n\tcase 'r', 'R':\n\t\treturn '6'\n\tdefault:\n\t\treturn 'X'\n\t}\n}", "title": "" }, { "docid": "edb9c4beacd3feafd70d62334315c9a1", "score": "0.46820205", "text": "func (s SourceCode) GoString() string {\n\treturn s.String()\n}", "title": "" }, { "docid": "679da681fff0becd06970dbdae4be6c3", "score": "0.46759686", "text": "func solve2(input string) string {\n\t// add the instruction to initialize c to 1\n\tops := parseInput(\"cpy 1 c\\n\" + input)\n\treg := runProgram(ops)\n\treturn fmt.Sprintf(\"%d\", reg[0])\n}", "title": "" }, { "docid": "28addf16264bd92dbea468cd934bc31d", "score": "0.4660962", "text": "func CgoAtio13(ri, di, utc1, utc2, dut1, elong, phi, hm, xp, yp, phpa,\n\ttc, rh, wl float64) (aob, zob, hob, dob, rob float64,\n\terr error) {\n\n\tvar cAob, cZob, cHob, cDob, cRob C.double\n\tcI := C.iauAtio13(C.double(ri), C.double(di), C.double(utc1),\n\t\tC.double(utc2), C.double(dut1), C.double(elong),\n\t\tC.double(phi), C.double(hm), C.double(xp), C.double(yp),\n\t\tC.double(phpa), C.double(tc), C.double(rh),\n\t\tC.double(wl),\n\t\t&cAob, &cZob, &cHob, &cDob, &cRob)\n\n\tswitch int(cI) {\n\tcase 0:\n\tcase 1:\n\t\terr = errAtio13Warn\n\tcase -1:\n\t\terr = errAtio13E1\n\tdefault:\n\t\terr = errAdmin\n\t}\n\treturn float64(cAob), float64(cZob), float64(cHob),\n\t\tfloat64(cDob), float64(cRob), err\n}", "title": "" }, { "docid": "e540237cb029166231f1157748105b5d", "score": "0.4648616", "text": "func createJsCodeGenerator(namespace string) func(*os.File, string, db.TypeDefinition) {\n\tjsPrefix := \"\"\n\tclassPrefix := \"\"\n\tcppPrefix := \"\"\n\tif namespace != \"\" {\n\t\tjsPrefix = namespace + \"$\"\n\t\tclassPrefix = namespace + \".prototype.\"\n\t\tcppPrefix = namespace + \"::\"\n\t}\n\t// These template extensions are used to transmogrify C++ symbols and value literals into\n\t// JavaScript. We mostly don't need to do anything since the parser has already done some\n\t// massaging and verification (e.g. it removed the trailing \"f\" from floating point literals).\n\t// However enums need some special care here. Emscripten bindings are flat, so our own\n\t// convention is to use $ for the scoping delimiter, which is a legal symbol character in JS.\n\t// However we still use . to separate the enum value from the enum type, because emscripten has\n\t// first-class support for class enums.\n\tcustomExtensions := template.FuncMap{\n\t\t\"qualifiedtype\": func(typename string) string {\n\t\t\ttypename = strings.ReplaceAll(typename, \"::\", \"$\")\n\t\t\treturn typename\n\t\t},\n\t\t\"flag\": func(field *db.StructField, flag string) bool {\n\t\t\t_, exists := field.EmitterFlags[flag]\n\t\t\treturn exists\n\t\t},\n\t\t\"qualifiedvalue\": func(name string) string {\n\t\t\tname = strings.Replace(name, \"INFINITY\", \"Infinity\", 1)\n\t\t\tcount := strings.Count(name, \"::\")\n\t\t\tif count > 0 {\n\t\t\t\tname = \"Filament.\" + jsPrefix + name\n\t\t\t}\n\t\t\tname = strings.Replace(name, \"::\", \"$\", count-1)\n\t\t\tname = strings.Replace(name, \"::\", \".\", 1)\n\t\t\treturn name\n\t\t},\n\t\t\"tstype\": func(cpptype string) string {\n\t\t\tif strings.HasPrefix(cpptype, \"math::\") {\n\t\t\t\treturn cpptype[6:]\n\t\t\t}\n\t\t\tswitch cpptype {\n\t\t\tcase \"float\", \"uint8_t\", \"uint32_t\", \"uint16_t\":\n\t\t\t\treturn \"number\"\n\t\t\tcase \"bool\":\n\t\t\t\treturn \"boolean\"\n\t\t\tcase \"LinearColorA\":\n\t\t\t\treturn \"float4\"\n\t\t\tcase \"LinearColor\":\n\t\t\t\treturn \"float3\"\n\t\t\t}\n\t\t\treturn jsPrefix + strings.ReplaceAll(cpptype, \"::\", \"$\")\n\t\t},\n\t\t\"jsprefix\": func() string { return jsPrefix },\n\t\t\"cprefix\": func() string { return cppPrefix },\n\t\t\"classprefix\": func() string { return classPrefix },\n\t\t\"docblock\": func(defn db.Documented, depth int) string {\n\t\t\tdoc := defn.GetDoc()\n\t\t\tif doc == \"\" {\n\t\t\t\treturn \"\"\n\t\t\t}\n\t\t\tindent := strings.Repeat(\" \", depth)\n\t\t\tif strings.Count(doc, \"\\n\") > 0 {\n\t\t\t\treturn strings.ReplaceAll(doc, \"\\n\", \"\\n\"+indent)\n\t\t\t}\n\t\t\treturn \"/**\\n\" + indent + \" * \" + doc + \"\\n\" + indent + \" */\\n\" + indent\n\t\t},\n\t}\n\n\ttempl := template.New(\"beamsplitter\").Funcs(customExtensions)\n\ttempl = template.Must(templ.ParseFiles(\"emitters/javascript.template\"))\n\treturn func(file *os.File, section string, definition db.TypeDefinition) {\n\t\terr := templ.ExecuteTemplate(file, section, definition)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err.Error())\n\t\t}\n\t}\n}", "title": "" }, { "docid": "43ce21ed95fb87786846bd5f5b441a07", "score": "0.464306", "text": "func (p *Package) writeDefs() {\n\tvar fgo2, fc io.Writer\n\tf := creat(*objDir + \"_cgo_gotypes.go\")\n\tdefer f.Close()\n\tfgo2 = f\n\tif *gccgo {\n\t\tf := creat(*objDir + \"_cgo_defun.c\")\n\t\tdefer f.Close()\n\t\tfc = f\n\t}\n\tfm := creat(*objDir + \"_cgo_main.c\")\n\n\tvar gccgoInit bytes.Buffer\n\n\tfflg := creat(*objDir + \"_cgo_flags\")\n\tfor k, v := range p.CgoFlags {\n\t\tfmt.Fprintf(fflg, \"_CGO_%s=%s\\n\", k, strings.Join(v, \" \"))\n\t\tif k == \"LDFLAGS\" && !*gccgo {\n\t\t\tfor _, arg := range v {\n\t\t\t\tfmt.Fprintf(fgo2, \"//go:cgo_ldflag %q\\n\", arg)\n\t\t\t}\n\t\t}\n\t}\n\tfflg.Close()\n\n\t// Write C main file for using gcc to resolve imports.\n\tfmt.Fprintf(fm, \"int main() { return 0; }\\n\")\n\tif *importRuntimeCgo {\n\t\tfmt.Fprintf(fm, \"void crosscall2(void(*fn)(void*, int, __SIZE_TYPE__), void *a, int c, __SIZE_TYPE__ ctxt) { }\\n\")\n\t\tfmt.Fprintf(fm, \"__SIZE_TYPE__ _cgo_wait_runtime_init_done(void) { return 0; }\\n\")\n\t\tfmt.Fprintf(fm, \"void _cgo_release_context(__SIZE_TYPE__ ctxt) { }\\n\")\n\t\tfmt.Fprintf(fm, \"char* _cgo_topofstack(void) { return (char*)0; }\\n\")\n\t} else {\n\t\t// If we're not importing runtime/cgo, we *are* runtime/cgo,\n\t\t// which provides these functions. We just need a prototype.\n\t\tfmt.Fprintf(fm, \"void crosscall2(void(*fn)(void*, int, __SIZE_TYPE__), void *a, int c, __SIZE_TYPE__ ctxt);\\n\")\n\t\tfmt.Fprintf(fm, \"__SIZE_TYPE__ _cgo_wait_runtime_init_done(void);\\n\")\n\t\tfmt.Fprintf(fm, \"void _cgo_release_context(__SIZE_TYPE__);\\n\")\n\t}\n\tfmt.Fprintf(fm, \"void _cgo_allocate(void *a, int c) { }\\n\")\n\tfmt.Fprintf(fm, \"void _cgo_panic(void *a, int c) { }\\n\")\n\tfmt.Fprintf(fm, \"void _cgo_reginit(void) { }\\n\")\n\n\t// Write second Go output: definitions of _C_xxx.\n\t// In a separate file so that the import of \"unsafe\" does not\n\t// pollute the original file.\n\tfmt.Fprintf(fgo2, \"// Code generated by cmd/cgo; DO NOT EDIT.\\n\\n\")\n\tfmt.Fprintf(fgo2, \"package %s\\n\\n\", p.PackageName)\n\tfmt.Fprintf(fgo2, \"import \\\"unsafe\\\"\\n\\n\")\n\tif !*gccgo && *importRuntimeCgo {\n\t\tfmt.Fprintf(fgo2, \"import _ \\\"runtime/cgo\\\"\\n\\n\")\n\t}\n\tif *importSyscall {\n\t\tfmt.Fprintf(fgo2, \"import \\\"syscall\\\"\\n\\n\")\n\t\tfmt.Fprintf(fgo2, \"var _ syscall.Errno\\n\")\n\t}\n\tfmt.Fprintf(fgo2, \"func _Cgo_ptr(ptr unsafe.Pointer) unsafe.Pointer { return ptr }\\n\\n\")\n\n\tif !*gccgo {\n\t\tfmt.Fprintf(fgo2, \"//go:linkname _Cgo_always_false runtime.cgoAlwaysFalse\\n\")\n\t\tfmt.Fprintf(fgo2, \"var _Cgo_always_false bool\\n\")\n\t\tfmt.Fprintf(fgo2, \"//go:linkname _Cgo_use runtime.cgoUse\\n\")\n\t\tfmt.Fprintf(fgo2, \"func _Cgo_use(interface{})\\n\")\n\t}\n\n\ttypedefNames := make([]string, 0, len(typedef))\n\tfor name := range typedef {\n\t\ttypedefNames = append(typedefNames, name)\n\t}\n\tsort.Strings(typedefNames)\n\tfor _, name := range typedefNames {\n\t\tdef := typedef[name]\n\t\tfmt.Fprintf(fgo2, \"type %s \", name)\n\t\t// We don't have source info for these types, so write them out without source info.\n\t\t// Otherwise types would look like:\n\t\t//\n\t\t// type _Ctype_struct_cb struct {\n\t\t// //line :1\n\t\t// on_test *[0]byte\n\t\t// //line :1\n\t\t// }\n\t\t//\n\t\t// Which is not useful. Moreover we never override source info,\n\t\t// so subsequent source code uses the same source info.\n\t\t// Moreover, empty file name makes compile emit no source debug info at all.\n\t\tvar buf bytes.Buffer\n\t\tnoSourceConf.Fprint(&buf, fset, def.Go)\n\t\tif bytes.HasPrefix(buf.Bytes(), []byte(\"_Ctype_\")) {\n\t\t\t// This typedef is of the form `typedef a b` and should be an alias.\n\t\t\tfmt.Fprintf(fgo2, \"= \")\n\t\t}\n\t\tfmt.Fprintf(fgo2, \"%s\", buf.Bytes())\n\t\tfmt.Fprintf(fgo2, \"\\n\\n\")\n\t}\n\tif *gccgo {\n\t\tfmt.Fprintf(fgo2, \"type _Ctype_void byte\\n\")\n\t} else {\n\t\tfmt.Fprintf(fgo2, \"type _Ctype_void [0]byte\\n\")\n\t}\n\n\tif *gccgo {\n\t\tfmt.Fprint(fgo2, gccgoGoProlog)\n\t\tfmt.Fprint(fc, p.cPrologGccgo())\n\t} else {\n\t\tfmt.Fprint(fgo2, goProlog)\n\t}\n\n\tif fc != nil {\n\t\tfmt.Fprintf(fc, \"#line 1 \\\"cgo-generated-wrappers\\\"\\n\")\n\t}\n\tif fm != nil {\n\t\tfmt.Fprintf(fm, \"#line 1 \\\"cgo-generated-wrappers\\\"\\n\")\n\t}\n\n\tgccgoSymbolPrefix := p.gccgoSymbolPrefix()\n\n\tcVars := make(map[string]bool)\n\tfor _, key := range nameKeys(p.Name) {\n\t\tn := p.Name[key]\n\t\tif !n.IsVar() {\n\t\t\tcontinue\n\t\t}\n\n\t\tif !cVars[n.C] {\n\t\t\tif *gccgo {\n\t\t\t\tfmt.Fprintf(fc, \"extern byte *%s;\\n\", n.C)\n\t\t\t} else {\n\t\t\t\tfmt.Fprintf(fm, \"extern char %s[];\\n\", n.C)\n\t\t\t\tfmt.Fprintf(fm, \"void *_cgohack_%s = %s;\\n\\n\", n.C, n.C)\n\t\t\t\tfmt.Fprintf(fgo2, \"//go:linkname __cgo_%s %s\\n\", n.C, n.C)\n\t\t\t\tfmt.Fprintf(fgo2, \"//go:cgo_import_static %s\\n\", n.C)\n\t\t\t\tfmt.Fprintf(fgo2, \"var __cgo_%s byte\\n\", n.C)\n\t\t\t}\n\t\t\tcVars[n.C] = true\n\t\t}\n\n\t\tvar node ast.Node\n\t\tif n.Kind == \"var\" {\n\t\t\tnode = &ast.StarExpr{X: n.Type.Go}\n\t\t} else if n.Kind == \"fpvar\" {\n\t\t\tnode = n.Type.Go\n\t\t} else {\n\t\t\tpanic(fmt.Errorf(\"invalid var kind %q\", n.Kind))\n\t\t}\n\t\tif *gccgo {\n\t\t\tfmt.Fprintf(fc, `extern void *%s __asm__(\"%s.%s\");`, n.Mangle, gccgoSymbolPrefix, n.Mangle)\n\t\t\tfmt.Fprintf(&gccgoInit, \"\\t%s = &%s;\\n\", n.Mangle, n.C)\n\t\t\tfmt.Fprintf(fc, \"\\n\")\n\t\t}\n\n\t\tfmt.Fprintf(fgo2, \"var %s \", n.Mangle)\n\t\tconf.Fprint(fgo2, fset, node)\n\t\tif !*gccgo {\n\t\t\tfmt.Fprintf(fgo2, \" = (\")\n\t\t\tconf.Fprint(fgo2, fset, node)\n\t\t\tfmt.Fprintf(fgo2, \")(unsafe.Pointer(&__cgo_%s))\", n.C)\n\t\t}\n\t\tfmt.Fprintf(fgo2, \"\\n\")\n\t}\n\tif *gccgo {\n\t\tfmt.Fprintf(fc, \"\\n\")\n\t}\n\n\tfor _, key := range nameKeys(p.Name) {\n\t\tn := p.Name[key]\n\t\tif n.Const != \"\" {\n\t\t\tfmt.Fprintf(fgo2, \"const %s = %s\\n\", n.Mangle, n.Const)\n\t\t}\n\t}\n\tfmt.Fprintf(fgo2, \"\\n\")\n\n\tcallsMalloc := false\n\tfor _, key := range nameKeys(p.Name) {\n\t\tn := p.Name[key]\n\t\tif n.FuncType != nil {\n\t\t\tp.writeDefsFunc(fgo2, n, &callsMalloc)\n\t\t}\n\t}\n\n\tfgcc := creat(*objDir + \"_cgo_export.c\")\n\tfgcch := creat(*objDir + \"_cgo_export.h\")\n\tif *gccgo {\n\t\tp.writeGccgoExports(fgo2, fm, fgcc, fgcch)\n\t} else {\n\t\tp.writeExports(fgo2, fm, fgcc, fgcch)\n\t}\n\n\tif callsMalloc && !*gccgo {\n\t\tfmt.Fprint(fgo2, strings.Replace(cMallocDefGo, \"PREFIX\", cPrefix, -1))\n\t\tfmt.Fprint(fgcc, strings.Replace(strings.Replace(cMallocDefC, \"PREFIX\", cPrefix, -1), \"PACKED\", p.packedAttribute(), -1))\n\t}\n\n\tif err := fgcc.Close(); err != nil {\n\t\tfatalf(\"%s\", err)\n\t}\n\tif err := fgcch.Close(); err != nil {\n\t\tfatalf(\"%s\", err)\n\t}\n\n\tif *exportHeader != \"\" && len(p.ExpFunc) > 0 {\n\t\tfexp := creat(*exportHeader)\n\t\tfgcch, err := os.Open(*objDir + \"_cgo_export.h\")\n\t\tif err != nil {\n\t\t\tfatalf(\"%s\", err)\n\t\t}\n\t\t_, err = io.Copy(fexp, fgcch)\n\t\tif err != nil {\n\t\t\tfatalf(\"%s\", err)\n\t\t}\n\t\tif err = fexp.Close(); err != nil {\n\t\t\tfatalf(\"%s\", err)\n\t\t}\n\t}\n\n\tinit := gccgoInit.String()\n\tif init != \"\" {\n\t\t// The init function does nothing but simple\n\t\t// assignments, so it won't use much stack space, so\n\t\t// it's OK to not split the stack. Splitting the stack\n\t\t// can run into a bug in clang (as of 2018-11-09):\n\t\t// this is a leaf function, and when clang sees a leaf\n\t\t// function it won't emit the split stack prologue for\n\t\t// the function. However, if this function refers to a\n\t\t// non-split-stack function, which will happen if the\n\t\t// cgo code refers to a C function not compiled with\n\t\t// -fsplit-stack, then the linker will think that it\n\t\t// needs to adjust the split stack prologue, but there\n\t\t// won't be one. Marking the function explicitly\n\t\t// no_split_stack works around this problem by telling\n\t\t// the linker that it's OK if there is no split stack\n\t\t// prologue.\n\t\tfmt.Fprintln(fc, \"static void init(void) __attribute__ ((constructor, no_split_stack));\")\n\t\tfmt.Fprintln(fc, \"static void init(void) {\")\n\t\tfmt.Fprint(fc, init)\n\t\tfmt.Fprintln(fc, \"}\")\n\t}\n}", "title": "" }, { "docid": "1097e756022c8b7991e88941ad22eb37", "score": "0.4638567", "text": "func makeBPFObject(outFile string) error {\n\t// drop capabilities for the compilation process\n\tcap, err := getSelfCapabilities()\n\tif err != nil {\n\t\treturn err\n\t}\n\tcapNew, err := capability.NewPid2(0)\n\tif err != err {\n\t\treturn err\n\t}\n\tcapNew.Clear(capability.BOUNDS)\n\terr = capNew.Apply(capability.BOUNDS)\n\tif err != err {\n\t\treturn err\n\t}\n\tdefer cap.Apply(capability.BOUNDS)\n\tdir, err := ioutil.TempDir(\"\", \"tracee-make\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif debug {\n\t\tfmt.Printf(\"building bpf object in: %s\\n\", dir)\n\t} else {\n\t\tdefer os.RemoveAll(dir)\n\t}\n\tobjFile := filepath.Join(dir, \"tracee.bpf.o\")\n\terr = unpackBPFBundle(dir)\n\tif err != nil {\n\t\treturn err\n\t}\n\tclang := locateFile(\"clang\", []string{os.Getenv(\"CLANG\")})\n\tif clang == \"\" {\n\t\treturn fmt.Errorf(\"missing compilation dependency: clang\")\n\t}\n\tcmdVer := exec.Command(clang, \"--version\")\n\tverOut, err := cmdVer.CombinedOutput()\n\tif err != nil {\n\t\treturn err\n\t}\n\t// we are looking for the \"version x.y.z\" part in the text output\n\tstart := strings.Index(string(verOut), \"version\") + 8\n\tend := strings.Index(string(verOut), \"\\n\")\n\tverStr := string(verOut[start:end])\n\tverMajor, err := strconv.Atoi(strings.SplitN(verStr, \".\", 2)[0])\n\tif err != nil {\n\t\tif debug {\n\t\t\tfmt.Printf(\"warning: could not detect clang version from: %s\", string(verOut))\n\t\t}\n\t} else if verMajor < 9 {\n\t\treturn fmt.Errorf(\"detected clang version: %d is older than required minimum version: 9\", verMajor)\n\t}\n\tllc := locateFile(\"llc\", []string{os.Getenv(\"LLC\")})\n\tif llc == \"\" {\n\t\treturn fmt.Errorf(\"missing compilation dependency: llc\")\n\t}\n\tllvmstrip := locateFile(\"llvm-strip\", []string{os.Getenv(\"LLVM_STRIP\")})\n\n\tkernelHeaders := locateFile(\"\", []string{os.Getenv(\"KERN_HEADERS\")})\n\tkernelBuildPath := locateFile(\"\", []string{fmt.Sprintf(\"/lib/modules/%s/build\", tracee.UnameRelease())})\n\tkernelSourcePath := locateFile(\"\", []string{fmt.Sprintf(\"/lib/modules/%s/source\", tracee.UnameRelease())})\n\tif kernelHeaders != \"\" {\n\t\t// In case KERN_HEADERS is set, use it for both source/ and build/\n\t\tkernelBuildPath = kernelHeaders\n\t\tkernelSourcePath = kernelHeaders\n\t}\n\tif kernelBuildPath == \"\" {\n\t\treturn fmt.Errorf(\"missing kernel source code compilation dependency\")\n\t}\n\t// In some distros (e.g. debian, suse), kernel headers are split to build/ and source/\n\t// while in others (e.g. ubuntu, arch), all headers will be located under build/\n\tif kernelSourcePath == \"\" {\n\t\tkernelSourcePath = kernelBuildPath\n\t}\n\tlinuxArch := os.Getenv(\"ARCH\")\n\tif linuxArch == \"\" {\n\t\tlinuxArch = strings.Replace(runtime.GOARCH, \"amd64\", \"x86\", 1)\n\t}\n\n\t// from the Makefile:\n\t// $(CLANG) -S \\\n\t// \t-D__BPF_TRACING__ \\\n\t// \t-D__KERNEL__ \\\n\t// \t-D__TARGET_ARCH_$(linux_arch) \\\n\t// \t-I $(LIBBPF_HEADERS)/bpf \\\n\t// \t-include $(KERN_SRC_PATH)/include/linux/kconfig.h \\\n\t// \t-I $(KERN_SRC_PATH)/arch/$(linux_arch)/include \\\n\t// \t-I $(KERN_SRC_PATH)/arch/$(linux_arch)/include/uapi \\\n\t// \t-I $(KERN_BLD_PATH)/arch/$(linux_arch)/include/generated \\\n\t// \t-I $(KERN_BLD_PATH)/arch/$(linux_arch)/include/generated/uapi \\\n\t// \t-I $(KERN_SRC_PATH)/include \\\n\t// \t-I $(KERN_BLD_PATH)/include \\\n\t// \t-I $(KERN_SRC_PATH)/include/uapi \\\n\t// \t-I $(KERN_BLD_PATH)/include/generated \\\n\t// \t-I $(KERN_BLD_PATH)/include/generated/uapi \\\n\t// \t-I $(BPF_HEADERS) \\\n\t// \t-Wno-address-of-packed-member \\\n\t// \t-Wno-compare-distinct-pointer-types \\\n\t// \t-Wno-deprecated-declarations \\\n\t// \t-Wno-gnu-variable-sized-type-not-at-end \\\n\t// \t-Wno-pointer-sign \\\n\t// \t-Wno-pragma-once-outside-heade \\\n\t// \t-Wno-unknown-warning-option \\\n\t// \t-Wno-unused-value \\\n\t// \t-Wunused \\\n\t// \t-Wall \\\n\t// \t-fno-stack-protector \\\n\t// \t-fno-jump-tables \\\n\t// \t-fno-unwind-tables \\\n\t// \t-fno-asynchronous-unwind-tables \\\n\t// \t-xc \\\n\t// \t-nostdinc \\\n\t// \t-O2 -emit-llvm -c -g $< -o $(@:.o=.ll)\n\tintermediateFile := strings.Replace(objFile, \".o\", \".ll\", 1)\n\t// TODO: validate all files/directories. perhaps using locateFile\n\tcmd1 := exec.Command(clang,\n\t\t\"-S\",\n\t\t\"-D__BPF_TRACING__\",\n\t\t\"-D__KERNEL__\",\n\t\tfmt.Sprintf(\"-D__TARGET_ARCH_%s\", linuxArch),\n\t\tfmt.Sprintf(\"-I%s\", dir),\n\t\tfmt.Sprintf(\"-include%s/include/linux/kconfig.h\", kernelSourcePath),\n\t\tfmt.Sprintf(\"-I%s/arch/%s/include\", kernelSourcePath, linuxArch),\n\t\tfmt.Sprintf(\"-I%s/arch/%s/include/uapi\", kernelSourcePath, linuxArch),\n\t\tfmt.Sprintf(\"-I%s/arch/%s/include/generated\", kernelBuildPath, linuxArch),\n\t\tfmt.Sprintf(\"-I%s/arch/%s/include/generated/uapi\", kernelBuildPath, linuxArch),\n\t\tfmt.Sprintf(\"-I%s/include\", kernelSourcePath),\n\t\tfmt.Sprintf(\"-I%s/include\", kernelBuildPath),\n\t\tfmt.Sprintf(\"-I%s/include/uapi\", kernelSourcePath),\n\t\tfmt.Sprintf(\"-I%s/include/generated\", kernelBuildPath),\n\t\tfmt.Sprintf(\"-I%s/include/generated/uapi\", kernelBuildPath),\n\t\t\"-Wno-address-of-packed-member\",\n\t\t\"-Wno-compare-distinct-pointer-types\",\n\t\t\"-Wno-deprecated-declarations\",\n\t\t\"-Wno-gnu-variable-sized-type-not-at-end\",\n\t\t\"-Wno-pointer-sign\",\n\t\t\"-Wno-pragma-once-outside-heade\",\n\t\t\"-Wno-unknown-warning-option\",\n\t\t\"-Wno-unused-value\",\n\t\t\"-Wunused\",\n\t\t\"-Wall\",\n\t\t\"-fno-stack-protector\",\n\t\t\"-fno-jump-tables\",\n\t\t\"-fno-unwind-tables\",\n\t\t\"-fno-asynchronous-unwind-tables\",\n\t\t\"-xc\",\n\t\t\"-nostdinc\", \"-O2\", \"-emit-llvm\", \"-c\", \"-g\", filepath.Join(dir, \"tracee.bpf.c\"), fmt.Sprintf(\"-o%s\", intermediateFile),\n\t)\n\tcmd1.Dir = dir\n\tif debug {\n\t\tfmt.Println(cmd1)\n\t\tcmd1.Stdout = os.Stdout\n\t\tcmd1.Stderr = os.Stderr\n\t}\n\terr = cmd1.Run()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to make BPF object (clang): %v. Try using --debug for more info\", err)\n\t}\n\n\t// from Makefile:\n\t// $(LLC) -march=bpf -filetype=obj -o $@ $(@:.o=.ll)\n\tcmd2 := exec.Command(llc,\n\t\t\"-march=bpf\",\n\t\t\"-filetype=obj\",\n\t\t\"-o\", objFile,\n\t\tintermediateFile,\n\t)\n\tcmd2.Dir = dir\n\tif debug {\n\t\tfmt.Println(cmd2)\n\t\tcmd2.Stdout = os.Stdout\n\t\tcmd2.Stderr = os.Stderr\n\t}\n\terr = cmd2.Run()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to make BPF object (llc): %v. Try using --debug for more info\", err)\n\t}\n\n\t// from Makefile:\n\t// -$(LLVM_STRIP) -g $@\n\tif llvmstrip != \"\" {\n\t\tcmd3 := exec.Command(llvmstrip,\n\t\t\t\"-g\", objFile,\n\t\t)\n\t\tcmd3.Dir = dir\n\t\tif debug {\n\t\t\tfmt.Println(cmd3)\n\t\t\tcmd3.Stdout = os.Stdout\n\t\t\tcmd3.Stderr = os.Stderr\n\t\t}\n\t\terr = cmd3.Run()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to make BPF object (llvm-strip): %v. Try using --debug for more info\", err)\n\t\t}\n\t}\n\n\tif debug {\n\t\tfmt.Printf(\"successfully built ebpf obj file at: %s\\n\", objFile)\n\t}\n\tos.MkdirAll(filepath.Dir(outFile), 0755)\n\terr = tracee.CopyFileByPath(objFile, outFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "c11abc19ec353de9094d1b8358ed2592", "score": "0.46378458", "text": "func ASTConv() {\n\n}", "title": "" }, { "docid": "00eaa0fe1b5ad1f8c36e70e3be26b343", "score": "0.46358368", "text": "func Compile() Command { return Main.Compile() }", "title": "" }, { "docid": "982b3a5fbb64ffe5212d1930111f0cde", "score": "0.4616609", "text": "func RunConverter() {\n\n\targs := os.Args[1:]\n\n\tif len(args) < 3 {\n\t\thelp()\n\t\tos.Exit(1)\n\t}\n\n\tamount, err := strconv.ParseFloat(args[0], 64)\n\tif err != nil {\n\t\tboldRed.Println(err.Error())\n\t\tos.Exit(1)\n\t}\n\n\tfrom := strings.ToUpper(args[1])\n\n\ttoItems := args[2:]\n\n\tconfigDir := createConfigDir(\".gocash\")\n\n\tconfigFileURL := \"https://github.com/basebandit/gocash/blob/master/config.json\"\n\n\tcurrencyFileURL := \"https://github.com/basebandit/gocash/blob/master/currencies.json\"\n\n\tconfigFile := fmt.Sprintf(\"%s/config.json\", configDir)\n\n\tcfg, err := config.LoadConfig(configFile)\n\n\tif err != nil {\n\t\tboldRed.Printf(\"Could not find your config file.Copy %s inside %s\\n\", yellow(configFileURL), yellow(configDir))\n\t\tos.Exit(1)\n\t}\n\n\tcurrencyFile := fmt.Sprintf(\"%s/currencies.json\", configDir)\n\tcurrencies, err := config.GetCurrencies(currencyFile)\n\n\tif err != nil {\n\t\tboldRed.Printf(\"Could not find currencies list.Copy %s inside %s\\n\", yellow(currencyFileURL), yellow(configDir))\n\t\tos.Exit(1)\n\t}\n\n\tif cfg.ApiKey == \"\" {\n\t\tboldRed.Println(\"\\nFixer.io API key not found!\")\n\t\tcolor.Cyan(\"Get it here for free: https://fixer.io/signup/free\")\n\t\tcolor.Cyan(\"Then save it inside `.gocash/config.json` in your home directory\\n\")\n\t\tos.Exit(1)\n\t}\n\n\tmoney, err := getCurrencyRates(cfg)\n\n\tif err != nil {\n\t\tboldRed.Println(err.Error())\n\t\tos.Exit(1)\n\t}\n\t//start loader\n\tw.Start()\n\ttime.Sleep(2 * time.Second)\n\n\tconvertCurrency(currencies, amount, from, toItems, money)\n\n\tc := color.New(color.FgHiBlack).Add(color.Bold).Add(color.Underline)\n\tc.Println(fmt.Sprintf(\"Conversion of %s %.f \\n\", from, amount))\n}", "title": "" }, { "docid": "dd0d2ea334747fa6f7f77f6a29a6b6ad", "score": "0.46165997", "text": "func GetCgoCharArray() (interface{}, int, int) {\n\treturn C.ca, len(C.ca), cap(C.ca)\n}", "title": "" }, { "docid": "1bd2079e35869a56ad97e9fcd9fe5290", "score": "0.46096274", "text": "func _cgoexp_7ada50ef5194_goStart(a *struct {\n\t\tp0 _Ctype_uchar\n\t\tp1 _Ctype_int\n\t\tp2 _Ctype_int\n\t}) {\ngoStart(a.p0, a.p1, a.p2)\n}", "title": "" }, { "docid": "09a159c3fe96192431b80bc171f1454f", "score": "0.46074262", "text": "func GoString(char *C.char) string {\n\treturn C.GoString(char)\n}", "title": "" }, { "docid": "6fcc1ec4a8f011bf8d27ed32d35f9008", "score": "0.4604073", "text": "func (s TransformationTool) GoString() string {\n\treturn s.String()\n}", "title": "" }, { "docid": "45a423ff2893093472890266b3348f6d", "score": "0.46033674", "text": "func main() {\n\tstr := \"Test for convertion\"\n\tfmt.Println(S2B(str))\n\tfmt.Println(B2S(S2B(str)))\n}", "title": "" }, { "docid": "f69b769e1ec828d12a13eb16045ca639", "score": "0.45940936", "text": "func (s TransformEncryption) GoString() string {\n\treturn s.String()\n}", "title": "" }, { "docid": "48856d450b6001dc02f157b173f3c52b", "score": "0.4586901", "text": "func cgoMain(callerFile string,\n\tserviceName string,\n\tserviceDescription string,\n\tlambdaAWSInfos []*sparta.LambdaAWSInfo,\n\tapi *sparta.API,\n\tsite *sparta.S3Site,\n\tworkflowHooks *sparta.WorkflowHooks) error {\n\n\tlogger, loggerErr := sparta.NewLogger(\"info\")\n\tif nil != loggerErr {\n\t\tpanic(\"Failed to initialize logger\")\n\t}\n\tcgoLambdaHTTPAdapter = cgoLambdaHTTPAdapterStruct{\n\t\tserviceName: serviceName,\n\t\tlambdaHTTPHandlerInstance: sparta.NewLambdaHTTPHandler(lambdaAWSInfos, logger),\n\t\tlogger: logger,\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "74eca10c8cb1f6795ac7e4205a6f4357", "score": "0.4586067", "text": "func (s GetBaiduChannelInput) GoString() string {\n\treturn s.String()\n}", "title": "" }, { "docid": "cbdd02f424772fdbde786aec83c93014", "score": "0.4582867", "text": "func argInfo2Go(argInfo *C.SoapySDRArgInfo) SDRArgInfo {\n\n\tvar argType SDRArgInfoType\n\tswitch argInfo._type {\n\tcase 0:\n\t\targType = ArgInfoBool\n\tcase 1:\n\t\targType = ArgInfoInt\n\tcase 2:\n\t\targType = ArgInfoFloat\n\tcase 3:\n\t\targType = ArgInfoString\n\t}\n\n\treturn SDRArgInfo{\n\t\tKey: C.GoString(argInfo.key),\n\t\tValue: C.GoString(argInfo.value),\n\t\tName: C.GoString(argInfo.name),\n\t\tDescription: C.GoString(argInfo.description),\n\t\tUnit: C.GoString(argInfo.units),\n\t\tType: argType,\n\t\tRange: SDRRange{\n\t\t\tMinimum: float64(argInfo._range.minimum),\n\t\t\tMaximum: float64(argInfo._range.maximum),\n\t\t\tStep: float64(argInfo._range.step),\n\t\t},\n\t\tNumOptions: int(argInfo.numOptions),\n\t\tOptions: stringArray2Go(argInfo.options, argInfo.numOptions),\n\t\tOptionNames: stringArray2Go(argInfo.optionNames, argInfo.numOptions),\n\t}\n}", "title": "" }, { "docid": "23a3d13fdfd4744c952a1c8bc2547216", "score": "0.45826915", "text": "func (p *Protoc) RunGo(pkg *config.Package, files ...string) error {\n\tlog.Println(\"protoc running go\")\n\targs, err := p.BuildGo(pkg, files...)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn p.Exec(args...)\n}", "title": "" }, { "docid": "038b4a075fba26e3caf6adc1aa920191", "score": "0.4575225", "text": "func Convert(from string, to string, src []byte) []byte {\n\tif to == \"utf-8\" {\n\t\tout, e := ToUTF8(from, src)\n\t\tif e == nil {\n\t\t\treturn out\n\t\t}\n\t\tlog.Printf(\"converting from %s to UTF-8 failed: %v\", from, e)\n\t\treturn src\n\t}\n\n\tif from == \"utf-8\" {\n\t\tout, e := FromUTF8(to, src)\n\t\tif e == nil {\n\t\t\treturn out\n\t\t}\n\t\tlog.Printf(\"converting from UTF-8 to %s failed: %v\", to, e)\n\t\treturn src\n\t}\n\tlog.Println(\"only converting between CJK encodings and UTF-8 is supported\")\n\treturn src\n}", "title": "" }, { "docid": "f397350a6281c950deabc4202f994e74", "score": "0.4575126", "text": "func MakeCodec() *codec.Codec {\n\tvar cdc = codec.New()\n\n\tModuleBasics.RegisterCodec(cdc)\n\tsdk.RegisterCodec(cdc)\n\tcodec.RegisterCrypto(cdc)\n\t// * Register evm account type in codec here\n\teminttypes.RegisterCodec(cdc)\n\n\treturn cdc\n}", "title": "" } ]
bf9f008e9582f0a85eae6318b1c718ae
sort.Interface we sort by descending file size
[ { "docid": "128c951501de262e4f4ab2af4b174638", "score": "0.0", "text": "func (s SnapshotFiles) Len() int { return len(s) }", "title": "" } ]
[ { "docid": "560586ca0a714c64df9e578d400c22ff", "score": "0.69225675", "text": "func (j *Job) SortSize() []string {\n\tvar sizeJobs []SizeJob\n\tvar result []string\n\n\tvar fileLen = len(j.Files)\n\tsizeJobs = make([]SizeJob, 0, fileLen)\n\tresult = make([]string, 0, fileLen)\n\n\tfor _, f := range j.Files {\n\t\tfile, _ := os.Stat(f)\n\t\tsizeJobs = append(sizeJobs, SizeJob{f, file.Size()})\n\t}\n\n\t// sort by size: 0, 1, 2, 3 ...\n\tif !j.Reverse {\n\t\tsort.Slice(sizeJobs, func(i, j int) bool {\n\t\t\treturn sizeJobs[i].Size < sizeJobs[j].Size\n\t\t})\n\t}\n\t// reverse sort by size: 100, 99, 98 ...\n\tif j.Reverse {\n\t\tsort.Slice(sizeJobs, func(i, j int) bool {\n\t\t\treturn sizeJobs[i].Size > sizeJobs[j].Size\n\t\t})\n\t}\n\n\tfor _, v := range sizeJobs {\n\t\tresult = append(result, v.Name)\n\t}\n\n\treturn result\n}", "title": "" }, { "docid": "8a37f30beae1a640c44a6129b46dbd95", "score": "0.67508733", "text": "func (s noOpStrategy) Sort(files Files) {}", "title": "" }, { "docid": "297a2013ec640c9a0221dd2137505367", "score": "0.66132575", "text": "func (a Files) BySize() Files {\n\tf := filesBySize{a}\n\tsort.Sort(f)\n\treturn f.Files\n}", "title": "" }, { "docid": "b69614c4c018f6c0318d7367a033fd33", "score": "0.6255208", "text": "func (a filesBySize) Less(i, j int) bool {\n\treturn a.Files[i].Size() < a.Files[j].Size()\n}", "title": "" }, { "docid": "bcd73eab459fc091efa6e87cc0373ff4", "score": "0.60391855", "text": "func (s EncryptedFileArray) Sort(less func(a, b EncryptedFile) bool) EncryptedFileArray {\n\tsort.Slice(s, func(i, j int) bool {\n\t\treturn less(s[i], s[j])\n\t})\n\treturn s\n}", "title": "" }, { "docid": "b264812414f7581e13df4bb0a57a8562", "score": "0.6037846", "text": "func (l PackageList) SortBySize() PackageList {\n\tpkgList := (*C.alpm_list_t)(unsafe.Pointer(l.List))\n\n\tpkgCache := C.alpm_list_msort(pkgList,\n\t\tC.alpm_list_count(pkgList),\n\t\tC.alpm_list_fn_cmp(C.pkg_cmp))\n\n\treturn makePackageList(pkgCache, l.handle)\n}", "title": "" }, { "docid": "ff561b8b85f58a2d301d5b96371fb38a", "score": "0.5961241", "text": "func (q *LFU) getWorstFilesUp2Size(totSize float64) []*files.Stats {\n\tif totSize <= 0. {\n\t\tpanic(\"ERROR: tot size is negative or equal to 0\")\n\t}\n\n\tvar sended float64\n\n\t// Filtering trick\n\t// https://github.com/golang/go/wiki/SliceTricks#filtering-without-allocating\n\tq.buffer = q.buffer[:0]\n\n\tfor idxOVal := 0; idxOVal < len(q.orderedValues); idxOVal++ {\n\t\tcurQueue := q.queue[q.orderedValues[idxOVal]]\n\t\tfor idx := 0; idx < len(curQueue); idx++ {\n\t\t\tfilename := curQueue[idx]\n\t\t\tfileStats, inQueue := q.files[filename]\n\n\t\t\tif inQueue {\n\t\t\t\tq.buffer = append(q.buffer, fileStats)\n\t\t\t\tsended += fileStats.Size\n\t\t\t\tif sended >= totSize {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlog.Fatal(fmt.Errorf(\"lfu getQueue: file %d not in queue\", filename))\n\t\t\t}\n\t\t}\n\t\tif sended >= totSize {\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// fmt.Println(totSize, sended, len(q.buffer))\n\n\treturn q.buffer\n}", "title": "" }, { "docid": "8418311c60d253e3555fd1f4a613716b", "score": "0.58677423", "text": "func ExternalSort(fname string, chunk int) (fnameSorted string, err error) {\n\ttempDir, err := ioutil.TempDir(\"\", fname)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer os.RemoveAll(tempDir)\n\n\tfnameSorted = fname + \"_sorted\"\n\tf, err := os.Open(fname)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer f.Close()\n\tpathTo := func(fname string) string {\n\t\treturn tempDir + \"/\" + fname\n\t}\n\n\treadChunk := func(rd *bufio.Reader, buf []int64) (int, error) {\n\t\treadNumbers := 0\n\t\tfor i := 0; i < len(buf); i++ {\n\t\t\tdata, err := rd.ReadBytes('\\n')\n\t\t\tif err != nil {\n\t\t\t\treturn readNumbers, err\n\t\t\t}\n\t\t\treadNumbers++\n\t\t\tbuf[i], err = strconv.ParseInt(string(data[:len(data)-1]), 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn readNumbers, err\n\t\t\t}\n\t\t}\n\t\treturn readNumbers, nil\n\t}\n\tsort := func(chunk []int64) {\n\t\tsort.Slice(chunk, func(i, j int) bool {\n\t\t\treturn chunk[i] < chunk[j]\n\t\t})\n\t}\n\twriteToTempFile := func(chunkNum int, chunk []int64, howManyNumToWrite int) error {\n\t\tname := pathTo(strconv.Itoa(chunkNum))\n\t\tf, err := os.Create(name)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfor i := 0; i < howManyNumToWrite; i++ {\n\t\t\tf.WriteString(strconv.FormatInt(chunk[i], 10))\n\t\t\tf.WriteString(\"\\n\")\n\t\t}\n\t\treturn f.Close()\n\t}\n\tchunkBuf := make([]int64, chunk)\n\t// read, sort and save chunks\n\trd := bufio.NewReader(f)\n\tcount := 0\n\treadNumbers := 0\n\tvar errReadChunk error\n\tfor errReadChunk == nil {\n\t\treadNumbers, errReadChunk = readChunk(rd, chunkBuf)\n\t\tif errReadChunk != nil {\n\t\t\tif errReadChunk != io.EOF {\n\t\t\t\treturn\n\t\t\t} else if readNumbers == 0 {\n\t\t\t\t// EOF but no data to write\n\t\t\t\tbreak\n\t\t\t}\n\t\t\t// write remaining data on EOF\n\t\t}\n\n\t\tsort(chunkBuf)\n\t\tcount++\n\t\terr = writeToTempFile(count, chunkBuf, readNumbers)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\tmergeFiles := func(suffix string, f1, f2 os.FileInfo) error {\n\t\tfd1, e1 := os.Open(pathTo(f1.Name()))\n\t\tif e1 != nil {\n\t\t\treturn e1\n\t\t}\n\t\tdefer fd1.Close()\n\t\tfd2, e2 := os.Open(pathTo(f2.Name()))\n\t\tif e2 != nil {\n\t\t\treturn e2\n\t\t}\n\t\tdefer fd2.Close()\n\t\tmfname := pathTo(\"merge_iter_\" + suffix)\n\t\tf, err := os.Create(mfname)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer f.Close()\n\t\tw := bufio.NewWriter(f)\n\t\tvar readers [2]*bufio.Reader\n\t\tvar nums [2]int64\n\t\tvar bufs [2][]byte\n\t\tfor i, r := range []io.Reader{fd1, fd2} {\n\t\t\treaders[i] = bufio.NewReader(r)\n\t\t\tbufs[i], e1 = readers[i].ReadBytes('\\n')\n\t\t\tif e1 != nil {\n\t\t\t\treturn e1\n\t\t\t}\n\t\t\tnums[i], e1 = strconv.ParseInt(string(bufs[i][:len(bufs[i])-1]), 10, 64)\n\t\t\tif e1 != nil {\n\t\t\t\treturn e1\n\t\t\t}\n\t\t}\n\n\t\twhich := 0\n\t\tfor {\n\t\t\tif nums[0] <= nums[1] {\n\t\t\t\tw.Write(bufs[0])\n\t\t\t\twhich = 0\n\t\t\t} else {\n\t\t\t\tw.Write(bufs[1])\n\t\t\t\twhich = 1\n\t\t\t}\n\t\t\tbufs[which], e1 = readers[which].ReadBytes('\\n')\n\t\t\tif e1 != nil {\n\t\t\t\tif e1 == io.EOF {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\treturn e1\n\t\t\t}\n\t\t\tnums[which], e1 = strconv.ParseInt(string(bufs[which][:len(bufs[which])-1]), 10, 64)\n\t\t\tif e1 != nil {\n\t\t\t\treturn e1\n\t\t\t}\n\t\t}\n\t\t// write what left in buf\n\t\t// which one returned error\n\t\tif which == 1 {\n\t\t\tw.Write(bufs[0])\n\t\t\twhich = 0\n\t\t} else {\n\t\t\tw.Write(bufs[1])\n\t\t\twhich = 1\n\t\t}\n\t\t// append remaining file\n\t\tfor {\n\t\t\tbufs[which], e1 = readers[which].ReadBytes('\\n')\n\t\t\tif e1 != nil {\n\t\t\t\tif e1 == io.EOF {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\treturn e1\n\t\t\t}\n\t\t\tw.Write(bufs[which])\n\t\t}\n\n\t\tw.Flush()\n\t\treturn nil\n\t}\n\t// merge in order chunks\n\tfiles, err := ioutil.ReadDir(tempDir)\n\tif err != nil {\n\t\treturn\n\t}\n\tcount = 0\n\tfor len(files) > 1 {\n\t\t// if there is odd numbers of files, merge on next iteration\n\t\tfor i := 0; i < len(files)-1; i += 2 {\n\t\t\tcount++\n\t\t\terr = mergeFiles(strconv.Itoa(count), files[i], files[i+1])\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\terr = os.Remove(pathTo(files[i].Name()))\n\t\t\terr = os.Remove(pathTo(files[i+1].Name()))\n\t\t}\n\t\tfiles, err = ioutil.ReadDir(tempDir)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\tw, err := os.Create(fnameSorted)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer w.Close()\n\tr, err := os.Open(pathTo(files[0].Name()))\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer r.Close()\n\tio.Copy(w, r)\n\treturn\n}", "title": "" }, { "docid": "d274360fa40665b193770bebbf145236", "score": "0.5865282", "text": "func (s byLastModified) Sort(files Files) {\n\ts.Files = files\n\tsort.Sort(s)\n}", "title": "" }, { "docid": "d7016f1c2e060e996201403f508c294e", "score": "0.58514225", "text": "func (s EncryptedFileClassArray) Sort(less func(a, b EncryptedFileClass) bool) EncryptedFileClassArray {\n\tsort.Slice(s, func(i, j int) bool {\n\t\treturn less(s[i], s[j])\n\t})\n\treturn s\n}", "title": "" }, { "docid": "be71f399b522fe1ab59be551d47ca089", "score": "0.5818491", "text": "func (s byKey) Sort(files Files) {\n\ts.Files = files\n\tsort.Sort(s)\n}", "title": "" }, { "docid": "aa811aad36ed2cfd5274c28e6552011c", "score": "0.5753121", "text": "func (b *Buffer) sort(start, end int, compar func(a, b *GlyphInfo) int) {\n\tfor i := start + 1; i < end; i++ {\n\t\tj := i\n\t\tfor j > start && compar(&b.Info[j-1], &b.Info[i]) > 0 {\n\t\t\tj--\n\t\t}\n\t\tif i == j {\n\t\t\tcontinue\n\t\t}\n\t\t// move item i to occupy place for item j, shift what's in between.\n\t\tb.mergeClusters(j, i+1)\n\n\t\tt := b.Info[i]\n\t\tcopy(b.Info[j+1:], b.Info[j:i])\n\t\tb.Info[j] = t\n\t}\n}", "title": "" }, { "docid": "b908e930e07ea8de246589d95c57d23a", "score": "0.5672637", "text": "func TestSortWithFiles(t *testing.T) {\n\ttmpDir, err := ioutil.TempDir(\"\", \"ls\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer os.RemoveAll(tmpDir)\n\n\t// Table-driven testing\n\tfor _, tt := range sortTests {\n\t\tsortWithFiles(t, tt, tmpDir, []string{\"in\"}, \"out\")\n\t}\n}", "title": "" }, { "docid": "0e6c053330561b69d6cded234dae5d87", "score": "0.5643849", "text": "func (by FilesBy) Sort(files []*File) {\n\tps := &fileSorter{\n\t\tfiles: files,\n\t\tby: by, // The Sort method's receiver is the function (closure) that defines the sort order.\n\t}\n\tsort.Sort(ps)\n}", "title": "" }, { "docid": "c8636f92364aab6ef0eba1279b9e9e17", "score": "0.55889547", "text": "func sortAndFilterFiles(filenames []string, token *queryVisibilityToken) ([]string, error) {\n\tvar parsedFilenames []*parsedVisFilename\n\tfor _, name := range filenames {\n\t\tpieces := strings.FieldsFunc(name, func(r rune) bool {\n\t\t\treturn r == '_' || r == '.'\n\t\t})\n\t\tif len(pieces) != 3 {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse visibility filename %s\", name)\n\t\t}\n\n\t\tcloseTime, err := strconv.ParseInt(pieces[0], 10, 64)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse visibility filename %s\", name)\n\t\t}\n\t\tparsedFilenames = append(parsedFilenames, &parsedVisFilename{\n\t\t\tname: name,\n\t\t\tcloseTime: timestamp.UnixOrZeroTime(closeTime),\n\t\t\thashedRunID: pieces[1],\n\t\t})\n\t}\n\n\tsort.Slice(parsedFilenames, func(i, j int) bool {\n\t\tif parsedFilenames[i].closeTime.Equal(parsedFilenames[j].closeTime) {\n\t\t\treturn parsedFilenames[i].hashedRunID > parsedFilenames[j].hashedRunID\n\t\t}\n\t\treturn parsedFilenames[i].closeTime.After(parsedFilenames[j].closeTime)\n\t})\n\n\tstartIdx := 0\n\tif token != nil {\n\t\tLastHashedRunID := hash(token.LastRunID)\n\t\tstartIdx = sort.Search(len(parsedFilenames), func(i int) bool {\n\t\t\tif parsedFilenames[i].closeTime.Equal(token.LastCloseTime) {\n\t\t\t\treturn parsedFilenames[i].hashedRunID < LastHashedRunID\n\t\t\t}\n\t\t\treturn parsedFilenames[i].closeTime.Before(token.LastCloseTime)\n\t\t})\n\t}\n\n\tif startIdx == len(parsedFilenames) {\n\t\treturn []string{}, nil\n\t}\n\n\tvar filteredFilenames []string\n\tfor _, parsedFilename := range parsedFilenames[startIdx:] {\n\t\tfilteredFilenames = append(filteredFilenames, parsedFilename.name)\n\t}\n\treturn filteredFilenames, nil\n}", "title": "" }, { "docid": "96b9c65044628c967bbbe953b2f6a92c", "score": "0.5586404", "text": "func (p Uint64Slice) Sort() { sort.Sort(p) }", "title": "" }, { "docid": "af93088ec71a8913d3bede7d7eee9f01", "score": "0.55656636", "text": "func Sort(source string, dest string) {\n\tsrc, err := os.Open(source)\n\tdefer src.Close()\n\tif err != nil {\n\t\tlog.Fatalf(\"Could not open source folder : %s\", err)\n\t}\n\tif filemode, _ := src.Stat(); !filemode.IsDir() {\n\t\tlog.Fatalf(\"%s is not a directory\", source)\n\t}\n\tfiles, err := src.Readdir(-1)\n\tif err != nil {\n\t\tlog.Fatalf(\"Readding %s failed : %s\", source, err)\n\t}\n\tfor _, file := range files {\n\t\tfilename := file.Name()\n\t\tif isSampleFile(filename) {\n\t\t\tcontinue\n\t\t}\n\t\tif isExtOk(filename) {\n\t\t\toldPath := filepath.Join(source, filename)\n\t\t\tnewPath := createNewSeriePath(filename)\n\t\t\tnewPath = filepath.Join(dest, newPath)\n\t\t\tos.MkdirAll(filepath.Dir(newPath), 0777)\n\t\t\tos.Rename(oldPath, newPath)\n\t\t} else if file.IsDir() {\n\t\t\tSort(filepath.Join(source, filename), dest)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "968da1c8d245b6b8feb889f8bf8266be", "score": "0.5533318", "text": "func (f FileSetFilesSlice) sortByTimeAscending() {\n\tsort.Slice(f, func(i, j int) bool {\n\t\treturn f[i].ID.BlockStart.Before(f[j].ID.BlockStart)\n\t})\n}", "title": "" }, { "docid": "6a96079a3c2a07cdc9ee9bab86a74be7", "score": "0.5469839", "text": "func (fm FileMatches) SortByModTimeDesc() {\n\tsort.Slice(fm, func(i, j int) bool {\n\t\treturn fm[i].ModTime().After(fm[j].ModTime())\n\t})\n}", "title": "" }, { "docid": "e4d9a40266edb9ce01c1cd94dcd972e8", "score": "0.53863376", "text": "func (a SortFilesByAge) Swap(i, j int) {\n\ta[i], a[j] = a[j], a[i]\n}", "title": "" }, { "docid": "4029031f74cf0ac504ceb7cc06bf01c6", "score": "0.53719664", "text": "func cmp() {}", "title": "" }, { "docid": "26a5b6b4e9fa3215ae85ac8e87066b70", "score": "0.53716826", "text": "func _1404vdbeSorterExtendFile(tls crt.TLS, _db uintptr /* *Tsqlite3 = Ssqlite3 */, _pFd uintptr /* *Tsqlite3_file = Ssqlite3_file */, anByte int64) {\n\tesc := crt.MustMalloc(36)\n\tvar (\n\t\t_nByte = esc // *int64\n\t\t_p = esc + 16 // **void\n\t\t_chunksize = esc + 32 // *int32\n\t)\n\tdefer crt.Free(esc)\n\t*(*int64)(unsafe.Pointer(_nByte)) = anByte\n\tif (*(*int64)(unsafe.Pointer(_nByte))) > int64(*(*int32)(unsafe.Pointer(_db + 172))) || (*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(_pFd))))) < int32(3) {\n\t\tgoto _1\n\t}\n\n\t*(*uintptr)(unsafe.Pointer(_p)) = 0\n\t*(*int32)(unsafe.Pointer(_chunksize)) = int32(4096)\n\t_521sqlite3OsFileControlHint(tls, _pFd, int32(6), _chunksize)\n\t_521sqlite3OsFileControlHint(tls, _pFd, int32(5), _nByte)\n\t_1170sqlite3OsFetch(tls, _pFd, int64(0), int32(*(*int64)(unsafe.Pointer(_nByte))), _p)\n\t_874sqlite3OsUnfetch(tls, _pFd, int64(0), *(*uintptr)(unsafe.Pointer(_p)))\n_1:\n}", "title": "" }, { "docid": "c85ef8f91f1acfe4d99edecf408864eb", "score": "0.535353", "text": "func Sort(x []int64) {\n\tif len(x) < MinSize {\n\t\tsort.Slice(x, func(i, j int) bool { return x[i] < x[j] })\n\t} else {\n\t\tbuffer := make([]int64, len(x))\n\t\tSortBYOB(x, buffer)\n\t}\n}", "title": "" }, { "docid": "0fd005e4d18cb4d302ffac08d10d1719", "score": "0.53528893", "text": "func (ia *Uint64) Sort() {\n\tia.mu.Lock()\n\tUint64s(ia.values)\n\tia.mu.Unlock()\n}", "title": "" }, { "docid": "5625df7a6d06b247d2025f0592b55f51", "score": "0.53500676", "text": "func (x Uint64Slice) Sort() { sort.Sort(x) }", "title": "" }, { "docid": "4892109ac6593b87ef63e96473a8c15c", "score": "0.5349788", "text": "func sortWithFiles(t *testing.T, tt test, tmpDir string,\n\tinFiles []string, outFile string) {\n\t// Create input files\n\tinPaths := make([]string, len(inFiles))\n\tfor i, inFile := range inFiles {\n\t\tinPaths[i] = filepath.Join(tmpDir, inFile)\n\t\tif err := ioutil.WriteFile(inPaths[i], []byte(tt.in), 0600); err != nil {\n\t\t\tt.Error(err)\n\t\t\treturn\n\t\t}\n\t}\n\toutPath := filepath.Join(tmpDir, outFile)\n\n\targs := append(append(tt.flags, \"-o\", outPath), inPaths...)\n\tout, err := testutil.Command(t, args...).CombinedOutput()\n\tif err != nil {\n\t\tt.Errorf(\"sort %s: %v\\n%s\", strings.Join(args, \" \"), err, out)\n\t\treturn\n\t}\n\n\tout, err = ioutil.ReadFile(outPath)\n\tif err != nil {\n\t\tt.Errorf(\"Cannot open out file: %v\", err)\n\t\treturn\n\t}\n\tif string(out) != tt.out {\n\t\tt.Errorf(\"sort %s = %#v; want %#v\", strings.Join(args, \" \"),\n\t\t\tstring(out), tt.out)\n\t}\n}", "title": "" }, { "docid": "c87804d5bb0d0dd8e1d9913647212565", "score": "0.5346542", "text": "func (p StringSliceDesc) Sort() { sort.Sort(p) }", "title": "" }, { "docid": "aef77caf5369713b3286c31a00b86cf4", "score": "0.53420943", "text": "func Sort(data []byte, size int, swap func(int, int)) {\n\tif len(data) <= size {\n\t\treturn\n\t}\n\tif size <= 0 || !internal.MultipleOf(size, len(data)) {\n\t\tpanic(\"input length is not a multiple of element size\")\n\t}\n\n\t// No specialization available. Use the slower generic sorting routine.\n\tif purego || size%8 != 0 || size > 32 {\n\t\tsort.Sort(newGeneric(data, size, swap))\n\t\treturn\n\t}\n\n\t// Byte swap each qword prior to sorting. Doing a single pass here, and\n\t// again after the sort, is faster than byte swapping during each\n\t// comparison. The sorting routines have been written to assume that high\n\t// qwords come before low qwords, and so we're able to use the same\n\t// Swap64() routine rather than needing separate byte swapping routines\n\t// for 8, 16, 24, or 32 bytes.\n\tbswap.Swap64(data)\n\tdefer bswap.Swap64(data)\n\n\t// If no indirect swapping is required, try to use the hybrid partitioning scheme from\n\t// https://blog.reverberate.org/2020/05/29/hoares-rebuttal-bubble-sorts-comeback.html\n\tswitch {\n\tcase swap == nil && size == 8 && cpu.X86.Has(cpu.CMOV):\n\t\thybridQuicksort64(unsafeBytesTo64(data))\n\tcase swap == nil && size == 16 && cpu.X86.Has(cpu.AVX):\n\t\thybridQuicksort128(unsafeBytesTo128(data))\n\tcase swap == nil && size == 32 && cpu.X86.Has(cpu.AVX2):\n\t\thybridQuicksort256(unsafeBytesTo256(data))\n\tcase size == 8:\n\t\tquicksort64(unsafeBytesTo64(data), 0, smallCutoff, insertionsort64, hoarePartition64, swap)\n\tcase size == 16:\n\t\tquicksort128(unsafeBytesTo128(data), 0, smallCutoff, insertionsort128, hoarePartition128, swap)\n\tcase size == 24:\n\t\tquicksort192(unsafeBytesTo192(data), 0, smallCutoff, insertionsort192, hoarePartition192, swap)\n\tcase size == 32:\n\t\tquicksort256(unsafeBytesTo256(data), 0, smallCutoff, insertionsort256, hoarePartition256, swap)\n\t}\n}", "title": "" }, { "docid": "ecd36e4803d4c2287ac70aba0502cffb", "score": "0.5326098", "text": "func SortName(filename string) string {\n\text := filepath.Ext(filename)\n\tname := filename[:len(filename)-len(ext)]\n\t// split numeric suffix\n\ti := len(name) - 1\n\tfor ; i >= 0; i-- {\n\t\tif '0' > name[i] || name[i] > '9' {\n\t\t\tbreak\n\t\t}\n\t}\n\ti++\n\t// string numeric suffix to uint64 bytes\n\t// empty string is zero, so integers are plus one\n\tb64 := make([]byte, 64/8)\n\ts64 := name[i:]\n\tif len(s64) > 0 {\n\t\tu64, err := strconv.ParseUint(s64, 10, 64)\n\t\tif err == nil {\n\t\t\tbinary.BigEndian.PutUint64(b64, u64+1)\n\t\t}\n\t}\n\t// prefix + numeric-suffix + ext\n\treturn name[:i] + string(b64) + ext\n}", "title": "" }, { "docid": "4991ff963c314adfad85d1147345a278", "score": "0.53203046", "text": "func walkDescending(files []File, filter FileFilter, action FileAction) {\n\tfor _, file := range files {\n\t\tif filter == nil || filter(file) {\n\t\t\taction(file)\n\t\t\twalkDescending(file.Contents, filter, action)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "7db3a497654eec1075891d87f53990c1", "score": "0.5314846", "text": "func sortByLength() {\n\tfmt.Println(\"*** sort by word length:\")\n\tcp := copyFruits()\n\tsort.Sort(byLength(cp))\n\tfmt.Println(cp)\n}", "title": "" }, { "docid": "f42d10da100a5d72839432194b577e18", "score": "0.5308926", "text": "func combineSortedFiles(fileNames []string) {\n\tfmt.Printf(\"Combining files: %s ....\\n\", strings.Join(fileNames, \", \"))\n\n\toutputFile := \"input-sorted.csv\"\n\t// reader of all the open files\n\tvar readers []*csv.Reader\n\n\t// using minheap for merging sorted files\n\tmh := &util.MinHeap{}\n\theap.Init(mh)\n\n\tvar header []string\n\n\tfor index, fileName := range fileNames {\n\t\tf, err := os.Open(fileName)\n\t\tcheck(err)\n\t\tdefer f.Close()\n\t\treaders = append(readers, csv.NewReader(f))\n\t\th, _ := readers[index].Read()\n\t\tif header == nil {\n\t\t\theader = h\n\t\t}\n\t\tline, _ := readers[index].Read()\n\t\thashKey := createHashNumber(strings.Join(line[:3], \":\"))\n\t\theap.Push(mh, util.HeapValue{HashNumber: hashKey, Index: index, Value: line})\n\t}\n\n\tcollector := [][]string{}\n\n\tfor mh.Len() > 0 {\n\t\ttopLine := heap.Pop(mh).(util.HeapValue)\n\t\tcollector = append(collector, topLine.Value)\n\n\t\tfor {\n\t\t\tnextLine, err := readers[topLine.Index].Read()\n\t\t\tif err != nil {\n\t\t\t\tif err == io.EOF {\n\t\t\t\t\tbreak\n\t\t\t\t} else {\n\t\t\t\t\tlog.Fatal(err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\thashKey := createHashNumber(strings.Join(nextLine[:3], \":\"))\n\t\t\tif topLine.HashNumber == hashKey {\n\t\t\t\tcollector = append(collector, nextLine)\n\n\t\t\t\tif len(collector) >= maxElemsCollectorFlush {\n\t\t\t\t\tappendCsv(&collector, &header, outputFile)\n\t\t\t\t\tcollector = nil\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\theap.Push(mh, util.HeapValue{HashNumber: hashKey, Index: topLine.Index, Value: nextLine})\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(collector) > 0 {\n\t\tappendCsv(&collector, &header, outputFile)\n\t}\n\n\t// remove bucket segments\n\tchunkNames, err := filepath.Glob(fmt.Sprintf(\"*:chunk*.csv\"))\n\tcheck(err)\n\n\tfor _, chunkName := range chunkNames {\n\t\tfmt.Printf(\"Removing bucket segment: %s....\\n\", chunkName)\n\t\terr = os.Remove(chunkName)\n\t\tcheck(err)\n\t}\n}", "title": "" }, { "docid": "a424c8d4166879d61b44314c4ca32e55", "score": "0.5299241", "text": "func (q *Stats) SortIt() string {\n\t//init again\n\tq.lock.Lock()\n\tdefer q.lock.Unlock()\n\n\tvar strs, fmtd []string\n\n\t//fmt here\n\tq1 := q.qInts\n\tq2 := q.qFloats\n\n\t//dump stats::ints\n\tfor k, _ := range q1 {\n\t\tstrs = append(strs, k)\n\t}\n\tsort.Strings(strs)\n\tfor _, sv := range strs {\n\t\tfmtd = append(fmtd, fmt.Sprintf(\"%-20s => %d\", sv, q1[sv]))\n\t}\n\n\t//dump stats::float\n\tstrs = []string{}\n\tfor k, _ := range q2 {\n\t\tstrs = append(strs, k)\n\t}\n\tsort.Strings(strs)\n\tfor _, sv := range strs {\n\t\tfmtd = append(fmtd, fmt.Sprintf(\"%-20s => %.08f\", sv, q2[sv]))\n\t}\n\n\t//give the formatted 1\n\treturn strings.Join(fmtd, \"\\n\")\n}", "title": "" }, { "docid": "ee1b408e550764c07bb92d4dca0051c6", "score": "0.5295138", "text": "func _1418vdbeSorterMapFile(tls crt.TLS, _pTask uintptr /* *TSortSubtask = SSortSubtask */, _pFile uintptr /* *TSorterFile = SSorterFile */, _pp uintptr /* **Tu8 = uint8 */) (r int32) {\n\tvar (\n\t\t_rc int32\n\t\t_pFd uintptr // *Tsqlite3_file = Ssqlite3_file\n\t)\n\t_rc = int32(0)\n\tif (*(*int64)(unsafe.Pointer(_pFile + 8))) > int64(*(*int32)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(_pTask + 16))) + 32))) + 172))) {\n\t\tgoto _1\n\t}\n\n\t_pFd = *(*uintptr)(unsafe.Pointer(_pFile))\n\tif (*(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(_pFd))))) < int32(3) {\n\t\tgoto _2\n\t}\n\n\t_rc = _1170sqlite3OsFetch(tls, _pFd, int64(0), int32(*(*int64)(unsafe.Pointer(_pFile + 8))), _pp)\n_2:\n_1:\n\treturn _rc\n}", "title": "" }, { "docid": "77af319ce1db78e9662109e5533a6b65", "score": "0.52860796", "text": "func MergeSort(unsortedFile, sortedFile *os.File, read ReadRecord, write WriteRecord, compare CompareRecords, context interface{}, blockSize int) error {\n\tvar err error\n\tsourceTape := make([]tape, 2)\n\trecord := make([]interface{}, 2)\n\n\t// create temporary files sourceTape[0] and sourceTape[1]\n\tsourceTape[0].fp, err = ioutil.TempFile(\"\", \"goms\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer os.Remove(sourceTape[0].fp.Name())\n\tsourceTape[1].fp, err = ioutil.TempFile(\"\", \"goms\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer os.Remove(sourceTape[1].fp.Name())\n\n\t// read blocks, sort them in memory, and write the alternately to tapes 0 and 1\n\tblockCount := 0\n\tdestination := 0\n\tlist := newRecordsList(blockSize, compare, context)\n\tfor {\n\t\trecord[0], err = read(unsortedFile, context)\n\t\tif err != nil && err != io.EOF {\n\t\t\t// error reading, return\n\t\t\treturn err\n\t\t}\n\t\tif err == nil {\n\t\t\t// not EOF, add record to in memory list\n\t\t\tlist.add(record[0])\n\t\t\tblockCount++\n\t\t}\n\t\tif blockCount == blockSize || err == io.EOF && blockCount != 0 {\n\t\t\t// sort the in memory list\n\t\t\tsort.Sort(list)\n\t\t\t// now write them out\n\t\t\tfor _, rec := range list.records {\n\t\t\t\terr := write(sourceTape[destination].fp, rec, context)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tsourceTape[destination].count++\n\t\t\t}\n\t\t\tlist = newRecordsList(blockSize, compare, context)\n\t\t\tdestination ^= 1 // toggle tape\n\t\t\tblockCount = 0\n\t\t}\n\t\tif err == io.EOF {\n\t\t\tbreak // all done\n\t\t}\n\t}\n\tif sortedFile == unsortedFile {\n\t\tunsortedFile.Seek(0, os.SEEK_SET)\n\t}\n\tsourceTape[0].fp.Seek(0, os.SEEK_SET)\n\tsourceTape[1].fp.Seek(0, os.SEEK_SET)\n\n\t// FIXME (what?) delete the unsorted file here, if required (see instructions)\n\n\tif sourceTape[1].count == 0 {\n\t\t// handle case where memory sort is all that is required\n\t\terr = sourceTape[1].fp.Close()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tsourceTape[1] = sourceTape[0]\n\t\tsourceTape[0].fp = sortedFile\n\t\tfor sourceTape[1].count != 0 {\n\t\t\trecord[0], err = read(sourceTape[1].fp, context)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\terr := write(sourceTape[0].fp, record[0], context)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tsourceTape[1].count--\n\t\t}\n\t} else {\n\t\t// merge tapes, two by two, until every record is in source_tape[0]\n\t\tfor sourceTape[1].count != 0 {\n\t\t\tdestination := 0\n\t\t\tdestinationTape := make([]tape, 2)\n\t\t\tif sourceTape[0].count <= blockSize {\n\t\t\t\tdestinationTape[0].fp = sortedFile\n\t\t\t} else {\n\t\t\t\tdestinationTape[0].fp, err = ioutil.TempFile(\"\", \"goms\")\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tdefer os.Remove(destinationTape[0].fp.Name())\n\t\t\t}\n\t\t\tdestinationTape[1].fp, err = ioutil.TempFile(\"\", \"goms\")\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tdefer os.Remove(destinationTape[1].fp.Name())\n\t\t\trecord[0], err = read(sourceTape[0].fp, context)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\trecord[1], err = read(sourceTape[1].fp, context)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tfor sourceTape[0].count != 0 {\n\t\t\t\tcount := make([]int, 2)\n\t\t\t\tcount[0] = sourceTape[0].count\n\t\t\t\tif count[0] > blockSize {\n\t\t\t\t\tcount[0] = blockSize\n\t\t\t\t}\n\t\t\t\tcount[1] = sourceTape[1].count\n\t\t\t\tif count[1] > blockSize {\n\t\t\t\t\tcount[1] = blockSize\n\t\t\t\t}\n\t\t\t\tfor count[0]+count[1] != 0 {\n\t\t\t\t\tsel := 0\n\t\t\t\t\tif count[0] == 0 {\n\t\t\t\t\t\tsel = 1\n\t\t\t\t\t} else if count[1] == 0 {\n\t\t\t\t\t\tsel = 0\n\t\t\t\t\t} else if compare(record[0], record[1], context) < 0 {\n\t\t\t\t\t\tsel = 0\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsel = 1\n\t\t\t\t\t}\n\t\t\t\t\terr = write(destinationTape[destination].fp, record[sel], context)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tif sourceTape[sel].count > 1 {\n\t\t\t\t\t\trecord[sel], err = read(sourceTape[sel].fp, context)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tsourceTape[sel].count--\n\t\t\t\t\tcount[sel]--\n\t\t\t\t\tdestinationTape[destination].count++\n\t\t\t\t}\n\t\t\t\tdestination ^= 1\n\t\t\t}\n\t\t\tsourceTape[0].fp.Close()\n\t\t\tsourceTape[1].fp.Close()\n\t\t\tdestinationTape[0].fp.Seek(0, os.SEEK_SET)\n\t\t\tdestinationTape[1].fp.Seek(0, os.SEEK_SET)\n\t\t\tsourceTape[0] = destinationTape[0]\n\t\t\tsourceTape[1] = destinationTape[1]\n\t\t\tblockSize <<= 1\n\t\t}\n\t}\n\tsourceTape[1].fp.Close()\n\treturn nil\n}", "title": "" }, { "docid": "9e550ff84e704476a3bace544b64e22d", "score": "0.5268381", "text": "func SortBiggest(items PairList) PairList {\n\tsort.Sort(sort.Reverse(items))\n\treturn items\n}", "title": "" }, { "docid": "143525ca8bfc03fe3203cc38bc2280d1", "score": "0.52513295", "text": "func ExternalSort(fileName string) {\n\tvar wg sync.WaitGroup\n\n\tf, err := os.Open(fileName)\n\tcheck(err)\n\tdefer f.Close()\n\n\tfilePrefix := strings.Split(fileName, \".csv\")[0]\n\t// splitting the csv into multiple chunks\n\tsplitCsv(f, fmt.Sprintf(\"%s:chunk\", filePrefix))\n\n\tchunkFiles, err := filepath.Glob(fmt.Sprintf(\"%s:chunk*.csv\", filePrefix))\n\tcheck(err)\n\n\t// processing those chunked files\n\tfor _, fn := range chunkFiles {\n\t\twg.Add(1)\n\t\t// semaphore size defines how many concurrent operations happen\n\t\tsem <- 1\n\t\t// spawning goroutine for sorting separate chunks\n\t\tgo func(fn string) {\n\t\t\tdefer wg.Done()\n\t\t\tsortFile(fn)\n\t\t\t<-sem\n\t\t}(fn)\n\t}\n\twg.Wait()\n\n\tcombineSortedFiles(chunkFiles)\n}", "title": "" }, { "docid": "15c6f8c52dd18d9a9e6435f12f99a266", "score": "0.5244822", "text": "func SortBytes[T ~[]byte](s []T) {\n\tslices.SortFunc(s, func(i, j T) bool {\n\t\treturn bytes.Compare(i, j) == -1\n\t})\n}", "title": "" }, { "docid": "7f72b4602171a274b4e8b3d11582a924", "score": "0.523217", "text": "func sortFiles(filePaths []string) (err error) {\n\tlines := make([]string, 0)\n\tfor _, filePath := range filePaths {\n\t\tl, err := bufioutil.LoadLines(filePath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tlines = append(lines, l...)\n\t}\n\tif len(filePaths) == 0 {\n\t\tlines, err = bufioutil.ReadLines(os.Stdin)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tsort.Strings(lines)\n\tfor _, line := range lines {\n\t\tfmt.Println(line)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "cc828c0dbb522456e20d85919d397a8b", "score": "0.5221355", "text": "func (suite *ItemListTestSuite) TestSort() {\n\tinput := bytes.NewBufferString(\"abc123 abc234 123xyz\")\n\til := itemList{}\n\til.Write(input.Bytes())\n\til.Flush()\n\til.Sort()\n\toutput := make([]byte, 21, 21)\n\til.Read(output)\n\tsuite.Equal(\"123xyz\\nabc123\\nabc234\\n\", string(output))\n}", "title": "" }, { "docid": "2b1ad566cfa5b4512559aab47cc5431f", "score": "0.52200973", "text": "func mergeResults(files []string, maxHeapHiz int) {\n\n\tvar filechannelMap = make(map[string]chan int)\n\tfor _, v := range files {\n\t\tfilechannelMap[v] = make(chan int)\n\t\tgo func(f string, C chan int) {\n\t\t\tfile, err := os.Open(f)\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t\tdefer file.Close()\n\n\t\t\tscanner := bufio.NewScanner(file)\n\n\t\t\tfor scanner.Scan() {\n\t\t\t\t//fmt.Println(scanner.Text())\n\t\t\t\tiNum, _ := strconv.Atoi(scanner.Text())\n\t\t\t\tC <- iNum\n\t\t\t}\n\t\t\tclose(C)\n\n\t\t}(v, filechannelMap[v])\n\t}\n\n\tfinal := \"results.txt\"\n\twf, err := os.Create(final)\n\tdefer wf.Close()\n\tif err != nil {\n\t\tfmt.Printf(\"error creating file: %v\", err)\n\t\treturn\n\t}\n\theap := fibheap.NewFloatFibHeap()\n\n\tfor _, v := range files {\n\t\theap.Enqueue(float64(<-filechannelMap[v]))\n\t}\n\n\tfor heap.Size() > 0 {\n\t\tmin, _ := heap.DequeueMin()\n\t\twf.WriteString(fmt.Sprintf(\"%v\\n\", min.Priority))\n\t\tfName := files[int(min.Priority)%100]\n\t\tv, ok := <-filechannelMap[fName]\n\t\tif ok {\n\t\t\theap.Enqueue(float64(v))\n\t\t}\n\n\t}\n\n}", "title": "" }, { "docid": "2b360443e48daf87daebc39ba13a915c", "score": "0.52178043", "text": "func (b *Builder) Sort(cmp func(x, y uint64) int) {\n\tb.cmp = cmp\n\tif b.block != nil { // partial last block\n\t\tb.block[b.i] = 0 // terminator\n\t\tb.blocks = append(b.blocks, b.block)\n\t\tb.block = nil\n\t}\n\tfor i, block := range b.blocks {\n\t\tn := blockSize\n\t\tif i == len(b.blocks)-1 {\n\t\t\tn = b.i\n\t\t}\n\t\tsort.Sort(ablock{block: block, n: n, cmp: cmp})\n\t\tb.merges(i + 1) // merge as we sort for better cache use\n\t}\n\tb.finishMerges()\n}", "title": "" }, { "docid": "14e58c9e10474a8c83428646f5f6c668", "score": "0.52096385", "text": "func _1401vdbeSorterCompare(tls crt.TLS, _pTask uintptr /* *TSortSubtask = SSortSubtask */, _pbKey2Cached uintptr /* *int32 */, _pKey1 uintptr /* *void */, _nKey1 int32, _pKey2 uintptr /* *void */, _nKey2 int32) (r int32) {\n\tvar _r2 uintptr // *TUnpackedRecord = SUnpackedRecord\n\n\t_r2 = *(*uintptr)(unsafe.Pointer(_pTask + 24))\n\tif (*(*int32)(unsafe.Pointer(_pbKey2Cached))) != 0 {\n\t\tgoto _1\n\t}\n\n\t_691sqlite3VdbeRecordUnpack(tls, *(*uintptr)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(_pTask + 16))) + 40)), _nKey2, _pKey2, _r2)\n\t*(*int32)(unsafe.Pointer(_pbKey2Cached)) = int32(1)\n_1:\n\treturn _986sqlite3VdbeRecordCompare(tls, _nKey1, _pKey1, _r2)\n}", "title": "" }, { "docid": "07616e5f646a7cbf0b35ecd4d0b29e1e", "score": "0.5208047", "text": "func do_job() int {\n\tvar filePath string\n\tvar cmd string\n\tvar numLines int64\n\tvar lineLen int\n\tvar memory bool\n\tvar maxLines int\n\n\tflag.StringVar(&filePath, \"filePath\", \"\", \"file to sort\")\n\tflag.StringVar(&cmd, \"cmd\", \"\", \"command to execute\")\n\tflag.Int64Var(&numLines, \"numLines\", -1, \"number of file lines\")\n\tflag.IntVar(&lineLen, \"lineLen\", -1, \"file line length\")\n\tflag.BoolVar(&memory, \"memory\", false, \"sort file in memory\")\n\tflag.IntVar(&maxLines, \"maxLines\", -1, \"max file lines to use in sort\")\n\n\tflag.Parse()\n\n\tlog.SetOutput(os.Stdout)\n\n\tswitch cmd {\n\tcase \"sort\":\n\t\tvar err error\n\t\tif memory {\n\t\t\terr = filesort.SortFileInMemory(filePath)\n\t\t} else {\n\t\t\terr = filesort.SortFile(filePath, maxLines)\n\t\t}\n\n\t\tif err != nil {\n\t\t\tlog.Printf(\"sort file %s error %v\", filePath, err)\n\t\t\treturn -1\n\t\t}\n\tcase \"generate\":\n\t\terr := filesort.GenerateFile(filePath, numLines, lineLen)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"generate file %s error %v\", filePath, err)\n\t\t\treturn -1\n\t\t}\n\tcase \"remove\":\n\t\terr := filesort.RemoveFile(filePath)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"remove file %s error %v\", filePath, err)\n\t\t\treturn -1\n\t\t}\n\tcase \"check\":\n\t\tsorted, err := filesort.IsFileSorted(filePath)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"file %s check sorted error %v\", filePath, err)\n\t\t\treturn -1\n\t\t}\n\t\tif !sorted {\n\t\t\tlog.Printf(\"file %s is not sorted\", filePath)\n\t\t\treturn -1\n\t\t}\n\tdefault:\n\t\tlog.Printf(\"unknown command %s\", cmd)\n\t\treturn -1\n\t}\n\treturn 0\n}", "title": "" }, { "docid": "7ccb4c2d75438f52eb7b0ed11ea80e10", "score": "0.5207865", "text": "func (s *fileSorter) Swap(i, j int) {\n\ts.files[i], s.files[j] = s.files[j], s.files[i]\n}", "title": "" }, { "docid": "aff33b3772e7ecf366a46e658fa1f72b", "score": "0.51972616", "text": "func DirSort(srt string) func(fsi.FileSystem) {\n\treturn func(fs fsi.FileSystem) {\n\t\tfst := fs.(*osFileSys)\n\n\t\tswitch srt {\n\t\tcase \"byDateAsc\":\n\t\t\tfst.readdirsorter = func(fis []os.FileInfo) { sort.Sort(byDateAsc(fis)) }\n\t\tcase \"byDateDesc\":\n\t\t\tfst.readdirsorter = func(fis []os.FileInfo) { sort.Sort(byDateDesc(fis)) }\n\t\tcase \"byName\":\n\t\t\tfst.readdirsorter = func(fis []os.FileInfo) {} // unchanged\n\t\t}\n\t}\n}", "title": "" }, { "docid": "57874749765a392a5e63a59584cade4a", "score": "0.51606065", "text": "func compareOutput(a, b []byte) int {\n fileLen := len(a)\n bLen := len(b)\n if fileLen != bLen {\n if fileLen > bLen {\n return fileLen - bLen\n }\n return bLen - fileLen\n }\n for i := 0; i < fileLen; i++ {\n if a[i] != b[i] {\n return i\n }\n }\n return -1\n}", "title": "" }, { "docid": "fe147f4b5db46d0a4a7213f8cb635c38", "score": "0.5157013", "text": "func (b BrokerList) SortByStorage() {\n\tsort.Sort(brokersByStorage(b))\n}", "title": "" }, { "docid": "1c7d1c5fb8218af686edea49bf9a2999", "score": "0.51525676", "text": "func (t *ExpirationTracker) Sort() {\n\tt.mutex.Lock()\n\tdefer t.mutex.Unlock()\n\tif t.Len() < 2 {\n\t\treturn\n\t}\n\tsort.Sort(t)\n\t//log.Debug(\"Sorted\", len(t.arr))\n}", "title": "" }, { "docid": "420ca33311aa007fc8df5eb34e35779e", "score": "0.5148616", "text": "func _988vdbeSorterSort(tls crt.TLS, _pTask uintptr /* *TSortSubtask = SSortSubtask */, _pList uintptr /* *TSorterList = SSorterList */) (r int32) {\n\tvar (\n\t\t_i int32\n\t\t_aSlot uintptr // **TSorterRecord = SSorterRecord\n\t\t_p uintptr // *TSorterRecord = SSorterRecord\n\t\t_rc int32\n\t\t_pNext uintptr // *TSorterRecord = SSorterRecord\n\t)\n\t_rc = _1203vdbeSortAllocUnpacked(tls, _pTask)\n\tif _rc == int32(0) {\n\t\tgoto _1\n\t}\n\n\treturn _rc\n\n_1:\n\t_p = *(*uintptr)(unsafe.Pointer(_pList))\n\t*(*uintptr)(unsafe.Pointer(_pTask + 64)) = _1204vdbeSorterGetCompare(tls, *(*uintptr)(unsafe.Pointer(_pTask + 16)))\n\t_aSlot = _135sqlite3MallocZero(tls, uint64(512))\n\tif _aSlot != 0 {\n\t\tgoto _2\n\t}\n\n\treturn int32(7)\n\n_2:\n_3:\n\tif _p == 0 {\n\t\tgoto _4\n\t}\n\n\tif (*(*uintptr)(unsafe.Pointer(_pList + 8))) == 0 {\n\t\tgoto _5\n\t}\n\n\tif _p != (*(*uintptr)(unsafe.Pointer(_pList + 8))) {\n\t\tgoto _7\n\t}\n\n\t_pNext = null\n\tgoto _8\n\n_7:\n\t_pNext = (*(*uintptr)(unsafe.Pointer(_pList + 8))) + uintptr(*(*int32)(unsafe.Pointer(_p + 8)))\n_8:\n\tgoto _6\n\n_5:\n\t_pNext = *(*uintptr)(unsafe.Pointer(_p + 8))\n_6:\n\t*(*uintptr)(unsafe.Pointer(_p + 8)) = null\n\t_i = int32(0)\n_9:\n\tif (*(*uintptr)(unsafe.Pointer(_aSlot + 8*uintptr(_i)))) == 0 {\n\t\tgoto _11\n\t}\n\n\t_p = _1205vdbeSorterMerge(tls, _pTask, _p, *(*uintptr)(unsafe.Pointer(_aSlot + 8*uintptr(_i))))\n\t*(*uintptr)(unsafe.Pointer(_aSlot + 8*uintptr(_i))) = null\n\t_i++\n\tgoto _9\n\n_11:\n\t*(*uintptr)(unsafe.Pointer(_aSlot + 8*uintptr(_i))) = _p\n\t_p = _pNext\n\tgoto _3\n\n_4:\n\t_p = null\n\t_i = int32(0)\n_12:\n\tif _i >= int32(64) {\n\t\tgoto _14\n\t}\n\n\tif (*(*uintptr)(unsafe.Pointer(_aSlot + 8*uintptr(_i)))) != 0 {\n\t\tgoto _15\n\t}\n\n\tgoto _13\n\n_15:\n\t_p = func() uintptr {\n\t\tif _p != 0 {\n\t\t\treturn _1205vdbeSorterMerge(tls, _pTask, _p, *(*uintptr)(unsafe.Pointer(_aSlot + 8*uintptr(_i))))\n\t\t}\n\t\treturn *(*uintptr)(unsafe.Pointer(_aSlot + 8*uintptr(_i)))\n\t}()\n\n_13:\n\t_i++\n\tgoto _12\n\n_14:\n\t*(*uintptr)(unsafe.Pointer(_pList)) = _p\n\tXsqlite3_free(tls, _aSlot)\n\n\treturn int32(*(*uint8)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(_pTask + 24))) + 19)))\n}", "title": "" }, { "docid": "7926e4d247584f683ad1188bd705a01d", "score": "0.51472855", "text": "func (p UIntSlice) Sort() { sort.Sort(p) }", "title": "" }, { "docid": "1a6b3c8f1624479d775ebadcb3661520", "score": "0.5145231", "text": "func (s BySortkey) Less(i, j int) bool { return s.SubcollectionRuns[i].sortkey > s.SubcollectionRuns[j].sortkey }", "title": "" }, { "docid": "39237dc7a853b2768313337ef0c6bc53", "score": "0.5140382", "text": "func Sort(a []interface{}, lt LessThan) (err error) {\n\tlo := 0\n\thi := len(a)\n\tnRemaining := hi\n\n\tif nRemaining < 2 {\n\t\treturn // Arrays of size 0 and 1 are always sorted\n\t}\n\n\t// If array is small, do a \"mini-TimSort\" with no merges\n\tif nRemaining < minMerge {\n\t\tinitRunLen, err := countRunAndMakeAscending(a, lo, hi, lt)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn binarySort(a, lo, hi, lo+initRunLen, lt)\n\t}\n\n\t/**\n\t * March over the array once, left to right, finding natural runs,\n\t * extending short natural runs to minRun elements, and merging runs\n\t * to maintain stack invariant.\n\t */\n\n\tts := newTimSort(a, lt)\n\tminRun, err := minRunLength(nRemaining)\n\tif err != nil {\n\t\treturn\n\t}\n\tfor {\n\t\t// Identify next run\n\t\trunLen, err := countRunAndMakeAscending(a, lo, hi, lt)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// If run is short, extend to min(minRun, nRemaining)\n\t\tif runLen < minRun {\n\t\t\tforce := minRun\n\t\t\tif nRemaining <= minRun {\n\t\t\t\tforce = nRemaining\n\t\t\t}\n\t\t\tif err = binarySort(a, lo, lo+force, lo+runLen, lt); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\trunLen = force\n\t\t}\n\n\t\t// Push run onto pending-run stack, and maybe merge\n\t\tts.pushRun(lo, runLen)\n\t\tif err = ts.mergeCollapse(); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Advance to find next run\n\t\tlo += runLen\n\t\tnRemaining -= runLen\n\t\tif nRemaining == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// Merge all remaining runs to complete sort\n\tif lo != hi {\n\t\treturn errors.New(\"lo must equal hi\")\n\t}\n\n\tif err = ts.mergeForceCollapse(); err != nil {\n\t\treturn\n\t}\n\tif ts.stackSize != 1 {\n\t\treturn errors.New(\"ts.stackSize != 1\")\n\t}\n\treturn\n}", "title": "" }, { "docid": "3a942386448354c53462ecc97b195023", "score": "0.51296103", "text": "func GetSortedFileList() (FileInfoSlice, error) {\n\tinfoList := FileInfoSlice{}\n\tfiles, err := ioutil.ReadDir(dataPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, f := range files {\n\t\tif strings.HasSuffix(f.Name(), \"_values\") {\n\t\t\tcontinue\n\t\t}\n\n\t\tinfo, err := timestampsFromFileName(f.Name())\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tinfo.name = pathTo(info.name)\n\t\tinfo.size = f.Size()\n\t\tinfoList = append(infoList, info)\n\t}\n\tsort.Sort(infoList)\n\treturn infoList, nil\n}", "title": "" }, { "docid": "ff85f2bbb8bc2154ec3a1148bd1fd64a", "score": "0.5124007", "text": "func (s byKey) Less(i, j int) bool {\n\tvar (\n\t\tiKey = s.Files[i].Key()\n\t\tjKey = s.Files[j].Key()\n\t)\n\n\tif s.isAscending {\n\t\treturn iKey < jKey\n\t}\n\treturn iKey >= jKey\n}", "title": "" }, { "docid": "50c3680ee018549435cdb3289f0b7514", "score": "0.5121093", "text": "func TestBitmaps_SortByHeight(t *testing.T) {\n\tbms := &Bitmaps{}\n\tbms.AddBitmap(New(10, 20))\n\tbms.AddBitmap(New(5, 18))\n\tbms.AddBitmap(New(2, 30))\n\tbms.AddBitmap(New(40, 20))\n\n\tbms.SortByHeight()\n\tassert.Equal(t, 18, bms.Values[0].Height)\n\tassert.Equal(t, 20, bms.Values[1].Height)\n\tassert.Equal(t, 20, bms.Values[2].Height)\n\tassert.Equal(t, 30, bms.Values[3].Height)\n}", "title": "" }, { "docid": "10c533260f8c37f9927d22253328b7b0", "score": "0.5121039", "text": "func (listings Listings) lessBySize(i, j int) bool {\n\ta := listings[i]\n\tb := listings[j]\n\taSize, _ := strconv.Atoi(a.size)\n\tbSize, _ := strconv.Atoi(b.size)\n\treturn aSize >= bSize\n}", "title": "" }, { "docid": "f26af26cd4d518714b01af128da8ce26", "score": "0.5114487", "text": "func Sort(paths []snet.Path) {\n\tsort.Slice(paths, func(a, b int) bool {\n\t\tintfA, intfB := paths[a].Metadata().Interfaces, paths[b].Metadata().Interfaces\n\t\t// Sort according to path length.\n\t\tif len(intfA) != len(intfB) {\n\t\t\treturn len(intfA) < len(intfB)\n\t\t}\n\t\tfor i := range intfA {\n\t\t\tif iaA, iaB := intfA[i].IA, intfA[i].IA; iaA != iaB {\n\t\t\t\treturn iaA < iaB\n\t\t\t}\n\t\t\tif idA, idB := intfA[i].ID, intfB[i].ID; idA != idB {\n\t\t\t\treturn idA < idB\n\t\t\t}\n\t\t}\n\t\texpA, expB := paths[a].Metadata().Expiry, paths[b].Metadata().Expiry\n\t\tif !expA.Equal(expB) {\n\t\t\treturn expA.Before(expB)\n\t\t}\n\t\treturn true\n\t})\n}", "title": "" }, { "docid": "157c682921f8d0b45666293517488062", "score": "0.5084064", "text": "func _1399vdbeSorterCompareInt(tls crt.TLS, _pTask uintptr /* *TSortSubtask = SSortSubtask */, _pbKey2Cached uintptr /* *int32 */, _pKey1 uintptr /* *void */, _nKey1 int32, _pKey2 uintptr /* *void */, _nKey2 int32) (r int32) {\n\tvar (\n\t\t_p1 uintptr // *Tu8 = uint8\n\t\t_p2 uintptr // *Tu8 = uint8\n\t\t_s1 int32\n\t\t_s2 int32\n\t\t_v1 uintptr // *Tu8 = uint8\n\t\t_v2 uintptr // *Tu8 = uint8\n\t\t_res int32\n\t\t_n uint8\n\t\t_i int32\n\t)\n\t_p1 = _pKey1\n\t_p2 = _pKey2\n\t_s1 = int32(*(*uint8)(unsafe.Pointer(_p1 + 1)))\n\t_s2 = int32(*(*uint8)(unsafe.Pointer(_p2 + 1)))\n\t_v1 = _p1 + uintptr(*(*uint8)(unsafe.Pointer(_p1)))\n\t_v2 = _p2 + uintptr(*(*uint8)(unsafe.Pointer(_p2)))\n\n\tif _s1 != _s2 {\n\t\tgoto _1\n\t}\n\n\t_n = *(*uint8)(unsafe.Pointer(_1685aLen + uintptr(_s1)))\n\t_res = int32(0)\n\t_i = int32(0)\n_3:\n\tif _i >= int32(_n) {\n\t\tgoto _5\n\t}\n\n\tif set5(&_res, int32(*(*uint8)(unsafe.Pointer(_v1 + uintptr(_i))))-int32(*(*uint8)(unsafe.Pointer(_v2 + uintptr(_i))))) == int32(0) {\n\t\tgoto _6\n\t}\n\n\tif ((int32(*(*uint8)(unsafe.Pointer(_v1))) ^ int32(*(*uint8)(unsafe.Pointer(_v2)))) & int32(0x80)) == int32(0) {\n\t\tgoto _7\n\t}\n\n\t_res = func() int32 {\n\t\tif (int32(*(*uint8)(unsafe.Pointer(_v1))) & int32(0x80)) != 0 {\n\t\t\treturn int32(-1)\n\t\t}\n\t\treturn int32(1)\n\t}()\n_7:\n\tgoto _5\n\n_6:\n\t_i++\n\tgoto _3\n\n_5:\n\tgoto _2\n\n_1:\n\tif _s1 <= int32(7) || _s2 <= int32(7) {\n\t\tgoto _8\n\t}\n\n\t_res = _s1 - _s2\n\tgoto _9\n\n_8:\n\tif _s2 <= int32(7) {\n\t\tgoto _10\n\t}\n\n\t_res = int32(1)\n\tgoto _11\n\n_10:\n\tif _s1 <= int32(7) {\n\t\tgoto _12\n\t}\n\n\t_res = int32(-1)\n\tgoto _13\n\n_12:\n\t_res = _s1 - _s2\n_13:\n_11:\n\tif _res <= int32(0) {\n\t\tgoto _14\n\t}\n\n\tif (int32(*(*uint8)(unsafe.Pointer(_v1))) & int32(0x80)) == 0 {\n\t\tgoto _16\n\t}\n\n\t_res = int32(-1)\n_16:\n\tgoto _15\n\n_14:\n\tif (int32(*(*uint8)(unsafe.Pointer(_v2))) & int32(0x80)) == 0 {\n\t\tgoto _17\n\t}\n\n\t_res = int32(1)\n_17:\n_15:\n_9:\n_2:\n\tif _res != int32(0) {\n\t\tgoto _18\n\t}\n\n\tif int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(_pTask + 16))) + 40))) + 6))) <= int32(1) {\n\t\tgoto _20\n\t}\n\n\t_res = _1686vdbeSorterCompareTail(tls, _pTask, _pbKey2Cached, _pKey1, _nKey1, _pKey2, _nKey2)\n_20:\n\tgoto _19\n\n_18:\n\tif (*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(_pTask + 16))) + 40))) + 24))))) == 0 {\n\t\tgoto _21\n\t}\n\n\t_res = _res * int32(-1)\n_21:\n_19:\n\treturn _res\n}", "title": "" }, { "docid": "9ad1bb915da9cefbefbed0363e964583", "score": "0.5082052", "text": "func SortBySize(LocMap map[string]*[]Location) (map[string]*[]Location, error) {\n\tfor k := range LocMap {\n\t\tstateArray := *LocMap[k]\n\t\tsort.Slice(stateArray, func(i, j int) bool {\n\t\t\treturn stateArray[i].HouseUnits > stateArray[j].HouseUnits\n\t\t})\n\t\tLocMap[k] = &stateArray\n\t}\n\treturn LocMap, nil\n}", "title": "" }, { "docid": "6e839bc41051ee7351abeba97a05057d", "score": "0.5077776", "text": "func main() {\n\tfruits := []string{\"peach\", \"banana\", \"kiwi\"}\n\tsort.Sort(ByLength(fruits))\n\tfmt.Println(fruits)\n}", "title": "" }, { "docid": "20aa4fdd168eb38d3e89286ffa2cc6ef", "score": "0.5077069", "text": "func SortStringsDesc(a []string) { sort.Sort(StringSliceDesc(a)) }", "title": "" }, { "docid": "1c70b5b7ff8e838121e6a240b7e783dc", "score": "0.5074368", "text": "func (sorter PicSorter) Sort(dirPath string) error {\n\tvar unsupportedPaths []string\n\tlog.Println(\"[INFO]\", \"Scanning incoming files from\", dirPath)\n\terr := filepath.Walk(dirPath, func(path string, info os.FileInfo, err error) error {\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !info.IsDir() {\n\t\t\tif isUnsupportedFileByExtension(path) {\n\t\t\t\tlog.Println(\"[INFO] Treating file as 'unsupported' based on its extension\", path)\n\t\t\t\tunsupportedPaths = append(unsupportedPaths, path)\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\tgoogleMetadata := sorter.getGooglePhotoMetadata(path)\n\t\t\tif googleMetadata != nil && googleMetadata.IsTrashed {\n\t\t\t\tlog.Println(\"[INFO] Treating file as 'trashed' based on the metadata\", path)\n\t\t\t\terr = sorter.handleTrashed(path, dirPath)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Println(\"[WARN]\", path, \"Failed to check/handle trashed:\", err)\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\tnewPath, err := sorter.deriveNewPathFromFileMetadata(path)\n\t\t\tif err != nil {\n\t\t\t\tif googleMetadata != nil {\n\t\t\t\t\tnewPath, err = sorter.deriveNewPathFromGoogleMetadata(path, googleMetadata)\n\t\t\t\t}\n\t\t\t\tif err != nil {\n\t\t\t\t\t// The file is unsupported. Nevertheless, check for duplicates.\n\t\t\t\t\t// This is realy only useful with eager deduping, but it could save us from having to care about why the file is unsupported.\n\t\t\t\t\tisDuplicate, err := sorter.checkAndHandleIndexedDupes(path, dirPath)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Println(\"[WARN]\", path, \"Failed to check/handle indexed duplicates:\", err)\n\t\t\t\t\t} else if isDuplicate {\n\t\t\t\t\t\tlog.Println(\"[INFO] Treating file as 'duplicate' (unsupported)\", path)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlog.Println(\"[INFO] Treating file as 'unsupported' due to lack of metadata (file or Google)\", path)\n\t\t\t\t\t\tunsupportedPaths = append(unsupportedPaths, path)\n\t\t\t\t\t}\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tisDuplicate, err := sorter.checkAndHandleDupes(path, dirPath, newPath)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(\"[WARN]\", path, \"Failed to check/handle duplicates:\", err)\n\t\t\t\treturn nil\n\t\t\t} else if isDuplicate {\n\t\t\t\tlog.Println(\"[INFO] Treating file as 'duplicate'\", path)\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\tlog.Println(\"[INFO] Relocating file\", path)\n\t\t\tdestPath, err := sorter.fileMover.MoveFileWithRename(path, newPath)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(\"[WARN]\", path, \"Failed to sort file:\", err)\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\terr = sorter.deduper.AddFileToIndex(destPath)\n\t\t\tif err != nil {\n\t\t\t\tif !sorter.isDryRun {\n\t\t\t\t\tlog.Println(\"[WARN]\", path, \"Failed to index file:\", err)\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n\n\tlog.Println(\"[INFO]\", \"Cleaning up unsupported files.\")\n\tfor _, unsupportedPath := range unsupportedPaths {\n\t\t_, err := sorter.fileMover.MoveFileWithPreservedPath(unsupportedPath, dirPath, sorter.unsupportedDir)\n\t\tif err != nil {\n\t\t\tlog.Println(\"[WARN]\", unsupportedPath, \"Failed to move unsupported file:\", err)\n\t\t}\n\t}\n\tsorter.fileMover.DeleteEmptyDirectories(dirPath)\n\n\treturn err\n}", "title": "" }, { "docid": "27601e7020ebd2a3c8406fd8832342f2", "score": "0.50710356", "text": "func (s byLastModified) Less(i, j int) bool {\n\tvar (\n\t\tiLastModified = s.Files[i].LastModified()\n\t\tjLastModified = s.Files[j].LastModified()\n\t)\n\n\tif s.isAscending {\n\t\treturn iLastModified.Before(jLastModified)\n\t}\n\treturn iLastModified.After(jLastModified)\n}", "title": "" }, { "docid": "2dfc63212092ccc1a088b9598727167c", "score": "0.5062388", "text": "func sortBuffer(pWork *tCmpStruct, bufferBegin uint, bufferEnd uint) {\n\tvar phashToIndex int\n\tvar bufferPtr uint\n\tvar totalSum = uint16(0)\n\tvar bytePairHash uint32 // Hash value of the byte pair\n\tvar bytePairOffs uint16 // Offset of the byte pair, relative to \"workBuff\"\n\n\t// Zero the entire \"phashToIndex\" table\n\tfor m := range pWork.phashToIndex {\n\t\tpWork.phashToIndex[m] = 0\n\t}\n\t// Step 1: Count amount of each PAIR_HASH in the input buffer\n\t// The table will look like this:\n\t// offs 0x000: Number of occurrences of PAIR_HASH 0\n\t// offs 0x001: Number of occurrences of PAIR_HASH 1\n\t// ...\n\t// offs 0x8F7: Number of occurrences of PAIR_HASH 0x8F7 (the highest hash value)\n\tfor bufferPtr = bufferBegin; bufferPtr < bufferEnd; bufferPtr++ {\n\t\tpWork.phashToIndex[getBytePairHash(pWork.workBuff, bufferPtr)]++\n\t}\n\t// Step 2: Convert the table to the array of PAIR_HASH amounts.\n\t// Each element contains count of PAIR_HASHes that is less or equal\n\t// to element index\n\t// The table will look like this:\n\t// offs 0x000: Number of occurrences of PAIR_HASH 0 or lower\n\t// offs 0x001: Number of occurrences of PAIR_HASH 1 or lower\n\t// ...\n\t// offs 0x8F7: Number of occurrences of PAIR_HASH 0x8F7 or lower\n\tfor phashToIndex = 0; phashToIndex < len(pWork.phashToIndex); phashToIndex++ {\n\t\ttotalSum = totalSum + pWork.phashToIndex[phashToIndex]\n\t\tpWork.phashToIndex[phashToIndex] = totalSum\n\t}\n\n\t// Step 3: Convert the table to the array of indexes.\n\t// Now, each element contains index to the first occurrence of given PAIR_HASH\n\tfor bufferEnd--; bufferEnd >= bufferBegin; bufferEnd-- {\n\t\tbytePairHash = uint32(getBytePairHash(pWork.workBuff, bufferEnd))\n\t\tbytePairOffs = uint16(bufferEnd)\n\n\t\tpWork.phashToIndex[bytePairHash]--\n\t\tpWork.phashOffs[pWork.phashToIndex[bytePairHash]] = bytePairOffs\n\t}\n}", "title": "" }, { "docid": "c150d6ceddc87834bd93aa39e0d3f9d5", "score": "0.50450987", "text": "func ByLastMod(aList []Archive) (archiveSort) {\n return archiveSort{ \n as: aList, \n less: func(aI, aJ *Archive) (bool) { return aI.LastMod().Before(aJ.LastMod())},\n }\n}", "title": "" }, { "docid": "165e9c9cdf998eedb783827423595ec1", "score": "0.50402486", "text": "func Sort(list []*LongChange) {\n sort.Sort( ByUpdated(list) )\n return\n}", "title": "" }, { "docid": "0ac9a69e989c6da90e4445ae7d7c83ef", "score": "0.50346273", "text": "func (s Uint64Slice) Sort() {\n\tsort.Sort(s)\n}", "title": "" }, { "docid": "9ddcc9341dba33611c1e4d12735f5482", "score": "0.50292957", "text": "func (a Files) ByMtime() Files {\n\tf := filesByMtime{a}\n\tsort.Sort(f)\n\treturn f.Files\n}", "title": "" }, { "docid": "a6700852b294fa221a44e500ccfba4c3", "score": "0.5025043", "text": "func CompareFile(xf, yf string) int {\n\tx := SansExt(BaseName(xf))\n\ty := SansExt(BaseName(yf))\n\tif *sort_lex {\n\t\treturn strings.Compare(x, y)\n\t}\n\treturn StrCmpNaturally(x, y)\n}", "title": "" }, { "docid": "fb6c16cddd5ce56ae50275e5b097352d", "score": "0.5014302", "text": "func (p Int64Slice) Sort() { sort.Sort(p) }", "title": "" }, { "docid": "b2f3b49b5dba4aa8aeec129e19a5988f", "score": "0.50143003", "text": "func (streamSelf *StreamForInterfaceDef) Sort(fn Comparator[interface{}]) *StreamForInterfaceDef {\n\tresult := streamSelf.Clone()\n\tSort(fn, *result)\n\treturn result\n}", "title": "" }, { "docid": "90dfab63688e899902b0212a559a009e", "score": "0.5009781", "text": "func (b ByVersion) Sort() {\n\tsort.Sort(b)\n}", "title": "" }, { "docid": "28f86fbca8d6c433f88b36107fc4d146", "score": "0.5002338", "text": "func tableSort(state *lua.State) int {\n\tts := tableSorter{state: state, len: int(length(state, 1, opReadWrite))}\n\tsort.Sort(&ts)\n\n\treturn 0\n}", "title": "" }, { "docid": "0240a98176599182d87308c61735413d", "score": "0.4998278", "text": "func getFilesSlice(root *os.File) (SortableFiles, error) {\n\tif root == nil {\n\t\treturn nil, nil\n\t}\n\tfileInfo, err := root.Stat()\n\tif err != nil {\n\t\tif Debug {\n\t\t\tLogger.Printf(\"Cannot stat File %s\", root.Name())\n\t\t}\n\t\treturn nil, err\n\t}\n\tif !fileInfo.IsDir() {\n\t\treturn SortableFiles{SortableFile{File: root}}, nil\n\t} else {\n\t\tvar fl SortableFiles\n\t\terr := filepath.Walk(root.Name(), func(path string, info os.FileInfo, err error) error {\n\t\t\tif info.IsDir() {\n\t\t\t\tif strings.HasPrefix(info.Name(), \".\") {\n\t\t\t\t\treturn filepath.SkipDir\n\t\t\t\t}\n\t\t\t}\n\t\t\tif strings.HasSuffix(path, \".tf\") {\n\t\t\t\tf, err := os.Open(path)\n\t\t\t\tif err != nil {\n\t\t\t\t\tif Debug {\n\t\t\t\t\t\tLogger.Printf(\"Cannot open File %s\", path)\n\t\t\t\t\t}\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tfl = append(fl, SortableFile{File: f})\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t\tif err != nil {\n\t\t\tif Debug {\n\t\t\t\tLogger.Printf(\"Cannot walk the directory \"+\n\t\t\t\t\t\"%s tree. Error: %s\", root.Name(), err)\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t\tsort.Sort(fl)\n\t\treturn fl, nil\n\t}\n}", "title": "" }, { "docid": "e1d2dbf0e31804986ff73d4a8ccc6b84", "score": "0.49974743", "text": "func (b BrokerList) SortByCount() {\n\tsort.Sort(brokersByCount(b))\n}", "title": "" }, { "docid": "961ee0d5e9fbd1f09634f8dcb37ace39", "score": "0.49953654", "text": "func TestSort(t *testing.T) {\n\t//Init\n\telements := sort.GetElements(10)\n\n\t//Execution\n\tSort(elements)\n\n\t//Validation\n\tassert.Equal(t, elements[0], 0)\n\tassert.Equal(t, elements[len(elements) - 1], 9)\n}", "title": "" }, { "docid": "827c1e04369db389a0d361acf36b7293", "score": "0.49952975", "text": "func (w *Win) Sort(less func(x, y string) bool) error {\n\tq0, q1, err := w.ReadAddr()\n\tif err != nil {\n\t\treturn err\n\t}\n\tdata, err := w.ReadAll(\"xdata\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tsuffix := \"\"\n\tlines := strings.Split(string(data), \"\\n\")\n\tif lines[len(lines)-1] == \"\" {\n\t\tsuffix = \"\\n\"\n\t\tlines = lines[:len(lines)-1]\n\t}\n\tsort.SliceStable(lines, func(i, j int) bool { return less(lines[i], lines[j]) })\n\tw.Addr(\"#%d,#%d\", q0, q1)\n\tw.Write(\"data\", []byte(strings.Join(lines, \"\\n\")+suffix))\n\treturn nil\n}", "title": "" }, { "docid": "9249e851f68ace14649ba48d85daeff0", "score": "0.49943197", "text": "func (p BlockIDSlice) Sort() { sort.Sort(p) }", "title": "" }, { "docid": "081b52cff3c82daa5ba4fc2e182f3a27", "score": "0.49904615", "text": "func newTimSort(a []interface{}, lt LessThan) (h *timSortHandler) {\n\th = new(timSortHandler)\n\n\th.a = a\n\th.lt = lt\n\th.minGallop = minGallop\n\th.stackSize = 0\n\n\t// Allocate temp storage (which may be increased later if necessary)\n\tlen := len(a)\n\n\ttmpSize := initialTmpStorageLength\n\tif len < 2*tmpSize {\n\t\ttmpSize = len / 2\n\t}\n\n\th.tmp = make([]interface{}, tmpSize)\n\n\t/*\n\t * Allocate runs-to-be-merged stack (which cannot be expanded). The\n\t * stack length requirements are described in listsort.txt. The C\n\t * version always uses the same stack length (85), but this was\n\t * measured to be too expensive when sorting \"mid-sized\" arrays (e.g.,\n\t * 100 elements) in Java. Therefore, we use smaller (but sufficiently\n\t * large) stack lengths for smaller arrays. The \"magic numbers\" in the\n\t * computation below must be changed if c_MIN_MERGE is decreased. See\n\t * the c_MIN_MERGE declaration above for more information.\n\t */\n\t// mk: confirmed that for small sorts this optimization gives measurable (albeit small)\n\t// performance enhancement\n\tstackLen := 40\n\tif len < 120 {\n\t\tstackLen = 5\n\t} else if len < 1542 {\n\t\tstackLen = 10\n\t} else if len < 119151 {\n\t\tstackLen = 19\n\t}\n\n\th.runBase = make([]int, stackLen)\n\th.runLen = make([]int, stackLen)\n\n\treturn h\n}", "title": "" }, { "docid": "99a358caf8fa000fb96cc4e4d756b237", "score": "0.49869922", "text": "func copySortDurations(input []time.Duration) []time.Duration {\n\tinputCopy := copyDurations(input)\n\tsort.Sort(durations(inputCopy))\n\treturn inputCopy\n}", "title": "" }, { "docid": "0a4729891ca2373698823c4ff2d92cd8", "score": "0.4979363", "text": "func _1686vdbeSorterCompareTail(tls crt.TLS, _pTask uintptr /* *TSortSubtask = SSortSubtask */, _pbKey2Cached uintptr /* *int32 */, _pKey1 uintptr /* *void */, _nKey1 int32, _pKey2 uintptr /* *void */, _nKey2 int32) (r int32) {\n\tvar _r2 uintptr // *TUnpackedRecord = SUnpackedRecord\n\n\t_r2 = *(*uintptr)(unsafe.Pointer(_pTask + 24))\n\tif (*(*int32)(unsafe.Pointer(_pbKey2Cached))) != int32(0) {\n\t\tgoto _1\n\t}\n\n\t_691sqlite3VdbeRecordUnpack(tls, *(*uintptr)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(_pTask + 16))) + 40)), _nKey2, _pKey2, _r2)\n\t*(*int32)(unsafe.Pointer(_pbKey2Cached)) = int32(1)\n_1:\n\treturn _1202sqlite3VdbeRecordCompareWithSkip(tls, _nKey1, _pKey1, _r2, int32(1))\n}", "title": "" }, { "docid": "fa76a9ecbaa4d5cca24c0ae30f0796c4", "score": "0.497759", "text": "func Sort(entries []Entry) {\n\tsort.Slice(entries, func(i, j int) bool {\n\t\treturn entries[i].Name() < entries[j].Name()\n\t})\n}", "title": "" }, { "docid": "b4ae69bc26f8cf3041e0e1be14e3385d", "score": "0.49770704", "text": "func SortbyType(dest string) string {\n\text := filepath.Ext(dest)\n\tdir := filepath.Dir(dest)\n\tfilename := filepath.Base(dest)\n\tjpg_folder := \"/JPG/\"\n\traw_folder := \"/RAW/\"\n\n\tif contains(jpg_ext, ext) {\n\t\treturn constructPath(dir, filename, jpg_folder)\n\t}\n\tif contains(raw_ext, ext) {\n\t\treturn constructPath(dir, filename, raw_folder)\n\t}\n\tfmt.Println(\"Keep \" + filename + \" in \" + dir)\n\treturn dest\n}", "title": "" }, { "docid": "563415b8ec160f842366403826d95616", "score": "0.49739015", "text": "func sortingSparepartHarga(arr *sparepart, total int) {\r\n\tvar i, pass int\r\n\tvar temp DetailSparepart\r\n\t\tpass = 0\r\n\t\t\tfor pass < total {\r\n\t\t\t\ti = pass + 1\r\n\t\t\t\ttemp = arr[i]\r\n\t\t\t\t\tfor i >= 1 && temp.Harga > arr[i - 1].Harga {\r\n\t\t\t\t\t\tarr[i] = arr[i - 1]\r\n\t\t\t\t\t\ti--\r\n\t\t\t\t\t}\r\n\t\t\t\tarr[i] = temp\r\n\t\t\t\tpass++\r\n\t\t\t}\r\n}", "title": "" }, { "docid": "69890e1f4de9ebbcc879c4f4a1eec501", "score": "0.49736556", "text": "func (info FileInfo) GetSortOrder() int32 {\n\tret0 := C.g_file_info_get_sort_order(info.native())\n\treturn int32(ret0)\n}", "title": "" }, { "docid": "24f0be79411a84220b343fbe6c697f1f", "score": "0.49663937", "text": "func (e tsSlice) Sort() { sort.Sort(e) }", "title": "" }, { "docid": "c19fde3e35200b16072b661136e47630", "score": "0.49595743", "text": "func SortImage(args []interface{}) (interface{}, error) {\n\tdata := args[0].([]byte) // Pixel data in bytes\n\twidth := int(args[1].(float64)) // Width in pixels\n\theight := int(args[2].(float64)) // Height in pixels\n\tbpp := int(args[3].(float64)) // Bytes per pixel\n\toptions := args[4].(map[string]interface{}) // Soring options\n\n\tif len(data) != width*height*bpp {\n\t\treturn nil, errors.New(\"Mismatch between data length and width/height\")\n\t}\n\n\tselectBy, invert, lowerRange, upperRange, desc, direction, sortBy := getOptions(options)\n\n\t// True if sort direction is horizontal\n\thorizontal := direction == \"horizontal\"\n\n\t// Set function that will be used to get the value used to select pixels\n\tvar getValue func([]byte, int) float32\n\tswitch selectBy {\n\tcase \"brightness\":\n\t\tgetValue = calcLumin\n\tcase \"saturation\":\n\t\tgetValue = calcSaturation\n\tcase \"hue\":\n\t\tgetValue = calcHue\n\tcase \"raw\":\n\t\tgetValue = calcRaw\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"Unknown 'selectBy' value: %s\", selectBy)\n\t}\n\tinRange := func(data []byte, i int) bool {\n\t\tv := getValue(data, i)\n\t\tif invert {\n\t\t\treturn v <= lowerRange || v >= upperRange\n\t\t}\n\t\treturn v >= lowerRange && v <= upperRange\n\t}\n\n\tswitch sortBy {\n\tdefault:\n\t\tbreak\n\t}\n\n\t// Get all rows to be sorted as separet slices\n\tvar rows [][]byte\n\tvar rowSize int\n\tif horizontal {\n\t\t// Get all the rows\n\t\trowSize = width * bpp\n\t\trows = make([][]byte, height)\n\t\tfor r := range rows {\n\t\t\trows[r] = make([]byte, width*bpp)\n\t\t\tfor x := range rows[r] {\n\t\t\t\trows[r][x] = data[r*width*bpp+x]\n\t\t\t}\n\t\t}\n\t} else { // Vertical\n\t\t// Convert colums to rows\n\t\trowSize = height * bpp\n\t\trows = make([][]byte, width)\n\t\tfor c := range rows {\n\t\t\trows[c] = make([]byte, rowSize)\n\t\t\tfor y := 0; y < rowSize; y += bpp {\n\t\t\t\ti := c*bpp + y*width\n\t\t\t\tfor d := 0; d < bpp; d++ {\n\t\t\t\t\trows[c][y+d] = data[i+d]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfor i := range rows {\n\t\t_, _, _, _ = rowSize, i, desc, inRange\n\t\tsortRow(rows[i], rowSize, bpp, desc, inRange)\n\t}\n\n\t// Copy back the sorted pixels to the data slice\n\tif horizontal {\n\t\ti := 0\n\t\tfor y := range rows {\n\t\t\tfor x := range rows[y] {\n\t\t\t\tdata[i] = rows[y][x]\n\t\t\t\ti++\n\t\t\t}\n\t\t}\n\t} else { // Vertical\n\t\tfor x := 0; x < width; x++ {\n\t\t\tfor y := 0; y < height*bpp; y += bpp {\n\t\t\t\ti := x*bpp + y*width\n\t\t\t\tfor d := 0; d < bpp; d++ {\n\t\t\t\t\tdata[i+d] = rows[x][y+d]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn data, nil\n}", "title": "" }, { "docid": "72ef0febba275d764234bca2b68170e9", "score": "0.49588743", "text": "func (p Float64Slice) Sort() { sort.Sort(p) }", "title": "" }, { "docid": "b765457cf96c16d6a12d12ccb06edaf8", "score": "0.49518695", "text": "func (fm FileMatches) SortByModTimeAsc() {\n\tsort.Slice(fm, func(i, j int) bool {\n\t\treturn fm[i].ModTime().Before(fm[j].ModTime())\n\t})\n}", "title": "" }, { "docid": "c70b569e0b70838451d06297e1c29959", "score": "0.49479023", "text": "func RunSortBenchmark(amountOfThreads int, sizeOfSlice int) {\n\n\twaitGroup.Add(amountOfThreads)\n\n\tfor i := 0; i < amountOfThreads; i++ {\n\t\tgo sortBenchmark(sizeOfSlice)\n\t}\n\n\twaitGroup.Wait()\n\n}", "title": "" }, { "docid": "a7d1646ae19685f6fdc68cc678fed684", "score": "0.49469805", "text": "func sort(filter *Filter, ary []interface{}, by interface{}, asc bool) int {\n\titemType := filter.schemaItems[len(filter.schemaItems)-1].iType.(ArrayItem).dataType\n\tswitch itemType.typeName {\n\tcase ItemTypeInt8, ItemTypeInt16, ItemTypeInt32, ItemTypeInt64:\n\t\tsortArrayInt(ary, asc)\n\tcase ItemTypeUint8, ItemTypeUint16, ItemTypeUint32, ItemTypeUint64:\n\t\tsortArrayUint(ary, asc)\n\tcase ItemTypeFloat32, ItemTypeFloat64:\n\t\tsortArrayFloat(ary, asc)\n\tcase ItemTypeString:\n\t\tsortArrayString(ary, asc)\n\tcase ItemTypeTime:\n\t\tsortArrayTime(ary, &itemType, asc)\n\tcase ItemTypeObject:\n\t\t// Convert \"by\" to string array\n\t\tvar byArr []string\n\t\tif s, ok := by.(string); ok {\n\t\t\tif s == \"\" {\n\t\t\t\treturn helpers.ErrorArrayItemNotSortable\n\t\t\t}\n\t\t\tbyArr = strings.Split(s, \".\")\n\t\t} else {\n\t\t\treturn helpers.ErrorInvalidMethodParameters\n\t\t}\n\t\tif len(byArr) == 0 {\n\t\t\treturn helpers.ErrorInvalidMethodParameters\n\t\t}\n\t\tif err := sortArrayByObjectItem(ary, &itemType, byArr, asc); err != 0 {\n\t\t\treturn err\n\t\t}\n\tdefault:\n\t\treturn helpers.ErrorArrayItemNotSortable\n\t}\n\treturn 0\n}", "title": "" }, { "docid": "9b826e27f0bf646773228c63cf5b0cd7", "score": "0.49406376", "text": "func Sort(s []int) {\n heapify(s)\n for n := len(s)-1; n > 0; n-- {\n s[n], s[0] = s[0], s[n]\n sink(s[0:n], 0)\n }\n}", "title": "" }, { "docid": "e869e223212c989bb3d8847ff610694f", "score": "0.493817", "text": "func HeapSort(in myInterface) {\n\tif in.Len() <= 1 {\n\t\treturn\n\t}\n\n\tbh := binaryHeap{}\n\tbh.maxHeapity = bh.maxHeapityLoopBased //switch loop or rescurse based maxheapity here\n\n\tbh.buildMaxHeap(in) // first build max heap\n\n\tfor i := in.Len(); i >= 2; i-- { // 1 started index here\n\t\tin.Swap(0, i-1) // move biggest element to the end\n\t\tbh.heapSize--\n\n\t\t// then find the biggest and move it to root again\n\t\t//bh.maxHeapityRecursed(in, 1)\n\t\t//bh.maxHeapityLoopBased(in, 1)\n\t\tbh.maxHeapity(in, 1)\n\t}\n}", "title": "" }, { "docid": "9a0e6d72fde87b724aba7fbcab0a93cf", "score": "0.49369228", "text": "func (c *ImmutableFloat64) Sort(fn func(float64, float64) bool) *ImmutableFloat64 {\n\td := c.Copy()\n\tsort.Slice(d.items, d.lessFunc(fn))\n\treturn d\n}", "title": "" }, { "docid": "b64cd14112e19844f14dce9e137c776e", "score": "0.49357253", "text": "func sortByLength(a *BitSet, b *BitSet) (ap *BitSet, bp *BitSet) {\n\tif a.length <= b.length {\n\t\tap, bp = a, b\n\t} else {\n\t\tap, bp = b, a\n\t}\n\treturn\n}", "title": "" }, { "docid": "c8fbceab707a7eb71a744b680007a681", "score": "0.49314123", "text": "func DoSorting(srcFile, newFile string) error {\n\n\ttotal, err := s.CalculateLines(srcFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// read file\n\tfmt.Println(\"\\nReading...\")\n\tsource, err := s.ReadLine(srcFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// sorting\n\tfmt.Println(\"Sorting...\")\n\tsort.Strings(source)\n\n\t// write file\n\tfmt.Println(\"Saving...\")\n\terr = s.WriteLine(source, newFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Println(\"\\nResult:\", srcFile)\n\tfmt.Println(\"-------------------------------------------\")\n\tfmt.Printf(\"|%-20s|%20d|\\n\", \"Total\", total)\n\tfmt.Println(\"-------------------------------------------\")\n\n\treturn nil\n}", "title": "" }, { "docid": "0fa80172479ce89e20682648d9c789bb", "score": "0.4926198", "text": "func SortTraceBytes(t *tempopb.TraceBytes) {\n\tsort.Slice(t.Traces, func(i, j int) bool {\n\t\ttraceI := t.Traces[i]\n\t\ttraceJ := t.Traces[j]\n\n\t\treturn bytes.Compare(traceI, traceJ) == -1\n\t})\n}", "title": "" }, { "docid": "96bf6c0fe67a053541d54eeb27f4eed3", "score": "0.49252853", "text": "func ByteComparator(a, b interface{}) int {\n\taAss := a.(byte)\n\tbAss := b.(byte)\n\tswitch {\n\tcase aAss > bAss:\n\t\treturn 1\n\tcase aAss < bAss:\n\t\treturn -1\n\tdefault:\n\t\treturn 0\n\t}\n}", "title": "" }, { "docid": "ee536821ded35f822c68f7686064acfd", "score": "0.4919543", "text": "func (s virtualDiskSubresourceSorter) Less(i, j int) bool {\n\tmi := s[i].(map[string]interface{})\n\tmj := s[j].(map[string]interface{})\n\treturn mi[\"unit_number\"].(int) < mj[\"unit_number\"].(int)\n}", "title": "" }, { "docid": "334502ecdfa2a7cb8c4ddc4ebe8c0692", "score": "0.49154365", "text": "func (sra ShardReferenceArray) Sort() { sort.Sort(sra) }", "title": "" } ]
bb5399b0b0a910e5f0627a1caa738784
NewDefaultConverter creates a Converter that assumes that the value is scannable into a String, and placed into the dataframe as a nullable string.
[ { "docid": "7958511b067e5b5ad9b9d7823c2af7d5", "score": "0.75329393", "text": "func NewDefaultConverter(name string, nullable bool, t reflect.Type) Converter {\n\tslice := reflect.MakeSlice(reflect.SliceOf(t), 0, 0).Interface()\n\tif !data.ValidFieldType(slice) {\n\t\treturn Converter{\n\t\t\tName: fmt.Sprintf(\"[%s] String converter\", t),\n\t\t\tInputScanType: reflect.TypeOf(sql.NullString{}),\n\t\t\tInputTypeName: name,\n\t\t\tFrameConverter: FrameConverter{\n\t\t\t\tFieldType: data.FieldTypeNullableString,\n\t\t\t\tConverterFunc: func(in interface{}) (interface{}, error) {\n\t\t\t\t\tv := in.(*sql.NullString)\n\n\t\t\t\t\tif !v.Valid {\n\t\t\t\t\t\treturn (*string)(nil), nil\n\t\t\t\t\t}\n\n\t\t\t\t\tf := v.String\n\t\t\t\t\treturn &f, nil\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t}\n\n\tv := reflect.New(t)\n\tvar fieldType data.FieldType\n\tif v.Type() == reflect.PtrTo(t) {\n\t\tv = v.Elem()\n\t\tfieldType = data.FieldTypeFor(v.Interface())\n\t} else {\n\t\tfieldType = data.FieldTypeFor(v.Interface()).NullableType()\n\t}\n\n\tif nullable {\n\t\tif converter, ok := NullConverters[t]; ok {\n\t\t\treturn converter\n\t\t}\n\t}\n\n\treturn Converter{\n\t\tName: fmt.Sprintf(\"Default converter for %s\", name),\n\t\tInputScanType: t,\n\t\tInputTypeName: name,\n\t\tFrameConverter: FrameConverter{\n\t\t\tFieldType: fieldType,\n\t\t\tConverterFunc: DefaultConverterFunc(t),\n\t\t},\n\t}\n}", "title": "" } ]
[ { "docid": "50c81ef058e7e07f2ba8921de8992227", "score": "0.6750156", "text": "func (s StringConverter) ToConverter() Converter {\n\treturn Converter{\n\t\tName: s.Name,\n\t\tInputScanType: reflect.TypeOf(sql.NullString{}),\n\t\tInputTypeName: s.InputTypeName,\n\t\tFrameConverter: StringFrameConverter(s),\n\t}\n}", "title": "" }, { "docid": "cdda8ec0d6f1bee6a7190cadda189d00", "score": "0.6026662", "text": "func StringFrameConverter(s StringConverter) FrameConverter {\n\tf := data.FieldTypeNullableString\n\n\tif s.Replacer != nil {\n\t\tf = s.Replacer.OutputFieldType\n\t}\n\n\treturn FrameConverter{\n\t\tFieldType: f,\n\t\tConverterFunc: func(in interface{}) (interface{}, error) {\n\t\t\tns := in.(*sql.NullString)\n\t\t\tif !ns.Valid {\n\t\t\t\treturn nil, nil\n\t\t\t}\n\n\t\t\tv := &ns.String\n\t\t\tif s.ConversionFunc != nil {\n\t\t\t\tconverted, err := s.ConversionFunc(v)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tv = converted\n\t\t\t}\n\n\t\t\tif s.Replacer.ReplaceFunc != nil {\n\t\t\t\treturn s.Replacer.ReplaceFunc(v)\n\t\t\t}\n\n\t\t\treturn v, nil\n\t\t},\n\t}\n}", "title": "" }, { "docid": "5e4a19185a22d496434ab1d36cb6fac6", "score": "0.58715224", "text": "func DefaultConverterFunc(t reflect.Type) func(in interface{}) (interface{}, error) {\n\treturn func(in interface{}) (interface{}, error) {\n\t\tinType := reflect.TypeOf(in)\n\t\tif inType == reflect.PtrTo(t) {\n\t\t\tn := reflect.ValueOf(in)\n\n\t\t\treturn n.Elem().Interface(), nil\n\t\t}\n\n\t\treturn in, nil\n\t}\n}", "title": "" }, { "docid": "8073664c6c9985099f082e5321b54243", "score": "0.53682315", "text": "func (n SQNull) Convert(newtype tokens.TokenID) (retVal Value, err error) {\n\treturn originalNull, nil\n}", "title": "" }, { "docid": "14dd57f1ca5b5d817ce798addb403af4", "score": "0.5317039", "text": "func NewConverter(nameFn NameFunc) *Converter {\n\tc := &Converter{\n\t\tconversionFuncs: NewConversionFuncs(),\n\t\tgeneratedConversionFuncs: NewConversionFuncs(),\n\t\tignoredConversions: make(map[typePair]struct{}),\n\t\tignoredUntypedConversions: make(map[typePair]struct{}),\n\t\tnameFunc: nameFn,\n\n\t\tinputFieldMappingFuncs: make(map[reflect.Type]FieldMappingFunc),\n\t\tinputDefaultFlags: make(map[reflect.Type]FieldMatchingFlags),\n\t}\n\tc.RegisterUntypedConversionFunc(\n\t\t(*[]byte)(nil), (*[]byte)(nil),\n\t\tfunc(a, b interface{}, s Scope) error {\n\t\t\treturn Convert_Slice_byte_To_Slice_byte(a.(*[]byte), b.(*[]byte), s)\n\t\t},\n\t)\n\treturn c\n}", "title": "" }, { "docid": "78ba393cbfc58313f5f1787b74d3238e", "score": "0.52582425", "text": "func NewConvert() (convert Converter) { return }", "title": "" }, { "docid": "0a6cc72a6c0c51662caaa440eae03a85", "score": "0.52511495", "text": "func toDefault(s string, args ...string) string {\n\tif len(s) == 0 && len(args) == 1 {\n\t\ts = args[0]\n\t}\n\treturn s\n}", "title": "" }, { "docid": "0a6cc72a6c0c51662caaa440eae03a85", "score": "0.52511495", "text": "func toDefault(s string, args ...string) string {\n\tif len(s) == 0 && len(args) == 1 {\n\t\ts = args[0]\n\t}\n\treturn s\n}", "title": "" }, { "docid": "f017377d9888e9d9217d214c832895c5", "score": "0.524501", "text": "func (conv defaultConverter) ConvertReflectValue(src, dst reflect.Value, options ...Options) error {\n\t// prepare conversion\n\tif !src.IsValid() {\n\t\treturn errors.New(\"source is invalid\")\n\t}\n\tif !dst.IsValid() {\n\t\treturn errors.New(\"destination is invalid\")\n\t}\n\n\t// unpackInterface src\n\tsrc = unpackInterface(src)\n\n\tif dst.Kind() != reflect.Ptr {\n\t\treturn errors.New(\"destination must be a pointer\")\n\t}\n\n\tif !src.IsValid() {\n\t\t// src was an interface to nothing\n\t\treturn nil\n\t}\n\n\t// interface(string) -> string\n\tout := unpackInterface(dst.Elem())\n\n\tif !out.IsValid() {\n\t\t// dst was an interface to nothing\n\t\t// if source was nil destination should also be nil\n\t\tif src.Type() == NilType {\n\t\t\tvar n interface{}\n\t\t\tdst.Elem().Set(reflect.ValueOf(&n).Elem())\n\t\t\treturn nil\n\t\t}\n\t\tdst.Elem().Set(src)\n\n\t\treturn nil\n\t}\n\n\t// create a new temporary variable (this variable is the real type that we want to convert to)\n\ttmp := reflect.New(out.Type())\n\ttmp.Elem().Set(out)\n\tout = tmp\n\n\tif len(options) > 0 {\n\t\tconv.options.SkipUnknownFields = options[0].SkipUnknownFields\n\t\tconv.options.Recipes = joinRecipes(conv.options.Recipes, options[0].Recipes)\n\t}\n\n\treturn conv.convertNow(src, dst, out, options...)\n}", "title": "" }, { "docid": "d37d317640c9a28295090b87910577f1", "score": "0.51828766", "text": "func NewConverter() ConverterEmpty {\n\treturn &Converter{\n\t\tlineLabels: make(map[string]int),\n\t\tdefinitions: make(map[string]*nast.Definition),\n\t\tmacros: make(map[string]*nast.MacroDefinition),\n\t\tmacroLevel: make([]string, 0),\n\t\tsexpOptimizer: optimizers.NewStaticExpressionOptimizer(),\n\t\tboolexpOptimizer: &optimizers.ExpressionInversionOptimizer{},\n\t\tvarnameOptimizer: optimizers.NewVariableNameOptimizer(),\n\t\tloopLevel: make([]loopinfo, 0),\n\t\ttargetChipType: validators.ChipTypeAuto,\n\t}\n}", "title": "" }, { "docid": "77c4b1923765a0db5ac94b2cf625d325", "score": "0.50658154", "text": "func (t nullT) Convert(v interface{}) (interface{}, error) {\n\tif v != nil {\n\t\treturn nil, fmt.Errorf(\"value not nil: %#v\", v)\n\t}\n\n\treturn nil, nil\n}", "title": "" }, { "docid": "22fb216824db26c11386536cb09005df", "score": "0.50375", "text": "func defaultTo(v, d string) string {\n\tif v != \"\" {\n\t\treturn v\n\t}\n\n\treturn d\n}", "title": "" }, { "docid": "887cf4fb29b96ad72e5fac72b3270961", "score": "0.50011003", "text": "func (a *defaultTypeAdapter) NativeToValue(value interface{}) ref.Val {\n\tswitch value.(type) {\n\tcase ref.Val:\n\t\treturn value.(ref.Val)\n\tcase bool:\n\t\treturn Bool(value.(bool))\n\tcase *bool:\n\t\treturn Bool(*value.(*bool))\n\tcase int:\n\t\treturn Int(value.(int))\n\tcase int32:\n\t\treturn Int(value.(int32))\n\tcase int64:\n\t\treturn Int(value.(int64))\n\tcase *int:\n\t\treturn Int(*value.(*int))\n\tcase *int32:\n\t\treturn Int(*value.(*int32))\n\tcase *int64:\n\t\treturn Int(*value.(*int64))\n\tcase uint:\n\t\treturn Uint(value.(uint))\n\tcase uint32:\n\t\treturn Uint(value.(uint32))\n\tcase uint64:\n\t\treturn Uint(value.(uint64))\n\tcase *uint:\n\t\treturn Uint(*value.(*uint))\n\tcase *uint32:\n\t\treturn Uint(*value.(*uint32))\n\tcase *uint64:\n\t\treturn Uint(*value.(*uint64))\n\tcase float32:\n\t\treturn Double(value.(float32))\n\tcase float64:\n\t\treturn Double(value.(float64))\n\tcase *float32:\n\t\treturn Double(*value.(*float32))\n\tcase *float64:\n\t\treturn Double(*value.(*float64))\n\tcase string:\n\t\treturn String(value.(string))\n\tcase *string:\n\t\treturn String(*value.(*string))\n\tcase []byte:\n\t\treturn Bytes(value.([]byte))\n\tcase []string:\n\t\treturn NewStringList(a, value.([]string))\n\tcase map[string]string:\n\t\treturn NewStringStringMap(value.(map[string]string))\n\tcase *dpb.Duration:\n\t\treturn Duration{value.(*dpb.Duration)}\n\tcase *structpb.ListValue:\n\t\treturn NewJSONList(a, value.(*structpb.ListValue))\n\tcase structpb.NullValue:\n\t\treturn NullValue\n\tcase *structpb.Struct:\n\t\treturn NewJSONStruct(a, value.(*structpb.Struct))\n\tcase *structpb.Value:\n\t\tv := value.(*structpb.Value)\n\t\tswitch v.Kind.(type) {\n\t\tcase *structpb.Value_BoolValue:\n\t\t\treturn a.NativeToValue(v.GetBoolValue())\n\t\tcase *structpb.Value_ListValue:\n\t\t\treturn a.NativeToValue(v.GetListValue())\n\t\tcase *structpb.Value_NullValue:\n\t\t\treturn NullValue\n\t\tcase *structpb.Value_NumberValue:\n\t\t\treturn a.NativeToValue(v.GetNumberValue())\n\t\tcase *structpb.Value_StringValue:\n\t\t\treturn a.NativeToValue(v.GetStringValue())\n\t\tcase *structpb.Value_StructValue:\n\t\t\treturn a.NativeToValue(v.GetStructValue())\n\t\t}\n\tcase *tpb.Timestamp:\n\t\treturn Timestamp{value.(*tpb.Timestamp)}\n\tcase *anypb.Any:\n\t\tval := value.(*anypb.Any)\n\t\tunpackedAny := ptypes.DynamicAny{}\n\t\tif ptypes.UnmarshalAny(val, &unpackedAny) != nil {\n\t\t\tNewErr(\"Fail to unmarshal any.\")\n\t\t}\n\t\treturn a.NativeToValue(unpackedAny.Message)\n\tdefault:\n\t\trefValue := reflect.ValueOf(value)\n\t\tif refValue.Kind() == reflect.Ptr {\n\t\t\trefValue = refValue.Elem()\n\t\t}\n\t\trefKind := refValue.Kind()\n\t\tswitch refKind {\n\t\tcase reflect.Array, reflect.Slice:\n\t\t\treturn NewDynamicList(a, value)\n\t\tcase reflect.Map:\n\t\t\treturn NewDynamicMap(a, value)\n\t\t// type aliases of primitive types cannot be asserted as that type, but rather need\n\t\t// to be downcast to int32 before being converted to a CEL representation.\n\t\tcase reflect.Int32:\n\t\t\tintType := reflect.TypeOf(int32(0))\n\t\t\treturn Int(refValue.Convert(intType).Interface().(int32))\n\t\tcase reflect.Int64:\n\t\t\tintType := reflect.TypeOf(int64(0))\n\t\t\treturn Int(refValue.Convert(intType).Interface().(int64))\n\t\tcase reflect.Uint32:\n\t\t\tuintType := reflect.TypeOf(uint32(0))\n\t\t\treturn Uint(refValue.Convert(uintType).Interface().(uint32))\n\t\tcase reflect.Uint64:\n\t\t\tuintType := reflect.TypeOf(uint64(0))\n\t\t\treturn Uint(refValue.Convert(uintType).Interface().(uint64))\n\t\tcase reflect.Float32:\n\t\t\tdoubleType := reflect.TypeOf(float32(0))\n\t\t\treturn Double(refValue.Convert(doubleType).Interface().(float32))\n\t\tcase reflect.Float64:\n\t\t\tdoubleType := reflect.TypeOf(float64(0))\n\t\t\treturn Double(refValue.Convert(doubleType).Interface().(float64))\n\t\t}\n\t}\n\treturn NewErr(\"unsupported type conversion for value '%v'\", value)\n}", "title": "" }, { "docid": "449e032f9c3e2e3cff8f03a5577f0a21", "score": "0.49699542", "text": "func NewConverter(v float64) Value {\n\treturn Value{val: v}\n}", "title": "" }, { "docid": "caa43cdb1a5b1ff83b1ac0fa02983b36", "score": "0.48806018", "text": "func DefaultCreatePrimaryStringType(ctx context.Context, in *PrimaryStringType, db *gorm.DB) (*PrimaryStringType, error) {\n\tif in == nil {\n\t\treturn nil, errors.NilArgumentError\n\t}\n\tormObj, err := in.ToORM(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif hook, ok := interface{}(&ormObj).(PrimaryStringTypeORMWithBeforeCreate_); ok {\n\t\tif db, err = hook.BeforeCreate_(ctx, db); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tif err = db.Omit().Create(&ormObj).Error; err != nil {\n\t\treturn nil, err\n\t}\n\tif hook, ok := interface{}(&ormObj).(PrimaryStringTypeORMWithAfterCreate_); ok {\n\t\tif err = hook.AfterCreate_(ctx, db); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tpbResponse, err := ormObj.ToPB(ctx)\n\treturn &pbResponse, err\n}", "title": "" }, { "docid": "ca04ff1489f6595ca549231cf8d3a4f4", "score": "0.48707938", "text": "func (conv defaultConverter) MustConvertReflectValue(src, dstTyp reflect.Value, options ...Options) {\n\tif err := conv.ConvertReflectValue(src, dstTyp, options...); err != nil {\n\t\tpanic(err)\n\t}\n}", "title": "" }, { "docid": "330ded8ee94b6dcc0971b91db831e99f", "score": "0.48652667", "text": "func ConvertToString(val interface{}) string {\n\tif bytes, isBytes := val.([]byte); isBytes {\n\t\treturn string(bytes)\n\t}\n\n\tif str, isString := val.(string); isString {\n\t\treturn str\n\t}\n\n\treturn fmt.Sprintf(\"%v\", val)\n}", "title": "" }, { "docid": "27d1368c4676daaa3e8cb07a478fc0e2", "score": "0.48049745", "text": "func DefaultStringSetter(ctx context.Context, variableValue *IndexedValue, value string) error {\n\treturn DefaultSetter(ctx, variableValue, value)\n}", "title": "" }, { "docid": "ce5142e5ffb28a1c1f2c95bf7cf9183e", "score": "0.48013297", "text": "func NewRateConverterDefault() *RateConverter {\n\treturn NewRateConverter(&http.Client{}, \"\", time.Duration(0))\n}", "title": "" }, { "docid": "31a162766023bc2f81c9c176113d93ed", "score": "0.47643644", "text": "func (st *statement) ColumnConverter(idx int) driver.ValueConverter {\n\tc := driver.ValueConverter(driver.DefaultParameterConverter)\n\tswitch col := st.columns[idx]; col.OracleType {\n\tcase C.DPI_ORACLE_TYPE_NUMBER:\n\t\tswitch col.NativeType {\n\t\tcase C.DPI_NATIVE_TYPE_INT64, C.DPI_NATIVE_TYPE_UINT64:\n\t\t\tc = Int64\n\t\t//case C.DPI_NATIVE_TYPE_FLOAT, C.DPI_NATIVE_TYPE_DOUBLE:\n\t\t//\tc = Float64\n\t\tdefault:\n\t\t\tc = Num\n\t\t}\n\t}\n\tLog(\"msg\", \"ColumnConverter\", \"c\", c)\n\treturn driver.Null{Converter: c}\n}", "title": "" }, { "docid": "b2c7baeb26008dc250608009730b2c61", "score": "0.4706602", "text": "func ValueConverterOption(converter driver.ValueConverter) func(*sqlmock) error {\n\treturn func(s *sqlmock) error {\n\t\ts.converter = converter\n\t\treturn nil\n\t}\n}", "title": "" }, { "docid": "46cac667da1dfc68fab7f48b465130e8", "score": "0.46999565", "text": "func NewConverter(kind Kind) Converter {\n\treturn Converter{kind: kind}\n}", "title": "" }, { "docid": "c7445833e231cbf1d1c5bea8c5704289", "score": "0.46921638", "text": "func MustConvert(src, dst interface{}, options ...Options) {\n\tdefaultConverterInstance.MustConvert(src, dst, options...)\n}", "title": "" }, { "docid": "aa9f266953b329e1dd58114066742ca7", "score": "0.46899018", "text": "func (t textT) Convert(v interface{}) (interface{}, error) {\n\treturn cast.ToStringE(v)\n}", "title": "" }, { "docid": "db6d954bbc1ccea0d3533bae76f76d66", "score": "0.46883184", "text": "func (conv defaultConverter) MustConvert(src, dstTyp interface{}, options ...Options) {\n\tif err := conv.Convert(src, dstTyp, options...); err != nil {\n\t\tpanic(err)\n\t}\n}", "title": "" }, { "docid": "22e47848904a9b68f2833c565e8d1cb3", "score": "0.4677593", "text": "func MustConvertReflectValue(src, dstTyp reflect.Value, options ...Options) {\n\tdefaultConverterInstance.MustConvertReflectValue(src, dstTyp, options...)\n}", "title": "" }, { "docid": "a1a701e8b919aedb1c37dcdbf152a1f0", "score": "0.46460015", "text": "func CoerceToString(val interface{}) (string, error) {\n\n\tswitch t := val.(type) {\n\tcase string:\n\t\treturn t, nil\n\tcase int:\n\t\treturn strconv.Itoa(t), nil\n\tcase int64:\n\t\treturn strconv.FormatInt(t, 10), nil\n\tcase float32:\n\t\treturn strconv.FormatFloat(float64(t), 'f', -1, 64), nil\n\tcase float64:\n\t\treturn strconv.FormatFloat(t, 'f', -1, 64), nil\n\tcase json.Number:\n\t\treturn t.String(), nil\n\tcase bool:\n\t\treturn strconv.FormatBool(t), nil\n\tcase nil:\n\t\treturn \"\", nil\n\tdefault:\n\t\tb, err := json.Marshal(t)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"unable to Coerce %#v to string\", t)\n\t\t}\n\t\treturn string(b), nil\n\t}\n}", "title": "" }, { "docid": "e0c792511d5d1bcc20dd1d40af5d0708", "score": "0.46316567", "text": "func formatDefault(fieldType ast.Expr, defaultValue string) string {\n\tswitch t := fieldType.(type) {\n\tcase *ast.Ident:\n\t\tif t.Name == \"string\" && defaultValue != \"\" && quoteStrings {\n\t\t\treturn fmt.Sprintf(\"`%s`\", defaultValue)\n\t\t}\n\t}\n\treturn defaultValue\n}", "title": "" }, { "docid": "f9d0a3ba9afc7224a0c66b22a8413be9", "score": "0.46308175", "text": "func convertToString(value interface{}) (string, error) {\n\tswitch typed := value.(type) {\n\tcase string:\n\t\treturn string(typed), nil\n\tcase float64:\n\t\treturn fmt.Sprintf(\"%f\", typed), nil\n\tcase int64:\n\t\treturn strconv.FormatInt(typed, 10), nil\n\tcase int:\n\t\treturn strconv.Itoa(typed), nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"Could not convert %T to string\", value)\n\t}\n}", "title": "" }, { "docid": "1dc3bd6f078644a47487af82331b2062", "score": "0.4619303", "text": "func NewStringValue(value interface{}) StringValue {\n\tswitch v := value.(type) {\n\tcase string:\n\t\treturn StringValue{value: v}\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"expected string value type but got %T type\", v))\n\t}\n}", "title": "" }, { "docid": "8cd6ea1cfffee5e873fe3b212336f53c", "score": "0.45766857", "text": "func NewStringValue(v interface{}) Value {\n\tswitch t := v.(type) {\n\tcase string:\n\t\treturn String(t)\n\tcase []byte:\n\t\treturn String(t)\n\tcase bool:\n\t\treturn String(fmt.Sprintf(\"%v\", t))\n\tcase int:\n\t\treturn String(strconv.FormatInt(int64(t), 10))\n\tcase int8:\n\t\treturn String(strconv.FormatInt(int64(t), 10))\n\tcase int16:\n\t\treturn String(strconv.FormatInt(int64(t), 10))\n\tcase int32:\n\t\treturn String(strconv.FormatInt(int64(t), 10))\n\tcase int64:\n\t\treturn String(strconv.FormatInt(t, 10))\n\tcase uint:\n\t\treturn String(strconv.FormatUint(uint64(t), 10))\n\tcase uint8: // byte is an alias for uint8\n\t\treturn String(strconv.FormatUint(uint64(t), 10))\n\tcase uint16:\n\t\treturn String(strconv.FormatUint(uint64(t), 10))\n\tcase uint32:\n\t\treturn String(strconv.FormatUint(uint64(t), 10))\n\tcase float32:\n\t\treturn String(strconv.FormatFloat(float64(t), 'f', -1, 64))\n\tcase float64:\n\t\treturn String(strconv.FormatFloat(t, 'f', -1, 64))\n\tcase time.Time:\n\t\treturn String(t.String())\n\tcase time.Duration:\n\t\treturn String(t.String())\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v(%T) is not supported yet\", v, v))\n\t}\n}", "title": "" }, { "docid": "b5e8e4983b166bac8f323af978d74914", "score": "0.45733452", "text": "func (t SimpleType) ConvertFromModel(value interface{}) (interface{}, error) {\n\tif value == nil {\n\t\treturn nil, nil\n\t}\n\tvalueType := reflect.TypeOf(value)\n\tswitch t.GetKind() {\n\tcase KindString, KindURL, KindUser, KindInteger, KindFloat, KindDuration, KindIteration, KindArea, KindLabel, KindBoolean:\n\t\treturn value, nil\n\tcase KindInstant:\n\t\tswitch valueType.Kind() {\n\t\tcase reflect.Float64:\n\t\t\tv, ok := value.(float64)\n\t\t\tif !ok {\n\t\t\t\treturn nil, errs.Errorf(\"value %v could not be converted into an %s\", value, reflect.Float64)\n\t\t\t}\n\t\t\tif v != math.Trunc(v) {\n\t\t\t\treturn nil, errs.Errorf(\"value %v is not a whole number\", value)\n\t\t\t}\n\t\t\treturn time.Unix(0, int64(v)), nil\n\t\tcase reflect.Int64:\n\t\t\tv, ok := value.(int64)\n\t\t\tif !ok {\n\t\t\t\treturn nil, errs.Errorf(\"value %v could not be converted into an %s\", value, reflect.Int64)\n\t\t\t}\n\t\t\treturn time.Unix(0, v), nil\n\t\tdefault:\n\t\t\treturn nil, errs.Errorf(\"value %v must be either %s or %s but has an unknown type %s\", value, reflect.Int64, reflect.Float64, valueType.Name())\n\t\t}\n\tcase KindMarkup:\n\t\tif valueType.Kind() != reflect.Map {\n\t\t\treturn nil, errs.Errorf(\"value %v should be %s, but is %s\", value, reflect.Map, valueType.Name())\n\t\t}\n\t\tmarkupContent := rendering.NewMarkupContentFromMap(value.(map[string]interface{}))\n\t\treturn markupContent, nil\n\tcase KindCodebase:\n\t\tif valueType.Kind() != reflect.Map {\n\t\t\treturn nil, errs.Errorf(\"value %v should be %s, but is %s\", value, reflect.Map, valueType.Name())\n\t\t}\n\t\tcb, err := codebase.NewCodebaseContent(value.(map[string]interface{}))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn cb, nil\n\tdefault:\n\t\treturn nil, errs.Errorf(\"unexpected field type: %s\", t.GetKind())\n\t}\n}", "title": "" }, { "docid": "975dd63480371d8e07fe286b8525548d", "score": "0.457317", "text": "func DefaultBeautyStrFunc(bePrintStr string) string {\n\treturn bePrintStr\n}", "title": "" }, { "docid": "851dd218a39726b47ad8b42f3c2f2b30", "score": "0.45476112", "text": "func (t blobT) Convert(v interface{}) (interface{}, error) {\n\tswitch value := v.(type) {\n\tcase []byte:\n\t\treturn value, nil\n\tcase string:\n\t\treturn []byte(value), nil\n\tcase fmt.Stringer:\n\t\treturn []byte(value.String()), nil\n\tdefault:\n\t\treturn nil, ErrInvalidType\n\t}\n}", "title": "" }, { "docid": "19672752b315db12abd9b511bcecfb16", "score": "0.45315924", "text": "func (s String) SetToDefault() {\n\t*s.Pointer = s.Default\n}", "title": "" }, { "docid": "eca0e9a705e93b9396cae3c29bb6bbbf", "score": "0.45227632", "text": "func NewDefaultColumnValue()(*DefaultColumnValue) {\n m := &DefaultColumnValue{\n }\n m.SetAdditionalData(make(map[string]interface{}));\n return m\n}", "title": "" }, { "docid": "058b900a1424e27981ec3e8031ddc4f9", "score": "0.45203763", "text": "func DefaultPatchPrimaryStringType(ctx context.Context, in *PrimaryStringType, updateMask *field_mask.FieldMask, db *gorm.DB) (*PrimaryStringType, error) {\n\tif in == nil {\n\t\treturn nil, errors.NilArgumentError\n\t}\n\tvar pbObj PrimaryStringType\n\tvar err error\n\tif hook, ok := interface{}(&pbObj).(PrimaryStringTypeWithBeforePatchRead); ok {\n\t\tif db, err = hook.BeforePatchRead(ctx, in, updateMask, db); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tpbReadRes, err := DefaultReadPrimaryStringType(ctx, &PrimaryStringType{Id: in.GetId()}, db)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tpbObj = *pbReadRes\n\tif hook, ok := interface{}(&pbObj).(PrimaryStringTypeWithBeforePatchApplyFieldMask); ok {\n\t\tif db, err = hook.BeforePatchApplyFieldMask(ctx, in, updateMask, db); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tif _, err := DefaultApplyFieldMaskPrimaryStringType(ctx, &pbObj, in, updateMask, \"\", db); err != nil {\n\t\treturn nil, err\n\t}\n\tif hook, ok := interface{}(&pbObj).(PrimaryStringTypeWithBeforePatchSave); ok {\n\t\tif db, err = hook.BeforePatchSave(ctx, in, updateMask, db); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tpbResponse, err := DefaultStrictUpdatePrimaryStringType(ctx, &pbObj, db)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif hook, ok := interface{}(pbResponse).(PrimaryStringTypeWithAfterPatchSave); ok {\n\t\tif err = hook.AfterPatchSave(ctx, in, updateMask, db); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn pbResponse, nil\n}", "title": "" }, { "docid": "73e00e2063241a830d353e395ae4bbd3", "score": "0.44946343", "text": "func DefaultStringFunc[T any](vals []T) string {\n\tstrs := make([]string, len(vals))\n\tfor i := range vals {\n\t\tstrs[i] = fmt.Sprint(vals[i])\n\t}\n\treturn strings.Join(strs, \", \")\n}", "title": "" }, { "docid": "7a1ca9f2face6a9eb100b3d495da9640", "score": "0.44941092", "text": "func toNullString(s string) sql.NullString {\n\treturn sql.NullString{String: s, Valid: s != \"\"}\n}", "title": "" }, { "docid": "3c7b5e5bee9178c42e2b3da9305fae14", "score": "0.44850296", "text": "func (m *QueryResponseRowEntry) FromNullableString(data *string) {\n\tm.data = data\n}", "title": "" }, { "docid": "e81df90699dc442999052785eee0a077", "score": "0.44841632", "text": "func MustConvert(t Type, v interface{}) interface{} {\n\tc, err := t.Convert(v)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tpanic(err)\n\t}\n\n\treturn c\n}", "title": "" }, { "docid": "eb3fb6967a22f6f640480dcbe61c0eb2", "score": "0.4474833", "text": "func ConvertReflectValue(src, dstTyp reflect.Value, options ...Options) error {\n\treturn defaultConverterInstance.ConvertReflectValue(src, dstTyp, options...)\n}", "title": "" }, { "docid": "dd593763baac62d76e145a3d89e65d38", "score": "0.44630584", "text": "func NullableString(value string) *string {\n\treturn &value\n}", "title": "" }, { "docid": "93d0fa2e4dc3c055271beafc06b38c99", "score": "0.4442646", "text": "func New(name string) (common.Converter, error) {\n\tswitch name {\n\tcase \"telegraf_json\":\n\t\treturn telegraf_json.NewConverter(), nil\n\tcase \"influxlp\":\n\t\treturn influxlp.NewConverter(), nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"No such converter: %v\", name)\n\t}\n}", "title": "" }, { "docid": "976ad1d32d8d095ae8b6c99b75acd1ce", "score": "0.4439247", "text": "func transformDefaultExprToDefaultVal(expr *ast.DefaultExpr) *DefaultVal {\n\treturn NewDefaultVal()\n}", "title": "" }, { "docid": "e6efa455a3257deb991cc1f97372b8d2", "score": "0.44139168", "text": "func New(options ...Options) Converter {\n\tconv := defaultConverterInstance\n\tif len(options) > 0 {\n\t\tconv.options.SkipUnknownFields = options[0].SkipUnknownFields\n\t\tconv.options.Recipes = joinRecipes(conv.options.Recipes, options[0].Recipes)\n\t}\n\treturn &conv\n}", "title": "" }, { "docid": "0aa51a4357acb71a6fcf702203f5cc5d", "score": "0.44127208", "text": "func NewConverter(config Configuration) *Converter {\n\tvar c Converter\n\tc.jobs = make(map[string]int)\n\tc.conf = config\n\treturn &c\n}", "title": "" }, { "docid": "81fb1181ba42a7305ade925236589d34", "score": "0.43859902", "text": "func (media *Media) DefaultDbValue() interface{} {\n\treturn new(string)\n}", "title": "" }, { "docid": "510361aef53a3c0531b6c48f03a31c1e", "score": "0.43733388", "text": "func NewConverter(api iface.CoreAPI, provider content.Provider) Converter {\n\treturn &converter{\n\t\tapi: api,\n\t\tprovider: provider,\n\t}\n}", "title": "" }, { "docid": "c3281938e0fcd38dcc1d939ad562824a", "score": "0.43623212", "text": "func (m *DefaultColumnValue) GetValue()(*string) {\n return m.value\n}", "title": "" }, { "docid": "615d070fe1eba0c2e82578b65189c658", "score": "0.43570465", "text": "func (o LogMetricFilterMetricTransformationOutput) DefaultValue() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v LogMetricFilterMetricTransformation) *string { return v.DefaultValue }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "1cb8816a499bfc730aac3a04a693fb1d", "score": "0.4355009", "text": "func NewConverter(Operators []Operator) Converter {\n\treturn Converter{Operators}\n}", "title": "" }, { "docid": "abb6d6e8d52605d384b2c5341ad1c400", "score": "0.43497685", "text": "func (nc numConverter) ConvertValue(src interface{}) (driver.Value, error) {\n\tvar err error\n\n\tif src == nil {\n\t\treturn nil, nil\n\t}\n\n\t// is numeric?\n\tif num, ok := src.(Num); ok {\n\t\tif num.isNull {\n\t\t\treturn nil, nil\n\t\t}\n\n\t\t// check for loss of precision\n\t\tif num.precision > nc.precision || num.scale > nc.scale {\n\t\t\treturn nil, ErrOverFlow\n\t\t}\n\n\t\treturn []byte(num.String()), err\n\t}\n\n\t// get num from pool\n\tnum := numPool.Get().(*Num)\n\tdefer numPool.Put(num)\n\tnum.precision, num.scale, num.isNull = nc.precision, nc.scale, false\n\n\t// check for driver values\n\tif val, ok := src.(driver.Valuer); ok {\n\t\tif src, err = val.Value(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif src == nil {\n\t\t\treturn nil, nil\n\t\t}\n\t}\n\n\t// use scan to convert to numeric\n\tif err = num.Scan(src); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn []byte(num.String()), err\n}", "title": "" }, { "docid": "f3dd57966fd003bcd775ea612f832644", "score": "0.43282515", "text": "func StringValue(v string) Value {\n\treturn Value{\n\t\tvtype: STRING,\n\t\tstringly: v,\n\t}\n}", "title": "" }, { "docid": "f25463789a07e3ec0dc9f82da444fc26", "score": "0.43125182", "text": "func NewDefault(t token.Token) *DefaultLiteral {\n\tfmt.Println(\"type and stuff\", TypeFromString(t.Value.String))\n\n\treturn &DefaultLiteral{\n\t\tToken: t,\n\t\tTypeOf: TypeFromString(t.Value.String),\n\t\tValue: t.Value.String,\n\t}\n}", "title": "" }, { "docid": "348c7561c079b7f2e26d05d7c209f4a6", "score": "0.43100718", "text": "func (t SimpleType) ConvertToModel(value interface{}) (interface{}, error) {\n\tif value == nil {\n\t\treturn nil, nil\n\t}\n\tvalueType := reflect.TypeOf(value)\n\tswitch t.GetKind() {\n\tcase KindString, KindUser, KindIteration, KindArea, KindLabel:\n\t\tif valueType.Kind() != reflect.String {\n\t\t\treturn nil, errs.Errorf(\"value %v should be %s, but is %s\", value, \"string\", valueType.Name())\n\t\t}\n\t\treturn value, nil\n\tcase KindURL:\n\t\tif valueType.Kind() == reflect.String && govalidator.IsURL(value.(string)) {\n\t\t\treturn value, nil\n\t\t}\n\t\treturn nil, errs.Errorf(\"value %v should be %s, but is %s\", value, \"URL\", valueType.Name())\n\tcase KindFloat:\n\t\tif valueType.Kind() != reflect.Float64 {\n\t\t\treturn nil, errs.Errorf(\"value %v should be %s, but is %s\", value, \"float64\", valueType.Name())\n\t\t}\n\t\treturn value, nil\n\tcase KindInteger, KindDuration: // NOTE: Duration is a typedef of int64\n\t\tif valueType.Kind() != reflect.Int && valueType.Kind() != reflect.Int64 {\n\t\t\treturn nil, errs.Errorf(\"value %v should be %s, but is %s\", value, \"int\", valueType.Name())\n\t\t}\n\t\treturn value, nil\n\tcase KindInstant:\n\t\t// instant == milliseconds\n\t\t// if !valueType.Implements(timeType) {\n\t\tif valueType.Kind() != timeType.Kind() {\n\t\t\treturn nil, errs.Errorf(\"value %v should be %s, but is %s\", value, \"time.Time\", valueType.Name())\n\t\t}\n\t\treturn value.(time.Time).UnixNano(), nil\n\tcase KindList:\n\t\tif (valueType.Kind() != reflect.Array) && (valueType.Kind() != reflect.Slice) {\n\t\t\treturn nil, errs.Errorf(\"value %v should be %s, but is %s,\", value, \"array/slice\", valueType.Kind())\n\t\t}\n\t\treturn value, nil\n\tcase KindEnum:\n\t\t// to be done yet | not sure what to write here as of now.\n\t\treturn value, nil\n\tcase KindMarkup:\n\t\t// 'markup' is just a string in the API layer for now:\n\t\t// it corresponds to the MarkupContent.Content field. The MarkupContent.Markup is set to the default value\n\t\tswitch value.(type) {\n\t\tcase rendering.MarkupContent:\n\t\t\tmarkupContent := value.(rendering.MarkupContent)\n\t\t\tif !rendering.IsMarkupSupported(markupContent.Markup) {\n\t\t\t\treturn nil, errs.Errorf(\"value %v (type %s) has no valid markup type %s\", value, \"MarkupContent\", markupContent.Markup)\n\t\t\t}\n\t\t\treturn markupContent.ToMap(), nil\n\t\tdefault:\n\t\t\treturn nil, errs.Errorf(\"value %v should be %s, but is %s\", value, \"MarkupContent\", valueType)\n\t\t}\n\tcase KindCodebase:\n\t\tswitch value.(type) {\n\t\tcase codebase.Content:\n\t\t\tcb := value.(codebase.Content)\n\t\t\tif err := cb.IsValid(); err != nil {\n\t\t\t\treturn nil, errs.Wrapf(err, \"value %v (type %s) is invalid %s\", value, \"Codebase\", cb)\n\t\t\t}\n\t\t\treturn cb.ToMap(), nil\n\t\tdefault:\n\t\t\treturn nil, errs.Errorf(\"value %v should be %s, but is %s\", value, \"CodebaseContent\", valueType)\n\t\t}\n\tcase KindBoolean:\n\t\tif valueType.Kind() != reflect.Bool {\n\t\t\treturn nil, errs.Errorf(\"value %v should be %s, but is %s\", value, \"boolean\", valueType.Name())\n\t\t}\n\t\treturn value, nil\n\tdefault:\n\t\treturn nil, errs.Errorf(\"unexpected type constant: '%s'\", t.GetKind())\n\t}\n}", "title": "" }, { "docid": "4af329339bd134d6c111c0f70ca25b41", "score": "0.43063208", "text": "func (s *String) ConvertType(which TypeFlag) Object {\n\tswitch which {\n\tcase StringType:\n\t\treturn s\n\tcase FloatType:\n\t\tif f, err := strconv.ParseFloat(s.Value, 64); err == nil {\n\t\t\treturn NewFloat(f)\n\t\t}\n\tcase IntType:\n\t\tif i, err := strconv.Atoi(s.Value); err == nil {\n\t\t\treturn NewInt(i)\n\t\t}\n\tcase ArrayType:\n\t\tn := len(s.Value)\n\t\ta := &Array{Elements: make([]Object, n), Len: n}\n\t\tfor i, s := range s.Value {\n\t\t\ta.Elements[i] = &Char{Value: byte(s)}\n\t\t}\n\t\treturn a\n\tcase BoolType:\n\t\treturn NewBool(s.Value != \"\")\n\t}\n\treturn NewError(\"Argument to %s not supported, got %s\", which, s.Type())\n}", "title": "" }, { "docid": "32fce94e000556a1009d5d55459dbb39", "score": "0.43006575", "text": "func dataInferer(value string) string {\n\n\tif charInString(value, \" \") { \t\t\t\t\t // check if there's a space in the value\n\t\treturn \"list\"\n\t} else if isNumeric(value) { \t\t\t\t\t\t // check if the value can be converted to a number\n\t\treturn \"number\"\n\t} else if isUUID(value) {\t\t\t\t\t\t\t // check if the value matches a UUID regexp\n\t\treturn \"uuid\"\n\t} else { \t\t\t\t\t\t\t\t\t\t\t // return String as default value\n\t\treturn \"string\"\n\t}\n\n}", "title": "" }, { "docid": "140e0ee84818489f3d616a15765b6422", "score": "0.42958713", "text": "func (base *Meta) Convert(value string, to string) (interface{}, error) {\n\tif to == \"string\" {\n\t\treturn value, nil\n\t}\n\tbits := 0\n\tvar err error\n\tprefixes := []string{\"float\", \"uint\", \"int\"}\n\tfor _, prefix := range prefixes {\n\t\tif strings.HasPrefix(to, prefix) {\n\t\t\tbitstr := to[len(prefix):]\n\t\t\tif bitstr != \"\" {\n\t\t\t\tbits, err = strconv.Atoi(bitstr)\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tto = prefix\n\t\t}\n\t}\n\tswitch to {\n\tcase \"float\":\n\t\tif value == \"\" {\n\t\t\treturn 0, nil\n\t\t}\n\t\treturn strconv.ParseFloat(value, bits)\n\tcase \"uint\":\n\t\treturn strconv.ParseUint(value, 10, bits)\n\tcase \"int\":\n\t\treturn strconv.ParseInt(value, 10, bits)\n\tcase \"bool\":\n\t\treturn strconv.ParseBool(value)\n\tcase \"date\":\n\t\tvar err error\n\t\tlayouts := []string{\"2006-01-02T15:04:05.000Z\", \"2006-01-02T15:04:05\", \"28/02/2003\", \"2002-01-23\"}\n\t\tvar date time.Time\n\t\tfor _, layout := range layouts {\n\t\t\tdate, err = time.Parse(layout, value)\n\t\t\tif err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn date, nil\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Could not convert time %s to %s, unknown date fmt\", value, to)\n\t\t}\n\n\t}\n\treturn nil, fmt.Errorf(\"Could not convert %s to %s\", value, to)\n}", "title": "" }, { "docid": "941401e81c783ba8b74412db1fa5c612", "score": "0.42946705", "text": "func CreateDefaultColumnValueFromDiscriminatorValue(parseNode i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, error) {\n return NewDefaultColumnValue(), nil\n}", "title": "" }, { "docid": "c64e50300da7ae8d0d14a8a99166d794", "score": "0.42942494", "text": "func (o LogMetricFilterMetricTransformationPtrOutput) DefaultValue() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v LogMetricFilterMetricTransformation) *string { return v.DefaultValue }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "df64b29d79ae5ccd60b7c9b214e28760", "score": "0.42934904", "text": "func convertField(typeData, value string) (newValue interface{}, err error) {\n\n\tswitch typeData {\n\tcase \"date\":\n\t\tnewValue, err = time.Parse(time.RFC3339, strings.TrimSpace(value))\n\t\tbreak\n\tcase \"number\":\n\t\tnewValue, err = strconv.ParseFloat(strings.TrimSpace(value), 64)\n\t\tbreak\n\tdefault:\n\t\tnewValue = value\n\t}\n\treturn\n}", "title": "" }, { "docid": "b8f766f29195dd0dca1bf63f2ca8ccca", "score": "0.4291148", "text": "func Convert(k Kind, v interface{}) (interface{}, error) {\n\tif c, ok := converters[k]; ok {\n\t\treturn c(v)\n\t}\n\treturn nil, ErrKindNotExist\n}", "title": "" }, { "docid": "4f394c419bac2d37f9bda5fdbf6aea01", "score": "0.42836034", "text": "func convertBasicType(val string, typ FieldType) (Value, error) {\n\tswitch typ {\n\tcase StringFieldType:\n\t\treturn val, nil\n\tcase BytesFieldType:\n\t\treturn base64.StdEncoding.DecodeString(val)\n\tcase IntegerFieldType:\n\t\treturn strconv.ParseInt(val, 10, 64)\n\tcase FloatFieldType:\n\t\treturn strconv.ParseFloat(val, 64)\n\tcase BooleanFieldType:\n\t\treturn strconv.ParseBool(val)\n\tcase TimestampFieldType:\n\t\tf, err := strconv.ParseFloat(val, 64)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tsecs := math.Trunc(f)\n\t\t// Timestamps in BigQuery have microsecond precision, so we must\n\t\t// return a round number of microseconds.\n\t\tmicros := math.Trunc((f-secs)*1e6 + 0.5)\n\t\treturn Value(time.Unix(int64(secs), int64(micros)*1000).UTC()), nil\n\tcase DateFieldType:\n\t\treturn civil.ParseDate(val)\n\tcase TimeFieldType:\n\t\treturn civil.ParseTime(val)\n\tcase DateTimeFieldType:\n\t\treturn civil.ParseDateTime(val)\n\tcase NumericFieldType:\n\t\tr, ok := (&big.Rat{}).SetString(val)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"bigquery: invalid NUMERIC value %q\", val)\n\t\t}\n\t\treturn Value(r), nil\n\tcase BigNumericFieldType:\n\t\tr, ok := (&big.Rat{}).SetString(val)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"bigquery: invalid BIGNUMERIC value %q\", val)\n\t\t}\n\t\treturn Value(r), nil\n\tcase GeographyFieldType:\n\t\treturn val, nil\n\tcase JSONFieldType:\n\t\treturn val, nil\n\tcase IntervalFieldType:\n\t\ti, err := ParseInterval(val)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"bigquery: invalid INTERVAL value %q\", val)\n\t\t}\n\t\treturn Value(i), nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unrecognized type: %s\", typ)\n\t}\n}", "title": "" }, { "docid": "d137a9135468506d710d6d09baf53473", "score": "0.42710614", "text": "func StringOrDefault(str, defaultTo string) string {\n\tif str == \"\" {\n\t\treturn defaultTo\n\t}\n\treturn str\n}", "title": "" }, { "docid": "8ae7003ba3d83f4807fe6e0bad42fbd9", "score": "0.42679247", "text": "func Convert(value interface{}, t reflect.Kind) (interface{}, error) {\n\n\tswitch reflect.TypeOf(value).Kind() {\n\tcase reflect.Slice:\n\t\tswitch t {\n\t\tcase reflect.String:\n\t\t\tif reflect.TypeOf(value).Elem().Kind() == reflect.Uint8 {\n\t\t\t\treturn string(value.([]byte)), nil\n\t\t\t} else {\n\t\t\t\treturn String(value), nil\n\t\t\t}\n\t\tcase reflect.Slice:\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"Could not convert slice into non-slice.\")\n\t\t}\n\tcase reflect.String:\n\t\tswitch t {\n\t\tcase reflect.Slice:\n\t\t\treturn Bytes(value), nil\n\t\t}\n\t}\n\n\tswitch t {\n\n\tcase reflect.String:\n\t\treturn String(value), nil\n\n\tcase reflect.Uint64:\n\t\treturn Uint64(value), nil\n\n\tcase reflect.Uint32:\n\t\treturn uint32(Uint64(value)), nil\n\n\tcase reflect.Uint16:\n\t\treturn uint16(Uint64(value)), nil\n\n\tcase reflect.Uint8:\n\t\treturn uint8(Uint64(value)), nil\n\n\tcase reflect.Uint:\n\t\treturn uint(Uint64(value)), nil\n\n\tcase reflect.Int64:\n\t\treturn int64(Int64(value)), nil\n\n\tcase reflect.Int32:\n\t\treturn int32(Int64(value)), nil\n\n\tcase reflect.Int16:\n\t\treturn int16(Int64(value)), nil\n\n\tcase reflect.Int8:\n\t\treturn int8(Int64(value)), nil\n\n\tcase reflect.Int:\n\t\treturn int(Int64(value)), nil\n\n\tcase reflect.Float64:\n\t\treturn Float64(value), nil\n\n\tcase reflect.Float32:\n\t\treturn float32(Float64(value)), nil\n\n\tcase reflect.Bool:\n\t\treturn Bool(value), nil\n\n\tcase reflect.Interface:\n\t\treturn value, nil\n\n\tcase KindTime:\n\t\treturn Time(value), nil\n\n\tcase KindDuration:\n\t\treturn Duration(value), nil\n\n\t}\n\n\treturn nil, fmt.Errorf(\"Could not convert %s into %s.\", reflect.TypeOf(value).Kind(), t)\n}", "title": "" }, { "docid": "be35673067d660b72cac54f8a85e8b6e", "score": "0.42678395", "text": "func NewDefaultStatusConverter(opts ...StatusConverterOption) StatusConverter {\n\treturn NewStatusConverter(append(opts, WithStatusMatchers(DefaultStatusMatchers...))...)\n}", "title": "" }, { "docid": "41b0c8eef36d50517d4a397d16d86465", "score": "0.4262183", "text": "func rustDefault(s string) template.HTML {\n\tswitch s {\n\tcase \"string\":\n\t\treturn \"String::new()\"\n\tcase \"int\":\n\t\tfallthrough\n\tcase \"int8\":\n\t\tfallthrough\n\tcase \"int16\":\n\t\tfallthrough\n\tcase \"int32\":\n\t\tfallthrough\n\tcase \"int64\":\n\t\tfallthrough\n\tcase \"uint\":\n\t\tfallthrough\n\tcase \"uint8\":\n\t\tfallthrough\n\tcase \"uint16\":\n\t\tfallthrough\n\tcase \"uint32\":\n\t\tfallthrough\n\tcase \"uint64\":\n\t\treturn \"std::default::Default::default()\"\n\tcase \"float32\":\n\t\tfallthrough\n\tcase \"float64\":\n\t\treturn \"0.0\"\n\tdefault:\n\t\tif strings.HasPrefix(s, \"map[\") {\n\t\t\tkeyType := rustType(s[4 : 4+strings.Index(s[4:], \"]\")])\n\t\t\tvalueType := rustType(s[5+len(keyType):])\n\t\t\treturn template.HTML(fmt.Sprintf(\"std::collections::HashMap::<%s, %s>::new()\", keyType, valueType))\n\t\t} else if strings.HasPrefix(s, \"[]\") {\n\t\t\treturn template.HTML(fmt.Sprintf(\"std::Vec::new()\"))\n\t\t}\n\t\treturn template.HTML(\"Default::default()\")\n\t}\n}", "title": "" }, { "docid": "48b35180af9abeb80e9ba01fb36be2b1", "score": "0.42580858", "text": "func DefaultStrictUpdatePrimaryStringType(ctx context.Context, in *PrimaryStringType, db *gorm.DB) (*PrimaryStringType, error) {\n\tif in == nil {\n\t\treturn nil, fmt.Errorf(\"Nil argument to DefaultStrictUpdatePrimaryStringType\")\n\t}\n\tormObj, err := in.ToORM(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar count int64\n\tlockedRow := &PrimaryStringTypeORM{}\n\tcount = db.Model(&ormObj).Set(\"gorm:query_option\", \"FOR UPDATE\").Where(\"id=?\", ormObj.Id).First(lockedRow).RowsAffected\n\tif hook, ok := interface{}(&ormObj).(PrimaryStringTypeORMWithBeforeStrictUpdateCleanup); ok {\n\t\tif db, err = hook.BeforeStrictUpdateCleanup(ctx, db); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tfilterChild := ExternalChildORM{}\n\tif ormObj.Id == \"\" {\n\t\treturn nil, errors.EmptyIdError\n\t}\n\tfilterChild.PrimaryStringTypeId = new(string)\n\t*filterChild.PrimaryStringTypeId = ormObj.Id\n\tif err = db.Where(filterChild).Delete(ExternalChildORM{}).Error; err != nil {\n\t\treturn nil, err\n\t}\n\tif hook, ok := interface{}(&ormObj).(PrimaryStringTypeORMWithBeforeStrictUpdateSave); ok {\n\t\tif db, err = hook.BeforeStrictUpdateSave(ctx, db); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tif err = db.Omit().Save(&ormObj).Error; err != nil {\n\t\treturn nil, err\n\t}\n\tif hook, ok := interface{}(&ormObj).(PrimaryStringTypeORMWithAfterStrictUpdateSave); ok {\n\t\tif err = hook.AfterStrictUpdateSave(ctx, db); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tpbResponse, err := ormObj.ToPB(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif count == 0 {\n\t\terr = gateway.SetCreated(ctx, \"\")\n\t}\n\treturn &pbResponse, err\n}", "title": "" }, { "docid": "3f9e8bf8b40cfe7ae9cd2f22aedc6871", "score": "0.42542964", "text": "func Convert(fromValue interface{}, toTypeName string, extraParams ...interface{}) interface{} {\n\treturn doConvert(doConvertInput{\n\t\tFromValue: fromValue,\n\t\tToTypeName: toTypeName,\n\t\tReferValue: nil,\n\t\tExtra: extraParams,\n\t})\n}", "title": "" }, { "docid": "dd43405ea2910997f44a1da5b2a2fc3b", "score": "0.42534417", "text": "func NullableString(s StringNullWhenEmpty) *StringNullWhenEmpty { return &s }", "title": "" }, { "docid": "c6f664bc39c93a89eb2d004427af4ed7", "score": "0.4245444", "text": "func strConv(src string, t reflect.Type) (rv reflect.Value, err error) {\n\tswitch t.Kind() {\n\tcase reflect.String:\n\t\trv = reflect.ValueOf(src)\n\tcase reflect.Int:\n\t\tv, err := strconv.Atoi(src)\n\t\tnoErrorFunc(err, func() {\n\t\t\trv = reflect.ValueOf(v)\n\t\t})\n\tcase reflect.Int64:\n\t\tv, err := strconv.ParseInt(src, 10, 64)\n\t\tnoErrorFunc(err, func() {\n\t\t\trv = reflect.ValueOf(v)\n\t\t})\n\tcase reflect.Bool:\n\t\tv, err := strconv.ParseBool(src)\n\t\tnoErrorFunc(err, func() {\n\t\t\trv = reflect.ValueOf(v)\n\t\t})\n\tcase reflect.Float64:\n\t\tv, err := strconv.ParseFloat(src, 64)\n\t\tnoErrorFunc(err, func() {\n\t\t\trv = reflect.ValueOf(v)\n\t\t})\n\tcase reflect.Float32:\n\t\tv, err := strconv.ParseFloat(src, 32)\n\t\tnoErrorFunc(err, func() {\n\t\t\trv = reflect.ValueOf(float32(v))\n\t\t})\n\tcase reflect.Uint64:\n\t\tv, err := strconv.ParseUint(src, 10, 64)\n\t\tnoErrorFunc(err, func() {\n\t\t\trv = reflect.ValueOf(v)\n\t\t})\n\tcase reflect.Uint32:\n\t\tv, err := strconv.ParseUint(src, 10, 32)\n\t\tnoErrorFunc(err, func() {\n\t\t\trv = reflect.ValueOf(uint32(v))\n\t\t})\n\tdefault:\n\t\terr = errors.New(\"elem of invalid type\")\n\t}\n\treturn rv, err\n}", "title": "" }, { "docid": "2361c8b13c4016e362cf927b57a16f14", "score": "0.424422", "text": "func DefaultSetter(ctx context.Context, variableValue *IndexedValue, value interface{}) error {\n\tvariableValue.data = value\n\tvariableValue.Valid = true\n\treturn nil\n}", "title": "" }, { "docid": "f67df2983805905ebacd50652ba2e185", "score": "0.42356554", "text": "func MustToString(v interface{}) string {\n\t_v, err := ToString(v)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn _v\n}", "title": "" }, { "docid": "f67df2983805905ebacd50652ba2e185", "score": "0.42356554", "text": "func MustToString(v interface{}) string {\n\t_v, err := ToString(v)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn _v\n}", "title": "" }, { "docid": "cbc97a31b8593f4ecef84916bd5e5e45", "score": "0.4223163", "text": "func (ftc *FieldTypeCreate) SetNillableStr(ss *sql.NullString) *FieldTypeCreate {\n\tif ss != nil {\n\t\tftc.SetStr(*ss)\n\t}\n\treturn ftc\n}", "title": "" }, { "docid": "a2ef4941b1cbae07a42004c118a5511b", "score": "0.42213798", "text": "func (val *String) DefaultValueString() string {\n\treturn val.DefaultValue\n}", "title": "" }, { "docid": "9be12bc422e258f1e5124648f766ea15", "score": "0.42082694", "text": "func SafeCastToString(v interface{}) string {\n\tif v != nil {\n\t\treturn v.(string)\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "83377cd571d81cc5aa39bd26a8401d21", "score": "0.41971654", "text": "func valueToString(v reflect.Value) (string, error) {\n if !v.IsValid() {\n return \"null\", nil\n }\n\n switch v.Kind() {\n case reflect.Ptr:\n return valueToString(reflect.Indirect(v))\n case reflect.Interface:\n return valueToString(v.Elem())\n case reflect.Bool:\n x := v.Bool()\n if x {\n return \"true\", nil\n } else {\n return \"false\", nil\n }\n\n case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n return strconv.FormatInt(v.Int(), 10), nil\n case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n return strconv.FormatUint(v.Uint(), 10), nil\n case reflect.UnsafePointer:\n return strconv.FormatUint(uint64(v.Pointer()), 10), nil\n\n case reflect.Float32, reflect.Float64:\n return strconv.FormatFloat(v.Float(), 'g', -1, 64), nil\n\n case reflect.String:\n return v.String(), nil\n\n //This is kind of a rough hack to replace the old []byte\n //detection with reflect.Uint8Type, it doesn't catch\n //zero-length byte slices\n case reflect.Slice:\n typ := v.Type()\n if typ.Elem().Kind() == reflect.Uint || typ.Elem().Kind() == reflect.Uint8 || typ.Elem().Kind() == reflect.Uint16 || typ.Elem().Kind() == reflect.Uint32 || typ.Elem().Kind() == reflect.Uint64 || typ.Elem().Kind() == reflect.Uintptr {\n if v.Len() > 0 {\n if v.Index(0).OverflowUint(257) {\n return string(v.Interface().([]byte)), nil\n }\n }\n }\n }\n return \"\", errors.New(\"Unsupported type\")\n}", "title": "" }, { "docid": "edf0930870d3adf4e390e38a3e3c26ea", "score": "0.41921517", "text": "func NewConversion(params ...interface{}) *Conversion {\n\tc := new(Conversion)\n\n\tc.base = \"0\"\n\tif len(params) != 0 {\n\t\tc.base = zero + ToString(params[0]) + zero\n\t}\n\n\tc.multiples = parseMultiples(params[:]...)\n\n\treturn c\n}", "title": "" }, { "docid": "ecd1111511ea237f73868a50c166c28d", "score": "0.41899127", "text": "func (album *Album) DefaultDbValue() interface{} {\n\treturn new(string)\n}", "title": "" }, { "docid": "c54684ca91fed0fd925748f5f68749db", "score": "0.41877204", "text": "func DefaultStr(values ...string) string {\n\tif len(values) == 1 {\n\t\treturn values[0]\n\t}\n\tif values[0] != \"\" {\n\t\treturn values[0]\n\t}\n\treturn DefaultStr(values[1:]...)\n}", "title": "" }, { "docid": "6144e98e85c338caea1d4e49dfc8c6af", "score": "0.4183283", "text": "func stringToObject(valueText string, valueKind reflect.Kind) (v interface{}, err error) {\n\n\tvar intValue int64\n\tvar uintValue uint64\n\tvar floatValue float64\n\n\tswitch valueKind {\n\n\t// Already a string, no conversion required\n\tcase reflect.String:\n\t\tv, err = valueText, nil\n\n\t// Convert boolean text\n\tcase reflect.Bool:\n\t\tv, err = strconv.ParseBool(valueText)\n\n\t// Convert signed integer text\n\tcase reflect.Int:\n\t\tintValue, err = strconv.ParseInt(valueText, 0, 64)\n\t\tv = int(intValue)\n\tcase reflect.Int8:\n\t\tintValue, err = strconv.ParseInt(valueText, 0, 8)\n\t\tv = int8(intValue)\n\tcase reflect.Int16:\n\t\tintValue, err = strconv.ParseInt(valueText, 0, 16)\n\t\tv = int16(intValue)\n\tcase reflect.Int32:\n\t\tintValue, err = strconv.ParseInt(valueText, 0, 32)\n\t\tv = int32(intValue)\n\tcase reflect.Int64:\n\t\tintValue, err = strconv.ParseInt(valueText, 0, 64)\n\t\tv = int64(intValue)\n\n\t// Convert unsigned integer text\n\tcase reflect.Uint:\n\t\tuintValue, err = strconv.ParseUint(valueText, 0, 64)\n\t\tv = uint(uintValue)\n\tcase reflect.Uint8:\n\t\tuintValue, err = strconv.ParseUint(valueText, 0, 8)\n\t\tv = uint8(uintValue)\n\tcase reflect.Uint16:\n\t\tuintValue, err = strconv.ParseUint(valueText, 0, 16)\n\t\tv = uint16(uintValue)\n\tcase reflect.Uint32:\n\t\tuintValue, err = strconv.ParseUint(valueText, 0, 32)\n\t\tv = uint32(uintValue)\n\tcase reflect.Uint64:\n\t\tuintValue, err = strconv.ParseUint(valueText, 0, 64)\n\t\tv = uint64(uintValue)\n\n\t// Convert float text\n\tcase reflect.Float32:\n\t\tfloatValue, err = strconv.ParseFloat(valueText, 32)\n\t\tv = float32(floatValue)\n\tcase reflect.Float64:\n\t\tfloatValue, err = strconv.ParseFloat(valueText, 32)\n\t\tv = float64(floatValue)\n\n\t// Unsupported data type\n\tdefault:\n\t\terr = windows.ERROR_INVALID_PARAMETER\n\t}\n\n\t// Log an error if an unsupported input type was passed in\n\tif err != nil {\n\t\tlog.Errorf(\"Unsupported stringToObject input values, valueText=%v, valueKind=%v\", valueText, valueKind)\n\t}\n\n\treturn v, err\n}", "title": "" }, { "docid": "ee0b31fd1c07255e200c117de2ead84b", "score": "0.4180269", "text": "func StrToValue(str string, field reflect.Value) (err error) {\n\t// empty string means nil point\n\tif field.Kind() == reflect.Ptr && str == \"\" {\n\t\tfield.Set(reflect.Zero(field.Type()))\n\t\treturn nil\n\t}\n\n\tv := AllocIndirect(field)\n\tswitch v.Kind() {\n\tcase reflect.Int:\n\t\terr = setIntField(str, 0, v)\n\tcase reflect.Int8:\n\t\terr = setIntField(str, 8, v)\n\tcase reflect.Int16:\n\t\terr = setIntField(str, 16, v)\n\tcase reflect.Int32:\n\t\terr = setIntField(str, 32, v)\n\tcase reflect.Int64:\n\t\terr = setIntField(str, 64, v)\n\tcase reflect.Uint:\n\t\terr = setUintField(str, 0, v)\n\tcase reflect.Uint8:\n\t\terr = setUintField(str, 8, v)\n\tcase reflect.Uint16:\n\t\terr = setUintField(str, 16, v)\n\tcase reflect.Uint32:\n\t\terr = setUintField(str, 32, v)\n\tcase reflect.Uint64:\n\t\terr = setUintField(str, 64, v)\n\tcase reflect.Bool:\n\t\terr = setBoolField(str, v)\n\tcase reflect.Float32:\n\t\terr = setFloatField(str, 32, v)\n\tcase reflect.Float64:\n\t\terr = setFloatField(str, 64, v)\n\tcase reflect.String:\n\t\tv.SetString(str)\n\tdefault:\n\t\treturn errors.New(\"reflectx: unexpected type for StrToValue: \" + field.Type().String())\n\t}\n\n\tif err != nil {\n\t\treturn errors.New(\"reflectx: \" + err.Error())\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "5812b1e9373f93951c871c603e6af831", "score": "0.41782266", "text": "func (v Value) Convert(t Type) Value {\n\treturn value_Convert(v, t)\n}", "title": "" }, { "docid": "bd101f21664c7061a2b0c78cb36e3368", "score": "0.4175189", "text": "func UnmarshalNullableString(v interface{}) (null.String, error) {\n\tif v == nil {\n\t\treturn null.String{Valid: false}, nil\n\t}\n\t// again you can delegate to the default implementation to save yourself some work.\n\ts, err := graphql.UnmarshalString(v)\n\treturn null.String{String: s}, err\n}", "title": "" }, { "docid": "dec702db68c6913c98f089763cce0cbf", "score": "0.4173255", "text": "func nullString(candidate sql.NullString) string {\n\n\tif candidate.Valid == false {\n\t\treturn candidate.String\n\t}\n\n\treturn \"\"\n}", "title": "" }, { "docid": "5b4b5e04c8d4e3d4109a5b96c8e0af72", "score": "0.41662753", "text": "func (d *decoder) decodeDefault() string {\n\treturn d.decodeChars(isDefault)\n}", "title": "" }, { "docid": "6adcfe3d5c55f68ad5f6c5ab042916cf", "score": "0.41599953", "text": "func (e *Entry2dStr) Convert() Entry2d {\n x, _ := strconv.Atof64(e.ValueX)\n y, _ := strconv.Atof64(e.ValueY)\n return Entry2d{x, y}\n}", "title": "" }, { "docid": "a03acb468d4b35fa872107a261dc4331", "score": "0.41501486", "text": "func (ptc *PropertyTypeCreate) SetNillableStringVal(s *string) *PropertyTypeCreate {\n\tif s != nil {\n\t\tptc.SetStringVal(*s)\n\t}\n\treturn ptc\n}", "title": "" }, { "docid": "89dfef993a94b1f00e04b69832d36933", "score": "0.41492668", "text": "func NewNullableStringFromJSONRawMessage(json json.RawMessage) sql.NullString {\n\tnullString := sql.NullString{}\n\tif json != nil && string(json) != \"null\" {\n\t\tnullString.String = string(json)\n\t\tnullString.Valid = true\n\t}\n\treturn nullString\n}", "title": "" }, { "docid": "a877d7724ec44e28df1d8a4134cd4f26", "score": "0.41488475", "text": "func TryToConvert(src, dstPtr, param interface{}) error {\n\tif reflect.TypeOf(dstPtr).Kind() == reflect.Ptr {\n\t\tdstVal := reflect.ValueOf(dstPtr).Elem()\n\t\tsrcStrOrig := fmt.Sprint(src)\n\t\tsrcStr := strings.Trim(srcStrOrig, ` \"'`)\n\t\tvar err error\n\t\tswitch dstVal.Kind() {\n\t\tcase reflect.Bool:\n\t\t\tfalsesTrues := [...]string{\n\t\t\t\t\"false\", \"off\", \"no\", \"0\", \"-\",\n\t\t\t\t\"true\", \"on\", \"yes\", \"1\", \"+\"}\n\t\t\tsrcStr = strings.ToLower(srcStr)\n\t\t\tfor i, s := range falsesTrues {\n\t\t\t\tif srcStr == s {\n\t\t\t\t\tdstVal.SetBool(i >= (len(falsesTrues) >> 1))\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t}\n\t\t\terr = fmt.Errorf(`parsing \"%s\": invalid syntax`, srcStrOrig)\n\t\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\t\tbase := GetBaseOfIntString(srcStr)\n\t\t\tswitch base {\n\t\t\tcase 16:\n\t\t\t\tsrcStr = strings.TrimPrefix(srcStr, \"0x\")\n\t\t\t\tsrcStr = strings.TrimSuffix(srcStr, \"h\")\n\t\t\tcase 2:\n\t\t\t\tsrcStr = strings.TrimSuffix(srcStr, \"b\")\n\t\t\t}\n\t\t\tif v, e := strconv.ParseInt(srcStr, base, int(dstVal.Type().Size())*8); e == nil {\n\t\t\t\tdstVal.SetInt(v)\n\t\t\t} else {\n\t\t\t\terr = e\n\t\t\t}\n\t\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:\n\t\t\tbase := GetBaseOfIntString(srcStr)\n\t\t\tswitch base {\n\t\t\tcase 16:\n\t\t\t\tsrcStr = strings.TrimPrefix(srcStr, \"0x\")\n\t\t\t\tsrcStr = strings.TrimSuffix(srcStr, \"h\")\n\t\t\tcase 2:\n\t\t\t\tsrcStr = strings.TrimSuffix(srcStr, \"b\")\n\t\t\t}\n\t\t\tif v, e := strconv.ParseUint(srcStr, base, int(dstVal.Type().Size())*8); e == nil {\n\t\t\t\tdstVal.SetUint(v)\n\t\t\t} else {\n\t\t\t\terr = e\n\t\t\t}\n\t\tcase reflect.Float32:\n\t\t\tif v, e := strconv.ParseFloat(srcStr, 32); e == nil {\n\t\t\t\tdstVal.SetFloat(v)\n\t\t\t} else {\n\t\t\t\terr = e\n\t\t\t}\n\t\tcase reflect.Float64:\n\t\t\tif v, e := strconv.ParseFloat(srcStr, 64); e == nil {\n\t\t\t\tdstVal.SetFloat(v)\n\t\t\t} else {\n\t\t\t\terr = e\n\t\t\t}\n\t\tcase reflect.String:\n\t\t\tdstVal.SetString(srcStrOrig)\n\t\tdefault:\n\t\t\tif dstVal.Type().String() == \"time.Time\" {\n\t\t\t\tvar t time.Time\n\t\t\t\tvar e error\n\t\t\t\tok := false\n\t\t\t\ttimeLayouts := []string{\n\t\t\t\t\ttime.ANSIC, time.UnixDate, time.RubyDate, time.RFC822, time.RFC822Z,\n\t\t\t\t\ttime.RFC850, time.RFC1123, time.RFC1123Z, time.RFC3339, time.Kitchen,\n\t\t\t\t\t\"2006-01-02 15:04:05\", \"02.01.2006 15:04:05\", \"15:04:05 02.01.2006\",\n\t\t\t\t\t\"2006-01-02 15:04:05 MST\", \"2006-01-02 15:04:05 -0700\",\n\t\t\t\t\t\"2006-01-02 15:04:05 -0700 MST\"}\n\t\t\t\tif param != nil {\n\t\t\t\t\ttimeLayouts = append(timeLayouts, fmt.Sprint(param))\n\t\t\t\t}\n\t\t\t\tfor _, layout := range timeLayouts {\n\t\t\t\t\tif t, e = time.Parse(layout, srcStrOrig); e == nil {\n\t\t\t\t\t\tok = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif !ok {\n\t\t\t\t\tvar unixTime int64\n\t\t\t\t\tvar unixTimeF float64\n\t\t\t\t\tif unixTime, e = strconv.ParseInt(srcStr, 10, 64); e == nil { // Unix time?\n\t\t\t\t\t\tt = time.Unix(unixTime, 0)\n\t\t\t\t\t\tok = true\n\t\t\t\t\t} else if unixTimeF, e = strconv.ParseFloat(srcStr, 64); e == nil {\n\t\t\t\t\t\tt = time.Unix(int64(unixTimeF), 0)\n\t\t\t\t\t\tok = true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ok {\n\t\t\t\t\tdstVal.Set(reflect.ValueOf(t))\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\terr = fmt.Errorf(`parsing \"%s\": unknown format`, srcStrOrig)\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"Target type '%s' is not supported\", dstVal.Type())\n\t\t\t}\n\t\t}\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Can't convert type '%v' to '%v': %s\", reflect.TypeOf(src), dstVal.Type(), err.Error())\n\t\t}\n\t\treturn nil\n\t}\n\treturn errors.New(\"'dstPtr' is not pointer\")\n}", "title": "" }, { "docid": "3d81617dc537501016025e40744c04ea", "score": "0.41472468", "text": "func (f *DefaultPropertyFactory) FromText(ctx context.Context, name string, value string, options ...interface{}) (Property, bool, error) {\n\tif flag, err := strconv.ParseBool(value); err == nil {\n\t\treturn f.FromAny(ctx, name, flag, options...)\n\t}\n\n\tif dateTime, err := dateparse.ParseAny(value); err == nil {\n\t\treturn f.FromAny(ctx, name, dateTime, options...)\n\t}\n\n\tif number, err := strconv.ParseInt(value, 10, 64); err == nil {\n\t\treturn f.FromAny(ctx, name, number, options...)\n\t}\n\n\treturn f.FromAny(ctx, name, value, options...)\n}", "title": "" }, { "docid": "f16d249ea8feb59b8c5533e3a28ddfeb", "score": "0.41420096", "text": "func ProtoToNullType(outfile *protogen.GeneratedFile, field *protogen.Field) (string, error) {\n\treturn generator_sql.ProtoToNullType(outfile, field)\n}", "title": "" }, { "docid": "000d7757aa960ab2f5f0eadfe1325de7", "score": "0.41402394", "text": "func (ftc *FieldTypeCreate) SetNillableStringScanner(ss *schema.StringScanner) *FieldTypeCreate {\n\tif ss != nil {\n\t\tftc.SetStringScanner(*ss)\n\t}\n\treturn ftc\n}", "title": "" }, { "docid": "ac31dc24707c7349b5e479e37f7a4cdb", "score": "0.41392487", "text": "func NoConverterForArgumentNumber(argumentType string) string {\n\treturn Exceptionf(\"NO_CONVERTER_FOR_ARGUMENT_NUMBER %v\", argumentType)\n}", "title": "" }, { "docid": "e09a0df53de326b5da0579a12ec6dba6", "score": "0.41359273", "text": "func NoOpTransformer(source string, infra *configv1.Infrastructure, network *configv1.Network) (string, error) {\n\treturn source, nil\n}", "title": "" }, { "docid": "19332a4a24f8b6d87be351880ff4af42", "score": "0.41321912", "text": "func NewConverter(csvInput *os.File, jsonOutput *os.File) *Converter {\n\tconverter := &Converter{\n\t\tinput: csvInput,\n\t\toutput: jsonOutput,\n\t}\n\treturn converter\n}", "title": "" }, { "docid": "d494834ab5ade6645cc221507963ccca", "score": "0.41306514", "text": "func (au *ActivityUpdate) SetNillableNewValue(s *string) *ActivityUpdate {\n\tif s != nil {\n\t\tau.SetNewValue(*s)\n\t}\n\treturn au\n}", "title": "" }, { "docid": "2d2e3c4934447bb129784deba698c7d7", "score": "0.41295487", "text": "func StringValue(stringValue sql.NullString) string {\r\n\tif stringValue.Valid {\r\n\t\treturn stringValue.String\r\n\t}\r\n\treturn \"\"\r\n}", "title": "" } ]
fa0bca73a83db526e1b917e2449b54f4
WithContext adds the context to the get log drains log drain ID ephemeral containers params
[ { "docid": "9bd506f726427fd1829d5cecf3077746", "score": "0.65753305", "text": "func (o *GetLogDrainsLogDrainIDEphemeralContainersParams) WithContext(ctx context.Context) *GetLogDrainsLogDrainIDEphemeralContainersParams {\n\to.SetContext(ctx)\n\treturn o\n}", "title": "" } ]
[ { "docid": "f5ab7549b49718d9d4b6505cdb45b638", "score": "0.526704", "text": "func (o *GetLogDrainsLogDrainIDEphemeralContainersParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "title": "" }, { "docid": "063911e93a5cc17f3303b9a0cafe7da1", "score": "0.4985165", "text": "func (o *GetLogDrainsLogDrainIDEphemeralContainersParams) WithHTTPClient(client *http.Client) *GetLogDrainsLogDrainIDEphemeralContainersParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "title": "" }, { "docid": "7251aef6c1658205f3d1e32c2344ec1a", "score": "0.49799612", "text": "func (o *PutLogDrainsIDParams) WithContext(ctx context.Context) *PutLogDrainsIDParams {\n\to.SetContext(ctx)\n\treturn o\n}", "title": "" }, { "docid": "33e822d5833513a0d6974054ef6b0736", "score": "0.49023694", "text": "func NewGetLogDrainsLogDrainIDEphemeralContainersParamsWithHTTPClient(client *http.Client) *GetLogDrainsLogDrainIDEphemeralContainersParams {\n\tvar ()\n\treturn &GetLogDrainsLogDrainIDEphemeralContainersParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "ef1b6a43f01fa0310961e8daa5c03127", "score": "0.49021205", "text": "func DebugWithContext(\n\tctx types.Context,\n\tt *testing.T,\n\tdriverName string,\n\tconfig []byte,\n\ttests ...APITestFunc) {\n\n\trun(ctx, t, types.IntegrationClient, nil,\n\t\tdriverName, config, true, false, tests...)\n}", "title": "" }, { "docid": "1f2da6aead14459c15e40410904ed2bd", "score": "0.4889716", "text": "func DebugGroupWithContext(\n\tctx types.Context,\n\tt *testing.T,\n\tdriverName string,\n\tconfig []byte,\n\ttests ...APITestFunc) {\n\n\trun(\n\t\tctx, t, types.IntegrationClient, nil,\n\t\tdriverName, config, true, true, tests...)\n}", "title": "" }, { "docid": "83ecd12f753f962f4f5c9090f06aacb1", "score": "0.48877865", "text": "func (o *GetLogDrainsLogDrainIDEphemeralContainersParams) WithTimeout(timeout time.Duration) *GetLogDrainsLogDrainIDEphemeralContainersParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "title": "" }, { "docid": "ef49a9884dbec02ea46b1e600acfc86d", "score": "0.48539424", "text": "func NewGetLogDrainsLogDrainIDEphemeralContainersParams() *GetLogDrainsLogDrainIDEphemeralContainersParams {\n\tvar ()\n\treturn &GetLogDrainsLogDrainIDEphemeralContainersParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "title": "" }, { "docid": "b25503306454009617924d1116248c9b", "score": "0.48103917", "text": "func (obj *Sys) AddServantWithContext(imp impSysWithContext, objStr string) {\n\ttars.AddServantWithContext(obj, imp, objStr)\n}", "title": "" }, { "docid": "8e5551002f28fc717e6a99d36d3f6142", "score": "0.47835502", "text": "func (l *logger) PanicWithContext(ctx context.Context, log string, fields ...zapcore.Field) {\n\tl.PanicWithSpan(opentracing.SpanFromContext(ctx), log, fields...)\n}", "title": "" }, { "docid": "9f21d24b45a666449802f5c66b349e62", "score": "0.4763193", "text": "func LogContextWith(parent context.Context, adder ContextAdder) context.Context {\n\treturn context.WithValue(parent, adder.getContextKey(), adder)\n}", "title": "" }, { "docid": "cdb08aa4284c379f74676e12916a0901", "score": "0.4737701", "text": "func (_obj *HelloWorld) AddServantWithContext(imp _impHelloWorldWithContext, obj string) {\n\ttars.AddServantWithContext(_obj, imp, obj)\n}", "title": "" }, { "docid": "ac59fa32a6d6f853262200303e12d26d", "score": "0.4702403", "text": "func populateContextWithLogInfo(ctx context.Context, command *pb.Command) context.Context {\n\tvar key logKey\n\n\t// TODO: get the server name from an environment variable\n\trawLog := pb.Log{\n\t\tTransactionNum: command.TransactionId,\n\t\tUsername: command.UserId,\n\t\tServerName: \"Beaver_1\",\n\t\tCommand: command.Name,\n\t}\n\tkey = \"log\"\n\tctx = context.WithValue(ctx, key, rawLog)\n\treturn ctx\n}", "title": "" }, { "docid": "a48c911bb53daad0485dbd4cf892e2f1", "score": "0.46960953", "text": "func handlerWithContext(ctx context.Context, handler func(context.Context, http.ResponseWriter, *http.Request)) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tctx := context.WithRequest(ctx, r)\n\t\tlogger := context.GetRequestLogger(ctx)\n\t\tctx = context.WithLogger(ctx, logger)\n\n\t\thandler(ctx, w, r)\n\t})\n}", "title": "" }, { "docid": "fc3b91d053cbbfa67fe17bc6390d99c7", "score": "0.4683551", "text": "func (c *Client) EventLogsContext(ctx context.Context, options EventLogOptions) ([]EventLog, error) {\n\treturn c.eventLogs(ctx, options)\n}", "title": "" }, { "docid": "4f3090f0d575380ba8b580c30a3df82d", "score": "0.4645822", "text": "func (_obj *SayHello) AddServantWithContext(imp _impSayHelloWithContext, obj string) {\n\ttars.AddServantWithContext(_obj, imp, obj)\n}", "title": "" }, { "docid": "6e3159edaf1d8d6bc65d39b59c9a6a37", "score": "0.46324372", "text": "func (l *logger) InfoWithContext(ctx context.Context, log string, fields ...zapcore.Field) {\n\tl.InfoWithSpan(opentracing.SpanFromContext(ctx), log, fields...)\n}", "title": "" }, { "docid": "386a4c28c7aff438206f3252b88848fc", "score": "0.46093875", "text": "func (l *logger) DebugWithContext(ctx context.Context, log string, fields ...zapcore.Field) {\n\tl.DebugWithSpan(opentracing.SpanFromContext(ctx), log, fields...)\n}", "title": "" }, { "docid": "2f30173a903029f62ecb05ea4028d333", "score": "0.45921472", "text": "func (o *GetLogDrainsLogDrainIDEphemeralContainersParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param log_drain_id\n\tif err := r.SetPathParam(\"log_drain_id\", swag.FormatInt64(o.LogDrainID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Page != nil {\n\n\t\t// query param page\n\t\tvar qrPage int64\n\t\tif o.Page != nil {\n\t\t\tqrPage = *o.Page\n\t\t}\n\t\tqPage := swag.FormatInt64(qrPage)\n\t\tif qPage != \"\" {\n\t\t\tif err := r.SetQueryParam(\"page\", qPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "4c0342418a598d1d9904592642ba0c11", "score": "0.45736116", "text": "func (l *logger) DPanicWithContext(ctx context.Context, log string, fields ...zapcore.Field) {\n\tl.DPanicWithSpan(opentracing.SpanFromContext(ctx), log, fields...)\n}", "title": "" }, { "docid": "65b458f0a12c14fafbd933acf9752824", "score": "0.4517504", "text": "func (o *GetLogDrainsLogDrainIDEphemeralContainersParams) WithLogDrainID(logDrainID int64) *GetLogDrainsLogDrainIDEphemeralContainersParams {\n\to.SetLogDrainID(logDrainID)\n\treturn o\n}", "title": "" }, { "docid": "2df83971b8da14471deed368f13d033f", "score": "0.45041373", "text": "func messageWithContext(ctx context.Context, args ...interface{}) interface{} {\n\tif ctx.Value(constants.Provider) != nil {\n\t\targs = append([]interface{}{ctx.Value(constants.Provider)}, args...)\n\t}\n\tif ctx.Value(constants.RequestID) != nil {\n\t\targs = append([]interface{}{ctx.Value(constants.RequestID)}, args...)\n\t}\n\treturn args\n}", "title": "" }, { "docid": "f4117e0247001d3a921aff27f98c7de3", "score": "0.44321045", "text": "func WithContext(ctx context.Context, log *Logger) context.Context {\n\treturn context.WithValue(ctx, loggerContextKey, log)\n}", "title": "" }, { "docid": "b4ff17a3dc0817683e924b19434201ba", "score": "0.44221216", "text": "func GetLogger(ctx context.Context) (context.Context, *logrus.Entry) {\n\tvar rid string\n\tfields := logrus.Fields{}\n\tif ctx == nil {\n\t\treturn ctx, utils.GetLogger().WithFields(fields)\n\t}\n\n\theaders, ok := metadata.FromIncomingContext(ctx)\n\tif ok {\n\t\treqid, ok := headers[csictx.RequestIDKey]\n\t\tif ok && len(reqid) > 0 {\n\t\t\trid = reqid[0]\n\t\t}\n\t}\n\n\tfields, _ = ctx.Value(utils.LogFields).(logrus.Fields)\n\tif fields == nil {\n\t\tfields = logrus.Fields{}\n\t}\n\n\tif ok {\n\t\tfields[utils.RequestID] = rid\n\t}\n\n\tlogMutex.Lock()\n\tdefer logMutex.Unlock()\n\tl := utils.GetLogger()\n\tlogWithFields := l.WithFields(fields)\n\tctx = context.WithValue(ctx, utils.PowerScaleLogger, logWithFields)\n\tctx = context.WithValue(ctx, utils.LogFields, fields)\n\treturn ctx, logWithFields\n}", "title": "" }, { "docid": "b2b5367a14629de9d8b4652ee2f116aa", "score": "0.44177854", "text": "func Context(ctx context.Context, log Logger) context.Context {\n\tl, ok := log.(*logger)\n\tif ok {\n\t\tl.Logger.WithOptions(zap.AddCallerSkip(1))\n\t}\n\treturn context.WithValue(ctx, contextKeyLogger, log)\n}", "title": "" }, { "docid": "c1f8dc15b178017944fb912bd8e43395", "score": "0.44144684", "text": "func (o *GetRetentionTaskLogParams) WithContext(ctx context.Context) *GetRetentionTaskLogParams {\n\to.SetContext(ctx)\n\treturn o\n}", "title": "" }, { "docid": "9fe6b282454d859debef692695c06948", "score": "0.4408387", "text": "func (o *GetReplicationLogParams) WithContext(ctx context.Context) *GetReplicationLogParams {\n\to.SetContext(ctx)\n\treturn o\n}", "title": "" }, { "docid": "3b5aeb0d2eda5efb4f4ccf08854e3251", "score": "0.44072846", "text": "func NewGetLogDrainsLogDrainIDEphemeralContainersParamsWithTimeout(timeout time.Duration) *GetLogDrainsLogDrainIDEphemeralContainersParams {\n\tvar ()\n\treturn &GetLogDrainsLogDrainIDEphemeralContainersParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "title": "" }, { "docid": "bb09da9d0c3e7124d56ca25889169889", "score": "0.43913287", "text": "func (l *suplogger) WithContext(ctx context.Context) Logger {\n\tl.initOnce()\n\toutCopy := l.copy()\n\toutCopy.entry = l.entry.WithContext(ctx)\n\n\treturn outCopy\n}", "title": "" }, { "docid": "6a61d868fd624cdcfe48329255c564e4", "score": "0.43848813", "text": "func newContextForHandleRequestIDChain(ctx *gin.Context, keys ...interface{}) {\n\trequestIDs, ok := fromGinContext(ctx)\n\tif !ok || len(requestIDs) == 0 {\n\t\tappendInOutMetadata(ctx, newRequestIDChain(ctx, keys...)...)\n\t\treturn\n\t}\n\trequestIDs = append(requestIDs, uuid.New().String())\n\tappendInOutMetadata(ctx, requestIDs...)\n\treturn\n}", "title": "" }, { "docid": "4cf9744bcd57533253433887e95ee4d4", "score": "0.4376232", "text": "func With() zerolog.Context {\n\treturn Logger.With()\n}", "title": "" }, { "docid": "c201be12a81e8a7311e09104685132bf", "score": "0.43754718", "text": "func (m *MockService) LogEventWithContext(ctx context.Context, args *events.LogEventArgs) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"LogEventWithContext\", ctx, args)\n}", "title": "" }, { "docid": "b4e3e3ff6c10331b88c649e527a096ad", "score": "0.4357671", "text": "func WithContext(ctx context.Context, instrumentOpts instrument.Options) *zap.Logger {\n\tif ctx == nil {\n\t\treturn instrumentOpts.Logger()\n\t}\n\tif ctxLogger, ok := ctx.Value(loggerKey).(*zap.Logger); ok {\n\t\treturn ctxLogger\n\t}\n\n\treturn instrumentOpts.Logger()\n}", "title": "" }, { "docid": "4a89828aaf4b0f405f1dcb594ff79a9e", "score": "0.435421", "text": "func NewGetLogDrainsLogDrainIDEphemeralContainersParamsWithContext(ctx context.Context) *GetLogDrainsLogDrainIDEphemeralContainersParams {\n\tvar ()\n\treturn &GetLogDrainsLogDrainIDEphemeralContainersParams{\n\n\t\tContext: ctx,\n\t}\n}", "title": "" }, { "docid": "fdbb34820ab4e480e7485bd1f71586d0", "score": "0.4339844", "text": "func WithContext(ctx context.Context, logger *logrus.Entry) context.Context {\n\treturn context.WithValue(ctx, loggerKey{}, logger)\n}", "title": "" }, { "docid": "aee12bfa93efa13fd168f35188e970a1", "score": "0.4323994", "text": "func WithContext(ctx context.Context, log Logger) context.Context {\n\treturn context.WithValue(ctx, loggerKey{}, log)\n}", "title": "" }, { "docid": "7558c824361f5cd73787a40ac23a0266", "score": "0.43216756", "text": "func getLogCtx(ctx context.Context) LogContext {\n\tparentLogCtx, ok := ctx.Value(requestContextKey).(*LogContext)\n\tif !ok {\n\t\treturn LogContext{}\n\t}\n\treturn parentLogCtx.getCopy()\n}", "title": "" }, { "docid": "f3e2b91d3294928e733aa52c9f875db8", "score": "0.42804664", "text": "func ConfigWithContext(ctx context.Context, config interface{}) context.Context {\n\treturn context.WithValue(ctx, configKey{}, config)\n}", "title": "" }, { "docid": "1aaf5144636cbcfb38e7901ccaa11ca3", "score": "0.42684695", "text": "func withProbeEventLoggingContext(ctx context.Context, event cloudevents.Event) context.Context {\n\tlogger := logging.FromContext(ctx)\n\tlogger = logger.With(zap.Any(\"event\", map[string]interface{}{\n\t\t\"id\": event.ID(),\n\t\t\"source\": event.Source(),\n\t\t\"specversion\": event.SpecVersion(),\n\t\t\"type\": event.Type(),\n\t\t\"extensions\": event.Extensions(),\n\t}))\n\treturn logging.WithLogger(ctx, logger)\n}", "title": "" }, { "docid": "780ca2e9b263b120f9589829ebe2371a", "score": "0.42671832", "text": "func (l *logger) FatalWithContext(ctx context.Context, log string, fields ...zapcore.Field) {\n\tl.FatalWithSpan(opentracing.SpanFromContext(ctx), log, fields...)\n}", "title": "" }, { "docid": "3c2546237dddf1d8ad5e0470af0a3683", "score": "0.4252209", "text": "func (svc namespace) log(ctx context.Context, fields ...zapcore.Field) *zap.Logger {\n\treturn logger.AddRequestID(ctx, svc.logger).With(fields...)\n}", "title": "" }, { "docid": "2a91cf43c7301a39eabddf21a37542d5", "score": "0.4250516", "text": "func With(ctx context.Context, key string, value interface{}) context.Context {\n\tlogger := logging.GetSDKRootLogger(ctx)\n\tif logger == nil {\n\t\t// this essentially should never happen in production the root\n\t\t// logger for code should be injected by the in\n\t\t// question, so really this is only likely in unit tests, at\n\t\t// most so just making this a no-op is fine\n\t\treturn ctx\n\t}\n\treturn logging.SetSDKRootLogger(ctx, logger.With(key, value))\n}", "title": "" }, { "docid": "faa32f43da5d686890d853787538740c", "score": "0.4247397", "text": "func (iter *SyncGroupLogListResultIterator) NextWithContext(ctx context.Context) (err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/SyncGroupLogListResultIterator.NextWithContext\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif iter.Response().Response.Response != nil {\n\t\t\t\tsc = iter.Response().Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\titer.i++\n\tif iter.i < len(iter.page.Values()) {\n\t\treturn nil\n\t}\n\terr = iter.page.NextWithContext(ctx)\n\tif err != nil {\n\t\titer.i--\n\t\treturn err\n\t}\n\titer.i = 0\n\treturn nil\n}", "title": "" }, { "docid": "7d67e11186a4a3ac39fecf24277f3360", "score": "0.42435926", "text": "func With(ctx context.Context, parent Logger) Logger {\n\tl, ok := parent.(log.Interface)\n\tif !ok {\n\t\treturn parent\n\t}\n\n\tval := ctx.Value(requestFieldsKey{})\n\tif val != nil {\n\t\tif fields, ok := val.(log.Fields); ok {\n\t\t\treturn l.WithFields(fields)\n\t\t}\n\t}\n\n\treturn l\n}", "title": "" }, { "docid": "0aa9449992765a3e10924d552a1e6dbf", "score": "0.42396402", "text": "func WithContext(enable bool) Option {\n\treturn WithConditionalContext(func(_ logger.Entry) bool {\n\t\treturn enable\n\t})\n}", "title": "" }, { "docid": "4f4460aad16402e74a45055fb3867306", "score": "0.42387807", "text": "func (l *logger) WarnWithContext(ctx context.Context, log string, fields ...zapcore.Field) {\n\tl.WarnWithSpan(opentracing.SpanFromContext(ctx), log, fields...)\n}", "title": "" }, { "docid": "dadf103dcac69d5ae584a92fca802b16", "score": "0.42357865", "text": "func requestWithLoggedContextValue(r *http.Request, contextKey interface{}, logKey string, value interface{}) *http.Request {\n\tctx := r.Context()\n\tctx = context.WithValue(ctx, contextKey, value)\n\tlog := jsonlog.LoggerFromContextOrDefault(ctx)\n\tlog = log.WithContext(ctx)\n\tlog = log.WithContextKey(contextKey, logKey)\n\tctx = jsonlog.ContextWithLogger(ctx, log)\n\treturn r.WithContext(ctx)\n}", "title": "" }, { "docid": "d98e79bf60453100af0e95003009a241", "score": "0.4234024", "text": "func NewAllDeviceLogsContext(ctx context.Context, r *http.Request, service *goa.Service) (*AllDeviceLogsContext, error) {\n\tvar err error\n\tresp := goa.ContextResponse(ctx)\n\tresp.Service = service\n\treq := goa.ContextRequest(ctx)\n\treq.Request = r\n\trctx := AllDeviceLogsContext{Context: ctx, ResponseData: resp, RequestData: req}\n\tparamDeviceID := req.Params[\"deviceId\"]\n\tif len(paramDeviceID) > 0 {\n\t\trawDeviceID := paramDeviceID[0]\n\t\trctx.DeviceID = rawDeviceID\n\t}\n\treturn &rctx, err\n}", "title": "" }, { "docid": "b5335ec72b957da7a6efae753a1824e9", "score": "0.42297453", "text": "func WithContext(context Message) Logger {\n\treturn globalLogger.WithContext(context)\n}", "title": "" }, { "docid": "9304222b4631600bb1bd85c2907c8927", "score": "0.42267329", "text": "func logOpts(restClientGetter genericclioptions.RESTClientGetter, pod *corev1.Pod, opts *attach.AttachOptions) error {\n\tctrName, err := opts.GetContainerName(pod)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\trequests, err := polymorphichelpers.LogsForObjectFn(restClientGetter, pod, &corev1.PodLogOptions{Container: ctrName}, opts.GetPodTimeout, false)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, request := range requests {\n\t\tif err := logs.DefaultConsumeRequest(request, opts.Out); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "9304222b4631600bb1bd85c2907c8927", "score": "0.42267329", "text": "func logOpts(restClientGetter genericclioptions.RESTClientGetter, pod *corev1.Pod, opts *attach.AttachOptions) error {\n\tctrName, err := opts.GetContainerName(pod)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\trequests, err := polymorphichelpers.LogsForObjectFn(restClientGetter, pod, &corev1.PodLogOptions{Container: ctrName}, opts.GetPodTimeout, false)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, request := range requests {\n\t\tif err := logs.DefaultConsumeRequest(request, opts.Out); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "a8313d69ace47e93388336b79e3f656e", "score": "0.42171246", "text": "func TestWithContext(t *testing.T) {\n\tctx := context.Background()\n\tctx = context.WithValue(ctx, \"key\", \"value\")\n\tlogger := DefaultLogger.WithContext(ctx)\n\tif logger.context != ctx {\n\t\tt.Error(\"Logger context was not set.\")\n\t}\n}", "title": "" }, { "docid": "5cf1ffa05973872929dad7c31877d987", "score": "0.42161492", "text": "func UseLogRecover(inner http.Handler, aParam int) http.Handler {\n\t// Possible stuff outside the closure\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tctx := context.WithValue(context.Background(), ctxKey(\"param\"), aParam)\n\t\tinner.ServeHTTP(w, r.WithContext(ctx))\n\t})\n}", "title": "" }, { "docid": "7dd32aa347bbc987bca81dec2f387b15", "score": "0.42132294", "text": "func DiscoverInstancesInServiceWithContext(ctx context.Context,\n\tnamespaceName string,\n\tserviceName string,\n\tattributes map[string]string,\n\tlogger *zerolog.Logger) ([]awsv2ServiceDiscoveryTypes.HttpInstanceSummary, error) {\n\n\t// Great, lookup the instances...\n\tqueryParams := make(map[string]string)\n\tfor eachKey, eachValue := range attributes {\n\t\tqueryParams[eachKey] = eachValue\n\t}\n\n\tawsConfig, awsConfigErr := spartaAWS.NewConfig(ctx, logger)\n\tif awsConfigErr != nil {\n\t\treturn nil, awsConfigErr\n\t}\n\tcloudmapSvc := awsv2ServiceDiscovery.NewFromConfig(awsConfig)\n\tlookupParams := &awsv2ServiceDiscovery.DiscoverInstancesInput{\n\t\tNamespaceName: awsv2.String(namespaceName),\n\t\tServiceName: awsv2.String(serviceName),\n\t\tQueryParameters: queryParams,\n\t}\n\tresults, resultsErr := cloudmapSvc.DiscoverInstances(ctx, lookupParams)\n\tif resultsErr != nil {\n\t\treturn nil, resultsErr\n\t}\n\n\treturn results.Instances, nil\n}", "title": "" }, { "docid": "2358c0e2a2b0aff26a0e610fcab9cc94", "score": "0.41988975", "text": "func (m *MockEventBridgeAPI) ListApiDestinationsWithContext(arg0 context.Context, arg1 *eventbridge.ListApiDestinationsInput, arg2 ...request.Option) (*eventbridge.ListApiDestinationsOutput, error) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"ListApiDestinationsWithContext\", varargs...)\n\tret0, _ := ret[0].(*eventbridge.ListApiDestinationsOutput)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "83af2d69501e4d4d064efc5252372136", "score": "0.41917548", "text": "func (r *containerReconciler) dockerAPIQueryContext() (context.Context, context.CancelFunc) {\n\t// use a reasoanble floor to avoid very small limit\n\ttimeout := 30 * time.Second\n\n\tif timeout < r.config.period {\n\t\ttimeout = r.config.period\n\t}\n\n\treturn context.WithTimeout(context.Background(), timeout)\n}", "title": "" }, { "docid": "329ea15cc412955191217eeb04900b1e", "score": "0.4189743", "text": "func AddLoggerToContext() echo.MiddlewareFunc {\n\treturn func(next echo.HandlerFunc) echo.HandlerFunc {\n\t\treturn func(c echo.Context) error {\n\n\t\t\tlogger := log.WithFields(log.Fields{\n\t\t\t\t\"request_id\": c.Response().Header().Get(echo.HeaderXRequestID),\n\t\t\t})\n\t\t\tc.Set(\"logger\", logger)\n\t\t\treturn next(c)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "7e137cfa3a4c6b527696a54900dd8685", "score": "0.41853213", "text": "func TestLogWithContext(t *testing.T) {\n\tlog := newLog()\n\tlog.WithContext(context.WithValue(context.Background(), \"key\", \"value\"))\n\n\tvalue, ok := log.ctx.Value(\"key\").(string)\n\tif !ok || value != \"value\" {\n\t\tt.Errorf(\"!ok %v || value %s != 'value'\", ok, value)\n\t}\n}", "title": "" }, { "docid": "a655c1e78c149f5a315d5e1905448b38", "score": "0.4175122", "text": "func Wrap(ctx context.Context, l *Logger, fields ...zap.Field) *Logger {\n\tif v := ctx.Value(RequestID); v != nil {\n\t\tfields = append(fields, zap.String(\"requestId\", v.(string)))\n\t\treturn l.With(fields...)\n\t}\n\treturn l\n}", "title": "" }, { "docid": "070bbe2531d5b6fff014d28c210e5740", "score": "0.41636953", "text": "func WithContext(ctx context.Context) *zap.SugaredLogger {\n\tif ctx == nil {\n\t\treturn logger\n\t}\n\n\tif ctxLogger, ok := ctx.Value(loggerKey).(*zap.SugaredLogger); ok {\n\t\treturn ctxLogger\n\t}\n\n\treturn logger\n}", "title": "" }, { "docid": "7bae4d10a7ef3edb6c9448f131d49726", "score": "0.41483262", "text": "func (s *Scan) AllWithContext(ctx context.Context, out interface{}) error {\n\titr := &scanIter{\n\t\tscan: s,\n\t\tunmarshal: unmarshalAppend,\n\t\terr: s.err,\n\t}\n\tfor itr.NextWithContext(ctx, out) {\n\t}\n\treturn itr.Err()\n}", "title": "" }, { "docid": "cb13fa0952b9d6889e6e6088c9355a6f", "score": "0.414747", "text": "func (o *AddFoodsLogParams) WithContext(ctx context.Context) *AddFoodsLogParams {\n\to.SetContext(ctx)\n\treturn o\n}", "title": "" }, { "docid": "1f8105e8021730a454b915f9df47ee3c", "score": "0.41412938", "text": "func (s *BaseclfListener) EnterLog(ctx *LogContext) {}", "title": "" }, { "docid": "1176be0df66e4dd519a1596c485355e0", "score": "0.4139018", "text": "func OpenWithContext(cfg eventstore.Config, ctx context.Context) (*TempDB, error) {\n\ttdb, err := New()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlogger := lager.NewLogger(\"test\")\n\ts := eventstore.New(ctx, tdb.Conn, logger, cfg)\n\tif err := s.Init(); err != nil {\n\t\treturn nil, err\n\t}\n\tif err := s.Refresh(); err != nil {\n\t\treturn nil, err\n\t}\n\ttdb.Schema = s\n\tgo func() {\n\t\terr := tdb.monitor(ctx)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t}\n\t}()\n\treturn tdb, nil\n}", "title": "" }, { "docid": "182a4e3801bfc9aad8a2f660a5b1a930", "score": "0.41367713", "text": "func With(ctx context.Context, fields ...zap.Field) context.Context {\n\tlogger := getLogger(ctx).With(fields...)\n\treturn context.WithValue(ctx, contextKeyLogger, logger)\n}", "title": "" }, { "docid": "d1b380abe28bb4f1a7ff548245c68de2", "score": "0.4133183", "text": "func ContextWithLogger(ctx context.Context, entry *logrus.Entry) context.Context {\n\treturn context.WithValue(ctx, logKey{}, entry)\n}", "title": "" }, { "docid": "1c03cc417428bfd9f68b291b2beff71a", "score": "0.41314077", "text": "func (futureTask *FutureTask) getWithContext(ctx context.Context) Result{\n\tselect {\n\tcase <-ctx.Done():\n\t\tfutureTask.done = true\n\t\tfutureTask.result = Result{value: nil,error: errors.New(\"request timed out\")}\n\t\treturn futureTask.result\n\tcase futureTask.result = <-futureTask.channel:\n\t\tfutureTask.done = true\n\t\treturn futureTask.result\n\t}\n}", "title": "" }, { "docid": "69d09467f50b341da00a6d48fc45914c", "score": "0.41203576", "text": "func (o *GetLogsParams) WithContext(ctx context.Context) *GetLogsParams {\n\to.SetContext(ctx)\n\treturn o\n}", "title": "" }, { "docid": "91b24d4986cb815e3966f6868af631ca", "score": "0.41147107", "text": "func (l *logger) With(ctxs ...Ctx) Lager {\n\tkvp := l.kvp\n\tfor _, ctx := range ctxs {\n\t\tkvp = kvp.Merge(ContextPairs(ctx))\n\t}\n\tif kvp == l.kvp {\n\t\treturn l\n\t}\n\tcp := *l\n\tcp.kvp = kvp\n\treturn &cp\n}", "title": "" }, { "docid": "073ca7c581b49caa1ce0a3bb898d7c98", "score": "0.41006592", "text": "func LogContext(ctx context.Context) []KV {\n\tif ctx == nil {\n\t\treturn nil\n\t}\n\tdata := ctx.Value(logContextKey)\n\tif data == nil {\n\t\treturn nil\n\t}\n\treturn data.([]KV)\n}", "title": "" }, { "docid": "f8c6ced4e9917f0430d915aa58b071cd", "score": "0.4091787", "text": "func NewClientWithContextSwitch(devSpaceConfig *latest.Config, switchContext bool) (kubernetes.Interface, error) {\n\tconfig, err := loadClientConfig(devSpaceConfig, switchContext)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trestConfig, err := config.ClientConfig()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn kubernetes.NewForConfig(restConfig)\n}", "title": "" }, { "docid": "7128cb99f52c7d905fc829f489ba41e1", "score": "0.4091487", "text": "func (o *GetAirlinkProxyElevationParams) WithContext(ctx context.Context) *GetAirlinkProxyElevationParams {\n\to.SetContext(ctx)\n\treturn o\n}", "title": "" }, { "docid": "51036b6d7cc0645e2d54d40a58d3ec69", "score": "0.40880764", "text": "func GetCtxLogger(c *gin.Context) *logrus.Entry {\n\tl, ok := c.Get(\"ctxLogger\")\n\tif ok {\n\t\treturn l.(*logrus.Entry)\n\t}\n\tvar logger *logrus.Entry\n\tlog, found := c.Get(\"aggregate-logger\")\n\tif found {\n\t\tlogger = logrus.WithFields(logrus.Fields{})\n\t\tlogger.Logger = log.(*logrus.Logger)\n\t}\n\tif !found {\n\t\t// not aggregate logging, so make sure to add some needed fields\n\t\tlogger = logrus.WithFields(logrus.Fields{\n\t\t\t\"requestID\": CxtRequestID(c),\n\t\t\t\"method\": c.Request.Method,\n\t\t\t\"path\": c.Request.URL.Path,\n\t\t})\n\t}\n\tc.Set(\"ctxLogger\", logger)\n\treturn logger\n}", "title": "" }, { "docid": "7f963fce4ec328eaa43e4aee94272b61", "score": "0.40859285", "text": "func WrapBackgroundContextWithStackdriverLogger(c context.Context, logName string) (context.Context, func()) {\n\tif IsDevAppServer {\n\t\treturn c, func() {}\n\t}\n\n\taeInfo := NewAppengineInfoFromContext(c)\n\n\tproject := aeInfo.NativeProjectID()\n\tif project == \"\" {\n\t\tpanic(\"aelog: no GCP project set in environment\")\n\t}\n\tparent := \"projects/\" + project\n\tlc := GetOrCreateLoggingClient()\n\tif logName == \"\" {\n\t\tlogName = ChildLogName\n\t}\n\treq, err := http.NewRequest(http.MethodGet, \"pendo.io/background\", bytes.NewReader([]byte{}))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tlogger := getLogger(aeInfo, lc, logName)\n\tlogCtxVal := getLogCtxVal(aeInfo, req, logger, parent+\"/traces/\"+fmt.Sprintf(\"%d\", rand.Int63()))\n\n\tctx := context.WithValue(c, loggingCtxKey, logCtxVal)\n\treturn ctx, func() {\n\t\t_ = logger.Flush()\n\t}\n}", "title": "" }, { "docid": "d87aa390ccce50a7a6d595f3d3f91bfc", "score": "0.40674302", "text": "func Context() gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\t\tc.Set(log.KeyRequestID, c.GetString(XRequestIDKey))\n\t\tc.Set(log.KeyUsername, c.GetString(UsernameKey))\n\t\tc.Next()\n\t}\n}", "title": "" }, { "docid": "798b51374ff370049fb8d5688bdf964b", "score": "0.40635318", "text": "func WithLogger(ctx context.Context, l *zerolog.Logger) context.Context {\n\treturn l.WithContext(ctx)\n}", "title": "" }, { "docid": "d81e8c5c05d3cbe4a73b71b2105e66de", "score": "0.4060219", "text": "func FromContext(c context.Context) zap.Logger {\n\treturn c.Value(key).(zap.Logger)\n}", "title": "" }, { "docid": "70a3fdd980adc426256cfea74c79c2d4", "score": "0.4055375", "text": "func (mr *MockServiceMockRecorder) LogEventWithContext(ctx, args interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"LogEventWithContext\", reflect.TypeOf((*MockService)(nil).LogEventWithContext), ctx, args)\n}", "title": "" }, { "docid": "150c5f534fdff4533d9e5f09a77d8707", "score": "0.405501", "text": "func ContextLoggerForResource(log logr.Logger, obj client.Object) logr.Logger {\n\tgvk := obj.GetObjectKind().GroupVersionKind()\n\tname := obj.(metav1.ObjectMetaAccessor).GetObjectMeta().GetName()\n\tnamespace := obj.(metav1.ObjectMetaAccessor).GetObjectMeta().GetNamespace()\n\treturn log.WithValues(\"Name\", name, \"Namespace\", namespace, \"Kind\", gvk.Kind)\n}", "title": "" }, { "docid": "f64c688b4eeca51960af8f7e1382a95c", "score": "0.40538013", "text": "func ContextWithLog(ctx context.Context, log Logger) context.Context {\n\treturn context.WithValue(ctx, contextKeyLog, log)\n}", "title": "" }, { "docid": "4d0753951dab57a0c63f2b01db07f26d", "score": "0.40504265", "text": "func (a *Adapter) ProxyWithContext(\n\tctx context.Context,\n\tev events.APIGatewayProxyRequest,\n) (out events.APIGatewayProxyResponse, err error) {\n\treq, err := a.EventToRequest(ev)\n\tif err != nil {\n\t\treturn out, fmt.Errorf(\"failed to create request from event: %w\", err)\n\t}\n\n\trec := httptest.NewRecorder()\n\ta.h.ServeHTTP(rec, withContext(ctx, req, ev)) // call the implemention\n\treturn ProxyResponse(rec), nil\n}", "title": "" }, { "docid": "14a6005365c297573c085ec031970dec", "score": "0.4049177", "text": "func RunWithContext(\n\tctx types.Context,\n\tt *testing.T,\n\tdriverName string,\n\tconfig []byte,\n\ttests ...APITestFunc) {\n\n\trun(ctx, t, types.IntegrationClient, nil,\n\t\tdriverName, config, false, false, tests...)\n}", "title": "" }, { "docid": "8b06a40694c93cc8cf8d02269099f25e", "score": "0.40470177", "text": "func (page *SyncGroupLogListResultPage) NextWithContext(ctx context.Context) (err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/SyncGroupLogListResultPage.NextWithContext\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif page.Response().Response.Response != nil {\n\t\t\t\tsc = page.Response().Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tfor {\n\t\tnext, err := page.fn(ctx, page.sgllr)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tpage.sgllr = next\n\t\tif !next.hasNextLink() || !next.IsEmpty() {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "ea181753f2604099f3d257f16d8261f0", "score": "0.40392932", "text": "func (c *Client) ListWithContext(ctx context.Context, g Listable) (s []interface{}, err error) {\n\ts = make([]interface{}, 0)\n\n\tdefer func() {\n\t\tif e := recover(); e != nil {\n\t\t\tif g == nil || reflect.ValueOf(g).IsNil() {\n\t\t\t\terr = fmt.Errorf(\"g Listable shouldn't be nil, got %#v\", g)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tpanic(e)\n\t\t}\n\t}()\n\n\treq, e := g.ListRequest()\n\tif e != nil {\n\t\terr = e\n\t\treturn\n\t}\n\tc.PaginateWithContext(ctx, req, func(item interface{}, e error) bool {\n\t\tif item != nil {\n\t\t\ts = append(s, item)\n\t\t\treturn true\n\t\t}\n\t\terr = e\n\t\treturn false\n\t})\n\n\treturn\n}", "title": "" }, { "docid": "3fc98e24006e5bf0a1c67dbfca6f4f40", "score": "0.40385008", "text": "func Logs(ctx *cli.Context) error {\n\t// NOTE: Does not use region because Fargate supported region is only 'us-east-1'\n\t_, name := detectAppFromRepo()\n\tif ctx.String(\"app\") != \"\" {\n\t\tlogrus.Debug(\"Override application name: \" + ctx.String(\"app\"))\n\t\tname = ctx.String(\"app\")\n\t}\n\n\treturn processLogs(&logsContext{\n\t\tname: name,\n\t\tapp: ctx.App,\n\t\tclient: api.NewClient(&api.ClientOption{\n\t\t\tRegion: \"us-east-1\", // NOTE: Currently, Fargate supported region is only `us-east-1`\n\t\t}),\n\t\tnum: ctx.Int(\"num\"),\n\t\tps: ctx.String(\"ps\"),\n\t\tsource: ctx.String(\"source\"),\n\t\ttail: ctx.Bool(\"tail\"),\n\t})\n}", "title": "" }, { "docid": "70994bdd34d7c0a8d9a8c2ba00b35987", "score": "0.40353644", "text": "func (page *LoggerCollectionPage) NextWithContext(ctx context.Context) (err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/LoggerCollectionPage.NextWithContext\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif page.Response().Response.Response != nil {\n\t\t\t\tsc = page.Response().Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tnext, err := page.fn(ctx, page.lc)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.lc = next\n\treturn nil\n}", "title": "" }, { "docid": "78bdd6a84e2691c26eb2739d5ea05e3f", "score": "0.40347847", "text": "func generateClientIDWithContext() (context.Context, uuid.UUID) {\n\tclientID := uuid.NewV4()\n\treturn context.WithValue(\n\t\t\tcontext.Background(),\n\t\t\tclientIDContextKey,\n\t\t\tclientID),\n\t\tclientID\n}", "title": "" }, { "docid": "3e1f918097f08a07a4a44e9279704ff6", "score": "0.4034355", "text": "func WithContext(ctx context.Context, logger *zap.Logger) context.Context {\n\treturn context.WithValue(ctx, ctxKey{}, logger)\n}", "title": "" }, { "docid": "c4bc8797e6ce6d94fd4ce5c3d056fc85", "score": "0.40330943", "text": "func setLogFieldsInContext(ctx context.Context, logParam string, logType string) (context.Context, *logrus.Entry) {\n\tlogMutex.Lock()\n\tdefer logMutex.Unlock()\n\n\tfields := logrus.Fields{}\n\tfields, ok := ctx.Value(utils.LogFields).(logrus.Fields)\n\tif !ok {\n\t\tfields = logrus.Fields{}\n\t}\n\tif fields == nil {\n\t\tfields = logrus.Fields{}\n\t}\n\tfields[logType] = logParam\n\tulog, ok := ctx.Value(utils.PowerScaleLogger).(*logrus.Entry)\n\tif !ok {\n\t\tulog = utils.GetLogger().WithFields(fields)\n\t}\n\tulog = ulog.WithFields(fields)\n\tctx = context.WithValue(ctx, utils.PowerScaleLogger, ulog)\n\tctx = context.WithValue(ctx, utils.LogFields, fields)\n\treturn ctx, ulog\n}", "title": "" }, { "docid": "33fe03cf30dce0757999249b769a5c71", "score": "0.40305808", "text": "func (assistant *AssistantV2) ListLogsWithContext(ctx context.Context, listLogsOptions *ListLogsOptions) (result *LogCollection, response *core.DetailedResponse, err error) {\n\terr = core.ValidateNotNil(listLogsOptions, \"listLogsOptions cannot be nil\")\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.ValidateStruct(listLogsOptions, \"listLogsOptions\")\n\tif err != nil {\n\t\treturn\n\t}\n\n\tpathParamsMap := map[string]string{\n\t\t\"assistant_id\": *listLogsOptions.AssistantID,\n\t}\n\n\tbuilder := core.NewRequestBuilder(core.GET)\n\tbuilder = builder.WithContext(ctx)\n\tbuilder.EnableGzipCompression = assistant.GetEnableGzipCompression()\n\t_, err = builder.ResolveRequestURL(assistant.Service.Options.URL, `/v2/assistants/{assistant_id}/logs`, pathParamsMap)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tfor headerName, headerValue := range listLogsOptions.Headers {\n\t\tbuilder.AddHeader(headerName, headerValue)\n\t}\n\n\tsdkHeaders := common.GetSdkHeaders(\"conversation\", \"V2\", \"ListLogs\")\n\tfor headerName, headerValue := range sdkHeaders {\n\t\tbuilder.AddHeader(headerName, headerValue)\n\t}\n\tbuilder.AddHeader(\"Accept\", \"application/json\")\n\n\tbuilder.AddQuery(\"version\", fmt.Sprint(*assistant.Version))\n\tif listLogsOptions.Sort != nil {\n\t\tbuilder.AddQuery(\"sort\", fmt.Sprint(*listLogsOptions.Sort))\n\t}\n\tif listLogsOptions.Filter != nil {\n\t\tbuilder.AddQuery(\"filter\", fmt.Sprint(*listLogsOptions.Filter))\n\t}\n\tif listLogsOptions.PageLimit != nil {\n\t\tbuilder.AddQuery(\"page_limit\", fmt.Sprint(*listLogsOptions.PageLimit))\n\t}\n\tif listLogsOptions.Cursor != nil {\n\t\tbuilder.AddQuery(\"cursor\", fmt.Sprint(*listLogsOptions.Cursor))\n\t}\n\n\trequest, err := builder.Build()\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar rawResponse map[string]json.RawMessage\n\tresponse, err = assistant.Service.Request(request, &rawResponse)\n\tif err != nil {\n\t\treturn\n\t}\n\tif rawResponse != nil {\n\t\terr = core.UnmarshalModel(rawResponse, \"\", &result, UnmarshalLogCollection)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tresponse.Result = result\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "d731367e0a0cc608b198d90c0b576a12", "score": "0.40261927", "text": "func withSpanAndLogger(t tracedHandler) func(http.ResponseWriter, *http.Request) {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tspan, _ := tracer.SpanFromContext(r.Context())\n\t\ttraceID := span.Context().TraceID()\n\t\tspanID := span.Context().SpanID()\n\t\tentry := log.WithFields(log.Fields{\n\t\t\t\"dd.trace_id\": traceID,\n\t\t\t\"dd.span_id\": spanID,\n\t\t})\n\t\tt(span, entry, w, r)\n\t}\n}", "title": "" }, { "docid": "bfe17a430df49df3809b6b79a8227a67", "score": "0.40261143", "text": "func (logger *Logger) WithContext(ctx context.Context) *Entry {\n\tentry := logger.newEntry()\n\tdefer logger.releaseEntry(entry)\n\treturn entry.WithContext(ctx)\n}", "title": "" }, { "docid": "8278af9d28a1b55b162ffb1715d847e5", "score": "0.40250754", "text": "func (l *kitLogger) WithContext(pairs ...string) Logger {\n\tif (len(pairs) % 2) != 0 {\n\t\tpanic(\"invalid argument\")\n\t}\n\tr := kitLogger{logger: l.logger, config: l.config}\n\tfor i := 0; i < len(pairs); i = i + 2 {\n\t\tr.logger = kitlog.With(r.logger, pairs[i], pairs[i+1])\n\t}\n\treturn &r\n}", "title": "" }, { "docid": "a1d26c3c1c00cade320c4bd6a749724d", "score": "0.40186062", "text": "func LastResortHandlerWithContext(ctx context.Context, loc string) {\n\tif r := recover(); r != nil {\n\t\tlog.Printf(\"LastResort: panic=%v\", r)\n\t\texceptionEvent(ctx, fmt.Errorf(\"LastResort:%v, panic:%v\", loc, r))\n\t\t//If panicking, need to wait to be sure flush of events clears prior to program close\n\t\tif isEventing {\n\t\t\ttime.Sleep(flushDuration() + time.Duration(time.Second*1))\n\t\t}\n\t}\n}", "title": "" }, { "docid": "44f5ae481bfc1edab85a18033516f911", "score": "0.40140438", "text": "func withEventLogInternal(ctx context.Context, eventLog trace.EventLog) context.Context {\n\tif opentracing.SpanFromContext(ctx) != nil {\n\t\tpanic(\"event log under span\")\n\t}\n\treturn embedCtxEventLog(ctx, &ctxEventLog{eventLog: eventLog})\n}", "title": "" }, { "docid": "ced83e92a5bca6afc3d656960e4208d5", "score": "0.40102267", "text": "func FlagValueWithContext(name string, context interface{}) interface{} {\n\tdefaultRegistryMu.RLock()\n\tdefer defaultRegistryMu.RUnlock()\n\treturn DefaultRegistry.FlagValueWithContext(name, context)\n}", "title": "" }, { "docid": "a7a0b9be89ff119d4e07b18c7f08441e", "score": "0.40097335", "text": "func DebugSleepProgressWithContext(waiter *request.Waiter) {\n\tvar req *request.Request\n\toldNewRequest := waiter.NewRequest\n\twaiter.NewRequest = func(opts []request.Option) (*request.Request, error) {\n\t\tnewReq, err := oldNewRequest(opts)\n\t\treq = newReq\n\t\treturn newReq, err\n\t}\n\twaiter.SleepWithContext = func(context aws.Context, duration time.Duration) error {\n\t\tlog.Debugf(\"Sleeping, previous response: %+#v\", req.Data)\n\t\treturn aws.SleepWithContext(context, duration)\n\t}\n}", "title": "" }, { "docid": "fd5327098cd227940fda75e7be90fd0e", "score": "0.40052897", "text": "func (proxy *ProxyHttpServer) requestWithContext(r *http.Request) *http.Request {\n\treturn SetCtxProxy(r, proxy)\n}", "title": "" }, { "docid": "0fafe34850c5de3cd7ddb93de2955800", "score": "0.4005159", "text": "func (m *MockEventBridgeAPI) ListArchivesWithContext(arg0 context.Context, arg1 *eventbridge.ListArchivesInput, arg2 ...request.Option) (*eventbridge.ListArchivesOutput, error) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"ListArchivesWithContext\", varargs...)\n\tret0, _ := ret[0].(*eventbridge.ListArchivesOutput)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "fbc2da40b63d8a0de6a9f3a350543a76", "score": "0.40002593", "text": "func RunGroupWithContext(\n\tctx types.Context,\n\tt *testing.T,\n\tdriverName string,\n\tconfig []byte,\n\ttests ...APITestFunc) {\n\n\trun(ctx, t, types.IntegrationClient, nil,\n\t\tdriverName, config, false, true, tests...)\n}", "title": "" } ]
8f00e5793124b6fad1fb05052fc7fb0b
GetSourceAddress retrieves the value of the leaf SourceAddress from the System_Logging_RemoteServer struct. Caution should be exercised whilst using this method since it will return the Go zero value if the field is explicitly unset. If the caller explicitly does not care if SourceAddress is set, it can safely use t.GetSourceAddress() to retrieve the value. In the case that the caller has different actions based on whether the leaf is set or unset, it should use 'if t.SourceAddress == nil' before retrieving the leaf's value.
[ { "docid": "1cddc01635bfcce0a91a77fccffef88f", "score": "0.8359933", "text": "func (t *System_Logging_RemoteServer) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" } ]
[ { "docid": "75a3ed2ce8fbb4e526bbe397b64f44c5", "score": "0.7984186", "text": "func (t *OpenconfigSystem_System_Logging_RemoteServers_RemoteServer_State) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "75a3ed2ce8fbb4e526bbe397b64f44c5", "score": "0.7984186", "text": "func (t *OpenconfigSystem_System_Logging_RemoteServers_RemoteServer_State) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "bcdaf778a946cc22b816ea723c601656", "score": "0.7881253", "text": "func (t *OpenconfigSystem_System_Logging_RemoteServers_RemoteServer_Config) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "bcdaf778a946cc22b816ea723c601656", "score": "0.7881253", "text": "func (t *OpenconfigSystem_System_Logging_RemoteServers_RemoteServer_Config) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "a4d5d40b2d57655de250835bdb71aecb", "score": "0.7434877", "text": "func (t *OpenconfigSystem_System_Aaa_ServerGroups_ServerGroup_Servers_Server_Radius_State) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "a4d5d40b2d57655de250835bdb71aecb", "score": "0.7434877", "text": "func (t *OpenconfigSystem_System_Aaa_ServerGroups_ServerGroup_Servers_Server_Radius_State) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "3385af0ed67cca55f68e82e01826de0c", "score": "0.74224854", "text": "func (t *OpenconfigSystem_System_Aaa_ServerGroups_ServerGroup_Servers_Server_Radius_Config) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "3385af0ed67cca55f68e82e01826de0c", "score": "0.74224854", "text": "func (t *OpenconfigSystem_System_Aaa_ServerGroups_ServerGroup_Servers_Server_Radius_Config) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "8f3b2cde038e36a404f96896896824b7", "score": "0.7420284", "text": "func (t *System_Aaa_ServerGroup_Server_Radius) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "15b452458b99d4e553be8d52f745e44f", "score": "0.70190614", "text": "func (t *OpenconfigSystem_System_Aaa_ServerGroups_ServerGroup_Servers_Server_Tacacs_State) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "15b452458b99d4e553be8d52f745e44f", "score": "0.70181495", "text": "func (t *OpenconfigSystem_System_Aaa_ServerGroups_ServerGroup_Servers_Server_Tacacs_State) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "e0bcf86e92548604f8b8080835fa10fb", "score": "0.70133907", "text": "func (t *OpenconfigSystem_System_Aaa_ServerGroups_ServerGroup_Servers_Server_Tacacs_Config) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "e0bcf86e92548604f8b8080835fa10fb", "score": "0.7013017", "text": "func (t *OpenconfigSystem_System_Aaa_ServerGroups_ServerGroup_Servers_Server_Tacacs_Config) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "6d98577d7ae2e0eee0b486d10423bc77", "score": "0.6951458", "text": "func (t *System_Aaa_ServerGroup_Server_Tacacs) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "c55368fb1e2a88cfb45ffd6ec1998540", "score": "0.68967307", "text": "func (t *Acl_AclSet_AclEntry_Ipv4) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "cd93fd5bf066770a4f99fc3da55388bf", "score": "0.6804335", "text": "func (t *Acl_AclSet_AclEntry_Ipv6) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "42aeb4b370fb7aa62623fb045d00fa6c", "score": "0.6775792", "text": "func (o *MicrosoftGraphNetworkConnection) GetSourceAddress() string {\n\tif o == nil || o.SourceAddress == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.SourceAddress\n}", "title": "" }, { "docid": "3648a8453f9395b39ef6b2d16cff2db6", "score": "0.67593586", "text": "func (t *NetworkInstance_Mpls_SignalingProtocols_RsvpTe_Session) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "e18229c792cf2755416549f8973b9d2d", "score": "0.64630425", "text": "func (t *System_Ntp) GetNtpSourceAddress() string {\n\tif t == nil || t.NtpSourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.NtpSourceAddress\n}", "title": "" }, { "docid": "c32a05cfc1cc1e6f9c3de212b8411c95", "score": "0.63642347", "text": "func (t *NetworkInstance_PolicyForwarding_Policy_Rule_Ipv4) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "106453faecd740279936c7090e426713", "score": "0.635626", "text": "func (t *OpenconfigSystem_System_Ntp_State) GetNtpSourceAddress() string {\n\tif t == nil || t.NtpSourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.NtpSourceAddress\n}", "title": "" }, { "docid": "106453faecd740279936c7090e426713", "score": "0.6355712", "text": "func (t *OpenconfigSystem_System_Ntp_State) GetNtpSourceAddress() string {\n\tif t == nil || t.NtpSourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.NtpSourceAddress\n}", "title": "" }, { "docid": "33a97e1eca1f5231fd9cb3d0d1e7112e", "score": "0.6284977", "text": "func (t *NetworkInstance_Protocol_Pim_Global) GetSource(Address string) *NetworkInstance_Protocol_Pim_Global_Source {\n\n\tif t == nil {\n\t\treturn nil\n\t}\n\n\tkey := Address\n\n\tif lm, ok := t.Source[key]; ok {\n\t\treturn lm\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "423ec374c916a14feba3b62bd79f9d70", "score": "0.62419033", "text": "func (o *VPCRouterSessionAnalysis) GetSourceAddress() []*VPCRouterStatisticsValue {\n\treturn o.SourceAddress\n}", "title": "" }, { "docid": "d2f842f2cf457c3366de386fe1d30ed4", "score": "0.62160736", "text": "func (t *OpenconfigSystem_System_Ntp_Config) GetNtpSourceAddress() string {\n\tif t == nil || t.NtpSourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.NtpSourceAddress\n}", "title": "" }, { "docid": "d2f842f2cf457c3366de386fe1d30ed4", "score": "0.62160736", "text": "func (t *OpenconfigSystem_System_Ntp_Config) GetNtpSourceAddress() string {\n\tif t == nil || t.NtpSourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.NtpSourceAddress\n}", "title": "" }, { "docid": "c13288d5cff96d6206080a48f428da2a", "score": "0.6155106", "text": "func (ep *Loc) GetSource() string {\n\treturn ep.SourcePath\n}", "title": "" }, { "docid": "bbc00e24fae89aee03b957a5de6ec07f", "score": "0.6101953", "text": "func (t *NetworkInstance_Protocol_Pim_Global_Source) GetAddress() string {\n\tif t == nil || t.Address == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Address\n}", "title": "" }, { "docid": "fdb893c435160c237669336d3c9a0108", "score": "0.60719633", "text": "func (msg *Message) GetSource() string {\n\treturn msg.Router.Source\n}", "title": "" }, { "docid": "32ccb0fce7fb7ce9406017d2cd7a309f", "score": "0.5998276", "text": "func (t *NetworkInstance_Mpls_Lsps_ConstrainedPath_Tunnel) GetSource() string {\n\tif t == nil || t.Source == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Source\n}", "title": "" }, { "docid": "a812011764344833dda074169b3ccdcc", "score": "0.59980524", "text": "func (t *NetworkInstance_PolicyForwarding_Policy_Rule_Ipv6) GetSourceAddress() string {\n\tif t == nil || t.SourceAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.SourceAddress\n}", "title": "" }, { "docid": "22ab7eb31f702feb829c88dc9187423e", "score": "0.5977241", "text": "func (t *NetworkInstance_Protocol_Igmp_Global_Ssm_Mapping) GetSource() string {\n\tif t == nil || t.Source == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Source\n}", "title": "" }, { "docid": "a8c37a20d6d37ae88f94496ea0aa95b3", "score": "0.5940858", "text": "func (p *Packet) SourceAddress() net.IP {\n\treturn p.ipHdr.sourceAddress\n}", "title": "" }, { "docid": "353848dfaafea0ff2f9394a4493b9cd9", "score": "0.5910999", "text": "func (t *Timeline) GetSource() *Source {\n\tif t == nil {\n\t\treturn nil\n\t}\n\treturn t.Source\n}", "title": "" }, { "docid": "45f0d12c85c0452925c1d6949eda595b", "score": "0.5901961", "text": "func (o *BeaconAuditTrail) GetSource() BeaconAuditTrailSource {\n\tif o == nil {\n\t\tvar ret BeaconAuditTrailSource\n\t\treturn ret\n\t}\n\n\treturn o.Source\n}", "title": "" }, { "docid": "024f55cb11ec4215c6c9739c34a08bb0", "score": "0.5863647", "text": "func (e *Local) GetSource() string {\n\treturn e.WorkspaceSource\n}", "title": "" }, { "docid": "5b8896e01b5304d1b24c5f9ad70476a4", "score": "0.5826167", "text": "func (x *Principal) GetSourceIp() *v32.CidrRange {\n\tif x, ok := x.GetIdentifier().(*Principal_SourceIp); ok {\n\t\treturn x.SourceIp\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "867c585d44b7bed783f2191d6a784658", "score": "0.57938826", "text": "func (o *TagWithSourceInfo) GetSource() string {\n\tif o == nil || o.Source == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Source\n}", "title": "" }, { "docid": "cc6259356e3c6523bce3f0d1523104f3", "score": "0.57386804", "text": "func (t ConntrackTuple) SourceAddress() util.Address {\n\tif t.Family() == IPv6 {\n\t\treturn util.V6Address(t.Saddr_l, t.Saddr_h)\n\t}\n\treturn util.V4Address(uint32(t.Saddr_l))\n}", "title": "" }, { "docid": "b78c50048fe903d465d9a08a1fe4c60f", "score": "0.56588507", "text": "func (t *Acl_AclSet_AclEntry_Transport) GetSourcePort() Acl_AclSet_AclEntry_Transport_SourcePort_Union {\n\tif t == nil || t.SourcePort == nil {\n\t\treturn nil\n\t}\n\treturn t.SourcePort\n}", "title": "" }, { "docid": "0c4b7ea2b44e6b0c47fc7d86eaba4d32", "score": "0.56331784", "text": "func (o *EventHeader) GetSrcIP() string {\n\tif o == nil || o.SrcIP == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.SrcIP\n}", "title": "" }, { "docid": "fb01ace3925dbd4f832ab7afa01bbe36", "score": "0.5628539", "text": "func (o *VulnerabilityReference) GetSource() string {\n\tif o == nil || o.Source == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Source\n}", "title": "" }, { "docid": "ddc0c90c584d2e297aff4380304fadea", "score": "0.56008637", "text": "func (b *binlogItem) GetSourceID() string {\n\treturn b.nodeID\n}", "title": "" }, { "docid": "192428519755022582077d1fef306c2e", "score": "0.55916697", "text": "func (t *NetworkInstance_PolicyForwarding_Policy_Rule_Action_EncapsulateGre_Target) GetSource() string {\n\tif t == nil || t.Source == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Source\n}", "title": "" }, { "docid": "9350b6368137a221c49fda48aca0baef", "score": "0.5586643", "text": "func (o *MicrosoftGraphNetworkConnection) GetNatSourceAddress() string {\n\tif o == nil || o.NatSourceAddress == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.NatSourceAddress\n}", "title": "" }, { "docid": "b9ab0f1331cb6bcde34bec9c21894b39", "score": "0.5545229", "text": "func (td TransitionDef) GetSource() plinko.State {\n\treturn td.Source\n}", "title": "" }, { "docid": "f049284809d31de1bc131ced058a666a", "score": "0.5537509", "text": "func GetLocalSourceIP(dest string) (string, error) {\n\trs, err := netlink.RouteGet(net.ParseIP(dest))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif len(rs) == 0 {\n\t\treturn \"\", errors.New(\"unable to determine default route\")\n\t}\n\treturn rs[0].Src.String(), nil\n}", "title": "" }, { "docid": "85338eba2cf4336196ec96b850ae22ec", "score": "0.55306625", "text": "func (o *HttpEvent) GetSrcIP() string {\n\tif o == nil || o.SrcIP == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.SrcIP\n}", "title": "" }, { "docid": "a5fe51c639ffa72da9d222ccde1213e6", "score": "0.5510055", "text": "func (t *Instance) GetSourceConfig() (*Config, error) {\n\tif t.Config.SourceConfig == \"\" {\n\t\treturn t.Config, nil\n\t}\n\tif t.sourceConfig == nil {\n\t\tconfig, err := ReadConfig(string(t.Config.SourceConfig))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif config.Project == \"\" {\n\t\t\t// fill-in missing project with our project\n\t\t\tconfig.Project = t.Config.Project\n\t\t}\n\t\tt.sourceConfig = config\n\t}\n\treturn t.sourceConfig, nil\n}", "title": "" }, { "docid": "00025153b8b796477c78f5bd12ae6e88", "score": "0.54981136", "text": "func (o *MarketNews) GetSource() string {\n\tif o == nil || o.Source == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Source\n}", "title": "" }, { "docid": "de6b86cd3fe3547c1b6641d926ff65c3", "score": "0.54618907", "text": "func (o *ActionEntity) GetSourceId() string {\n\tif o == nil || o.SourceId == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.SourceId\n}", "title": "" }, { "docid": "78e5177b8ad3c790b5a86eb2276e7f38", "score": "0.54147524", "text": "func (o *VPCRouterFirewallRule) GetSourceNetwork() types.VPCFirewallNetwork {\n\treturn o.SourceNetwork\n}", "title": "" }, { "docid": "24cfd094bf6f9056a2d9c391bb521706", "score": "0.5395717", "text": "func (o *ApplianceNetworkLinkStatus) GetSourceHostname() string {\n\tif o == nil || o.SourceHostname == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.SourceHostname\n}", "title": "" }, { "docid": "c6b99d815057c951ab8a6534c59e9155", "score": "0.5381053", "text": "func (t *NetworkInstance_Protocol_Igmp_Interface_Group) GetSource() string {\n\tif t == nil || t.Source == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Source\n}", "title": "" }, { "docid": "770f7be62e5c5c929cd519f0647b63e8", "score": "0.5377904", "text": "func GetSource(event linebot.Event) string {\n\tswitch event.Source.Type {\n\tcase linebot.EventSourceTypeUser:\n\t\treturn event.Source.UserID\n\tcase linebot.EventSourceTypeGroup:\n\t\treturn event.Source.UserID\n\tcase linebot.EventSourceTypeRoom:\n\t\treturn event.Source.RoomID\n\t}\n\treturn event.Source.UserID\n}", "title": "" }, { "docid": "b2d621f0386c456f6fd716436fd7ded7", "score": "0.5349101", "text": "func (o *RngConfig) GetSrc() string {\n\tif o == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\n\treturn o.Src\n}", "title": "" }, { "docid": "a9327de551aaefad02d998065b1ca400", "score": "0.5338661", "text": "func (bucket *BitBucket) GetSource() map[string]string {\n\treturn bucket.Source\n}", "title": "" }, { "docid": "b8e4b0ed83c38d0c3108f5ec02a1770f", "score": "0.5300926", "text": "func (t *NetworkInstance_Mpls_SignalingProtocols_Ldp_Targeted_AddressFamily_Target) GetLocalAddress() string {\n\tif t == nil || t.LocalAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.LocalAddress\n}", "title": "" }, { "docid": "11a1b98e0a0afbd4279ed6b41b08e2a1", "score": "0.52842575", "text": "func (o *EnsemblingJobSpec) GetSource() EnsemblingJobSource {\n\tif o == nil {\n\t\tvar ret EnsemblingJobSource\n\t\treturn ret\n\t}\n\n\treturn o.Source\n}", "title": "" }, { "docid": "0e12c364204ed1f8869fd87316507b46", "score": "0.52691376", "text": "func (r *IPFilterRule) GetSourceIP() string {\n\treturn r.srcIP\n}", "title": "" }, { "docid": "d56f4073f87db917f74efaa0f1714fcd", "score": "0.5267466", "text": "func (o *MicrosoftGraphNetworkConnection) SetSourceAddress(v string) {\n\to.SourceAddress = &v\n}", "title": "" }, { "docid": "14f45cda1e5c2150830481bdd653872e", "score": "0.52592194", "text": "func (o *VPCRouterFirewallRule) GetSourcePort() types.VPCFirewallPort {\n\treturn o.SourcePort\n}", "title": "" }, { "docid": "ff2176dd0073a96d9acd8754fd117c21", "score": "0.52577055", "text": "func (o *PacketFilterExpression) GetSourceNetwork() types.PacketFilterNetwork {\n\treturn o.SourceNetwork\n}", "title": "" }, { "docid": "6b750089d58ccdcb980773c37311500e", "score": "0.52530897", "text": "func (o *EventHeader) GetSrcHost() string {\n\tif o == nil || o.SrcHost == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.SrcHost\n}", "title": "" }, { "docid": "11c7fc1d7f57cb22aba0f5ea8f428a25", "score": "0.52323765", "text": "func (n *sourceStateEntryTreeNode) Get(relPath RelPath) SourceStateEntry {\n\tnode := n.GetNode(relPath)\n\tif node == nil {\n\t\treturn nil\n\t}\n\treturn node.sourceStateEntry\n}", "title": "" }, { "docid": "2223dd1702222452abdae0f5945cc567", "score": "0.5225652", "text": "func (o RuleV2Output) SourceIpAddress() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *RuleV2) pulumi.StringPtrOutput { return v.SourceIpAddress }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "a8b5544c9c6a647fd0994fdf58cef225", "score": "0.52112347", "text": "func (o *PacketFilterExpression) GetSourcePort() types.PacketFilterPort {\n\treturn o.SourcePort\n}", "title": "" }, { "docid": "1e8e34850c69cf40249f3940870dabbf", "score": "0.52062553", "text": "func (t *NetworkInstance_PolicyForwarding_Policy_Rule_Transport) GetSourcePort() NetworkInstance_PolicyForwarding_Policy_Rule_Transport_SourcePort_Union {\n\tif t == nil || t.SourcePort == nil {\n\t\treturn nil\n\t}\n\treturn t.SourcePort\n}", "title": "" }, { "docid": "9642edf2af554d916e9a5f2c864db08a", "score": "0.5197416", "text": "func (o *Ga4ghCelltransplant) GetCellSource() string {\n\tif o == nil || o.CellSource == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.CellSource\n}", "title": "" }, { "docid": "93b44223e933d03e6c6cdb6da8a7ecad", "score": "0.51721066", "text": "func (s *SQLTraceStore) GetSource(ctx context.Context, commitNumber types.CommitNumber, traceName string) (string, error) {\n\tvar filename string\n\ttraceID := traceIDForSQLFromTraceName(traceName)\n\n\tsourceContext := getSourceContext{\n\t\tMD5HexTraceID: traceID,\n\t\tCommitNumber: commitNumber,\n\t}\n\n\tvar b bytes.Buffer\n\tif err := s.unpreparedStatements[getSource].Execute(&b, sourceContext); err != nil {\n\t\treturn \"\", skerr.Wrapf(err, \"failed to expand get source template\")\n\t}\n\tsql := b.String()\n\n\tif err := s.db.QueryRow(ctx, sql).Scan(&filename); err != nil {\n\t\treturn \"\", skerr.Wrapf(err, \"commitNumber=%d traceName=%q traceID=%q\", commitNumber, traceName, traceID)\n\t}\n\treturn filename, nil\n}", "title": "" }, { "docid": "f41b541cab6ed22202aa15628daade77", "score": "0.51615554", "text": "func (o *VPCRouterSessionAnalysis) SetSourceAddress(v []*VPCRouterStatisticsValue) {\n\to.SourceAddress = v\n}", "title": "" }, { "docid": "b82115db1333fd517e01a6537d1b42cf", "score": "0.51515317", "text": "func (t *System_Ntp_Server) GetAddress() string {\n\tif t == nil || t.Address == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Address\n}", "title": "" }, { "docid": "5d41afa326735e1dcef0ff15d7066340", "score": "0.5146213", "text": "func GetSource(ctx context.Context, ownerUID int, prefix string, db *sql.DB) (*Source, error) {\n\tdlock.Lock().RLock()\n\tdefer dlock.Lock().RUnlock()\n\n\tres, err := db.QueryContext(ctx, `\n\t\tSELECT rowid, owner_uid, created_at, prefix, kind, value1, value2, value3 FROM fs_sources WHERE owner_uid = ? AND prefix = ?;\n\t`, ownerUID, prefix)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer res.Close()\n\n\tif !res.Next() {\n\t\treturn nil, os.ErrNotExist\n\t}\n\n\tvar o Source\n\treturn &o, res.Scan(&o.UID, &o.OwnerID, &o.CreatedAt, &o.Prefix, &o.Kind, &o.Value1, &o.Value2, &o.Value3)\n}", "title": "" }, { "docid": "3b44f8b6f940c9c8631d70ac924109b4", "score": "0.51175404", "text": "func (t *NetworkInstance_Mpls_SignalingProtocols_Ldp_Targeted_AddressFamily_Target) GetRemoteAddress() string {\n\tif t == nil || t.RemoteAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.RemoteAddress\n}", "title": "" }, { "docid": "cfc12abe2d6c9ee89679785940f7ca42", "score": "0.5113064", "text": "func (o *ICViolation) GetSource() string {\n\tif o == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\n\treturn o.Source\n}", "title": "" }, { "docid": "c0483ac439d1f8ffc38822979a9e7d4b", "score": "0.5100138", "text": "func (t *OpenconfigSystem_System_Ntp_Servers_Server_State) GetAddress() string {\n\tif t == nil || t.Address == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Address\n}", "title": "" }, { "docid": "c0483ac439d1f8ffc38822979a9e7d4b", "score": "0.50980157", "text": "func (t *OpenconfigSystem_System_Ntp_Servers_Server_State) GetAddress() string {\n\tif t == nil || t.Address == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Address\n}", "title": "" }, { "docid": "5695e6a20bd012add7b04b75689b9ca2", "score": "0.5094591", "text": "func (ns *Namespace) GetSource(gvk schema.GroupVersionKind, name string) *unstructured.Unstructured {\n\tpos := ns.GetPropagatedObjects(gvk)\n\tfor _, po := range pos {\n\t\tif po.GetName() == name {\n\t\t\treturn po\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "ba570a2030f13d35d2686add65a6e2c8", "score": "0.50877", "text": "func (edge *Edge) GetSrcNode() *Node {\n\treturn edge.srcNode\n}", "title": "" }, { "docid": "069747a224a2cd22198d8d1e58a26870", "score": "0.5082686", "text": "func (b *BigTableTraceStore) GetSource(ctx context.Context, index int32, traceId string) (string, error) {\n\ttileKey := b.TileKey(index)\n\tops, err := b.GetOrderedParamSet(ctx, tileKey)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Failed to load OrderedParamSet for tile: %s\", err)\n\t}\n\tp, err := query.ParseKey(traceId)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Invalid traceid: %s\", err)\n\t}\n\tencodedTraceId, err := ops.EncodeParamsAsString(p)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Failed to encode key: %s\", err)\n\t}\n\ttctx, cancel := context.WithTimeout(context.Background(), TIMEOUT)\n\tdefer cancel()\n\trow, err := b.getTable().ReadRow(tctx, tileKey.TraceRowName(encodedTraceId, b.shards), bigtable.RowFilter(\n\t\tbigtable.ChainFilters(\n\t\t\tbigtable.LatestNFilter(1),\n\t\t\tbigtable.FamilyFilter(SOURCES_FAMILY),\n\t\t\tbigtable.ColumnFilter(fmt.Sprintf(\"^%d$\", index%b.tileSize)),\n\t\t),\n\t))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Failed to read source row: %s\", err)\n\t}\n\tif len(row) == 0 {\n\t\treturn \"\", fmt.Errorf(\"No source found.\")\n\t}\n\tsourceHash := fmt.Sprintf(\"&%x\", row[SOURCES_FAMILY][0].Value)\n\n\trow, err = b.getTable().ReadRow(tctx, sourceHash, bigtable.RowFilter(\n\t\tbigtable.ChainFilters(\n\t\t\tbigtable.LatestNFilter(1),\n\t\t\tbigtable.FamilyFilter(HASHES_FAMILY),\n\t\t),\n\t))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Failed to read source row: %s\", err)\n\t}\n\tif len(row) == 0 {\n\t\treturn \"\", fmt.Errorf(\"No source found.\")\n\t}\n\n\treturn string(row[HASHES_FAMILY][0].Value), nil\n}", "title": "" }, { "docid": "621e671fa20e51a2e04a8d9b84cb30e0", "score": "0.50643605", "text": "func (t *OpenconfigSystem_System_Aaa_ServerGroups_ServerGroup_Servers_Server_State) GetAddress() string {\n\tif t == nil || t.Address == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Address\n}", "title": "" }, { "docid": "621e671fa20e51a2e04a8d9b84cb30e0", "score": "0.5063419", "text": "func (t *OpenconfigSystem_System_Aaa_ServerGroups_ServerGroup_Servers_Server_State) GetAddress() string {\n\tif t == nil || t.Address == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Address\n}", "title": "" }, { "docid": "a4a46e4a33fd216bc84886e60d024f2b", "score": "0.50579137", "text": "func (o *ThumbnailSet) GetSource() AnyOfmicrosoftGraphThumbnail {\n\tif o == nil || o.Source == nil {\n\t\tvar ret AnyOfmicrosoftGraphThumbnail\n\t\treturn ret\n\t}\n\treturn *o.Source\n}", "title": "" }, { "docid": "167b0e7d1f597411bd03f182db4fd3bd", "score": "0.50271994", "text": "func (t *System_Aaa_ServerGroup_Server) GetAddress() string {\n\tif t == nil || t.Address == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Address\n}", "title": "" }, { "docid": "7266f0c1bb1bf5aefd009d6d5a82fa08", "score": "0.5022023", "text": "func (t *Bgp_PeerGroup_Transport) GetLocalAddress() string {\n\tif t == nil || t.LocalAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.LocalAddress\n}", "title": "" }, { "docid": "7a8f8464dfdf31452f63cde524f7cada", "score": "0.50200635", "text": "func (c Config) GetTraceAddress() string {\n\tif c.TraceAddress != \"\" {\n\t\treturn c.TraceAddress\n\t}\n\tif c.TraceHostname != \"\" {\n\t\treturn fmt.Sprintf(\"%s:%s\", c.TraceHostname, c.TracePortOrDefault())\n\t}\n\tif c.Hostname != \"\" {\n\t\treturn fmt.Sprintf(\"%s:%s\", c.Hostname, c.TracePortOrDefault())\n\t}\n\treturn \"\"\n}", "title": "" }, { "docid": "12c7908c639c834b2d8e75356ba5f112", "score": "0.5015534", "text": "func (l *LogForwarderV2) GetAddress() string {\n\treturn l.Spec.Address\n}", "title": "" }, { "docid": "0f8a5a6c459acbf01d9bfbf04e01a550", "score": "0.50041515", "text": "func (t *OpenconfigSystem_System_Dns_Servers_Server_State) GetAddress() string {\n\tif t == nil || t.Address == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Address\n}", "title": "" }, { "docid": "479bd15798a0a034f77e87f3901f5a45", "score": "0.5003641", "text": "func (o *MicrosoftGraphNetworkConnection) GetSourcePort() string {\n\tif o == nil || o.SourcePort == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.SourcePort\n}", "title": "" }, { "docid": "0f8a5a6c459acbf01d9bfbf04e01a550", "score": "0.5002024", "text": "func (t *OpenconfigSystem_System_Dns_Servers_Server_State) GetAddress() string {\n\tif t == nil || t.Address == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Address\n}", "title": "" }, { "docid": "3bc63221bc955e8019a9df0e503954cf", "score": "0.50007784", "text": "func (o *MicrosoftGraphNetworkConnection) GetSourceAddressOk() (string, bool) {\n\tif o == nil || o.SourceAddress == nil {\n\t\tvar ret string\n\t\treturn ret, false\n\t}\n\treturn *o.SourceAddress, true\n}", "title": "" }, { "docid": "91744f9c33ec1cbda7af3248c3527cf3", "score": "0.49919745", "text": "func (t *OpenconfigSystem_System_Ntp_Servers_Server) GetAddress() string {\n\tif t == nil || t.Address == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Address\n}", "title": "" }, { "docid": "0ac57ffe02d06054b7ff1e85779f6f6a", "score": "0.49900985", "text": "func (o *HttpEvent) GetSrcHost() string {\n\tif o == nil || o.SrcHost == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.SrcHost\n}", "title": "" }, { "docid": "91744f9c33ec1cbda7af3248c3527cf3", "score": "0.49886638", "text": "func (t *OpenconfigSystem_System_Ntp_Servers_Server) GetAddress() string {\n\tif t == nil || t.Address == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Address\n}", "title": "" }, { "docid": "62ce140392ddfab202f331ebfe7adb2e", "score": "0.49823254", "text": "func (t *System_Dns_Server) GetAddress() string {\n\tif t == nil || t.Address == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Address\n}", "title": "" }, { "docid": "9d3b52cd71131dbd950711f164dff0c2", "score": "0.49461186", "text": "func (t *OpenconfigSystem_System_Aaa_ServerGroups_ServerGroup_Servers_Server) GetAddress() string {\n\tif t == nil || t.Address == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Address\n}", "title": "" }, { "docid": "9d3b52cd71131dbd950711f164dff0c2", "score": "0.49454403", "text": "func (t *OpenconfigSystem_System_Aaa_ServerGroups_ServerGroup_Servers_Server) GetAddress() string {\n\tif t == nil || t.Address == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Address\n}", "title": "" }, { "docid": "4b0f2602251a469cd0fd5b88f6f35dc8", "score": "0.49343047", "text": "func (m ExecutionReport) GetIDSource() (v enum.IDSource, err quickfix.MessageRejectError) {\n\tvar f field.IDSourceField\n\tif err = m.Get(&f); err == nil {\n\t\tv = f.Value()\n\t}\n\treturn\n}", "title": "" }, { "docid": "38e4364cdbb9f3ec711f3589103d1fd1", "score": "0.49263623", "text": "func (t *Bgp_Neighbor_Transport) GetLocalAddress() string {\n\tif t == nil || t.LocalAddress == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.LocalAddress\n}", "title": "" }, { "docid": "f085a988e016923edbe3307be42d8513", "score": "0.4915548", "text": "func (o *SnapmirrorQuiesceRequest) SourceVserver() string {\n\tvar r string\n\tif o.SourceVserverPtr == nil {\n\t\treturn r\n\t}\n\tr = *o.SourceVserverPtr\n\treturn r\n}", "title": "" } ]
3820d112b3ba053a5d646be571561bf1
Method of memcacheConnection to call the set command
[ { "docid": "3d4872d5db537d7183571f92da84e564", "score": "0.71942556", "text": "func (m memcacheConnection) set(key string, value string) (string, error) {\n\t// Write to server\n\tm.con.Write([]byte(\"set \" + key + \" \" + strconv.Itoa(len(value)) + \" \\r\\n\"))\n\ttime.Sleep(250 * time.Millisecond)\n\tm.con.Write([]byte(value + \" \\r\\n\"))\n\t// Get server response\n\tserverReader := bufio.NewReader(m.con)\n\tserverResponse, err := serverReader.ReadString('\\n')\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn serverResponse, nil\n\n}", "title": "" } ]
[ { "docid": "24590fafcb9722eadee7a26158b65b69", "score": "0.7222723", "text": "func setCommand(req *proto.Request, conn *ClientConnection) {\n\tkey, val := req.Key(), req.Value()\n\tconn.cache.Set(key, val)\n}", "title": "" }, { "docid": "69e321f42898b9a4f9c10057c43fd178", "score": "0.6796084", "text": "func (ps *proxy) setCommand(\n\tconnID uint32,\n\tcmdID int,\n\tdatabase string,\n\tquery string,\n\tparams []protocol.PreparedParameter,\n\texecutable bool,\n) {\n\tvar parametersSlice []string\n\tfor _, parameter := range params {\n\t\tparametersSlice = append(parametersSlice, parameter.Value)\n\t}\n\n\tps.cmdChan <- chat.Cmd{\n\t\tConnId: connID,\n\t\tCmdId: cmdID,\n\t\tDatabase: database,\n\t\tQuery: query,\n\t\tExecutable: executable,\n\t\tParameters: parametersSlice,\n\t}\n}", "title": "" }, { "docid": "e513854a6e8c17bc64417ce953ccdf17", "score": "0.6749443", "text": "func (r RConnect) Set(key, value string) error {\n\terr := radixClient.Do(radix.Cmd(nil, \"SET\", key, value))\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Println(\"Redis: The SET action has been successfully executed\")\n\treturn nil\n}", "title": "" }, { "docid": "292c9f6af07200f2150e4f61d2b51f4a", "score": "0.6729645", "text": "func SetCommand(c *Client, s *Server) {\n\tobjKey := c.Argv[1]\n\tobjValue := c.Argv[2]\n\tif c.Argc != 3 {\n\t\taddReplyError(c, \"(error) ERR wrong number of arguments for 'set' command\")\n\t}\n\tif stringKey, ok1 := objKey.Ptr.(string); ok1 {\n\t\tif stringValue, ok2 := objValue.Ptr.(string); ok2 {\n\t\t\tc.Db.Dict[stringKey] = CreateObject(ObjectTypeString, stringValue)\n\t\t}\n\t}\n\ts.Dirty++\n\taddReplyStatus(c, \"OK\")\n}", "title": "" }, { "docid": "558c437bde1ae64cf70c949e53953d60", "score": "0.6527116", "text": "func Set(key string, value string) (reply interface{}, err error) {\n redisConn := <-redisConnsAvail\n err = (*redisConn).Send(\"SET\", key, value)\n if err != nil {\n fmt.Println(\"redis send error\", err)\n return nil, err\n }\n err = (*redisConn).Flush()\n if err != nil {\n fmt.Println(\"redis flush error\", err)\n return nil, err\n }\n reply, err = (*redisConn).Receive()\n redisConnsAvail <- redisConn\n return reply, err\n}", "title": "" }, { "docid": "2abc467435a98ea3ac51a579ec76c90c", "score": "0.64919287", "text": "func (client *memClient) Set(key string, value string, expiration int) {\n\tflags := \"0\"\n\tcommand := fmt.Sprintf(\"set %s %s %d %d\\r\\n%s\\r\\n\", key, flags, expiration, len(value), value)\n\tclient.executor.execute(command, []string{\"STORED\"})\n}", "title": "" }, { "docid": "124553fb078929f0b7c311c1e82e7a90", "score": "0.63815194", "text": "func (c *Conn) Set(ctx context.Context, longCommandName string, args ...string) error {\n\trequest := protocol.Request{Command: protocol.LongCommand(longCommandName), Args: args}\n\n\tresult := make(chan error)\n\tgo func() {\n\t\tdefer close(result)\n\t\t_, err := c.trx.Send(ctx, request)\n\t\tresult <- err\n\t}()\n\n\tselect {\n\tcase err := <-result:\n\t\treturn err\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\t}\n}", "title": "" }, { "docid": "6760fdd0710e92f18fcf42bdfb395820", "score": "0.62933546", "text": "func (g *Minigoredis) Set(key string, val interface{}, _ time.Duration) *redis.StatusCmd {\n\terr := g.Miniredis.Set(key, val.(string))\n\treturn redis.NewStatusResult(\"OK\", err)\n}", "title": "" }, { "docid": "7066ef5b47f3ab1fbb7aa55393a491ca", "score": "0.6276529", "text": "func (RedisOP) Set(key string, data interface{}, time time.Duration) error {\n\tRedisdb.Set(ctx, key, data, time)\n\t//if err != nil {\n\t//\treturn err\n\t//}\n\treturn nil\n}", "title": "" }, { "docid": "e74fb06a98db77500f5645dae548f7b0", "score": "0.6183374", "text": "func SET(key string, val []byte) error {\n\tc, err := _pool.Get()\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = c.Cmd(\"SET\", key, val).Err\n\t_pool.Put(c)\n\treturn err\n}", "title": "" }, { "docid": "092644c4b163185d5d71dcece26d85b6", "score": "0.6169143", "text": "func (object *RedisClientWrapper) set(cacheKey string,\n\tcache []byte,\n\texpiration, timeout time.Duration) (err error) {\n\tctx, cancel := context.WithTimeout(context.Background(), timeout)\n\tdefer cancel()\n\t_, err = object.client.Set(ctx, cacheKey, cache, expiration).Result()\n\treturn\n}", "title": "" }, { "docid": "cf57895cd457c122994466a9bd5eabd3", "score": "0.6141056", "text": "func (c *Client) Set(key string, value string) error {\n args := make(map[string]string)\n args[FunctionArg] = SetCommand\n args[KeyArg] = key\n args[ValueArg] = value\n data, marshal_err := json.Marshal(args)\n if marshal_err != nil {\n return marshal_err\n }\n keys := []raft.Key{raft.Key([]byte(key))}\n c.session.SendFastRequest(data, keys, &raft.ClientResponse{})\n return nil\n}", "title": "" }, { "docid": "9a7ea92ccaa348d4113248ccbaac74bb", "score": "0.61351424", "text": "func (cp *ConnPool) SET(key string, value interface{}) (err error) {\n\treturn cp.SETExtra(key, value, 0, 0, Default)\n}", "title": "" }, { "docid": "819ffc90865c8dd139973c34d9072414", "score": "0.6078946", "text": "func (c *commands) CommandSet(t tokens) *result {\n\tr := &result{}\n\n\tif len(t) < 2 {\n\t\tr.err = ProtocolError{}\n\t\treturn r\n\t}\n\n\tkey := t[0]\n\tttl := 0\n\n\tif len(t) >= 3 {\n\t\tttl, _ = strconv.Atoi(string(t[2]))\n\t}\n\n\tc.cache.set(string(key), t[1], ttl)\n\tr.value = t[1]\n\n\treturn r\n}", "title": "" }, { "docid": "43efc8a1d2ddd8643105ef14a4d4b0ec", "score": "0.60437346", "text": "func execMSet(db *DB, args [][]byte) redis.Reply {\n\tif len(args)%2 != 0 {\n\t\treturn reply.MakeSyntaxErrReply()\n\t}\n\n\tsize := len(args) / 2\n\tkeys := make([]string, size)\n\tvalues := make([][]byte, size)\n\tfor i := 0; i < size; i++ {\n\t\tkeys[i] = string(args[2*i])\n\t\tvalues[i] = args[2*i+1]\n\t}\n\n\tfor i, key := range keys {\n\t\tvalue := values[i]\n\t\tdb.PutEntity(key, &DataEntity{Data: value})\n\t}\n\tdb.AddAof(makeAofCmd(\"mset\", args))\n\treturn &reply.OkReply{}\n}", "title": "" }, { "docid": "98bac252ddeeddf8521a18980cd9e720", "score": "0.59976536", "text": "func (c *Connection) Set(key, value string) error {\n\treturn c.rc.Set(key, value, 0).Err()\n\n}", "title": "" }, { "docid": "56956704891c51de4f7bfae5a2a6b26d", "score": "0.5952113", "text": "func set(c redis.Conn) error {\n\t_, err := c.Do(\"SET\", \"Favorite Movie\", \"Repo Man\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = c.Do(\"SET\", \"Release Year\", 1984)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "3cbc79cf04d93b95ca4b891660fa9ac6", "score": "0.59490097", "text": "func (h *RedisCache) Set(key string , value interface{} , expire time.Duration) (error){\n\th.mutex.Lock()\n\tdefer func() {\n\t\th.mutex.Unlock()\n\t}()\n\terr := h.client.Set(key , value , expire).Err()\n\treturn err\n}", "title": "" }, { "docid": "5f61430875e35c26b765dc410d13d68f", "score": "0.59210664", "text": "func set(connection net.Conn, key, value string) {\n\n _, ok := cache.Data[key]\n if ok {\n connection.Write([]byte(key+\" already added. To modify, UPDATE key\"))\n } else {\n cache.Lock()\n cache.Data[key] = value\n cache.Unlock()\n connection.Write([]byte(\"Added \"+key+\":\"+value))\n }\n}", "title": "" }, { "docid": "e3e14f8e2d5c86ad1b783c5ec4906291", "score": "0.591874", "text": "func execGetSet(db *DB, args [][]byte) redis.Reply {\n\tkey := string(args[0])\n\tvalue := args[1]\n\n\told, err := db.getAsString(key)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdb.PutEntity(key, &DataEntity{Data: value})\n\tdb.Persist(key) // override ttl\n\tdb.AddAof(makeAofCmd(\"getset\", args))\n\tif old == nil {\n\t\treturn new(reply.NullBulkReply)\n\t}\n\treturn reply.MakeBulkReply(old)\n}", "title": "" }, { "docid": "672bc4da10fb6a92bab522c5187abae7", "score": "0.58957267", "text": "func (c *client) Set(key string, value interface{}) {\n\tc.lock.Lock()\n\tdefer c.lock.Unlock()\n\n\tvalByte, _ := json.Marshal(value)\n\tfmt.Fprintf(c.conn, \"SET %s '%s'\\n\", key, string(valByte))\n\tbufio.NewReader(c.conn).ReadString('\\n')\n}", "title": "" }, { "docid": "9c17af64fb9c3aa60f90fbb741cd7f64", "score": "0.5883963", "text": "func execMSetNX(db *DB, args [][]byte) redis.Reply {\n\t// parse args\n\tif len(args)%2 != 0 {\n\t\treturn reply.MakeSyntaxErrReply()\n\t}\n\tsize := len(args) / 2\n\tvalues := make([][]byte, size)\n\tkeys := make([]string, size)\n\tfor i := 0; i < size; i++ {\n\t\tkeys[i] = string(args[2*i])\n\t\tvalues[i] = args[2*i+1]\n\t}\n\n\tfor _, key := range keys {\n\t\t_, exists := db.GetEntity(key)\n\t\tif exists {\n\t\t\treturn reply.MakeIntReply(0)\n\t\t}\n\t}\n\n\tfor i, key := range keys {\n\t\tvalue := values[i]\n\t\tdb.PutEntity(key, &DataEntity{Data: value})\n\t}\n\tdb.AddAof(makeAofCmd(\"msetnx\", args))\n\treturn reply.MakeIntReply(1)\n}", "title": "" }, { "docid": "7675a91dc93393a3ec3a2d5f7eb69054", "score": "0.58833456", "text": "func (t *Cache) Set(key string, val interface{}, timeout time.Duration) error {\n\titem,err := t.NewCacheItem(key,val,timeout)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn t.conn.Set(item)\n}", "title": "" }, { "docid": "4527f7660072eed70a441e953d1d464e", "score": "0.58676624", "text": "func Set(host string, state int, data, errS string) error {\n\tif data == \"\" {\n\t\tdata = \"---\"\n\t}\n\tif errS == \"\" {\n\t\terrS = \"---\"\n\t}\n\n\tputr := put_item.Request{\n\t\tTableName: CACHE_TAB,\n\t\tItem: make(item.Item),\n\t}\n\n\t// Randomize the exp time by inserting the value up to \"expiry\" in the past\n\t// THIS MEANS THAT ITEMS ARE CACHED FOR A TIME FROM 0 TO expiry\n\trnd := rand.Int63n(int64(expiry))\n\tmtime := time.Now().UTC().Add(-time.Duration(rnd)).Unix()\n\n\tputr.Item[\"hostname\"] = &attributevalue.AttributeValue{S: host}\n\tputr.Item[\"Mtime\"] = &attributevalue.AttributeValue{N: strconv.FormatInt(mtime, 10)}\n\tputr.Item[\"Status\"] = &attributevalue.AttributeValue{N: strconv.FormatInt(int64(state), 10)}\n\tputr.Item[\"Data\"] = &attributevalue.AttributeValue{S: data}\n\tputr.Item[\"Error\"] = &attributevalue.AttributeValue{S: errS}\n\n\tbody, code, err := putr.EndpointReq()\n\tif err != nil {\n\t\tlog.Printf(\"[cache] ERROR: put failed %v, %s\", err, body)\n\t\treturn err\n\t}\n\tif code != http.StatusOK {\n\t\tlog.Printf(\"[cache] ERROR: put failed %v, %s\", code, body)\n\t\treturn fmt.Errorf(\"put failed: code %d\", code)\n\t}\n\n\t// log.Printf(\"####CACHE_SET: %s\\n\", string(body))\n\treturn nil\n}", "title": "" }, { "docid": "3ce5137a96f2a941fa0557666ca2234a", "score": "0.58598965", "text": "func (c *RedisCache) Set(key, value string) error {\n\tconn := c.pool.Get()\n\tdefer conn.Close()\n\n\tconn.Send(\"PUBLISH\", \"ingress-router\", \"updated\")\n\tif _, err := conn.Do(\"SET\", key, value); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "a8cd516cf6465c4e42641f43a66e314f", "score": "0.58559525", "text": "func execSetNX(db *DB, args [][]byte) redis.Reply {\n\tkey := string(args[0])\n\tvalue := args[1]\n\tentity := &DataEntity{\n\t\tData: value,\n\t}\n\tresult := db.PutIfAbsent(key, entity)\n\tdb.AddAof(makeAofCmd(\"setnx\", args))\n\treturn reply.MakeIntReply(int64(result))\n}", "title": "" }, { "docid": "7d5a84ad350e3b1f99926b0052fd44ad", "score": "0.58475363", "text": "func (c Cache) Set(key, val string) error {\n\tconn := c.Conn()\n\tdefer conn.Close()\n\n\t_, err := conn.Do(\"SET\", key, val)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "109e8d7056d1a0f05e81e3637c7324f4", "score": "0.58453554", "text": "func (s *RedisCache) Set(ctx context.Context, key string, value []byte, ttl uint64) error {\n\tconn := common.GetRedisConnection(ctx)\n\trs := conn.Set(ctx, key, value, time.Second*time.Duration(ttl))\n\tif rs.Err() != nil {\n\t\tfmt.Println(\"error setting value in redis\", rs.Err())\n\t\treturn rs.Err()\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "66fede6089a2aab6096a1c944eef234c", "score": "0.58222264", "text": "func (c Memcache) Set(_ context.Context, key string, value interface{}, expire time.Duration) error {\n\tv, err := c.enc(value)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn c.client.Set(&memcache.Item{\n\t\tKey: key,\n\t\tValue: v,\n\t\tExpiration: int32(expire.Seconds()),\n\t})\n}", "title": "" }, { "docid": "0f0425d5a0f206da27ad02e9d69962de", "score": "0.5777976", "text": "func (cp *ConnPool) MSET(m map[string]interface{}) (err error) {\n\targs := make([]interface{}, 0, len(m)*2)\n\tfor k, v := range m {\n\t\targs = append(args, k, v)\n\t}\n\tconn := cp.GetMasterConn()\n\t_, err = conn.Do(\"MSET\", args...)\n\tconn.Close()\n\treturn\n}", "title": "" }, { "docid": "5888acc200171cf66be4e567948b1440", "score": "0.577355", "text": "func Set(key string, value string) (err error) {\n\tconn, err := getConn()\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer conn.Close()\n\n\tconn.Send(\"SET\", key, value)\n\treturn conn.Flush()\n}", "title": "" }, { "docid": "f68e83dbcc8df8ece449c77a5f2aa85c", "score": "0.57711226", "text": "func (oc *OmniCache) Set(k, v []byte) error {\n\treturn oc.Conn.Write(k, v)\n}", "title": "" }, { "docid": "63a33f666498969c6ab27468e1656c36", "score": "0.5768005", "text": "func (r Redis) Set(key string, value interface{}, ttl time.Duration) {\n\tr.Client.Set(key, value, ttl)\n}", "title": "" }, { "docid": "84e36ae8531df5c21d7ee1f8522c7a10", "score": "0.5766375", "text": "func (c cache) Set(key string, resp []byte) {\n\tc.Do(\"SET\", cacheKey(key), resp)\n}", "title": "" }, { "docid": "fa302fdb8c38c76f553306139d7187f7", "score": "0.5762631", "text": "func (self *redisDriver) redisSet(client *r.Client, key, value string) error {\n\t// expiration will always be zero\n\texpiration := 0 * time.Second\n\tstatus := client.Set(getKeyName(key), value, expiration)\n\tif status.Err() != nil {\n\t\tlog.Printf(\"Error during SET: %s\\n\", status.Err())\n\t\treturn status.Err()\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "64f1dd80e77b81d76bb4a632fb4e10ad", "score": "0.5751507", "text": "func (self *RedisCache) Set(key string, parsed Parsed, ttl int) error {\n\tswitch {\n\tcase ttl == 0:\n\t\treturn nil // do not cache\n\n\tcase ttl > 0:\n\t\tkey = self.keyPrefix + key //TODO \"B\" + IPVersion + \"_\" + key\n\t\tpayload, err := json.Marshal(parsed)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tctx := context.Background()\n\t\t_, err = self.client.Set(\n\t\t\tctx, key, payload, time.Duration(ttl)*time.Minute).Result()\n\t\treturn err\n\n\tdefault: // ttl negative - invalid\n\t\treturn fmt.Errorf(\"negative TTL value for key: %s\", key)\n\t}\n}", "title": "" }, { "docid": "7eb23b1f9825810391d1102ffa0f29a0", "score": "0.57508945", "text": "func (rc *Redis) Set(key string, val string) error {\n\tvar err error\n\tif _, err = rc.do(\"SET\", key, val); err != nil {\n\t\treturn err\n\t}\n\n\treturn err\n}", "title": "" }, { "docid": "3d6f95dff1d1e04d1f18a2a31f971ee7", "score": "0.5737751", "text": "func (c *Client) Set(key string, value []byte) error {\n\tdata, err := c.Queryf(\"set %s %s\\n\", key, value)\n\n\treturn c.assertSuccess(data, err)\n}", "title": "" }, { "docid": "c4e0802755c62439d3aad1cf98fcc727", "score": "0.5722882", "text": "func (r *simpleRemoteControl) setCommand(command iCommand) {\n\tr.slot = command\n}", "title": "" }, { "docid": "4b3c67242b29f4481c0e092d6729b5f8", "score": "0.5711974", "text": "func (cn *Conn) Set(key string, val []byte, flags, exp uint32, ocas uint64) (cas uint64, err error) {\n\t// Variants: [R] Set [Q]\n\treturn cn.setGeneric(OpSet, key, val, ocas, flags, exp)\n}", "title": "" }, { "docid": "e1c48a35e1c6203924231e68b21b3d84", "score": "0.5705166", "text": "func (cache *SSMCache) Set(ctx context.Context, key string, value string, ttl time.Duration) error {\n\tparameterName := cache.getParameterName(key)\n\tparam := paramValue{uint(ttl.Seconds()), value}\n\n\tparamJSON, err := json.Marshal(param)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tjsonString := new(string)\n\t*jsonString = string(paramJSON)\n\n\tparamType := cache.getParamType()\n\n\t_, err = cache.ssm.PutParameter(ctx, &ssm.PutParameterInput{Name: &parameterName, Value: jsonString, Type: paramType})\n\treturn err\n}", "title": "" }, { "docid": "b4cf37561a4beedc4a099a5c0866928d", "score": "0.56957906", "text": "func Set(key, value string) string {\n\n\t// TODO encode the words for the relivant Set command\n\tsetWord := coder.Encode(set)\n\tkeyWord := coder.Encode(key)\n\tvalueWord := coder.Encode(value)\n\n\tconcat := append(append(setWord, keyWord...), valueWord...)\n\n\t// TODO send the command to the server\n\t// TODO get the response from the server\n\tresponse := sendNetworkRequest(concat)\n\n\t// TODO return the value obtained, as required\n\tstrResponse := coder.Decode(response)[0]\n\treturn strResponse\n\n}", "title": "" }, { "docid": "fe04e746335e90737861645c1e4431cd", "score": "0.56912756", "text": "func (db *Database) Set(key string, data []byte) error {\n\tif err := hord.ValidKey(key); err != nil {\n\t\treturn err\n\t}\n\n\tif err := hord.ValidData(data); err != nil {\n\t\treturn err\n\t}\n\n\tif db == nil || db.pool == nil {\n\t\treturn hord.ErrNoDial\n\t}\n\n\tc := db.pool.Get()\n\tdefer c.Close()\n\n\t_, err := c.Do(\"SET\", key, data)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to write data to Redis - %s\", err)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "035d67ffc4c86799b98447e454c99d8d", "score": "0.56853706", "text": "func (ps *proxy) setCommandResult(connId uint32, cmdId int, cmdState byte, error string, duration time.Duration) {\n\tps.cmdStateChan <- chat.CmdResult{\n\t\tConnId: connId,\n\t\tCmdId: cmdId,\n\t\tResult: cmdState,\n\t\tError: error,\n\t\tDuration: fmt.Sprintf(\"%.2f\", duration.Seconds()),\n\t}\n}", "title": "" }, { "docid": "b64243118f623000a2ae6e5716d3e975", "score": "0.5684346", "text": "func (s *Session) Set(param string, val interface{}) error {\n\n\ts.Lock()\n\tdefer s.Unlock()\n\tclient := Redis_Pool.Get()\n\tdefer client.Close()\n\tif !isConnected {\n\t\treturn ErrNoConnection\n\t}\n\n\tif s.Values == nil {\n\t\ts.Values = make(map[string]interface{})\n\t}\n\n\ts.Values[param] = val\n\n\traw, _ := json.Marshal(s)\n\tclient.Do(\"SETEX\", s.ID, opts.Timeout, raw)\n\t//dostr,err:=client.Do(\"SETEX\", s.ID, opts.Timeout,raw)\n\t//fmt.Println(\"set redis\", s.ID,raw,dostr,err)\n\treturn nil\n}", "title": "" }, { "docid": "867a88b13828065a873a152cc1ffc3bc", "score": "0.5681362", "text": "func (c *Client) Set(key, val, typ string) (map[string]interface{}, error) {\n\t// typ = 'str' for string (default, if provided \"\")\n\t// typ = 'int' for integer\n\t// typ = 'bin' for binary\n\n\t// New TCP-connection to the server\n\tconn, err := net.Dial(c.Network, c.Address)\n\tif err != nil {\n\t\treturn map[string]interface{}{}, err\n\t}\n\tdefer conn.Close()\n\n\t// Writing SET message/command to server\n\tfstr := shell.FormatCmd(\"SET \" + key + \" \" + val + \" --\" + typ)\n\t// fmt.Println(\"fstr\", fstr)\n\tconn.Write([]byte(fstr))\n\n\treturn handleResponse(&conn) // Returning server response\n}", "title": "" }, { "docid": "8d4acaeb86b2e766d9d14a6f225e9a66", "score": "0.5656319", "text": "func SetCommand() *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: \"set [config] [key] [value]\",\n\t\tShort: \"Set an application config value\",\n\t\tLong: \"Set an application config value. The [config] argument must be the path of the file when using the tool standalone, otherwise it must be the name of the config file without the .toml extension.\",\n\t\tArgs: cobra.ExactArgs(3),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tfilename, inputValue := args[0], args[2]\n\t\t\t// parse key e.g mempool.size -> [mempool, size]\n\t\t\tkey := strings.Split(args[1], \".\")\n\n\t\t\tclientCtx := client.GetClientContextFromCmd(cmd)\n\t\t\tif clientCtx.HomeDir != \"\" {\n\t\t\t\tfilename = fmt.Sprintf(\"%s/config/%s.toml\", clientCtx.HomeDir, filename)\n\t\t\t}\n\n\t\t\tplan := transform.Plan{\n\t\t\t\t{\n\t\t\t\t\tDesc: fmt.Sprintf(\"update %q=%q in %s\", key, inputValue, filename),\n\t\t\t\t\tT: transform.Func(func(_ context.Context, doc *tomledit.Document) error {\n\t\t\t\t\t\tresults := doc.Find(key...)\n\t\t\t\t\t\tif len(results) == 0 {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"key %q not found\", key)\n\t\t\t\t\t\t} else if len(results) > 1 {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"key %q is ambiguous\", key)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvalue, err := parser.ParseValue(inputValue)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\tvalue = parser.MustValue(`\"` + inputValue + `\"`)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ok := transform.InsertMapping(results[0].Section, &parser.KeyValue{\n\t\t\t\t\t\t\tBlock: results[0].Block,\n\t\t\t\t\t\t\tName: results[0].Name,\n\t\t\t\t\t\t\tValue: value,\n\t\t\t\t\t\t}, true); !ok {\n\t\t\t\t\t\t\treturn errors.New(\"failed to set value\")\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t}\n\n\t\t\toutputPath := filename\n\t\t\tif FlagStdOut {\n\t\t\t\toutputPath = \"\"\n\t\t\t}\n\n\t\t\tctx := cmd.Context()\n\t\t\tif FlagVerbose {\n\t\t\t\tctx = confix.WithLogWriter(ctx, cmd.ErrOrStderr())\n\t\t\t}\n\n\t\t\treturn confix.Upgrade(ctx, plan, filename, outputPath, FlagSkipValidate)\n\t\t},\n\t}\n\n\tcmd.Flags().BoolVar(&FlagStdOut, \"stdout\", false, \"print the updated config to stdout\")\n\tcmd.Flags().BoolVarP(&FlagVerbose, \"verbose\", \"v\", false, \"log changes to stderr\")\n\tcmd.Flags().BoolVarP(&FlagSkipValidate, \"skip-validate\", \"s\", false, \"skip configuration validation (allows to mutate unknown configurations)\")\n\n\treturn cmd\n}", "title": "" }, { "docid": "df39cc2883fcd8cccaceef29a031905a", "score": "0.5634479", "text": "func (r *Redis) Set(key interface{}, value interface{}, tm time.Duration) error {\n\tconn := r.pool.Get()\n\tdefer conn.Close()\n\n\ttms := int64(tm.Seconds())\n\n\t_, erro := conn.Do(\"SETEX\", key, tms, value)\n\tif erro != nil {\n\t\treturn erro\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "678f248a9cad8006fbc11be7f79f5c35", "score": "0.56337786", "text": "func (c *commands) CommandSetx(t tokens) *result {\n\tr := &result{}\n\n\tif len(t) < 2 {\n\t\tr.err = ProtocolError{}\n\t\treturn r\n\t}\n\n\tkey := t[0]\n\tvalue, _ := strconv.Atoi(string(t[1]))\n\tentry := c.cache.get(string(key))\n\n\tif entry == nil || value < 0 {\n\t\tr.value = []byte(\"false\")\n\t\treturn r\n\t}\n\n\tentry.ttl = value\n\tr.value = []byte(\"true\")\n\n\treturn r\n}", "title": "" }, { "docid": "a488b1800df14c9a69ffd706fbf1b504", "score": "0.5616149", "text": "func SetValue(key string, value interface{}) error {\n\tvar err error\n\tif err = redisClient.Set(key, value, 0).Err(); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "d7a99cf081e66637f85cc6f8560bec20", "score": "0.55960447", "text": "func TestSet(t *testing.T) {\n\terr := mcache.Set(key2, dataSet, TTL_FOREVER)\n\tif err != nil {\n\t\tt.Errorf(\"Error %s cache data: %v, ERROR_MSG: %v\", t.Name(), dataSet, err)\n\t}\n\tlog.Printf(\"%s : OK\\n\", t.Name())\n}", "title": "" }, { "docid": "68e11d1c2ecdd15c60a828f8ace8c4c9", "score": "0.5584781", "text": "func (c *Cache) Set(_ context.Context, key dataloader.Key, value dataloader.Thunk) {\n\tc.c.Set(key.String(), value, 0)\n}", "title": "" }, { "docid": "9fc1dca155b0285b95e2c5daa4231895", "score": "0.5574233", "text": "func (d *Dao) Set(key string, value string, timeout int64) error {\n\t_, err := d.xredisClient.SetEx(key, value, timeout)\n\treturn err\n}", "title": "" }, { "docid": "e7146656e8c169f0e3eb9f62a709c23a", "score": "0.5561213", "text": "func (s *Store) Set(key, value string) error {\n\tif s.raft.State() != raft.Leader {\n\t\treturn fmt.Errorf(\"not leader\")\n\t}\n\n\tc := &command{\n\t\tOp: \"set\",\n\t\tKey: key,\n\t\tValue: value,\n\t}\n\tb, err := json.Marshal(c)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tf := s.raft.Apply(b, raftTimeout)\n\treturn f.Error()\n}", "title": "" }, { "docid": "32601d97574929f1a217bad9b5c9314f", "score": "0.55554384", "text": "func testSetGet(i int, c chan bool) {\n\tmemCon, err := newMemcacheConnection(serverAddress)\n\tif err != nil {\n\t\tfmt.Println(\"Error: \", err)\n\t\tc <- false\n\t\treturn\n\t}\n\n\tdefer memCon.Close()\n\n\tvar response string\n\tkey := \"key\" + strconv.Itoa(i) + \".ryoost\"\n\tvalue := \"This is the \" + strconv.Itoa(i) + \"th value at %s\" + time.Now().String()\n\tresponse, err = memCon.set(key, value)\n\tif err != nil {\n\t\tfmt.Println(\"Error: \", err)\n\t}\n\tif response == \"NOT-STORED\\r\\n\" {\n\t\tc <- false\n\t\treturn\n\t}\n\n\tvar gotValue string\n\tgotValue, err = memCon.get(key)\n\tif err != nil {\n\t\tfmt.Println(\"Error: \", err)\n\t}\n\n\tc <- value == gotValue\n\n}", "title": "" }, { "docid": "387b8b9f0f5c7204f97355ed3fea0229", "score": "0.55513465", "text": "func (p *Pool) SetValue(key string, value string, expiration ...interface{}) error {\n\tif p.Connection != nil {\n\n\t\tconn := p.Connection.Get()\n\t\tdefer conn.Close()\n\n\t\t_, err := conn.Do(\"SET\", key, value)\n\n\t\tif err == nil && expiration != nil {\n\t\t\tp.Connection.Get().Do(\"EXPIRE\", key, expiration[0])\n\t\t}\n\n\t\treturn err\n\t}\n\n\treturn errors.New(\"Redis cache not initialized\")\n}", "title": "" }, { "docid": "2cfe43e66d715db646df1a2582653a0e", "score": "0.55449575", "text": "func (client *RedisClient) SetValue(key string, value string, expiration time.Duration) error {\n err := client.connection.Set(client.buildRedisKey(key), value, expiration).Err()\n if err != nil {\n return errors.RedisSetValueError.ToErrorWithArguments(err, key)\n }\n return nil\n}", "title": "" }, { "docid": "10a98ddcb6fc2d49ecf15e83e0732ceb", "score": "0.5531344", "text": "func (c *cache) Set(k string, x string, d time.Duration) {\n\tc.consumerChannel <- []string{\"set\", k, x}\n}", "title": "" }, { "docid": "120a5aa4df8528399d0a8be8d107f101", "score": "0.5513798", "text": "func (c *atomicConnectionClass) set(cc rpc.ConnectionClass) {\n\tatomic.StoreUint32((*uint32)(c), uint32(cc))\n}", "title": "" }, { "docid": "671bf5f6e0b4e5af68ef7929cb1c7897", "score": "0.5507685", "text": "func (r *Redis) set(key string, value interface{}, expiration time.Duration) error {\n\tif expiration == 0 {\n\t\texpiration = defaultExpiration\n\t}\n\n\titem := &rediscache.Item{\n\t\tKey: keyWithPrefix(key),\n\t\tObject: value,\n\t\tExpiration: expiration,\n\t}\n\n\treturn r.codec.Set(item)\n}", "title": "" }, { "docid": "95032b43802558353a0c218af395b983", "score": "0.5503952", "text": "func (r *Redigo) Set(ctx context.Context, items ...cachebox.Item) error {\n\tconn, err := r.pool.GetContext(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer conn.Close() //nolint:errcheck\n\n\tfor _, item := range items {\n\t\tif err := conn.Send(\"SETEX\", item.Key, int32(item.TTL.Seconds()), item.Value); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn conn.Flush()\n}", "title": "" }, { "docid": "c42b3d605a0c9a0b630e74761481855e", "score": "0.54966384", "text": "func (c *CiderClient) Set(key, value string) (err error) {\n\t_, err = c.Send(SprintfEscape(\"SET %v %v\", key, value))\n\treturn\n}", "title": "" }, { "docid": "d523d46d86edb3250499e01b3bc064f5", "score": "0.5479836", "text": "func (m *MuninRunner) setCredentials(command *exec.Cmd, cache *CredentialCache) error {\n\tif err := m.applyCommandUser(command, m.user, cache); err != nil {\n\t\treturn err\n\t}\n\n\tif err := m.applyCommandGroup(command, m.group, cache); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "dd588ec206b32dd7ce21503201c2bf50", "score": "0.54731995", "text": "func (s *RedisClusterStore) Set(ctx context.Context, key any, value any, options ...lib_store.Option) error {\n\topts := lib_store.ApplyOptionsWithDefault(s.options, options...)\n\n\terr := s.clusclient.Set(ctx, key.(string), value, opts.Expiration).Err()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif tags := opts.Tags; len(tags) > 0 {\n\t\ts.setTags(ctx, key, tags)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "b52a21945ce6d05002b49299f9a7db4c", "score": "0.5471034", "text": "func (s *Store) Set(key string, value []byte) error {\n\tif s.raft.State() != raft.Leader {\n\t\treturn fmt.Errorf(\"not leader\")\n\t}\n\n\tc := &command{\n\t\tOp: \"set\",\n\t\tKey: key,\n\t\tValue: value,\n\t}\n\tb, err := msgpack.Marshal(c)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tf := s.raft.Apply(b, raftTimeout)\n\treturn f.Error()\n}", "title": "" }, { "docid": "43618e73c202f606a61bac4fa0a4c488", "score": "0.5470211", "text": "func execSetEX(db *DB, args [][]byte) redis.Reply {\n\tkey := string(args[0])\n\tvalue := args[2]\n\n\tttlArg, err := strconv.ParseInt(string(args[1]), 10, 64)\n\tif err != nil {\n\t\treturn &reply.SyntaxErrReply{}\n\t}\n\tif ttlArg <= 0 {\n\t\treturn reply.MakeErrReply(\"ERR invalid expire time in setex\")\n\t}\n\tttl := ttlArg * 1000\n\n\tentity := &DataEntity{\n\t\tData: value,\n\t}\n\n\tdb.PutEntity(key, entity)\n\texpireTime := time.Now().Add(time.Duration(ttl) * time.Millisecond)\n\tdb.Expire(key, expireTime)\n\tdb.AddAof(makeAofCmd(\"setex\", args))\n\tdb.AddAof(makeExpireCmd(key, expireTime))\n\treturn &reply.OkReply{}\n}", "title": "" }, { "docid": "ab438de046bcd0fee1c46fefb64af973", "score": "0.5456167", "text": "func (c *Cache) set(key uint64, msg *dns.Msg, mt response.Type, duration time.Duration) {\n\tswitch mt {\n\tcase response.NoError, response.Delegation, response.NameError, response.NoData:\n\t\ti := newItem(msg, c.now(), duration, c.rate)\n\t\tc.pcache.Add(key, i)\n\n\tcase response.OtherError:\n\t\ti := newItem(msg, c.now(), duration, c.rate)\n\t\tc.ncache.Add(key, i)\n\t}\n}", "title": "" }, { "docid": "e7f9f480e7a90bb5cc57a15404caa95d", "score": "0.54455173", "text": "func execSet(db *DB, args [][]byte) redis.Reply {\n\tkey := string(args[0])\n\tvalue := args[1]\n\tpolicy := upsertPolicy\n\tttl := unlimitedTTL\n\n\t// parse options\n\tif len(args) > 2 {\n\t\tfor i := 2; i < len(args); i++ {\n\t\t\targ := strings.ToUpper(string(args[i]))\n\t\t\tif arg == \"NX\" { // insert\n\t\t\t\tif policy == updatePolicy {\n\t\t\t\t\treturn &reply.SyntaxErrReply{}\n\t\t\t\t}\n\t\t\t\tpolicy = insertPolicy\n\t\t\t} else if arg == \"XX\" { // update policy\n\t\t\t\tif policy == insertPolicy {\n\t\t\t\t\treturn &reply.SyntaxErrReply{}\n\t\t\t\t}\n\t\t\t\tpolicy = updatePolicy\n\t\t\t} else if arg == \"EX\" { // ttl in seconds\n\t\t\t\tif ttl != unlimitedTTL {\n\t\t\t\t\t// ttl has been set\n\t\t\t\t\treturn &reply.SyntaxErrReply{}\n\t\t\t\t}\n\t\t\t\tif i+1 >= len(args) {\n\t\t\t\t\treturn &reply.SyntaxErrReply{}\n\t\t\t\t}\n\t\t\t\tttlArg, err := strconv.ParseInt(string(args[i+1]), 10, 64)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn &reply.SyntaxErrReply{}\n\t\t\t\t}\n\t\t\t\tif ttlArg <= 0 {\n\t\t\t\t\treturn reply.MakeErrReply(\"ERR invalid expire time in set\")\n\t\t\t\t}\n\t\t\t\tttl = ttlArg * 1000\n\t\t\t\ti++ // skip next arg\n\t\t\t} else if arg == \"PX\" { // ttl in milliseconds\n\t\t\t\tif ttl != unlimitedTTL {\n\t\t\t\t\treturn &reply.SyntaxErrReply{}\n\t\t\t\t}\n\t\t\t\tif i+1 >= len(args) {\n\t\t\t\t\treturn &reply.SyntaxErrReply{}\n\t\t\t\t}\n\t\t\t\tttlArg, err := strconv.ParseInt(string(args[i+1]), 10, 64)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn &reply.SyntaxErrReply{}\n\t\t\t\t}\n\t\t\t\tif ttlArg <= 0 {\n\t\t\t\t\treturn reply.MakeErrReply(\"ERR invalid expire time in set\")\n\t\t\t\t}\n\t\t\t\tttl = ttlArg\n\t\t\t\ti++ // skip next arg\n\t\t\t} else {\n\t\t\t\treturn &reply.SyntaxErrReply{}\n\t\t\t}\n\t\t}\n\t}\n\n\tentity := &DataEntity{\n\t\tData: value,\n\t}\n\n\tdb.Persist(key) // clean ttl\n\tvar result int\n\tswitch policy {\n\tcase upsertPolicy:\n\t\tresult = db.PutEntity(key, entity)\n\tcase insertPolicy:\n\t\tresult = db.PutIfAbsent(key, entity)\n\tcase updatePolicy:\n\t\tresult = db.PutIfExists(key, entity)\n\t}\n\t/*\n\t * 如果设置了ttl 则以最新的ttl为准\n\t * 如果没有设置ttl 是新增key的情况,不设置ttl。\n\t * 如果没有设置ttl 且已存在key的 不修改ttl 但需要增加aof\n\t */\n\tif ttl != unlimitedTTL {\n\t\texpireTime := time.Now().Add(time.Duration(ttl) * time.Millisecond)\n\t\tdb.Expire(key, expireTime)\n\t\tdb.AddAof(reply.MakeMultiBulkReply([][]byte{\n\t\t\t[]byte(\"SET\"),\n\t\t\targs[0],\n\t\t\targs[1],\n\t\t}))\n\t\tdb.AddAof(makeExpireCmd(key, expireTime))\n\t} else if result > 0 {\n\t\tdb.Persist(key) // override ttl\n\t\tdb.AddAof(makeAofCmd(\"set\", args))\n\t} else {\n\t\tdb.AddAof(makeAofCmd(\"set\", args))\n\t}\n\n\tif policy == upsertPolicy || result > 0 {\n\t\treturn &reply.OkReply{}\n\t}\n\treturn &reply.NullBulkReply{}\n}", "title": "" }, { "docid": "e9440a09a303fad9547f4c2ffcb7f9a1", "score": "0.5437592", "text": "func (c *Client) Set(key string, data interface{}, seconds int64) error {\n\tvar payload interface{}\n\t// k := reflect.ValueOf(data).Kind()\n\tjsonBytes, errJSON := json.Marshal(data) // try to marshal it to json, when failed set payload as it is.\n\tif errJSON != nil {\n\t\treturn errJSON\n\t}\n\tpayload = string(jsonBytes)\n\tcmd := c.rc.Set(key, payload, time.Duration(seconds)*time.Second)\n\tok, err := cmd.Result()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif ok != \"OK\" {\n\t\treturn e.Service(\"REDIS_ERR\", \"redis\", errors.New(\"failed saving data to redis\"))\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "1778a16be64b9d57b7e16ed0d9203546", "score": "0.54343027", "text": "func (s *Server) Set(ctx context.Context, msg *pb.SetRequest) (*pb.SetResponse, error) {\n\t// Define reply message\n\tr := &pb.SetResponse{\n\t\tStatus: &pb.Status{\n\t\t\tCode: 0,\n\t\t\tDescription: \"Success\",\n\t\t},\n\t}\n\n\t// Check key length\n\tif len(msg.Key) == 0 {\n\t\tlog.Trace(\"Key is not defined within request\")\n\t\tr.Status.Code = 4\n\t\tr.Status.Description = \"Key not defined in request\"\n\t\treturn r, nil\n\t}\n\n\t// Create data item for insertion\n\td := &databases.Data{}\n\td.Data = msg.Data\n\td.LastUpdated = time.Now().UnixNano()\n\n\t// Insert data into datastore\n\terr := db.Set(msg.Key, d)\n\tif err != nil {\n\t\tlog.WithFields(logrus.Fields{\"key\": msg.Key, \"error\": err}).Tracef(\"Failed to store data for key - %s\", err)\n\t\tr.Status.Code = 5\n\t\tr.Status.Description = \"Error storing data within datastore\"\n\t\treturn r, nil\n\t}\n\n\tr.Key = msg.Key\n\treturn r, nil\n}", "title": "" }, { "docid": "667354b0e4ea8a2d0b92743a663ffbd2", "score": "0.5412023", "text": "func (c *Redis) Set(k, v string, x time.Duration) (bool, error) {\n\terr := c.cli.Set(ctx, k, v, x).Err()\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"unable to set key: %s, error: %v\", k, err)\n\t}\n\treturn true, nil\n}", "title": "" }, { "docid": "4c6488d387f91dc528236e2f7e5b2928", "score": "0.54014105", "text": "func (p *Provider) Set(ctx context.Context, key string, data []byte) (err error) {\n\tif key == \"seterror\" {\n\t\treturn fmt.Errorf(\"seterror\")\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "8ce28fbf3be620a062df9cec258b520d", "score": "0.53994685", "text": "func (r *DB) SetCommandBreaker(commandName string, timeout, maxConcurrent int, args ...interface{}) *DB {\n\n\tr.commandName = &commandName\n\tr.retryCount = r.config.CB.Retry\n\tif len(args) == 1 {\n\t\tswitch args[0].(type) {\n\t\tcase fallbackFunc:\n\t\t\tr.fallbackFunc = args[0].(fallbackFunc)\n\t\t}\n\t}\n\n\thystrix.ConfigureCommand(commandName, hystrix.CommandConfig{\n\t\tMaxConcurrentRequests: maxConcurrent,\n\t\tTimeout: timeout,\n\t\tErrorPercentThreshold: 25,\n\t})\n\n\treturn r\n}", "title": "" }, { "docid": "a060ac930205aa743f97287daede6e0c", "score": "0.53925306", "text": "func (c *memcache) Set(key string, value string) {\n\tc.mu.Lock()\n\tc.data[key] = value\n\tc.mu.Unlock()\n}", "title": "" }, { "docid": "50c031030b5d19c2ea192f50ffad4337", "score": "0.5391586", "text": "func (c *Conn) SetCommand(ctx context.Context, cmd api.Command) error {\n\treturn c.SetState(ctx, &api.State{\n\t\tCommand: cmd,\n\t})\n}", "title": "" }, { "docid": "9e008e0092fcdb6892296646665acab6", "score": "0.539148", "text": "func (c *Cache) Set(key interface{}, value interface{}) (interface{}, error) {\n\trespChannel := make(chan *response)\n\tc.requestChannel <- &request{\n\t\trequestType: SET,\n\t\tkey: key,\n\t\tvalue: value,\n\t\tresponseChannel: respChannel,\n\t}\n\tresp := <-respChannel\n\treturn resp.existingValue, resp.error\n}", "title": "" }, { "docid": "0d567a94b6365ab2c7f9e56e86676b45", "score": "0.53759056", "text": "func (c *Cache) Set(key string, val interface{}, timeout time.Duration) (err error) {\n\ttime := int(timeout / time.Second)\n\tc.client.Set(key, val, time)\n\treturn nil\n}", "title": "" }, { "docid": "83447bc271615fde12db1a90d7c62a50", "score": "0.5371461", "text": "func (s *Session) ClientSet(key string, data string) {\n\t// Send the request to the client.\n\ts.SendCommand(`Bulldozer.data.set('` + utils.EscapeJS(key) + `','` + utils.EscapeJS(data) + `');`)\n\n}", "title": "" }, { "docid": "37b12aeec4e75f470d422ae3eeccb2eb", "score": "0.53544974", "text": "func (s *CassandraStore) Set(key string, value []byte, ttl int) error {\n\tquery := fmt.Sprintf(`INSERT INTO \"%s\".\"%s\" (key, value) VALUES (?,?) USING TTL ?`, s.Keyspace, s.Table)\n\treturn s.session.Query(query, key, value, ttl).Consistency(gocql.LocalQuorum).Exec()\n}", "title": "" }, { "docid": "91b59018a9668cbe97b529ea0e234956", "score": "0.5351185", "text": "func (c *backingCache) Set(ctx context.Context, key string, val atomic_miss_cache.Value) error {\n\tcv := val.(*CachedValue)\n\tif !cv.RepoState.Valid() {\n\t\treturn fmt.Errorf(\"Invalid RepoState: %+v\", cv.RepoState)\n\t}\n\treturn WriteTasksCfgToBigTable(ctx, c.table, key, cv)\n}", "title": "" }, { "docid": "257acf216f414a64f7c242c629079fd9", "score": "0.53450555", "text": "func (c *CacheStore) Set(cKey string, d *HeadlessResponse) error {\n\n\tswitch c.Type {\n\tcase typeLocal:\n\t\tc.gocache.Set(cKey, d, cache.DefaultExpiration)\n\tcase typeRedis:\n\t\top := &bytes.Buffer{}\n\t\tenc := json.NewEncoder(op)\n\t\tenc.SetEscapeHTML(false)\n\t\terr := enc.Encode(d)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = c.redis.SetNX(cKey, string(op.Bytes()), c.DefaultTimeout).Err()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\tcase typeNone:\n\tdefault:\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "a84252134f3174a56e34f8d01d1eaa3c", "score": "0.534385", "text": "func set(stub shim.ChaincodeStubInterface, args []string) (string, error) {\n if len(args) != 2 {\n return \"\", fmt.Errorf(\"Incorrect arguments. Expecting a key and a value\")\n }\n\n err := stub.PutState(args[0], []byte(args[1]))\n if err != nil {\n return \"\", fmt.Errorf(\"Failed to set asset: %s\", args[0])\n }\n return args[1], nil\n}", "title": "" }, { "docid": "f688baea05075349f25a97692205492a", "score": "0.5343113", "text": "func (tran *Transaction) Do(command string, args ...interface{}) (interface{}, error) {\n\tswitch command{\n\tcase \"SET\",\"DEL\":\n\t\tsetMap :=(tran.LastKV[\"SET\"]).(map[interface{}]interface{})\n\t\tif checkLength(command,args...){\n\t\t\ttemp,er :=tran.Con.Do(\"GET\",args[0])\n\t\t\tif er!=nil{\n\t\t\t\t setMap[args[0]]=\"\"\n\t\t\t}\n\t\t\tsetMap[args[0]]=temp\n\t\t}else{\n\t\t\treturn nil,errors.New(command+\"参数数量错误\")\n\t\t}\n\tcase \"HSET\",\"HDEL\":\n\t\tif checkLength(command,args...) {\n\t\t\thSetMap := (tran.LastKV[\"HSET\"]).(map[interface{}]interface{})\n\t\t\ttemp, _ := tran.Con.Do(\"HGET\", args[0], args[1])\n\t\t\tvar inMap map[interface{}]interface{}\n\t\t\tif hSetMap[args[0]] != nil {\n\t\t\t\tinMap = hSetMap[args[0]].(map[interface{}]interface{})\n\t\t\t} else {\n\t\t\t\tinMap = make(map[interface{}]interface{})\n\t\t\t}\n\t\t\tinMap[args[1]] = temp\n\t\t\thSetMap[args[0]] = inMap\n\t\t}else{\n\t\t\treturn nil,errors.New(command+\"参数数量错误\")\n\t\t}\n\t//default:\n\t//\treturn tran.Con.Do(command, args...)\n\t}\n\treturn tran.Con.Do(command, args...)\n}", "title": "" }, { "docid": "d18221f94524e6e37f6ec3cda26e4151", "score": "0.53388804", "text": "func (r redisClient) Set(key, field string, value interface{}) error {\n\treturn r.Client.HSet(key, field, value).Err()\n}", "title": "" }, { "docid": "a2b9019dcd7aa66d8197628326565c76", "score": "0.5338578", "text": "func (client *ClientConn) handleSet(req *Header, extras, key, value []byte) error {\n\tlog.Printf(\"INFO: [%d] - set\\n\", client.id)\n\n\tif len(extras) != 8 || len(value) == 0 {\n\t\tresp := NewResponse(req.Opcode, STATUS_INVALID_ARGUMENT,\n\t\t\tnil, nil, nil, req.Opaque, 0)\n\t\treturn WriteResponse(client.bio, &resp, nil, nil, nil)\n\t}\n\n\tver, ok := client.cache.Set(key, value, extras[0:4], req.Cas)\n\n\tresp := NewResponse(req.Opcode, ok, nil, nil, nil, req.Opaque, ver)\n\treturn WriteResponse(client.bio, &resp, nil, nil, nil)\n}", "title": "" }, { "docid": "ca049cf8ad05a3356690fa09c19b2f9c", "score": "0.53382254", "text": "func (this *RedisStateStore) Set(key string, value string) error {\n\tkey = this.KeyPath + \".\" + key\n\tclient := this.rds\n\terr := client.Set(key, value, 0).Err()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to set key %s, error %v\", key, err)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "8cd2175949ec5a318a89165e7cae740c", "score": "0.5333668", "text": "func (sm *SetMethod) Invoke(ctx *KContext, args map[string][]byte) (*contract.Response, error) {\n\tif args[\"Bucket\"] == nil || args[\"Key\"] == nil || args[\"Value\"] == nil {\n\t\treturn nil, fmt.Errorf(\"invoke Set failed, args are invalid: %v\", args)\n\t}\n\tbucket := string(args[\"Bucket\"])\n\tkey := args[\"Key\"]\n\tvalue := args[\"Value\"]\n\t_, err := ctx.ModelCache.Get(bucket, key)\n\terr = ctx.ModelCache.Put(bucket, key, value)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &contract.Response{\n\t\tStatus: contract.StatusOK,\n\t\tBody: value,\n\t}, nil\n}", "title": "" }, { "docid": "3cdb1cdaed3c35907cd0a671c7b76a29", "score": "0.53292984", "text": "func SetValue(key string, value interface{}) (bool, error) {\n\tserializedValue, _ := json.Marshal(value)\n\terr := redisClient.Set(key, string(serializedValue), 0).Err()\n\treturn true, err\n}", "title": "" }, { "docid": "fea19bac0efd25d6a41ddaa480b79fad", "score": "0.53282386", "text": "func execPSetEX(db *DB, args [][]byte) redis.Reply {\n\tkey := string(args[0])\n\tvalue := args[2]\n\n\tttlArg, err := strconv.ParseInt(string(args[1]), 10, 64)\n\tif err != nil {\n\t\treturn &reply.SyntaxErrReply{}\n\t}\n\tif ttlArg <= 0 {\n\t\treturn reply.MakeErrReply(\"ERR invalid expire time in setex\")\n\t}\n\n\tentity := &DataEntity{\n\t\tData: value,\n\t}\n\n\tdb.PutEntity(key, entity)\n\texpireTime := time.Now().Add(time.Duration(ttlArg) * time.Millisecond)\n\tdb.Expire(key, expireTime)\n\tdb.AddAof(makeAofCmd(\"setex\", args))\n\tdb.AddAof(makeExpireCmd(key, expireTime))\n\n\treturn &reply.OkReply{}\n}", "title": "" }, { "docid": "7c5b8319cdb74695cab2ef70eaa75fa7", "score": "0.53193045", "text": "func (r *Redis) Set(ctx context.Context, key string, value interface{}, expiration time.Duration, retry bool) error {\n\tvar err error\n\tretries := 1\n\tif retry {\n\t\tretries = defaultRetries\n\t}\n\n\tfor i := 0; i < retries; i++ {\n\t\tif err = r.set(key, value, expiration); err == nil {\n\t\t\treturn nil\n\t\t}\n\n\t\tlog.Debug().Msgf(\"failed to set cache item. retry #%v for key: %s, with error: %v\", i, key, err)\n\t}\n\n\treturn err\n}", "title": "" }, { "docid": "e0fd66837e691492dee450ce66ee8fcf", "score": "0.53137296", "text": "func (r *Set) Execute(s *Session) (bool, error) {\n\t// zero r.val is acceptable but r.val must not be nil.\n\tif r.key == nil || len(r.key) == 0 || r.val == nil || r.result == nil {\n\t\treturn false, fmt.Errorf(\"required members nil, r.key %v, r.val %v, r.result %v\", r.key, r.val, r.result)\n\t}\n\tcKey := C.CBytes(r.key)\n\tdefer C.free(cKey)\n\tcVal := C.CBytes(r.val)\n\tdefer C.free(cVal)\n\tcPass := C.CString(r.pass)\n\tdefer C.free(unsafe.Pointer(cPass))\n\tvar expire *C.time_t\n\t// WARNING: You can't set zero expire.\n\tif r.expire != 0 {\n\t\texpire = (*C.time_t)(&r.expire)\n\t}\n\tr.result.ok = C.k2hdkc_pm_set_value_wa(\n\t\ts.handler,\n\t\t(*C.uchar)(cKey),\n\t\tC.size_t(len(r.key)),\n\t\t(*C.uchar)(cVal),\n\t\tC.size_t(len(r.val)),\n\t\tC._Bool(r.rmSubKeyList),\n\t\tcPass,\n\t\texpire)\n\tr.result.resCode = C.k2hdkc_get_res_code(s.handler)\n\tr.result.subResCode = C.k2hdkc_get_res_subcode(s.handler)\n\n\tif r.result.ok == false {\n\t\treturn false, errors.New(\"C.k2hdkc_pm_set_value_wa returned false\")\n\t}\n\treturn true, nil\n}", "title": "" }, { "docid": "57813ce9344ca365d14f1c83e2bc24e1", "score": "0.5285022", "text": "func (r *Redis) Set(key, value []byte) error {\n\tconn := r.pool.Get()\n\tdefer conn.Close()\n\t// https://redis.io/commands/setnx\n\ti, err := redis.Int(conn.Do(\"SETNX\", key, value))\n\tif err != nil {\n\t\treturn err\n\t}\n\tif i == 0 {\n\t\treturn fmt.Errorf(\"Key already exists\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "fce6f0fa3e4500c46bcbd4c1ff05b60b", "score": "0.528486", "text": "func (c *Context) Set(args *shared_server.ScoreItem, reply *int) error {\n\treturn c.rpcContext.Call(\"Set\", args, reply)\n}", "title": "" }, { "docid": "6d74d1919cb31675de1a0848d5c42d39", "score": "0.52818173", "text": "func (ns *NodeStorage) Set(key, val []byte) error {\n\t// if not leader should not accept any write.\n\tif !ns.IsLeader() {\n\t\treturn errNotLeader\n\t}\n\t// try protobuff\n\tcmd := pkv.LogEntryData{Op: pkv.LogEntryData_SET, Key: key, Value: val}\n\tb, err := proto.Marshal(&cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ns.tryQuorum(b)\n}", "title": "" }, { "docid": "df023ca26151e41751bc1f0645b6acbf", "score": "0.5280832", "text": "func (c *Client) Set(path string, data []byte, version int32) error {\n\terr := c.retryUntilConnected(func() error {\n\t\t_, err := c.getConn().Set(path, data, version)\n\t\treturn err\n\t})\n\treturn errors.Wrapf(err, \"zk client failed to set data at %s\", path)\n}", "title": "" }, { "docid": "36a56be90e3d88e9855b892c8c93e5ef", "score": "0.5278281", "text": "func (d *Dao) SetUserCache(c context.Context, mid int64, status model.BlockStatus, startTime, endTime int64) (err error) {\n\tvar (\n\t\tkey = userKey(mid)\n\t\tconn = d.mc.Get(c)\n\t\tinfo = &model.MCBlockInfo{\n\t\t\tBlockStatus: status,\n\t\t\tStartTime: startTime,\n\t\t\tEndTime: endTime,\n\t\t}\n\t)\n\tlog.Info(\"Set User Cache key (%s) obj (%+v)\", key, info)\n\tdefer conn.Close()\n\tif err = conn.Set(&memcache.Item{\n\t\tKey: key,\n\t\tObject: info,\n\t\tExpiration: d.mcUserExpire(key),\n\t\tFlags: memcache.FlagJSON,\n\t}); err != nil {\n\t\terr = (err)\n\t\treturn\n\t}\n\treturn\n}", "title": "" }, { "docid": "2da32420fcb85a2525a40f70e6872c46", "score": "0.5277511", "text": "func (r *Redis) Set(key, value string, expiration time.Duration) (bool, error) {\n\tresult := r.Client.Set(key, value, expiration)\n\n\tif result.Err() != nil {\n\t\treturn false, result.Err()\n\t}\n\n\treturn result.Val() == \"OK\", nil\n}", "title": "" }, { "docid": "8febbc09df4da385ba769f2d90a1db54", "score": "0.5269068", "text": "func (c Client) SetString(key BaseRedisKey, value string) error {\n\tconn := c.getConnection()\n\t_, err := conn.Do(\"SET\", key, value)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not set key %s: %s\", key, err.Error())\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "f944085802befe00319c228817dbfcac", "score": "0.5266843", "text": "func (r *Redis) MSet(keys []string, values []interface{}, duration time.Duration) error {\n\tvar ifaces []interface{}\n\tpipe := r.Client.TxPipeline()\n\tfor i := range keys {\n\t\tkey := keys[i]\n\t\tkey = buildServiceKey(key)\n\n\t\tifaces = append(ifaces, key, values[i])\n\t\tpipe.Expire(key, duration)\n\t}\n\n\tif err := r.Client.MSet(ifaces...).Err(); err != nil {\n\t\treturn err\n\t}\n\n\tif _, err := pipe.Exec(); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "38ef3512b47dafae7cbac20e85099183", "score": "0.52661544", "text": "func (c *Clusterclient) Set(key, value string, exp int) {\n\texpiration := time.Duration(exp) * time.Millisecond\n\t_, err := c.clusterclient.Set(c.clusterclient.Context(), key, value, expiration).Result()\n\tif err != nil {\n\t\tfmt.Println(fmt.Sprintf(\"error seting key %v\", err))\n\t}\n}", "title": "" } ]
9647b873210526979d097a3177472b54
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be nonnil.
[ { "docid": "6502eb4511d14b46184710050bf0959d", "score": "0.7894612", "text": "func (in *Docker) DeepCopyInto(out *Docker) {\n\t*out = *in\n\treturn\n}", "title": "" } ]
[ { "docid": "6d3c7f706ada34b172e55056fd08da9b", "score": "0.8279333", "text": "func (in *Ipxe) DeepCopyInto(out *Ipxe) {\n\t*out = *in\n}", "title": "" }, { "docid": "1c2d70d782e9a1af879ef1c56794f835", "score": "0.82406765", "text": "func (in *Data) DeepCopyInto(out *Data) {\n\t*out = *in\n}", "title": "" }, { "docid": "c6850f95c4b786dfb720021fee99aac3", "score": "0.81070966", "text": "func (in *Version) DeepCopyInto(out *Version) {\n\t*out = *in\n}", "title": "" }, { "docid": "ba7c8360408ac096e3adb773d7271afe", "score": "0.8105864", "text": "func (in *Fluentd) DeepCopyInto(out *Fluentd) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "b819c01a4847e2b7250bf24ee066a2a6", "score": "0.80966014", "text": "func (in *PachydermRestore) DeepCopyInto(out *PachydermRestore) {\n\t*out = *in\n}", "title": "" }, { "docid": "d25ee8020a516841733ada81b932cfb8", "score": "0.80923074", "text": "func (in *Osie) DeepCopyInto(out *Osie) {\n\t*out = *in\n}", "title": "" }, { "docid": "ca54ebd80220b5981408fecbbe316176", "score": "0.80904734", "text": "func (in *DBInfo) DeepCopyInto(out *DBInfo) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "fd68cc5c404d65fa5c03c64949665da7", "score": "0.80897367", "text": "func (in *Size) DeepCopyInto(out *Size) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "be58e6c182cda9967f881999acd59c2f", "score": "0.8079092", "text": "func (in *Debug) DeepCopyInto(out *Debug) {\n\t*out = *in\n}", "title": "" }, { "docid": "afe2a3f4b3b9253dedc6bb9e45e3d492", "score": "0.8078006", "text": "func (in *AchievedStep) DeepCopyInto(out *AchievedStep) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "566b517300fca63a0f999b4e20011d0f", "score": "0.80758965", "text": "func (in *Keto) DeepCopyInto(out *Keto) {\n\t*out = *in\n}", "title": "" }, { "docid": "0402379222701ce5cbc47a58147b675c", "score": "0.80742425", "text": "func (in *EclipseChe) DeepCopyInto(out *EclipseChe) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "8c157f4759e96806dd0b74060472d480", "score": "0.8063352", "text": "func (in *Node) DeepCopyInto(out *Node) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "8c157f4759e96806dd0b74060472d480", "score": "0.8063352", "text": "func (in *Node) DeepCopyInto(out *Node) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "a082503dcbc413c6f686bfa34ed34463", "score": "0.8056361", "text": "func (in *NodeInterface) DeepCopyInto(out *NodeInterface) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "d4907b7e87f96cc9f592e887afb9927d", "score": "0.8051146", "text": "func (in *Node) DeepCopyInto(out *Node) {\n\t*out = *in\n}", "title": "" }, { "docid": "bf7b4b522057ae01ab0d93d4522fe30a", "score": "0.80479336", "text": "func (in *ObjectRef) DeepCopyInto(out *ObjectRef) {\n\t*out = *in\n}", "title": "" }, { "docid": "4d63c7d1929a6b53ca46be5738e434a5", "score": "0.80312425", "text": "func (in *OutputEntry) DeepCopyInto(out *OutputEntry) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "6eec4c5e3d639e136aafd047e93f99cd", "score": "0.8029222", "text": "func (in *JSONCheck) DeepCopyInto(out *JSONCheck) {\n\t*out = *in\n}", "title": "" }, { "docid": "1c3455c7f0a06e92261a5b10b622ca06", "score": "0.80243576", "text": "func (in *Fateflow) DeepCopyInto(out *Fateflow) {\n\t*out = *in\n}", "title": "" }, { "docid": "5b24c3ee0cabe62c71b4995b5197f3e8", "score": "0.80212104", "text": "func (in *ObjectSelector) DeepCopyInto(out *ObjectSelector) {\n\t*out = *in\n}", "title": "" }, { "docid": "554e9c3fc35ac1866e0c1f4c3107b730", "score": "0.8010892", "text": "func (in *PathTest) DeepCopyInto(out *PathTest) {\n\t*out = *in\n}", "title": "" }, { "docid": "2f2cf86d90535cd828decdd6d982e087", "score": "0.8003615", "text": "func (in *Output) DeepCopyInto(out *Output) {\n\t*out = *in\n\tif in.output != nil {\n\t\tin, out := &in.output, &out.output\n\t\t*out = make([]OutputEntry, len(*in))\n\t\tcopy(*out, *in)\n\t}\n\treturn\n}", "title": "" }, { "docid": "e1c2499dce71eea1ba530425d987e65d", "score": "0.8000417", "text": "func (in *OutputType) DeepCopyInto(out *OutputType) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "873314226084acb05455ef131ac0e4e6", "score": "0.79890496", "text": "func (in *Nodeport) DeepCopyInto(out *Nodeport) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "3dfe5656fa02ed58112cacdc9eac4f47", "score": "0.7979421", "text": "func (in *VMSpec) DeepCopyInto(out *VMSpec) {\n\t*out = *in\n}", "title": "" }, { "docid": "8edce588d322f861d4f46b2f3aae92a8", "score": "0.7977874", "text": "func (in *TaskRef) DeepCopyInto(out *TaskRef) {\n\t*out = *in\n}", "title": "" }, { "docid": "8edce588d322f861d4f46b2f3aae92a8", "score": "0.7977874", "text": "func (in *TaskRef) DeepCopyInto(out *TaskRef) {\n\t*out = *in\n}", "title": "" }, { "docid": "09a622ae41a2172d4fd07d376190f880", "score": "0.7972777", "text": "func (in *Runtime) DeepCopyInto(out *Runtime) {\n\t*out = *in\n}", "title": "" }, { "docid": "be82863d9978b104237d2472cfdf3614", "score": "0.79602563", "text": "func (in *CrossVersionObjectReference) DeepCopyInto(out *CrossVersionObjectReference) {\n\t*out = *in\n}", "title": "" }, { "docid": "fcd61e82f34db96b76efba6276644908", "score": "0.79566926", "text": "func (in *ObjectSelector) DeepCopyInto(out *ObjectSelector) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "ee7f1891e9e6a3a794787c1609ae9fd7", "score": "0.7951786", "text": "func (in *Exchange) DeepCopyInto(out *Exchange) {\n\t*out = *in\n}", "title": "" }, { "docid": "b37c436bd18ef0f2ea068cd1e94529fb", "score": "0.7951687", "text": "func (in *Partitions) DeepCopyInto(out *Partitions) {\n\t*out = *in\n}", "title": "" }, { "docid": "a62d2491925276d66a89576351b7bdb4", "score": "0.7940367", "text": "func (in *Replicas) DeepCopyInto(out *Replicas) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "ac71660e3edf3bf0db01580f6440913a", "score": "0.79402304", "text": "func (in *L2FibEntry) DeepCopyInto(out *L2FibEntry) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "77fc7d629fd026ad04ef51dfccebef4b", "score": "0.7940019", "text": "func (in *LiveRef) DeepCopyInto(out *LiveRef) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "9a15d89300bd7975c23b970cd7e97f3d", "score": "0.7928252", "text": "func (in *File) DeepCopyInto(out *File) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "bf6832a027499f414e4fefd23952a785", "score": "0.79256", "text": "func (in *ZookeeperNode) DeepCopyInto(out *ZookeeperNode) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "b7c82ab7f0b3eea65c1bf495c6e516a5", "score": "0.79142493", "text": "func (in *BackupProgress) DeepCopyInto(out *BackupProgress) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "57d7989b793af6d5839b019cc8c81aaa", "score": "0.7913025", "text": "func (in *ZookeeperNode) DeepCopyInto(out *ZookeeperNode) {\n\t*out = *in\n}", "title": "" }, { "docid": "6a74df2be2dbe701a0ee65d8e03053f6", "score": "0.79124033", "text": "func (in *IPXE) DeepCopyInto(out *IPXE) {\n\t*out = *in\n}", "title": "" }, { "docid": "ebde97abbe9aa8149c7ca6159e15bd33", "score": "0.7901579", "text": "func (in *CPUAndMem) DeepCopyInto(out *CPUAndMem) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "0153348545a3d712d327a2aac1b6c396", "score": "0.7896532", "text": "func (in *HostPort) DeepCopyInto(out *HostPort) {\n\t*out = *in\n}", "title": "" }, { "docid": "8cb26178b91e9e46e2760b02c39719bd", "score": "0.7893806", "text": "func (in *FileInfo) DeepCopyInto(out *FileInfo) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "a00993b464b505c32d052ed0ac29e929", "score": "0.78926784", "text": "func (in *RolloutStrategyStep) DeepCopyInto(out *RolloutStrategyStep) {\n\t*out = *in\n\tout.Capacity = in.Capacity\n\tout.Traffic = in.Traffic\n\treturn\n}", "title": "" }, { "docid": "6ac1005d81e338e324c2b485bacbcd96", "score": "0.78905296", "text": "func (in *FileSourceCommandOutput) DeepCopyInto(out *FileSourceCommandOutput) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "dddf435977ebcd6bfaf0b4c062ea8042", "score": "0.7889831", "text": "func (in *Image) DeepCopyInto(out *Image) {\n\t*out = *in\n}", "title": "" }, { "docid": "dddf435977ebcd6bfaf0b4c062ea8042", "score": "0.7889831", "text": "func (in *Image) DeepCopyInto(out *Image) {\n\t*out = *in\n}", "title": "" }, { "docid": "7e9a1e6442b0e3e96a5fbeee635960c2", "score": "0.7886163", "text": "func (in *TiltBuild) DeepCopyInto(out *TiltBuild) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "23db226639df1ec5bfce6ed220d55ed3", "score": "0.7885264", "text": "func (in *Port) DeepCopyInto(out *Port) {\n\t*out = *in\n}", "title": "" }, { "docid": "a65c4b2c1d2be68d2c000a97d8eedfc2", "score": "0.78841376", "text": "func (in *Custom) DeepCopyInto(out *Custom) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "a80bfc6073fb7569830178e573ccf4ff", "score": "0.7883546", "text": "func (in *CanaryStepInfo) DeepCopyInto(out *CanaryStepInfo) {\n\t*out = *in\n\tif in.Pods != nil {\n\t\tin, out := &in.Pods, &out.Pods\n\t\t*out = make([]Pod, len(*in))\n\t\tcopy(*out, *in)\n\t}\n}", "title": "" }, { "docid": "834926315fc14d71c5b8c19960384fb8", "score": "0.7881973", "text": "func (in *NodeToDelete) DeepCopyInto(out *NodeToDelete) {\n\t*out = *in\n}", "title": "" }, { "docid": "df764ce7904760faaa8b2c0ff322edf9", "score": "0.7880071", "text": "func (in *NamespacedObjectReference) DeepCopyInto(out *NamespacedObjectReference) {\n\t*out = *in\n}", "title": "" }, { "docid": "b0f2d00d7b4d64e85270beb9b90cd6ab", "score": "0.78789407", "text": "func (in *KoupletObjectStorage) DeepCopyInto(out *KoupletObjectStorage) {\n\t*out = *in\n}", "title": "" }, { "docid": "786362133c8c7c161acd95331377635b", "score": "0.78761685", "text": "func (in *NoteAffectedVersionEnd) DeepCopyInto(out *NoteAffectedVersionEnd) {\n\t*out = *in\n\tif in.Epoch != nil {\n\t\tin, out := &in.Epoch, &out.Epoch\n\t\t*out = new(int)\n\t\t**out = **in\n\t}\n\tif in.FullName != nil {\n\t\tin, out := &in.FullName, &out.FullName\n\t\t*out = new(string)\n\t\t**out = **in\n\t}\n\tif in.Name != nil {\n\t\tin, out := &in.Name, &out.Name\n\t\t*out = new(string)\n\t\t**out = **in\n\t}\n\tif in.Revision != nil {\n\t\tin, out := &in.Revision, &out.Revision\n\t\t*out = new(string)\n\t\t**out = **in\n\t}\n\treturn\n}", "title": "" }, { "docid": "dfd9b82d38c6fee08dd3cf0209bd1133", "score": "0.78745943", "text": "func (in *Disk) DeepCopyInto(out *Disk) {\n\t*out = *in\n}", "title": "" }, { "docid": "fa756ae28922fed925a87b236587b156", "score": "0.7873978", "text": "func (in *Git) DeepCopyInto(out *Git) {\n\t*out = *in\n}", "title": "" }, { "docid": "d04effc735adc59932f839adb9a5fcca", "score": "0.78713626", "text": "func (in *Target) DeepCopyInto(out *Target) {\n\t*out = *in\n}", "title": "" }, { "docid": "87da18a2ecb0daf97f6ceebabd38dbce", "score": "0.7870675", "text": "func (in *ArgoCDDexSpec) DeepCopyInto(out *ArgoCDDexSpec) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "c20aacaaa0cb697cdf50015f05812d0b", "score": "0.7868126", "text": "func (in *Persistent) DeepCopyInto(out *Persistent) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "a676d91e11264164f55179f00108d1a4", "score": "0.7864204", "text": "func (in *IPamEntry) DeepCopyInto(out *IPamEntry) {\n\t*out = *in\n\tout.Config = in.Config\n\treturn\n}", "title": "" }, { "docid": "130014cc93330670791582c6062e4db7", "score": "0.78633904", "text": "func (in *RestoreOptions) DeepCopyInto(out *RestoreOptions) {\n\t*out = *in\n\tout.Pachyderm = in.Pachyderm\n}", "title": "" }, { "docid": "1e1088954cae99b323e1b34730ad0490", "score": "0.78633827", "text": "func (in *Proxy) DeepCopyInto(out *Proxy) {\n\t*out = *in\n}", "title": "" }, { "docid": "5186b8d1bfd3abf2fb983694f27e4aed", "score": "0.7863321", "text": "func (in *Image) DeepCopyInto(out *Image) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "249004da5f8f92f3538948abf74c7c43", "score": "0.78623", "text": "func (in *ChainMatch) DeepCopyInto(out *ChainMatch) {\n\t*out = *in\n}", "title": "" }, { "docid": "7cc05f62bb39d146b68b80d858d6a207", "score": "0.7862143", "text": "func (in *Vector) DeepCopyInto(out *Vector) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "e39896940442e2145aef5b05f65f5935", "score": "0.7861722", "text": "func (in *PodInfo) DeepCopyInto(out *PodInfo) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "e6970237e6216981baddfbdbd7abccc6", "score": "0.7861194", "text": "func (in *Tap) DeepCopyInto(out *Tap) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "a510fbe7bc41427b104d0eaa08202270", "score": "0.78590775", "text": "func (in *Host) DeepCopyInto(out *Host) {\n\t*out = *in\n}", "title": "" }, { "docid": "5e7b3746576fd5b9b7b41728c6111924", "score": "0.7854789", "text": "func (in *UnidleInfo) DeepCopyInto(out *UnidleInfo) {\n\t*out = *in\n\tout.CrossGroupObjectReference = in.CrossGroupObjectReference\n\treturn\n}", "title": "" }, { "docid": "e315197e0d9ead19327c6af4ed12a3cb", "score": "0.7854774", "text": "func (in *Run) DeepCopyInto(out *Run) {\n\t*out = *in\n\tin.CollectorMeta.DeepCopyInto(&out.CollectorMeta)\n\tif in.Command != nil {\n\t\tin, out := &in.Command, &out.Command\n\t\t*out = make([]string, len(*in))\n\t\tcopy(*out, *in)\n\t}\n\tif in.Args != nil {\n\t\tin, out := &in.Args, &out.Args\n\t\t*out = make([]string, len(*in))\n\t\tcopy(*out, *in)\n\t}\n\tif in.ImagePullSecret != nil {\n\t\tin, out := &in.ImagePullSecret, &out.ImagePullSecret\n\t\t*out = new(ImagePullSecrets)\n\t\t(*in).DeepCopyInto(*out)\n\t}\n}", "title": "" }, { "docid": "96083041971f9626da3004536999b74d", "score": "0.7854016", "text": "func (in *Instance) DeepCopyInto(out *Instance) {\n\t*out = *in\n\tout.Info = in.Info\n\treturn\n}", "title": "" }, { "docid": "2a009d2984c86675e264e6dada29ff80", "score": "0.7852593", "text": "func (in *KV) DeepCopyInto(out *KV) {\n\t*out = *in\n}", "title": "" }, { "docid": "ea91a35f5981150f1fd702f1fe925417", "score": "0.7850946", "text": "func (in *FFTEstimator) DeepCopyInto(out *FFTEstimator) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "da7f24e673d9d09df8d3a9d9f9ee7150", "score": "0.785077", "text": "func (in *ClusterObjectVersion) DeepCopyInto(out *ClusterObjectVersion) {\n\t*out = *in\n}", "title": "" }, { "docid": "e4913de28c2145467caf2d40a4f1654c", "score": "0.78487825", "text": "func (in *ConsoleType) DeepCopyInto(out *ConsoleType) {\n\t*out = *in\n}", "title": "" }, { "docid": "b0adf7eb2ad49b2db1b146fe5f0c63c8", "score": "0.78466296", "text": "func (in *DataToBackup) DeepCopyInto(out *DataToBackup) {\n\t*out = *in\n\tif in.Paths != nil {\n\t\tin, out := &in.Paths, &out.Paths\n\t\t*out = make([]string, len(*in))\n\t\tcopy(*out, *in)\n\t}\n\treturn\n}", "title": "" }, { "docid": "24bd47aa15850c3e5d10ce0c3cdb5c1a", "score": "0.78445584", "text": "func (in *TwinProperty) DeepCopyInto(out *TwinProperty) {\n\t*out = *in\n\tif in.Metadata != nil {\n\t\tin, out := &in.Metadata, &out.Metadata\n\t\t*out = make(map[string]string, len(*in))\n\t\tfor key, val := range *in {\n\t\t\t(*out)[key] = val\n\t\t}\n\t}\n\treturn\n}", "title": "" }, { "docid": "a79f2a418acb2bd0e96737a5c3c73fa6", "score": "0.784417", "text": "func (in *SetupNode) DeepCopyInto(out *SetupNode) {\n\t*out = *in\n\tout.Ccow = in.Ccow\n\tin.Ccowd.DeepCopyInto(&out.Ccowd)\n\tout.Auditd = in.Auditd\n\tif in.ClusterNodes != nil {\n\t\tin, out := &in.ClusterNodes, &out.ClusterNodes\n\t\t*out = make([]string, len(*in))\n\t\tcopy(*out, *in)\n\t}\n\tin.Rtrd.DeepCopyInto(&out.Rtrd)\n\tif in.RtrdSlaves != nil {\n\t\tin, out := &in.RtrdSlaves, &out.RtrdSlaves\n\t\t*out = make([]RTDevices, len(*in))\n\t\tfor i := range *in {\n\t\t\t(*in)[i].DeepCopyInto(&(*out)[i])\n\t\t}\n\t}\n\tin.Rtlfs.DeepCopyInto(&out.Rtlfs)\n\tin.Rtkvs.DeepCopyInto(&out.Rtkvs)\n\treturn\n}", "title": "" }, { "docid": "906c07db0ca76d2700f3f766a3da7142", "score": "0.78413755", "text": "func (in *ConfigLookup) DeepCopyInto(out *ConfigLookup) {\n\t*out = *in\n\tif in.Config != nil {\n\t\tin, out := &in.Config, &out.Config\n\t\t*out = new(Config)\n\t\t(*in).DeepCopyInto(*out)\n\t}\n\tout.Display = in.Display\n}", "title": "" }, { "docid": "7cae9d5836b9ff88d8f2685e755e15d2", "score": "0.78387314", "text": "func (in *Mirroring) DeepCopyInto(out *Mirroring) {\n\t*out = *in\n\tif in.MaxBodySize != nil {\n\t\tin, out := &in.MaxBodySize, &out.MaxBodySize\n\t\t*out = new(int64)\n\t\t**out = **in\n\t}\n\tif in.Mirrors != nil {\n\t\tin, out := &in.Mirrors, &out.Mirrors\n\t\t*out = make([]MirrorService, len(*in))\n\t\tcopy(*out, *in)\n\t}\n\tif in.HealthCheck != nil {\n\t\tin, out := &in.HealthCheck, &out.HealthCheck\n\t\t*out = new(HealthCheck)\n\t\t**out = **in\n\t}\n\treturn\n}", "title": "" }, { "docid": "2dc7abef201d917589f010f613212296", "score": "0.78380525", "text": "func (in *ArgoCDTLSSpec) DeepCopyInto(out *ArgoCDTLSSpec) {\n\t*out = *in\n\tout.CA = in.CA\n\treturn\n}", "title": "" }, { "docid": "87b2689ec313f65bf8b34547d5fe1c22", "score": "0.7836369", "text": "func (in *ImpersonationConfig) DeepCopyInto(out *ImpersonationConfig) {\n\t*out = *in\n\tif in.Groups != nil {\n\t\tin, out := &in.Groups, &out.Groups\n\t\t*out = make([]string, len(*in))\n\t\tcopy(*out, *in)\n\t}\n\tif in.Extra != nil {\n\t\tin, out := &in.Extra, &out.Extra\n\t\t*out = make(map[string][]string, len(*in))\n\t\tfor key, val := range *in {\n\t\t\tif val == nil {\n\t\t\t\t(*out)[key] = nil\n\t\t\t} else {\n\t\t\t\t(*out)[key] = make([]string, len(val))\n\t\t\t\tcopy((*out)[key], val)\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "title": "" }, { "docid": "a77814382dc5efa98656ab59390c4583", "score": "0.7835097", "text": "func (in *KeyValue) DeepCopyInto(out *KeyValue) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "3ba2a8b441a37bfd038c30f2cd4bd608", "score": "0.78349304", "text": "func (in *NoteBuild) DeepCopyInto(out *NoteBuild) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "bef878ec968416a156e7ebe2543d4ca2", "score": "0.7832464", "text": "func (in *KeyToPath) DeepCopyInto(out *KeyToPath) {\n\t*out = *in\n}", "title": "" }, { "docid": "8fdfc31c802e3f9c9a872e578c5339d3", "score": "0.78312844", "text": "func (in *ArgoCDConfig) DeepCopyInto(out *ArgoCDConfig) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "f5023cb13be74cf25182a7183395c30a", "score": "0.78304505", "text": "func (in *ObjectFieldSelector) DeepCopyInto(out *ObjectFieldSelector) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "cbb68d49fd2c1144f25e0b31d5dc670a", "score": "0.78285265", "text": "func (in *BdInterface) DeepCopyInto(out *BdInterface) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "8e14ffa5d59641d2c993b17ea5ba3246", "score": "0.78278834", "text": "func (in *Delegate) DeepCopyInto(out *Delegate) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "9ec11989c5ce05665e2c4f7c6180862a", "score": "0.78255737", "text": "func (in *NodepoolGvnic) DeepCopyInto(out *NodepoolGvnic) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "74a105a690c14ec8e268cba9618912f1", "score": "0.78254706", "text": "func (in *K8sVersion) DeepCopyInto(out *K8sVersion) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "783f47424c191839399d4e44b906dd71", "score": "0.7825281", "text": "func (in *Port) DeepCopyInto(out *Port) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "783f47424c191839399d4e44b906dd71", "score": "0.7825281", "text": "func (in *Port) DeepCopyInto(out *Port) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "783f47424c191839399d4e44b906dd71", "score": "0.7825281", "text": "func (in *Port) DeepCopyInto(out *Port) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "8ff4edb62aac78b649c6382f24a79f61", "score": "0.78250456", "text": "func (in *Database) DeepCopyInto(out *Database) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "0d0b1cb857e61e9b21e4a27a1ea1d959", "score": "0.78236157", "text": "func (in *ExternalData) DeepCopyInto(out *ExternalData) {\n\t*out = *in\n}", "title": "" }, { "docid": "dc9cccc7cfa6b224aed958820b379d64", "score": "0.78215", "text": "func (in *Blob) DeepCopyInto(out *Blob) {\n\t*out = *in\n}", "title": "" }, { "docid": "5787cd6847ddd85de272065e4c4ef750", "score": "0.7820067", "text": "func (in *GitRef) DeepCopyInto(out *GitRef) {\n\t*out = *in\n\treturn\n}", "title": "" } ]
c745da3e1e665d436b6a2a18f62bb4d1
The IP tag type. Example: FirstPartyUsage.
[ { "docid": "c4fbcb949d5a12f86888c4c0b3de0410", "score": "0.72139764", "text": "func (o IpTagResponseOutput) IpTagType() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v IpTagResponse) *string { return v.IpTagType }).(pulumi.StringPtrOutput)\n}", "title": "" } ]
[ { "docid": "39e6dd63b5997fc067fdc495be4020ae", "score": "0.7184975", "text": "func (o IpTagOutput) IpTagType() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v IpTag) *string { return v.IpTagType }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "13d5dca7f07b240895abc464873c8770", "score": "0.68826395", "text": "func (o *IPOpt) Type() string {\n\treturn \"ip\"\n}", "title": "" }, { "docid": "586e749a44865b7db0959b730ad6d9f8", "score": "0.64281213", "text": "func (o WindowsVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTagOutput) Type() pulumi.StringOutput {\n\treturn o.ApplyT(func(v WindowsVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTag) string {\n\t\treturn v.Type\n\t}).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "5ae5948631e1fb99ceffa9e1f2c3dba7", "score": "0.6371147", "text": "func (o LinuxVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTagOutput) Type() pulumi.StringOutput {\n\treturn o.ApplyT(func(v LinuxVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTag) string {\n\t\treturn v.Type\n\t}).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "bce17f0ed51a2c65763cf7d1828edb38", "score": "0.6327553", "text": "func (*IPAddress) ResourceType() string {\n\treturn \"PublicIpAddress\"\n}", "title": "" }, { "docid": "7c1353655f94eea32702a5be4b8be748", "score": "0.61595696", "text": "func (o GetVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTagOutput) Type() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTag) string {\n\t\treturn v.Type\n\t}).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "7fbe08a07de4441e0d59c7bb909459ab", "score": "0.6109776", "text": "func (o PublicIPAddressTypeOutput) IpTags() IpTagArrayOutput {\n\treturn o.ApplyT(func(v PublicIPAddressType) []IpTag { return v.IpTags }).(IpTagArrayOutput)\n}", "title": "" }, { "docid": "bd0c79d06aefc036826e68c4ce2f00ac", "score": "0.6069969", "text": "func IP(v net.IP) predicate.FieldType {\n\tvc := []byte(v)\n\treturn predicate.FieldType(func(t *dsl.Traversal) {\n\t\tt.Has(Label, FieldIP, p.EQ(vc))\n\t})\n}", "title": "" }, { "docid": "ce1816eb9f4b6451da374e267d4b9e7b", "score": "0.60622525", "text": "func (myDeviceInfo *DeviceInfo) IP() (param string) {\n\treturn myDeviceInfo.IPvar\n}", "title": "" }, { "docid": "79e3740fb63ea2c4720c4d74658a5c4c", "score": "0.60601753", "text": "func (e *ENIIP) GetType() string {\n\treturn ResourceTypeENIIP\n}", "title": "" }, { "docid": "047eb64d4e2ef60b422d60ec9f2768f1", "score": "0.6038702", "text": "func (o OrchestratedVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTagOutput) Type() pulumi.StringOutput {\n\treturn o.ApplyT(func(v OrchestratedVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTag) string {\n\t\treturn v.Type\n\t}).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "3571325b09c817cc36c49b0b9ec90c24", "score": "0.59530103", "text": "func (o IPAddressOutput) Kind() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *IPAddress) pulumi.StringOutput { return v.Kind }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "cb11493514027e819c4e88b437f26be7", "score": "0.5912903", "text": "func (o GetOrchestratedVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTagOutput) Type() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetOrchestratedVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTag) string {\n\t\treturn v.Type\n\t}).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "f765f971e111b6635f02c858ff676f06", "score": "0.5876584", "text": "func (s *Space) getAddrTypeIP(address string) []string {\n\tvar addrType string\n\tvar ipaddr string\n\tr := regexp.MustCompile(`(\\d+\\.\\d+\\.\\d+\\.\\d+)(\\/\\d+)?`)\n\tmatch := r.FindStringSubmatch(address)\n\n\tswitch match[2] {\n\tcase \"\", \"/32\":\n\t\taddrType = \"IPADDRESS\"\n\t\tipaddr = match[1]\n\tdefault:\n\t\taddrType = \"NETWORK\"\n\t\tipaddr = address\n\t}\n\n\treturn []string{addrType, ipaddr}\n}", "title": "" }, { "docid": "8882c25ac203c1fc529d753cae883cbc", "score": "0.584425", "text": "func (info *BaseEndpointInfo) IP() string {\n\treturn utilproxy.IPPart(info.Endpoint)\n}", "title": "" }, { "docid": "8882c25ac203c1fc529d753cae883cbc", "score": "0.584425", "text": "func (info *BaseEndpointInfo) IP() string {\n\treturn utilproxy.IPPart(info.Endpoint)\n}", "title": "" }, { "docid": "a52a8aa4793fe06d7954463e18cec637", "score": "0.5837207", "text": "func (i *IE) IP() (net.IP, error) {\n\tif len(i.Payload) < 4 {\n\t\treturn nil, io.ErrUnexpectedEOF\n\t}\n\n\tswitch i.Type {\n\tcase EndUserAddress:\n\t\tif i.MustPDPTypeOrganization() != pdpTypeIETF {\n\t\t\treturn nil, ErrMalformed\n\t\t}\n\t\treturn net.IP(i.Payload[2:]), nil\n\tcase GSNAddress:\n\t\treturn net.IP(i.Payload), nil\n\tdefault:\n\t\treturn nil, &InvalidTypeError{i.Type}\n\t}\n}", "title": "" }, { "docid": "7ba0647cabe90e596e73a12c9fd9380c", "score": "0.5821186", "text": "func (o WindowsVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTagOutput) Tag() pulumi.StringOutput {\n\treturn o.ApplyT(func(v WindowsVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTag) string {\n\t\treturn v.Tag\n\t}).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "5d346e062b743e622cbef672e296b43f", "score": "0.57688063", "text": "func (o LinuxVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTagOutput) Tag() pulumi.StringOutput {\n\treturn o.ApplyT(func(v LinuxVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTag) string {\n\t\treturn v.Tag\n\t}).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "0be0abc1021eac7055c2c0bc9d4453b2", "score": "0.57296085", "text": "func IP(ctx context.Context) (string, bool) {\n\tv, ok := ctx.Value(ctxKeyIP).(string)\n\treturn v, ok\n}", "title": "" }, { "docid": "2cf8b223e6d3aed889e0ae043598edd9", "score": "0.56977874", "text": "func (f *FlagSet) IPNet(name string, value net.IPNet, usage string) *net.IPNet {\n\tp := new(net.IPNet)\n\tf.IPNetVarP(p, name, \"\", value, usage)\n\treturn p\n}", "title": "" }, { "docid": "53843c584a341dbda7b4068722880ca1", "score": "0.56896514", "text": "func suitableType(target string) string {\n\tif net.ParseIP(target) != nil && net.ParseIP(target).To4() != nil {\n\t\treturn endpoint.RecordTypeA\n\t} else if net.ParseIP(target) != nil && net.ParseIP(target).To16() != nil {\n\t\treturn endpoint.RecordTypeAAAA\n\t}\n\treturn endpoint.RecordTypeCNAME\n}", "title": "" }, { "docid": "831834c6a8458f919ecb80e24ff9c272", "score": "0.5675855", "text": "func (o PublicIpOutput) IpTags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *PublicIp) pulumi.StringMapOutput { return v.IpTags }).(pulumi.StringMapOutput)\n}", "title": "" }, { "docid": "31d014e91c9d34460b4ba9c8d23ecf4f", "score": "0.5666692", "text": "func (n *common) Type() string {\n\treturn n.netType\n}", "title": "" }, { "docid": "e54b087a989341ae9005be9c64dc276d", "score": "0.56439054", "text": "func (o IpTagOutput) Tag() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v IpTag) *string { return v.Tag }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "a6b05fbeeef8f9f965b771b4b8a81a30", "score": "0.56193334", "text": "func IPGTE(v net.IP) predicate.FieldType {\n\tvc := []byte(v)\n\treturn predicate.FieldType(func(t *dsl.Traversal) {\n\t\tt.Has(Label, FieldIP, p.GTE(vc))\n\t})\n}", "title": "" }, { "docid": "230226c762656f09dad929e9f41c2b7b", "score": "0.5618391", "text": "func (o GetVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTagOutput) Tag() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTag) string {\n\t\treturn v.Tag\n\t}).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "98b5fb565ad8488414e405d9d76bb8bb", "score": "0.56181484", "text": "func (c *Client) IP(ctx context.Context) (res string, err error) {\n\tvar ires interface{}\n\tires, err = c.IPEndpoint(ctx, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\treturn ires.(string), nil\n}", "title": "" }, { "docid": "c01c41ac91a4f7bda75e267c1c615b49", "score": "0.5606351", "text": "func (o OrchestratedVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTagOutput) Tag() pulumi.StringOutput {\n\treturn o.ApplyT(func(v OrchestratedVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTag) string {\n\t\treturn v.Tag\n\t}).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "66f272b019a1af0c9f6543f22a65a056", "score": "0.5588139", "text": "func (i *Instance) IP(public bool) (string, error) {\n\tif public {\n\t\tip, err := i.publicIP()\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn ip, nil\n\t}\n\n\tip, err := i.privateIP()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn ip, nil\n}", "title": "" }, { "docid": "efca319c294758e655beb2127166e8a1", "score": "0.5587777", "text": "func (o PublicIPAddressTypePtrOutput) IpTags() IpTagArrayOutput {\n\treturn o.ApplyT(func(v *PublicIPAddressType) []IpTag {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.IpTags\n\t}).(IpTagArrayOutput)\n}", "title": "" }, { "docid": "21f011622e5885dea82e92a576412fa1", "score": "0.5567446", "text": "func TestIsIpAddressTagged(t *testing.T) {\n\tpassed := false\n\tip := \"32.141.173.1\"\n\tserver := \"sub-mci01-data01\"\n\ttagType := \"midgress-only\"\n\tips, err := GetInterfaceTags(server, tagType)\n\tif err != nil {\n\t\tt.Errorf(\"could not get tag from netbox\")\n\t}\n\tfor _, v1 := range ips {\n\t\tfor _, v2 := range v1 {\n\t\t\tipAdd := ip + \"/32\"\n\t\t\tif IsSameAddressFamily(ipAdd, v2) {\n\t\t\t\tpassed = true\n\t\t\t}\n\t\t}\n\t}\n\tif !passed {\n\t\tt.Errorf(\"could not match IP address with an interface in netbox that has the tag\")\n\t}\n}", "title": "" }, { "docid": "526bce972096658b9782f306181eeb5a", "score": "0.5547403", "text": "func (a *IPAddr) Network() string {\n\treturn \"ip\"\n}", "title": "" }, { "docid": "3f5d2863722291ccc6bd2c5e419a28db", "score": "0.55450356", "text": "func (o VpcEndpointSpecOutput) IpAddressType() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v VpcEndpointSpec) *string { return v.IpAddressType }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "0b3d6feb33a8efe5bf497de04c3b956f", "score": "0.55183935", "text": "func (o *AWSNodePool) InstanceType() string {\n\tif o != nil && o.bitmap_&16 != 0 {\n\t\treturn o.instanceType\n\t}\n\treturn \"\"\n}", "title": "" }, { "docid": "c3ad386b306fba36124444fb4b53f718", "score": "0.5496411", "text": "func (nsRelated) IP(value string) fld.Field {\n\treturn ecsString(\"related.ip\", value)\n}", "title": "" }, { "docid": "bee6f103c2f9bcd7ca31b1f4b081ac09", "score": "0.5481758", "text": "func (input *BeegoInput) IP() string {\n\treturn (*context.BeegoInput)(input).IP()\n}", "title": "" }, { "docid": "fee88fd67b85fdc0e9b1a02e793c02aa", "score": "0.5481582", "text": "func (a *Addr) Type() string {\n\treturn \"string\"\n}", "title": "" }, { "docid": "514234699ce0fc8c57fb9958c19d30e8", "score": "0.5481182", "text": "func (o GetOrchestratedVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTagOutput) Tag() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetOrchestratedVirtualMachineScaleSetNetworkInterfaceIpConfigurationPublicIpAddressIpTag) string {\n\t\treturn v.Tag\n\t}).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "6f22f820a431670dfa50c67ae572ec21", "score": "0.54768115", "text": "func IP(s string) error {\n\treturn ip.Validate(s)\n}", "title": "" }, { "docid": "5b67f3167a4a804e585dba3392be5e98", "score": "0.54730606", "text": "func (b *baseNode) IP() string {\n\tif len(b.node.Status.Addresses) == 0 {\n\t\treturn \"N/A\"\n\t}\n\taddress := b.node.Status.Addresses[0]\n\treturn address.Address\n}", "title": "" }, { "docid": "37f8248f5266089a5671fb82e481c7bb", "score": "0.5465966", "text": "func (vm *VM) IP() (string, bool) {\n\treturn vm.internalIP, true\n}", "title": "" }, { "docid": "2ecd6d467d98db39ceca166168c3bab9", "score": "0.54503417", "text": "func (i *Internet) IP() string {\n\tresult := []string{}\n\n\tfor i := 0; i < 4; i++ {\n\t\tresult = append(result, string(random(255)))\n\t}\n\n\treturn strings.Join(result, \".\")\n}", "title": "" }, { "docid": "97612f0afc2f29d3857939e3db59aba6", "score": "0.54496706", "text": "func (t Type) Describe() string {\n\tswitch t {\n\tcase IP4, IP6:\n\t\treturn fmt.Sprintf(\"IPv%d\", t)\n\tdefault:\n\t\treturn \"<unrecognized IP network>\"\n\t}\n}", "title": "" }, { "docid": "cedc362f1d32042146eeaaeaefece607", "score": "0.544595", "text": "func (b Ethernet) Type() tcpip.NetworkProtocolNumber {\n\treturn tcpip.NetworkProtocolNumber(binary.BigEndian.Uint16(b[ethType:]))\n}", "title": "" }, { "docid": "5c8fe8f70fd91c262dc8f288325a57ef", "score": "0.54415363", "text": "func (t *Tag) Type() uint16 {\n\tif !t.Valid() {\n\t\treturn 0\n\t}\n\treturn t.E.Type\n}", "title": "" }, { "docid": "f45c77f0daa9d05c9f06fa8d09b6a781", "score": "0.5439683", "text": "func IPGT(v net.IP) predicate.FieldType {\n\tvc := []byte(v)\n\treturn predicate.FieldType(func(t *dsl.Traversal) {\n\t\tt.Has(Label, FieldIP, p.GT(vc))\n\t})\n}", "title": "" }, { "docid": "b39ea78bb8a426d4f86171812ed5847c", "score": "0.5439309", "text": "func (t HttpTracker) IP() string {\n\treturn t.Tracker.IP()\n}", "title": "" }, { "docid": "5128aa66013d83b98215ff65904e5825", "score": "0.5432455", "text": "func (me TaddressCategoryType) IsIpv4Net() bool { return me.String() == \"ipv4-net\" }", "title": "" }, { "docid": "109c866f0de45db4f1fbc5b39b0c6482", "score": "0.54149044", "text": "func (o IPAddressListOutput) Kind() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *IPAddressList) pulumi.StringOutput { return v.Kind }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "0cee973cacd5d56b4645417ebd991ab0", "score": "0.5403684", "text": "func (nsSource) IP(value string) fld.Field {\n\treturn ecsString(\"source.ip\", value)\n}", "title": "" }, { "docid": "fe3937786a5b2ef0d8b13f94e2c9cc1d", "score": "0.53966326", "text": "func (addr *IPv4AddrOption) Type() uint8 {\n\treturn uint8(addr.AddrType)\n}", "title": "" }, { "docid": "900a9bf59a0819ab8d8089c70879c14b", "score": "0.53760886", "text": "func (o ClusterOutput) PublicIpType() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *Cluster) pulumi.StringPtrOutput { return v.PublicIpType }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "8329044e5ae96246d656927fa42f95e9", "score": "0.5368415", "text": "func (o VmwareHostIpResponseOutput) Ip() pulumi.StringOutput {\n\treturn o.ApplyT(func(v VmwareHostIpResponse) string { return v.Ip }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "1bca879c9dfdaf64e0e8c6204756619d", "score": "0.5362701", "text": "func (nsServer) IP(value string) fld.Field {\n\treturn ecsString(\"server.ip\", value)\n}", "title": "" }, { "docid": "5b57af2fec4c30b425da4a63622a031c", "score": "0.533088", "text": "func (r *AWSGameLiftFleet_IpPermission) AWSCloudFormationType() string {\n\treturn \"AWS::GameLift::Fleet.IpPermission\"\n}", "title": "" }, { "docid": "45ffd0f96b32f89ca2836efc7ba86442", "score": "0.53280884", "text": "func (nsObserver) IP(value string) fld.Field {\n\treturn ecsString(\"observer.ip\", value)\n}", "title": "" }, { "docid": "eb772ed8f835047a564489daa8991e2f", "score": "0.53249943", "text": "func (p *Pool) IPNet() *net.IPNet {\n\treturn p.ipnet\n}", "title": "" }, { "docid": "d1b52ab8a6e09fefb24bd4fa62b0004e", "score": "0.531779", "text": "func (o IngressLoadBalancerIngressOutput) Ip() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v IngressLoadBalancerIngress) *string { return v.Ip }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "ee8872890207237f6e442d6dcf59fd74", "score": "0.5302726", "text": "func (dt *DHCPTag) ConfigType() ConfigType { return ConfigDHCP }", "title": "" }, { "docid": "2ca9913a770dfda3e7763e85c1a1ba6c", "score": "0.5292738", "text": "func IPNotNil() predicate.FieldType {\n\treturn predicate.FieldType(func(t *dsl.Traversal) {\n\t\tt.HasLabel(Label).Has(FieldIP)\n\t})\n}", "title": "" }, { "docid": "0ddf5fd1d7c6a70b4eb7d8b14e8b4d2f", "score": "0.5271534", "text": "func (o ICMPOptionUnknown) Type() ICMPOptionType {\n\treturn o.optionType\n}", "title": "" }, { "docid": "1c4dd68aee15ab7b70bf4d23d65eee9e", "score": "0.5271024", "text": "func (o InboundNatPoolResponseOutput) Type() pulumi.StringOutput {\n\treturn o.ApplyT(func(v InboundNatPoolResponse) string { return v.Type }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "81531ad172e33e3778142a66249bfaab", "score": "0.5270204", "text": "func (dt *DHCPTag) ConfigSubType() string { return \"tag\" }", "title": "" }, { "docid": "81e4d7dcb893be24826f6446114df12d", "score": "0.5263036", "text": "func (o ApplicationGatewayFrontendIPConfigurationResponseOutput) Type() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ApplicationGatewayFrontendIPConfigurationResponse) string { return v.Type }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "fbb449024f977e978ace3e804297103d", "score": "0.5255914", "text": "func getPacketTypeFromClassifiers(classifierInfo map[string]interface{}) string {\n\tvar packetType string\n\tovid, ivid := false, false\n\tif vlanID, ok := classifierInfo[VlanVid].(uint32); ok {\n\t\tvid := vlanID & VlanvIDMask\n\t\tif vid != ReservedVlan {\n\t\t\tovid = true\n\t\t}\n\t}\n\tif metadata, ok := classifierInfo[Metadata].(uint64); ok {\n\t\tvid := uint32(metadata)\n\t\tif vid != ReservedVlan {\n\t\t\tivid = true\n\t\t}\n\t}\n\tif ovid && ivid {\n\t\tpacketType = DoubleTag\n\t} else if !ovid && !ivid {\n\t\tpacketType = Untagged\n\t} else {\n\t\tpacketType = SingleTag\n\t}\n\treturn packetType\n}", "title": "" }, { "docid": "2b54d5765d873e36417b175067fe7f58", "score": "0.52489084", "text": "func (nsHost) IP(value string) fld.Field {\n\treturn ecsString(\"host.ip\", value)\n}", "title": "" }, { "docid": "c268a23c6dc3a342c7db796c99d9e3b5", "score": "0.52429545", "text": "func (Region3int16) Type() string {\n\treturn \"Region3int16\"\n}", "title": "" }, { "docid": "b0e178510dc258e8c6ede66b3fc7c858", "score": "0.52415353", "text": "func (o ApplicationGatewayIPConfigurationResponseOutput) Type() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ApplicationGatewayIPConfigurationResponse) string { return v.Type }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "25b2b65d1ade019f5df1e5c67fdb61d6", "score": "0.522956", "text": "func IP(ip cue.Value) bool {\n\t// TODO: convert to native CUE.\n\treturn netGetIP(ip) != nil\n}", "title": "" }, { "docid": "3375cfda4bcda405b8493a2e50472a1d", "score": "0.5220424", "text": "func (me TbulkobservableTypeType) IsIpv4Net() bool { return me.String() == \"ipv4-net\" }", "title": "" }, { "docid": "f7d6f651618cc774cdccf9d4321ae0fe", "score": "0.52179986", "text": "func (Int) Type() TagID {\n\treturn TagInt\n}", "title": "" }, { "docid": "3c05332874053c4efb82c039bab4f418", "score": "0.5206092", "text": "func (nsClient) IP(value string) fld.Field {\n\treturn ecsString(\"client.ip\", value)\n}", "title": "" }, { "docid": "5be404757b52d343edc9ff35a9f7fece", "score": "0.52005357", "text": "func (c Container) IP() string { return c.ip }", "title": "" }, { "docid": "585c653faa007ccd1abdd37316ceef11", "score": "0.51991034", "text": "func checkIPAddressType(ip string) int {\n\tif net.ParseIP(ip) == nil {\n\t\treturn -1 //Error\n\t}\n\tfor i := 0; i < len(ip); i++ {\n\t\tswitch ip[i] {\n\t\tcase '.':\n\t\t\treturn 0 //IPv4\n\t\tcase ':':\n\t\t\treturn 1 //IPv6\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "36fc0f051c6a648e8854ec4b1beaf72a", "score": "0.5197436", "text": "func IPIn(vs ...net.IP) predicate.FieldType {\n\tv := make([]any, len(vs))\n\tfor i := range v {\n\t\tv[i] = []byte(vs[i])\n\t}\n\treturn predicate.FieldType(func(t *dsl.Traversal) {\n\t\tt.Has(Label, FieldIP, p.Within(v...))\n\t})\n}", "title": "" }, { "docid": "b107788d427e3dccc47cc21c279ffdcf", "score": "0.51956135", "text": "func (o VmwareHostIpOutput) Ip() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v VmwareHostIp) *string { return v.Ip }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "59e590bc4b7f516dbb90c183f7da13fa", "score": "0.51954675", "text": "func IPNet(name string, value net.IPNet, usage string) *net.IPNet {\n\treturn CommandLine.IPNetP(name, \"\", value, usage)\n}", "title": "" }, { "docid": "0a67bbd10e45737c75100711284ead64", "score": "0.51919234", "text": "func (vp *valueParser) IP() net.IP {\n\tif vp.err != nil {\n\t\treturn nil\n\t}\n\n\ts, ok := vp.v.(string)\n\tif !ok {\n\t\tvp.err = errors.New(\"value for IP is not of type string\")\n\t\treturn nil\n\t}\n\n\tip := net.ParseIP(s)\n\tif ip == nil {\n\t\tvp.err = fmt.Errorf(\"invalid IP address: %q\", s)\n\t\treturn nil\n\t}\n\n\treturn ip\n}", "title": "" }, { "docid": "5220d239218feaf2a14bb439301436c1", "score": "0.51877266", "text": "func (r *AWSSESReceiptFilter_IpFilter) AWSCloudFormationType() string {\n\treturn \"AWS::SES::ReceiptFilter.IpFilter\"\n}", "title": "" }, { "docid": "2e5aac266199eab3eadb7cefe1d8c821", "score": "0.51788634", "text": "func (v Vlan) Type() string {\n\treturn genericitems.VlanTypename\n}", "title": "" }, { "docid": "e0def0bd90f59c95d9adc9aafe151a85", "score": "0.51780534", "text": "func IPLT(v net.IP) predicate.FieldType {\n\tvc := []byte(v)\n\treturn predicate.FieldType(func(t *dsl.Traversal) {\n\t\tt.Has(Label, FieldIP, p.LT(vc))\n\t})\n}", "title": "" }, { "docid": "c79770d59d7b37fe45fcefa9917f3038", "score": "0.51709956", "text": "func (c *Config) NameType(n string) string {\n\t// ip address is not likely to be used as instance name and cluster name\n\tif IsValidIP(n) {\n\t\tif _, ipFound := c.IpMap[n]; ipFound {\n\t\t\treturn NameIP\n\t\t} else {\n\t\t\treturn NameInvalid\n\t\t}\n\t}\n\tif _, insFound := c.InstanceMap[n]; insFound {\n\t\treturn NameInstance\n\t}\n\tif _, clsFound := c.ClusterMap[n]; clsFound {\n\t\treturn NameCluster\n\t}\n\treturn NameInvalid\n}", "title": "" }, { "docid": "909d340e9c59893de8bbfc04e8b6c5ba", "score": "0.51576465", "text": "func (p *pingProvider) Type() string {\n\treturn providerType\n}", "title": "" }, { "docid": "5d8430acf5e81bd24b8757b7b749bf5c", "score": "0.51557493", "text": "func (o IpTagResponseOutput) Tag() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v IpTagResponse) *string { return v.Tag }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "b4b66b5e4c2b8323aa9fbfeeb87e112f", "score": "0.5149292", "text": "func (o PublicIpOutput) Tags() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *PublicIp) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)\n}", "title": "" }, { "docid": "48141fb6d17c2b0511234366ad428d44", "score": "0.5146148", "text": "func (i *Identity) InstanceType() (string, error) {\n\treturn i.CustomIdentity.InstanceType, nil\n}", "title": "" }, { "docid": "1c11a00f949d8ea66ae04423ad433a8c", "score": "0.5142916", "text": "func (p *Params) GetIP(paramName string) net.IP {\r\n\tv := p.Get(paramName)\r\n\r\n\tswitch val := v.(type) {\r\n\tcase net.IP:\r\n\t\treturn val\r\n\t}\r\n\r\n\treturn nil\r\n}", "title": "" }, { "docid": "ba5e56951e8c1386b6b4eb76f2805891", "score": "0.5140837", "text": "func (o *option) IP() (net.IP, error) {\n\tip := net.ParseIP(o.i.Value)\n\tif ip.String() == \"<nil>\" {\n\t\treturn nil, fmt.Errorf(\"failed to parse IP address for option %s \", o.Name)\n\t}\n\treturn ip, nil\n}", "title": "" }, { "docid": "7f7907448ce925ee9c8f043f4f339301", "score": "0.5138211", "text": "func (f *nopExtensionFactory) Type() config.Type {\n\treturn \"nop\"\n}", "title": "" }, { "docid": "2f14df305c71ea1f8ef91e511e230265", "score": "0.51300377", "text": "func (PingrespPacket) PacketType() byte { return PINGRESP }", "title": "" }, { "docid": "4ad11b79206b80d5e67cfe99188eaf93", "score": "0.5123607", "text": "func (o EndpointOutput) EndpointIp() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Endpoint) pulumi.StringOutput { return v.EndpointIp }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "eb1b264f3aadaa064d9318fc1e4f69ef", "score": "0.5122929", "text": "func isIP(fl validator.FieldLevel) bool {\n\treturn net.ParseIP(fl.Field().String()) != nil\n}", "title": "" }, { "docid": "ed6716ac061a07167797d77daa82d297", "score": "0.51196694", "text": "func (t Type) Int() int {\n\tswitch t {\n\tcase IP4, IP6:\n\t\treturn int(t)\n\tdefault:\n\t\treturn 0\n\t}\n}", "title": "" }, { "docid": "600a349981b94a1308ad02dc94987cf2", "score": "0.5118874", "text": "func (f *FlagSet) IPNetP(name, shorthand string, value net.IPNet, usage string) *net.IPNet {\n\tp := new(net.IPNet)\n\tf.IPNetVarP(p, name, shorthand, value, usage)\n\treturn p\n}", "title": "" }, { "docid": "d90ba58da6dcfdd40bcffdd9bca76897", "score": "0.5105871", "text": "func (o NodePoolOutput) ImageType() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *NodePool) pulumi.StringOutput { return v.ImageType }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "6838bc2f14bdd13f72b758c7a267359d", "score": "0.50976807", "text": "func (e *EIP) GetType() string {\n\treturn ResourceTypeEIP\n}", "title": "" }, { "docid": "873c67bb9cb986bdf177af0288e143ba", "score": "0.50932133", "text": "func (o PublicIPAddressResponseOutput) IpTags() IpTagResponseArrayOutput {\n\treturn o.ApplyT(func(v PublicIPAddressResponse) []IpTagResponse { return v.IpTags }).(IpTagResponseArrayOutput)\n}", "title": "" }, { "docid": "6e6ec4245efca4c317cc62f8b07895ad", "score": "0.5090597", "text": "func (l *ListData) TagType() TagID {\n\treturn l.tagType\n}", "title": "" }, { "docid": "a320138ee56905e23f6c75bfdeb2dca7", "score": "0.5089214", "text": "func (o IngressLoadBalancerIngressPatchOutput) Ip() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v IngressLoadBalancerIngressPatch) *string { return v.Ip }).(pulumi.StringPtrOutput)\n}", "title": "" } ]
f618f9ce4dadea8bcc6a7af2304c1608
Shutdown stops the exporter and is invoked during shutdown.
[ { "docid": "359e3ff726d0bd5cabcfc0a9ed857171", "score": "0.7340112", "text": "func (sle *SinkLogsExporter) Shutdown(context.Context) error {\n\treturn nil\n}", "title": "" } ]
[ { "docid": "068636dfb96e104bea7487eddfb34a88", "score": "0.7694988", "text": "func (e *Exporter) Shutdown(ctx context.Context) error {\n\treturn e.traceExporter.Shutdown(ctx)\n}", "title": "" }, { "docid": "9a54dca641f019485a1e762a2680a501", "score": "0.7441613", "text": "func (e *Exporter) Shutdown(ctx context.Context) error {\n\te.mu.RLock()\n\tstarted := e.started\n\te.mu.RUnlock()\n\n\tif !started {\n\t\treturn nil\n\t}\n\n\tvar err error\n\n\te.stopOnce.Do(func() {\n\t\terr = e.client.Stop(ctx)\n\t\te.mu.Lock()\n\t\te.started = false\n\t\te.mu.Unlock()\n\t})\n\n\treturn err\n}", "title": "" }, { "docid": "ac6507c64f234b41050f4407c4a8f4a7", "score": "0.7425088", "text": "func (i *InMemoryOCExporter) Shutdown(ctx context.Context) error {\n\ti.stackdriverExporter.StopMetricsExporter()\n\terr := i.stackdriverExporter.Close()\n\ti.testServer.Shutdown()\n\n\tview.Unregister(getViews()...)\n\treturn err\n}", "title": "" }, { "docid": "74fde695e64c2e068929ccd5513c452b", "score": "0.7410411", "text": "func (e *Exporter) Shutdown(ctx context.Context) error {\n\terr := errShutdown\n\te.shutdownOnce.Do(func() {\n\t\te.clientMu.Lock()\n\t\tclient := e.client\n\t\te.client = shutdownClient{\n\t\t\ttemporalitySelector: client.Temporality,\n\t\t\taggregationSelector: client.Aggregation,\n\t\t}\n\t\te.clientMu.Unlock()\n\t\terr = client.Shutdown(ctx)\n\t})\n\treturn err\n}", "title": "" }, { "docid": "90b48261225e02c0b8f602c8bee0fa04", "score": "0.7403878", "text": "func (c *testExporter) Shutdown(ctx context.Context) error {\n\treturn nil\n}", "title": "" }, { "docid": "2326fb10cb4acc28fef5172d39da470e", "score": "0.738236", "text": "func (me *logsExporter) Shutdown(ctx context.Context) error {\n\treturn me.shutdown(ctx)\n}", "title": "" }, { "docid": "75ad188fe1f4c23d5372e66a09dc2336", "score": "0.7374059", "text": "func (sme *SinkMetricsExporter) Shutdown(context.Context) error {\n\treturn nil\n}", "title": "" }, { "docid": "30f393c973668c9935302509bd7265cd", "score": "0.7154165", "text": "func (tr *StubExporter) Shutdown(ctx context.Context) error {\n\treturn nil\n}", "title": "" }, { "docid": "d74611ae83f687b8ffa2bb21e01680e8", "score": "0.71462196", "text": "func (ste *SinkTraceExporter) Shutdown(context.Context) error {\n\treturn nil\n}", "title": "" }, { "docid": "c421d7064f33dc2565f2593f8566e31e", "score": "0.7034974", "text": "func (e *neevaFileExporter) Shutdown(context.Context) error {\n\te.logger.Info(\"Shutdown neevaFileExporter\")\n\te.mu.Lock()\n\te.shutdown = true\n\te.mu.Unlock()\n\t// Closing spanCh causes graceful shutdown of the json loops, which closes jsonCh, which causes\n\t// graceful shutdown of the writer loop.\n\tclose(e.spanCh)\n\treturn e.group.Wait()\n}", "title": "" }, { "docid": "210a1c1c7c0dc063d7655b479c875ea4", "score": "0.7023473", "text": "func (e *httpSinkExporter) Shutdown(context.Context) error {\n\t// shutdown http server\n\treturn nil\n\n}", "title": "" }, { "docid": "127304999255469833efc2369ccdd592", "score": "0.6689804", "text": "func (s *StatsSimple) Shutdown() {\n\tclose(s.logchan)\n}", "title": "" }, { "docid": "f472c54903070bb1e6ba8230343f6edb", "score": "0.66376007", "text": "func (ssp *simpleSpanProcessor) Shutdown(ctx context.Context) error {\n\tvar err error\n\tssp.stopOnce.Do(func() {\n\t\tstopFunc := func(exp SpanExporter) (<-chan error, func()) {\n\t\t\tdone := make(chan error)\n\t\t\treturn done, func() { done <- exp.Shutdown(ctx) }\n\t\t}\n\n\t\t// The exporter field of the simpleSpanProcessor needs to be zeroed to\n\t\t// signal it is shut down, meaning all subsequent calls to OnEnd will\n\t\t// be gracefully ignored. This needs to be done synchronously to avoid\n\t\t// any race condition.\n\t\t//\n\t\t// A closure is used to keep reference to the exporter and then the\n\t\t// field is zeroed. This ensures the simpleSpanProcessor is shut down\n\t\t// before the exporter. This order is important as it avoids a\n\t\t// potential deadlock. If the exporter shut down operation generates a\n\t\t// span, that span would need to be exported. Meaning, OnEnd would be\n\t\t// called and try acquiring the lock that is held here.\n\t\tssp.exporterMu.Lock()\n\t\tdone, shutdown := stopFunc(ssp.exporter)\n\t\tssp.exporter = nil\n\t\tssp.exporterMu.Unlock()\n\n\t\tgo shutdown()\n\n\t\t// Wait for the exporter to shut down or the deadline to expire.\n\t\tselect {\n\t\tcase err = <-done:\n\t\tcase <-ctx.Done():\n\t\t\t// It is possible for the exporter to have immediately shut down\n\t\t\t// and the context to be done simultaneously. In that case this\n\t\t\t// outer select statement will randomly choose a case. This will\n\t\t\t// result in a different returned error for similar scenarios.\n\t\t\t// Instead, double check if the exporter shut down at the same\n\t\t\t// time and return that error if so. This will ensure consistency\n\t\t\t// as well as ensure the caller knows the exporter shut down\n\t\t\t// successfully (they can already determine if the deadline is\n\t\t\t// expired given they passed the context).\n\t\t\tselect {\n\t\t\tcase err = <-done:\n\t\t\tdefault:\n\t\t\t\terr = ctx.Err()\n\t\t\t}\n\t\t}\n\t})\n\treturn err\n}", "title": "" }, { "docid": "0885721f8e56a2250ee32252a54473b3", "score": "0.65990883", "text": "func Shutdown() {\n\tclose(app.dieChan)\n}", "title": "" }, { "docid": "0a6be2a827a9c248f6b125c1866736df", "score": "0.6585606", "text": "func (a *Aggregator) shutdown() {\n\tlog.Info(\"shutting down\")\n\ta.shutdownHandler.CancelFunc() // initiate shutdown on other modules as well\n\n\tif r := recover(); r != nil {\n\t\tlog.Warn(\"recovering from panic \", r)\n\t}\n\n\tdefer func() {\n\t\t// recover if channel is already closed\n\t\t_ = recover()\n\t}()\n\n\tlog.Debug(\"closing output channel\")\n\tclose(a.outputChan)\n}", "title": "" }, { "docid": "a6d275c3d92dd56182d8003c7bde68d1", "score": "0.6561681", "text": "func (bsp *BatchSpanProcessor) Shutdown() {\n\tbsp.stopOnce.Do(func() {\n\t\tclose(bsp.stopCh)\n\t\tbsp.stopWait.Wait()\n\t})\n}", "title": "" }, { "docid": "9132a9d5de89cb3a40533edbb2d323c9", "score": "0.6555493", "text": "func (manager *ReaperManager) Shutdown() {\n\tmanager.quit <- true\n}", "title": "" }, { "docid": "c43706c9c827f9f85ea3900092edc807", "score": "0.65497166", "text": "func (m Marshaller) shutdown() {\n\tlog.Info(\"shutting down\")\n\tm.shutdownHandler.CancelFunc() // initiate shutdown on other modules as well\n\n\tif r := recover(); r != nil {\n\t\tlog.Error(\"recovering from panic \", r)\n\t}\n\n\tdefer func() {\n\t\t// recover if channel is already closed\n\t\t_ = recover()\n\t}()\n\n\tlog.Debug(\"closing output channel\")\n\tclose(m.OutputChan)\n}", "title": "" }, { "docid": "49da41717c004da60fd3652662877a0c", "score": "0.6496537", "text": "func (receiver *Receiver) Shutdown(ctx context.Context) error {\n\treceiver.stopOnce.Do(func() {\n\t\treceiver.nginxStatsCollector.StopCollection()\n\t})\n\treturn nil\n}", "title": "" }, { "docid": "16b97d3bbdda7a1bade13f5163f0d984", "score": "0.64847815", "text": "func (rjs *RedisJobStatsManager) Shutdown() {\n\tdefer func() {\n\t\trjs.isRunning.Store(false)\n\t}()\n\n\tif !(rjs.isRunning.Load().(bool)) {\n\t\treturn\n\t}\n\n\trjs.opCommands.Stop()\n\trjs.stopChan <- struct{}{}\n\t<-rjs.doneChan\n}", "title": "" }, { "docid": "a8cf6c335852d21c6de792b5bf213515", "score": "0.64463484", "text": "func Shutdown(g *run.Group, logger log.Logger) {\n\n\tc := make(chan os.Signal, 1)\n\tsignal.Notify(c, syscall.SIGINT, syscall.SIGTERM)\n\tshutdown := shutdownActor(logger, c)\n\tg.Add(shutdown.Execute, shutdown.Interrupt)\n\n}", "title": "" }, { "docid": "df6cfed7245f29c02e5c3fa3eb063a40", "score": "0.6435134", "text": "func (e *ExporterAgent) Stop() {\n\tif k, ok := e.Exporter.(Kafka); ok {\n\t\tk.Stop()\n\t}\n\n\te.ir.Stop()\n}", "title": "" }, { "docid": "67259f1b65fe49597a824ec133d2e2e6", "score": "0.64053935", "text": "func Shutdown() {\n\tdefaultDaemon.Shutdown()\n}", "title": "" }, { "docid": "560d09109e60fd31eb4d195285fe84a7", "score": "0.6397254", "text": "func (s *Difuse) Shutdown() {\n\tlog.Println(\"[chord] Shutdown\")\n}", "title": "" }, { "docid": "d734689a506f31cbf61d8943b6cab4d3", "score": "0.636398", "text": "func (_m *Integration) Shutdown() {\n\t_m.Called()\n}", "title": "" }, { "docid": "aea29ab39335fe12d1d658169e844c28", "score": "0.6356836", "text": "func (p *BlsCosiMaskAggr) Shutdown() error {\n\tp.stoppedOnce.Do(func() {\n\t\tclose(p.startChan)\n\t\tclose(p.FinalSignature)\n\t})\n\treturn nil\n}", "title": "" }, { "docid": "15971df52930eeccd4ca50cdd319c8fa", "score": "0.6345766", "text": "func (w *webBasedWatcher) Shutdown() {\n\tlog.Info(\"[Web Based Watcher] Shutting down\")\n\tctx, cancel := context.WithTimeout(context.Background(), maxShutdownWaitTimeSeconds*time.Second)\n\tdefer cancel()\n\t_ = w.server.Shutdown(ctx)\n\n\tlog.Debug(\"[Web Based Watcher] HTTP server shutdown\")\n\tlog.Debug(\"[Web Based Watcher] Shutting down all actioners\")\n\n\tvar wg sync.WaitGroup\n\tfor _, a := range w.registeredActioners {\n\t\twg.Add(1)\n\n\t\tgo func(ma actioner.MetadataActioner) {\n\t\t\tma.Shutdown()\n\t\t\twg.Done()\n\t\t}(a)\n\t}\n\twg.Wait()\n\tlog.Info(\"[Web Based Watcher] Bye-bye\")\n}", "title": "" }, { "docid": "bffbc1ddf3deecf2dc5da9a6c3ea2c25", "score": "0.6336291", "text": "func (dd *Deduper) Shutdown() {\n\tdd.shutdownOnce.Do(func() { close(dd.shutdownChan) })\n}", "title": "" }, { "docid": "8dd75e92cb2370bca9e190f2682df742", "score": "0.632891", "text": "func (p *datadogProcessor) Shutdown(context.Context) error {\n\tif !p.started {\n\t\treturn nil\n\t}\n\tp.started = false\n\tp.agent.Stop()\n\tp.exit <- struct{}{} // signal exit\n\t<-p.exit // wait for close\n\treturn nil\n}", "title": "" }, { "docid": "52dfcc9807a492fcca87c104278b5a77", "score": "0.63200974", "text": "func (cmd *ProxyLogger) Shutdown() error {\n\treturn nil\n}", "title": "" }, { "docid": "c8bfe83f8ea5eec794c022dc3779793e", "score": "0.6314947", "text": "func (r *Runner) shutdown() {\n\tr.logger.Info(\"shutting down the runner\")\n\tr.Iteration.Input.Shutdown()\n\tr.Iteration.Output.Shutdown()\n\tr.Iteration.Tracker.Shutdown()\n\tr.logger.Info(\"runner has been shut down\")\n}", "title": "" }, { "docid": "0f0bb32c62670e81e125014d72be5d0f", "score": "0.6313772", "text": "func (e *Extension) Shutdown() error {\n\treturn nil\n}", "title": "" }, { "docid": "0f5d0c42d516a593c4262bffff813d41", "score": "0.62999964", "text": "func (m *MockExporter) Stop() {\n\tm.logger.Infof(\"{%s} stopping the mock exporter\", m.Name())\n\tm.stop.Do(func() {\n\t\tclose(m.shutdown)\n\t})\n\n\t// wait for the exporter to finish\n\tm.wg.Wait()\n}", "title": "" }, { "docid": "0f28af72f121e22fea21dbdc756483d4", "score": "0.62875503", "text": "func (mf *MetricFactory) Shutdown() chan struct{} {\n\t// Stop the ticker if it is there and flush gauges for the last time.\n\tif mf.flushGaugesTicker != nil {\n\t\tmf.flushGaugesTicker.stop()\n\t\tmf.flushGauges()\n\t}\n\t// Shutdown our shipper\n\treturn mf.shipper.Shutdown()\n}", "title": "" }, { "docid": "5adee0d015fcc8994e52f13701cf251a", "score": "0.6253089", "text": "func (e *Extension) Shutdown() {\n\tclose(e.done)\n\te.wg.Wait()\n}", "title": "" }, { "docid": "5adee0d015fcc8994e52f13701cf251a", "score": "0.6253089", "text": "func (e *Extension) Shutdown() {\n\tclose(e.done)\n\te.wg.Wait()\n}", "title": "" }, { "docid": "537e88a31799a460de0c8e72e02bda1b", "score": "0.6251221", "text": "func Shutdown() {\n\n}", "title": "" }, { "docid": "537e88a31799a460de0c8e72e02bda1b", "score": "0.6251221", "text": "func Shutdown() {\n\n}", "title": "" }, { "docid": "46e81327cfec29633fe91bb09db401ba", "score": "0.6245262", "text": "func (e *Exporter) Stop() error {\n\t// exporter does not require being stopped\n\treturn nil\n}", "title": "" }, { "docid": "bc62a9ef65248bb01654f2907f1fa1df", "score": "0.6242086", "text": "func (p *Prontab) Shutdown() {\n\tdefer close(p.outChan)\n\tdefer close(p.errChan)\n\n\tp.j.externalJobs = []externalJob{}\n\tp.j.internalJobs = []internalJob{}\n\tp.t.Stop()\n}", "title": "" }, { "docid": "da333d8a5225da4f3734a33333998c79", "score": "0.6211122", "text": "func Shutdown() {\n\tif global != nil {\n\t\tglobal.Shutdown()\n\t}\n}", "title": "" }, { "docid": "8bc019c017ef9a0384a2825db0d04e10", "score": "0.62101233", "text": "func (_m *NodeWatchFactory) Shutdown() {\n\t_m.Called()\n}", "title": "" }, { "docid": "d613dcf492cb61b447ee2ee8b628bb3e", "score": "0.6209583", "text": "func Shutdown() {\n\tdefaultApp.Shutdown()\n}", "title": "" }, { "docid": "85965e6cbd5e3f5e2fdc97e6de848b2d", "score": "0.6195131", "text": "func (s *SimpleSource) Shutdown() error {\n\tlog.Info(\"simplesource: shutdown called\")\n\ts.donechan <- true\n\treturn nil\n}", "title": "" }, { "docid": "12a14b821bfc0775cd7a92daaeb70c5c", "score": "0.6192214", "text": "func (util Utility) Shutdown() error {\n\n\tfor key, startup := range util.Items {\n\t\tutil.LogDebug(\"Shutdown\", key)\n\t\terr := startup.DoShutdownChecks(util)\n\t\tif err != nil {\n\t\t\tutil.LogErrorE(\"Shutdown\", err)\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// flush the reports before closing\n\tutil.FlushRecords()\n\n\t// close reports\n\tfor _, sud := range util.Reports {\n\t\tif sud.File != nil {\n\t\t\tsud.File.Close()\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "830e995e85f05056045c926821ee199f", "score": "0.6171206", "text": "func (runner *TaskRunner) Shutdown(executor.ExecutorDriver) {\n\tfmt.Println(\"Shutting down the executor\")\n}", "title": "" }, { "docid": "bfa4361f3d867827655d9b2c5e65ae8c", "score": "0.6153442", "text": "func (d *HttpsDistributor) Shutdown() {\n\tlog.Printf(\"Shutting down %s distributor.\", DistName)\n\n\t// Signal to housekeeping that it's time to stop.\n\tclose(d.shutdown)\n\td.wg.Wait()\n}", "title": "" }, { "docid": "ee547551e09d9301f4afc9a36bbbc5c6", "score": "0.61298734", "text": "func (a *Agent) Shutdown() {\n\tinfo(a.Logger, \"[server] shutting down\")\n\tos.RemoveAll(a.SocketPath)\n\tfor _, ws := range a.workspaces {\n\t\tws.Stop()\n\t}\n}", "title": "" }, { "docid": "365837fc4b4609ee01dbd4f370fda831", "score": "0.6128485", "text": "func (px *Pex) Shutdown() {\n\tif px.quit != nil {\n\t\tclose(px.quit)\n\t\tpx.quit = nil\n\t}\n}", "title": "" }, { "docid": "f386c1bf00a8e2582369fc37a45f1dc7", "score": "0.6122058", "text": "func (disk *Informer) Shutdown() error {\n\tdisk.rpcClient = nil\n\treturn nil\n}", "title": "" }, { "docid": "ef4de4b79abb31a4e9e7b29ee52aa5cb", "score": "0.6121468", "text": "func (c *SimpleClient) Shutdown() {\n\tif !c.shutdown {\n\t\tc.FeatureStore.Shutdown()\n\t\tc.eventsRecorder.Shutdown()\n\t\tc.eventsCountAggregator.Shutdown()\n\t\tc.shutdown = true\n\t}\n}", "title": "" }, { "docid": "1808586369971ad1faa0f488f74109b8", "score": "0.6116686", "text": "func (e *endpoint) Shutdown() error {\n\t// Terminate filesystem watching. This will result in the associated events\n\t// channel being closed.\n\te.watchCancel()\n\n\t// Done.\n\treturn nil\n}", "title": "" }, { "docid": "6c927d681a82fb9d843e89ad9c1b4459", "score": "0.61046493", "text": "func (w *RedWorker) Shutdown() {\n\tclose(w.done)\n\t<-w.shutDownChan\n}", "title": "" }, { "docid": "ab90183ca3b3244d1b0b60e4c29661bb", "score": "0.6095747", "text": "func (de *BaseExporter) UnExport() {\n\tlogger.Infof(\"Exporter unexport.\")\n\tde.invoker.Destroy()\n\tde.exporterMap.Delete(de.key)\n}", "title": "" }, { "docid": "99f2c04fdb28f0f69a2f300dcc1db835", "score": "0.6094669", "text": "func (s *ETHScanner) Shutdown() {\n\ts.log.Info(\"Closing ETH scanner\")\n\ts.ethClient.Shutdown()\n\ts.base.Shutdown()\n\ts.log.Info(\"Waiting for ETH scanner to stop\")\n\ts.log.Info(\"ETH scanner stopped\")\n}", "title": "" }, { "docid": "cc398c59fed6486860c6628533581c35", "score": "0.6082921", "text": "func (s *BackupSupervisor) Shutdown() {\n\ts.logger.Debug(\"Shutting down backup supervisor\")\n}", "title": "" }, { "docid": "7dd6ed89bfa5eecd3be4fa51a2c54281", "score": "0.60741514", "text": "func shutdown() {\n\tlog.Println(\"Shutting down..\")\n\n\tos.Exit(0)\n}", "title": "" }, { "docid": "7751b5ab345c0e01f6fd68fdaaade971", "score": "0.6068352", "text": "func Shutdown() {\n\tdone <- nil\n}", "title": "" }, { "docid": "f874170000cad341e0d9517c0fb3972d", "score": "0.60673195", "text": "func (rpc *rpc) Shutdown() {\n\trpc.info(\"Shutting down rpc\")\n\tif !rpc.extTransport {\n\t\trpc.t.Shutdown()\n\t}\n}", "title": "" }, { "docid": "2f9369082ccb009067e2482c33344c82", "score": "0.6061585", "text": "func (r *Ring) Shutdown() {\n\tr.stopVnodes()\n\tr.stopDelegate()\n}", "title": "" }, { "docid": "7327c21416211b8abb55f8e4e896d044", "score": "0.6056259", "text": "func (s *SingularityRuntime) Shutdown() error {\n\tif err := s.streaming.Stop(); err != nil {\n\t\treturn fmt.Errorf(\"could not stop streaming server: %v\", err)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "5fe7ce9e3ca4f183e6c2a765b8dfed2e", "score": "0.60551053", "text": "func (a *Agent) Shutdown() {\n}", "title": "" }, { "docid": "c7a3f2535f870f6e6e506a707a73aad1", "score": "0.6055075", "text": "func (p *BlsCosi) Shutdown() error {\n\tp.stoppedOnce.Do(func() {\n\t\tclose(p.startChan)\n\t\tclose(p.FinalSignature)\n\t})\n\treturn nil\n}", "title": "" }, { "docid": "408d7ddb33078dc4858d95cbc87b1544", "score": "0.6046714", "text": "func (dtrp *deltaToRateProcessor) Shutdown(context.Context) error {\n\treturn nil\n}", "title": "" }, { "docid": "e3feaafe9a1952b518d8e2ed6c07c012", "score": "0.6046421", "text": "func (h *MICListener) Shutdown() {\n\tlog.Printf(\"miclistener: Shutdown not implemented\")\n}", "title": "" }, { "docid": "81fd54916fc498959cb20cea09a5db9a", "score": "0.60442376", "text": "func (p *GossipRegistationProtocol) Shutdown() error {\n\treturn nil\n}", "title": "" }, { "docid": "ba8309018cea7e8868c200050763fb8a", "score": "0.6040922", "text": "func (s *Streaming) Shutdown() {\n\tatomic.StoreInt32(&s.inShutdown, 1)\n}", "title": "" }, { "docid": "1fd1dad8bea3ac3da968c7394942fea6", "score": "0.60311097", "text": "func (c *csiHook) Shutdown() {\n\tc.logger.Trace(\"shutting down hook\")\n\tc.shutdownCancelFn()\n}", "title": "" }, { "docid": "0b95723d262f871f0d8a1de246ab53bc", "score": "0.6027974", "text": "func (op *ShellOperator) Shutdown() {\n\top.ScheduleManager.Stop()\n\top.KubeEventsManager.PauseHandleEvents()\n\top.TaskQueues.Stop()\n\t// Wait for queues to stop, but no more than 10 seconds\n\top.TaskQueues.WaitStopWithTimeout(WaitQueuesTimeout)\n}", "title": "" }, { "docid": "887b706e46db828fc0354229f7ec44d2", "score": "0.6026793", "text": "func (se *SyslogExecutor) Shutdown(executor.ExecutorDriver) {\n\tfmt.Println(\"Shutting down the executor\")\n\n\tselect {\n\tcase se.close <- true:\n\tdefault:\n\t}\n}", "title": "" }, { "docid": "47370127b3b2f4411746b98c4ae9f21c", "score": "0.60236114", "text": "func (self *Daemon) Shutdown() {\n\tself.Pool.Shutdown()\n\tself.Peers.Shutdown()\n\tself.Visor.Shutdown()\n\tgnet.EraseMessages()\n}", "title": "" }, { "docid": "07250a893a7ff08d32af5c6b73c9a815", "score": "0.6019193", "text": "func (service *Service) Shutdown() {\n\tservice.Log.Infof(\"service shutdown\")\n\n\tservice.ShutdownServers()\n\n\tif service.Tracker.Tracker != nil {\n\t\tservice.Log.Infof(\"shutting down tracker\")\n\t\tservice.Tracker.Tracker.Close()\n\t}\n\n\tservice.Log.Infof(\"shutdown done\")\n\tos.Create(\"cache/.shutdown_done\")\n\n\t// flush cue buffers\n\tcue.Close(5 * time.Second)\n\n}", "title": "" }, { "docid": "3fd607f1ec3853de148fd6556ef3dc00", "score": "0.60121465", "text": "func (o *Orchestrator) Shutdown() {\n\to.done <- true\n}", "title": "" }, { "docid": "15a8c9f66225da021e3ed8f27a908073", "score": "0.60069215", "text": "func (bcp *BlockchainParser) Shutdown() {\n\tclose(bcp.quit)\n\t<-bcp.done\n}", "title": "" }, { "docid": "e88aec18fa04186d86b87ea5b5210530", "score": "0.6003296", "text": "func (mgr *PeriodicTaskManager) Shutdown() {\n\tclose(mgr.done)\n\tmgr.wg.Wait()\n\tmgr.s.Shutdown()\n}", "title": "" }, { "docid": "28622fb7f64f9e5c4f887aa636f65e56", "score": "0.60006803", "text": "func (driver *TitusMesosDriver) Shutdown(exec mesosExecutor.ExecutorDriver) {\n\tlog.Printf(\"Shutting down Mesos driver\")\n\ttime.AfterFunc(time.Hour, func() {\n\t\tlog.Error(\"Executor is performing emergency termination after shutdown\")\n\t\ttime.Sleep(10 * time.Second)\n\t\tos.Exit(1)\n\t})\n\tdriver.runner.Kill()\n}", "title": "" }, { "docid": "542e0fc249839dab394c51dc593dd003", "score": "0.59897095", "text": "func (s *ForwarderService) Shutdown() {\n\ts.shutdown <- struct{}{}\n}", "title": "" }, { "docid": "eb26208fad7e70bdb8c2361101c2c840", "score": "0.5989015", "text": "func (e *EventsHub) Shutdown() {\n\tlog.Logger.Debugf(\"EventsHub is shutting down\")\n}", "title": "" }, { "docid": "b671a5db12e2ebf784e386ce52d8aa46", "score": "0.5987945", "text": "func (l *c14Objects) Shutdown(ctx context.Context) error {\n\treturn nil\n}", "title": "" }, { "docid": "34b00944669a503ebba1d1e61cbefd50", "score": "0.59877896", "text": "func Finalise() error {\n\tglobalData.Lock()\n\tdefer globalData.Unlock()\n\n\tif !globalData.initialised {\n\t\treturn fault.ErrNotInitialised\n\t}\n\n\tglobalData.log.Info(\"shutting down…\")\n\tglobalData.log.Flush()\n\n\t// stop background\n\tglobalData.background.Stop()\n\n\t// finally...\n\tglobalData.initialised = false\n\n\treturn nil\n}", "title": "" }, { "docid": "0d99fad0e9ed70a6dcae9edf2d199496", "score": "0.59799755", "text": "func (m *Mesh)Shutdown() {\n\tfor _, node := range m.Nodes {\n\t\tnode.NetceptorInstance.Shutdown()\n\t}\n}", "title": "" }, { "docid": "23f536c625c6ad4afd23a9e3fa37a5c6", "score": "0.5978487", "text": "func (b *Board) Shutdown() {\n\tb.close <- 1\n}", "title": "" }, { "docid": "b7bb84ddb045826dc311865e20766793", "score": "0.5975189", "text": "func (a *app) Shutdown() {\n\tlog.Printf(\"cleaning up\")\n\tdefer log.Printf(\"shutting down\")\n\ta.Sprout().MarkSelfOffline()\n}", "title": "" }, { "docid": "258f2432b747b6288915064538990f52", "score": "0.59722257", "text": "func (s *FIFOScheduler) Shutdown() {\n\ts.shutdownOnce.Do(func() {\n\t\tclose(s.shutdownSignal)\n\t})\n\n\ts.shutdown.Wait()\n\ts.allMessagesScheduledWG.Wait()\n\ts.tangle.ConsensusManager.Events.MessageOpinionFormed.Detach(s.onOpinionFormed)\n\ts.tangle.Events.MessageInvalid.Detach(s.onMessageInvalid)\n}", "title": "" }, { "docid": "2de87f9cdb6835c86758e3b33df6896c", "score": "0.5967918", "text": "func (es *EventSource) Shutdown() {\n\tes.shutdown <- true\n}", "title": "" }, { "docid": "237f1a045354645cbec18f1e70bb8acc", "score": "0.59573203", "text": "func (w *Worker) Shutdown(req stubs.Empty, res *stubs.Empty) (err error) {\n\tprintln(\"Received shutdown request\")\n\tserver.Close()\n\tos.Exit(0)\n\treturn\n}", "title": "" }, { "docid": "11b7ba3df845b4caa76d124e5add0032", "score": "0.5955076", "text": "func (s *ScrapingService) Shutdown() {\n\ts.log.Infof(\"trying to gracefully shutdown the server\")\n\ts.inner.GracefulStop()\n}", "title": "" }, { "docid": "9b4d88f2211a4426484396da6a31a8d5", "score": "0.59548604", "text": "func (s *ResolverService) Shutdown() {\n\ts.shutdown <- struct{}{}\n}", "title": "" }, { "docid": "c9f54f56e53b15c712cc3ebd7e69ac38", "score": "0.594659", "text": "func (pool *ConnectionPool) Shutdown() {\n\tclose(pool.quit)\n\n\tif pool.listener != nil {\n\t\tpool.listener.Close()\n\t}\n\n\tpool.listener = nil\n}", "title": "" }, { "docid": "f0affe993623092b7741be8d5373857a", "score": "0.5938758", "text": "func (m *Metrics) Shutdown(ctx context.Context) (err error) {\n\tm.mu.Lock()\n\tdefer m.mu.Unlock()\n\n\tif m.closed {\n\t\treturn\n\t}\n\n\tm.closed = true\n\n\tclose(m.shutdownCh)\n\n\tif m.server != nil {\n\t\tm.server.Shutdown(ctx) //nolint:errcheck\n\t}\n\n\tfor _, writer := range m.writers {\n\t\twriter.Stop()\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "f582bca1469f96844f053a1dd3ffb24c", "score": "0.59366566", "text": "func (s *badgerStore) Shutdown() {\n}", "title": "" }, { "docid": "c9545d676f1c1f159c8eb961d6890f7a", "score": "0.5931639", "text": "func (r *SidecarRing) Shutdown() {\n\tr.rcvr.Looper.Quit()\n\tr.managerLooper.Quit()\n}", "title": "" }, { "docid": "94cdbc6349f7823eb476c2c75cdcc887", "score": "0.5931143", "text": "func (s *Service) Shutdown() {\n\tlog.Println(\"[Match] -> Closing service\")\n\tclose(s.shutdown)\n\ts.manager.Close()\n}", "title": "" }, { "docid": "1c65515ac3b02f1d4a824a76a24b695c", "score": "0.5930119", "text": "func (t *Trigger) Shutdown() {\n\tclose(t.closeChan)\n}", "title": "" }, { "docid": "6714ed87f3b1b3f544663549e7d102e1", "score": "0.592996", "text": "func (master *BuildMaster) Shutdown() {\n\tmaster.stopWorkers <- struct{}{}\n\tmaster.stopListening <- struct{}{}\n\t<-master.stopListening\n\tmaster.workersWaitGroup.Wait()\n\tclose(master.reports)\n\tclose(master.stopWorkers)\n\tclose(master.stopListening)\n}", "title": "" }, { "docid": "88205f0753da972e3e4bd9c31ae54be1", "score": "0.5929391", "text": "func Shutdown() {\n\tC.g_mime_shutdown()\n}", "title": "" }, { "docid": "93af68ba122a202b8fe7bb8e024bdb00", "score": "0.59280986", "text": "func (proc *MessageProcessor) Shutdown() {\n\tproc.shutdownMutex.Lock()\n\tdefer proc.shutdownMutex.Unlock()\n\n\tproc.shutdown = true\n\tproc.wp.StopAndWait()\n\tproc.workUnits.Shutdown()\n}", "title": "" }, { "docid": "93e446314a2653151d51ab3106b39ed1", "score": "0.5922766", "text": "func (dm *Daemon) Shutdown() {\n\tdefer logger.Info(\"Daemon shutdown complete\")\n\n\t// close daemon run loop first to avoid creating new connection after\n\t// the connection pool is shutdown.\n\tlogger.Info(\"Stopping the daemon run loop\")\n\tclose(dm.quit)\n\n\tlogger.Info(\"Shutting down Pool\")\n\tdm.pool.Shutdown()\n\n\tlogger.Info(\"Shutting down Pex\")\n\tdm.pex.Shutdown()\n\n\t<-dm.done\n}", "title": "" }, { "docid": "83fc39bfe93086e49924fe588e3ae97a", "score": "0.59211934", "text": "func (proc *MessageProcessor) Shutdown() {\n\tproc.shutdownMutex.Lock()\n\tdefer proc.shutdownMutex.Unlock()\n\n\tproc.shutdown = true\n\tproc.wp.Shutdown()\n\tproc.workUnits.Shutdown()\n}", "title": "" }, { "docid": "3ccc9b254d62edf13dc2feafc1a5598b", "score": "0.5919897", "text": "func (g *GlobalContext) Shutdown(mctx MetaContext) error {\n\tvar err error\n\tdidShutdown := false\n\n\t// Wrap in a Once.Do so that we don't inadvertedly\n\t// run this code twice.\n\tg.shutdownOnce.Do(func() {\n\t\tg.Log.Debug(\"GlobalContext#Shutdown(%p)\\n\", g)\n\t\tif g.PerfLog != nil {\n\t\t\tg.PerfLog.Debug(\"GlobalContext#Shutdown(%p)\\n\", g)\n\t\t}\n\t\tdidShutdown = true\n\n\t\tepick := FirstErrorPicker{}\n\n\t\tif g.hiddenTeamChainManager != nil {\n\t\t\tg.hiddenTeamChainManager.Shutdown(mctx)\n\t\t}\n\n\t\tif g.NotifyRouter != nil {\n\t\t\tg.NotifyRouter.Shutdown()\n\t\t}\n\n\t\tif g.UIRouter != nil {\n\t\t\tg.UIRouter.Shutdown()\n\t\t}\n\n\t\tif g.ConnectionManager != nil {\n\t\t\tg.ConnectionManager.Shutdown()\n\t\t}\n\n\t\tif g.UI != nil {\n\t\t\tepick.Push(g.UI.Shutdown())\n\t\t}\n\n\t\t// Shutdown can still race with Logout, so make sure that we hold onto\n\t\t// the cacheMu before shutting down the caches. See comments in\n\t\t// shutdownCachesLocked\n\t\tg.cacheMu.Lock()\n\t\tg.shutdownCachesLocked()\n\t\tg.cacheMu.Unlock()\n\n\t\tif g.proofServices != nil {\n\t\t\tg.proofServices.Shutdown()\n\t\t}\n\n\t\tif g.Resolver != nil {\n\t\t\tg.Resolver.Shutdown(NewMetaContextBackground(g))\n\t\t}\n\n\t\tg.Log.Debug(\"executing %d shutdown hooks; errCount=%d\", len(g.ShutdownHooks), epick.Count())\n\t\tfor _, hook := range g.ShutdownHooks {\n\t\t\tepick.Push(hook(mctx))\n\t\t}\n\t\tg.Log.Debug(\"executed shutdown hooks; errCount=%d\", epick.Count())\n\n\t\tif g.LocalNetworkInstrumenterStorage != nil {\n\t\t\t<-g.LocalNetworkInstrumenterStorage.Stop(mctx.Ctx())\n\t\t}\n\n\t\tif g.RemoteNetworkInstrumenterStorage != nil {\n\t\t\t<-g.RemoteNetworkInstrumenterStorage.Stop(mctx.Ctx())\n\t\t}\n\n\t\t// shutdown the databases after the shutdown hooks run, we may want to\n\t\t// flush memory caches to disk during shutdown.\n\t\tif g.LocalDb != nil {\n\t\t\tepick.Push(g.LocalDb.Close())\n\t\t}\n\t\tif g.LocalChatDb != nil {\n\t\t\tepick.Push(g.LocalChatDb.Close())\n\t\t}\n\t\tif g.GUILogFile != nil {\n\t\t\tepick.Push(g.GUILogFile.Close())\n\t\t}\n\t\t<-g.Identify3State.Shutdown()\n\n\t\terr = epick.Error()\n\n\t\tg.Log.Debug(\"exiting shutdown code=%d; errCount=%d; firstErr=%v\", g.ExitCode, epick.Count(), err)\n\t})\n\n\t// Make a little bit of a statement if we wind up here a second time\n\t// (which is a bug).\n\tif !didShutdown {\n\t\tg.Log.Debug(\"Skipped shutdown on second call\")\n\t}\n\n\treturn err\n}", "title": "" } ]
3cfb7a6c64b8fa3b7b93350da3f1538c
New create service instance and return.
[ { "docid": "5ce38351c30fbe9b378543fa84c9f5cb", "score": "0.0", "text": "func New(c *conf.Config) (s *Service) {\n\ts = &Service{\n\t\tc: c,\n\t\tdao: dao.New(c),\n\t\tmissch: make(chan func(), 1024000),\n\t\tarcRPC: arcrpc.New2(c.RPCClient2.Archive),\n\t\tmemRPC: memrpc.New(c.RPCClient2.Member),\n\t\ttagMap: make(map[int8]int64),\n\t\tannouncement: &announcement{\n\t\t\tdef: make([]*model.BlockedAnnouncement, 0, 4),\n\t\t\talist: make(map[int8][]*model.BlockedAnnouncement),\n\t\t\tamap: make(map[int64]*model.BlockedAnnouncement),\n\t\t},\n\t}\n\tvar err error\n\tif s.fliClient, err = fligrpc.NewClient(c.GRPCClient.Filter); err != nil {\n\t\tpanic(errors.WithMessage(err, \"Failed to dial filter service\"))\n\t}\n\tif s.accountClient, err = accgrpc.NewClient(c.GRPCClient.Account); err != nil {\n\t\tpanic(errors.WithMessage(err, \"Failed to dial account service\"))\n\t}\n\ts.initTag()\n\ts.loadConf()\n\ts.loadQuestion()\n\ts.loadManager()\n\ts.LoadAnnouncement(context.TODO())\n\tgo s.loadConfproc()\n\tgo s.loadQuestionproc()\n\tgo s.loadManagerproc()\n\tgo s.loadAnnouncementproc()\n\tgo s.cacheproc()\n\treturn\n}", "title": "" } ]
[ { "docid": "e4fee4d123198d281e9ecbe4bdef1097", "score": "0.7608114", "text": "func New() Service {\n\treturn service{}\n}", "title": "" }, { "docid": "1fdea176fc18f57e8b2ebdccea603f3d", "score": "0.7390706", "text": "func (h *ServicesHandler) Create(ctx context.Context, project string, req CreateServiceRequest) (*Service, error) {\n\tpath := buildPath(\"project\", project, \"service\")\n\tbts, err := h.client.doPostRequest(ctx, path, req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar r ServiceResponse\n\terrR := checkAPIResponse(bts, &r)\n\n\treturn r.Service, errR\n}", "title": "" }, { "docid": "c8a6baaf3a469b9119205b37c495f56b", "score": "0.7382995", "text": "func New() *service {\n\tvar result = &service{\n\t\tAbstractService: endly.NewAbstractService(ServiceID),\n\t}\n\tresult.AbstractService.Service = result\n\tresult.registerRoutes()\n\treturn result\n}", "title": "" }, { "docid": "b7d1bd6c1658972b37d2f3930da8eee8", "score": "0.7340318", "text": "func New() *Service {\n\treturn &Service{}\n}", "title": "" }, { "docid": "b7d1bd6c1658972b37d2f3930da8eee8", "score": "0.7340318", "text": "func New() *Service {\n\treturn &Service{}\n}", "title": "" }, { "docid": "b7d1bd6c1658972b37d2f3930da8eee8", "score": "0.7340318", "text": "func New() *Service {\n\treturn &Service{}\n}", "title": "" }, { "docid": "b7d1bd6c1658972b37d2f3930da8eee8", "score": "0.7340318", "text": "func New() *Service {\n\treturn &Service{}\n}", "title": "" }, { "docid": "8fa15c2a9c8a731b1ed98805732b984b", "score": "0.73023427", "text": "func New(c *conf.Config) (s *Service) {\n\ts = &Service{\n\t\tc: c,\n\t\tdao: dao.New(c),\n\t\teventChan: cache.New(1, 10240),\n\t}\n\ts.generate(context.Background(), x, 0, len(x)-1)\n\treturn\n}", "title": "" }, { "docid": "33eb76a84f025fbbf3fda48ec923146f", "score": "0.7270399", "text": "func New(config *Config) Service {\n\treturn &service{\n\t\tConfig: config,\n\t\twritePolicy: aero.NewWritePolicy(0, 0),\n\t}\n}", "title": "" }, { "docid": "7bb361d95639b83ab0b522c6cd379f52", "score": "0.7251531", "text": "func ServiceNew(homeDirectory string, org string, specRef string, version string, images []string, noImageGen bool, dconfig []string, noPattern bool, noPolicy bool) {\n\t// get message printer\n\tmsgPrinter := i18n.GetMessagePrinter()\n\n\t// validate the parameters\n\tdir, err := verifyNewServiceInputs(homeDirectory, org, specRef, version, images, noImageGen, dconfig, noPattern)\n\tif err != nil {\n\t\tcliutils.Fatal(cliutils.CLI_INPUT_ERROR, \"'%v %v' %v\", SERVICE_COMMAND, SERVICE_CREATION_COMMAND, err)\n\t}\n\n\t// fill unspecified parameters witht the default\n\tif len(images) != 0 {\n\t\t// get the specRef and version from the image name if not specified\n\t\tif specRef == \"\" {\n\t\t\tspecRef1, version1, err := GetServiceSpecFromImage(images[0])\n\t\t\tif err != nil {\n\t\t\t\tcliutils.Fatal(cliutils.CLI_GENERAL_ERROR, msgPrinter.Sprintf(\"'%v %v' Failed to get the service name from the image name. %v\", SERVICE_COMMAND, SERVICE_CREATION_COMMAND, err))\n\t\t\t} else {\n\t\t\t\tspecRef = specRef1\n\t\t\t}\n\n\t\t\tif version == \"\" && version1 != \"\" {\n\t\t\t\tversion = version1\n\t\t\t}\n\t\t}\n\t}\n\tif specRef != \"\" && version == \"\" {\n\t\tversion = SERVICE_NEW_DEFAULT_VERSION\n\t}\n\n\t// Create the working directory.\n\tif err := CreateWorkingDir(dir); err != nil {\n\t\tcliutils.Fatal(cliutils.CLI_INPUT_ERROR, \"'%v %v' %v\", SERVICE_COMMAND, SERVICE_CREATION_COMMAND, err)\n\t}\n\n\t// If there are any horizon metadata files already in the directory then we wont create any files.\n\tcmd := fmt.Sprintf(\"%v %v\", SERVICE_COMMAND, SERVICE_CREATION_COMMAND)\n\tFileNotExist(dir, cmd, USERINPUT_FILE, UserInputExists)\n\tFileNotExist(dir, cmd, SECRETS_FILE, SecretsFileExists)\n\tFileNotExist(dir, cmd, SERVICE_DEFINITION_FILE, ServiceDefinitionExists)\n\tFileNotExist(dir, cmd, PATTERN_DEFINITION_FILE, PatternDefinitionExists)\n\tFileNotExist(dir, cmd, PATTERN_DEFINITION_ALL_ARCHES_FILE, PatternDefinitionAllArchesExists)\n\n\tif org == \"\" {\n\t\torg = os.Getenv(DEVTOOL_HZN_ORG)\n\t}\n\n\timageInfo, image_base, err := GetImageInfoFromImageList(images, version, noImageGen)\n\tif err != nil {\n\t\tcliutils.Fatal(cliutils.CLI_GENERAL_ERROR, \"'%v %v' %v\", SERVICE_COMMAND, SERVICE_CREATION_COMMAND, err)\n\t}\n\n\t// create env var file\n\tcliutils.Verbose(msgPrinter.Sprintf(\"Creating config file for environmental variables: %v/%v\", dir, HZNENV_FILE))\n\terr = CreateHznEnvFile(dir, org, specRef, version, image_base)\n\tif err != nil {\n\t\tcliutils.Fatal(cliutils.CLI_GENERAL_ERROR, \"'%v %v' %v\", SERVICE_COMMAND, SERVICE_CREATION_COMMAND, err)\n\t}\n\n\t// Create the metadata files.\n\tcliutils.Verbose(msgPrinter.Sprintf(\"Creating user input file: %v/%v\", dir, USERINPUT_FILE))\n\terr = CreateUserInputs(dir, specRef)\n\tif err != nil {\n\t\tcliutils.Fatal(cliutils.CLI_GENERAL_ERROR, \"'%v %v' %v\", SERVICE_COMMAND, SERVICE_CREATION_COMMAND, err)\n\t}\n\n\tcliutils.Verbose(msgPrinter.Sprintf(\"Creating secrets file: %v/%v\", dir, SECRETS_FILE))\n\terr = CreateSecretsFile(dir)\n\tif err != nil {\n\t\tcliutils.Fatal(cliutils.CLI_GENERAL_ERROR, \"'%v %v' %v\", SERVICE_COMMAND, SERVICE_CREATION_COMMAND, err)\n\t}\n\n\tcliutils.Verbose(msgPrinter.Sprintf(\"Creating service definition file: %v/%v\", dir, SERVICE_DEFINITION_FILE))\n\terr = CreateServiceDefinition(dir, specRef, imageInfo, noImageGen, dconfig)\n\tif err != nil {\n\t\tcliutils.Fatal(cliutils.CLI_GENERAL_ERROR, \"'%v %v' %v\", SERVICE_COMMAND, SERVICE_CREATION_COMMAND, err)\n\t}\n\n\tif !noPattern {\n\t\tcliutils.Verbose(msgPrinter.Sprintf(\"Creating pattern definition file: %v/%v\", dir, PATTERN_DEFINITION_FILE))\n\t\terr = CreatePatternDefinition(dir)\n\t\tif err != nil {\n\t\t\tcliutils.Fatal(cliutils.CLI_GENERAL_ERROR, \"'%v %v' %v\", SERVICE_COMMAND, SERVICE_CREATION_COMMAND, err)\n\t\t}\n\t\tif cutil.SliceContains(dconfig, \"native\") {\n\t\t\tcliutils.Verbose(msgPrinter.Sprintf(\"Creating pattern definition file: %v/%v\", dir, PATTERN_DEFINITION_ALL_ARCHES_FILE))\n\t\t\terr = CreatePatternDefinitionAllArches(dir)\n\t\t\tif err != nil {\n\t\t\t\tcliutils.Fatal(cliutils.CLI_GENERAL_ERROR, \"'%v %v' %v\", SERVICE_COMMAND, SERVICE_CREATION_COMMAND, err)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Create default service policy file\n\tif !noPolicy {\n\t\tcliutils.Verbose(msgPrinter.Sprintf(\"Creating service policy file: %v/%v\", dir, SERVICE_POLICY_FILE))\n\t\terr = CreateServicePolicy(dir)\n\t\tif err != nil {\n\t\t\tcliutils.Fatal(cliutils.CLI_GENERAL_ERROR, \"'%v %v' %v\", SERVICE_COMMAND, SERVICE_CREATION_COMMAND, err)\n\t\t}\n\t}\n\n\t// create files for source code control.\n\tcliutils.Verbose(msgPrinter.Sprintf(\"Creating .gitignore files for source code management.\"))\n\terr = CreateSourceCodeManagementFiles(dir)\n\tif err != nil {\n\t\tcliutils.Fatal(cliutils.CLI_GENERAL_ERROR, \"'%v %v' %v\", SERVICE_COMMAND, SERVICE_CREATION_COMMAND, err)\n\t}\n\n\t// create the image related files under current direcotry.\n\tif !noImageGen && specRef != \"\" && cutil.SliceContains(dconfig, \"native\") {\n\t\tif current_dir, err := os.Getwd(); err != nil {\n\t\t\tcliutils.Fatal(cliutils.CLI_GENERAL_ERROR, \"'%v %v' %v\", SERVICE_COMMAND, SERVICE_CREATION_COMMAND, err)\n\t\t} else {\n\t\t\tcliutils.Verbose(msgPrinter.Sprintf(\"Creating image generation files under %v directory.\", current_dir))\n\t\t\tif err := CreateServiceImageFiles(current_dir, dir); err != nil {\n\t\t\t\tcliutils.Fatal(cliutils.CLI_GENERAL_ERROR, \"'%v %v' %v\", SERVICE_COMMAND, SERVICE_CREATION_COMMAND, err)\n\t\t\t} else {\n\t\t\t\tmsgPrinter.Printf(\"Created image generation files in %v and horizon metadata files in %v. Edit these files to define and configure your new %v.\", current_dir, dir, SERVICE_COMMAND)\n\t\t\t\tmsgPrinter.Println()\n\t\t\t}\n\t\t}\n\t} else {\n\t\tmsgPrinter.Printf(\"Created horizon metadata files in %v. Edit these files to define and configure your new %v.\", dir, SERVICE_COMMAND)\n\t\tmsgPrinter.Println()\n\t}\n}", "title": "" }, { "docid": "f4c194f348a8a7888655cdff475faac6", "score": "0.7248317", "text": "func newService(pub publisher) *Service {\n\treturn &Service{publisher: pub}\n}", "title": "" }, { "docid": "3ef5ed33af45cc58b675c2f2bea10ce5", "score": "0.7241484", "text": "func Create(arg *Arg) *Service {\n\tif arg.LoggerMore == nil {\n\t\targ.LoggerMore = DefaultLogger\n\t}\n\n\ts := New(arg)\n\tif s.LoggerMore == nil {\n\t\ts.LoggerMore = DefaultLogger\n\t}\n\n\tif err := s.Open(); err != nil {\n\t\ts.Panicf(\"failed to open Store: %s\", err.Error())\n\t}\n\n\treturn &Service{Arg: arg, Store: s, DealerMap: MakeDealerMap(), LeaderCh: make(chan bool, 1)}\n}", "title": "" }, { "docid": "246a6fa74a9644bc6a1fd565e2b30cf4", "score": "0.7172873", "text": "func New() endly.Service {\n\tvar result = &service{\n\t\tAbstractService: endly.NewAbstractService(ServiceID),\n\t}\n\tresult.AbstractService.Service = result\n\tresult.registerRoutes()\n\treturn result\n}", "title": "" }, { "docid": "246a6fa74a9644bc6a1fd565e2b30cf4", "score": "0.7172873", "text": "func New() endly.Service {\n\tvar result = &service{\n\t\tAbstractService: endly.NewAbstractService(ServiceID),\n\t}\n\tresult.AbstractService.Service = result\n\tresult.registerRoutes()\n\treturn result\n}", "title": "" }, { "docid": "246a6fa74a9644bc6a1fd565e2b30cf4", "score": "0.7172873", "text": "func New() endly.Service {\n\tvar result = &service{\n\t\tAbstractService: endly.NewAbstractService(ServiceID),\n\t}\n\tresult.AbstractService.Service = result\n\tresult.registerRoutes()\n\treturn result\n}", "title": "" }, { "docid": "246a6fa74a9644bc6a1fd565e2b30cf4", "score": "0.7172873", "text": "func New() endly.Service {\n\tvar result = &service{\n\t\tAbstractService: endly.NewAbstractService(ServiceID),\n\t}\n\tresult.AbstractService.Service = result\n\tresult.registerRoutes()\n\treturn result\n}", "title": "" }, { "docid": "b4f338dd3f54dc68edaad7d3eeff832e", "score": "0.7164969", "text": "func New() (*Service, error) {\n\treturn &Service{\n\t\t//locks: make(map[[48]byte]*sync.Mutex),\n\t\tlocks: &sync.Map{},\n\t\tnewLockMutex: &sync.Mutex{},\n\t}, nil\n}", "title": "" }, { "docid": "82fc4533f79a954b8c884cefdb9443d8", "score": "0.71368873", "text": "func New(c *conf.Config, rpcdaos *service.RPCDaos) *Service {\n\ts := &Service{\n\t\tc: c,\n\t\tassist: assist.New(c),\n\t\treply: reply.New(c),\n\t\tdm: danmu.New(c),\n\t\tacc: rpcdaos.Acc,\n\t}\n\treturn s\n}", "title": "" }, { "docid": "a6d5ec8e4f3d85598d17845656470b67", "score": "0.713206", "text": "func New(db *database.Database) *Service {\n\treturn &Service{\n\t\tdb: db,\n\t}\n}", "title": "" }, { "docid": "ec07d56d5a8702a2d3fbe915bcbab02a", "score": "0.7121591", "text": "func New(t transport.Session) *Service {\n return &Service{\n t,\n }\n}", "title": "" }, { "docid": "396d1d05d482004fcf90e1ac758ca1b3", "score": "0.71139807", "text": "func New() Service {\n\treturn &service{\n\t\tregistry: newRegistry(),\n\t}\n}", "title": "" }, { "docid": "4e9ef088d4b5ca9ec47e81e459ef505e", "score": "0.70861655", "text": "func New() (*Service, error) {\n\tsvc := &Service{}\n\treturn svc, nil\n}", "title": "" }, { "docid": "5c0840c478ab29a14224b9843bdb7e72", "score": "0.7071546", "text": "func (p *Platform) Create(srv *runtime.Service, opts ...runtime.CreateOption) error {\n\t_, err := call(\"POST\", \"platform/CreateService\", map[string]interface{}{\n\t\t\"service\": map[string]interface{}{\n\t\t\t\"name\": srv.Name,\n\t\t\t\"source\": srv.Source,\n\t\t\t\"version\": srv.Version,\n\t\t\t\"metadata\": srv.Metadata,\n\t\t},\n\t})\n\n\tif err == nil {\n\t\tfmt.Printf(\"[Platform] Service %v:%v created\\n\", srv.Name, srv.Version)\n\t}\n\n\treturn err\n}", "title": "" }, { "docid": "bf1f9fc3bd6c7d97e05edae8d90b069a", "score": "0.7060077", "text": "func New(c *conf.Config) (s *Service) {\n\ts = &Service{\n\t\tc: c,\n\t\td: dao.New(c),\n\t}\n\treturn\n}", "title": "" }, { "docid": "591ee6642e7e0b4451f8658b74fc0f74", "score": "0.7057158", "text": "func New() *Service {\n\treturn &Service{\n\t\tm: make(map[string]key),\n\t}\n}", "title": "" }, { "docid": "43f7929a6ea31e9e2fb088ce56c60cba", "score": "0.7045274", "text": "func NewService() (s Service) {\n\treturn\n}", "title": "" }, { "docid": "ee88c40a14f2ed9bacb082f8a909334d", "score": "0.7042279", "text": "func New(conf config.Service) (*Service, error) {\n\n\t// Start off with existing start & exit chans, but since it's not running,\n\t// exitChan should be closed, and startChan should be open.\n\texitChan := make(chan interface{})\n\tclose(exitChan)\n\tstartChan := make(chan interface{})\n\n\treturn &Service{\n\t\tConf: conf,\n\t\tstartChan: startChan,\n\t\texitChan: exitChan,\n\n\t\tlog: log.New(\"service\", conf.Name),\n\t}, nil\n}", "title": "" }, { "docid": "0f7229aa1310a73587b9b0fcc64ccee3", "score": "0.7036089", "text": "func New() (s *Service) {\n\tvar ac = new(paladin.TOML)\n\tif err := paladin.Watch(\"application.toml\", ac); err != nil {\n\t\tpanic(err)\n\t}\n\ts = &Service{\n\t\tac: ac,\n\t\tdao: dao.New(),\n\t}\n\treturn s\n}", "title": "" }, { "docid": "f7ede945e9ff5ba4cd8a8d1ffb8cf5ce", "score": "0.7015445", "text": "func (c *ServiceClient) Create() *ServiceCreate {\n\tmutation := newServiceMutation(c.config, OpCreate)\n\treturn &ServiceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}\n}", "title": "" }, { "docid": "eb373b963ee87b3def87d715c5a90fb3", "score": "0.7005066", "text": "func New(d dao.Dao) (s *Service, cf func(), err error) {\n\ts = &Service{\n\t\tac: &paladin.TOML{},\n\t\tdao: d,\n\t}\n\tcf = s.Close\n\terr = paladin.Watch(\"application.toml\", s.ac)\n\treturn\n}", "title": "" }, { "docid": "eb373b963ee87b3def87d715c5a90fb3", "score": "0.7005066", "text": "func New(d dao.Dao) (s *Service, cf func(), err error) {\n\ts = &Service{\n\t\tac: &paladin.TOML{},\n\t\tdao: d,\n\t}\n\tcf = s.Close\n\terr = paladin.Watch(\"application.toml\", s.ac)\n\treturn\n}", "title": "" }, { "docid": "1551d30c71dfb9564583d5bd87e40d88", "score": "0.7004867", "text": "func CreateNewService(r repo.Repository) *ServiceImpl {\n\treturn &ServiceImpl{\n\t\trepo: r,\n\t}\n}", "title": "" }, { "docid": "957e22a8c882a3c302c11b8fd2b624ea", "score": "0.7002099", "text": "func New(r interfaces.Repository, p *bluemonday.Policy) interfaces.Service {\n\treturn &service{\n\t\trepository: r,\n\t\tsanitizer: p,\n\t}\n}", "title": "" }, { "docid": "04743cae378d3b0a7d35386bcb7a16d9", "score": "0.6999358", "text": "func New(sync *contract.Sync, dao dao.Service) Service {\n\treturn newService(sync, dao)\n}", "title": "" }, { "docid": "b429c16ca5cd90aff181b482761d7724", "score": "0.69913334", "text": "func New(h hash.Hash) Service {\n\treturn Service{h: h}\n}", "title": "" }, { "docid": "8acd8788962d9e4ece4425a44cb11378", "score": "0.69883054", "text": "func (c *ServiceTypeClient) Create() *ServiceTypeCreate {\n\tmutation := newServiceTypeMutation(c.config, OpCreate)\n\treturn &ServiceTypeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}\n}", "title": "" }, { "docid": "fd376e4d78846b28e53f6b0c5f943a94", "score": "0.698286", "text": "func New() *Service {\n\ts := new(Service)\n\treturn s\n}", "title": "" }, { "docid": "91acc4ce651d9176d312b6132b7a2ac4", "score": "0.6979891", "text": "func New(c *conf.Config) (s *Service) {\n\ts = &Service{\n\t\tc: c,\n\t\tdao: dao.New(c),\n\t}\n\treturn\n}", "title": "" }, { "docid": "0fb614ab5b3334bb6554108410263f12", "score": "0.69485617", "text": "func New(d dao.Dao) (s *Service, cf func(), err error) {\n\ts = &Service{\n\t\tac: &paladin.TOML{},\n\t\tdao: d,\n\t\tcache: fanout.New(\"cache\"),\n\t\trpid: 1,\n\t}\n\tcf = s.Close\n\terr = paladin.Watch(\"application.toml\", s.ac)\n\treturn\n}", "title": "" }, { "docid": "cfdcb6dd0611943561281f9014647490", "score": "0.69364935", "text": "func New(b backend.Backend) *Service {\n\treturn &Service{b: b}\n}", "title": "" }, { "docid": "7a1f22a32d82bf085b9276ae0c64fb67", "score": "0.693062", "text": "func CreateService(w http.ResponseWriter, r *http.Request) {\n\tvar service models.Service\n\tdecoder := json.NewDecoder(r.Body)\n\tif err := decoder.Decode(&service); err != nil {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\tif err := service.InsertG(boil.Infer()); err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\tif err := proxy.LoadServices(); err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tproxy.Swapper.Swap(proxy.LoadRouter())\n\n\tw.WriteHeader(http.StatusCreated)\n\n\tif err := json.NewEncoder(w).Encode(utils.Response{Status: \"OK\"}); err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "134ed3b2312f7869056f783378ae337c", "score": "0.69292206", "text": "func New(ctx context.Context, config *Config) (Service, error) {\n\tsrv := &service{\n\t\tconfig: config,\n\t\tfs: afs.New(),\n\t\tRegistry: task.NewRegistry(),\n\t}\n\treturn srv, srv.Init(ctx)\n}", "title": "" }, { "docid": "547ea9250cec5e913041690a5669bced", "score": "0.6915262", "text": "func New(c *conf.Config) *Service {\n\ts := &Service{\n\t\tc: c,\n\t\tass: assist.New(c),\n\t\tacc: account.New(c),\n\t\tmsg: message.New(c),\n\t\t// chan\n\t\tcacheChan: make(chan func(), 1024),\n\t\t// databus\n\t\trelationSub: databus.New(c.RelationSub),\n\t}\n\ts.wg.Add(1)\n\tgo s.relationConsumer()\n\ts.wg.Add(1)\n\tgo s.cacheproc()\n\treturn s\n}", "title": "" }, { "docid": "8df8b52d7b2d78f75a9b2251f0ae4c8a", "score": "0.6911362", "text": "func New(d dao.Dao) (s *Service, err error) {\n\ts = &Service{\n\t\tac: &paladin.TOML{},\n\t\tdao: d,\n\t}\n\terr = paladin.Watch(\"application.toml\", s.ac)\n\treturn\n}", "title": "" }, { "docid": "d74e7ee8941a42ce197b143a266404f5", "score": "0.6875536", "text": "func newService(binaryPath, name, args string, dependencies []string, recoveryActions []recoveryAction,\n\trecoveryPeriod int) (*service, error) {\n\tif binaryPath == \"\" || name == \"\" {\n\t\treturn nil, fmt.Errorf(\"can't instantiate a service with incomplete service parameters\")\n\t}\n\treturn &service{\n\t\tbinaryPath: binaryPath,\n\t\tname: name,\n\t\targs: args,\n\t\tdependencies: dependencies,\n\t\trecoveryActions: recoveryActions,\n\t\trecoveryPeriod: recoveryPeriod,\n\t}, nil\n}", "title": "" }, { "docid": "b23c6784aa63e614c6f81e4d6a3f47ff", "score": "0.6870201", "text": "func newService(namespace, name string) *v1.Service {\n\treturn &v1.Service{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: name,\n\t\t\tNamespace: namespace,\n\t\t\tLabels: labelMap(),\n\t\t},\n\t\tSpec: v1.ServiceSpec{\n\t\t\tSelector: labelMap(),\n\t\t\tPorts: []v1.ServicePort{\n\t\t\t\t{Name: \"port-1338\", Port: 1338, Protocol: \"TCP\", TargetPort: intstr.FromInt32(1338)},\n\t\t\t\t{Name: \"port-1337\", Port: 1337, Protocol: \"TCP\", TargetPort: intstr.FromInt32(1337)},\n\t\t\t},\n\t\t},\n\t}\n}", "title": "" }, { "docid": "88f854c6756032b75bee13bc551509ff", "score": "0.6868899", "text": "func New() *Service {\n\treturn &Service{\n\t\tGoogle: google.NewService(),\n\t}\n}", "title": "" }, { "docid": "33097aa1a22f7b86239895ae44873d22", "score": "0.6855658", "text": "func New(s *session.Session) Service {\n\treturn Service{\n\t\tsts: sts.New(s),\n\t}\n}", "title": "" }, { "docid": "ce935cbcce5c611d1317a956262dd85e", "score": "0.6838173", "text": "func (api *serviceAPI) Create(obj *network.Service) error {\n\tif api.ct.resolver != nil {\n\t\tapicl, err := api.ct.apiClient()\n\t\tif err != nil {\n\t\t\tapi.ct.logger.Errorf(\"Error creating API server clent. Err: %v\", err)\n\t\t\treturn err\n\t\t}\n\n\t\t_, err = apicl.NetworkV1().Service().Create(context.Background(), obj)\n\t\tif err != nil && strings.Contains(err.Error(), \"AlreadyExists\") {\n\t\t\t_, err = apicl.NetworkV1().Service().Update(context.Background(), obj)\n\n\t\t}\n\t\treturn err\n\t}\n\n\tapi.ct.handleServiceEvent(&kvstore.WatchEvent{Object: obj, Type: kvstore.Created})\n\treturn nil\n}", "title": "" }, { "docid": "88b02fdbe06aecdf9d904ac15ea12bfa", "score": "0.6837899", "text": "func New() TOTP {\n\treturn &service{}\n}", "title": "" }, { "docid": "28448485cae7d5eb68d4f6a5f998bbb2", "score": "0.6830614", "text": "func New(sync *contract.Sync, dao dao.Service, mutex *shared.Mutex) Service {\n\treturn &service{\n\t\tSync: sync,\n\t\tdao: dao,\n\t\tBuilder: dao.Builder(),\n\t\tMutex: mutex,\n\t}\n}", "title": "" }, { "docid": "6f694081468bbcf32d16158af205914f", "score": "0.6827424", "text": "func New(c Doer) *Service {\n\treturn &Service{\n\t\tclient: c,\n\t}\n}", "title": "" }, { "docid": "d8cb6a0205094aabf4c3794276259011", "score": "0.6826484", "text": "func New(config Config) *Service {\n\treturn &Service{\n\t\tds: config.Datastore,\n\t}\n}", "title": "" }, { "docid": "425ab29b153c31eac48f5572f99255d7", "score": "0.6820037", "text": "func New() (kms.Service, error) {\n\tsess, err := session.NewSession()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &service{\n\t\tSSM: ssm.New(sess),\n\t\tKMS: akms.New(sess),\n\t}, nil\n}", "title": "" }, { "docid": "320ecdfffa50f60a0c064a35870c9701", "score": "0.68104994", "text": "func NewService(keys ...string) *Service {\n\tfmt.Printf(\"Create service with %d keys\\n\", len(keys))\n\n\treturn &Service{\n\t\tkeys: keys,\n\t}\n}", "title": "" }, { "docid": "7c37712ef8c4255279f2a9439bd49f31", "score": "0.68059295", "text": "func New(c *rpc.ClientConfig) (s *Service) {\n\ts = &Service{}\n\ts.client = rpc.NewDiscoveryCli(_appid, c)\n\treturn\n}", "title": "" }, { "docid": "7c37712ef8c4255279f2a9439bd49f31", "score": "0.68059295", "text": "func New(c *rpc.ClientConfig) (s *Service) {\n\ts = &Service{}\n\ts.client = rpc.NewDiscoveryCli(_appid, c)\n\treturn\n}", "title": "" }, { "docid": "d2ab8b82c3a94bc66d21fc149a5f3ecf", "score": "0.6779989", "text": "func New(d dao.Dao) (s *Service, cf func(), err error) {\n\ts = &Service{\n\t\tdao: d,\n\t}\n\tcf = s.Close\n\treturn\n}", "title": "" }, { "docid": "c5f48d75b4a7cff2896486079a2e8c40", "score": "0.6775066", "text": "func New() Service {\n\treturn normalizer{}\n}", "title": "" }, { "docid": "0b305c9dbd2c794bbada89a2845561a0", "score": "0.67711735", "text": "func NewService() Service {\n\treturn Service{}\n}", "title": "" }, { "docid": "d3a0b6842206fe33e0acc8a7a3ee3bf5", "score": "0.6769666", "text": "func New(db *sqlx.DB) *Service {\n\treturn &Service{\n\t\tdb: db,\n\t}\n}", "title": "" }, { "docid": "afab4161225409bc2e70b68091f4c976", "score": "0.67669684", "text": "func New() Service {\n\treturn Service{\n\t\trunner: command.New(),\n\t}\n}", "title": "" }, { "docid": "e52d0b2408bbba7cfee81ea635791fd3", "score": "0.67576635", "text": "func New(addr string, cluster Cluster) *Service {\n\treturn &Service{\n\t\taddr: addr,\n\t\tcluster: cluster,\n\t}\n}", "title": "" }, { "docid": "d5f640b323cb380fc439fa036845662c", "score": "0.6749008", "text": "func New(cfg Config, logger *log.SugaredLogger, store *storage.Service, key string) *Service {\n\treturn &Service{&cfg, logger, key, store}\n}", "title": "" }, { "docid": "8867e9d54d899c816a8735d730fa3ddf", "score": "0.6748155", "text": "func New(c *conf.Config) *Service {\n\ts := &Service{\n\t\tc: c,\n\t\tdao: dao.New(c),\n\t\trelRPC: relation.New(c.RelationRPC),\n\t\tcoinRPC: coin.New(c.CoinRPC),\n\t\tcachepq: queue.NewPriorityQueue(2048, false),\n\t}\n\tgo s.cachedelayproc(context.Background())\n\treturn s\n}", "title": "" }, { "docid": "41cdb8c5ae686b4fb8988a5cf4874252", "score": "0.674439", "text": "func New(opts ...Option) *Service {\n\t// setup micro, this triggers the Before\n\t// function which parses CLI flags.\n\tcmd.New(cmd.Service()).Run()\n\n\t// setup auth\n\tprofile.SetupAccount(nil)\n\n\t// return a new service\n\treturn &Service{opts: newOptions(opts...)}\n}", "title": "" }, { "docid": "9d6c2fee3523c8c5b97a08d48e911e25", "score": "0.67422605", "text": "func NewBookingService()(*BookingService) {\n m := &BookingService{\n Entity: *NewEntity(),\n }\n return m\n}", "title": "" }, { "docid": "08e1c600f99085ef7cf15bbf9875b42b", "score": "0.6740818", "text": "func New(client *http.Client) (*Service, error) {\n\tif client == nil {\n\t\treturn nil, errors.New(\"client is nil\")\n\t}\n\ts := &Service{client: client, BasePath: basePath}\n\ts.Media = NewMediaService(s)\n\ts.Spaces = NewSpacesService(s)\n\treturn s, nil\n}", "title": "" }, { "docid": "d5d5c84f7bfbe5937f1f0cde64e50c9a", "score": "0.6734827", "text": "func createService(service models.Service) models.ServerResponse {\n\tinsertResult, err := servicesCollection.InsertOne(context.Background(), service)\n\treturn insertOneQuery(insertResult, err)\n}", "title": "" }, { "docid": "aff8b2ce1bbb55cb185d421291a82a6a", "score": "0.67335916", "text": "func New(client *client.Client) *Service {\n\tservice := Service{}\n\tservice.client = client\n\n\treturn &service\n}", "title": "" }, { "docid": "7e5eb882fd373d7b363e2e6a2d290f40", "score": "0.6731809", "text": "func New(c *conf.Config) (s *Service) {\n\ts = &Service{\n\t\tc: c,\n\t\t//dao\n\t\tarc: arcdao.New(c),\n\t\tredis: redisdao.New(c),\n\t\thbase: hbasedao.New(c),\n\t\t//databus\n\t\tarchiveSub: databus.New(c.ArchiveSub),\n\t\tarcResultSub: databus.New(c.ArchiveResultSub),\n\t\tvideoupSub: databus.New(c.VideoupSub),\n\t\tManagerDBSub: databus.New(c.ManagerDBSub),\n\t\tdataDao: data.New(c),\n\t\temail: email.New(c),\n\t\tmng: manager.New(c),\n\t\t// cache\n\t\ttaskCache: &arcmdl.TaskCache{\n\t\t\tTask: make(map[int64]*arcmdl.Task),\n\t\t},\n\t\tvideoAuditCache: &arcmdl.VideoAuditCache{\n\t\t\tData: make(map[int16]map[string]int),\n\t\t},\n\t\tarcMoveTypeCache: &arcmdl.ArcMoveTypeCache{\n\t\t\tData: make(map[int8]map[int16]map[string]int),\n\t\t},\n\t\tarcRoundFlowCache: &arcmdl.ArcRoundFlowCache{\n\t\t\tData: make(map[int8]map[int64]map[string]int),\n\t\t},\n\t\txcodeTimeCache: &arcmdl.XcodeTimeCache{\n\t\t\tData: make(map[int8][]int),\n\t\t},\n\t\tarcRPCGroup2: arcrpc.New2(c.ArchiveRPCGroup2),\n\t\tlastjumpMap: make(map[int64]struct{}),\n\t\tjumplist: taskmdl.NewJumpList(),\n\t\tjumpchan: make(chan *taskmdl.WeightLog, _jumpChanSize),\n\t\ttasklogchan: make(chan *taskmdl.WeightLog, _logChanSize),\n\t\ttagDao: tag.New(c),\n\t\tmissionDao: mission.New(c),\n\t}\n\tvar err error\n\tif s.accRPC, err = account.NewClient(conf.Conf.GRPC.AccRPC); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif s.upsRPC, err = upsrpc.NewClient(conf.Conf.GRPC.UpsRPC); err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor i := 0; i < s.c.ChanSize; i++ {\n\t\tlog.Info(\"videoup-report-job chanSize starting(%d)\", i)\n\t\ts.arcUpChs = append(s.arcUpChs, make(chan *arcmdl.UpInfo, 10240))\n\t\ts.waiter.Add(1)\n\t\tgo s.arcUpdateproc(i)\n\t\ts.videoUpInfoChs = append(s.videoUpInfoChs, make(chan *arcmdl.VideoUpInfo, 10240))\n\t\ts.waiter.Add(1)\n\t\tgo s.upVideoproc(i)\n\t}\n\ts.loadConf()\n\ts.loadType()\n\t// load cache.\n\ts.loadTask()\n\ts.loadTaskTookSort()\n\ts.hdlTraffic()\n\ts.loadMission()\n\tgo s.cacheproc()\n\tgo s.monitorNotifyProc()\n\ts.waiter.Add(1)\n\tgo s.hotarchiveproc()\n\ts.waiter.Add(1)\n\tgo s.arcCanalConsume()\n\ts.waiter.Add(1)\n\tgo s.arcResultConsume()\n\ts.waiter.Add(1)\n\tgo s.taskWeightConsumer()\n\ts.waiter.Add(1)\n\tgo s.taskweightproc()\n\ts.waiter.Add(1)\n\tgo s.movetaskproc()\n\tgo s.deltaskproc()\n\ts.waiter.Add(1)\n\tgo s.videoupConsumer()\n\ts.waiter.Add(1)\n\tgo s.emailProc()\n\ts.waiter.Add(1)\n\tgo s.emailFastProc()\n\ts.waiter.Add(1)\n\tgo s.retryProc()\n\ts.waiter.Add(1)\n\tgo s.managerDBConsume()\n\n\treturn s\n}", "title": "" }, { "docid": "e5e45f0a17e94a7fefa5f5d4c8e3dbf4", "score": "0.67273694", "text": "func NewService () (*Service, error) {\n\treturn nil, nil\n}", "title": "" }, { "docid": "bf4bb1245067b35fe5fecd9f2e54d50e", "score": "0.67255545", "text": "func New(scope BastionScope) *Service {\n\treturn &Service{\n\t\tScope: scope,\n\t\tclient: newClient(scope),\n\t\tsubnetsClient: subnets.NewClient(scope),\n\t\tpublicIPsClient: publicips.NewClient(scope),\n\t}\n}", "title": "" }, { "docid": "9b64bb9c9f698a7a7029af9ce7fbd7e5", "score": "0.671955", "text": "func New(c *conf.Config) (s *Service) {\n\tvar (\n\t\tpgc *pgcdao.Dao\n\t\terr error\n\t)\n\tif pgc, err = pgcdao.New(c); err != nil {\n\t\tlog.Error(\"pgcdao.New error(%v)\", err)\n\t\treturn\n\t}\n\ts = &Service{\n\t\tshowDao: showdao.New(c),\n\t\tpgcDao: pgc,\n\t\taccDao: accdao.New(c),\n\t\tarcDao: arcdao.New(c),\n\t\tclient: httpx.NewClient(c.HTTPClient),\n\t\tmanagerURL: c.Host.Manager,\n\t}\n\treturn\n}", "title": "" }, { "docid": "d6742fdcca5763be936d866e00da8d0c", "score": "0.6718736", "text": "func New(data Data, trades *thirdpf.Trades) (*Service, error) {\n\treturn &Service{}, nil\n}", "title": "" }, { "docid": "57a579834457300d866d28ed3df26b30", "score": "0.671717", "text": "func New(storage afs.Service) Service {\n\treturn &service{fs: storage}\n}", "title": "" }, { "docid": "2b5badf2fc91baba97e0324f0942f1a0", "score": "0.67148995", "text": "func New(ctx context.Context, config *Config) (Service, error) {\n\tsrv := &service{\n\t\tconfig: config,\n\t\tfs: afs.New(),\n\t\tcfs: cache.Singleton(config.URL),\n\t\tRegistry: task.NewRegistry(),\n\t}\n\treturn srv, srv.Init(ctx)\n}", "title": "" }, { "docid": "19c00b135984bc1ad81cac1f14558af8", "score": "0.6705346", "text": "func New(loader *module.Loader) *Service {\n\treturn &Service{\n\t\tloader: loader,\n\t}\n}", "title": "" }, { "docid": "ebaa4ab8c5e6f1fde4cb40105d077c5e", "score": "0.6689397", "text": "func New(name, version string) Service {\n\treturn Service{\n\t\tName: name,\n\t\tDNSName: name,\n\t\tVersion: version,\n\t\tMethods: make(map[string]Method),\n\t\tProtocol: \"http\",\n\t\tSocket: \":80\",\n\t\tTimeout: time.Second * 10,\n\t\tContext: make(map[string]interface{}),\n\t\tForwardLocal: false,\n\t\tKnownErrors: makeDefaultErrorMap(),\n\t}\n}", "title": "" }, { "docid": "6e475e0556a54e9be687876f26d7eb00", "score": "0.66883415", "text": "func (m *Model) CreateService(service *Service, startOnCreate bool) (*Service, error) {\n\n\ts, err := m.persistenceDriver.PersistService(service)\n\tif err != nil {\n\t\treturn nil, errors.New(fmt.Sprintf(\"Unable to persist service %s in etcd : %s\", service.Name, err.Error()))\n\t}\n\n\tif m.serviceDriver != nil {\n\t\tinfo, err := m.serviceDriver.Create(s, startOnCreate)\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(fmt.Sprintf(\"Unable to create service in backend : %s\", s.Name, err.Error()))\n\t\t}\n\n\t\tm.updateInfoFromDriver(s, info)\n\t}\n\n\ts, err = m.saveService(s)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif s.Domain != \"\" {\n\n\t\tif domain, ok := m.Domains[s.Domain]; ok {\n\t\t\tdomain.Typ = \"service\"\n\t\t\tdomain.Value = s.Name\n\t\t\t_, err = m.UpdateDomain(domain)\n\t\t\tif err != nil {\n\t\t\t\tlog.Errorf(\"Unable to update domain %s for service %s : %v\", s.Domain, s.Name, err)\n\t\t\t}\n\t\t} else {\n\t\t\t_, err := m.CreateDomain(&Domain{Name: s.Domain, Typ: \"service\", Value: s.Name})\n\t\t\tif err != nil {\n\t\t\t\tlog.Errorf(\"Unable to create domain %s for service %s : %v\", s.Domain, s.Name, err)\n\t\t\t}\n\t\t}\n\t}\n\n\tm.eventBuffer.events <- NewModelEvent(\"create\", s)\n\n\treturn s, nil\n\n}", "title": "" }, { "docid": "6ebd1f73359ad7b642a5c59b437cf036", "score": "0.6687814", "text": "func NewService(name string,age int32) *Service {\n\treturn &Service{Name:name,age:age}\n}", "title": "" }, { "docid": "84cd7fc096c93cb687aaf803673ce6b8", "score": "0.6683351", "text": "func (s *ServiceAWSService) Create(path string, description string, keyID, role string, cfgs ...*aws.Config) (*api.Service, error) {\n\treturn s.CreateFunc(path, description, keyID, role, cfgs...)\n}", "title": "" }, { "docid": "a4c1cba2f69558c0e27f93865331aab2", "score": "0.66752", "text": "func New() endly.Service {\n\tvar result = &service{\n\t\tAbstractService: endly.NewAbstractService(NetworkServiceID),\n\t}\n\tresult.AbstractService.Service = result\n\tresult.registerRoutes()\n\treturn result\n}", "title": "" }, { "docid": "b7d12675e344a6c5d824a94ae9a8c36d", "score": "0.667199", "text": "func NewService(sid string) (s *Service) {\n\tsm.Lock()\n\tdefer sm.Unlock()\n\tif sid == \"\" {\n\t\tsid = \"default\"\n\t}\n\ts = initService()\n\ts.sid = sid\n\tsm.store[sid] = s\n\tlogf(\"added service %s.\", sid)\n\treturn\n}", "title": "" }, { "docid": "5986e4e888c522f26e345f19b81e0a30", "score": "0.66565865", "text": "func (jc *JobController) CreateNewService(job metav1.Object, rtype apiv1.ReplicaType,\n\tspec *apiv1.ReplicaSpec, index string) error {\n\tjobKey, err := KeyFunc(job)\n\tif err != nil {\n\t\tutilruntime.HandleError(fmt.Errorf(\"couldn't get key for job object %#v: %v\", job, err))\n\t\treturn err\n\t}\n\n\trt := strings.ToLower(string(rtype))\n\tlabels := jc.GenLabels(job.GetName())\n\tutillabels.SetReplicaType(labels, rt)\n\tutillabels.SetReplicaIndexStr(labels, index)\n\n\tports, err := jc.GetPortsFromJob(spec)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tservice := &v1.Service{\n\t\tSpec: v1.ServiceSpec{\n\t\t\tClusterIP: \"None\",\n\t\t\tSelector: labels,\n\t\t\tPorts: []v1.ServicePort{},\n\t\t},\n\t}\n\n\t// Add service ports to headless service\n\tfor name, port := range ports {\n\t\tsvcPort := v1.ServicePort{Name: name, Port: port}\n\t\tservice.Spec.Ports = append(service.Spec.Ports, svcPort)\n\t}\n\n\tservice.Name = GenGeneralName(job.GetName(), rt, index)\n\tservice.Labels = labels\n\t// Create OwnerReference.\n\tcontrollerRef := jc.GenOwnerReference(job)\n\n\t// Creation is expected when there is no error returned\n\texpectationServicesKey := expectation.GenExpectationServicesKey(jobKey, rt)\n\tjc.Expectations.RaiseExpectations(expectationServicesKey, 1, 0)\n\n\terr = jc.ServiceControl.CreateServicesWithControllerRef(job.GetNamespace(), service, job.(runtime.Object), controllerRef)\n\tif err != nil && errors.IsTimeout(err) {\n\t\t// Service is created but its initialization has timed out.\n\t\t// If the initialization is successful eventually, the\n\t\t// controller will observe the creation via the informer.\n\t\t// If the initialization fails, or if the service keeps\n\t\t// uninitialized for a long time, the informer will not\n\t\t// receive any update, and the controller will create a new\n\t\t// service when the expectation expires.\n\t\tsucceededServiceCreationCount.Inc()\n\t\treturn nil\n\t} else if err != nil {\n\t\t// Since error occurred(the informer won't observe this service),\n\t\t// we decrement the expected number of creates\n\t\t// and wait until next reconciliation\n\t\tjc.Expectations.CreationObserved(expectationServicesKey)\n\t\tfailedServiceCreationCount.Inc()\n\t\treturn err\n\t}\n\tsucceededServiceCreationCount.Inc()\n\treturn nil\n}", "title": "" }, { "docid": "7a910e92ff6d81ea5cfb70637940f70f", "score": "0.6650741", "text": "func New(db *badger.DB, app *firebase.App, client *firebaseDB.Client) Service {\n\tvar svc Service\n\t{\n\t\tsvc = NewBasicService(db, app, client)\n\t}\n\treturn svc\n}", "title": "" }, { "docid": "e4a4b23edcc76de5c528a7884bc655c5", "score": "0.66499877", "text": "func NewService(keys map[string]string, lease int64, data string, id string) Service {\n\tstate := Service{\n\t\tKeys: keys,\n\t\tLease: lease,\n\t\tData: data,\n\t\tID: id,\n\t}\n\treturn state\n}", "title": "" }, { "docid": "1dd6f6c0d6dc5ac4c76a5a538fc2fd35", "score": "0.66499645", "text": "func New(bq *bigquery.Service, registry task.Registry, projectID string, storageService afs.Service, config base.Config) Service {\n\treturn &service{\n\t\tService: bq,\n\t\tConfig: config,\n\t\tRegistry: registry,\n\t\tprojectID: projectID,\n\t\tfs: storageService,\n\t}\n}", "title": "" }, { "docid": "cc7f409f19f64235d76de9abbb63273d", "score": "0.6647698", "text": "func (s *Service) Create() (*v1.Service, error) {\n\topts := metav1.CreateOptions{}\n\tcreatedSvc, err := s.clientSet.CoreV1().Services(s.service.Namespace).Create(context.TODO(), s.service, opts)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"Unable to create service %s/%s\", s.service.Name, s.service.Namespace)\n\t}\n\treturn createdSvc, nil\n}", "title": "" }, { "docid": "e19209e0255dad0ac096fea001fe2144", "score": "0.66419077", "text": "func New(s Saver, d Dispatcher) *Service {\n\treturn &Service{s, d}\n}", "title": "" }, { "docid": "6f299bc8950b92298c7cad447775bc08", "score": "0.6629859", "text": "func New(client *http.Client) (*Service, error) {\n\tif client == nil {\n\t\treturn nil, errors.New(\"client is nil\")\n\t}\n\ts := &Service{client: client, BasePath: basePath}\n\ts.Data = NewDataService(s)\n\ts.Management = NewManagementService(s)\n\treturn s, nil\n}", "title": "" }, { "docid": "600c24c834d4291b8e11f6c9f2323a82", "score": "0.6629739", "text": "func New(c *conf.Config) (s *Service) {\n\ts = &Service{\n\t\tc: c,\n\t\tdao: dao.New(c),\n\t\thttpClient: bm.NewClient(c.HTTPClient),\n\t\tdpClient: bm.NewClient(c.DPClient),\n\t\tpartitions: make(map[int]string),\n\t}\n\ts.DB = s.dao.DB.Scopes(func(db *gorm.DB) *gorm.DB {\n\t\treturn db.Where(\"dtime = ?\", 0)\n\t})\n\ts.loadPartitions()\n\tgo s.loadPartitionsproc()\n\tgo s.cleanDiskFilesproc()\n\treturn s\n}", "title": "" }, { "docid": "261323238becec69528404d13fad0031", "score": "0.6629448", "text": "func New(cred esign.Credential) *Service {\n\treturn &Service{credential: cred}\n}", "title": "" }, { "docid": "261323238becec69528404d13fad0031", "score": "0.6629448", "text": "func New(cred esign.Credential) *Service {\n\treturn &Service{credential: cred}\n}", "title": "" }, { "docid": "261323238becec69528404d13fad0031", "score": "0.6629448", "text": "func New(cred esign.Credential) *Service {\n\treturn &Service{credential: cred}\n}", "title": "" }, { "docid": "261323238becec69528404d13fad0031", "score": "0.6629448", "text": "func New(cred esign.Credential) *Service {\n\treturn &Service{credential: cred}\n}", "title": "" }, { "docid": "261323238becec69528404d13fad0031", "score": "0.6629448", "text": "func New(cred esign.Credential) *Service {\n\treturn &Service{credential: cred}\n}", "title": "" }, { "docid": "261323238becec69528404d13fad0031", "score": "0.6629448", "text": "func New(cred esign.Credential) *Service {\n\treturn &Service{credential: cred}\n}", "title": "" }, { "docid": "e36d487e23b05d9211eb3d82e35adfbf", "score": "0.66265625", "text": "func New(config Config) *Service {\n\treturn &Service{\n\t\tca: config.ServerCA,\n\t\ttd: config.TrustDomain,\n\t}\n}", "title": "" }, { "docid": "47ca963d04a6d463beb24e68175db70a", "score": "0.6625798", "text": "func New(ctx context.Context) (*Service, error) {\n\t// get mongo uri config\n\tmongoURI := \"\"\n\n\t// create mongodb connection\n\tmongoClient, err := utils.NewMongoConnection(ctx, mongoURI)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error connecting to mongodb: %v\", err)\n\t}\n\n\treturn &Service{\n\t\tdb: repository.New(mongoClient),\n\t}, nil\n}", "title": "" }, { "docid": "b3dea4ec263f8d0f0ea220a935f737a2", "score": "0.66251165", "text": "func New(client *http.Client) (*Service, error) {\n\tif client == nil {\n\t\treturn nil, errors.New(\"client is nil\")\n\t}\n\ts := &Service{client: client, BasePath: basePath}\n\ts.Processes = NewProcessesService(s)\n\ts.Projects = NewProjectsService(s)\n\ts.Scripts = NewScriptsService(s)\n\treturn s, nil\n}", "title": "" } ]
1abbbd98f31cad625536a47c9a7a2a23
NotifySpecificPortHealthCheckResult Sends email for each specific port scan
[ { "docid": "0310e0797c0047ef3903fc6c1b69f075", "score": "0.7380537", "text": "func (t *EmailNotifier) NotifySpecificPortHealthCheckResult(result s.SpecificPortHealthCheckResult, templateString string) error {\n\tfmt.Println(\"sending an email from\", t.smtpConfig.Sender, \"to\", t.recipientConfig.To)\n\n\tmessageTemplate := `Port Scan Result:\nPort: {{.Port}}\nIs Reachable: {{.IsReachable}}\n\t`\n\n\tif len(templateString) > 0 {\n\t\tmessageTemplate = templateString\n\t}\n\n\ttmpl, err := template.New(\"test\").Parse(messageTemplate)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tvar tpl bytes.Buffer\n\n\terr = tmpl.Execute(&tpl, result)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tmsg := \"From: \" + t.smtpConfig.Sender + \"\\n\" +\n\t\t\"To: \" + t.recipientConfig.To + \"\\n\" +\n\t\t\"Subject: \" + t.recipientConfig.Subject + \"\\n\" + tpl.String()\n\n\terr = smtp.SendMail(fmt.Sprintf(\"%s:%d\", t.smtpConfig.Server, t.smtpConfig.Port),\n\t\tsmtp.PlainAuth(\"\", t.smtpConfig.Auth.Username, t.smtpConfig.Auth.Password, t.smtpConfig.Server),\n\t\tt.smtpConfig.Sender, []string{t.recipientConfig.To}, []byte(msg))\n\n\tif err != nil {\n\n\t\tfmt.Printf(\"smtp error: %s\", err)\n\t\treturn err\n\t}\n\n\tfmt.Println(\"Mail sent successfully!\")\n\n\treturn nil\n}", "title": "" } ]
[ { "docid": "7b30fd9b942e68f58ecaf4f377237037", "score": "0.7258805", "text": "func (t *TelegramNotifier) NotifySpecificPortHealthCheckResult(result s.SpecificPortHealthCheckResult, templateString string) error {\n\tfmt.Println(\"sending message with bot token\", t.botConfig.Token)\n\n\tbot, err := tgbotapi.NewBotAPI(t.botConfig.Token)\n\t//Checks for errors\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\t//Silences the debug messages\n\tbot.Debug = false\n\n\tmessageTemplate := `Port Scan Result:\nPort: {{.Port}}\nIs Reachable: {{.IsReachable}}\n\t`\n\n\tif len(templateString) > 0 {\n\t\tmessageTemplate = templateString\n\t}\n\n\ttmpl, err := template.New(\"test\").Parse(messageTemplate)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tvar tpl bytes.Buffer\n\n\terr = tmpl.Execute(&tpl, result)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t_, err = bot.Send(tgbotapi.NewMessage(t.chatConfig.ChatId, tpl.String()))\n\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "3b02afb9533c9f19c3909b4d72484579", "score": "0.5698728", "text": "func worker(ports, results chan int) {\n\tfor p := range ports {\n\t\taddress := fmt.Sprintf(\"scanme.nmap.org:%d\", p)\n\t\tconn, err := net.DialTimeout(\"tcp\", address, 5*time.Second)\n\n\t\tif err != nil {\n\t\t\tresults <- 0\n\t\t\tcontinue\n\t\t}\n\n\t\t// idea: implement verbosity flag and include this line\n\t\t//fmt.Println(fmt.Sprintf(\"[*] Found port %d\", p))\n\n\t\tconn.Close()\n\t\tresults <- p\n\t}\n}", "title": "" }, { "docid": "05e2a975d295fe375a95bc6e4bd41ebd", "score": "0.5590882", "text": "func (t *EmailNotifier) NotifyHealthCheckResult(result s.HealthCheckResult, templateString string) error {\n\tfmt.Println(\"sending an email from\", t.smtpConfig.Sender, \"to\", t.recipientConfig.To)\n\n\tmessageTemplate := `Scan Finished:\nHost: {{.Host}}\nNumber Of Scanned Ports Down: {{.NumberOfUnreachableServices}}\n`\n\n\tif len(templateString) > 0 {\n\t\tmessageTemplate = templateString\n\t}\n\n\ttmpl, err := template.New(\"test\").Parse(messageTemplate)\n\tutils.Check(err)\n\n\tvar tpl bytes.Buffer\n\n\terr = tmpl.Execute(&tpl, result)\n\tutils.Check(err)\n\n\tmsg := \"From: \" + t.smtpConfig.Sender + \"\\n\" +\n\t\t\"To: \" + t.recipientConfig.To + \"\\n\" +\n\t\t\"Subject: \" + t.recipientConfig.Subject + \"\\n\" + tpl.String()\n\n\terr = smtp.SendMail(fmt.Sprintf(\"%s:%d\", t.smtpConfig.Server, t.smtpConfig.Port),\n\t\tsmtp.PlainAuth(\"\", t.smtpConfig.Auth.Username, t.smtpConfig.Auth.Password, t.smtpConfig.Server),\n\t\tt.smtpConfig.Sender, []string{t.recipientConfig.To}, []byte(msg))\n\n\tif err != nil {\n\n\t\tfmt.Printf(\"smtp error: %s\", err)\n\t\treturn err\n\t}\n\n\tfmt.Println(\"Mail sent successfully!\")\n\n\treturn nil\n}", "title": "" }, { "docid": "1493c3acd85a9d64572ae6cb711da6e7", "score": "0.5458422", "text": "func (h *HealthCheck) Notify(isHealthy bool) {\n\tvar subject string\n\tvar body string\n\n\tif !isHealthy {\n\t\tsubject = fmt.Sprintf(\"Service %s is experiencing problems\", h.Name)\n\t\tbody = fmt.Sprintf(\"Service %s failed a health check at %s.\", h.Name, time.Now().Format(layoutISO))\n\t} else {\n\t\tsubject = fmt.Sprintf(\"Service %s is healthy again\", h.Name)\n\t\tbody = fmt.Sprintf(\"Service %s back online at %s!\", h.Name, time.Now().Format(layoutISO))\n\t}\n\n\tfor _, notifier := range h.Notifiers {\n\t\tnotifier.Notify(subject, body)\n\t}\n}", "title": "" }, { "docid": "ffac9d35912fab0cdad9d0516e398093", "score": "0.54340976", "text": "func (t *TelegramNotifier) NotifyHealthCheckResult(result s.HealthCheckResult, templateString string) error {\n\tfmt.Println(\"sending message with bot token\", t.botConfig.Token)\n\n\tbot, err := tgbotapi.NewBotAPI(t.botConfig.Token)\n\t//Checks for errors\n\tutils.Check(err)\n\t//Silences the debug messages\n\tbot.Debug = false\n\n\tmessageTemplate := `Scan Finished:\nHost: {{.Host}}\nNumber Of Scanned Ports Down: {{.NumberOfUnreachableServices}}\n`\n\n\tif len(templateString) > 0 {\n\t\tmessageTemplate = templateString\n\t}\n\n\ttmpl, err := template.New(\"test\").Parse(messageTemplate)\n\tutils.Check(err)\n\n\tvar tpl bytes.Buffer\n\n\terr = tmpl.Execute(&tpl, result)\n\tutils.Check(err)\n\n\t_, err = bot.Send(tgbotapi.NewMessage(t.chatConfig.ChatId, tpl.String()))\n\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "a4ad2679021de32dd2969eaba78ad43f", "score": "0.54178566", "text": "func checkPortListening(port, times int, delay time.Duration) error {\n\tfor i := 0; i < times; i++ {\n\t\ttime.Sleep(delay)\n\t\tif CheckListening(port) {\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn fmt.Errorf(\"Port(%v) is not listening within time: %v\",\n\t\tport, time.Duration(int64(times))*delay)\n}", "title": "" }, { "docid": "c2f63e43e64b59d37869572826326323", "score": "0.5402349", "text": "func (p *PortScanner) ScanPort(protocol, hostname, service string, port int, resultChannel chan Result, wg *sync.WaitGroup, fireWallDetectionOff bool) {\n\tdefer wg.Done()\n\twg.Add(1)\n\tresult := Result{Port: port, Service: service}\n\taddress := hostname + \":\" + strconv.Itoa(port)\n\trandTime := time.Duration(rand.Int31n(1)) + 1\n\n\tif fireWallDetectionOff == true {\n\t\trandTime = time.Duration(1)\n\t}\n\n\tconn, err := netScanner.DialTimeout(protocol, address, randTime*time.Second)\n\tif err != nil {\n\t\tif strings.Contains(err.Error(), \"too many open files\") {\n\t\t\ttime.Sleep(1 * time.Second)\n\t\t\tp.ScanPort(\"tcp\", hostname, service, port, resultChannel, wg, fireWallDetectionOff)\n\t\t} else {\n\t\t\t//fmt.Println(port, \"closed\") //INDICATE CLOSED PORTS\n\t\t\tresult.State = false\n\t\t\tresultChannel <- result\n\t\t}\n\t\treturn\n\t}\n\t//fmt.Println(port, \"open\") //INDICATE OPEN PORTS\n\tdefer conn.Close()\n\tif result.Service == \"\" {\n\t\tresult.Service = \"open\"\n\t}\n\tresult.State = true\n\tresultChannel <- result\n\treturn\n}", "title": "" }, { "docid": "25bf3a0798e54ad9b6e8c087cd272201", "score": "0.53236586", "text": "func (s Slack) Notify(results []Result) error {\n\tfor _, result := range results {\n\t\tif !result.Healthy {\n\t\t\ts.Send(result)\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "80c94e8482a555c34da44746f8dd157a", "score": "0.5227533", "text": "func (s KPNsms) Notify(results []Result) error {\n\tfor _, result := range results {\n\t\tif !result.Healthy {\n\t\t\ts.Send(result)\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "a08c5eff77b02264a1eb039283f17701", "score": "0.51452786", "text": "func (p *PortScanner) ScanPorts(hostname string, ports Range, threads int, fireWallDetectionOff bool) (ScanResult, error) {\n\tvar results []Result\n\tvar scanned ScanResult\n\tvar wgRight sync.WaitGroup\n\tvar wgLeft sync.WaitGroup\n\truntime.GOMAXPROCS(threads)\n\tresultChannel := make(chan Result, (ports.End-ports.Start)+1)\n\n\taddr, err := netScanner.LookupIP(hostname)\n\tif err != nil {\n\t\treturn scanned, err\n\t}\n\n\tif fireWallDetectionOff == false {\n\n\t\tfor i := ports.Start; i <= ports.End; i = i + 2 {\n\t\t\tservice, _ := common[i]\n\t\t\tgo p.ScanPort(\"tcp\", hostname, service, i, resultChannel, &wgRight, fireWallDetectionOff)\n\t\t}\n\t\twgRight.Wait()\n\n\t\tfor i := ports.Start + 1; i <= ports.End; i = i + 2 {\n\t\t\tservice, _ := common[i]\n\t\t\tgo p.ScanPort(\"tcp\", hostname, service, i, resultChannel, &wgLeft, fireWallDetectionOff)\n\t\t}\n\t\twgLeft.Wait()\n\n\t} else {\n\n\t\tfor i := ports.Start; i <= ports.End; i++ {\n\t\t\tservice, _ := common[i]\n\t\t\tgo p.ScanPort(\"tcp\", hostname, service, i, resultChannel, &wgRight, fireWallDetectionOff)\n\t\t}\n\t\twgRight.Wait()\n\t}\n\n\tclose(resultChannel)\n\tfor result := range resultChannel {\n\t\tresults = append(results, result)\n\t}\n\n\tscanned = ScanResult{\n\t\thostname: hostname,\n\t\tip: addr,\n\t\tresults: results,\n\t}\n\treturn scanned, nil\n}", "title": "" }, { "docid": "07323185794b4c5bf0a27fb4b688d525", "score": "0.5127531", "text": "func (r *Checker) checkPorts(ctx context.Context, servers []Server) error {\n\treq := constructPingPongRequest(servers, r.config.Requirements)\n\tr.log.Infof(\"Ping pong request: %v.\", req)\n\n\tif len(req) == 0 {\n\t\tr.log.Info(\"Empty ping pong request.\")\n\t\treturn nil\n\t}\n\n\tresp, err := r.config.Remote.CheckPorts(ctx, req)\n\tif err != nil {\n\t\treturn trace.Wrap(err)\n\t}\n\n\tr.log.Infof(\"Ping pong response: %v.\", resp)\n\n\tif len(resp.Failures()) != 0 {\n\t\treturn trace.BadParameter(strings.Join(resp.Failures(), \", \"))\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "de85133c7987835225228ef58898dc71", "score": "0.5106187", "text": "func portChangedForDeployment(deployment *appsv1.Deployment, mediator *eventsv1alpha1.EventMediator) bool {\n\n ports := deployment.Spec.Template.Spec.Containers[0].Ports\n\n check := make(map[int32] int32)\n for _, portInfo := range ports {\n check[portInfo.ContainerPort] = portInfo.ContainerPort\n }\n\n numMediatorPorts := 0\n port := getListenerPort(mediator)\n numMediatorPorts++\n if _, exists:= check[port]; ! exists {\n return true\n }\n if len(ports) != numMediatorPorts {\n return true\n }\n\n return false\n}", "title": "" }, { "docid": "1e69ead442e8e978cfa861c6965f7052", "score": "0.5099736", "text": "func WaitForPort(port uint16) {\n\tserverPort := fmt.Sprintf(\"localhost:%v\", port)\n\tfor i := 0; i < maxAttempts; i++ {\n\t\tlog.Println(\"Pinging port: \", serverPort)\n\t\t_, err := net.Dial(\"tcp\", serverPort)\n\t\tif err == nil {\n\t\t\tlog.Println(\"The port is up and running...\")\n\t\t\treturn\n\t\t}\n\t\tlog.Println(\"Wait 200ms and try again.\")\n\t\ttime.Sleep(200 * time.Millisecond)\n\t}\n\tlog.Println(\"Give up the wait, continue the test...\")\n}", "title": "" }, { "docid": "1e69ead442e8e978cfa861c6965f7052", "score": "0.5099736", "text": "func WaitForPort(port uint16) {\n\tserverPort := fmt.Sprintf(\"localhost:%v\", port)\n\tfor i := 0; i < maxAttempts; i++ {\n\t\tlog.Println(\"Pinging port: \", serverPort)\n\t\t_, err := net.Dial(\"tcp\", serverPort)\n\t\tif err == nil {\n\t\t\tlog.Println(\"The port is up and running...\")\n\t\t\treturn\n\t\t}\n\t\tlog.Println(\"Wait 200ms and try again.\")\n\t\ttime.Sleep(200 * time.Millisecond)\n\t}\n\tlog.Println(\"Give up the wait, continue the test...\")\n}", "title": "" }, { "docid": "fa5aaf182dbc9c1c15d9f92206414d7c", "score": "0.5074824", "text": "func checkPort(target string, port uint, timeout time.Duration) {\n\tif target == \"\" {\n\t\treturn\n\t}\n\tconn, err := net.DialTimeout(\"tcp\", fmt.Sprintf(\"%s:%d\", target, port), timeout)\n\tif err != nil {\n\t\tif strings.Contains(err.Error(), \"too many open files\") {\n\t\t\tprettyPrintLn(warning, \"Too many open files. You are running too many scan workers and the OS is limiting file descriptors. YOU ARE MISSING SCAN RESULTS. Scan with less workers\")\n\t\t} else {\n\t\t\treturn\n\t\t}\n\t}\n\tdefer conn.Close()\n\t// Port is open since no errors occured until here\n\tprettyPrintLn(info, fmt.Sprintf(\"%s:%d is open\", target, port))\n\tCheckEndpoint(target, port, false)\n}", "title": "" }, { "docid": "51f291b99632a515380323b3c5d5895f", "score": "0.5065615", "text": "func (o HttpHealthCheckOutput) Port() pulumi.IntOutput {\n\treturn o.ApplyT(func(v *HttpHealthCheck) pulumi.IntOutput { return v.Port }).(pulumi.IntOutput)\n}", "title": "" }, { "docid": "96b1679647671a02144c771b0cd279d3", "score": "0.50604856", "text": "func worker(ports, results chan int) {\n\tfor p := range ports {\n\t\taddress := fmt.Sprintf(\"192.168.100.1:%d\", p)\n\t\tconn, err := net.Dial(\"tcp\", address)\n\t\tif err != nil {\n\t\t\tresults <- 0\n\t\t\tcontinue\n\t\t}\n\t\tconn.Close()\n\t\tresults <- p\n\t}\n}", "title": "" }, { "docid": "5f1ee7290f11307cfad2864353ff4ab2", "score": "0.500546", "text": "func ScanPorts(start int, end int, protocol string) {\n\tfor i := start; i < end; i++ {\n\t\tisOpen := ScanPort(protocol, hostname, i, timeout)\n\n\t\tif isOpen {\n\t\t\tlog.Printf(\"port '%d' is in use\", i)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "0dfd80e2db2bef1d3157d721e9945655", "score": "0.49804297", "text": "func RunAllMonitoring(ctx context.Context, settings *evergreen.Settings) error {\n\t// initialize the notifier\n\tnotifier := &Notifier{\n\t\tnotificationBuilders: defaultNotificationBuilders,\n\t}\n\n\t// send notifications\n\terr := notifier.Notify(settings)\n\tgrip.Error(message.WrapError(err, message.Fields{\n\t\t\"runner\": RunnerName,\n\t\t\"message\": \"Error sending notifications\",\n\t}))\n\n\t// Do alerts for spawnhosts - collect all hosts expiring in the next 12 hours.\n\t// The trigger logic will filter out any hosts that aren't in a notification window, or have\n\t// already have alerts sent.\n\tnow := time.Now()\n\tthresholdTime := now.Add(12 * time.Hour)\n\texpiringSoonHosts, err := host.Find(host.ByExpiringBetween(now, thresholdTime))\n\tif err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\n\tfor _, h := range expiringSoonHosts {\n\t\tif err = alerts.RunSpawnWarningTriggers(&h); err != nil {\n\t\t\tgrip.Error(message.WrapError(err, message.Fields{\n\t\t\t\t\"runner\": RunnerName,\n\t\t\t\t\"message\": \"Error queuing alert\",\n\t\t\t\t\"host\": h.Id,\n\t\t\t}))\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "6e60a2f573049ca88fecdbac8c2422b5", "score": "0.4917561", "text": "func portInfo(c func(value float64, labels ...string), m *modemmanager.Modem) {\n\tfor _, p := range m.Ports {\n\t\t// Only export information about network ports because they can be\n\t\t// joined with other metrics such as those from node_exporter. It isn't\n\t\t// clear that exporting AT, MBIM, etc. would be useful at this point.\n\t\tif p.Type != modemmanager.PortTypeNet {\n\t\t\tcontinue\n\t\t}\n\n\t\tc(1.0, m.DeviceIdentifier, p.Name)\n\t}\n}", "title": "" }, { "docid": "e15fd56a3e3d858524474f637b4fed1c", "score": "0.4907352", "text": "func Notify(cfg config.VersioncheckConfig, res moduleRunner.RunnerResult) {\n\twait := new(sync.WaitGroup)\n\n\tfor _, item := range res.Changed {\n\t\twait.Add(1)\n\t\tgo func() {\n\t\t\targs := []string{\n\t\t\t\titem.Name,\n\t\t\t\titem.Module,\n\t\t\t\titem.OldVersion,\n\t\t\t\titem.NewVersion,\n\t\t\t}\n\t\t\targs = append(args, item.Tags...)\n\t\t\tcmd := exec.Command(cfg.Notificator, args...)\n\t\t\tcmd.Stdout = os.Stdout\n\t\t\tcmd.Stderr = os.Stderr\n\t\t\terr := cmd.Start()\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"%s\\n\", err)\n\t\t\t\twait.Done()\n\t\t\t\treturn\n\t\t\t}\n\t\t\terr = cmd.Wait()\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"%s\\n\", err)\n\t\t\t}\n\t\t\twait.Done()\n\t\t}()\n\t}\n\twait.Wait()\n}", "title": "" }, { "docid": "155591467876746cd2e38ddc838c0dd6", "score": "0.4906543", "text": "func DefaultHealthCheck(service *apistructs.Service) *apiv1.Probe {\n\tif len(service.Ports) == 0 {\n\t\treturn nil\n\t}\n\n\tprobe := NewCheckProbe()\n\tprobe.TCPSocket = &apiv1.TCPSocketAction{\n\t\tPort: intstr.FromInt(service.Ports[0].Port),\n\t}\n\treturn probe\n}", "title": "" }, { "docid": "b5e09a6a3c59ead92dafcd5ee17c499f", "score": "0.48963943", "text": "func CheckClusterPortConflict(clusterList map[string]Metadata, clusterName string, topo Topology) error {\n\ttype Entry struct {\n\t\tclusterName string\n\t\tcomponentName string\n\t\tport int\n\t\tinstance Instance\n\t}\n\n\tcurrentEntries := []Entry{}\n\texistingEntries := []Entry{}\n\n\tfor name, metadata := range clusterList {\n\t\tif name == clusterName {\n\t\t\tcontinue\n\t\t}\n\n\t\tuniqueHosts := set.NewStringSet()\n\t\tmetadata.GetTopology().IterInstance(func(inst Instance) {\n\t\t\tmOpt := metadata.GetTopology().GetMonitoredOptions()\n\t\t\tif mOpt == nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tnodeExporterPort := mOpt.NodeExporterPort\n\t\t\tblackboxExporterPort := mOpt.BlackboxExporterPort\n\t\t\tfor _, port := range inst.UsedPorts() {\n\t\t\t\texistingEntries = append(existingEntries, Entry{\n\t\t\t\t\tclusterName: name,\n\t\t\t\t\tcomponentName: inst.ComponentName(),\n\t\t\t\t\tport: port,\n\t\t\t\t\tinstance: inst,\n\t\t\t\t})\n\t\t\t}\n\t\t\tif !uniqueHosts.Exist(inst.GetManageHost()) {\n\t\t\t\tuniqueHosts.Insert(inst.GetManageHost())\n\t\t\t\texistingEntries = append(existingEntries,\n\t\t\t\t\tEntry{\n\t\t\t\t\t\tclusterName: name,\n\t\t\t\t\t\tcomponentName: RoleMonitor,\n\t\t\t\t\t\tport: nodeExporterPort,\n\t\t\t\t\t\tinstance: inst,\n\t\t\t\t\t},\n\t\t\t\t\tEntry{\n\t\t\t\t\t\tclusterName: name,\n\t\t\t\t\t\tcomponentName: RoleMonitor,\n\t\t\t\t\t\tport: blackboxExporterPort,\n\t\t\t\t\t\tinstance: inst,\n\t\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\tuniqueHosts := set.NewStringSet()\n\ttopo.IterInstance(func(inst Instance) {\n\t\tfor _, port := range inst.UsedPorts() {\n\t\t\tcurrentEntries = append(currentEntries, Entry{\n\t\t\t\tcomponentName: inst.ComponentName(),\n\t\t\t\tport: port,\n\t\t\t\tinstance: inst,\n\t\t\t})\n\t\t}\n\n\t\tmOpt := topo.GetMonitoredOptions()\n\t\tif mOpt == nil {\n\t\t\treturn\n\t\t}\n\t\tif !uniqueHosts.Exist(inst.GetManageHost()) {\n\t\t\tuniqueHosts.Insert(inst.GetManageHost())\n\t\t\tcurrentEntries = append(currentEntries,\n\t\t\t\tEntry{\n\t\t\t\t\tcomponentName: RoleMonitor,\n\t\t\t\t\tport: mOpt.NodeExporterPort,\n\t\t\t\t\tinstance: inst,\n\t\t\t\t},\n\t\t\t\tEntry{\n\t\t\t\t\tcomponentName: RoleMonitor,\n\t\t\t\t\tport: mOpt.BlackboxExporterPort,\n\t\t\t\t\tinstance: inst,\n\t\t\t\t})\n\t\t}\n\t})\n\n\tfor _, p1 := range currentEntries {\n\t\tfor _, p2 := range existingEntries {\n\t\t\tif p1.instance.GetManageHost() != p2.instance.GetManageHost() {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif p1.port == p2.port {\n\t\t\t\t// build the conflict info\n\t\t\t\tproperties := map[string]string{\n\t\t\t\t\t\"ThisPort\": strconv.Itoa(p1.port),\n\t\t\t\t\t\"ThisComponent\": p1.componentName,\n\t\t\t\t\t\"ThisHost\": p1.instance.GetManageHost(),\n\t\t\t\t\t\"ExistCluster\": p2.clusterName,\n\t\t\t\t\t\"ExistPort\": strconv.Itoa(p2.port),\n\t\t\t\t\t\"ExistComponent\": p2.componentName,\n\t\t\t\t\t\"ExistHost\": p2.instance.GetManageHost(),\n\t\t\t\t}\n\t\t\t\t// if one of the instances marks itself as ignore_exporter, do not report\n\t\t\t\t// the monitoring agent ports conflict and just skip\n\t\t\t\tif (p1.componentName == RoleMonitor || p2.componentName == RoleMonitor) &&\n\t\t\t\t\t(p1.instance.IgnoreMonitorAgent() || p2.instance.IgnoreMonitorAgent()) {\n\t\t\t\t\tzap.L().Debug(\"Ignored deploy port conflict\", zap.Any(\"info\", properties))\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\t// build error message\n\t\t\t\tzap.L().Info(\"Meet deploy port conflict\", zap.Any(\"info\", properties))\n\t\t\t\treturn errDeployPortConflict.New(\"Deploy port conflicts to an existing cluster\").WithProperty(tui.SuggestionFromTemplate(`\nThe port you specified in the topology file is:\n Port: {{ColorKeyword}}{{.ThisPort}}{{ColorReset}}\n Component: {{ColorKeyword}}{{.ThisComponent}} {{.ThisHost}}{{ColorReset}}\n\nIt conflicts to a port in the existing cluster:\n Existing Cluster Name: {{ColorKeyword}}{{.ExistCluster}}{{ColorReset}}\n Existing Port: {{ColorKeyword}}{{.ExistPort}}{{ColorReset}}\n Existing Component: {{ColorKeyword}}{{.ExistComponent}} {{.ExistHost}}{{ColorReset}}\n\nPlease change to use another port or another host.\n`, properties))\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "71a4724685e4309cb2ea7ec8f7ec367f", "score": "0.4896009", "text": "func Port(parameters []string) (exitCode int, exitMessage string) {\n\tport := parseMyInt(parameters[0])\n\topen := getOpenPorts()\n\tfor _, p := range open {\n\t\tif p == port {\n\t\t\treturn 0, \"\"\n\t\t}\n\t}\n\t// Convert ports to string to send to genericError\n\tvar strPorts []string\n\tfor _, port := range open {\n\t\tstrPorts = append(strPorts, fmt.Sprint(port))\n\t}\n\treturn genericError(\"Port not open\", fmt.Sprint(port), strPorts)\n}", "title": "" }, { "docid": "b21f365e5d153505f65aca5a646ff192", "score": "0.4885084", "text": "func scanPorts(a string, ps <-chan int, os chan<- portRes, wg *sync.WaitGroup) {\n\tdefer wg.Done()\n\tfor p := range ps {\n\t\tvar (\n\t\t\tb []byte\n\t\t\terr error\n\t\t)\n\ttry:\n\t\t/* Attack the single port */\n\t\tb, err = tryPort(a, p)\n\t\tif nil != err {\n\t\t\t/* This means we're trying too hard, retry in a bit */\n\t\t\tif strings.HasSuffix(\n\t\t\t\terr.Error(),\n\t\t\t\t\"connect: no route to host\",\n\t\t\t) {\n\t\t\t\ttime.Sleep(time.Second)\n\t\t\t\tgoto try\n\t\t\t}\n\t\t\t/* Port's not open, try the next one */\n\t\t\tcontinue\n\t\t}\n\t\t/* Port's open, return the banner */\n\t\tos <- portRes{port: p, banner: b}\n\t}\n}", "title": "" }, { "docid": "7b38cf1c6bcb8b02a785be7dca078a1c", "score": "0.4879839", "text": "func (o HealthCheckCheckOutput) Port() pulumi.IntOutput {\n\treturn o.ApplyT(func(v HealthCheckCheck) int { return v.Port }).(pulumi.IntOutput)\n}", "title": "" }, { "docid": "83709ec8e7314cd18e6c0addc9edb288", "score": "0.48757938", "text": "func ReportInfo(infoJSON []byte) {\n\tfor {\n\t\t//task scheduler parameters\n\t\tschHTTPPort := config.SchHTTPPort\n\t\tschAddr := config.SchAddr\n\t\tschPath := config.SchPathServerReport\n\n\t\treqSch := bytes.NewBuffer(infoJSON)\n\t\tvar respSch *http.Response\n\t\trespSch, err := http.Post(\"http://\"+string(schAddr)+\":\"+string(schHTTPPort)+schPath, \"application/json;charset=utf-8\", reqSch)\n\t\tif err != nil {\n\t\t\tutils.CheckErr(err, \"Scheduler HTTP POST error\")\n\t\t}\n\n\t\tbodySch, err := ioutil.ReadAll(respSch.Body)\n\t\tif err != nil {\n\t\t\tutils.CheckErr(err, \"Scheduler HTTP response error\")\n\t\t}\n\t\trespSch.Body.Close()\n\t\tif bytes.Compare(bodySch, []byte(\"Succeed\")) != 0 {\n\t\t\tlog.Println(\"Report info is not received correctly\")\n\t\t\tfmt.Println(bodySch)\n\t\t} else {\n\t\t\tlog.Println(\"Report OK\")\n\t\t}\n\t\ttime.Sleep(time.Duration(time.Second * 5))\n\t}\n}", "title": "" }, { "docid": "07641dfbd120fd09e73afc4cef3eb6db", "score": "0.48736888", "text": "func (self *Notifier) Notify(settings *evergreen.Settings) error {\n\t// used to store any errors that occur\n\tcatcher := grip.NewBasicCatcher()\n\tstartAt := time.Now()\n\n\tfor _, f := range self.NotificationBuilders {\n\n\t\t// get the necessary notifications\n\t\tnotifications, err := f(settings)\n\n\t\t// continue on error so that one wonky function doesn't stop the others\n\t\t// from running\n\t\tif err != nil {\n\t\t\tcatcher.Add(errors.Wrap(err,\n\t\t\t\t\"error building notifications to be sent\"))\n\t\t\tcontinue\n\t\t}\n\n\t\t// send the actual notifications. continue on error to allow further\n\t\t// notifications to be sent\n\t\tcatcher.Extend(sendNotifications(notifications, settings))\n\t}\n\n\tgrip.Info(message.Fields{\n\t\t\"runner\": RunnerName,\n\t\t\"message\": \"completed monitor notifications\",\n\t\t\"num_builders\": len(self.NotificationBuilders),\n\t\t\"num_errors\": catcher.Len(),\n\t\t\"duration_secs\": time.Since(startAt).Seconds(),\n\t})\n\n\treturn catcher.Resolve()\n}", "title": "" }, { "docid": "145ad2f4615429877f3e1c288bdd9204", "score": "0.48720565", "text": "func ScanIP(host string, ports *[]int, timeout int) {\n fmt.Println(\"Scanning ports...\")\n expire := time.Millisecond * time.Duration(timeout)\n\n for _, port := range *ports {\n address := net.JoinHostPort(host, strconv.Itoa(port))\n conn, err := net.DialTimeout(\"tcp\", address, expire)\n if err != nil {\n // TODO\n }\n if conn != nil {\n defer conn.Close()\n fmt.Printf(\"OPEN PORT: %s %s\\n\", address, Ports[port])\n }\n }\n}", "title": "" }, { "docid": "dcd58bea09ee240e6141c2a912a7e190", "score": "0.486988", "text": "func notify(items []apimodel.GetItemResponse) {\n\tfor idx, item := range items {\n\t\tfmt.Printf(\"[%d] You have mail! --- %s\\n\", idx, item.Title)\n\t\t// TODO: Add URL?\n\t}\n}", "title": "" }, { "docid": "71c75b4dc07a24b7af987c842eedc3ea", "score": "0.48468423", "text": "func portChangedForService(service *corev1.Service, mediator *eventsv1alpha1.EventMediator) bool {\n\n ports := service.Spec.Ports\n\n check := make(map[int32] int32)\n for _, portInfo := range ports {\n check[portInfo.Port] = portInfo.Port\n }\n\n port := getListenerPort(mediator)\n numMediatorPorts:= 1\n if _, exists:= check[port]; ! exists {\n return true\n }\n if len(ports) != numMediatorPorts {\n return true\n }\n return false\n}", "title": "" }, { "docid": "97326a40ed9189e0babaafa37477cdba", "score": "0.4835636", "text": "func port(parameters []string) (exitCode int, exitMessage string) {\n\t// getHexPorts gets all open ports as hex strings from /proc/net/tcp\n\tgetHexPorts := func() (ports []string) {\n\t\tpaths := [2]string{\"/proc/net/tcp\",\"/proc/net/udp\"}\n\t\tfor _,path := range paths {\n\t\t\tdata := wrkutils.FileToString(path)\n\t\t\ttable := tabular.ProbabalisticSplit(data)\n\t\t\t// TODO by header isn't working\n\t\t\t//localAddresses := tabular.GetColumnByHeader(\"local_address\", table)\n\t\t\tlocalAddresses := tabular.GetAllNoHeader(table)\n\t\t\tportRe := regexp.MustCompile(`([0-9A-F]{8}):([0-9A-F]{4})`)\n\t\t\tfor _, address := range localAddresses {\n\t\t\t\tport := portRe.FindString(address)\n\t\t\t\tif port != \"\" {\n\t\t\t\t\tif len(port) < 10 {\n\t\t\t\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\t\t\t\"port\": port,\n\t\t\t\t\t\t\t\"length\": len(port),\n\t\t\t\t\t\t}).Fatal(\"Couldn't parse port number in \" + path)\n\t\t\t\t\t}\n\t\t\t\t\tportString := string(port[9:])\n\t\t\t\t\tports = append(ports, portString)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn ports\n\t}\n\n\t// strHexToDecimal converts from string containing hex number to int\n\tstrHexToDecimal := func(hex string) int {\n\t\tportInt, err := strconv.ParseInt(hex, 16, 64)\n\t\tif err != nil {\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"number\": hex,\n\t\t\t\t\"error\": err.Error(),\n\t\t\t}).Fatal(\"Couldn't parse hex number\")\n\t\t}\n\t\treturn int(portInt)\n\t}\n\n\t// getOpenPorts gets a list of open/listening ports as integers\n\tgetOpenPorts := func() (ports []int) {\n\t\tfor _, port := range getHexPorts() {\n\t\t\tports = append(ports, strHexToDecimal(port))\n\t\t}\n\t\treturn ports\n\t}\n\n\t// TODO check if it is in a valid range\n\tport := wrkutils.ParseMyInt(parameters[0])\n\topen := getOpenPorts()\n\tfor _, p := range open {\n\t\tif p == port {\n\t\t\treturn 0, \"\"\n\t\t}\n\t}\n\t// convert ports to string to send to wrkutils.GenericError\n\tvar strPorts []string\n\tfor _, port := range open {\n\t\tstrPorts = append(strPorts, fmt.Sprint(port))\n\t}\n\treturn wrkutils.GenericError(\"Port not open\", fmt.Sprint(port), strPorts)\n}", "title": "" }, { "docid": "b61a5ecc0246236b031078a47e0bc3d5", "score": "0.48194852", "text": "func PortChecker(ports []string) []string {\n\tvar unavailable []string\n\tfor _, port := range ports {\n\t\tif isPortUnavailable(port) {\n\t\t\tunavailable = append(unavailable, port)\n\t\t}\n\t}\n\n\treturn unavailable\n}", "title": "" }, { "docid": "2f9616bd7dd637f9f5e3b8ea109635fe", "score": "0.4798006", "text": "func (server *YalppsServer) ScanPort(host string, port int) bool {\n\tps := portscanner.NewPortScanner(host, time.Duration(time.Second*10))\n\treturn ps.IsOpen(port)\n}", "title": "" }, { "docid": "51b2740e1735572917726f3f7c37fdf8", "score": "0.4783009", "text": "func RunHealthCheck(port int, plusClient *client.NginxClient, cnf *configs.Configurator, healthProbeTLSSecret *v1.Secret) {\n\taddr := fmt.Sprintf(\":%s\", strconv.Itoa(port))\n\ths, err := NewHealthServer(addr, plusClient, cnf, healthProbeTLSSecret)\n\tif err != nil {\n\t\tglog.Fatal(err)\n\t}\n\tglog.Infof(\"Starting Service Insight listener on: %v%v\", addr, \"/probe\")\n\tglog.Fatal(hs.ListenAndServe())\n}", "title": "" }, { "docid": "a4ffbd75eb2e43c02ba232c5d215c47b", "score": "0.47606748", "text": "func initMetricsPortscanner() {\n\tportscanner = &Portscanner{}\n\tportscanner.Init()\n\n\tprometheusPublicIpPortscanStatus = prometheus.NewGaugeVec(\n\t\tprometheus.GaugeOpts{\n\t\t\tName: \"azurerm_publicip_portscan_status\",\n\t\t\tHelp: \"Azure ResourceManager public ip portscan status\",\n\t\t},\n\t\t[]string{\"ipAddress\", \"type\"},\n\t)\n\n\tprometheusPublicIpPortscanPort = prometheus.NewGaugeVec(\n\t\tprometheus.GaugeOpts{\n\t\t\tName: \"azurerm_publicip_portscan_port\",\n\t\t\tHelp: \"Azure ResourceManager public ip port\",\n\t\t},\n\t\t[]string{\"ipAddress\", \"protocol\", \"port\", \"description\"},\n\t)\n\n\tprometheus.MustRegister(prometheusPublicIpPortscanStatus)\n\tprometheus.MustRegister(prometheusPublicIpPortscanPort)\n\n\n\tportscanner.Callbacks.FinishScan = func(c *Portscanner) {\n\t\tLogger.Messsage(\"portscan: finished for %v IPs\", len(portscanner.PublicIps))\n\t}\n\n\tportscanner.Callbacks.StartupScan = func(c *Portscanner) {\n\t\tLogger.Messsage(\n\t\t\t\"portscan: starting for %v IPs (parallel:%v, threads per run:%v, timeout:%vs, portranges:%v)\",\n\t\t\tlen(c.PublicIps),\n\t\t\topts.PortscanPrallel,\n\t\t\topts.PortscanThreads,\n\t\t\topts.PortscanTimeout,\n\t\t\topts.portscanPortRange,\n\t\t)\n\n\t\tprometheusPublicIpPortscanStatus.Reset()\n\t}\n\n\tportscanner.Callbacks.StartScanIpAdress = func(c *Portscanner, ipAddress string) {\n\t\tLogger.Messsage(\"portscan[%v]: start port scanning\", ipAddress)\n\n\t\t// set the ipAdress to be scanned\n\t\tprometheusPublicIpPortscanStatus.With(prometheus.Labels{\n\t\t\t\"ipAddress\": ipAddress,\n\t\t\t\"type\": \"finished\",\n\t\t}).Set(0)\n\t}\n\n\tportscanner.Callbacks.FinishScanIpAdress = func(c *Portscanner, ipAddress string, elapsed float64) {\n\t\t// set ipAddess to be finsihed\n\t\tprometheusPublicIpPortscanStatus.With(prometheus.Labels{\n\t\t\t\"ipAddress\": ipAddress,\n\t\t\t\"type\": \"finished\",\n\t\t}).Set(1)\n\n\t\t// set the elapsed time\n\t\tprometheusPublicIpPortscanStatus.With(prometheus.Labels{\n\t\t\t\"ipAddress\": ipAddress,\n\t\t\t\"type\": \"elapsed\",\n\t\t}).Set(elapsed)\n\n\t\t// set update time\n\t\tprometheusPublicIpPortscanStatus.With(prometheus.Labels{\n\t\t\t\"ipAddress\": ipAddress,\n\t\t\t\"type\": \"updated\",\n\t\t}).SetToCurrentTime()\n\t}\n\n\tportscanner.Callbacks.ResultCleanup = func(c *Portscanner) {\n\t\tprometheusPublicIpPortscanPort.Reset()\n\t}\n\n\tportscanner.Callbacks.ResultPush = func(c *Portscanner, result PortscannerResult) {\n\t\tprometheusPublicIpPortscanPort.With(result.Labels).Set(result.Value)\n\t}\n}", "title": "" }, { "docid": "cdbb76a40e77a53820657eaffcbbee50", "score": "0.47461328", "text": "func (n *Node) CheckHostport(hostport int) error {\n\tc := n.Cluster()\n\treturn c.CheckHostport(hostport)\n}", "title": "" }, { "docid": "6eaa48293cb1a568fcceb560746531c3", "score": "0.47219375", "text": "func (r *Receiver) Notify(context context.Context, data *alertmanager.Data) (map[string]StatusNotify, error) {\n\t\n\tvar m map[string]StatusNotify = make(map[string]StatusNotify)\n\tproject := r.tmpl.Execute(r.conf.Project, data)\n\t// check errors from r.tmpl.Execute()\n\tif r.tmpl.err != nil {\n\t\treturn nil, r.tmpl.err\n\t}\n\tlog.Infof(\"looping on the alerts from the group\")\n\t// multipeErrors will be used to stock errors\n\t// occuring while iterating on alarms\n\n\tfor _, alert := range data.Alerts {\n\t\t// Looks like an ALERT metric name, with spaces removed.\n\t\tissueLabel := toIssueLabel(alert.Labels)\n\t\tissue, err := r.getIssue(issueLabel, project)\n\t\tif err != nil {\n\t\t\tlog.Warnf(\"got an error while searching %s\", err)\n\t\t\tm[issueLabel] = StatusNotify{Status: http.StatusInternalServerError, Err: err}\n\t\t\tcontinue\n\t\t}\n\n\t\tif issue != nil {\n\t\t\tr.addComment(issue, r.tmpl.Execute(r.conf.Comment, alert))\n\t\t\t// The set of JIRA status categories is fixed, this is a safe check to make.\n\t\t\tif issue.Fields.Status.StatusCategory.Key != \"done\" {\n\t\t\t\t// Issue is in a \"to do\" or \"in progress\" state, all done here.\n\t\t\t\tlog.Infof(\"Issue %s for %s is unresolved, nothing to do\", issue.Key, issueLabel)\n\t\t\t\t// nothing to be done on this issues\n\t\t\t\tm[issueLabel] = StatusNotify{Status: http.StatusOK, Err: nil}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif r.conf.WontFixResolution != \"\" && issue.Fields.Resolution != nil &&\n\t\t\t\tissue.Fields.Resolution.Name == r.conf.WontFixResolution {\n\t\t\t\t// Issue is resolved as \"Won't Fix\" or equivalent, log a message just in case.\n\t\t\t\tlog.Infof(\"Issue %s for %s is resolved as %q, not reopening\", issue.Key, issueLabel, issue.Fields.Resolution.Name)\n\t\t\t\t// nothing to be done on this issues\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlog.Infof(\"Issue %s for %s was resolved, reopening\", issue.Key, issueLabel)\n\t\t\tif err := r.reopen(issue.Key); err != nil {\n\t\t\t\tm[issueLabel] = StatusNotify{Status: http.StatusInternalServerError, Err: err}\n\n\t\t\t}\n\t\t\tm[issueLabel] = StatusNotify{Status: http.StatusOK, Err: nil}\n\t\t\tcontinue\n\t\t}\n\n\t\tlog.Infof(\"No issue matching %s found, creating new issue\", issueLabel)\n\n\t\tissue = &jira.Issue{\n\t\t\tFields: &jira.IssueFields{\n\t\t\t\tProject: jira.Project{Key: project},\n\t\t\t\tType: jira.IssueType{Name: r.tmpl.Execute(r.conf.IssueType, data)},\n\t\t\t\tDescription: r.tmpl.Execute(r.conf.Description, alert),\n\t\t\t\tSummary: r.tmpl.Execute(r.conf.Summary, alert),\n\t\t\t\tLabels: []string{\n\t\t\t\t\tissueLabel,\n\t\t\t\t},\n\n\t\t\t\tUnknowns: tcontainer.NewMarshalMap(),\n\t\t\t},\n\t\t}\n\t\tlog.Printf(\"issue.field %+v\", issue.Fields)\n\t\tif r.conf.Priority != \"\" {\n\t\t\tissue.Fields.Priority = &jira.Priority{Name: r.conf.Priority}\n\t\t}\n\n\t\t// Add Components\n\t\tif len(r.conf.Components) > 0 {\n\t\t\tissue.Fields.Components = make([]*jira.Component, 0, len(r.conf.Components))\n\t\t\tfor _, component := range r.conf.Components {\n\t\t\t\tissue.Fields.Components = append(issue.Fields.Components, &jira.Component{Name: component})\n\t\t\t}\n\t\t}\n\n\t\t// Add Labels\n\t\tif r.conf.AddGroupLabels {\n\t\t\tfor k, v := range data.GroupLabels {\n\t\t\t\tissue.Fields.Labels = append(issue.Fields.Labels, fmt.Sprintf(\"%s=%q\", k, v))\n\t\t\t}\n\t\t}\n\n\t\t// check errors from r.tmpl.Execute()\n\t\tif r.tmpl.err != nil {\n\t\t\tm[issueLabel] = StatusNotify{Status: http.StatusInternalServerError, Err: r.tmpl.err}\n\t\t\tcontinue\n\t\t}\n\t\tissue, err = r.create(issue)\n\t\tlog.Infof(\"issue %+v\", issue)\n\t\tif err != nil {\n\t\t\tm[issueLabel] = StatusNotify{Status: http.StatusInternalServerError, Err: err}\n\t\t\tcontinue\n\t\t}\n\t\tm[issueLabel] = StatusNotify{Status: http.StatusOK, Err: nil}\n\t\tlog.Infof(\"Issue created: key=%s ID=%s\", issue.Key, issue.ID)\n\n\t}\n\n\treturn m, nil\n\n}", "title": "" }, { "docid": "c98b44de2f4d02441aab8fde8f5768b8", "score": "0.4711696", "text": "func (s *server) broadcastGoalCountReached() {\n\tfor selectorAddr := range s.selectorCheckinList {\n\t\tselector := selectorAddr\n\n\t\t// create client\n\t\tvar conn *grpc.ClientConn\n\t\tconn, err := grpc.Dial(selector, grpc.WithInsecure(), grpc.WithBlock())\n\n\t\tif err != nil {\n\t\t\t// log.Fatalf(\"Could not connect to %s: %s\", selector, err)\n\t\t\tlog.Println(\"Could not connect to: \", selector)\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\t\tdefer conn.Close()\n\n\t\t// send broadcast\n\t\tc := pbIntra.NewFLGoalCountBroadcastClient(conn)\n\t\t_, err = c.GoalCountReached(context.Background(), &pbIntra.Empty{})\n\n\t\tif err != nil {\n\t\t\t// log.Fatalf(\"Error sending to %s: %s\", selector, err)\n\t\t\tlog.Println(\"Could not connect to: \", selector)\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\t\tlog.Printf(\"Goal Count Reached message sent to %s\", selector)\n\t}\n}", "title": "" }, { "docid": "abb1b3e1e56b426cab6a13d21042cdc4", "score": "0.4710302", "text": "func (p *VideoAnalyticsProvider) schedulePortScans() {\n\tp.intervalTicker = time.NewTicker(time.Second * time.Duration(p.options.Interval))\n\tintervalCount := 0\n\tintervalStart := time.Now()\n\tgo func() {\n\t\tfor ; scanOnStartup; <-p.intervalTicker.C {\n\t\t\tintervalCount++\n\t\t\tdeviceCount, err := p.DiscoverDevices(*p.options)\n\t\t\tif err != nil {\n\t\t\t\tp.lc.Error(err.Error())\n\t\t\t}\n\t\t\ttime.Sleep(1 * time.Second) // permits device sdk log entries to settle (affects presentation only)\n\t\t\tp.lc.Info(fmt.Sprintf(\"%v new VA Pipeline devices registered during this scan\", deviceCount))\n\t\t\t// Report next anticipated interval trigger\n\t\t\tnextScan := intervalStart.Local().Add(time.Second * time.Duration(p.options.Interval*intervalCount))\n\t\t\tremainSec := time.Until(nextScan)\n\t\t\tp.lc.Info(fmt.Sprintf(\"Next scan triggers in %.f seconds (%v), and each %v seconds thereafter.\", remainSec.Seconds(), nextScan.Format(time.Stamp), p.options.Interval))\n\t\t}\n\t}()\n}", "title": "" }, { "docid": "4f5cbf0fc87e3b83509b944a9046ee4a", "score": "0.47043717", "text": "func WaitPort(port uint16, timeout time.Duration) error {\n\n\tover := time.After(timeout)\n\tfound := make(chan bool, 1)\n\tnotfound := make(chan bool, 1)\n\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-over:\n\t\t\t\tnotfound <- true\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\tcs, err := procspy.Connections(false)\n\t\t\t\tif err != nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tfor c := cs.Next(); c != nil; c = cs.Next() {\n\t\t\t\t\tif c.LocalPort == port {\n\t\t\t\t\t\tfound <- true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttime.Sleep(50 * time.Millisecond)\n\t\t\t}\n\t\t}\n\t}()\n\n\tselect {\n\tcase <-found:\n\t\treturn nil\n\tcase <-notfound:\n\t\treturn fmt.Errorf(\"Timed out waiting for port %d\", port)\n\t}\n}", "title": "" }, { "docid": "f10f4b8756c8739ffdd5ed16e6e1a4b6", "score": "0.47039193", "text": "func HealthCheckForFQDNPort(client *route53.Route53, fqdn string, port int64) (exists bool, check HealthCheckFQDN, err error) {\n\tresp, err := getHealthChecks(client)\n\n\t//check if any of them contain the healthcheck.\n\t//assumption is that there will be a unique health check\n\t//per fqdn/port\n\tfor _, healthcheck := range resp.HealthChecks {\n\t\tconfig := healthcheck.HealthCheckConfig\n\t\tif *config.FullyQualifiedDomainName == fqdn {\n\t\t\tif *config.Port == port {\n\t\t\t\treturn true, HealthCheckFQDN{\n\t\t\t\t\tFqdn: *healthcheck.HealthCheckConfig.FullyQualifiedDomainName,\n\t\t\t\t\tHealthCheckID: *healthcheck.ID,\n\t\t\t\t}, nil\n\t\t\t}\n\t\t} else {\n\t\t\tglog.Infof(\"No string match\")\n\t\t}\n\t}\n\treturn false, HealthCheckFQDN{}, nil\n}", "title": "" }, { "docid": "1b8c761fefe8b42a20623fd0f9431541", "score": "0.46967396", "text": "func Portscan(target string, timeout, threads int) (pr []int) {\n\tps := portscanner.NewPortScanner(target, time.Duration(timeout)*time.Second, threads)\n\topened_ports := ps.GetOpenedPort(0, 65535)\n\n\tfor p := range opened_ports {\n\t\tport := opened_ports[p]\n\t\tpr = append(pr, port)\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "03f6d36d06c75150b0659afdbb4e55d5", "score": "0.46775106", "text": "func WaitUntilPortIsAvailable(port int) {\n\t// we wait until the workers are killed\n\tfor {\n\t\tconn, err := net.DialTimeout(\"tcp\", fmt.Sprintf(\"0.0.0.0:%v\", port), 1*time.Second)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tconn.Close()\n\t\t// kill nginx worker processes\n\t\tfs, err := proc.NewFS(\"/proc\")\n\t\tif err != nil {\n\t\t\tglog.Errorf(\"unexpected error reading /proc information: %v\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\tprocs, _ := fs.FS.AllProcs()\n\t\tfor _, p := range procs {\n\t\t\tpn, err := p.Comm()\n\t\t\tif err != nil {\n\t\t\t\tglog.Errorf(\"unexpected error obtaining process information: %v\", err)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif pn == \"nginx\" {\n\t\t\t\tosp, err := os.FindProcess(p.PID)\n\t\t\t\tif err != nil {\n\t\t\t\t\tglog.Errorf(\"unexpected error obtaining process information: %v\", err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tosp.Signal(syscall.SIGQUIT)\n\t\t\t}\n\t\t}\n\t\ttime.Sleep(100 * time.Millisecond)\n\t}\n}", "title": "" }, { "docid": "6fcdc91e1452303570e567c41188b209", "score": "0.46767357", "text": "func processPorts(application marathon.Application, task marathon.Task, serviceName string) (int, error) {\n\tlabels := getLabels(application, serviceName)\n\tlblPort := getLabelName(serviceName, label.SuffixPort)\n\n\tif label.Has(labels, lblPort) {\n\t\tport := label.GetIntValue(labels, lblPort, 0)\n\n\t\tif port <= 0 {\n\t\t\treturn 0, fmt.Errorf(\"explicitly specified port %d must be larger than zero\", port)\n\t\t} else if port > 0 {\n\t\t\treturn port, nil\n\t\t}\n\t}\n\n\tports := retrieveAvailablePorts(application, task)\n\tif len(ports) == 0 {\n\t\treturn 0, errors.New(\"no port found\")\n\t}\n\n\tlblPortIndex := getLabelName(serviceName, label.SuffixPortIndex)\n\tportIndex := label.GetIntValue(labels, lblPortIndex, 0)\n\tif portIndex < 0 || portIndex > len(ports)-1 {\n\t\treturn 0, fmt.Errorf(\"index %d must be within range (0, %d)\", portIndex, len(ports)-1)\n\t}\n\treturn ports[portIndex], nil\n}", "title": "" }, { "docid": "73b981b375717c9e7d08e83563f465d5", "score": "0.4656097", "text": "func (o WildFlyDetector) DoPortsDetection(component *model.Component, ctx *context.Context) {\n\tports := []int{}\n\t// Fetch the content of xml for this component\n\tpaths, err := utils.GetCachedFilePathsFromRoot(component.Path, ctx)\n\tif err != nil {\n\t\treturn\n\t}\n\tpomXML := utils.GetFile(&paths, \"pom.xml\")\n\tportPlaceholder := GetPortsForJBossFrameworks(pomXML, \"wildfly-maven-plugin\", \"org.wildfly.plugins\")\n\tif portPlaceholder == \"\" {\n\t\treturn\n\t}\n\n\tif port, err := utils.GetValidPort(portPlaceholder); err == nil {\n\t\tports = append(ports, port)\n\t}\n\n\tif len(ports) > 0 {\n\t\tcomponent.Ports = ports\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "3c33b57599b7d1a9f5a05e71402ff8f0", "score": "0.46530518", "text": "func (s *UpdateEndpointGroupInput) SetHealthCheckPort(v int64) *UpdateEndpointGroupInput {\n\ts.HealthCheckPort = &v\n\treturn s\n}", "title": "" }, { "docid": "0b9f9ff0c4e8f9bd53751a63ecbc41eb", "score": "0.4642568", "text": "func (s *CreateEndpointGroupInput) SetHealthCheckPort(v int64) *CreateEndpointGroupInput {\n\ts.HealthCheckPort = &v\n\treturn s\n}", "title": "" }, { "docid": "2ba1bfd1dbf7b56345a4727457af0702", "score": "0.4642462", "text": "func (a *APIAddresser) WatchAPIHostPorts() (watcher.NotifyWatcher, error) {\n\tvar result params.NotifyWatchResult\n\terr := a.caller.Call(a.facadeName, \"\", \"WatchAPIHostPorts\", nil, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn watcher.NewNotifyWatcher(a.caller, result), nil\n}", "title": "" }, { "docid": "506315f095d1b5ae772f49748ffff740", "score": "0.46359098", "text": "func (s *EndpointGroup) SetHealthCheckPort(v int64) *EndpointGroup {\n\ts.HealthCheckPort = &v\n\treturn s\n}", "title": "" }, { "docid": "6b794d5d39a41dea49d903aeb3021bef", "score": "0.4635284", "text": "func (scanner *ThoroughScan) Port(result *Result, port uint32) (*Result, error) {\n\t// Connect with a 1 second timeout\n\t// @todo - make this configurable?\n\tconnection, err := net.DialTimeout(\n\t\t\"tcp\", result.Addr+\":\"+fmt.Sprintf(\"%d\", port),\n\t\ttime.Duration(1*time.Second),\n\t)\n\n\t// Port inactive\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tconnection.Close()\n\n\tresult.PortScan = &PortScanResult{\n\t\tPort: port,\n\t\tActive: true,\n\t}\n\treturn result, nil\n}", "title": "" }, { "docid": "f8e3131a70496e46ea8fa01db0f8aac8", "score": "0.46067202", "text": "func NotifyMeetingsOnSlack(sheetsService *sheets.Service) {\n\tresp, err := sheetsService.Spreadsheets.Values.Get(spreadsheetID, sheetRange).Do()\n\n\tif err != nil {\n\t\tlog.Fatalf(\"[coach - meetings] Unable to retrieve data from sheet. %v\", err)\n\t}\n\n\tif len(resp.Values) == 0 {\n\t\tlog.Infof(\"[coach - meetings] No data found\")\n\t\treturn\n\t}\n\n\tfor key, row := range resp.Values {\n\t\tif 0 != key {\n\t\t\tnextMonth := findNextMonth()\n\n\t\t\tif strings.Contains(row[columnMeetingMonth].(string), nextMonth) {\n\t\t\t\tsendSlackNotification(row)\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "97e98d9ccbefe00692226f1a9cabd231", "score": "0.4594962", "text": "func listenersUseAnyPortOtherThan(addresses []string, otherPort string) bool {\n\totherPortInt, err := strconv.Atoi(otherPort)\n\tif err != nil {\n\t\treturn false\n\t}\n\tfor _, lnAddr := range addresses {\n\t\tladdrs, err := caddy.ParseNetworkAddress(lnAddr)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tif uint(otherPortInt) > laddrs.EndPort || uint(otherPortInt) < laddrs.StartPort {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "503e9bcb6a01e295cc7060add58fbe67", "score": "0.45895216", "text": "func (vrsConnection *VRSConnection) RegisterForPortUpdates(brport string, pnc chan *PortIPv4Info) error {\n\tvrsConnection.registrationChannel <- &Registration{Brport: brport, Channel: pnc, Register: true}\n\treturn nil\n}", "title": "" }, { "docid": "3b824009734bcb582c7062c9e9c7f73a", "score": "0.457163", "text": "func (s *Service) doPortScan(ctx context.Context, userContext am.UserContext, host string, address *am.ScanGroupAddress) error {\n\tlog.Ctx(ctx).Info().Msg(\"doing portscan\")\n\tportAddress, portResults, err := s.clientServices.PortScanClient.Analyze(ctx, userContext, address)\n\tif err != nil {\n\t\tlog.Ctx(ctx).Error().Err(err).Msg(\"failed to do port scan\")\n\t\treturn err\n\t}\n\n\tif err := s.state.PutPortResults(ctx, userContext.GetOrgID(), address.GroupID, twoHours, host, portResults); err != nil {\n\t\treturn err\n\t}\n\n\t// ignore the 'address' result from the portscanner if the host/ip matches what we are already working on\n\t// so we don't have duplicates.\n\tif portAddress.HostAddress == address.HostAddress && portAddress.IPAddress == address.IPAddress {\n\t\tportAddress = nil // address client UpdateHostPorts disregards address if nil\n\t}\n\n\tlog.Ctx(ctx).Info().Msgf(\"portscan results %#v\\n\", portResults.Ports.Current)\n\tif _, err := s.clientServices.AddressClient.UpdateHostPorts(ctx, userContext, portAddress, portResults); err != nil {\n\t\tlog.Ctx(ctx).Error().Err(err).Msg(\"failed to insert port scan results\")\n\t} else {\n\t\tlog.Ctx(ctx).Info().Msg(\"inserted port scan results\")\n\t}\n\tlog.Ctx(ctx).Info().Msg(\"portscan completed\")\n\treturn nil\n}", "title": "" }, { "docid": "9934dfa5ecdf6eeae65731ba52caf651", "score": "0.45441955", "text": "func PortsFit(j *pbe.Job, w *pbr.Worker) bool {\n\t// Get the set of active ports on the worker\n\tactive := map[int32]bool{}\n\tfor _, p := range w.ActivePorts {\n\t\tactive[p] = true\n\t}\n\t// Loop through the requested ports, fail if they are active.\n\tfor _, d := range j.GetTask().GetDocker() {\n\t\tfor _, p := range d.Ports {\n\t\t\th := p.GetHost()\n\t\t\tif h == 0 {\n\t\t\t\t// \"0\" means \"assign a random port, so skip checking this one.\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif b := active[h]; b {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\treturn true\n}", "title": "" }, { "docid": "064bc5d06ade08b75d4945d965184542", "score": "0.454382", "text": "func (n *Notifier) sendAll(alerts ...*model.Alert) int {\n\tbegin := time.Now()\n\n\t// Attach external labels before sending alerts.\n\tfor _, a := range alerts {\n\t\tfor ln, lv := range n.opts.ExternalLabels {\n\t\t\tif _, ok := a.Labels[ln]; !ok {\n\t\t\t\ta.Labels[ln] = lv\n\t\t\t}\n\t\t}\n\t}\n\n\tb, err := json.Marshal(alerts)\n\tif err != nil {\n\t\tlog.Errorf(\"Encoding alerts failed: %s\", err)\n\t\treturn len(n.opts.AlertmanagerURLs)\n\t}\n\tctx, _ := context.WithTimeout(context.Background(), n.opts.Timeout)\n\n\tsend := func(u string) error {\n\t\tresp, err := ctxhttp.Post(ctx, http.DefaultClient, postURL(u), contentTypeJSON, bytes.NewReader(b))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer resp.Body.Close()\n\n\t\tif resp.StatusCode/100 != 2 {\n\t\t\treturn fmt.Errorf(\"bad response status %v\", resp.Status)\n\t\t}\n\t\treturn err\n\t}\n\n\tvar (\n\t\twg sync.WaitGroup\n\t\tnumErrors uint64\n\t)\n\tfor _, u := range n.opts.AlertmanagerURLs {\n\t\twg.Add(1)\n\n\t\tgo func(u string) {\n\t\t\tif err := send(u); err != nil {\n\t\t\t\tlog.With(\"alertmanager\", u).With(\"count\", fmt.Sprintf(\"%d\", len(alerts))).Errorf(\"Error sending alerts: %s\", err)\n\t\t\t\tn.errors.WithLabelValues(u).Inc()\n\t\t\t\tatomic.AddUint64(&numErrors, 1)\n\t\t\t}\n\t\t\tn.latency.WithLabelValues(u).Observe(time.Since(begin).Seconds())\n\t\t\tn.sent.WithLabelValues(u).Add(float64(len(alerts)))\n\n\t\t\twg.Done()\n\t\t}(u)\n\t}\n\twg.Wait()\n\n\treturn int(numErrors)\n}", "title": "" }, { "docid": "c66139b2c90cd455c60507650b5c1561", "score": "0.45203564", "text": "func sendProbesToHostPort(oc *exutil.CLI, proberPod *v1.Pod, url, targetProtocol, targetHost string, targetPort, iterations int) (string, error) {\n\tif oc == nil {\n\t\treturn \"\", fmt.Errorf(\"Nil pointer to exutil.CLI oc was provided in sendProbesToHostPort.\")\n\t}\n\tif proberPod == nil {\n\t\treturn \"\", fmt.Errorf(\"Nil pointer to proberPod was provided in sendProbesToHostPort.\")\n\t}\n\tif targetProtocol != \"http\" && targetProtocol != \"udp\" {\n\t\treturn \"\", fmt.Errorf(\"sendProbesToHostPort supports only 'http' and 'udp' protocols.\")\n\t}\n\n\trandomID := uuid.New()\n\trandomIDStr := randomID.String()\n\tif targetProtocol == \"udp\" {\n\t\trandomIDStr = fmt.Sprintf(\"START%sEOF\", randomIDStr)\n\t}\n\n\t// Connect to the url, instruct the netexec server running on the other side to dial targetProtocol/targetHost/targetPort and insert\n\t// the randomIDStr in the request. Run these tests in their own go routines to speed this up (for UDP, agnhost unfortunately has a\n\t// 7 second or so wait time before it returns and the delay here compounds a lot when running several iterations).\n\trequest := fmt.Sprintf(\"http://%s/dial?protocol=%s&host=%s&port=%d&request=%s\", url, targetProtocol, targetHost, targetPort, randomIDStr)\n\tvar wg sync.WaitGroup\n\terrChan := make(chan error, iterations)\n\tfor i := 0; i < iterations; i++ {\n\t\t// Make sure that we don´t reuse the i variable when passing it to the go func.\n\t\ti := i\n\t\t// Randomize the start time a little bit per go routine.\n\t\t// Max of 250 ms * current iteration counter\n\t\tn := rand.Intn(250) * i\n\t\tframework.Logf(\"Sleeping for %d ms for iteration %d\", n, i)\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\ttime.Sleep(time.Duration(n) * time.Millisecond)\n\t\t\toutput, err := runOcWithRetry(oc.AsAdmin(), \"exec\", proberPod.Name, \"--\", \"curl\", \"--max-time\", \"15\", \"-s\", request)\n\t\t\t// Report errors.\n\t\t\tif err != nil {\n\t\t\t\terrChan <- fmt.Errorf(\"Query failed. Request: %s, Output: %s, Error: %v\", request, output, err)\n\t\t\t}\n\t\t\treturn\n\t\t}()\n\t}\n\twg.Wait()\n\n\t// If the above yielded any errors, then append them to a list and report them.\n\tif len(errChan) > 0 {\n\t\terrList := \"Encountered the following errors: \"\n\t\tfor e := range errChan {\n\t\t\terrList = fmt.Sprintf(\"%s {%s}\", errList, e.Error())\n\t\t}\n\t\treturn \"\", fmt.Errorf(errList)\n\t}\n\n\treturn randomID.String(), nil\n}", "title": "" }, { "docid": "8a27187f5ec0fa0c307b02f230e9f77a", "score": "0.45112348", "text": "func (n *AlertmanagerNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error) {\n\tn.logger.Debug(\"sending Alertmanager alert\", \"alertmanager\", n.Name)\n\tif len(as) == 0 {\n\t\treturn true, nil\n\t}\n\n\t_ = withStoredImages(ctx, n.logger, n.images,\n\t\tfunc(index int, image ngmodels.Image) error {\n\t\t\t// If there is an image for this alert and the image has been uploaded\n\t\t\t// to a public URL then include it as an annotation\n\t\t\tif image.URL != \"\" {\n\t\t\t\tas[index].Annotations[\"image\"] = model.LabelValue(image.URL)\n\t\t\t}\n\t\t\treturn nil\n\t\t}, as...)\n\n\tbody, err := json.Marshal(as)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tvar (\n\t\tlastErr error\n\t\tnumErrs int\n\t)\n\tfor _, u := range n.urls {\n\t\tif _, err := sendHTTPRequest(ctx, u, httpCfg{\n\t\t\tuser: n.basicAuthUser,\n\t\t\tpassword: n.basicAuthPassword,\n\t\t\tbody: body,\n\t\t}, n.logger); err != nil {\n\t\t\tn.logger.Warn(\"failed to send to Alertmanager\", \"error\", err, \"alertmanager\", n.Name, \"url\", u.String())\n\t\t\tlastErr = err\n\t\t\tnumErrs++\n\t\t}\n\t}\n\n\tif numErrs == len(n.urls) {\n\t\t// All attempts to send alerts have failed\n\t\tn.logger.Warn(\"all attempts to send to Alertmanager failed\", \"alertmanager\", n.Name)\n\t\treturn false, fmt.Errorf(\"failed to send alert to Alertmanager: %w\", lastErr)\n\t}\n\n\treturn true, nil\n}", "title": "" }, { "docid": "6c4b537ae013fc035a634458d554e597", "score": "0.45095742", "text": "func CheckPort(port string) (string, error) {\n\n\t//cleanup whitespace\n\tport = strings.TrimSpace(port)\n\n\tre := regexp.MustCompile(\":\")\n\tmatches := re.FindAllString(port, -1)\n\n\t//port entered without : adding :.\n\tif len(matches) == 0 {\n\t\tport = \":\" + port\n\t\tfmt.Printf(\"adding : to port numbder %s \\n\", port)\n\t\treturn port, nil\n\t}\n\n\t//port entered with 1 : correctly.\n\tif len(matches) == 1 {\n\t\t//confirming it's placement at 0 index\n\t\tif strings.IndexAny(port, \":\") == 0 {\n\t\t\treturn port, nil\n\t\t}\n\t\tif strings.IndexAny(port, \":\") == 0 {\n\t\t\treturn port, errors.New(\"Port Malformed, single : not at start\")\n\t\t}\n\t}\n\n\tif len(matches) > 1 {\n\t\treturn port, errors.New(\"Port Malformed \")\n\t}\n\n\treturn port, nil\n\n}", "title": "" }, { "docid": "3ee955efdddbb13d58727b02849fbab9", "score": "0.4506711", "text": "func (pn *PagerdutyNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error) {\n\talerts := types.Alerts(as...)\n\tif alerts.Status() == model.AlertResolved && !pn.SendResolved() {\n\t\tpn.log.Debug(\"not sending a trigger to Pagerduty\", \"status\", alerts.Status(), \"auto resolve\", pn.SendResolved())\n\t\treturn true, nil\n\t}\n\n\tmsg, eventType, err := pn.buildPagerdutyMessage(ctx, alerts, as)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"build pagerduty message: %w\", err)\n\t}\n\n\tbody, err := json.Marshal(msg)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"marshal json: %w\", err)\n\t}\n\n\tpn.log.Info(\"notifying Pagerduty\", \"event_type\", eventType)\n\tcmd := &SendWebhookSettings{\n\t\tUrl: PagerdutyEventAPIURL,\n\t\tBody: string(body),\n\t\tHttpMethod: \"POST\",\n\t\tHttpHeader: map[string]string{\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t},\n\t}\n\tif err := pn.ns.SendWebhook(ctx, cmd); err != nil {\n\t\treturn false, fmt.Errorf(\"send notification to Pagerduty: %w\", err)\n\t}\n\n\treturn true, nil\n}", "title": "" }, { "docid": "5652e25f29cbd6a7ac703ae07054cf05", "score": "0.44880205", "text": "func handlePorts(basic bool, showAll bool) error {\n ports, err := GetPorts()\n if err != nil {\n return err\n }\n\n log.Info(log.Cyan, \"Num of ports: \")\n log.Infoln(\"%d\\n\", len(ports))\n\n numOpenPorts := 0\n for _, port := range ports {\n if port.USBProduct() != \"\" || port.USBManufacturer() != \"\" {\n numOpenPorts++\n }\n\n if port.USBProduct() == \"\" && port.USBManufacturer() == \"\" && !showAll {\n continue\n }\n\n log.Infoln(log.Yellow, port.Name())\n\n if !basic {\n log.Info(log.Cyan, \"Description: \")\n log.Infoln(port.Description())\n log.Info(log.Cyan, \"Manufacturer: \")\n log.Infoln(port.USBManufacturer())\n log.Info(log.Cyan, \"Serial Number: \")\n log.Infoln(port.USBSerialNumber())\n log.Info(log.Cyan, \"Product: \")\n log.Infoln(port.USBProduct())\n\n if bus, addr, err := port.USBBusAddress(); err != nil {\n log.Infoln(log.Cyan, \"Bus: %d Addr: %d\", bus, addr)\n }\n\n if vid, pid, err := port.USBVIDPID(); err != nil {\n log.Infoln(log.Cyan, \"Vid: %d Addr: %d\", vid, pid)\n }\n }\n\n log.Infoln()\n }\n\n log.Info(log.Cyan, \"Num of open ports: \")\n log.Infoln(\"%d\", numOpenPorts)\n return nil\n}", "title": "" }, { "docid": "27500f650fe81247f72f26d6f65ed997", "score": "0.44856414", "text": "func (l *Lead) Status(rw http.ResponseWriter, r *http.Request) {\n\tfor k, v := range l.Ports {\n\t\ttmp := cache.Workers[k]\n\t\tvar status interface{}\n\n\t\tif writeChannel(v.Channel(), \"STATUS\") {\n\t\t\tif status = readChannel(v.Channel()); status == nil {\n\t\t\t\tlog.WARNING.Println(\"Unable to retrieve status of \" + k)\n\n\t\t\t\ttmp.Health = \"Unknown\"\n\t\t\t\ttmp.Timestamp = time.Now()\n\t\t\t\ttmp.State = \"Unknown\"\n\t\t\t\tcache.Workers[k] = tmp\n\n\t\t\t\tRespond(rw, false, \"Unknown\")\n\t\t\t\treturn\n\t\t\t} else {\n\t\t\t\tlog.INFO.Println(\"Received status from \" + k)\n\n\t\t\t\tif status == \"Unhealthy\" {\n\t\t\t\t\ttmp.Health = \"Unhealthy\"\n\t\t\t\t\ttmp.Timestamp = time.Now()\n\t\t\t\t\tcache.Workers[k] = tmp\n\n\t\t\t\t\tRespond(rw, true, \"Unhealthy\")\n\t\t\t\t\treturn\n\t\t\t\t} else {\n\t\t\t\t\ttmp.Health = \"Healthy\"\n\t\t\t\t\ttmp.Timestamp = time.Now()\n\t\t\t\t\tcache.Workers[k] = tmp\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tlog.WARNING.Println(\"Unable to retrieve status of \" + k)\n\n\t\t\ttmp.Health = \"Unknown\"\n\t\t\ttmp.Timestamp = time.Now()\n\t\t\ttmp.State = \"Unknown\"\n\t\t\tcache.Workers[k] = tmp\n\n\t\t\tRespond(rw, false, \"Unknown\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tRespond(rw, true, \"Healthy\")\n\treturn\n}", "title": "" }, { "docid": "b6a908451d5fcb0771d7fe1e58dd1e8b", "score": "0.44691417", "text": "func (o ServerGroupHealthCheckConfigOutput) HealthCheckConnectPort() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ServerGroupHealthCheckConfig) *int { return v.HealthCheckConnectPort }).(pulumi.IntPtrOutput)\n}", "title": "" }, { "docid": "e72ddd2a0b528b02d9f2808352a234db", "score": "0.44677478", "text": "func checkPorts(t *testing.T, podSpec corev1.PodSpec) {\n\tvar foundValidPort bool\n\tfor _, container := range podSpec.Containers {\n\t\tfor _, port := range container.Ports {\n\t\t\tswitch port.ContainerPort {\n\t\t\tcase cloudControllerManagerDefaultPort, cloudNodeManagerDefaultPort:\n\t\t\t\tfoundValidPort = true\n\t\t\tdefault:\n\t\t\t\tt.Errorf(\"Unknown Container Port %d: All ports on Host Network processes must be registered before use\", port.ContainerPort)\n\t\t\t}\n\n\t\t}\n\t}\n\tif !foundValidPort {\n\t\tt.Errorf(\"Container Ports must specify any used ports. CloudControllerManager should use port %d, CloudNodeManager should use port %d.\", cloudControllerManagerDefaultPort, cloudNodeManagerDefaultPort)\n\t}\n}", "title": "" }, { "docid": "bb61d370c7a999f147b6b1ce83b61958", "score": "0.4466923", "text": "func CheckClusterPortConflict(clusterName string, topo *spec.Specification) error {\n\tclusterDir := spec.ProfilePath(spec.TiOpsClusterDir)\n\tfileInfos, err := ioutil.ReadDir(clusterDir)\n\tif err != nil && !os.IsNotExist(err) {\n\t\treturn err\n\t}\n\n\ttype Entry struct {\n\t\tclusterName string\n\t\tinstance spec.Instance\n\t\tport int\n\t}\n\n\tcurrentEntries := []Entry{}\n\texistingEntries := []Entry{}\n\n\tfor _, fi := range fileInfos {\n\t\tif fi.Name() == clusterName {\n\t\t\tcontinue\n\t\t}\n\n\t\tif tiuputils.IsNotExist(spec.ClusterPath(fi.Name(), spec.MetaFileName)) {\n\t\t\tcontinue\n\t\t}\n\t\tmetadata, err := spec.ClusterMetadata(fi.Name())\n\t\tif err != nil {\n\t\t\treturn errors.Trace(err)\n\t\t}\n\n\t\tmetadata.Topology.IterInstance(func(inst spec.Instance) {\n\t\t\tfor _, port := range inst.UsedPorts() {\n\t\t\t\texistingEntries = append(existingEntries, Entry{\n\t\t\t\t\tclusterName: fi.Name(),\n\t\t\t\t\tinstance: inst,\n\t\t\t\t\tport: port,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\n\ttopo.IterInstance(func(inst spec.Instance) {\n\t\tfor _, port := range inst.UsedPorts() {\n\t\t\tcurrentEntries = append(currentEntries, Entry{\n\t\t\t\tinstance: inst,\n\t\t\t\tport: port,\n\t\t\t})\n\t\t}\n\t})\n\n\tfor _, p1 := range currentEntries {\n\t\tfor _, p2 := range existingEntries {\n\t\t\tif p1.instance.GetHost() != p2.instance.GetHost() {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif p1.port == p2.port {\n\t\t\t\tproperties := map[string]string{\n\t\t\t\t\t\"ThisPort\": strconv.Itoa(p1.port),\n\t\t\t\t\t\"ThisComponent\": p1.instance.ComponentName(),\n\t\t\t\t\t\"ThisHost\": p1.instance.GetHost(),\n\t\t\t\t\t\"ExistCluster\": p2.clusterName,\n\t\t\t\t\t\"ExistPort\": strconv.Itoa(p2.port),\n\t\t\t\t\t\"ExistComponent\": p2.instance.ComponentName(),\n\t\t\t\t\t\"ExistHost\": p2.instance.GetHost(),\n\t\t\t\t}\n\t\t\t\tzap.L().Info(\"Meet deploy port conflict\", zap.Any(\"info\", properties))\n\t\t\t\treturn errDeployPortConflict.New(\"Deploy port conflicts to an existing cluster\").WithProperty(cliutil.SuggestionFromTemplate(`\nThe port you specified in the topology file is:\n Port: {{ColorKeyword}}{{.ThisPort}}{{ColorReset}}\n Component: {{ColorKeyword}}{{.ThisComponent}} {{.ThisHost}}{{ColorReset}}\n\nIt conflicts to a port in the existing cluster:\n Existing Cluster Name: {{ColorKeyword}}{{.ExistCluster}}{{ColorReset}}\n Existing Port: {{ColorKeyword}}{{.ExistPort}}{{ColorReset}}\n Existing Component: {{ColorKeyword}}{{.ExistComponent}} {{.ExistHost}}{{ColorReset}}\n\nPlease change to use another port or another host.\n`, properties))\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "8e2852bb3dccff5418bc2b97085c94b7", "score": "0.44650838", "text": "func ScanPort(protocol string, hostname string, port int, timeout time.Duration) bool {\n\taddr := fmt.Sprintf(\"%s:%d\", hostname, port)\n\tconn, err := net.DialTimeout(protocol, addr, timeout)\n\n\tif err != nil {\n\t\treturn false\n\t}\n\n\tif conn != nil {\n\t\tdefer conn.Close()\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "27967a6fb87afb21656af95758279177", "score": "0.4454809", "text": "func (vn *VictoropsNotifier) Notify(evalContext *alerting.EvalContext) error {\n\tvn.log.Info(\"Executing victorops notification\", \"ruleId\", evalContext.Rule.ID, \"notification\", vn.Name)\n\n\truleURL, err := evalContext.GetRuleURL()\n\tif err != nil {\n\t\tvn.log.Error(\"Failed get rule link\", \"error\", err)\n\t\treturn err\n\t}\n\n\tif evalContext.Rule.State == models.AlertStateOK && !vn.AutoResolve {\n\t\tvn.log.Info(\"Not alerting VictorOps\", \"state\", evalContext.Rule.State, \"auto resolve\", vn.AutoResolve)\n\t\treturn nil\n\t}\n\n\tmessageType := evalContext.Rule.State\n\tif evalContext.Rule.State == models.AlertStateAlerting { // translate 'Alerting' to 'CRITICAL' (Victorops analog)\n\t\tmessageType = AlertStateCritical\n\t}\n\n\tif evalContext.Rule.State == models.AlertStateOK {\n\t\tmessageType = alertStateRecovery\n\t}\n\n\tfields := make(map[string]interface{})\n\tfieldLimitCount := 4\n\tfor index, evt := range evalContext.EvalMatches {\n\t\tfields[evt.Metric] = evt.Value\n\t\tif index > fieldLimitCount {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tbodyJSON := simplejson.New()\n\tbodyJSON.Set(\"message_type\", messageType)\n\tbodyJSON.Set(\"entity_id\", evalContext.Rule.Name)\n\tbodyJSON.Set(\"entity_display_name\", evalContext.GetNotificationTitle())\n\tbodyJSON.Set(\"timestamp\", time.Now().Unix())\n\tbodyJSON.Set(\"state_start_time\", evalContext.StartTime.Unix())\n\tbodyJSON.Set(\"state_message\", evalContext.Rule.Message)\n\tbodyJSON.Set(\"monitoring_tool\", \"Grafana v\"+setting.BuildVersion)\n\tbodyJSON.Set(\"alert_url\", ruleURL)\n\tbodyJSON.Set(\"metrics\", fields)\n\n\tif evalContext.Error != nil {\n\t\tbodyJSON.Set(\"error_message\", evalContext.Error.Error())\n\t}\n\n\tif evalContext.ImagePublicURL != \"\" {\n\t\tbodyJSON.Set(\"image_url\", evalContext.ImagePublicURL)\n\t}\n\n\tdata, _ := bodyJSON.MarshalJSON()\n\tcmd := &models.SendWebhookSync{Url: vn.URL, Body: string(data)}\n\n\tif err := bus.DispatchCtx(evalContext.Ctx, cmd); err != nil {\n\t\tvn.log.Error(\"Failed to send Victorops notification\", \"error\", err, \"webhook\", vn.Name)\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "1a8d01a255282e85fa2b18650344e6f5", "score": "0.4444442", "text": "func (c *Config) SendResults(results *Results, url string) {\n\tdata, _ := json.MarshalIndent(results, \"\", \" \")\n\tc.Debug(\"Sending Payload:\", string(data))\n\n\tif _, err := c.Notify.SendJSON(url, data); err != nil {\n\t\tc.Error(\"Sending service check update to Notifiarr:\", err)\n\t}\n}", "title": "" }, { "docid": "28730c8ca2ff967cf436c45d7896d106", "score": "0.44436187", "text": "func TestCheckPortAvailability(t *testing.T) {\n\tif runtime.GOOS != \"linux\" {\n\t\tt.Skip()\n\t}\n\n\tl, err := net.Listen(\"tcp\", \"localhost:0\") // ask kernel for a free port.\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer l.Close()\n\n\tport := l.Addr().(*net.TCPAddr).Port\n\n\ttestCases := []struct {\n\t\thost string\n\t\tport int\n\t\texpectedErr error\n\t}{\n\t\t{\"\", port, fmt.Errorf(\"listen tcp :%v: bind: address already in use\", port)},\n\t\t{\"127.0.0.1\", port, fmt.Errorf(\"listen tcp 127.0.0.1:%v: bind: address already in use\", port)},\n\t}\n\n\tfor _, testCase := range testCases {\n\t\terr := CheckPortAvailability(testCase.host, strconv.Itoa(testCase.port), TCPOptions{})\n\t\tswitch {\n\t\tcase testCase.expectedErr == nil:\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"error: expected = <nil>, got = %v\", err)\n\t\t\t}\n\t\tcase err == nil:\n\t\t\tt.Fatalf(\"error: expected = %v, got = <nil>\", testCase.expectedErr)\n\t\tcase testCase.expectedErr.Error() != err.Error():\n\t\t\tt.Fatalf(\"error: expected = %v, got = %v\", testCase.expectedErr, err)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "79bc69410fd534ae177f0ab3dd830168", "score": "0.4443127", "text": "func getHealthCheckFromPodPort(pod *api.Pod, checkPort int32) *HealthCheck {\n\tcheck := HealthCheck{}\n\n\t// Create a list of valid routing ports\n\tfor _, container := range pod.Spec.Containers {\n\t\t// Pod has multiple containers, return health check for a container port\n\t\tfor _, port := range container.Ports {\n\t\t\tif port.ContainerPort == checkPort {\n\t\t\t\tvar probe *api.Probe\n\t\t\t\t// Check ReadinessProbe and use first\n\t\t\t\tif container.ReadinessProbe != nil {\n\t\t\t\t\tprobe = container.ReadinessProbe\n\t\t\t\t} else if container.LivenessProbe != nil { // Fallback on LivenessProbe\n\t\t\t\t\tprobe = container.LivenessProbe\n\t\t\t\t}\n\n\t\t\t\t// If non are found don't create HealthCheck\n\t\t\t\tif probe == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\n\t\t\t\tcheck.HTTPCheck = false\n\t\t\t\tcheck.TimeoutMs = probe.TimeoutSeconds * 1000 // convert to ms\n\t\t\t\tcheck.IntervalMs = probe.PeriodSeconds * 1000 // convert to ms\n\t\t\t\tcheck.UnhealthyThreshold = probe.FailureThreshold\n\t\t\t\tcheck.HealthyThreshold = probe.SuccessThreshold\n\n\t\t\t\tif probe.Handler.HTTPGet != nil {\n\t\t\t\t\tcheck.HTTPCheck = true\n\t\t\t\t\tcheck.Port = int32(probe.Handler.HTTPGet.Port.IntValue())\n\t\t\t\t\tcheck.Path = probe.Handler.HTTPGet.Path\n\t\t\t\t\t// Default to GET kubernetes doesn't have method option\n\t\t\t\t\tcheck.Method = \"GET\"\n\t\t\t\t} else if probe.Handler.TCPSocket != nil {\n\t\t\t\t\tcheck.Port = int32(probe.Handler.TCPSocket.Port.IntValue())\n\t\t\t\t} else {\n\t\t\t\t\tcheck.Port = checkPort\n\t\t\t\t}\n\n\t\t\t\treturn &check\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "7fbe0f57012108fc4e6222f3307e4895", "score": "0.44421977", "text": "func checkPort() string {\r\n\targs := os.Args[1:]\r\n\tvar res string\r\n\tif len(args) == 1 {\r\n\t\tcheckEqual := false\r\n\t\tvar numEqual int\r\n\t\tfor i := range args[0] {\r\n\t\t\tif args[0][i] == '=' {\r\n\t\t\t\tcheckEqual = true\r\n\t\t\t\tnumEqual = i + 1\r\n\t\t\t}\r\n\t\t}\r\n\t\tif checkEqual {\r\n\t\t\tres = args[0][numEqual:]\r\n\t\t} else {\r\n\t\t\tres = args[0]\r\n\t\t}\r\n\t} else {\r\n\t\tres = \":8000\"\r\n\t\tfmt.Println()\r\n\t}\r\n\treturn res\r\n}", "title": "" }, { "docid": "d8ff380be5424f2be915dd2d31536ad8", "score": "0.44389355", "text": "func (o GetServerGroupsGroupHealthCheckConfigOutput) HealthCheckConnectPort() pulumi.IntOutput {\n\treturn o.ApplyT(func(v GetServerGroupsGroupHealthCheckConfig) int { return v.HealthCheckConnectPort }).(pulumi.IntOutput)\n}", "title": "" }, { "docid": "eece2e11700666382d1e5b77682f06e1", "score": "0.44320384", "text": "func (StatMgr *OpenOltStatisticsMgr) PortStatisticsIndication(ctx context.Context, PortStats *openolt.PortStatistics, NumPonPorts uint32) {\n\tStatMgr.PortsStatisticsKpis(ctx, PortStats, NumPonPorts)\n\tlogger.Debugw(ctx, \"received-port-stats-indication\", log.Fields{\"port-stats\": PortStats})\n\t//Indicate that PortStatisticsIndication is handled\n\t//PortStats.IntfId is actually the port number\n\tStatMgr.processStatIndication(ctx, portStatsType, PortStats.IntfId)\n\t// TODO send stats to core topic to the voltha kafka or a different kafka ?\n}", "title": "" }, { "docid": "7cf81d32d5042b30e7f8e4b1ec23cd35", "score": "0.44240445", "text": "func (c *Controller) rpcHealthCheck() (chan struct{}, error) {\n\tgone := make(chan struct{})\n\n\tclient, err := node.NewLBClient(c.options.ServicedEndpoint)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tgo func() {\n\t\tvar ts time.Time\n\t\tretries := 3\n\t\tfailures := 0\n\t\tfor {\n\t\t\terr := client.Ping(2*time.Second, &ts)\n\t\t\tif err != nil {\n\t\t\t\tfailures++\n\t\t\t\tglog.Warningf(\"RPC Server healthcheck ping to delegate failed. Error: %v\", err)\n\t\t\t\tif failures == retries {\n\t\t\t\t\tglog.Error(\"RPC Server healthcheck retries exhausted, marking it dead and closing channel.\")\n\t\t\t\t\tclose(gone)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfailures = 0\n\t\t\t}\n\t\t\tselect {\n\t\t\tcase <-time.After(10 * time.Second):\n\t\t\t\tcontinue\n\n\t\t\t}\n\t\t}\n\t}()\n\treturn gone, nil\n}", "title": "" }, { "docid": "5b05bdcf9742f7fe946d03ab6185715f", "score": "0.44231462", "text": "func checkPortsRange(portsRange []string) {\n\tfor i := 0; i < len(portsRange); i++ {\n\t\tconverted, err := strconv.Atoi(portsRange[i])\n\t\tif err != nil {\n log.Log.Debug(\"Port value to convert: \" + portsRange[i])\n\t\t\tlog.Log.Error(\"[-] Conversion error: \" + err.Error())\n\t\t\tos.Exit(1)\n\t\t}\n\t\tif converted < 1 || converted > 65535 {\n\t\t\tlog.Log.Error(\"[-] The value \" + strconv.Itoa(converted) + \" is not in the ports range (1-65535).\")\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "facd3328fa88b041e093a4ce6b47af41", "score": "0.44095537", "text": "func executeHealthCheck(wg *sync.WaitGroup, cmd buddha.Command, check buddha.Check, done chan bool, fail chan error) {\n\tdefer wg.Done()\n\n\tfor i := 1; true; i++ {\n\t\tlog.Println(log.LevelInfo, \"Check %d/%d: %s: checking...\", i, cmd.Failures, check.String())\n\t\terr := check.Execute(cmd.Timeout.Duration())\n\t\tif err != nil {\n\t\t\tswitch e := err.(type) {\n\t\t\tcase buddha.CheckFalse:\n\t\t\t\tlog.Println(log.LevelInfo, \"Check %d/%d: %s: returned false: %s\", i, cmd.Failures, check.String(), e)\n\t\t\t\tif i < cmd.Failures {\n\t\t\t\t\tlog.Println(log.LevelInfo, \"Check %d/%d: %s: waiting %s...\", i, cmd.Failures, check.String(), cmd.Interval)\n\t\t\t\t\ttime.Sleep(cmd.Interval.Duration())\n\t\t\t\t} else {\n\t\t\t\t\tdone <- false\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\t// unexpected failure\n\t\t\t\tlog.Println(log.LevelInfo, \"Check %d/%d: %s: returned error: %s\", i, cmd.Failures, check.String(), e)\n\t\t\t\tif i < cmd.Failures {\n\t\t\t\t\tlog.Println(log.LevelInfo, \"Check %d/%d: %s: waiting %s...\", i, cmd.Failures, check.String(), cmd.Interval)\n\t\t\t\t\ttime.Sleep(cmd.Interval.Duration())\n\t\t\t\t} else {\n\t\t\t\t\tfail <- err\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tlog.Println(log.LevelInfo, \"Check %d/%d: %s success!\", i, cmd.Failures, check.String())\n\t\t\tdone <- true\n\t\t\treturn\n\t\t}\n\t}\n}", "title": "" }, { "docid": "38bba15315e27dcc1177220441c24274", "score": "0.43979448", "text": "func (o GetHealthCheckTemplatesTemplateOutput) HealthCheckConnectPort() pulumi.IntOutput {\n\treturn o.ApplyT(func(v GetHealthCheckTemplatesTemplate) int { return v.HealthCheckConnectPort }).(pulumi.IntOutput)\n}", "title": "" }, { "docid": "1b2ec6c626035970134da20ce782b239", "score": "0.43936616", "text": "func (a AppHealthChecks) Run(id HealthCheckID) (HealthCheckResult, error) {\n\tif id == HealthCheckID(0) {\n\t\treturn HealthCheckResult{}, IllegalArgumentError(\"HealthCheckIS cannot be 0\")\n\t}\n\n\thealthchecksMutex.Lock()\n\tdefer healthchecksMutex.Unlock()\n\n\thealthCheckService := Services.Service(HEALTHCHECK_SERVICE_ID)\n\tif healthCheckService == nil {\n\t\treturn HealthCheckResult{}, ServiceAlreadyRegisteredError(HEALTHCHECK_SERVICE_ID)\n\t}\n\n\thealthcheck := registeredHealthChecks[id]\n\tif healthcheck == nil {\n\t\treturn HealthCheckResult{}, HealthCheckNotRegisteredError(id)\n\t}\n\n\tc := make(chan HealthCheckResult, 1)\n\tselect {\n\tcase healthcheck.RunOnDemandChan <- c:\n\tcase <-healthcheck.Dying():\n\t\treturn HealthCheckResult{}, HealthCheckNotAliveError(id)\n\tcase <-healthCheckService.Dying():\n\t\treturn HealthCheckResult{}, ServiceNotAliveError(HEALTHCHECK_SERVICE_ID)\n\t}\n\n\tselect {\n\tcase result := <-c:\n\t\treturn result, nil\n\tcase <-healthcheck.Dying():\n\t\treturn HealthCheckResult{}, HealthCheckNotAliveError(id)\n\tcase <-healthCheckService.Dying():\n\t\treturn HealthCheckResult{}, ServiceNotAliveError(HEALTHCHECK_SERVICE_ID)\n\t}\n}", "title": "" }, { "docid": "879caeaebdb65a83107ce143b8941511", "score": "0.4391559", "text": "func MultiplePort(ports []int, change bool) (int, error) {\n\tlast := len(ports) - 1\n\tfor k, v := range ports {\n\t\tc := false\n\t\tif last == k {\n\t\t\tc = change\n\t\t}\n\t\tn, err := Port(v, c)\n\t\tif err == nil {\n\t\t\treturn n, nil\n\t\t}\n\t}\n\treturn 0, errors.New(\"no available port\")\n}", "title": "" }, { "docid": "b34d2a5f1a3374d42a5825b9e8917e97", "score": "0.4385183", "text": "func (p PrometheusFunctionNotifier) Notify(method string, URL string, statusCode int, duration time.Duration) {\n\tseconds := duration.Seconds()\n\tserviceName := getServiceName(URL)\n\n\tp.Metrics.GatewayFunctionsHistogram.\n\t\tWithLabelValues(serviceName).\n\t\tObserve(seconds)\n\n\tcode := strconv.Itoa(statusCode)\n\n\tp.Metrics.GatewayFunctionInvocation.\n\t\tWith(prometheus.Labels{\"function_name\": serviceName, \"code\": code}).\n\t\tInc()\n}", "title": "" }, { "docid": "c46395b236cc26e4e9c1770d0fe9a1fe", "score": "0.43766594", "text": "func setUpHealthCheckService(port string, endpoint string) {\n\tmux := http.NewServeMux()\n\tmux.HandleFunc(endpoint, func(rw http.ResponseWriter, req *http.Request) {\n\t\trw.WriteHeader(http.StatusOK)\n\t\tcommon.Log.Counter(\"Health-Check\")\n\t})\n\tgo http.ListenAndServe(\":\"+port, mux)\n\tlog.Printf(\"Health-check listening on:%s%s\", port, endpoint)\n}", "title": "" }, { "docid": "74dbccf78a7f01cec3332dadf815f8cb", "score": "0.43722388", "text": "func (r Reporter) Report(ctx context.Context, suite string, rep *report.Report) error {\n\tfor _, c := range rep.Checks {\n\t\t// TODO: close alert\n\t\tif c.Status == report.CheckStatusFailed {\n\t\t\tif err := r.createAlert(ctx, suite, c); err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"create alert for %s:%s:%s\", suite, c.Group, c.Name)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "cbfc5eabedf9b5a3dccd4ce0116ec8a1", "score": "0.43686914", "text": "func scan(a string, nAttempt uint, start time.Time) []byte {\n\tdebug(\"%v Scanning\", a)\n\t/* Open ports */\n\tvar successes = make(map[int][]byte)\n\n\t/* Port Scanners */\n\tvar wg sync.WaitGroup\n\tps := make(chan int)\n\tos := make(chan portRes)\n\twg.Add(int(nAttempt))\n\tfor i := 0; i < int(nAttempt); i++ {\n\t\tgo scanPorts(a, ps, os, &wg)\n\t}\n\n\t/* Send ports to scanners */\n\tfor i := 1; i <= 65535; i++ {\n\t\tps <- i\n\t\tif 0 == i%10000 {\n\t\t\tdebug(\n\t\t\t\t\"%v Queued port %v (%v)\",\n\t\t\t\ta,\n\t\t\t\ti,\n\t\t\t\ttime.Now().Sub(start),\n\t\t\t)\n\t\t}\n\t}\n\tclose(ps)\n\n\t/* Receive scanners' output, put in successes */\n\tsdone := make(chan struct{})\n\tgo func() {\n\t\tfor o := range os {\n\t\t\tsuccesses[o.port] = o.banner\n\t\t}\n\t\tclose(sdone)\n\t}()\n\n\t/* Wait for scanners to finish */\n\twg.Wait()\n\tclose(os)\n\n\t/* Wait for receiver to finish */\n\t<-sdone\n\n\tsd := time.Now().Sub(start) /* Scan duration */\n\tdebug(\"%v Scanned in %v\", a, sd)\n\n\t/* Maintain averages */\n\tupdateAverages(sd)\n\n\t/* Craft and return result */\n\treturn openPortsReport(successes, start)\n}", "title": "" }, { "docid": "eacbbb38f9a125c1496c9e0b747256b5", "score": "0.43663856", "text": "func (n *Notifier) Run() {\n\tnumAMs := len(n.opts.AlertmanagerURLs)\n\t// Just warn once in the beginning to prevent noisy logs.\n\tif numAMs == 0 {\n\t\tlog.Warnf(\"No AlertManagers configured, not dispatching any alerts\")\n\t\treturn\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase <-n.ctx.Done():\n\t\t\treturn\n\t\tcase <-n.more:\n\t\t}\n\t\talerts := n.nextBatch()\n\n\t\tif numAMs > 0 {\n\n\t\t\tif len(alerts) > 0 {\n\t\t\t\tnumErrors := n.sendAll(alerts...)\n\t\t\t\t// Increment the dropped counter if we could not send\n\t\t\t\t// successfully to a single AlertManager.\n\t\t\t\tif numErrors == numAMs {\n\t\t\t\t\tn.dropped.Add(float64(len(alerts)))\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tn.dropped.Add(float64(len(alerts)))\n\t\t}\n\t\t// If the queue still has items left, kick off the next iteration.\n\t\tif n.queueLen() > 0 {\n\t\t\tn.setMore()\n\t\t}\n\t}\n}", "title": "" }, { "docid": "58e8017570d78d52d3601f870d2f1987", "score": "0.4357212", "text": "func pollContainerTcpPortHealth(host string, port uint, timeout_sec uint) error {\n\tlog.Printf(\"Attempting connection to TCP %s:%d...\", host, port)\n\tfor i := uint(0); i < timeout_sec; i++ {\n\t\tconn, err := net.Dial(\"tcp\", fmt.Sprintf(\"%s:%d\", host, port))\n\t\tif err != nil {\n\t\t\tfmt.Printf(\".\")\n\t\t} else {\n\t\t\tconn.Close()\n\t\t\tfmt.Printf(\" Success.\\n\")\n\t\t\treturn nil\n\t\t}\n\t\ttime.Sleep(time.Second)\n\t}\n\tfmt.Printf(\" Timeout reached.\\n\")\n\treturn fmt.Errorf(\"Connection attempt to %s:%d timed out after %d seconds.\", host, port, timeout_sec)\n}", "title": "" }, { "docid": "d64677c630e5a825cf05074310d14ebc", "score": "0.43569595", "text": "func (s *Server) runOnPortClosed(p *port) {\n\t<-p.CloseChan()\n\ts.portSetMut.Lock()\n\tdefer s.portSetMut.Unlock()\n\taddr := p.config.GetAddr()\n\tif s.portSet[addr] == p {\n\t\tdelete(s.portSet, addr)\n\t}\n\ts.log.Infof(\"port %q closed\", p.config.GetAddr())\n}", "title": "" }, { "docid": "e9b80006503bebf7d42e945626fd9808", "score": "0.43528783", "text": "func (p *Pinger) Run(reporters map[string]reporters.Interface) {\n\ttags := []string{\n\t\tfmt.Sprintf(\"address:%s\", p.address),\n\t\tfmt.Sprintf(\"name:%s\", p.name),\n\t}\n\n\tcollect := func() {\n\t\tstats, err := p.Collect()\n\t\tif err != nil {\n\t\t\tlog.Get().Warn(\"failed to execute ping\", zap.String(\"name\", p.name), zap.String(\"address\", p.address), zap.Error(err))\n\t\t\t// error statistic\n\t\t\tstats.Add(\n\t\t\t\tstatistics.NewStatistic(\n\t\t\t\t\tstatistics.NewMetric(\n\t\t\t\t\t\tstatistics.MetricTypeCount,\n\t\t\t\t\t\tmetricPrefix+\"pinger.\"+collectFailureSuffix,\n\t\t\t\t\t\tstatistics.NewIntValue(1),\n\t\t\t\t\t\ttags...,\n\t\t\t\t\t),\n\t\t\t\t\tnil,\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\t\tfor _, reporter := range reporters {\n\t\t\treporter.ReportStatistics(stats)\n\t\t}\n\t}\n\n\tgo func() {\n\t\tticker := time.NewTicker(p.collectInterval)\n\t\tcollect()\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-ticker.C:\n\t\t\t\tcollect()\n\t\t\t}\n\t\t}\n\t}()\n}", "title": "" }, { "docid": "0956f78037bee2c40646e5b9bc9e8ccf", "score": "0.43517238", "text": "func GetNodesHealthCheckPort() int32 {\n\treturn lbNodesHealthCheckPort\n}", "title": "" }, { "docid": "3eb263220e50d5d4b8039a5f525f8d1b", "score": "0.43456575", "text": "func checkServiceLabelPortV1(container dockerData) error {\n\t// If port container label is present, there is a default values for all ports, use it for the check\n\t_, err := strconv.Atoi(container.Labels[label.TraefikPort])\n\tif err != nil {\n\t\tserviceLabelPorts := make(map[string]struct{})\n\t\tserviceLabels := make(map[string]struct{})\n\t\tfor lbl := range container.Labels {\n\t\t\t// Get all port service labels\n\t\t\tportLabel := extractServicePortV1(lbl)\n\t\t\tif len(portLabel) > 0 {\n\t\t\t\tserviceLabelPorts[portLabel[0]] = struct{}{}\n\t\t\t}\n\t\t\t// Get only one instance of all service names from service labels\n\t\t\tservicesLabelNames := label.FindSegmentSubmatch(lbl)\n\n\t\t\tif len(servicesLabelNames) > 0 {\n\t\t\t\tserviceLabels[strings.Split(servicesLabelNames[0], \".\")[1]] = struct{}{}\n\t\t\t}\n\t\t}\n\t\t// If the number of service labels is different than the number of port services label\n\t\t// there is an error\n\t\tif len(serviceLabels) == len(serviceLabelPorts) {\n\t\t\tfor labelPort := range serviceLabelPorts {\n\t\t\t\t_, err = strconv.Atoi(container.Labels[labelPort])\n\t\t\t\tif err != nil {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\terr = errors.New(\"port service labels missing, please use traefik.port as default value or define all port service labels\")\n\t\t}\n\t}\n\treturn err\n}", "title": "" }, { "docid": "a16128cca6269b8cfae53b03b0b6f3b1", "score": "0.43452886", "text": "func (m *metrics) do(IPMap map[string]map[string]map[string]data, refresh int) {\n\thosts := prometheus.NewGaugeVec(\n\t\tprometheus.GaugeOpts{\n\t\t\tName: \"hosts_src_dst\",\n\t\t\tHelp: \"Number of bytes transfered between hosts\",\n\t\t},\n\t\t// []string{\"addr\", \"port\", \"firstSeen\", \"srcPort\", \"dstPort\"},\n\t\t[]string{\"a_srcAddr\", \"b_dstAddr\", \"c_dstPort\", \"d_firstSeen\"},\n\t)\n\n\ttotalInOpts := prometheus.GaugeOpts{\n\t\tName: \"total_incoming\",\n\t\tHelp: \"total incoming bytes from internet\",\n\t}\n\ttotalInGauge := promauto.NewGauge(totalInOpts)\n\n\ttotalOutOpts := prometheus.GaugeOpts{\n\t\tName: \"total_outgoing\",\n\t\tHelp: \"total outgoing bytes from internet\",\n\t}\n\ttotalOutGauge := promauto.NewGauge(totalOutOpts)\n\n\t// Metrics have to be registered to be exposed:\n\tprometheus.MustRegister(hosts)\n\n\tfor {\n\t\tmu.Lock()\n\t\tvar totalIn int\n\t\tvar totalOut int\n\n\t\tfor ksip, vsip := range IPMap {\n\t\t\tfor kdip, vdip := range vsip {\n\t\t\t\tfor kdport, vdport := range vdip {\n\t\t\t\t\thosts.With(prometheus.Labels{\"a_srcAddr\": ksip, \"b_dstAddr\": kdip, \"c_dstPort\": kdport, \"d_firstSeen\": vdport.firstSeen}).Set(float64(vdport.totalAmount))\n\n\t\t\t\t\tfor _, v3 := range m.localNetworks.values {\n\t\t\t\t\t\tcidr := strings.Split(v3, \"/\")\n\t\t\t\t\t\tif len(cidr) < 2 {\n\t\t\t\t\t\t\tlog.Printf(\"error: local networks: wrong format of addr/maskbits\\n\")\n\t\t\t\t\t\t\tos.Exit(1)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmaskb, err := strconv.Atoi(cidr[1])\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\tlog.Printf(\"error: failed to convert maskbits to int: %v\\n\", err)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Check if the source address is a local address.\n\t\t\t\t\t\tok1, err := checkAddrInPrefix(vdport.srcIP, cidr[0], maskb)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\tlog.Printf(\"error: checkAddrInPrefix failed: %v\\n\", err)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Check if the destination address is a local address.\n\t\t\t\t\t\tok2, err := checkAddrInPrefix(vdport.dstIP, cidr[0], maskb)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\tlog.Printf(\"error: checkAddrInPrefix failed: %v\\n\", err)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// If source is local, and destination is not local.\n\t\t\t\t\t\tif ok1 && !ok2 {\n\t\t\t\t\t\t\ttotalOut += vdport.totalAmount\n\t\t\t\t\t\t\t// fmt.Println(\"totalOut += v2.totalAmount: \", totalOut)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// If source is not local, and destination is local.\n\t\t\t\t\t\tif !ok1 && ok2 {\n\t\t\t\t\t\t\ttotalIn += vdport.totalAmount\n\t\t\t\t\t\t\t// fmt.Println(\"totalIn += v2.totalAmount: \", totalIn)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\ttotalInGauge.Set(float64(totalIn))\n\t\ttotalOutGauge.Set(float64(totalOut))\n\t\t//fmt.Printf(\"totalIn = %v\\n\", totalIn)\n\t\t//fmt.Printf(\"totalOut = %v\\n\", totalOut)\n\t\tmu.Unlock()\n\n\t\ttime.Sleep(time.Second * time.Duration(refresh))\n\t}\n}", "title": "" }, { "docid": "85112b58f401783d82a2591e55f8068d", "score": "0.43389007", "text": "func (_m *NotifyListener) NotifyAll(_a0 []*registry.ServiceEvent, _a1 func()) {\n\t_m.Called(_a0, _a1)\n}", "title": "" }, { "docid": "33ef4bf5adcc7061afd502433eb99388", "score": "0.4336189", "text": "func CompareResults(expected []Host, discovered []Host) Result {\n\tvar r Result\n\n\t// Check if all hosts scanned as expected\n\tfor e := range expected {\n\t\t// Empty Name means host was not in nmap scan results\n\t\tif getHostByName(expected[e].Name, discovered).Name == \"\" {\n\t\t\th := HostResult{\n\t\t\t\tName: expected[e].Name,\n\t\t\t}\n\n\t\t\t// All expected ports will be marked as missing due to host not being present in scan result\n\t\t\tfor p := range expected[e].Ports {\n\t\t\t\th.Ports = append(h.Ports, PortResult{\n\t\t\t\t\tPort: expected[e].Ports[p],\n\t\t\t\t\tExpected: true,\n\t\t\t\t\tMissing: true,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tr.Hosts = append(r.Hosts, h)\n\t\t}\n\t}\n\n\t// Check the discoveries\n\tfor d := range discovered {\n\t\texp := getHostByName(discovered[d].Name, expected)\n\n\t\tif exp.Name == \"\" {\n\t\t\tlog.Fatalf(\"Discovered host %s not on the expected list!\", discovered[d].Name)\n\t\t}\n\n\t\th := HostResult{\n\t\t\tName: exp.Name,\n\t\t}\n\n\t\t// First loop over expected ports and check whether they are in the scan\n\t\tfor p := range exp.Ports {\n\t\t\th.Ports = append(h.Ports, PortResult{\n\t\t\t\tPort: exp.Ports[p],\n\t\t\t\tExpected: true,\n\t\t\t\tMissing: !stringInSlice(exp.Ports[p], discovered[d].Ports),\n\t\t\t})\n\t\t}\n\n\t\t// Next loop over discovered ports\n\t\tfor p := range discovered[d].Ports {\n\t\t\t// Skip ports that are on expected list already (no duplications)\n\t\t\tif !stringInSlice(discovered[d].Ports[p], exp.Ports) {\n\t\t\t\th.Ports = append(h.Ports, PortResult{\n\t\t\t\t\tPort: discovered[d].Ports[p],\n\t\t\t\t\tExpected: false,\n\t\t\t\t\tMissing: false,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tr.Hosts = append(r.Hosts, h)\n\t}\n\n\treturn r\n}", "title": "" }, { "docid": "8fafdd6645251418d01e5a59309cbf28", "score": "0.43356746", "text": "func (m MicronautDetector) DoPortsDetection(component *model.Component, ctx *context.Context) {\n\t// check if port is set on env var\n\tports := getMicronautPortsFromEnvs()\n\tif len(ports) > 0 {\n\t\tcomponent.Ports = ports\n\t\treturn\n\t}\n\n\tbytes, err := utils.ReadAnyApplicationFile(component.Path, []model.ApplicationFileInfo{\n\t\t{\n\t\t\tDir: \"src/main/resources\",\n\t\t\tFile: \"application.yml\",\n\t\t},\n\t\t{\n\t\t\tDir: \"src/main/resources\",\n\t\t\tFile: \"application.yaml\",\n\t\t},\n\t}, ctx)\n\tif err != nil {\n\t\treturn\n\t}\n\tports = getMicronautPortsFromBytes(bytes)\n\tif len(ports) > 0 {\n\t\tcomponent.Ports = ports\n\t}\n}", "title": "" }, { "docid": "58ffdbe658a4b6f74077b7b3a5781532", "score": "0.43341887", "text": "func (o OnPremisesConfigurationResponseOutput) HostPort() pulumi.StringOutput {\n\treturn o.ApplyT(func(v OnPremisesConfigurationResponse) string { return v.HostPort }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "7f0683f19d0531681e14b9aa6c424f77", "score": "0.43335935", "text": "func ForListeningPort(port nat.Port) *HostPortStrategy {\n\treturn NewHostPortStrategy(port)\n}", "title": "" }, { "docid": "e2cf46f4fc62522614d85eb42c739454", "score": "0.43239868", "text": "func (q QuarkusDetector) DoPortsDetection(component *model.Component, ctx *context.Context) {\n\t// check if port is set on env var\n\tports := getQuarkusPortsFromEnvs()\n\tif len(ports) > 0 {\n\t\tcomponent.Ports = ports\n\t\treturn\n\t}\n\t// check if port is set on .env file\n\tinsecureRequestEnabled := utils.GetStringValueFromEnvFile(component.Path, `QUARKUS_HTTP_INSECURE_REQUESTS=(\\w*)`)\n\tregexes := []string{`QUARKUS_HTTP_SSL_PORT=(\\d*)`}\n\tif insecureRequestEnabled != \"disabled\" {\n\t\tregexes = append(regexes, `QUARKUS_HTTP_PORT=(\\d*)`)\n\t}\n\tports = utils.GetPortValuesFromEnvFile(component.Path, regexes)\n\tif len(ports) > 0 {\n\t\tcomponent.Ports = ports\n\t\treturn\n\t}\n\n\tapplicationFile := utils.GetAnyApplicationFilePath(component.Path, []model.ApplicationFileInfo{\n\t\t{\n\t\t\tDir: \"src/main/resources\",\n\t\t\tFile: \"application.properties\",\n\t\t},\n\t\t{\n\t\t\tDir: \"src/main/resources\",\n\t\t\tFile: \"application.yml\",\n\t\t},\n\t\t{\n\t\t\tDir: \"src/main/resources\",\n\t\t\tFile: \"application.yaml\",\n\t\t},\n\t}, ctx)\n\tif applicationFile == \"\" {\n\t\treturn\n\t}\n\n\tvar err error\n\tif filepath.Ext(applicationFile) == \".yml\" || filepath.Ext(applicationFile) == \".yaml\" {\n\t\tports, err = getServerPortsFromQuarkusApplicationYamlFile(applicationFile)\n\t} else {\n\t\tports, err = getServerPortsFromQuarkusPropertiesFile(applicationFile)\n\t}\n\tif err != nil {\n\t\treturn\n\t}\n\tcomponent.Ports = ports\n}", "title": "" }, { "docid": "c5d4f4e1e643a19b2912fb56ce5470f4", "score": "0.43159315", "text": "func (o OpenLibertyDetector) DoPortsDetection(component *model.Component, ctx *context.Context) {\n\tbytes, err := utils.ReadAnyApplicationFile(component.Path, []model.ApplicationFileInfo{\n\t\t{\n\t\t\tDir: \"\",\n\t\t\tFile: \"server.xml\",\n\t\t},\n\t\t{\n\t\t\tDir: \"src/main/liberty/config\",\n\t\t\tFile: \"server.xml\",\n\t\t},\n\t}, ctx)\n\tif err != nil {\n\t\treturn\n\t}\n\tvar data ServerXml\n\terr = xml.Unmarshal(bytes, &data)\n\tif err != nil {\n\t\treturn\n\t}\n\tports := utils.GetValidPorts([]string{data.HttpEndpoint.HttpPort, data.HttpEndpoint.HttpsPort})\n\tif len(ports) > 0 {\n\t\tcomponent.Ports = ports\n\t}\n}", "title": "" }, { "docid": "edef3cb9df20263d0466108ff3b9dca3", "score": "0.4314635", "text": "func CheckDeployed(services []*config.Service) []Result {\n\tresultChan := make(chan Result)\n\n\tfor _, s := range services {\n\t\tgo func(service *config.Service) {\n\t\t\t// If service has no URL set, skip deploy check\n\t\t\tif service.URL == \"\" {\n\t\t\t\tlog.Printf(\"Skipping deploy check for %s because no URL is set\", color.Cyan(service.Name))\n\t\t\t\tresultChan <- Result{service, ErrNoDeployCheckURL}\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tlog.Printf(\"Checking %s for newly deployed version of %s\\n\", color.Blue(service.URL), color.Cyan(service.Name))\n\n\t\t\tfor {\n\t\t\t\ttime.Sleep(checkIntervalDuration)\n\n\t\t\t\tfetchedSha, err := fetchRevisionSha(service.URL)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Printf(\"Could not parse a Git SHA version from header or body at %s\\n\", color.Blue(service.URL))\n\t\t\t\t\tlog.Printf(\"Error: %v\", err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tlog.Printf(\"Got %s from %s\\n\", color.Magenta(fetchedSha), color.Blue(service.URL))\n\t\t\t\tif len(fetchedSha) > 7 && strings.HasPrefix(service.Gitsha, fetchedSha) {\n\t\t\t\t\tresultChan <- Result{Service: service}\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}(s)\n\t}\n\n\t// Set of service names that completed the deploy check\n\tcompletedServices := make(map[string]bool)\n\tvar results []Result\n\nloop:\n\tfor i := 0; i < len(services); i++ {\n\t\tselect {\n\t\tcase result := <-resultChan:\n\t\t\tif result.Err != nil {\n\t\t\t\tlog.Printf(\n\t\t\t\t\t\"Traffic showing version %s on %s, waiting for old versions to stop...\\n\",\n\t\t\t\t\tcolor.Green(result.Service.Gitsha),\n\t\t\t\t\tcolor.Cyan(result.Service.Name),\n\t\t\t\t)\n\t\t\t}\n\t\t\tcompletedServices[result.Service.Name] = true\n\t\t\tresults = append(results, result)\n\t\tcase <-time.After(timeoutDuration):\n\t\t\t// Stop looping, anything that didn't succeed has now failed\n\t\t\tbreak loop\n\t\t}\n\t}\n\n\t// Figure out which, if any, services timed out\n\tfor _, s := range services {\n\t\tcompleted := completedServices[s.Name]\n\t\tif !completed {\n\t\t\tresults = append(results, Result{s, ErrTimedOut})\n\t\t}\n\t}\n\n\treturn results\n}", "title": "" }, { "docid": "f26880c2c0278053f083de025b4af6e8", "score": "0.4305388", "text": "func validatePonsConfig(pons *PonPortsConfig) error {\n\n\tif pons.Number == 0 {\n\t\treturn fmt.Errorf(\"no-pon-ports\")\n\t}\n\n\tdefinedPorts := make([]int, pons.Number)\n\n\tfor rIndex, resRange := range pons.Ranges {\n\t\tif _, err := PonTechnologyFromString(resRange.Technology); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif resRange.PonRange.EndId < resRange.PonRange.StartId {\n\t\t\treturn fmt.Errorf(\"invalid-pon-ports-limits-in-range-%d\", rIndex)\n\t\t}\n\n\t\t//Keep track of the defined pons\n\t\tfor p := resRange.PonRange.StartId; p <= resRange.PonRange.EndId; p++ {\n\t\t\tif p > uint32(len(definedPorts)-1) {\n\t\t\t\treturn fmt.Errorf(\"pon-port-%d-in-range-%d-but-max-is-%d\", p, rIndex, pons.Number-1)\n\t\t\t}\n\t\t\tdefinedPorts[p]++\n\n\t\t\tif definedPorts[p] > 1 {\n\t\t\t\treturn fmt.Errorf(\"pon-port-%d-has-duplicate-definition-in-range-%d\", p, rIndex)\n\t\t\t}\n\t\t}\n\n\t\tif resRange.OnuRange.EndId < resRange.OnuRange.StartId {\n\t\t\treturn fmt.Errorf(\"invalid-onus-limits-in-range-%d\", rIndex)\n\t\t}\n\t\tif resRange.AllocIdRange.EndId < resRange.AllocIdRange.StartId {\n\t\t\treturn fmt.Errorf(\"invalid-allocid-limits-in-range-%d\", rIndex)\n\t\t}\n\t\tif resRange.GemportRange.EndId < resRange.GemportRange.StartId {\n\t\t\treturn fmt.Errorf(\"invalid-gemport-limits-in-range-%d\", rIndex)\n\t\t}\n\t}\n\n\t//Check if the ranges define all the pons\n\tfor i, num := range definedPorts {\n\t\tif num < 1 {\n\t\t\treturn fmt.Errorf(\"pon-port-%d-is-not-defined-in-ranges\", i)\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" } ]
92051cb512cb79e771bc47f76c44472c
sendDone is used to signal the end
[ { "docid": "c495e43d34f8cd2f4d5cd3c0be1012e6", "score": "0.71872205", "text": "func (qs *queryResponseStream) sendDone() error {\n\theader := responseHeader{\n\t\tSeq: qs.seq,\n\t\tError: \"\",\n\t}\n\trec := queryRecord{\n\t\tType: queryRecordDone,\n\t}\n\treturn qs.client.Send(&header, &rec)\n}", "title": "" } ]
[ { "docid": "4504fdab8fc37400b36fe40729d0e535", "score": "0.69037086", "text": "func (s *AppBase) sendDone() string {\n var err error\n if s.resultEvent == nil {\n Log.Print( \"debug AppBase::sendDone creating result event\" )\n s.resultEvent,_ = NewBaseEvent( EV_RESULT )\n s.resultEvent.SetBSuccess( true )\n } // if\n \n var strEvent string\n if strEvent,err = s.resultEvent.SerialiseToString(); err!=nil { Log.Print( \"WARN AppBase::sendDone failed to serialise: \", s.resultEvent.String(), \" err - \", err ) }\n s.resultEvent = nil\n return strEvent\n}", "title": "" }, { "docid": "f8ef149a155ce8277e1dd07d782ab1b4", "score": "0.68695354", "text": "func (b *bfxWebsocket) Done() <-chan struct{} { return b.mc.Done() }", "title": "" }, { "docid": "f8dc4290bcb236483e3caf55c4c5f056", "score": "0.6550814", "text": "func SendTransferFinished(payload []byte, addr *net.Addr) {\n\tsendUDPRequest(addr, payload, TRANSFER_FINISHED_MSG)\n}", "title": "" }, { "docid": "165436ea214653b204c343f15b6ad5cf", "score": "0.6525203", "text": "func (b *RequestBroker) done() {\n\tb.close()\n}", "title": "" }, { "docid": "15cddb3f66d80a3a43f04ae5868ce50c", "score": "0.651036", "text": "func (m EP) Done() <-chan struct{} { return m.DoneQ }", "title": "" }, { "docid": "5e2dee91e795319d2e762af956569e10", "score": "0.6507251", "text": "func (s *Server) WaitDone() {\n\t<-s.done\n}", "title": "" }, { "docid": "14b9fd112a156044d9b4015034a13540", "score": "0.65061295", "text": "func (s *Server) Done() {\n\ts.DoneCh <- true\n}", "title": "" }, { "docid": "b62724f2381bbd09c81aff729eace17a", "score": "0.6501986", "text": "func (b *Broker) Done() <-chan struct{} {\n\treturn b.stop\n}", "title": "" }, { "docid": "e7a66a4e82574d4cd9b190f31224cb5d", "score": "0.6384281", "text": "func (d *Dialer) Done() <-chan struct{} { return d.donec }", "title": "" }, { "docid": "571a35f734bbe391a57b96674ce57e7c", "score": "0.63433164", "text": "func (c *context) Done() <-chan struct{} { return c.c.Done() }", "title": "" }, { "docid": "ca6b2b547d5f44934ab7e91d3711dda0", "score": "0.6342234", "text": "func (br *breaker) Done() <-chan struct{} {\n\treturn br.signal\n}", "title": "" }, { "docid": "acf9ec95ef498421c8e1a42e1232da69", "score": "0.6310272", "text": "func (f *fakeCallCmd) Done() <-chan struct{} {\n\treturn closedChan\n}", "title": "" }, { "docid": "93a9fb09c3d9cafe3e80dcde5cbd2673", "score": "0.6259461", "text": "func (r *RPC) Done(done *Done, rep *bool) error {\n\t*rep = true\n\tr.onDone(done.Src, done.Dst)\n\treturn nil\n}", "title": "" }, { "docid": "1a202402638929928a967d47fdcefc31", "score": "0.6237323", "text": "func (w *Waiter) Done() {\n\tw.w <- struct{}{}\n}", "title": "" }, { "docid": "45d7bcaa23585c046bd19fa603c60354", "score": "0.6232745", "text": "func (cb *ConnectorBuffered) Done() {\n\tclose(cb.Quit)\n\tcb.conn.Close()\n}", "title": "" }, { "docid": "25f1c9a8331cfaaaed4ef356e7b5fbb8", "score": "0.6174816", "text": "func (re *remoteEntity) Send(done chan interface{}) {\n}", "title": "" }, { "docid": "96df2bb198f5ada7605a4816f606e8f0", "score": "0.61745113", "text": "func (p *AsyncAppend) Done() <-chan struct{} { return p.commitCh }", "title": "" }, { "docid": "546766b49b51a49229568b4c0baeeef2", "score": "0.6141906", "text": "func (s *server) Done(err error) {\n\tvar errStr string\n\tif err == nil {\n\t\terrStr = \"\"\n\t} else {\n\t\terrStr = err.Error()\n\t}\n\ts.Send(ErrType, errStr)\n}", "title": "" }, { "docid": "fcc11f6245040e9a3cea64025e302d08", "score": "0.60994273", "text": "func (ui *chatUI) end() {\n\tui.doneCh <- struct{}{}\n}", "title": "" }, { "docid": "d2dfe8a2da70ef58eafc660564786697", "score": "0.60963875", "text": "func (q *blockQueue) done() <-chan struct{} {\n\treturn q.doneCh\n}", "title": "" }, { "docid": "9217a1f199a3562c2ce212865535c119", "score": "0.60784215", "text": "func (handler *listenerHandler) Done() <-chan struct{} {\n\treturn handler.done\n}", "title": "" }, { "docid": "9217a1f199a3562c2ce212865535c119", "score": "0.60784215", "text": "func (handler *listenerHandler) Done() <-chan struct{} {\n\treturn handler.done\n}", "title": "" }, { "docid": "69d5661cc1bb740efbfac71ddfe96f9c", "score": "0.6075026", "text": "func (l *websocketImpl) Done() <-chan bool {\n\treturn l.stop\n}", "title": "" }, { "docid": "d9f2c1ab62d33d84f1d7b43316acc5c4", "score": "0.6071341", "text": "func (t *Transport) Done() chan struct{} {\n\treturn t.stopchan\n}", "title": "" }, { "docid": "7e30d78c33b23c9f12318cf56c86dad8", "score": "0.604307", "text": "func (p *pool) workerDone() {\n\tp.doneWorker <- struct{}{}\n}", "title": "" }, { "docid": "7e30d78c33b23c9f12318cf56c86dad8", "score": "0.604307", "text": "func (p *pool) workerDone() {\n\tp.doneWorker <- struct{}{}\n}", "title": "" }, { "docid": "a761ca588560849abb567872127235f6", "score": "0.60274506", "text": "func (c ctxWithoutCancel) Done() <-chan struct{} { return nil }", "title": "" }, { "docid": "7043ba2af935334431c4ad93005a81bc", "score": "0.597843", "text": "func (rs *RPCServer) Done() <-chan error {\n\treturn rs.server.DoneCh\n}", "title": "" }, { "docid": "50672283b56bca60d8954dbd05a6e02c", "score": "0.5977048", "text": "func (it *streamingMessageIterator) done(ackID string, ack bool) {\n\tit.mu.Lock()\n\tdefer it.mu.Unlock()\n\tdelete(it.keepAliveDeadlines, ackID)\n\tif ack {\n\t\tit.pendingReq.AckIds = append(it.pendingReq.AckIds, ackID)\n\t} else {\n\t\tit.addDeadlineMod(ackID, 0) // Nack indicated by modifying the deadline to zero.\n\t}\n\tit.checkDrained()\n}", "title": "" }, { "docid": "8c33e50aa30884251cc790cd61df1376", "score": "0.5972727", "text": "func (c *Concurrent) Done() {\n c.wait.Done()\n <-c.channel\n}", "title": "" }, { "docid": "7083140cc2d98ae57b39bd1ad608fb94", "score": "0.59614605", "text": "func (w *Wait) Done() {\n\tw.wg.Done()\n}", "title": "" }, { "docid": "4cf63dfc197aa4fc34a42daf7c1b6b6c", "score": "0.59279406", "text": "func (k *Executor) Done() <-chan struct{} {\n\treturn k.terminate\n}", "title": "" }, { "docid": "ec30c7177f465f3b53a8adb9e9feb842", "score": "0.5876453", "text": "func (c *chanS) Done(d uintptr) {\n\tfence.RW_SMP() // Done has RELEASE semantic.\n\tatomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(d)), nil)\n\tc.event.Send()\n}", "title": "" }, { "docid": "5261836dbaa33bd3f5ebed26aed7f683", "score": "0.58693945", "text": "func (eip *EventInProgress) Done() {\n\teip.doneFunc(eip.loggables) // create final event with extra data\n}", "title": "" }, { "docid": "a9905c0a30ee55ce02b899be8caedb61", "score": "0.5867548", "text": "func (br *BlockHashesReceiver) finishReceiver() {\n\tbr.status = receiverStatusFinished\n\tbr.peer.ConsumeRequest(br.requestID)\n}", "title": "" }, { "docid": "e0d1735cc5d7e349c639830c51016f49", "score": "0.5867348", "text": "func (b *blockManager) DonePeer(sp *ServerPeer) {\n\t// Ignore if we are shutting down.\n\tif atomic.LoadInt32(&b.shutdown) != 0 {\n\t\treturn\n\t}\n\n\tselect {\n\tcase b.peerChan <- &donePeerMsg{peer: sp}:\n\tcase <-b.quit:\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "29368df8edf4af1a1500f5a3f7ca41ee", "score": "0.58417577", "text": "func worker(done chan bool) {\n fmt.Println(\"working...\")\n time.Sleep(time.Second)\n fmt.Println(\"done\")\n\n // send a value to notify that we're done\n done <- true\n}", "title": "" }, { "docid": "58d5345bfb570529b6d0aed22ecef148", "score": "0.58254206", "text": "func (r *Receiver[T]) finalize() {\n\tclose(r.done)\n}", "title": "" }, { "docid": "1a2ebc42487fec77ddfb05ea0b322d22", "score": "0.58133763", "text": "func (px *Paxos) Done(seq int) {\n\t// Your code here.\n\n\tpx.mu.Lock()\n\tdefer px.mu.Unlock()\n\n\tif seq > px.done[px.peers[px.me]] {\n\t\tpx.done[px.peers[px.me]] = seq\n\t}\n}", "title": "" }, { "docid": "2ecabe7850fc4a324ec50506c0f0e791", "score": "0.5806545", "text": "func (m *AlerterMock) MinimockSendDone() bool {\n\tfor _, e := range m.SendMock.expectations {\n\t\tif mm_atomic.LoadUint64(&e.Counter) < 1 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// if default expectation was set then invocations count should be greater than zero\n\tif m.SendMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSendCounter) < 1 {\n\t\treturn false\n\t}\n\t// if func was set then invocations count should be greater than zero\n\tif m.funcSend != nil && mm_atomic.LoadUint64(&m.afterSendCounter) < 1 {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "04e7957e6753a1eecf2e55a2ad3e3d01", "score": "0.57905906", "text": "func (br *contextBreaker) Done() <-chan struct{} {\n\treturn br.signal\n}", "title": "" }, { "docid": "c0646131718ac4b4b3fd2830580936dc", "score": "0.57888776", "text": "func (vc *vdiskCompletion) Done() {\n\tvc.wg.Done()\n}", "title": "" }, { "docid": "beb54416df2b3d2a7045e2396988f5f7", "score": "0.57873166", "text": "func (msg *message) Complete() bool { return msg.End }", "title": "" }, { "docid": "436af5572b015cf2bbcd835ef5f499c5", "score": "0.5775878", "text": "func SendDoneRequest(packetCount uint64, ip string) error {\n\theaders := map[string]string{\"Command-Type\": \"Done\",\n\t\t\"Requester-IP\": MyIP + \":\" + myTCPPort,\n\t\t\"Packets\": strconv.FormatUint(packetCount, 10)}\n\n\t_, err := sendRequest(nil, &headers, ip)\n\tif err != nil {\n\t\t// log.Println(\"SendDoneRequest : \", err)\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "05296528a6b43449acff2f92264f0c94", "score": "0.5768108", "text": "func (c *Correctable) Done() <-chan struct{} {\n\treturn c.donech\n}", "title": "" }, { "docid": "8420b659053c026b81c24d5f98be8118", "score": "0.5752925", "text": "func (s *Tester) Done() {\n\terr := s.Client.CC.Close()\n\tlogging.OnError(err).Error(\"integration tester client close\")\n\n\ts.Shutdown <- os.Interrupt\n\ts.wg.Wait()\n}", "title": "" }, { "docid": "d8479d43dac3195d16dc35e3a1024883", "score": "0.5751793", "text": "func (res *Response) End(s ...interface{}) {\n\tfor i := range s {\n\t\tres.Send(s[i])\n\t}\n\tres.isComplete = true\n}", "title": "" }, { "docid": "7233b52d1424adb74a9bd26f86c499e8", "score": "0.5751664", "text": "func (ctx *Context) Done() <-chan struct{} {\n\treturn nil\n}", "title": "" }, { "docid": "c2fff87f1419a37d6f5f9411d393285e", "score": "0.5748045", "text": "func (cml *ContextMessageLayer) Done() <-chan struct{} {\n\treturn wsContext.Done()\n}", "title": "" }, { "docid": "ad59a737753d8f825194e3d012b738a3", "score": "0.57446843", "text": "func (is *InfoSyncer) Done() <-chan struct{} {\n\tif is.etcdCli == nil {\n\t\treturn make(chan struct{}, 1)\n\t}\n\treturn is.session.Done()\n}", "title": "" }, { "docid": "5ca4682294d4b747de841f45e929d5e0", "score": "0.5744633", "text": "func (c *Chain) Done() {\n\tc.blkGenerator.close()\n}", "title": "" }, { "docid": "c88eeea7006db552e101b2ce8d00c3c2", "score": "0.57429886", "text": "func (px *Paxos) Done(seq int) {\n\t// Your code here.\n\tfor me, peer := range px.peers {\n\t\tgo func(me int, peer string) {\n\t\t\targs := &SeqArgs{Seq: seq, Sender: px.me}\n\t\t\tvar reply SeqReply\n\t\t\tif me != px.me {\n\t\t\t\tutil.Call(\"unix\", peer, \"Paxos.UpdateDoneSeqs\", args, &reply)\n\t\t\t} else {\n\t\t\t\t// the same reason using local invocation instead of RPC\n\t\t\t\tpx.UpdateDoneSeqs(args, &reply)\n\t\t\t}\n\t\t}(me, peer)\n\t}\n}", "title": "" }, { "docid": "56b2fa6ad83cdc816dacb50292de10a4", "score": "0.57403874", "text": "func (mgr *syncManager) OnPeerDone(cp *connection.ConnPeer, t config.NodeType) {\n\tmgr.actorCtx.Send(mgr.worker, message.NewEvent(evtDonePeer, &peerMail{connPeer: cp, nodeType: t}), nil)\n}", "title": "" }, { "docid": "76a6b78da25e90d31e26690d8cf26f92", "score": "0.57368946", "text": "func (sm *SyncManager) handleDonePeerMsg(peer *peer.Peer) {\n\tsm.clearSyncPeerState(peer)\n\n\t// Attempt to find a new peer to sync from if the quitting peer is the\n\t// sync peer. Also, reset the headers-first state if in headers-first\n\t// mode so\n\tif sm.syncPeer == peer {\n\t\tsm.syncPeer = nil\n\t\tsm.startSync()\n\t}\n}", "title": "" }, { "docid": "d5183458710e70c645dff780e55a621a", "score": "0.5730033", "text": "func (m *MockCloudSpanner) Done() {\n\tclose(m.msgs)\n}", "title": "" }, { "docid": "1d555fbc535040e4d5070620309b567c", "score": "0.5721088", "text": "func (dc *DoneChan) Done() chan lang.PlaceholderType {\n\treturn dc.done\n}", "title": "" }, { "docid": "7ca43b7f36e4bccf00b5db7cb0c004fc", "score": "0.5713005", "text": "func (v *Virtual) Done() {\n\tfor h, _ := range v.generator {\n\t\tv.DetachGenerator(h)\n\t}\n\tv.DetachFallbackGenerator()\n\tclose(v.receive)\n}", "title": "" }, { "docid": "088e1c28815ead1e3e9eacce0ba944f7", "score": "0.57119524", "text": "func (h *DataJobHandler) Done() {\n\tfor {\n\t\thandleEnd := true\n\t\th.chanMap.Range(func(key, value interface{}) bool {\n\t\t\tunboundedChan, ok := value.(chanx.UnboundedChan)\n\t\t\tif !ok {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif unboundedChan.Len() != 0 {\n\t\t\t\thandleEnd = false\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\t\tif handleEnd {\n\t\t\tbreak\n\t\t}\n\t}\n\th.stopCancel()\n}", "title": "" }, { "docid": "ad333124394347533af896c5f4bd051b", "score": "0.56964874", "text": "func (c *C) Done() {\n\tc.wg.Done()\n\t<-c.ch\n}", "title": "" }, { "docid": "832d1f80660f6305ab25145a14081ee8", "score": "0.56951594", "text": "func worker(done chan bool) {\n fmt.Print(\"working...\")\n time.Sleep(time.Second)\n fmt.Println(\"done\")\n\n // Send a value to notify that worker is done.\n done <- true\n}", "title": "" }, { "docid": "454a201bf19b79ac8f012e6db41828fb", "score": "0.56943285", "text": "func (r *Room) Done() <-chan struct{} {\n\treturn r.done\n}", "title": "" }, { "docid": "80fd3b5a4389a4ac3732cc3387e82927", "score": "0.56882703", "text": "func (o *Server) shutdownFinished() {\n\ttime.Sleep(10 * time.Millisecond)\n\tclose(o.ShutdownComplete)\n}", "title": "" }, { "docid": "f6d92f00842f7894fcf66da73a0fe8a0", "score": "0.5672422", "text": "func (prod *SimpleProducer) WorkerDone() {\n\tprod.runState.WorkerDone()\n}", "title": "" }, { "docid": "b33d1422e4e7730debbf9dc00a4d899a", "score": "0.56689775", "text": "func (c *Context) Done() <-chan struct{} {\n\treturn nil\n}", "title": "" }, { "docid": "0616e594692eaef823da25a9abf1da9f", "score": "0.5661192", "text": "func (c Client) Done(src, dst addr.IA) error {\n\tclient, err := rpc.DialHTTP(\"unix\", c.Socket)\n\tif err != nil {\n\t\treturn err\n\t}\n\targs := &Done{Src: src, Dst: dst}\n\tvar ignore bool\n\treturn client.Call(\"RPC.Done\", args, &ignore)\n}", "title": "" }, { "docid": "d93943e04e2e1d47ca69835fe8d76f76", "score": "0.5656855", "text": "func (c *Client) Done() <-chan struct{} {\n\treturn c.done\n}", "title": "" }, { "docid": "2d35118663c3218ca58b384ac0c40ba4", "score": "0.56561124", "text": "func (i *inflight) done(keys []jose.JSONWebKey, err error) {\n\ti.keys = keys\n\ti.err = err\n\tclose(i.doneCh)\n}", "title": "" }, { "docid": "8be8cf788bbb9e167646f6c4cd1afb0f", "score": "0.5655619", "text": "func (actor *localActor) Done() <-chan struct{} {\n\treturn actor.ctx.Done()\n}", "title": "" }, { "docid": "7228e650c1a16feae48ddb177348c453", "score": "0.5639288", "text": "func (t *TerminalSession) Done() {\n\tclose(t.doneChan)\n}", "title": "" }, { "docid": "db2b5e7f4075c30b630107a7888be332", "score": "0.5632707", "text": "func (f *Flag) Done() <-chan struct{} {\n\treturn f.ch\n}", "title": "" }, { "docid": "541c91ae775ec893dd383cbceb369a85", "score": "0.562253", "text": "func (p *Process) Done() { p.Kill() }", "title": "" }, { "docid": "541c91ae775ec893dd383cbceb369a85", "score": "0.562253", "text": "func (p *Process) Done() { p.Kill() }", "title": "" }, { "docid": "1acf633be054a61b5cfd7fdd7b689be8", "score": "0.5611657", "text": "func (api *WebSocketAPI) SendFinish(finish *submarine_battle.Finish) error {\n\tmessage, err := typhenapi.NewMessage(api.serializer, MessageType_Finish, finish)\n\n\tif err != nil {\n\t\tif api.errorHandler != nil {\n\t\t\tapi.errorHandler(err)\n\t\t}\n\t\treturn err\n\t}\n\n\tif err := api.session.Send(message.Bytes()); err != nil {\n\t\tif api.errorHandler != nil {\n\t\t\tapi.errorHandler(err)\n\t\t}\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "cd4cd31a0a0daaf5c026b54b81ce9c50", "score": "0.56100523", "text": "func (t *WriteTransaction) end() error {\n\treturn t.client.CloseSend()\n}", "title": "" }, { "docid": "884a71b34035f7cdee5726e041ea9a42", "score": "0.5610029", "text": "func (p *ClientTicket) finish() {\n}", "title": "" }, { "docid": "a00e4fd40ccd9e1c9d99237e19cda6d9", "score": "0.5608395", "text": "func (r *Receiver[Elem]) finalize() {\n\tclose(r.done)\n}", "title": "" }, { "docid": "3a91d9cc694daef2fa4a996cc6a4503e", "score": "0.56056327", "text": "func (m *Message) Done() {\n\tif m.wg != nil {\n\t\tm.wg.Done()\n\t}\n}", "title": "" }, { "docid": "ec3e8d7238bdab92dbd556b61ef743a8", "score": "0.55957866", "text": "func (d detachedContext) Done() <-chan struct{} {\n\treturn nil\n}", "title": "" }, { "docid": "4e80f2f3bde662875fc54a706a6a3ba2", "score": "0.55909854", "text": "func (fst *Filestore) Done() <-chan struct{} {\n\treturn fst.doneCh\n}", "title": "" }, { "docid": "1adac679627e6cbb1d441666834fbd9c", "score": "0.5586563", "text": "func (b *Bootstrap) done() {\n\t// make sure background thread is done but if channel is blocked go on\n\tselect {\n\tcase b.stop <- true:\n\tdefault:\n\t}\n\t// store up to date tox information\n\terr := b.Store()\n\tif err != nil {\n\t\tlog.Println(\"Failed to store:\", err)\n\t\t// warn but continue to execute everything\n\t}\n\t// notify of done\n\tif b.onDone != nil {\n\t\tb.onDone()\n\t} else {\n\t\tlog.Println(\"onDone is nil!\")\n\t}\n}", "title": "" }, { "docid": "38725c54fb82067fdc50302ff33b9759", "score": "0.55823636", "text": "func (in *instance) signalDone(tainr *types.Container) error {\n\tpods, err := in.getPods(tainr)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn exec.RemoteCmd(exec.Request{\n\t\tClient: in.cli,\n\t\tRestConfig: in.cfg,\n\t\tPod: pods[0],\n\t\tContainer: \"setup\",\n\t\tCmd: []string{\"touch\", \"/tmp/done\"},\n\t\tStderr: os.Stderr,\n\t})\n}", "title": "" }, { "docid": "d6745f423f07e6818d10d60ff720fd84", "score": "0.55792224", "text": "func (tx *Tx) Done() <-chan TxResult {\n\treturn tx.done\n}", "title": "" }, { "docid": "87553ba29ca73cb9e1eb38ed9439a468", "score": "0.5579122", "text": "func (client *Client) send() {\n\t// This method needs to close client.rw when the client is stopped.\n\t// It takes responsibility for this to prevent writing to rw when it is closed (by someone else).\n\tdefer client.rw.Close()\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlog.Printf(\"Error sending data from client handler to %s: %s\\n\", client, r)\n\t\t}\n\t\tlog.Printf(\"Stopping pipe from client handler to %s\\n\", client)\n\t}()\n\tlog.Printf(\"Starting pipe from client handler to %s\\n\", client)\n\n\tfor data := range client.Send {\n\t\t// Keep sending till data is empty, or there is an error\n\t\tfor len(data) > 0 {\n\t\t\tn, err := client.rw.Write(data)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"Error sending data to client %s: %s\\n\", client, err)\n\t\t\t\tclient.Stop(\"Send error\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif n > len(data) {\n\t\t\t\t// Shouldn't happen, but if it does, data would be indexed out of bounds\n\t\t\t\tn = len(data)\n\t\t\t}\n\n\t\t\tdata = data[n:]\n\t\t}\n\t}\n}", "title": "" }, { "docid": "5ca9c978a0490dd405ea8297f56a46be", "score": "0.55692506", "text": "func (pf *PF) WaitFinish() {\n\t<-pf.finish\n}", "title": "" }, { "docid": "f1a8a7f42a259adca2bbd58053fc733f", "score": "0.5569151", "text": "func worker(done chan<- bool) {\n fmt.Print(\"Working...\")\n time.Sleep(time.Second)\n fmt.Println(\" done\")\n\n // Send a value to notify that the work is done.\n done <- true\n}", "title": "" }, { "docid": "c330eec7798ca133a26d64a864770d72", "score": "0.55635107", "text": "func (sm *SyncManager) DonePeer(peer *peer.Peer) {\n\t// Ignore if we are shutting down.\n\tif atomic.LoadInt32(&sm.shutdown) != 0 {\n\t\treturn\n\t}\n\n\tsm.processBusinessChan <- &donePeerMsg{peer: peer}\n}", "title": "" }, { "docid": "5089b75595d2ce82a9503c906882824f", "score": "0.55550086", "text": "func (c *Client) Done() <-chan struct{} {\n\treturn c.ctx.Done()\n}", "title": "" }, { "docid": "cc3c67fc17415e86ac5186cc04ba6d64", "score": "0.5554172", "text": "func (m *MessageBusMock) MinimockSendDone() bool {\n\tfor _, e := range m.SendMock.expectations {\n\t\tif mm_atomic.LoadUint64(&e.Counter) < 1 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// if default expectation was set then invocations count should be greater than zero\n\tif m.SendMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSendCounter) < 1 {\n\t\treturn false\n\t}\n\t// if func was set then invocations count should be greater than zero\n\tif m.funcSend != nil && mm_atomic.LoadUint64(&m.afterSendCounter) < 1 {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "0326e7d04261ee3c618d99fc00ea4c14", "score": "0.5553082", "text": "func worker_end(wch *chan int64){\n\t<-(*wch)\n}", "title": "" }, { "docid": "735ec460ade580c70578a70708b02e7d", "score": "0.5552082", "text": "func (f TxnSenderFunc) OnFinish(_ func(error)) { panic(\"unimplemented\") }", "title": "" }, { "docid": "f6d4d4cd6c616bde15bf7b2b7f88d764", "score": "0.5528736", "text": "func (sm *SyncManager) DonePeer(peer *peerpkg.Peer) {\n\t// Ignore if we are shutting down.\n\tif atomic.LoadInt32(&sm.shutdown) != 0 {\n\t\treturn\n\t}\n\n\tsm.msgChan <- &donePeerMsg{peer: peer}\n}", "title": "" }, { "docid": "26b232446a719902d92e9507e5ea2cde", "score": "0.5522731", "text": "func (c *Connection) sendHandler() {\n\t// TODO\n\t// . check QoS\n\t// . error handler function\n\tconst fn string = \"sendHandler\"\n\tfor packet := range c.SendChan {\n\t\terr := c.send(packet)\n\t\tif err != nil {\n\t\t\tlogger.FDebug(fn, \"- [Connection] unable to send packet. error:\", err)\n\t\t\tbreak\n\t\t}\n\t}\n\tlogger.FInfo(fn, \"+ [Connection] signaling done to work group.\")\n\tc.corous.Done()\n}", "title": "" }, { "docid": "6a92b6e3c1ffe278374c5add6927a22d", "score": "0.55182815", "text": "func (p *archivePcapOp) Done() <-chan struct{} {\n\treturn p.done\n}", "title": "" }, { "docid": "7c52ad6893e9697da1c5f982dc90d584", "score": "0.55141306", "text": "func (t *Traffic) Done() (done <-chan struct{}) {\n\treturn t.done\n}", "title": "" }, { "docid": "cbc1a164d7a148431c97e7e9d89b3a9b", "score": "0.5513511", "text": "func (pool *listenerPool) Done() <-chan struct{} {\n\treturn pool.done\n}", "title": "" }, { "docid": "cbc1a164d7a148431c97e7e9d89b3a9b", "score": "0.5513511", "text": "func (pool *listenerPool) Done() <-chan struct{} {\n\treturn pool.done\n}", "title": "" }, { "docid": "60473bfe8d03a470f8fd4a258e54607b", "score": "0.54969084", "text": "func (c *Client) Done() <-chan struct{} {\n\treturn c.Conn.Done()\n}", "title": "" }, { "docid": "5771c56837856af958f4f309706b7b00", "score": "0.5487944", "text": "func (c *closeHelper) Done() error {\n\treturn c.err\n}", "title": "" }, { "docid": "d625325acd9c0bcd1754b3118930a6d7", "score": "0.5486072", "text": "func (m *Message) Finish() {\n\tm.Message.Finish()\n}", "title": "" }, { "docid": "fe987edde9f182d02c9d23da98d9d74b", "score": "0.5484715", "text": "func (l *FreeLooper) Done(err error) {\n\tif l.DoneChan != nil {\n\t\tl.DoneChan <- err\n\t}\n}", "title": "" } ]
7327725327a11690f5cdfa7d938e1298
RefreshResources Gets the agent and dataplane resources from API server
[ { "docid": "689c7be08f7d752dace4f3b03894a6f2", "score": "0.8325135", "text": "func RefreshResources() error {\n\t// IMP - To be removed once the model is in production\n\tif agent.cfg.GetAgentName() == \"\" {\n\t\treturn nil\n\t}\n\n\tvar err error\n\tagent.agentResource, err = getAgentResource()\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Get Dataplane Resources\n\tagent.dataplaneResource, err = getDataplaneResource(agent.agentResource)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" } ]
[ { "docid": "9cbb13da2ba67ce87808e962cd7d8093", "score": "0.5921414", "text": "func (s *Slurm) Resources(_ context.Context, req *api.ResourcesRequest) (*api.ResourcesResponse, error) {\n\tslurmResources, err := s.client.Resources(req.Partition)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"could not get resources for partition %s\", req.Partition)\n\t}\n\n\tpartitionResources := s.cfg[req.Partition]\n\tresponse := &api.ResourcesResponse{\n\t\tNodes: partitionResources.Nodes,\n\t\tCpuPerNode: partitionResources.CPUPerNode,\n\t\tMemPerNode: partitionResources.MemPerNode,\n\t\tWallTime: int64(partitionResources.WallTime.Seconds()),\n\t}\n\n\tfor _, f := range slurmResources.Features {\n\t\tresponse.Features = append(response.Features, &api.Feature{\n\t\t\tName: f.Name,\n\t\t\tVersion: f.Version,\n\t\t\tQuantity: f.Quantity,\n\t\t})\n\t}\n\tfor _, f := range partitionResources.AdditionalFeatures {\n\t\tresponse.Features = append(response.Features, &api.Feature{\n\t\t\tName: f.Name,\n\t\t\tVersion: f.Version,\n\t\t\tQuantity: f.Quantity,\n\t\t})\n\t}\n\n\tif partitionResources.AutoNodes || response.Nodes == 0 {\n\t\tresponse.Nodes = slurmResources.Nodes\n\t}\n\tif partitionResources.AutoCPUPerNode || response.CpuPerNode == 0 {\n\t\tresponse.CpuPerNode = slurmResources.CPUPerNode\n\t}\n\tif partitionResources.AutoMemPerNode || response.MemPerNode == 0 {\n\t\tresponse.MemPerNode = slurmResources.MemPerNode\n\t}\n\tif partitionResources.AutoWallTime || response.WallTime == 0 {\n\t\tresponse.WallTime = int64(slurmResources.WallTime.Seconds())\n\t}\n\n\treturn response, nil\n}", "title": "" }, { "docid": "d60f11f61c65a8c90aaaa86c29a836f4", "score": "0.5807108", "text": "func (rest *RestAPI) UnloadResources() {\n}", "title": "" }, { "docid": "eb384cb73acb5a706a97ea6965325145", "score": "0.5805887", "text": "func collectCRDResources(discovery discovery.DiscoveryInterface) ([]*metav1.APIResourceList, error) {\n\tresources, err := discovery.ServerResources()\n\tcrdResources := []*metav1.APIResourceList{}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, res := range resources {\n\t\tgv, err := schema.ParseGroupVersion(res.GroupVersion)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tif gv.Group != \"apiextensions.k8s.io\" {\n\t\t\tcontinue\n\t\t}\n\t\temptyAPIResourceList := metav1.APIResourceList{\n\t\t\tGroupVersion: res.GroupVersion,\n\t\t}\n\t\temptyAPIResourceList.APIResources = findCRDGVRs(res.APIResources)\n\t\tcrdResources = append(crdResources, &emptyAPIResourceList)\n\t}\n\n\treturn crdResources, nil\n}", "title": "" }, { "docid": "6cea1a9498ee85bb5a5df65c26f6de83", "score": "0.58057505", "text": "func getAvailableResources(clientBuilder corecontroller.ClientBuilder) (map[schema.GroupVersionResource]bool, error) {\n\tvar discoveryClient discovery.DiscoveryInterface\n\n\tvar healthzContent string\n\t// If apiserver is not running we should wait for some time and fail only then. This is particularly\n\t// important when we start apiserver and controller manager at the same time.\n\terr := wait.PollImmediate(time.Second, 10*time.Second, func() (bool, error) {\n\t\tclient, err := clientBuilder.Client(\"controller-discovery\")\n\t\tif err != nil {\n\t\t\tklog.Errorf(\"Failed to get api versions from server: %v\", err)\n\t\t\treturn false, nil\n\t\t}\n\n\t\thealthStatus := 0\n\t\tresp := client.Discovery().RESTClient().Get().AbsPath(\"/healthz\").Do(context.TODO()).StatusCode(&healthStatus)\n\t\tif healthStatus != http.StatusOK {\n\t\t\tklog.Errorf(\"Server isn't healthy yet. Waiting a little while.\")\n\t\t\treturn false, nil\n\t\t}\n\t\tcontent, _ := resp.Raw()\n\t\thealthzContent = string(content)\n\n\t\tdiscoveryClient = client.Discovery()\n\t\treturn true, nil\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get api versions from server: %v: %v\", healthzContent, err)\n\t}\n\n\tresourceMap, err := discoveryClient.ServerResources()\n\tif err != nil {\n\t\tutilruntime.HandleError(fmt.Errorf(\"unable to get all supported resources from server: %v\", err))\n\t}\n\tif len(resourceMap) == 0 {\n\t\treturn nil, fmt.Errorf(\"unable to get any supported resources from server\")\n\t}\n\n\tallResources := map[schema.GroupVersionResource]bool{}\n\tfor _, apiResourceList := range resourceMap {\n\t\tversion, err := schema.ParseGroupVersion(apiResourceList.GroupVersion)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tfor _, apiResource := range apiResourceList.APIResources {\n\t\t\tallResources[version.WithResource(apiResource.Name)] = true\n\t\t}\n\t}\n\n\treturn allResources, nil\n}", "title": "" }, { "docid": "759d824b88354038f9d9250de1838117", "score": "0.57456744", "text": "func (c *APIGatewayConfiguration) ApplyResources(dataplaneResource *v1.ResourceInstance, agentResource *v1.ResourceInstance) error {\n\tdp := &v1alpha1.EdgeDataplane{}\n\terr := dp.FromInstance(dataplaneResource)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tda := &v1alpha1.EdgeTraceabilityAgent{}\n\terr = da.FromInstance(agentResource)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcfgFromRes, err := createFromResources(dp, da)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Check if local config not set to default and resource is non default use the config from res\n\tif c.Host == \"localhost\" && cfgFromRes.Host != \"localhost\" {\n\t\tc.Host = cfgFromRes.Host\n\t}\n\tif c.Port == 8090 && cfgFromRes.Port != 8090 {\n\t\tc.Port = cfgFromRes.Port\n\t}\n\tif c.PollInterval == 1*time.Minute && cfgFromRes.PollInterval != 1*time.Minute {\n\t\tc.PollInterval = cfgFromRes.PollInterval\n\t}\n\tif c.EnableAPICalls && !cfgFromRes.EnableAPICalls {\n\t\tc.EnableAPICalls = cfgFromRes.EnableAPICalls\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "02a463782f4bfae5ebf9504da097b588", "score": "0.56893986", "text": "func (r *ResourceWatcher) DumpAPIResources() error {\n\tresourceName := \"apiresources\"\n\tdestDir := path.Join(r.storeConfig.CacheDir, r.storeConfig.ClusterDir)\n\terr := util.WriteStringToFile(k8sresources.APIResourceHeader, destDir, resourceName, \"header\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar res strings.Builder\n\tresourceLists, _ := r.clientset.Discovery().ServerPreferredResources()\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, resourceList := range resourceLists {\n\t\tfor _, apiResource := range resourceList.APIResources {\n\t\t\ta := k8sresources.APIResource{}\n\t\t\ta.FromAPIResource(apiResource, resourceList)\n\t\t\t_, err := res.WriteString(a.ToString())\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\terr = util.WriteStringToFile(res.String(), destDir, resourceName, \"resource\")\n\treturn err\n}", "title": "" }, { "docid": "644ec0d901ee1a60db03fec3d0b078ae", "score": "0.56128556", "text": "func (vm *VirtualMachine) Refresh(client SkytapClient) (RunstateAwareResource, error) {\n\treturn GetVirtualMachine(client, vm.Id)\n}", "title": "" }, { "docid": "f5bef951c99e329e2cee5af201cf113b", "score": "0.5505697", "text": "func (r *Resource) refresh() (interface{}, error) {\n\tc := &http.Client{}\n\n\t// TODO: Figure out if we should be setting the body (3rd) parameter\n\treq, err := http.NewRequest(\"GET\", r.URI.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Set(\"Accept\", r.ContentType)\n\n\tfor k, v := range r.nextRefreshHeaders {\n\t\treq.Header.Set(k, v)\n\t}\n\n\tresp, err := c.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer resp.Body.Close()\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tr.Representor, err = representor.CreateFromResponse(*r.URI, *resp, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn r.Representor.GetBody(), nil\n}", "title": "" }, { "docid": "df5b8861e66fc49efa20dd3d8ed4b20f", "score": "0.54820335", "text": "func (router *Router) getResources(w http.ResponseWriter, r *http.Request) {\n\tclusterNames := r.URL.Query()[\"cluster\"]\n\tnamespaces := r.URL.Query()[\"namespace\"]\n\tname := r.URL.Query().Get(\"name\")\n\tresource := r.URL.Query().Get(\"resource\")\n\tpath := r.URL.Query().Get(\"path\")\n\tparamName := r.URL.Query().Get(\"paramName\")\n\tparam := r.URL.Query().Get(\"param\")\n\n\tlog.WithFields(logrus.Fields{\"clusters\": clusterNames, \"namespaces\": namespaces, \"name\": name, \"resource\": resource, \"path\": path, \"paramName\": paramName, \"param\": param}).Tracef(\"getResources\")\n\n\tvar resources []Resources\n\n\t// Loop through all the given cluster names and get for each provided name the cluster interface. After that we\n\t// check if the resource was provided via the forbidden resources list.\n\tfor _, clusterName := range clusterNames {\n\t\tcluster := router.clusters.GetCluster(clusterName)\n\t\tif cluster == nil {\n\t\t\terrresponse.Render(w, r, nil, http.StatusBadRequest, \"Invalid cluster name\")\n\t\t\treturn\n\t\t}\n\n\t\tif router.isForbidden(resource) {\n\t\t\terrresponse.Render(w, r, nil, http.StatusForbidden, fmt.Sprintf(\"Access for resource %s is forbidding\", resource))\n\t\t\treturn\n\t\t}\n\n\t\t// If the namespaces slice is nil, we retrieve the resource for all namespaces. If a list of namespaces was\n\t\t// provided we loop through all the namespaces and return the resources for these namespaces. All results are\n\t\t// added to the resources slice, which is then returned by the api.\n\t\tif namespaces == nil {\n\t\t\tlist, err := cluster.GetResources(r.Context(), \"\", name, path, resource, paramName, param)\n\t\t\tif err != nil {\n\t\t\t\terrresponse.Render(w, r, err, http.StatusBadRequest, \"Could not get resources\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tvar tmpResources map[string]interface{}\n\t\t\terr = json.Unmarshal(list, &tmpResources)\n\t\t\tif err != nil {\n\t\t\t\terrresponse.Render(w, r, err, http.StatusInternalServerError, \"Could not unmarshal resources\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tresources = append(resources, Resources{\n\t\t\t\tCluster: clusterName,\n\t\t\t\tNamespace: \"\",\n\t\t\t\tResources: tmpResources,\n\t\t\t})\n\t\t} else {\n\t\t\tfor _, namespace := range namespaces {\n\t\t\t\tlist, err := cluster.GetResources(r.Context(), namespace, name, path, resource, paramName, param)\n\t\t\t\tif err != nil {\n\t\t\t\t\terrresponse.Render(w, r, err, http.StatusBadRequest, \"Could not get resources\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tvar tmpResources map[string]interface{}\n\t\t\t\terr = json.Unmarshal(list, &tmpResources)\n\t\t\t\tif err != nil {\n\t\t\t\t\terrresponse.Render(w, r, err, http.StatusInternalServerError, \"Could not unmarshal resources\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tresources = append(resources, Resources{\n\t\t\t\t\tCluster: clusterName,\n\t\t\t\t\tNamespace: namespace,\n\t\t\t\t\tResources: tmpResources,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\tlog.WithFields(logrus.Fields{\"count\": len(resources)}).Tracef(\"getResources\")\n\trender.JSON(w, r, resources)\n}", "title": "" }, { "docid": "f987f2e324f7c8a951b11334d03fcd18", "score": "0.5460262", "text": "func getResources(endpoint *string, token string, resourceID string) (*Resources, error) {\n\tif endpoint == nil {\n\t\tendpointString := resourcesEndpoint + \"?resource_id=\" + resourceID\n\t\tendpoint = &endpointString\n\t} else {\n\t\tendpointString := resourcesRoot + *endpoint\n\t\tendpoint = &endpointString\n\t}\n\n\theader := map[string]string{\n\t\t\"Authorization\": \"Bearer \" + token,\n\t}\n\n\tresult := &Resources{}\n\terr := fetch(*endpoint, header, result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn result, nil\n}", "title": "" }, { "docid": "ede6849ac62104243b8410561481e994", "score": "0.5457904", "text": "func ActionApiResources() carapace.Action {\n\treturn carapace.ActionCallback(func(c carapace.Context) carapace.Action {\n\t\treturn carapace.ActionExecCommand(\"kubectl\", \"api-resources\", \"--output=name\", \"--cached\")(func(output []byte) carapace.Action {\n\t\t\tlines := strings.Split(string(output), \"\\n\")\n\t\t\tfor index, line := range lines {\n\t\t\t\tlines[index] = strings.SplitN(line, \".\", 2)[0]\n\t\t\t}\n\t\t\treturn carapace.ActionValues(lines[:len(lines)-1]...)\n\t\t})\n\t})\n}", "title": "" }, { "docid": "76cbb9c2f364bb61443a78a78385d5f1", "score": "0.5394057", "text": "func (r *RPC) ResourceAll(c context.Context, a *struct{}, res *[]*model.Resource) (err error) {\n\t*res = r.s.ResourceAll(c)\n\treturn\n}", "title": "" }, { "docid": "883f802e21391e13fa8c7079dd58f5ae", "score": "0.5393693", "text": "func (c *resourceCache) UpdateResources(resources []NamedProtoMessage) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\tfor _, res := range resources {\n\t\tname := GetResourceName(res)\n\t\tc.cache[name] = res\n\t}\n}", "title": "" }, { "docid": "809586a2d50e8c2b37ce2f16de677df6", "score": "0.5379323", "text": "func (k *proxy) ListResources(ctx context.Context, labels map[string]string, namespaces ...string) ([]unstructured.Unstructured, error) {\n\tcs, err := k.newClientSet()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tc, err := k.NewClient()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Get all the API resources in the cluster.\n\tresourceListBackoff := newReadBackoff()\n\tvar resourceList []*metav1.APIResourceList\n\tif err := retryWithExponentialBackoff(resourceListBackoff, func() error {\n\t\tresourceList, err = cs.Discovery().ServerPreferredResources()\n\t\treturn err\n\t}); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to list api resources\")\n\t}\n\n\t// Exclude from discovery the objects from the cert-manager/provider's CRDs.\n\t// Those objects are not part of the components, and they will eventually be removed when removing the CRD definition.\n\tcrdsToExclude := sets.Set[string]{}\n\n\tcrdList := &apiextensionsv1.CustomResourceDefinitionList{}\n\tif err := retryWithExponentialBackoff(newReadBackoff(), func() error {\n\t\treturn c.List(ctx, crdList)\n\t}); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to list CRDs\")\n\t}\n\tfor _, crd := range crdList.Items {\n\t\tcomponent, isCoreComponent := labels[clusterctlv1.ClusterctlCoreLabel]\n\t\t_, isProviderResource := crd.Labels[clusterv1.ProviderNameLabel]\n\t\tif (isCoreComponent && component == clusterctlv1.ClusterctlCoreLabelCertManagerValue) || isProviderResource {\n\t\t\tfor _, version := range crd.Spec.Versions {\n\t\t\t\tcrdsToExclude.Insert(metav1.GroupVersionKind{\n\t\t\t\t\tGroup: crd.Spec.Group,\n\t\t\t\t\tVersion: version.Name,\n\t\t\t\t\tKind: crd.Spec.Names.Kind,\n\t\t\t\t}.String())\n\t\t\t}\n\t\t}\n\t}\n\n\t// Select resources with list and delete methods (list is required by this method, delete by the callers of this method)\n\tresourceList = discovery.FilteredBy(discovery.SupportsAllVerbs{Verbs: []string{\"list\", \"delete\"}}, resourceList)\n\n\tvar ret []unstructured.Unstructured\n\tfor _, resourceGroup := range resourceList {\n\t\tfor _, resourceKind := range resourceGroup.APIResources {\n\t\t\t// Discard the resourceKind that exists in two api groups (we are excluding one of the two groups arbitrarily).\n\t\t\tif resourceGroup.GroupVersion == \"extensions/v1beta1\" &&\n\t\t\t\t(resourceKind.Name == \"daemonsets\" || resourceKind.Name == \"deployments\" || resourceKind.Name == \"replicasets\" || resourceKind.Name == \"networkpolicies\" || resourceKind.Name == \"ingresses\") {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Continue if the resource is an excluded CRD.\n\t\t\tgv, err := schema.ParseGroupVersion(resourceGroup.GroupVersion)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Wrapf(err, \"failed to parse GroupVersion\")\n\t\t\t}\n\t\t\tif crdsToExclude.Has(metav1.GroupVersionKind{\n\t\t\t\tGroup: gv.Group,\n\t\t\t\tVersion: gv.Version,\n\t\t\t\tKind: resourceKind.Kind,\n\t\t\t}.String()) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// List all the object instances of this resourceKind with the given labels\n\t\t\tif resourceKind.Namespaced {\n\t\t\t\tfor _, namespace := range namespaces {\n\t\t\t\t\tobjList, err := listObjByGVK(ctx, c, resourceGroup.GroupVersion, resourceKind.Kind, []client.ListOption{client.MatchingLabels(labels), client.InNamespace(namespace)})\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\tret = append(ret, objList.Items...)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tobjList, err := listObjByGVK(ctx, c, resourceGroup.GroupVersion, resourceKind.Kind, []client.ListOption{client.MatchingLabels(labels)})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tret = append(ret, objList.Items...)\n\t\t\t}\n\t\t}\n\t}\n\treturn ret, nil\n}", "title": "" }, { "docid": "1664bb44c24534d7edb7e02ff29d5bbe", "score": "0.53555804", "text": "func AllResources(o *VeleroOptions) *unstructured.UnstructuredList {\n\tresources := AllCRDs()\n\n\tns := Namespace(o.Namespace)\n\tif err := appendUnstructured(resources, ns); err != nil {\n\t\tfmt.Printf(\"error appending Namespace %s: %s\\n\", ns.GetName(), err.Error())\n\t}\n\n\tserviceAccountName := defaultServiceAccountName\n\tif o.ServiceAccountName == \"\" {\n\t\tcrb := ClusterRoleBinding(o.Namespace)\n\t\tif err := appendUnstructured(resources, crb); err != nil {\n\t\t\tfmt.Printf(\"error appending ClusterRoleBinding %s: %s\\n\", crb.GetName(), err.Error())\n\t\t}\n\t\tsa := ServiceAccount(o.Namespace, o.ServiceAccountAnnotations)\n\t\tif err := appendUnstructured(resources, sa); err != nil {\n\t\t\tfmt.Printf(\"error appending ServiceAccount %s: %s\\n\", sa.GetName(), err.Error())\n\t\t}\n\t} else {\n\t\tserviceAccountName = o.ServiceAccountName\n\t}\n\n\tif o.SecretData != nil {\n\t\tsec := Secret(o.Namespace, o.SecretData)\n\t\tif err := appendUnstructured(resources, sec); err != nil {\n\t\t\tfmt.Printf(\"error appending Secret %s: %s\\n\", sec.GetName(), err.Error())\n\t\t}\n\t}\n\n\tif !o.NoDefaultBackupLocation {\n\t\tbsl := BackupStorageLocation(o.Namespace, o.ProviderName, o.Bucket, o.Prefix, o.BSLConfig, o.CACertData)\n\t\tif err := appendUnstructured(resources, bsl); err != nil {\n\t\t\tfmt.Printf(\"error appending BackupStorageLocation %s: %s\\n\", bsl.GetName(), err.Error())\n\t\t}\n\t}\n\n\t// A snapshot location may not be desirable for users relying on pod volume backup/restore\n\tif o.UseVolumeSnapshots {\n\t\tvsl := VolumeSnapshotLocation(o.Namespace, o.ProviderName, o.VSLConfig)\n\t\tif err := appendUnstructured(resources, vsl); err != nil {\n\t\t\tfmt.Printf(\"error appending VolumeSnapshotLocation %s: %s\\n\", vsl.GetName(), err.Error())\n\t\t}\n\t}\n\n\tsecretPresent := o.SecretData != nil\n\n\tdeployOpts := []podTemplateOption{\n\t\tWithAnnotations(o.PodAnnotations),\n\t\tWithLabels(o.PodLabels),\n\t\tWithImage(o.Image),\n\t\tWithResources(o.VeleroPodResources),\n\t\tWithSecret(secretPresent),\n\t\tWithDefaultRepoMaintenanceFrequency(o.DefaultRepoMaintenanceFrequency),\n\t\tWithServiceAccountName(serviceAccountName),\n\t\tWithGarbageCollectionFrequency(o.GarbageCollectionFrequency),\n\t\tWithUploaderType(o.UploaderType),\n\t}\n\n\tif len(o.Features) > 0 {\n\t\tdeployOpts = append(deployOpts, WithFeatures(o.Features))\n\t}\n\n\tif o.RestoreOnly {\n\t\tdeployOpts = append(deployOpts, WithRestoreOnly())\n\t}\n\n\tif len(o.Plugins) > 0 {\n\t\tdeployOpts = append(deployOpts, WithPlugins(o.Plugins))\n\t}\n\n\tif o.DefaultVolumesToFsBackup {\n\t\tdeployOpts = append(deployOpts, WithDefaultVolumesToFsBackup())\n\t}\n\n\tdeploy := Deployment(o.Namespace, deployOpts...)\n\n\tif err := appendUnstructured(resources, deploy); err != nil {\n\t\tfmt.Printf(\"error appending Deployment %s: %s\\n\", deploy.GetName(), err.Error())\n\t}\n\n\tif o.UseNodeAgent {\n\t\tdsOpts := []podTemplateOption{\n\t\t\tWithAnnotations(o.PodAnnotations),\n\t\t\tWithLabels(o.PodLabels),\n\t\t\tWithImage(o.Image),\n\t\t\tWithResources(o.NodeAgentPodResources),\n\t\t\tWithSecret(secretPresent),\n\t\t\tWithServiceAccountName(serviceAccountName),\n\t\t}\n\t\tif len(o.Features) > 0 {\n\t\t\tdsOpts = append(dsOpts, WithFeatures(o.Features))\n\t\t}\n\t\tds := DaemonSet(o.Namespace, dsOpts...)\n\t\tif err := appendUnstructured(resources, ds); err != nil {\n\t\t\tfmt.Printf(\"error appending DaemonSet %s: %s\\n\", ds.GetName(), err.Error())\n\t\t}\n\t}\n\n\treturn resources\n}", "title": "" }, { "docid": "4227c530d0d4ac4ac1131d036977dd07", "score": "0.53435135", "text": "func getDataplaneResource(agentResource *apiV1.ResourceInstance) (*apiV1.ResourceInstance, error) {\n\tdataplaneName := getDataplaneNameFromAgent(agentResource)\n\tdataplaneResourceType := getDataplaneType()\n\tdataplaneResourceURL := agent.cfg.GetEnvironmentURL() + \"/\" + dataplaneResourceType + \"/\" + dataplaneName\n\n\tresponse, err := agent.apicClient.ExecuteAPI(coreapi.GET, dataplaneResourceURL, nil, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdataplane := apiV1.ResourceInstance{}\n\tjson.Unmarshal(response, &dataplane)\n\treturn &dataplane, nil\n}", "title": "" }, { "docid": "dfe4e8d62f3a148a39bae3077b7afbb2", "score": "0.53286093", "text": "func ActionApiResourceResources() carapace.Action {\n\treturn carapace.ActionMultiParts(\"/\", func(c carapace.Context) carapace.Action {\n\t\tswitch len(c.Parts) {\n\t\tcase 0:\n\t\t\treturn ActionApiResources().Invoke(c).Suffix(\"/\").ToA()\n\t\tcase 1:\n\t\t\treturn ActionResources(ResourceOpts{Namespace: \"\", Types: c.Parts[0]})\n\t\tdefault:\n\t\t\treturn carapace.ActionValues()\n\t\t}\n\t})\n}", "title": "" }, { "docid": "06ab981249918563a2f786d01c7d8f59", "score": "0.5318807", "text": "func getResources(client *ApiClient) (map[schema.GroupVersion][]metav1.APIResource, error) {\n\n\tresourceLists, err := client.ClientSet.Discovery().ServerPreferredResources()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tversionResource := map[schema.GroupVersion][]metav1.APIResource{}\n\n\tfor _, apiResourceList := range resourceLists {\n\t\tversion, err := schema.ParseGroupVersion(apiResourceList.GroupVersion)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to parse GroupVersion %v\",err)\n\t\t}\n\n\t\tversionResource[version] = uniqResources(apiResourceList.APIResources)\n\t}\n\n\treturn versionResource, nil\n}", "title": "" }, { "docid": "69e17baed25d634147e6f0d6aa2ac66b", "score": "0.5311959", "text": "func (c *clusterCache) GetAPIResources() []kube.APIResourceInfo {\n\tc.lock.RLock()\n\tdefer c.lock.RUnlock()\n\n\treturn c.apiResources\n}", "title": "" }, { "docid": "277ac636678a20959557d1ec855c181f", "score": "0.52936596", "text": "func LoadSubscriptionData(configFile *config.Config) {\n\tconf = configFile\n\taccessToken = auth.GetBasicAuth(configFile.ControlPlane.Username, configFile.ControlPlane.Password)\n\n\tvar responseChannel = make(chan response)\n\tfor _, url := range resources {\n\t\tgo InvokeService(url.endpoint, url.responseType, nil, responseChannel, 0)\n\t}\n\n\t// Take the configured labels from the adapter\n\tconfiguredEnvs := conf.ControlPlane.EnvironmentLabels\n\n\t// If no environments are configured, default gateway label value is assigned.\n\tif len(configuredEnvs) == 0 {\n\t\tconfiguredEnvs = append(configuredEnvs, config.DefaultGatewayName)\n\t}\n\tfor _, configuredEnv := range configuredEnvs {\n\t\tqueryParamMap := make(map[string]string, 1)\n\t\tqueryParamMap[GatewayLabelParam] = configuredEnv\n\t\tgo InvokeService(ApisEndpoint, APIListMap[configuredEnv], queryParamMap, APIListChannel, 0)\n\t}\n\n\tgo retrieveAPIListFromChannel(APIListChannel)\n\tvar response response\n\tfor i := 1; i <= len(resources); i++ {\n\t\tresponse = <-responseChannel\n\n\t\tresponseType := reflect.TypeOf(response.Type).Elem()\n\t\tnewResponse := reflect.New(responseType).Interface()\n\n\t\tif response.Error == nil && response.Payload != nil {\n\t\t\terr := json.Unmarshal(response.Payload, &newResponse)\n\n\t\t\tif err != nil {\n\t\t\t\tlogger.LoggerSubscription.Errorf(\"Error occurred while unmarshalling the response received for: \"+response.Endpoint, err)\n\t\t\t} else {\n\t\t\t\tswitch t := newResponse.(type) {\n\t\t\t\tcase *types.SubscriptionList:\n\t\t\t\t\tlogger.LoggerSubscription.Debug(\"Received Subscription information.\")\n\t\t\t\t\tSubList = newResponse.(*types.SubscriptionList)\n\t\t\t\t\txds.UpdateEnforcerSubscriptions(xds.MarshalSubscriptionList(SubList))\n\t\t\t\tcase *types.ApplicationList:\n\t\t\t\t\tlogger.LoggerSubscription.Debug(\"Received Application information.\")\n\t\t\t\t\tAppList = newResponse.(*types.ApplicationList)\n\t\t\t\t\txds.UpdateEnforcerApplications(xds.MarshalApplicationList(AppList))\n\t\t\t\tcase *types.ApplicationPolicyList:\n\t\t\t\t\tlogger.LoggerSubscription.Debug(\"Received Application Policy information.\")\n\t\t\t\t\tAppPolicyList = newResponse.(*types.ApplicationPolicyList)\n\t\t\t\t\txds.UpdateEnforcerApplicationPolicies(xds.MarshalApplicationPolicyList(AppPolicyList))\n\t\t\t\tcase *types.SubscriptionPolicyList:\n\t\t\t\t\tlogger.LoggerSubscription.Debug(\"Received Subscription Policy information.\")\n\t\t\t\t\tSubPolicyList = newResponse.(*types.SubscriptionPolicyList)\n\t\t\t\t\txds.UpdateEnforcerSubscriptionPolicies(xds.MarshalSubscriptionPolicyList(SubPolicyList))\n\t\t\t\tcase *types.ApplicationKeyMappingList:\n\t\t\t\t\tlogger.LoggerSubscription.Debug(\"Received Application Key Mapping information.\")\n\t\t\t\t\tAppKeyMappingList = newResponse.(*types.ApplicationKeyMappingList)\n\t\t\t\t\txds.UpdateEnforcerApplicationKeyMappings(xds.MarshalKeyMappingList(AppKeyMappingList))\n\t\t\t\tdefault:\n\t\t\t\t\tlogger.LoggerSubscription.Debugf(\"Unknown type %T\", t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "f2e183eba46c7d72ac5e455e5cbd43cd", "score": "0.52557176", "text": "func (p *Proxy) refreshMetrics() {\n\t// get a list of services to update\n\tp.RLock()\n\n\tservices := make([]string, 0, len(p.Routes))\n\n\tfor service := range p.Routes {\n\t\tservices = append(services, service)\n\t}\n\n\tp.RUnlock()\n\n\t// get and cache the routes for the service\n\tfor _, service := range services {\n\t\tp.cacheRoutes(service)\n\t}\n}", "title": "" }, { "docid": "fe07c374fa566cb1a9bc7c7822d390db", "score": "0.52546054", "text": "func (c *Client) Push(resources []APIResource) error {\n\tfor _, res := range resources {\n\t\t// REVISIT: maybe we should save updates (and thus zk and\n\t\t// midolman loads) by performing GET and compare first.\n\t\t// Or we can make the MidoNet API detect and ignore no-op updates.\n\t\tresp, body, err := c.post(res)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif resp.StatusCode == 404 || resp.StatusCode == 400 {\n\t\t\t// There are a few cases we can see 404 here.\n\t\t\t// - The resource is HasParent and the parent has not been\n\t\t\t// created yet\n\t\t\t// - The resource has a reference to the other resources (e.g.\n\t\t\t// filter chains for a Bridge) and they have not been created\n\t\t\t// yet\n\t\t\t// Also, MidoNet API returns 400 in a similar cases.\n\t\t\t// - When the port referenced by Route.nextHopPort doesn't exist.\n\t\t\t// (ROUTE_NEXT_HOP_PORT_NOT_NULL)\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"resource\": res,\n\t\t\t}).Info(\"Referent doesn't exist yet?\")\n\t\t\treturn fmt.Errorf(\"Referent doesn't exist yet?\")\n\t\t}\n\t\tif resp.StatusCode == 409 || (resp.StatusCode == 500 && mna1315(res)) {\n\t\t\tif res.Path(\"PUT\") != \"\" {\n\t\t\t\tresp, body, err = c.put(res)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif resp.StatusCode == 409 {\n\t\t\t\t\tif _, ok := res.(*TunnelZone); ok {\n\t\t\t\t\t\t// Workaound for UNIQUE_TUNNEL_ZONE_NAME_TYPE issue.\n\t\t\t\t\t\t// https://midonet.atlassian.net/browse/MNA-1293\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif res.Path(\"GET\") != \"\" {\n\t\t\t\t\texists, err := c.exists(res)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tif !exists {\n\t\t\t\t\t\t// assume a transient error\n\t\t\t\t\t\treturn fmt.Errorf(\"Unexpected 409\")\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// assume 409 meant ok\n\t\t\t\t// REVISIT: confirm that the existing resource is\n\t\t\t\t// same enough as what we want.\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tif resp.StatusCode/100 != 2 {\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"statusCode\": resp.StatusCode,\n\t\t\t\t\"body\": body,\n\t\t\t}).Fatal(\"Unexpected status code\")\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "fb38430d063497c8148043dbc58d1fd4", "score": "0.52485424", "text": "func (g *ServiceLevelObjectiveGenerator) InitResources() error {\n\tdatadogClient := g.Args[\"datadogClient\"].(*datadog.APIClient)\n\tauth := g.Args[\"auth\"].(context.Context)\n\tapi := datadogV1.NewServiceLevelObjectivesApi(datadogClient)\n\n\tvar slos []datadogV1.ServiceLevelObjective\n\tresp, _, err := api.ListSLOs(auth)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tslos = append(slos, resp.GetData()...)\n\tg.Resources = g.createResources(slos)\n\treturn nil\n}", "title": "" }, { "docid": "023ef11456f69718b60614bc5e62ecb5", "score": "0.5225731", "text": "func (r *Resource[R, T]) refresh(ctx context.Context) (bool, error) {\n\tgstore := storev2.Of[R, T](r.store)\n\tpred := &store.SelectionPredicate{\n\t\tUpdatedSince: r.updatedSince,\n\t\tIncludeDeletes: true,\n\t}\n\tresources, err := gstore.List(ctx, storev2.ID{}, pred)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tr.cacheMu.Lock()\n\tdefer r.cacheMu.Unlock()\n\thasUpdates := len(resources) > 0\n\tvar newestUpdate time.Time\n\t_ = newestUpdate.UnmarshalText([]byte(r.updatedSince))\n\tfor _, resource := range resources {\n\t\tmeta := resource.GetMetadata()\n\t\tvar updatedAt time.Time\n\t\tif err := updatedAt.UnmarshalText([]byte(meta.Labels[store.SensuUpdatedAtKey])); err == nil {\n\t\t\tif updatedAt.After(newestUpdate) {\n\t\t\t\tnewestUpdate = updatedAt\n\t\t\t}\n\t\t}\n\t\tslice := resourceSlice[R, T](r.cache[meta.Namespace])\n\t\tif _, ok := meta.Labels[store.SensuDeletedAtKey]; ok {\n\t\t\ttoDelete, ok := slice.FindIndex(meta.Name)\n\t\t\tif ok {\n\t\t\t\t// remove value\n\t\t\t\tslice = append(slice[:toDelete], slice[toDelete+1:]...)\n\t\t\t\tr.cache[meta.Namespace] = slice\n\t\t\t}\n\t\t} else {\n\t\t\tvalue := getCacheValue(resource, r.synthesize)\n\t\t\tidx, ok := slice.FindIndex(meta.Name)\n\t\t\tif ok {\n\t\t\t\t// replace value\n\t\t\t\tslice[idx] = value\n\t\t\t} else {\n\t\t\t\t// new value, sorted insert\n\t\t\t\tslice = append(slice, value)\n\t\t\t\tcopy(slice[idx+1:], slice[idx:])\n\t\t\t\tslice[idx] = value\n\t\t\t\tr.cache[meta.Namespace] = slice\n\t\t\t}\n\t\t}\n\t}\n\tvar resourceCount int64\n\tfor _, slice := range r.cache {\n\t\tresourceCount += int64(len(slice))\n\t}\n\tatomic.StoreInt64(&r.count, resourceCount)\n\tb, _ := newestUpdate.MarshalText()\n\tr.updatedSince = string(b)\n\n\treturn hasUpdates, nil\n}", "title": "" }, { "docid": "c34bfb485cd36affe0530e0fd331f155", "score": "0.5218961", "text": "func (d *discovery) Refresh() error {\n\td.retrieverLock.RLock()\n\tsrvs, err := d.retriever.Retrieve(d.service, d.proto, d.name)\n\td.retrieverLock.RUnlock()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\td.serversLock.Lock()\n\tdefer d.serversLock.Unlock()\n\n\tvar servers []*net.SRV\n\tfor _, srv := range srvs {\n\t\td.healthCheckerLock.RLock()\n\t\tok, err := d.healthChecker.HealthCheck(srv.Target, srv.Port, d.proto)\n\t\td.healthCheckerLock.RUnlock()\n\n\t\tif err != nil {\n\t\t\td.errorsLock.Lock()\n\t\t\td.errors = append(d.errors, err)\n\t\t\td.errorsLock.Unlock()\n\t\t}\n\n\t\tif err == nil && ok {\n\t\t\tservers = append(servers, srv)\n\t\t}\n\t}\n\n\t// the default retriever already do the sort for us (lookupSRV), but if it's\n\t// replaced for other algorithm the library needs to ensure that it is\n\t// ordered, because the default load balancer algorithm depends on that\n\tbyPriorityWeight(servers).sort()\n\n\td.loadBalancerLock.RLock()\n\td.loadBalancer.ChangeServers(servers)\n\td.loadBalancerLock.RUnlock()\n\treturn nil\n}", "title": "" }, { "docid": "0d5bffd0eb63185da6b040a49293528d", "score": "0.52183044", "text": "func collectPreferredCRDResource(discovery discovery.DiscoveryInterface) ([]*metav1.APIResourceList, error) {\n\tresources, err := discovery.ServerPreferredResources()\n\tcrdResource := []*metav1.APIResourceList{}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, res := range resources {\n\t\tgv, err := schema.ParseGroupVersion(res.GroupVersion)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tif gv.Group != \"apiextensions.k8s.io\" {\n\t\t\tcontinue\n\t\t}\n\t\temptyAPIResourceList := metav1.APIResourceList{\n\t\t\tGroupVersion: res.GroupVersion,\n\t\t}\n\t\temptyAPIResourceList.APIResources = findCRDGVRs(res.APIResources)\n\t\tcrdResource = append(crdResource, &emptyAPIResourceList)\n\t\tbreak\n\t}\n\n\treturn crdResource, nil\n}", "title": "" }, { "docid": "cfea833ec89dc3215b68ab51f00d8e91", "score": "0.5181323", "text": "func (nd *Node) Refresh() ([]*Host, error) {\n\tvar friends []*Host\n\n\tnd.refreshCount.IncrementAndGet()\n\n\tconn, err := nd.GetConnection(nd.cluster.ClientPolicy().Timeout)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar commands []string\n\tif !nd.cluster.useServicesAlternate {\n\t\tcommands = []string{\"node\", \"partition-generation\", \"services\"}\n\t} else {\n\t\tcommands = []string{\"node\", \"partition-generation\", \"services-alternate\"}\n\t}\n\n\tinfoMap, err := RequestInfo(conn, commands...)\n\tif err != nil {\n\t\tnd.InvalidateConnection(conn)\n\t\tnd.DecreaseHealth()\n\t\treturn nil, err\n\t}\n\n\tif err := nd.verifyNodeName(infoMap); err != nil {\n\t\tnd.PutConnection(conn)\n\t\treturn nil, err\n\t}\n\tnd.RestoreHealth()\n\tnd.responded.Set(true)\n\n\tif friends, err = nd.addFriends(infoMap); err != nil {\n\t\tnd.PutConnection(conn)\n\t\treturn nil, err\n\t}\n\n\tif err := nd.updatePartitions(conn, infoMap); err != nil {\n\t\tnd.InvalidateConnection(conn)\n\t\treturn nil, err\n\t}\n\n\t// Suppose there is a request peak, and we create lots of connections to\n\t// handle those requests. We want to keep those connections around while the\n\t// peak is taking place. When the peak is over, we hopefully will want to\n\t// close and those connections, and remove pressure from our side (the\n\t// client) and servers. Because the connection pool is a FIFO queue, if we\n\t// refresh the connection here, we may end up preventing lots of unused\n\t// connections from going idle, and therefore preventing them from being\n\t// closed. We should keep the number of connections to servers as low as\n\t// possible when there is no need for them. For that reason, we just put the\n\t// connection back into the pool without refreshing it.\n\tnd.PutConnection(conn)\n\treturn friends, nil\n}", "title": "" }, { "docid": "9be92f7230f57f1b3c8adf5d56889d18", "score": "0.5178043", "text": "func (c *Client) updateResources(ctx context.Context, id string, resources types.Resources) error {\n\tif !c.lock.TrylockWithRetry(ctx, id) {\n\t\treturn errtypes.ErrLockfailed\n\t}\n\tdefer c.lock.Unlock(id)\n\n\tpack, err := c.watch.get(id)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tr, err := toLinuxResources(resources)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn pack.task.Update(ctx, containerd.WithResources(r))\n}", "title": "" }, { "docid": "921f5e10eb2ea23e00e265a26f9ee558", "score": "0.5148671", "text": "func (r *registryRouter) refresh() {\n\tvar attempts int\n\tlogger := r.Options().Logger\n\n\tfor {\n\t\tservices, err := r.opts.Registry.ListServices()\n\t\tif err != nil {\n\t\t\tattempts++\n\t\t\tlogger.Logf(log.ErrorLevel, \"unable to list services: %v\", err)\n\t\t\ttime.Sleep(time.Duration(attempts) * time.Second)\n\t\t\tcontinue\n\t\t}\n\n\t\tattempts = 0\n\n\t\t// for each service, get service and store endpoints\n\t\tfor _, s := range services {\n\t\t\tservice, err := r.rc.GetService(s.Name)\n\t\t\tif err != nil {\n\t\t\t\tlogger.Logf(log.ErrorLevel, \"unable to get service: %v\", err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tr.store(service)\n\t\t}\n\n\t\t// refresh list in 10 minutes... cruft\n\t\t// use registry watching\n\t\tselect {\n\t\tcase <-time.After(time.Minute * 10):\n\t\tcase <-r.exit:\n\t\t\treturn\n\t\t}\n\t}\n}", "title": "" }, { "docid": "2c76a983ae3563daaf021bacea903087", "score": "0.51446146", "text": "func fetchGroupVersionResources(d discovery.DiscoveryInterface, apiGroups []*metav1.APIGroup) (map[schema.GroupVersion]*metav1.APIResourceList, map[schema.GroupVersion]error) {\n\tgroupVersionResources := make(map[schema.GroupVersion]*metav1.APIResourceList)\n\tfailedGroups := make(map[schema.GroupVersion]error)\n\n\twg := &sync.WaitGroup{}\n\tresultLock := &sync.Mutex{}\n\tfor _, apiGroup := range apiGroups {\n\t\tfor _, version := range apiGroup.Versions {\n\t\t\tgroupVersion := schema.GroupVersion{Group: apiGroup.Name, Version: version.Version}\n\t\t\twg.Add(1)\n\t\t\tgo func() {\n\t\t\t\tdefer wg.Done()\n\t\t\t\tdefer utilruntime.HandleCrash()\n\n\t\t\t\tapiResourceList, err := d.ServerResourcesForGroupVersion(groupVersion.String())\n\n\t\t\t\t// lock to record results\n\t\t\t\tresultLock.Lock()\n\t\t\t\tdefer resultLock.Unlock()\n\n\t\t\t\tif err != nil {\n\t\t\t\t\t// TODO: maybe restrict this to NotFound errors\n\t\t\t\t\tfailedGroups[groupVersion] = err\n\t\t\t\t}\n\t\t\t\tif apiResourceList != nil {\n\t\t\t\t\t// even in case of error, some fallback might have been returned\n\t\t\t\t\tgroupVersionResources[groupVersion] = apiResourceList\n\t\t\t\t}\n\t\t\t}()\n\t\t}\n\t}\n\twg.Wait()\n\n\treturn groupVersionResources, failedGroups\n}", "title": "" }, { "docid": "101db8ed167c414995e484edcaa86d2e", "score": "0.51424176", "text": "func (sp *schemaPuller) PullCRDs(context context.Context, resourceNames ...string) (map[schema.GroupResource]*apiextensionsv1.CustomResourceDefinition, error) {\n\tcrds := map[schema.GroupResource]*apiextensionsv1.CustomResourceDefinition{}\n\t_, apiResourcesLists, err := sp.discoveryClient.ServerGroupsAndResources()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tpullAllResources := len(resourceNames) == 0\n\tresourcesToPull := sets.NewString(resourceNames...)\n\n\tapiResourceNames := map[schema.GroupVersion]sets.String{}\n\tfor _, apiResourcesList := range apiResourcesLists {\n\t\tgv, err := schema.ParseGroupVersion(apiResourcesList.GroupVersion)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tapiResourceNames[gv] = sets.NewString()\n\t\tfor _, apiResource := range apiResourcesList.APIResources {\n\t\t\tapiResourceNames[gv].Insert(apiResource.Name)\n\t\t}\n\n\t}\n\n\tapiResourcesLists, err = sp.discoveryClient.ServerPreferredResources()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor _, apiResourcesList := range apiResourcesLists {\n\t\tgv, err := schema.ParseGroupVersion(apiResourcesList.GroupVersion)\n\t\tif err != nil {\n\t\t\tklog.Errorf(\"skipping discovery due to error parsing GroupVersion %s: %v\", apiResourcesList.GroupVersion, err)\n\t\t\tcontinue\n\t\t}\n\n\t\tfor _, apiResource := range apiResourcesList.APIResources {\n\t\t\tgroupResource := schema.GroupResource{\n\t\t\t\tGroup: gv.Group,\n\t\t\t\tResource: apiResource.Name,\n\t\t\t}\n\t\t\tif !pullAllResources && !resourcesToPull.Has(groupResource.String()) && !resourcesToPull.Has(apiResource.Name) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif genericcontrolplanescheme.Scheme.IsGroupRegistered(gv.Group) && !genericcontrolplanescheme.Scheme.IsVersionRegistered(gv) {\n\t\t\t\tklog.Warningf(\"ignoring an apiVersion since it is part of the core KCP resources, but not compatible with KCP version: %s\", gv.String())\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tgvk := gv.WithKind(apiResource.Kind)\n\t\t\tif genericcontrolplanescheme.Scheme.Recognizes(gvk) || extensionsapiserver.Scheme.Recognizes(gvk) {\n\t\t\t\tklog.Infof(\"ignoring a resource since it is part of the core KCP resources: %s (%s)\", apiResource.Name, gvk.String())\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tcrdName := apiResource.Name\n\t\t\tif gv.Group == \"\" {\n\t\t\t\tcrdName = crdName + \".core\"\n\t\t\t} else {\n\t\t\t\tcrdName = crdName + \".\" + gv.Group\n\t\t\t}\n\n\t\t\tvar resourceScope apiextensionsv1.ResourceScope\n\t\t\tif apiResource.Namespaced {\n\t\t\t\tresourceScope = apiextensionsv1.NamespaceScoped\n\t\t\t} else {\n\t\t\t\tresourceScope = apiextensionsv1.ClusterScoped\n\t\t\t}\n\n\t\t\tklog.Infof(\"processing discovery for resource %s (%s)\", apiResource.Name, crdName)\n\t\t\tvar schemaProps apiextensionsv1.JSONSchemaProps\n\t\t\tvar additionalPrinterColumns []apiextensionsv1.CustomResourceColumnDefinition\n\t\t\tcrd, err := sp.crdClient.CustomResourceDefinitions().Get(context, crdName, metav1.GetOptions{})\n\t\t\tif err == nil {\n\t\t\t\tif apihelpers.IsCRDConditionTrue(crd, apiextensionsv1.NonStructuralSchema) {\n\t\t\t\t\tklog.Warningf(\"non-structural schema for resource %s (%s): the resources will not be validated\", apiResource.Name, gvk.String())\n\t\t\t\t\tschemaProps = apiextensionsv1.JSONSchemaProps{\n\t\t\t\t\t\tType: \"object\",\n\t\t\t\t\t\tXPreserveUnknownFields: boolPtr(true),\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tvar versionFound bool\n\t\t\t\t\tfor _, version := range crd.Spec.Versions {\n\t\t\t\t\t\tif version.Name == gv.Version {\n\t\t\t\t\t\t\tschemaProps = *version.Schema.OpenAPIV3Schema\n\t\t\t\t\t\t\tadditionalPrinterColumns = version.AdditionalPrinterColumns\n\t\t\t\t\t\t\tversionFound = true\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif !versionFound {\n\t\t\t\t\t\tklog.Errorf(\"expected version not found in CRD %s: %s\", crdName, gv.Version)\n\t\t\t\t\t\tschemaProps = apiextensionsv1.JSONSchemaProps{\n\t\t\t\t\t\t\tType: \"object\",\n\t\t\t\t\t\t\tXPreserveUnknownFields: boolPtr(true),\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif !errors.IsNotFound(err) {\n\t\t\t\t\tklog.Errorf(\"error looking up CRD for %s: %v\", crdName, err)\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tprotoSchema := sp.models[gvk]\n\t\t\t\tif protoSchema == nil {\n\t\t\t\t\tklog.Infof(\"ignoring a resource that has no OpenAPI Schema: %s (%s)\", apiResource.Name, gvk.String())\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tswaggerSpecDefinitionName := protoSchema.GetPath().String()\n\n\t\t\t\tvar errors []error\n\t\t\t\tconverter := &SchemaConverter{\n\t\t\t\t\tschemaProps: &schemaProps,\n\t\t\t\t\tschemaName: swaggerSpecDefinitionName,\n\t\t\t\t\tvisited: sets.NewString(),\n\t\t\t\t\terrors: &errors,\n\t\t\t\t}\n\t\t\t\tprotoSchema.Accept(converter)\n\t\t\t\tif len(*converter.errors) > 0 {\n\t\t\t\t\tklog.Errorf(\"error during the OpenAPI schema import of resource %s (%s) : %v\", apiResource.Name, gvk.String(), *converter.errors)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\n\t\t\thasSubResource := func(subResource string) bool {\n\t\t\t\tgroupResourceNames := apiResourceNames[gv]\n\t\t\t\tif groupResourceNames != nil {\n\t\t\t\t\treturn groupResourceNames.Has(apiResource.Name + \"/\" + subResource)\n\t\t\t\t}\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\tstatusSubResource := &apiextensionsv1.CustomResourceSubresourceStatus{}\n\t\t\tif !hasSubResource(\"status\") {\n\t\t\t\tstatusSubResource = nil\n\t\t\t}\n\n\t\t\tscaleSubResource := &apiextensionsv1.CustomResourceSubresourceScale{\n\t\t\t\tSpecReplicasPath: \".spec.replicas\",\n\t\t\t\tStatusReplicasPath: \".status.replicas\",\n\t\t\t}\n\t\t\tif !hasSubResource(\"scale\") {\n\t\t\t\tscaleSubResource = nil\n\t\t\t}\n\n\t\t\tcrd = &apiextensionsv1.CustomResourceDefinition{\n\t\t\t\tTypeMeta: metav1.TypeMeta{\n\t\t\t\t\tKind: \"CustomResourceDefinition\",\n\t\t\t\t\tAPIVersion: \"apiextensions.k8s.io/v1\",\n\t\t\t\t},\n\t\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\t\tName: crdName,\n\t\t\t\t\tLabels: map[string]string{},\n\t\t\t\t\tAnnotations: map[string]string{},\n\t\t\t\t},\n\t\t\t\tSpec: apiextensionsv1.CustomResourceDefinitionSpec{\n\t\t\t\t\tGroup: gv.Group,\n\t\t\t\t\tVersions: []apiextensionsv1.CustomResourceDefinitionVersion{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName: gv.Version,\n\t\t\t\t\t\t\tSchema: &apiextensionsv1.CustomResourceValidation{\n\t\t\t\t\t\t\t\tOpenAPIV3Schema: &schemaProps,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tSubresources: &apiextensionsv1.CustomResourceSubresources{\n\t\t\t\t\t\t\t\tStatus: statusSubResource,\n\t\t\t\t\t\t\t\tScale: scaleSubResource,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tServed: true,\n\t\t\t\t\t\t\tStorage: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tScope: resourceScope,\n\t\t\t\t\tNames: apiextensionsv1.CustomResourceDefinitionNames{\n\t\t\t\t\t\tPlural: apiResource.Name,\n\t\t\t\t\t\tKind: apiResource.Kind,\n\t\t\t\t\t\tCategories: apiResource.Categories,\n\t\t\t\t\t\tShortNames: apiResource.ShortNames,\n\t\t\t\t\t\tSingular: apiResource.SingularName,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}\n\t\t\tif len(additionalPrinterColumns) != 0 {\n\t\t\t\tcrd.Spec.Versions[0].AdditionalPrinterColumns = additionalPrinterColumns\n\t\t\t}\n\t\t\tapiextensionsv1.SetDefaults_CustomResourceDefinition(crd)\n\n\t\t\t// In Kubernetes, to make it clear to the API consumer that APIs in *.k8s.io or *.kubernetes.io domains\n\t\t\t// should be following all quality standards of core Kubernetes, CRDs under these domains\n\t\t\t// are expected to go through the API Review process and so must link the API review approval PR\n\t\t\t// in an `api-approved.kubernetes.io` annotation.\n\t\t\t// Without this annotation, a CRD under the *.k8s.io or *.kubernetes.io domains is rejected by the API server\n\t\t\t//\n\t\t\t// Of course here we're simply adding already-known resources of existing physical clusters as CRDs in KCP.\n\t\t\t// But to please this Kubernetes approval requirement, let's add the required annotation in imported CRDs\n\t\t\t// with one of the KCP PRs that hacked Kubernetes CRD support for KCP.\n\t\t\tif apihelpers.IsProtectedCommunityGroup(gv.Group) {\n\t\t\t\tcrd.ObjectMeta.Annotations[\"api-approved.kubernetes.io\"] = \"https://github.com/kcp-dev/kubernetes/pull/4\"\n\t\t\t}\n\t\t\tcrds[groupResource] = crd\n\t\t}\n\t}\n\treturn crds, nil\n}", "title": "" }, { "docid": "ba7f4da7d85469606986f1a960490899", "score": "0.51388484", "text": "func getAPIResourceConfig(options configapi.MasterConfig) genericapiserver.APIResourceConfigSource {\n\tresourceConfig := genericapiserver.NewResourceConfig()\n\n\tfor group := range configapi.KnownKubeAPIGroups {\n\t\tfor _, version := range configapi.GetEnabledAPIVersionsForGroup(*options.KubernetesMasterConfig, group) {\n\t\t\tgv := unversioned.GroupVersion{Group: group, Version: version}\n\t\t\tresourceConfig.EnableVersions(gv)\n\t\t}\n\t}\n\n\tfor group := range options.KubernetesMasterConfig.DisabledAPIGroupVersions {\n\t\tfor _, version := range configapi.GetDisabledAPIVersionsForGroup(*options.KubernetesMasterConfig, group) {\n\t\t\tgv := unversioned.GroupVersion{Group: group, Version: version}\n\t\t\tresourceConfig.DisableVersions(gv)\n\t\t}\n\t}\n\n\treturn resourceConfig\n}", "title": "" }, { "docid": "b40cece3ed7ed69049b4fd5b4deb5259", "score": "0.5124967", "text": "func (s ServerResourcesFake) ServerResources() ([]*metav1.APIResourceList, error) { return nil, nil }", "title": "" }, { "docid": "2bee841927ca90766fc029a5f8bb8774", "score": "0.5124929", "text": "func (d *HetznerCloudProvider) Refresh() error {\n\tfor _, group := range d.manager.nodeGroups {\n\t\tgroup.resetTargetSize(0)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c54ce640707897c9a7173306789ada32", "score": "0.51101804", "text": "func (s *Server) StreamAggregatedResources(server xds_discovery.AggregatedDiscoveryService_StreamAggregatedResourcesServer) error {\n\t// When a new Envoy proxy connects, ValidateClient would ensure that it has a valid certificate,\n\t// and the Subject CN is in the allowedCommonNames set.\n\tcertCommonName, certSerialNumber, err := utils.ValidateClient(server.Context(), nil)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Could not start Aggregated Discovery Service gRPC stream for newly connected Envoy proxy\")\n\t}\n\n\t// If maxDataPlaneConnections is enabled i.e. not 0, then check that the number of Envoy connections is less than maxDataPlaneConnections\n\tif s.cfg.GetMaxDataPlaneConnections() != 0 && s.proxyRegistry.GetConnectedProxyCount() >= s.cfg.GetMaxDataPlaneConnections() {\n\t\treturn errTooManyConnections\n\t}\n\n\tlog.Trace().Msgf(\"Envoy with certificate SerialNumber=%s connected\", certSerialNumber)\n\tmetricsstore.DefaultMetricsStore.ProxyConnectCount.Inc()\n\n\t// This is the Envoy proxy that just connected to the control plane.\n\t// NOTE: This is step 1 of the registration. At this point we do not yet have context on the Pod.\n\t// Details on which Pod this Envoy is fronting will arrive via xDS in the NODE_ID string.\n\t// When this arrives we will call RegisterProxy() a second time - this time with Pod context!\n\tproxy := envoy.NewProxy(certCommonName, certSerialNumber, utils.GetIPFromContext(server.Context()))\n\ts.proxyRegistry.RegisterProxy(proxy) // First of Two invocations. Second one will be during xDS hand-shake!\n\n\tdefer s.proxyRegistry.UnregisterProxy(proxy)\n\n\tctx, cancel := context.WithCancel(server.Context())\n\tdefer cancel()\n\n\tquit := make(chan struct{})\n\trequests := make(chan xds_discovery.DiscoveryRequest)\n\n\t// This helper handles receiving messages from the connected Envoys\n\t// and any gRPC error states.\n\tgo receive(requests, &server, proxy, quit, s.proxyRegistry)\n\n\t// Register to Envoy global broadcast updates\n\tbroadcastUpdate := events.GetPubSubInstance().Subscribe(announcements.ProxyBroadcast)\n\n\t// Register for certificate rotation updates\n\tcertAnnouncement := events.GetPubSubInstance().Subscribe(announcements.CertificateRotated)\n\n\t// Issues a send all response on a connecting envoy\n\t// If this were to fail, it most likely just means we still have configuration being applied on flight,\n\t// which will get triggered by the dispatcher anyway\n\tif err = s.sendResponse(proxy, &server, nil, s.cfg, envoy.XDSResponseOrder...); err != nil {\n\t\tlog.Error().Err(err).Msgf(\"Initial sendResponse for proxy %s returned error\", proxy.GetCertificateSerialNumber())\n\t}\n\n\tnewJob := func(typeURIs []envoy.TypeURI, discoveryRequest *xds_discovery.DiscoveryRequest) *proxyResponseJob {\n\t\treturn &proxyResponseJob{\n\t\t\ttypeURIs: typeURIs,\n\t\t\tproxy: proxy,\n\t\t\tadsStream: &server,\n\t\t\trequest: discoveryRequest,\n\t\t\txdsServer: s,\n\t\t\tdone: make(chan struct{}),\n\t\t}\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tmetricsstore.DefaultMetricsStore.ProxyConnectCount.Dec()\n\t\t\treturn nil\n\n\t\tcase <-quit:\n\t\t\tlog.Debug().Msgf(\"gRPC stream with Envoy on Pod with UID=%s closed!\", proxy.GetPodUID())\n\t\t\tmetricsstore.DefaultMetricsStore.ProxyConnectCount.Dec()\n\t\t\treturn nil\n\n\t\tcase discoveryRequest, ok := <-requests:\n\t\t\tif !ok {\n\t\t\t\tlog.Error().Msgf(\"Envoy with xDS Certificate SerialNumber=%s on Pod with UID=%s closed gRPC!\", proxy.GetCertificateSerialNumber(), proxy.GetPodUID())\n\t\t\t\tmetricsstore.DefaultMetricsStore.ProxyConnectCount.Dec()\n\t\t\t\treturn errGrpcClosed\n\t\t\t}\n\n\t\t\t// This function call runs xDS proto state machine given DiscoveryRequest as input.\n\t\t\t// It's output is the decision to reply or not to this request.\n\t\t\tif !respondToRequest(proxy, &discoveryRequest) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\ttypeURL := envoy.TypeURI(discoveryRequest.TypeUrl)\n\t\t\tvar typesRequest []envoy.TypeURI\n\t\t\tif typeURL == envoy.TypeWildcard {\n\t\t\t\ttypesRequest = envoy.XDSResponseOrder\n\t\t\t} else {\n\t\t\t\ttypesRequest = []envoy.TypeURI{typeURL}\n\t\t\t}\n\n\t\t\t<-s.workqueues.AddJob(newJob(typesRequest, &discoveryRequest))\n\n\t\tcase <-broadcastUpdate:\n\t\t\tlog.Info().Msgf(\"Broadcast wake for Proxy SerialNumber=%s UID=%s\", proxy.GetCertificateSerialNumber(), proxy.GetPodUID())\n\n\t\t\t// Queue a full configuration update\n\t\t\t<-s.workqueues.AddJob(newJob(envoy.XDSResponseOrder, nil))\n\n\t\tcase certUpdateMsg := <-certAnnouncement:\n\t\t\tcert := certUpdateMsg.(events.PubSubMessage).NewObj.(certificate.Certificater)\n\t\t\tif isCNforProxy(proxy, cert.GetCommonName()) {\n\t\t\t\t// The CN whose corresponding certificate was updated (rotated) by the certificate provider is associated\n\t\t\t\t// with this proxy, so update the secrets corresponding to this certificate via SDS.\n\t\t\t\tlog.Debug().Msgf(\"Certificate has been updated for proxy with SerialNumber=%s, UID=%s\", proxy.GetCertificateSerialNumber(), proxy.GetPodUID())\n\n\t\t\t\t// Empty DiscoveryRequest should create the SDS specific request\n\t\t\t\t// Prepare to queue the SDS proxy response job on the worker pool\n\t\t\t\t<-s.workqueues.AddJob(newJob([]envoy.TypeURI{envoy.TypeSDS}, nil))\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "4dfb0d700240ff2a24cbdfbe70133d61", "score": "0.5100103", "text": "func getAgentResource() (*apiV1.ResourceInstance, error) {\n\tagentResourceType := getAgentResourceType()\n\tagentResourceURL := agent.cfg.GetEnvironmentURL() + \"/\" + agentResourceType + \"/\" + agent.cfg.GetAgentName()\n\n\tresponse, err := agent.apicClient.ExecuteAPI(coreapi.GET, agentResourceURL, nil, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tagent := apiV1.ResourceInstance{}\n\tjson.Unmarshal(response, &agent)\n\treturn &agent, nil\n}", "title": "" }, { "docid": "7afccd346eb06cb06e0d9d591c7d0f12", "score": "0.50825834", "text": "func (cc *Controller) Resources() (map[string]*Resource, error) {\n\tresources := make(map[string]*Resource)\n\n\ttotal := NewResource()\n\tfor name, cloud := range cc.Clouds {\n\t\t// waitGroup.Add(1)\n\t\tres, err := cloud.Resource()\n\t\tif err != nil {\n\t\t\t// maybe some clouds are offline, ignore them\n\t\t\tlogdog.Error(\"CloudCtroller: can not get resources from cloud\", logdog.Fields{\"cloud\": cloud.Name(), \"err\": err})\n\t\t\tcontinue\n\t\t}\n\t\ttotal.Add(res)\n\t\tresources[name] = res\n\n\t}\n\n\tresources[\"_total\"] = total\n\treturn resources, nil\n}", "title": "" }, { "docid": "51821d79f29315e26dfa76063bc549d0", "score": "0.50769114", "text": "func collectPreferredResources(discovery discovery.DiscoveryInterface) ([]*metav1.APIResourceList, error) {\n\tresources, err := discovery.ServerPreferredNamespacedResources()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, res := range resources {\n\t\tres.APIResources = excludeSubresources(res.APIResources)\n\t\t// Some resources appear not to have permissions to list, need to exclude those.\n\t\tres.APIResources = listAllowed(res.APIResources)\n\t}\n\n\treturn resources, nil\n}", "title": "" }, { "docid": "03897ae2b0639ede2b91fbfb5ba072fb", "score": "0.5070856", "text": "func ResourcesCmd(cmd *cobra.Command, args []string) error {\n\tclient := env.NewClientSet(&Settings)\n\tlists, err := client.Discovery().ServerPreferredResources()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tresources := []metav1.APIResource{}\n\tfor _, item := range lists {\n\t\tif len(item.APIResources) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tresources = append(resources, item.APIResources...)\n\t}\n\ttable := uitable.New()\n\ttable.AddRow(\"Name\", \"Namespaced\", \"Kind\")\n\tfor _, resource := range resources {\n\t\ttable.AddRow(resource.Name, resource.Namespaced, resource.Kind)\n\t}\n\tfmt.Print(table)\n\treturn nil\n}", "title": "" }, { "docid": "601078bab3e4e1099d4467d5c52db347", "score": "0.5066077", "text": "func (s *Server) StreamAggregatedResources(server xds_discovery.AggregatedDiscoveryService_StreamAggregatedResourcesServer) error {\n\t// When a new Envoy proxy connects, ValidateClient would ensure that it has a valid certificate,\n\t// and the Subject CN is in the allowedCommonNames set.\n\tcertCommonName, certSerialNumber, err := utils.ValidateClient(server.Context(), nil)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Could not start Aggregated Discovery Service gRPC stream for newly connected Envoy proxy\")\n\t}\n\n\t// TODO(draychev): check for envoy.ErrTooManyConnections; GitHub Issue https://github.com/openservicemesh/osm/issues/2332\n\n\tlog.Trace().Msgf(\"Envoy with certificate SerialNumber=%s connected\", certSerialNumber)\n\tmetricsstore.DefaultMetricsStore.ProxyConnectCount.Inc()\n\n\t// This is the Envoy proxy that just connected to the control plane.\n\t// NOTE: This is step 1 of the registration. At this point we do not yet have context on the Pod.\n\t// Details on which Pod this Envoy is fronting will arrive via xDS in the NODE_ID string.\n\t// When this arrives we will call RegisterProxy() a second time - this time with Pod context!\n\tproxy := envoy.NewProxy(certCommonName, certSerialNumber, utils.GetIPFromContext(server.Context()))\n\ts.catalog.RegisterProxy(proxy) // First of Two invocations. Second one will be during xDS hand-shake!\n\n\tdefer s.catalog.UnregisterProxy(proxy)\n\n\tctx, cancel := context.WithCancel(server.Context())\n\tdefer cancel()\n\n\tquit := make(chan struct{})\n\trequests := make(chan xds_discovery.DiscoveryRequest)\n\n\t// This helper handles receiving messages from the connected Envoys\n\t// and any gRPC error states.\n\tgo receive(requests, &server, proxy, quit, s.catalog)\n\n\t// Register to Envoy global broadcast updates\n\tbroadcastUpdate := events.GetPubSubInstance().Subscribe(announcements.ProxyBroadcast)\n\n\t// Register for certificate rotation updates\n\tcertAnnouncement := events.GetPubSubInstance().Subscribe(announcements.CertificateRotated)\n\n\t// Issues a send all response on a connecting envoy\n\t// If this were to fail, it most likely just means we still have configuration being applied on flight,\n\t// which will get triggered by the dispatcher anyway\n\terr = s.sendResponse(mapset.NewSetWith(\n\t\tenvoy.TypeCDS,\n\t\tenvoy.TypeEDS,\n\t\tenvoy.TypeLDS,\n\t\tenvoy.TypeRDS,\n\t\tenvoy.TypeSDS),\n\t\tproxy, &server, nil, s.cfg)\n\tif err != nil {\n\t\tlog.Error().Err(err).Msgf(\"Initial sendResponse for proxy %s returned error\", proxy.GetCertificateSerialNumber())\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tmetricsstore.DefaultMetricsStore.ProxyConnectCount.Dec()\n\t\t\treturn nil\n\n\t\tcase <-quit:\n\t\t\tlog.Debug().Msgf(\"gRPC stream with Envoy on Pod with UID=%s closed!\", proxy.GetPodUID())\n\t\t\tmetricsstore.DefaultMetricsStore.ProxyConnectCount.Dec()\n\t\t\treturn nil\n\n\t\tcase discoveryRequest, ok := <-requests:\n\t\t\tlog.Debug().Msgf(\"Received %s (nonce=%s; version=%s; resources=%v) from Envoy with xDS Certificate SerialNumber=%s on Pod with UID=%s\",\n\t\t\t\tdiscoveryRequest.TypeUrl, discoveryRequest.ResponseNonce, discoveryRequest.VersionInfo, discoveryRequest.ResourceNames, proxy.GetCertificateSerialNumber(), proxy.GetPodUID())\n\t\t\tlog.Debug().Msgf(\"Last sent for %s nonce=%s; last sent version=%s for Envoy with xDS Certificate SerialNumber=%s on Pod with UID=%s\",\n\t\t\t\tdiscoveryRequest.TypeUrl, discoveryRequest.ResponseNonce, discoveryRequest.VersionInfo, proxy.GetCertificateSerialNumber(), proxy.GetPodUID())\n\t\t\tif !ok {\n\t\t\t\tlog.Error().Msgf(\"Envoy with xDS Certificate SerialNumber=%s on Pod with UID=%s closed gRPC!\", proxy.GetCertificateSerialNumber(), proxy.GetPodUID())\n\t\t\t\tmetricsstore.DefaultMetricsStore.ProxyConnectCount.Dec()\n\t\t\t\treturn errGrpcClosed\n\t\t\t}\n\n\t\t\tif discoveryRequest.ErrorDetail != nil {\n\t\t\t\tlog.Error().Msgf(\"[NACK] DiscoveryRequest error from Envoy with xDS Certificate SerialNumber=%s on Pod with UID=%s: %s\",\n\t\t\t\t\tproxy.GetCertificateSerialNumber(), proxy.GetPodUID(), discoveryRequest.ErrorDetail)\n\t\t\t\t// NOTE(draychev): We could also return errEnvoyError - but it seems appropriate to also ignore this request and continue on.\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\ttypeURL, ok := envoy.ValidURI[discoveryRequest.TypeUrl]\n\t\t\tif !ok {\n\t\t\t\tlog.Error().Err(err).Msgf(\"Unknown/Unsupported URI: %s\", discoveryRequest.TypeUrl)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// It is possible for Envoy to return an empty VersionInfo.\n\t\t\t// When that's the case - start with 0\n\t\t\tackVersion := uint64(0)\n\t\t\tif discoveryRequest.VersionInfo != \"\" {\n\t\t\t\tif ackVersion, err = strconv.ParseUint(discoveryRequest.VersionInfo, 10, 64); err != nil {\n\t\t\t\t\t// It is probable that Envoy responded with a VersionInfo we did not understand\n\t\t\t\t\t// We log this and continue. The ackVersion will be 0 in this state.\n\t\t\t\t\tlog.Error().Err(err).Msgf(\"Error parsing DiscoveryRequest with TypeURL=%s VersionInfo=%s from Envoy with Certificate SerialNumber=%s on Pod with UID=%s\",\n\t\t\t\t\t\ttypeURL, discoveryRequest.VersionInfo, proxy.GetCertificateSerialNumber(), proxy.GetPodUID())\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlog.Debug().Msgf(\"Incoming Discovery Request %s (nonce=%s; version=%d) from Envoy with xDS Certificate SerialNumber=%s on Pod with UID=%s; last applied version: %d\",\n\t\t\t\tdiscoveryRequest.TypeUrl,\n\t\t\t\tdiscoveryRequest.ResponseNonce,\n\t\t\t\tackVersion,\n\t\t\t\tproxy.GetCertificateSerialNumber(),\n\t\t\t\tproxy.GetPodUID(),\n\t\t\t\tproxy.GetLastAppliedVersion(typeURL))\n\n\t\t\tlog.Debug().Msgf(\"Last sent nonce=%s; last sent version=%d for Envoy with xDS Certificate SerialNumber=%s on Pod with UID=%s\",\n\t\t\t\tproxy.GetLastSentNonce(typeURL),\n\t\t\t\tproxy.GetLastSentVersion(typeURL),\n\t\t\t\tproxy.GetCertificateSerialNumber(),\n\t\t\t\tproxy.GetPodUID())\n\n\t\t\tproxy.SetLastAppliedVersion(typeURL, ackVersion)\n\n\t\t\t// In the DiscoveryRequest we have a VersionInfo field.\n\t\t\t// When this is smaller or equal to what we last sent to this proxy - it is\n\t\t\t// interpreted as an acknowledgement of a previously sent request.\n\t\t\t// Such DiscoveryRequest requires no further action.\n\t\t\tif ackVersion > 0 && ackVersion <= proxy.GetLastSentVersion(typeURL) {\n\t\t\t\tlog.Debug().Msgf(\"Skipping request of type %s from Envoy on Pod with UID=%s for resources (%v), VersionInfo (%d) <= last sent VersionInfo (%d); ACK\",\n\t\t\t\t\ttypeURL, proxy.GetPodUID(), discoveryRequest.ResourceNames, ackVersion, proxy.GetLastSentVersion(typeURL))\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// The version of the config received along with the DiscoveryRequest (ackVersion)\n\t\t\t// is what the Envoy proxy may be acknowledging. It is acknowledging\n\t\t\t// and not requesting when the ackVersion is <= what we last sent.\n\t\t\t// It is possible however for a proxy to have a version that is higher\n\t\t\t// than what we last sent. (Perhaps the control plane restarted.)\n\t\t\t// In that case we want to make sure that we send new responses with\n\t\t\t// VersionInfo incremented starting with the version which the proxy last had.\n\t\t\tif ackVersion > proxy.GetLastSentVersion(typeURL) {\n\t\t\t\tproxy.SetLastSentVersion(typeURL, ackVersion)\n\t\t\t}\n\n\t\t\tlastNonce := proxy.GetLastSentNonce(typeURL)\n\t\t\tif lastNonce != \"\" && discoveryRequest.ResponseNonce == lastNonce {\n\t\t\t\tlog.Debug().Msgf(\"Nothing changed for Envoy on Pod with UID=%s since Nonce=%s\", proxy.GetPodUID(), discoveryRequest.ResponseNonce)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif discoveryRequest.ResponseNonce != \"\" {\n\t\t\t\tlog.Debug().Msgf(\"Received discovery request with Nonce=%s from Envoy on Pod with UID=%s; matches=%t; proxy last Nonce=%s\",\n\t\t\t\t\tdiscoveryRequest.ResponseNonce, proxy.GetPodUID(), discoveryRequest.ResponseNonce == lastNonce, lastNonce)\n\t\t\t}\n\t\t\txdsShortName := envoy.XDSShortURINames[typeURL]\n\t\t\tlog.Info().Msgf(\"Discovery request <%s> for resources (%v) from Envoy UID=<%s> with Nonce=%s\",\n\t\t\t\txdsShortName, discoveryRequest.ResourceNames, proxy.GetPodUID(), discoveryRequest.ResponseNonce)\n\n\t\t\tvar xdsUpdatePaths mapset.Set\n\t\t\tswitch typeURL {\n\t\t\tcase envoy.TypeWildcard:\n\t\t\t\txdsUpdatePaths = mapset.NewSetWith(\n\t\t\t\t\tenvoy.TypeCDS,\n\t\t\t\t\tenvoy.TypeEDS,\n\t\t\t\t\tenvoy.TypeLDS,\n\t\t\t\t\tenvoy.TypeRDS,\n\t\t\t\t\tenvoy.TypeSDS)\n\t\t\tdefault:\n\t\t\t\txdsUpdatePaths = mapset.NewSetWith(typeURL)\n\t\t\t}\n\n\t\t\terr = s.sendResponse(xdsUpdatePaths, proxy, &server, &discoveryRequest, s.cfg)\n\t\t\tif err != nil {\n\t\t\t\tlog.Error().Err(err).Msgf(\"Failed to create and send %s update to Envoy with xDS Certificate SerialNumber=%s on Pod with UID=%s\",\n\t\t\t\t\tenvoy.XDSShortURINames[typeURL], proxy.GetCertificateSerialNumber(), proxy.GetPodUID())\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\tcase <-broadcastUpdate:\n\t\t\tlog.Info().Msgf(\"Broadcast wake for Proxy SerialNumber=%s UID=%s\", proxy.GetCertificateSerialNumber(), proxy.GetPodUID())\n\t\t\terr := s.sendResponse(mapset.NewSetWith(\n\t\t\t\tenvoy.TypeCDS,\n\t\t\t\tenvoy.TypeEDS,\n\t\t\t\tenvoy.TypeLDS,\n\t\t\t\tenvoy.TypeRDS,\n\t\t\t\tenvoy.TypeSDS),\n\t\t\t\tproxy, &server, nil, s.cfg)\n\t\t\tif err != nil {\n\t\t\t\tlog.Error().Err(err).Msgf(\"Failed to create and send ADS update to Envoy with xDS Certificate SerialNumber=%s on Pod with UID=%s\",\n\t\t\t\t\tproxy.GetCertificateSerialNumber(), proxy.GetPodUID())\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\tcase certUpdateMsg := <-certAnnouncement:\n\t\t\tcertificate := certUpdateMsg.(events.PubSubMessage).NewObj.(certificate.Certificater)\n\t\t\tif isCNforProxy(proxy, certificate.GetCommonName()) {\n\t\t\t\t// The CN whose corresponding certificate was updated (rotated) by the certificate provider is associated\n\t\t\t\t// with this proxy, so update the secrets corresponding to this certificate via SDS.\n\t\t\t\tlog.Debug().Msgf(\"Certificate has been updated for proxy with SerialNumber=%s, UID=%s\", proxy.GetCertificateSerialNumber(), proxy.GetPodUID())\n\t\t\t\t// Empty DiscoveryRequest should create the SDS specific request\n\t\t\t\terr := s.sendResponse(mapset.NewSetWith(envoy.TypeSDS), proxy, &server, nil, s.cfg)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Error().Err(err).Msgf(\"Failed to create and send SDS update to Envoy with xDS Certificate SerialNumber=%s on Pod with UID=%s\",\n\t\t\t\t\t\tproxy.GetCertificateSerialNumber(), proxy.GetPodUID())\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "9c07e496f968cbbf781542fbe75ffc4d", "score": "0.50345623", "text": "func PushRegionResources(req *restful.Request, resp *restful.Response) {\n\tresourcesReq := new(types.RegionResourcesReq)\n\terr := req.ReadEntity(&resourcesReq)\n\tif err != nil {\n\t\tklog.Errorf(\"Failed to unmarshall region resources from request body, err: %s\", err)\n\t\tutils.WriteFailedJSONResponse(resp, http.StatusBadRequest, utils.RequestBodyParamInvalid(err.Error()))\n\t\treturn\n\t}\n\tklog.Infof(\"RegionResourceReq: %s\", utils.GetJSONString(resourcesReq))\n\tresources := resourcesReq.RegionResources\n\tsched := scheduler.GetScheduler()\n\tif sched == nil {\n\t\tklog.Errorf(\"Scheduler is not initialized, please wait...\")\n\t\tutils.WriteFailedJSONResponse(resp, http.StatusInternalServerError, utils.InternalServerError())\n\t\treturn\n\t}\n\tfor _, resource := range resources {\n\t\terr = sched.UpdateSiteDynamicResource(resource.RegionName, &types.SiteResource{CPUMemResources: resource.CPUMemResources, VolumeResources: resource.VolumeResources})\n\t\tif err != nil {\n\t\t\tklog.Errorf(\"Schedule to update site dynamic resource for region %s with err %v\", resource.RegionName, err)\n\t\t\tutils.WriteFailedJSONResponse(resp, http.StatusInternalServerError, utils.InternalServerWithError(err.Error()))\n\t\t\treturn\n\t\t}\n\t}\n\tresourceResp := types.SiteResourceRes{Result: \"ok\"}\n\tresp.WriteHeaderAndEntity(http.StatusCreated, resourceResp)\n}", "title": "" }, { "docid": "c9ffc8fcc9fd05516814a8ab70430772", "score": "0.50210166", "text": "func (client *Client) UntagResources(request *UntagResourcesRequest) (_result *UntagResourcesResponse, _err error) {\n\truntime := &util.RuntimeOptions{}\n\t_result = &UntagResourcesResponse{}\n\t_body, _err := client.UntagResourcesWithOptions(request, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_result = _body\n\treturn _result, _err\n}", "title": "" }, { "docid": "c9ffc8fcc9fd05516814a8ab70430772", "score": "0.50210166", "text": "func (client *Client) UntagResources(request *UntagResourcesRequest) (_result *UntagResourcesResponse, _err error) {\n\truntime := &util.RuntimeOptions{}\n\t_result = &UntagResourcesResponse{}\n\t_body, _err := client.UntagResourcesWithOptions(request, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_result = _body\n\treturn _result, _err\n}", "title": "" }, { "docid": "b5a287735abfd759c269590d07417b34", "score": "0.5019825", "text": "func (a KubectlLayerApplier) GetResources(ctx context.Context, layer layers.Layer) (resources []kraanv1alpha1.Resource, err error) {\n\tlogging.TraceCall(a.getLog(layer))\n\tdefer logging.TraceExit(a.getLog(layer))\n\n\tsourceHrs, clusterHrs, err := a.GetSourceAndClusterHelmReleases(ctx, layer)\n\tif err != nil {\n\t\treturn nil, errors.WithMessagef(err, \"%s - failed to get helm releases\", logging.CallerStr(logging.Me))\n\t}\n\n\tfor key, source := range sourceHrs {\n\t\tresource := kraanv1alpha1.Resource{\n\t\t\tNamespace: source.GetNamespace(),\n\t\t\tName: source.GetName(),\n\t\t\tKind: \"helmreleases.helm.toolkit.fluxcd.io\",\n\t\t\tLastTransitionTime: metav1.Now(),\n\t\t\tStatus: \"Unknown\",\n\t\t}\n\t\thr, ok := clusterHrs[key]\n\t\tif ok {\n\t\t\ta.logDebug(\"HelmRelease in AddonsLayer source directory and on cluster\", layer, logging.GetObjKindNamespaceName(source)...)\n\t\t\tresources = append(resources, a.getResourceInfo(layer, resource, hr.Status.Conditions))\n\t\t} else {\n\t\t\t// this resource exists in the source directory but not on the cluster\n\t\t\ta.logDebug(\"HelmRelease in AddonsLayer source directory but not on cluster\", layer, logging.GetObjKindNamespaceName(source)...)\n\t\t\tresource.Status = kraanv1alpha1.NotDeployed\n\t\t\tresources = append(resources, resource)\n\t\t}\n\t}\n\n\tfor key, hr := range clusterHrs {\n\t\tresource := kraanv1alpha1.Resource{\n\t\t\tNamespace: hr.GetNamespace(),\n\t\t\tName: hr.GetName(),\n\t\t\tKind: \"helmreleases.helm.toolkit.fluxcd.io\",\n\t\t\tLastTransitionTime: metav1.Now(),\n\t\t\tStatus: \"Unknown\",\n\t\t}\n\t\t_, ok := sourceHrs[key]\n\t\tif !ok {\n\t\t\ta.logDebug(\"HelmRelease not in AddonsLayer source directory but on cluster\", layer, \"name\", clusterHrs[key])\n\t\t\tresources = append(resources, a.getResourceInfo(layer, resource, hr.Status.Conditions))\n\t\t}\n\t}\n\treturn resources, err\n}", "title": "" }, { "docid": "1e51f822566c30de7bc3f0962de804b4", "score": "0.50124806", "text": "func (g *RoleGenerator) InitResources() error {\n\tclient := g.Args[\"mackerelClient\"].(*mackerel.Client)\n\n\tservices, err := client.FindServices()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, service := range services {\n\t\troles, err := client.FindRoles(service.Name)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tg.Resources = append(g.Resources, g.createResources(service.Name, roles)...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c8821367cf203983faa939475d92e0c0", "score": "0.49934888", "text": "func (s *MultipassServer) Refresh(ctx context.Context, request *apigrpc.CloudProviderServiceRequest) (*apigrpc.RefreshReply, error) {\n\tglog.V(5).Infof(\"Call server Refresh: %v\", request)\n\n\tif request.GetProviderID() != s.Configuration.ProviderID {\n\t\tglog.Errorf(errMismatchingProvider)\n\t\treturn nil, fmt.Errorf(errMismatchingProvider)\n\t}\n\n\tfor _, ng := range s.Groups {\n\t\tng.refresh()\n\t}\n\n\tif phSaveState {\n\t\tif err := s.save(phSavedState); err != nil {\n\t\t\tglog.Errorf(errFailedToSaveServerState, err)\n\t\t}\n\t}\n\n\treturn &apigrpc.RefreshReply{\n\t\tError: nil,\n\t}, nil\n}", "title": "" }, { "docid": "ce8f0bc2ccfe1b259ee45fe57f697447", "score": "0.49883077", "text": "func (r *ReconcileHyperConverged) getAllResources(cr *hcov1alpha1.HyperConverged, request reconcile.Request) []runtime.Object {\n\treturn []runtime.Object{\n\t\tnewKubeVirtConfigForCR(cr, request.Namespace),\n\t\tnewKubeVirtForCR(cr, request.Namespace),\n\t\tnewCDIForCR(cr, UndefinedNamespace),\n\t\tnewNetworkAddonsForCR(cr, UndefinedNamespace),\n\t\tnewKubeVirtCommonTemplateBundleForCR(cr, OpenshiftNamespace),\n\t\tnewKubeVirtNodeLabellerBundleForCR(cr, request.Namespace),\n\t\tnewKubeVirtTemplateValidatorForCR(cr, request.Namespace),\n\t}\n}", "title": "" }, { "docid": "15e5dbe8bacec96ee4d15774acddd9c3", "score": "0.49803856", "text": "func (m KubedgeBaseManager) BaseReconcileResource(ctx context.Context) (*av1.SubResourceList, error) {\n\terrs := make([]error, 0)\n\treconciled := av1.NewSubResourceList(m.PhaseNamespace, m.PhaseName)\n\n\tif m.DeployedSubResourceList == nil {\n\t\t// There was an error during SyncResource\n\t\treturn reconciled, ErrReconcile\n\t}\n\n\trendered, err := m.Render(ctx)\n\tif err != nil {\n\t\treturn m.DeployedSubResourceList, err\n\t}\n\n\tfor _, renderedResource := range rendered.Items {\n\t\texistingResource := unstructured.Unstructured{}\n\t\texistingResource.SetAPIVersion(renderedResource.GetAPIVersion())\n\t\texistingResource.SetKind(renderedResource.GetKind())\n\t\texistingResource.SetName(renderedResource.GetName())\n\t\texistingResource.SetNamespace(renderedResource.GetNamespace())\n\n\t\terr := m.KubeClient.Get(context.TODO(), types.NamespacedName{Name: existingResource.GetName(), Namespace: existingResource.GetNamespace()}, &existingResource)\n\t\tif err != nil {\n\t\t\tif !apierrors.IsNotFound(err) {\n\t\t\t\tlog.Error(err, \"Can't Retrieve Resource\", \"kind\", existingResource.GetKind(), \"name\", existingResource.GetName())\n\t\t\t\terrs = append(errs, err)\n\t\t\t}\n\t\t} else {\n\t\t\tif renderedResource.GetKind() == \"StatefulSet\" {\n\n\t\t\t\texistingStatefulSet := v1.StatefulSet{}\n\t\t\t\terr1 := runtime.DefaultUnstructuredConverter.FromUnstructured(existingResource.UnstructuredContent(), &existingStatefulSet)\n\t\t\t\tif err1 != nil {\n\t\t\t\t\tlog.Error(err1, \"error converting existingResource from Unstructured\")\n\t\t\t\t}\n\n\t\t\t\trenderedStatefulSet := v1.StatefulSet{}\n\t\t\t\terr2 := runtime.DefaultUnstructuredConverter.FromUnstructured(renderedResource.UnstructuredContent(), &renderedStatefulSet)\n\t\t\t\tif err2 != nil {\n\t\t\t\t\tlog.Error(err2, \"error converting from renderedResource Unstructured\")\n\t\t\t\t}\n\n\t\t\t\tif (existingStatefulSet.Spec.Replicas != nil) && (renderedStatefulSet.Spec.Replicas != nil) && (*existingStatefulSet.Spec.Replicas != *renderedStatefulSet.Spec.Replicas) {\n\t\t\t\t\t// A merge patch will preserve other fields modified at runtime.\n\t\t\t\t\tpatch := client.MergeFrom(existingResource.DeepCopy())\n\n\t\t\t\t\t// JEB: Seems convolutedy, probably needs to go through golang training again\n\t\t\t\t\texistingStatefulSet.Spec.Replicas = new(int32)\n\t\t\t\t\t*existingStatefulSet.Spec.Replicas = *renderedStatefulSet.Spec.Replicas\n\t\t\t\t\tunst, err3 := runtime.DefaultUnstructuredConverter.ToUnstructured(&existingStatefulSet)\n\t\t\t\t\tif err3 != nil {\n\t\t\t\t\t\tlog.Error(err3, \"error converting to Unstructured\")\n\t\t\t\t\t}\n\t\t\t\t\texistingResource.SetUnstructuredContent(unst)\n\n\t\t\t\t\terr := m.KubeClient.Patch(context.TODO(), &existingResource, patch)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tif !apierrors.IsNotFound(err) {\n\t\t\t\t\t\t\tlog.Error(err, \"Can't Patch Resource\", \"kind\", existingResource.GetKind(), \"name\", existingResource.GetName())\n\t\t\t\t\t\t\terrs = append(errs, err)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlog.Info(\"Patched Resource\", \"kind\", existingResource.GetKind(), \"name\", existingResource.GetName())\n\t\t\t\t\t\treconciled.Items = append(reconciled.Items, existingResource)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treconciled.Items = append(reconciled.Items, existingResource)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treconciled.Items = append(reconciled.Items, existingResource)\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(errs) != 0 {\n\t\treturn reconciled, errs[0]\n\t}\n\treturn reconciled, nil\n}", "title": "" }, { "docid": "1bf00c207ceaaba6ffb779d11a7e61e8", "score": "0.49749467", "text": "func collectNamespacedResources(discovery discovery.DiscoveryInterface) ([]*metav1.APIResourceList, error) {\n\tresources, err := discovery.ServerResources()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, res := range resources {\n\t\tres.APIResources = namespaced(res.APIResources)\n\t\tres.APIResources = excludeSubresources(res.APIResources)\n\t\t// Some resources appear not to have permissions to list, need to exclude those.\n\t\tres.APIResources = listAllowed(res.APIResources)\n\t}\n\n\treturn resources, nil\n}", "title": "" }, { "docid": "78ca082c52d66621784d4adb5c75bda1", "score": "0.49734512", "text": "func (n *resPool) UpdateResourceMetrics() {\n\tn.RLock()\n\tdefer n.RUnlock()\n\tn.updateStaticResourceMetrics()\n\tn.updateDynamicResourceMetrics()\n}", "title": "" }, { "docid": "b581af38e2fd9f132e83d9b0e9ec9888", "score": "0.49730334", "text": "func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) {\n\tprovider := &instanceProvider{instanceAPI: instance.NewAPI(p.client), profile: p.profile}\n\treturn provider.GetResource(ctx)\n}", "title": "" }, { "docid": "afa559004000d58cfdd160edc5ec70b3", "score": "0.49709213", "text": "func (c *Controller) cleanupNegotiatedAPIResource(ctx context.Context, clusterName string, gvr metav1.GroupVersionResource, negotiatedApiResource *apiresourcev1alpha1.NegotiatedAPIResource) error {\n\t// In any case change the status on every APIResourceImport with the same GVR, to remove Compatible and Available conditions.\n\n\tobjs, err := c.apiResourceImportIndexer.ByIndex(clusterNameAndGVRIndexName, GetClusterNameAndGVRIndexKey(clusterName, gvr))\n\tif err != nil {\n\t\tklog.Errorf(\"Error in %s: %v\", runtime.GetCaller(), err)\n\t\treturn err\n\t}\n\tfor _, obj := range objs {\n\t\tapiResourceImport := obj.(*apiresourcev1alpha1.APIResourceImport).DeepCopy()\n\t\tapiResourceImport.RemoveCondition(apiresourcev1alpha1.Available)\n\t\tapiResourceImport.RemoveCondition(apiresourcev1alpha1.Compatible)\n\t\tif _, err := c.kcpClient.ApiresourceV1alpha1().APIResourceImports().UpdateStatus(ctx, apiResourceImport, metav1.UpdateOptions{}); err != nil {\n\t\t\tklog.Errorf(\"Error in %s: %v\", runtime.GetCaller(), err)\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// if a CRD with the same GR has a version == to the current NegotiatedAPIResource version *and* has the current object as owner:\n\t// => if this CRD version is the only one, then delete the CRD\n\t// else remove this CRD version from the CRD, as well as the corresponding owner\n\n\tcrdName := gvr.Resource\n\tif gvr.Group == \"\" {\n\t\tcrdName = crdName + \".core\"\n\t} else {\n\t\tcrdName = crdName + \".\" + gvr.Group\n\t}\n\n\tcrdKey, err := cache.MetaNamespaceKeyFunc(&metav1.PartialObjectMetadata{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: crdName,\n\t\t\tClusterName: clusterName,\n\t\t},\n\t})\n\tif err != nil {\n\t\tklog.Errorf(\"Error in %s: %v\", runtime.GetCaller(), err)\n\t\treturn err\n\t}\n\tcrd, err := c.crdLister.Get(crdKey)\n\tif k8serrors.IsNotFound(err) {\n\t\treturn nil\n\t}\n\tif err != nil {\n\t\tklog.Errorf(\"Error in %s: %v\", runtime.GetCaller(), err)\n\t\treturn err\n\t}\n\n\tvar ownerReferenceAlreadyExists bool\n\tvar cleanedOwnerReferences []metav1.OwnerReference\n\tfor _, ownerRef := range crd.OwnerReferences {\n\t\tif ownerRef.Name == negotiatedApiResource.Name && ownerRef.UID == negotiatedApiResource.UID {\n\t\t\townerReferenceAlreadyExists = true\n\t\t\tcontinue\n\t\t}\n\t\tcleanedOwnerReferences = append(cleanedOwnerReferences, ownerRef)\n\t}\n\tif !ownerReferenceAlreadyExists {\n\t\treturn nil\n\t}\n\n\tvar cleanedVersions []apiextensionsv1.CustomResourceDefinitionVersion\n\tfor _, version := range crd.Spec.Versions {\n\t\tif version.Name == gvr.Version {\n\t\t\tcontinue\n\t\t}\n\t\tcleanedVersions = append(cleanedVersions, version)\n\t}\n\tif len(cleanedVersions) == len(crd.Spec.Versions) {\n\t\treturn nil\n\t}\n\tif len(cleanedVersions) == 0 {\n\t\tif err := c.apiExtensionsClient.ApiextensionsV1().CustomResourceDefinitions().Delete(ctx, crd.Name, metav1.DeleteOptions{}); err != nil {\n\t\t\tklog.Errorf(\"Error in %s: %v\", runtime.GetCaller(), err)\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\tcrd = crd.DeepCopy()\n\t\tcrd.Spec.Versions = cleanedVersions\n\t\tcrd.OwnerReferences = cleanedOwnerReferences\n\t\tif _, err := c.apiExtensionsClient.ApiextensionsV1().CustomResourceDefinitions().Update(ctx, crd, metav1.UpdateOptions{}); err != nil {\n\t\t\tklog.Errorf(\"Error in %s: %v\", runtime.GetCaller(), err)\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "44768b45bd06381681afdf263e371c3c", "score": "0.49633512", "text": "func (wd WorkerDiscovery) Refresh(regions Regions, intervalMinutes int) {\n\tfor true {\n\t\tfor prefix, data := range regions.regionMap {\n\t\t\t// bit yuck can't do async, cause can't do concurrent map writes\n\t\t\twd.GetWorker(prefix, data.InitialLocation, data.ShowInCityList)\n\t\t}\n\t\ttime.Sleep(time.Minute * time.Duration(intervalMinutes))\n\t}\n}", "title": "" }, { "docid": "8949d2d39f4652b566ec96274f5cb091", "score": "0.4945644", "text": "func (c *Clients) GetKubeResources(r *ReleaseData) (map[string]interface{}, error) {\n\tlog.Printf(\"Getting resources for %s\", r.Name)\n\tif r.Manifest == \"\" {\n\t\treturn nil, errors.New(\"manifest not provided in the request\")\n\t}\n\tresources := map[string]interface{}{}\n\tinfos, err := c.getManifestDetails(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tnamespace := \"default\"\n\tfor _, info := range infos {\n\t\tvar spec interface{}\n\t\tkind := info.Object.GetObjectKind().GroupVersionKind().GroupKind().Kind\n\t\tv := kube.AsVersioned(info)\n\t\tif checkSize(resources, ResourcesOutputSize) {\n\t\t\tbreak\n\t\t}\n\n\t\tif stringInSlice(reflect.TypeOf(v).String(), ResourcesOutputIgnoredTypes) {\n\t\t\tcontinue\n\t\t}\n\t\tinner := make(map[string]interface{})\n\t\tname, ok := ScanFromStruct(v, \"ObjectMeta.Name\")\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\t\tns, ok := ScanFromStruct(v, \"ObjectMeta.Namespace\")\n\t\tif ok {\n\t\t\tnamespace = fmt.Sprint(ns)\n\t\t}\n\t\tif stringInSlice(reflect.TypeOf(v).String(), ResourcesOutputIncludedSpec) {\n\t\t\tspec, ok = ScanFromStruct(v, \"Spec\")\n\t\t\tif ok {\n\t\t\t\tspec = structToMap(spec)\n\t\t\t}\n\t\t}\n\t\tstatus, ok := ScanFromStruct(v, \"Status\")\n\t\tif ok {\n\t\t\tstatus = structToMap(status)\n\t\t}\n\t\tinner = map[string]interface{}{\n\t\t\tfmt.Sprint(name): map[string]interface{}{\n\t\t\t\t\"Namespace\": namespace,\n\t\t\t\t\"Spec\": spec,\n\t\t\t\t\"Status\": status,\n\t\t\t},\n\t\t}\n\t\tif IsZero(resources[kind]) {\n\t\t\tresources[kind] = map[string]interface{}{}\n\t\t}\n\t\ttemp := resources[kind].(map[string]interface{})\n\t\tresources[kind] = mergeMaps(temp, inner)\n\t}\n\treturn resources, nil\n}", "title": "" }, { "docid": "f8c2f27d47d57b014e70bfe1c5d721f5", "score": "0.4939403", "text": "func UpdateAllDynamicResources(client client.Client, log logr.Logger, scheme *runtime.Scheme, cache *helpers.ResourceCache) (ctrl.Result, error) {\n\t// Clear the watched roles cache maps since we're about to recreate them anyway - gets rid of anything we used to care about but no longer need\n\tcache.WatchedRoles = map[types.NamespacedName]bool{}\n\tcache.WatchedClusterRoles = map[types.NamespacedName]bool{}\n\n\tdynamicRoleList := &rbacv1alpha1.DynamicRoleList{}\n\terr := client.List(context.TODO(), dynamicRoleList)\n\tif err != nil {\n\t\tlog.Error(err, \"could not list Dynamic Roles\")\n\t\treturn reconcile.Result{}, err\n\t}\n\tfor _, dynamicRole := range dynamicRoleList.Items {\n\t\t_, err := ReconcileDynamicRole(&dynamicRole, client, scheme, log, cache)\n\t\tif err != nil {\n\t\t\treturn reconcile.Result{}, err\n\t\t}\n\t}\n\tdynamicClusterRoleList := &rbacv1alpha1.DynamicClusterRoleList{}\n\terr = client.List(context.TODO(), dynamicClusterRoleList)\n\tif err != nil {\n\t\tlog.Error(err, \"could not list Dynamic Cluster Roles\")\n\t\treturn reconcile.Result{}, err\n\t}\n\tfor _, dynamicClusterRole := range dynamicClusterRoleList.Items {\n\t\t_, err := ReconcileDynamicClusterRole(&dynamicClusterRole, client, scheme, log, cache)\n\t\tif err != nil {\n\t\t\treturn reconcile.Result{}, err\n\t\t}\n\t}\n\tlog.Info(\"All computed roles have been reconciled\")\n\treturn reconcile.Result{}, nil\n}", "title": "" }, { "docid": "d1b453c602a1cf25dc83e8a2800506be", "score": "0.49337515", "text": "func (n *resPool) updateDynamicResourceMetrics() {\n\tn.metrics.TotalEntitlement.Update(n.entitlement)\n\tn.metrics.SlackEntitlement.Update(n.slackEntitlement)\n\tn.metrics.NonSlackEntitlement.Update(n.nonSlackEntitlement)\n\n\tn.metrics.TotalAllocation.Update(n.allocation.GetByType(\n\t\tscalar.TotalAllocation))\n\tn.metrics.SlackAllocation.Update(n.allocation.GetByType(\n\t\tscalar.SlackAllocation))\n\tn.metrics.NonPreemptibleAllocation.Update(n.allocation.GetByType(\n\t\tscalar.NonPreemptibleAllocation))\n\tn.metrics.ControllerAllocation.Update(n.allocation.GetByType(\n\t\tscalar.ControllerAllocation))\n\tn.metrics.NonSlackAllocation.Update(n.allocation.GetByType(\n\t\tscalar.NonSlackAllocation))\n\n\tn.metrics.NonSlackAvailable.Update(n.nonSlackEntitlement.\n\t\tSubtract(n.allocation.GetByType(scalar.NonSlackAllocation)))\n\tn.metrics.SlackAvailable.Update(n.slackEntitlement.\n\t\tSubtract(n.allocation.GetByType(scalar.SlackAllocation)))\n\n\tn.metrics.Demand.Update(n.demand)\n\tn.metrics.SlackDemand.Update(n.slackDemand)\n\n\tn.metrics.PendingQueueSize.Update(float64(n.aggregateQueueByType(PendingQueue)))\n\tn.metrics.RevocableQueueSize.Update(float64(n.aggregateQueueByType(RevocableQueue)))\n\tn.metrics.ControllerQueueSize.Update(float64(n.aggregateQueueByType(ControllerQueue)))\n\tn.metrics.NPQueueSize.Update(float64(n.aggregateQueueByType(NonPreemptibleQueue)))\n}", "title": "" }, { "docid": "56f1e2f9ad2a15fefa6ff3ff65a72db8", "score": "0.4932128", "text": "func monitoringExporter(ctx context.Context, getRsc ResourceAvailable, refreshInterval time.Duration, logger *log.Logger) {\n\n\tlastRefresh := time.Now()\n\n\tresourceMonitor.Do(func() {\n\t\trefresh := time.NewTicker(30 * time.Second)\n\t\tdefer refresh.Stop()\n\n\t\tlastMsg := \"\"\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-refresh.C:\n\t\t\t\tmsg := getRsc.FetchMachineResources().String()\n\t\t\t\tif lastMsg != msg || time.Since(lastRefresh) > time.Duration(20*time.Minute) {\n\t\t\t\t\tlastRefresh = time.Now()\n\t\t\t\t\tlogger.Info(\"capacity\", \"available\", msg)\n\t\t\t\t\tlastMsg = msg\n\t\t\t\t}\n\t\t\tcase <-ctx.Done():\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t})\n\n\trefresh := time.NewTicker(refreshInterval)\n\tdefer refresh.Stop()\n\n\tfor {\n\t\tselect {\n\t\tcase <-refresh.C:\n\t\t\t// The function will update our resource consumption gauges for the\n\t\t\t// host we are running on\n\t\t\tupdateGauges(getRsc.FetchMachineResources())\n\n\t\tcase <-ctx.Done():\n\t\t\treturn\n\t\t}\n\t}\n}", "title": "" }, { "docid": "912774a8ddd3a6678b16fcaa5ba6d88f", "score": "0.49319488", "text": "func (m *Meta) LoadResources(f Factory) error {\n\tm.mx.Lock()\n\tdefer m.mx.Unlock()\n\n\tm.resMetas = make(ResourceMetas, 100)\n\tif err := loadPreferred(f, m.resMetas); err != nil {\n\t\treturn err\n\t}\n\tloadNonResource(m.resMetas)\n\tloadCRDs(f, m.resMetas)\n\n\treturn nil\n}", "title": "" }, { "docid": "8e9b131623ab61e3c3391dd6483c7dcc", "score": "0.49273658", "text": "func SetAPIResources(apiresList []*metav1.APIResourceList) {\n\tkubeAPIResourceList = apiresList\n}", "title": "" }, { "docid": "09b01ea89b8599ea204ba0783a218cd1", "score": "0.49241492", "text": "func (r *Fireboard) Gather(acc telegraf.Accumulator) error {\n\t// Perform the GET request to the fireboard servers\n\treq, err := http.NewRequest(\"GET\", r.URL, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq.Header.Set(\"Authorization\", \"Token \"+r.AuthToken)\n\tresp, err := r.client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\n\t// Successful responses will always return status code 200\n\tif resp.StatusCode != http.StatusOK {\n\t\tif resp.StatusCode == http.StatusForbidden {\n\t\t\treturn fmt.Errorf(\"fireboard server responded with %d [Forbidden], verify your authToken\", resp.StatusCode)\n\t\t}\n\t\treturn fmt.Errorf(\"fireboard responded with unexpected status code %d\", resp.StatusCode)\n\t}\n\t// Decode the response JSON into a new stats struct\n\tvar stats []fireboardStats\n\tif err := json.NewDecoder(resp.Body).Decode(&stats); err != nil {\n\t\treturn fmt.Errorf(\"unable to decode fireboard response: %w\", err)\n\t}\n\t// Range over all devices, gathering stats. Returns early in case of any error.\n\tfor _, s := range stats {\n\t\tr.gatherTemps(s, acc)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "6531a1d78bc64efef4c1c10149974e24", "score": "0.4917317", "text": "func TestPopulateResources(t *testing.T) {\n\ttestName := \"TestPopulateResources\"\n\n\tbeforeTest()\n\t// kinds to check for status\n\tvar kindsToCheckStatus = map[string]bool{}\n\n\tvar files = []string{\n\t\tKappnavConfigFile,\n\t\tCrdApplication,\n\t\tappBookinfo,\n\t\tappDetails,\n\t\tdeploymentDetailsV1,\n\t\tserviceDetails,\n\t\tingressBookinfo,\n\t\tappProductpage,\n\t\tnetworkpolicyProductpage,\n\t\tdeploymentProcuctpageV1,\n\t\tserviceProductpage,\n\t\tappRatings,\n\t\tdeploymentRatingsV1,\n\t\tserviceRatings,\n\t\tappReviews,\n\t\tnetworkpolicyReviews,\n\t\tdeploymentReviewsV1,\n\t\tdeploymentReviewsV2,\n\t\tdeploymentReviewsV3,\n\t\tserviceReview,\n\t\tcrdFoo,\n\t\tfooExample,\n\t\tappFoo,\n\t\tkappnavCRFile,\n\t}\n\n\titeration0IDs, err := readResourceIDs(files)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t/* Iteration 0: all normal */\n\ttestActions := newTestActions(testName, kindsToCheckStatus)\n\tvar emptyIDs = []resourceID{}\n\ttestActions.addIteration(iteration0IDs, emptyIDs)\n\n\t/* iteration 1: clean up */\n\ttestActions.addIteration(emptyIDs, emptyIDs)\n\n\t/* create a watcher that populates all resources */\n\tclusterWatcher, err := createClusterWatcher(iteration0IDs, testActions, StatusFailureRate)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer clusterWatcher.shutDown()\n\n\t// ensure we can find each resource\n\tfor _, res := range iteration0IDs {\n\t\texists, _ := resourceExists(clusterWatcher, res)\n\t\tif !exists {\n\t\t\tt.Fatal(fmt.Errorf(\"can't find resource for %s\\n,\", res.fileName))\n\t\t}\n\t}\n\n\terr = testActions.transitionAll()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n}", "title": "" }, { "docid": "f9a5af379af7da5a19e662b942e4aba0", "score": "0.49111217", "text": "func (m *MesosMonitor) Refresh() {\n\n\tm.mesosCache.tasks = m.getTasks()\n\tm.mesosCache.frameworks = m.getProtectedFrameworks()\n\tm.mesosCache.slaves = m.getSlaves()\n}", "title": "" }, { "docid": "b1667bb00cd127f7278fed0c2239b097", "score": "0.4910601", "text": "func GetResourceObjects(clients *Clients, names ResourceNames) (*ResourceObjects, error) {\n\trouteObject, err := clients.ServingClient.Routes.Get(names.Route, metav1.GetOptions{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserviceObject, err := clients.ServingClient.Services.Get(names.Service, metav1.GetOptions{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tconfigObject, err := clients.ServingClient.Configs.Get(names.Config, metav1.GetOptions{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trevisionObject, err := clients.ServingClient.Revisions.Get(names.Revision, metav1.GetOptions{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &ResourceObjects{\n\t\tRoute: routeObject,\n\t\tService: serviceObject,\n\t\tConfig: configObject,\n\t\tRevision: revisionObject,\n\t}, nil\n}", "title": "" }, { "docid": "5003ea80ab68dfd12b15b181c9a38d61", "score": "0.49042162", "text": "func (m *RegeneratingDiscoveryRESTMapper) ResourcesFor(input schema.GroupVersionResource) ([]schema.GroupVersionResource, error) {\n\tm.mu.RLock()\n\tdefer m.mu.RUnlock()\n\n\treturn m.delegate.ResourcesFor(input)\n\n}", "title": "" }, { "docid": "09b1e369c30e4535a8af865ca1ebc554", "score": "0.48990014", "text": "func generateResourceList(mgr manager.Manager, s *releasev1.HelmRelease) (kube.ResourceList, error) {\n\tchartDir, err := downloadChart(mgr.GetClient(), s)\n\tif err != nil {\n\t\tklog.Error(err, \" - Failed to download the chart\")\n\t\treturn nil, err\n\t}\n\n\tvar values map[string]interface{}\n\n\treqBodyBytes := new(bytes.Buffer)\n\n\terr = json.NewEncoder(reqBodyBytes).Encode(s.Spec)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = yaml.Unmarshal(reqBodyBytes.Bytes(), &values)\n\tif err != nil {\n\t\tklog.Error(err, \" - Failed to Unmarshal the spec \", s.Spec)\n\t\treturn nil, err\n\t}\n\n\tklog.V(3).Info(\"ChartDir: \", chartDir)\n\n\tchart, err := loader.LoadDir(chartDir)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load chart dir: %w\", err)\n\t}\n\n\trcg, err := newRESTClientGetter(mgr, s.Namespace)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get REST client getter from manager: %w\", err)\n\t}\n\n\tkubeClient := kube.New(rcg)\n\n\tactionConfig := &action.Configuration{}\n\tif err := actionConfig.Init(rcg, s.GetNamespace(), \"secret\", func(_ string, _ ...interface{}) {}); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to initialized actionConfig: %w\", err)\n\t}\n\n\tinstall := action.NewInstall(actionConfig)\n\tinstall.ReleaseName = s.Name\n\tinstall.Namespace = s.Namespace\n\tinstall.DryRun = true\n\tinstall.ClientOnly = true\n\tinstall.Replace = true\n\n\trelease, err := install.Run(chart, values)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresources, err := kubeClient.Build(bytes.NewBufferString(release.Manifest), false)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to build kubernetes objects from release manifest: %w\", err)\n\t}\n\n\treturn resources, nil\n}", "title": "" }, { "docid": "1ca1e2c0143f79d95e628d4d7c98a3b5", "score": "0.48955333", "text": "func (m *mongoDB) ListSuggestedResources(profileID, lang string) ([]schema.Resource, error) {\n\tctx, cancel := context.WithTimeout(context.Background(), defaultTimeout)\n\tdefer cancel()\n\n\tc := m.client.Database(m.database).Collection(schema.ProfileCollection)\n\tcursor, err := c.Aggregate(ctx, mongo.Pipeline{\n\t\tAggregationMatch(bson.M{\"id\": profileID}),\n\t\tAggregationProject(bson.M{\n\t\t\t\"id\": 1,\n\t\t\t\"points_of_interest.resource_ratings.resources\": 1,\n\t\t}),\n\t\tAggregationUnwind(\"$points_of_interest\"),\n\t\tAggregationUnwind(\"$points_of_interest.resource_ratings.resources\"),\n\t\tAggregationAddFields(bson.M{\n\t\t\t\"resource\": bson.A{\n\t\t\t\tbson.A{\n\t\t\t\t\t\"$points_of_interest.resource_ratings.resources.resource.id\",\n\t\t\t\t\t\"$points_of_interest.resource_ratings.resources.resource\",\n\t\t\t\t},\n\t\t\t},\n\t\t}),\n\t\tAggregationProject(bson.M{\n\t\t\t\"id\": 1,\n\t\t\t\"resource\": bson.M{\n\t\t\t\t\"$arrayToObject\": \"$resource\",\n\t\t\t},\n\t\t}),\n\t\tAggregationGroup(\"$id\", bson.D{\n\t\t\tbson.E{\n\t\t\t\tKey: \"resources\",\n\t\t\t\tValue: bson.M{\n\t\t\t\t\t\"$mergeObjects\": \"$resource\",\n\t\t\t\t},\n\t\t\t},\n\t\t}),\n\t})\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar result []struct {\n\t\tResources map[string]schema.Resource `json:\"resources\" bson:\"resources\"`\n\t}\n\n\tif err := cursor.All(ctx, &result); nil != err {\n\t\treturn nil, err\n\t}\n\n\timportantResources, err := getResourceList(lang, true)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar resources []schema.Resource\n\tif len(result) == 1 {\n\t\tselfOwnedResources := result[0].Resources\n\t\tresources = make([]schema.Resource, 0, len(result[0].Resources))\n\t\tfor id, r := range selfOwnedResources {\n\t\t\tif name, _ := ResolveResourceNameByID(id, lang); name != \"\" {\n\t\t\t\tr.Name = name\n\t\t\t}\n\t\t\tresources = append(resources, r)\n\t\t}\n\n\t\tfor _, r := range importantResources {\n\t\t\tif _, ok := selfOwnedResources[r.ID]; !ok {\n\t\t\t\tresources = append(resources, r)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tresources = importantResources\n\t}\n\n\treturn resources, nil\n}", "title": "" }, { "docid": "1219e7a72396b978cdd46dddf8e4213d", "score": "0.48945653", "text": "func (a *Client) GetSchedulingV1alpha1APIResources(params *GetSchedulingV1alpha1APIResourcesParams) (*GetSchedulingV1alpha1APIResourcesOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewGetSchedulingV1alpha1APIResourcesParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"getSchedulingV1alpha1APIResources\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/apis/scheduling.k8s.io/v1alpha1/\",\n\t\tProducesMediaTypes: []string{\"application/json\", \"application/vnd.kubernetes.protobuf\", \"application/yaml\"},\n\t\tConsumesMediaTypes: []string{\"application/json\", \"application/vnd.kubernetes.protobuf\", \"application/yaml\"},\n\t\tSchemes: []string{\"http\"},\n\t\tParams: params,\n\t\tReader: &GetSchedulingV1alpha1APIResourcesReader{formats: a.formats},\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*GetSchedulingV1alpha1APIResourcesOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for getSchedulingV1alpha1APIResources: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "title": "" }, { "docid": "de6dd22fd4c1abb0f9801a3a2ac2383b", "score": "0.48940036", "text": "func Resources(configFlags *genericclioptions.ConfigFlags, args []string) error {\n\tclientcfg := configFlags.ToRawKubeConfigLoader()\n\tcfg, err := clientcfg.RawConfig()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Can't assemble raw config\")\n\t}\n\tif len(args) < 1 {\n\t\treturn errors.New(\"need a cluster to operate on, please provide the cluster name\")\n\t}\n\tclusterID := args[0]\n\tcontext := contextOf(cfg, clusterID)\n\terr = resourceDetails(cfg, context)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "f3081caf57ede86253da551e454da138", "score": "0.48926318", "text": "func (c *CfgSvc) GetDiscoveredResources() ([]*configservice.ResourceIdentifier, error) {\n\t// List of resource types pulled from\n\t// github.com/aws/aws-sdk-go/models/apis/config/2014-11-12/api-2.json\n\tvar resourceTypes = [...]string{\n\t\t\"AWS::AppStream::DirectoryConfig\",\n\t\t\"AWS::AppStream::Application\",\n\t\t\"AWS::AppFlow::Flow\",\n\t\t\"AWS::ApiGateway::Stage\",\n\t\t\"AWS::ApiGateway::RestApi\",\n\t\t\"AWS::ApiGatewayV2::Stage\",\n\t\t\"AWS::ApiGatewayV2::Api\",\n\t\t\"AWS::Athena::WorkGroup\",\n\t\t\"AWS::Athena::DataCatalog\",\n\t\t\"AWS::CloudFront::Distribution\",\n\t\t\"AWS::CloudFront::StreamingDistribution\",\n\t\t\"AWS::CloudWatch::Alarm\",\n\t\t\"AWS::CloudWatch::MetricStream\",\n\t\t\"AWS::RUM::AppMonitor\",\n\t\t\"AWS::Evidently::Project\",\n\t\t\"AWS::CodeGuruReviewer::RepositoryAssociation\",\n\t\t\"AWS::Connect::PhoneNumber\",\n\t\t\"AWS::CustomerProfiles::Domain\",\n\t\t\"AWS::Detective::Graph\",\n\t\t\"AWS::DynamoDB::Table\",\n\t\t\"AWS::EC2::Host\",\n\t\t\"AWS::EC2::EIP\",\n\t\t\"AWS::EC2::Instance\",\n\t\t\"AWS::EC2::NetworkInterface\",\n\t\t\"AWS::EC2::SecurityGroup\",\n\t\t\"AWS::EC2::NatGateway\",\n\t\t\"AWS::EC2::EgressOnlyInternetGateway\",\n\t\t\"AWS::EC2::EC2Fleet\",\n\t\t\"AWS::EC2::SpotFleet\",\n\t\t\"AWS::EC2::PrefixList\",\n\t\t\"AWS::EC2::FlowLog\",\n\t\t\"AWS::EC2::TransitGateway\",\n\t\t\"AWS::EC2::TransitGatewayAttachment\",\n\t\t\"AWS::EC2::TransitGatewayRouteTable\",\n\t\t\"AWS::EC2::VPCEndpoint\",\n\t\t\"AWS::EC2::VPCEndpointService\",\n\t\t\"AWS::EC2::VPCPeeringConnection\",\n\t\t\"AWS::EC2::RegisteredHAInstance\",\n\t\t\"AWS::EC2::SubnetRouteTableAssociation\",\n\t\t\"AWS::EC2::LaunchTemplate\",\n\t\t\"AWS::EC2::NetworkInsightsAccessScopeAnalysis\",\n\t\t\"AWS::EC2::TrafficMirrorTarget\",\n\t\t\"AWS::EC2::TrafficMirrorSession\",\n\t\t\"AWS::EC2::DHCPOptions\",\n\t\t\"AWS::EC2::IPAM\",\n\t\t\"AWS::EC2::NetworkInsightsPath\",\n\t\t\"AWS::EC2::TrafficMirrorFilter\",\n\t\t\"AWS::EC2::Volume\",\n\t\t\"AWS::ImageBuilder::ImagePipeline\",\n\t\t\"AWS::ImageBuilder::DistributionConfiguration\",\n\t\t\"AWS::ImageBuilder::InfrastructureConfiguration\",\n\t\t\"AWS::ECR::Repository\",\n\t\t\"AWS::ECR::RegistryPolicy\",\n\t\t\"AWS::ECR::PullThroughCacheRule\",\n\t\t\"AWS::ECR::PublicRepository\",\n\t\t\"AWS::ECS::Cluster\",\n\t\t\"AWS::ECS::TaskDefinition\",\n\t\t\"AWS::ECS::Service\",\n\t\t\"AWS::ECS::TaskSet\",\n\t\t\"AWS::EFS::FileSystem\",\n\t\t\"AWS::EFS::AccessPoint\",\n\t\t\"AWS::EKS::Cluster\",\n\t\t\"AWS::EKS::FargateProfile\",\n\t\t\"AWS::EKS::IdentityProviderConfig\",\n\t\t\"AWS::EKS::Addon\",\n\t\t\"AWS::EMR::SecurityConfiguration\",\n\t\t\"AWS::Events::EventBus\",\n\t\t\"AWS::Events::ApiDestination\",\n\t\t\"AWS::Events::Archive\",\n\t\t\"AWS::Events::Endpoint\",\n\t\t\"AWS::Events::Connection\",\n\t\t\"AWS::Events::Rule\",\n\t\t\"AWS::EC2::TrafficMirrorSession\",\n\t\t\"AWS::EventSchemas::RegistryPolicy\",\n\t\t\"AWS::EventSchemas::Discoverer\",\n\t\t\"AWS::EventSchemas::Schema\",\n\t\t\"AWS::Forecast::Dataset\",\n\t\t\"AWS::FraudDetector::Label\",\n\t\t\"AWS::FraudDetector::EntityType\",\n\t\t\"AWS::FraudDetector::Variable\",\n\t\t\"AWS::FraudDetector::Outcome\",\n\t\t\"AWS::GuardDuty::Detector\",\n\t\t\"AWS::GuardDuty::ThreatIntelSet\",\n\t\t\"AWS::GuardDuty::IPSet\",\n\t\t\"AWS::GuardDuty::Filter\",\n\t\t\"AWS::HealthLake::FHIRDatastore\",\n\t\t\"AWS::Cassandra::Keyspace\",\n\t\t\"AWS::IVS::Channel\",\n\t\t\"AWS::IVS::RecordingConfiguration\",\n\t\t\"AWS::IVS::PlaybackKeyPair\",\n\t\t\"AWS::Elasticsearch::Domain\",\n\t\t\"AWS::OpenSearch::Domain\",\n\t\t\"AWS::Elasticsearch::Domain\",\n\t\t\"AWS::Pinpoint::ApplicationSettings\",\n\t\t\"AWS::Pinpoint::Segment\",\n\t\t\"AWS::Pinpoint::App\",\n\t\t\"AWS::Pinpoint::Campaign\",\n\t\t\"AWS::Pinpoint::InAppTemplate\",\n\t\t\"AWS::QLDB::Ledger\",\n\t\t\"AWS::Kinesis::Stream\",\n\t\t\"AWS::Kinesis::StreamConsumer\",\n\t\t\"AWS::KinesisAnalyticsV2::Application\",\n\t\t\"AWS::KinesisFirehose::DeliveryStream\",\n\t\t\"AWS::KinesisVideo::SignalingChannel\",\n\t\t\"AWS::Lex::BotAlias\",\n\t\t\"AWS::Lex::Bot\",\n\t\t\"AWS::Lightsail::Disk\",\n\t\t\"AWS::Lightsail::Certificate\",\n\t\t\"AWS::Lightsail::Bucket\",\n\t\t\"AWS::Lightsail::StaticIp\",\n\t\t\"AWS::LookoutMetrics::Alert\",\n\t\t\"AWS::LookoutVision::Project\",\n\t\t\"AWS::AmazonMQ::Broker\",\n\t\t\"AWS::MSK::Cluster\",\n\t\t\"AWS::Redshift::Cluster\",\n\t\t\"AWS::Redshift::ClusterParameterGroup\",\n\t\t\"AWS::Redshift::ClusterSecurityGroup\",\n\t\t\"AWS::Redshift::ScheduledAction\",\n\t\t\"AWS::Redshift::ClusterSnapshot\",\n\t\t\"AWS::Redshift::ClusterSubnetGroup\",\n\t\t\"AWS::Redshift::EventSubscription\",\n\t\t\"AWS::RDS::DBInstance\",\n\t\t\"AWS::RDS::DBSecurityGroup\",\n\t\t\"AWS::RDS::DBSnapshot\",\n\t\t\"AWS::RDS::DBSubnetGroup\",\n\t\t\"AWS::RDS::EventSubscription\",\n\t\t\"AWS::RDS::DBCluster\",\n\t\t\"AWS::RDS::DBClusterSnapshot\",\n\t\t\"AWS::RDS::GlobalCluster\",\n\t\t\"AWS::Route53::HostedZone\",\n\t\t\"AWS::Route53::HealthCheck\",\n\t\t\"AWS::Route53Resolver::ResolverEndpoint\",\n\t\t\"AWS::Route53Resolver::ResolverRule\",\n\t\t\"AWS::Route53Resolver::ResolverRuleAssociation\",\n\t\t\"AWS::Route53Resolver::FirewallDomainList\",\n\t\t\"AWS::AWS::Route53Resolver::FirewallRuleGroupAssociation\",\n\t\t\"AWS::Route53RecoveryReadiness::Cell\",\n\t\t\"AWS::Route53RecoveryReadiness::ReadinessCheck\",\n\t\t\"AWS::Route53RecoveryReadiness::RecoveryGroup\",\n\t\t\"AWS::Route53RecoveryControl::Cluster\",\n\t\t\"AWS::Route53RecoveryControl::ControlPanel\",\n\t\t\"AWS::Route53RecoveryControl::RoutingControl\",\n\t\t\"AWS::Route53RecoveryControl::SafetyRule\",\n\t\t\"AWS::Route53RecoveryReadiness::ResourceSet\",\n\t\t\"AWS::SageMaker::CodeRepository\",\n\t\t\"AWS::SageMaker::Domain\",\n\t\t\"AWS::SageMaker::AppImageConfig\",\n\t\t\"AWS::SageMaker::Image\",\n\t\t\"AWS::SageMaker::Model\",\n\t\t\"AWS::SageMaker::NotebookInstance\",\n\t\t\"AWS::SageMaker::NotebookInstanceLifecycleConfig\",\n\t\t\"AWS::SageMaker::EndpointConfig\",\n\t\t\"AWS::SageMaker::Workteam\",\n\t\t\"AWS::SES::ConfigurationSet\",\n\t\t\"AWS::SES::ContactList\",\n\t\t\"AWS::SES::Template\",\n\t\t\"AWS::SES::ReceiptFilter\",\n\t\t\"AWS::SES::ReceiptRuleSet\",\n\t\t\"AWS::SNS::Topic\",\n\t\t\"AWS::SQS::Queue\",\n\t\t\"AWS::S3::Bucket\",\n\t\t\"AWS::S3::AccountPublicAccessBlock\",\n\t\t\"AWS::S3::MultiRegionAccessPoint\",\n\t\t\"AWS::S3::StorageLens\",\n\t\t\"AWS::EC2::CustomerGateway\",\n\t\t\"AWS::EC2::InternetGateway\",\n\t\t\"AWS::EC2::NetworkAcl\",\n\t\t\"AWS::EC2::RouteTable\",\n\t\t\"AWS::EC2::Subnet\",\n\t\t\"AWS::EC2::VPC\",\n\t\t\"AWS::EC2::VPNConnection\",\n\t\t\"AWS::EC2::VPNGateway\",\n\t\t\"AWS::NetworkManager::TransitGatewayRegistration\",\n\t\t\"AWS::NetworkManager::Site\",\n\t\t\"AWS::NetworkManager::Device\",\n\t\t\"AWS::NetworkManager::Link\",\n\t\t\"AWS::NetworkManager::GlobalNetwork\",\n\t\t\"AWS::WorkSpaces::ConnectionAlias\",\n\t\t\"AWS::WorkSpaces::Workspace\",\n\t\t\"AWS::Amplify::App\",\n\t\t\"AWS::AppConfig::Application\",\n\t\t\"AWS::AppConfig::Environment\",\n\t\t\"AWS::AppConfig::ConfigurationProfile\",\n\t\t\"AWS::AppConfig::DeploymentStrategy\",\n\t\t\"AWS::AppRunner::VpcConnector\",\n\t\t\"AWS::AppMesh::VirtualNode\",\n\t\t\"AWS::AppMesh::VirtualService\",\n\t\t\"AWS::AppSync::GraphQLApi\",\n\t\t\"AWS::AuditManager::Assessment\",\n\t\t\"AWS::AutoScaling::AutoScalingGroup\",\n\t\t\"AWS::AutoScaling::LaunchConfiguration\",\n\t\t\"AWS::AutoScaling::ScalingPolicy\",\n\t\t\"AWS::AutoScaling::ScheduledAction\",\n\t\t\"AWS::AutoScaling::WarmPool\",\n\t\t\"AWS::Backup::BackupPlan\",\n\t\t\"AWS::Backup::BackupSelection\",\n\t\t\"AWS::Backup::BackupVault\",\n\t\t\"AWS::Backup::RecoveryPoint\",\n\t\t\"AWS::Backup::ReportPlan\",\n\t\t\"AWS::Backup::BackupPlan\",\n\t\t\"AWS::Backup::BackupSelection\",\n\t\t\"AWS::Backup::BackupVault\",\n\t\t\"AWS::Backup::RecoveryPoint\",\n\t\t\"AWS::Batch::JobQueue\",\n\t\t\"AWS::Batch::ComputeEnvironment\",\n\t\t\"AWS::Budgets::BudgetsAction\",\n\t\t\"AWS::ACM::Certificate\",\n\t\t\"AWS::CloudFormation::Stack\",\n\t\t\"AWS::CloudTrail::Trail\",\n\t\t\"AWS::Cloud9::EnvironmentEC2\",\n\t\t\"AWS::ServiceDiscovery::Service\",\n\t\t\"AWS::ServiceDiscovery::PublicDnsNamespace\",\n\t\t\"AWS::ServiceDiscovery::HttpNamespace\",\n\t\t\"AWS::CodeArtifact::Repository\",\n\t\t\"AWS::CodeBuild::Project\",\n\t\t\"AWS::CodeDeploy::Application\",\n\t\t\"AWS::CodeDeploy::DeploymentConfig\",\n\t\t\"AWS::CodeDeploy::DeploymentGroup\",\n\t\t\"AWS::CodePipeline::Pipeline\",\n\t\t\"AWS::Config::ResourceCompliance\",\n\t\t\"AWS::Config::ConformancePackCompliance\",\n\t\t\"AWS::Config::ConfigurationRecorder\",\n\t\t\"AWS::Config::ResourceCompliance\",\n\t\t\"AWS::Config::ConfigurationRecorder\",\n\t\t\"AWS::Config::ConformancePackCompliance\",\n\t\t\"AWS::Config::ConfigurationRecorder\",\n\t\t\"AWS::DMS::EventSubscription\",\n\t\t\"AWS::DMS::ReplicationSubnetGroup\",\n\t\t\"AWS::DMS::ReplicationInstance\",\n\t\t\"AWS::DMS::ReplicationTask\",\n\t\t\"AWS::DMS::Certificate\",\n\t\t\"AWS::DataSync::LocationSMB\",\n\t\t\"AWS::DataSync::LocationFSxLustre\",\n\t\t\"AWS::DataSync::LocationFSxWindows\",\n\t\t\"AWS::DataSync::LocationS3\",\n\t\t\"AWS::DataSync::LocationEFS\",\n\t\t\"AWS::DataSync::LocationNFS\",\n\t\t\"AWS::DataSync::LocationHDFS\",\n\t\t\"AWS::DataSync::LocationObjectStorage\",\n\t\t\"AWS::DataSync::Task\",\n\t\t\"AWS::DeviceFarm::TestGridProject\",\n\t\t\"AWS::DeviceFarm::InstanceProfile\",\n\t\t\"AWS::DeviceFarm::Project\",\n\t\t\"AWS::ElasticBeanstalk::Application\",\n\t\t\"AWS::ElasticBeanstalk::ApplicationVersion\",\n\t\t\"AWS::ElasticBeanstalk::Environment\",\n\t\t\"AWS::FIS::ExperimentTemplate\",\n\t\t\"AWS::GlobalAccelerator::Listener\",\n\t\t\"AWS::GlobalAccelerator::EndpointGroup\",\n\t\t\"AWS::GlobalAccelerator::Accelerator\",\n\t\t\"AWS::Glue::Job\",\n\t\t\"AWS::Glue::Classifier\",\n\t\t\"AWS::Glue::MLTransform\",\n\t\t\"AWS::GroundStation::Config\",\n\t\t\"AWS::IAM::User\",\n\t\t\"AWS::IAM::SAMLProvider\",\n\t\t\"AWS::IAM::ServerCertificate\",\n\t\t\"AWS::IAM::Group\",\n\t\t\"AWS::IAM::Role\",\n\t\t\"AWS::IAM::Policy\",\n\t\t\"AWS::AccessAnalyzer::Analyzer\",\n\t\t\"AWS::IoT::Authorizer\",\n\t\t\"AWS::IoT::SecurityProfile\",\n\t\t\"AWS::IoT::RoleAlias\",\n\t\t\"AWS::IoT::Dimension\",\n\t\t\"AWS::IoT::Policy\",\n\t\t\"AWS::IoT::MitigationAction\",\n\t\t\"AWS::IoT::ScheduledAudit\",\n\t\t\"AWS::IoT::AccountAuditConfiguration\",\n\t\t\"AWS::IoTSiteWise::Gateway\",\n\t\t\"AWS::IoT::CustomMetric\",\n\t\t\"AWS::IoTWireless::ServiceProfile\",\n\t\t\"AWS::IoT::FleetMetric\",\n\t\t\"AWS::IoTAnalytics::Datastore\",\n\t\t\"AWS::IoTAnalytics::Dataset\",\n\t\t\"AWS::IoTAnalytics::Pipeline\",\n\t\t\"AWS::IoTAnalytics::Channel\",\n\t\t\"AWS::IoTEvents::Input\",\n\t\t\"AWS::IoTEvents::DetectorModel\",\n\t\t\"AWS::IoTEvents::AlarmModel\",\n\t\t\"AWS::IoTTwinMaker::Workspace\",\n\t\t\"AWS::IoTTwinMaker::Entity\",\n\t\t\"AWS::IoTTwinMaker::Scene\",\n\t\t\"AWS::IoTSiteWise::Dashboard\",\n\t\t\"AWS::IoTSiteWise::Project\",\n\t\t\"AWS::IoTSiteWise::Portal\",\n\t\t\"AWS::IoTSiteWise::AssetModel\",\n\t\t\"AWS::KMS::Key\",\n\t\t\"AWS::KMS::Alias\",\n\t\t\"AWS::Lambda::Function\",\n\t\t\"AWS::Lambda::Alias\",\n\t\t\"AWS::NetworkFirewall::Firewall\",\n\t\t\"AWS::NetworkFirewall::FirewallPolicy\",\n\t\t\"AWS::NetworkFirewall::RuleGroup\",\n\t\t\"AWS::NetworkFirewall::TLSInspectionConfiguration\",\n\t\t\"AWS:Panorama::Package\",\n\t\t\"AWS::ResilienceHub::ResiliencyPolicy\",\n\t\t\"AWS::RoboMaker::RobotApplicationVersion\",\n\t\t\"AWS::RoboMaker::RobotApplication\",\n\t\t\"AWS::RoboMaker::SimulationApplication\",\n\t\t\"AWS::Signer::SigningProfile\",\n\t\t\"AWS::SecretsManager::Secret\",\n\t\t\"AWS::ServiceCatalog::CloudFormationProduct\",\n\t\t\"AWS::ServiceCatalog::CloudFormationProvisionedProduct\",\n\t\t\"AWS::ServiceCatalog::Portfolio\",\n\t\t\"AWS::Shield::Protection\",\n\t\t\"AWS::ShieldRegional::Protection\",\n\t\t\"AWS::StepFunctions::Activity\",\n\t\t\"AWS::StepFunctions::StateMachine\",\n\t\t\"AWS::SSM::ManagedInstanceInventory\",\n\t\t\"AWS::SSM::PatchCompliance\",\n\t\t\"AWS::SSM::AssociationCompliance\",\n\t\t\"AWS::SSM::FileData\",\n\t\t\"AWS::Transfer::Agreement\",\n\t\t\"AWS::Transfer::Connector\",\n\t\t\"AWS::Transfer::Workflow\",\n\t\t\"AWS::WAF::RateBasedRule\",\n\t\t\"AWS::WAF::Rule\",\n\t\t\"AWS::WAF::WebACL\",\n\t\t\"AWS::WAF::RuleGroup\",\n\t\t\"AWS::WAFRegional::RateBasedRule\",\n\t\t\"AWS::WAFRegional::Rule\",\n\t\t\"AWS::WAFRegional::WebACL\",\n\t\t\"AWS::WAFRegional::RuleGroup\",\n\t\t\"AWS::WAFv2::WebACL\",\n\t\t\"AWS::WAFv2::RuleGroup\",\n\t\t\"AWS::WAFv2::ManagedRuleSet\",\n\t\t\"AWS::WAFv2::IPSet\",\n\t\t\"AWS::WAFv2::RegexPatternSet\",\n\t\t\"AWS::XRay::EncryptionConfig\",\n\t\t\"AWS::ElasticLoadBalancingV2::LoadBalancer\",\n\t\t\"AWS::ElasticLoadBalancingV2::Listener\",\n\t\t\"AWS::ElasticLoadBalancing::LoadBalancer\",\n\t\t\"AWS::ElasticLoadBalancingV2::LoadBalancer\",\n\t\t\"AWS::MediaPackage::PackagingGroup\",\n\t\t\"AWS::MediaPackage::PackagingConfiguration\",\n\t}\n\t// nolint: prealloc\n\tvar res []*configservice.ResourceIdentifier\n\n\tfor _, t := range &resourceTypes {\n\t\tt := t\n\t\tinput := &configservice.ListDiscoveredResourcesInput{\n\t\t\tResourceType: aws.String(t),\n\t\t}\n\n\t\tresult, err := c.Client.ListDiscoveredResources(input)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Error ListDiscoveredResources (ResourceType: %s): %v\\n\", t, err)\n\t\t\treturn nil, err\n\t\t}\n\n\t\tres = append(res, result.ResourceIdentifiers...)\n\n\t\tfor aws.StringValue(result.NextToken) != \"\" {\n\t\t\tinput.NextToken = result.NextToken\n\n\t\t\tresult, err = c.Client.ListDiscoveredResources(input)\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatalf(\"Error ListDiscoveredResources (Input: %v): %v\\n\", input, err)\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tres = append(res, result.ResourceIdentifiers...)\n\t\t}\n\t}\n\n\treturn res, nil\n}", "title": "" }, { "docid": "5c58d05f4c04c7f4718acd0fb4597943", "score": "0.48853293", "text": "func findResource(groupVersion string, kind string, serverPreferredResources, serverGroupsAndResources []*metav1.APIResourceList) (\n\tapiResource, parentAPIResource *metav1.APIResource, gvr schema.GroupVersionResource, err error,\n) {\n\tmatchingServerResources := getMatchingServerResources(groupVersion, kind, serverGroupsAndResources)\n\n\tonlySubresourcePresentInMatchingResources := len(matchingServerResources) > 0\n\tfor _, matchingServerResource := range matchingServerResources {\n\t\tif !kubeutils.IsSubresource(matchingServerResource.apiResource.Name) {\n\t\t\tonlySubresourcePresentInMatchingResources = false\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif onlySubresourcePresentInMatchingResources {\n\t\tapiResourceWithListGV := matchingServerResources[0]\n\t\tmatchingServerResource := apiResourceWithListGV.apiResource\n\t\tlogger.V(6).Info(\"matched API resource to kind\", \"apiResource\", matchingServerResource, \"kind\", kind)\n\n\t\tgroupVersionResource := schema.GroupVersionResource{\n\t\t\tResource: matchingServerResource.Name,\n\t\t\tGroup: matchingServerResource.Group,\n\t\t\tVersion: matchingServerResource.Version,\n\t\t}\n\t\tlogger.V(6).Info(\"gv with resource\", \"gvWithResource\", groupVersionResource)\n\t\tgv, err := schema.ParseGroupVersion(apiResourceWithListGV.listGV)\n\t\tif err != nil {\n\t\t\treturn nil, nil, schema.GroupVersionResource{}, fmt.Errorf(\"failed to parse group version %s: %v\", apiResourceWithListGV.listGV, err)\n\t\t}\n\t\tparentAPIResource, err := findResourceFromResourceName(\n\t\t\tgv.WithResource(strings.Split(matchingServerResource.Name, \"/\")[0]),\n\t\t\tserverPreferredResources,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, nil, schema.GroupVersionResource{}, fmt.Errorf(\"failed to find parent resource for subresource %s: %v\", matchingServerResource.Name, err)\n\t\t}\n\t\tlogger.V(6).Info(\"parent API resource\", \"parentAPIResource\", parentAPIResource)\n\n\t\treturn &matchingServerResource, parentAPIResource, groupVersionResource, nil\n\t}\n\n\tif groupVersion == \"\" && len(matchingServerResources) > 0 {\n\t\tfor _, serverResourceList := range serverPreferredResources {\n\t\t\tfor _, serverResource := range serverResourceList.APIResources {\n\t\t\t\tserverResourceGv := getServerResourceGroupVersion(serverResourceList.GroupVersion, serverResource.Group, serverResource.Version)\n\t\t\t\tif serverResource.Kind == kind || serverResource.SingularName == kind {\n\t\t\t\t\tgv, _ := schema.ParseGroupVersion(serverResourceGv)\n\t\t\t\t\tserverResource.Group = gv.Group\n\t\t\t\t\tserverResource.Version = gv.Version\n\t\t\t\t\tgroupVersionResource := gv.WithResource(serverResource.Name)\n\n\t\t\t\t\tlogger.V(6).Info(\"matched API resource to kind\", \"apiResource\", serverResource, \"kind\", kind)\n\t\t\t\t\treturn &serverResource, nil, groupVersionResource, nil\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor _, apiResourceWithListGV := range matchingServerResources {\n\t\t\tmatchingServerResource := apiResourceWithListGV.apiResource\n\t\t\tif !kubeutils.IsSubresource(matchingServerResource.Name) {\n\t\t\t\tlogger.V(6).Info(\"matched API resource to kind\", \"apiResource\", matchingServerResource, \"kind\", kind)\n\n\t\t\t\tgroupVersionResource := schema.GroupVersionResource{\n\t\t\t\t\tResource: matchingServerResource.Name,\n\t\t\t\t\tGroup: matchingServerResource.Group,\n\t\t\t\t\tVersion: matchingServerResource.Version,\n\t\t\t\t}\n\t\t\t\tlogger.V(6).Info(\"gv with resource\", \"groupVersionResource\", groupVersionResource)\n\t\t\t\treturn &matchingServerResource, nil, groupVersionResource, nil\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil, nil, schema.GroupVersionResource{}, fmt.Errorf(\"kind '%s' not found in groupVersion '%s'\", kind, groupVersion)\n}", "title": "" }, { "docid": "2b24fa6f6d766e7242ac685281597176", "score": "0.48834455", "text": "func (g *VpcGenerator) InitResources() error {\n\tclient, err := g.LoadClientFromProfile()\n\tif err != nil {\n\t\treturn err\n\t}\n\tremaining := 1\n\tpageNumber := 1\n\tpageSize := 10\n\n\tallVpcs := make([]vpc.Vpc, 0)\n\n\tfor remaining > 0 {\n\t\traw, err := client.WithVpcClient(func(vpcClient *vpc.Client) (interface{}, error) {\n\t\t\trequest := vpc.CreateDescribeVpcsRequest()\n\t\t\trequest.RegionId = client.RegionID\n\t\t\trequest.PageSize = requests.NewInteger(pageSize)\n\t\t\trequest.PageNumber = requests.NewInteger(pageNumber)\n\t\t\treturn vpcClient.DescribeVpcs(request)\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tresponse := raw.(*vpc.DescribeVpcsResponse)\n\t\tallVpcs = append(allVpcs, response.Vpcs.Vpc...)\n\t\tremaining = response.TotalCount - pageNumber*pageSize\n\t\tpageNumber++\n\t}\n\n\tfor _, Vpc := range allVpcs {\n\t\tresource := resourceFromVpcResponse(Vpc)\n\t\tg.Resources = append(g.Resources, resource)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "a635bbb07eb05bfced6def7e488048f8", "score": "0.4872699", "text": "func (s *ResourceScaler) ReadResources(ctx context.Context, clusterID string) ([]*ResourceList, error) {\n\tresources, err := s.Provider.ReadResources(ctx, clusterID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor i := range resources {\n\t\tfor resourceName, quantity := range resources[i].Resources {\n\t\t\tscaled := quantity\n\t\t\tScaleResources(corev1.ResourceName(resourceName), scaled, s.Factor)\n\t\t\tresources[i].Resources[resourceName] = scaled\n\t\t}\n\t}\n\treturn resources, nil\n}", "title": "" }, { "docid": "918bea3240a181f90c727e76f53b3e8b", "score": "0.48663864", "text": "func (d *DryccCmd) ResourcesList(appID string, results int) error {\n\ts, appID, err := load(d.ConfigFile, appID)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif results == defaultLimit {\n\t\tresults = s.Limit\n\t}\n\tresources, count, err := resources.List(s.Client, appID, results)\n\tif d.checkAPICompatibility(s.Client, err) != nil {\n\t\treturn err\n\t}\n\n\tif count == 0 {\n\t\td.Println(\"Could not find any resources\")\n\t} else {\n\t\tprintResources(d, appID, resources)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "70d3a0eefaef31b096c22bee07ab4d5b", "score": "0.48533383", "text": "func (s *Service) GetResourcesStats(start, end time.Time) (*statistic.BaseStats, error) {\n\tresult := statistic.NewBaseStats()\n\n\tsLogs, err := s.store.FetchLogs(start, end, \"\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor len(sLogs) > 0 {\n\t\terr = result.CalculateLogs(sLogs)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tstart = sLogs[len(sLogs)-1].CreatedAt\n\n\t\tsLogs, err = s.store.FetchLogs(start, end, \"\")\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn result, nil\n}", "title": "" }, { "docid": "bdf7cebcf187f3a858cfe352bf63ea39", "score": "0.48463798", "text": "func (l *SyncStorageLock) RefreshResource(ns string, expiration time.Duration) error {\n\terr := l.s.getDbBackend(ns).PExpireIE(getNsPrefix(ns)+l.key, l.value, expiration)\n\treturn err\n}", "title": "" }, { "docid": "43e805939235dbd77c5d6b614b3bb5f9", "score": "0.48384985", "text": "func (s *Server) StreamAggregatedResources(stream mcp.AggregatedMeshConfigService_StreamAggregatedResourcesServer) error { // nolint: lll\n\tcon, err := s.newConnection(stream)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefer s.closeConnection(con)\n\tgo con.receive()\n\n\t// fan-in per-type response channels into single response channel for the select loop below.\n\tresponseChan := make(chan *watch, 1)\n\tfor _, w := range con.watches {\n\t\tgo func(w *watch) {\n\t\t\tfor state := range w.newPushResponseReadyChan {\n\t\t\t\tif state == newPushResponseStateClosed {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tresponseChan <- w\n\t\t\t}\n\n\t\t\t// Any closed watch can close the overall connection. Use\n\t\t\t// `nil` value to indicate a closed state to the run loop\n\t\t\t// below instead of closing the channel to avoid closing\n\t\t\t// the channel multiple times.\n\t\t\tresponseChan <- nil\n\t\t}(w)\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase w, more := <-responseChan:\n\t\t\tif !more || w == nil {\n\t\t\t\treturn status.Error(codes.Unavailable, \"server canceled watch\")\n\t\t\t}\n\n\t\t\tw.mu.Lock()\n\t\t\tresp := w.newPushResponse\n\t\t\tw.newPushResponse = nil\n\t\t\tw.mu.Unlock()\n\n\t\t\t// newPushResponse may have been cleared before we got to it\n\t\t\tif resp == nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif err := con.pushServerResponse(w, resp); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase req, more := <-con.requestC:\n\t\t\tif !more {\n\t\t\t\treturn con.reqError\n\t\t\t}\n\t\t\tif err := con.processClientRequest(req); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase <-stream.Context().Done():\n\t\t\tscope.Debugf(\"MCP: connection %v: stream done, err=%v\", con, stream.Context().Err())\n\t\t\treturn stream.Context().Err()\n\t\t}\n\t}\n}", "title": "" }, { "docid": "fcc737f3edadb6c59ac41e078b763074", "score": "0.48310137", "text": "func (l *Manager) ReleaseResources(client string) {\n\t// Looping over the set\n\tfor r := range l.ClientHolder[client] {\n\t\tmsg := l.ReleaseResource(client, r.(string))\n\t\tlog.Println(msg)\n\t}\n}", "title": "" }, { "docid": "9ff827f20caf969c12f9013da40dfa16", "score": "0.48303032", "text": "func (c *Controller) ListResources(w http.ResponseWriter, r *http.Request) {\n\tresources := c.Dao.GetResources()\n\tlog.Println(resources)\n\n\tdata, _ := json.Marshal(resources)\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tw.WriteHeader(http.StatusOK)\n\tw.Write(data)\n\treturn\n}", "title": "" }, { "docid": "0f6ee01c9d392609733dc1efdd0a9a56", "score": "0.4818087", "text": "func ScheduleRefresh(scheduleConfig ScheduleConfig) {\n\tschedule := gocron.NewScheduler(time.UTC)\n\tclient = newClient()\n\n\tschedule.Every(scheduleConfig.HCSSTokenRefreshInterval).Minutes().Do(func() {\n\t\tlog.Println(\"Refreshing access token...\")\n\t\tclient = newClient()\n\t})\n\tschedule.Every(scheduleConfig.JobRefreshInterval).Minutes().Do(refreshJobs)\n\tschedule.Every(scheduleConfig.EmployeeRefreshInterval).Minutes().Do(refreshEmployees)\n\tschedule.Every(scheduleConfig.EquipmentRefreshInterval).Minutes().Do(refreshEquipment)\n\tschedule.Every(scheduleConfig.TimecardRefreshInterval).Minutes().Do(refreshTimecards)\n\n\tschedule.StartAsync()\n}", "title": "" }, { "docid": "737a2647f99deec3ef9e1efbd59e0a3b", "score": "0.4816116", "text": "func (d *ceph) GetResources() (*api.ResourcesStoragePool, error) {\n\tvar stdout bytes.Buffer\n\n\terr := shared.RunCommandWithFds(context.TODO(), nil, &stdout,\n\t\t\"ceph\",\n\t\t\"--name\", fmt.Sprintf(\"client.%s\", d.config[\"ceph.user.name\"]),\n\t\t\"--cluster\", d.config[\"ceph.cluster_name\"],\n\t\t\"df\",\n\t\t\"-f\", \"json\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Temporary structs for parsing.\n\ttype cephDfPoolStats struct {\n\t\tBytesUsed int64 `json:\"bytes_used\"`\n\t\tBytesAvailable int64 `json:\"max_avail\"`\n\t}\n\n\ttype cephDfPool struct {\n\t\tName string `json:\"name\"`\n\t\tStats cephDfPoolStats `json:\"stats\"`\n\t}\n\n\ttype cephDf struct {\n\t\tPools []cephDfPool `json:\"pools\"`\n\t}\n\n\t// Parse the JSON output.\n\tdf := cephDf{}\n\terr = json.NewDecoder(&stdout).Decode(&df)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar pool *cephDfPool\n\tfor _, entry := range df.Pools {\n\t\tif entry.Name == d.config[\"ceph.osd.pool_name\"] {\n\t\t\tpool = &entry\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif pool == nil {\n\t\treturn nil, fmt.Errorf(\"OSD pool missing in df output\")\n\t}\n\n\tspaceUsed := uint64(pool.Stats.BytesUsed)\n\tspaceAvailable := uint64(pool.Stats.BytesAvailable)\n\n\tres := api.ResourcesStoragePool{}\n\tres.Space.Total = spaceAvailable + spaceUsed\n\tres.Space.Used = spaceUsed\n\n\treturn &res, nil\n}", "title": "" }, { "docid": "89e93983b6ea48f26a5742e272a6a83d", "score": "0.48149422", "text": "func UpdateResources(template *servingv1alpha1.RevisionTemplateSpec, requestsResourceList corev1.ResourceList, limitsResourceList corev1.ResourceList) error {\n\tcontainer, err := ContainerOfRevisionTemplate(template)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif container.Resources.Requests == nil {\n\t\tcontainer.Resources.Requests = corev1.ResourceList{}\n\t}\n\n\tfor k, v := range requestsResourceList {\n\t\tcontainer.Resources.Requests[k] = v\n\t}\n\n\tif container.Resources.Limits == nil {\n\t\tcontainer.Resources.Limits = corev1.ResourceList{}\n\t}\n\n\tfor k, v := range limitsResourceList {\n\t\tcontainer.Resources.Limits[k] = v\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "919faba7fe4c8fc1371202b4a48a5435", "score": "0.48129004", "text": "func (a *Agent) RemoveResources(releaseName string) error {\n\t// Remove CassandraDatacenter (cass-operator should delete all the finalizers and associated resources)\n\tif err := a.removeCassandraDatacenter(releaseName); err != nil {\n\t\tlog.Fatalf(\"Failed to remove Cassandra cluster(s): %v\", err)\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "919faba7fe4c8fc1371202b4a48a5435", "score": "0.48129004", "text": "func (a *Agent) RemoveResources(releaseName string) error {\n\t// Remove CassandraDatacenter (cass-operator should delete all the finalizers and associated resources)\n\tif err := a.removeCassandraDatacenter(releaseName); err != nil {\n\t\tlog.Fatalf(\"Failed to remove Cassandra cluster(s): %v\", err)\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "426d550e154004e826ebc7e8b0f47899", "score": "0.481269", "text": "func refresh() error {\n\tconfigs := config.GetEgressConfig()\n\tok, _ := egress.ValidateEgressRule(configs.Destinations)\n\tif !ok {\n\t\terr := fmt.Errorf(\"egress rule type assertion fail, key: %v\", configs.Destinations)\n\t\treturn err\n\t}\n\n\tdests = configs.Destinations\n\treturn nil\n}", "title": "" }, { "docid": "b16a57da91cac4d038994d556b037a79", "score": "0.4812209", "text": "func (swagger *MgwSwagger) GetResources() []*Resource {\n\treturn swagger.resources\n}", "title": "" }, { "docid": "7cbc8f6d7f92f0e503459ccbf2880066", "score": "0.48116645", "text": "func resourceDetails(cfg api.Config, context string) error {\n\tcs, err := csForContext(cfg, context)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Can't create a clientset based on config provided\")\n\t}\n\t_, reslist, err := cs.Discovery().ServerGroupsAndResources()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Can't get cluster server version\")\n\t}\n\tfmt.Println(\"Resources supported in this cluster:\")\n\tfor _, res := range reslist {\n\t\tfmt.Println(strings.Repeat(\"-\", 80))\n\t\tfmt.Printf(\"%v:\\n \", res.GroupVersion)\n\t\tfor _, r := range res.APIResources {\n\t\t\tif !strings.Contains(r.Name, \"/\") {\n\t\t\t\tfmt.Printf(\"%v (namespaced: %v) \", r.Name, r.Namespaced)\n\t\t\t}\n\t\t}\n\t\tfmt.Printf(\"\\n\")\n\t}\n\tfmt.Println(strings.Repeat(\"*\", 80))\n\treturn nil\n}", "title": "" }, { "docid": "74dc2b91f5ab6f42f9cdb1ba42802b1b", "score": "0.48097563", "text": "func (s *Service) GetResourceStats(url string, start, end time.Time) (*statistic.DetailStats, error) {\n\tresult := statistic.NewDetailStats()\n\n\tsLogs, err := s.store.FetchLogs(start, end, url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor len(sLogs) > 0 {\n\t\terr = result.CalculateLogs(sLogs)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tstart = sLogs[len(sLogs)-1].CreatedAt\n\n\t\tsLogs, err = s.store.FetchLogs(start, end, url)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn result, nil\n}", "title": "" }, { "docid": "de1312711ef917e223ac4fcdffd634c6", "score": "0.48093563", "text": "func listResources(clt resourcesAPIGetter, r *http.Request, resourceKind string) (*types.ListResourcesResponse, error) {\n\tvalues := r.URL.Query()\n\n\tlimit, err := queryLimitAsInt32(values, \"limit\", defaults.MaxIterationLimit)\n\tif err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\n\t// Sort is expected in format `<fieldName>:<asc|desc>` where\n\t// index 0 is fieldName and index 1 is direction.\n\t// If a direction is not set, or is not recognized, it defaults to ASC.\n\tvar sortBy types.SortBy\n\tsortParam := values.Get(\"sort\")\n\tif sortParam != \"\" {\n\t\tvals := strings.Split(sortParam, \":\")\n\t\tif vals[0] != \"\" {\n\t\t\tsortBy.Field = vals[0]\n\t\t\tif len(vals) > 1 && vals[1] == \"desc\" {\n\t\t\t\tsortBy.IsDesc = true\n\t\t\t}\n\t\t}\n\t}\n\n\tstartKey := values.Get(\"startKey\")\n\treq := proto.ListResourcesRequest{\n\t\tResourceType: resourceKind,\n\t\tLimit: limit,\n\t\tStartKey: startKey,\n\t\tSortBy: sortBy,\n\t\tPredicateExpression: values.Get(\"query\"),\n\t\tSearchKeywords: client.ParseSearchKeywords(values.Get(\"search\"), ' '),\n\t\tUseSearchAsRoles: values.Get(\"searchAsRoles\") == \"yes\",\n\t}\n\n\treturn clt.ListResources(r.Context(), req)\n}", "title": "" }, { "docid": "760c2d4962581251cd625300f0a7081d", "score": "0.4803304", "text": "func initializeResources(ctx context.Context, f *framework.Framework, protocols []v1.Protocol, ports []int32) *kubeManager {\n\tk8s, err := initializeCluster(ctx, f, protocols, ports)\n\tframework.ExpectNoError(err, \"unable to initialize resources\")\n\treturn k8s\n}", "title": "" }, { "docid": "d60d07c35378b221483012d614e7f6cd", "score": "0.480304", "text": "func (s *ResourcesService) List(ctx context.Context, realm, clientID string) ([]*Resource, *http.Response, error) {\n\tu := fmt.Sprintf(\"admin/realms/%s/clients/%s/authz/resource-server/resource\", realm, clientID)\n\treq, err := s.keycloak.NewRequest(http.MethodGet, u, nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tvar resources []*Resource\n\tres, err := s.keycloak.Do(ctx, req, &resources)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treturn resources, res, nil\n}", "title": "" }, { "docid": "d48ac3efb1da66554df5277233111114", "score": "0.48010445", "text": "func getResourceList(cpu, memory string) v1.ResourceList {\n\tres := v1.ResourceList{}\n\tif cpu != \"\" {\n\t\tres[v1.ResourceCPU] = resource.MustParse(cpu)\n\t}\n\tif memory != \"\" {\n\t\tres[v1.ResourceMemory] = resource.MustParse(memory)\n\t}\n\treturn res\n}", "title": "" }, { "docid": "957ecd2876110fc221fc4a69b546ca16", "score": "0.47966555", "text": "func (w *windowsResourceUsageGatherer) Gather(executor QueryExecutor, startTime time.Time, config *measurement.MeasurementConfig) ([]measurement.Summary, error) {\n\tcpuSummary, err := getSummary(cpuUsageQueryTop10, convertToCPUPerfData, cpuUsageMetricsName, executor, config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tmemorySummary, err := getSummary(memoryUsageQueryTop10, convertToMemoryPerfData, memoryUsageMetricsName, executor, config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn []measurement.Summary{cpuSummary, memorySummary}, nil\n}", "title": "" }, { "docid": "e76652a284173b393d4e38598de3cc09", "score": "0.4791523", "text": "func createFromResources(dp *v1alpha1.EdgeDataplane, da *v1alpha1.EdgeTraceabilityAgent) (*APIGatewayConfiguration, error) {\n\n\tcfg := &APIGatewayConfiguration{\n\t\tHost: dp.Spec.ApiGatewayManager.Host,\n\t\tPort: int(dp.Spec.ApiGatewayManager.Port),\n\t\tEnableAPICalls: da.Spec.Config.ProcessHeaders,\n\t\tPollInterval: 1 * time.Minute,\n\t}\n\n\tif dp.Spec.ApiGatewayManager.PollInterval != \"\" {\n\t\tresCfgPollInterval, err := time.ParseDuration(dp.Spec.ApiGatewayManager.PollInterval)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tcfg.PollInterval = resCfgPollInterval\n\t}\n\treturn cfg, nil\n}", "title": "" }, { "docid": "fc920539eb083e1ad0b0d31185dc8b34", "score": "0.479019", "text": "func (um *Manager) upgradeGroupVersion(ctx context.Context, groupVersion string) error {\n\t// new client to get updated restmapper\n\tc, err := client.New(um.mgr.GetConfig(), client.Options{Scheme: um.mgr.GetScheme(), Mapper: nil})\n\tif err != nil {\n\t\treturn err\n\t}\n\tum.client = c\n\tif err := um.ensureCRDExists(ctx); err != nil {\n\t\tlog.Info(\"required crd has not been deployed \", \"CRD\", crdName)\n\t\treturn err\n\t}\n\t// get all resource kinds\n\tresourceList, err := um.getAllKinds(groupVersion)\n\tif err != nil {\n\t\t// If the resource doesn't exist, it doesn't need upgrading\n\t\tif errors.IsNotFound(err) {\n\t\t\treturn nil\n\t\t}\n\t\treturn err\n\t}\n\n\tresourceGV := strings.Split(resourceList.GroupVersion, \"/\")\n\tgroup := resourceGV[0]\n\tversion := resourceGV[1]\n\n\t// For some reason we have seen duplicate kinds, suppress that\n\tuniqueKinds := make(map[string]bool)\n\tfor i := range resourceList.APIResources {\n\t\tuniqueKinds[resourceList.APIResources[i].Kind] = true\n\t}\n\n\t// get resource for each Kind\n\tfor kind := range uniqueKinds {\n\t\tlog.Info(\"resource\", \"kind\", kind, \"group\", group, \"version\", version)\n\t\tresourceGvk := schema.GroupVersionKind{\n\t\t\tGroup: group,\n\t\t\tVersion: version,\n\t\t\tKind: kind + \"List\",\n\t\t}\n\t\tinstanceList := &unstructured.UnstructuredList{}\n\t\tinstanceList.SetGroupVersionKind(resourceGvk)\n\t\terr := um.client.List(ctx, instanceList)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tlog.Info(\"resource count\", \"count\", len(instanceList.Items))\n\t\tupdateResources := make(map[util.KindVersionName]unstructured.Unstructured, len(instanceList.Items))\n\t\t// get each resource\n\t\tfor _, item := range instanceList.Items {\n\t\t\tkey := util.GetUniqueKey(item)\n\t\t\tupdateResources[key] = item\n\t\t}\n\n\t\tif len(updateResources) > 0 {\n\t\t\turloop := &updateResourceLoop{\n\t\t\t\tur: updateResources,\n\t\t\t\tclient: um.client,\n\t\t\t\tstop: make(chan struct{}),\n\t\t\t\tstopped: make(chan struct{}),\n\t\t\t}\n\t\t\tlog.Info(\"starting update resources loop\", \"group\", group, \"version\", version, \"kind\", kind)\n\t\t\tgo urloop.update(ctx)\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "0a7c3635fbc04181dea2f002e2fc4e8d", "score": "0.4789984", "text": "func (adminVdc *AdminVdc) Refresh() error {\n\tif *adminVdc == (AdminVdc{}) || adminVdc.AdminVdc.HREF == \"\" {\n\t\treturn fmt.Errorf(\"cannot refresh, Object is empty or HREF is empty\")\n\t}\n\n\t// Empty struct before a new unmarshal, otherwise we end up with duplicate\n\t// elements in slices.\n\tunmarshalledAdminVdc := &types.AdminVdc{}\n\n\t_, err := adminVdc.client.ExecuteRequest(adminVdc.AdminVdc.HREF, http.MethodGet,\n\t\t\"\", \"error refreshing VDC: %s\", nil, unmarshalledAdminVdc)\n\tif err != nil {\n\t\treturn err\n\t}\n\tadminVdc.AdminVdc = unmarshalledAdminVdc\n\n\treturn nil\n}", "title": "" }, { "docid": "07f8f6b3fd199d7b211f30649a0ae10d", "score": "0.4787788", "text": "func (p *DockerPod) UpdateResources(id string, resource *schedTypes.TaskResources) error {\n\tvar exist bool\n\tvar conTask *container.BcsContainerTask\n\n\tfor _, con := range p.conTasks {\n\t\tif con.RuntimeConf.ID == id {\n\t\t\texist = true\n\t\t\tconTask = con\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !exist {\n\t\treturn fmt.Errorf(\"container id %s is invalid\", id)\n\t}\n\n\terr := p.conClient.UpdateResources(id, resource)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tconTask.RuntimeConf.Resource.Cpus = *resource.ReqCpu\n\tconTask.RuntimeConf.Resource.Mem = *resource.ReqMem\n\treturn nil\n}", "title": "" }, { "docid": "d6539359f7bf3f19e176e2d7586a4775", "score": "0.4786592", "text": "func (d *Dao) Resources(c context.Context) (rscs []*model.Resource, err error) {\n\tvar size sql.NullString\n\trows, err := d.db.Query(c, _allResSQL)\n\tif err != nil {\n\t\tlog.Error(\"d.Resources query error (%v)\", err)\n\t\treturn\n\t}\n\tdefer rows.Close()\n\tfor rows.Next() {\n\t\trsc := &model.Resource{}\n\t\tif err = rows.Scan(&rsc.ID, &rsc.Platform, &rsc.Name, &rsc.Parent, &rsc.Counter, &rsc.Position, &rsc.Rule, &size, &rsc.Previce,\n\t\t\t&rsc.Desc, &rsc.Mark, &rsc.CTime, &rsc.MTime, &rsc.Level, &rsc.Type, &rsc.IsAd); err != nil {\n\t\t\tlog.Error(\"Resources rows.Scan err (%v)\", err)\n\t\t\treturn\n\t\t}\n\t\trsc.Size = size.String\n\t\trscs = append(rscs, rsc)\n\t}\n\terr = rows.Err()\n\treturn\n}", "title": "" }, { "docid": "be1d69374533e6b673c7aaa1fc72d151", "score": "0.47733623", "text": "func (d *instanceProvider) GetResource(ctx context.Context) (*schema.Resources, error) {\n\tlist := &schema.Resources{}\n\n\tfor _, zone := range scw.AllZones {\n\t\treq := &instance.ListServersRequest{\n\t\t\tZone: zone,\n\t\t}\n\t\tvar totalResults uint32\n\t\tfor {\n\t\t\tresp, err := d.instanceAPI.ListServers(req)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tfor _, server := range resp.Servers {\n\t\t\t\ttotalResults++\n\n\t\t\t\tvar ip4, privateIP4 string\n\t\t\t\tif server.PublicIP != nil && server.PublicIP.Address != nil {\n\t\t\t\t\tip4 = server.PublicIP.Address.String()\n\t\t\t\t}\n\t\t\t\tif server.PrivateIP != nil {\n\t\t\t\t\tprivateIP4 = *server.PrivateIP\n\t\t\t\t}\n\t\t\t\tlist.Append(&schema.Resource{\n\t\t\t\t\tProvider: providerName,\n\t\t\t\t\tPublicIPv4: ip4,\n\t\t\t\t\tProfile: d.profile,\n\t\t\t\t\tPrivateIpv4: privateIP4,\n\t\t\t\t\tPublic: ip4 != \"\",\n\t\t\t\t})\n\t\t\t}\n\t\t\tif resp.TotalCount == totalResults {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\t*req.Page = *req.Page + 1\n\t\t}\n\t}\n\treturn list, nil\n}", "title": "" }, { "docid": "b7d695cf39e1e5fd987645791364f913", "score": "0.47701323", "text": "func (p *StoragePool) Refresh(flags uint32) error {\n\treq := libvirt.RemoteStoragePoolRefreshReq{Pool: p.RemoteStoragePool, Flags: uint32(flags)}\n\n\tbuf, err := encode(&req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tresp, err := p.l.send(libvirt.RemoteProcStoragePoolRefresh, 0, libvirt.MessageTypeCall, libvirt.RemoteProgram, libvirt.MessageStatusOK, &buf)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tr := <-resp\n\tif r.Header.Status != libvirt.MessageStatusOK {\n\t\treturn decodeError(r.Payload)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "67ee8f0dfcdccfa69aa61ae787227953", "score": "0.47700542", "text": "func (n *resPool) updateStaticResourceMetrics() {\n\tn.metrics.ResourcePoolShare.Update(getShare(n.resourceConfigs))\n\tn.metrics.ResourcePoolLimit.Update(getLimits(n.resourceConfigs))\n\tn.metrics.ResourcePoolReservation.Update(n.reservation)\n\n\tif n.controllerLimit != nil {\n\t\tn.metrics.ControllerLimit.Update(n.controllerLimit)\n\t}\n\tif n.slackLimit != nil {\n\t\tn.metrics.SlackLimit.Update(n.slackLimit)\n\t}\n}", "title": "" } ]
446f195723e35da5dae1dac3952486e5
NewMetrics creates a new set of metrics and registers them with the supplied registry. NOTE: when adding new metrics, update Zero() and run `./hack/generatemetricsdoc.go` using `make generatemetricsdocs` to regenerate the metrics documentation.
[ { "docid": "027ce0af57397c4af6fdddd080dae4b0", "score": "0.66623515", "text": "func NewMetrics(registry *prometheus.Registry) *Metrics {\n\tm := Metrics{\n\t\tbuildInfoGauge: prometheus.NewGaugeVec(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tName: BuildInfoGauge,\n\t\t\t\tHelp: \"Build information for Contour. Labels include the branch and git SHA that Contour was built from, and the Contour version.\",\n\t\t\t},\n\t\t\t[]string{\"branch\", \"revision\", \"version\"},\n\t\t),\n\t\tproxyMetricCache: &RouteMetric{},\n\t\tproxyTotalGauge: prometheus.NewGaugeVec(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tName: HTTPProxyTotalGauge,\n\t\t\t\tHelp: \"Total number of HTTPProxies that exist regardless of status.\",\n\t\t\t},\n\t\t\t[]string{\"namespace\"},\n\t\t),\n\t\tproxyRootTotalGauge: prometheus.NewGaugeVec(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tName: HTTPProxyRootTotalGauge,\n\t\t\t\tHelp: \"Total number of root HTTPProxies. Note there will only be a single root HTTPProxy per vhost.\",\n\t\t\t},\n\t\t\t[]string{\"namespace\"},\n\t\t),\n\t\tproxyInvalidGauge: prometheus.NewGaugeVec(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tName: HTTPProxyInvalidGauge,\n\t\t\t\tHelp: \"Total number of invalid HTTPProxies.\",\n\t\t\t},\n\t\t\t[]string{\"namespace\", \"vhost\"},\n\t\t),\n\t\tproxyValidGauge: prometheus.NewGaugeVec(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tName: HTTPProxyValidGauge,\n\t\t\t\tHelp: \"Total number of valid HTTPProxies.\",\n\t\t\t},\n\t\t\t[]string{\"namespace\", \"vhost\"},\n\t\t),\n\t\tproxyOrphanedGauge: prometheus.NewGaugeVec(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tName: HTTPProxyOrphanedGauge,\n\t\t\t\tHelp: \"Total number of orphaned HTTPProxies which have no root delegating to them.\",\n\t\t\t},\n\t\t\t[]string{\"namespace\"},\n\t\t),\n\t\tdagRebuildGauge: prometheus.NewGauge(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tName: DAGRebuildGauge,\n\t\t\t\tHelp: \"Timestamp of the last DAG rebuild.\",\n\t\t\t},\n\t\t),\n\t\tdagCacheObjectGauge: prometheus.NewGaugeVec(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tName: DAGCacheObjectGauge,\n\t\t\t\tHelp: \"Total number of items that are currently in the DAG cache.\",\n\t\t\t},\n\t\t\t[]string{\"kind\"},\n\t\t),\n\t\tdagRebuildTotal: prometheus.NewCounter(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tName: DAGRebuildTotal,\n\t\t\t\tHelp: \"Total number of times DAG has been rebuilt since startup\",\n\t\t\t},\n\t\t),\n\t\tDAGRebuildSeconds: prometheus.NewSummary(\n\t\t\tprometheus.SummaryOpts{\n\t\t\t\tName: DAGRebuildSeconds,\n\t\t\t\tHelp: \"Duration in seconds of DAG rebuilds\",\n\t\t\t\tObjectives: map[float64]float64{\n\t\t\t\t\t0.00: 0.01,\n\t\t\t\t\t0.25: 0.01,\n\t\t\t\t\t0.50: 0.01,\n\t\t\t\t\t0.75: 0.01,\n\t\t\t\t\t0.90: 0.01,\n\t\t\t\t\t0.95: 0.005,\n\t\t\t\t\t0.99: 0.001,\n\t\t\t\t\t1.00: 0.001,\n\t\t\t\t},\n\t\t\t},\n\t\t),\n\t\tCacheHandlerOnUpdateSummary: prometheus.NewSummary(prometheus.SummaryOpts{\n\t\t\tName: cacheHandlerOnUpdateSummary,\n\t\t\tHelp: \"Histogram for the runtime of xDS cache regeneration.\",\n\t\t\tObjectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},\n\t\t}),\n\t\tEventHandlerOperations: prometheus.NewCounterVec(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tName: eventHandlerOperations,\n\t\t\t\tHelp: \"Total number of Kubernetes object changes Contour has received by operation and object kind.\",\n\t\t\t},\n\t\t\t[]string{\"op\", \"kind\"},\n\t\t),\n\t\tstatusUpdateTotal: prometheus.NewCounterVec(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tName: statusUpdateTotal,\n\t\t\t\tHelp: \"Total number of status updates by object kind.\",\n\t\t\t},\n\t\t\t[]string{\"kind\"},\n\t\t),\n\t\tstatusUpdateSuccess: prometheus.NewCounterVec(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tName: statusUpdateSuccess,\n\t\t\t\tHelp: \"Number of status updates that succeeded by object kind.\",\n\t\t\t},\n\t\t\t[]string{\"kind\"},\n\t\t),\n\t\tstatusUpdateNoop: prometheus.NewCounterVec(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tName: statusUpdateNoop,\n\t\t\t\tHelp: \"Number of status updates that are no-ops by object kind. This is a subset of successful status updates.\",\n\t\t\t},\n\t\t\t[]string{\"kind\"},\n\t\t),\n\t\tstatusUpdateFailed: prometheus.NewCounterVec(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tName: statusUpdateFailed,\n\t\t\t\tHelp: \"Number of status updates that failed by object kind.\",\n\t\t\t},\n\t\t\t[]string{\"kind\"},\n\t\t),\n\t\tstatusUpdateConflict: prometheus.NewCounterVec(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tName: statusUpdateConflict,\n\t\t\t\tHelp: \"Number of status update conflicts encountered by object kind.\",\n\t\t\t},\n\t\t\t[]string{\"kind\"},\n\t\t),\n\t\tstatusUpdateDurationSeconds: prometheus.NewSummaryVec(\n\t\t\tprometheus.SummaryOpts{\n\t\t\t\tName: statusUpdateDurationSeconds,\n\t\t\t\tHelp: \"How long a status update takes to finish.\",\n\t\t\t\tObjectives: map[float64]float64{\n\t\t\t\t\t0.00: 0.01,\n\t\t\t\t\t0.25: 0.01,\n\t\t\t\t\t0.50: 0.01,\n\t\t\t\t\t0.75: 0.01,\n\t\t\t\t\t0.90: 0.01,\n\t\t\t\t\t0.95: 0.005,\n\t\t\t\t\t0.99: 0.001,\n\t\t\t\t\t1.00: 0.001,\n\t\t\t\t},\n\t\t\t},\n\t\t\t[]string{\"kind\", \"error\"},\n\t\t),\n\t}\n\tm.buildInfoGauge.WithLabelValues(build.Branch, build.Sha, build.Version).Set(1)\n\tm.register(registry)\n\treturn &m\n}", "title": "" } ]
[ { "docid": "8e69559ab0d2bd802aeaa5c293e5f6e7", "score": "0.7483742", "text": "func NewMetrics(reg prometheus.Registerer) *Metrics {\n\tvar m Metrics\n\tm.reg = reg\n\n\tm.dockerEntries = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tName: \"loki_source_docker_target_entries_total\",\n\t\tHelp: \"Total number of successful entries sent to the Docker target\",\n\t})\n\tm.dockerErrors = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tName: \"loki_source_docker_target_parsing_errors_total\",\n\t\tHelp: \"Total number of parsing errors while receiving Docker messages\",\n\t})\n\n\tif reg != nil {\n\t\treg.MustRegister(\n\t\t\tm.dockerEntries,\n\t\t\tm.dockerErrors,\n\t\t)\n\t}\n\n\treturn &m\n}", "title": "" }, { "docid": "fe56dd6b3947a66d5b0b897e91a6363c", "score": "0.7483411", "text": "func NewMetrics(reg prometheus.Registerer) *Metrics {\n\tvar m Metrics\n\tm.reg = reg\n\n\tm.gelfEntries = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tNamespace: \"agent\",\n\t\tName: \"loki_source_gelf_target_entries_total\",\n\t\tHelp: \"Total number of successful entries sent to the gelf target\",\n\t})\n\tm.gelfErrors = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tNamespace: \"agent\",\n\t\tName: \"loki_source_gelf_target_parsing_errors_total\",\n\t\tHelp: \"Total number of parsing errors while receiving gelf messages\",\n\t})\n\n\tif reg != nil {\n\t\treg.MustRegister(\n\t\t\tm.gelfEntries,\n\t\t\tm.gelfErrors,\n\t\t)\n\t}\n\n\treturn &m\n}", "title": "" }, { "docid": "9bb87ddabf97377a8164229f9cb55af8", "score": "0.73789376", "text": "func NewMetrics() (*Metrics, error) {\n\ta := &Metrics{\n\t\tsplitBrain: prometheus.NewGauge(prometheus.GaugeOpts{\n\t\t\tNamespace: \"quorum\",\n\t\t\tName: \"split_brain\",\n\t\t\tHelp: \"whether this node is in split brain mode or not\",\n\t\t}),\n\t\traftMembers: prometheus.NewGauge(prometheus.GaugeOpts{\n\t\t\tNamespace: \"quorum\",\n\t\t\tName: \"raft_members\",\n\t\t\tHelp: \"how many nodes are in the raft group\",\n\t\t}),\n\t\tmemberlistMembers: prometheus.NewGauge(prometheus.GaugeOpts{\n\t\t\tNamespace: \"quorum\",\n\t\t\tName: \"memberlist_members\",\n\t\t\tHelp: \"how many nodes are in the memberlist group\",\n\t\t}),\n\t}\n\treturn a, a.Register()\n}", "title": "" }, { "docid": "9fdf90e83dfc7fcd497c8c956d66de6a", "score": "0.73377794", "text": "func NewMetrics() *Metrics {\n\treturn &Metrics{\n\t\tclients: make(map[string]bool),\n\t\taggregation: new(stats.Statistics),\n\t}\n}", "title": "" }, { "docid": "7dc589e3206d46dc2e3f5f193cd6e414", "score": "0.7267172", "text": "func NewMetrics(body []byte) (*Metrics, error) {\n\tmetrics := &Metrics{}\n\tif err := metrics.parseMetrics(string(body)); err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to create a new Metrics object: %v\", err)\n\t}\n\treturn metrics, nil\n}", "title": "" }, { "docid": "c6fe94f977273f307d90f7862f3b8fd6", "score": "0.7237815", "text": "func NewMetrics(scope tally.Scope) *Metrics {\n\treturn &Metrics{\n\t\tstartMaintenanceSuccess: scope.Counter(\"start_maintenance_success\"),\n\t\tstartMaintenanceFail: scope.Counter(\"start_maintenance_fail\"),\n\t\tcompleteMaintenanceSuccess: scope.Counter(\"complete_maintenance_success\"),\n\t\tcompleteMaintenanceFail: scope.Counter(\"complete_maintenance_fail\"),\n\t\tdequeueErrors: scope.Counter(\"dequeue_errors\"),\n\t\tenqueueErrors: scope.Counter(\"enqueue_errors\"),\n\t\tpendingMoveRequests: scope.Gauge(\"pending_move_requests\"),\n\t\treconcileHostRequests: scope.Gauge(\"reconcile_host_requests\"),\n\t\treconcileHostSuccess: scope.Counter(\"reconcile_host_success\"),\n\t\treconcileHostFailed: scope.Counter(\"reconcile_host_failed\"),\n\n\t\tscope: scope,\n\t}\n}", "title": "" }, { "docid": "b3fa0032e434d57ad54c1bed4fcba4df", "score": "0.7120818", "text": "func NewMetrics() *Metrics {\n\tsubsystem := \"rbac_generator_controller\"\n\tcm := &Metrics{\n\t\tWorkers: prometheus.NewGauge(prometheus.GaugeOpts{\n\t\t\tNamespace: metricNamespace,\n\t\t\tSubsystem: subsystem,\n\t\t\tName: \"workers\",\n\t\t\tHelp: \"The number of running RBACGenerator controller workers\",\n\t\t}),\n\t}\n\n\tcm.Workers.Set(0)\n\treturn cm\n}", "title": "" }, { "docid": "91e285237a769fdf00c156c27b6e801a", "score": "0.7061546", "text": "func NewMetrics(scope tally.Scope) *Metrics {\n\tactiveTaskQuerySuccess := scope.Tagged(map[string]string{\"result\": \"success\"})\n\tactiveTaskQueryFailed := scope.Tagged(map[string]string{\"result\": \"fail\"})\n\n\treturn &Metrics{\n\t\tActiveTaskQuerySuccess: activeTaskQuerySuccess.Counter(\"active_task_query\"),\n\t\tActiveTaskQueryFail: activeTaskQueryFailed.Counter(\"active_task_query\"),\n\t\tUpdaterRMTasksDuraion: scope.Timer(\"update_rm_tasks_duration\"),\n\t}\n\n}", "title": "" }, { "docid": "365e5de6aa1cc0c5da8815d3521ef134", "score": "0.6976666", "text": "func New() *Metrics {\n\tregistry := prometheus.NewRegistry()\n\n\tregistry.MustRegister(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{\n\t\tNamespace: namespace,\n\t}))\n\n\tregistry.MustRegister(collectors.NewGoCollector())\n\tregistry.MustRegister(version.Collector(namespace))\n\n\treturn &Metrics{\n\t\tNamespace: namespace,\n\t\tRegistry: registry,\n\t}\n}", "title": "" }, { "docid": "92519226e4fc5d0de59cb2c0591f5eb3", "score": "0.6962698", "text": "func NewMetrics() (Metrics, *prometheus.Registry) {\n\tconst (\n\t\tnamespace = \"netconsoled\"\n\t\tlogSubsystem = \"logs\"\n\n\t\tlabelHost = \"host\"\n\t\tlabelStatus = \"status\"\n\t)\n\n\treg := prometheus.NewRegistry()\n\treg.MustRegister(prometheus.NewGoCollector())\n\treg.MustRegister(prometheus.NewProcessCollector(os.Getpid(), \"\"))\n\n\tlogsRecv := prometheus.NewCounterVec(prometheus.CounterOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: logSubsystem,\n\t\tName: \"received_total\",\n\t\tHelp: \"Total number of logs received by the UDP server.\",\n\t}, []string{labelHost})\n\treg.MustRegister(logsRecv)\n\n\tlogsFilter := prometheus.NewCounterVec(prometheus.CounterOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: logSubsystem,\n\t\tName: \"filter_total\",\n\t\tHelp: \"Total number of logs passed through a filter by status.\",\n\t}, []string{labelHost, labelStatus})\n\treg.MustRegister(logsFilter)\n\n\tlogsSink := prometheus.NewCounterVec(prometheus.CounterOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: logSubsystem,\n\t\tName: \"sink_total\",\n\t\tHelp: \"Total number of logs passed to a sink by status.\",\n\t}, []string{labelHost, labelStatus})\n\treg.MustRegister(logsSink)\n\n\treturn Metrics{\n\t\tLogsReceivedTotal: logsRecv,\n\t\tLogsFilterTotal: logsFilter,\n\t\tLogsSinkTotal: logsSink,\n\t}, reg\n}", "title": "" }, { "docid": "2ff287d85164b9bd29f3cd417df532c7", "score": "0.69309694", "text": "func NewMetrics() *Metrics {\n\tcounter := promauto.NewCounterVec(prometheus.CounterOpts{\n\t\tName: \"kiosk_requests_count\",\n\t\tHelp: \"Number of requests handled so far\",\n\t}, []string{\"type\", \"service\", \"method\", \"code\", \"message\", \"status\"})\n\n\thistogram := promauto.NewHistogramVec(prometheus.HistogramOpts{\n\t\tName: \"kiosk_requests_seconds\",\n\t\tHelp: \"The time took us to handle each request\",\n\t}, []string{\"type\", \"service\", \"method\", \"code\", \"message\", \"status\"})\n\n\treturn &Metrics{\n\t\tHandledCounter: counter,\n\t\tHandledHistogram: histogram,\n\t}\n}", "title": "" }, { "docid": "2705181e762f232a484452c64a479b87", "score": "0.6881852", "text": "func newMonitoringMetrics() monitoringMetrics {\n\tlabels := prometheus.Labels{}\n\treturn monitoringMetrics{\n\t\tSuccessCertIssuance: successCertIssuanceCount.With(labels),\n\t\tCSR: csrCount.With(labels),\n\t\tAuthenticationError: authenticationErrorCount.With(labels),\n\t\tCSRParsingError: csrParsingErrorCount.With(labels),\n\t\tIDExtractionError: idExtractionErrorCount.With(labels),\n\t\tCSRSignError: csrSignErrorCount.With(labels),\n\t}\n}", "title": "" }, { "docid": "d0514b215bf1e7e85e29fb8ea0844528", "score": "0.68767184", "text": "func NewMetrics() *Metrics {\n\tbaseLabels := []string{\"method\", \"url\", \"status\"}\n\treturn &Metrics{\n\t\trequestLatencyHistogram: prometheus.NewHistogramVec(prometheus.HistogramOpts{\n\t\t\tName: \"request_seconds\",\n\t\t\tHelp: \"Request latency\",\n\t\t\tBuckets: prometheus.DefBuckets,\n\t\t}, baseLabels),\n\t\trequestBytesInCounter: prometheus.NewCounterVec(prometheus.CounterOpts{\n\t\t\tName: \"request_bytes_in\",\n\t\t\tHelp: \"Bytes received from servers as response to requests\",\n\t\t}, baseLabels),\n\t\trequestBytesOutCounter: prometheus.NewCounterVec(prometheus.CounterOpts{\n\t\t\tName: \"request_bytes_out\",\n\t\t\tHelp: \"Bytes sent to servers during requests\",\n\t\t}, baseLabels),\n\t\trequestFailCounter: prometheus.NewCounterVec(prometheus.CounterOpts{\n\t\t\tName: \"request_fail_count\",\n\t\t\tHelp: \"Count of failed requests\",\n\t\t}, append(baseLabels[:len(baseLabels):len(baseLabels)], \"message\")),\n\t}\n}", "title": "" }, { "docid": "5b6bd6ff14e7d044146cafc0ba6f4021", "score": "0.68764746", "text": "func NewMetrics(logger logrus.FieldLogger) Metrics {\n\treturn Metrics{\n\t\tRegistry: prometheus.NewRegistry(),\n\t\tFieldLogger: logger,\n\t\tMetrics: map[string]prometheus.Collector{\n\t\t\tIngressRouteTotalGauge: prometheus.NewGaugeVec(\n\t\t\t\tprometheus.GaugeOpts{\n\t\t\t\t\tName: IngressRouteTotalGauge,\n\t\t\t\t\tHelp: \"Total number of IngressRoutes\",\n\t\t\t\t},\n\t\t\t\t[]string{\"namespace\", \"vhost\"},\n\t\t\t),\n\t\t},\n\t}\n}", "title": "" }, { "docid": "28f9bf4ace839ca772d72921a714adbb", "score": "0.685958", "text": "func NewMetrics(ctx context.Context, namespace, kubeconfig string) (metrics *MetricsHandler, err error) {\n\tvar (\n\t\tconfig *rest.Config\n\t\tclientset *metricsv.Clientset\n\t)\n\n\tif len(kubeconfig) != 0 {\n\t\t// create a rest config from kubeconfig\n\t\tif config, err = clientcmd.BuildConfigFromFlags(\"\", kubeconfig); err != nil {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\t// create a rest config in-cluster config\n\t\tif config, err = rest.InClusterConfig(); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\n\t// create a metrics clientset from rest config\n\tclientset, err = metricsv.NewForConfig(config)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tmetrics = &MetricsHandler{}\n\tmetrics.kubeconfig = kubeconfig\n\tmetrics.namespace = namespace\n\tmetrics.ctx = ctx\n\tmetrics.config = config\n\tmetrics.clientset = clientset\n\treturn\n}", "title": "" }, { "docid": "a9a4350632ab2366dc4bfd7b9d4e9cfb", "score": "0.68378234", "text": "func NewMetrics(name string) *Metrics {\n\tcontainer := &metricsContainer{\n\t\tname: name,\n\t\tpid: os.Getpid(),\n\t}\n\n\treturn &Metrics{\n\t\texecutor: executors.NewPeriodicalExecutor(logInterval, container),\n\t\tcontainer: container,\n\t}\n}", "title": "" }, { "docid": "c390ffaf8952c8cf78975ac98ca61f1f", "score": "0.67794216", "text": "func NewMetrics(scope tally.Scope) *Metrics {\n\tpoolScope := scope.SubScope(\"pool\")\n\n\t// resources in ready & placing host status\n\treadyScope := poolScope.SubScope(\"ready\")\n\treadyRevocableScope := poolScope.SubScope(\"ready_revocable\")\n\tplacingScope := poolScope.SubScope(\"placing\")\n\tplacingRevocableScope := poolScope.SubScope(\"placing_revocable\")\n\n\thostsScope := poolScope.SubScope(\"hosts\")\n\toffersScope := poolScope.SubScope(\"offers\")\n\n\treturn &Metrics{\n\t\tReady: scalar.NewGaugeMaps(readyScope),\n\t\tReadyRevocable: scalar.NewGaugeMaps(readyRevocableScope),\n\t\tPlacing: scalar.NewGaugeMaps(placingScope),\n\t\tPlacingRevocable: scalar.NewGaugeMaps(placingRevocableScope),\n\n\t\tUnavailableOffers: offersScope.Counter(\"unavilable\"),\n\t\tAcceptableOffers: offersScope.Counter(\"acceptable\"),\n\t\tRescindEvents: offersScope.Counter(\"rescind\"),\n\t\tExpiredOffers: offersScope.Counter(\"expired\"),\n\t\tDecline: offersScope.Counter(\"decline\"),\n\t\tDeclineFail: offersScope.Counter(\"decline_fail\"),\n\n\t\tReadyHosts: hostsScope.Gauge(\"ready\"),\n\t\tPlacingHosts: hostsScope.Gauge(\"placing\"),\n\t\tAvailableHosts: hostsScope.Gauge(\"available\"),\n\t\tReturnUnusedHosts: hostsScope.Counter(\"return_unused\"),\n\t\tResetExpiredPlacingHosts: hostsScope.Counter(\"reset_expired_placing\"),\n\t\tResetExpiredHeldHosts: hostsScope.Counter(\"reset_expired_held\"),\n\t}\n}", "title": "" }, { "docid": "35c6066ea76917e51581e44ef8053731", "score": "0.6743922", "text": "func NewRegistry() *Registry {\n\treturn &Registry{\n\t\tmetrics: make(map[string]metric),\n\t}\n}", "title": "" }, { "docid": "a4202b89378716a73bb3096a509735f0", "score": "0.67262524", "text": "func New() *Metrics {\n\tm := &Metrics{\n\t\tout: os.Stderr,\n\t\tcounters: make(map[string]*Counter),\n\t\tformatter: NewFormatter(\"\\n\"),\n\t}\n\treturn m\n}", "title": "" }, { "docid": "c627416dbbde87e689efaaa68482ba87", "score": "0.6698334", "text": "func New() *Metrics {\n\tmu.Lock()\n\tdefer mu.Unlock()\n\n\t// If the metrics value was not constructed yet, then\n\t// perform the construction.\n\tif m == nil {\n\t\tm = &Metrics{\n\t\t\tGoroutines: expvar.NewInt(\"goroutines\"),\n\t\t\tRequests: expvar.NewInt(\"requests\"),\n\t\t\tErrors: expvar.NewInt(\"errors\"),\n\t\t\tPanics: expvar.NewInt(\"panics\"),\n\t\t}\n\t}\n\treturn m\n}", "title": "" }, { "docid": "e520cff124e29cca1d9eafb348949116", "score": "0.66643506", "text": "func RegisterMetrics() error {\n\tconfig := prometheus.Config{\n\t\tRegistry: metrics.Registry.(*crprometheus.Registry), // use the controller runtime metrics registry / gatherer\n\t}\n\tc := controller.New(\n\t\tprocessor.NewFactory(\n\t\t\tselector.NewWithHistogramDistribution(\n\t\t\t\thistogram.WithExplicitBoundaries(config.DefaultHistogramBoundaries),\n\t\t\t),\n\t\t\taggregation.CumulativeTemporalitySelector(),\n\t\t\tprocessor.WithMemory(true),\n\t\t),\n\t)\n\texporter, err := prometheus.New(config, c)\n\tif err != nil {\n\t\treturn err\n\t}\n\tglobal.SetMeterProvider(exporter.MeterProvider())\n\n\treturn nil\n}", "title": "" }, { "docid": "3d57e73da4201385a7659765db84d341", "score": "0.66564363", "text": "func NewMetrics(executor interfaces.CommandExecutor, lc logger.LoggingClient, executorPath string) *metrics {\n\treturn &metrics{\n\t\texecutor: executor,\n\t\tlc: lc,\n\t\texecutorPath: executorPath,\n\t}\n}", "title": "" }, { "docid": "530fb46b4f192d47f41f295a9c35a975", "score": "0.6653898", "text": "func NewMetrics(scope tally.Scope) *Metrics {\n\treturn &Metrics{\n\t\tSkipOrphanTasksTotal: scope.Counter(\"skip_orphan_task_total\"),\n\n\t\tTasksFailedTotal: scope.Counter(\"tasks_failed_total\"),\n\t\tTasksLostTotal: scope.Counter(\"tasks_lost_total\"),\n\t\tTasksSucceededTotal: scope.Counter(\"tasks_succeeded_total\"),\n\t\tTasksKilledTotal: scope.Counter(\"tasks_killed_total\"),\n\t\tTasksRunningTotal: scope.Counter(\"tasks_running_total\"),\n\t\tTasksLaunchedTotal: scope.Counter(\"tasks_launched_total\"),\n\t\tTasksStartingTotal: scope.Counter(\"tasks_starting_total\"),\n\n\t\tTasksHealthyTotal: scope.Counter(\"tasks_healthy_total\"),\n\t\tTasksUnHealthyTotal: scope.Counter(\"tasks_unhealthy_total\"),\n\n\t\tTasksInPlacePlacementTotal: scope.Counter(\"tasks_in_place_placement_total\"),\n\t\tTasksInPlacePlacementSuccess: scope.Counter(\"tasks_in_place_placement_success\"),\n\n\t\tTasksReconciledTotal: scope.Counter(\"tasks_reconciled_total\"),\n\t\tTasksFailedReason: newTasksFailedReasonScope(scope),\n\t}\n}", "title": "" }, { "docid": "898cb942f4e89d6b3e7fa7ae4a058310", "score": "0.66283387", "text": "func NewRegistry() *Registry {\n\tr := &Registry{\n\t\tallCounters: map[string]*Counter{},\n\t\tallDurationDistributions: map[string]*Distribution[time.Duration]{},\n\t\tallSizeDistributions: map[string]*Distribution[int64]{},\n\t\tallThroughput: map[string]*Throughput{},\n\t}\n\n\treleasable.Created(\"metric-registry\", r)\n\n\treturn r\n}", "title": "" }, { "docid": "fc9c6e41bd0c4c99f33d8c29c8c95f39", "score": "0.65997", "text": "func NewMetricsRegistryMock(t minimock.Tester) *MetricsRegistryMock {\n\tm := &MetricsRegistryMock{t: t}\n\tif controller, ok := t.(minimock.MockController); ok {\n\t\tcontroller.RegisterMocker(m)\n\t}\n\n\tm.SetOldestAbandonedRequestAgeMock = mMetricsRegistryMockSetOldestAbandonedRequestAge{mock: m}\n\tm.SetOldestAbandonedRequestAgeMock.callArgs = []*MetricsRegistryMockSetOldestAbandonedRequestAgeParams{}\n\n\tm.UpdateMetricsMock = mMetricsRegistryMockUpdateMetrics{mock: m}\n\tm.UpdateMetricsMock.callArgs = []*MetricsRegistryMockUpdateMetricsParams{}\n\n\treturn m\n}", "title": "" }, { "docid": "16a7f724cf6e847caf5a0d0fa46e88e8", "score": "0.6575313", "text": "func NewMockMetrics(ctrl *gomock.Controller) *MockMetrics {\n\tmock := &MockMetrics{ctrl: ctrl}\n\tmock.recorder = &MockMetricsMockRecorder{mock}\n\treturn mock\n}", "title": "" }, { "docid": "0f9624956f1d886e23171815dd807af2", "score": "0.65512687", "text": "func NewMetrics( //nolint:funlen // By design.\n\treg *prometheus.Registry,\n\tservice string,\n\tsubsystem string,\n\tmethodsFrom map[string]interface{},\n\terrsCommon []error,\n\terrsExtra map[string][]error,\n) (\n\tmetric Metrics,\n) {\n\tmetric.reqInFlight = prometheus.NewGauge(\n\t\tprometheus.GaugeOpts{\n\t\t\tNamespace: service,\n\t\t\tSubsystem: subsystem,\n\t\t\tName: \"http_requests_in_flight\",\n\t\t\tHelp: \"Amount of currently processing API requests.\",\n\t\t},\n\t)\n\treg.MustRegister(metric.reqInFlight)\n\tmetric.reqTotal = prometheus.NewCounterVec(\n\t\tprometheus.CounterOpts{\n\t\t\tNamespace: service,\n\t\t\tSubsystem: subsystem,\n\t\t\tName: \"http_requests_total\",\n\t\t\tHelp: \"Amount of processed API requests.\",\n\t\t},\n\t\t[]string{methodLabel, codeLabel},\n\t)\n\treg.MustRegister(metric.reqTotal)\n\tmetric.reqDuration = prometheus.NewHistogramVec(\n\t\tprometheus.HistogramOpts{\n\t\t\tNamespace: service,\n\t\t\tSubsystem: subsystem,\n\t\t\tName: \"http_request_duration_seconds\",\n\t\t\tHelp: \"API request latency distributions.\",\n\t\t},\n\t\t[]string{methodLabel, failedLabel},\n\t)\n\treg.MustRegister(metric.reqDuration)\n\n\tcommonCodes := []string{\"\"} // Successful RPC.\n\tcommonCodes = append(commonCodes, codes(errsCommon)...)\n\tfor name, rcvr := range methodsFrom {\n\t\tfor _, methodName := range reflectx.RPCMethodsOf(rcvr) {\n\t\t\tmethodName = name + \".\" + methodName\n\t\t\tif _, ok := errsExtra[methodName]; !ok {\n\t\t\t\tpanic(fmt.Sprintf(\"missing ErrsExtra[%s]\", methodName))\n\t\t\t}\n\t\t\tcodes := append(commonCodes, codes(errsExtra[methodName])...) //nolint:gocritic // Not same slice.\n\t\t\tfor _, code := range codes {\n\t\t\t\tl := prometheus.Labels{\n\t\t\t\t\tmethodLabel: methodName,\n\t\t\t\t\tcodeLabel: code,\n\t\t\t\t}\n\t\t\t\tmetric.reqTotal.With(l)\n\t\t\t}\n\t\t\tfor _, failed := range []string{\"true\", \"false\"} {\n\t\t\t\tl := prometheus.Labels{\n\t\t\t\t\tmethodLabel: methodName,\n\t\t\t\t\tfailedLabel: failed,\n\t\t\t\t}\n\t\t\t\tmetric.reqDuration.With(l)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn metric\n}", "title": "" }, { "docid": "3bf1d94af2789354f218037f9c9d845d", "score": "0.6495576", "text": "func NewMetrics(subsystem string) *Metrics {\n\tbase := metrics.NewBase(\"batch_submitter\", subsystem)\n\treturn &Metrics{\n\t\tBase: base,\n\t\tBatchPruneCount: promauto.NewGauge(prometheus.GaugeOpts{\n\t\t\tName: \"batch_prune_count\",\n\t\t\tHelp: \"Number of times a batch is pruned\",\n\t\t\tSubsystem: base.SubsystemName(),\n\t\t}),\n\t}\n}", "title": "" }, { "docid": "ecb0045bdd9758b5901c3b41d08e6f84", "score": "0.64926296", "text": "func NewMetrics(o Options) Metrics {\n\tvar m Metrics\n\tswitch o.Format {\n\tcase AllKind:\n\t\tm = NewAll(o)\n\tcase PrometheusKind:\n\t\tm = NewPrometheus(o)\n\tdefault:\n\t\t// CodaHale is the default metrics implementation.\n\t\tm = NewCodaHale(o)\n\t}\n\n\treturn m\n}", "title": "" }, { "docid": "b9cacf2b2a9a41716577734334710656", "score": "0.6477388", "text": "func New(cfg *config.Config) *Metrics {\n\tm := &Metrics{\n\t\tqueries: prometheus.NewCounterVec(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tName: \"dns_queries_total\",\n\t\t\t\tHelp: \"How many DNS queries processed\",\n\t\t\t},\n\t\t\t[]string{\"qtype\", \"rcode\"},\n\t\t),\n\t}\n\t_ = prometheus.Register(m.queries)\n\n\treturn m\n}", "title": "" }, { "docid": "1cd84e700947c247d7c2e4ab41e6ae82", "score": "0.6466691", "text": "func New(ctx context.Context, d time.Duration, l logging.Logger) *Metrics {\n\tregistry := metrics.NewPrefixedRegistry(\"krakend.\")\n\n\tm := Metrics{\n\t\tRouter: NewRouterMetrics(&registry),\n\t\tProxy: NewProxyMetrics(&registry),\n\t\tRegistry: &registry,\n\t\tlatestSnapshot: NewStats(),\n\t}\n\n\tm.processMetrics(ctx, d, logger{l})\n\n\treturn &m\n}", "title": "" }, { "docid": "f7037906d76975056ebbc0b54a5005fe", "score": "0.64555866", "text": "func New(ns string, reg prometheus.Registerer) *PrometheusMetrics {\n\tpm := &PrometheusMetrics{}\n\tif reg == nil {\n\t\treg = prometheus.DefaultRegisterer\n\t}\n\n\tpm.apiCalls = prometheus.NewCounterVec(prometheus.CounterOpts{\n\t\tNamespace: ns,\n\t\tName: \"api_calls_total\",\n\t\tHelp: \"Count of API Calls made\",\n\t}, []string{\"kind\"})\n\n\tpm.failedAPICalls = prometheus.NewCounterVec(prometheus.CounterOpts{\n\t\tNamespace: ns,\n\t\tName: \"failed_api_calls_total\",\n\t\tHelp: \"Count of failed API Calls made\",\n\t}, []string{\"kind\"})\n\n\treg.MustRegister(pm.apiCalls)\n\treg.MustRegister(pm.failedAPICalls)\n\treturn pm\n}", "title": "" }, { "docid": "d9447d760284995a745c46beb8b2d646", "score": "0.64486796", "text": "func NewMetrics() *Metrics {\n\treturn &Metrics{\n\t\tInputBytesTotal: promauto.NewCounterVec(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tName: \"router_input_bytes_total\",\n\t\t\t\tHelp: \"Total number of bytes received\",\n\t\t\t},\n\t\t\t[]string{\"interface\", \"isd_as\", \"neighbor_isd_as\"},\n\t\t),\n\t\tOutputBytesTotal: promauto.NewCounterVec(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tName: \"router_output_bytes_total\",\n\t\t\t\tHelp: \"Total number of bytes sent.\",\n\t\t\t},\n\t\t\t[]string{\"interface\", \"isd_as\", \"neighbor_isd_as\"},\n\t\t),\n\t\tInputPacketsTotal: promauto.NewCounterVec(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tName: \"router_input_pkts_total\",\n\t\t\t\tHelp: \"Total number of packets received\",\n\t\t\t},\n\t\t\t[]string{\"interface\", \"isd_as\", \"neighbor_isd_as\"},\n\t\t),\n\t\tOutputPacketsTotal: promauto.NewCounterVec(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tName: \"router_output_pkts_total\",\n\t\t\t\tHelp: \"Total number of packets sent.\",\n\t\t\t},\n\t\t\t[]string{\"interface\", \"isd_as\", \"neighbor_isd_as\"},\n\t\t),\n\t\tInputErrorsTotal: promauto.NewCounterVec(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tName: \"router_input_read_errors_total\",\n\t\t\t\tHelp: \"Total number of input socket read errors\",\n\t\t\t},\n\t\t\t[]string{\"interface\", \"isd_as\", \"neighbor_isd_as\"},\n\t\t),\n\t\tOutputErrorsTotal: promauto.NewCounterVec(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tName: \"router_output_write_errors_total\",\n\t\t\t\tHelp: \"Total number of output socket write errors.\",\n\t\t\t},\n\t\t\t[]string{\"interface\", \"isd_as\", \"neighbor_isd_as\"},\n\t\t),\n\t\tInputDroppedPacketsTotal: promauto.NewCounterVec(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tName: \"router_input_dropped_pkts_total\",\n\t\t\t\tHelp: \"Total number of packets dropped by kernel due to receive buffer overflow\",\n\t\t\t},\n\t\t\t[]string{\"interface\", \"isd_as\", \"neighbor_isd_as\"},\n\t\t),\n\t}\n}", "title": "" }, { "docid": "efdb922ec64f07f256fac81f4219ecdc", "score": "0.6448665", "text": "func (c *Allocator) newMetrics(ctx context.Context) *metrics {\n\tctx, err := tag.New(ctx, latencyTags...)\n\tif err != nil {\n\t\tc.baseLogger.WithError(err).Warn(\"failed to tag latency recorder.\")\n\t}\n\treturn &metrics{\n\t\tctx: ctx,\n\t\tgameServerLister: c.allocationCache.gameServerLister,\n\t\tlogger: c.baseLogger,\n\t\tstart: time.Now(),\n\t}\n}", "title": "" }, { "docid": "bba3def99b7e951818181664675e9bb9", "score": "0.63457024", "text": "func RegisterMetrics() {\n\tregisterMetrics.Do(func() {\n\t\tlegacyregistry.MustRegister(OVSFlows)\n\t\tlegacyregistry.MustRegister(OVSOperationsResult)\n\t\tlegacyregistry.MustRegister(ARPCacheAvailableEntries)\n\t\tlegacyregistry.MustRegister(PodIPs)\n\t\tlegacyregistry.MustRegister(PodOperationsErrors)\n\t\tlegacyregistry.MustRegister(PodOperationsLatency)\n\t\tlegacyregistry.MustRegister(VnidNotFoundErrors)\n\t\tlegacyregistry.MustRegister(AssignedEgressIP)\n\t\tlegacyregistry.MustRegister(EgressIPCapacity)\n\t})\n}", "title": "" }, { "docid": "e7c2b3ade54f7c05ae15168544c19882", "score": "0.633078", "text": "func initMetrics(registry *prometheus.Registry, namespace string, detailed bool, nodeIndex int32) *metricsHolder {\n\n\tif registry == nil {\n\t\tvar ok bool\n\t\tregistry, ok = prometheus.DefaultRegisterer.(*prometheus.Registry)\n\t\tif !ok {\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tmh := &metricsHolder{\n\t\tdetailed: detailed,\n\t\tregistry: registry,\n\t}\n\n\t// We include a const label to indicate which node index in the cluster is originating the metric. In production\n\t// environments the node could typically be inferred from labels added externally as part of the deployment (e.g.\n\t// kubernetes prometheus operator jobLabel). Incorporating a label tied to the config provides an unambiguous,\n\t// possibly redundant target label in the metrics.\n\n\tmh.stateGauge = prometheus.NewGauge(prometheus.GaugeOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: \"raft\",\n\t\tName: \"role\",\n\t\tHelp: \"role indicates which state node is in at sampling time: follower, candidate or leader (1,2,3 respectively).\",\n\t\tConstLabels: map[string]string{\"nodeIndex\": fmt.Sprint(nodeIndex)},\n\t})\n\n\tmh.leader = prometheus.NewGauge(prometheus.GaugeOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: \"raft\",\n\t\tName: \"leader\",\n\t\tHelp: \"current leader from the perspective of this node (-1 indicate no leader).\",\n\t\tConstLabels: map[string]string{\"nodeIndex\": fmt.Sprint(nodeIndex)},\n\t})\n\n\tmh.term = prometheus.NewGauge(prometheus.GaugeOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: \"raft\",\n\t\tName: \"term\",\n\t\tHelp: \"current term from the perspective of this node.\",\n\t\tConstLabels: map[string]string{\"nodeIndex\": fmt.Sprint(nodeIndex)},\n\t})\n\n\tmh.committedIndex = prometheus.NewGauge(prometheus.GaugeOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: \"raft\",\n\t\tName: \"committedIndex\",\n\t\tHelp: \"current committedIndex from the perspective of this node.\",\n\t\tConstLabels: map[string]string{\"nodeIndex\": fmt.Sprint(nodeIndex)},\n\t})\n\n\tmh.lastApplied = prometheus.NewGauge(prometheus.GaugeOpts{\n\t\tNamespace: namespace,\n\t\tSubsystem: \"raft\",\n\t\tName: \"lastApplied\",\n\t\tHelp: \"current lastApplied from the perspective of this node.\",\n\t\tConstLabels: map[string]string{\"nodeIndex\": fmt.Sprint(nodeIndex)},\n\t})\n\n\tregistry.MustRegister(\n\t\tmh.stateGauge,\n\t\tmh.leader,\n\t\tmh.term,\n\t\tmh.committedIndex,\n\t\tmh.lastApplied)\n\n\treturn mh\n}", "title": "" }, { "docid": "3fd81adb70df8081837182271e3d8829", "score": "0.63178486", "text": "func newMetricsCollector(report *model.Report) *metricsCollector {\n\treturn &metricsCollector{\n\t\treport: report,\n\t}\n}", "title": "" }, { "docid": "fbbea6275be9a11a4a37ba7de9eea456", "score": "0.6284546", "text": "func NewMetrics(endpoint string, listen string) (*Metrics, error) {\n\t//available metrics\n\tscrapes := prometheus.NewCounterVec(\n\t\tprometheus.CounterOpts{\n\t\t\tName: \"http_get\",\n\t\t\tHelp: \"How many HTTP GET scraped, partitioned by url and response code.\",\n\t\t},\n\t\t[]string{\"code\",\"url\"},\n\t)\n\n\tservice := prometheus.NewCounterVec(\n\t\tprometheus.CounterOpts{\n\t\t\tName: \"http_requests_total\",\n\t\t\tHelp: \"How many HTTP requests received, partitioned response code.\",\n\t\t},\n\t\t[]string{\"code\"},\n\t)\n\n\tworkerWait := prometheus.NewHistogram(\n\t\tprometheus.HistogramOpts{\n\t\t\tName: \"wait_available_worker\",\n\t\t\tHelp: \"Time waiting for an available worker. In milliseconds.\",\n\t\t\tBuckets: []float64{10, 100, 1000, 2000, 5000, 10000},\n\t\t},\n\t)\n\n\t// Creates a prometheus registry and register the previous metrics \n\treg := prometheus.NewRegistry()\n\treg.MustRegister(scrapes)\n\treg.MustRegister(service)\n\treg.MustRegister(workerWait)\n\n\thttpListener, err := net.Listen(\"tcp\", listen)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Creates a handler for prometheus registry\n\thandler := promhttp.HandlerFor(reg, promhttp.HandlerOpts{})\n\n\tmux := http.NewServeMux()\n\tmux.Handle(endpoint, handler)\n\thttpSrv := &http.Server {\n\t\tHandler: mux,\n\t}\n\n\tgo httpSrv.Serve(httpListener)\n\n\tmetrics := new(Metrics)\n\n\tmetrics.GetService = func(c int) (float64, error) {\n\t\tvar m = &dto.Metric{}\n\t\terr := service.WithLabelValues(toString(c)).Write(m)\n\t\tif (err != nil) {\n\t\t\treturn 0, nil\n\t\t}\n\t\t\n\t\treturn m.Counter.GetValue(), nil\n\t}\n\n\tmetrics.IncService = func(c int) {\n\t\tservice.WithLabelValues(toString(c)).Inc()\n\t}\n\n\tmetrics.GetScrapes = func(url string, c int) (float64, error) {\n\t\tvar m = &dto.Metric{}\n\t\terr := scrapes.WithLabelValues(url, toString(c)).Write(m)\n\t\tif (err != nil) {\n\t\t\treturn 0, nil\n\t\t}\n\t\t\n\t\treturn m.Counter.GetValue(), nil\n\t}\n\n\tmetrics.IncScrapes = func(url string, c int) {\n\t\tscrapes.WithLabelValues(url, toString(c)).Inc()\n\t}\n\n\tmetrics.AddWorkerWait = func(w float64) {\n\t\tworkerWait.Observe(w)\n\t}\n\n\tmetrics.GetCountWorkerWaits = func() (uint64, error) {\n\t\tvar m = &dto.Metric{}\n\t\terr := workerWait.Write(m)\n\t\tif (err != nil) {\n\t\t\treturn 0, nil\n\t\t}\n\t\t\n\t\treturn m.Histogram.GetSampleCount(), nil\n\t}\n\n\tmetrics.GetSumWorkerWaits = func() (float64, error) {\n\t\tvar m = &dto.Metric{}\n\t\terr := workerWait.Write(m)\n\t\tif (err != nil) {\n\t\t\treturn 0, nil\n\t\t}\n\t\t\n\t\treturn m.Histogram.GetSampleSum(), nil\n\t}\n\n\tmetrics.Close = func() {\n\t\thttpSrv.Shutdown(context.Background())\n\t\thttpListener.Close()\n\t\tscrapes.Reset()\n\t\tservice.Reset()\n\t\treg.Unregister(scrapes)\n\t\treg.Unregister(service)\n\t\treg.Unregister(workerWait)\n\t}\n\n\treturn metrics, nil\n}", "title": "" }, { "docid": "5713ec8e0ad27f57bd3dd9735c2bba52", "score": "0.6187838", "text": "func NewRegistry() *Registry {\n\n\treturn &Registry{\n\t\tmetricsCounterVars: map[string]*go_kit_expvar.Counter{},\n\t\tmetricsGaugeVars: map[string]*go_kit_expvar.Gauge{},\n\t}\n}", "title": "" }, { "docid": "d952e4b4c0bd7b1067293f6ce0075375", "score": "0.61685884", "text": "func newFakeMetrics(fakeFields *fakeMetricsFields) *Metrics {\n\treturn &Metrics{\n\t\tNumberNodes: fakeFields.fakeNumberNodes,\n\t\tCommittedBlockNumber: fakeFields.fakeCommittedBlockNumber,\n\t\tLastConsensusTimestampPersisted: fakeFields.fakeLastConsensusTimestampPersisted,\n\t\tNumberMessagesDropped: fakeFields.fakeMessagesDropped,\n\t\tNumberChunksDropped: fakeFields.fakeChunksDropped,\n\t}\n}", "title": "" }, { "docid": "689ef4b935a15e7e54f1152d68b6e1bd", "score": "0.61460614", "text": "func NewMetrics(client ConnectClient) *Metrics {\n\treturn &Metrics{\n\t\tclient: client,\n\t\tGaugeVec: prom.NewGaugeVec(\n\t\t\tprom.GaugeOpts{\n\t\t\t\tNamespace: \"kafka\",\n\t\t\t\tSubsystem: \"connect\",\n\t\t\t\tName: \"tasks\",\n\t\t\t\tHelp: \"deployed tasks\",\n\t\t\t},\n\t\t\t[]string{\"connector\", \"state\", \"worker\"},\n\t\t),\n\t}\n}", "title": "" }, { "docid": "7d90ae7f87716bd684a747a6d6e9d0ea", "score": "0.6138481", "text": "func newMetricsConfigurations(c *MetricsV1alpha1Client) *metricsConfigurations {\n\treturn &metricsConfigurations{\n\t\tclient: c.RESTClient(),\n\t}\n}", "title": "" }, { "docid": "37f73d09d5f8cbf5d6f7d03bdf71bd84", "score": "0.61321205", "text": "func RegisterMetrics() {\n\tlegacyregistry.MustRegister(vsphereAPIMetric)\n\tlegacyregistry.MustRegister(vsphereAPIErrorMetric)\n\tlegacyregistry.MustRegister(vsphereOperationMetric)\n\tlegacyregistry.MustRegister(vsphereOperationErrorMetric)\n\tlegacyregistry.CustomMustRegister(vCenterMetric)\n}", "title": "" }, { "docid": "69b221cce1266395bd76a91d71d920dc", "score": "0.6106571", "text": "func NewMetrics(listenAddress string) (Metrics, error) {\n\treturn nil, nil\n}", "title": "" }, { "docid": "cc4c059e025813849c80615b4c5e19e7", "score": "0.6104268", "text": "func RegisterMetrics() {\n\tregisterMetrics.Do(func() {\n\t\tlegacyregistry.MustRegister(EndpointsAddedPerSync)\n\t\tlegacyregistry.MustRegister(EndpointsUpdatedPerSync)\n\t\tlegacyregistry.MustRegister(EndpointsRemovedPerSync)\n\t\tlegacyregistry.MustRegister(AddressesSkippedPerSync)\n\t\tlegacyregistry.MustRegister(EndpointsSyncDuration)\n\t\tlegacyregistry.MustRegister(EndpointsDesired)\n\t\tlegacyregistry.MustRegister(NumEndpointSlices)\n\t\tlegacyregistry.MustRegister(DesiredEndpointSlices)\n\t\tlegacyregistry.MustRegister(EndpointSliceChanges)\n\t})\n}", "title": "" }, { "docid": "b984dcfa8a854774967556b3f1dae69b", "score": "0.6082536", "text": "func NewRegistry(logger *log.Logger, opts ...RegistryOption) *Registry {\n\tpr := &Registry{\n\t\tloggr: logger,\n\t\tmux: http.NewServeMux(),\n\t}\n\n\tfor _, o := range opts {\n\t\to(pr)\n\t}\n\n\tregistry := prometheus.NewRegistry()\n\tpr.registerer = registry\n\n\tpr.mux.Handle(\"/metrics\", promhttp.HandlerFor(registry, promhttp.HandlerOpts{\n\t\tRegistry: pr.registerer,\n\t}))\n\treturn pr\n}", "title": "" }, { "docid": "801083b380f2890f5d1cb4d896889efc", "score": "0.6061394", "text": "func InitMetrics(registry *prometheus.Registry) {\n\tregistry.MustRegister(kvEventCounter)\n\tregistry.MustRegister(txnCollectCounter)\n\tregistry.MustRegister(pullerResolvedTsGauge)\n\tregistry.MustRegister(memBufferSizeGauge)\n\tregistry.MustRegister(outputChanSizeGauge)\n\tregistry.MustRegister(eventChanSizeGauge)\n\tregistry.MustRegister(entrySorterResolvedChanSizeGauge)\n\tregistry.MustRegister(entrySorterOutputChanSizeGauge)\n\tregistry.MustRegister(entrySorterUnsortedSizeGauge)\n\tregistry.MustRegister(entrySorterSortDuration)\n\tregistry.MustRegister(entrySorterMergeDuration)\n}", "title": "" }, { "docid": "014fdb68f4b4cc277ebdeb39834b4b4d", "score": "0.6049435", "text": "func RegisterMetrics() (err error) {\n\t// Register the Stackdriver exporter\n\tif metricsRegistered {\n\t\treturn nil\n\t}\n\terr = view.Register(TemperatorView, HumidityView, PressuareView, AirQualityView)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to register the views: %v\", err)\n\t}\n\tStackdriver, err = stackdriver.NewExporter(stackdriver.Options{})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to create Stackdriver exporter: %v\", err)\n\t}\n\tif err := Stackdriver.StartMetricsExporter(); err != nil {\n\t\treturn fmt.Errorf(\"Error starting metric exporter: %v\", err)\n\t}\n\n\t// Register it as a metrics exporter\n\tview.RegisterExporter(Stackdriver)\n\tview.SetReportingPeriod(60 * time.Second)\n\tmetricsRegistered = true\n\n\treturn nil\n}", "title": "" }, { "docid": "ec252ff00a14c57456c1a071d5e3adc9", "score": "0.60167456", "text": "func RegisterMetrics() {\n\tregisterMetrics.Do(func() {\n\t\tlegacyregistry.MustRegister(EndpointsAddedPerSync)\n\t\tlegacyregistry.MustRegister(EndpointsRemovedPerSync)\n\t\tlegacyregistry.MustRegister(EndpointsDesired)\n\t\tlegacyregistry.MustRegister(NumEndpointSlices)\n\t\tlegacyregistry.MustRegister(DesiredEndpointSlices)\n\t\tlegacyregistry.MustRegister(EndpointSliceChanges)\n\t\tlegacyregistry.MustRegister(EndpointSlicesChangedPerSync)\n\t\tlegacyregistry.MustRegister(EndpointSliceSyncs)\n\t})\n}", "title": "" }, { "docid": "58f9db74e9954699d30918531c2d29c8", "score": "0.59992975", "text": "func CreateMetrics(config *config.Config) Metrics {\n\tvar metrics PrometheusMetrics\n\tmetrics.HitsTotal = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tName: config.Metrics.ServiceName + \"_hits_total\",\n\t})\n\tif err := prometheus.Register(metrics.HitsTotal); err != nil {\n\t\tlogger.Log.Fatal(\"error in registering prometheus hits\", zap.Error(err))\n\t\treturn nil\n\t}\n\tmetrics.Hits = prometheus.NewCounterVec(\n\t\tprometheus.CounterOpts{\n\t\t\tName: config.Metrics.ServiceName + \"_hits\",\n\t\t},\n\t\t[]string{\"status\", \"method\", \"path\"},\n\t)\n\tif err := prometheus.Register(metrics.Hits); err != nil {\n\t\tlogger.Log.Fatal(\"error in registering prometheus hits\", zap.Error(err))\n\t\treturn nil\n\t}\n\tmetrics.Times = prometheus.NewHistogramVec(\n\t\tprometheus.HistogramOpts{\n\t\t\tName: config.Metrics.ServiceName + \"_times\",\n\t\t},\n\t\t[]string{\"status\", \"method\", \"path\"},\n\t)\n\tif err := prometheus.Register(metrics.Times); err != nil {\n\t\tlogger.Log.Fatal(\"error in registering prometheus\", zap.Error(err))\n\t\treturn nil\n\t}\n\tif err := prometheus.Register(prometheus.NewBuildInfoCollector()); err != nil {\n\t\tlogger.Log.Fatal(\"error in registering prometheus\", zap.Error(err))\n\t\treturn nil\n\t}\n\tgo func() {\n\t\trouter := echo.New()\n\t\trouter.GET(\"/metrics\", echo.WrapHandler(promhttp.Handler()))\n\t\tif err := router.Start(config.Metrics.URL); err != nil {\n\t\t\tlogger.Log.Fatal(\"unable to create metrics\", zap.Error(err))\n\t\t}\n\t}()\n\tlogger.Log.Info(\"Metrics available URL: \", zap.String(\"url\", config.Metrics.URL),\n\t\tzap.String(\"service name:\", config.Metrics.ServiceName))\n\treturn &metrics\n}", "title": "" }, { "docid": "085cc871f3b594f695bf42153fa9e35e", "score": "0.58671725", "text": "func New(\n\taddress string,\n\tstats *stats.Stats,\n\tparent Parent,\n) (*Metrics, error) {\n\tmux := http.NewServeMux()\n\tmux.Handle(\"/metrics\", promhttp.Handler())\n\n\tm := &Metrics{\n\t\tstats: stats,\n\t\tserver: &http.Server{\n\t\t\tAddr: address,\n\t\t\tHandler: mux,\n\t\t},\n\t}\n\n\tif err := prometheus.Register(m); err != nil {\n\t\treturn nil, err\n\t}\n\n\tparent.Log(logger.Info, \"[metrics] opened on \"+address)\n\n\tgo m.run()\n\treturn m, nil\n}", "title": "" }, { "docid": "41d5f99815cc38a3dfaf60bb85029fcc", "score": "0.58530843", "text": "func init() {\n\tfor _, metric := range metrics {\n\t\tlegacyregistry.MustRegister(metric)\n\t}\n}", "title": "" }, { "docid": "511a137f253b645bb568eb1868ef6b29", "score": "0.58405113", "text": "func InitializeMetrics() *Metrics {\n\treturn &Metrics{\n\t\tGetServiceRetryAttempts: promauto.NewCounter(prometheus.CounterOpts{\n\t\t\tName: \"get_service_retry_attempts\",\n\t\t}),\n\t\tGetServiceRetryExhausted: promauto.NewCounter(prometheus.CounterOpts{\n\t\t\tName: \"get_service_retry_exhausted\",\n\t\t}),\n\t\tPostServiceRetryAttempts: promauto.NewCounter(prometheus.CounterOpts{\n\t\t\tName: \"update_service_retry_attempts\",\n\t\t}),\n\t\tPostServiceRetryExhausted: promauto.NewCounter(prometheus.CounterOpts{\n\t\t\tName: \"update_service_retry_exhausted\",\n\t\t}),\n\t}\n}", "title": "" }, { "docid": "bc66cd002032bc39eef964123cff2a75", "score": "0.58356696", "text": "func (s *Service) RegisterMetrics() {\n\tpClient := prometheusmetrics.NewPrometheusProvider(\n\t\ts.Client.Config().MetricRegistry,\n\t\t\"kafka\",\n\t\t\"sarama\",\n\t\tprometheus.DefaultRegisterer,\n\t\t5*time.Second)\n\tgo pClient.UpdatePrometheusMetrics()\n}", "title": "" }, { "docid": "380a22899a8c484486d3f51fdc2d61f6", "score": "0.58111805", "text": "func NewFieldMetrics(resource Resource) (customresource.RegistryFactory, error) {\n\tcompiled, err := compile(resource)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tgvk := schema.GroupVersionKind(resource.GroupVersionKind)\n\treturn &fieldMetrics{\n\t\tNamespace: resource.GetNamespace(),\n\t\tSubsystem: resource.GetSubsystem(),\n\t\tGroupVersionKind: gvk,\n\t\tFamilies: compiled,\n\t\tResourceName: resource.GetResourceName(),\n\t}, nil\n}", "title": "" }, { "docid": "86f11423405801ddff5fe439c9eaca45", "score": "0.58017033", "text": "func NewMetricsHandler(registry prometheus.Registerer, namespace string) Handler {\n\treturn &metricsHandler{\n\t\thandler: NewHandler(),\n\t\tregistry: registry,\n\t\tnamespace: namespace,\n\t}\n}", "title": "" }, { "docid": "b07aa9f7660b9b1dd6f94bdcfc1a41a5", "score": "0.5796864", "text": "func RegisterMetrics() {\n\tprometheus.MustRegister(ErrorCounter)\n\tprometheus.MustRegister(ChangeCounter)\n\tprometheus.MustRegister(ReconcileCounter)\n}", "title": "" }, { "docid": "7f37b7849a4687223b1773849aae28d2", "score": "0.57964474", "text": "func RegisterMetrics(nodeName string) {\n\tregisterMetrics.Do(func() {\n\t\tprometheus.MustRegister(OffsetFromMaster)\n\t\tprometheus.MustRegister(MaxOffsetFromMaster)\n\t\tprometheus.MustRegister(OffsetFromSystem)\n\t\tprometheus.MustRegister(MaxOffsetFromSystem)\n\t\tprometheus.MustRegister(FrequencyAdjustment)\n\t\tprometheus.MustRegister(DelayFromMaster)\n\t\tprometheus.MustRegister(MasterSyncState)\n\t\tprometheus.MustRegister(Threshold)\n\t\tprometheus.MustRegister(InterfaceRole)\n\n\t\t// Including these stats kills performance when Prometheus polls with multiple targets\n\t\tprometheus.Unregister(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}))\n\t\tprometheus.Unregister(collectors.NewGoCollector())\n\n\t\tptpNodeName = nodeName\n\t})\n}", "title": "" }, { "docid": "fd71d81bda8871b5074f554eb24a73f2", "score": "0.578701", "text": "func RegisterMetrics() error {\n\tfor _, metric := range metricsList {\n\t\terr := prometheus.Register(metric)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "697e53273b2b0e64d3fc34b506d32af1", "score": "0.57861215", "text": "func initMetrics() *Metrics {\n\treturn &Metrics{\n\t\tstartTime: time.Now(),\n\t}\n}", "title": "" }, { "docid": "f46d784ebf9000cecbb5a4e7b87b95c0", "score": "0.5781238", "text": "func (r *registry) RegisterMetrics(quota adapter.MetricsBuilder) {\n\tr.insert(quota)\n}", "title": "" }, { "docid": "9062e06ef6550d6e3161b810aea9d483", "score": "0.5774022", "text": "func newMetricsServer() *server {\n\treturn &server{gauges: make(map[string]*gauge)}\n}", "title": "" }, { "docid": "3736b0bcb498b1c6eaa5a9aef7da4dde", "score": "0.57359403", "text": "func newMetricsService(name, namespace, appKey, appName string, port int32) *corev1.Service {\n\tlabels := map[string]string{\n\t\tappKey: appName,\n\t}\n\n\tif name == \"\" {\n\t\tname = appName\n\t}\n\n\tservicePorts := []corev1.ServicePort{\n\t\t{Port: port, Name: \"metrics\", Protocol: corev1.ProtocolTCP, TargetPort: intstr.IntOrString{\n\t\t\tType: intstr.Int,\n\t\t\tIntVal: port,\n\t\t}},\n\t}\n\n\tservice := &corev1.Service{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tLabels: labels,\n\t\t\tNamespace: namespace,\n\t\t\tName: fmt.Sprintf(\"%s-metrics\", name),\n\t\t},\n\t\tSpec: corev1.ServiceSpec{\n\t\t\tPorts: servicePorts,\n\t\t\tSelector: labels,\n\t\t},\n\t}\n\n\treturn service\n}", "title": "" }, { "docid": "5b9021c145aac0fbe6ebe972280579cd", "score": "0.5729226", "text": "func newMetricsExporter(config *metricsConfig, logger *zap.SugaredLogger) error {\n\t// If there is a Prometheus Exporter server running, stop it.\n\tresetCurPromSrv()\n\tce := getCurMetricsExporter()\n\tif ce != nil {\n\t\t// UnregisterExporter is idempotent and it can be called multiple times for the same exporter\n\t\t// without side effects.\n\t\tview.UnregisterExporter(ce)\n\t}\n\tvar err error\n\tvar e view.Exporter\n\tswitch config.backendDestination {\n\tcase Stackdriver:\n\t\te, err = newStackdriverExporter(config, logger)\n\tcase Prometheus:\n\t\te, err = newPrometheusExporter(config, logger)\n\tdefault:\n\t\terr = fmt.Errorf(\"Unsupported metrics backend %v\", config.backendDestination)\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\texistingConfig := getCurMetricsConfig()\n\tsetCurMetricsExporterAndConfig(e, config)\n\tlogger.Infof(\"Successfully updated the metrics exporter; old config: %v; new config %v\", existingConfig, config)\n\treturn nil\n}", "title": "" }, { "docid": "4e45206d21da523b84f1ccff3ca13f57", "score": "0.5700195", "text": "func (c *Client) RegisterMetrics() error {\n\tlog.Debugln(\"RegisterMetrics ENTER\")\n\n\tvar err error\n\n\tif c.config.VSphereType == string(config.VSphereRoleEsx) {\n\t\tlog.Infoln(\"Calling registerEsxMetrics\")\n\t\terr = c.registerEsxMetrics()\n\t\tif err != nil {\n\t\t\tlog.Debugln(\"registerEsxMetrics Failed:\", err)\n\t\t\tlog.Debugln(\"RegisterMetrics LEAVE\")\n\t\t\treturn err\n\t\t}\n\t} else if c.config.VSphereType == string(config.VSphereRoleDatastore) {\n\t\tlog.Infoln(\"Calling registerDatastoreMetrics\")\n\t\terr = c.registerDatastoreMetrics()\n\t\tif err != nil {\n\t\t\tlog.Debugln(\"registerDatastoreMetrics Failed:\", err)\n\t\t\tlog.Debugln(\"RegisterMetrics LEAVE\")\n\t\t\treturn err\n\t\t}\n\t} else if c.config.VSphereType == string(config.VSphereRoleVirtualMachine) {\n\t\tlog.Infoln(\"Calling registerVMMetrics\")\n\t\terr = c.registerVMMetrics()\n\t\tif err != nil {\n\t\t\tlog.Debugln(\"registerVMMetrics Failed:\", err)\n\t\t\tlog.Debugln(\"RegisterMetrics LEAVE\")\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\tlog.Debugln(\"RegisterMetrics Failed. Invalid discovery type.\")\n\t\tlog.Debugln(\"RegisterMetrics LEAVE\")\n\t\treturn ErrDiscoveryTypeNil\n\t}\n\n\tlog.Debugln(\"RegisterMetrics Succeeded\")\n\tlog.Debugln(\"RegisterMetrics LEAVE\")\n\treturn nil\n}", "title": "" }, { "docid": "d7c70a75d3a19437d38e30671cb4343f", "score": "0.56979936", "text": "func newServiceMetrics() *serviceMetrics {\n\treturn &serviceMetrics{\n\t\t// Runtime Component metrics\n\t\tcomponentLoaded: stats.Int64(\n\t\t\t\"runtime/component/loaded\",\n\t\t\t\"The number of successfully loaded components.\",\n\t\t\tstats.UnitDimensionless),\n\t\tcomponentInitCompleted: stats.Int64(\n\t\t\t\"runtime/component/init_total\",\n\t\t\t\"The number of initialized components.\",\n\t\t\tstats.UnitDimensionless),\n\t\tcomponentInitFailed: stats.Int64(\n\t\t\t\"runtime/component/init_fail_total\",\n\t\t\t\"The number of component initialization failures.\",\n\t\t\tstats.UnitDimensionless),\n\n\t\t// mTLS\n\t\tmtlsInitCompleted: stats.Int64(\n\t\t\t\"runtime/mtls/init_total\",\n\t\t\t\"The number of successful mTLS authenticator initialization.\",\n\t\t\tstats.UnitDimensionless),\n\t\tmtlsInitFailed: stats.Int64(\n\t\t\t\"runtime/mtls/init_fail_total\",\n\t\t\t\"The number of mTLS authenticator init failures.\",\n\t\t\tstats.UnitDimensionless),\n\t\tmtlsWorkloadCertRotated: stats.Int64(\n\t\t\t\"runtime/mtls/workload_cert_rotated_total\",\n\t\t\t\"The number of the successful workload certificate rotations.\",\n\t\t\tstats.UnitDimensionless),\n\t\tmtlsWorkloadCertRotatedFailed: stats.Int64(\n\t\t\t\"runtime/mtls/workload_cert_rotated_fail_total\",\n\t\t\t\"The number of the failed workload certificate rotations.\",\n\t\t\tstats.UnitDimensionless),\n\n\t\t// Actor\n\t\tactorStatusReportTotal: stats.Int64(\n\t\t\t\"runtime/actor/status_report_total\",\n\t\t\t\"The number of the successful status reports to placement service.\",\n\t\t\tstats.UnitDimensionless),\n\t\tactorStatusReportFailedTotal: stats.Int64(\n\t\t\t\"runtime/actor/status_report_fail_total\",\n\t\t\t\"The number of the failed status reports to placement service.\",\n\t\t\tstats.UnitDimensionless),\n\t\tactorTableOperationRecvTotal: stats.Int64(\n\t\t\t\"runtime/actor/table_operation_recv_total\",\n\t\t\t\"The number of the received actor placement table operations.\",\n\t\t\tstats.UnitDimensionless),\n\t\tactorRebalancedTotal: stats.Int64(\n\t\t\t\"runtime/actor/rebalanced_total\",\n\t\t\t\"The number of the actor rebalance requests.\",\n\t\t\tstats.UnitDimensionless),\n\t\tactorDeactivationTotal: stats.Int64(\n\t\t\t\"runtime/actor/deactivated_total\",\n\t\t\t\"The number of the successful actor deactivation.\",\n\t\t\tstats.UnitDimensionless),\n\t\tactorDeactivationFailedTotal: stats.Int64(\n\t\t\t\"runtime/actor/deactivated_failed_total\",\n\t\t\t\"The number of the failed actor deactivation.\",\n\t\t\tstats.UnitDimensionless),\n\t\tactorPendingCalls: stats.Int64(\n\t\t\t\"runtime/actor/pending_actor_calls\",\n\t\t\t\"The number of pending actor calls waiting to acquire the per-actor lock.\",\n\t\t\tstats.UnitDimensionless),\n\t\tactorTimers: stats.Int64(\n\t\t\t\"runtime/actor/timers\",\n\t\t\t\"The number of actor timer requests.\",\n\t\t\tstats.UnitDimensionless),\n\t\tactorReminders: stats.Int64(\n\t\t\t\"runtime/actor/reminders\",\n\t\t\t\"The number of actor reminder requests.\",\n\t\t\tstats.UnitDimensionless),\n\t\tactorReminderFiredTotal: stats.Int64(\n\t\t\t\"runtime/actor/reminders_fired_total\",\n\t\t\t\"The number of actor reminders fired requests.\",\n\t\t\tstats.UnitDimensionless),\n\t\tactorTimerFiredTotal: stats.Int64(\n\t\t\t\"runtime/actor/timers_fired_total\",\n\t\t\t\"The number of actor timers fired requests.\",\n\t\t\tstats.UnitDimensionless),\n\n\t\t// Access Control Lists for service invocation\n\t\tappPolicyActionAllowed: stats.Int64(\n\t\t\t\"runtime/acl/app_policy_action_allowed_total\",\n\t\t\t\"The number of requests allowed by the app specific action specified in the access control policy.\",\n\t\t\tstats.UnitDimensionless),\n\t\tglobalPolicyActionAllowed: stats.Int64(\n\t\t\t\"runtime/acl/global_policy_action_allowed_total\",\n\t\t\t\"The number of requests allowed by the global action specified in the access control policy.\",\n\t\t\tstats.UnitDimensionless),\n\t\tappPolicyActionBlocked: stats.Int64(\n\t\t\t\"runtime/acl/app_policy_action_blocked_total\",\n\t\t\t\"The number of requests blocked by the app specific action specified in the access control policy.\",\n\t\t\tstats.UnitDimensionless),\n\t\tglobalPolicyActionBlocked: stats.Int64(\n\t\t\t\"runtime/acl/global_policy_action_blocked_total\",\n\t\t\t\"The number of requests blocked by the global action specified in the access control policy.\",\n\t\t\tstats.UnitDimensionless),\n\n\t\t// Service Invocation\n\t\tserviceInvocationRequestSentTotal: stats.Int64(\n\t\t\t\"runtime/service_invocation/req_sent_total\",\n\t\t\t\"The number of requests sent via service invocation.\",\n\t\t\tstats.UnitDimensionless),\n\t\tserviceInvocationRequestReceivedTotal: stats.Int64(\n\t\t\t\"runtime/service_invocation/req_recv_total\",\n\t\t\t\"The number of requests received via service invocation.\",\n\t\t\tstats.UnitDimensionless),\n\t\tserviceInvocationResponseSentTotal: stats.Int64(\n\t\t\t\"runtime/service_invocation/res_sent_total\",\n\t\t\t\"The number of responses sent via service invocation.\",\n\t\t\tstats.UnitDimensionless),\n\t\tserviceInvocationResponseReceivedTotal: stats.Int64(\n\t\t\t\"runtime/service_invocation/res_recv_total\",\n\t\t\t\"The number of responses received via service invocation.\",\n\t\t\tstats.UnitDimensionless),\n\t\tserviceInvocationResponseReceivedLatency: stats.Float64(\n\t\t\t\"runtime/service_invocation/res_recv_latency_ms\",\n\t\t\t\"The latency of service invocation response.\",\n\t\t\tstats.UnitMilliseconds),\n\n\t\t// TODO: use the correct context for each request\n\t\tctx: context.Background(),\n\t\tenabled: false,\n\t}\n}", "title": "" }, { "docid": "9eac15bcb4f404ce03bd3cc32a18197e", "score": "0.56779003", "text": "func NewRegistry() Registry {\n\treturn &registryImpl{\n\t\tbuffered: make(map[string]query),\n\t\tcompleted: make(map[string]query),\n\t\tunblocked: make(map[string]query),\n\t\tfailed: make(map[string]query),\n\t}\n}", "title": "" }, { "docid": "c0de5c227cc2d081cc55e5122f3b4361", "score": "0.56770957", "text": "func newMetricsHandler(config *kubeschedulerconfig.KubeSchedulerConfiguration, informers informers.SharedInformerFactory, isLeader func() bool) http.Handler {\n\tpathRecorderMux := mux.NewPathRecorderMux(\"kube-scheduler\")\n\tinstallMetricHandler(pathRecorderMux, informers, isLeader)\n\tif config.EnableProfiling {\n\t\troutes.Profiling{}.Install(pathRecorderMux)\n\t\tif config.EnableContentionProfiling {\n\t\t\tgoruntime.SetBlockProfileRate(1)\n\t\t}\n\t\troutes.DebugFlags{}.Install(pathRecorderMux, \"v\", routes.StringFlagPutHandler(logs.GlogSetter))\n\t}\n\treturn pathRecorderMux\n}", "title": "" }, { "docid": "44691778bf0882a3b213514180fa2873", "score": "0.56565386", "text": "func Register(registerFn func(...compbasemetrics.Registerable)) *Metrics {\n\tregisterFn(metrics...)\n\treturn &Metrics{\n\t\tHealthyTargetsTotal: HealthyTargetsTotal,\n\t\tCurrentHealthyTargets: CurrentHealthyTargets,\n\t\tUnHealthyTargetsTotal: UnHealthyTargetsTotal,\n\t\tReadyzProtocolRequestTotal: ReadyzProtocolRequestTotal,\n\t}\n}", "title": "" }, { "docid": "f03ed53b5ada514d78fa38bdffb4aafd", "score": "0.56172276", "text": "func NewMetric(name string, labelKeys []string, labelValues []string, value float64) (*Metric, error) {\n\tif len(labelKeys) != len(labelValues) {\n\t\treturn nil, errors.New(\"expected labelKeys to be of same length as labelValues\")\n\t}\n\n\tm := strings.Builder{}\n\n\tm.WriteString(name)\n\n\tlabelsToString(&m, labelKeys, labelValues)\n\n\tm.WriteByte(' ')\n\n\twriteFloat(&m, value)\n\n\tm.WriteByte('\\n')\n\n\tmetric := Metric(m.String())\n\n\treturn &metric, nil\n}", "title": "" }, { "docid": "89a0b9408ff0bddb9970438445787abc", "score": "0.5615585", "text": "func newDialMetrics() *DialMetrics {\n\tstarts := metrics.NewCounterVec(\n\t\t&metrics.CounterOpts{\n\t\t\tNamespace: namespace,\n\t\t\tSubsystem: subsystem,\n\t\t\tName: \"dial_start_total\",\n\t\t\tHelp: \"Dial starts, labeled by the protocol (http-connect or grpc) and transport (tcp or uds).\",\n\t\t\tStabilityLevel: metrics.ALPHA,\n\t\t},\n\t\t[]string{\"protocol\", \"transport\"},\n\t)\n\n\tlatencies := metrics.NewHistogramVec(\n\t\t&metrics.HistogramOpts{\n\t\t\tNamespace: namespace,\n\t\t\tSubsystem: subsystem,\n\t\t\tName: \"dial_duration_seconds\",\n\t\t\tHelp: \"Dial latency histogram in seconds, labeled by the protocol (http-connect or grpc), transport (tcp or uds)\",\n\t\t\tBuckets: latencyBuckets,\n\t\t\tStabilityLevel: metrics.ALPHA,\n\t\t},\n\t\t[]string{\"protocol\", \"transport\"},\n\t)\n\n\tfailures := metrics.NewCounterVec(\n\t\t&metrics.CounterOpts{\n\t\t\tNamespace: namespace,\n\t\t\tSubsystem: subsystem,\n\t\t\tName: \"dial_failure_count\",\n\t\t\tHelp: \"Dial failure count, labeled by the protocol (http-connect or grpc), transport (tcp or uds), and stage (connect or proxy). The stage indicates at which stage the dial failed\",\n\t\t\tStabilityLevel: metrics.ALPHA,\n\t\t},\n\t\t[]string{\"protocol\", \"transport\", \"stage\"},\n\t)\n\n\tlegacyregistry.MustRegister(starts)\n\tlegacyregistry.MustRegister(latencies)\n\tlegacyregistry.MustRegister(failures)\n\treturn &DialMetrics{starts: starts, latencies: latencies, failures: failures, clock: clock.RealClock{}}\n}", "title": "" }, { "docid": "f8621ff30e51ad0240b14d443dd0b75a", "score": "0.5606399", "text": "func RegisterMetrics(serviceName string, version *utils.Version, edition utils.ProductEdition) {\n\tregisterLock.Do(func() {\n\t\tprometheus.MustRegister(connectionCounter)\n\t\tprometheus.MustRegister(connectionProcessingTimeHistogram)\n\t\tbase.RegisterAcraStructProcessingMetrics()\n\t\tbase.RegisterEncryptionDecryptionProcessingMetrics()\n\t\tbase.RegisterTokenizationProcessingMetrics()\n\t\tbase.RegisterDbProcessingMetrics()\n\t\tcmd.RegisterVersionMetrics(serviceName, version)\n\t\tcmd.RegisterBuildInfoMetrics(serviceName, edition)\n\t})\n}", "title": "" }, { "docid": "367a566b55aa399ffadb1fa5f0a44f46", "score": "0.56043595", "text": "func New(dbHost string, dbPort int, dbUser string, dbPassword string, statuses map[string]*TesterStatus) Metrics {\n\treturn &defaultMetrics{\n\t\tdbHost: dbHost,\n\t\tdbPort: dbPort, // 3306 is default MySQL port\n\t\tdbUser: dbUser,\n\t\tdbPassword: dbPassword,\n\t\tcurrentStatus: statuses,\n\t}\n}", "title": "" }, { "docid": "d70a359dc5d3f56f3bb489fd7558709a", "score": "0.559735", "text": "func (p *NodeMetrics) CreateMetrics(ctx context.Context, metrics DaoMetricTypes.NodeMetricMap) error {\n\treturn errors.New(\"create metrics to prometheus is not supported\")\n}", "title": "" }, { "docid": "ef4f8fc607d22cbfe63e249643dd732c", "score": "0.55857104", "text": "func NewMetric() *Metric {\n\treturn &Metric{time.Now(), make([]KeyVal, 0)}\n}", "title": "" }, { "docid": "9039ae006870a32ec7d569f1a1882394", "score": "0.5563958", "text": "func NewMetricsCollector(ctx context.Context, clients client.SliceOfClients, requiredMetrics []string, databases []int) *MetricsCollector {\n\treturn &MetricsCollector{\n\t\tctx: ctx,\n\t\tclients: clients,\n\t\tdatabases: databases,\n\t\trequiredMetrics: requiredMetrics,\n\t\tclientsConnectedTotal: clientsConnectedTotal,\n\t\tkeysPerDatabaseCount: keysPerDatabaseCount,\n\t\texpiringKeysCount: expiringKeysCount,\n\t\taverageKeyTTLSeconds: averageKeyTTLSeconds,\n\t}\n}", "title": "" }, { "docid": "f36e1b2d172e10cec7a60ad19691adc1", "score": "0.55619305", "text": "func newWALMetrics(labels prometheus.Labels) *walMetrics {\n\tvar names []string\n\tfor k := range labels {\n\t\tnames = append(names, k)\n\t}\n\tsort.Strings(names)\n\n\twriteNames := append(append([]string(nil), names...), \"status\")\n\tsort.Strings(writeNames)\n\n\treturn &walMetrics{\n\t\tOldSegmentBytes: prometheus.NewGaugeVec(prometheus.GaugeOpts{\n\t\t\tNamespace: namespace,\n\t\t\tSubsystem: walSubsystem,\n\t\t\tName: \"old_segment_bytes\",\n\t\t\tHelp: \"Number of bytes old WAL segments using on disk.\",\n\t\t}, names),\n\t\tCurrentSegmentBytes: prometheus.NewGaugeVec(prometheus.GaugeOpts{\n\t\t\tNamespace: namespace,\n\t\t\tSubsystem: walSubsystem,\n\t\t\tName: \"current_segment_bytes\",\n\t\t\tHelp: \"Number of bytes TSM files using on disk.\",\n\t\t}, names),\n\t\tSegments: prometheus.NewGaugeVec(prometheus.GaugeOpts{\n\t\t\tNamespace: namespace,\n\t\t\tSubsystem: walSubsystem,\n\t\t\tName: \"segments_total\",\n\t\t\tHelp: \"Number of WAL segment files on disk.\",\n\t\t}, names),\n\t\tWrites: prometheus.NewCounterVec(prometheus.CounterOpts{\n\t\t\tNamespace: namespace,\n\t\t\tSubsystem: walSubsystem,\n\t\t\tName: \"writes_total\",\n\t\t\tHelp: \"Number of writes to the WAL.\",\n\t\t}, writeNames),\n\t}\n}", "title": "" }, { "docid": "23e1467de3c439131c025587d3bff3f9", "score": "0.5555185", "text": "func NewMetric(name string, labelKeys []string, labelValues []string, value float64) (*Metric, error) {\n\tif len(labelKeys) != len(labelValues) {\n\t\treturn nil, errors.New(\"expected labelKeys to be of same length as labelValues\")\n\t}\n\n\tm := \"\"\n\n\tm = m + name\n\n\tm = m + labelsToString(labelKeys, labelValues)\n\n\tm = m + fmt.Sprintf(\" %v\", value)\n\n\tm = m + \"\\n\"\n\n\tmetric := Metric(m)\n\n\treturn &metric, nil\n}", "title": "" }, { "docid": "7ba833daab0c5493e373bdaa91397664", "score": "0.5549933", "text": "func initMetrics(aInRegistry *prometheus.Registry) error {\n\tcollectors := initCollectors()\n\tfor _, collector := range collectors {\n\t\terr := registerCollector(collector, aInRegistry)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "1c64bd47af8c5e79753bf3201025b385", "score": "0.55449015", "text": "func (s *ListAvailableResourceDimensionsInput) SetMetrics(v []*string) *ListAvailableResourceDimensionsInput {\n\ts.Metrics = v\n\treturn s\n}", "title": "" }, { "docid": "cf66a735d13a3f97f1b00532b3821c33", "score": "0.5543371", "text": "func (mc *MetricController) New() (r types.Resource) {\n\treturn new(types.Metric)\n}", "title": "" }, { "docid": "3fd66312f22d358ee0f3ee27eab2bdd7", "score": "0.5533743", "text": "func (in *Metrics) DeepCopy() *Metrics {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(Metrics)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "3fd66312f22d358ee0f3ee27eab2bdd7", "score": "0.5533743", "text": "func (in *Metrics) DeepCopy() *Metrics {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(Metrics)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "title": "" }, { "docid": "04e6bb4e20ca38f8929a63ab59206678", "score": "0.5505557", "text": "func NewMetricsServer() *MetricsServer {\n\tmux := http.NewServeMux()\n\tmux.Handle(\"/metrics\", promhttp.Handler())\n\tms := MetricsServer{}\n\tms.httpServer = &http.Server{\n\t\tAddr: \":8080\",\n\t\tHandler: mux,\n\t}\n\treturn &ms\n}", "title": "" }, { "docid": "345114d3ed7f6dd3fd78c3eda571ce14", "score": "0.5496574", "text": "func WithMetrics(method string,\r\n\tcalls *prometheus.CounterVec,\r\n\terrors *prometheus.CounterVec,\r\n\tsaturation *prometheus.GaugeVec,\r\n\tduration *prometheus.HistogramVec,\r\n\tnext Handler) Handler {\r\n\tfn := func(ctx context.Context, w Writer, r Reader) error {\r\n\t\t// Handle metrics\r\n\t\tstart := time.Now()\r\n\t\tcalls.WithLabelValues(method).Inc()\r\n\t\tsaturation.WithLabelValues(method).Inc()\r\n\t\terr := next(ctx, w, r)\r\n\t\tif err != nil {\r\n\t\t\terrors.WithLabelValues(method).Inc()\r\n\t\t}\r\n\t\tsaturation.WithLabelValues(method).Dec()\r\n\t\tduration.WithLabelValues(method).Observe(float64(time.Since(start).Nanoseconds()) / 1000000)\r\n\t\treturn err\r\n\t}\r\n\treturn fn\r\n}", "title": "" }, { "docid": "49425c3f396c4ba7a6d75befd2041d59", "score": "0.549108", "text": "func (s *Statsd) RegisterMetrics(handler http.Handler) http.Handler {\n\treturn http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {\n\n\t\tpath := req.URL.Path\n\t\thandlerName := prepareHandlerName(path)\n\n\t\trequestTimer := s.client.NewTiming()\n\n\t\tlrw := &LoggedResponseWriter{responseWriter: resp}\n\n\t\thandler.ServeHTTP(lrw, req)\n\n\t\trequestTimer.Send(fmt.Sprintf(\n\t\t\t\"request.%v.%v.%v.request_time\",\n\t\t\treq.Method,\n\t\t\tlrw.Status(),\n\t\t\thandlerName,\n\t\t))\n\n\t\tif s.withLog {\n\t\t\t//Example: 200 POST /rec/ (127.0.0.1) 1.460s\n\t\t\ts.logger.Infof(\"%v %v %v (%v) %.3fs\",\n\t\t\t\tlrw.Status(), req.Method, path, req.RemoteAddr, requestTimer.Duration().Seconds())\n\t\t}\n\t})\n}", "title": "" }, { "docid": "32c36b8776e3df89c7518aab79c6269d", "score": "0.54821885", "text": "func NewUrmMetrics(reg prometheus.Registerer, s influxdb.UserResourceMappingService, opts ...metric.ClientOptFn) *UrmMetrics {\n\to := metric.ApplyMetricOpts(opts...)\n\treturn &UrmMetrics{\n\t\trec: metric.New(reg, o.ApplySuffix(\"urm\")),\n\t\turmService: s,\n\t}\n}", "title": "" }, { "docid": "d57161ad3c4a6ab17292620ce48cb5ed", "score": "0.54772097", "text": "func (m *Metrics) register(registry *prometheus.Registry) {\n\tregistry.MustRegister(\n\t\tm.buildInfoGauge,\n\t\tm.proxyTotalGauge,\n\t\tm.proxyRootTotalGauge,\n\t\tm.proxyInvalidGauge,\n\t\tm.proxyValidGauge,\n\t\tm.proxyOrphanedGauge,\n\t\tm.dagRebuildGauge,\n\t\tm.dagRebuildTotal,\n\t\tm.dagCacheObjectGauge,\n\t\tm.DAGRebuildSeconds,\n\t\tm.CacheHandlerOnUpdateSummary,\n\t\tm.EventHandlerOperations,\n\t\tm.statusUpdateTotal,\n\t\tm.statusUpdateSuccess,\n\t\tm.statusUpdateFailed,\n\t\tm.statusUpdateConflict,\n\t\tm.statusUpdateNoop,\n\t\tm.statusUpdateDurationSeconds,\n\t)\n}", "title": "" }, { "docid": "47819dcd8cc64ddefcfaabde483a5f9d", "score": "0.54742956", "text": "func (s *GetReservationCoverageInput) SetMetrics(v []*string) *GetReservationCoverageInput {\n\ts.Metrics = v\n\treturn s\n}", "title": "" }, { "docid": "a084792cfaa6298880d89147dbb30136", "score": "0.5450277", "text": "func New(registryURL string) *Registry {\n\tregistry := &Registry{\n\t\tURL: registryURL,\n\t}\n\n\treturn registry\n}", "title": "" }, { "docid": "1f20e7a90b4fb218cb4de76bbb17d9ea", "score": "0.544505", "text": "func newGRPCMetrics() grpcMetrics {\n\treturn grpcMetrics{}\n}", "title": "" }, { "docid": "d36916a0e7259d5e579ef148e9069a16", "score": "0.54367423", "text": "func NewAPIMetrics(apiDuration HistogramVec, connectedClients GaugeVec) APIMetrics {\n\treturn APIMetrics{\n\t\tapiDuration: apiDuration,\n\t\tconnectedClients: connectedClients,\n\t}\n}", "title": "" }, { "docid": "5b7ebea35aa4ce09cbc170b402088661", "score": "0.54339737", "text": "func NewMetric(m *Metric, subsystem string) prometheus.Collector {\n\tvar metric prometheus.Collector\n\tswitch m.Type {\n\tcase \"counter_vec\":\n\t\tmetric = prometheus.NewCounterVec(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tSubsystem: subsystem,\n\t\t\t\tName: m.Name,\n\t\t\t\tHelp: m.Description,\n\t\t\t},\n\t\t\tm.Args,\n\t\t)\n\tcase \"counter\":\n\t\tmetric = prometheus.NewCounter(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tSubsystem: subsystem,\n\t\t\t\tName: m.Name,\n\t\t\t\tHelp: m.Description,\n\t\t\t},\n\t\t)\n\tcase \"gauge_vec\":\n\t\tmetric = prometheus.NewGaugeVec(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tSubsystem: subsystem,\n\t\t\t\tName: m.Name,\n\t\t\t\tHelp: m.Description,\n\t\t\t},\n\t\t\tm.Args,\n\t\t)\n\tcase \"gauge\":\n\t\tmetric = prometheus.NewGauge(\n\t\t\tprometheus.GaugeOpts{\n\t\t\t\tSubsystem: subsystem,\n\t\t\t\tName: m.Name,\n\t\t\t\tHelp: m.Description,\n\t\t\t},\n\t\t)\n\tcase \"histogram_vec\":\n\t\tmetric = prometheus.NewHistogramVec(\n\t\t\tprometheus.HistogramOpts{\n\t\t\t\tSubsystem: subsystem,\n\t\t\t\tName: m.Name,\n\t\t\t\tHelp: m.Description,\n\t\t\t},\n\t\t\tm.Args,\n\t\t)\n\tcase \"histogram\":\n\t\tmetric = prometheus.NewHistogram(\n\t\t\tprometheus.HistogramOpts{\n\t\t\t\tSubsystem: subsystem,\n\t\t\t\tName: m.Name,\n\t\t\t\tHelp: m.Description,\n\t\t\t},\n\t\t)\n\tcase \"summary_vec\":\n\t\tmetric = prometheus.NewSummaryVec(\n\t\t\tprometheus.SummaryOpts{\n\t\t\t\tSubsystem: subsystem,\n\t\t\t\tName: m.Name,\n\t\t\t\tHelp: m.Description,\n\t\t\t},\n\t\t\tm.Args,\n\t\t)\n\tcase \"summary\":\n\t\tmetric = prometheus.NewSummary(\n\t\t\tprometheus.SummaryOpts{\n\t\t\t\tSubsystem: subsystem,\n\t\t\t\tName: m.Name,\n\t\t\t\tHelp: m.Description,\n\t\t\t},\n\t\t)\n\t}\n\treturn metric\n}", "title": "" }, { "docid": "b3d5eb86e3c79b72287434ba4ed61d79", "score": "0.5432772", "text": "func newWorkerMetrics(observationContext *observation.Context, workerName string) (workerutil.WorkerMetrics, dbworker.ResetterMetrics) {\n\tworkerMetrics := workerutil.NewMetrics(observationContext, workerName+\"_processor\")\n\tresetterMetrics := dbworker.NewMetrics(observationContext, workerName)\n\treturn workerMetrics, *resetterMetrics\n}", "title": "" }, { "docid": "ca87768712d87c66b5a530656b79af96", "score": "0.54321647", "text": "func (r *Registry) NewGauge(\n\tname string,\n\tlabels ...Label,\n) (*Gauge, error) {\n\tr.metricsMutex.Lock()\n\tdefer r.metricsMutex.Unlock()\n\n\tif _, exists := r.metrics[name]; exists {\n\t\treturn nil, fmt.Errorf(\"metric [%v] already exists\", name)\n\t}\n\n\tgauge := &Gauge{\n\t\tname: name,\n\t\tlabels: processLabels(labels),\n\t}\n\n\tr.metrics[name] = gauge\n\treturn gauge, nil\n}", "title": "" }, { "docid": "e97ed4e01cd76eff0d9435b4ab575fad", "score": "0.5426601", "text": "func doRegisterAPIMetrics() {\n\tregisterAPIMetrics.Do(func() {\n\t\tlegacyregistry.MustRegister(\n\t\t\tAPIRequestMetrics.Duration,\n\t\t\tAPIRequestMetrics.Total,\n\t\t\tAPIRequestMetrics.Errors,\n\t\t)\n\t})\n}", "title": "" }, { "docid": "965091357d46a4ea92d23c649030f020", "score": "0.5423294", "text": "func NewRegistry(opts *RegistryOpts) *Registry {\n\tif opts == nil {\n\t\topts = DefaultRegistryOpts\n\t}\n\n\tif opts.CapDescChan < 1 {\n\t\topts.CapDescChan = defaultCapDescChan\n\t}\n\tif opts.CapMetricChan < 1 {\n\t\topts.CapMetricChan = defaultCapMetricChan\n\t}\n\n\treturn &Registry{\n\t\topts: opts,\n\t\treporter: nil,\n\t\tmtx: sync.RWMutex{},\n\t\tcollectors: []Collector{},\n\t\tmetricChs: make(chan Metric, opts.CapMetricChan),\n\t\tmetadata: map[string]*MetaData{},\n\t\tstop: make(chan struct{}),\n\t\texit: make(chan struct{}),\n\t}\n}", "title": "" }, { "docid": "7133d862c00f83ca3152a6072c09bbf9", "score": "0.5421146", "text": "func InitMetrics(mf monitoring.MetricFactory) {\n\tmetricsOnce.Do(func() {\n\t\tMetrics.AcquiredTokens = mf.NewCounter(\"quota_acquired_tokens\", \"Number of acquired quota tokens\", \"spec\", \"success\")\n\t\tMetrics.ReturnedTokens = mf.NewCounter(\"quota_returned_tokens\", \"Number of quota tokens returned due to overcharging (bad requests, duplicates, etc)\", \"spec\", \"success\")\n\t\tMetrics.ReplenishedTokens = mf.NewCounter(\"quota_replenished_tokens\", \"Number of quota tokens replenished due to sequencer progress\", \"spec\", \"success\")\n\t})\n}", "title": "" }, { "docid": "da102f991eb0f8c4a1ae1a0dc3a5a2d6", "score": "0.5417674", "text": "func addMetrics(ctx context.Context, cfg *rest.Config, namespace string) {\n\tif err := serveCRMetrics(cfg); err != nil {\n\t\tif errors.Is(err, k8sutil.ErrRunLocal) {\n\t\t\tlog.Info(\"Skipping CR metrics server creation; not running in a cluster.\")\n\t\t\treturn\n\t\t}\n\t\tlog.Info(\"Could not generate and serve custom resource metrics\", \"error\", err.Error())\n\t}\n\n\t// Add to the below struct any other metrics ports you want to expose.\n\tservicePorts := []v1.ServicePort{\n\t\t{Port: metricsPort, Name: metrics.OperatorPortName, Protocol: v1.ProtocolTCP, TargetPort: intstr.IntOrString{Type: intstr.Int, IntVal: metricsPort}},\n\t\t{Port: operatorMetricsPort, Name: metrics.CRPortName, Protocol: v1.ProtocolTCP, TargetPort: intstr.IntOrString{Type: intstr.Int, IntVal: operatorMetricsPort}},\n\t}\n\n\t// Create Service object to expose the metrics port(s).\n\tservice, err := metrics.CreateMetricsService(ctx, cfg, servicePorts)\n\tif err != nil {\n\t\tlog.Info(\"Could not create metrics Service\", \"error\", err.Error())\n\t}\n\n\t// CreateServiceMonitors will automatically create the prometheus-operator ServiceMonitor resources\n\t// necessary to configure Prometheus to scrape metrics from this operator.\n\tservices := []*v1.Service{service}\n\t_, err = metrics.CreateServiceMonitors(cfg, namespace, services)\n\tif err != nil {\n\t\tlog.Info(\"Could not create ServiceMonitor object\", \"error\", err.Error())\n\t\t// If this operator is deployed to a cluster without the prometheus-operator running, it will return\n\t\t// ErrServiceMonitorNotPresent, which can be used to safely skip ServiceMonitor creation.\n\t\tif err == metrics.ErrServiceMonitorNotPresent {\n\t\t\tlog.Info(\"Install prometheus-operator in your cluster to create ServiceMonitor objects\", \"error\", err.Error())\n\t\t}\n\t}\n}", "title": "" }, { "docid": "cf2b121682e69d2afdff2739a48822b4", "score": "0.54089123", "text": "func NewMetricsPlugin() *MetricsPlugin {\n\treturn &MetricsPlugin{Registry: metrics.NewRegistry(), seqs: make(map[uint64]int64, 100)}\n}", "title": "" } ]
d381888b05ea1cac548e5fbd0db33014
MarshalJSON implements the json.Marshaller interface for type RecordSetListResult.
[ { "docid": "d8fe6a987050b8fd2830ca035ef750b9", "score": "0.81494033", "text": "func (r RecordSetListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", r.NextLink)\n\tpopulate(objectMap, \"value\", r.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" } ]
[ { "docid": "8ba5168c151182f8fa2bf1425e306241", "score": "0.8025164", "text": "func (rslr RecordSetListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\tif rslr.Value != nil {\n\t\tobjectMap[\"value\"] = rslr.Value\n\t}\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "63f5b42abcfc1f9c7eaa4aa5e2224812", "score": "0.7262291", "text": "func (dlr DatabaseListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "b0f2f5f44c9439551a2fdfebdce2d31d", "score": "0.72366965", "text": "func (mdlr ManagedDatabaseListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "09740b0aa18ff78b92e0ac590f75a9ad", "score": "0.72336715", "text": "func (p PolicySetDefinitionListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\tpopulate(objectMap, \"nextLink\", p.NextLink)\n\tpopulate(objectMap, \"value\", p.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "0cc58c229a1835d83aa27fbd06acc9ca", "score": "0.7209573", "text": "func (r RestorableSQLResourcesListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", r.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "80eac70711b7e14b60b79f188a785ff6", "score": "0.7199284", "text": "func (rmdlr RecoverableManagedDatabaseListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "0387808c64d9195286c63a2946f9ee24", "score": "0.71944106", "text": "func (r RestorableSQLDatabasesListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", r.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "3ecef5b6d838f6487ad1148836c30b8b", "score": "0.7170713", "text": "func (milr ManagedInstanceListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "789b5a095c87e89957ebfa75177eeb71", "score": "0.70697325", "text": "func (r RestorableSQLContainersListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", r.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "7d01923b994c59e7eab5b859897159e3", "score": "0.7066058", "text": "func (r RecoverableSQLPoolListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", r.NextLink)\n\tpopulate(objectMap, \"value\", r.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "2c7fe4a2eb21d527d171ace1ff163915", "score": "0.7065478", "text": "func (dslr DatabaseSchemaListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "b6c7e58e8b1425250ebb68e2edd23366", "score": "0.7048768", "text": "func (s SQLPoolSchemaListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", s.NextLink)\n\tpopulate(objectMap, \"value\", s.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "3e074aab6608b5a77920fa41a8c5ed37", "score": "0.7038302", "text": "func (r RestorableMongodbDatabasesListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", r.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "a2a3de300d95eb507fef4e054e4ca598", "score": "0.70274794", "text": "func (r RestorableGremlinDatabasesListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", r.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "7c4e09ce97b345d699ef61d97f39e5d2", "score": "0.7021599", "text": "func (k KustoPoolListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", k.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "8cece45bce0b4f836799f26cb80b56a7", "score": "0.7012251", "text": "func (vasrlr VulnerabilityAssessmentScanRecordListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "410d06870bfe9ee195d4eb9537ce4d2d", "score": "0.7010165", "text": "func (rs RecordSet) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\tif rs.Etag != nil {\n\t\tobjectMap[\"etag\"] = rs.Etag\n\t}\n\tif rs.RecordSetProperties != nil {\n\t\tobjectMap[\"properties\"] = rs.RecordSetProperties\n\t}\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "e556caa6050fde42c166870922393256", "score": "0.699707", "text": "func (r RestorableMongodbCollectionsListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", r.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "f895d1ad3c667babbe9b481802036474", "score": "0.6984796", "text": "func (a AvailabilitySetListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", a.NextLink)\n\tpopulate(objectMap, \"value\", a.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "77df4c19ed2cf9744ddf091c1aecc213", "score": "0.6945786", "text": "func (s SQLPoolTableListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", s.NextLink)\n\tpopulate(objectMap, \"value\", s.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "bf9caae4af79074c7594a718f6c7b747", "score": "0.69351745", "text": "func (elr ExportListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "1b0d0a7c897be80d36fbe2a440e88b69", "score": "0.69298816", "text": "func (s SQLContainerListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", s.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "6a66474099fa26fadede2acc239e4713", "score": "0.6924247", "text": "func (dtlr DatabaseTableListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "372dbf64b6d0d8a59cbee4ef18a72832", "score": "0.6911148", "text": "func (s SQLDatabaseListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", s.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "a167127e698ca16e52dd6961f2426854", "score": "0.68897796", "text": "func (r RestorableTablesListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", r.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "656ff2c6014c834d6fe383acfaf63e72", "score": "0.6887716", "text": "func (m MongoDBCollectionListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", m.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "d25793db27deafca948ef23bda09135e", "score": "0.6885096", "text": "func (r RestorableMongodbResourcesListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", r.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "0eedcdb2150bdc5be3cbb57c4ab10139", "score": "0.6883309", "text": "func (slr ServerListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "1288a45d84e9168b36131424fca44cae", "score": "0.6869527", "text": "func (stglr ServerTrustGroupListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "6d20188e18783fa912efcfac22a24eeb", "score": "0.6860629", "text": "func (v VulnerabilityAssessmentScanRecordListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", v.NextLink)\n\tpopulate(objectMap, \"value\", v.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "615dcf39b2f887e63bfb9c01cbbca565", "score": "0.6849286", "text": "func (dulr DatabaseUsageListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "38c8be7871f744f64eff0c5c5e72de0f", "score": "0.684299", "text": "func (mbstrplr ManagedBackupShortTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "badbecf6e88bdb6b6b7a8290ed5029b5", "score": "0.68392986", "text": "func (rplr RestorePointListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "3033f169b535f5acfb6d0cd504e0d255", "score": "0.6839002", "text": "func (s SQLPoolInfoListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", s.NextLink)\n\tpopulate(objectMap, \"value\", s.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "73b554f3f2211c7ca6bab0a19ecb7514", "score": "0.68346345", "text": "func (jtglr JobTargetGroupListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "51e2412d02dbe1a2aac3433e565971f0", "score": "0.68340343", "text": "func (rdmdlr RestorableDroppedManagedDatabaseListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "8e165327768b6740c5a38d1ca4891e8e", "score": "0.68276286", "text": "func (miolr ManagedInstanceOperationListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "cfa5fab605fc173ebf0f904d77150aa2", "score": "0.68240225", "text": "func (b BigDataPoolResourceInfoListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", b.NextLink)\n\tpopulate(objectMap, \"value\", b.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "d8d5417aaf983ad2d9ea8764c62b374a", "score": "0.68186945", "text": "func (r RestorableTableResourcesListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", r.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "ccfcc751ed022cec698ada793c92d90f", "score": "0.68168133", "text": "func (mwlr MyWorkbooksListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "35b60412c80e822b83095b93aac4835f", "score": "0.68150616", "text": "func (m ManagedAPIListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", m.NextLink)\n\tpopulate(objectMap, \"value\", m.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "c711e55f0429e0bf914986a69a4eeccd", "score": "0.6813786", "text": "func (r RestorableGremlinResourcesListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", r.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "2cb4fa22498bc26c86c51a6d3ff6ad6d", "score": "0.68047255", "text": "func (wlr WorkbooksListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "12c4fda06089f387b17e9b387bee29d0", "score": "0.68000174", "text": "func (d DatabaseListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", d.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "12c4fda06089f387b17e9b387bee29d0", "score": "0.68000174", "text": "func (d DatabaseListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", d.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "d57faf7cac1d8af8c2287faefa395976", "score": "0.6799797", "text": "func (sgllr SyncGroupLogListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "0a2e72902e66de8926d9a1ecf54ce480", "score": "0.6788553", "text": "func (r RecordSet) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"etag\", r.Etag)\n\tpopulate(objectMap, \"id\", r.ID)\n\tpopulate(objectMap, \"name\", r.Name)\n\tpopulate(objectMap, \"properties\", r.Properties)\n\tpopulate(objectMap, \"type\", r.Type)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "7aa4706711f9a198311d2edf374c7774", "score": "0.67798495", "text": "func (saldlr SyncAgentLinkedDatabaseListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "7dc7dcdd14feabdf208d6e914defb873", "score": "0.6779443", "text": "func (jlr JobListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "da221b44efb5acb96cb5177616976e97", "score": "0.6778637", "text": "func (r RestorableDroppedSQLPoolListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", r.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "0444dacdbcfd83b81f70dff8ea7e849e", "score": "0.6773208", "text": "func (iplr InstancePoolListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "8b2dc6245439856425810ce09f5fb733", "score": "0.67714334", "text": "func (s SQLPoolColumnListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", s.NextLink)\n\tpopulate(objectMap, \"value\", s.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "c5fbb61a0f9fa90cba593eb9b52382fb", "score": "0.6762946", "text": "func (eplr ElasticPoolListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "aab9be0b403e11d45ba9ad5bf31a626a", "score": "0.67516124", "text": "func (dolr DatabaseOperationListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "d09e78861b6f3a182b3d437635d6bd32", "score": "0.67390233", "text": "func (s SQLPoolUsageListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", s.NextLink)\n\tpopulate(objectMap, \"value\", s.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "043577a68b884a2d350f51d3cae3c0f9", "score": "0.67350906", "text": "func (qtrl QueryTextsResultList) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "e32a38ac9f6124072d527f028af4d256", "score": "0.6731683", "text": "func (lr ListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\tif lr.Value != nil {\n\t\tobjectMap[\"value\"] = lr.Value\n\t}\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "8280ca23b54c888808a811ac4db8b1a5", "score": "0.6729619", "text": "func (alr AdministratorListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "49132119bb2666ac28aa395e9428cd43", "score": "0.6720907", "text": "func (elr EntityListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\tif elr.Value != nil {\n\t\tobjectMap[\"value\"] = elr.Value\n\t}\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "cb8ac178c239ac6cd6dc61b5ec42fbc0", "score": "0.6718256", "text": "func (sglr SyncGroupListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "ce35efb9d0a215799b00813970c30958", "score": "0.67149824", "text": "func (dlr DimensionsListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "26a2d0dcf302c9d37e9ad58f05e2df41", "score": "0.67109853", "text": "func (j JobCollectionListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", j.NextLink)\n\tpopulate(objectMap, \"value\", j.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "6b4975d466daa0405d9a9c6f8d8cfe43", "score": "0.670914", "text": "func (s ServiceResourceListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", s.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "c4be8bf914daf9177d9b502341141b4d", "score": "0.670862", "text": "func (p PartitionMetricListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", p.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "fd4310bd0ad58048ed3002c691f0b0bc", "score": "0.6698543", "text": "func (m MongoDBDatabaseListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", m.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "7891f9dd6cfd4702de795744d3511e89", "score": "0.6698362", "text": "func (mdsaplr ManagedDatabaseSecurityAlertPolicyListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "44a4001460d00820ec7d1793ce685974", "score": "0.6698288", "text": "func (r RestorableDatabaseAccountsListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", r.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "1a8bb8776d747165a570608296190ff8", "score": "0.6695942", "text": "func (s StorageListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\tpopulate(objectMap, \"nextLink\", s.NextLink)\n\tpopulate(objectMap, \"value\", s.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "e0f6439ef4b1cca225e8333f4fec1806", "score": "0.6689579", "text": "func (miltrplr ManagedInstanceLongTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "18bd4524780d5344adb0d937b493b113", "score": "0.6689046", "text": "func (rddlr RestorableDroppedDatabaseListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "bd5ff4980d9b72a8e4fdace65cb291f6", "score": "0.66865534", "text": "func (bstrplr BackupShortTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "5b9f676270c993aa9791bbfd7bee775f", "score": "0.66854835", "text": "func (arl AdvisorsResultList) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "8af60fbcdca390b9c211e52cb651436b", "score": "0.66801804", "text": "func (sllr SensitivityLabelListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "c01aa609fdc2a786cca50350aeed0efe", "score": "0.6678359", "text": "func (sklr ServerKeyListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "c01aa609fdc2a786cca50350aeed0efe", "score": "0.6678359", "text": "func (sklr ServerKeyListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "74acfbfc4363cfcfe9b2de6ac1395416", "score": "0.66757095", "text": "func (sdilr SyncDatabaseIDListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "47ccfb7a854fd489d096f32466ceb1f5", "score": "0.66740364", "text": "func (rllr ReplicationLinkListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "016989eaa6e252ceaf99eda5a5a325c3", "score": "0.6663873", "text": "func (miklr ManagedInstanceKeyListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "cca49abe38eb25e78add975d7cb61b85", "score": "0.66556835", "text": "func (solr ServerOperationListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "d7c379dfdd4362de8dd8b7985a6ff329", "score": "0.6652057", "text": "func (s SQLRoleDefinitionListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", s.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "d38f71a4ff408b6bee47c719e53efb44", "score": "0.66493237", "text": "func (ulr UsageListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "c0e02ab19d67808fce47fd793edd7381", "score": "0.6642282", "text": "func (c CustomEntityStoreAssignmentsListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\tpopulate(objectMap, \"nextLink\", c.NextLink)\n\tpopulate(objectMap, \"value\", c.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "fde33f0417723482929f7f3d446697b3", "score": "0.6635893", "text": "func (tqlr TopQueriesListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "9dbb3ce22cb550994f7135b5eb745de1", "score": "0.6633447", "text": "func (s SQLPoolBlobAuditingPolicySQLPoolOperationListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", s.NextLink)\n\tpopulate(objectMap, \"value\", s.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "2511f9d09cfc503e2847e5d477b4463a", "score": "0.66248786", "text": "func (c CustomEntityStoreAssignmentsListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", c.NextLink)\n\tpopulate(objectMap, \"value\", c.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "228cc647a199e4c0b00bd7c83cc487fd", "score": "0.6624654", "text": "func (m MongoRoleDefinitionListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", m.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "39d233638f7a1bcc002b166852115927", "score": "0.6622542", "text": "func (r RestorePointListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", r.NextLink)\n\tpopulate(objectMap, \"value\", r.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "a6516e48248b661abf254a0df82e8d48", "score": "0.66159964", "text": "func (m MongoClusterListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", m.NextLink)\n\tpopulate(objectMap, \"value\", m.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "fa25409803c79bad59b55ff57d8010e1", "score": "0.6615653", "text": "func (vlr ViewListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "22226dd603a823e498c9772738bcd9bc", "score": "0.6605584", "text": "func (dslr DeletedServerListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "f4f8684ac166e34014e33fe54d9cf9f6", "score": "0.6604957", "text": "func (ertlr EnabledResourceTypesListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "76f5feb04912879a5c9bde78d6d6e35a", "score": "0.6603427", "text": "func (vclr VirtualClusterListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "c8922368acb4ca91828a5b6828418c71", "score": "0.66028273", "text": "func (mialr ManagedInstanceAdministratorListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "72ffb48de069042212aec498deea67f8", "score": "0.6599475", "text": "func (v VMMServerListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", v.NextLink)\n\tpopulate(objectMap, \"value\", v.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "85243c590cb78aa7c3bb98b739de27ef", "score": "0.6590575", "text": "func (smlr SyncMemberListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "fa7cc9919280362e69bfb2f489919780", "score": "0.65866137", "text": "func (i IntegrationServiceEnvironmentManagedAPIListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", i.NextLink)\n\tpopulate(objectMap, \"value\", i.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "db602edcf456b0ca4edf75441d10ba8f", "score": "0.6569566", "text": "func (m MetricListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", m.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "71a6e8bf24ace703ebe09cca7a1b01e6", "score": "0.65628624", "text": "func (wiclr WorkItemConfigurationsListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "904cc4b287ab744808d579f7723fe149", "score": "0.6562632", "text": "func (ltrplr LongTermRetentionPolicyListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "e0acf2c105485c43ce666b4c3ec8597c", "score": "0.6557955", "text": "func (m MetricDefinitionsListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"value\", m.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" } ]
d5338918268fbd5f61cee201210609dd
newRequest creates a new request for a InputService8ProtocolTest operation and runs any custom request initialization.
[ { "docid": "03ac67b0a6dd4edb0da1da6f3318acec", "score": "0.85271907", "text": "func (c *InputService8ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" } ]
[ { "docid": "688c35b18b973f0b5536dd82de8409df", "score": "0.8338607", "text": "func (c *InputService8ProtocolTest) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {\n\treq := aws.NewRequest(c.Service, op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "702af20907e798db9172bab50fe8a7a4", "score": "0.8291841", "text": "func (c *InputService7ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "702af20907e798db9172bab50fe8a7a4", "score": "0.8291841", "text": "func (c *InputService7ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "af1e372f431d0bc9b2198648fc1c94cd", "score": "0.8223201", "text": "func (c *InputService9ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "af1e372f431d0bc9b2198648fc1c94cd", "score": "0.8223201", "text": "func (c *InputService9ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "145ad088b6aca6e5f8c531ad78515144", "score": "0.82057554", "text": "func (c *InputService6ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "145ad088b6aca6e5f8c531ad78515144", "score": "0.82057554", "text": "func (c *InputService6ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "41166de2f4848fc23640120f6d85e0c8", "score": "0.81799376", "text": "func (c *InputService11ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "41166de2f4848fc23640120f6d85e0c8", "score": "0.81799376", "text": "func (c *InputService11ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "12d44c833339080f897e13ccc2481f24", "score": "0.81667095", "text": "func (c *InputService16ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "12d44c833339080f897e13ccc2481f24", "score": "0.81667095", "text": "func (c *InputService16ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "200927996b123025f369229416a3b685", "score": "0.81472164", "text": "func (c *InputService10ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "200927996b123025f369229416a3b685", "score": "0.81472164", "text": "func (c *InputService10ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "bd4666b64a376b3f67d20223490cae2b", "score": "0.81305075", "text": "func (c *InputService1ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "bd4666b64a376b3f67d20223490cae2b", "score": "0.81305075", "text": "func (c *InputService1ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "38c6659a545ef17d6c4a1a6d75fdb6b4", "score": "0.81294906", "text": "func (c *InputService12ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "38c6659a545ef17d6c4a1a6d75fdb6b4", "score": "0.81294906", "text": "func (c *InputService12ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "a3cd86fe981988a24240e7206cbb206a", "score": "0.8124878", "text": "func (c *InputService18ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "a84a808a0b94291e95209a9ea351a150", "score": "0.8123062", "text": "func (c *InputService17ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "9e731c5ed694a8110e631bf25819a72f", "score": "0.8103924", "text": "func (c *InputService7ProtocolTest) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {\n\treq := aws.NewRequest(c.Service, op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "bc65467a731d0520f18586b51c9eaa86", "score": "0.80946577", "text": "func (c *InputService4ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "bc65467a731d0520f18586b51c9eaa86", "score": "0.80946577", "text": "func (c *InputService4ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "25ea9622c8fb1051bebe509839790cd2", "score": "0.80594647", "text": "func (c *InputService5ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "25ea9622c8fb1051bebe509839790cd2", "score": "0.80594647", "text": "func (c *InputService5ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "b15bbdcde11503e7a87962bbe8f72ac7", "score": "0.80577826", "text": "func (c *InputService15ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "b15bbdcde11503e7a87962bbe8f72ac7", "score": "0.80577826", "text": "func (c *InputService15ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "6769ab56be9d773701ae9ebb9e0dc618", "score": "0.80526173", "text": "func (c *InputService6ProtocolTest) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {\n\treq := aws.NewRequest(c.Service, op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "5baee392869957e56d8a2c8d797df104", "score": "0.8048082", "text": "func (c *InputService19ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "20904a58492efa46d3886eee1bcb19eb", "score": "0.80281746", "text": "func (c *InputService14ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "20904a58492efa46d3886eee1bcb19eb", "score": "0.80281746", "text": "func (c *InputService14ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "4394ee27d8e2208d78ae2ec5a9bf106d", "score": "0.80218637", "text": "func (c *InputService20ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "66a7ec5ecbc66ff1f2c17dca7e624bc7", "score": "0.7980378", "text": "func (c *InputService2ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "66a7ec5ecbc66ff1f2c17dca7e624bc7", "score": "0.7980378", "text": "func (c *InputService2ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "ccad233ba137f04a8a161ada8974d9b0", "score": "0.7952432", "text": "func (c *InputService13ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "ccad233ba137f04a8a161ada8974d9b0", "score": "0.7952432", "text": "func (c *InputService13ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "1f9fd8bf4c60b7ac05cdde8bab39da7a", "score": "0.7942943", "text": "func (c *InputService1ProtocolTest) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {\n\treq := aws.NewRequest(c.Service, op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "351a5850a038ebb79e92dc6b7041574a", "score": "0.79315037", "text": "func (c *InputService21ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "c0b926ab41d6ad3ca2b89f933b8ef2ac", "score": "0.7869424", "text": "func (c *InputService5ProtocolTest) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {\n\treq := aws.NewRequest(c.Service, op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "27087697d82b91d40dca5f981237c7f9", "score": "0.7868785", "text": "func (c *InputService3ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "27087697d82b91d40dca5f981237c7f9", "score": "0.7868785", "text": "func (c *InputService3ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "8c6f2b96ce944d54365055b96043b3a4", "score": "0.78597295", "text": "func (c *InputService4ProtocolTest) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {\n\treq := aws.NewRequest(c.Service, op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "9cdb31360cf1ba7c6fd4dc95c46463d2", "score": "0.77628744", "text": "func (c *InputService2ProtocolTest) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {\n\treq := aws.NewRequest(c.Service, op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "69aebbb300391bfe3f12ce935866dee9", "score": "0.75810003", "text": "func (c *InputService3ProtocolTest) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {\n\treq := aws.NewRequest(c.Service, op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "2400e0b5375cc08902113d70991ba06c", "score": "0.723732", "text": "func (c *CodePipeline) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\t// Run custom request initialization if present\n\tif initRequest != nil {\n\t\tinitRequest(req)\n\t}\n\n\treturn req\n}", "title": "" }, { "docid": "4f10eaac8f11c0a3ce0065b0af8a48a0", "score": "0.70536363", "text": "func (c *IAM) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\t// Run custom request initialization if present\n\tif initRequest != nil {\n\t\tinitRequest(req)\n\t}\n\n\treturn req\n}", "title": "" }, { "docid": "b7daedcee94a2f536b11db620f7a5e00", "score": "0.7046274", "text": "func (s *AdminConfigService) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := s.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "9c3f665d235084d305cd79b416830308", "score": "0.70171905", "text": "func (s *ThirdPartyServicesService) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := s.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "2b82f233e3d8f31db7418131bde62cd7", "score": "0.69746244", "text": "func (c *DataPipeline) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\t// Run custom request initialization if present\n\tif initRequest != nil {\n\t\tinitRequest(req)\n\t}\n\n\treturn req\n}", "title": "" }, { "docid": "203a4e148c6fff942ed00c1a5e99e65f", "score": "0.6901405", "text": "func (s *AcmeService) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := s.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "f8a0dbc44f5cfbb467f4d3ab7956843f", "score": "0.68665504", "text": "func (s *EngineListenersService) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := s.NewRequest(op, params, data)\n\n\treturn req\n}", "title": "" }, { "docid": "6145e33e92a74da984055ea20f2d8280", "score": "0.68399715", "text": "func (c *ECR) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\t// Run custom request initialization if present\n\tif initRequest != nil {\n\t\tinitRequest(req)\n\t}\n\n\treturn req\n}", "title": "" }, { "docid": "590a70dc46ebfad346e649faa0d7a36a", "score": "0.66684544", "text": "func NewInputService8ProtocolTest(config *aws.Config) *InputService8ProtocolTest {\n\tservice := &service.Service{\n\t\tServiceInfo: serviceinfo.ServiceInfo{\n\t\t\tConfig: defaults.DefaultConfig.Merge(config),\n\t\t\tServiceName: \"inputservice8protocoltest\",\n\t\t\tAPIVersion: \"2014-01-01\",\n\t\t},\n\t}\n\tservice.Initialize()\n\n\t// Handlers\n\tservice.Handlers.Sign.PushBack(v4.Sign)\n\tservice.Handlers.Build.PushBack(restxml.Build)\n\tservice.Handlers.Unmarshal.PushBack(restxml.Unmarshal)\n\tservice.Handlers.UnmarshalMeta.PushBack(restxml.UnmarshalMeta)\n\tservice.Handlers.UnmarshalError.PushBack(restxml.UnmarshalError)\n\n\treturn &InputService8ProtocolTest{service}\n}", "title": "" }, { "docid": "9c0a2ff1be9bf6d7be235e3680cab89e", "score": "0.65744615", "text": "func (c *Client) NewRequest(operation *Operation, input interface{}, data interface{}) *Request {\n c.GetLogger().Debug(\"client: NewRequest() executing\")\n return NewRequest(c.GetConfig(), c.GetMiddleware(), operation, input, data)\n}", "title": "" }, { "docid": "ee450050710d4af6e371d436bbacf400", "score": "0.65709853", "text": "func newInputService8ProtocolTestClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *InputService8ProtocolTest {\n\tsvc := &InputService8ProtocolTest{\n\t\tClient: client.New(\n\t\t\tcfg,\n\t\t\tmetadata.ClientInfo{\n\t\t\t\tServiceName: \"inputservice8protocoltest\",\n\t\t\t\tSigningRegion: signingRegion,\n\t\t\t\tEndpoint: endpoint,\n\t\t\t\tAPIVersion: \"2014-01-01\",\n\t\t\t},\n\t\t\thandlers,\n\t\t),\n\t}\n\n\t// Handlers\n\tsvc.Handlers.Sign.PushBack(v4.Sign)\n\tsvc.Handlers.Build.PushBackNamed(restjson.BuildHandler)\n\tsvc.Handlers.Unmarshal.PushBackNamed(restjson.UnmarshalHandler)\n\tsvc.Handlers.UnmarshalMeta.PushBackNamed(restjson.UnmarshalMetaHandler)\n\tsvc.Handlers.UnmarshalError.PushBackNamed(restjson.UnmarshalErrorHandler)\n\n\treturn svc\n}", "title": "" }, { "docid": "187eb0c6fa40653f80d65b1cfa5c612f", "score": "0.6565228", "text": "func NewInputService8ProtocolTest(config *aws.Config) *InputService8ProtocolTest {\n\tif config == nil {\n\t\tconfig = &aws.Config{}\n\t}\n\n\tservice := &aws.Service{\n\t\tConfig: aws.DefaultConfig.Merge(config),\n\t\tServiceName: \"inputservice8protocoltest\",\n\t\tAPIVersion: \"2014-01-01\",\n\t}\n\tservice.Initialize()\n\n\t// Handlers\n\tservice.Handlers.Sign.PushBack(v4.Sign)\n\tservice.Handlers.Build.PushBack(query.Build)\n\tservice.Handlers.Unmarshal.PushBack(query.Unmarshal)\n\tservice.Handlers.UnmarshalMeta.PushBack(query.UnmarshalMeta)\n\tservice.Handlers.UnmarshalError.PushBack(query.UnmarshalError)\n\n\treturn &InputService8ProtocolTest{service}\n}", "title": "" }, { "docid": "0ba67158df51d26ce1ae3a86df1f4efe", "score": "0.64735425", "text": "func (c *Client) newRequest(method, path string, params url.Values, payload io.Reader) (*http.Request, error) {\n\turl := c.getURL(path, params)\n\treq, err := http.NewRequest(method, url.String(), payload)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treq.Header.Set(\"User-Agent\", c.UserAgent)\n\treturn req, nil\n}", "title": "" }, { "docid": "7c6ac409fe71ca18315a60ee7a163b4f", "score": "0.64524513", "text": "func (c *Client) newRequest(r *Request) (*http.Request, error) {\n\n\turi := url.URL{\n\t\tScheme: \"http\",\n\t\tHost: c.Address,\n\t\tPath: r.Path,\n\t\t//RawQuery: params.Encode\n\t}\n\turi.RawQuery = r.Values.Encode()\n\t//url.Query you can set parameters\n\treq, err := http.NewRequest(r.Method, uri.RequestURI(), r.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.URL.Scheme = uri.Scheme\n\treq.URL.Host = uri.Host\n\treq.Host = uri.Host\n\n\treq.Header.Set(\"X-Envoy-Token\", c.Token)\n\treturn req, nil\n}", "title": "" }, { "docid": "74ea5959e9bebdaf14c90938f6e7b05f", "score": "0.6437235", "text": "func (c *Client) newRequest(ctx context.Context, method string, subPath string, body io.Reader) (*http.Request, error) {\n\tendpointURL := *c.BaseURL\n\tendpointURL.Path = path.Join(c.BaseURL.Path, subPath)\n\n\treq, err := http.NewRequest(method, endpointURL.String(), body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to build HTTP request: err = %s, method = %s, endpointURL = %s, body = %#v\", err, method, endpointURL.String(), body)\n\t}\n\n\treq = req.WithContext(ctx)\n\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\treturn req, nil\n}", "title": "" }, { "docid": "84c7779f97fa0a7d217f8e6af828c727", "score": "0.6408526", "text": "func NewInputService8ProtocolTest(p client.ConfigProvider, cfgs ...*aws.Config) *InputService8ProtocolTest {\n\tc := p.ClientConfig(\"inputservice8protocoltest\", cfgs...)\n\treturn newInputService8ProtocolTestClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)\n}", "title": "" }, { "docid": "652a203f702bc2c7f8cdd94e307b8b26", "score": "0.6349432", "text": "func (c *Client) newRequest(method string, path string, body io.Reader) (*http.Request, error) {\n\trelPath, err := url.Parse(apiKeyPath(path, c.apiKey))\n\n\tif err != nil {\n\t\treturn nil, err\n\n\t}\n\n\turl := c.endPoint.ResolveReference(relPath)\n\n\treq, err := http.NewRequest(method, url.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\n\t}\n\n\treq.Header.Add(\"User-Agent\", c.userAgent)\n\treq.Header.Add(\"Accept\", ContentType)\n\n\tc.debugLog(\"making a %s request to %s\", method, url)\n\treturn req, nil\n}", "title": "" }, { "docid": "38cc9b34070825adf353540db5d13313", "score": "0.6338401", "text": "func (c *_Crawler) NewTestRequest(ctx context.Context) (reqs []*http.Request) {\n\tfor _, u := range []string{\n\t\t//\"https://www.theoutnet.com/en-us\",\n\t\t\"https://www.theoutnet.com/en-us/shop/product/acne-studios/jeans/straight-leg-jeans/log-high-rise-straight-leg-jeans/17476499598965898\",\n\t\t// \"https://www.theoutnet.com/en-us/shop/product/balmain/shoulder-bag/cross-body/disco-leather-trimmed-shearling-shoulder-bag/10163292708696549\",\n\t} {\n\t\treq, err := http.NewRequest(http.MethodGet, u, nil)\n\t\tif err != nil {\n\t\t\tc.logger.Fatal(err)\n\t\t} else {\n\t\t\treqs = append(reqs, req)\n\t\t}\n\t}\n\treturn\n}", "title": "" }, { "docid": "df8dad9301e572e4c7ebd8736ee78625", "score": "0.63283485", "text": "func (preFlight *PreFlight) newRequest() (*http.Request, error) {\n\treq, err := http.NewRequest(http.MethodOptions, preFlight.target, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Origin\", preFlight.origin)\n\treq.Header.Add(\"Access-Control-Request-Method\", preFlight.method)\n\n\theaders := strings.Join(preFlight.header, \",\")\n\treq.Header.Add(\"Access-Control-Request-Headers\", headers)\n\n\treturn req, err\n}", "title": "" }, { "docid": "bdb01f9c8462c80381671ed6fecb19ec", "score": "0.63051885", "text": "func newTestRequest(method, path string) (*httptest.ResponseRecorder, *http.Request) {\n\trequest, err := http.NewRequest(method, path, nil)\n\tif err != nil {\n\t\tfmt.Printf(\"could not make request %s (%s): %s\\n\", path, method, err.Error())\n\t}\n\trecorder := httptest.NewRecorder()\n\n\treturn recorder, request\n}", "title": "" }, { "docid": "36692fcf46e7acb38102d16b0fb059f4", "score": "0.629863", "text": "func (c *Client) newRequest(method, path string, payload interface{}) (*http.Request, error) {\n\turl := fmt.Sprintf(\"%s/%s/%s\", c.APIEndpoint, c.APIVersion, path)\n\n\tbody := new(bytes.Buffer)\n\tif payload != nil {\n\t\terr := json.NewEncoder(body).Encode(payload)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treq, err := http.NewRequest(method, url, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Add(\"Accept\", \"application/json\")\n\n\treturn req, nil\n}", "title": "" }, { "docid": "306905264fd319364d59827bc49aefc8", "score": "0.6263849", "text": "func (c *_Crawler) NewTestRequest(ctx context.Context) (reqs []*http.Request) {\n\tfor _, u := range []string{\n\t\t//\"https://www.hunterboots.com/us/en_us\",\n\t\t//\"https://www.hunterboots.com/us/en_us/womens-footwear-rainboots\",\n\t\t// \"https://www.hunterboots.com/us/en_us/womens-ankle-boots\",\n\t\t//\"https://www.hunterboots.com/us/en_us/womens-ankle-boots/womens-original-chelsea-boots/yellow/6503\",\n\t\t//\"https://www.hunterboots.com/us/en_us/sale-womens-sale-footwear\",\n\t\t//\"https://www.hunterboots.com/us/en_us/mens-winter-footwear/mens-insulated-roll-top-sherpa-boots/black/7226\",\n\t\t\"https://www.hunterboots.com/us/en_us/kids-rain-boots/kids-first-classic-nebula-rain-boots/blue/7249\",\n\t} {\n\t\treq, err := http.NewRequest(http.MethodGet, u, nil)\n\t\tif err != nil {\n\t\t\tc.logger.Fatal(err)\n\t\t} else {\n\t\t\treqs = append(reqs, req)\n\t\t}\n\t}\n\treturn\n}", "title": "" }, { "docid": "29fa82ebbfa42aeb80799f0e0bf043a5", "score": "0.6210937", "text": "func (c *InputService8ProtocolTest) InputService8TestCaseOperation6Request(input *InputService8TestShapeInputShape) (req *aws.Request, output *InputService8TestShapeInputService8TestCaseOperation6Output) {\n\tif opInputService8TestCaseOperation6 == nil {\n\t\topInputService8TestCaseOperation6 = &aws.Operation{\n\t\t\tName: \"OperationName\",\n\t\t}\n\t}\n\n\treq = c.newRequest(opInputService8TestCaseOperation6, input, output)\n\toutput = &InputService8TestShapeInputService8TestCaseOperation6Output{}\n\treq.Data = output\n\treturn\n}", "title": "" }, { "docid": "9c3e762ed562dfa78ec0da57bb2fac23", "score": "0.6201176", "text": "func newKeyRequest(label, algo string, size int) (keyRequest, error) {\n\tswitch algo {\n\tcase RSA:\n\t\treturn newRSAKeyRequest(label, size)\n\tcase ECDSA:\n\t\treturn newECDSAKeyRequest(label, size)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported algorithm: %s\", algo)\n\t}\n}", "title": "" }, { "docid": "55d49e46dcaec2eee02f498b1c1a0f52", "score": "0.6199731", "text": "func (i *instance) NewRequest(method, urlStr string, body io.Reader) (*http.Request, error) {\n\treq, err := http.NewRequest(method, urlStr, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Associate this request.\n\treturn internal.RegisterTestRequest(req, i.apiURL, \"dev~\"+i.appID), nil\n}", "title": "" }, { "docid": "cbf9e8e5620bd53ca23aaf2f6ecd3164", "score": "0.6190396", "text": "func newRequest(method string, params interface{}, id uint64) (req *request, err error) {\n\tdata, err := json.Marshal(params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trawMsg := json.RawMessage(data)\n\tr := &request{method, &rawMsg, id}\n\treturn r, err\n}", "title": "" }, { "docid": "6f468100c6408cd8ffdb268b29b8c5c4", "score": "0.6169855", "text": "func (c *httpClient) newRequest(payload *api.Payload) (*http.Request, error) {\n\tif c.token == \"\" {\n\t\treturn nil, errors.New(\"empty token\")\n\t}\n\n\tdata, err := json.Marshal(payload)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to encode payload\")\n\t}\n\n\treq, err := http.NewRequest(http.MethodPost, c.endpoint, bytes.NewReader(data))\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to create new POST request\")\n\t}\n\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"User-Agent\", UserAgent)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "344cd7e374653904dc0c6e1facf3d5c8", "score": "0.6163329", "text": "func newRequest() *asanaRequest {\n\treturn &asanaRequest{\n\t\tpNames: make([]string, 0, maxParam),\n\t\tpValues: make([]string, 0, maxParam),\n\t\tdata: make(map[interface{}]interface{}),\n\t}\n}", "title": "" }, { "docid": "dd419c35fee6694a09882d68143c79d0", "score": "0.6128683", "text": "func newScheduleRequest(flags ScheduleFlags) *svcpb.StartTestSessionRequest {\n\tvar workers []*svcpb.Component\n\tif flags.server != \"\" {\n\t\tworkers = append(workers, &svcpb.Component{\n\t\t\tContainerImage: flags.server,\n\t\t\tKind: svcpb.Component_SERVER,\n\t\t\tPool: flags.serverPool,\n\t\t})\n\t}\n\tfor _, client := range flags.clients.clients {\n\t\tworkers = append(workers, &svcpb.Component{\n\t\t\tContainerImage: client,\n\t\t\tKind: svcpb.Component_CLIENT,\n\t\t\tPool: flags.clientPool,\n\t\t})\n\t}\n\n\treturn &svcpb.StartTestSessionRequest{\n\t\tScenario: flags.scenario.proto,\n\t\tDriver: &svcpb.Component{\n\t\t\tContainerImage: flags.driver,\n\t\t\tKind: svcpb.Component_DRIVER,\n\t\t\tPool: flags.driverPool,\n\t\t},\n\t\tWorkers: workers,\n\t}\n}", "title": "" }, { "docid": "a96f45f7b473988f2e32432f9bf9e052", "score": "0.6124031", "text": "func (c *Conn) newRequest(method, urlStr string, body io.Reader) (*http.Request, error) {\n\tc.log.Debugf(\"%s: %s\", method, urlStr)\n\treq, err := http.NewRequest(method, urlStr, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Header.Set(\"User-Agent\", \"go-sechat (https://qms.li/gsc)\")\n\treturn req, nil\n}", "title": "" }, { "docid": "ea324ed35a8ea73c1583aabfce697fee", "score": "0.6121358", "text": "func (c *InputService8ProtocolTest) InputService8TestCaseOperation1Request(input *InputService8TestShapeInputShape) (req *aws.Request, output *InputService8TestShapeInputService8TestCaseOperation1Output) {\n\tif opInputService8TestCaseOperation1 == nil {\n\t\topInputService8TestCaseOperation1 = &aws.Operation{\n\t\t\tName: \"OperationName\",\n\t\t}\n\t}\n\n\treq = c.newRequest(opInputService8TestCaseOperation1, input, output)\n\toutput = &InputService8TestShapeInputService8TestCaseOperation1Output{}\n\treq.Data = output\n\treturn\n}", "title": "" }, { "docid": "8244008f1e29e2947233a2680fac3766", "score": "0.61087996", "text": "func newRequest(ctx context.Context, url string, reqBody io.Reader, contentType string) (*http.Request, error) {\n\treq, err := http.NewRequest(\"POST\", url, reqBody)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq = req.WithContext(ctx)\n\tif customHeader := getCustomHTTPReqHeaders(ctx); customHeader != nil {\n\t\treq.Header = customHeader\n\t}\n\treq.Header.Set(\"Accept\", contentType)\n\treq.Header.Set(\"Content-Type\", contentType)\n\treq.Header.Set(\"Twirp-Version\", \"v8.1.0\")\n\treturn req, nil\n}", "title": "" }, { "docid": "e23f9d198e94b9bd97e027e458e3ccd8", "score": "0.6080166", "text": "func newRequest(ctx context.Context, url string, reqBody io.Reader, contentType string) (*http.Request, error) {\n\treq, err := http.NewRequest(\"POST\", url, reqBody)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq = req.WithContext(ctx)\n\tif customHeader := getCustomHTTPReqHeaders(ctx); customHeader != nil {\n\t\treq.Header = customHeader\n\t}\n\treq.Header.Set(\"Accept\", contentType)\n\treq.Header.Set(\"Content-Type\", contentType)\n\treq.Header.Set(\"Twirp-Version\", \"v7.1.1\")\n\treturn req, nil\n}", "title": "" }, { "docid": "df06913ff476607b244c5c5da53e434a", "score": "0.6074783", "text": "func newRequest(ctx context.Context, url string, reqBody io.Reader, contentType string) (*http.Request, error) {\n\treq, err := http.NewRequest(\"POST\", url, reqBody)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq = req.WithContext(ctx)\n\tif customHeader := getCustomHTTPReqHeaders(ctx); customHeader != nil {\n\t\treq.Header = customHeader\n\t}\n\treq.Header.Set(\"Accept\", contentType)\n\treq.Header.Set(\"Content-Type\", contentType)\n\treq.Header.Set(\"Twirp-Version\", \"v7.1.0\")\n\treturn req, nil\n}", "title": "" }, { "docid": "da0fac5056fb0964a0263575debcc2e7", "score": "0.6055642", "text": "func newRequest(url, method string) *Request {\n\tvar resp http.Response\n\treq := http.Request{\n\t\tMethod: method,\n\t\tHeader: make(http.Header),\n\t\tProto: \"HTTP/1.1\",\n\t\tProtoMajor: 1,\n\t\tProtoMinor: 1,\n\t}\n\treturn &Request{url, &req, map[string]string{}, defaultSetting, &resp, nil}\n}", "title": "" }, { "docid": "2a8e18d69ae2dad2dab3c227f396dcc7", "score": "0.6040781", "text": "func newRequest(ctx context.Context, url string, reqBody io.Reader, contentType string) (*http.Request, error) {\n\treq, err := http.NewRequest(\"POST\", url, reqBody)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq = req.WithContext(ctx)\n\tif customHeader := getCustomHTTPReqHeaders(ctx); customHeader != nil {\n\t\treq.Header = customHeader\n\t}\n\treq.Header.Set(\"Content-Type\", contentType)\n\treq.Header.Set(\"Twirp-Version\", \"v5.0.0\")\n\treturn req, nil\n}", "title": "" }, { "docid": "dff4d72a2741b7f5488c230ce530f011", "score": "0.604058", "text": "func (c *Codec) NewRequest(topic string, payload []byte) (rpc.CodecRequest, error) {\n\treturn newCodecRequest(topic, payload)\n}", "title": "" }, { "docid": "359796ec4e8cd00a7335ec5164ecbb87", "score": "0.60394645", "text": "func (c Client) newRequest(\n\tmethod, spath string,\n\tparams map[string]string,\n) (req *http.Request, err error) {\n\n\t// Assemble URL from path\n\turi := c.BaseURL\n\turi.Path = path.Join(uri.Path, spath)\n\n\tif method != http.MethodGet {\n\t\treq, err = http.NewRequest(method, uri.String(), bytes.NewBufferString(BuildBody(params).Encode()))\n\t\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\t} else {\n\t\treq, err = http.NewRequest(http.MethodGet, BuildURL(uri, params).String(), nil)\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Add APIKey to HTTP header\n\treq.Header.Set(\"X-ChatWorkToken\", c.APIKey)\n\n\treturn req, nil\n}", "title": "" }, { "docid": "a253b752e7fd2bd14c34ad6d9350a587", "score": "0.602202", "text": "func (c *InputService8ProtocolTest) InputService8TestCaseOperation1Request(input *InputService8TestShapeInputService8TestCaseOperation1Input) (req *request.Request, output *InputService8TestShapeInputService8TestCaseOperation1Output) {\n\top := &request.Operation{\n\t\tName: opInputService8TestCaseOperation1,\n\t\tHTTPMethod: \"POST\",\n\t\tHTTPPath: \"/2014-01-01/hostedzone\",\n\t}\n\n\tif input == nil {\n\t\tinput = &InputService8TestShapeInputService8TestCaseOperation1Input{}\n\t}\n\n\treq = c.newRequest(op, input, output)\n\toutput = &InputService8TestShapeInputService8TestCaseOperation1Output{}\n\treq.Data = output\n\treturn\n}", "title": "" }, { "docid": "0183bf1c2048557e6b6ae6401f47930d", "score": "0.6021828", "text": "func New(k8Client k8sv1.Clienter) Requestor {\n\treturn &request{\n\t\tk8Client,\n\t}\n}", "title": "" }, { "docid": "563891ab80256e9e937a0b17ec0dc66f", "score": "0.6016745", "text": "func newRequest(ctx context.Context, url string, reqBody io.Reader, contentType string) (*http.Request, error) {\n\treq, err := http.NewRequest(\"POST\", url, reqBody)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq = req.WithContext(ctx)\n\tif customHeader := getCustomHTTPReqHeaders(ctx); customHeader != nil {\n\t\treq.Header = customHeader\n\t}\n\treq.Header.Set(\"Accept\", contentType)\n\treq.Header.Set(\"Content-Type\", contentType)\n\treq.Header.Set(\"Twirp-Version\", \"v5.10.0\")\n\treturn req, nil\n}", "title": "" }, { "docid": "eb4a2bd74779edb524091fe92c134b14", "score": "0.60134", "text": "func newRequest(ctx context.Context, url string, reqBody io.Reader, contentType string) (*http.Request, error) {\n\treq, err := http.NewRequest(\"POST\", url, reqBody)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq = req.WithContext(ctx)\n\tif customHeader := getCustomHTTPReqHeaders(ctx); customHeader != nil {\n\t\treq.Header = customHeader\n\t}\n\treq.Header.Set(\"Accept\", contentType)\n\treq.Header.Set(\"Content-Type\", contentType)\n\treq.Header.Set(\"Twirp-Version\", \"v5.12.1\")\n\treturn req, nil\n}", "title": "" }, { "docid": "652c02a8ee51c6f96b3b9abd2170d333", "score": "0.6008921", "text": "func NewRequest(data string, low uint64, up uint64) *Message {\n\treturn &Message{\n\t\tType: Request,\n\t\tData: data,\n\t\tLower: low,\n\t\tUpper: up}\n\n}", "title": "" }, { "docid": "eeef3ad7c3b27f445e0e456fc77bee05", "score": "0.60051996", "text": "func NewRequest(event json.RawMessage) (*http.Request, error) {\n\tvar r struct {\n\t\tVersion string `json:\"version\"`\n\t}\n\tif PayloadVersion == \"\" {\n\t\tif err := json.Unmarshal(event, &r); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else {\n\t\tr.Version = PayloadVersion\n\t}\n\n\tswitch r.Version {\n\tcase \"2.0\":\n\t\tvar rv2 RequestV2\n\t\tif err := json.Unmarshal(event, &rv2); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn rv2.httpRequest()\n\tcase \"1.0\", \"\":\n\t\tvar rv1 RequestV1\n\t\tif err := json.Unmarshal(event, &rv1); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn rv1.httpRequest()\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"Payload Version %s is not supported\", r.Version)\n\t}\n}", "title": "" }, { "docid": "d2e15b5e50e758e1c7346f4d6f6ea356", "score": "0.599766", "text": "func (p ManagedPlatform) NewRequest(method, url string) (*http.Request, error) {\n\treq, err := p.platformBase.NewRequest(method, url)\n\tif err == nil {\n\t\ttoken, err := CreateIDToken(url)\n\t\tif err != nil {\n\t\t\treturn req, err\n\t\t}\n\t\treq.Header.Add(\"Authorization\", fmt.Sprintf(\"Bearer %s\", token))\n\t}\n\treturn req, err\n}", "title": "" }, { "docid": "7454a1ea1de0d138bbb9ca27d3a1ad61", "score": "0.59910953", "text": "func (s *WebhookTrigger) newRequest(vars map[string]interface{}) (*http.Request, error) {\n\tmethod := s.getMethod()\n\turl, err := s.getUrl(vars)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbody, err := s.getBody(vars)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq, err := http.NewRequest(method, url, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\theaders, err := s.getHeaders(vars)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor headr, val := range headers {\n\t\treq.Header.Set(headr, val)\n\t}\n\treturn req, nil\n}", "title": "" }, { "docid": "2b4e7044fb50a01db3c47cbfbd8a8f42", "score": "0.5985076", "text": "func (rm *resourceManager) newCreateRequestPayload(\n\tr *resource,\n) (*svcsdk.CreateTrainingJobInput, error) {\n\tres := &svcsdk.CreateTrainingJobInput{}\n\n\tif r.ko.Spec.AlgorithmSpecification != nil {\n\t\tf0 := &svcsdk.AlgorithmSpecification{}\n\t\tif r.ko.Spec.AlgorithmSpecification.AlgorithmName != nil {\n\t\t\tf0.SetAlgorithmName(*r.ko.Spec.AlgorithmSpecification.AlgorithmName)\n\t\t}\n\t\tif r.ko.Spec.AlgorithmSpecification.EnableSageMakerMetricsTimeSeries != nil {\n\t\t\tf0.SetEnableSageMakerMetricsTimeSeries(*r.ko.Spec.AlgorithmSpecification.EnableSageMakerMetricsTimeSeries)\n\t\t}\n\t\tif r.ko.Spec.AlgorithmSpecification.MetricDefinitions != nil {\n\t\t\tf0f2 := []*svcsdk.MetricDefinition{}\n\t\t\tfor _, f0f2iter := range r.ko.Spec.AlgorithmSpecification.MetricDefinitions {\n\t\t\t\tf0f2elem := &svcsdk.MetricDefinition{}\n\t\t\t\tif f0f2iter.Name != nil {\n\t\t\t\t\tf0f2elem.SetName(*f0f2iter.Name)\n\t\t\t\t}\n\t\t\t\tif f0f2iter.Regex != nil {\n\t\t\t\t\tf0f2elem.SetRegex(*f0f2iter.Regex)\n\t\t\t\t}\n\t\t\t\tf0f2 = append(f0f2, f0f2elem)\n\t\t\t}\n\t\t\tf0.SetMetricDefinitions(f0f2)\n\t\t}\n\t\tif r.ko.Spec.AlgorithmSpecification.TrainingImage != nil {\n\t\t\tf0.SetTrainingImage(*r.ko.Spec.AlgorithmSpecification.TrainingImage)\n\t\t}\n\t\tif r.ko.Spec.AlgorithmSpecification.TrainingInputMode != nil {\n\t\t\tf0.SetTrainingInputMode(*r.ko.Spec.AlgorithmSpecification.TrainingInputMode)\n\t\t}\n\t\tres.SetAlgorithmSpecification(f0)\n\t}\n\tif r.ko.Spec.CheckpointConfig != nil {\n\t\tf1 := &svcsdk.CheckpointConfig{}\n\t\tif r.ko.Spec.CheckpointConfig.LocalPath != nil {\n\t\t\tf1.SetLocalPath(*r.ko.Spec.CheckpointConfig.LocalPath)\n\t\t}\n\t\tif r.ko.Spec.CheckpointConfig.S3URI != nil {\n\t\t\tf1.SetS3Uri(*r.ko.Spec.CheckpointConfig.S3URI)\n\t\t}\n\t\tres.SetCheckpointConfig(f1)\n\t}\n\tif r.ko.Spec.DebugHookConfig != nil {\n\t\tf2 := &svcsdk.DebugHookConfig{}\n\t\tif r.ko.Spec.DebugHookConfig.CollectionConfigurations != nil {\n\t\t\tf2f0 := []*svcsdk.CollectionConfiguration{}\n\t\t\tfor _, f2f0iter := range r.ko.Spec.DebugHookConfig.CollectionConfigurations {\n\t\t\t\tf2f0elem := &svcsdk.CollectionConfiguration{}\n\t\t\t\tif f2f0iter.CollectionName != nil {\n\t\t\t\t\tf2f0elem.SetCollectionName(*f2f0iter.CollectionName)\n\t\t\t\t}\n\t\t\t\tif f2f0iter.CollectionParameters != nil {\n\t\t\t\t\tf2f0elemf1 := map[string]*string{}\n\t\t\t\t\tfor f2f0elemf1key, f2f0elemf1valiter := range f2f0iter.CollectionParameters {\n\t\t\t\t\t\tvar f2f0elemf1val string\n\t\t\t\t\t\tf2f0elemf1val = *f2f0elemf1valiter\n\t\t\t\t\t\tf2f0elemf1[f2f0elemf1key] = &f2f0elemf1val\n\t\t\t\t\t}\n\t\t\t\t\tf2f0elem.SetCollectionParameters(f2f0elemf1)\n\t\t\t\t}\n\t\t\t\tf2f0 = append(f2f0, f2f0elem)\n\t\t\t}\n\t\t\tf2.SetCollectionConfigurations(f2f0)\n\t\t}\n\t\tif r.ko.Spec.DebugHookConfig.HookParameters != nil {\n\t\t\tf2f1 := map[string]*string{}\n\t\t\tfor f2f1key, f2f1valiter := range r.ko.Spec.DebugHookConfig.HookParameters {\n\t\t\t\tvar f2f1val string\n\t\t\t\tf2f1val = *f2f1valiter\n\t\t\t\tf2f1[f2f1key] = &f2f1val\n\t\t\t}\n\t\t\tf2.SetHookParameters(f2f1)\n\t\t}\n\t\tif r.ko.Spec.DebugHookConfig.LocalPath != nil {\n\t\t\tf2.SetLocalPath(*r.ko.Spec.DebugHookConfig.LocalPath)\n\t\t}\n\t\tif r.ko.Spec.DebugHookConfig.S3OutputPath != nil {\n\t\t\tf2.SetS3OutputPath(*r.ko.Spec.DebugHookConfig.S3OutputPath)\n\t\t}\n\t\tres.SetDebugHookConfig(f2)\n\t}\n\tif r.ko.Spec.DebugRuleConfigurations != nil {\n\t\tf3 := []*svcsdk.DebugRuleConfiguration{}\n\t\tfor _, f3iter := range r.ko.Spec.DebugRuleConfigurations {\n\t\t\tf3elem := &svcsdk.DebugRuleConfiguration{}\n\t\t\tif f3iter.InstanceType != nil {\n\t\t\t\tf3elem.SetInstanceType(*f3iter.InstanceType)\n\t\t\t}\n\t\t\tif f3iter.LocalPath != nil {\n\t\t\t\tf3elem.SetLocalPath(*f3iter.LocalPath)\n\t\t\t}\n\t\t\tif f3iter.RuleConfigurationName != nil {\n\t\t\t\tf3elem.SetRuleConfigurationName(*f3iter.RuleConfigurationName)\n\t\t\t}\n\t\t\tif f3iter.RuleEvaluatorImage != nil {\n\t\t\t\tf3elem.SetRuleEvaluatorImage(*f3iter.RuleEvaluatorImage)\n\t\t\t}\n\t\t\tif f3iter.RuleParameters != nil {\n\t\t\t\tf3elemf4 := map[string]*string{}\n\t\t\t\tfor f3elemf4key, f3elemf4valiter := range f3iter.RuleParameters {\n\t\t\t\t\tvar f3elemf4val string\n\t\t\t\t\tf3elemf4val = *f3elemf4valiter\n\t\t\t\t\tf3elemf4[f3elemf4key] = &f3elemf4val\n\t\t\t\t}\n\t\t\t\tf3elem.SetRuleParameters(f3elemf4)\n\t\t\t}\n\t\t\tif f3iter.S3OutputPath != nil {\n\t\t\t\tf3elem.SetS3OutputPath(*f3iter.S3OutputPath)\n\t\t\t}\n\t\t\tif f3iter.VolumeSizeInGB != nil {\n\t\t\t\tf3elem.SetVolumeSizeInGB(*f3iter.VolumeSizeInGB)\n\t\t\t}\n\t\t\tf3 = append(f3, f3elem)\n\t\t}\n\t\tres.SetDebugRuleConfigurations(f3)\n\t}\n\tif r.ko.Spec.EnableInterContainerTrafficEncryption != nil {\n\t\tres.SetEnableInterContainerTrafficEncryption(*r.ko.Spec.EnableInterContainerTrafficEncryption)\n\t}\n\tif r.ko.Spec.EnableManagedSpotTraining != nil {\n\t\tres.SetEnableManagedSpotTraining(*r.ko.Spec.EnableManagedSpotTraining)\n\t}\n\tif r.ko.Spec.EnableNetworkIsolation != nil {\n\t\tres.SetEnableNetworkIsolation(*r.ko.Spec.EnableNetworkIsolation)\n\t}\n\tif r.ko.Spec.ExperimentConfig != nil {\n\t\tf7 := &svcsdk.ExperimentConfig{}\n\t\tif r.ko.Spec.ExperimentConfig.ExperimentName != nil {\n\t\t\tf7.SetExperimentName(*r.ko.Spec.ExperimentConfig.ExperimentName)\n\t\t}\n\t\tif r.ko.Spec.ExperimentConfig.TrialComponentDisplayName != nil {\n\t\t\tf7.SetTrialComponentDisplayName(*r.ko.Spec.ExperimentConfig.TrialComponentDisplayName)\n\t\t}\n\t\tif r.ko.Spec.ExperimentConfig.TrialName != nil {\n\t\t\tf7.SetTrialName(*r.ko.Spec.ExperimentConfig.TrialName)\n\t\t}\n\t\tres.SetExperimentConfig(f7)\n\t}\n\tif r.ko.Spec.HyperParameters != nil {\n\t\tf8 := map[string]*string{}\n\t\tfor f8key, f8valiter := range r.ko.Spec.HyperParameters {\n\t\t\tvar f8val string\n\t\t\tf8val = *f8valiter\n\t\t\tf8[f8key] = &f8val\n\t\t}\n\t\tres.SetHyperParameters(f8)\n\t}\n\tif r.ko.Spec.InputDataConfig != nil {\n\t\tf9 := []*svcsdk.Channel{}\n\t\tfor _, f9iter := range r.ko.Spec.InputDataConfig {\n\t\t\tf9elem := &svcsdk.Channel{}\n\t\t\tif f9iter.ChannelName != nil {\n\t\t\t\tf9elem.SetChannelName(*f9iter.ChannelName)\n\t\t\t}\n\t\t\tif f9iter.CompressionType != nil {\n\t\t\t\tf9elem.SetCompressionType(*f9iter.CompressionType)\n\t\t\t}\n\t\t\tif f9iter.ContentType != nil {\n\t\t\t\tf9elem.SetContentType(*f9iter.ContentType)\n\t\t\t}\n\t\t\tif f9iter.DataSource != nil {\n\t\t\t\tf9elemf3 := &svcsdk.DataSource{}\n\t\t\t\tif f9iter.DataSource.FileSystemDataSource != nil {\n\t\t\t\t\tf9elemf3f0 := &svcsdk.FileSystemDataSource{}\n\t\t\t\t\tif f9iter.DataSource.FileSystemDataSource.DirectoryPath != nil {\n\t\t\t\t\t\tf9elemf3f0.SetDirectoryPath(*f9iter.DataSource.FileSystemDataSource.DirectoryPath)\n\t\t\t\t\t}\n\t\t\t\t\tif f9iter.DataSource.FileSystemDataSource.FileSystemAccessMode != nil {\n\t\t\t\t\t\tf9elemf3f0.SetFileSystemAccessMode(*f9iter.DataSource.FileSystemDataSource.FileSystemAccessMode)\n\t\t\t\t\t}\n\t\t\t\t\tif f9iter.DataSource.FileSystemDataSource.FileSystemID != nil {\n\t\t\t\t\t\tf9elemf3f0.SetFileSystemId(*f9iter.DataSource.FileSystemDataSource.FileSystemID)\n\t\t\t\t\t}\n\t\t\t\t\tif f9iter.DataSource.FileSystemDataSource.FileSystemType != nil {\n\t\t\t\t\t\tf9elemf3f0.SetFileSystemType(*f9iter.DataSource.FileSystemDataSource.FileSystemType)\n\t\t\t\t\t}\n\t\t\t\t\tf9elemf3.SetFileSystemDataSource(f9elemf3f0)\n\t\t\t\t}\n\t\t\t\tif f9iter.DataSource.S3DataSource != nil {\n\t\t\t\t\tf9elemf3f1 := &svcsdk.S3DataSource{}\n\t\t\t\t\tif f9iter.DataSource.S3DataSource.AttributeNames != nil {\n\t\t\t\t\t\tf9elemf3f1f0 := []*string{}\n\t\t\t\t\t\tfor _, f9elemf3f1f0iter := range f9iter.DataSource.S3DataSource.AttributeNames {\n\t\t\t\t\t\t\tvar f9elemf3f1f0elem string\n\t\t\t\t\t\t\tf9elemf3f1f0elem = *f9elemf3f1f0iter\n\t\t\t\t\t\t\tf9elemf3f1f0 = append(f9elemf3f1f0, &f9elemf3f1f0elem)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tf9elemf3f1.SetAttributeNames(f9elemf3f1f0)\n\t\t\t\t\t}\n\t\t\t\t\tif f9iter.DataSource.S3DataSource.S3DataDistributionType != nil {\n\t\t\t\t\t\tf9elemf3f1.SetS3DataDistributionType(*f9iter.DataSource.S3DataSource.S3DataDistributionType)\n\t\t\t\t\t}\n\t\t\t\t\tif f9iter.DataSource.S3DataSource.S3DataType != nil {\n\t\t\t\t\t\tf9elemf3f1.SetS3DataType(*f9iter.DataSource.S3DataSource.S3DataType)\n\t\t\t\t\t}\n\t\t\t\t\tif f9iter.DataSource.S3DataSource.S3URI != nil {\n\t\t\t\t\t\tf9elemf3f1.SetS3Uri(*f9iter.DataSource.S3DataSource.S3URI)\n\t\t\t\t\t}\n\t\t\t\t\tf9elemf3.SetS3DataSource(f9elemf3f1)\n\t\t\t\t}\n\t\t\t\tf9elem.SetDataSource(f9elemf3)\n\t\t\t}\n\t\t\tif f9iter.InputMode != nil {\n\t\t\t\tf9elem.SetInputMode(*f9iter.InputMode)\n\t\t\t}\n\t\t\tif f9iter.RecordWrapperType != nil {\n\t\t\t\tf9elem.SetRecordWrapperType(*f9iter.RecordWrapperType)\n\t\t\t}\n\t\t\tif f9iter.ShuffleConfig != nil {\n\t\t\t\tf9elemf6 := &svcsdk.ShuffleConfig{}\n\t\t\t\tif f9iter.ShuffleConfig.Seed != nil {\n\t\t\t\t\tf9elemf6.SetSeed(*f9iter.ShuffleConfig.Seed)\n\t\t\t\t}\n\t\t\t\tf9elem.SetShuffleConfig(f9elemf6)\n\t\t\t}\n\t\t\tf9 = append(f9, f9elem)\n\t\t}\n\t\tres.SetInputDataConfig(f9)\n\t}\n\tif r.ko.Spec.OutputDataConfig != nil {\n\t\tf10 := &svcsdk.OutputDataConfig{}\n\t\tif r.ko.Spec.OutputDataConfig.KMSKeyID != nil {\n\t\t\tf10.SetKmsKeyId(*r.ko.Spec.OutputDataConfig.KMSKeyID)\n\t\t}\n\t\tif r.ko.Spec.OutputDataConfig.S3OutputPath != nil {\n\t\t\tf10.SetS3OutputPath(*r.ko.Spec.OutputDataConfig.S3OutputPath)\n\t\t}\n\t\tres.SetOutputDataConfig(f10)\n\t}\n\tif r.ko.Spec.ResourceConfig != nil {\n\t\tf11 := &svcsdk.ResourceConfig{}\n\t\tif r.ko.Spec.ResourceConfig.InstanceCount != nil {\n\t\t\tf11.SetInstanceCount(*r.ko.Spec.ResourceConfig.InstanceCount)\n\t\t}\n\t\tif r.ko.Spec.ResourceConfig.InstanceType != nil {\n\t\t\tf11.SetInstanceType(*r.ko.Spec.ResourceConfig.InstanceType)\n\t\t}\n\t\tif r.ko.Spec.ResourceConfig.VolumeKMSKeyID != nil {\n\t\t\tf11.SetVolumeKmsKeyId(*r.ko.Spec.ResourceConfig.VolumeKMSKeyID)\n\t\t}\n\t\tif r.ko.Spec.ResourceConfig.VolumeSizeInGB != nil {\n\t\t\tf11.SetVolumeSizeInGB(*r.ko.Spec.ResourceConfig.VolumeSizeInGB)\n\t\t}\n\t\tres.SetResourceConfig(f11)\n\t}\n\tif r.ko.Spec.RoleARN != nil {\n\t\tres.SetRoleArn(*r.ko.Spec.RoleARN)\n\t}\n\tif r.ko.Spec.StoppingCondition != nil {\n\t\tf13 := &svcsdk.StoppingCondition{}\n\t\tif r.ko.Spec.StoppingCondition.MaxRuntimeInSeconds != nil {\n\t\t\tf13.SetMaxRuntimeInSeconds(*r.ko.Spec.StoppingCondition.MaxRuntimeInSeconds)\n\t\t}\n\t\tif r.ko.Spec.StoppingCondition.MaxWaitTimeInSeconds != nil {\n\t\t\tf13.SetMaxWaitTimeInSeconds(*r.ko.Spec.StoppingCondition.MaxWaitTimeInSeconds)\n\t\t}\n\t\tres.SetStoppingCondition(f13)\n\t}\n\tif r.ko.Spec.Tags != nil {\n\t\tf14 := []*svcsdk.Tag{}\n\t\tfor _, f14iter := range r.ko.Spec.Tags {\n\t\t\tf14elem := &svcsdk.Tag{}\n\t\t\tif f14iter.Key != nil {\n\t\t\t\tf14elem.SetKey(*f14iter.Key)\n\t\t\t}\n\t\t\tif f14iter.Value != nil {\n\t\t\t\tf14elem.SetValue(*f14iter.Value)\n\t\t\t}\n\t\t\tf14 = append(f14, f14elem)\n\t\t}\n\t\tres.SetTags(f14)\n\t}\n\tif r.ko.Spec.TensorBoardOutputConfig != nil {\n\t\tf15 := &svcsdk.TensorBoardOutputConfig{}\n\t\tif r.ko.Spec.TensorBoardOutputConfig.LocalPath != nil {\n\t\t\tf15.SetLocalPath(*r.ko.Spec.TensorBoardOutputConfig.LocalPath)\n\t\t}\n\t\tif r.ko.Spec.TensorBoardOutputConfig.S3OutputPath != nil {\n\t\t\tf15.SetS3OutputPath(*r.ko.Spec.TensorBoardOutputConfig.S3OutputPath)\n\t\t}\n\t\tres.SetTensorBoardOutputConfig(f15)\n\t}\n\tif r.ko.Spec.TrainingJobName != nil {\n\t\tres.SetTrainingJobName(*r.ko.Spec.TrainingJobName)\n\t}\n\tif r.ko.Spec.VPCConfig != nil {\n\t\tf17 := &svcsdk.VpcConfig{}\n\t\tif r.ko.Spec.VPCConfig.SecurityGroupIDs != nil {\n\t\t\tf17f0 := []*string{}\n\t\t\tfor _, f17f0iter := range r.ko.Spec.VPCConfig.SecurityGroupIDs {\n\t\t\t\tvar f17f0elem string\n\t\t\t\tf17f0elem = *f17f0iter\n\t\t\t\tf17f0 = append(f17f0, &f17f0elem)\n\t\t\t}\n\t\t\tf17.SetSecurityGroupIds(f17f0)\n\t\t}\n\t\tif r.ko.Spec.VPCConfig.Subnets != nil {\n\t\t\tf17f1 := []*string{}\n\t\t\tfor _, f17f1iter := range r.ko.Spec.VPCConfig.Subnets {\n\t\t\t\tvar f17f1elem string\n\t\t\t\tf17f1elem = *f17f1iter\n\t\t\t\tf17f1 = append(f17f1, &f17f1elem)\n\t\t\t}\n\t\t\tf17.SetSubnets(f17f1)\n\t\t}\n\t\tres.SetVpcConfig(f17)\n\t}\n\n\treturn res, nil\n}", "title": "" }, { "docid": "2f50a5525b8ed65ff26f8c450ffcee1b", "score": "0.59713507", "text": "func newInputService9ProtocolTestClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *InputService9ProtocolTest {\n\tsvc := &InputService9ProtocolTest{\n\t\tClient: client.New(\n\t\t\tcfg,\n\t\t\tmetadata.ClientInfo{\n\t\t\t\tServiceName: \"inputservice9protocoltest\",\n\t\t\t\tSigningRegion: signingRegion,\n\t\t\t\tEndpoint: endpoint,\n\t\t\t\tAPIVersion: \"2014-01-01\",\n\t\t\t},\n\t\t\thandlers,\n\t\t),\n\t}\n\n\t// Handlers\n\tsvc.Handlers.Sign.PushBack(v4.Sign)\n\tsvc.Handlers.Build.PushBackNamed(restjson.BuildHandler)\n\tsvc.Handlers.Unmarshal.PushBackNamed(restjson.UnmarshalHandler)\n\tsvc.Handlers.UnmarshalMeta.PushBackNamed(restjson.UnmarshalMetaHandler)\n\tsvc.Handlers.UnmarshalError.PushBackNamed(restjson.UnmarshalErrorHandler)\n\n\treturn svc\n}", "title": "" }, { "docid": "5be12763f3f86b10090ef8212439c152", "score": "0.59554005", "text": "func (c *InputService8ProtocolTest) InputService8TestCaseOperation5Request(input *InputService8TestShapeInputShape) (req *aws.Request, output *InputService8TestShapeInputService8TestCaseOperation5Output) {\n\tif opInputService8TestCaseOperation5 == nil {\n\t\topInputService8TestCaseOperation5 = &aws.Operation{\n\t\t\tName: \"OperationName\",\n\t\t}\n\t}\n\n\treq = c.newRequest(opInputService8TestCaseOperation5, input, output)\n\toutput = &InputService8TestShapeInputService8TestCaseOperation5Output{}\n\treq.Data = output\n\treturn\n}", "title": "" }, { "docid": "02e30433924622005c4037489a106f77", "score": "0.5948736", "text": "func (c *InputService8ProtocolTest) InputService8TestCaseOperation4Request(input *InputService8TestShapeInputShape) (req *aws.Request, output *InputService8TestShapeInputService8TestCaseOperation4Output) {\n\tif opInputService8TestCaseOperation4 == nil {\n\t\topInputService8TestCaseOperation4 = &aws.Operation{\n\t\t\tName: \"OperationName\",\n\t\t}\n\t}\n\n\treq = c.newRequest(opInputService8TestCaseOperation4, input, output)\n\toutput = &InputService8TestShapeInputService8TestCaseOperation4Output{}\n\treq.Data = output\n\treturn\n}", "title": "" }, { "docid": "9c2f3bbdf737946cc11be7e7c8c94887", "score": "0.59465647", "text": "func (c *SSOAuthenticator) newRequest(method, urlStr string, body interface{}, mediaType string) (*http.Request, error) {\n\trel, err := url.Parse(urlStr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbuf := new(bytes.Buffer)\n\tif body != nil {\n\t\terr = json.NewEncoder(buf).Encode(body)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treq, err := http.NewRequest(method, rel.String(), buf)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "title": "" }, { "docid": "f665a5a7d81b9e37f6df2daadeca20ea", "score": "0.59421414", "text": "func NewRequest(data string, lower, upper uint64) *Message {\r\n\treturn &Message{\r\n\t\tType: Request,\r\n\t\tData: data,\r\n\t\tLower: lower,\r\n\t\tUpper: upper,\r\n\t}\r\n}", "title": "" }, { "docid": "bcda22cc758a70bb541fa21332583299", "score": "0.5936864", "text": "func (c *Client) newRequest(method, urlPath string, options interface{}) (*http.Request, error) {\n\n\tapiURL, err := url.Parse(urlPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\turlParams := url.Values{}\n\turlParams.Set(\"apiKey\", c.apiKey)\n\n\tif options != nil {\n\t\tqueryParams, err := query.Values(options)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tfor k, v := range queryParams {\n\t\t\tfor _, values := range v {\n\t\t\t\turlParams.Add(k, values)\n\t\t\t}\n\t\t}\n\t}\n\n\tvar body io.Reader\n\tif method != http.MethodGet {\n\t\tbody = strings.NewReader(urlParams.Encode())\n\t} else {\n\t\tapiURL.RawQuery = urlParams.Encode()\n\t}\n\n\treq, err := http.NewRequest(method, apiURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Accept\", \"application/json\")\n\treq.Header.Add(\"User-Agent\", UserAgent)\n\n\tif method != http.MethodGet {\n\t\treq.Header.Add(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\t}\n\n\treturn req, nil\n}", "title": "" }, { "docid": "89320b357dfc6858109ec9bb9ac9f810", "score": "0.59336776", "text": "func (c *Client) newRequest(path string) (req *http.Request, err error) {\n\n\tu := c.host + fmt.Sprintf(path, c.node)\n\n\tif !strings.Contains(u, \"://\") {\n\t\tu = fmt.Sprintf(\"http://%s\", u)\n\t}\n\n\tlog.Debug().Msg(\"Fetching from \" + u)\n\n\treq, err = http.NewRequest(http.MethodGet, u, nil)\n\tif err != nil {\n\t\tlog.Debug().Msg(\"Failed to create http request: \" + err.Error())\n\t\treturn req, fmt.Errorf(\"Failed to create http request: %v\", err)\n\t}\n\n\t//set request headers\n\treq.SetBasicAuth(c.username, c.password)\n\treq.Header.Set(\"Accept\", \"application/json\")\n\n\treturn\n}", "title": "" }, { "docid": "2e9747655a2af30e13bb330dd5efd8e3", "score": "0.58932996", "text": "func newRequest(ctx context.Context, kind string, op Action) *request {\n\tauthCtx := auth.GetIdentity(ctx)\n\tn := request{\n\t\tkind: kind,\n\t\top: op,\n\t\tdomain: authCtx.DomainID(),\n\t\tproject: authCtx.ProjectID(),\n\t\troles: getUserRoles(ctx),\n\t}\n\n\treturn &n\n}", "title": "" }, { "docid": "2081639ef34a4f1d7ac5fe1c60a54260", "score": "0.5892437", "text": "func newInputService10ProtocolTestClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *InputService10ProtocolTest {\n\tsvc := &InputService10ProtocolTest{\n\t\tClient: client.New(\n\t\t\tcfg,\n\t\t\tmetadata.ClientInfo{\n\t\t\t\tServiceName: \"inputservice10protocoltest\",\n\t\t\t\tSigningRegion: signingRegion,\n\t\t\t\tEndpoint: endpoint,\n\t\t\t\tAPIVersion: \"2014-01-01\",\n\t\t\t},\n\t\t\thandlers,\n\t\t),\n\t}\n\n\t// Handlers\n\tsvc.Handlers.Sign.PushBack(v4.Sign)\n\tsvc.Handlers.Build.PushBackNamed(restjson.BuildHandler)\n\tsvc.Handlers.Unmarshal.PushBackNamed(restjson.UnmarshalHandler)\n\tsvc.Handlers.UnmarshalMeta.PushBackNamed(restjson.UnmarshalMetaHandler)\n\tsvc.Handlers.UnmarshalError.PushBackNamed(restjson.UnmarshalErrorHandler)\n\n\treturn svc\n}", "title": "" } ]
66dd0a37b72696f5220d904d8718a293
TagDelete indicates an expected call of TagDelete.
[ { "docid": "26e664e9741c2343e2554720317588e3", "score": "0.7485322", "text": "func (mr *MockGitModuleMockRecorder) TagDelete(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"TagDelete\", reflect.TypeOf((*MockGitModule)(nil).TagDelete), arg0)\n}", "title": "" } ]
[ { "docid": "d196cccf7298e09d5cab0008d9d582e3", "score": "0.7444994", "text": "func (mr *MockLocalRepoMockRecorder) TagDelete(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"TagDelete\", reflect.TypeOf((*MockLocalRepo)(nil).TagDelete), arg0)\n}", "title": "" }, { "docid": "6de67ecb1c38883047662c584bc27cf8", "score": "0.71058196", "text": "func (mr *MockWorkitemtrackingClientMockRecorder) DeleteTag(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"DeleteTag\", reflect.TypeOf((*MockWorkitemtrackingClient)(nil).DeleteTag), arg0, arg1)\n}", "title": "" }, { "docid": "7faa861ed0c229422e17f7382b9aa0a4", "score": "0.6786081", "text": "func (a *Client) TagDelete(params *TagDeleteParams, opts ...ClientOption) (*TagDeleteOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewTagDeleteParams()\n\t}\n\top := &runtime.ClientOperation{\n\t\tID: \"tag.delete\",\n\t\tMethod: \"POST\",\n\t\tPathPattern: \"/v1/tag/delete\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"http\"},\n\t\tParams: params,\n\t\tReader: &TagDeleteReader{formats: a.formats},\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t}\n\tfor _, opt := range opts {\n\t\topt(op)\n\t}\n\n\tresult, err := a.transport.Submit(op)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*TagDeleteOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for tag.delete: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "title": "" }, { "docid": "6e28e393e7bdea5d113c3770a353bacc", "score": "0.67000115", "text": "func (rc *RegClient) TagDelete(ctx context.Context, r ref.Ref) error {\n\tschemeAPI, err := rc.schemeGet(r.Scheme)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn schemeAPI.TagDelete(ctx, r)\n}", "title": "" }, { "docid": "74ab701574d470d43099a6c38300326a", "score": "0.6638045", "text": "func (gm *BasicGitModule) TagDelete(tagname string) error {\n\t_, err := ExecGitCmd(gm.gitBinPath, gm.path, \"tag\", \"-d\", tagname)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"tag delete failed\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "da6a45357b9bbcf67a56f9a4f329fc69", "score": "0.6518763", "text": "func TestContactTagDelete_Success(t *testing.T) {\n\tassert.NotEmpty(t, testContactTagID)\n\tid := int64(testContactTagID)\n\terr := C.ContactTagDelete(id)\n\tassert.Nil(t, err)\n}", "title": "" }, { "docid": "dbdbea80741e21f2497cd18e02895246", "score": "0.6471145", "text": "func (client TagClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, tagID string, ifMatch string) (result autorest.Response, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/TagClient.Delete\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.Response != nil {\n\t\t\t\tsc = result.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tif err := validation.Validate([]validation.Validation{\n\t\t{TargetValue: serviceName,\n\t\t\tConstraints: []validation.Constraint{{Target: \"serviceName\", Name: validation.MaxLength, Rule: 50, Chain: nil},\n\t\t\t\t{Target: \"serviceName\", Name: validation.MinLength, Rule: 1, Chain: nil},\n\t\t\t\t{Target: \"serviceName\", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},\n\t\t{TargetValue: tagID,\n\t\t\tConstraints: []validation.Constraint{{Target: \"tagID\", Name: validation.MaxLength, Rule: 80, Chain: nil},\n\t\t\t\t{Target: \"tagID\", Name: validation.MinLength, Rule: 1, Chain: nil},\n\t\t\t\t{Target: \"tagID\", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {\n\t\treturn result, validation.NewError(\"apimanagement.TagClient\", \"Delete\", err.Error())\n\t}\n\n\treq, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, tagID, ifMatch)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"apimanagement.TagClient\", \"Delete\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresp, err := client.DeleteSender(req)\n\tif err != nil {\n\t\tresult.Response = resp\n\t\terr = autorest.NewErrorWithError(err, \"apimanagement.TagClient\", \"Delete\", resp, \"Failure sending request\")\n\t\treturn\n\t}\n\n\tresult, err = client.DeleteResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"apimanagement.TagClient\", \"Delete\", resp, \"Failure responding to request\")\n\t\treturn\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "0a369444e6bff8a4ec16623b9f8564da", "score": "0.6393668", "text": "func (m *MockGitModule) TagDelete(arg0 string) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"TagDelete\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "58474ae923baada1872633c70eda63ee", "score": "0.63666654", "text": "func (client *Client) TagDelete(project_id, name string, params *TagDeleteParams) error {\n\n\terr := func() error {\n\n\t\turl := fmt.Sprintf(\"/v2/projects/%s/tags/%s\", url.QueryEscape(project_id), url.QueryEscape(name))\n\n\t\tparamsBuf := bytes.NewBuffer(nil)\n\t\terr := json.NewEncoder(paramsBuf).Encode(&params)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\trc, err := client.sendRequest(\"DELETE\", url, \"application/json\", paramsBuf, 204)\n\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer rc.Close()\n\n\t\treturn nil\n\t}()\n\treturn err\n}", "title": "" }, { "docid": "969f5c7f7e25bfa2ca5fe0dfbd547f37", "score": "0.63410354", "text": "func APIDeleteTag(c *gin.Context) {\n\tvar json []llrp.TagRecord\n\tc.BindWith(&json, binding.JSON)\n\tif res := ReqDeleteTag(\"delete\", json); res == \"error\" {\n\t\tc.String(http.StatusNoContent, \"The tag doesn't exist!\\n\")\n\t} else {\n\t\tc.String(http.StatusAccepted, \"Delete requested!\\n\")\n\t}\n}", "title": "" }, { "docid": "97ec68a29f686f7252cefc20fcc6ccf5", "score": "0.6316073", "text": "func (m *EdiscoveryCasesItemTagsTagItemRequestBuilder) Delete(ctx context.Context, requestConfiguration *EdiscoveryCasesItemTagsTagItemRequestBuilderDeleteRequestConfiguration)(error) {\n requestInfo, err := m.ToDeleteRequestInformation(ctx, requestConfiguration);\n if err != nil {\n return err\n }\n errorMapping := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.ErrorMappings {\n \"4XX\": i20a3050780ee0b0cde0a884a4f35429a20d60067e3bcda382ec5400079147459.CreateODataErrorFromDiscriminatorValue,\n \"5XX\": i20a3050780ee0b0cde0a884a4f35429a20d60067e3bcda382ec5400079147459.CreateODataErrorFromDiscriminatorValue,\n }\n err = m.BaseRequestBuilder.RequestAdapter.SendNoContent(ctx, requestInfo, errorMapping)\n if err != nil {\n return err\n }\n return nil\n}", "title": "" }, { "docid": "fa4a1291bcdb5f40223e8d50f2d9475d", "score": "0.6240911", "text": "func (mr *MockEC2MockRecorder) DeleteTags(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"DeleteTags\", reflect.TypeOf((*MockEC2)(nil).DeleteTags), arg0)\n}", "title": "" }, { "docid": "58a7ae8deb9ab472f598b9b7fa77ad5f", "score": "0.62134737", "text": "func (t ConsensusTagTable) Delete(\n\tdb DBi,\n\tDatasetID string,\n\tFingerprint string,\n\tTagTypeID string,\n) (\n\terr error,\n) {\n\t_, err = db.Exec(deleteQuery_ConsensusTag,\n\t\tDatasetID,\n\t\tFingerprint,\n\t\tTagTypeID)\n\n\tif err == nil {\n\t\treturn nil\n\t}\n\tif err := translateDBError(err); err != nil {\n\t\treturn err\n\t}\n\n\t// Not a known error.\n\treturn errors.Unexpected.\n\t\tWrap(\"ConsensusTag.Delete failed: %w\", err).\n\t\tAlert()\n}", "title": "" }, { "docid": "97fecb74bb6b3e100552975588c86f29", "score": "0.619014", "text": "func (e Endpoints) DeleteTag(ctx context.Context, name string, token string) (message string, status string, err error) {\n\trequest := DeleteTagRequest{\n\t\tName: name,\n\t\tToken: token,\n\t}\n\tresponse, err := e.DeleteTagEndpoint(ctx, request)\n\tif err != nil {\n\t\treturn\n\t}\n\treturn response.(DeleteTagResponse).Message, response.(DeleteTagResponse).Status, response.(DeleteTagResponse).Err\n}", "title": "" }, { "docid": "4b390be1c8a6c00e33dcec8a8ee03124", "score": "0.6162933", "text": "func (th *tagHandler) DeleteTag(w http.ResponseWriter, r *http.Request) {\n\tdcontext.GetLogger(th).Debug(\"DeleteTag\")\n\n\tif th.App.isCache {\n\t\tth.Errors = append(th.Errors, errcode.ErrorCodeUnsupported)\n\t\treturn\n\t}\n\n\tif th.writeFSMetadata {\n\t\ttagService := th.Repository.Tags(th)\n\t\tif err := tagService.Untag(th.Context, th.Tag); err != nil {\n\t\t\tth.appendDeleteTagError(err)\n\t\t\treturn\n\t\t}\n\t}\n\n\tif th.useDatabase {\n\t\tif err := dbDeleteTag(th.Context, th.db, th.Repository.Named().Name(), th.Tag); err != nil {\n\t\t\tth.appendDeleteTagError(err)\n\t\t\treturn\n\t\t}\n\t}\n\n\tw.WriteHeader(http.StatusAccepted)\n}", "title": "" }, { "docid": "a9bc70f61192d26c4093a56d0937b80c", "score": "0.6006288", "text": "func (s *syncer) deleteTag(txn *gorm.DB, log *zap.SugaredLogger, tags []model.ResourceTag) {\n\n\tfor _, t := range tags {\n\t\tvar resTag []model.ResourceTag\n\t\ttxn.Where(&model.ResourceTag{TagID: t.TagID}).Find(&resTag)\n\n\t\tif len(resTag) == 0 {\n\t\t\ttxn.Unscoped().Where(\"id = ?\", t.TagID).Delete(&model.Tag{})\n\t\t\tlog.Infof(\"Tag with ID: %d has been deleted\", t.TagID)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "5b4d784525b3a61dcec54f752b2be6bb", "score": "0.6004557", "text": "func ReqDeleteTag(ut string, req []TagInString) string {\n\t// TODO: success/fail notification per tag\n\tfailed := false\n\tfor _, t := range req {\n\t\ttag, err := buildTag([]string{t.PCBits, t.Length, t.EPCLengthBits, t.EPC, t.ReadData})\n\t\tcheck(err)\n\n\t\tdelete := &TagManager{\n\t\t\taction: DeleteTags,\n\t\t\ttags: []*Tag{&tag}}\n\t\ttagManager <- delete\n\n\t\tif delete = <-tagManager; len(delete.tags) != 0 {\n\t\t\tm := WebsocketMessage{\n\t\t\t\tUpdateType: \"delete\",\n\t\t\t\tTag: t,\n\t\t\t\tTags: []map[string]interface{}{}}\n\t\t\tclientMessage, err := json.Marshal(m)\n\t\t\tcheck(err)\n\t\t\tBroadcast(clientMessage)\n\t\t} else {\n\t\t\tfailed = true\n\t\t}\n\t}\n\tif failed {\n\t\tlogger.Errorf(\"failed %v %v\", ut, req)\n\t\treturn \"error\"\n\t}\n\tlogger.Debugf(\"%v %v\", ut, req)\n\treturn ut\n}", "title": "" }, { "docid": "747d0e3fbde7bf975c48590955f02364", "score": "0.60029113", "text": "func DeleteTag(ctx context.Context, db *database.Connection, i DeleteTagInput) error {\n\toperation, err := lookupOperation(db, i.OperationSlug)\n\tif err != nil {\n\t\treturn backend.WrapError(\"Unable to delete tag\", backend.UnauthorizedWriteErr(err))\n\t}\n\n\tif err := policy.Require(middleware.Policy(ctx), policy.CanModifyTagsOfOperation{OperationID: operation.ID}); err != nil {\n\t\treturn backend.WrapError(\"Unwilling to delete tag\", backend.UnauthorizedWriteErr(err))\n\t}\n\n\terr = db.WithTx(ctx, func(tx *database.Transactable) {\n\t\ttx.Delete(sq.Delete(\"tag_evidence_map\").Where(sq.Eq{\"tag_id\": i.ID}))\n\t\ttx.Delete(sq.Delete(\"tags\").Where(sq.Eq{\"id\": i.ID}))\n\t})\n\tif err != nil {\n\t\treturn backend.WrapError(\"Cannot delete tag\", backend.DatabaseErr(err))\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "22d1868c1ed0cf6d5650c74f019641b2", "score": "0.5990286", "text": "func verifyDeleteOperation(queryResult *cnstypes.CnsQueryResult, volumeID string, resourceType string) error {\n\tif len(queryResult.Volumes) == 0 && resourceType == PV {\n\t\treturn nil\n\t}\n\tentityMetadata := queryResult.Volumes[0].Metadata.EntityMetadata\n\tfor _, metadata := range entityMetadata {\n\t\tif len(metadata.GetCnsEntityMetadata().Labels) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tqueryLabel := metadata.GetCnsEntityMetadata().Labels[0].Key\n\t\tqueryValue := metadata.GetCnsEntityMetadata().Labels[0].Value\n\t\tif resourceType == PV && queryLabel == testPVLabelName && queryValue == testPVLabelValue {\n\t\t\treturn fmt.Errorf(\"delete operation failed for volume Id %s and resource type %s \", volumeID, resourceType)\n\t\t}\n\t\tif resourceType == PVC && queryLabel == testPVCLabelName && queryValue == testPVCLabelValue {\n\t\t\treturn fmt.Errorf(\"delete operation failed for volume Id %s and resource type %s \", volumeID, resourceType)\n\t\t}\n\t\tif resourceType == POD && queryLabel == testPodLabelName && queryValue == testPodLabelValue {\n\t\t\treturn fmt.Errorf(\"delete operation failed for volume Id %s and resource type %s \", volumeID, resourceType)\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "9919c3da5c39643a33564bc0dcb18891", "score": "0.59761673", "text": "func Delete(client *gophercloud.ServiceClient, resourceType string, resourceID string, tag string) (r DeleteResult) {\n\turl := deleteURL(client, resourceType, resourceID, tag)\n\tresp, err := client.Delete(url, &gophercloud.RequestOpts{\n\t\tOkCodes: []int{204},\n\t})\n\t_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)\n\treturn\n}", "title": "" }, { "docid": "6f509ea80dadabdbaaf496dde43635cc", "score": "0.5972591", "text": "func verifyDeleteOperation(queryResult *cnstypes.CnsQueryResult, volumeID string, resourceType string) error {\n\tif len(queryResult.Volumes) == 0 && resourceType == PV {\n\t\treturn nil\n\t}\n\tentityMetadata := queryResult.Volumes[0].Metadata.EntityMetadata\n\tfor _, metadata := range entityMetadata {\n\t\tif len(metadata.GetCnsEntityMetadata().Labels) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tqueryLabel := metadata.GetCnsEntityMetadata().Labels[0].Key\n\t\tqueryValue := metadata.GetCnsEntityMetadata().Labels[0].Value\n\t\tif resourceType == PVC && queryLabel == testPVCLabelName && queryValue == testPVCLabelValue {\n\t\t\treturn fmt.Errorf(\"delete operation failed for volume Id %s and resource type %s \", volumeID, resourceType)\n\t\t}\n\t\tif resourceType == PV && queryLabel == testPVLabelName && queryValue == testPVLabelValue {\n\t\t\treturn fmt.Errorf(\"delete operation failed for volume Id %s and resource type %s \", volumeID, resourceType)\n\t\t}\n\t\tif resourceType == POD && queryLabel == testPodLabelName && queryValue == testPodLabelValue {\n\t\t\treturn fmt.Errorf(\"delete operation failed for volume Id %s and resource type %s \", volumeID, resourceType)\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "5d3401bb95cee5eee840db91c8ec31cb", "score": "0.59622085", "text": "func DeleteTag(dbConn *sqlx.DB, transaction *sqlx.Tx, tag string) error {\n\tstmt := `\n DELETE FROM\n Tag\n WHERE\n Tag = ?;\n `\n\n\treturn helpers.SqlExecute(dbConn, transaction, stmt, tag)\n}", "title": "" }, { "docid": "f46faaf10e7c075df6027544bd09ae28", "score": "0.5915736", "text": "func (m *MockLocalRepo) TagDelete(arg0 string) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"TagDelete\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "3ff52331680a66451fc005140fe55629", "score": "0.590146", "text": "func Tags_delete () {\n\n // DELETE /tags/{tag_id}.json\n\n }", "title": "" }, { "docid": "008ea964b96c91b0480c9cf5ac8e9ed9", "score": "0.5895622", "text": "func AssertIamPolicyDeleted(t *testing.T, actualIamPolicyARN string, env EnvVars) {\n\terr := AssertIamPolicyExistsE(t, env.AWSRegion, actualIamPolicyARN)\n\tassert.Error(t, err, \"resource hasn't been deleted\")\n}", "title": "" }, { "docid": "0fb2fd1066e3c7ac3ecee0c22b45f47a", "score": "0.5877114", "text": "func ReqDeleteTag(ut string, req []llrp.TagRecord) string {\n\t// TODO: success/fail notification per tag\n\tfailed := false\n\tfor _, t := range req {\n\t\ttag, err := llrp.NewTag(&llrp.TagRecord{\n\t\t\tPCBits: t.PCBits,\n\t\t\tEPC: t.EPC,\n\t\t})\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tdelete := TagManager{\n\t\t\tAction: DeleteTags,\n\t\t\tTags: []*llrp.Tag{tag},\n\t\t}\n\t\ttagManagerChannel <- delete\n\t}\n\tif failed {\n\t\tlog.Warnf(\"failed %v %v\", ut, req)\n\t\treturn \"error\"\n\t}\n\tlog.Debugf(\"%v %v\", ut, req)\n\treturn ut\n}", "title": "" }, { "docid": "824cc9197bd710016e68b82c9404bba8", "score": "0.5832474", "text": "func AssertVpcDeleted(t *testing.T, actualVpcID string, env EnvVars) {\n\t_, err := aws.GetVpcByIdE(t, actualVpcID, env.AWSRegion)\n\tassert.Error(t, err, \"resource hasn't been deleted\")\n}", "title": "" }, { "docid": "fa67157db60e326c3ccde1faa40bde23", "score": "0.5817582", "text": "func (client TagClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),\n\t\tautorest.ByClosing())\n\tresult.Response = resp\n\treturn\n}", "title": "" }, { "docid": "00022d6692089b698210b47ed6ae10eb", "score": "0.58163315", "text": "func (o *Tag) Delete(exec boil.Executor) error {\n\tif o == nil {\n\t\treturn errors.New(\"public: no Tag provided for delete\")\n\t}\n\n\tif err := o.doBeforeDeleteHooks(exec); err != nil {\n\t\treturn err\n\t}\n\n\targs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), tagPrimaryKeyMapping)\n\tquery := \"DELETE FROM \\\"tag\\\" WHERE \\\"id\\\"=$1\"\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintln(boil.DebugWriter, query)\n\t\tfmt.Fprintln(boil.DebugWriter, args...)\n\t}\n\n\t_, err := exec.Exec(query, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"public: unable to delete from tag\")\n\t}\n\n\tif err := o.doAfterDeleteHooks(exec); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "9bf121ee17c00b9998a6c85e08337669", "score": "0.5803559", "text": "func (mr *MockShortURLMockRecorder) Delete(ctx, shortCode interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockShortURL)(nil).Delete), ctx, shortCode)\n}", "title": "" }, { "docid": "e4d6a1337f08f4ff21e070dcd3547002", "score": "0.58025867", "text": "func (mr *MockMessageHandlerMockRecorder) HandleDelete() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"HandleDelete\", reflect.TypeOf((*MockMessageHandler)(nil).HandleDelete))\n}", "title": "" }, { "docid": "78b83a729d4d1c5028e1b247c75a879d", "score": "0.5770313", "text": "func (c *remoteClient) DeleteTag(key, value string) error {\n\trequest := tag.NewDeleteTagRequest()\n\trequest.TagKey = &key\n\trequest.TagValue = &value\n\n\t_, err := c.tagClient.DeleteTag(request)\n\tlog.Printf(\"[DEBUG] delete tag %s:%s: error: %v\", key, value, err)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to delete tag: %s -> %s: %s\", key, value, err)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "320c4c2d2a722305e56fdea8f08a5628", "score": "0.5719422", "text": "func (mr *MockOVSBridgeClientMockRecorder) Delete() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockOVSBridgeClient)(nil).Delete))\n}", "title": "" }, { "docid": "829e03ed4602bbe87403f04077fcb2bf", "score": "0.57144475", "text": "func (client BaseClient) DeleteAcrTagResponder(resp *http.Response) (result autorest.Response, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tclient.ByInspecting(),\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),\n\t\tautorest.ByClosing())\n\tresult.Response = resp\n\treturn\n}", "title": "" }, { "docid": "9c79403cd79a932cd1eb79bfa6390f65", "score": "0.57124376", "text": "func (c *TagClient) Delete() *TagDelete {\n\tmutation := newTagMutation(c.config, OpDelete)\n\treturn &TagDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}\n}", "title": "" }, { "docid": "37d0b3919cf07529ccc9c720a29922a0", "score": "0.5709331", "text": "func (re *Revision) DeleteTag(t *Tag) bool {\n\ti, ok := re.getTagIndex(t)\n\tif ok {\n\t\tre.Tags = append(re.Tags[:i], re.Tags[i+1:]...)\n\t}\n\treturn ok\n}", "title": "" }, { "docid": "bc9ba5c757a9f28351768e03508bc54a", "score": "0.5692468", "text": "func (a *TagsApiService) TagsDelete(ctx context.Context, name string, contentType string, accept string) (Tag, *http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = strings.ToUpper(\"Delete\")\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t \tsuccessPayload Tag\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/tags/{name}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"name\"+\"}\", fmt.Sprintf(\"%v\", name), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{ \"application/json\", }\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\n\t\t\"application/json\",\n\t\t}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tlocalVarHeaderParams[\"Content-Type\"] = parameterToString(contentType, \"\")\n\tlocalVarHeaderParams[\"Accept\"] = parameterToString(accept, \"\")\n\tif ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {\n\t\t\tvar key string\n\t\t\tif auth.Prefix != \"\" {\n\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t} else {\n\t\t\t\tkey = auth.Key\n\t\t\t}\n\t\t\tlocalVarHeaderParams[\"x-api-key\"] = key\n\t\t}\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn successPayload, nil, err\n\t}\n\n\tlocalVarHttpResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHttpResponse == nil {\n\t\treturn successPayload, localVarHttpResponse, err\n\t}\n\tdefer localVarHttpResponse.Body.Close()\n\tif localVarHttpResponse.StatusCode >= 300 {\n\t\tbodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)\n\t\treturn successPayload, localVarHttpResponse, reportError(\"Status: %v, Body: %s\", localVarHttpResponse.Status, bodyBytes)\n\t}\n\n\tif err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {\n\t\treturn successPayload, localVarHttpResponse, err\n\t}\n\n\n\treturn successPayload, localVarHttpResponse, err\n}", "title": "" }, { "docid": "5b5540fcff4ca66f2d6386531f5a87eb", "score": "0.56474674", "text": "func (client BaseClient) DeleteAcrTagMetadataResponder(resp *http.Response) (result autorest.Response, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tclient.ByInspecting(),\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),\n\t\tautorest.ByClosing())\n\tresult.Response = resp\n\treturn\n}", "title": "" }, { "docid": "cdbe50d23e8da1aa0f151eaf078d2b0c", "score": "0.5647296", "text": "func (mr *MockAlertManagerSilencerMockRecorder) Delete(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockAlertManagerSilencer)(nil).Delete), arg0)\n}", "title": "" }, { "docid": "3ebd7540e432036a2c6826e0ac240994", "score": "0.56446815", "text": "func DeleteTag(c *gin.Context) {\n\tmessages := msg.GetMessages(c)\n\tuser := router.GetUser(c)\n\tid, _ := strconv.ParseInt(c.Query(\"id\"), 10, 32)\n\t// Retrieve the torrent\n\ttorrent, err := torrents.FindByID(uint(id))\n\n\t// If torrent not found, display 404\n\tif err != nil {\n\t\tc.Status(http.StatusNotFound)\n\t\treturn\n\t}\n\n\t// We load tags for user and torrents\n\tuser.LoadTags(torrent)\n\n\ttagForm := &tagsValidator.CreateForm{c.Query(\"tag\"), c.Query(\"type\")}\n\tif c.Query(\"tag\") != \"\" && user.ID > 0 {\n\t\tvalidator.ValidateForm(tagForm, messages)\n\n\t\tif !messages.HasErrors() {\n\t\t\tfor _, tag := range user.Tags {\n\t\t\t\tif tag.Tag == tagForm.Tag && tag.Type == tagForm.Type {\n\t\t\t\t\t_, err := tag.Delete()\n\t\t\t\t\tlog.CheckError(err)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif _, ok := c.GetQuery(\"json\"); ok {\n\t\tapiUtils.ResponseHandler(c, tagForm)\n\t\treturn\n\t}\n\tc.Redirect(http.StatusSeeOther, fmt.Sprintf(\"/view/%d\", id))\n}", "title": "" }, { "docid": "3e3bb2f0619b917a84b1a1d80722e0db", "score": "0.5636192", "text": "func (mr *MockEndpointClientMockRecorder) Delete(arg0, arg1, arg2 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockEndpointClient)(nil).Delete), arg0, arg1, arg2)\n}", "title": "" }, { "docid": "aef0dc13c9e347ad7612c3716997d0f6", "score": "0.5629399", "text": "func (mr *MockVirtualNetworksClientAPIMockRecorder) Delete(arg0, arg1, arg2 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockVirtualNetworksClientAPI)(nil).Delete), arg0, arg1, arg2)\n}", "title": "" }, { "docid": "ccdd5ddfdcded3816c7b67426e9f310d", "score": "0.5625971", "text": "func (DBConnection *MariaDBPlugin) DeleteTag(TagID uint64) error {\n\t//Ensure not in use\n\tvar useCount int\n\tif err := DBConnection.DBHandle.QueryRow(\"SELECT COUNT(*) AS UseCount FROM ImageTags WHERE TagID = ?\", TagID).Scan(&useCount); err != nil {\n\t\tlogging.WriteLog(logging.LogLevelError, \"MariaDBPlugin/DeleteTag\", \"0\", logging.ResultFailure, []string{\"Failed to get tag use information\", err.Error()})\n\t\treturn errors.New(\"failed to check tag to delete usage\")\n\t}\n\n\tif useCount > 0 {\n\t\tlogging.WriteLog(logging.LogLevelError, \"MariaDBPlugin/DeleteTag\", \"0\", logging.ResultFailure, []string{\"Tag to delete is still in use\", strconv.FormatUint(TagID, 10), \"in use\", strconv.Itoa(useCount)})\n\t\treturn errors.New(\"tag to delete is still in use\")\n\t}\n\n\t//Delete\n\t_, err := DBConnection.DBHandle.Exec(\"DELETE FROM Tags WHERE ID=?;\", TagID)\n\tif err != nil {\n\t\tlogging.WriteLog(logging.LogLevelError, \"MariaDBPlugin/DeleteTag\", \"0\", logging.ResultFailure, []string{\"Failed to delete tag\", err.Error(), strconv.FormatUint(TagID, 10)})\n\t} else {\n\t\tlogging.WriteLog(logging.LogLevelError, \"MariaDBPlugin/DeleteTag\", \"0\", logging.ResultSuccess, []string{\"Tag deleted\", strconv.FormatUint(TagID, 10)})\n\t}\n\treturn err\n}", "title": "" }, { "docid": "1f1cb672d26257126a2ba7151e9baf99", "score": "0.5622924", "text": "func (mr *MockCLIClientMockRecorder) Delete(ctx, indexName, docID, version interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockCLIClient)(nil).Delete), ctx, indexName, docID, version)\n}", "title": "" }, { "docid": "30240b9c85396e98b508b2bdbdedb585", "score": "0.5610761", "text": "func matchRepoTagDelete(req *http.Request) bool {\n\tif req.Method != http.MethodDelete {\n\t\treturn false\n\t}\n\n\tif inWhiteList(req) {\n\t\treturn false\n\t}\n\n\tre := regexp.MustCompile(tagURL)\n\ts := re.FindStringSubmatch(req.URL.Path)\n\tif len(s) == 3 {\n\t\treturn true\n\t}\n\n\tre = regexp.MustCompile(repoURL)\n\ts = re.FindStringSubmatch(req.URL.Path)\n\tif len(s) == 2 {\n\t\treturn true\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "671e8f9c9e56cfa7acf5aa2abc954111", "score": "0.5601598", "text": "func (mr *MockFlowOperationsMockRecorder) Delete(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockFlowOperations)(nil).Delete), arg0)\n}", "title": "" }, { "docid": "ca1eb3e506f7c43949989c7b8c0c65a5", "score": "0.5578842", "text": "func (a *IamOrganisationPolicyApiService) IamOrganisationPolicyTagDelete(ctx context.Context, organisationId string, policyId string, tagId string) ApiIamOrganisationPolicyTagDeleteRequest {\n\treturn ApiIamOrganisationPolicyTagDeleteRequest{\n\t\tApiService: a,\n\t\tctx: ctx,\n\t\torganisationId: organisationId,\n\t\tpolicyId: policyId,\n\t\ttagId: tagId,\n\t}\n}", "title": "" }, { "docid": "1cd044cfc66f8a44ce4e08557c80d3eb", "score": "0.55662906", "text": "func DeleteTag(c *gin.Context) {\n\tmessages := msg.GetMessages(c)\n\tuser := router.GetUser(c)\n\tid, _ := strconv.ParseInt(c.Query(\"id\"), 10, 32)\n\t// Retrieve the torrent\n\ttorrent, err := torrents.FindByID(uint(id))\n\n\t// If torrent not found, display 404\n\tif err != nil {\n\t\tc.Status(http.StatusNotFound)\n\t\treturn\n\t}\n\n\t// We load tags for user and torrents\n\tuser.LoadTags(torrent)\n\ttorrent.LoadTags()\n\n\tif c.Query(\"tag\") != \"\" && user.ID > 0 {\n\t\ttagForm := &tagsValidator.CreateForm{c.Query(\"tag\"), c.Query(\"type\")}\n\n\t\tvalidator.ValidateForm(tagForm, messages)\n\n\t\tif !messages.HasErrors() {\n\t\t\tfor _, tag := range user.Tags {\n\t\t\t\tif tag.Tag == tagForm.Tag && tag.Type == tagForm.Type {\n\t\t\t\t\ttagRef := &models.Tag{tag.TorrentID, tag.UserID, tag.Tag, tag.Type, tag.Weight, tag.Accepted, tag.Total}\n\t\t\t\t\t_, err := tag.Delete()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.CheckError(err)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tif _, ok := c.GetQuery(\"json\"); ok {\n\t\t\t\t\t\tapiUtils.ResponseHandler(c, tagRef)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif _, ok := c.GetQuery(\"json\"); ok {\n\t\tapiUtils.ResponseHandler(c)\n\t\treturn\n\t}\n\tc.Redirect(http.StatusSeeOther, fmt.Sprintf(\"/view/%d\", id))\n}", "title": "" }, { "docid": "3572615e53a65c5784a2194fa5ace0a5", "score": "0.55652475", "text": "func (cl *Client) VolumeTagsDelete(ctx context.Context, vta *csp.VolumeTagArgs) (*csp.Volume, error) {\n\t// TBD: fill this in\n\treturn nil, nil // fake success\n}", "title": "" }, { "docid": "dc089c96caa860e5f81ad2c2b6b2169c", "score": "0.55644464", "text": "func IsDelete(operation string) bool {\n\treturn isRequestedOperation(operation, \"delete\")\n}", "title": "" }, { "docid": "97254d0a01000c5178c6699d1186f652", "score": "0.55622154", "text": "func (mr *MockReconcilerMockRecorder) Delete(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockReconciler)(nil).Delete), arg0)\n}", "title": "" }, { "docid": "5c36dd05de5e2f16fc6eedec2725e367", "score": "0.5559775", "text": "func (a *IamProjectGroupApiService) IamProjectGroupTagDelete(ctx context.Context, projectId string, groupId string, tagId string) ApiIamProjectGroupTagDeleteRequest {\n\treturn ApiIamProjectGroupTagDeleteRequest{\n\t\tApiService: a,\n\t\tctx: ctx,\n\t\tprojectId: projectId,\n\t\tgroupId: groupId,\n\t\ttagId: tagId,\n\t}\n}", "title": "" }, { "docid": "7d83d069c343593955cc4b004cd679f1", "score": "0.55501354", "text": "func (mr *MockIngredienteServiceMockRecorder) Delete(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockIngredienteService)(nil).Delete), arg0)\n}", "title": "" }, { "docid": "c46faefc4c484071f68d675c7dc0af28", "score": "0.5548074", "text": "func TestDelete(t *testing.T) {\n\tif testing.Short() {\n\t\tt.SkipNow()\n\t}\n\tt.Parallel()\n\n\t// Create SiaFileSet with SiaFile\n\tentry, _, _ := newTestSiaFileSetWithFile()\n\t// Delete file.\n\tif err := entry.Delete(); err != nil {\n\t\tt.Fatal(\"Failed to delete file\", err)\n\t}\n\t// Check if file was deleted and if deleted flag was set.\n\tif !entry.Deleted() {\n\t\tt.Fatal(\"Deleted flag was not set correctly\")\n\t}\n\tif _, err := os.Open(entry.siaFilePath); !os.IsNotExist(err) {\n\t\tt.Fatal(\"Expected a file doesn't exist error but got\", err)\n\t}\n}", "title": "" }, { "docid": "c6d5313c434e8fa1276a7efda258cb97", "score": "0.5537223", "text": "func (mr *MockArticlesUsecaseMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockArticlesUsecase)(nil).Delete), arg0, arg1)\n}", "title": "" }, { "docid": "09234baa095f142e956167dc8509fd09", "score": "0.55320007", "text": "func (mr *MockVolumeClientMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockVolumeClient)(nil).Delete), arg0, arg1)\n}", "title": "" }, { "docid": "72294bf1fb4a5f0c2ea3535929658a75", "score": "0.55295306", "text": "func (c *TagsService) Delete(ctx context.Context, id int, params interface{}) (*Tag, *Response, error) {\n\tvar deleted Tag\n\tentityURL := fmt.Sprintf(\"tags/%v\", id)\n\tresp, err := c.Client.Delete(ctx, entityURL, params, &deleted)\n\treturn &deleted, resp, err\n}", "title": "" }, { "docid": "2a432ed89a691ab428f1033e0c32e468", "score": "0.55278707", "text": "func (o *Tag) Delete(exec boil.Executor) error {\n\tif o == nil {\n\t\treturn errors.New(\"mdbmdbmodels: no Tag provided for delete\")\n\t}\n\n\targs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), tagPrimaryKeyMapping)\n\tsql := \"DELETE FROM \\\"tags\\\" WHERE \\\"id\\\"=$1\"\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintln(boil.DebugWriter, sql)\n\t\tfmt.Fprintln(boil.DebugWriter, args...)\n\t}\n\n\t_, err := exec.Exec(sql, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"mdbmdbmodels: unable to delete from tags\")\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "0032c7c88b94e918b9860bfb6ca34d1f", "score": "0.55081", "text": "func (s *TagsService) DeleteTag(ctx context.Context, categoryExternalID string, tagExternalID string) (*Response, error) {\n\tu := fmt.Sprintf(\"tags/categories/%v/tags/%v\", categoryExternalID, tagExternalID)\n\treq, err := s.client.NewRequest(\"DELETE\", u, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn s.client.Do(ctx, req, nil)\n}", "title": "" }, { "docid": "344d10d5cca7919a4a4f47ed8b30c97b", "score": "0.54990983", "text": "func (mr *MockHttpCommunicationsMockRecorder) Delete(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockHttpCommunications)(nil).Delete), arg0)\n}", "title": "" }, { "docid": "1873927a768afc629c7cd0de83507c0c", "score": "0.5482444", "text": "func (mr *MockHorizontalPodAutoscalerInterfaceMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockHorizontalPodAutoscalerInterface)(nil).Delete), arg0, arg1)\n}", "title": "" }, { "docid": "ffd402e63b3bc052163a707f8bebb1f8", "score": "0.5476515", "text": "func (mr *MockPodServiceMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockPodService)(nil).Delete), arg0, arg1)\n}", "title": "" }, { "docid": "170986c825632dcd840d4d420ed22965", "score": "0.5473241", "text": "func AssertBucketDeleted(t *testing.T, actualBucketName string, env EnvVars) {\n\terr := aws.AssertS3BucketExistsE(t, env.AWSRegion, actualBucketName)\n\tassert.Error(t, err, \"resource hasn't been deleted\")\n}", "title": "" }, { "docid": "e1ca84d07456b6291b605f3fd11d7567", "score": "0.54708445", "text": "func (m *MockWorkitemtrackingClient) DeleteTag(arg0 context.Context, arg1 workitemtracking.DeleteTagArgs) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"DeleteTag\", arg0, arg1)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "title": "" }, { "docid": "0083b55895b901caba55320192750a78", "score": "0.54690963", "text": "func (mr *MockInstanceMockRecorder) Delete(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockInstance)(nil).Delete), arg0, arg1, arg2, arg3)\n}", "title": "" }, { "docid": "9ddbea270a9f61bf3232e5264862ebc7", "score": "0.54575104", "text": "func (w *ServerInterfaceWrapper) DeletePatientTag(ctx echo.Context) error {\n\tvar err error\n\t// ------------- Path parameter \"clinicId\" -------------\n\tvar clinicId ClinicId\n\n\terr = runtime.BindStyledParameterWithLocation(\"simple\", false, \"clinicId\", runtime.ParamLocationPath, ctx.Param(\"clinicId\"), &clinicId)\n\tif err != nil {\n\t\treturn echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf(\"Invalid format for parameter clinicId: %s\", err))\n\t}\n\n\t// ------------- Path parameter \"patientTagId\" -------------\n\tvar patientTagId PatientTagId\n\n\terr = runtime.BindStyledParameterWithLocation(\"simple\", false, \"patientTagId\", runtime.ParamLocationPath, ctx.Param(\"patientTagId\"), &patientTagId)\n\tif err != nil {\n\t\treturn echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf(\"Invalid format for parameter patientTagId: %s\", err))\n\t}\n\n\tctx.Set(SessionTokenScopes, []string{})\n\n\t// Invoke the callback with all the unmarshalled arguments\n\terr = w.Handler.DeletePatientTag(ctx, clinicId, patientTagId)\n\treturn err\n}", "title": "" }, { "docid": "676c4c0a212a77912195110ec97dd615", "score": "0.5447061", "text": "func (mr *MockBucketInterfaceMockRecorder) Delete(fileID interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockBucketInterface)(nil).Delete), fileID)\n}", "title": "" }, { "docid": "ec2458933aaa44be8e0fa745aa019beb", "score": "0.54332316", "text": "func (_mr *MockClientMockRecorder) Delete(arg0 interface{}) *gomock.Call {\r\n\treturn _mr.mock.ctrl.RecordCallWithMethodType(_mr.mock, \"Delete\", reflect.TypeOf((*MockClient)(nil).Delete), arg0)\r\n}", "title": "" }, { "docid": "0cc6408baaa4bcbf07faa00004c33682", "score": "0.5432355", "text": "func (mr *MockClientMockRecorder) Delete(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockClient)(nil).Delete), arg0)\n}", "title": "" }, { "docid": "8d41ce1d66a722ab932ea9629540a1bc", "score": "0.5429551", "text": "func Delete(client *golangsdk.ServiceClient, id string, tags []ResourceTag) (r ActionResult) {\n\topts := ActionOpts{\n\t\tTags: tags,\n\t\tAction: \"delete\",\n\t}\n\treturn doAction(client, id, opts)\n}", "title": "" }, { "docid": "09f18779479d6e043114acf1bd1c17da", "score": "0.5426418", "text": "func (mr *MockGitModuleMockRecorder) RefDelete(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"RefDelete\", reflect.TypeOf((*MockGitModule)(nil).RefDelete), arg0)\n}", "title": "" }, { "docid": "d2c536fba4042768a6fa8b53d919359d", "score": "0.542411", "text": "func TestDeleteOK(t *testing.T) {\n\tfor i := 0; i < 2; i++ {\n\t\tw := s3proxytest.ServeDeleteObject(t, r, dummyBucket, dummyFile, \"\")\n\t\tassert.Equal(t, http.StatusOK, w.Code)\n\n\t\tobjmap := unmarshallJSON(t, w.Body.Bytes())\n\t\tassert.Contains(t, objmap[\"response\"], \"ok\")\n\t}\n}", "title": "" }, { "docid": "4f83c9c8c1257e70e8b27f66a8c344d3", "score": "0.54207534", "text": "func (client BaseClient) DeleteTagByIDMethodResponder(resp *http.Response) (result autorest.Response, err error) {\n err = autorest.Respond(\n resp,\n client.ByInspecting(),\n azure.WithErrorUnlessStatusCode(http.StatusOK),\n autorest.ByClosing())\n result.Response = resp\n return\n }", "title": "" }, { "docid": "2c56e4268641e141a4fd4e97b099e2cb", "score": "0.54205024", "text": "func (mr *MockBranchMockRecorder) Delete() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockBranch)(nil).Delete))\n}", "title": "" }, { "docid": "829c2de1016926d61fc3c86ea6376eca", "score": "0.5418486", "text": "func (mr *MockFloatingIPClientMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockFloatingIPClient)(nil).Delete), arg0, arg1)\n}", "title": "" }, { "docid": "9ffe18c4e335860620d8802bd11f3d65", "score": "0.5406545", "text": "func (mr *MockInterfaceMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockInterface)(nil).Delete), arg0, arg1)\n}", "title": "" }, { "docid": "bed3d94a4ecfa7c75f9780518fc31783", "score": "0.54049325", "text": "func (mr *MockUseCaseMockRecorder) Delete(ctx, userID interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockUseCase)(nil).Delete), ctx, userID)\n}", "title": "" }, { "docid": "94727a804303d37afdfcfa44a93a2b03", "score": "0.540287", "text": "func (mr *MockVolumeProviderMockRecorder) Delete(volumeID interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockVolumeProvider)(nil).Delete), volumeID)\n}", "title": "" }, { "docid": "098fd98b6dfabe6d71de663613b29157", "score": "0.5400575", "text": "func (mut *MostUsedTag) Deleted() bool {\n\treturn mut._deleted\n}", "title": "" }, { "docid": "18deec65a2d1132c52b170f543d43602", "score": "0.5387368", "text": "func (mr *MockRouteTableClientMockRecorder) Delete(arg0, arg1, arg2 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockRouteTableClient)(nil).Delete), arg0, arg1, arg2)\n}", "title": "" }, { "docid": "4dbf14c00d6a232decb16368c6b6b9c6", "score": "0.5371556", "text": "func (mr *MockPostRepositoryMockRecorder) Delete(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockPostRepository)(nil).Delete), arg0)\n}", "title": "" }, { "docid": "2c4d1526421bdec711256714280fb6a3", "score": "0.5345626", "text": "func (mr *MockStorageMockRecorder) Delete(ctx, runner, id interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockStorage)(nil).Delete), ctx, runner, id)\n}", "title": "" }, { "docid": "488b0ee8d8648fa155f0c4b9dc0e1ca2", "score": "0.5337331", "text": "func (mr *MockAppsServiceMockRecorder) Delete(appID interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockAppsService)(nil).Delete), appID)\n}", "title": "" }, { "docid": "fae18b9ba66a3ab0f68600449f56b7e9", "score": "0.53350925", "text": "func (o *Tag) Delete(db *gorm.DB) error {\n\treturn db.Delete(o).Error\n}", "title": "" }, { "docid": "e03bf3fa8e191524a1b6921058d70bb4", "score": "0.53267264", "text": "func (is *ItemService) Delete(itemID, eTag string) (bool, *http.Response, error) {\n\trequestHeaders := make(map[string]string)\n\tif eTag != \"\" {\n\t\trequestHeaders[\"if-match\"] = eTag\n\t}\n\n\tpath := fmt.Sprintf(\"/drive/items/%s\", itemID)\n\treq, err := is.newRequest(\"DELETE\", path, requestHeaders, nil)\n\tif err != nil {\n\t\treturn false, nil, err\n\t}\n\n\tresp, err := is.do(req, nil)\n\tif err != nil {\n\t\treturn false, resp, err\n\t}\n\n\treturn (resp.StatusCode == statusNoContent), resp, err\n}", "title": "" }, { "docid": "950b567799af2e53edc0773adf0c5953", "score": "0.5324537", "text": "func (mr *MockMessageRepositoryMockRecorder) Delete(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockMessageRepository)(nil).Delete), arg0)\n}", "title": "" }, { "docid": "e095759a860fb9b734f3fb4e92041623", "score": "0.5321438", "text": "func (client BaseClient) DeleteTagByIDMethod(ctx context.Context) (result autorest.Response, err error) {\n if tracing.IsEnabled() {\n ctx = tracing.StartSpan(ctx, fqdn + \"/BaseClient.DeleteTagByIDMethod\")\n defer func() {\n sc := -1\n if result.Response != nil {\n sc = result.Response.StatusCode\n }\n tracing.EndSpan(ctx, sc, err)\n }()\n }\n req, err := client.DeleteTagByIDMethodPreparer(ctx)\n if err != nil {\n err = autorest.NewErrorWithError(err, \".BaseClient\", \"DeleteTagByIDMethod\", nil , \"Failure preparing request\")\n return\n }\n\n resp, err := client.DeleteTagByIDMethodSender(req)\n if err != nil {\n result.Response = resp\n err = autorest.NewErrorWithError(err, \".BaseClient\", \"DeleteTagByIDMethod\", resp, \"Failure sending request\")\n return\n }\n\n result, err = client.DeleteTagByIDMethodResponder(resp)\n if err != nil {\n err = autorest.NewErrorWithError(err, \".BaseClient\", \"DeleteTagByIDMethod\", resp, \"Failure responding to request\")\n }\n\n return\n }", "title": "" }, { "docid": "5356d58ba3c554822d0ca90270bb89e2", "score": "0.5319674", "text": "func (suite *ControllerImplSuite) TestDeletePet() {\n\tsuite.mockPetService.EXPECT().Delete(gomock.Any(), testID).Return(nil)\n\terr := suite.controller.DeletePet(suite.ctx, testID)\n\tsuite.Assert().NoError(err)\n\tsuite.Assert().Equal(http.StatusNoContent, suite.rec.Result().StatusCode)\n}", "title": "" }, { "docid": "c47f2cbd35042db71ba67c63be08929f", "score": "0.53138053", "text": "func (m *VirtualEndpointRequestBuilder) Delete(ctx context.Context, requestConfiguration *VirtualEndpointRequestBuilderDeleteRequestConfiguration)(error) {\n requestInfo, err := m.ToDeleteRequestInformation(ctx, requestConfiguration);\n if err != nil {\n return err\n }\n errorMapping := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.ErrorMappings {\n \"4XX\": i20a3050780ee0b0cde0a884a4f35429a20d60067e3bcda382ec5400079147459.CreateODataErrorFromDiscriminatorValue,\n \"5XX\": i20a3050780ee0b0cde0a884a4f35429a20d60067e3bcda382ec5400079147459.CreateODataErrorFromDiscriminatorValue,\n }\n err = m.BaseRequestBuilder.RequestAdapter.SendNoContent(ctx, requestInfo, errorMapping)\n if err != nil {\n return err\n }\n return nil\n}", "title": "" }, { "docid": "a1091a59a16c6c5969138b1cd05e0fe7", "score": "0.53129107", "text": "func (mr *MockServiceMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockService)(nil).Delete), arg0, arg1)\n}", "title": "" }, { "docid": "3546bd4f69f5cff9321c2de49d17d331", "score": "0.530327", "text": "func (mr *MockLocalRepoMockRecorder) RefDelete(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"RefDelete\", reflect.TypeOf((*MockLocalRepo)(nil).RefDelete), arg0)\n}", "title": "" }, { "docid": "caacb19f0ab3fe049d1ebad0731e6755", "score": "0.5302543", "text": "func (mr *MockPermissionClientMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockPermissionClient)(nil).Delete), arg0, arg1)\n}", "title": "" }, { "docid": "09eef2f9e6b67f67c176ad73b1701a76", "score": "0.5300862", "text": "func (mut *MostUsedTag) Delete(db XODB) error {\n\tvar err error\n\n\t// if doesn't exist, bail\n\tif !mut._exists {\n\t\treturn nil\n\t}\n\n\t// if deleted, bail\n\tif mut._deleted {\n\t\treturn nil\n\t}\n\n\t// sql query\n\tconst sqlstr = `DELETE FROM trackit.most_used_tags WHERE id = ?`\n\n\t// run query\n\tXOLog(sqlstr, mut.ID)\n\t_, err = db.Exec(sqlstr, mut.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// set deleted\n\tmut._deleted = true\n\n\treturn nil\n}", "title": "" }, { "docid": "e0214761fa0f08b87f41c34890962080", "score": "0.5300571", "text": "func (mr *MockClientMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockClient)(nil).Delete), arg0, arg1)\n}", "title": "" }, { "docid": "688f1d59a5465bfc8446c11924ae29fe", "score": "0.52998936", "text": "func (mr *MockResourceGroupsClientMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockResourceGroupsClient)(nil).Delete), arg0, arg1)\n}", "title": "" }, { "docid": "5d57446765e37683638dea4b7df1740d", "score": "0.5296837", "text": "func DELETE(entity interface{}, afterKeyword Expression) Expression {\n\treturn &PrefixedExp{\"DELETE\", afterKeyword, \"\", nil}\n}", "title": "" }, { "docid": "965c4682b43b634f6800d8548f83290d", "score": "0.52923983", "text": "func (mr *MockTodoAPIMockRecorder) Delete(w, r interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockTodoAPI)(nil).Delete), w, r)\n}", "title": "" }, { "docid": "bbe36b71abadb9d70529da328d5e7bbc", "score": "0.5292396", "text": "func (mr *MockRegistryServiceClientMockRecorder) Delete(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\tvarargs := append([]interface{}{arg0, arg1}, arg2...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockRegistryServiceClient)(nil).Delete), varargs...)\n}", "title": "" }, { "docid": "974980cbaccc6123ef9679c4dc0411cc", "score": "0.529196", "text": "func (c *CatalogMock) Delete(ID string) error {\n\targs := c.Called(ID)\n\treturn args.Error(0)\n}", "title": "" }, { "docid": "705a6eff983083e21d8d5cde3de3856c", "score": "0.5291185", "text": "func (mr *MockDbConnectorMockRecorder) Delete(arg0 interface{}, arg1 ...interface{}) *gomock.Call {\n\tvarargs := append([]interface{}{arg0}, arg1...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Delete\", reflect.TypeOf((*MockDbConnector)(nil).Delete), varargs...)\n}", "title": "" } ]
e6ac1d50894b43692c761aa022f7a8ce
FindFistString returns the first index of specified element of type string. If can't find anything, return 1 and false
[ { "docid": "774411de76595401a50673ccf6fe0fd3", "score": "0.8707439", "text": "func FindFistString(s []string, a string) (int, bool) {\n\treturn findFist(s, a)\n}", "title": "" } ]
[ { "docid": "0e91bab8a44085f6b7179ed4a25ee034", "score": "0.7297446", "text": "func findString(list []string, p string) (bool, int){\n\tfor ind, l := range list{\n\t\tif l == p {\n\t\t\treturn true, ind\n\t\t}\n\t}\n\treturn false, -1\n}", "title": "" }, { "docid": "7c706ee0f5fb56dbc0c9455853f961a2", "score": "0.7212161", "text": "func findString(slice []string, val string) (int, bool) {\n\tfor i, item := range slice {\n\t\tif item == val {\n\t\t\treturn i, true\n\t\t}\n\t}\n\treturn -1, false\n}", "title": "" }, { "docid": "5c7af63ce1777985501afe25feefc0cf", "score": "0.71088225", "text": "func FindString(slice []string, val string) (int, bool) {\n\tfor i, item := range slice {\n\t\tif item == val {\n\t\t\treturn i, true\n\t\t}\n\t}\n\treturn -1, false\n}", "title": "" }, { "docid": "a21bcaa0ef18b3e9eccd3aab0dca7f03", "score": "0.6833831", "text": "func FindFistByte(s []byte, a byte) (int, bool) {\n\treturn findFist(s, a)\n}", "title": "" }, { "docid": "0a84415693ee77ef7b8faf6d1cbbba49", "score": "0.67211205", "text": "func FindFistInt(s []int, a int) (int, bool) {\n\treturn findFist(s, a)\n}", "title": "" }, { "docid": "5be7fdd9bedf32d36d768fa37f6f0dd1", "score": "0.6661432", "text": "func posString(slice []string, element string) int {\n\tfor index, elem := range slice {\n\t\tif elem == element {\n\t\t\treturn index\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "5be7fdd9bedf32d36d768fa37f6f0dd1", "score": "0.6661432", "text": "func posString(slice []string, element string) int {\n\tfor index, elem := range slice {\n\t\tif elem == element {\n\t\t\treturn index\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "7438bdd8fcaf7003663569e328b08f76", "score": "0.6582849", "text": "func IndexStr(s []string, t string) int {\n for i, v := range s {\n if v == t {\n return i\n }\n }\n\n return -1\n}", "title": "" }, { "docid": "babd880bf9443a98476bc326f75ff059", "score": "0.65473676", "text": "func find(ss []string, s string) int {\n\tfor i, j := range ss {\n\t\tif j == s {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "f2533ef73a06d88a206e01443da14f74", "score": "0.650652", "text": "func First(n int, s string) (first string, ok bool) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tfirst, ok = \"\", false\n\t\t}\n\t}()\n\treturn UnsafeFirst(n, s), true\n}", "title": "" }, { "docid": "3f08c85f430ff62b3609b923c2f35a0d", "score": "0.6501608", "text": "func findFirst2(s string) (int, int) {\n\t// len can increase 98 99 100\n\tfor l := 1; l <= 6; l++ {\n\t\t//a := s[0 : l+1]\n\t\tn, err := strconv.Atoi(s[0 : l+1])\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tif check(s[l+1:], n+1) {\n\t\t\treturn n, n + 1\n\t\t}\n\t\tif check(s[l+1:], n+2) {\n\t\t\treturn n, n + 1\n\t\t}\n\t}\n\treturn -1, -1\n}", "title": "" }, { "docid": "a3d98743839a1f65a7f36c9fad5c4b1a", "score": "0.64961565", "text": "func First(n int, s string) (first string, ok bool) {\n\tok = n <= len(s)\n\tif ok {\n\t\tfirst = UnsafeFirst(n, s)\n\t}\n\treturn\n}", "title": "" }, { "docid": "206489355e94b7f5c12634783d91b9b3", "score": "0.6437897", "text": "func (obj *rule) FindFirst(str string) (string, bool, error) {\n\tout := []string{}\n\tfor _, oneSection := range obj.sections {\n\t\tfound, err := oneSection.FindFirst(str)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tif found != \"\" {\n\t\t\tindex := strings.Index(str, found)\n\t\t\tif index != 0 {\n\t\t\t\treturn \"\", false, nil\n\t\t\t}\n\n\t\t\tout = append(out, found)\n\t\t\tstr = str[len(found):]\n\t\t\tcontinue\n\t\t}\n\n\t\treturn \"\", false, nil\n\t}\n\n\treturn strings.Join(out, \"\"), true, nil\n}", "title": "" }, { "docid": "16ed5b836b5e54f9c09257268f6c1e9c", "score": "0.64294225", "text": "func FindInStringSlice(s []string, e string) int {\n\tif len(e) < 1 {\n\t\treturn -1\n\t}\n\tfor i, a := range s {\n\t\tif strings.Contains(a, e) {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "9fd7e2e11109b740bc9a344e006b6106", "score": "0.6394502", "text": "func SearchString(arr []string, elem string) bool {\n\tfound := false\n\tif len(arr) == 0 {\n\t\treturn found\n\t}\n\n\tif elem == \"\" {\n\t\treturn found\n\t}\n\n\tfor _, s := range arr {\n\t\tif s == elem {\n\t\t\tfound = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn found\n}", "title": "" }, { "docid": "ed9103636cf83ffdfa1e84ad2a03db7a", "score": "0.6372706", "text": "func findIndex(s1 string, s2 string) int {\n\ti := 0\n\tmin := min(len(s1), len(s2))\n\tfor i < min {\n\t\tif s1[i] == s2[i] {\n\t\t\ti++\n\t\t} else {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn i\n}", "title": "" }, { "docid": "ba21219c17f9b429c27729c943ecda54", "score": "0.635043", "text": "func strStr(haystack string, needle string) int {\n hl,nl := len(haystack), len(needle)\n if nl > hl { return -1 }\n for i := 0; i < hl - nl + 1; i += 1 {\n if haystack[i] == needle[0] {\n counter := 1 // First symbol is already checked.\n for j := 1; j < nl; j += 1{\n if needle[j] != haystack[i+j] { break }\n counter += 1\n }\n if nl == counter {\n return i\n }\n }\n }\n return -1\n}", "title": "" }, { "docid": "f6c093278df752d3de763fcea58c4c75", "score": "0.63036346", "text": "func strStr(haystack string, needle string) int {\n\tlengthSub := len(needle)\n\tif lengthSub == 0 {\n\t\treturn 0\n\t}\n\tlength := len(haystack)\n\tdiffLength := length - lengthSub\n\tfor i := 0; i <= diffLength; i++ {\n\t\tif haystack[i:i+lengthSub] == needle {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "44b90a8163ae66361226e36200efc72b", "score": "0.6296012", "text": "func strFound(needle string, hayStack []string) bool {\n\tfor _, str := range hayStack {\n\t\tif str == needle {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "956b332d2658a7d045329849e27e05e0", "score": "0.627833", "text": "func strStr(haystack string, needle string) int {\n\t// 20200817\n\tif needle == \"\" {\n\t\treturn 0\n\t}\n\tif haystack == \"\" {\n\t\treturn -1\n\t}\n\t// 1、标准库法\n\t// 执行耗时:0 ms,击败了100.00% 的Go用户\n\t// 内存消耗:2.3 MB,击败了64.65% 的Go用户\n\t/*\n\t\treturn strings.Index(haystack, needle)*/\n\t// 2、滑动窗口法\n\t// O((N-L)*L)/O(1)\n\t// 执行耗时:0 ms,击败了100.00% 的Go用户\n\t// 内存消耗:2.3 MB,击败了100.00% 的Go用户\n\tn, l := len(haystack), len(needle)\n\tfor start := 0; start < n-l+1; start++ {\n\t\tif haystack[start:start+l] == needle {\n\t\t\treturn start\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "2deef71e169eb36b2b53120f9af55ef1", "score": "0.62634826", "text": "func StringIndexOf(element string, data []string) int {\n\tfor k, v := range data {\n\t\tif element == v {\n\t\t\treturn k\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "cddeeaa6b415f408b32d530acce4729e", "score": "0.6259398", "text": "func strStr(haystack string, needle string) int {\n i,j,index := 0,0,-1\n flag :=0\n if len(needle)==0 {\n return 0\n }\n if len(needle)>len(haystack) {\n return index\n } \n for i=0 ; i<len(haystack) ; i++ {\n if flag==len(needle) {\n return index \n }\n if needle[j]==haystack[i] {\n if(index==-1){\n index=i\n fmt.Println(index)\n }\n flag=flag+1\n j++\n continue\n } else {\n if index!=-1 {\n i=index}\n index=-1\n flag=0;\n j=0;\n continue\n }\n }\n if flag==len(needle) {\n return index\n } else {\n return -1\n }\n}", "title": "" }, { "docid": "89ed359e0c58fb90497b29cd7140a96f", "score": "0.6236428", "text": "func (sops *StrOps) FindFirstNonSpaceChar(\n\ttargetStr string,\n\tstartIndex,\n\tendIndex int,\n\tePrefix string) (\n\tint,\n\terror) {\n\n\tif sops.stringDataMutex == nil {\n\t\tsops.stringDataMutex = new(sync.Mutex)\n\t}\n\n\tsops.stringDataMutex.Lock()\n\n\tdefer sops.stringDataMutex.Unlock()\n\n\tePrefix += \"StrOps.FindFirstNonSpaceChar() \"\n\n\tsOpsElectron := strOpsElectron{}\n\n\treturn sOpsElectron.findFirstNonSpaceChar(\n\t\ttargetStr,\n\t\tstartIndex,\n\t\tendIndex,\n\t\tePrefix)\n}", "title": "" }, { "docid": "4b1da1c9c941ee75b4df939f20a1049e", "score": "0.6230942", "text": "func index(s []byte, t string) int {\n\ti := 0\n\tfor {\n\t\tj := bytes.IndexByte(s[i:], t[0])\n\t\tif j < 0 {\n\t\t\treturn -1\n\t\t}\n\t\ti = i + j\n\t\tif i+len(t) > len(s) {\n\t\t\treturn -1\n\t\t}\n\t\tfor k := 1; k < len(t); k++ {\n\t\t\tif s[i+k] != t[k] {\n\t\t\t\tgoto nomatch\n\t\t\t}\n\t\t}\n\t\treturn i\n\tnomatch:\n\t\ti++\n\t}\n}", "title": "" }, { "docid": "2a6e5b647a78bf1be8279ec1b1087167", "score": "0.6206763", "text": "func First(n int, input string) (string, bool) {\n\tif n > len(input) {\n\t\treturn UnsafeFirst(n, input), false\n\t} else {\n\t\treturn UnsafeFirst(n, input), true\n\t}\n}", "title": "" }, { "docid": "de3ae08cbc82dcd03141da5443efeef6", "score": "0.6190237", "text": "func strStr(haystack string, needle string) int {\n\thaystackLen := len(haystack)\n\tneedleLen := len(needle)\n\tif needleLen > haystackLen {\n\t\treturn -1\n\t}\n\n\tif needleLen == 0 {\n\t\treturn 0\n\t}\n\n\tc := needle[0]\n\tfor i := 0; i <= haystackLen-needleLen; i++ {\n\t\tif haystack[i] != c {\n\t\t\tcontinue\n\t\t}\n\n\t\tif haystack[i:i+needleLen] == needle {\n\t\t\treturn i\n\t\t}\n\t}\n\n\treturn -1\n}", "title": "" }, { "docid": "7313688b7955cb8ca36d8dbb32b0ad98", "score": "0.6164102", "text": "func (tr *Trie) MatchFirstString(input string) *Match {\n\treturn tr.MatchFirst([]byte(input))\n}", "title": "" }, { "docid": "1364b9c7f18b401598d387a528736276", "score": "0.61453265", "text": "func Find(slice []string, val string) (int, bool) {\n for i, item := range slice {\n if item == val {\n return i, true\n }\n }\n return -1, false\n}", "title": "" }, { "docid": "2fe20ce2504afa6c9df4f44346a56281", "score": "0.61419034", "text": "func Index(strs []string, str string) int {\n\tfor i, v := range strs {\n\t\tif v == str {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "9b8ae4f6d8731074cfa62818262b4f4d", "score": "0.61006033", "text": "func (s *sortedString) Index(c string) (int, bool) {\n\t// Define f(-1) == false and f(n) == true.\n\t// Invariant: f(i-1) == false, f(j) == true.\n\ti, j := 0, len(*s)\n\tvar cur string\n\tfor i < j {\n\t\th := i + (j-i)/2 // avoid overflow when computing h\n\t\tcur = (*s)[h]\n\t\t// i ≤ h < j\n\t\tif cur > c {\n\t\t\ti = h + 1 // preserves f(i-1) == false\n\t\t} else if cur == c {\n\t\t\treturn h, true\n\t\t} else {\n\t\t\tj = h // preserves f(j) == true\n\t\t}\n\t}\n\treturn i, false\n}", "title": "" }, { "docid": "e8c7e39339537fc2af3c8142e8d91feb", "score": "0.6076693", "text": "func (tr *Trie) MatchStringFirst(input string) *Match {\n\treturn tr.MatchFirst([]byte(input))\n}", "title": "" }, { "docid": "ffc8f3b8c37c0d20ab0bf998a9c64ba0", "score": "0.606807", "text": "func IndexOfString(strslice []string, val string) int {\n\tfor i, ele := range strslice {\n\t\tif ele == val {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "e72b3cec8c471a54a8ac369c44eb3bf3", "score": "0.6041837", "text": "func (s Str) Index(substr Str) int {\n\tswitch n := len(substr); {\n\tcase n == 0:\n\t\treturn 0\n\tcase n == 1:\n\t\tfor i := range s {\n\t\t\tif s[i] == substr[0] {\n\t\t\t\treturn i\n\t\t\t}\n\t\t}\n\t\treturn -1\n\tcase n == len(s):\n\t\tif s.Equal(substr) {\n\t\t\treturn 0\n\t\t}\n\t\treturn -1\n\tcase n > len(s):\n\t\treturn -1\n\t}\n\n\t// brute force\n\tvar i, j int\n\tfor j < len(substr) && i < len(s) {\n\t\tsi := s[i]\n\t\tbi := substr[j]\n\n\t\ti++\n\n\t\tif si == bi {\n\t\t\tj++\n\t\t} else {\n\t\t\tj = 0\n\t\t}\n\t}\n\n\tif j == len(substr) {\n\t\treturn i - len(substr)\n\t}\n\treturn -1\n\n}", "title": "" }, { "docid": "b795c9126fba4f96ef78cccc4f9a1e36", "score": "0.60390335", "text": "func find(s []string, x string) bool {\n\tfor _, n := range s {\n\t\tif x == n {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "803dbd1bd48122cd0cf380bf02a7c461", "score": "0.6028284", "text": "func contains(s []string, str string) int {\n\tfor k, v := range s {\n\t\tif strings.Contains(v, str) {\n\t\t\treturn k\n\t\t}\n\t}\n\n\treturn -1\n}", "title": "" }, { "docid": "0c744b30a6b0008fcd8975c1e0042f20", "score": "0.5999785", "text": "func strstr(haystack string, needle string) int {\n\n\tif len(haystack) == 0 {\n\t\treturn -1\n\t}\n\tif len(needle) == 0 {\n\t\treturn 0\n\t}\n\n\tih := 0\n\tin := 0\n\tindex := -1\n\tfor ;ih < len(haystack) && in < len(needle); ih++ {\n\t\tfmt.Println(\"cmp\", string(haystack[ih]), ih, string(needle[in]), in)\n\t\tif haystack[ih] == needle[in] {\n\t\t\tif index == -1 {\n\t\t\t\tindex = ih\n\t\t\t}\n\t\t\tin++\n\t\t} else if index != -1 {\n\t\t\tindex = -1\n\t\t\tin = 0\n\t\t\tih--\t//已经匹配到过,又发现后面的不匹配,要回退这个不匹配的字符与needle首字符重新比较,否则会错过一个\n\t\t}\n\t}\n\treturn index\n}", "title": "" }, { "docid": "aa90344eef40bd7d893a85a71e533e67", "score": "0.59944576", "text": "func FindFistBool(s []bool, a bool) (int, bool) {\n\treturn findFist(s, a)\n}", "title": "" }, { "docid": "c2d479283fd2d411087a351728f92210", "score": "0.5992253", "text": "func TestIndexOf(t *testing.T) {\n\tstr := \"hello my friend.\"\n\ts := NewString(str)\n\tis, err := s.IndexOf(\"my\")\n\tif err != nil {\n\t\tt.Errorf(\"TestIndexOf(): got -> %v, want: nil\", err)\n\t}\n\tlog.Println(is)\n}", "title": "" }, { "docid": "3c06b864b5c93f50ffc30988c1b3bdf9", "score": "0.59754324", "text": "func strStr(haystack string, needle string) int {\n\tif len(needle) == 0 {\n\t\treturn 0\n\t}\n\n\tif len(haystack) == 0 {\n\t\treturn -1\n\t}\n\n\tfor i := 0; i < len(haystack); i++ {\n\t\tvar j int\n\t\tfor j = i; j < len(haystack) && j-i < len(needle); j++ {\n\t\t\tif haystack[j] != needle[j-i] {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif j-i == len(needle) {\n\t\t\treturn i\n\t\t}\n\t}\n\n\treturn -1\n}", "title": "" }, { "docid": "fa9809785b7eab11fdc8924b4e39df6f", "score": "0.59591544", "text": "func TestFindString(t *testing.T) {\n\ttarget := stringArray[0]\n\n\tv := Find(stringArray, func(val interface{}) bool {\n\t\treturn val.(string) == target\n\t})\n\n\tif v != target {\n\t\tt.Fatalf(`value :%v does not match :%v`, v, target)\n\t}\n}", "title": "" }, { "docid": "42b3c2b2565fcc96756613a16ecd8fb0", "score": "0.59511685", "text": "func First(n int, s string) (string, bool) {\n\tif n > len(s) {\n\t\treturn \"\", false\n\t}\n\n\treturn s[:n], true\n}", "title": "" }, { "docid": "ad97fc3516a2d7f30455cb23ab9f08ab", "score": "0.5944903", "text": "func IndexOfS(haystack []string, needle string) (int, bool) {\n\tfor i, v := range haystack {\n\t\tif v == needle {\n\t\t\treturn i, true\n\t\t}\n\t}\n\treturn 0, false\n}", "title": "" }, { "docid": "d8d4b2946d2cc0fb0b0dea928039b5a0", "score": "0.59055537", "text": "func (it Item) FindStringKey(key string) (int, bool) {\n\tfor i, v := range it.Strings {\n\t\tif v.Key == key {\n\t\t\treturn i, true\n\t\t}\n\t}\n\treturn 0, false\n}", "title": "" }, { "docid": "bc33515543c1d188c4ae45b02fdf034d", "score": "0.58953035", "text": "func SparseStringSearch(data []string, search string) int {\n\tl, r := 0, len(data)-1\n\tll, lr := l, r\n\tfor l <= r {\n\t\tmid := (l + r) / 2\n\t\tif val := data[mid]; val == search {\n\t\t\treturn mid\n\t\t} else if val == \"\" {\n\t\t\tfor ; data[mid] == \"\"; mid++ {\n\t\t\t}\n\t\t\tif nextval := data[mid]; nextval == search {\n\t\t\t\treturn mid\n\t\t\t} else if search < nextval {\n\t\t\t\tr = mid - 1\n\t\t\t} else {\n\t\t\t\tl = mid + 1\n\t\t\t}\n\t\t\tif r == lr && l == ll {\n\t\t\t\treturn -1\n\t\t\t}\n\t\t} else if search < val {\n\t\t\tr = mid - 1\n\t\t} else {\n\t\t\tl = mid + 1\n\t\t}\n\t\tll = l\n\t\tlr = r\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "59c6521ae96ed96836ac2ce6e6b4eb8c", "score": "0.58895683", "text": "func FindInSlice(slice []string, elem string) int {\n\tfor i := range slice {\n\t\tif slice[i] == elem {\n\t\t\treturn i\n\t\t}\n\t}\n\n\treturn -1\n}", "title": "" }, { "docid": "5403de0e5351987879029a6b77b02534", "score": "0.58797455", "text": "func FindFistInt64(s []int64, a int64) (int, bool) {\n\treturn findFist(s, a)\n}", "title": "" }, { "docid": "b03aa7e843ce6e0be61d4f2e334ca116", "score": "0.5868784", "text": "func Findstrinslice(v string, list []string) bool {\n\n for _, t := range list {\n if v == t { return true }\n }\n\n return false\n}", "title": "" }, { "docid": "46439ee72aa89b8a7260ec5b7f270961", "score": "0.5835215", "text": "func FindFistInt32(s []int32, a int32) (int, bool) {\n\treturn findFist(s, a)\n}", "title": "" }, { "docid": "7f7f8111dbb2ae8a2c64a9f9a6db8ab1", "score": "0.58322287", "text": "func indexOf(str string, pattern string, i int) int {\n\tif i > len(str)-1 {\n\t\treturn -1\n\t}\n\tif i <= 0 {\n\t\treturn strings.Index(str, pattern)\n\t}\n\tind := strings.Index(str[i:], pattern)\n\tif ind == -1 {\n\t\treturn -1\n\t}\n\treturn ind + i\n}", "title": "" }, { "docid": "7e0f2f881b8fe915b3cbae96dc7df500", "score": "0.58294696", "text": "func Find(slice []string, val string) (bool, int) {\n\t//Iterate throug index of a slice\n\tfor i, _ := range slice {\n\t\t//Compare if the string on i index is equal to val string\n\t\tif slice[i] == val {\n\t\t\treturn true, i\n\t\t}\n\t}\n\treturn false, 0\n}", "title": "" }, { "docid": "cf21a06d215c62c06e14c4f30c3341da", "score": "0.581473", "text": "func (s StringSlice) Index(str string) int {\n\tfor i, v := range s {\n\t\tif v == str {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "3c8768c318870a618ca4100413f72547", "score": "0.5811897", "text": "func strStr(haystack string, needle string) int {\n\tm, n := len(haystack), len(needle)\n\tif n == 0 {\n\t\treturn 0\n\t}\n\tfor i := 0; i <= m-n; i++ {\n\t\tvar j int\n\t\tfor j < n {\n\t\t\tif haystack[i+j] != needle[j] {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tj++\n\t\t}\n\t\tif j == n {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "c3f1b266882e0413587b445c40ff638e", "score": "0.5802166", "text": "func scanFirstString(rows *sql.Rows, err error) (string, bool, error) {\n\treturn basestore.ScanFirstString(rows, err)\n}", "title": "" }, { "docid": "e3124e69bec6156caeb45ec69f2f701b", "score": "0.5787846", "text": "func findSlice(re *regexp.Regexp, slice []string) (i int) {\n\tfor i, v := range slice {\n\t\tif (re.FindStringIndex(v) != nil) && i != 0 {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "56457c574195e0fa825d836daab63be3", "score": "0.5773994", "text": "func findPrefix(s string, prefixes []string) int {\n for k,v := range prefixes {\n if strings.HasPrefix(s, v) {\n return k\n }\n }\n return -1\n}", "title": "" }, { "docid": "2707fec9d877a0a7a6fe41ccc8e31732", "score": "0.57635623", "text": "func FindPos(elem string, elemArray []string) int {\n\tfor p, v := range elemArray {\n\t\tif v == elem {\n\t\t\treturn p\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "c9a6fc1e0d956ccc878c232dda25bc88", "score": "0.5743783", "text": "func StrStr(haystack string, needle string) int {\n\tif len(haystack) > 50000 || len(haystack) < 0 || len(needle) > 50000 || len(needle) < 0 {\n\t\treturn 0\n\t}\n\n\t// not contain\n\treturn strings.Index(haystack, needle)\n}", "title": "" }, { "docid": "232c466a82286f0007fc6bf12cc57a5f", "score": "0.5741019", "text": "func Find(a []string, x string) int {\n\tfor i, n := range a {\n\t\tif x == n {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn len(a)\n}", "title": "" }, { "docid": "4fde903cc151c9216395d80a0521c047", "score": "0.5721632", "text": "func indexOf(value string, slice []string) int {\n\tfor p, v := range slice {\n\t\tif (v == value) {\n\t\t\treturn p\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "7936db02cfa964462bdd8c6611b850fa", "score": "0.5721423", "text": "func containsIdx(l []string, e string) int {\n\tfor idx, i := range l {\n\t\tif i == e {\n\t\t\treturn idx\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "3ef535fe15b2256bf517bcad49c312a2", "score": "0.57131535", "text": "func (s String) IndexOf(str string) (int, error) {\n\tindex := strings.Index(s.base, str)\n\tif index == -1 {\n\t\treturn -1, ErrNotFound\n\t}\n\treturn index, nil\n}", "title": "" }, { "docid": "8c17198be951adc6b20dc66cc1228a04", "score": "0.570747", "text": "func FindLastString(s []string, a string) (int, bool) {\n\treturn findLast(s, a)\n}", "title": "" }, { "docid": "3e110d57011cd9a88311f876589fd4e4", "score": "0.57049906", "text": "func Search(s *Set, str string) int {\n\t// TODO: optimize this if it gets used a lot.\n\tn := len(s.Index) - 1\n\tp := sort.Search(n, func(i int) bool {\n\t\treturn s.Elem(i) >= str\n\t})\n\tif p == n || str != s.Elem(p) {\n\t\treturn -1\n\t}\n\treturn p\n}", "title": "" }, { "docid": "93574e48fb1726e171c7b51badec1ee3", "score": "0.56999457", "text": "func Find(slice []string, val string) (int, bool) {\n\tfor i, item := range slice {\n\t\tif item == val {\n\t\t\treturn i, true\n\t\t}\n\t}\n\treturn -1, false\n}", "title": "" }, { "docid": "93574e48fb1726e171c7b51badec1ee3", "score": "0.56999457", "text": "func Find(slice []string, val string) (int, bool) {\n\tfor i, item := range slice {\n\t\tif item == val {\n\t\t\treturn i, true\n\t\t}\n\t}\n\treturn -1, false\n}", "title": "" }, { "docid": "93574e48fb1726e171c7b51badec1ee3", "score": "0.56999457", "text": "func Find(slice []string, val string) (int, bool) {\n\tfor i, item := range slice {\n\t\tif item == val {\n\t\t\treturn i, true\n\t\t}\n\t}\n\treturn -1, false\n}", "title": "" }, { "docid": "93574e48fb1726e171c7b51badec1ee3", "score": "0.56999457", "text": "func Find(slice []string, val string) (int, bool) {\n\tfor i, item := range slice {\n\t\tif item == val {\n\t\t\treturn i, true\n\t\t}\n\t}\n\treturn -1, false\n}", "title": "" }, { "docid": "93574e48fb1726e171c7b51badec1ee3", "score": "0.56999457", "text": "func Find(slice []string, val string) (int, bool) {\n\tfor i, item := range slice {\n\t\tif item == val {\n\t\t\treturn i, true\n\t\t}\n\t}\n\treturn -1, false\n}", "title": "" }, { "docid": "93574e48fb1726e171c7b51badec1ee3", "score": "0.56999457", "text": "func Find(slice []string, val string) (int, bool) {\n\tfor i, item := range slice {\n\t\tif item == val {\n\t\t\treturn i, true\n\t\t}\n\t}\n\treturn -1, false\n}", "title": "" }, { "docid": "b055a900c756af76f6dea726c9e2fb72", "score": "0.5676588", "text": "func indexOf(haystack []string, needle string) int {\n\tfor i, val := range haystack {\n\t\tif val == needle {\n\t\t\treturn i\n\t\t}\n\t}\n\n\treturn len(haystack)\n}", "title": "" }, { "docid": "a285bef1458b2243a5a5b7f4e3143a9e", "score": "0.56732464", "text": "func StringSliceIndexOf(element string, slice []string) int {\n\tfor k, v := range slice {\n\t\tif element == v {\n\t\t\treturn k\n\t\t}\n\t}\n\n\treturn -1\n}", "title": "" }, { "docid": "5853ca3b06b193adb1038ea34954fbbb", "score": "0.5616554", "text": "func findSmallest(data []string) int {\n\tsmallest := data[0]\n\tidx := 0\n\n\tfor i := 1; i < len(data); i++ {\n\t\tif data[i] < smallest {\n\t\t\tsmallest = data[i]\n\t\t\tidx = i\n\t\t}\n\t}\n\n\treturn idx\n}", "title": "" }, { "docid": "7cfa8d03c2782f69eeef0c3dca223b23", "score": "0.5602804", "text": "func FindStringInSlice(val string, slice []string) (isFound bool) {\n\tfor _, item := range slice {\n\t\tif item == val {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "34240ca6c7e8d1df4727c0a13dd8ff68", "score": "0.55918854", "text": "func LatestStringInSlice(symbol string, list []string) (bool, int) {\n\n\t// if starting from the end the symbol is found\n\tfor i := len(list)-1; i >= 0; i-- {\n\n\t\tif strings.EqualFold(symbol, list[i]) {\n\t\t\treturn true, i\n\t\t}\n\n\t}\n\n\treturn false, -1\n\n}", "title": "" }, { "docid": "95a834b7321e96ebc3509aa7384199df", "score": "0.5588403", "text": "func (it Item) FindString(key string) (string, bool) {\n\tfor _, v := range it.Strings {\n\t\tif v.Key == key {\n\t\t\treturn v.Value, true\n\t\t}\n\t}\n\treturn \"\", false\n}", "title": "" }, { "docid": "e500ced78b778f9c4386c26cc98fe46d", "score": "0.5578196", "text": "func (tr *Trie) MatchFirst(input []byte) *Match {\n\tvar match *Match\n\ttr.walk(input, func(end, n int) bool {\n\t\tpos := end - n + 1\n\t\tmatch = &Match{pos: pos, match: input[pos : pos+n]}\n\t\treturn false\n\t})\n\treturn match\n}", "title": "" }, { "docid": "58eea9c68314a7e1225df1376a2a3b77", "score": "0.55727166", "text": "func StringExists(array []string, element string) bool {\n\tfor _, v := range array {\n\t\tif v == element {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "3950c442e030b58074e2ee010a89078b", "score": "0.55658287", "text": "func findOpt(str string, args []string) (string, bool) {\n\tfor _, elem := range args {\n\t\tif strings.Contains(elem, str) {\n\t\t\topt := strings.Split(elem, \"=\")\n\t\t\tif len(opt) > 1 {\n\t\t\t\treturn opt[1], true\n\t\t\t}\n\t\t\treturn \"\", true\n\t\t}\n\t}\n\treturn \"\", false\n}", "title": "" }, { "docid": "0136f3035a8916c6f381b59487ef841e", "score": "0.5562014", "text": "func SliceContainsString(s []string, a string) (int, bool) {\n\tfor i, b := range s {\n\t\tif b == a {\n\t\t\treturn i, true\n\t\t}\n\t}\n\n\treturn -1, false\n}", "title": "" }, { "docid": "f9f60bb0edf2de4e2fe5cc8eaaf21f0c", "score": "0.55616343", "text": "func Index(s, substr string) int {\n\treturn strings.Index(s, substr)\n}", "title": "" }, { "docid": "6278f9a5667a5830d460c1a91915a050", "score": "0.5560651", "text": "func IndexString(s, substr string) int {\n\t// This is a partial copy of strings.Index, here because bytes.IndexAny and bytes.LastIndexAny\n\t// call bytealg.IndexString. Some platforms have an optimized assembly version of this function.\n\t// This implementation is used for those that do not. Although the pure Go implementation here\n\t// works for the case of len(b) > MaxLen, we do not require that its assembly implementation also\n\t// supports the case of len(b) > MaxLen. And we do not guarantee that this function supports the\n\t// case of len(b) > MaxLen.\n\tn := len(substr)\n\tc0 := substr[0]\n\tc1 := substr[1]\n\ti := 0\n\tt := len(s) - n + 1\n\tfails := 0\n\tfor i < t {\n\t\tif s[i] != c0 {\n\t\t\to := IndexByteString(s[i:t], c0)\n\t\t\tif o < 0 {\n\t\t\t\treturn -1\n\t\t\t}\n\t\t\ti += o\n\t\t}\n\t\tif s[i+1] == c1 && s[i:i+n] == substr {\n\t\t\treturn i\n\t\t}\n\t\ti++\n\t\tfails++\n\t\tif fails >= 4+i>>4 && i < t {\n\t\t\t// See comment in src/bytes/bytes.go.\n\t\t\tj := IndexRabinKarp(s[i:], substr)\n\t\t\tif j < 0 {\n\t\t\t\treturn -1\n\t\t\t}\n\t\t\treturn i + j\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "a3c609edf3279a01bef710113f3c23a8", "score": "0.55161977", "text": "func (t *trie) search(s string, i int) bool {\n\tif t == nil {\n\t\treturn false\n\t}\n\n\tif i >= len(s) {\n\t\treturn false\n\t}\n\n\tc := int(s[i])\n\n\tif c == t.key {\n\t\t// Current char matches current node's char\n\t\tif i == len(s)-1 {\n\t\t\treturn t.complete // s is a complete word in t\n\t\t}\n\t\treturn t.middle.search(s, i+1)\n\t} else if c < t.key {\n\t\treturn t.left.search(s, i)\n\t} else {\n\t\treturn t.right.search(s, i)\n\t}\n}", "title": "" }, { "docid": "60b8ca46d566ac99b41cb7c545053685", "score": "0.5495365", "text": "func TestStringInSliceRegularStringFound(t *testing.T) {\n\tslice := []string{\"foo\", \"bar\", \"baz\"}\n\n\t// try to find the first item\n\tif !collections.StringInSlice(\"foo\", slice) {\n\t\tt.Fatal(\"String should be found in the slice\")\n\t}\n\n\t// try to find middle item\n\tif !collections.StringInSlice(\"bar\", slice) {\n\t\tt.Fatal(\"String should be found in the slice\")\n\t}\n\n\t// try to find the last item\n\tif !collections.StringInSlice(\"baz\", slice) {\n\t\tt.Fatal(\"String should be found in the slice\")\n\t}\n}", "title": "" }, { "docid": "cfe3d42e7c3fc995a6fe582d34ca0d23", "score": "0.54742265", "text": "func contains(list []string, e string) int {\n\tif len(list) < 1 {\n\t\treturn -1\n\t}\n\tfor i, a := range list {\n\t\tif a == e {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "d641aab26c0b80b9f4d57ec954361a94", "score": "0.5473737", "text": "func IndexOf(a []string, toFind string) int {\n\ti := sort.Search(len(a), func(index int) bool {\n\t\treturn strings.Compare(a[index], toFind) >= 0\n\t})\n\tif i < 0 || i >= len(a) {\n\t\treturn -1\n\t}\n\tif a[i] == toFind {\n\t\treturn i\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "57aa0cc637046dc4749d7f1bdd57d841", "score": "0.54577684", "text": "func index_in_array(index[]string, element string)int{\n\tret := -1\n\t\n\n\tfor i := 0; i < len(index); i++{\n\n\t\tif strings.Compare(index[i], element) == 0{\n\n\t\t\tret = i\n\t\t\t\n\t\t}\n\t}\n\treturn ret\n}", "title": "" }, { "docid": "08cb54bba163244dd6040f192b8546d6", "score": "0.5455463", "text": "func (w *Samurai) position(find string, values []string) int {\n\tlfind := strings.ToLower(find)\n\tfor i, k := range values {\n\t\tif strings.ToLower(k) == lfind {\n\t\t\treturn i\n\t\t}\n\t}\n\n\treturn -1\n}", "title": "" }, { "docid": "a36eabc54522eaa37b9fc6d31285b3be", "score": "0.5452489", "text": "func index_of(slice []string, id string) int {\n for index, value := range slice {\n if (value == id) {\n return index\n }\n }\n return -1 \n}", "title": "" }, { "docid": "02f62fceac83c97d8e02db8d96d1fcf4", "score": "0.54487133", "text": "func First(check func(s string) bool, step int, vals ...string) string {\n\tl := len(vals)\n\treverse := step < 0\n\tfor i := ugo.Ifi(reverse, l-1, 0); ugo.Ifb(reverse, i >= 0, i < l); i += step {\n\t\tif check(vals[i]) {\n\t\t\treturn vals[i]\n\t\t}\n\t}\n\treturn \"\"\n}", "title": "" }, { "docid": "1b02b1d563128d270693d0057ef78007", "score": "0.5445517", "text": "func IndexInStrings(str string, slice []string) int {\n\tfor i := range slice {\n\t\tif str == slice[i] {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "45631700e7741970735a3aabcf0046e5", "score": "0.5442468", "text": "func IndexOf(element string, data []string) int {\n\tfor k, v := range data {\n\t\tif element == v {\n\t\t\treturn k\n\t\t}\n\t}\n\treturn -1 //not found.\n}", "title": "" }, { "docid": "52d535eeef4019a4a1568915da45381f", "score": "0.5437046", "text": "func (s items) find(e Interface) (index int, found bool) {\n\ti := sort.Search(len(s), func(i int) bool {\n\t\treturn Compare(e, s[i]) < 0\n\t})\n\tif i > 0 && Equal(s[i-1], e) {\n\t\treturn i - 1, true\n\t}\n\treturn i, false\n}", "title": "" }, { "docid": "db73ef7876e224808177ddd6a39d9ab4", "score": "0.54290736", "text": "func my_memmem(haystack string, needle string) int {\n\tfor i := 0; i < len(haystack); i++ {\n\t\tif haystack[i] == needle[0] && strings.Index(haystack[i:], needle) != -1 {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "3bf8ce04b74526c320538abba3b78e1e", "score": "0.5424232", "text": "func (tr *Trie) MatchFirst(input []byte) *Match {\n\ts := RootState\n\n\tfor i, c := range input {\n\t\ts = tr.step(s, EncodeByte(c))\n\n\t\tif tr.dict[s] != 0 {\n\t\t\tpos := int64(i+1) - tr.dict[s]\n\t\t\treturn newMatch(pos, input[pos:i+1])\n\t\t}\n\n\t\tif f := tr.suff[s]; f != EmptyCell {\n\t\t\tpos := int64(i+1) - tr.dict[f]\n\t\t\treturn newMatch(pos, input[pos:i+1])\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "955d48d9841e2b358a69bfc6dbb7adaa", "score": "0.54198617", "text": "func indexOfWord(value string, words []string) int {\n\tfor i := range words {\n\t\tif words[i] == value {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}", "title": "" }, { "docid": "67c0dee2218deb0bb0fdebb7e35333f7", "score": "0.5399234", "text": "func findKeyword(test string, valid []string) int {\n\tfor n, v := range valid {\n\t\tif strings.EqualFold(test, v) {\n\t\t\treturn n\n\t\t}\n\t}\n\n\treturn -1\n}", "title": "" }, { "docid": "cf6426b10557302e95619f4707056940", "score": "0.5398718", "text": "func lookForString(cmd string, args []string, expectedString string) (bool, error) {\n\tresult, err := runCmd(cmd, args)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif strings.Contains(result, expectedString) {\n\t\treturn true, nil\n\t}\n\treturn false, nil\n}", "title": "" }, { "docid": "c24b462e6702e2643f8caa84eb415e9e", "score": "0.5393582", "text": "func maybeFind(header []string, col string) int {\n\tfor i := 0; i < len(header); i++ {\n\t\tif header[i] == col {\n\t\t\treturn i\n\t\t}\n\t}\n\n\treturn -1\n}", "title": "" }, { "docid": "0e11656c0d72138ef577739f40554553", "score": "0.5391872", "text": "func Find(key string, slice []string) (int, bool) {\n\tfor i, item := range slice {\n\t\tif item == key {\n\t\t\treturn i, true\n\t\t}\n\t}\n\treturn -1, false\n}", "title": "" }, { "docid": "3c1211905ea93486dda0674405aa6b54", "score": "0.53861487", "text": "func StrPos(L *lua.State) int {\n\tstr := L.ToString(1)\n\tneedle := L.ToString(2)\n\n\treg := regexp.MustCompile(needle)\n\td := reg.FindAllStringIndex(str, -1)\n\n\tif len(d) > 0 {\n\t\tL.PushInteger(int64(d[0][0]))\n\t} else {\n\t\tL.PushBoolean(false)\n\t}\n\treturn 1\n}", "title": "" } ]
b0902a6815ed564e8ff159778b82607b
newStream creates a new Stream
[ { "docid": "c3f55d82fc3af152c01a34730691a012", "score": "0.74659204", "text": "func newStream(session streamHandler, connectionParameterManager *handshake.ConnectionParametersManager, connectionFlowController flowcontrol.FlowController, flowControlManager flowcontrol.FlowControlManager, StreamID protocol.StreamID) (*stream, error) {\n\ts := &stream{\n\t\tsession: session,\n\t\tstreamID: StreamID,\n\t\tflowControlManager: flowControlManager,\n\t\tconnectionFlowController: connectionFlowController,\n\t\tcontributesToConnectionFlowControl: true,\n\t\tflowController: flowcontrol.NewFlowController(StreamID, connectionParameterManager),\n\t\tframeQueue: newStreamFrameSorter(),\n\t}\n\n\t// crypto and header stream don't contribute to connection level flow control\n\t// TODO: only include the header stream here when using HTTP2\n\tif s.streamID == 1 || s.streamID == 3 {\n\t\ts.contributesToConnectionFlowControl = false\n\t}\n\n\ts.newFrameOrErrCond.L = &s.mutex\n\ts.windowUpdateOrErrCond.L = &s.mutex\n\n\treturn s, nil\n}", "title": "" } ]
[ { "docid": "91dc7834d12527082d2b8cf7d81b846a", "score": "0.72057474", "text": "func (s *Server) newStream(protoStream *proto.Stream, recovered bool) (*stream, error) {\n\tlog, err := commitlog.New(commitlog.Options{\n\t\tPath: filepath.Join(s.config.DataDir, \"streams\", protoStream.Subject, protoStream.Name),\n\t\tMaxSegmentBytes: s.config.Log.SegmentMaxBytes,\n\t\tMaxLogBytes: s.config.Log.RetentionMaxBytes,\n\t\tMaxLogMessages: s.config.Log.RetentionMaxMessages,\n\t\tLogger: s.logger,\n\t})\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to create commit log\")\n\t}\n\n\th := sha1.New()\n\th.Write([]byte(protoStream.Subject))\n\tsubjectHash := fmt.Sprintf(\"%x\", h.Sum(nil))\n\n\treplicas := make(map[string]struct{}, len(protoStream.Replicas))\n\tfor _, replica := range protoStream.Replicas {\n\t\treplicas[replica] = struct{}{}\n\t}\n\n\tisr := make(map[string]*replica, len(protoStream.Isr))\n\tfor _, rep := range protoStream.Isr {\n\t\tisr[rep] = &replica{offset: -1}\n\t}\n\n\tst := &stream{\n\t\tStream: protoStream,\n\t\tlog: log,\n\t\tsrv: s,\n\t\tsubjectHash: subjectHash,\n\t\treplicas: replicas,\n\t\tisr: isr,\n\t\tcommitCheck: make(chan struct{}, len(protoStream.Replicas)),\n\t\trecovered: recovered,\n\t}\n\n\treturn st, nil\n}", "title": "" }, { "docid": "011da12031832bb981df156c687a3e60", "score": "0.7141631", "text": "func New(c changes.Change, base streams.Stream) streams.Stream {\n\treturn stream{c, base}\n}", "title": "" }, { "docid": "1236c31501555634e1e89ab871af6fb7", "score": "0.70899934", "text": "func (cm *udpClient) newStream(p *util.BatPair, readBufferSize int, reg *prometheus.Registry) util.ClientImpl {\n\tstream := &udpStream{pair: p, mutex: &sync.Mutex{}, stop: false}\n\tstream.isStopped.Add(3)\n\tmsgHeaderLength, err := util.GetMessageHeaderLength()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tstream.msgHeaderLength = msgHeaderLength\n\tstream.promRegistry = reg\n\tstream.streamMetrics = make([]prometheus.Collector, 0)\n\tstream.readBufferSize = readBufferSize\n\tstream.conf = cm.conf\n\treturn stream\n}", "title": "" }, { "docid": "8cbbf6dd602ed96bea9e35ee7a578586", "score": "0.7022276", "text": "func NewStream(it Iterator) Stream {\n\treturn Stream{it: it}\n}", "title": "" }, { "docid": "de643dade8838cc12d1af10eb3ec1c2e", "score": "0.70043576", "text": "func NewStream() Stream {\n\treturn &StreamHelper{}\n}", "title": "" }, { "docid": "158bccd65086fd907afdcf32fee50e42", "score": "0.6805039", "text": "func (factory *statsStreamFactory) New(net, transport gopacket.Flow) tcpassembly.Stream {\n\tlog.Printf(\"new stream %v:%v started\", net, transport)\n\ts := &statsStream{\n\t\tnet: net,\n\t\ttransport: transport,\n\t\tstart: time.Now(),\n\t}\n\ts.end = s.start\n\t// ReaderStream implements tcpassembly.Stream, so we can return a pointer to it.\n\treturn s\n}", "title": "" }, { "docid": "3bcd8d58c35c4542e9ddd5eee248af94", "score": "0.68024385", "text": "func (c *Client) newTunnelStream(ctx context.Context, tag int32) (*ioStream, error) {\n\tts, err := c.tc.Tunnel(ctx, c.cc.Opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err = ts.Send(&tpb.Data{Tag: tag}); err != nil {\n\t\treturn nil, err\n\t}\n\treturn newIOStream(ctx, ts), nil\n}", "title": "" }, { "docid": "4dc366ce8bcebc53cde8b512f78c725e", "score": "0.67866", "text": "func newIOStream(ctx context.Context, d dataStream) *ioStream {\n\tctx, cancel := context.WithCancel(ctx)\n\treturn &ioStream{\n\t\tdataSafeStream: dataSafeStream{\n\t\t\tdataStream: d,\n\t\t},\n\t\tcancel: cancel,\n\t\tdoneCh: ctx.Done(),\n\t}\n}", "title": "" }, { "docid": "5d14bf2d771be3e0b2901aaa5f5c13e0", "score": "0.6730583", "text": "func (c *Wrapper) NewStream(ctx context.Context, rpc string, enc drpc.Encoding) (_ drpc.Stream, err error) {\n\treturn c.Conn.NewStream(c.trace(ctx), rpc, enc)\n}", "title": "" }, { "docid": "e7b319148e2be70952ab22914a244c60", "score": "0.6677656", "text": "func NewStream() *Streamer {\n\treturn &Streamer{\n\t\tdepGroup: NewDependencyGroup(),\n\t}\n}", "title": "" }, { "docid": "18935aea93d2b9308eadd299af171bcb", "score": "0.66621894", "text": "func (m *Multiplexer) newStream(k TcpKey) *Stream {\n\tgplog(logInfo, \"Multiplexer creating new stream for key\", k)\n\tstream := &Stream{\n\t\tdata: make(chan *orderedData, 10),\n\t\tKey: k,\n\t\tReverseStream: make(chan *Stream, 1),\n\t}\n\tstream.blockingDataStream = &blockingDataStream{\n\t\tInput: stream.data,\n\t\t//SkipTimeout: time.Second * 1,\n\t\tSkipLength: 10,\n\t}\n\tstream.dataStreamReader = newDataStreamReader(stream.blockingDataStream)\n\tstream.currentReader = stream.dataStreamReader\n\tm.closeWaiter.Add(1)\n\tgo func() {\n\t\tdefer m.closeWaiter.Done()\n\t\t// Handle the stream with our read creator's HandleStream.\n\t\tm.readCreator.HandleStream(stream)\n\t\t// If HandleStream doesn't read everything, we still want to discard\n\t\t// all bytes going into the stream.\n\t\t// So we have a default fallback to do just that.\n\t\tDiscardBytes(stream)\n\t}()\n\treturn stream\n}", "title": "" }, { "docid": "7ae784700c8dc8c006efc52d04ae8b28", "score": "0.6642307", "text": "func (no *Node) handlerNewStream(s net.Stream) {\n\tno.strPool.Add(s)\n}", "title": "" }, { "docid": "aee9d16d7887fb0c11e6bfbe9f9bfd3d", "score": "0.66015834", "text": "func NewStream() *Stream {\n\treturn &Stream{queue: &queue{List: list.New()}}\n}", "title": "" }, { "docid": "f7b480dd7c488acdbb95fff7e7577efa", "score": "0.6572105", "text": "func (c *Client) newClientStream(ctx context.Context, tag int32, id string) error {\n\tstream, err := c.newTunnelStream(ctx, tag)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn c.cc.Handler(id, stream)\n}", "title": "" }, { "docid": "6661d2ff69eaaf628c94c137e0995d37", "score": "0.65283346", "text": "func NewStream(order binary.Order) *Stream {\n\treturn NewStreamBytes(order, []byte{})\n}", "title": "" }, { "docid": "6dacf207c211aa0b7829b696d4c6663f", "score": "0.6501434", "text": "func (t *Transport) newremotestream(opaque uint64) *Stream {\n\tstream := t.fromrxstrm()\n\n\t//TODO: Issue #2, remove or prevent value escape to heap\n\t//fmsg := \"%v ##%d(remote:%v) stream created ...\\n\"\n\t//verbosef(fmsg, t.logprefix, opaque, remote)\n\n\t// reset all fields (it is coming from a pool)\n\tstream.transport, stream.remote, stream.opaque = t, true, opaque\n\tstream.rxcallb = nil\n\treturn stream\n}", "title": "" }, { "docid": "a871e73f79ef2a911b97e98f2fec152a", "score": "0.6427711", "text": "func NewStream(pattern, cmd, delim, file string, args []string) (*Stream, error) {\n\ts := Stream{\n\t\tcmd: cmd,\n\t\targs: args,\n\t\tdelim: delim,\n\t\tfile: file,\n\t\tlines: make(chan string),\n\t\t// timeout: timeout,\n\t}\n\treg, err := setupRegexp(pattern)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ts.fields = parseFields(s.args)\n\ts.Regexp = reg\n\treturn &s, nil\n}", "title": "" }, { "docid": "8e23fe09c5945ce0302371e07cbc12b5", "score": "0.64046186", "text": "func NewStream(r io.Reader, inputLimit uint64) *Stream {\n\ts := new(Stream)\n\ts.Reset(r, inputLimit)\n\treturn s\n}", "title": "" }, { "docid": "48ebc8d2436563d11a267988409c56ef", "score": "0.6391366", "text": "func NewStreamHandler(w http.ResponseWriter, r *http.Request) {\r\n\tif r.Method != http.MethodGet {\r\n\t\thttp.NotFound(w, r)\r\n\t\treturn\r\n\t}\r\n\r\n\tanfitrion := sesion.GetCookie(r)\r\n\r\n\tif anfitrion != nil {\r\n\r\n\t\tnuevoStream := model.RStream{\r\n\t\t\tUsuario: anfitrion.Nombre,\r\n\t\t\tInicio: time.Now().UTC(),\r\n\t\t\tExpira: time.Now().UTC().Add(time.Minute * 1),\r\n\t\t\tID: time.Now().Unix(),\r\n\t\t}\r\n\r\n\t\t//sqlclient.CrearStream(&nuevoStream)\r\n\r\n\t\tstream.NuevaSala(&nuevoStream, *anfitrion)\r\n\r\n\t\thttp.Redirect(w, r, \"/stream/\"+anfitrion.Nombre, 301)\r\n\t} else {\r\n\t\thttp.Redirect(w, r, \"/sesion\", 301)\r\n\t}\r\n}", "title": "" }, { "docid": "1cb116c78b2291f6ebffbdd38adff242", "score": "0.6390995", "text": "func NewStream(program uint32, cbID int32) *Stream {\n\tic := &Stream{\n\t\tProgram: program,\n\t\tCallbackID: cbID,\n\t\tin: make(chan Event),\n\t\tout: make(chan Event),\n\t}\n\n\tic.shutdown = ic.start()\n\n\treturn ic\n}", "title": "" }, { "docid": "e025bd84a3126451991c77c3d0379814", "score": "0.6384476", "text": "func NewStream() events.Stream {\n\treturn new(stream)\n}", "title": "" }, { "docid": "12e8c84e294e93b58b7594ca10dd175d", "score": "0.6379333", "text": "func newStreamingBuffer() *streamingBuffer {\n\treturn &streamingBuffer{buf: bytes.NewBuffer(nil)}\n}", "title": "" }, { "docid": "74737b38731fdbe0b1ec4ac908669860", "score": "0.6376556", "text": "func NewStream(r io.ReadSeeker) *Stream {\n\treturn &Stream{ReadSeeker: r}\n}", "title": "" }, { "docid": "f784c0c2a453eca70aa630bb2e11b08b", "score": "0.63713086", "text": "func NewStream(cam *Camera) *Stream {\n\treturn &Stream{\n\t\tcam: cam,\n\t\tstills: make(chan *Still, 100),\n\t\tdata: make(chan []*gmf.Frame),\n\t}\n}", "title": "" }, { "docid": "3ec249d31e56781eb660e399e479aacc", "score": "0.633201", "text": "func (f *Factory) New(netFlow, tcpFlow gopacket.Flow) tcpassembly.Stream {\n\tf.wg.Add(1)\n\n\tkey := streamKey{net: netFlow, tcp: tcpFlow}\n\tstream := newHTTPStream(key)\n\trevkey := streamKey{net: netFlow.Reverse(), tcp: tcpFlow.Reverse()}\n\n\tf.uniStreamsLock.Lock()\n\tdefer f.uniStreamsLock.Unlock()\n\n\tif p, ok := f.uniStreams[revkey]; ok {\n\t\tdelete(f.uniStreams, revkey)\n\t\tgo p.run(&f.wg, stream, f.methodAllowed)\n\t\treturn stream\n\t}\n\n\tp := newPair(f.seq, f.eventChan, f.onlyRequests)\n\tf.uniStreams[key] = p\n\tf.seq++\n\n\tgo func() {\n\t\tdefer Count(&f.runningStream)()\n\t\tdefer f.DeleteUniStream(key)\n\n\t\tp.run(&f.wg, stream, f.methodAllowed)\n\t}()\n\n\treturn stream\n}", "title": "" }, { "docid": "7e4631b65272153c4800eb9bbf7311df", "score": "0.6263247", "text": "func (n *Network) NewStream(ctx context.Context, p peer.ID) (inet.Stream, error) {\n\tlog.Debugf(\"[%s] network opening stream to peer [%s]\", n.local, p)\n\ts, err := n.Swarm().NewStreamWithPeer(ctx, p)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn inet.Stream(s), nil\n}", "title": "" }, { "docid": "1f99e02532c3e2c1f1dbc4fbcd43b688", "score": "0.6238044", "text": "func newImageStream(key types.NamespacedName) *imagev1.ImageStream {\n\treturn &imagev1.ImageStream{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: key.Name,\n\t\t\tNamespace: key.Namespace,\n\t\t},\n\t}\n}", "title": "" }, { "docid": "e285bad5679f4d8ab5473e864695ae7f", "score": "0.6231102", "text": "func NewStream(id string, retriever Retriever, options ...*Option) Stream {\n\tmtrx := createMetrics(id, \"stream\")\n\tedge := newEdge()\n\tinput := newEdge()\n\n\tbuilder := &builder{\n\t\tvertex: vertex{\n\t\t\tid: id,\n\t\t\tvertexType: \"stream\",\n\t\t\tmetrics: mtrx,\n\t\t\thandler: func(p []*Packet) {\n\t\t\t\tedge.channel <- p\n\t\t\t},\n\t\t\tinput: input,\n\t\t},\n\t\tvertacies: map[string]*vertex{},\n\t\toption: defaultOptions.merge(options...),\n\t}\n\n\tbuilder.connector = func(ctx context.Context, r recorder, vertacies map[string]*vertex, option *Option) error {\n\t\ti := retriever(ctx)\n\n\t\tgo func() {\n\t\tLoop:\n\t\t\tfor {\n\t\t\t\tselect {\n\t\t\t\tcase <-ctx.Done():\n\t\t\t\t\tbreak Loop\n\t\t\t\tcase data := <-i:\n\t\t\t\t\tif len(data) < 1 {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tpayload := make([]*Packet, len(data))\n\t\t\t\t\tfor i, item := range data {\n\t\t\t\t\t\tpacket := &Packet{\n\t\t\t\t\t\t\tID: uuid.New().String(),\n\t\t\t\t\t\t\tData: item,\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif *option.Span {\n\t\t\t\t\t\t\tpacket.newSpan(ctx, mtrx.tracer, \"stream.begin\", id, \"stream\")\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpayload[i] = packet\n\t\t\t\t\t}\n\n\t\t\t\t\tinput.channel <- payload\n\t\t\t\t}\n\t\t\t}\n\t\t}()\n\t\treturn builder.next.cascade(ctx, r, vertacies, option, edge)\n\t}\n\n\treturn builder\n}", "title": "" }, { "docid": "31348741494322bfe058b3d32c9c5e43", "score": "0.6193274", "text": "func NewStream(cfg StreamConfig) (*Stream, error) {\n\tvar c *torrent.Client\n\tvar err error\n\tvar client = &Stream{}\n\tclient.Config = cfg\n\n\n\tpath := cfg.TorrentPath\n\tif _, err := os.Stat(path); os.IsNotExist(err) {\n\t\tos.Mkdir(path, 0777)\n\t}\n\n\t// Create client.\n\tc, err = torrent.NewClient(&torrent.Config{\n\t\tDataDir: path,\n\t\tNoUpload: !cfg.Seed,\n\t\tSeed: cfg.Seed,\n\t\tDisableTCP: !cfg.TCP,\n\t\tDefaultStorage: storage.NewBoltDB(\"./\"),\n\t\tListenAddr: fmt.Sprintf(\":%d\", cfg.TorrentPort),\n\t})\n\n\tif err != nil {\n\t\treturn client, StreamError{Type: \"creating torrent client\", Origin: err}\n\t}\n\n\tclient.Client = c\n\n\tgo client.SetIPBlockList()\n\n\treturn client, nil\n}", "title": "" }, { "docid": "e8f5d30cac71540370b1301554365bf0", "score": "0.6176678", "text": "func NewStream(metadata map[string]string, data map[string]string, channel *network.Channel) (s *Stream, err error) {\n\treturn newStream(uuid.NewString(), metadata, data, channel, true)\n}", "title": "" }, { "docid": "7a68c09f6944cf92ee1918972f308253", "score": "0.6151499", "text": "func (db *DB) NewStream() *Stream {\n\tif db.opt.managedTxns {\n\t\tpanic(\"This API can not be called in managed mode.\")\n\t}\n\treturn db.newStream()\n}", "title": "" }, { "docid": "aef2ceb513137bbc4da6341b17c56472", "score": "0.61339706", "text": "func NewStream(dataset []interface{}) *stream {\n\tstrm := new(stream)\n\tstrm.dataset = dataset\n\tstrm.head = strm\n\treturn strm\n}", "title": "" }, { "docid": "12a15f96bbc32a6bdbb707aadfc4ac14", "score": "0.6119477", "text": "func NewStream() (stream *Stream, err error) {\n\tclient, err := turnpike.NewWebsocketClient(turnpike.JSON, WebsocketAddress, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t_, err = client.JoinRealm(WebsocketRealm, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn &Stream{\n\t\tclient: client,\n\t\tevents: make(chan orderbook.Event, 1000),\n\t\terrors: make(chan error, 10),\n\t}, nil\n}", "title": "" }, { "docid": "70e8ae89d19078b4f13c27294e484183", "score": "0.6106133", "text": "func (mc *MetaCipher) NewStream(conn net.Conn) net.Conn {\n\treturn &aead.Stream{\n\t\tKey: mc.Key,\n\t\tSaltSize: mc.SaltSize,\n\t\tConn: conn,\n\t\tAEADBuilder: mc.AEADBuilder,\n\t}\n}", "title": "" }, { "docid": "5bc1518e783a1949882c1ec44fe7717a", "score": "0.605313", "text": "func (c *Client) NewStream(ctx context.Context, options ...ClientStreamOption) *ClientStream {\n\tclientStream := &ClientStream{\n\t\tctx: ctx,\n\t\tclient: c,\n\t}\n\tfor _, option := range options {\n\t\toption.apply(&clientStream.clientStreamOptions)\n\t}\n\t// warm-up the stream\n\tclientStream.getStream()\n\treturn clientStream\n}", "title": "" }, { "docid": "59fce3f504c1fc56fd80b9e22b770312", "score": "0.6022533", "text": "func NewStream(L *lua.LState, stream chan interface{}) *lua.LUserData {\n\tluaStream := &Stream{s: stream}\n\tud := L.NewUserData()\n\tud.Value = luaStream\n\tL.SetMetatable(ud, L.GetTypeMetatable(luaLuaStreamTypeName))\n\treturn ud\n}", "title": "" }, { "docid": "3dc185a14491c5416d148101365185d7", "score": "0.6013915", "text": "func (c *cloudWatchLogs) NewStream(prefix string, sType streamType) (log.Outputter, error) {\n\tstream := &cloudWatchLogsStream{\n\t\tclient: c,\n\t\tname: prefix + \"/\" + string(sType),\n\t}\n\t_, err := c.client.CreateLogStream(&cloudwatchlogs.CreateLogStreamInput{\n\t\tLogGroupName: aws.String(stream.client.group),\n\t\tLogStreamName: aws.String(stream.name),\n\t})\n\tif err != nil {\n\t\taerr, ok := err.(awserr.Error)\n\t\tif ok && aerr.Code() != cloudwatchlogs.ErrCodeResourceAlreadyExistsException {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn stream, nil\n}", "title": "" }, { "docid": "97a8409fcc2fc4c2e6ea2f4c03fd8c08", "score": "0.60071474", "text": "func NewCommandStream(ctx context.Context, name string, args ...interface{}) (*Command, error) {\n\tcmd, err := NewCommand(ctx, name, args...)\n\tcmd.stream = true\n\treturn cmd, err\n}", "title": "" }, { "docid": "801c626735660b0f21b930f74839f157", "score": "0.59899837", "text": "func (s *Server) handleNewStream(stream network.Stream) {\n\tif s.handleNewMessages(stream) {\n\t\t// If we exited without error, close gracefully.\n\t\t_ = stream.Close()\n\t} else {\n\t\t// otherwise, send an error.\n\t\t_ = stream.Reset()\n\t}\n}", "title": "" }, { "docid": "ed7f680b26d457501c73fd244db4e0ba", "score": "0.5954456", "text": "func NewStreamReader(stream io.Reader) StreamReader {\n\tsr := StreamReader{make(chan ReadResult)}\n\tgo func() {\n\t\tbuf := make([]byte, 1024)\n\t\tfor {\n\t\t\tn, err := stream.Read(buf)\n\n\t\t\tcpy := make([]byte, n)\n\t\t\tcopy(cpy, buf)\n\t\t\tsr.streamChan <- ReadResult{\n\t\t\t\tBytes: cpy,\n\t\t\t\tError: err,\n\t\t\t}\n\t\t}\n\t}()\n\treturn sr\n}", "title": "" }, { "docid": "e3be2b3d6af167473da9624d9b00d9ff", "score": "0.59218204", "text": "func NewBlockchainFromStream(stream io.ReadWriteSeeker) {\n\n}", "title": "" }, { "docid": "68bed33dbfe8b88a0bed5ad6bbd80253", "score": "0.5911897", "text": "func (c *FileCipherStreamCreator) CreateNew(\n\tctx context.Context,\n) (*enginepbccl.EncryptionSettings, FileStream, error) {\n\tkey, err := c.keyManager.ActiveKey(ctx)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tsettings := &enginepbccl.EncryptionSettings{}\n\tif key == nil || key.Info.EncryptionType == enginepbccl.EncryptionType_Plaintext {\n\t\tsettings.EncryptionType = enginepbccl.EncryptionType_Plaintext\n\t\tstream := &filePlainStream{}\n\t\treturn settings, stream, nil\n\t}\n\tsettings.EncryptionType = key.Info.EncryptionType\n\tsettings.KeyId = key.Info.KeyId\n\tsettings.Nonce = make([]byte, ctrNonceSize)\n\t_, err = rand.Read(settings.Nonce)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tcounterBytes := make([]byte, 4)\n\tif _, err = rand.Read(counterBytes); err != nil {\n\t\treturn nil, nil, err\n\t}\n\t// Does not matter how we convert 4 random bytes into uint32\n\tsettings.Counter = binary.LittleEndian.Uint32(counterBytes)\n\tctrCS, err := newCTRBlockCipherStream(key, settings.Nonce, settings.Counter)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\treturn settings, &fileCipherStream{bcs: ctrCS}, nil\n}", "title": "" }, { "docid": "6167363c7a701560d48680d7a2f0da42", "score": "0.5881742", "text": "func New() BridgeStream {\n\tstream := BridgeStream{\n\t\tbuffer: new(bytes.Buffer),\n\t\treadIndex: 0,\n\t\twriteIndex: 0,\n\t}\n\tstream.Clear()\n\treturn stream\n}", "title": "" }, { "docid": "843f828266ad884f17e441b9b10301ee", "score": "0.5878652", "text": "func (c *ScraperConfig) StreamNewTrades(cursor string, h horizonclient.TradeHandler) error {\n\tc.Logger.Info(\"Starting to stream trades with cursor at:\", cursor)\n\treturn c.streamTrades(h, cursor)\n}", "title": "" }, { "docid": "fe6d7da90b2f6574e5ed2efa9fd74784", "score": "0.5871966", "text": "func constructStream(s *goquery.Selection) *Stream {\n\tsrc, _ := s.Find(\"img\").Attr(\"src\")\n\ttitle, _ := s.Find(\"img\").Attr(\"title\")\n\tlocation := extractLocation(title)\n\trelUrl, _ := s.Find(\"a\").Attr(\"href\")\n\tinsecamId := strings.Split(relUrl, \"/\")[3]\n\treturn &Stream{src: src, location: location, insecamId: insecamId}\n}", "title": "" }, { "docid": "455590a2f9c6185acbfebdcd899179b9", "score": "0.58505577", "text": "func NewStreamFileSystem(root, prefix string) *StreamFileSystem {\r\n\treturn &StreamFileSystem{\r\n\t\troot: root,\r\n\t\tprefix: prefix,\r\n\t}\r\n}", "title": "" }, { "docid": "0bbe148bb26ea23a1a2e305fcdebf7f3", "score": "0.5840016", "text": "func NewStreamOK() *StreamOK {\n\treturn &StreamOK{}\n}", "title": "" }, { "docid": "6d8eea80779f9647a2fbae68dc131b58", "score": "0.5821878", "text": "func newChanMsgStream(f *fundingManager, h *htlcswitch.Switch, p *peer,\n\tc lnwire.ChannelID) *chanMsgStream {\n\n\tstream := &chanMsgStream{\n\t\tfundingMgr: f,\n\t\thtlcSwitch: h,\n\t\tpeer: p,\n\t\tcid: c,\n\t\tquit: make(chan struct{}),\n\t}\n\tstream.msgCond = sync.NewCond(&stream.mtx)\n\n\treturn stream\n}", "title": "" }, { "docid": "30164c1a86b73e8188d871f4a7882012", "score": "0.5792584", "text": "func newDecoderStreamWithDigest(reader DecoderStream) *decoderStreamWithDigest {\n\treturn &decoderStreamWithDigest{\n\t\treader: reader,\n\t\treaderDigest: adler32.New(),\n\t\tsingleByteBuf: make([]byte, 1),\n\t}\n}", "title": "" }, { "docid": "53955db3f1c33acecc5bd9b9caa5dc77", "score": "0.5790872", "text": "func (s *StreamManager) New(n string, c string, i interface{}, b bool) {\n\tst := &Stream{\n\t\tName: n,\n\t\tCollection: c,\n\t\tStructValue: reflect.TypeOf(i),\n\t\tBroadcast: b,\n\t}\n\n\ts.Streams.Store(st.Name, st)\n}", "title": "" }, { "docid": "4345dd4d184ca9d0074be38e052c9360", "score": "0.5774815", "text": "func New(logger *jamsonic.Logger) *StreamHandler {\n\treturn &StreamHandler{\n\t\tlogger: logger,\n\t\tfinishedChan: make(chan struct{}),\n\t\tstopChan: make(chan struct{}),\n\t\tnewTrackChan: make(chan *switchStream),\n\t\terrChan: make(chan error),\n\t\tpauseChan: make(chan struct{}),\n\t\tcontinueChan: make(chan struct{}),\n\t}\n}", "title": "" }, { "docid": "c0b7b99a3ba13d5050a4429e181068cc", "score": "0.5773413", "text": "func NewStream(d *Device) *Stream {\n\treturn &Stream{\n\t\tdevice: d,\n\t\tChannels: make(map[string]*Channel),\n\t}\n}", "title": "" }, { "docid": "b5d880aff79d4060bb39f5c36324fcd6", "score": "0.57732344", "text": "func NewStream() grpc.StreamServerInterceptor {\n\tinterceptor := grpc_recovery.StreamServerInterceptor(grpc_recovery.WithRecoveryHandlerContext(recoveryFunc))\n\treturn interceptor\n}", "title": "" }, { "docid": "c453a35b64785be575b363d83792b7d4", "score": "0.5766547", "text": "func (s *Server) newStreamer(ctx context.Context, sessionID string, clusterConfig services.ClusterConfig) (libevents.Streamer, error) {\n\tmode := clusterConfig.GetSessionRecording()\n\tif services.IsRecordSync(mode) {\n\t\ts.log.Debugf(\"Using sync streamer for session %v.\", sessionID)\n\t\treturn s.cfg.AuthClient, nil\n\t}\n\ts.log.Debugf(\"Using async streamer for session %v.\", sessionID)\n\tuploadDir := filepath.Join(\n\t\ts.cfg.DataDir, teleport.LogsDir, teleport.ComponentUpload,\n\t\tlibevents.StreamingLogsDir, defaults.Namespace)\n\t// Make sure the upload dir exists, otherwise file streamer will fail.\n\t_, err := utils.StatDir(uploadDir)\n\tif err != nil && !trace.IsNotFound(err) {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\tif trace.IsNotFound(err) {\n\t\ts.log.Debugf(\"Creating upload dir %v.\", uploadDir)\n\t\tif err := os.MkdirAll(uploadDir, 0755); err != nil {\n\t\t\treturn nil, trace.Wrap(err)\n\t\t}\n\t}\n\tfileStreamer, err := filesessions.NewStreamer(uploadDir)\n\tif err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\treturn libevents.NewTeeStreamer(fileStreamer, s.cfg.StreamEmitter), nil\n}", "title": "" }, { "docid": "1699828f2c49a93e6246e6448d97eebe", "score": "0.5761702", "text": "func (s *Server) newStreamWriter(sessionCtx *common.Session) (libevents.StreamWriter, error) {\n\tclusterConfig, err := s.cfg.AccessPoint.GetClusterConfig()\n\tif err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\t// TODO(r0mant): Add support for record-at-proxy.\n\t// Create a sync or async streamer depending on configuration of cluster.\n\tstreamer, err := s.newStreamer(s.closeContext, sessionCtx.ID, clusterConfig)\n\tif err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\t// Audit stream is using server context, not session context,\n\t// to make sure that session is uploaded even after it is closed\n\treturn libevents.NewAuditWriter(libevents.AuditWriterConfig{\n\t\tContext: s.closeContext,\n\t\tStreamer: streamer,\n\t\tClock: s.cfg.Clock,\n\t\tSessionID: session.ID(sessionCtx.ID),\n\t\tNamespace: defaults.Namespace,\n\t\tServerID: sessionCtx.Server.GetHostID(),\n\t\tRecordOutput: clusterConfig.GetSessionRecording() != services.RecordOff,\n\t\tComponent: teleport.ComponentDatabase,\n\t})\n}", "title": "" }, { "docid": "765b5f735ecd2b97ab0bb37153c56e29", "score": "0.5754506", "text": "func (this *Server) NewStreamContext() context.Context {\n\treturn nil\n}", "title": "" }, { "docid": "4af03880c4fe3fbf8e4eb68a6afeb2a6", "score": "0.57334644", "text": "func newStreamMetric(name, streamName, help string, t prometheus.ValueType, constLabels prometheus.Labels) metricInfo {\n\treturn metricInfo{\n\t\tdesc: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(\"nats_jsz\", \"streams\", name),\n\t\t\thelp,\n\t\t\t[]string{\"stream\"},\n\t\t\tconstLabels,\n\t\t),\n\t\tpromType: t,\n\t\tvalueType: name,\n\t\tnatsType: \"stream\",\n\t\tstreamName: streamName,\n\t}\n}", "title": "" }, { "docid": "77edcaa6043850d5b733d3fda86e7567", "score": "0.5731214", "text": "func (c ReaderConfig) newStreamReader(xz io.Reader) (r *streamReader, err error) {\n\tif err = c.Verify(); err != nil {\n\t\treturn nil, err\n\t}\n\tdata := make([]byte, HeaderLen)\n\tif _, err := io.ReadFull(xz, data[:4]); err != nil {\n\t\treturn nil, err\n\t}\n\tif bytes.Equal(data[:4], []byte{0, 0, 0, 0}) {\n\t\treturn nil, errPadding\n\t}\n\tif _, err = io.ReadFull(xz, data[4:]); err != nil {\n\t\tif err == io.EOF {\n\t\t\terr = io.ErrUnexpectedEOF\n\t\t}\n\t\treturn nil, err\n\t}\n\tr = &streamReader{\n\t\tReaderConfig: c,\n\t\txz: xz,\n\t\tindex: make([]record, 0, 4),\n\t}\n\tif err = r.h.UnmarshalBinary(data); err != nil {\n\t\treturn nil, err\n\t}\n\txlog.Debugf(\"xz header %s\", r.h)\n\tif r.newHash, err = newHashFunc(r.h.flags); err != nil {\n\t\treturn nil, err\n\t}\n\treturn r, nil\n}", "title": "" }, { "docid": "87eaa36a1cbc010e2c0e2829a3d349b5", "score": "0.56877124", "text": "func NewStreamReader(r io.Reader) *StreamReader {\n\treturn &StreamReader{orig: r}\n}", "title": "" }, { "docid": "ea923513a23df36872edd7618e37d479", "score": "0.56835634", "text": "func New(c stream.Config) stream.Stream {\n\treturn &kstream{\n\t\tc: c,\n\t}\n}", "title": "" }, { "docid": "1c0270f961549aae6ded4170059793f1", "score": "0.5673053", "text": "func NewStream(subscribeTo ...Subscribable) *Stream {\n\tstream := new(Stream)\n\tfor _, source := range subscribeTo {\n\t\tsource.Subscribe(RepublishHandler(stream))\n\t}\n\treturn stream\n}", "title": "" }, { "docid": "b871114d5a194ba847c86636f6306f98", "score": "0.5661874", "text": "func (rest *RestCli) Stream() *RestCli {\n\trest.isStream = true\n\treturn rest\n}", "title": "" }, { "docid": "77bb1fa7015642398be0057733f8e03d", "score": "0.5652063", "text": "func newPipe() (read *os.File, write *os.File, err error) {\n\tfds, err := unix.Socketpair(unix.AF_LOCAL, unix.SOCK_SEQPACKET|unix.SOCK_CLOEXEC, 0)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\treturn os.NewFile(uintptr(fds[1]), \"read\"), os.NewFile(uintptr(fds[0]), \"write\"), nil\n}", "title": "" }, { "docid": "cf4adcd05ec849809b6174598576f579", "score": "0.5634962", "text": "func newPortAudioStream() (*portAudioStream, error) {\n\tlog.Print(\"Initializing PortAudio...\")\n\tif err := portaudio.Initialize(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tlog.Print(\"Creating PortAudio stream...\")\n\tout, err := portaudio.DefaultHostApi()\n\tif err != nil {\n\t\tportaudio.Terminate()\n\t\treturn nil, err\n\t}\n\treturn &portAudioStream{device: out.DefaultOutputDevice}, nil\n}", "title": "" }, { "docid": "4f291ae5b3a7dda191d57da5daa5e7a2", "score": "0.5627936", "text": "func newStreamingCall(ctx context.Context, dest peer.ID, svcName, svcMethod string, streamArgs, streamReplies reflect.Value, done chan *Call) *Call {\n\tsID := ServiceID{svcName, svcMethod}\n\n\tcheckChanTypesValid(sID, streamArgs, reflect.RecvDir)\n\tcheckChanTypesValid(sID, streamReplies, reflect.SendDir)\n\n\tctx2, cancel := context.WithCancel(ctx)\n\treturn &Call{\n\t\tctx: ctx2,\n\t\tcancel: cancel,\n\t\tDest: dest,\n\t\tSvcID: sID,\n\t\tStreamArgs: streamArgs,\n\t\tStreamReplies: streamReplies,\n\t\tError: nil,\n\t\tDone: done,\n\t}\n}", "title": "" }, { "docid": "09cb6e6024a05b27b03108d8b680b233", "score": "0.562426", "text": "func newStreamingSet() *streamingSet {\n\treturn &streamingSet{\n\t\tset: cid.NewSet(),\n\t\tnew: make(chan *cid.Cid),\n\t}\n}", "title": "" }, { "docid": "f1fa34bbaf46d3b8fb512771d89b3d25", "score": "0.56096745", "text": "func (s *Swarm) NewStream(ctx context.Context, p peer.ID) (network.Stream, error) {\n\tlog.Debugf(\"[%s] opening stream to peer [%s]\", s.local, p)\n\n\t// Algorithm:\n\t// 1. Find the best connection, otherwise, dial.\n\t// 2. Try opening a stream.\n\t// 3. If the underlying connection is, in fact, closed, close the outer\n\t// connection and try again. We do this in case we have a closed\n\t// connection but don't notice it until we actually try to open a\n\t// stream.\n\t//\n\t// Note: We only dial once.\n\t//\n\t// TODO: Try all connections even if we get an error opening a stream on\n\t// a non-closed connection.\n\tdials := 0\n\tfor {\n\t\t// will prefer direct connections over relayed connections for opening streams\n\t\tc, err := s.bestAcceptableConnToPeer(ctx, p)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif c == nil {\n\t\t\tif nodial, _ := network.GetNoDial(ctx); nodial {\n\t\t\t\treturn nil, network.ErrNoConn\n\t\t\t}\n\n\t\t\tif dials >= DialAttempts {\n\t\t\t\treturn nil, errors.New(\"max dial attempts exceeded\")\n\t\t\t}\n\t\t\tdials++\n\n\t\t\tvar err error\n\t\t\tc, err = s.dialPeer(ctx, p)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\n\t\ts, err := c.NewStream(ctx)\n\t\tif err != nil {\n\t\t\tif c.conn.IsClosed() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t\treturn s, nil\n\t}\n}", "title": "" }, { "docid": "8f3f028f0a166b876d46fa875213c1e2", "score": "0.56090635", "text": "func NoOpNewStreamHandler(stream Stream, replySent <-chan struct{}) error { return nil }", "title": "" }, { "docid": "13130ec77ad4cd1ad310a8d0783bd606", "score": "0.55900943", "text": "func FromStream(stream Stream, bufferSize int) *Streams {\n\tstreams := Streams{[]Stream{stream}, bufferSize}\n\treturn &streams\n}", "title": "" }, { "docid": "6aea72b625a2abb14e90fed34d5dabed", "score": "0.557992", "text": "func New(ctx context.Context, cancel context.CancelFunc,\n\tagent agent.Agent, storage check.Storage, endpoint string,\n\ttimeout time.Duration, log *logrus.Entry) (Stream, error) {\n\n\tconn, _, err := websocket.DefaultDialer.Dial(endpoint, http.Header{})\n\tif err != nil {\n\t\treturn Stream{}, err\n\t}\n\tevents := make(chan Message, BufLen)\n\ts := Stream{\n\t\tctx: ctx,\n\t\tcancel: cancel,\n\t\tagent: agent,\n\t\tstorage: storage,\n\t\tstatus: StatusConnecting,\n\t\tendpoint: endpoint,\n\t\tstream: conn,\n\t\tevents: events,\n\t\ttimeout: timeout,\n\t\tlog: log,\n\t}\n\n\treturn s, nil\n}", "title": "" }, { "docid": "a7833094bbc42045c76864203e906a63", "score": "0.5571982", "text": "func (rc *RemoteContext) NewStream(timeout time.Duration) (*Stream, error) {\n\tif err := rc.ProbeConn(rc.conn); err != nil {\n\t\treturn nil, err\n\t}\n\n\tctx, cancel := context.WithCancel(context.TODO())\n\tstream, err := rc.Client.Step(ctx)\n\tif err != nil {\n\t\tcancel()\n\t\treturn nil, errors.WithStack(err)\n\t}\n\n\tstreamID := atomic.AddUint64(&rc.nextStreamID, 1)\n\tnodeName := commonNameFromContext(stream.Context())\n\n\tvar canceled uint32\n\n\tabortChan := make(chan struct{})\n\n\tabort := func() {\n\t\tcancel()\n\t\trc.streamsByID.Delete(streamID)\n\t\trc.Metrics.reportEgressStreamCount(rc.Channel, atomic.LoadUint32(&rc.streamsByID.size))\n\t\trc.Logger.Debugf(\"Stream %d to %s(%s) is aborted\", streamID, nodeName, rc.endpoint)\n\t\tatomic.StoreUint32(&canceled, 1)\n\t\tclose(abortChan)\n\t}\n\n\tonce := &sync.Once{}\n\tabortReason := &atomic.Value{}\n\tcancelWithReason := func(err error) {\n\t\tabortReason.Store(err.Error())\n\t\tonce.Do(abort)\n\t}\n\n\tlogger := flogging.MustGetLogger(\"orderer.common.cluster.step\")\n\tstepLogger := logger.WithOptions(zap.AddCallerSkip(1))\n\n\ts := &Stream{\n\t\tChannel: rc.Channel,\n\t\tmetrics: rc.Metrics,\n\t\tabortReason: abortReason,\n\t\tabortChan: abortChan,\n\t\tsendBuff: make(chan *orderer.StepRequest, rc.SendBuffSize),\n\t\tcommShutdown: rc.shutdownSignal,\n\t\tNodeName: nodeName,\n\t\tLogger: stepLogger,\n\t\tID: streamID,\n\t\tEndpoint: rc.endpoint,\n\t\tTimeout: timeout,\n\t\tCluster_StepClient: stream,\n\t\tCancel: cancelWithReason,\n\t\tcanceled: &canceled,\n\t}\n\n\ts.expCheck = &certificateExpirationCheck{\n\t\tminimumExpirationWarningInterval: rc.minimumExpirationWarningInterval,\n\t\texpirationWarningThreshold: rc.certExpWarningThreshold,\n\t\texpiresAt: rc.expiresAt,\n\t\tendpoint: s.Endpoint,\n\t\tnodeName: s.NodeName,\n\t\talert: func(template string, args ...interface{}) {\n\t\t\ts.Logger.Warningf(template, args...)\n\t\t},\n\t}\n\n\trc.Logger.Debugf(\"Created new stream to %s with ID of %d and buffer size of %d\",\n\t\trc.endpoint, streamID, cap(s.sendBuff))\n\n\trc.streamsByID.Store(streamID, s)\n\trc.Metrics.reportEgressStreamCount(rc.Channel, atomic.LoadUint32(&rc.streamsByID.size))\n\n\tgo func() {\n\t\trc.workerCountReporter.increment(s.metrics)\n\t\ts.serviceStream()\n\t\trc.workerCountReporter.decrement(s.metrics)\n\t}()\n\n\treturn s, nil\n}", "title": "" }, { "docid": "c6678004690b462ce7808b87f2cc08b8", "score": "0.5565368", "text": "func newStreamer(ctx context.Context, cp *mysql.ConnParams, pos mysql.Position, filter *proto.Filter, p *player, r *Replicator) *streamer {\n\t// FIXME unused cancel\n\tctx, cancel := context.WithCancel(ctx)\n\n\treturn &streamer{\n\t\tctx: ctx,\n\t\tcancel: cancel,\n\t\tcp: cp,\n\t\tpos: pos,\n\t\tfilter: filter,\n\t\tplans: make(map[uint64]*streamerPlan),\n\t\tpkColumns: make(map[uint64][]int),\n\t\tp: p,\n\t\tr: r,\n\t}\n}", "title": "" }, { "docid": "7593bc8ee20ad05e5615c54742b30c40", "score": "0.5557725", "text": "func NewStream(opts ...StreamOption) *Stream {\n\ts := &Stream{\n\t\taudioMux: &sync.Mutex{},\n\t\tclientMux: &sync.Mutex{},\n\t\tlisteners: make(map[string]*Listener),\n\t\tqueue: []*Audio{},\n\t\tdequeued: make(chan int),\n\t}\n\n\tfor _, o := range opts {\n\t\to(s)\n\t}\n\n\tif s.frameSize == 0 {\n\t\ts.frameSize = defaultFrameSize\n\t}\n\n\treturn s\n}", "title": "" }, { "docid": "e952fd4dc5af2036eec0f13c4c96d514", "score": "0.55564564", "text": "func New(name string, size int) *StreamLogger {\n\treturn &StreamLogger{\n\t\tname: name,\n\t\tsize: size,\n\t\tsubscribed: make(map[chan interface{}]string),\n\t}\n}", "title": "" }, { "docid": "0db42409a19cf393b7d426e33808babc", "score": "0.5544192", "text": "func (subC *ServerSubConn) getNewDataSendStream() (quic.SendStream, error) {\n\tsubC.serverConnection.dataStreamOpenMutex.Lock()\n\tdefer subC.serverConnection.dataStreamOpenMutex.Unlock()\n\treturn subC.serverConnection.quicSession.OpenUniStreamSync()\n}", "title": "" }, { "docid": "8ca42d0755b29e09ad7d213052792bbf", "score": "0.5534632", "text": "func newPortAudioStream() (portAudioStream, error) {\n\tvar s portAudioStream\n\tif err := portaudio.Initialize(); err != nil {\n\t\treturn s, err\n\t}\n\tout, err := portaudio.DefaultHostApi()\n\tif err != nil {\n\t\tportaudio.Terminate()\n\t\treturn s, err\n\t}\n\ts.device = out.DefaultOutputDevice\n\treturn s, nil\n}", "title": "" }, { "docid": "fbd7c6e55a830e2d8d0843a4fa6ec004", "score": "0.5526507", "text": "func New(config postgres.Config) *Stream {\n\n\treturn &Stream{\n\t\tconfig: config,\n\t\tconn: nil,\n\t\tstarted: false,\n\t}\n}", "title": "" }, { "docid": "f8d4f2fa1ab7f6a8d3f4ee4cd3bcaf75", "score": "0.55221146", "text": "func NewStepClientStream(t mockConstructorTestingTNewStepClientStream) *StepClientStream {\n\tmock := &StepClientStream{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "title": "" }, { "docid": "28ce07ca2db226840bcd5f219039dc5e", "score": "0.54995376", "text": "func (dtnet *libp2pDataTransferNetwork) handleNewStream(s network.Stream) {\n\tdefer s.Close() // nolint: errcheck,gosec\n\n\tif dtnet.receiver == nil {\n\t\ts.Reset() // nolint: errcheck,gosec\n\t\treturn\n\t}\n\n\tp := s.Conn().RemotePeer()\n\tfor {\n\t\tvar received datatransfer.Message\n\t\tvar err error\n\t\tswitch s.Protocol() {\n\t\tcase datatransfer.ProtocolDataTransfer1_2:\n\t\t\treceived, err = message.FromNet(s)\n\t\t}\n\n\t\tif err != nil {\n\t\t\tif err != io.EOF && err != io.ErrUnexpectedEOF {\n\t\t\t\ts.Reset() // nolint: errcheck,gosec\n\t\t\t\tgo dtnet.receiver.ReceiveError(err)\n\t\t\t\tlog.Debugf(\"net handleNewStream from %s error: %s\", p, err)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tctx := context.Background()\n\t\tlog.Debugf(\"net handleNewStream from %s\", p)\n\n\t\tif received.IsRequest() {\n\t\t\treceivedRequest, ok := received.(datatransfer.Request)\n\t\t\tif ok {\n\t\t\t\tif receivedRequest.IsRestartExistingChannelRequest() {\n\t\t\t\t\tdtnet.receiver.ReceiveRestartExistingChannelRequest(ctx, p, receivedRequest)\n\t\t\t\t} else {\n\t\t\t\t\tdtnet.receiver.ReceiveRequest(ctx, p, receivedRequest)\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\treceivedResponse, ok := received.(datatransfer.Response)\n\t\t\tif ok {\n\t\t\t\tdtnet.receiver.ReceiveResponse(ctx, p, receivedResponse)\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "f9b6090a67707b0ffb61a8f213831418", "score": "0.5483442", "text": "func (rs *Session) replaceStream(oldOut *SsrcStream) (newOut *SsrcStream) {\n\tvar str *SsrcStream\n\tvar idx uint32\n\trs.streamsMapMutex.RLock()\n\tfor idx, str = range rs.streamsOut {\n\t\tif oldOut.Ssrc() == str.Ssrc() {\n\t\t\tbreak\n\t\t}\n\t}\n\trs.streamsMapMutex.RUnlock()\n\t// get new stream and copy over attributes from old stream\n\toldOut.RLock()\n\tnewOut = newSsrcStreamOut(&Address{oldOut.IpAddr, oldOut.DataPort, oldOut.CtrlPort, oldOut.Zone}, 0, 0)\n\tfor itemType, itemTxt := range oldOut.SdesItems {\n\t\tnewOut.SetSdesItem(itemType, itemTxt)\n\t}\n\tnewOut.SetPayloadType(oldOut.payloadType)\n\tnewOut.RLock()\n\tnewOut.sender = oldOut.sender\n\tnewOut.RUnlock()\n\toldOut.RUnlock()\n\n\t// Don't reuse an existing SSRC\n\tfor _, _, exists := rs.lookupSsrcMap(newOut.Ssrc()); exists; _, _, exists = rs.lookupSsrcMap(newOut.Ssrc()) {\n\t\tnewOut.newSsrc()\n\t}\n\tnewOut.Lock()\n\tnewOut.streamType = OutputStream\n\tnewOut.Unlock()\n\n\trs.streamsMapMutex.Lock()\n\trs.streamsOut[idx] = newOut // replace the oldOut with a new initialized out, new SSRC, sequence but old address\n\trs.streamsMapMutex.Unlock()\n\n\t// sanity check - this is a panic, something stange happened\n\trs.streamsMapMutex.RLock()\n\tfor idx, str = range rs.streamsIn {\n\t\tif oldOut.Ssrc() == str.Ssrc() {\n\t\t\trs.streamsMapMutex.RUnlock()\n\t\t\tpanic(\"Panic: found input stream during collision handling - expected none\")\n\t\t\treturn\n\t\t}\n\t}\n\trs.streamsMapMutex.RUnlock()\n\n\toldOut.Lock()\n\toldOut.streamType = InputStream\n\toldOut.Unlock()\n\n\trs.streamsMapMutex.Lock()\n\trs.streamsIn[rs.streamInIndex] = oldOut\n\trs.streamInIndex++\n\trs.streamsMapMutex.Unlock()\n\n\treturn\n}", "title": "" }, { "docid": "881adf7e11214b14a2fda85071c3594c", "score": "0.54247797", "text": "func newGameServerMockStream() *gameServerMockStream {\n\treturn &gameServerMockStream{\n\t\tctx: context.Background(),\n\t\tmsgs: make(chan *sdk.GameServer, 10),\n\t}\n}", "title": "" }, { "docid": "66fcba589e89787999a66afbe124b9c0", "score": "0.5421064", "text": "func NewStreamFn(opts ...Option) streamfunction.Client {\n\toptions := newOptions(opts...)\n\treturn streamfunction.New(options.AppName)\n}", "title": "" }, { "docid": "f4d97c03353e81c65db2d31a55762c4e", "score": "0.5420341", "text": "func NewWriteStream(writer io.Writer) *WriteStream {\r\n\treturn &WriteStream{\r\n\t\twriter: writer,\r\n\t}\r\n}", "title": "" }, { "docid": "b0708b830a06f83b97295b2ec6c58fce", "score": "0.541538", "text": "func NewOutputStream(streamChan chan string) *OutputStream {\n\tout := &OutputStream{\n\t\tstreamChan: streamChan,\n\t\tbufSize: 16384,\n\t\tbuf: make([]byte, 16384),\n\t\tlastChar: 0,\n\t}\n\treturn out\n}", "title": "" }, { "docid": "b0708b830a06f83b97295b2ec6c58fce", "score": "0.541538", "text": "func NewOutputStream(streamChan chan string) *OutputStream {\n\tout := &OutputStream{\n\t\tstreamChan: streamChan,\n\t\tbufSize: 16384,\n\t\tbuf: make([]byte, 16384),\n\t\tlastChar: 0,\n\t}\n\treturn out\n}", "title": "" }, { "docid": "34cbed95b69755e7ddd922627d40f41f", "score": "0.5408951", "text": "func NewStreamBuffer(bufferCount int, bufferSize int) *StreamBuffer {\n\t// Initialize all of the buffers at once.\n\t// We could eventually do this more dynamically and only initialize new ones as needed\n\t// to optimize for smaller streams.\n\tbuffers := ring.New(bufferCount)\n\tfor i := 0; i < bufferCount; i++ {\n\t\tbuffers.Value = bytes.NewBuffer(make([]byte, bufferSize))\n\t\tbuffers = buffers.Next()\n\t}\n\n\treturn &StreamBuffer{\n\t\tbufferSize: bufferSize,\n\t\tbuffers: buffers,\n\t\twrittenChunks: map[int64]int64{},\n\t}\n}", "title": "" }, { "docid": "21fba3b6ba1148c4db8144792f8efe17", "score": "0.54008895", "text": "func newWriter(streamName, partitionKey string) *kinesis.BufferedWriter {\n\treturn kinesis.NewFastWriter(streamName, partitionKey)\n}", "title": "" }, { "docid": "e843f34a63ab7655f0b397d645fbc734", "score": "0.53913224", "text": "func Stream(out chan<- *Message, stop <-chan bool, sampleTime time.Duration) error {\n\tstate, err := New()\n\tif err != nil {\n\t\treturn err\n\t}\n\tgo doStream(state, out, stop, sampleTime)\n\treturn nil\n}", "title": "" }, { "docid": "3121cb284aa473b869cd0839e28b6648", "score": "0.5388289", "text": "func (sp *syncProtocol) OpenedStream(net network.Network, stream network.Stream) {}", "title": "" }, { "docid": "f3c48b763b3a059595735c529c4e569d", "score": "0.53652614", "text": "func NewClientStream() *clientStream {\n\tbaseStream := newBaseStream(nil)\n\tnewclientStream := &clientStream{\n\t\tbaseStream: *baseStream,\n\t}\n\treturn newclientStream\n}", "title": "" }, { "docid": "3c52f1d4efb481aa658ee4439bca37e2", "score": "0.53640205", "text": "func GetStream(cl *client.Client, server *mockserver.Server, mode int) (*graylog.Stream, func(string), error) {\n\tstreams, _, _, err := cl.GetStreams()\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tif len(streams) != 0 {\n\t\tif mode == 1 {\n\t\t\tfor _, stream := range streams {\n\t\t\t\tif stream.IsDefault {\n\t\t\t\t\treturn &stream, nil, nil\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn nil, nil, fmt.Errorf(\"default stream is not found\")\n\t\t}\n\t\tif mode == 2 {\n\t\t\tfor _, stream := range streams {\n\t\t\t\tif !stream.IsDefault {\n\t\t\t\t\treturn &stream, nil, nil\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn nil, nil, fmt.Errorf(\"not default stream is not found\")\n\t\t}\n\t\treturn &(streams[0]), nil, nil\n\t}\n\tis, f, err := GetIndexSet(cl, server, \"hoge\")\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tstream := Stream()\n\tstream.IndexSetID = is.ID\n\tif _, err := cl.CreateStream(stream); err != nil {\n\t\tif f != nil {\n\t\t\tf(is.ID)\n\t\t}\n\t\treturn nil, nil, err\n\t}\n\treturn stream, func(id string) {\n\t\tcl.DeleteStream(id)\n\t\tif f != nil {\n\t\t\tf(is.ID)\n\t\t}\n\t}, nil\n}", "title": "" }, { "docid": "e728d8ed952d54740b73b942227fb8dc", "score": "0.53607273", "text": "func NewStreamNotFound() *StreamNotFound {\n\treturn &StreamNotFound{}\n}", "title": "" }, { "docid": "05741e46c828ae0f38d7a72b60e2b55f", "score": "0.53563696", "text": "func newFs() *fs.MockFs {\n\treturn fs.NewMockFs(map[string][]byte{})\n}", "title": "" }, { "docid": "e027311ce0af818eef4246132e948eeb", "score": "0.5349393", "text": "func newStreamingProcessor(s *serverStream, pkgHandler common.PackageHandler, desc grpc.StreamDesc, serializer common.Dubbo3Serializer, option *config.Option) (processor, error) {\n\treturn &streamingProcessor{\n\t\tbaseProcessor: baseProcessor{\n\t\t\tserializer: serializer,\n\t\t\tstream: s,\n\t\t\tpkgHandler: pkgHandler,\n\t\t\tdone: make(chan struct{}, 1),\n\t\t\tquitOnce: sync.Once{},\n\t\t\topt: option,\n\t\t},\n\t\tstreamDesc: desc,\n\t}, nil\n}", "title": "" }, { "docid": "15b96a6772bb9a555bafcedf0ea4f710", "score": "0.53456616", "text": "func newMarketEventsStream() MarketEventsStream {\n\treturn &marketEventsStream{\n\t\tlogger: utils.Logger.WithFields(logrus.Fields{\n\t\t\t\"module\": \"datastreams.MarketEventsStream\",\n\t\t}),\n\t\tbroadcastStream: NewBroadcastStream(),\n\t}\n}", "title": "" }, { "docid": "170fd0e3c0fb98eef60565e30130f8df", "score": "0.53277844", "text": "func NewStreamReader() *StreamReader {\n\tr := new(StreamReader)\n\tr.stopCh = make(chan interface{})\n\tr.buffer = bytes.NewBuffer([]byte(\"\"))\n\tr.src = make(chan *StreamDataBlock, 32)\n\treturn r\n}", "title": "" }, { "docid": "d13479c77451494a61249b58f84176b5", "score": "0.53163946", "text": "func NewStreamDecoder(r io.Reader) *StreamDecoder {\n\treturn &StreamDecoder{r: r, path: newPathBuilder(), done: make(chan struct{}, 0), context: context.Background()}\n}", "title": "" }, { "docid": "2565d3ee4fb5d578ff0b1d2425abd12a", "score": "0.5315667", "text": "func newPipe() (parent *os.File, child *os.File, err error) {\n\tfds, err := unix.Socketpair(unix.AF_LOCAL, unix.SOCK_STREAM|unix.SOCK_CLOEXEC, 0)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\treturn os.NewFile(uintptr(fds[1]), \"parent\"), os.NewFile(uintptr(fds[0]), \"child\"), nil\n}", "title": "" }, { "docid": "da790917adcb634fdacd3b20f9eb73b9", "score": "0.53070307", "text": "func Stream(input <-chan interface{}) *Streamer {\n\tstream := NewStream()\n\tstream.Log = DefaultLogger.WithField(\"task\", \"stream\")\n\tstream.In = input\n\treturn stream\n}", "title": "" }, { "docid": "677e8760e2cd9bed930e6f236927ac03", "score": "0.5287551", "text": "func newReader(rd io.Reader) *Reader {\n\tpr, pw := io.Pipe()\n\tcmd := exec.Command(xzFullPath, \"--no-warn\", \"--stdout\", \"--decompress\", \"-\")\n\tcmd.Stdin = rd\n\tcmd.Stdout = pw\n\txz := &Reader{\n\t\tcmd: cmd,\n\t\tpr: pr,\n\t\tpw: pw,\n\t\tdone: make(chan struct{}),\n\t}\n\tcmd.Stderr = &xz.stderr\n\truntime.SetFinalizer(xz, (*Reader).Close)\n\treturn xz\n}", "title": "" } ]
49586db5095c81ed7f0b787683318f96
arguments := '|' IDENT (PERIOD IDENT) '|'
[ { "docid": "dd4f81d257112d336634d859d0d76e87", "score": "0.48733118", "text": "func (p *Parser) parseBlockArguments() []string {\n\tp.expect(scan.BINARY)\n\n\targs := []string{p.expect(scan.IDENT)}\n\tfor p.tok != scan.BINARY && p.lit != \"|\" {\n\t\tperiod := p.expect(scan.PERIOD)\n\t\tif period != \".\" {\n\t\t\tbreak\n\t\t}\n\t\targs = append(args, p.expect(scan.IDENT))\n\t}\n\tp.expect(scan.BINARY)\n\treturn args\n}", "title": "" } ]
[ { "docid": "93dd99523fa34b0fcd665e463d60dd39", "score": "0.5697875", "text": "func (sc *SearchCommand) genListIdentifierArgsFromCommandLine() ListIdentifierArgs {\n var set string\n\n set = *(sc.setName)\n if set == \"\" {\n set = sc.Ctx.Provider.Set\n } else if set == \"*\" {\n set = \"\"\n }\n\n args := ListIdentifierArgs{\n Set: set,\n From: parseDateString(*(sc.afterDate)),\n Until: parseDateString(*(sc.beforeDate)),\n }\n\n return args\n}", "title": "" }, { "docid": "1e4944b88f614025d124092258611e03", "score": "0.55061", "text": "func formatArguments_range(args []string) (string) {\n\n\t// Declare 2 variables, both strings\n\tvar s, sep string\n\n\tfor _, arg := range args[1:] {\n\t\ts += sep + arg\n\t\tsep = \" \"\n\t}\n\n\treturn s;\n}", "title": "" }, { "docid": "42f883d87fe28bdab6bb10d6cc9777c9", "score": "0.52887315", "text": "func positionalArgs(args ...interface{}) string {\n\tinAssigns := make([]string, len(args))\n\tfor i := range args {\n\t\tinAssigns[i] = fmt.Sprintf(\"$%d\", i+1)\n\t}\n\treturn strings.Join(inAssigns, \", \")\n}", "title": "" }, { "docid": "a3c3bd5a003c6d9d2d5098e76e4dbc7a", "score": "0.5139287", "text": "func parseCommand(\n\tcmd commands.Command) (\n\tstart time.Time,\n\tend time.Time,\n\tperiod string,\n\taccountName string,\n\tenvironment string,\n\tservice string,\n\tgroupBy []string,\n\tcols []string,\n\theaders []string,\n\terr error) {\n\n\tdateFormat := dates.DateFormat()\n\tcmdSet := cmd.Set\n\n\tstartStr := cmdSet.Lookup(\"start-date\").Value.String()\n\tendStr := cmdSet.Lookup(\"end-date\").Value.String()\n\tstart, err = time.Parse(dateFormat, startStr)\n\tend, err = time.Parse(dateFormat, endStr)\n\n\taccountName = cmdSet.Lookup(\"account\").Value.String()\n\tenvironment = cmdSet.Lookup(\"env\").Value.String()\n\tservice = cmdSet.Lookup(\"service\").Value.String()\n\t// split these by ,\n\tgs := cmdSet.Lookup(\"data-group-by\").Value.String()\n\tif len(gs) > 1 {\n\t\tgroupBy = strings.Split(gs, \",\")\n\t}\n\tc := cmdSet.Lookup(\"data-columns\").Value.String()\n\tif len(c) > 1 {\n\t\tcols = strings.Split(c, \",\")\n\t}\n\th := cmdSet.Lookup(\"data-headers\").Value.String()\n\tif len(h) > 1 {\n\t\theaders = strings.Split(h, \",\")\n\t}\n\n\tperiod = cmdSet.Lookup(\"granularity\").Value.String()\n\tif period != \"DAILY\" && period != \"MONTHLY\" {\n\t\terr = fmt.Errorf(\"Granularity is invalid [%v]\", period)\n\t}\n\n\treturn\n\n}", "title": "" }, { "docid": "20f765d9d4d42c78c45cfd4404d64b10", "score": "0.5110659", "text": "func main() {\n\tc, err := NewCmd()\n\tif err != nil {\n\t\tPanic(c, err)\n\t}\n\n\tyear, month, err := c.ParseArgs(os.Args[1:], time.Now())\n\tif err != nil {\n\t\tPanic(c, err)\n\t}\n\n\tfor _, line := range c.CreateCalendar(year, month) {\n\t\tfmt.Println(line)\n\t}\n}", "title": "" }, { "docid": "eedd703bc4e3ae355d91664ff0fc62f1", "score": "0.5106127", "text": "func seq(name string, args ...interface{}) []byte {\n\tc := commands[name]\n\tif len(args) == 0 {\n\t\treturn []byte(c)\n\t}\n\treturn []byte(fmt.Sprintf(string(c), args...))\n}", "title": "" }, { "docid": "5d13cc91f797a648a63010f04fd75aec", "score": "0.50973326", "text": "func TestArgumentName(t string) string {\n\treturn \"op\" + t\n}", "title": "" }, { "docid": "bf469069c1be4c652a921374322e32bd", "score": "0.5031327", "text": "func regexpArgument(str string) []string {\n\treturn regexp.MustCompile(`(?i:<|\\[)[A-Za-z0-9_\\[\\]<>-]+\\b(?i:>|])`).\n\t\tFindAllString(str, -1)\n}", "title": "" }, { "docid": "a53bcc29bf0a5ee36aac050713eeb1d7", "score": "0.4937287", "text": "func javaDeclarationArgStr(args []*compile.Field, env *compile.Env, leadingComma bool) string {\n\tvar buf bytes.Buffer\n\tfor i, arg := range args {\n\t\tif leadingComma || i > 0 {\n\t\t\tbuf.WriteString(\", \")\n\t\t}\n\t\tbuf.WriteString(\"final \")\n\t\tbuf.WriteString(javaType(arg.Type, false, env))\n\t\tbuf.WriteString(\" \")\n\t\tif arg.Name != \"\" {\n\t\t\tbuf.WriteString(arg.Name)\n\t\t} else {\n\t\t\tbuf.WriteString(fmt.Sprintf(\"arg%d\", i+1))\n\t\t}\n\t}\n\treturn buf.String()\n}", "title": "" }, { "docid": "5f9bae24f550a1e6b7958f355bfa25d5", "score": "0.48910287", "text": "func identifier(i *int, src string) string {\n\tstart := *i\n\tfor isAlphaNumeric(string(src[*i])) {\n\t\t*i++\n\t}\n\ts := src[start:*i]\n\t*i = *i - 1\n\treturn s\n}", "title": "" }, { "docid": "16947a4f406dcac355a1cf92fcb98c61", "score": "0.48755887", "text": "func quoteIdent(segments ...string) string {\n\tvar buf bytes.Buffer\n\tfor i, segment := range segments {\n\t\tneedQuote := identNeedsQuotes(segment) ||\n\t\t\t// not last segment && not \"\"\n\t\t\t((i < len(segments)-1) && segment != \"\") ||\n\t\t\t// the first or last segment and an empty string\n\t\t\t((i == 0 || i == len(segments)-1) && segment == \"\")\n\n\t\tif needQuote {\n\t\t\t_ = buf.WriteByte('\"')\n\t\t}\n\n\t\t_, _ = buf.WriteString(qiReplacer.Replace(segment))\n\n\t\tif needQuote {\n\t\t\t_ = buf.WriteByte('\"')\n\t\t}\n\n\t\tif i < len(segments)-1 {\n\t\t\t_ = buf.WriteByte('.')\n\t\t}\n\t}\n\treturn buf.String()\n}", "title": "" }, { "docid": "0f9c15f9d7b9891b636be95d12a5cc93", "score": "0.4847859", "text": "func CommandChecker(s *lexmachine.Scanner) {\n\tparamType := \"\"\n\tvar paramError error\n\tconcat := false\n\taux := param{}\n\n\tfor tok, err, eof := s.Next(); !eof; tok, err, eof = s.Next() {\n\t\t//Si existe un error lexico termina la lectura de la lista de tokens\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\tbreak\n\t\t}\n\t\t//Obtenemos el token a leer\n\t\ttoken := tok.(*lexmachine.Token)\n\t\t//Verificamos si es alguna reserveda de los comandos\n\t\t/*\n\t\t\tEXEC\n\t\t\tPAUSE\n\t\t\tMKDISK\n\t\t\tRMDISK\n\t\t\tFDISK\n\t\t\tMOUNT\n\t\t\tUNMOUNT\n\t\t\tREP\n\t\t*/\n\t\tfor _, value := range keywords {\n\t\t\tif strings.EqualFold(string(token.Lexeme), value) {\n\t\t\t\taux.paramType = value\n\t\t\t}\n\t\t}\n\t\tif aux.paramType == \"\" && string(token.Lexeme) != \"\\n\" {\n\t\t\tfmt.Println(\"[ERROR]: Este comando \\\"\", string(token.Lexeme), \"\\\" no esta admitido en el sistema.\")\n\t\t\treturn\n\t\t}\n\t\t//Verificamos si viene algun parametro para asignarlo\n\t\tif tokens[token.Type] == \"PARAMETER\" {\n\t\t\tparamType = string(token.Lexeme)\n\t\t\tparamType = strings.Replace(paramType, \"-\", \"\", -1)\n\t\t\tparamType = strings.ToUpper(paramType)\n\t\t} else if tokens[token.Type] == \"IDN\" {\n\t\t\tparamType = \"IDN\"\n\t\t} else if tokens[token.Type] == \"FILEN\" {\n\t\t\tparamType = \"FILEN\"\n\t\t}\n\t\t//Se asigna el parametro a la estructura del comando\n\t\tif tokens[token.Type] == \"->\" {\n\t\t\ttokenAux, err, _ := s.Next()\n\t\t\t//Si existe un error lexico termina la lectura de la lista de tokens\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(err)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\taux, paramError = paramDesigned(tokenAux.(*lexmachine.Token), paramType, aux)\n\t\t\tparamType = \"\"\n\t\t}\n\t\tif paramType == \"P\" {\n\t\t\taux.pathComplete = true\n\t\t}\n\t\t//Verificamos si no existe un error en la asignacion\n\t\tif paramError != nil {\n\t\t\tbreak\n\t\t}\n\t\t//Concatenamos la siguiente fila\n\t\tif tokens[token.Type] == \"\\\\*\" {\n\t\t\tconcat = true\n\t\t}\n\t\t//Se ejecuta el comando\n\t\tif tokens[token.Type] == \"FINISHCOMMAND\" && !concat && aux.paramType != \"\" {\n\t\t\tcontrolCommands(aux)\n\t\t\taux = param{}\n\t\t}\n\t\t//Reseteamos la concatenacion\n\t\tif tokens[token.Type] == \"FINISHCOMMAND\" {\n\t\t\tconcat = false\n\t\t}\n\t}\n}", "title": "" }, { "docid": "3dd27561c1666a9a4103f63218b3264e", "score": "0.4815514", "text": "func appendArgument(dst, src []byte) ([]byte, int) {\n\t// skip initial blanks\n\tpos := 0\n\tfor ; pos < len(src) && asciiSpace[src[pos]]; pos++ {\n\t}\n\n\tvar inQ, inSQ bool\nMainLoop:\n\tfor pos < len(src) {\n\t\tp := src[pos]\n\n\t\tif inQ {\n\t\t\tif p == '\"' {\n\t\t\t\tpos++\n\t\t\t\tbreak MainLoop\n\t\t\t} else if p == '\\\\' && pos+3 < len(src) && src[pos+1] == 'x' && isHexChar(src[pos+2]) && isHexChar(src[pos+3]) {\n\t\t\t\tp = fromHexChar(src[pos+2])<<4 | fromHexChar(src[pos+3])\n\t\t\t\tpos += 3\n\t\t\t} else if p == '\\\\' && pos+1 < len(src) {\n\t\t\t\tpos++\n\t\t\t\tp = src[pos]\n\t\t\t\tswitch p {\n\t\t\t\tcase 'n':\n\t\t\t\t\tp = '\\n'\n\t\t\t\tcase 'r':\n\t\t\t\t\tp = '\\r'\n\t\t\t\tcase 't':\n\t\t\t\t\tp = '\\t'\n\t\t\t\tcase 'b':\n\t\t\t\t\tp = '\\b'\n\t\t\t\tcase 'a':\n\t\t\t\t\tp = '\\a'\n\t\t\t\t}\n\t\t\t}\n\t\t\tdst = append(dst, p)\n\n\t\t} else if inSQ {\n\t\t\tif p == '\\'' {\n\t\t\t\tpos++\n\t\t\t\tbreak MainLoop\n\t\t\t}\n\t\t\tdst = append(dst, p)\n\n\t\t} else {\n\t\t\tswitch p {\n\t\t\tcase ' ', '\\n', '\\r', '\\t':\n\t\t\t\tbreak MainLoop\n\t\t\tcase '\"':\n\t\t\t\tif len(dst) != 0 {\n\t\t\t\t\tbreak MainLoop\n\t\t\t\t}\n\t\t\t\tinQ = true\n\t\t\tcase '\\'':\n\t\t\t\tif len(dst) != 0 {\n\t\t\t\t\tbreak MainLoop\n\t\t\t\t}\n\t\t\t\tinSQ = true\n\t\t\tdefault:\n\t\t\t\tdst = append(dst, p)\n\t\t\t}\n\t\t}\n\t\tpos++\n\t}\n\treturn dst, pos\n}", "title": "" }, { "docid": "a97d283db2ad4a0d0c1d351190e5ba15", "score": "0.47872928", "text": "func execRepeat(_ int, p *gop.Context) {\n\targs := p.GetArgs(2)\n\tret := strings.Repeat(args[0].(string), args[1].(int))\n\tp.Ret(2, ret)\n}", "title": "" }, { "docid": "96e5c147316c2003e5901ddda4bbde8f", "score": "0.47825903", "text": "func passEscapeSequence(write func(c byte) error, input string, i int) int {\n\tc := input[i]\n\n\tif write(c) != nil {\n\t\treturn i\n\t}\n\n\tswitch {\n\tcase c >= '0' && c <= '7':\n\t\ti = passOctalSequence(write, input, i+1)\n\tcase c == 'x':\n\t\ti = passHexadecimalSequence(write, input, i+1, 2)\n\tcase c == 'u':\n\t\ti = passHexadecimalSequence(write, input, i+1, 4)\n\tcase c == 'U':\n\t\ti = passHexadecimalSequence(write, input, i+1, 8)\n\t}\n\treturn i\n}", "title": "" }, { "docid": "83814e65471bd9f42800cbe6a3bbe8ff", "score": "0.4766692", "text": "func main() {\n\tx := \"10 -5 *2 \"\n\n\tgetOperation(x)\n}", "title": "" }, { "docid": "5b5964037625c275a00230be228973f7", "score": "0.47631812", "text": "func (s *BaseVerilogParserListener) EnterReal_identifier(ctx *Real_identifierContext) {}", "title": "" }, { "docid": "7e975847758f85cb58640a035e50c33b", "score": "0.47596636", "text": "func parse_arguments() {\n\tflag.StringVar(&protoClientPort, \"port\", \"443\", \"Port number for proto-client \")\n\tflag.IntVar(&segmentLimitParameter, \"n\", 200, \"The Segment number limit \")\n\tflag.BoolVar(&list, \"l\", false, \"List all the representations\")\n\tflag.BoolVar(&download, \"d\", false, \"Keep the video files after playback\")\n\tflag.BoolVar(&quic, \"quic\", false, \"Enable quic with quic-go library\")\n\tflag.BoolVar(&proto, \"proto\", false, \"Enable proto-quic client console for downloading segments\")\n\tflag.BoolVar(&h2, \"h2\", false, \"Enable http2\")\n\tflag.BoolVar(&h1, \"h1\", false, \"Enable http1.1\")\n\tflag.StringVar(&playbackType, \"p\", \"basic\", \"Playback type (basic, sara, netflix, or all)\")\n\tflag.StringVar(&mpdFullUrl, \"m\", \"https://caddy.quic/BigBuckBunny_4s.mpd\", \"Url to the MPD File\")\n\tflag.StringVar(&LOCAL_TEMP_DIR, \"f\", \"/home/sevket/go/src/github.com/sevketarisu/GoDashPlayer/dashquic/_tmp/DOWNLOADED/\", \"Temp folder for downloading segments\")\n\tflag.BoolVar(&java, \"java\", false, \"Enable java-client console for downloading segments\")\n\tflag.StringVar(&protoClientHostName, \"host\", \"127.0.0.1\", \"Hostname for proto client\")\n\tflag.IntVar(&repeatCount, \"r\", 10, \"Repeat count for playing file \")\n\tflag.Parse()\n}", "title": "" }, { "docid": "78414af486fafbe19bafe0b576d5dcc9", "score": "0.474874", "text": "func (s *BaseVerilogParserListener) EnterParameter_identifier(ctx *Parameter_identifierContext) {}", "title": "" }, { "docid": "eb23f9823794239abc40d21abb60177c", "score": "0.4745425", "text": "func setDef(t string) (int, string, error) {\n\n\tm := `(execute|call|within)\\((.*)\\)`\n\tre, err := regexp.Compile(m)\n\tif err != nil {\n\t\treturn 0, \"\", errors.New(\"bad regex\")\n\t}\n\n\tres := re.FindAllStringSubmatch(t, -1)\n\tif len(res[0]) == 3 {\n\t\tif res[0][1] == \"call\" {\n\t\t\treturn 1, res[0][2], nil\n\t\t} else if res[0][1] == \"execute\" {\n\t\t\treturn 2, res[0][2], nil\n\t\t} else if res[0][1] == \"within\" {\n\t\t\treturn 3, res[0][2], nil\n\t\t} else {\n\t\t\treturn 0, \"\", errors.New(\"bad pointcut\")\n\t\t}\n\t} else {\n\t\treturn 0, \"\", errors.New(\"bad pointcut\")\n\t}\n}", "title": "" }, { "docid": "68856edd4fe0ae8b20eb6dcc0c259a7c", "score": "0.47390503", "text": "func foo(arg string) {\n\tfmt.Println(\"Hello\", arg)\n}", "title": "" }, { "docid": "d9a65ab990acbc0efd1a115cca2884b1", "score": "0.47336245", "text": "func parseArgument() (string, string) {\n\tstr := flag.String(\"str\", \"\", \"string to match\")\n\tregex := flag.String(\"pat\", \"\", \"pattern to match\")\n\n\tflag.Parse()\n\n\t// if len(*str) == 0 { // allow empty string\n\t// \tpanic(\"No string\")\n\t// }\n\n\tif len(*regex) == 0 {\n\t\tpanic(\"No pattern\")\n\t}\n\n\treturn *str, *regex\n}", "title": "" }, { "docid": "c01a459c178584379f8d56269df74fa3", "score": "0.4730616", "text": "func (s *BaseZZListener) EnterAExp_identifier(ctx *AExp_identifierContext) {}", "title": "" }, { "docid": "8ae5431f868e76ddbe25288525dbc02c", "score": "0.47303212", "text": "func CommandName(text string) string {\n\tp := parser{text, 0}\n\tp.skipSpaces()\n\tmark := p.i\n\tif !p.skipAlphas() {\n\t\treturn \"\"\n\t}\n\treturn text[mark:p.i]\n}", "title": "" }, { "docid": "34918d2eefe787b3b0807ee550696f55", "score": "0.47206557", "text": "func SplitLiteralCommand(cl string) (name string, args []string) {\n\ta := SplitLiteral(cl)\n\tswitch len(a) {\n\tcase 0:\n\t\treturn\n\tcase 1:\n\t\tname = a[0]\n\tdefault:\n\t\tname = a[0]\n\t\targs = a[1:]\n\t}\n\treturn\n}", "title": "" }, { "docid": "9546a6bf71384e3594c7146254459d88", "score": "0.47021574", "text": "func ParamTokens(startAt, count int) string {\n\tif count < 1 {\n\t\treturn \"\"\n\t}\n\tvar str string\n\tfor i := startAt; i < startAt+count; i++ {\n\t\tstr = str + fmt.Sprintf(\"$%d\", i)\n\t\tif i < (startAt + count - 1) {\n\t\t\tstr = str + \",\"\n\t\t}\n\t}\n\treturn str\n}", "title": "" }, { "docid": "938e494ffde6483e3f42b1c6145e0903", "score": "0.46980652", "text": "func TestParseParamBeginEnd(t *testing.T) {\n\ttype date_pair struct {\n\t\tsrc, begin, end, exp string\n\t}\n\ttests := []date_pair{\n\t\t{\"xxxxxxbegin^_^end\", \"begin\", \"end\", \"^_^\"},\n\t\t{`symbol:\"sh600112\"`, `symbol:\"`, `\"`, \"sh600112\"},\n\t}\n\tfor i, td := range tests {\n\t\tact := string(ParseParamBeginEnd([]byte(td.src), []byte(td.begin), []byte(td.end)))\n\t\tif act != td.exp {\n\t\t\tt.Error(\n\t\t\t\t\"For\", \"case\", i,\n\t\t\t\t\"expected\", td.exp,\n\t\t\t\t\"got\", act,\n\t\t\t)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "0ccbc05633c2efd9898552b480d0d11c", "score": "0.46953315", "text": "func parseArgument(p *parser) *ast.Argument {\n\tvar label string\n\tvar labelStartPos, labelEndPos ast.Position\n\n\texpr := parseExpression(p, lowestBindingPower)\n\tp.skipSpaceAndComments(true)\n\n\t// If a colon follows the expression, the expression was our label.\n\tif p.current.Is(lexer.TokenColon) {\n\t\tidentifier, ok := expr.(*ast.IdentifierExpression)\n\t\tif !ok {\n\t\t\tpanic(fmt.Errorf(\n\t\t\t\t\"expected identifier for label, got %s\",\n\t\t\t\texpr,\n\t\t\t))\n\t\t}\n\t\tlabel = identifier.Identifier.Identifier\n\t\tlabelStartPos = expr.StartPosition()\n\t\tlabelEndPos = expr.EndPosition()\n\n\t\t// Skip the identifier\n\t\tp.next()\n\t\tp.skipSpaceAndComments(true)\n\n\t\texpr = parseExpression(p, lowestBindingPower)\n\t}\n\n\tif len(label) > 0 {\n\t\treturn &ast.Argument{\n\t\t\tLabel: label,\n\t\t\tLabelStartPos: &labelStartPos,\n\t\t\tLabelEndPos: &labelEndPos,\n\t\t\tExpression: expr,\n\t\t}\n\t}\n\treturn &ast.Argument{\n\t\tExpression: expr,\n\t}\n}", "title": "" }, { "docid": "d4ccf22a1a4db3c289b0d59bc80cf34d", "score": "0.46844602", "text": "func main() {\n\tstr := \"My name is %s and my lastname is %s.\\n\"\n\n\tfmt.Printf(str, \"Andrii\", \"Bekker\")\n}", "title": "" }, { "docid": "50a3384aad6b8505e1c165fc55adb8b4", "score": "0.46712324", "text": "func javaCallingArgStr(args []*compile.Field, leadingComma bool) string {\n\tvar buf bytes.Buffer\n\tfor i, arg := range args {\n\t\tif leadingComma || i > 0 {\n\t\t\tbuf.WriteString(\", \")\n\t\t}\n\t\tif arg.Name != \"\" {\n\t\t\tbuf.WriteString(arg.Name)\n\t\t} else {\n\t\t\tbuf.WriteString(fmt.Sprintf(\"arg%d\", i+1))\n\t\t}\n\t}\n\treturn buf.String()\n}", "title": "" }, { "docid": "4ee8ceab09f5d102fdb916cd134a0af3", "score": "0.4670939", "text": "func inputNumber() {\n\temitln(\"CALL SCANN\")\n}", "title": "" }, { "docid": "b22797e9a9c3fd15659211a159532664", "score": "0.46699393", "text": "func main() {\n\tflag.Parse()\n\n\tif len(flag.Args()) > 1 {\n\t\tfmt.Println(\"The program accept only a single parameter as input string\")\n\t\tos.Exit(1)\n\t}\n\n\tcmd := flag.Args()[0]\n\tif strings.Contains(cmd, \"\\n\") {\n\t\tfmt.Println(\"The input string needs to be on a single line\")\n\t\tos.Exit(1)\n\t}\n\n\t// we instantiate the expression holder that is responsible for checking the correctness of the cron expression string\n\texpressionHolder, err := expressions.NewDefaultSyntax(cmd)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\tos.Exit(1)\n\t}\n\n\t// We instantiate the parser that is responsbile for parsing the string and expands all the fields\n\tp, err := parsers.NewDefaultParser(expressionHolder)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\tos.Exit(1)\n\t}\n\n\t// We instantiate the printer that prints out the results based on a specific format/template\n\tprt := printers.NewSimple()\n\tres, err := p.Results()\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\tos.Exit(1)\n\t}\n\tprt.Print(res)\n}", "title": "" }, { "docid": "7b8908d0319b8b010d1d91265e41a2bd", "score": "0.46409857", "text": "func argNames(boxPrefix, argPrefix, first, second, last string, args []*compile.Field) string {\n\tvar result []string\n\tif first != \"\" {\n\t\tresult = append(result, first)\n\t}\n\tif second != \"\" {\n\t\tresult = append(result, second)\n\t}\n\tfor ix, arg := range args {\n\t\tname := arg.Name\n\t\tif argPrefix != \"\" {\n\t\t\tname = fmt.Sprintf(\"%s%d\", argPrefix, ix)\n\t\t}\n\t\tif arg.Type == vdl.ErrorType {\n\t\t\t// TODO(toddw): Also need to box user-defined external interfaces. Or can\n\t\t\t// we remove this special-case now?\n\t\t\tname = boxPrefix + name\n\t\t}\n\t\tresult = append(result, name)\n\t}\n\tif last != \"\" {\n\t\tresult = append(result, last)\n\t}\n\treturn strings.Join(result, \", \")\n}", "title": "" }, { "docid": "9a5f70a0c84ebbcbb3325abdd250a09a", "score": "0.4638973", "text": "func Identifier(parts ...interface{}) string {\n\treturn SepIdentifier(\":\", parts...)\n}", "title": "" }, { "docid": "517d1be4536c2b07b59db3e72c39e14e", "score": "0.4636685", "text": "func main() {\n\tfmt.Println(formatArguments_basic(os.Args))\n\tfmt.Println(formatArguments_range(os.Args))\n\tfmt.Println(formatArguments_join(os.Args))\n\n\t// Usefull for printing slices\n\tfmt.Println(os.Args[1:])\n}", "title": "" }, { "docid": "d3d84363643bd2ebdff8301e8d3ef33e", "score": "0.4625873", "text": "func regexpCommand(str string) []string {\n\treturn regexp.MustCompile(`[A-Za-z0-9_-]+`).FindAllString(\n\t\tregexp.MustCompile(`^[A-Za-z0-9_|\\(\\)\\s-]+`).FindString(str), -1)\n}", "title": "" }, { "docid": "f7d5f4ca4fe4f32801530ec05d734816", "score": "0.46234602", "text": "func execmNameToRDNSequence(_ int, p *gop.Context) {\n\targs := p.GetArgs(1)\n\tret := args[0].(pkix.Name).ToRDNSequence()\n\tp.Ret(1, ret)\n}", "title": "" }, { "docid": "35346b86c2dd03c92650eb3c724459c1", "score": "0.46161005", "text": "func SplitLiteral(cl string) (args []string) {\n\tvar (\n\t\tbuffer = make([]rune, len(cl)) // Buffer for current argument\n\t\tinQuote bool // Are we in a section escaped by quotes?\n\t\tinArg bool // Have we read some portion of an argument?\n\t\tslashes int // Current number of contiguous backslashes\n\t\tb int // Current position within buffer\n\t)\n\n\tfor _, runeValue := range cl {\n\t\tswitch runeValue {\n\t\tcase '\\\\':\n\t\t\tb = write(buffer, b, runeValue)\n\t\t\tinArg = true\n\t\t\tslashes++\n\t\tcase '\"':\n\t\t\tb = write(buffer, b, runeValue)\n\t\t\tinArg = true\n\t\t\tswitch slashes % 2 {\n\t\t\tcase 0:\n\t\t\t\t// A quote preceded by an even number of backslashes\n\t\t\t\tinQuote = !inQuote\n\t\t\tcase 1:\n\t\t\t\t// A quote preceded by an odd number of backslashes\n\t\t\t}\n\t\t\tslashes = 0\n\t\tcase ' ', '\\t':\n\t\t\tslashes = 0\n\t\t\tif inQuote {\n\t\t\t\t// A whitespace character within a quoted section\n\t\t\t\tb = write(buffer, b, runeValue)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif inArg {\n\t\t\t\t// A whitespace character terminating an argument\n\t\t\t\tb = flushArg(&args, buffer, b)\n\t\t\t\tinArg = false\n\t\t\t}\n\t\tdefault:\n\t\t\tinArg = true\n\t\t\tb = write(buffer, b, runeValue)\n\t\t\tslashes = 0\n\t\t}\n\t}\n\n\tif inArg {\n\t\tflushArg(&args, buffer, b)\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "852adacc6a1f9d0b9d7ce466d1a198fd", "score": "0.46150592", "text": "func spec(line int, text string) string {\n\treturn fmt.Sprintf(`\"%d|%s\"`, line, strings.ReplaceAll(text, `\"`, `\"\"`))\n}", "title": "" }, { "docid": "dc41694e40318fc7eac82979765036dd", "score": "0.4606532", "text": "func dateToken(start, end time.Time) string {\n\t// GitHub's GraphQL API silently fails if you provide it with an invalid time\n\t// string.\n\t// Dates before 1970 (unix epoch) are considered invalid.\n\tstartString, endString := \"*\", \"*\"\n\tif start.Year() >= 1970 {\n\t\tstartString = start.Format(github.SearchTimeFormat)\n\t}\n\tif end.Year() >= 1970 {\n\t\tendString = end.Format(github.SearchTimeFormat)\n\t}\n\treturn fmt.Sprintf(\"updated:%s..%s\", startString, endString)\n}", "title": "" }, { "docid": "7f3224e5d53decf61a7add89de09dbda", "score": "0.46036905", "text": "func print_arguments() {\n\tlog.WithFields(log.Fields{\n\t\t\"segmentLimitParameter\": segmentLimitParameter,\n\t\t\"list\": list,\n\t\t\"download\": download,\n\t\t\"quic\": quic,\n\t\t\"http2\": h2,\n\t\t\"playbackType\": playbackType,\n\t\t\"mpdFullUrl\": mpdFullUrl,\n\t\t\"LOCAL_TEMP_DIR\": LOCAL_TEMP_DIR,\n\t}).Infoln(\"DASH_CLIENT: Command Line Parameters:\")\n}", "title": "" }, { "docid": "984428237068e4606c21ac6440ea5816", "score": "0.46015972", "text": "func (s *scanner) scanIdent() token {\n\t// Create a buffer and read the current character into it.\n\tvar buf bytes.Buffer\n\tbuf.WriteRune(s.read())\n\n\t// Read every subsequent ident character into the buffer.\n\t// Non-ident characters and EOF will cause the loop to exit.\n\tfor {\n\t\tif ch := s.read(); ch == eof {\n\t\t\tbreak\n\t\t} else if !isLetter(ch) && !isDigit(ch) && ch != '-' && ch != '_' {\n\t\t\ts.unread()\n\t\t\tbreak\n\t\t} else {\n\t\t\t_, _ = buf.WriteRune(ch)\n\t\t}\n\t}\n\n\tstr := buf.String()\n\n\t// If the string matches a keyword then return that keyword\n\tswitch str {\n\tcase \"eq\":\n\t\treturn newToken(EQUAL, str)\n\tcase \"ne\":\n\t\treturn newToken(NOTEQUAL, str)\n\tcase \"handle\":\n\t\treturn newToken(HANDLE, str)\n\tcase \"client\":\n\t\treturn newToken(CLIENT, str)\n\tcase \"expect\":\n\t\treturn newToken(EXPECT, str)\n\tcase \"req\":\n\t\treturn newToken(REQ, str)\n\tcase \"resp\":\n\t\treturn newToken(RESP, str)\n\t\t// req/resp fields follow\n\tcase \"method\":\n\t\treturn newToken(METHOD, str)\n\tcase \"headers\":\n\t\treturn newToken(HEADERS, str)\n\tcase \"body\":\n\t\treturn newToken(BODY, str)\n\tcase \"status\":\n\t\treturn newToken(STATUS, str)\n\tcase \"tx\":\n\t\treturn newToken(TX, str)\n\t\t// tx arguments follow\n\tcase \"-body\":\n\t\treturn newToken(BODY_ARG, str)\n\tcase \"-status\":\n\t\treturn newToken(STATUS_ARG, str)\n\tcase \"-header\":\n\t\treturn newToken(HEADER_ARG, str)\n\tcase \"-method\":\n\t\treturn newToken(METHOD_ARG, str)\n\tcase \"-url\":\n\t\treturn newToken(URL_ARG, str)\n\t}\n\n\tif _, err := strconv.Atoi(str); err == nil {\n\t\t// Looks like an integer\n\t\treturn newToken(INTEGER, str)\n\t}\n\n\t// Otherwise assume this is illegal\n\treturn newToken(ILLEGAL, str)\n}", "title": "" }, { "docid": "b3abe129f71ba9407f97a311db49126d", "score": "0.4589549", "text": "func Repeat(arg string, times int) string {\n\tvar holder string\n\tfor i := 1; i <= times; i++ {\n\t\tholder += arg\n\t}\n\treturn holder\n}", "title": "" }, { "docid": "f9a8e3ca211ebf981f763d9c8bdaa802", "score": "0.45891714", "text": "func parameterList(count int) []Token {\n\ttokens := []Token{{Text: \"(\"}}\n\n\tif count != 0 {\n\t\ttokens = append(tokens, Token{Kind: \"implicit\", Text: \"?\"})\n\t\tfor count--; count != 0; count-- {\n\t\t\ttokens = append(tokens,\n\t\t\t\tToken{Text: \", \"},\n\t\t\t\tToken{Kind: \"implicit\", Text: \"?\"})\n\t\t}\n\t}\n\n\treturn append(tokens, Token{Text: \")\"})\n}", "title": "" }, { "docid": "65e53d3cb6a1cd2f67e65588920a858a", "score": "0.45806718", "text": "func (e *Server) parseParameters(str string, args []interface{}) (string, []interface{}) {\n re := regexp.MustCompile(`\\$(\\d+)`)\n sli := re.FindAllStringSubmatch(str, -1)\n newArgs := make([]interface{}, len(sli))\n for i, v := range sli {\n vi, err := strconv.ParseInt(v[1], 10, 0)\n if err != nil {\n log.Printf(\"%s\\n\", err)\n }\n newArgs[i] = args[vi-1]\n }\n return re.ReplaceAllString(str, \"?\"), newArgs\n}", "title": "" }, { "docid": "665a3d0300e23e629c1a01f06c2e7a38", "score": "0.45648718", "text": "func main() {\n\tname := \"Sam\"\n\tage, location := 24, \"Ibadan\"\n\tfmt.Printf(\"I am %s, %d years old from %s \", name, age, location)\n}", "title": "" }, { "docid": "c9cb236882049133664025cf2fdfe002", "score": "0.45642406", "text": "func ident(s string) string {\n\treturn s\n}", "title": "" }, { "docid": "7b693e68666ba30b8647c92d1566e9f6", "score": "0.45639092", "text": "func newIdentCmd(identifier string, pos parse.Pos) *parse.CommandNode {\n\treturn &parse.CommandNode{\n\t\tNodeType: parse.NodeCommand,\n\t\tArgs: []parse.Node{parse.NewIdentifier(identifier).SetTree(nil).SetPos(pos)}, // TODO: SetTree.\n\t}\n}", "title": "" }, { "docid": "8eef6ed976de3f3a2be12160e2c5c775", "score": "0.45636004", "text": "func addArg(msg *osc.Message, arg string) error {\n\tpieces := strings.Split(arg, argsep)\n\ttypetag, data := pieces[0], pieces[1]\n\tswitch typetag {\n\tdefault:\n\t\treturn errors.New(\"unsupported typetag: \" + typetag)\n\tcase \"s\":\n\t\tmsg.Arguments = append(msg.Arguments, osc.String(data))\n\tcase \"i\":\n\t\ti, err := strconv.ParseInt(data, 10, 64)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"could not parse integer from %s\", data)\n\t\t}\n\t\tmsg.Arguments = append(msg.Arguments, osc.Int(i))\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "a8251dc332c71a4c39052b3c665a85df", "score": "0.45554993", "text": "func main() {\n\t//otra forma de asignacion individual\n\ttexto := \"numeroEntero := 3\"\n\t//asignacion multiple\n\tdoce, ss, cuatro, ss2 := 12, \"txt en variable\", 4, \"txt concatenado\"\n\tfmt.Println(texto, \"\\n->\", doce, \"->\", ss, \"->\", cuatro, \"->\", ss2, \"\\n-algo\")\n\t//llamdo de funciones\n\tModTipadoFloat()\n\tModTipadoStringEntero()\n}", "title": "" }, { "docid": "e083235b74f7fd62168a2bd1e5f9b3db", "score": "0.45502812", "text": "func (c Command) ArgsSignature(pkg string, d Domain) string {\n\tvar args []string\n\tfor _, arg := range filter(optional(false), c.Parameters...) {\n\t\tname := arg.Name(d)\n\t\tif name == \"range\" || name == \"type\" {\n\t\t\tname = name[0 : len(name)-1]\n\t\t}\n\t\tname += \" \"\n\t\targs = append(args, name+arg.GoType(pkg, d))\n\t}\n\treturn strings.Join(args, \", \")\n}", "title": "" }, { "docid": "5afedfd05d7ec4ae387ead312e7c0174", "score": "0.4540689", "text": "func isValidArg(a string) bool {\n\tswitch a {\n\tcase \"from\", \"to\", \"orderasc\", \"orderdesc\", \"first\", \"offset\", \"after\", \"depth\":\n\t\treturn true\n\t}\n\treturn false\n}", "title": "" }, { "docid": "d3b8451b9da01f513922974fe83d0602", "score": "0.45180574", "text": "func Split(cl string) (args []string) {\n\tvar (\n\t\tbuffer = make([]rune, len(cl)) // Buffer for current argument\n\t\tinQuote bool // Are we in a section escaped by quotes?\n\t\tinArg bool // Have we read some portion of an argument?\n\t\tslashes int // Current number of contiguous backslashes\n\t\tb int // Current position within buffer\n\t)\n\n\tfor _, runeValue := range cl {\n\t\tswitch runeValue {\n\t\tcase '\\\\':\n\t\t\tinArg = true\n\t\t\tslashes++\n\t\tcase '\"':\n\t\t\tinArg = true\n\t\t\tswitch slashes % 2 {\n\t\t\tcase 0:\n\t\t\t\t// A quote preceded by an even number of backslashes\n\t\t\t\tb, slashes = writeSlashes(buffer, b, slashes/2)\n\t\t\t\tinQuote = !inQuote\n\t\t\tcase 1:\n\t\t\t\t// A quote preceded by an odd number of backslashes\n\t\t\t\tb, slashes = writeSlashes(buffer, b, (slashes-1)/2)\n\t\t\t\tb = write(buffer, b, '\"')\n\t\t\t}\n\t\tcase ' ', '\\t':\n\t\t\tb, slashes = writeSlashes(buffer, b, slashes)\n\t\t\tif inQuote {\n\t\t\t\t// A whitespace character within a quoted section\n\t\t\t\tb = write(buffer, b, runeValue)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif inArg {\n\t\t\t\t// A whitespace character terminating an argument\n\t\t\t\tb = flushArg(&args, buffer, b)\n\t\t\t\tinArg = false\n\t\t\t}\n\t\tdefault:\n\t\t\tinArg = true\n\t\t\tb, slashes = writeSlashes(buffer, b, slashes)\n\t\t\tb = write(buffer, b, runeValue)\n\t\t}\n\t}\n\n\tb, _ = writeSlashes(buffer, b, slashes)\n\tif inArg {\n\t\tflushArg(&args, buffer, b)\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "4b27ff2f2d925277a009f78e3655f3c3", "score": "0.45154634", "text": "func lrangeCommand(s *storage, r *request) (interface{}, error) {\n\tif r.argc != 3 {\n\t\treturn nil, ErrWrongNumOfArguments\n\t}\n\n\tstart, strerr := strconv.Atoi(r.argv[1])\n\tstop, stperr := strconv.Atoi(r.argv[2])\n\tif strerr != nil || stperr != nil {\n\t\treturn nil, ErrListValueOutOfRange\n\t}\n\n\tlist, err := findListEntry(s, r.argv[0])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlen := len(list)\n\tif len < 1 {\n\t\treturn nil, ErrListEmpty\n\t}\n\n\tif start >= len {\n\t\treturn nil, ErrListValueOutOfRange\n\t}\n\tif start < 0 {\n\t\tif start = len + start; start < 0 {\n\t\t\tstart = 0\n\t\t}\n\t}\n\tif stop < 0 {\n\t\tif stop = len + stop + 1; stop < 0 {\n\t\t\tstop = 0\n\t\t}\n\t}\n\tif stop > len {\n\t\tstop = len\n\t}\n\tif start > stop {\n\t\treturn nil, ErrListValueOutOfRange\n\t}\n\n\treturn list[start:stop], nil\n}", "title": "" }, { "docid": "e012ce36568098802e79b4a79fcde997", "score": "0.45130265", "text": "func (c *Cmd) parseArgs() error {\n\tnArgs := len(c.Args)\n\tif nArgs == 0 {\n\t\treturn nil\n\t}\n\n\tc.args = make([]argument, nArgs)\n\n\tvar chanArg, required, optional, variadic bool\n\n\tfor i := 0; i < nArgs; i++ {\n\t\targ := strings.ToLower(c.Args[i])\n\t\tif !rgxArgs.MatchString(arg) {\n\t\t\treturn fmt.Errorf(errFmtArgumentForm, arg)\n\t\t}\n\n\t\targMeta := &c.args[i]\n\t\targMeta.Original = arg\n\t\targMeta.Name = strings.Trim(c.Args[i], argStripChars)\n\t\tfor j := 0; j < i; j++ {\n\t\t\tif c.args[j].Name == argMeta.Name {\n\t\t\t\treturn fmt.Errorf(errFmtArgumentDupName, argMeta.Name)\n\t\t\t}\n\t\t}\n\n\t\tmodifier := arg[0]\n\t\tif modifier == '[' {\n\t\t\tmodifier = arg[1]\n\t\t}\n\t\tswitch modifier {\n\t\tcase '#':\n\t\t\tif chanArg {\n\t\t\t\treturn fmt.Errorf(errFmtArgumentDupChan, arg)\n\t\t\t} else if required || optional || variadic {\n\t\t\t\treturn fmt.Errorf(errFmtArgumentOrderChan, arg)\n\t\t\t}\n\t\t\targMeta.Type = CHANNEL\n\t\t\tchanArg = true\n\t\tcase '~':\n\t\t\targMeta.Type = NICK\n\t\tcase '*':\n\t\t\targMeta.Type = USER\n\t\t}\n\n\t\tswitch arg[len(arg)-1] {\n\t\tcase ']':\n\t\t\tif variadic {\n\t\t\t\treturn fmt.Errorf(errFmtArgumentOrderOpt, arg)\n\t\t\t}\n\t\t\targMeta.Type |= OPTIONAL\n\t\t\toptional = true\n\t\t\tc.optArgs++\n\t\tcase '.':\n\t\t\tif variadic {\n\t\t\t\treturn fmt.Errorf(errFmtArgumentDupVargs, arg)\n\t\t\t}\n\t\t\targMeta.Type |= VARIADIC\n\t\t\tvariadic = true\n\t\tdefault:\n\t\t\tif optional {\n\t\t\t\treturn fmt.Errorf(errFmtArgumentOrderReq, arg)\n\t\t\t}\n\t\t\targMeta.Type |= REQUIRED\n\t\t\trequired = true\n\t\t\tc.reqArgs++\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "47cacd6c6527d818a4a240980c1ab6f0", "score": "0.45112503", "text": "func argumentKey(id uint64) []byte {\n\treturn buildKey(ArgumentsKeyPrefix, id)\n}", "title": "" }, { "docid": "f64cf428e980598c218d7534efd7a843", "score": "0.45048025", "text": "func (s *BaseVerilogParserListener) EnterSpecparam_identifier(ctx *Specparam_identifierContext) {}", "title": "" }, { "docid": "ad5fe7a5c9f1e04b8687e7e18decff69", "score": "0.45023862", "text": "func (s *BasematlabListener) EnterIdentifier_list(ctx *Identifier_listContext) {}", "title": "" }, { "docid": "3bdb57f492ec45bb9e5393fbb56b8bd8", "score": "0.45017475", "text": "func defineInvocationExpression() {\n\tsetExprLeftBindingPower(lexer.TokenParenOpen, exprLeftBindingPowerAccess)\n\tsetExprLeftDenotation(\n\t\tlexer.TokenParenOpen,\n\t\tfunc(p *parser, token lexer.Token, left ast.Expression) ast.Expression {\n\t\t\targuments, endPos := parseArgumentListRemainder(p)\n\t\t\treturn &ast.InvocationExpression{\n\t\t\t\tInvokedExpression: left,\n\t\t\t\tArguments: arguments,\n\t\t\t\tArgumentsStartPos: token.EndPos,\n\t\t\t\tEndPos: endPos,\n\t\t\t}\n\t\t},\n\t)\n}", "title": "" }, { "docid": "a1bee8d55fca2327effd9ebf57107a4e", "score": "0.44994763", "text": "func (s *tokenScanner) scanIdentifier() token {\n\ti := s.pos\n\n\t// advance to the first non-identifier character\n\tfor ; s.pos < len(s.bytes); s.pos++ {\n\t\tc := s.bytes[s.pos]\n\n\t\t// validate identifier characters\n\t\tif (c < 'A' || c > 'Z') && (c < '0' || c > '9') && c != '_' {\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// extract the label\n\tid := string(s.bytes[i:s.pos])\n\n\t// determine whether the label is an instruction, register or reference\n\tswitch id {\n\tcase \"V0\":\n\t\treturn token{typ: TOKEN_V, val: 0}\n\tcase \"V1\":\n\t\treturn token{typ: TOKEN_V, val: 1}\n\tcase \"V2\":\n\t\treturn token{typ: TOKEN_V, val: 2}\n\tcase \"V3\":\n\t\treturn token{typ: TOKEN_V, val: 3}\n\tcase \"V4\":\n\t\treturn token{typ: TOKEN_V, val: 4}\n\tcase \"V5\":\n\t\treturn token{typ: TOKEN_V, val: 5}\n\tcase \"V6\":\n\t\treturn token{typ: TOKEN_V, val: 6}\n\tcase \"V7\":\n\t\treturn token{typ: TOKEN_V, val: 7}\n\tcase \"V8\":\n\t\treturn token{typ: TOKEN_V, val: 8}\n\tcase \"V9\":\n\t\treturn token{typ: TOKEN_V, val: 9}\n\tcase \"VA\":\n\t\treturn token{typ: TOKEN_V, val: 10}\n\tcase \"VB\":\n\t\treturn token{typ: TOKEN_V, val: 11}\n\tcase \"VC\":\n\t\treturn token{typ: TOKEN_V, val: 12}\n\tcase \"VD\":\n\t\treturn token{typ: TOKEN_V, val: 13}\n\tcase \"VE\":\n\t\treturn token{typ: TOKEN_V, val: 14}\n\tcase \"VF\":\n\t\treturn token{typ: TOKEN_V, val: 15}\n\tcase \"R\":\n\t\treturn token{typ: TOKEN_R}\n\tcase \"I\":\n\t\treturn token{typ: TOKEN_I}\n\tcase \"F\":\n\t\treturn token{typ: TOKEN_F}\n\tcase \"HF\":\n\t\treturn token{typ: TOKEN_HF}\n\tcase \"K\":\n\t\treturn token{typ: TOKEN_K}\n\tcase \"A\":\n\t\treturn token{typ: TOKEN_ASCII}\n\tcase \"D\", \"DT\":\n\t\treturn token{typ: TOKEN_DT}\n\tcase \"S\", \"ST\":\n\t\treturn token{typ: TOKEN_ST}\n\tcase \"CLS\", \"RET\", \"EXIT\", \"LOW\", \"HIGH\", \"SCU\", \"SCD\", \"SCR\", \"SCL\", \"SYS\", \"JP\", \"CALL\", \"SE\", \"SNE\", \"SGT\", \"SLT\", \"SKP\", \"SKNP\", \"LD\", \"OR\", \"AND\", \"XOR\", \"ADD\", \"SUB\", \"SUBN\", \"MUL\", \"DIV\", \"SHR\", \"SHL\", \"BCD\", \"RND\", \"DRW\":\n\t\treturn token{typ: TOKEN_INSTRUCTION, val: id}\n\tcase \"ASCII\", \"BYTE\", \"WORD\", \"ALIGN\", \"PAD\":\n\t\treturn token{typ: TOKEN_INSTRUCTION, val: id}\n\tcase \"BREAK\":\n\t\treturn token{typ: TOKEN_BREAK}\n\tcase \"ASSERT\":\n\t\treturn token{typ: TOKEN_ASSERT}\n\tcase \"EQU\":\n\t\treturn token{typ: TOKEN_EQU}\n\tcase \"VAR\":\n\t\treturn token{typ: TOKEN_VAR}\n\tcase \"SUPER\":\n\t\treturn token{typ: TOKEN_SUPER}\n\tcase \"EXTENDED\":\n\t\treturn token{typ: TOKEN_EXTENDED}\n\t}\n\n\tif i == 0 {\n\t\treturn token{typ: TOKEN_LABEL, val: id}\n\t} else {\n\t\treturn token{typ: TOKEN_ID, val: id}\n\t}\n}", "title": "" }, { "docid": "f423544037c6c26f530ebe96a9e70e66", "score": "0.44966796", "text": "func _1677addArgumentToVtab(tls crt.TLS, _pParse uintptr /* *TParse = SParse */) {\n\tvar (\n\t\t_z uintptr // *int8\n\t\t_n int32\n\t\t_db uintptr // *Tsqlite3 = Ssqlite3\n\t)\n\tif (*(*uintptr)(unsafe.Pointer(_pParse + 536))) == 0 || (*(*uintptr)(unsafe.Pointer(_pParse + 512))) == 0 {\n\t\tgoto _1\n\t}\n\n\t_z = *(*uintptr)(unsafe.Pointer(_pParse + 536))\n\t_n = int32(*(*uint32)(unsafe.Pointer((_pParse + 536) + 8)))\n\t_db = *(*uintptr)(unsafe.Pointer(_pParse))\n\t_1422addModuleArgument(tls, _db, *(*uintptr)(unsafe.Pointer(_pParse + 512)), _618sqlite3DbStrNDup(tls, _db, _z, uint64(_n)))\n_1:\n}", "title": "" }, { "docid": "2edb0a596333009acac819e59e350b85", "score": "0.449602", "text": "func main() {\n var token Token\n src := \"(call (identifier +) (integer 10) (integer 20))\"\n idx := 0\n offset := 0\n fmt.Printf(\"src: %s\\n\", src)\n for ; idx < 15; idx++ {\n token = next(src, offset)\n offset = token.lexeme_offset + len(token.lexeme)\n fmt.Printf(\"token: %s, offset: %d\\n\", token.lexeme, offset)\n }\n\n result := read_list(src, 0)\n\n fmt.Printf(\"result: %T%v\\n\", result, result)\n\n roundtrip := sexpression2string(result)\n\n fmt.Printf(\"round trip? %s\\n\", roundtrip)\n}", "title": "" }, { "docid": "abbc211e9595ab0826578e58ce803ae1", "score": "0.44946754", "text": "func (s *BaseformulaListener) EnterArguments(ctx *ArgumentsContext) {}", "title": "" }, { "docid": "458fa88bf9d3484276c045e6967acdc7", "score": "0.44940037", "text": "func createNewID(cmd *cobra.Command, args []string) error {\n\tpanic(\"Implement me\")\n}", "title": "" }, { "docid": "28b115b27400616df88d5176fd37ace3", "score": "0.44923455", "text": "func (p *parser) parseArguments(elementKind string) (*token, *ast.Arguments, bool, errors.StaticError) {\n\targs := &ast.Arguments{}\n\tgotComma := false\n\tnamedArgumentAdded := false\n\tfirst := true\n\tfor {\n\t\tcommaFodder := ast.Fodder{}\n\t\tnext := p.peek()\n\n\t\tif next.kind == tokenParenR {\n\t\t\t// gotComma can be true or false here.\n\t\t\treturn p.pop(), args, gotComma, nil\n\t\t}\n\n\t\tif !first && !gotComma {\n\t\t\treturn nil, nil, false, errors.MakeStaticError(fmt.Sprintf(\"Expected a comma before next %s, got %s\", elementKind, next), next.loc)\n\t\t}\n\n\t\tidFodder, id, eqFodder, expr, err := p.parseArgument()\n\t\tif err != nil {\n\t\t\treturn nil, nil, false, err\n\t\t}\n\n\t\tif p.peek().kind == tokenComma {\n\t\t\tcomma := p.pop()\n\t\t\tgotComma = true\n\t\t\tcommaFodder = comma.fodder\n\t\t} else {\n\t\t\tgotComma = false\n\t\t}\n\n\t\tif id == nil {\n\t\t\tif namedArgumentAdded {\n\t\t\t\treturn nil, nil, false, errors.MakeStaticError(\"Positional argument after a named argument is not allowed\", next.loc)\n\t\t\t}\n\t\t\tel := ast.CommaSeparatedExpr{Expr: expr}\n\t\t\tif gotComma {\n\t\t\t\tel.CommaFodder = commaFodder\n\t\t\t}\n\t\t\targs.Positional = append(args.Positional, el)\n\t\t} else {\n\t\t\tnamedArgumentAdded = true\n\t\t\targs.Named = append(args.Named, ast.NamedArgument{\n\t\t\t\tNameFodder: idFodder,\n\t\t\t\tName: *id,\n\t\t\t\tEqFodder: eqFodder,\n\t\t\t\tArg: expr,\n\t\t\t\tCommaFodder: commaFodder,\n\t\t\t})\n\t\t}\n\n\t\tfirst = false\n\t}\n}", "title": "" }, { "docid": "873e09bdbb7f14bf56fa4f2b8cc8c9b5", "score": "0.44905758", "text": "func main() {\n var start = time.Now().UnixNano()\n s, sep := \"\", \"\"\n for _, arg := range os.Args[1:] {\n s += sep + arg\n sep = \" \"\n }\n fmt.Println(s)\n durationFor := time.Now().UnixNano() - start\n\n start = time.Now().UnixNano()\n fmt.Println(strings.Join(os.Args[0:], \" \"))\n durationJoin := time.Now().UnixNano() - start\n\n fmt.Printf(\"durationFor: %d nanoseconds\\n\", durationFor)\n fmt.Printf(\"durationJoin: %d nano\", durationJoin)\n}", "title": "" }, { "docid": "3300a75fbe5bb4d09a856fa307cc6b27", "score": "0.4484028", "text": "func foo(name string) {\n\tfmt.Println(\"Hello\" , name)\n}", "title": "" }, { "docid": "0777c15a04493f85f2adeb21ea801cbf", "score": "0.4478129", "text": "func addPeriod(str string) string {\n\t// featuring (1)\n\tr := regexp.MustCompile(` feat `)\n\tstr = r.ReplaceAllString(str, \" feat. \")\n\t// featuring (2)\n\tr = regexp.MustCompile(` ft `)\n\tstr = r.ReplaceAllString(str, \" ft. \")\n\t// versus\n\tr = regexp.MustCompile(` vs `)\n\treturn r.ReplaceAllString(str, \" vs. \")\n}", "title": "" }, { "docid": "2eabdd905803c1c735de4af8963c34f6", "score": "0.44767687", "text": "func main() {\n\n\tbase := flag.String(\"currency\", \"USD\", \"a string\")\n\tstartdate := flag.String(\"startdate\", \"2018-02-02\", \"a string\")\n\tenddate := flag.String(\"enddate\", \"2018-02-06\", \"a string\")\n\tflag.Parse()\n\n\tURLNameStart := fmt.Sprintf(URL, *startdate, *base)\n\tURLNameEnd := fmt.Sprintf(URL, *enddate, *base)\n\n\texratesStart := FromURL(URLNameStart)\n\texratesEnd := FromURL(URLNameEnd)\n\n\tfmt.Printf(\"Base value: %s \\n\", exratesStart.Base)\n\tfmt.Printf(\"Start Date: %s \\n\", exratesStart.Date)\n\tfmt.Printf(\"End Date: %s \\n\", exratesEnd.Date)\n\tfor k, v := range exratesStart.Rates {\n\t\tfmt.Printf(\"Currency: %s Difference: %5.2f%%\\n\", k, Percentage(v, exratesEnd.Rates[k]))\n\t}\n}", "title": "" }, { "docid": "06f88e640a858e75351e5992d2550099", "score": "0.44662794", "text": "func execSplit(_ int, p *gop.Context) {\n\targs := p.GetArgs(2)\n\tret := strings.Split(args[0].(string), args[1].(string))\n\tp.Ret(2, ret)\n}", "title": "" }, { "docid": "4d1dda861b6b82d495052f637b030455", "score": "0.44590643", "text": "func (s *BasematlabListener) EnterAnd_expression(ctx *And_expressionContext) {}", "title": "" }, { "docid": "06e9842b355964468cb076e69a4ff3b0", "score": "0.44495887", "text": "func functionName(param1 string, param2 int) {}", "title": "" }, { "docid": "8d1dbe3b99aad48c5494b909d3b308f2", "score": "0.44460362", "text": "func (p *Parser) Arg1() string {\n\ttokens := strings.Fields(p.CurrentCommand)\n\tswitch p.CurrentCommandType {\n\tcase CArithmetic:\n\t\treturn tokens[0]\n\tdefault:\n\t\treturn tokens[1]\n\t}\n}", "title": "" }, { "docid": "3aa06d598717aac4403cb91aa5ff31ea", "score": "0.44437352", "text": "func QuoteIdent(segments ...string) string {\n\tvar buf bytes.Buffer\n\tfor i, segment := range segments {\n\t\tneedQuote := IdentNeedsQuotes(segment) ||\n\t\t\t((i < len(segments)-1) && segment != \"\") || // not last segment && not \"\"\n\t\t\t((i == 0 || i == len(segments)-1) && segment == \"\") // the first or last segment and an empty string\n\n\t\tif needQuote {\n\t\t\t_ = buf.WriteByte('\"')\n\t\t}\n\n\t\t_, _ = buf.WriteString(qiReplacer.Replace(segment))\n\n\t\tif needQuote {\n\t\t\t_ = buf.WriteByte('\"')\n\t\t}\n\n\t\tif i < len(segments)-1 {\n\t\t\t_ = buf.WriteByte('.')\n\t\t}\n\t}\n\treturn buf.String()\n}", "title": "" }, { "docid": "f78d17f5c6eed791e6bc7b97898aabb0", "score": "0.44369778", "text": "func decodeCommand(command elev.Action) HallOrderElement {\n\tparameterList := strings.Split(command.Parameters, \" \")\n\tdirection := parameterList[0]\n\tfloor, _ := strconv.Atoi(parameterList[1])\n\n\treturn HallOrderElement{Command: command.Command, Direction: direction, Floor: floor}\n}", "title": "" }, { "docid": "7d4e94769a9cc6f8672a8ed282803fc2", "score": "0.443275", "text": "func method2() {\n s, sep := \"\", \"\"\n for _, arg := range os.Args[1:] {\n s += sep + arg\n sep = \", \"\n }\n fmt.Println(s)\n}", "title": "" }, { "docid": "9fc038a16e41075aa6a516f329c6b703", "score": "0.44304305", "text": "func Ident(p string) (string, string, error) {\n\tvar x int\n\n\tif c, w := utf8.DecodeRuneInString(p); !unicode.IsLetter(c) && c != '_' {\n\t\treturn \"\", p, ErrInvalidSequence\n\t} else {\n\t\tx += w\n\t}\n\n\tl := len(p)\n\tfor x < l {\n\t\tc, w := utf8.DecodeRuneInString(p[x:])\n\t\tif !unicode.IsLetter(c) && !unicode.IsDigit(c) && c != '_' {\n\t\t\tbreak\n\t\t}\n\t\tx += w\n\t}\n\n\treturn p[:x], p[x:], nil\n}", "title": "" }, { "docid": "4263855f100841dc0de57874eb1adf7e", "score": "0.44276512", "text": "func main() {\n\tvar n, m int\n\tfmt.Scanf(\"%d %d\", &n, &m)\n\n\tfmt.Println(abc159A(n, m))\n}", "title": "" }, { "docid": "5ff5de9a65361e0a97cb30883aeae73f", "score": "0.44257358", "text": "func consumeIdentifier(l *Lexer) {\n\tvar ident string\n\tfor p := l.Peek(); isLetter(p) || isDigit(p); {\n\t\tident += string(p)\n\t\tl.Next()\n\t\tp = l.Peek()\n\t}\n\tif strings.Compare(ident, \"print\") == 0 {\n\t\tl.Emit(TokenPrint)\n\t} else if strings.Compare(ident, \"while\") == 0 {\n\t\tl.Emit(TokenWhile)\n\t} else {\n\t\tl.Emit(TokenName)\n\t}\n}", "title": "" }, { "docid": "5c604f59b0134e33ed2df12380b5e87f", "score": "0.44243115", "text": "func addEphPattern(rec *ephemera.Recorder, els ...string) {\n\tfor i := 0; i < len(els); i += 4 {\n\t\tdec, _ := strconv.ParseBool(els[i+3])\n\t\tvar category string\n\t\tif dec {\n\t\t\tcategory = tables.NAMED_PARAMETER\n\t\t} else {\n\t\t\tcategory = tables.NAMED_ARGUMENT\n\t\t}\n\n\t\tpat := rec.NewName(els[i+0], tables.NAMED_PATTERN, strconv.Itoa(i))\n\t\targ := pat\n\t\tif n := els[i+1]; len(n) > 0 {\n\t\t\targ = rec.NewName(els[i+1], category, strconv.Itoa(i))\n\t\t}\n\t\ttyp := rec.NewName(els[i+2], tables.NAMED_TYPE, strconv.Itoa(i))\n\n\t\tif dec {\n\t\t\trec.NewPatternDecl(pat, arg, typ, \"\")\n\t\t} else {\n\t\t\trec.NewPatternRef(pat, arg, typ, \"\")\n\t\t}\n\t}\n}", "title": "" }, { "docid": "ab06e61bd783ee92e0584fea0cd99eb0", "score": "0.44213563", "text": "func (fcomp *fcomp) args(call *syntax.CallExpr) (op Opcode, arg uint32) {\n\tvar callmode int\n\t// Compute the number of each kind of parameter.\n\tvar p, n int // number of positional, named arguments\n\tvar varargs, kwargs syntax.Expr\n\tfor _, arg := range call.Args {\n\t\tif binary, ok := arg.(*syntax.BinaryExpr); ok && binary.Op == syntax.EQ {\n\n\t\t\t// named argument (name, value)\n\t\t\tfcomp.string(binary.X.(*syntax.Ident).Name)\n\t\t\tfcomp.expr(binary.Y)\n\t\t\tn++\n\t\t\tcontinue\n\t\t}\n\t\tif unary, ok := arg.(*syntax.UnaryExpr); ok {\n\t\t\tif unary.Op == syntax.STAR {\n\t\t\t\tcallmode |= 1\n\t\t\t\tvarargs = unary.X\n\t\t\t\tcontinue\n\t\t\t} else if unary.Op == syntax.STARSTAR {\n\t\t\t\tcallmode |= 2\n\t\t\t\tkwargs = unary.X\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\t// positional argument\n\t\tfcomp.expr(arg)\n\t\tp++\n\t}\n\n\t// Python2 and Python3 both permit named arguments\n\t// to appear both before and after a *args argument:\n\t// f(1, 2, x=3, *[4], y=5, **dict(z=6))\n\t//\n\t// They also differ in their evaluation order:\n\t// Python2: 1 2 3 5 4 6 (*args and **kwargs evaluated last)\n\t// Python3: 1 2 4 3 5 6 (positional args evaluated before named args)\n\t// Starlark-in-Java historically used a third order:\n\t// Lexical: 1 2 3 4 5 6 (all args evaluated left-to-right)\n\t//\n\t// After discussion in github.com/bazelbuild/starlark#13, the\n\t// spec now requires Starlark to statically reject named\n\t// arguments after *args (e.g. y=5), and to use Python2-style\n\t// evaluation order. This is both easy to implement and\n\t// consistent with lexical order:\n\t//\n\t// f(1, 2, x=3, *[4], **dict(z=6)) # 1 2 3 4 6\n\n\t// *args\n\tif varargs != nil {\n\t\tfcomp.expr(varargs)\n\t}\n\n\t// **kwargs\n\tif kwargs != nil {\n\t\tfcomp.expr(kwargs)\n\t}\n\n\t// TODO(adonovan): avoid this with a more flexible encoding.\n\tif p >= 256 || n >= 256 {\n\t\t// resolve already checked this; should be unreachable\n\t\tpanic(\"too many arguments in call\")\n\t}\n\n\treturn CALL + Opcode(callmode), uint32(p<<8 | n)\n}", "title": "" }, { "docid": "c0e4a6eab838fbcb2d157234afbb706b", "score": "0.4420652", "text": "func (s *BaseVerilogParserListener) EnterPort_identifier(ctx *Port_identifierContext) {}", "title": "" }, { "docid": "5a2da3858958ad43ac293b512c285df0", "score": "0.44202256", "text": "func main() {\n\tvar a int\n\tvar s string\n\tfmt.Scanf(\"%d\", &a)\n\tfmt.Scanf(\"%s\", &s)\n\n\tfmt.Println(abc138A(a, s))\n}", "title": "" }, { "docid": "1becdeab22263499a152592e486e7fc0", "score": "0.441607", "text": "func add(s string) {\n\targ := make([]uint8, 4)\n\ts = strings.Trim(s, \"\\n\")\n\tsSlice := strings.Split(s, \" \")\n\n\tswitch sSlice[0] {\n\tcase \"protocol_version\":\n\t\targ[0] = 6\n\tcase \"name\":\n\t\targ[0] = 7\n\tcase \"version\":\n\t\targ[0] = 8\n\tcase \"list_commands\":\n\t\targ[0] = 9\n\tcase \"quit\":\n\t\targ[0] = 5\n\tcase \"clear_board\":\n\t\targ[0] = 4\n\tcase \"known_commands\":\n\t\targ[0] = 10\n\t\tknown := 0\n\t\tfor _, v := range commands {\n\t\t\tif strings.EqualFold(sSlice[1], v) {\n\t\t\t\tknown = 1\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\targ[1] = uint8(known)\n\tcase \"genmove\":\n\t\targ[0] = 1\n\t\targ[1] = FromColorStr(sSlice[1])\n\tcase \"boardsize\":\n\t\tsize, _ := strconv.ParseUint(sSlice[1], 10, 8)\n\t\targ[0] = 3\n\t\targ[1] = uint8(size)\n\tcase \"komi\":\n\t\tkomi, _ := strconv.ParseFloat(sSlice[1], 32)\n\t\tkomi = komi / 0.5 // convert to number of half points\n\t\tkomiInt := uint8(komi)\n\t\targ[0] = 2\n\t\targ[1] = komiInt\n\tcase \"play\":\n\t\targ[0] = 0\n\t\targ[1] = FromColorStr(sSlice[1])\n\t\targ[2], arg[3] = ToXY(sSlice[2])\n\tdefault:\n\t\targ[0] = 255\n\t}\n\treceived <- arg\n}", "title": "" }, { "docid": "7cd82b198840b6767508cfa0bfb590fd", "score": "0.44151425", "text": "func RangeArgs(min int, max int) PositionalArgs {\n\treturn func(cmd *Command, args []string) error {\n\t\tif len(args) < min || len(args) > max {\n\t\t\treturn fmt.Errorf(\"accepts between %d and %d arg(s), received %d\", min, max, len(args))\n\t\t}\n\t\treturn nil\n\t}\n}", "title": "" }, { "docid": "e88937ce33d241b3bb49362fd6634a48", "score": "0.44136113", "text": "func (s *Scanner) Date(name string) *Scanner {\n\tcount := len(s.ParamDefinitions)\n\ts.ParamDefinitions[count+1] = &ParamDefinition{Type: Date, Name: name}\n\treturn s\n}", "title": "" }, { "docid": "0848b35659d280cb13c54bd4ede0ff03", "score": "0.44123057", "text": "func (s *BaseKotlinParserListener) EnterAssignableSuffix(ctx *AssignableSuffixContext) {}", "title": "" }, { "docid": "e42987ff42e9feff4d0a283d01419b59", "score": "0.44117293", "text": "func (p *parser) parseArgument() (ast.Fodder, *ast.Identifier, ast.Fodder, ast.Node, errors.StaticError) {\n\tvar idFodder ast.Fodder\n\tvar id *ast.Identifier\n\tvar eqFodder ast.Fodder\n\tif p.peek().kind == tokenIdentifier && p.doublePeek().kind == tokenOperator && p.doublePeek().data == \"=\" {\n\t\tident := p.pop()\n\t\tvar tmpID = ast.Identifier(ident.data)\n\t\tid = &tmpID\n\t\tidFodder = ident.fodder\n\t\teq := p.pop()\n\t\teqFodder = eq.fodder\n\t}\n\texpr, err := p.parse(maxPrecedence)\n\tif err != nil {\n\t\treturn nil, nil, nil, nil, err\n\t}\n\treturn idFodder, id, eqFodder, expr, nil\n}", "title": "" }, { "docid": "e6d435b20ebc38084f262e16e3d46cb9", "score": "0.4411729", "text": "func Arguments() {\n\t//count argument\n\t//count := len(os.Args) - 1\n\t//fmt.Printf(\"There are %d names.\\n\", count)\n\n\t//print the path\n\t//fmt.Println(os.Args[2])\n\n\t//fmt.Println(\"Hello\", os.Args[1])\n\t//fmt.Println(\"How are you?\")\n\n\tvar (\n\t\tl = len(os.Args) - 1\n\t\tn1 = os.Args[1]\n\t\tn2 = os.Args[2]\n\t\tn3 = os.Args[3]\n\t)\n\n\tfmt.Println(\"There are\", l, \"people !\")\n\tfmt.Println(\"Hello great\", n1, \"!\")\n\tfmt.Println(\"Hello great\", n2, \"!\")\n\tfmt.Println(\"Hello great\", n3, \"!\")\n\tfmt.Println(\"Nice to meet you all.\")\n\n}", "title": "" }, { "docid": "c07d5a4872f852e6c0f2c87377ba2264", "score": "0.44073957", "text": "func MyEcho2() {\n\tfmt.Println(\"Pattern1 start...\")\n\tstart1 := time.Now()\n\t// Patten 1\n\t// using range\n\ts, sep := \"\", \"\"\n\tfor _, arg := range os.Args[1:] { // range generates index, value\n\t\ts += sep + arg\n\t\tsep = \" \"\n\t}\n\tfmt.Println(s)\n\tgoal1 := time.Now()\n\n\tfmt.Println(\"Pattern2 start...\")\n\tstart2 := time.Now()\n\t// Pattern 2\n\t// this returns process name & result\n\t// fmt.Printf(\"Process name:\\n%v\\n\\n\", os.Args[0])\n\t// fmt.Printf(\"Result:\\n\")\n\tfmt.Printf(strings.Join(os.Args[1:], \" \"))\n\tgoal2 := time.Now()\n\n\t// Pattern 3\n\t// index, value\n\t//for key, val := range os.Args[1:] {\n\t//\tfmt.Printf(\"%v: %v\", key, val)\n\t//}\n\n\t// measure time\n\tfmt.Printf(\"\\nPattern1:\\n%v\\nPattern2:\\n%v\", goal1.Sub(start1), goal2.Sub(start2))\n}", "title": "" }, { "docid": "998f475b3095b8858d5d39ba83bd97f1", "score": "0.44058812", "text": "func RunCommand(format string, command ...interface{}) {\n runCommand(format, command...)\n}", "title": "" }, { "docid": "426fcc8b39db67b7ba49baf02854d678", "score": "0.44030592", "text": "func (s *BaseVerilogParserListener) EnterEscaped_arrayed_identifier(ctx *Escaped_arrayed_identifierContext) {\n}", "title": "" }, { "docid": "a4e955ea96a2a951809edd444b77d02b", "score": "0.44003144", "text": "func printHelp(name string) {\n\tfn := strings.Split(name, \"\\\\\")\n\tfmt.Printf(\"Usage:\\n\\t%q <CarName> <RPCServerIP:port>\\n\", fn[len(fn)-1])\n\tfmt.Printf(\"\\tCarName range {R1, R2, B1, B2}\\n\")\n}", "title": "" }, { "docid": "1de48e3513f96bc5c6defecc60f27c5d", "score": "0.43952456", "text": "func oneInput(s string) {\n\tfmt.Println(\"oneInput\", s)\n}", "title": "" }, { "docid": "7f3cca11ac5e068f55ce18dc4b340f27", "score": "0.4393247", "text": "func (this *import_data_parser) expect_ident(ident string) {\n\ttok := this.expect(scanner.Ident)\n\tif tok != ident {\n\t\tthis.errorf(\"expected identifier: \\\"%s\\\", got: \\\"%s\\\"\", ident, tok)\n\t}\n}", "title": "" }, { "docid": "8a9ad2349c49b8679c6e1ad419bc5321", "score": "0.43839183", "text": "func Set(args ...string) string {\n\treturn fmt.Sprintf(\"~%d\\r\\n\", len(args)) + strings.Join(args, \"\")\n}", "title": "" }, { "docid": "624807ed8b8c744edc10404d12f594b8", "score": "0.43780267", "text": "func (s *BaseVerilogParserListener) EnterInput_identifier(ctx *Input_identifierContext) {}", "title": "" }, { "docid": "c3948aeaeb93ee6c71dbb57b9f7b1f0b", "score": "0.4375132", "text": "func execFields(_ int, p *gop.Context) {\n\targs := p.GetArgs(1)\n\tret := strings.Fields(args[0].(string))\n\tp.Ret(1, ret)\n}", "title": "" }, { "docid": "9d34546bf2fc3f3f6fa3c933c8530d5b", "score": "0.43744054", "text": "func main() {\n\ts, sep := os.Args[0] + \" \", \"\"\n\tfor _, arg := range os.Args[1:] {\n\t\ts += sep + arg\n\t\tsep = \" \"\n\t}\n\tfmt.Println(s)\n}", "title": "" }, { "docid": "ca5d5d7730e73a6a56ca43f9cea086f7", "score": "0.43715584", "text": "func prototype(xyz []string) {}", "title": "" } ]
65db054707c173411956930a66617f26
ShuffleBallots shuffles the ballots in an election.
[ { "docid": "5df6f5ed468ec3201015bf00d88f47b4", "score": "0.7120376", "text": "func (h *HTTP) ShuffleBallots(w http.ResponseWriter, r *http.Request) {\n\tshuffleBallotsRequest := &types.ShuffleBallotsRequest{}\n\terr := json.NewDecoder(r.Body).Decode(shuffleBallotsRequest)\n\tif err != nil {\n\t\thttp.Error(w, \"failed to decode ShuffleBallotsRequest: \"+err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\telectionsMetadata, err := h.getElectionsMetadata()\n\tif err != nil {\n\t\thttp.Error(w, \"failed to get election metadata\", http.StatusNotFound)\n\t\treturn\n\t}\n\n\tif !contains(electionsMetadata.ElectionsIds, shuffleBallotsRequest.ElectionID) {\n\t\thttp.Error(w, \"the election does not exist\", http.StatusNotFound)\n\t\treturn\n\t}\n\n\telectionIDBuff, err := hex.DecodeString(shuffleBallotsRequest.ElectionID)\n\tif err != nil {\n\t\thttp.Error(w, \"failed to decode electionID: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tproof, err := h.orderingSvc.GetProof(electionIDBuff)\n\tif err != nil {\n\t\thttp.Error(w, \"failed to read on the blockchain: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\telection := &types.Election{}\n\terr = json.Unmarshal(proof.GetValue(), election)\n\tif err != nil {\n\t\thttp.Error(w, \"failed to unmarshal Election: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif election.Status != types.Closed {\n\t\thttp.Error(w, \"The election must be closed !\", http.StatusUnauthorized)\n\t\treturn\n\t}\n\n\tif !(len(election.EncryptedBallots) > 1) {\n\t\thttp.Error(w, \"only one vote has been casted !\", http.StatusNotAcceptable)\n\t\treturn\n\t}\n\n\tif election.AdminId != shuffleBallotsRequest.UserId {\n\t\thttp.Error(w, \"only the admin can shuffle the ballots !\", http.StatusUnauthorized)\n\t\treturn\n\t}\n\n\taddrs := make([]mino.Address, len(election.Members))\n\tpubkeys := make([]crypto.PublicKey, len(election.Members))\n\n\tfor i, member := range election.Members {\n\t\taddr, pubkey, err := decodeMember(member.Address, member.PublicKey, h.mino)\n\t\tif err != nil {\n\t\t\thttp.Error(w, \"failed to decode CollectiveAuthorityMember: \"+err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\taddrs[i] = addr\n\t\tpubkeys[i] = pubkey\n\t}\n\n\tcollectiveAuthority := authority.New(addrs, pubkeys)\n\n\terr = h.shuffleActor.Shuffle(collectiveAuthority, string(election.ElectionID))\n\n\tif err != nil {\n\t\thttp.Error(w, \"failed to shuffle: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tresponse := types.ShuffleBallotsResponse{\n\t\tMessage: fmt.Sprintf(\"shuffle started for nodes %v\", addrs),\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\terr = json.NewEncoder(w).Encode(response)\n\tif err != nil {\n\t\thttp.Error(w, \"failed to write in ResponseWriter: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n}", "title": "" } ]
[ { "docid": "981af3dd1cdd69dd67690c84294015da", "score": "0.6035439", "text": "func shuffle(vals puzzle) {\n\tr := rand.New(rand.NewSource(time.Now().UnixNano()))\n\tfor n := len(vals); n > 0; n-- {\n\t\trandIndex := r.Intn(n)\n\t\tvals[n-1], vals[randIndex] = vals[randIndex], vals[n-1]\n\t}\n}", "title": "" }, { "docid": "fe5720a0154e9c21776ff4b9de338485", "score": "0.5988119", "text": "func (d *deck) shuffle() {\n\trand.Seed(time.Now().UnixNano())\n\trand.Shuffle(len(*d), func(i int, j int) {\n\t\t(*d)[i], (*d)[j] = (*d)[j], (*d)[i]\n\t})\n}", "title": "" }, { "docid": "4f64245c98e0401590c77c9e99a87e02", "score": "0.59726804", "text": "func (q *Quiz) shuffle() {\n\trand.Seed(time.Now().UTC().UnixNano())\n\trand.Shuffle(len(q.qas), func(i, j int) {\n\t\tq.qas[i], q.qas[j] = q.qas[j], q.qas[i]\n\t})\n}", "title": "" }, { "docid": "37def54c393221ed667787c6ccaa1bf8", "score": "0.59671724", "text": "func ShuffleCandidate(candidates []incognitokey.CommitteePublicKey, rand int64) ([]incognitokey.CommitteePublicKey, error) {\n\tfmt.Println(\"Beacon Process/Shuffle Candidate: Candidate Before Sort \", candidates)\n\thashes := []string{}\n\tm := make(map[string]incognitokey.CommitteePublicKey)\n\tsortedCandidate := []incognitokey.CommitteePublicKey{}\n\tfor _, candidate := range candidates {\n\t\tcandidateStr, _ := candidate.ToBase58()\n\t\tseed := candidateStr + strconv.Itoa(int(rand))\n\t\thash := common.HashB([]byte(seed))\n\t\thashes = append(hashes, string(hash[:32]))\n\t\tm[string(hash[:32])] = candidate\n\t}\n\tsort.Strings(hashes)\n\tfor _, hash := range hashes {\n\t\tsortedCandidate = append(sortedCandidate, m[hash])\n\t}\n\tfmt.Println(\"Beacon Process/Shuffle Candidate: Candidate After Sort \", sortedCandidate)\n\treturn sortedCandidate, nil\n}", "title": "" }, { "docid": "06d70fa487981741f8d079b7712dd779", "score": "0.5915074", "text": "func (pl PlayerList) shuffle() {\n\trng.Shuffle(len(pl), func(i, j int) {\n\t\tpl[i], pl[j] = pl[j], pl[i]\n\t})\n}", "title": "" }, { "docid": "9e41e64d87075f886cf3a152d3fc479f", "score": "0.590157", "text": "func shuffleNodes(nodes []*nodeState) {\n\tn := len(nodes)\n\trand.Shuffle(n, func(i, j int) {\n\t\tnodes[i], nodes[j] = nodes[j], nodes[i]\n\t})\n}", "title": "" }, { "docid": "a1ecc63aac00a0e5eafd10d03bac6d83", "score": "0.5882019", "text": "func ExampleShuffle() {\n\ts, _ := Shuffle(1000, 1020, NewFeistel(keys, roundFunction))\n\tfor v := range s {\n\t\tfmt.Println(v)\n\t}\n\t// Output:\n\t// 1003\n\t// 1005\n\t// 1006\n\t// 1009\n\t// 1004\n\t// 1011\n\t// 1008\n\t// 1016\n\t// 1010\n\t// 1001\n\t// 1017\n\t// 1000\n\t// 1013\n\t// 1012\n\t// 1015\n\t// 1014\n\t// 1007\n\t// 1002\n\t// 1018\n\t// 1019\n}", "title": "" }, { "docid": "fb90a844ff54e166b0b921bee253b94b", "score": "0.58753496", "text": "func shuffleAnswers(answers []dns.RR) []dns.RR {\n\trand.Seed(time.Now().UTC().UnixNano())\n\n\tn := len(answers)\n\tfor i := 0; i < n; i++ {\n\t\tr := i + rand.Intn(n-i)\n\t\tanswers[r], answers[i] = answers[i], answers[r]\n\t}\n\n\treturn answers\n}", "title": "" }, { "docid": "30190252914992a1e547e1938ce42b8d", "score": "0.5824715", "text": "func Shuffle(rs []*youtube.SearchResult) {\n\trand.Seed(time.Now().UnixNano())\n\tfor i := range rs {\n\t\tj := rand.Intn(i + 1)\n\t\trs[i], rs[j] = rs[j], rs[i]\n\t}\n}", "title": "" }, { "docid": "672a05a64a432633051190c130d8859e", "score": "0.58161753", "text": "func Shuffle(data Swapper, rng RNG) {\n\tn := data.Len()\n\tfor i := 0; i < n; i++ {\n\t\tdata.Swap(i, int(rng.Uintn(uint(n))))\n\t}\n}", "title": "" }, { "docid": "01ef5e11697dcc9b3d9e8d74e9d676d9", "score": "0.57784516", "text": "func shuffleB(d deck) deck {\n\t//src := rand.NewSource(time.Now().UnixNano())\n\t//r := rand.New(src)\n\n\trand.Seed(time.Now().UnixNano())\n\n\trand.Shuffle(len(d), func(i, j int) {\n\t\td[i], d[j] = d[j], d[i]\n\t})\n\n\treturn d\n}", "title": "" }, { "docid": "b96665a2136126ff028ef16d9fa18cd7", "score": "0.5764655", "text": "func (d deck) shuffle() {\n\trand.Seed(time.Now().Unix())\n\n\trand.Shuffle(len(d), func(i, j int) {\n\t\td[i], d[j] = d[j], d[i]\n\t})\n}", "title": "" }, { "docid": "c4f134a6a66548b720098f71d9575d9c", "score": "0.5742998", "text": "func (s *Solution384) Shuffle() []int {\n\trand.Shuffle(len(s.arr), func(i, j int) {\n\t\ts.b[i], s.b[j] = s.b[j], s.b[i]\n\t})\n\treturn s.b\n}", "title": "" }, { "docid": "0436964f59ff1030a29337cce7b8e319", "score": "0.57043856", "text": "func (d Deck) Shuffle() {\n\tfor i := range d {\n\t\tj := rand.Intn(i + 1)\n\t\td[i], d[j] = d[j], d[i]\n\t}\n}", "title": "" }, { "docid": "9d5ab2c54ca4cb3763a7803545a14fc2", "score": "0.56879675", "text": "func shuffle(t []T) []T {\n\trand.Seed(time.Now().UnixNano())\n\trand.Shuffle(len(t), func(i, j int) {\n\t\tt[i], t[j] = t[j], t[i]\n\t})\n\treturn t\n}", "title": "" }, { "docid": "8bd3a9955ce158a3bb3f0121ecf1b7f3", "score": "0.5671015", "text": "func Shuffle(deck []Card) {\n\tfor i := 0; i < 10; i++ {\n\t\trandm := rand.New(rand.NewSource(time.Now().UnixNano()))\n\t\tfor len(deck) > 0 {\n\t\t\tn := len(deck)\n\t\t\trando := randm.Intn(n)\n\t\t\tdeck[n-1], deck[rando] = deck[rando], deck[n-1]\n\t\t\tdeck = deck[:n-1]\n\t\t}\n\t}\n}", "title": "" }, { "docid": "4e218e07b6fa952d570364a60263cc4e", "score": "0.5651468", "text": "func (deck Deck) Shuffle() {\n\n\trand.Seed(time.Now().UnixNano())\n\trand.Shuffle(len(deck.cards), func(i, j int) { deck.cards[i], deck.cards[j] = deck.cards[j], deck.cards[i] })\n\n}", "title": "" }, { "docid": "0511d75bab11e9c308ee8c4cd22810e0", "score": "0.56489587", "text": "func (d *Deck) Shuffle() {\n\trand.Seed(time.Now().UnixNano())\n\trand.Shuffle(len(d), func(i, j int) {\n\t\td[i], d[j] = d[j], d[i]\n\t})\n\n}", "title": "" }, { "docid": "ebf6884c91f9f5d19ea2d7da0d6325ed", "score": "0.56333035", "text": "func shuffleCards(){\n\trand.Seed(time.Now().UnixNano())\n\tfor i:=0; i<TOTAL_CARDS; i++{\n\t\tvar rd = rand.Intn(TOTAL_CARDS-1)+1\n\t\tvar aux = cards[i]\n\t\tcards[i] = cards[rd]\n\t\tcards[rd] = aux\n\t}\n}", "title": "" }, { "docid": "593a7ee914906561f2203259aaea5a91", "score": "0.56291085", "text": "func (d Deck) Shuffle() {\n\tr := rand.New(rand.NewSource(time.Now().UnixNano()))\n\tfor i := 0; i < len(d); i++ {\n\t\ttarget := i + r.Intn(len(d)-i)\n\t\td[i], d[target] = d[target], d[i]\n\t}\n}", "title": "" }, { "docid": "2fffaaf79fcbf4099fbbec5a921aded1", "score": "0.5627673", "text": "func (d Deck) Shuffle() {\n\trand.Shuffle(len(d), func(i, j int) {\n\t\td[i], d[j] = d[j], d[i]\n\t})\n}", "title": "" }, { "docid": "63dbf2bd00f2574c3f3a3c3f5dfaf6a9", "score": "0.5624419", "text": "func shuffle(slice []string) {\n\tn := len(slice)\n\tfor i := n - 1; i > 0; i-- {\n\t\tj := rand.Intn(i + 1)\n\t\tslice[i], slice[j] = slice[j], slice[i]\n\t}\n}", "title": "" }, { "docid": "63699651221f36bc70840092a70c7e90", "score": "0.5586586", "text": "func shuffle() {\n\tregenStarField()\n}", "title": "" }, { "docid": "2dc25b2fe2f2cc85ae7ca4c901fc617d", "score": "0.55707085", "text": "func Shuffle(deck Deck) {\n\tr := rand.New(rand.NewSource(time.Now().Unix()))\n\tfor len(deck.Cards) > 0 {\n\t\tn := len(deck.Cards)\n\t\trandIndex := r.Intn(n)\n\t\tdeck.Cards[n-1], deck.Cards[randIndex] = deck.Cards[randIndex], deck.Cards[n-1]\n\t\tdeck.Cards = deck.Cards[:n-1]\n\t}\n}", "title": "" }, { "docid": "6401e3966201b24099fbea4807b7efa0", "score": "0.55564064", "text": "func Shuffle(a []int) {\n\trand.Seed(time.Now().UnixNano())\n\n\tfor i := range a {\n\t\tj := rand.Intn(i + 1)\n\t\ta[i], a[j] = a[j], a[i]\n\t}\n}", "title": "" }, { "docid": "738e2fdc553df77f505a423e0a3221a4", "score": "0.55518806", "text": "func (result *Result) ShuffleChoices() []string {\n\t//Shuffle choices\n\tfor l := len(result.IncorrectAnswer) - 1; l > 0; l-- {\n\t\tr := rand.Intn(l + 1)\n\t\tresult.IncorrectAnswer[l], result.IncorrectAnswer[r] = result.IncorrectAnswer[r], result.IncorrectAnswer[l]\n\t}\n\treturn result.IncorrectAnswer\n}", "title": "" }, { "docid": "dea5a12fa0e354dd07a038024034417a", "score": "0.5551839", "text": "func shuffle(ips []net.IP) []net.IP {\n\tipsLength := len(ips)\n\n\tif ipsLength < 2 {\n\t\treturn ips\n\t}\n\n\tr := rand.New(rand.NewSource(time.Now().UnixNano()))\n\tret := make([]net.IP, ipsLength)\n\tperm := r.Perm(ipsLength)\n\n\tfor i, randIndex := range perm {\n\t\tret[i] = ips[randIndex]\n\t}\n\n\treturn ret\n}", "title": "" }, { "docid": "3018134b744123418e357e5737e92d6e", "score": "0.55419075", "text": "func (qs Questions) Shuffle() error {\n\tnumOfQuestions := len(qs.Questions)\n\n\tif len(qs.Questions) < 2 {\n\t\treturn fmt.Errorf(\"There are not enough questions to be shuffled\")\n\t}\n\n\tfor i := range qs.Questions {\n\t\tswapIndex := rand.Intn(numOfQuestions)\n\t\ttempt := qs.Questions[i]\n\t\tqs.Questions[i] = qs.Questions[swapIndex]\n\t\tqs.Questions[swapIndex] = tempt\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "e4b36615c2fa90e817f58d5b29f62420", "score": "0.55312645", "text": "func shuffle (data sort.Interface) {\n N := data.Len()\n for i := 0; i < N; i++ {\n r := rand.Intn(i + 1)\n data.Swap(r, i)\n }\n}", "title": "" }, { "docid": "158647ee7bff18c6d8dcb92383fba5db", "score": "0.5524186", "text": "func (d deck) shuffle() {\n\tsource := rand.NewSource(time.Now().UnixNano())\n\tr := rand.New(source)\n\n\tfor i := range d {\n\t\tnewPos := r.Intn(len(d) - 1)\n\t\td[i], d[newPos] = d[newPos], d[i]\n\t}\n}", "title": "" }, { "docid": "70131185c4b0174c2a283a0695c68e15", "score": "0.5506322", "text": "func (this *Solution) Shuffle() []int {\n\tfor i := len(this.shuf) - 1; i >= 0; i-- {\n\t\tj := rand.Intn(i + 1)\n\t\tthis.shuf[i], this.shuf[j] = this.shuf[j], this.shuf[i]\n\t}\n\treturn this.shuf\n}", "title": "" }, { "docid": "43e8d084be611038aaffa1c384ec1774", "score": "0.54982805", "text": "func ShuffleAnswers(w http.ResponseWriter, r *http.Request) {\n\tqParams := mux.Vars(r)\n\tquizID := qParams[\"id\"]\n\tquestionID := qParams[\"qa_id\"]\n\tquiz, _ := findQuiz(quizID)\n\tif quiz == nil {\n\t\tw.WriteHeader(http.StatusNotFound)\n\t\tw.Write([]byte(\"Quiz is not found\"))\n\t\treturn\n\t}\n\tqa, _ := quiz.Find(questionID)\n\tif qa == nil {\n\t\tw.WriteHeader(http.StatusNotFound)\n\t\tw.Write([]byte(\"Question is not found\"))\n\t\treturn\n\t}\n\tqa.Shuffle()\n\tw.WriteHeader(http.StatusOK)\n\tw.Write([]byte(\"OK\"))\n}", "title": "" }, { "docid": "36b57ad6ab002ad6ed8c00b7773fac44", "score": "0.54879445", "text": "func (d deck) shuffle() {\r\n\t//creating a random no generator\r\n\tsource := rand.NewSource(time.Now().UnixNano())\r\n\tr := rand.New(source)\r\n\t//for index in range of d\r\n\tfor i := range d {\r\n\t\t// rand.Intn is a func - length of slice(actual size) - 1 - resulting in a random no.\r\n\t\tnewPosition := r.Intn(len(d) - 1)\r\n\t\t//one line swapping [a,b=b,a] ; math/rand - import stm\r\n\t\td[i], d[newPosition] = d[newPosition], d[i]\r\n\t}\r\n}", "title": "" }, { "docid": "752cd1ec51d6096fffc7481fb9e6956b", "score": "0.54781306", "text": "func (s *SeriesMutator) Shuffle(seed int64) {\n\tindex := makeIntRange(0, s.series.Len())\n\trand.Seed(seed)\n\trand.Shuffle(len(index), func(i, j int) { index[i], index[j] = index[j], index[i] })\n\ts.Subset(index)\n}", "title": "" }, { "docid": "0d453626a064e5cddf0f130cd1e0ab22", "score": "0.54778844", "text": "func Shuffle(a []Letter) {\n\tfor i := range a {\n\t\tj := rand.Intn(i + 1)\n\t\ta[i], a[j] = a[j], a[i]\n\t}\n}", "title": "" }, { "docid": "86d4107c4297dd0e9190ef218dfe51a6", "score": "0.5465833", "text": "func (d *Deck) Shuffle() {\n\tfor i := len(d.cards) - 1; i > 0; i-- {\n\t\tj := rand.Intn(i + 1)\n\t\td.cards[i], d.cards[j] = d.cards[j], d.cards[i]\n\t}\n}", "title": "" }, { "docid": "c4a63f161aa84691bb6b15db9e905832", "score": "0.54596394", "text": "func (deck *Deck) Shuffle() {\n\tN := len(deck.Cards)\n\tfor i := 0; i < N; i++ {\n\t\tr := i + rand.Intn(N-i)\n\t\tdeck.Cards[r], deck.Cards[i] = deck.Cards[i], deck.Cards[r]\n\t}\n}", "title": "" }, { "docid": "e9c49e8bdb421cc1cbccfa9582862340", "score": "0.5454031", "text": "func ShuffleAnimals() (shuffled []string) {\n\tanimals := []string{\"ant\", \"beaver\", \"cat\", \"dog\", \"elephant\", \"fox\", \"giraffe\", \"hedgehog\"}\n\n\tfor _, v := range rand.Perm(len(animals)) {\n\t\tshuffled = append(shuffled, animals[v])\n\t}\n\treturn shuffled\n}", "title": "" }, { "docid": "99349f68a477c410475ef268defd8fc3", "score": "0.5451925", "text": "func (d *Deck) Shuffle() {\n\trand.Seed(time.Now().UnixNano())\n\tfor i := 1; i < len(d.cards); i++ {\n\t\tr := rand.Intn(i + 1)\n\t\tif i != r {\n\t\t\td.cards[r], d.cards[i] = d.cards[i], d.cards[r]\n\t\t}\n\t}\n}", "title": "" }, { "docid": "e1c53d431c090ab313444ac268bf9ae0", "score": "0.54494655", "text": "func (h *HTTP) DecryptBallots(w http.ResponseWriter, r *http.Request) {\n\tdecryptBallotsRequest := &types.DecryptBallotsRequest{}\n\terr := json.NewDecoder(r.Body).Decode(decryptBallotsRequest)\n\tif err != nil {\n\t\thttp.Error(w, \"failed to decode DecryptBallotsRequest: \"+err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\telectionsMetadata, err := h.getElectionsMetadata()\n\tif err != nil {\n\t\thttp.Error(w, \"failed to get election metadata\", http.StatusNotFound)\n\t\treturn\n\t}\n\n\tif !contains(electionsMetadata.ElectionsIds, decryptBallotsRequest.ElectionID) {\n\t\thttp.Error(w, \"The election does not exist\", http.StatusNotFound)\n\t\treturn\n\t}\n\n\telectionIDBuff, err := hex.DecodeString(decryptBallotsRequest.ElectionID)\n\tif err != nil {\n\t\thttp.Error(w, \"failed to decode electionID: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tproof, err := h.orderingSvc.GetProof(electionIDBuff)\n\tif err != nil {\n\t\thttp.Error(w, \"failed to read on the blockchain: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\telection := &types.Election{}\n\terr = json.Unmarshal(proof.GetValue(), election)\n\tif err != nil {\n\t\thttp.Error(w, \"failed to unmarshal Election: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif election.Status != types.ShuffledBallots {\n\t\thttp.Error(w, \"the ballots must have been shuffled !\", http.StatusUnauthorized)\n\t\treturn\n\t}\n\n\tif election.AdminId != decryptBallotsRequest.UserId {\n\t\thttp.Error(w, \"only the admin can decrypt the ballots!\", http.StatusUnauthorized)\n\t\treturn\n\t}\n\n\tKs := make([]kyber.Point, 0, len(election.ShuffledBallots))\n\tCs := make([]kyber.Point, 0, len(election.ShuffledBallots))\n\n\tfor _, v := range election.ShuffledBallots[election.ShuffleThreshold] {\n\t\tciphertext := new(types.Ciphertext)\n\t\terr = json.NewDecoder(bytes.NewBuffer(v)).Decode(ciphertext)\n\t\tif err != nil {\n\t\t\thttp.Error(w, \"failed to unmarshal Ciphertext: \"+err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tK := suite.Point()\n\t\terr = K.UnmarshalBinary(ciphertext.K)\n\t\tif err != nil {\n\t\t\thttp.Error(w, \"failed to unmarshal Kyber.Point: \"+err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tC := suite.Point()\n\t\terr = C.UnmarshalBinary(ciphertext.C)\n\t\tif err != nil {\n\t\t\thttp.Error(w, \"failed to unmarshal Kyber.Point: \"+err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tKs = append(Ks, K)\n\t\tCs = append(Cs, C)\n\t}\n\n\tdecryptedBallots := make([]types.Ballot, 0, len(election.ShuffledBallots))\n\n\tfor i := 0; i < len(Ks); i++ {\n\t\tmessage, err := h.dkgActor.Decrypt(Ks[i], Cs[i], string(election.ElectionID))\n\t\tif err != nil {\n\t\t\thttp.Error(w, \"failed to decrypt (K,C): \"+err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tdecryptedBallots = append(decryptedBallots, types.Ballot{Vote: string(message)})\n\t}\n\n\tdecryptBallotsTransaction := types.DecryptBallotsTransaction{\n\t\tElectionID: decryptBallotsRequest.ElectionID,\n\t\tUserId: decryptBallotsRequest.UserId,\n\t\tDecryptedBallots: decryptedBallots,\n\t}\n\n\tpayload, err := json.Marshal(decryptBallotsTransaction)\n\tif err != nil {\n\t\thttp.Error(w, \"failed to marshal DecryptBallotsTransaction: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\terr = h.submitAndWaitForTxn(r.Context(), evoting.CmdDecryptBallots, evoting.DecryptBallotsArg, payload)\n\tif err != nil {\n\t\thttp.Error(w, \"failed to submit txn: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tresponse := types.DecryptBallotsResponse{}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\terr = json.NewEncoder(w).Encode(response)\n\tif err != nil {\n\t\thttp.Error(w, \"failed to write in ResponseWriter: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "f4ca57a5369b25594929c718718035de", "score": "0.5447574", "text": "func shuffleDeck(cards *Cards) *Cards {\n\n\trand.Seed(time.Now().Unix())\n\t// first munge stuff back together if necessary\n\tcards.Deck = append(cards.Deck, cards.Hand...)\n\tcards.Hand = append(cards.Hand[:0])\n\trand.Shuffle(len(cards.Deck), func(i, j int) { cards.Deck[i], cards.Deck[j] = cards.Deck[j], cards.Deck[i] })\n\treturn cards\n}", "title": "" }, { "docid": "8eea337cd06ace1cae872e2491947f6e", "score": "0.5432509", "text": "func Suffle(cards []Card) []Card {\n\trand.Seed(time.Now().UnixNano())\n\trand.Shuffle(len(cards), func(i, j int) {\n\t\tcards[i], cards[j] = cards[j], cards[i]\n\t})\n\treturn cards\n}", "title": "" }, { "docid": "4a181ab242206785ce619c3f0b776671", "score": "0.54298854", "text": "func Shuffle(s []string) []string {\n\tfor i := len(s) - 1; i > 0; i-- {\n\t\tj := rand.Intn(i + 1)\n\t\ts[i], s[j] = s[j], s[i]\n\t}\n\n\treturn s\n}", "title": "" }, { "docid": "bee37796e77abca4811c5b600b2d8ad9", "score": "0.54189277", "text": "func shuffle(a []string) []string {\n\tfinal := make([]string, len(a))\n\n\tfor i, v := range rand.Perm(len(a)) {\n\t\tfinal[v] = a[i]\n\t}\n\treturn final\n}", "title": "" }, { "docid": "da273355800143d6213b063eefd8f293", "score": "0.54114187", "text": "func Shuffle(slice []string) {\n\tr := rand.New(newCryptoRandSource())\n\tsliceLen := len(slice)\n\tfor i := range slice {\n\t\tj := r.Intn(sliceLen)\n\t\tslice[i], slice[j] = slice[j], slice[i]\n\t}\n}", "title": "" }, { "docid": "560d7c8bdc8f6d56ef57de55490f8daf", "score": "0.5402812", "text": "func shuffle(a []*orderers.Endpoint) []*orderers.Endpoint {\n\tn := len(a)\n\treturnedSlice := make([]*orderers.Endpoint, n)\n\tindices := rand.Perm(n)\n\tfor i, idx := range indices {\n\t\treturnedSlice[i] = a[idx]\n\t}\n\treturn returnedSlice\n}", "title": "" }, { "docid": "72787a8b5559df422d770d110f4b383a", "score": "0.53937984", "text": "func Shuffle(slice []interface{}) {\n\tr := NewRand()\n\tfor len(slice) > 0 {\n\t\tn := len(slice)\n\t\trandIndex := r.Intn(n)\n\t\tslice[n-1], slice[randIndex] = slice[randIndex], slice[n-1]\n\t\tslice = slice[:n-1]\n\t}\n}", "title": "" }, { "docid": "65fbfe75cbac6c36a3412c7aaf019b67", "score": "0.53850055", "text": "func shuffle(data [][]float32) {\n\trand.Shuffle(len(data), func(i, j int) {\n\t\tdata[i], data[j] = data[j], data[i]\n\t})\n}", "title": "" }, { "docid": "0407b36ec6661d5f3ab79d65dbb9c97b", "score": "0.53812295", "text": "func execShuffle(_ int, p *gop.Context) {\n\targs := p.GetArgs(2)\n\trand.Shuffle(args[0].(int), args[1].(func(i int, j int)))\n}", "title": "" }, { "docid": "6d19012120cf0654774e7411289a5cb5", "score": "0.5374603", "text": "func (it *Iter2) Shuffle() {\n\tindex := MustRandperm(it.totalSize, gotch.Int64, gotch.CPU)\n\n\tit.xs = it.xs.MustIndexSelect(0, index, true)\n\tit.ys = it.ys.MustIndexSelect(0, index, true)\n\n\tindex.MustDrop()\n}", "title": "" }, { "docid": "964b9767c8a3214fa8355dda1ff762d7", "score": "0.5366852", "text": "func (d deck) shuffle() deck {\n\tsource := rand.NewSource(time.Now().UnixNano())\n\tr := rand.New(source)\n\tfor i := range d {\n\t\tswap := r.Intn(d.size())\n\t\t//d[i] = d[swap]\n\t\t//d[swap] = card\n\t\td[i], d[swap] = d[swap], d[i]\n\t}\n\treturn d\n}", "title": "" }, { "docid": "22796d17c5fbcc86586c6d20abb4823b", "score": "0.53609955", "text": "func (addrs byPriorityWeight) shuffleByWeight() {\n\tsum := 0\n\tfor _, addr := range addrs {\n\t\tsum += int(addr.Weight)\n\t}\n\tfor sum > 0 && len(addrs) > 1 {\n\t\ts := 0\n\t\tn := rand.Intn(sum)\n\t\tfor i := range addrs {\n\t\t\ts += int(addrs[i].Weight)\n\t\t\tif s > n {\n\t\t\t\tif i > 0 {\n\t\t\t\t\taddrs[0], addrs[i] = addrs[i], addrs[0]\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tsum -= int(addrs[0].Weight)\n\t\taddrs = addrs[1:]\n\t}\n}", "title": "" }, { "docid": "7df65eb4202e6cc2693e2b6b79edcb32", "score": "0.53570014", "text": "func (stack *cardStack) shuffle() {\n\trand.Seed(time.Now().UnixNano())\n\n\tfor i := len(stack.Flashcards) - 1; i > 0; i-- {\n\t\tj := rand.Intn(i)\n\t\tstack.Flashcards[i], stack.Flashcards[j] = stack.Flashcards[j], stack.Flashcards[i]\n\t}\n}", "title": "" }, { "docid": "a51737b99cdea41f33994c2fecdf915c", "score": "0.53558135", "text": "func (d *CardDeck) Shuffle() {\n\tr := rand.New(rand.NewSource(time.Now().Unix()))\n\tfor n := len(d.Deck); n > 0; n-- {\n\t\trandIndex := r.Intn(n)\n\t\td.Deck[n-1], d.Deck[randIndex] = d.Deck[randIndex], d.Deck[n-1]\n\t}\n}", "title": "" }, { "docid": "7d8635c1f1d8b9025fff9c9edb22f698", "score": "0.5354352", "text": "func (m *memberlist) Shuffle() {\n\tm.members.Lock()\n\tm.members.list = shuffle(m.members.list)\n\tm.members.Unlock()\n}", "title": "" }, { "docid": "24c9183d2aac7b05e7e88f50016c54e3", "score": "0.5353997", "text": "func shuffle(src []string) []string {\n\tfinal := make([]string, len(src))\n\trand.Seed(time.Now().UTC().UnixNano())\n\tperm := rand.Perm(len(src))\n\n\tfor i, v := range perm {\n\t\tfinal[v] = src[i]\n\t}\n\treturn final\n}", "title": "" }, { "docid": "021600a5f0b7abe677a80c1dd0e68dd1", "score": "0.5339929", "text": "func (d *DefaultDeck) Shuffle() {\n\tfor i := range d.cards {\n\t\tj := rand.Intn(i + 1)\n\t\td.cards[i], d.cards[j] = d.cards[j], d.cards[i]\n\t}\n}", "title": "" }, { "docid": "8eab39643e1b77c1616bfb1ef521d661", "score": "0.533564", "text": "func (deck *Deck) Shuffle() {\n for i := 0; i < deck.numCards; i++ {\n index = rand.Intn(52 - i) + i\n temp := deck.cards[i]\n deck.cards[i] = deck.cards[index]\n deck.cards[index] = temp\n }\n}", "title": "" }, { "docid": "2cd05ac1b791bb9d4293286cd759406e", "score": "0.53346634", "text": "func shuffle(names []string) {\n for i := range names {\n j := rand.Intn(i + 1)\n names[i], names[j] = names[j], names[i]\n }\n}", "title": "" }, { "docid": "4f8c453296332fd1b551cf515e2a3367", "score": "0.52923554", "text": "func (this *Solution) Shuffle() []int {\n\tsize := len(this.original)\n\tfor i := size -1; i > 0; i-- {\n\t\tpos := rand.Int() % (i + 1)\n\t\tfmt.Println(pos)\n\t\tthis.shuffled[pos], this.shuffled[i] = this.shuffled[i], this.shuffled[pos]\n\t}\n\treturn this.shuffled\n}", "title": "" }, { "docid": "2b431edb83ece9e799d1f8df1c745d2e", "score": "0.52805567", "text": "func (addrs byPriorityWeight) shuffleByWeight() {\n\tsum := 0\n\tfor _, addr := range addrs {\n\t\tsum += int(addr.Weight)\n\t}\n\tfor sum > 0 && len(addrs) > 1 {\n\t\ts := 0\n\t\tn := rand.Intn(sum + 1)\n\t\tfor i := range addrs {\n\t\t\ts += int(addrs[i].Weight)\n\t\t\tif s >= n {\n\t\t\t\tif i > 0 {\n\t\t\t\t\tt := addrs[i]\n\t\t\t\t\tcopy(addrs[1:i+1], addrs[0:i])\n\t\t\t\t\taddrs[0] = t\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tsum -= int(addrs[0].Weight)\n\t\taddrs = addrs[1:]\n\t}\n}", "title": "" }, { "docid": "8173d7266e47cf69b6d6ce79b2cba8fd", "score": "0.5275401", "text": "func Shuffle(x []complex128) []complex128 {\n\tN := len(x)\n\tw := Log2(N)\n\ty := make([]complex128, N)\n\tfor n, v := range x {\n\t\ty[reverseBits(uint32(n), w)] = v\n\t}\n\treturn y\n}", "title": "" }, { "docid": "a590160d80fa090c882931be28cd22b9", "score": "0.5260137", "text": "func Shuffle(orig Cards) (Cards, int64) {\n\tseed := time.Now().UTC().UnixNano()\n\treturn SeededShuffle(orig, seed), seed\n}", "title": "" }, { "docid": "c57cf68ef201a55678cb06677b6bf583", "score": "0.5257118", "text": "func (d deck) shuffle() {\n\tl := len(d)\n\n\t// improve the default rand.Intn with a pseudo-random source\n\tr := rand.New(rand.NewSource(time.Now().UnixNano()))\n\n\t// loop through the deck\n\t// generate a random integer b/w 0 & deck length - 1\n\t// swap the current card with the one at the rand-int index\n\tfor i := range d {\n\t\tri := r.Intn(l - 1)\n\t\td[i], d[ri] = d[ri], d[i]\n\t}\n}", "title": "" }, { "docid": "a43eae2c9339cf38b764558e9d82083a", "score": "0.52238846", "text": "func Shuffle(cards []Card) []Card {\n\tr := rand.New(rand.NewSource(time.Now().UnixNano()))\n\tvar newDeck []Card\n\trandomNum := r.Perm(len(cards))\n\tfor i := 0; i < len(cards); i++ {\n\t\tnewDeck = append(newDeck, cards[randomNum[i]])\n\t}\n\treturn newDeck\n}", "title": "" }, { "docid": "d3f8bd05d3c8f1eebeed2a3c90cf8d8d", "score": "0.5223144", "text": "func (this *Solution) Shuffle() []int {\n\tre := make([]int, this.size)\n\tcopy(re, this.original)\n\n\tfor i := 0; i < this.size; i++ {\n\t\tj := this.rd.Intn(this.size)\n\t\tre[i], re[j] = re[j], re[i]\n\t}\n\treturn re\n}", "title": "" }, { "docid": "29144cf907cec6e3525ba7abda5bdc71", "score": "0.52201205", "text": "func (d deck) shuffle() {\n\t// use timestamp to generate a different seed for every shuffle\n\tsource := rand.NewSource(time.Now().UnixNano())\n\tr := rand.New(source)\n\t// implement yates shuffle\n\tfor i := range d {\n\t\tranInt := r.Intn(len(d) - 1)\n\t\td[i], d[ranInt] = d[ranInt], d[i]\n\t}\n}", "title": "" }, { "docid": "861eb126b0fc3261934d64ce1162bd88", "score": "0.52162105", "text": "func ShuffleQuiz(w http.ResponseWriter, r *http.Request) {\n\tqParam := mux.Vars(r)\n\tid := qParam[\"id\"]\n\tquiz, _ := findQuiz(id)\n\tif quiz == nil {\n\t\tw.WriteHeader(http.StatusNotFound)\n\t\tw.Write([]byte(\"Quiz is not found\"))\n\t\treturn\n\t}\n\tquiz.Shuffle()\n\tw.WriteHeader(http.StatusOK)\n\tw.Write([]byte(\"OK\"))\n}", "title": "" }, { "docid": "28c3832dfc863d24dc8415e57fe61223", "score": "0.5209995", "text": "func shuffleShardCandidate(candidates []string, rand int64) []string {\n\tm := make(map[string]string)\n\ttemp := []string{}\n\tshuffledCandidates := []string{}\n\tfor _, candidate := range candidates {\n\t\tseed := strconv.Itoa(int(rand)) + candidate\n\t\thash := common.HashH([]byte(seed)).String()\n\t\tm[hash] = candidate\n\t\ttemp = append(temp, hash)\n\t}\n\tif len(m) != len(temp) {\n\t\tfmt.Println(candidates)\n\t\tpanic(\"Failed To Shuffle Shard Candidate Before Assign to Shard\")\n\t}\n\tsort.Strings(temp)\n\tfor _, key := range temp {\n\t\tshuffledCandidates = append(shuffledCandidates, m[key])\n\t}\n\tif len(shuffledCandidates) != len(candidates) {\n\t\tpanic(\"Failed To Shuffle Shard Candidate Before Assign to Shard\")\n\t}\n\treturn shuffledCandidates\n}", "title": "" }, { "docid": "775759d4dad34b07dc38abeb27536a45", "score": "0.5207428", "text": "func (s *Solution) Shuffle() []int {\n\tfor j := len(s.nums) - 1; j >= 1; j-- {\n\t\ti := rand.Intn(j + 1)\n\t\ts.nums[i], s.nums[j] = s.nums[j], s.nums[i]\n\t}\n\treturn s.nums\n}", "title": "" }, { "docid": "6c79e8447601c86e67e6f27062c67b76", "score": "0.51976055", "text": "func (c commands) Shuffle() {\n\tfor i := range c {\n\t\tj := rand.Intn(i + 1)\n\t\tc[i], c[j] = c[j], c[i]\n\t}\n}", "title": "" }, { "docid": "869b5f1968e9d12626913f5a2c39fafa", "score": "0.5191847", "text": "func (*Float64) Shuffle(ints []float64) {\n\tswap := func(i, j int) { ints[i], ints[j] = ints[j], ints[i] }\n\trand.Shuffle(len(ints), swap)\n}", "title": "" }, { "docid": "4c6693f235aff5d745e7a9b04a3e8a2d", "score": "0.5190024", "text": "func (d deck) shuffle() {\n\t// make new truly random generator\n\t// create a new source\n\t// pass in int64, we want it to be a little different every time\n\t// use time now function, UnixNano, this will make it random\n\tsource := rand.NewSource(time.Now().UnixNano())\n\n\t// create new Rand value to use with Intn\n\tr := rand.New(source)\n\n\tfor i := range d {\n\t\t// create random number between 0 and length of array - 1\n\t\tnewPosition := r.Intn(len(d) - 1)\n\n\t\t// swap cards at each position\n\t\t// this works (sort of), but last 4 are always the same\n\t\t// the rand.Intn is a pseudo random generator, it always uses\n\t\t// the same seed, so we always get the same sequence\n\t\td[i], d[newPosition] = d[newPosition], d[i]\n\t}\n}", "title": "" }, { "docid": "e1a13ee7342b06344ea9fe364172fd3b", "score": "0.5188533", "text": "func (s *Solution) Shuffle() []int {\n\tvar shuffled = make([]int, len(s.nums))\n\tcopy(shuffled, s.nums)\n\n\trand.Seed(time.Now().UnixNano())\n\trand.Shuffle(len(s.nums), func(i, j int) {\n\t\tshuffled[i], shuffled[j] = shuffled[j], shuffled[i]\n\t})\n\treturn shuffled\n}", "title": "" }, { "docid": "e2dbfec96e17cd48e45f8843e9a63266", "score": "0.51835597", "text": "func Shuffle(n int, swap func(i, j int)) {\n\tif n < 0 {\n\t\tpanic(\"fastrand: invalid argument to Shuffle\")\n\t}\n\n\t// Fisher-Yates shuffle: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle\n\t// Shuffle really ought not be called with n that doesn't fit in 32 bits.\n\t// Not only will it take a very long time, but with 2³¹! possible permutations,\n\t// there's no way that any PRNG can have a big enough internal state to\n\t// generate even a minuscule percentage of the possible permutations.\n\t// Nevertheless, the right API signature accepts an int n, so handle it as best we can.\n\ti := n - 1\n\tfor ; i > 1<<31-1-1; i-- {\n\t\tj := int(Int63n(int64(i + 1)))\n\t\tswap(i, j)\n\t}\n\tfor ; i > 0; i-- {\n\t\tj := int(Int31n(int32(i + 1)))\n\t\tswap(i, j)\n\t}\n}", "title": "" }, { "docid": "5a6d3bfc298dc0a2b0f4794155fa7a77", "score": "0.51829255", "text": "func (r *Random) Shuffle(n int, swap func(i, j int)) {\n\tr.rnd.Shuffle(n, swap)\n}", "title": "" }, { "docid": "c2d1945886612378de923695d471ab0d", "score": "0.5172941", "text": "func FisherYatesShuffle(slice []uint16) []uint16 {\n\trand.Seed(time.Now().UnixNano())\n\tn := len(slice)\n\tfor i := n - 1; i > 0; i-- {\n\t\tj := rand.Intn(i + 1)\n\t\tslice[i], slice[j] = slice[j], slice[i]\n\t}\n\treturn slice\n}", "title": "" }, { "docid": "f0d7897d09fc651bdd7719c94d6b61de", "score": "0.5150941", "text": "func main() {\n\tfmt.Println(shuffle([]int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, 5))\n}", "title": "" }, { "docid": "cdc373eb7118d89eb495e937c1f7651f", "score": "0.5143451", "text": "func Shuffle(r rand.Source64, n int, swap func(i, j int)) {\n\tswitch {\n\tcase n == 0:\n\t\treturn\n\tcase n < 0:\n\t\tpanic(\"randstat.Shuffle: n < 0\")\n\tcase r == nil:\n\t\tpanic(\"randstat.Shuffle: no random source given\")\n\t}\n\n\t// Fisher-Yates shuffle.\n\tfor i := n - 1; i > maxint32-1; i-- {\n\t\tj := int(Int63n(r, int64(1+i)))\n\t\tif i != j {\n\t\t\tswap(i, j)\n\t\t}\n\t}\n\n\tfor i := n - 1; i > 0; i-- {\n\t\tj := int(Int31n(r, int32(1+i)))\n\t\tif i != j {\n\t\t\tswap(i, j)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "7936d641ff4f5ce6485ce189c51dcd88", "score": "0.51334727", "text": "func (this *Solution) Shuffle() []int {\n\tnums := make([]int, len(this.data))\n\tcopy(nums, this.data)\n\trand.Shuffle(len(nums), func(i int, j int) {\n\t\tprintln(i)\n\t\tnums[i], nums[j] = nums[j], nums[i]\n\t})\n\treturn nums\n}", "title": "" }, { "docid": "106b642de47200711908a468169e78e7", "score": "0.5132954", "text": "func (this *Solution) Shuffle() []int {\n\ttmp := make([]int, 0)\n\ttmp = append(tmp, this.nums...)\n\trand.Seed(int64(len(this.nums)))\n\tfor i := len(this.nums) - 1; i >= 0; i-- {\n\t\tj := rand.Intn(i)\n\t\ttmp[i], tmp[j] = tmp[j], tmp[i]\n\t}\n\treturn tmp\n}", "title": "" }, { "docid": "1b08ebca887a68ac627f9195427526c0", "score": "0.51217383", "text": "func (this *Solution) Shuffle() []int {\n\tfor i := len(this.nums) - 1; i >= 0; i-- {\n\t\tidx := rand.Intn(i + 1)\n\t\tthis.nums[i], this.nums[idx] = this.nums[idx], this.nums[i]\n\t}\n\treturn this.nums\n}", "title": "" }, { "docid": "d25d6e100713bca8b48161f31634f639", "score": "0.5107585", "text": "func (this *Solution) Shuffle() []int {\n\ttemp := make([]int, len(this.source))\n\tcopy(temp, this.source)\n\tcnt := len(temp)\n\tfor i := 0; i < cnt; i++ {\n\t\tn := rand.Intn(cnt)\n\t\ttemp[i], temp[n] = temp[n], temp[i]\n\t}\n\treturn temp\n}", "title": "" }, { "docid": "e96a225282645d641bce983a62fbf708", "score": "0.51070666", "text": "func Shuffle(list List) (r List) {\n\tl := len(list)\n\tr = List(make([]Item, l))\n\tcopy(r, list)\n\tif l > 1 {\n\t\trand.Seed(time.Now().UnixNano())\n\t\trand.Shuffle(l, func(i, j int) {\n\t\t\tr[i], r[j] = r[j], r[i]\n\t\t})\n\t}\n\treturn\n}", "title": "" }, { "docid": "79e9ad72db33cb60c445874bf39d2861", "score": "0.5084083", "text": "func Shuffle(cards []Card) []Card {\n\tret := make([]Card, len(cards))\n\tperm := shuffleRand.Perm(len(cards))\n\tfor idx, randVal := range perm {\n\t\tret[idx] = cards[randVal]\n\t}\n\n\treturn ret\n}", "title": "" }, { "docid": "803ec3f72b6fa7a45c2e522fb33f6483", "score": "0.5078161", "text": "func (dist *UniformDist) Shuffle(ary []interface{}) []interface{} {\n\tout := ary[:]\n\tdist.r.Shuffle(len(ary), func (i, j int) { out[i], out[j] = out[j], out[i] })\n\n\treturn out\n}", "title": "" }, { "docid": "5afd1238a918f734add1e4d9c1b8f43b", "score": "0.5077133", "text": "func randomizeBidSet(n, m int) (bs BidSet) {\n\tbs = make(BidSet, n+1)\n\tfor a := 1; a <= n; a++ {\n\t\tbs[a] = getRandomBid(m)\n\t}\n\treturn\n}", "title": "" }, { "docid": "c3d69081250e5a7432bf888af206c852", "score": "0.50771207", "text": "func ShuffleDeck(p *Player) {\n\trand.Seed(time.Now().UnixNano())\n\td := p.Deck.Cards\n\tvar n []cd.Card\n\tfor _ = range d {\n\t\tr := rand.Intn(len(d))\n\t\tn = append(n, d[r])\n\t\td = append(d[:r], d[r+1:]...)\n\t}\n\tp.Deck.Cards = n\n}", "title": "" }, { "docid": "56f0594376f7a32f589d829ef8459c1c", "score": "0.50329757", "text": "func Shuffle(slice []string) []string {\n\tr := rand.New(rand.NewSource(time.Now().Unix()))\n\tret := make([]string, len(slice))\n\tn := len(slice)\n\tfor i := 0; i < n; i++ {\n\t\trandIndex := r.Intn(len(slice))\n\t\tret[i] = slice[randIndex]\n\t\tslice = append(slice[:randIndex], slice[randIndex+1:]...)\n\t}\n\treturn ret\n}", "title": "" }, { "docid": "76fdc88aa574c5462e701bbb0343af24", "score": "0.50319284", "text": "func Shuffle(array []string, source rand.Source) {\n\trandom := rand.New(source)\n\tfor i := len(array) - 1; i > 0; i-- {\n\t\tj := random.Intn(i + 1)\n\t\tarray[i], array[j] = array[j], array[i]\n\t}\n}", "title": "" }, { "docid": "710ff591017b4860d279853486d82a5e", "score": "0.5030929", "text": "func (this *Solution) Shuffle() []int {\n\tres := append([]int{}, this.array...)\n\tfor i := len(res) - 1; i > 0; i-- {\n\t\tj := rand.Intn(i + 1)\n\t\tres[i], res[j] = res[j], res[i]\n\t}\n\treturn res\n}", "title": "" }, { "docid": "bf4e18e06feb92ef910d7bbe4f444ba0", "score": "0.5026708", "text": "func SuffleSlice(data []interface{}) []interface{} {\n\tfor i := range data {\n\t\tj := rand.Intn(i + 1)\n\t\tdata[i], data[j] = data[j], data[i]\n\t}\n\treturn data\n}", "title": "" }, { "docid": "0c0db188de284f6960a3487360189239", "score": "0.5015971", "text": "func ShuffleSlice(s []string) []string {\n\trand.Seed(time.Now().UnixNano())\n\trand.Shuffle(len(s), func(i, j int) {\n\t\ts[i], s[j] = s[j], s[i]\n\t})\n\n\treturn s\n}", "title": "" }, { "docid": "894c70da0e29cc430b98e798eca78778", "score": "0.5010821", "text": "func (d *CardDeck) Reshuffle() {\n\td.Deck, d.DiscardPile = append(d.Deck, d.Discard), d.DiscardPile[:0]\n\tr := rand.New(rand.NewSource(time.Now().Unix()))\n\tfor n := len(d.Deck); n > 0; n-- {\n\t\trandIndex := r.Intn(n)\n\t\td.Deck[n-1], d.Deck[randIndex] = d.Deck[randIndex], d.Deck[n-1]\n\t}\n}", "title": "" }, { "docid": "fc4dc92d23592985a3dd7813e55e38cd", "score": "0.49716786", "text": "func (this *Solution) Shuffle() []int {\n \n}", "title": "" }, { "docid": "93973d95a0065489d9c28a726df73feb", "score": "0.49545762", "text": "func shuffleLocations(locations []location) []location {\n order := rand.Perm(len(locations))\n result := make([]location, len(locations))\n for i, j := range order {\n result[j] = locations[i]\n }\n return result\n}", "title": "" }, { "docid": "ce2774738be31f2389eaac0aa4bcd53e", "score": "0.49467415", "text": "func (s byPref) sort() {\n\tfor i := range s {\n\t\tj := rand.Intn(i + 1)\n\t\ts[i], s[j] = s[j], s[i]\n\t}\n\tsort.Sort(s)\n}", "title": "" }, { "docid": "aef6d19186dc18e4d6413332738721da", "score": "0.49449623", "text": "func (d *Deck) Shuffle() *Deck {\n\trand.Shuffle(len(d.cards), func(i, j int) {\n\t\td.cards[i], d.cards[j] = d.cards[j], d.cards[i]\n\t})\n\treturn d\n}", "title": "" }, { "docid": "3be1d70f79c38ce6c180933dc957215c", "score": "0.4942986", "text": "func main() {\n\tnums := []int{1, 2, 3, 4, 5, 6, 7, 8}\n\tobj := Constructor(nums)\n\tfor i := 0; i < 100; i++ {\n\t\tres := obj.Shuffle()\n\t\tfmt.Println(res)\n\t}\n}", "title": "" }, { "docid": "7c783c041fd599b0f4893297d24068dc", "score": "0.49226832", "text": "func (s *Series) Shuffle(seed int64) *Series {\n\ts = s.Copy()\n\ts.InPlace().Shuffle(seed)\n\treturn s\n}", "title": "" } ]
6a4d552d9f334bcc112fb0ef2419ea3a
Kind is the kind for this field.
[ { "docid": "92448d2232b671b1c96fe6619de294ce", "score": "0.8113895", "text": "func (f *Field) Kind() string {\n\treturn f.kind\n}", "title": "" } ]
[ { "docid": "36fb43b1292636e582890d92e706ff3e", "score": "0.7751451", "text": "func (f *Field) Kind() reflect.Kind {\n\treturn f.Value.Kind()\n}", "title": "" }, { "docid": "74f71b32a18d888b09ed3b80fa4136a3", "score": "0.72631043", "text": "func (f Field) Type() string { return f.kind }", "title": "" }, { "docid": "fca906e55c717695001169ab4e307779", "score": "0.71007305", "text": "func (fe *fieldError) Kind() reflect.Kind {\n\treturn fe.kind\n}", "title": "" }, { "docid": "f46259c6131a1c1af9f1d4d7992144d2", "score": "0.70326436", "text": "func (i *Instance) Kind() string {\n\treturn i.kind\n}", "title": "" }, { "docid": "019e4f8def4796bbad65703806042e36", "score": "0.6896115", "text": "func (st *BuildStruct) Kind() string {\n\tfor _, field := range st.Fields {\n\t\tif field.Tag.Kind != \"\" {\n\t\t\treturn field.Tag.Kind\n\t\t}\n\t}\n\treturn st.Name()\n}", "title": "" }, { "docid": "29655be8c2e931634b527e1acaf54f17", "score": "0.6883227", "text": "func (myself *MetadataCore) GetKind() string {\n\treturn myself.kind\n}", "title": "" }, { "docid": "17d2dabf6152bd8441fb501f3b1109cf", "score": "0.68639547", "text": "func (d *DatabaseV3) GetKind() string {\n\treturn d.Kind\n}", "title": "" }, { "docid": "612b9210f91a9ec372020867f5a2e298", "score": "0.6799947", "text": "func (element *Element) GetKind() int {\n\treturn element.kind\n}", "title": "" }, { "docid": "1501a87defcd1d34b5ce32c4734c6e59", "score": "0.67876655", "text": "func (*Instance) Kind() string {\n\treturn Kind\n}", "title": "" }, { "docid": "45164480f0767b55974c25b70d5ca06a", "score": "0.67670023", "text": "func (fd FileDef) Kind() string {\n\treturn fd.kind\n}", "title": "" }, { "docid": "76482b69127d115bb743f70492a97eea", "score": "0.6754708", "text": "func (o *MetaPropDefinitionAllOf) GetKind() string {\n\tif o == nil || o.Kind == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Kind\n}", "title": "" }, { "docid": "0dcf08504f91608ac39653172ba50912", "score": "0.6743364", "text": "func (b *ObjectReferenceBuilder) Kind(value string) *ObjectReferenceBuilder {\n\tb.kind = value\n\tb.bitmap_ |= 4\n\treturn b\n}", "title": "" }, { "docid": "e788e8f53a283938be3540dad3e8594c", "score": "0.67354023", "text": "func (k *Key) Kind() string {\n\treturn k.kind\n}", "title": "" }, { "docid": "d0a116e2ced9718ce08093aa21aff930", "score": "0.6731338", "text": "func (v Value) Kind() Kind {\n\treturn v.internal().kind\n}", "title": "" }, { "docid": "b3fd9360f48f50e0df02d530fa35ab01", "score": "0.6721092", "text": "func (v *Value) Kind() int {\n\tif v.isRef() {\n\t\treturn v.findRef(v.content.(int)).kind\n\t}\n\treturn v.kind\n}", "title": "" }, { "docid": "56310af480e780ed9116e243692fa0de", "score": "0.6695781", "text": "func (db *DB) Kind() Kind {\n\treturn db.k\n}", "title": "" }, { "docid": "119c25d1b878f97a29b7fcb2b45571fe", "score": "0.66863966", "text": "func (d *TypeDescriptor) Kind() string {\n\tname := strings.ToLower(d.Name)\n\n\tswitch {\n\tcase name == \"date-time\":\n\t\tname = \"time.Time\"\n\tcase name == \"date\":\n\t\tname = \"time.Time\"\n\tcase name == \"uuid\":\n\t\tname = \"schema.UUID\"\n\tdefault:\n\t\tswitch {\n\t\tcase d.IsAny:\n\t\t\tname = \"interface{}\"\n\t\tcase d.IsMap:\n\t\t\tname = fmt.Sprintf(\"map[%s]%s\", d.Key.Kind(), d.Element.Kind())\n\t\tcase !d.IsPrimitive:\n\t\t\tname = inflect.Camelize(d.Name)\n\t\t}\n\t}\n\n\tif item := element(d); item.IsNullable {\n\t\tname = inflect.Pointer(name)\n\t}\n\n\treturn name\n}", "title": "" }, { "docid": "1819f080b5fcafd9f017b45c7ef154cc", "score": "0.6658202", "text": "func (resource *Resource) GetKind() string {\n\treturn resource.Kind\n}", "title": "" }, { "docid": "3db482b7a3a01e153a46ffbdbf1bf18b", "score": "0.6653764", "text": "func (o *ResourceQuota) GetKind() string {\n\tif o == nil || o.Kind == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Kind\n}", "title": "" }, { "docid": "965ac8b2142e79327761ad1e519177b4", "score": "0.6649246", "text": "func (d *FakeResourceData) Kind() string {\n\treturn d.kind\n}", "title": "" }, { "docid": "a625c3933b6cb284c8affeffe6782a97", "score": "0.66320443", "text": "func (b *Basic) Kind() BasicKind {}", "title": "" }, { "docid": "b332b0d0e38a7c2ff750ce594a19a0af", "score": "0.66168886", "text": "func (r Resource) Kind() string {\n\treturn r.ar.Kind\n}", "title": "" }, { "docid": "3cd0eba4f2f2fc6449215f131cd7fdbd", "score": "0.6615459", "text": "func (_this *HTMLTrackElement) Kind() string {\n\tvar ret string\n\tvalue := _this.Value_JS.Get(\"kind\")\n\tret = (value).String()\n\treturn ret\n}", "title": "" }, { "docid": "3cf70be2fbb2250fcaaaad30379c48bf", "score": "0.6609745", "text": "func (n *Node) Kind() reflect.Kind {\n\treturn n.value.Kind()\n}", "title": "" }, { "docid": "c88e26382748ad99a69de3cc4c7614b4", "score": "0.6566819", "text": "func (_this *MediaStreamTrack) Kind() string {\n\tvar ret string\n\tvalue := _this.Value_JS.Get(\"kind\")\n\tret = (value).String()\n\treturn ret\n}", "title": "" }, { "docid": "efe4d7c79042041139b70a21cc0ca8ef", "score": "0.65574056", "text": "func (_this *VideoTrack) Kind() string {\n\tvar ret string\n\tvalue := _this.Value_JS.Get(\"kind\")\n\tret = (value).String()\n\treturn ret\n}", "title": "" }, { "docid": "a1c3774500f7bb38319999a00e956b0e", "score": "0.6557289", "text": "func (v Value) Kind() Kind {\n\treturn v.typ.Kind()\n}", "title": "" }, { "docid": "1d0685bc2cfaab84184fac5ac7a9d3e8", "score": "0.65501803", "text": "func (m *FakeMessage) GetKind() string { return m.kind }", "title": "" }, { "docid": "7de7944a26d2067bbf85f4deeeab1e13", "score": "0.6522242", "text": "func (v Value) Kind() Kind { return ^Kind(v.kind) }", "title": "" }, { "docid": "edb75ea8eb08c4e8c67a83332db6e5d2", "score": "0.6509386", "text": "func (c *Float64Flg) Kind() error {\n\trv := reflect.ValueOf(c)\n\tif rv.Kind() != reflect.Ptr {\n\t\tname := rv.FieldByName(\"Name\").String()\n\t\treturn &InvalidObjectError{reflect.TypeOf(c), \"'\" + name + \"' flag of type\"}\n\t} else if rv.IsNil() {\n\t\treturn &InvalidObjectError{reflect.TypeOf(c), \"\"}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "097404eb2064bb5cd22709f4a6d76ad1", "score": "0.64740634", "text": "func (b *ManagementClusterParentBuilder) Kind(value string) *ManagementClusterParentBuilder {\n\tb.kind = value\n\tb.bitmap_ |= 4\n\treturn b\n}", "title": "" }, { "docid": "27e5d917a8d3b3ae571f84de531ce316", "score": "0.64498496", "text": "func (k *kubernetesfileImageDifferentiator) Kind() kind.Kind {\n\treturn k.kind\n}", "title": "" }, { "docid": "980d0fb34b39b7ecae7361edd11385be", "score": "0.64360994", "text": "func (_this *DataTransferItem) Kind() string {\n\tvar ret string\n\tvalue := _this.Value_JS.Get(\"kind\")\n\tret = (value).String()\n\treturn ret\n}", "title": "" }, { "docid": "de48459dd1b89fe751b2be49c745e392", "score": "0.6411944", "text": "func (g *Gosto) Kind(src interface{}) string {\n\tif k, err := g.KeyError(src); err == nil {\n\t\treturn k.Kind\n\t}\n\treturn \"\"\n}", "title": "" }, { "docid": "599c8f8d4d892b05271c24e908fce531", "score": "0.6405083", "text": "func (t Token) Kind() Kind {\n\treturn t.kind\n}", "title": "" }, { "docid": "534577dc27c0d5c7e13bac330b91442e", "score": "0.6403222", "text": "func (_this *AudioTrack) Kind() string {\n\tvar ret string\n\tvalue := _this.Value_JS.Get(\"kind\")\n\tret = (value).String()\n\treturn ret\n}", "title": "" }, { "docid": "2f4a7fc8f8c87907834bb542a58e3ee9", "score": "0.64022946", "text": "func (_this *MediaDeviceInfo) Kind() MediaDeviceKind {\n\tvar ret MediaDeviceKind\n\tvalue := _this.Value_JS.Get(\"kind\")\n\tret = MediaDeviceKindFromJS(value)\n\treturn ret\n}", "title": "" }, { "docid": "eb888d1ff5e404b5e653ac3accebb919", "score": "0.63867724", "text": "func (v *EventPayloadValue) Kind() reflect.Kind {\n\treturn v.value.Kind()\n}", "title": "" }, { "docid": "cdb8fec33a95a7e3c96fc8af788dd045", "score": "0.63826096", "text": "func (o *MetaPropDefinition) GetKind() string {\n\tif o == nil || o.Kind == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Kind\n}", "title": "" }, { "docid": "ceef03a63a877baa30fceb3d6c80d739", "score": "0.6379499", "text": "func (d Crd) Kind(kind string) schema.GroupKind {\n\treturn d.GroupVersion().WithKind(kind).GroupKind()\n}", "title": "" }, { "docid": "f50beaecc12c9875ed9df548837f5f6a", "score": "0.6377166", "text": "func (ci *Column[T]) Kind() reflect.Kind {\n\treturn ci.kind\n}", "title": "" }, { "docid": "d64f2d02c771b806c069e76c09184136", "score": "0.63754636", "text": "func GetType() string {\n\treturn kind\n}", "title": "" }, { "docid": "d64f2d02c771b806c069e76c09184136", "score": "0.63754636", "text": "func GetType() string {\n\treturn kind\n}", "title": "" }, { "docid": "d64f2d02c771b806c069e76c09184136", "score": "0.63754636", "text": "func GetType() string {\n\treturn kind\n}", "title": "" }, { "docid": "d64f2d02c771b806c069e76c09184136", "score": "0.63754636", "text": "func GetType() string {\n\treturn kind\n}", "title": "" }, { "docid": "4cfdaacc16c7f57af14b832545e9139a", "score": "0.6363046", "text": "func (sf *StatFactory) Kind(k string) *StatFactory {\n\tsf.kind = k\n\treturn sf\n}", "title": "" }, { "docid": "a00a0a3b41649b0a5dfcefd83571f034", "score": "0.6356389", "text": "func (r ResourceFile) Kind() string {\n\tif r.kind != \"\" {\n\t\treturn r.kind\n\t}\n\treturn KindResourceFile\n}", "title": "" }, { "docid": "f73a35aefc36ecfd8d12acb48f7c97b5", "score": "0.6351478", "text": "func (v Villager) GetKind() string {\n\treturn \"villager\"\n}", "title": "" }, { "docid": "7de3020fea247de9d8a20570bd03042e", "score": "0.6330488", "text": "func (o *Placeholder) GetKind() string {\n\tif o == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\n\treturn o.Kind\n}", "title": "" }, { "docid": "0d2f9e405dc02629355cc82ab6fa202c", "score": "0.6323039", "text": "func (t *Type) Kind() reflect.Kind {\n\treturn reflect.Kind(t.kind & kindMask)\n}", "title": "" }, { "docid": "2b62885315ce93c8403e974e6e2e9184", "score": "0.6320981", "text": "func (k *kubernetesfileImageFormatter) Kind() kind.Kind {\n\treturn k.kind\n}", "title": "" }, { "docid": "a5c161d7bab5934490b55b9fb3626db9", "score": "0.63159734", "text": "func (d *dockerfileImageFormatter) Kind() kind.Kind {\n\treturn d.kind\n}", "title": "" }, { "docid": "54b1acc2d171ec1b1f67c8b6d37aede3", "score": "0.63100284", "text": "func (p *Parameter) Kind() int {\n\treturn p.data.Kind\n}", "title": "" }, { "docid": "7309995561e4b314b4b9d4c10f617efc", "score": "0.6304794", "text": "func Kind(v string) predicate.K8sObject {\n\treturn predicate.K8sObject(func(s *sql.Selector) {\n\t\ts.Where(sql.EQ(s.C(FieldKind), v))\n\t})\n}", "title": "" }, { "docid": "e75ca0c9ceee43c267b1c8cd9cf145b4", "score": "0.6300263", "text": "func (o *JsonV1Event) GetKind() string {\n\tif o == nil || o.Kind == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Kind\n}", "title": "" }, { "docid": "8c926bdaf0defdb13f3d0bb44d2f41bf", "score": "0.6294503", "text": "func (s *AnySchema) Kind() string {\n\treturn reflect.Interface.String()\n}", "title": "" }, { "docid": "a75f896a546bcdaaf634659bd17210ea", "score": "0.62936187", "text": "func (o *QuotaCost) GetKind() string {\n\tif o == nil || o.Kind == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Kind\n}", "title": "" }, { "docid": "f6b131ee59c55cb5cb2f66df0fa571b3", "score": "0.6290869", "text": "func (c *StaticTokensV2) GetKind() string {\n\treturn c.Kind\n}", "title": "" }, { "docid": "f6b131ee59c55cb5cb2f66df0fa571b3", "score": "0.6290869", "text": "func (c *StaticTokensV2) GetKind() string {\n\treturn c.Kind\n}", "title": "" }, { "docid": "1c425e1ac202b16a12b5d7e961bbd84d", "score": "0.6287077", "text": "func (o *CloudRegion) Kind() string {\n\tif o == nil {\n\t\treturn CloudRegionNilKind\n\t}\n\tif o.bitmap_&1 != 0 {\n\t\treturn CloudRegionLinkKind\n\t}\n\treturn CloudRegionKind\n}", "title": "" }, { "docid": "d7958a131c9ba8f96d7263f98fd95d20", "score": "0.6286646", "text": "func (n *Node) Kind() string {\n\treturn n.Keys[0].Token.Value().(string)\n}", "title": "" }, { "docid": "566548085ccc5a0fe84eb0ca9ae9908e", "score": "0.6276535", "text": "func (m *Link) GetKind() Link_Kind {\n\tif m != nil {\n\t\treturn m.Kind\n\t}\n\treturn Link_DEFINITION\n}", "title": "" }, { "docid": "5192de68f473f36f76a780fb1a3bb174", "score": "0.626911", "text": "func (c CustomResource) Kind() string {\n\treturn TypeName(c.Object)\n}", "title": "" }, { "docid": "718025222b1f8262e3ca5997bb6faeb3", "score": "0.6267164", "text": "func (media *Media) Kind() data.Kind {\n\treturn MediaKind\n}", "title": "" }, { "docid": "10b0c54362f3fe51519ac1dccd0dc7db", "score": "0.6263509", "text": "func (ev event) Kind() Kind {\n\treturn Kind(ev.kind)\n}", "title": "" }, { "docid": "a1f33d4a52f7567b39d076aaa4dfb92c", "score": "0.6254344", "text": "func (b *Builder) Kind(kind Kind) *Builder {\n\tif b != nil {\n\t\tif kind == \"\" {\n\t\t\tb.kind = DefaultKind\n\t\t} else {\n\t\t\tb.kind = kind\n\t\t}\n\t}\n\treturn b\n}", "title": "" }, { "docid": "d74001e890e1e9fc92e1617ecade59dd", "score": "0.62436986", "text": "func (typ *gqlType) Kind() string {\n\tswitch {\n\tcase !typ.isNullable():\n\t\treturn \"NON_NULL\"\n\tcase typ.isScalar():\n\t\treturn \"SCALAR\"\n\tcase typ.isObject():\n\t\treturn \"OBJECT\"\n\tcase typ.isUnion():\n\t\treturn \"UNION\"\n\tcase typ.isEnum():\n\t\treturn \"ENUM\"\n\tcase typ.isInputObject():\n\t\treturn \"INPUT_OBJECT\"\n\tcase typ.isList():\n\t\treturn \"LIST\"\n\tdefault:\n\t\tpanic(\"invalid type\")\n\t}\n}", "title": "" }, { "docid": "0de8cb451344823daf4b39ba69166684", "score": "0.6240935", "text": "func (q *Query) Kind(kind string) *Query {\n\treturn q.mod(func(q *Query) {\n\t\tq.kind = kind\n\t})\n}", "title": "" }, { "docid": "a2ce6b30e79a57c245d3184432a915e9", "score": "0.6224823", "text": "func (o *Registry) GetKind() string {\n\tif o == nil || o.Kind == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Kind\n}", "title": "" }, { "docid": "1d19cbab9a131e47bf0fcc1d18efdb30", "score": "0.6219688", "text": "func (p *PluginV1) GetKind() string {\n\treturn p.Kind\n}", "title": "" }, { "docid": "b793d343a4782e2dae1043477f96b32e", "score": "0.6215851", "text": "func (nid *NodeID) Kind() reflect.Kind {\n\treturn nid.value.Kind()\n}", "title": "" }, { "docid": "3fb5bd5ae0a36f9784a0a77c0be0a4e1", "score": "0.62044215", "text": "func (b *AddonInstallationBillingBuilder) Kind(value string) *AddonInstallationBillingBuilder {\n\tb.kind = value\n\tb.bitmap_ |= 16\n\treturn b\n}", "title": "" }, { "docid": "e6d8305196fcbc4ea4ffa728564ea538", "score": "0.6189795", "text": "func (n Node) Kind() Kind {\n\tif n.tree != nil {\n\t\treturn n.event().Kind()\n\t}\n\treturn 0\n}", "title": "" }, { "docid": "17df6fc092366952d4e0e4e098688264", "score": "0.6184348", "text": "func (delete Delete) GetKind() string {\n\treturn delete.Kind\n}", "title": "" }, { "docid": "e9424897ff399aa1bf3d37a1a63b7b1a", "score": "0.6175165", "text": "func (s *ServerV2) GetKind() string {\n\treturn s.Kind\n}", "title": "" }, { "docid": "e20afc573af49ec6f51bcacce8355880", "score": "0.61635965", "text": "func (t *TrackRemote) Kind() RTPCodecType {\n\tt.mu.RLock()\n\tdefer t.mu.RUnlock()\n\treturn t.kind\n}", "title": "" }, { "docid": "c2f70ed971197ad859dcc734d87625b6", "score": "0.615779", "text": "func (o *Account) GetKind() string {\n\tif o == nil || o.Kind == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Kind\n}", "title": "" }, { "docid": "46d4e0df2cd32bf237d08e291d756909", "score": "0.61568415", "text": "func (c *ClusterConfigV3) GetKind() string {\n\treturn c.Kind\n}", "title": "" }, { "docid": "bc9f7f767848acf2ecfa1979cae328a7", "score": "0.61550075", "text": "func Kind(rc *tfjson.ResourceChange) string {\n\treturn rc.Type\n}", "title": "" }, { "docid": "bae49590f0ef575f0a9de6da91c2ce1c", "score": "0.6148923", "text": "func (o *DecisionRequest) GetKind() string {\n\tif o == nil || o.Kind == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Kind\n}", "title": "" }, { "docid": "7726519674f706c8165bbbd75380f0ed", "score": "0.61451954", "text": "func (o *TemplateSummaryLabel) GetKind() string {\n\tif o == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\n\treturn o.Kind\n}", "title": "" }, { "docid": "2f7e1943b6357f74c5fbf41fa6957961", "score": "0.614434", "text": "func (value ZValue) Kind() (reflect.Kind) {\n\treturn value.ReflectValue().Kind()\n}", "title": "" }, { "docid": "fc8d623e2df241e0cbc7e9a4e9416251", "score": "0.61403954", "text": "func (o PersistentVolumeClaimPatchTypeOutput) Kind() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v PersistentVolumeClaimPatchType) *string { return v.Kind }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "7f984a06f897fbff29e1aaab34ce0b8b", "score": "0.6127375", "text": "func (o BoundObjectReferenceOutput) Kind() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v BoundObjectReference) *string { return v.Kind }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "751356466d718f03963a6a3259e20cb4", "score": "0.6126858", "text": "func (o *VersionGate) Kind() string {\n\tif o == nil {\n\t\treturn VersionGateNilKind\n\t}\n\tif o.bitmap_&1 != 0 {\n\t\treturn VersionGateLinkKind\n\t}\n\treturn VersionGateKind\n}", "title": "" }, { "docid": "441dee49a4adb05f960a4a8ffa2059ac", "score": "0.6126409", "text": "func (o BoundObjectReferencePatchOutput) Kind() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v BoundObjectReferencePatch) *string { return v.Kind }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "08bedb15a9a50fb4548c9dd40b340acb", "score": "0.6119409", "text": "func (o *TemplateSummaryDiffBucket) GetKind() string {\n\tif o == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\n\treturn o.Kind\n}", "title": "" }, { "docid": "b00631524a52f60027998b4bed7ddf9a", "score": "0.61131215", "text": "func (o *TemplateSummaryCommon) GetKind() string {\n\tif o == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\n\treturn o.Kind\n}", "title": "" }, { "docid": "48b5fba14ddae74f506f6859f9e0d8e5", "score": "0.61129284", "text": "func (o BindingPatchTypeOutput) Kind() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v BindingPatchType) *string { return v.Kind }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "a50463328650d67b066785c27f51cb53", "score": "0.61104757", "text": "func (_this *TextTrack) Kind() TextTrackKind {\n\tvar ret TextTrackKind\n\tvalue := _this.Value_JS.Get(\"kind\")\n\tret = TextTrackKindFromJS(value)\n\treturn ret\n}", "title": "" }, { "docid": "19cbbf8ac2fb8b010e858da901b8c8e6", "score": "0.6106901", "text": "func (o TypedLocalObjectReferenceOutput) Kind() pulumi.StringOutput {\n\treturn o.ApplyT(func(v TypedLocalObjectReference) string { return v.Kind }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "7ad7d21baf34db5146a83a6feb7cd903", "score": "0.61035854", "text": "func (d *dockerfileWriter) Kind() kind.Kind {\n\treturn d.kind\n}", "title": "" }, { "docid": "e17d4c2957907ed1a2c1b7c3931364e1", "score": "0.6102976", "text": "func (r *Resolver) Kind() pulumi.StringOutput {\n\treturn (pulumi.StringOutput)(r.s.State[\"kind\"])\n}", "title": "" }, { "docid": "f884ff5df26e1499c0b8d0a41678062c", "score": "0.6100311", "text": "func (p *path) Kind() kind.Kind {\n\treturn p.kind\n}", "title": "" }, { "docid": "41c385a7db4e547e70c484e671858249", "score": "0.6093459", "text": "func (o TypedLocalObjectReferencePatchOutput) Kind() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v TypedLocalObjectReferencePatch) *string { return v.Kind }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "04eebe71ee3a127f48f8a7415dad8236", "score": "0.60930705", "text": "func (o PersistentVolumePatchTypeOutput) Kind() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v PersistentVolumePatchType) *string { return v.Kind }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "55abb511bdf19b1c23586abfb7564237", "score": "0.60895", "text": "func (t Types) Kind() Kind {\n\tfor k := kindMax; k > kindMin; k-- {\n\t\tif t.Get(k) {\n\t\t\treturn k\n\t\t}\n\t}\n\treturn kindMin\n}", "title": "" }, { "docid": "098088516537d20f6b42da32f69f2e7f", "score": "0.60889435", "text": "func (im *InstanceManager) Kind() string {\n\treturn instanceKind + im.Gds.SuffixOfKind\n}", "title": "" }, { "docid": "adbe740b0b3236e29c6e1d22561822ea", "score": "0.6084027", "text": "func (o CustomResourceDefinitionPatchTypeOutput) Kind() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v CustomResourceDefinitionPatchType) *string { return v.Kind }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "1ac93d2c4f3a1fd009037354f47f5e77", "score": "0.60787016", "text": "func (o *ResourceQuota) SetKind(v string) {\n\to.Kind = &v\n}", "title": "" } ]
0f4af1d9ddca3c8cd909a0c488e80bfc
ProcessUsers returns a list of users given a set of filters.
[ { "docid": "f0c53e99c11d851f9a64ea7fa8a88bf3", "score": "0.66598654", "text": "func (b *backend) ProcessUsers(users *v1.Users) (*v1.UsersReply, error) {\n\tvar reply v1.UsersReply\n\treply.Users = make([]v1.AbridgedUser, 0)\n\n\temailQuery := strings.ToLower(users.Email)\n\tusernameQuery := formatUsername(users.Username)\n\n\terr := b.db.AllUsers(func(user *database.User) {\n\t\treply.TotalUsers++\n\t\tuserMatches := true\n\n\t\t// If both emailQuery and usernameQuery are non-empty, the user must\n\t\t// match both to be included in the results.\n\t\tif emailQuery != \"\" {\n\t\t\tif !strings.Contains(strings.ToLower(user.Email), emailQuery) {\n\t\t\t\tuserMatches = false\n\t\t\t}\n\t\t}\n\n\t\tif usernameQuery != \"\" && userMatches {\n\t\t\tif !strings.Contains(strings.ToLower(user.Username), usernameQuery) {\n\t\t\t\tuserMatches = false\n\t\t\t}\n\t\t}\n\n\t\tif userMatches {\n\t\t\treply.TotalMatches++\n\t\t\tif reply.TotalMatches < v1.UserListPageSize {\n\t\t\t\treply.Users = append(reply.Users, v1.AbridgedUser{\n\t\t\t\t\tID: user.ID.String(),\n\t\t\t\t\tEmail: user.Email,\n\t\t\t\t\tUsername: user.Username,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Sort results alphabetically.\n\tsort.Slice(reply.Users, func(i, j int) bool {\n\t\treturn reply.Users[i].Username < reply.Users[j].Username\n\t})\n\n\treturn &reply, nil\n}", "title": "" } ]
[ { "docid": "d8ff79675bd17389cb6c240f190ae659", "score": "0.6353452", "text": "func ProcessUsers(userList []*User) error {\n\texistingGroups := make(map[string]bool)\n\n\tfor _, u := range userList {\n\t\t// Check for OS groups and create them if needed\n\t\tfor _, g := range u.Groups {\n\t\t\tif !existingGroups[g] {\n\t\t\t\tif err := checkOrCreateGroup(g); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\texistingGroups[g] = true\n\t\t\t}\n\t\t}\n\n\t\tif u.notExist && u.Action != Disable {\n\t\t\terr := u.osCreateUser()\n\t\t\tif err != nil {\n\t\t\t\tuerr := fmt.Errorf(\"Error attempting to create user %s: %s\", u.Username, err.Error())\n\t\t\t\treturn uerr\n\t\t\t}\n\t\t} else if u.Action == Disable {\n\t\t\tif !u.notExist {\n\t\t\t\terr := u.Disable()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\terr := u.Update()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "e4cf0c68a3944231678ca72e5ab88013", "score": "0.6262576", "text": "func (c *ThreeScaleClient) ListUsers(accountID int64, filterParams Params) (*UserList, error) {\n\tendpoint := fmt.Sprintf(userList, accountID)\n\treq, err := c.buildGetReq(endpoint)\n\tif err != nil {\n\t\treturn nil, httpReqError\n\t}\n\n\tvalues := url.Values{}\n\tfor k, v := range filterParams {\n\t\tvalues.Add(k, v)\n\t}\n\treq.URL.RawQuery = values.Encode()\n\n\tresp, err := c.httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\tuserList := &UserList{}\n\terr = handleJsonResp(resp, http.StatusOK, userList)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn userList, nil\n}", "title": "" }, { "docid": "0dbfd263e323de3321870c3adda73824", "score": "0.62411666", "text": "func FindUsersByFilters(ID string, page int64, search string, relationType string) ([]*models.User, bool) {\n\tctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)\n\tdefer cancel()\n\n\tdb := MongoConnection.Database(\"gotwitor\")\n\tcollection := db.Collection(\"user\")\n\n\tvar result []*models.User\n\topts := options.Find()\n\topts.SetSkip((page - 1) * 20)\n\topts.SetLimit(20)\n\n\tquery := bson.M{\n\t\t\"name\": bson.M{\"$regex\": `(?i)` + search},\n\t}\n\trecords, err := collection.Find(ctx, query, opts)\n\n\tif err != nil {\n\t\tlog.Fatal(err.Error())\n\t\treturn result, false\n\t}\n\n\tvar add bool\n\n\tfor records.Next(context.TODO()) {\n\t\tvar usu models.User\n\t\terr = records.Decode(&usu)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err.Error())\n\t\t\treturn result, false\n\t\t}\n\t\tif ID == usu.ID.Hex() {\n\t\t\tcontinue\n\t\t}\n\t\trel, _ := FindRelationByUserAndRelationUser(ID, usu.ID.Hex())\n\t\tif ID == rel.RelationUserID {\n\t\t\tcontinue\n\t\t}\n\t\tadd = false\n\t\tif relationType == \"NO_FOLLOW\" && len(rel.UserID) < 1 {\n\t\t\tadd = true\n\t\t} else if relationType == \"FOLLOW\" && len(rel.UserID) > 0 {\n\t\t\tadd = true\n\t\t}\n\n\t\tif add {\n\t\t\tusu.Password = \"\"\n\t\t\tresult = append(result, &usu)\n\t\t}\n\t}\n\trecords.Close(context.TODO())\n\treturn result, true\n}", "title": "" }, { "docid": "d55fc5b73c2a74a1649529f9d36cce93", "score": "0.6201679", "text": "func (us *UserStorage) FetchUsers(filterString string, skip, limit int) ([]model.User, int, error) {\n\tq := bson.D{}\n\tif len(filterString) > 0 {\n\t\tq = bson.D{\n\t\t\tprimitive.E{Key: \"$or\", Value: bson.A{\n\t\t\t\tbson.D{primitive.E{Key: \"username\", Value: primitive.Regex{Pattern: filterString, Options: \"i\"}}},\n\t\t\t\tbson.D{primitive.E{Key: \"email\", Value: primitive.Regex{Pattern: filterString, Options: \"i\"}}},\n\t\t\t\tbson.D{primitive.E{Key: \"phone\", Value: primitive.Regex{Pattern: filterString, Options: \"i\"}}},\n\t\t\t}},\n\t\t}\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), 2*us.timeout)\n\tdefer cancel()\n\n\ttotal, err := us.coll.CountDocuments(ctx, q)\n\tif err != nil {\n\t\treturn []model.User{}, 0, err\n\t}\n\n\tfindOptions := options.Find()\n\tfindOptions.SetSort(bson.D{primitive.E{Key: \"username\", Value: 1}})\n\tfindOptions.SetLimit(int64(limit))\n\tfindOptions.SetSkip(int64(skip))\n\n\tcurr, err := us.coll.Find(ctx, q, findOptions)\n\tif err != nil {\n\t\treturn []model.User{}, 0, err\n\t}\n\n\tusersData := []model.User{}\n\tif err = curr.All(ctx, &usersData); err != nil {\n\t\treturn []model.User{}, 0, err\n\t}\n\n\treturn usersData, int(total), err\n}", "title": "" }, { "docid": "e1ba19168931bc45b522f3bc70b6424b", "score": "0.61870474", "text": "func (c Client) GetUsers(usersList []string) ([]UserData, error) {\n\tvar s []UserData\n\n\tfor i := 0; i < int(math.Ceil(float64(len(usersList))/MAX_STREAMS)); i++ {\n\t\tend := i*MAX_STREAMS + MAX_STREAMS\n\t\tif len(usersList) < end {\n\t\t\tend = len(usersList)\n\t\t}\n\n\t\tr, err := c.get100Users(usersList[i*MAX_STREAMS : end])\n\t\tif err != nil {\n\t\t\tlog.Error(\"Error while reggint str: \", err)\n\t\t\treturn s, nil\n\t\t}\n\n\t\ts = append(s, r...)\n\t\t// log.Debug(\"Streams: \", s)\n\t}\n\n\treturn s, nil\n}", "title": "" }, { "docid": "c7677bd60b7e5abcb71ae02dad9272ae", "score": "0.6178317", "text": "func GetUsers(c *gin.Context) {\n\tqueryParams := c.Request.URL.Query()\n\tif len(queryParams) >= 0 {\n\t\tc.JSON(http.StatusOK, gin.H{\"status\": http.StatusOK, \"data\": filterUsers(queryParams)})\n\t} else {\n\t\tc.JSON(http.StatusOK, gin.H{\"status\": http.StatusOK, \"data\": getSlicedUsers()})\n\t}\n}", "title": "" }, { "docid": "7730272a338c568e1219626af2417be4", "score": "0.611573", "text": "func (u *Userpg) GetAllUsers(pRequesterUserID int64, pHowMany int) ([]Userpg, error) {\n\tvar result []User\n\trequester, errSelectRequester := getRequesterSecurityGroup(b, 1)\n\tif errSelectRequester != nil {\n\t\treturn result, errSelectRequester\n\t}\n\tvar errSelect error\n\tswitch requester.SecurityGroup {\n\tcase 1:\n\t\t{\n\t\t\terrSelect = b.DBConn.Model(&result).Order(\"id DESC\").Limit(pHowMany).Select()\n\t\t}\n\tcase 2:\n\t\t{\n\t\t\terrSelect = b.DBConn.Model(&result).Where(\"team_id = ?\", requester.TeamID).Limit(pHowMany).Select()\n\t\t}\n\t}\n\treturn result, errSelect\n}", "title": "" }, { "docid": "9df787787f0cdf34cd118b6d23be22eb", "score": "0.61063206", "text": "func SearchUsers(conn *store.Connection, s store.Sort, f store.Filters, p *store.Pagination) ([]*user.User, error) {\n\ttx := conn.Model(new(user.User))\n\tfilters := f.Copy()\n\tif v, ok := filters[key.UserID]; ok {\n\t\tfilters[key.ID] = v\n\t\tdelete(filters, key.UserID)\n\t}\n\tif uid, ok := filters[key.ID].(string); ok && uid != \"\" {\n\t\tid, err := uuid.Parse(uid)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tfilters[key.ID] = id\n\t}\n\tif v, ok := filters[key.Role].(string); ok {\n\t\tfilters[key.Role] = user.ToRole(v)\n\t}\n\tflt := store.Filter{\n\t\tFilters: filters,\n\t\tDataField: key.Data,\n\t\tFields: []string{\n\t\t\tkey.Email,\n\t\t\tkey.ID,\n\t\t\tkey.Provider,\n\t\t\tkey.Role,\n\t\t\tkey.Username,\n\t\t},\n\t}\n\tvar users []*user.User\n\ttx = tx.Where(key.ID+\" <> ?\", user.SuperAdminID.String())\n\terr := store.Search(tx, &users, s, flt, p)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn users, err\n}", "title": "" }, { "docid": "24823be38de6f64f01866671d967a4e0", "score": "0.608023", "text": "func (it *Users) GetByFilter(filter string) ([]User, error) {\n\tlog.WithFields(log.Fields{\n\t\t\"filter\": filter,\n\t\t\"base\": it.c.Attributes.SearchBase,\n\t}).Debug(\"GetByFilter\")\n\tsr := client.NewSearchRequest(it.c.Attributes.SearchBase, filter)\n\tentries, err := it.c.cl.SearchEntries(sr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"can't perform search: %s\", err.Error())\n\t}\n\tif len(entries) == 0 {\n\t\treturn nil, nil\n\t}\n\tusers := []User{}\n\tfor _, e := range entries {\n\t\tusers = append(users, User{\n\t\t\tDN: e.DN,\n\t\t\tID: e.GetAttributeValue(\"sAMAccountName\"),\n\t\t\tCN: e.GetAttributeValue(\"cn\"),\n\t\t\tMail: e.GetAttributeValue(\"mail\"),\n\t\t\tDisplayName: e.GetAttributeValue(\"displayName\"),\n\t\t})\n\t}\n\treturn users, nil\n}", "title": "" }, { "docid": "ed8c2eaa39af4a10d572388a8496ae54", "score": "0.60551053", "text": "func findAllUsers(db *gorm.DB, filter usersFilter) []User {\n\tusers := []User{}\n\tif filter.active == -1 {\n\t\tdb.Find(&users)\n\t} else if filter.active == 0 {\n\t\tdb.Where(\"active = ?\", false).Find(&users)\n\t} else {\n\t\tdb.Where(\"active = ?\", true).Find(&users)\n\t}\n\n\treturn users\n}", "title": "" }, { "docid": "3a2d8d0d94c9062af611a78cea3a05c4", "score": "0.59364086", "text": "func (m *userStorage) GetUsers(\n\tgtx context.Context,\n\toffset, limit int64,\n\tfilter *teak.Filter) ([]*teak.User, error) {\n\tselector := GenerateSelector(filter)\n\tusers := make([]*teak.User, 0, limit)\n\tfopts := options.Find().SetSkip(offset).SetLimit(limit)\n\tcur, err := C(\"users\").Find(gtx, selector, fopts)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer cur.Close(gtx)\n\terr = cur.All(gtx, &users)\n\treturn users, teak.LogError(\"t.user.mongo\", err)\n}", "title": "" }, { "docid": "a10c38631ddf2f141b2670e983f2c680", "score": "0.58855265", "text": "func fetchUsers(params map[string]interface{}) ([]User, error) {\n\tcount := params[\"count\"].(int)\n\n\tif interests, ok := params[\"interests\"].([]string); ok {\n\t\tvar allUsers []User\n\n\t\tfor _, interest := range interests {\n\t\t\tif users, err := _fetchUsers(\"ZRANGE\", fmt.Sprint(\"interest:\", interest), 0, count-1); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t} else {\n\t\t\t\tfor _, user := range users {\n\t\t\t\t\tif !user.in(allUsers) {\n\t\t\t\t\t\tallUsers = append(allUsers, user)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn allUsers, nil\n\t}\n\n\treturn _fetchUsers(\"ZRANGE\", \"users\", 0, count-1)\n}", "title": "" }, { "docid": "85c18dc5c7ca2afe128013987718ec90", "score": "0.58688384", "text": "func GetUsers(db *gorm.DB, limit *string) (*[]UserItem, error) {\n\tvar err error\n\tvar users []UserItem\n\tif limit != nil {\n\t\tvar limitval int\n\t\tif limitval, err = strconv.Atoi(*limit); err != nil {\n\t\t\tfmt.Printf(\"Error(GetUsers): Invalid limit param : %s\\n\", err.Error())\n\t\t\treturn nil, ErrInvalidLimit\n\t\t} else if limitval < 1 || limitval > maxLimit {\n\t\t\treturn nil, ErrInvalidLimit\n\t\t}\n\t\tif goscrappy.Debug {\n\t\t\tfmt.Printf(\"Info(GetUsers): Will looking for %v first users\\n\", limitval)\n\t\t}\n\t\tif err = db.Limit(limitval).Find(&users).Error; err != nil {\n\t\t\tfmt.Printf(\"Error(GetUsers): %s\\n\", err.Error())\n\t\t\tif err == gorm.ErrRecordNotFound {\n\t\t\t\treturn nil, nil\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\n\t} else if err = db.Find(&users).Error; err != nil {\n\t\tfmt.Printf(\"Error(GetUsers): %s\\n\", err.Error())\n\t\tif err == gorm.ErrRecordNotFound {\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn nil, err\n\t}\n\tfor el := range users {\n\t\tusers[el].GetSubList()\n\t\tif err = db.Model(&users[el]).\n\t\t\tAssociation(\"ScrappingRequestItems\").\n\t\t\tFind(&users[el].ScrappingRequestItems); err != nil {\n\t\t\tfmt.Printf(\"Error(GetUsers): %s\\n\", err.Error())\n\t\t\treturn nil, err\n\t\t}\n\t\tif goscrappy.Debug {\n\t\t\tfmt.Printf(\"Info(GetUsers): Found user [%+v]\\n\", users[el])\n\t\t}\n\t}\n\treturn &users, nil\n}", "title": "" }, { "docid": "e35be6e84be22f9d6487f21db0692b15", "score": "0.58512366", "text": "func getUsers(identifications []internal.IdentificationType) []string {\n\tvar users []string\n\tfor _, identification := range identifications {\n\t\tusers = append(users, identification.User)\n\t}\n\treturn users\n}", "title": "" }, { "docid": "0db6edce2a16ebe2c0b048262f391ed7", "score": "0.58398885", "text": "func (repo *MongoRepository) GetAllUsersFromWhitelist() ([]models.WhitelistUser, error) {\n\t//data structure to where the data will be written to\n\tvar users []models.WhitelistUser\n\n\t//choose the database and collection\n\tcollection := repo.Client.Database(\"podchef\").Collection(\"whitelist\")\n\n\t//data to filter the search with\n\tfilter := bson.M{}\n\n\t//call driven adapter responsible for getting a users's data from the database to a cursor\n\tcur, err := collection.Find(context.Background(), filter)\n\n\tif err != nil {\n\t\tif err == mongo.ErrNoDocuments {\n\t\t\treturn nil, &pkg.Error{Err: err, Code: http.StatusNotFound, Message: \"No users were found\"}\n\t\t}\n\t\t//print the error stack\n\t\tlog.Error(err)\n\n\t\t//return a custom error\n\t\treturn nil, &pkg.Error{Err: err, Code: http.StatusInternalServerError, Message: \"Internal error\"}\n\t}\n\n\t//decode all the data from the cursor into the users's structure\n\terr = cur.All(context.Background(), &users)\n\n\tif err != nil {\n\t\t//print the error stack\n\t\tlog.Error(err)\n\n\t\t//return a custom error\n\t\treturn nil, &pkg.Error{Err: err, Code: http.StatusInternalServerError, Message: \"Internal error\"}\n\t}\n\n\treturn users, nil\n}", "title": "" }, { "docid": "1fe85b28d43f8b2f8f1ad59278bad2ee", "score": "0.5838749", "text": "func (service *UserService) Users(params map[string]string) (*[]models.User, *response.Meta) {\n\tvar (\n\t\tpage = 1\n\t\tlimit = 10\n\t\tstart int\n\t\ttotal int64\n\t\terr error\n\t)\n\n\tif value, exist := params[\"page\"]; exist == true {\n\t\tv, err := strconv.Atoi(value)\n\t\tif err != nil {\n\n\t\t}\n\t\tif v >= 0 {\n\t\t\tpage = v\n\t\t}\n\t}\n\n\tif value, exist := params[\"limit\"]; exist == true {\n\t\tv, err := strconv.Atoi(value)\n\t\tif err != nil {\n\n\t\t}\n\t\tif v >= 0 {\n\t\t\tlimit = v\n\t\t}\n\t}\n\n\tstart = (page - 1) * limit\n\tusers := make([]models.User, 0)\n\n\tif search, exist := params[\"search\"]; exist && search != \"\" {\n\t\ttotal, err = models.Engine.Where(builder.Like{\"name\", search}).Limit(limit, start).Count(&users)\n\t} else {\n\t\ttotal, err = models.Engine.Limit(limit, start).Count(&users)\n\t}\n\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\n\treturn &users, &response.Meta{\n\t\tLimit: limit,\n\t\tPage: page,\n\t\tTotal: int(total),\n\t}\n}", "title": "" }, { "docid": "9f1f45e15d390de951910888693977fb", "score": "0.5822141", "text": "func FetchPeopleUsers(profileIDStr string, filterOptionsStr string, usersOffsetStr string) ([]*response.UserResponse, error) {\n\tprofileID, _ := primitive.ObjectIDFromHex(profileIDStr)\n\n\tusersCollection := db.Instance.Database.Collection(\"users\")\n\n\tvar profile *models.User\n\n\tcontext := context.TODO()\n\n\tusersCollection.FindOne(context, bson.M{\"_id\": profileID}).Decode(&profile)\n\n\tlocationsCollection := db.Instance.Database.Collection(\"locations\")\n\n\tvar locations []models.Location\n\n\tcurLocations, err := locationsCollection.Find(context, bson.M{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor curLocations.Next(context) {\n\t\tvar location models.Location\n\n\t\tif err := curLocations.Decode(&location); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tlocations = append(locations, location)\n\t}\n\n\tif err := curLocations.Err(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tcurLocations.Close(context)\n\n\tvar targetSex string\n\n\tif profile.Sex == \"male\" {\n\t\ttargetSex = \"female\"\n\t}\n\n\tif profile.Sex == \"female\" {\n\t\ttargetSex = \"male\"\n\t}\n\n\tusersMatch := bson.M{\n\t\t\"_id\": bson.M{\"$ne\": profileID},\n\t\t\"photos\": bson.M{\"$exists\": true, \"$ne\": bson.A{}},\n\t}\n\n\tif targetSex != \"\" {\n\t\tusersMatch[\"sex\"] = targetSex\n\t}\n\n\tvar users []models.User\n\n\tcurUsers, err := usersCollection.Find(context, usersMatch)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor curUsers.Next(context) {\n\t\tvar user models.User\n\n\t\tif err := curUsers.Decode(&user); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tusers = append(users, user)\n\t}\n\n\tif err := curUsers.Err(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tcurUsers.Close(context)\n\n\tvar filterOptions models.FilterOptions\n\n\tif err := json.Unmarshal([]byte(filterOptionsStr), &filterOptions); err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar usersResponse []*response.UserResponse\n\n\tfor _, user := range users {\n\t\tif ApplyFilters(&user, filterOptions) {\n\t\t\tusersResponse = append(usersResponse, response.MakeUserResponse(&user))\n\t\t}\n\t}\n\n\treturn usersResponse, nil\n}", "title": "" }, { "docid": "bbf26662d1d2a6dce33e2a98a3cc9d42", "score": "0.5817524", "text": "func GetUsers(w http.ResponseWriter, r *http.Request) {\n\tqueries := r.URL.Query()\n\tlog.Println(\"queries...\", queries)\n\n\tusername := baseinfo.GetUsernameFromHeader(r)\n\tsid, sname, stype := MysqlClient.GetBaseInfo(username)\n\tif stype == \"\" {\n\t\tmsg := \"there is no user or invalid user with no type\"\n\t\tlog.Println(msg)\n\t\thttp.Error(w, msg, http.StatusBadRequest)\n\t\treturn\n\t}\n\n\terr := validOperation(OP_LIST, &BaseInfo{sid, sname, stype}, nil)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\ttarType := queries.Get(\"type\")\n\tpage, _ := strconv.Atoi(queries.Get(\"page\"))\n\titems, _ := strconv.Atoi(queries.Get(\"items\"))\n\n\tlog.Println(page, items, \"page and items...\")\n\t// if page is 0, then return all\n\tdata := MysqlClient.GetAllUsers(page, items, sid, stype, tarType)\n\n\tret, _ := json.Marshal(data)\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Header().Set(\"Content-Length\", strconv.Itoa(len(ret)))\n\tw.WriteHeader(http.StatusOK)\n\tw.Write([]byte(ret))\n\treturn\n}", "title": "" }, { "docid": "85f0f0025f03c605555c867058e9bd5e", "score": "0.5796191", "text": "func (c Client) GetUsers(filter ...*getUsersFilter) (*Users, error) {\n\tgetBody, err := c.GenericGetQuery(linkUsers, merge(filter))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar users Users\n\terrUnmarshal := json.Unmarshal(getBody, &users)\n\tif errUnmarshal != nil {\n\t\treturn nil, errUnmarshal\n\t}\n\n\treturn &users, nil\n}", "title": "" }, { "docid": "87d3952308cdf3dcfbbc5c8632d5904a", "score": "0.5787108", "text": "func GetFilteredUserRegistrations(w http.ResponseWriter, r *http.Request) {\n\tparameters := r.URL.Query()\n\tuser_registrations, err := service.GetFilteredUserRegistrations(parameters)\n\n\tif err != nil {\n\t\terrors.WriteError(w, r, errors.DatabaseError(err.Error(), \"Could not get filtered user registrations.\"))\n\t\treturn\n\t}\n\n\tjson.NewEncoder(w).Encode(user_registrations)\n}", "title": "" }, { "docid": "f6047f4d4e174329a8ba8b97224ee699", "score": "0.5779309", "text": "func UsersHandler(res http.ResponseWriter, req *http.Request) {\n\t// user list variable\n\tvar usersList UsersList\n\t// user array of user lists\n\tvar usersArray []UsersList\n\n\t// Get all users listed in a specific organization\n\trows, err := DB.Query(`SELECT firstname, lastname, email, admin FROM users WHERE organization=$1;`, DBUser.Organization)\n\tif DBUser.Organization == \"all\" && DBUser.Creator == true {\n\t\trows, err = DB.Query(`SELECT firstname, lastname, email, admin FROM users;`)\n\t}\n\tif err, ok := OnError(err, http.StatusInternalServerError); !ok {\n\t\tres.Write(err)\n\t\treturn\n\t}\n\n\tdefer rows.Close()\n\n\tfor rows.Next() {\n\t\terr := rows.Scan(&usersList.FirstName, &usersList.LastName, &usersList.Email, &usersList.Admin)\n\t\tif err, ok := OnError(err, http.StatusInternalServerError); !ok {\n\t\t\tres.Write(err)\n\t\t\treturn\n\t\t}\n\t\tusersArray = append(usersArray, usersList)\n\t}\n\n\t// If user requesting this information is an admin return all the users for that organization\n\t// else The user requesting this information is returned a bool specifying they are not an admin\n\tif DBUser.Admin == true {\n\t\tusers, err := json.Marshal(usersArray)\n\t\tif err, ok := OnError(err, http.StatusInternalServerError); !ok {\n\t\t\tres.Write(err)\n\t\t\treturn\n\t\t}\n\n\t\tres.Header().Set(\"Content-Type\", \"application/json\")\n\t\tres.Write(users)\n\t} else {\n\t\tunAuthUser, err := json.Marshal(struct {\n\t\t\tType int `json:\"type\"`\n\t\t\tAdmin bool `json:\"admin\"`\n\t\t}{\n\t\t\tType: http.StatusUnauthorized,\n\t\t\tAdmin: false,\n\t\t})\n\t\tif err, ok := OnError(err, http.StatusUnauthorized); !ok {\n\t\t\tres.Write(err)\n\t\t\treturn\n\t\t}\n\t\tres.Header().Set(\"Content-Type\", \"application/json\")\n\t\tres.Write(unAuthUser)\n\t}\n}", "title": "" }, { "docid": "4e1263028cab1c14a79e5fe101473305", "score": "0.5740078", "text": "func (c *SafeUsersMap) Filter(f func(*model.User) bool) (L []*model.User) {\n\tc.RLock()\n\tdefer c.RUnlock()\n\tfor _, v := range c.M {\n\t\tif f(v) {\n\t\t\tL = append(L, v)\n\t\t}\n\t}\n\treturn\n}", "title": "" }, { "docid": "25ec2a2bdb0fe59d435757ea8a2d1400", "score": "0.5729917", "text": "func (a *App) GetUsers(limit, offset int) ([]*model.User, *model.AppErr) {\n\tusers, err := a.Srv().Store.User().GetAll(limit, offset)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor _, u := range users {\n\t\tu.Sanitize(map[string]bool{})\n\t}\n\treturn users, nil\n}", "title": "" }, { "docid": "82eaaa4757e73a782edb1df6cf8168d2", "score": "0.5718633", "text": "func getUsersInfos(w http.ResponseWriter, r *http.Request) {\n\tsmask := context.Get(r, \"infomask\").(string)\n\tmask, err := strconv.ParseInt(smask, 10, 0)\n\tif err != nil {\n\t\tEasyErrorResponse(w, core.NebError, err)\n\t\treturn\n\t}\n\tspage := context.Get(r, \"page\").(string)\n\tpage, err := strconv.ParseInt(spage, 10, 0)\n\tif err != nil {\n\t\tEasyErrorResponse(w, core.NebError, err)\n\t\treturn\n\t}\n\t// Pages start at 1\n\tpage -= 1\n\tusers, err := core.GetUsersInfos(int(page)*30, 30, int(mask))\n\tif err != nil {\n\t\tEasyErrorResponse(w, core.NebError, err)\n\t\treturn\n\t}\n\n\tEasyDataResponse(w, users)\n}", "title": "" }, { "docid": "42a6dc6e377975f289f7ff1105577baa", "score": "0.5704001", "text": "func (g *groupService) GetUsers(group, filter string) ([]*User, error) {\n\tloc := fmt.Sprintf(\n\t\t\"/rest/api/1.0/admin/groups/more-members?context=%s\", group)\n\tif len(filter) > 0 {\n\t\tloc += fmt.Sprintf(\"&filter=%s\", filter)\n\t}\n\n\treq, err := g.createReq(\"GET\", loc, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar r PagedUsers\n\terr = json.NewDecoder(resp.Body).Decode(&r)\n\tresp.Body.Close()\n\treturn r.Values, err\n}", "title": "" }, { "docid": "3ac21416d06d169f7e2025e28866191c", "score": "0.5701571", "text": "func GetUsersByName(name string, delFilter int) ([]*User, error) {\n\tdeleted1 := false\n\tdeleted2 := false\n\tswitch delFilter {\n\tcase DELETED:\n\t\tdeleted1 = true\n\t\tdeleted2 = true\n\tcase ALL:\n\t\tdeleted2 = true\n\t}\n\trows, err := userSQL.GetByName.Query(name, deleted1, deleted2)\n\tif err != nil {\n\t\trows.Close()\n\t\tlog.Println(err.Error())\n\t\treturn nil, err\n\t}\n\tusers := []*User{}\n\tfor rows.Next() {\n\t\tuser := new(User)\n\t\tif err = rows.Scan(&user.LoginID, &user.Name, &user.Email, &user.Password, &user.DeletedUser, &user.DelOn); err != nil {\n\t\t\tlog.Println(err.Error())\n\t\t\trows.Close()\n\t\t\treturn users, err\n\t\t}\n\t\tusers = append(users, user)\n\t}\n\n\trows.Close()\n\treturn users, nil\n}", "title": "" }, { "docid": "04e59787d88568b87568893b4ca0df26", "score": "0.569543", "text": "func ListUsers(search map[string]string) ([]UserSummary, error) {\n\tquery, queryParams := usersSearchMapping.CreateQuery(`SELECT id, username, fullname, role, email, phone FROM users\n\tWHERE %MAPPING_CONDITIONS%`, search)\n\n\t// Read all users from the database\n\trows, err := db.Query(query, queryParams...)\n\n\tif err != nil {\n\t\treturn []UserSummary{}, utils.InternalServerError(err)\n\t}\n\n\t// Iterate over all rows and store in slice\n\treturn readUsersFromRows(rows)\n}", "title": "" }, { "docid": "404889d1d73e31f08c65d7566737dcf4", "score": "0.5692382", "text": "func ListUsers(c *gin.Context) {\n\tinfo := struct {\n\t\tNetworkID int `form:\"networkID\"`\n\t}{}\n\n\tif err := c.ShouldBindQuery(&info); err != nil {\n\t\tresponse.Err(http.StatusBadRequest, enum.CodeErrMissingArgument).\n\t\t\tSetMessage(err.Error()).\n\t\t\tResult(c.JSON)\n\t\treturn\n\t}\n\n\tvar users []model.CaUser\n\tvar err error\n\tif info.NetworkID == 0 {\n\t\tusers, err = dao.FindAllCaUser()\n\t} else {\n\t\tusers, err = dao.FindAllUserInNetwork(info.NetworkID)\n\t}\n\tif err != nil {\n\t\tresponse.Err(http.StatusInternalServerError, enum.CodeErrDB).\n\t\t\tSetMessage(err.Error()).\n\t\t\tResult(c.JSON)\n\t}\n\n\tresponse.Ok().\n\t\tSetPayload(response.NewUsers(users)).\n\t\tResult(c.JSON)\n}", "title": "" }, { "docid": "b219f8caa3337ab2d298b1c081bcc028", "score": "0.5684211", "text": "func (req *SubmissionRequest) validateUsers(env *TestEnvironment) ([]*Student, error) {\n\n\tallStudents := make([]*Student, 0)\n\n\tfor _, user := range req.Users {\n\n\t\tif students, err := getStudents(user.Email, user.Token, env); err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tallStudents = append(allStudents, students[0])\n\t\t}\n\t}\n\n\treturn allStudents, nil\n}", "title": "" }, { "docid": "58440bd7c4859c0b25df11b34159c81f", "score": "0.5653044", "text": "func (*Server) GetAllUsers(ctx context.Context, r *user.GetAllUsersRequest) (*user.GetAllUsersResponse, error) {\n\tlog.Printf(\"Receive message body from client: %v\", r.GetPageNumber())\n\n\tusers, count, err := models.GetAllUsers(r.GetPageNumber(), r.GetResultPerPage())\n\tif err != nil {\n\t\tlog.Printf(\"An error occured: %v\", err)\n\t\treturn &user.GetAllUsersResponse{}, err\n\t}\n\tvar test user.GetUserResponse\n\tvar data []*user.GetUserResponse\n\t//FIX: throwing slice error\n\tcopier.Copy(&test, users)\n\tdata = append(data, &test)\n\n\treturn &user.GetAllUsersResponse{\n\t\tPageNumber: r.GetPageNumber(),\n\t\tResultPerPage: r.GetResultPerPage(),\n\t\tTotalCount: count,\n\t\tUsers: data,\n\t}, nil\n}", "title": "" }, { "docid": "6cb697cf6d66a1fd14cff43d533bd07a", "score": "0.565004", "text": "func (sp *ScyllaOrganizationProvider) ListUsers(organizationID string) ([]string, derrors.Error) {\n\n\tsp.Lock()\n\tdefer sp.Unlock()\n\n\t// 1.-Check if the organization exists\n\texists, err := sp.UnsafeGenericExist(organizationTable, organizationTablePK, organizationID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !exists {\n\t\treturn nil, derrors.NewNotFoundError(\"organization\").WithParams(organizationID)\n\t}\n\n\tstmt, names := qb.Select(organizationUserTable).Columns(\"email\").Where(qb.Eq(\"organization_id\")).ToCql()\n\tq := gocqlx.Query(sp.Session.Query(stmt), names).BindMap(qb.M{\n\t\t\"organization_id\": organizationID,\n\t})\n\n\tusers := make([]string, 0)\n\tcqlErr := q.SelectRelease(&users)\n\tif cqlErr != nil {\n\t\treturn nil, derrors.AsError(cqlErr, \"cannot list users\")\n\t}\n\n\treturn users, nil\n}", "title": "" }, { "docid": "97d064b2c1fed7011812ff1caee8b820", "score": "0.56496644", "text": "func (srv httpService) ListUsers(w http.ResponseWriter, r *http.Request) {\n\tjwt := r.Header.Get(\"X-Authentication-Token\")\n\tif jwt == \"\" {\n\t\t// 400\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tfmt.Fprintf(w, `{\"error\":\"jwt not found\"}`)\n\n\t\treturn\n\t}\n\n\t// validate jwt\n\tif email := ddd.ParseJWTClaims(jwt); email == \"\" {\n\t\t// 400\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tfmt.Fprintf(w, `{\"error\":\"invalid jwt\"}`)\n\n\t\treturn\n\t}\n\n\tusers, err := srv.userRepo.List()\n\tif err != nil {\n\t\t// 400 - we should be able to override this status code but we will use this for now\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tfmt.Fprintf(w, `{\"error\":\"%s\"}`, err)\n\n\t\treturn\n\t}\n\n\tbs, _ := json.Marshal(UsersResponse{\n\t\tUsers: newUserResponse(users),\n\t})\n\n\tfmt.Fprintf(w, \"%s\", bs)\n}", "title": "" }, { "docid": "6a31c00268e25b9986c62d478096d4c9", "score": "0.5646173", "text": "func (srv *Server) ListUsers(ctx context.Context, req *gooserv1.ListRequest) (*gooserv1.ListUsersResponse, error) {\n\tu, err := srv.GetUserFromContext(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif u == nil {\n\t\treturn nil, status.Errorf(codes.Unauthenticated, \"unauthenticated\")\n\t}\n\tprinter := message.NewPrinter(language.Make(u.Language))\n\tfilter := req.GetFilter()\n\tusers, totalSize, token, err := srv.store.ListUsers(ctx, printer, filter, \"\", req.GetPageToken(), req.GetPageSize())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar pbUsers []*gooserv1.User\n\tvar pageSize int32\n\tif users != nil {\n\t\tpageSize = int32(len(*users))\n\t\tfor _, m := range *users {\n\t\t\tpbUsers = append(pbUsers, m.ToPb())\n\t\t}\n\t}\n\treturn &gooserv1.ListUsersResponse{\n\t\tUsers: pbUsers,\n\t\tNextPageToken: token,\n\t\tPageSize: pageSize,\n\t\tTotalSize: totalSize,\n\t}, nil\n}", "title": "" }, { "docid": "b535d2949c7aeb257b6f3a0b29f52e6d", "score": "0.56114286", "text": "func (h *Handler) GetUsers() []User {\n\tvar users []User\n\trows, _ := h.DB.Raw(\"SELECT user_id, full_name, msisdn, user_email, birth_date FROM ws_user WHERE birth_date IS NOT NULL LIMIT 500\").Rows()\n\tdefer rows.Close()\n\tfor rows.Next() {\n\t\tvar user User\n\t\trows.Scan(&user.UserID, &user.Name, &user.MSISDN, &user.Email, &user.BirthDate)\n\t\tuser.UserAge = AgeAt(user.BirthDate, time.Now())\n\t\tuser.MSISDN = normalizephone.Normalize(user.MSISDN)\n\t\tif user.UserAge < 150 {\n\t\t\tusers = append(users, user)\n\t\t}\n\t}\n\treturn users\n}", "title": "" }, { "docid": "fc35f8f5109225335303d46be7deb128", "score": "0.55795443", "text": "func (s *Storage) Users(term, value string) ([]model.UserResult, error) {\n\tfmt.Printf(\"Searching users by: %q with value: %q\\n\", term, value)\n\n\tif term == \"_id\" {\n\t\treturn s.searchUserByID(value)\n\t}\n\n\treturn s.searchUserByTerm(term, value)\n}", "title": "" }, { "docid": "298958f802f728356de0c059a5095f8d", "score": "0.55710006", "text": "func (s *Storage) GetUsers(ctx context.Context, typ string, query *jq.Query) (users []*User, count int, next *jq.Query, err error) {\n\tq := *query\n\n\tif q.SortBy == \"\" {\n\t\tq.SortBy = UsersDefaultSortColumn\n\t}\n\n\tsortExpr, err := jq.ColumnExpr(q.SortBy, userQueryColumns)\n\tif err != nil {\n\t\terr = errors.Wrap(err, errors.CodeQuerySyntax)\n\t\treturn\n\t}\n\n\tselOpt := jq.Options{\n\t\tSelectExpr: fmt.Sprintf(\"SELECT users.*, m.membership, ips.ip_whitelist, %s AS _sorted_by\", sortExpr),\n\t\tFromExpr: `\nFROM\n users \n LEFT JOIN\n (\n SELECT\n membership.user_id,\n json_agg( json_build_object( 'tenant_id', membership.tenant_id, 'type', membership.membership_type, 'tenant_name', tenants.name, 'tenant_type', tenants.tenant_type, 'roles', r.roles ) ) AS membership \n FROM\n membership \n INNER JOIN\n tenants \n ON tenants.id = membership.tenant_id \n LEFT JOIN\n (\n SELECT\n membership_id,\n json_agg(role) AS roles \n FROM\n roles \n GROUP BY\n membership_id \n )\n AS r \n ON membership.id = r.membership_id \n WHERE\n membership.membership_status = 'active' \n GROUP BY\n membership.user_id \n )\n AS m \n ON m.user_id = users.id \n LEFT JOIN\n (\n SELECT\n user_id,\n array_agg(addr) AS ip_whitelist \n FROM\n service_account_ip \n GROUP BY\n user_id \n )\n AS ips \n ON ips.user_id = users.id\n`,\n\t\tIDColumn: \"id\",\n\t\tColumns: userQueryColumns,\n\t\tDriverParams: jq.PostgresDriverParams,\n\t}\n\n\tif typ != \"\" {\n\t\tnode := &jq.EQExpr{\n\t\t\tKey: \"account_type\",\n\t\t\tValue: typ,\n\t\t}\n\n\t\tif q.Expr == nil {\n\t\t\tq.Expr = &jq.Expr{Node: node}\n\t\t} else {\n\t\t\tq.Expr = &jq.Expr{Node: &jq.ANDExpr{\n\t\t\t\tq.Expr,\n\t\t\t\t&jq.Expr{Node: node},\n\t\t\t}}\n\t\t}\n\t}\n\n\tstmt, args, err := q.SelectStmt(&selOpt)\n\tif err != nil {\n\t\terr = errors.Wrap(err, errors.CodeQuerySyntax)\n\t\treturn\n\t}\n\n\trows, err := s.DB.QueryxContext(ctx, stmt, args...)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer rows.Close()\n\n\tusersSlice := []*User{}\n\tvar lastItem *userModel\n\n\tfor rows.Next() {\n\t\tvar user userModel\n\t\tif err = rows.StructScan(&user); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tlastItem = &user\n\t\tusersSlice = append(usersSlice, user.toUser())\n\t}\n\n\tif err = rows.Err(); err != nil {\n\t\treturn\n\t}\n\n\t// Count\n\tif q.TotalCount {\n\t\tif stmt, args, err = q.CountStmt(&selOpt); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tif err = s.DB.Get(&count, stmt, args...); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\n\tusers = usersSlice\n\n\tif lastItem != nil {\n\t\t// Update query\n\t\tlastID := lastItem.ID.String()\n\t\tret := *query\n\t\tret.LastID = &lastID\n\t\tret.Last = &lastItem.SortedBy\n\t\tret.TotalCount = false\n\n\t\tnext = &ret\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "1e0bf7019ab7cc885534ff60b1fecd66", "score": "0.5568298", "text": "func (s *StoreProxy) GetAllUsers(pred *SelectionPredicate) ([]*types.User, error) {\n\treturn s.do().GetAllUsers(pred)\n}", "title": "" }, { "docid": "080afa5174598699654c5ece030494de", "score": "0.55645317", "text": "func (h Handler) GetUsers(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tq := r.URL.Query().Get(\"q\")\n\n\tusers, err := h.repository.GetUsersByLoginLike(q)\n\tif err != nil {\n\t\th.logger.Error(\"get users by login like\", zap.String(\"q\", q), zap.Error(err))\n\t\th.SendError(w, http.StatusInternalServerError, DetailGetUsersByLoginFailed)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", DefaultContentType)\n\tjson.NewEncoder(w).Encode(users)\n}", "title": "" }, { "docid": "2ddede11d2a6ef6c5caeebf11b820ddd", "score": "0.55643594", "text": "func (r *queryResolver) Users(ctx context.Context) ([]*model.Player, error) {\n\tpanic(fmt.Errorf(\"not implemented\"))\n}", "title": "" }, { "docid": "a6d672dc18ac69f7fd13a0001c665a18", "score": "0.55596864", "text": "func (nc *NexusConn) UserList(prefix string, limit int, skip int) ([]UserInfo, error) {\n\tpar := map[string]interface{}{\n\t\t\"prefix\": prefix,\n\t\t\"limit\": limit,\n\t\t\"skip\": skip,\n\t}\n\tres, err := nc.Exec(\"user.list\", par)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tusers := make([]UserInfo, 0)\n\tb, err := json.Marshal(res)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = json.Unmarshal(b, &users)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn users, nil\n}", "title": "" }, { "docid": "62841adbd715ad5b73054c666b758324", "score": "0.55492806", "text": "func ApplyList(c echo.Context) error {\n\tresults := &[]orgUserJoinUser{}\n\n\tdb := dbconn.GetConnection()\n\n\terr := db.RawQuery(`\n\t\tselect\n\t\t\tou.id id\n\t\t,\tou.identity identity\n\t\t,\tou.roles roles\n\t\t,\tou.aws_id awsId\n\t\t,\tou.created_at createdAt\n\t\t,\tou.updated_at updatedAt\n\t\t,\tu.identity userIdentity\n\t\t,\tu.is_active isActive\n\t\tfrom org_users ou left join users u\n\t\ton ou.identity = u.org_user\n\t\tand ou.roles = u.roles\n\t\tand u.identity = ?\n\t\twhere ou.is_active = true;\n\t`, jwt.DecodeContext(c, \"identity\")).All(results)\n\n\tif err != nil {\n\t\treturn c.String(http.StatusBadRequest, err.Error())\n\t}\n\n\treturn c.JSON(http.StatusOK, results)\n}", "title": "" }, { "docid": "71f358f904de9cb246bde26f1015bea2", "score": "0.5539076", "text": "func (c *Cache) FilterUsersID(ctx context.Context, filter iface.FilterUsers) ([]int64, error) {\n\tvar ids = make([]int64, 0)\n\tcachekey := userFilterCacheKey(filter)\n\titem, err := c.client.Get(cachekey)\n\tif err != nil {\n\t\tlog.Log(err)\n\t} else if item != nil {\n\t\terr = binary.Read(bytes.NewBuffer(item.Value), binary.LittleEndian, &ids)\n\t\tif err != nil {\n\t\t\tlog.Log(err)\n\t\t} else {\n\t\t\treturn ids, nil\n\t\t}\n\t}\n\n\tidsFromDB, err := c.storage.FilterUsersID(ctx, filter)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbuf := new(bytes.Buffer)\n\terr = binary.Write(buf, binary.LittleEndian, idsFromDB)\n\tif err != nil {\n\t\tlog.Log(err)\n\t} else {\n\t\tvar expiration int32 = 60 * 10 // 10min\n\t\tif filter.Email != \"\" {\n\t\t\texpiration = 10\n\t\t}\n\n\t\terr := c.client.Set(&memcache.Item{\n\t\t\tKey: cachekey,\n\t\t\tValue: buf.Bytes(),\n\t\t\tExpiration: expiration,\n\t\t})\n\t\tif err != nil {\n\t\t\tlog.Log(err)\n\t\t}\n\t}\n\n\treturn idsFromDB, nil\n}", "title": "" }, { "docid": "bcfabb231ed7f16c09dc148958aeaffc", "score": "0.553391", "text": "func GetAllUsers(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"http://localhost:3000\")\n\t// Create an empty list of users\n\tvar users []User\n\t// Query the database\n\trows, queryErr := DB.Query(\"SELECT * FROM users\")\n\t// Catch and handle errors\n\tif queryErr != nil {\n\t\tthrowError(queryErr, w, http.StatusInternalServerError)\n\t}\n\t// For all the rows produced by the query get the user information, put it into a temp user, and then add it to\n\t// the users list\n\tfor rows.Next(){\n\t\tvar u User\n\t\tif scanErr := rows.Scan(&u.ID, &u.First, &u.Last); scanErr != nil{\n\t\t\tthrowError(scanErr, w, http.StatusInternalServerError)\n\t\t}\n\t\tusers = append(users, u)\n\t}\n\t// Encode the users list and send it back as JSON\n\tif encErr := json.NewEncoder(w).Encode(users); encErr != nil{\n\t\tthrowError(encErr, w, http.StatusInternalServerError)\n\t}\n}", "title": "" }, { "docid": "fb9665ff7103f1e441da500216cb6180", "score": "0.55331993", "text": "func GetUsers(ctx context.Context, db sqlx.Queryer, limit, offset int) ([]User, error) {\n\tvar users []User\n\n\terr := sqlx.Select(db, &users, `\n\t\tselect\n\t\t\t*\n\t\tfrom\n\t\t\t\"user\"\n\t\torder by\n\t\t\temail\n\t\tlimit $1\n\t\toffset $2\n\t`, limit, offset)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"select error\")\n\t}\n\treturn users, nil\n}", "title": "" }, { "docid": "e04b91a8bbdcc37a10ef3a7c81756698", "score": "0.55306447", "text": "func (p4 *impl) Users() ([]User, error) {\n\tout, err := p4.ExecCmd(\"users\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar users []User\n\tlines := strings.Split(string(out), \"\\n\")\n\tfor _, line := range lines {\n\t\t// formt of output line is:\n\t\t// username <email@domain> (real name) accessed YYYY/MM/DD\n\t\twords := strings.Split(line, \" \")\n\t\tif len(words) >= 5 {\n\t\t\tu := words[0]\n\t\t\te := words[1]\n\t\t\tn := words[2]\n\t\t\tfor i := 3; i < len(words)-2; i++ {\n\t\t\t\tn += words[i]\n\t\t\t}\n\t\t\td := words[len(words)-1]\n\t\t\tuser := User{\n\t\t\t\tUser: u,\n\t\t\t\tEmail: e,\n\t\t\t\tName: n,\n\t\t\t\tAccessed: d,\n\t\t\t}\n\t\t\tusers = append(users, user)\n\t\t}\n\t}\n\n\treturn users, nil\n}", "title": "" }, { "docid": "370fa564d7c7dd6a0048fd1b9d3e5717", "score": "0.55293894", "text": "func (us *UserService) Users() ([]checkin.User, error) {\n\tus.UsersInvoked = true\n\treturn us.UsersFn()\n}", "title": "" }, { "docid": "a39877926801e89afa47ac322b5b2df3", "score": "0.5522995", "text": "func GetUsersByEmail(email nulls.String, delFilter int) ([]*User, error) {\n\tdeleted1 := false\n\tdeleted2 := false\n\tswitch delFilter {\n\tcase DELETED:\n\t\tdeleted1 = true\n\t\tdeleted2 = true\n\tcase ALL:\n\t\tdeleted2 = true\n\t}\n\trows, err := userSQL.GetByEmail.Query(email, deleted1, deleted2)\n\tif err != nil {\n\t\trows.Close()\n\t\tlog.Println(err.Error())\n\t\treturn nil, err\n\t}\n\tusers := []*User{}\n\tfor rows.Next() {\n\t\tuser := new(User)\n\t\tif err = rows.Scan(&user.LoginID, &user.Name, &user.Email, &user.Password, &user.DeletedUser, &user.DelOn); err != nil {\n\t\t\tlog.Println(err.Error())\n\t\t\trows.Close()\n\t\t\treturn users, err\n\t\t}\n\t\tusers = append(users, user)\n\t}\n\n\trows.Close()\n\treturn users, nil\n}", "title": "" }, { "docid": "bb7ef106f7e2f4738554664bb95eb714", "score": "0.5517378", "text": "func GetAllUsers(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tvar users mymodels.AllUsers\n\tvar Db, err = config.MYSQLConnection()\n\tdefer Db.Close()\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\titrlog.Info(err.Error(), CurrentLocalTime)\n\t\treturn\n\t}\n\trows, err := Db.Query(\"CALL GetAllUsers()\")\n\tdefer rows.Close()\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\titrlog.Info(err.Error(), CurrentLocalTime)\n\t\tfmt.Fprintf(w, err.Error())\n\t\treturn\n\t}\n\tfor rows.Next() {\n\t\tvar userID, countryID, documentTypeID, areaID int\n\t\tvar firstLastName, secondLastName, firstName, otherNames, country, documentType, document, email, startDate, status, area, registrationDate string\n\t\tif err := rows.Scan(&userID, &firstLastName, &secondLastName, &firstName, &otherNames, &countryID, &country, &documentTypeID, &documentType, &document, &email, &startDate, &status, &areaID, &area, &registrationDate); err != nil {\n\t\t\tfmt.Fprintf(w, \"(SQL) %v\", err.Error())\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\t// Next line is used in production because it has\n\t\t// RegistrationDate attribute\n\t\tvar user = mymodels.User{ID: &userID, FirstLastName: &firstLastName, SecondLastName: &secondLastName, FirstName: &firstName, OtherNames: &otherNames, CountryID: &countryID, Country: &country, DocumentTypeID: &documentTypeID, DocumentType: &documentType, Document: &document, Email: &email, StartDate: &startDate, AreaID: &areaID, Area: &area, Status: &status, RegistrationDate: &registrationDate}\n\n\t\t// Next line is used in development because RegistrationDate\n\t\t// attribute is always changing.\n\t\t// var user = mymodels.User{ID: &userID, FirstLastName: &firstLastName, SecondLastName: &secondLastName, FirstName: &firstName, OtherNames: &otherNames, CountryID: &countryID, Country: &country, DocumentTypeID: &documentTypeID, DocumentType: &documentType, Document: &document, Email: &email, StartDate: &startDate, AreaID: &areaID, Area: &area, Status: &status}\n\t\tusers = append(users, user)\n\t}\n\tjson.NewEncoder(w).Encode(users)\n\treturn\n}", "title": "" }, { "docid": "d0f599dcc6c8b4c687ad94c2e6a54ee7", "score": "0.55168784", "text": "func ListUsers(start string, limit uint) ([]interface{}, error) {\n\treturn list(tpState.Namespace+tpState.UserNamespace, start, limit)\n}", "title": "" }, { "docid": "b672bd10c890728cc44640ece768d651", "score": "0.55168253", "text": "func (c Client) GetUsers(query url.Values) ([]map[string]interface{}, error) {\n\tvar m struct{ Records []map[string]interface{} }\n\terr := c.GetRecordsFor(\"sys_user\", query, &m)\n\treturn m.Records, err\n}", "title": "" }, { "docid": "43bc93ffc428b1158e1d8498422040dd", "score": "0.55143654", "text": "func (s *SearchService) Users(ctx context.Context, query string, opt *SearchOptions) (*UsersSearchResult, *Response, error) {\n\tresult := new(UsersSearchResult)\n\tresp, err := s.search(ctx, \"users\", &searchParameters{Query: query}, opt, result)\n\treturn result, resp, err\n}", "title": "" }, { "docid": "f989bca19b5848a12dfb17145ffbfabd", "score": "0.5511922", "text": "func (b *Backend) GetUsers(provider string, withTokens bool, pagingQuery *common.PagingQuery) (users []*common.User, cursor *paginator.Cursor, err error) {\n\tif pagingQuery == nil {\n\t\treturn nil, nil, fmt.Errorf(\"missing paging query\")\n\t}\n\n\tp := pagingQuery.Paginator()\n\tp.SetKeys(\"CreatedAt\", \"ID\")\n\n\tstmt := b.db.Model(&common.User{})\n\n\tif withTokens {\n\t\tstmt = stmt.Preload(\"Tokens\")\n\t}\n\n\tif provider != \"\" {\n\t\tstmt = stmt.Where(&common.User{Provider: provider})\n\t}\n\n\terr = p.Paginate(stmt, &users).Error\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tc := p.GetNextCursor()\n\n\treturn users, &c, err\n}", "title": "" }, { "docid": "ef179d83797ea28b36037c20bb4a9a89", "score": "0.55087477", "text": "func (s *service) SearchUsers(ctx context.Context, keyWords *SearchInput) (*UsersListOutput, error) {\n\ttx, err := s.db.Begin(context.Background())\n\tif err != nil {\n\t\treturn nil, entity.TransactionBeginError\n\t}\n\tdefer tx.Rollback(context.Background())\n\n\tusers := make([]*UserOutput, 0)\n\trows, err := tx.Query(context.Background(), SearchUsersQuery, \"%\"+keyWords.KeyWords+\"%\")\n\tif err != nil {\n\t\tif err == pgx.ErrNoRows {\n\t\t\treturn nil, entity.UsersNotFoundError\n\t\t}\n\t\treturn nil, err\n\t}\n\n\tfor rows.Next() {\n\t\tuser := UserOutput{}\n\n\t\tfirstNamePtr := new(string)\n\t\tsecondNamePtr := new(string)\n\t\tavatarPtr := new(string)\n\n\t\terr = rows.Scan(&user.UserID, &user.Username, &user.Email, &firstNamePtr,\n\t\t\t&secondNamePtr, &avatarPtr, &user.FollowedBy, &user.Following,\n\t\t\t&user.BoardsCount, &user.PinsCount, &user.VkID)\n\t\tif err != nil {\n\t\t\treturn nil, entity.UserScanError\n\t\t}\n\n\t\tuser.FirstName = *emptyIfNil(firstNamePtr)\n\t\tuser.LastName = *emptyIfNil(secondNamePtr)\n\t\tuser.Avatar = *emptyIfNil(avatarPtr)\n\t\tusers = append(users, &user)\n\t}\n\n\terr = tx.Commit(context.Background())\n\tif err != nil {\n\t\treturn nil, entity.TransactionCommitError\n\t}\n\treturn &UsersListOutput{Users: users}, nil\n}", "title": "" }, { "docid": "33ba06434e8feb4bb3003cf43d63a813", "score": "0.5507875", "text": "func (ss *SqlStore) ConvertToUsers(userIDs map[int]bool) ([]*User, error) {\n\tusers := []*User{}\n\t// for userID := range userIDs {\n\t// \tuser, err := store.GetByID(userID)\n\t// \tif err != nil {\n\t// \t\treturn nil, fmt.Errorf(\"error getting user: %v\", err)\n\t// \t}\n\t// \tusers = append(users, user)\n\t// }\n\n\treturn users, nil\n}", "title": "" }, { "docid": "7d2816b63b8245653705f36c8bd7b303", "score": "0.5507668", "text": "func (m Manager) GetAllUsers(ctx context.Context) (all []User, err error) {\n\terr = m.Invoke(ctx).All(&all)\n\treturn\n}", "title": "" }, { "docid": "0ccbb42ceb487bd61ea531b882b1fd9d", "score": "0.5502403", "text": "func (c *GrpcClient) ListUsers(ctx context.Context) ([]entity.User, error) {\n\tif c.Service == nil {\n\t\treturn nil, ErrClientNotReady\n\t}\n\n\treq := &milvuspb.SelectUserRequest{}\n\n\tresp, err := c.Service.SelectUser(ctx, req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err = handleRespStatus(resp.GetStatus()); err != nil {\n\t\treturn nil, err\n\t}\n\n\tusers := make([]entity.User, 0, len(resp.GetResults()))\n\tfor _, result := range resp.GetResults() {\n\t\tusers = append(users, entity.User{Name: result.GetUser().GetName()})\n\t}\n\n\treturn users, nil\n}", "title": "" }, { "docid": "dcf9c6bd8f201db98db3ed21e040ec48", "score": "0.5502281", "text": "func GetUsers(\n\toffset int64, number int64,\n\tsortField string, sortType int,\n\tsearchWord string,\n) (total int64, users []TypeDB, err error) {\n\tpipeline := []bson.M{}\n\tusers = make([]TypeDB, 0)\n\n\tif searchWord != \"\" {\n\t\tpipeline = append(pipeline, bson.M{\n\t\t\t\"$match\": bson.M{\n\t\t\t\t\"username\": bson.M{\"$regex\": searchWord, \"$options\": \"i\"},\n\t\t\t},\n\t\t})\n\t}\n\tif sortField != \"\" {\n\t\tpipeline = append(pipeline, bson.M{\n\t\t\t\"$sort\": bson.M{\n\t\t\t\tsortField: sortType,\n\t\t\t},\n\t\t})\n\t}\n\tif number != 0 {\n\t\tpipeline = append(pipeline, mongo.AggregateOffset(offset, number)...)\n\t}\n\n\ttotal, err = mongo.Aggregate(\n\t\t\"blotter\", \"users\",\n\t\tpipeline, nil,\n\t\t&users,\n\t)\n\treturn\n}", "title": "" }, { "docid": "13d654f6840fa419d4d856d5b772c96b", "score": "0.5498196", "text": "func (s *UsersService) List(org, flow string) ([]User, *http.Response, error) {\n\tu := fmt.Sprintf(\"flows/%v/%v/users\", org, flow)\n\n\treq, err := s.client.NewRequest(\"GET\", u, nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tusers := new([]User)\n\tresp, err := s.client.Do(req, users)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn *users, resp, err\n}", "title": "" }, { "docid": "cef32290642ccad4c37bab9ba530a48c", "score": "0.5495602", "text": "func ListUsers(w http.ResponseWriter, r *http.Request) {\n\tuserType := r.URL.Query().Get(\"type\")\n\tpage := r.URL.Query().Get(\"page\")\n\tsearch := r.URL.Query().Get(\"search\")\n\n\tpagTemp, err := strconv.Atoi(page)\n\tif err != nil {\n\t\thttp.Error(w, \"You must to send the page parameter like an integer > 0\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tpag := int64(pagTemp)\n\n\tres, status := db.ReadUsers(UserID, pag, search, userType)\n\tif status == false {\n\t\thttp.Error(w, \"Error ocurred while reading users\", http.StatusBadRequest)\n\t\treturn\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusCreated)\n\tjson.NewEncoder(w).Encode(res)\n}", "title": "" }, { "docid": "e5eb2735d4a19dc4cd393eedd84cf26e", "score": "0.549559", "text": "func (a *App) ListUsers() error {\n\tuserList, err := a.db.GetUserList()\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar regifters int\n\tvar germans []string\n\tfor i, u := range userList {\n\t\tif u.Regift {\n\t\t\tregifters++\n\t\t}\n\t\tfmt.Printf(\"%3v - %20v - %20v - %v\\n\", i, u.Username, u.RepSubreddit, u.Address.Country)\n\t}\n\n\tfmt.Printf(\"we have %v potential rematchers\\n\", regifters)\n\tfmt.Println(germans)\n\n\treturn nil\n}", "title": "" }, { "docid": "7a0f5bb919441090555c45bb8f017bef", "score": "0.5493285", "text": "func GetUsers(rq *orm.RequestQuery, session *auth.SessionData) (m *[]model.User, total int64, err error) {\n\t// make new orm query\n\tq, _ := rq.Query(new(model.User))\n\n\tif session.User.Usergroup.ID != int64(1) {\n\t\tq = q.Filter(\"id\", session.User.ID)\n\t}\n\n\t// get total data\n\tif total, err = q.Count(); err != nil || total == 0 {\n\t\treturn nil, total, err\n\t}\n\n\t// get data requested\n\tvar mx []model.User\n\tif _, err = q.All(&mx, rq.Fields...); err == nil {\n\t\treturn &mx, total, nil\n\t}\n\n\t// return error some thing went wrong\n\treturn nil, total, err\n}", "title": "" }, { "docid": "9b3a4c723e37d464b4978ddc874b2664", "score": "0.5491837", "text": "func (s *service) GetUsers(ctx context.Context, in *empty.Empty) (*UsersListOutput, error) {\n\ttx, err := s.db.Begin(context.Background())\n\tif err != nil {\n\t\treturn nil, entity.TransactionBeginError\n\t}\n\tdefer tx.Rollback(context.Background())\n\n\tusers := make([]*UserOutput, 0)\n\trows, err := tx.Query(context.Background(), getUsersQuery)\n\tif err != nil {\n\t\tif err == pgx.ErrNoRows {\n\t\t\treturn nil, entity.UserNotFoundError\n\t\t}\n\t\treturn nil, err\n\t}\n\n\tfor rows.Next() {\n\t\tuser := UserOutput{}\n\t\tfirstNamePtr := new(string)\n\t\tsecondNamePtr := new(string)\n\t\tavatarPtr := new(string)\n\n\t\terr = rows.Scan(&user.UserID, &user.Username, &user.Email, &firstNamePtr,\n\t\t\t&secondNamePtr, &avatarPtr, &user.FollowedBy, &user.Following,\n\t\t\t&user.BoardsCount, &user.PinsCount, &user.VkID)\n\t\tif err != nil {\n\t\t\tif err == pgx.ErrNoRows {\n\t\t\t\treturn nil, entity.UserNotFoundError\n\t\t\t}\n\t\t\treturn nil, entity.UserScanError\n\t\t}\n\n\t\tuser.FirstName = *emptyIfNil(firstNamePtr)\n\t\tuser.LastName = *emptyIfNil(secondNamePtr)\n\t\tuser.Avatar = *emptyIfNil(avatarPtr)\n\t\tusers = append(users, &user)\n\t}\n\n\terr = tx.Commit(context.Background())\n\tif err != nil {\n\t\treturn nil, entity.TransactionCommitError\n\t}\n\treturn &UsersListOutput{Users: users}, nil\n}", "title": "" }, { "docid": "39b3c9d3735531dc752a1c9c6c4e5a6e", "score": "0.5479253", "text": "func (s *userServer) ListUsers(ctx context.Context, r *proto.ListUserRequest) (*proto.ListUserResponse, error) {\n\tif r.GetPage() < 1 || r.GetLimit() < 1 {\n\t\treturn nil, status.Error(codes.Internal, \"Invalid page or limit value. Please provide values greater then 1\")\n\t}\n\n\tvar users []persistence.User\n\tvar list []*proto.User\n\n\ttotalUsers, err := s.userRepository.Count(ctx)\n\tif err != nil {\n\t\ts.logger.Error(ctx, \"%v\\n\", errors.Wrap(err, errors.INTERNAL, \"Failed to count users\"))\n\t\treturn nil, status.Error(codes.Internal, \"Failed to count users\")\n\t}\n\n\toffset := (r.GetPage() * r.GetLimit()) - r.GetLimit()\n\n\tif totalUsers < 1 || offset > (totalUsers-1) {\n\t\treturn &proto.ListUserResponse{\n\t\t\tPage: r.GetPage(),\n\t\t\tLimit: r.GetLimit(),\n\t\t\tTotal: totalUsers,\n\t\t\tUsers: list,\n\t\t}, nil\n\t}\n\n\tusers, err = s.userRepository.FindAll(ctx, r.GetLimit(), offset)\n\tif err != nil {\n\t\ts.logger.Error(ctx, \"%v\\n\", errors.Wrap(err, errors.INTERNAL, \"Failed to fetch users\"))\n\t\treturn nil, status.Error(codes.Internal, \"Failed to fetch users\")\n\t}\n\n\tlist = make([]*proto.User, len(users))\n\tfor i := range users {\n\t\tlist[i] = &proto.User{\n\t\t\tId: users[i].GetID(),\n\t\t\tProvider: users[i].GetProvider(),\n\t\t\tName: users[i].GetName(),\n\t\t\tEmail: users[i].GetEmail(),\n\t\t\tNickname: users[i].GetNickName(),\n\t\t\tLocation: users[i].GetLocation(),\n\t\t\tAvatarurl: users[i].GetAvatarURL(),\n\t\t\tDescription: users[i].GetDescription(),\n\t\t\tUserid: users[i].GetUserID(),\n\t\t\tRefreshtoken: users[i].GetRefreshToken(),\n\t\t}\n\t}\n\n\tresponse := &proto.ListUserResponse{\n\t\tPage: r.GetPage(),\n\t\tLimit: r.GetLimit(),\n\t\tTotal: totalUsers,\n\t\tUsers: list,\n\t}\n\n\treturn response, nil\n}", "title": "" }, { "docid": "a10ad5873bd97811c03f38b78347cd9c", "score": "0.5476391", "text": "func (h IndexUsersHandler) Handle(params userop.IndexUsersParams) middleware.Responder {\n\treturn h.AuditableAppContextFromRequestWithErrors(params.HTTPRequest,\n\t\tfunc(appCtx appcontext.AppContext) (middleware.Responder, error) {\n\n\t\t\t// Here is where NewQueryFilter will be used to create Filters from the 'filter' query param\n\t\t\tqueryFilters := generateQueryFilters(appCtx.Logger(), params.Filter, usersFilterConverters)\n\n\t\t\tordering := query.NewQueryOrder(params.Sort, params.Order)\n\t\t\tpagination := h.NewPagination(params.Page, params.PerPage)\n\n\t\t\tvar users models.Users\n\t\t\terr := h.ListFetcher.FetchRecordList(appCtx, &users, queryFilters, nil, pagination, ordering)\n\t\t\tif err != nil {\n\t\t\t\treturn handlers.ResponseForError(appCtx.Logger(), err), err\n\t\t\t}\n\n\t\t\ttotalUsersCount, err := h.ListFetcher.FetchRecordCount(appCtx, &users, queryFilters)\n\t\t\tif err != nil {\n\t\t\t\treturn handlers.ResponseForError(appCtx.Logger(), err), err\n\t\t\t}\n\n\t\t\tqueriedUsersCount := len(users)\n\n\t\t\tpayload := make(adminmessages.Users, queriedUsersCount)\n\n\t\t\tfor i, s := range users {\n\t\t\t\tpayload[i] = payloadForUserModel(s)\n\t\t\t}\n\n\t\t\treturn userop.NewIndexUsersOK().WithContentRange(fmt.Sprintf(\"users %d-%d/%d\", pagination.Offset(), pagination.Offset()+queriedUsersCount, totalUsersCount)).WithPayload(payload), nil\n\t\t})\n}", "title": "" }, { "docid": "64ddc1e549fc4058eca599a1d9576a9a", "score": "0.5465952", "text": "func (inter *UserInteractorImpl) List(pager entities.Pager, sorter entities.Sorter) (*entities.UserCollection, error) {\n\tuserTbl := inter.DBMap.Dialect.QuotedTableForQuery(\"\", \"user\")\n\ttotal, err := inter.DBMap.SelectInt(fmt.Sprintf(\"SELECT COUNT(*) FROM %v\", userTbl))\n\tif err != nil {\n\t\treturn nil, errs.NewUseCaseError(errs.ErrorTypeOperational, \"Failed to count users\", err)\n\t}\n\n\tvar records []db.UserWithStats\n\tq := `SELECT u.*, count(du.user_id) AS domains_count FROM %v AS u\n\t\tLEFT JOIN domain_user AS du ON u.user_id = du.user_id\n\t\tGROUP BY u.user_id %v %v;`\n\t_, err = inter.DBMap.Select(&records, fmt.Sprintf(q, userTbl, db.OrderByClause(sorter, \"u\"), db.LimitOffset(pager)))\n\tif err == sql.ErrNoRows {\n\t\treturn nil, errs.NewUseCaseError(errs.ErrorTypeNotFound, \"No users found\", err)\n\t} else if err != nil {\n\t\treturn nil, errs.NewUseCaseError(errs.ErrorTypeOperational, \"Failed to perform a lookup of users\", err)\n\t}\n\n\tc := &entities.UserCollection{\n\t\tUsers: []entities.User{},\n\t\tPaginator: *pager.CreatePaginator(len(records), total),\n\t}\n\tfor _, r := range records {\n\t\tc.Users = append(c.Users, entities.User{*userToEntity(&r.User), r.DomainsCount})\n\t}\n\treturn c, nil\n}", "title": "" }, { "docid": "cd0dae651a66c7597bdbf0a8b5b2f60c", "score": "0.54623336", "text": "func (client *XINGClient) Users(userIDs []string) []User {\n\tusers := []User{}\n\tvar waitGroup sync.WaitGroup\n\tfor _, userID := range userIDs {\n\t\twaitGroup.Add(1)\n\t\tgo client.User(userID, func(user User, err error) {\n\t\t\tif err == nil {\n\t\t\t\tPrintUserOneLine(user)\n\t\t\t\tusers = append(users, user)\n\t\t\t}\n\t\t\twaitGroup.Done()\n\t\t})\n\t}\n\n\twaitGroup.Wait()\n\treturn users\n}", "title": "" }, { "docid": "4cb7fe3297ee5fff2ba3835f83a2c972", "score": "0.54616237", "text": "func (u *Unifi) GetUsers(sites []*Site, hours int) ([]*User, error) {\n\tdata := make([]*User, 0)\n\n\tfor _, site := range sites {\n\t\tvar (\n\t\t\tresponse struct {\n\t\t\t\tData []*User `json:\"data\"`\n\t\t\t}\n\t\t\tparams = fmt.Sprintf(`{ \"type\": \"all:\", \"conn\": \"all\", \"within\":%d }`, hours)\n\t\t)\n\n\t\tu.DebugLog(\"Polling Controller, retrieving UniFi Users, site %s \", site.SiteName)\n\n\t\tclientPath := fmt.Sprintf(APIAllUserPath, site.Name)\n\t\tif err := u.GetData(clientPath, &response, params); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tfor i, d := range response.Data {\n\t\t\t// Add special SourceName value.\n\t\t\tresponse.Data[i].SourceName = u.URL\n\t\t\t// Add the special \"Site Name\" to each client. This becomes a Grafana filter somewhere.\n\t\t\tresponse.Data[i].SiteName = site.SiteName\n\t\t\t// Fix name and hostname fields. Sometimes one or the other is blank.\n\t\t\tresponse.Data[i].Hostname = strings.TrimSpace(pick(d.Hostname, d.Name, d.Mac))\n\t\t\tresponse.Data[i].Name = strings.TrimSpace(pick(d.Name, d.Hostname))\n\t\t}\n\n\t\tdata = append(data, response.Data...)\n\t}\n\n\treturn data, nil\n}", "title": "" }, { "docid": "b1fa56d97fcb1aef6f74f075fefc892b", "score": "0.5460645", "text": "func (c *UserExtDataClient) GetUsers(userList []*groups.Member) ([]*User, error) {\n\tlogger.Debugf(\"In GetUsers\")\n\tuinfo := make([]*UserInfo, 0, len(userList))\n\tc.userList = userList\n\tc.info = uinfo\n\terr := c.fetchInfo()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tusarz := make([]*User, 0, len(c.info))\n\tfor _, uEntry := range c.info {\n\t\tlogger.Debugf(\"Getting entry for %s. Does not exist? %v\", uEntry.Username, uEntry.DoesNotExist)\n\t\tif uEntry.DoesNotExist {\n\t\t\t// A user needs to be created.\n\t\t\tnewUser, err := New(uEntry.Username, uEntry.Name, uEntry.HomeDir, uEntry.Shell, uEntry.Action, uEntry.Groups, uEntry.AuthorizedKeys)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tusarz = append(usarz, newUser)\n\t\t} else {\n\t\t\t// user already exists\n\t\t\tuObj, err := Get(uEntry.Username)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\terr = uObj.updateInfo(uEntry)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tusarz = append(usarz, uObj)\n\t\t}\n\t}\n\n\treturn usarz, err\n}", "title": "" }, { "docid": "7a44334e8736e8b50d2a8665621135b4", "score": "0.54584193", "text": "func (a *UserAPI) GetUsers(ctx *gin.Context) {\n\n\tvar (\n\t\tstart int64\n\t\tend int64\n\t\tsort string\n\t\torder int\n\t)\n\tid := ctx.DefaultQuery(\"id\", \"\")\n\tif id != \"\" {\n\t\ta.GetUserByIDs(ctx)\n\t\treturn\n\t}\n\tstart, _ = strconv.ParseInt(ctx.DefaultQuery(\"_skip\", \"0\"), 10, 64)\n\tend, _ = strconv.ParseInt(ctx.DefaultQuery(\"_limit\", \"10\"), 10, 64)\n\tsort = ctx.DefaultQuery(\"_sort\", \"_id\")\n\torder = 1\n\n\tif sort == \"id\" {\n\t\tsort = \"_id\"\n\t}\n\n\tif ctx.DefaultQuery(\"_order\", \"DESC\") == \"DESC\" {\n\t\torder = -1\n\t}\n\tif ctx.Query(\"_order\") == \"-1\" {\n\t\torder = -1\n\t}\n\n\tlimit := end - start\n\n\t// now instance param\n\tusers := a.DB.GetUsers(\n\t\t&models.Filter{\n\t\t\tSkip: &start,\n\t\t\tLimit: &limit,\n\t\t\tSortKey: sort,\n\t\t\tSortVal: order,\n\t\t\tCondition: nil,\n\t\t})\n\n\tctx.Header(\"Doc-Count \", a.DB.CountUser())\n\tctx.JSON(http.StatusOK, users)\n}", "title": "" }, { "docid": "0c8307e9eec2da271924588d059eaab8", "score": "0.54567736", "text": "func getUsers(t string, a bool) GitlabUsers {\n\ta_str := strconv.FormatBool(a)\n\tresponse, httpErr := http.Get(GitlabURL + \"users?active=\" + a_str + \"&external=false&order_by=id&page=1&per_page=100&skip_ldap=false&sort=desc&with_custom_attributes=false&private_token=\" + t)\n\tcheck(httpErr)\n\tdefer response.Body.Close()\n\tdata, responseErr := ioutil.ReadAll(response.Body)\n\tcheck(responseErr)\n\tvar jsonResponse GitlabUsers\n\tjsonErr := json.Unmarshal(data, &jsonResponse)\n\tcheck(jsonErr)\n\tcurrentPage, err := strconv.Atoi(response.Header[\"X-Page\"][0])\n\tcheck(err)\n\ttotalPages, err := strconv.Atoi(response.Header[\"X-Total-Pages\"][0])\n\tcheck(err)\n\t// Retrieve additional pages if needed\n\tfor ; currentPage < totalPages; currentPage++ {\n\t\tnextPage := strconv.Itoa(currentPage + 1)\n\t\tresponse, httpErr := http.Get(GitlabURL + \"users?active=\" + a_str + \"&external=false&order_by=id&page=\" + nextPage + \"&per_page=100&skip_ldap=false&sort=desc&with_custom_attributes=false&private_token=\" + t)\n\t\tcheck(httpErr)\n\t\tdefer response.Body.Close()\n\t\tdata, responseErr := ioutil.ReadAll(response.Body)\n\t\tcheck(responseErr)\n\t\tvar tmpJsonResponse GitlabUsers\n\t\tjsonErr := json.Unmarshal(data, &tmpJsonResponse)\n\t\tcheck(jsonErr)\n\t\tjsonResponse = append(jsonResponse, tmpJsonResponse...)\n\t}\n\treturn jsonResponse\n}", "title": "" }, { "docid": "c9a578855fd9c17c04bf457134c97873", "score": "0.5450431", "text": "func (db *DB) FindAllUsers(filter string, paging model.Paging) ([]*model.User, int, error) {\n\torderAndLimit, limit := createOrderAndLimitForUser(paging)\n\twhereClause := \"\"\n\tif filter != \"\" {\n\t\twhereClause = \" WHERE LOWER(username) LIKE '%\" + strings.ToLower(filter) + \"%'\"\n\t\torderAndLimit = whereClause + orderAndLimit\n\t}\n\trows, err := db.Query(db.Sanitizer(db.Stmt[\"sqlUserAll\"]) + orderAndLimit)\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n\tdefer func() {\n\t\terr := rows.Close()\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"error closing rows in user: %v\", err)\n\t\t}\n\t}()\n\tusers := make([]*model.User, 0)\n\tfor rows.Next() {\n\t\tuser := new(model.User)\n\t\terr := rows.Scan(\n\t\t\t&user.Id,\n\t\t\t&user.Username,\n\t\t\t&user.Password,\n\t\t\t&user.Role,\n\t\t\t&user.Email)\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t}\n\t\tusers = append(users, user)\n\t}\n\tif err = rows.Err(); err != nil {\n\t\tlog.Error(err)\n\t}\n\n\ttotal := len(users)\n\tif limit {\n\t\ttotal = db.countRows(db.Sanitizer(db.Stmt[\"sqlUserCount\"]) + whereClause)\n\t}\n\n\treturn users, total, err\n}", "title": "" }, { "docid": "10afb5417b74ec5b98b03a0691f05572", "score": "0.5446087", "text": "func ProcessUsersAPI(domain string, key, secret string, orProcess models.ORProcess, districtIDs []bson.ObjectId) error {\n\n\tvar orUsers []models.ORUser\n\t// call the api\n\tlimit := 100\n\toffset := 0\n\thasNext := true\n\tfor hasNext == true {\n\t\turl := fmt.Sprintf(\"%s/ims/oneroster/v1p1/users?limit=%s&offset=%s\", domain, strconv.Itoa(limit), strconv.Itoa(offset))\n\n\t\toneRoster := oauth1.OneRosterNew(key, secret)\n\t\tstatusCode, response, header := oneRoster.MakeRosterRequest(url)\n\t\ttotalRowsCount, _ := strconv.Atoi(header.Get(\"x-total-count\"))\n\t\tb := []byte(response)\n\n\t\t// If status_code is 200, create array of users from response, otherwise return error\n\t\tif statusCode == 200 {\n\n\t\t\tvar usersResponse models.UsersResponse\n\t\t\tjson.Unmarshal(b, &usersResponse)\n\t\t\torUsers = usersResponse.Users\n\n\t\t} else if statusCode == 401 {\n\t\t\treturn fmt.Errorf(\"Unauthorized Request: %s\", response)\n\t\t} else if statusCode == 404 {\n\t\t\treturn fmt.Errorf(\"Not found: %s\", response)\n\t\t} else if statusCode == 500 {\n\t\t\treturn fmt.Errorf(\"Server Error: %s\", response)\n\t\t}\n\n\t\torUsersToEdit := []models.ORUser{}\n\t\torUsersIDsToDelete := []string{}\n\t\tfor _, orUser := range orUsers {\n\n\t\t\t// collect orgsId and add it in orUser.OrgSourcedIds\n\t\t\torgsIds := []string{}\n\t\t\tfor _, org := range orUser.Orgs {\n\t\t\t\torgsIds = append(orgsIds, org.SourcedId)\n\t\t\t}\n\t\t\torgsIdsString := strings.Join(orgsIds, \",\")\n\t\t\torUser.OrgSourcedIds = orgsIdsString\n\n\t\t\t// collect usersids and add it in orUser.UserIds\n\t\t\tuserIds := []string{}\n\t\t\tfor _, iden := range orUser.UserIdsIdentifer {\n\t\t\t\tuserIds = append(userIds, iden.Identifier)\n\t\t\t}\n\t\t\tuserIdsString := strings.Join(userIds, \",\")\n\t\t\torUser.UserIds = userIdsString\n\n\t\t\t// collect agentSourcedIds and add it in orUser.AgentSourcedIds\n\t\t\tagentSourcedIds := []string{}\n\t\t\tfor _, agent := range orUser.Agents {\n\t\t\t\tagentSourcedIds = append(agentSourcedIds, agent.SourcedId)\n\t\t\t}\n\t\t\tagentSourcedIdsString := strings.Join(agentSourcedIds, \",\")\n\t\t\torUser.AgentSourcedIds = agentSourcedIdsString\n\n\t\t\tif strings.ToLower(orUser.Status) == strings.ToLower(models.STATUS_TYPE_ACTIVE) {\n\t\t\t\torUsersToEdit = append(orUsersToEdit, orUser)\n\t\t\t} else if strings.ToLower(orUser.Status) == strings.ToLower(models.STATUS_TYPE_TOBEDELETED) {\n\t\t\t\torUsersIDsToDelete = append(orUsersIDsToDelete, orUser.SourcedId)\n\t\t\t}\n\t\t}\n\n\t\t// Add or Edit Users\n\t\tif len(orUsersToEdit) > 0 {\n\t\t\terr := orProcess.HandleAddOrEditUsers(orUsersToEdit, districtIDs)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\t//Delete Users\n\t\tif len(orUsersIDsToDelete) > 0 {\n\t\t\terr := orProcess.HandleDeleteUsers(orUsersIDsToDelete, districtIDs)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tif totalRowsCount > (offset + limit) {\n\t\t\toffset = offset + 100\n\t\t} else {\n\t\t\thasNext = false\n\t\t\tbreak\n\t\t}\n\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "9170a1fd70994aa4245d313f6fbbabba", "score": "0.5444706", "text": "func (h *Handler) GetUsers(w http.ResponseWriter, r *http.Request) {\n\tuserid := chi.URLParam(r, \"userid\")\n\tuserid, err := url.PathUnescape(userid)\n\tif err != nil {\n\t\tresponse.WriteOCSError(w, r, response.MetaServerError.StatusCode, \"could not unescape username\", err)\n\t\treturn\n\t}\n\n\tcurrentUser, ok := ctxpkg.ContextGetUser(r.Context())\n\tif !ok {\n\t\tresponse.WriteOCSError(w, r, response.MetaServerError.StatusCode, \"missing user in context\", fmt.Errorf(\"missing user in context\"))\n\t\treturn\n\t}\n\n\tvar user *cs3identity.User\n\tswitch {\n\tcase userid == \"\":\n\t\tresponse.WriteOCSError(w, r, response.MetaBadRequest.StatusCode, \"missing username\", fmt.Errorf(\"missing username\"))\n\t\treturn\n\tcase userid == currentUser.Username:\n\t\tuser = currentUser\n\tdefault:\n\t\t// FIXME allow fetching other users info? only for admins\n\t\tresponse.WriteOCSError(w, r, http.StatusForbidden, \"user id mismatch\", fmt.Errorf(\"%s tried to access %s user info endpoint\", currentUser.Id.OpaqueId, user))\n\t\treturn\n\t}\n\n\td := &User{\n\t\tEnabled: \"true\", // TODO include in response only when admin?\n\t\tDisplayName: user.DisplayName,\n\t\tEmail: user.Mail,\n\t\tUserType: conversions.UserTypeString(user.Id.Type),\n\t\tQuota: &Quota{},\n\t}\n\t// TODO how do we fill lastlogin of a user when another user (with the necessary permissions) looks up the user?\n\t// TODO someone needs to fill last-login\n\tif lastLogin := utils.ReadPlainFromOpaque(user.Opaque, \"last-login\"); lastLogin != \"\" {\n\t\td.LastLogin, _ = strconv.ParseInt(lastLogin, 10, 64)\n\t}\n\n\t// lightweight and federated users don't have access to their storage space\n\tif currentUser.Id.Type != cs3identity.UserType_USER_TYPE_LIGHTWEIGHT && currentUser.Id.Type != cs3identity.UserType_USER_TYPE_FEDERATED {\n\t\th.fillPersonalQuota(r.Context(), d, user)\n\t}\n\n\tresponse.WriteOCSSuccess(w, r, d)\n}", "title": "" }, { "docid": "7653cdb11f16889d5603a02ea2e1891d", "score": "0.5444035", "text": "func (repository *UserQueryRepositoryCircuitBreaker) SelectUsers() ([]entity.User, error) {\n\toutput := make(chan []entity.User, 1)\n\thystrix.ConfigureCommand(\"select_user\", config.Settings())\n\terrors := hystrix.Go(\"select_user\", func() error {\n\t\tusers, err := repository.UserQueryRepositoryInterface.SelectUsers()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\toutput <- users\n\t\treturn nil\n\t}, nil)\n\n\tselect {\n\tcase out := <-output:\n\t\treturn out, nil\n\tcase err := <-errors:\n\t\treturn []entity.User{}, err\n\t}\n}", "title": "" }, { "docid": "68f5860c7dd7c5ba33f6ad5cd18fa620", "score": "0.5439379", "text": "func (b *Backend) ForEachUsers(f func(user *common.User) error) (err error) {\n\trows, err := b.db.Model(&common.User{}).Rows()\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() { _ = rows.Close() }()\n\n\tfor rows.Next() {\n\t\tuser := &common.User{}\n\t\terr = b.db.ScanRows(rows, user)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = f(user)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "75fb40bfab5bf5044b6859c09b2974cf", "score": "0.5438685", "text": "func (uc UserController) GetAllUsers(w http.ResponseWriter, r *http.Request, p httprouter.Params) {\n\t// Stub user\n\tu := []models.USER{}\n\n\t// Fetch user\n\tlog.Info(\"fetching all users\")\n\tif err := uc.session.DB(ndpdbname).C(\"users\").Find(bson.M{}).All(&u); err != nil {\n\t\tlog.Info(err)\n\t\tw.WriteHeader(404)\n\t\treturn\n\t}\n\n\t// Marshal provided interface into JSON structure\n\tuj, _ := json.Marshal(u)\n\n\t// Write content-type, statuscode, payload\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(200)\n\tfmt.Fprintf(w, \"%s\", uj)\n}", "title": "" }, { "docid": "0f6fbaea2fcd5fef58516a2cd1d24399", "score": "0.5430913", "text": "func (ud *UserDeliveryMemory) GetAllUsers(path string) error {\n\tvar err error\n\thttp.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {\n\t\tif r.Method == \"POST\" {\n\t\t\t//get all users.\n\t\t\tusers, err := ud.usecase.GetAll()\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tusersMarshal, err := json.Marshal(users)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tusersJson := string(usersMarshal)\n\t\t\tfmt.Fprintf(w, usersJson)\n\t\t} else {\n\t\t\tfmt.Fprintf(w, \"method not allowed.\")\n\t\t}\n\n\t})\n\n\treturn err\n}", "title": "" }, { "docid": "4ae4afc2124d66b9a475ffb30770c984", "score": "0.5427204", "text": "func GetUsers(readPasswords bool) ([]*User, error) {\n\tvar errs multierror.Errors\n\n\t// We are using a number of thread sensitive C functions in\n\t// this file, most importantly setpwent/getpwent/endpwent and\n\t// setspent/getspent/endspent. And we set errno (which is thread-local).\n\truntime.LockOSThread()\n\tdefer runtime.UnlockOSThread()\n\n\tusers, err := readPasswdFile(readPasswords)\n\tif err != nil {\n\t\terrs = append(errs, err)\n\t}\n\n\tif len(users) > 0 {\n\t\terr = enrichWithGroups(users)\n\t\tif err != nil {\n\t\t\terrs = append(errs, err)\n\t\t}\n\n\t\tif readPasswords {\n\t\t\terr = enrichWithShadow(users)\n\t\t\tif err != nil {\n\t\t\t\terrs = append(errs, err)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn users, errs.Err()\n}", "title": "" }, { "docid": "5fdb414515cb3da66a7b7fbea64c8b7a", "score": "0.54250026", "text": "func GetUsers(w http.ResponseWriter, r *http.Request) {\n\t// Retrieve render\n\tren := context.Get(r, CtxRender).(*render.Render)\n\n\t// Output struct for users request\n\tout := UsersResponse{}\n\n\t// Check API version\n\tif version, ok := mux.Vars(r)[\"version\"]; ok {\n\t\t// Check if this API call is supported in the advertised version\n\t\tif !apiVersionSet.Has(version) {\n\t\t\tren.JSON(w, 400, errRes(400, \"unsupported API version: \"+version))\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Check for an ID parameter\n\tif pID, ok := mux.Vars(r)[\"id\"]; ok {\n\t\t// Verify valid integer ID\n\t\tid, err := strconv.Atoi(pID)\n\t\tif err != nil {\n\t\t\tren.JSON(w, 400, errRes(400, \"invalid integer user ID\"))\n\t\t\treturn\n\t\t}\n\n\t\t// Load the user\n\t\tuser := &data.User{ID: id}\n\t\tif err := user.Load(); err != nil {\n\t\t\t// Check for invalid ID\n\t\t\tif err == sql.ErrNoRows {\n\t\t\t\tren.JSON(w, 404, errRes(404, \"user ID not found\"))\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// All other errors\n\t\t\tlog.Println(err)\n\t\t\tren.JSON(w, 500, serverErr)\n\t\t\treturn\n\t\t}\n\n\t\t// HTTP 200 OK with JSON\n\t\tout.Users = []data.User{*user}\n\t\tren.JSON(w, 200, out)\n\t\treturn\n\t}\n\n\t// If no other case, retrieve all users\n\tusers, err := data.DB.AllUsers()\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tren.JSON(w, 500, serverErr)\n\t\treturn\n\t}\n\n\t// HTTP 200 OK with JSON\n\tout.Users = users\n\tren.JSON(w, 200, out)\n\treturn\n}", "title": "" }, { "docid": "60e52cebf0488c6196cb0c3e3d9630a0", "score": "0.54186714", "text": "func ExtractUsers(r pagination.Page) ([]User, error) {\n\tvar s struct {\n\t\tUsers []User `json:\"users\"`\n\t}\n\terr := (r.(UserPage)).ExtractInto(&s)\n\treturn s.Users, err\n}", "title": "" }, { "docid": "6612a87d7f2fa170fb9e9d3e777514df", "score": "0.54178965", "text": "func (backend *RESTBackend) HandleListUsers(w http.ResponseWriter, r *http.Request) {\n\turlPathParams := gmux.Vars(r)\n\tnumUrlPathParams := len(urlPathParams)\n\n\tbackend.StdLog.Printf(\"Received %s request matching '/v1beta1/users': %q\", r.Method, r.URL)\n\tbackend.StdLog.Printf(\" urlPathParams (expect 0, have %d): %q\", numUrlPathParams, urlPathParams)\n\n\tif numUrlPathParams != 0 {\n\t\tw.Write([]byte(fmt.Sprintf(\"unexpected number of URL variables: expected 0, have %d: %#v\", numUrlPathParams, urlPathParams)))\n\t\treturn\n\t}\n\n\trequest := &genprotopb.ListUsersRequest{}\n\t// TODO: Ensure we handle URL-encoded values in path variables\n\tif err := resttools.PopulateSingularFields(request, urlPathParams); err != nil {\n\t\tbackend.StdLog.Printf(\" error reading URL path params: %s\", err)\n\t\t// TODO: Properly handle error\n\t\tw.Write([]byte(err.Error()))\n\t\treturn\n\t}\n\n\t// TODO: Decide whether query-param value or URL-path value takes precedence when a field appears in both\n\t// TODO: Ensure we handle URL-encoded values in query parameters\n\tqueryParams := map[string][]string(r.URL.Query())\n\tif err := resttools.PopulateFields(request, queryParams); err != nil {\n\t\tbackend.StdLog.Printf(\" error reading query params: %s\", err)\n\t\t// TODO: Properly handle error\n\t\tw.Write([]byte(err.Error()))\n\t\treturn\n\t}\n\n\tmarshaler := &jsonpb.Marshaler{}\n\trequestJSON, _ := marshaler.MarshalToString(request)\n\tbackend.StdLog.Printf(\" request: %s\", requestJSON)\n\n\tresponse, err := backend.IdentityServer.ListUsers(context.Background(), request)\n\tif err != nil {\n\t\t// TODO: Properly handle error\n\t\tw.Write([]byte(err.Error()))\n\t\treturn\n\t}\n\n\tjson, err := marshaler.MarshalToString(response)\n\tif err != nil {\n\t\t// TODO: Properly handle error\n\t\tw.Write([]byte(err.Error()))\n\t\treturn\n\t}\n\n\tw.Write([]byte(json))\n}", "title": "" }, { "docid": "4412b5da8b4cf8340160ef51e76ca143", "score": "0.54156464", "text": "func (m Manager) SearchUsers(ctx context.Context, query string) ([]User, error) {\n\tvar users []User\n\tqueryFormat := fmt.Sprintf(\"%%%s%%\", query)\n\tsqlQuery := `select * from users where username ilike $1 or first_name ilike $1 or last_name ilike $1 or email_address ilike $1`\n\terr := m.Invoke(ctx).Query(sqlQuery, queryFormat).OutMany(&users)\n\treturn users, err\n}", "title": "" }, { "docid": "21f1227515ca5343c55919b3331178ed", "score": "0.541306", "text": "func MultiReadUser(app domain.Application, ids []string) ([]*domain.User, error) {\n\t// Fetch LDAP and H2 users separately if required\n\th2IDs := []string{}\n\tldapIDs := []string{}\n\n\tfor _, uid := range ids {\n\t\tif _, _, ok := IsLDAPUser(app, uid); ok {\n\t\t\tldapIDs = append(ldapIDs)\n\t\t} else {\n\t\t\th2IDs = append(h2IDs, uid)\n\t\t}\n\t}\n\n\tusers := []*domain.User{}\n\n\t// Fetch H2 Users\n\th2Users, err := readH2Users(app, h2IDs)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tldapUsers, err := readLDAPUsers(ldapIDs)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tusers = append(users, h2Users...)\n\tusers = append(users, ldapUsers...)\n\n\treturn users, nil\n}", "title": "" }, { "docid": "2985cfc4d50d4fef115eaf23a3ba97a4", "score": "0.5411862", "text": "func AllUsers(res http.ResponseWriter, req *http.Request) {\n\tpageURL := req.URL.Query().Get(\"page\")\n\tsearch := req.URL.Query().Get(\"search\")\n\t_type := req.URL.Query().Get(\"type\")\n\tif len(pageURL) == 0 || len(_type) == 0 {\n\t\thttp.Error(res, \"No todos los parametros son correctos\", 400)\n\t\treturn\n\t}\n\t_page, error := strconv.Atoi(pageURL)\n\tif error != nil {\n\t\thttp.Error(res, \"Error al leer el parámetro pagina \"+error.Error(), 400)\n\t\treturn\n\t}\n\tpage := int64(_page)\n\tresults, status := db.ReadUsers(ID, page, search, _type)\n\tif status == false {\n\t\thttp.Error(res, \"Ha ocurrido un error al lista los usuarios\", 400)\n\t\treturn\n\t}\n\tres.Header().Set(\"Content-Type\", \"application/json\")\n\tres.WriteHeader(http.StatusOK)\n\tjson.NewEncoder(res).Encode(results)\n}", "title": "" }, { "docid": "bb4ed75c4a63f9a8ef940f5cf8e56749", "score": "0.5409109", "text": "func (s *Service) ListUsers(ctx context.Context, req *pbsvc.UserRequest) (*pbsvc.UserResponse, error) {\n\t//TODO\n\tlogger.RequestService(\"ListUsers\")\n\treturn &pbsvc.UserResponse{}, nil\n}", "title": "" }, { "docid": "356d23fc87446debaee1bf18fabd59ae", "score": "0.5400484", "text": "func GetUsers(writer http.ResponseWriter, request *http.Request) {\n\twriter.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\twriter.WriteHeader(http.StatusOK)\n\tif err := json.NewEncoder(writer).Encode(assembler.ToUserDTOs(dao.Users())); err != nil {\n\t\twriteErrorResponse(writer, err.Error())\n\t}\n}", "title": "" }, { "docid": "eb316c4da22cf0e6cbf1f02a6636346a", "score": "0.5398064", "text": "func ListUsers(w http.ResponseWriter, r *http.Request) {\n\tnameOrNick := strings.ToLower(r.URL.Query().Get(\"user\"))\n\n\tdb, err := database.Connect()\n\tif err != nil {\n\t\terrors.Err(w, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\n\tdefer db.Close()\n\n\trepositorie := repositories.NewUserRepositorie(db)\n\tusers, err := repositorie.List(nameOrNick)\n\tif err != nil {\n\t\terrors.Err(w, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\n\tpresentation.JSON(w, http.StatusOK, users)\n}", "title": "" }, { "docid": "3a6e1ec651e4d07e58d49863e129e174", "score": "0.53949404", "text": "func (ctrl *Controller) ListUsers(c *gin.Context) {\n\tctx := c.Request.Context()\n\tresponse := make(map[string]interface{})\n\n\tusersList, err := ctrl.userProvider.List(ctx)\n\n\tif err != nil {\n\t\tlogger.Log().Error(\"error while getting users\", zap.Error(err))\n\t\tresponse[\"error\"] = err.Error()\n\t\tc.JSON(http.StatusInternalServerError, response)\n\t\tc.Abort()\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, usersList)\n}", "title": "" }, { "docid": "b3431acc32ea48661acc20db5cbe25bc", "score": "0.53942025", "text": "func getAvaliableUsers(r *http.Request) (users []string) {\n\n\tusername := getUserName(r)\n\tnoteid := getNoteID(r)\n\n\treturn getAvaliableUsersSQL(username, noteid)\n}", "title": "" }, { "docid": "61dc51ca195a9c8fc4a68244de937aa0", "score": "0.539329", "text": "func GetUsers(c *gin.Context) {\n\tvar user []models.Users\n\terr := models.GetAllUserDetails(&user)\n\n\tcontrollerhandling.ReturnObject(c, err, user)\n\n}", "title": "" }, { "docid": "b648d0fda0b9520cde5ef58cc6ad9d39", "score": "0.53875303", "text": "func ListUsers(db *sqlx.DB) gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\t\t// return all users\n\t\tusrs, err := user.Bloggers(c.Request.Context(), \"*\", db)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\tc.JSON(http.StatusInternalServerError, standardroutes.NotFoundBody())\n\t\t\treturn\n\t\t}\n\n\t\tc.JSON(http.StatusOK, usrs)\n\n\t}\n}", "title": "" }, { "docid": "9c9607c78a45565c4a6efaad47d43292", "score": "0.5384966", "text": "func GetAllUsersHandler(s Server) func(w http.ResponseWriter, r *http.Request) {\n\ttype User struct {\n\t\tID int `json:\"id\"`\n\t\tCreatedAt time.Time `json:\"created_at\"`\n\t\tName string `json:\"name\"`\n\t\tEmail string `json:\"email\"`\n\t}\n\n\tstmt, err := s.DB.Prepare(`SELECT id, created_at, name, email FROM users`)\n\tif err != nil {\n\t\tlog.Fatal(\"Error preparing sql statement: \" + err.Error())\n\t}\n\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tuserID := r.Context().Value(UserContextKey(\"userID\"))\n\t\tfmt.Printf(\"UserID: %d\\n\", userID)\n\n\t\trows, err := stmt.Query()\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tdefer rows.Close()\n\n\t\tvar users []User\n\n\t\tfor rows.Next() {\n\t\t\tvar user User\n\t\t\tif err := rows.Scan(&user.ID, &user.CreatedAt, &user.Name, &user.Email); err != nil {\n\t\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tusers = append(users, user)\n\t\t}\n\n\t\tenc := json.NewEncoder(w)\n\t\terr = enc.Encode(users)\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t}\n}", "title": "" }, { "docid": "c0eb0df9c81c444acb1e01431b8e0ce1", "score": "0.5382358", "text": "func (u *UsersService) GetUsers(opts *GetUserOptions, options ...OptionFunc) (*UserList, *Response, error) {\n\treq, err := u.client.NewRequest(IDM, \"GET\", \"security/users\", opts, options)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\treq.Header.Set(\"api-version\", userAPIVersion)\n\tvar bundleResponse struct {\n\t\tExchange struct {\n\t\t\tUsers []struct {\n\t\t\t\tUserUUID string `json:\"userUUID\"`\n\t\t\t}\n\t\t\tNextPageExists bool `json:\"nextPageExists\"`\n\t\t}\n\t\tResponseCode string `json:\"responseCode\"`\n\t\tResponseMessage string `json:\"responseMessage\"`\n\t}\n\n\tresp, err := u.client.DoSigned(req, &bundleResponse)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\tvar list UserList\n\n\tlist.HasNextPage = bundleResponse.Exchange.NextPageExists\n\tlist.Users = make([]User, len(bundleResponse.Exchange.Users))\n\tfor i, u := range bundleResponse.Exchange.Users {\n\t\tlist.Users[i] = User{ID: u.UserUUID}\n\t}\n\n\treturn &list, resp, err\n}", "title": "" }, { "docid": "e5b391412ad1815ead25f38dee40dc17", "score": "0.5382261", "text": "func GetUsers(disabled bool) (Users, error) {\n\tvar users Users\n\tvar query = \"SELECT * FROM wiki.user WHERE enabled = 1\"\n\tif disabled {\n\t\tquery = \"SELECT * FROM wiki.user\"\n\t}\n\n\trows, err := db.Queryx(query)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\n\tfor rows.Next() {\n\t\tuser := User{}\n\t\terr = rows.StructScan(&user)\n\t\tusers = append(users, user)\n\t}\n\n\treturn users, nil\n}", "title": "" }, { "docid": "c32ebaf05fecfa8b70e4e468b1309fc7", "score": "0.5367865", "text": "func (a *App) GetAllUsers(w http.ResponseWriter, r *http.Request) {\n\thandler.GetAllUsers(a.DB, w, r)\n}", "title": "" }, { "docid": "c32ebaf05fecfa8b70e4e468b1309fc7", "score": "0.5367865", "text": "func (a *App) GetAllUsers(w http.ResponseWriter, r *http.Request) {\n\thandler.GetAllUsers(a.DB, w, r)\n}", "title": "" }, { "docid": "f19cc4391297a54236c2fc162e56426d", "score": "0.5366016", "text": "func getUserInfos(w http.ResponseWriter, r *http.Request) {\n\tsmask := context.Get(r, \"infomask\").(string)\n\tmask, err := strconv.ParseInt(smask, 10, 0)\n\tif err != nil {\n\t\tEasyErrorResponse(w, core.NebError, err)\n\t\treturn\n\t}\n\tuser := context.Get(r, \"user\").(*core.User)\n\n\terr = user.FetchUserInfos(int(mask))\n\tif err != nil {\n\t\tEasyErrorResponse(w, core.NebError, err)\n\t\treturn\n\t}\n\n\tEasyDataResponse(w, user)\n}", "title": "" }, { "docid": "52ea95957eedfc8ab90abce5d9b7da8a", "score": "0.53633064", "text": "func (c *certifierBlobstore) ListUsers() ([]*protos.User, error) {\n\tstore, err := c.factory.StartTransaction(&storage.TxOptions{ReadOnly: true})\n\tif err != nil {\n\t\treturn nil, status.Errorf(codes.Unavailable, \"failed to start transaction: %s\", err)\n\t}\n\tdefer store.Rollback()\n\tblobs, err := blobstore.GetAllOfType(store, placeholderNetworkID, constants.UserType)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get all users: %w\", err)\n\t}\n\tusers := make([]*protos.User, len(blobs))\n\tfor i, blob := range blobs {\n\t\tuser := &protos.User{}\n\t\terr = proto.Unmarshal(blob.Value, user)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to unmarshal user: %w\", err)\n\t\t}\n\t\tusers[i] = user\n\t}\n\treturn users, store.Commit()\n}", "title": "" }, { "docid": "eefb50203d7c9f132468567556c2b338", "score": "0.53594124", "text": "func (a *Client) ListUsers(params *ListUsersParams, authInfo runtime.ClientAuthInfoWriter) (*ListUsersOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewListUsersParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"listUsers\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/users\",\n\t\tProducesMediaTypes: []string{\"application/vnd.pagerduty+json;version=2\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &ListUsersReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.(*ListUsersOK), nil\n\n}", "title": "" }, { "docid": "7d552ec86836c4125b7cb47e2ac308c0", "score": "0.5357936", "text": "func (ach *AdminUserHandler) GetUsers(w http.ResponseWriter,\n\tr *http.Request, _ httprouter.Params) {\n\n\tusers, errs := ach.userService.Users()\n\tif len(errs) > 0 {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\thttp.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)\n\t\treturn\n\t}\n\toutput, err := json.MarshalIndent(users, \"\", \"\\t\\t\")\n\n\tif err != nil {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\thttp.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)\n\t\treturn\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Write(output)\n\treturn\n\n}", "title": "" } ]
20415578cbd3b1d9dd58ca8047ce5f73
Deprecated: Use BranchInfo.ProtoReflect.Descriptor instead.
[ { "docid": "d0f094193be4e1a552f2d358bb8eb147", "score": "0.70692766", "text": "func (*BranchInfo) Descriptor() ([]byte, []int) {\n\treturn file_dtmgrpc_dtmgrpc_proto_rawDescGZIP(), []int{2}\n}", "title": "" } ]
[ { "docid": "05bdc27e59ba9137394bdf6338e1defe", "score": "0.6876636", "text": "func (*Branch) Descriptor() ([]byte, []int) {\n\treturn file_code_coverage_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "c088f355c83e27879b2b4fd1d4ad82ee", "score": "0.68322736", "text": "func (*Branch) Descriptor() ([]byte, []int) {\n\treturn file_branchService_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "a340f511fca5ea7bd4fcfc7c5ddd3ffa", "score": "0.66477215", "text": "func (*ListBranchesRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_github_proto_rawDescGZIP(), []int{6}\n}", "title": "" }, { "docid": "e44f5f6dcbb3c154a462a3656a28209c", "score": "0.6532026", "text": "func (*DtmTccBranchRequest) Descriptor() ([]byte, []int) {\n\treturn file_dtmgrpc_dtmgrpc_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "7da7d14189f412b98fe6eb031896ef88", "score": "0.64440763", "text": "func (*BranchBrief) Descriptor() ([]byte, []int) {\n\treturn file_proto_company_company_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "253aceb3a0a1cf4bbb832d856ef76ba0", "score": "0.6439089", "text": "func (*ListBranchesResponse) Descriptor() ([]byte, []int) {\n\treturn file_proto_github_proto_rawDescGZIP(), []int{7}\n}", "title": "" }, { "docid": "e96ec464acd20c1b1703390074c6eb10", "score": "0.6414022", "text": "func (*LabelDescriptor) Descriptor() ([]byte, []int) {\n\treturn file_google_api_label_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "62dc5252410d7c0364495ed400813d3f", "score": "0.6411569", "text": "func (*Label) Descriptor() ([]byte, []int) {\n\treturn file_tarianpb_types_proto_rawDescGZIP(), []int{7}\n}", "title": "" }, { "docid": "31893b98c797fad19668869564bb3194", "score": "0.6408616", "text": "func (*TelemetryLabel) Descriptor() ([]byte, []int) {\n\treturn file_proto_telemetry_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "e1508e22c5b8a568dd2c14aa2263a7d1", "score": "0.6395224", "text": "func (*BreadCrumb) Descriptor() ([]byte, []int) {\n\treturn file_hub3_fragments_api_proto_rawDescGZIP(), []int{7}\n}", "title": "" }, { "docid": "f0867426f299d4ff7b03a5de9753d4f2", "score": "0.63701683", "text": "func (*Label) Descriptor() ([]byte, []int) {\n\treturn file_api_gadgettracermanager_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "5bf70298dc9a7ea45a04005377e97238", "score": "0.6319084", "text": "func (*Tree) Descriptor() ([]byte, []int) {\n\treturn file_build_bazel_remote_execution_v2_remote_execution_proto_rawDescGZIP(), []int{13}\n}", "title": "" }, { "docid": "8fcd32d27c9334f9d0470caca5209e7a", "score": "0.63125354", "text": "func (*BlacklistPB) Descriptor() ([]byte, []int) {\n\treturn file_yb_master_master_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "515a0d40febdcac14a507e6d3be1c576", "score": "0.63100415", "text": "func (*Info) Descriptor() ([]byte, []int) {\n\treturn file_github_com_gunk_opt_openapiv2_all_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "5c33eec76b2473e29b07559c80b0b778", "score": "0.6292406", "text": "func (*MaxnoofLabelInfo) Descriptor() ([]byte, []int) {\n\treturn file_e2sm_kpm_v2_go_v2_e2sm_kpm_v2_go_proto_rawDescGZIP(), []int{38}\n}", "title": "" }, { "docid": "ebb4ac925db14da2db4f7c5e2752468f", "score": "0.62818223", "text": "func (Branch) EnumDescriptor() ([]byte, []int) {\n\treturn file_proto_role_proto_rawDescGZIP(), []int{1}\n}", "title": "" }, { "docid": "3a3d5719eab5051c94de33c42b7a6ac3", "score": "0.6276988", "text": "func (Trickle_Target) EnumDescriptor() ([]byte, []int) {\n\treturn file_pkg_grpc_biz_biz_proto_rawDescGZIP(), []int{7, 0}\n}", "title": "" }, { "docid": "95bab920b0943baa418a13561923bbb7", "score": "0.6253337", "text": "func (*Label) Descriptor() ([]byte, []int) {\n\treturn file_proto_growlog_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "d1334ebdff39cec507bf2746d0edfd03", "score": "0.6242254", "text": "func (*Ref_Foo_Bar) Descriptor() ([]byte, []int) {\n\treturn file_constructsserver_pb_constructs_proto_rawDescGZIP(), []int{12, 1, 1}\n}", "title": "" }, { "docid": "80ecaaa21ffa6184896022b65ed86da9", "score": "0.62389976", "text": "func (*BranchResponse) Descriptor() ([]byte, []int) {\n\treturn file_branchService_proto_rawDescGZIP(), []int{1}\n}", "title": "" }, { "docid": "5451e6af10d0848da6b9ae8d4c27dc79", "score": "0.62258106", "text": "func (*ChangeLoadBalancerStateRequestPB) Descriptor() ([]byte, []int) {\n\treturn file_yb_master_master_proto_rawDescGZIP(), []int{92}\n}", "title": "" }, { "docid": "01de35a00644b97528fa5a1d40822b18", "score": "0.62226975", "text": "func (*Inner) Descriptor() ([]byte, []int) {\n\treturn file_go_chromium_org_luci_common_proto_protowalk_fields_test_proto_rawDescGZIP(), []int{1}\n}", "title": "" }, { "docid": "fae7db905cd613cf8e3eaf8ce53e9c64", "score": "0.621458", "text": "func (*Ref_Bar) Descriptor() ([]byte, []int) {\n\treturn file_constructsserver_pb_constructs_proto_rawDescGZIP(), []int{12, 0}\n}", "title": "" }, { "docid": "2cd366e70db24f94b48a1a78706246a6", "score": "0.62029606", "text": "func (*Field) Descriptor() ([]byte, []int) {\n\treturn file_google_apps_drive_labels_v2beta_field_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "97ce2f7ec81ea2a7b0b4f23f3dec7376", "score": "0.62005347", "text": "func (*Target) Descriptor() ([]byte, []int) {\n\treturn file_src_main_protobuf_analysis_v2_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "aca5e6df53c16368572a9dfe8892e998", "score": "0.6195386", "text": "func (*UpdateBranchStatsByIDRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_company_company_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "46589fbd2e656aadcd7f605ce078b0b2", "score": "0.61840814", "text": "func (*B) Descriptor() ([]byte, []int) {\n\treturn file_go_chromium_org_luci_common_proto_protowalk_fields_test_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "63bfe6674ee27d4d3ba43ef64aa6a4b3", "score": "0.61723816", "text": "func (*GracefulFailoverResponseProto) Descriptor() ([]byte, []int) {\n\treturn file_ZKFCProtocol_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "49a4a4f1349e2d35bfcce114a78cbc87", "score": "0.617174", "text": "func (*Blinked) Descriptor() ([]byte, []int) {\n\treturn file_proto_health_proto_rawDescGZIP(), []int{2}\n}", "title": "" }, { "docid": "fcf68c3dd627c0e0aa3ca9d5eadf1f5c", "score": "0.6166914", "text": "func (*Ref_Foo) Descriptor() ([]byte, []int) {\n\treturn file_constructsserver_pb_constructs_proto_rawDescGZIP(), []int{12, 1}\n}", "title": "" }, { "docid": "42b93f04d6d95b0b5038649d7f77a19f", "score": "0.6162837", "text": "func (*BlackredLevelDesc) Descriptor() ([]byte, []int) {\n\treturn file_platform_proto_rawDescGZIP(), []int{23}\n}", "title": "" }, { "docid": "abd9f68f688e35e3281e02fb5ff9d036", "score": "0.61476505", "text": "func (*ConfiguredTarget) Descriptor() ([]byte, []int) {\n\treturn file_src_main_protobuf_analysis_v2_proto_rawDescGZIP(), []int{9}\n}", "title": "" }, { "docid": "2b1d14eab70604ab73b54f6b2c016199", "score": "0.6144636", "text": "func (*BytesProto) Descriptor() ([]byte, []int) {\n\treturn file_go_chromium_org_luci_server_internal_gae_base_api_base_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "e69c23d14b54e8f11be51205bd263249", "score": "0.6139268", "text": "func (*ColdInfo) Descriptor() ([]byte, []int) {\n\treturn file_ffs_rpc_rpc_proto_rawDescGZIP(), []int{11}\n}", "title": "" }, { "docid": "c4b25b83c20e9296875426fd4b56317d", "score": "0.61361766", "text": "func (*HotInfo) Descriptor() ([]byte, []int) {\n\treturn file_ffs_rpc_rpc_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "e30a5e2cffcd292e846686302a612e88", "score": "0.6132403", "text": "func (*DtmXaBranchRequest) Descriptor() ([]byte, []int) {\n\treturn file_dtmgrpc_dtmgrpc_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "0395f997b9b492d84da93773e9e7f07f", "score": "0.6131077", "text": "func (*ProjectLight) Descriptor() ([]byte, []int) {\n\treturn file_zeropsApiProtocol_proto_rawDescGZIP(), []int{45}\n}", "title": "" }, { "docid": "9ddd7020926763ad8ec70ccadb6d611c", "score": "0.6125029", "text": "func (*Info) Descriptor() ([]byte, []int) {\n\treturn file_protobuf_osm_proto_rawDescGZIP(), []int{7}\n}", "title": "" }, { "docid": "ec868d23c25bace490301f43127f7d35", "score": "0.61219287", "text": "func (*Bar) Descriptor() ([]byte, []int) {\n\treturn file_nested_proto_rawDescGZIP(), []int{1}\n}", "title": "" }, { "docid": "04d2f7174b93f07f7719bd363a9ca335", "score": "0.6118315", "text": "func (*LabelsGet) Descriptor() ([]byte, []int) {\n\treturn file_chat_labels_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "a84933180a78f2281307c6ca61c1355f", "score": "0.61144567", "text": "func (*CLobbyTeamDetails) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_common_lobby_proto_rawDescGZIP(), []int{9}\n}", "title": "" }, { "docid": "89662405d01e18aae31be472b9232ea3", "score": "0.6114027", "text": "func (*AddrInfo) Descriptor() ([]byte, []int) {\n\treturn file_ffs_rpc_rpc_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "52f74679b0513fac0f6a5d37a8daf63d", "score": "0.6109519", "text": "func (*VersionResponseProto) Descriptor() ([]byte, []int) {\n\treturn file_HdfsServer_proto_rawDescGZIP(), []int{12}\n}", "title": "" }, { "docid": "ac3a8d1877a37e48cc6e5176fd468afb", "score": "0.61085993", "text": "func (*Outer) Descriptor() ([]byte, []int) {\n\treturn file_go_chromium_org_luci_common_proto_protowalk_fields_test_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "ad2ba9cf9ecca73554c4ff769f8946d2", "score": "0.60962564", "text": "func (*LabelPair) Descriptor() ([]byte, []int) {\n\treturn file_logproto_proto_rawDescGZIP(), []int{19}\n}", "title": "" }, { "docid": "6d0595a100c3990e8a8ba64f16183026", "score": "0.60958236", "text": "func (*LabelsDelete) Descriptor() ([]byte, []int) {\n\treturn file_chat_labels_proto_rawDescGZIP(), []int{2}\n}", "title": "" }, { "docid": "546eca3f5f2acedea59f3471311d514b", "score": "0.6088649", "text": "func (*CallUpdateStatusChanged) Descriptor() ([]byte, []int) {\n\treturn file_client_call_proto_rawDescGZIP(), []int{51}\n}", "title": "" }, { "docid": "5da27589c14bdb4a277bae7e6c346bc5", "score": "0.6083881", "text": "func (*TeamDriveReference) Descriptor() ([]byte, []int) {\n\treturn file_google_apps_drive_activity_v2_target_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "3dd34cff7bbc8880b633b4ccfd3c696d", "score": "0.60821027", "text": "func (*BaccaratLevelDesc) Descriptor() ([]byte, []int) {\n\treturn file_platform_proto_rawDescGZIP(), []int{26}\n}", "title": "" }, { "docid": "0ccb51bfaf61f420b466aeff2b4585c9", "score": "0.6076747", "text": "func (*PBDetailView) Descriptor() ([]byte, []int) {\n\treturn file_github_com_lemmerelassal_PBFlutter_proto_pbflutter_proto_rawDescGZIP(), []int{33}\n}", "title": "" }, { "docid": "20e30b3bc9738dd37def1c91c22b67a4", "score": "0.6076089", "text": "func (*Trickle) Descriptor() ([]byte, []int) {\n\treturn file_pkg_grpc_biz_biz_proto_rawDescGZIP(), []int{7}\n}", "title": "" }, { "docid": "38144eb6465398e14691173a11b157d4", "score": "0.60707504", "text": "func (*VisitRequest) Descriptor() ([]byte, []int) {\n\treturn file_src_transport_grpc_proto_visit_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "5b163d91d6a1b6ea16a977a21f0eb0a1", "score": "0.6066907", "text": "func (*BoolProto) Descriptor() ([]byte, []int) {\n\treturn file_go_chromium_org_luci_server_internal_gae_base_api_base_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "11a4b616cd86c66cdbc7fc41d1cc910f", "score": "0.60583603", "text": "func (*Detail) Descriptor() ([]byte, []int) {\n\treturn file_crawlingproto_crawling_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "0f88ba55fa02dda4983c5c974fa243f3", "score": "0.60577196", "text": "func (x *fastReflection_Bar) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_Bar\n}", "title": "" }, { "docid": "bfce22ff8841b0e2a037f4ae94490387", "score": "0.60529983", "text": "func (*NodePool_UpdateInfo_BlueGreenInfo) Descriptor() ([]byte, []int) {\n\treturn file_google_container_v1_cluster_service_proto_rawDescGZIP(), []int{77, 1, 0}\n}", "title": "" }, { "docid": "63097f242660b5ece2889ef29c55baeb", "score": "0.6050869", "text": "func (*VoidProto) Descriptor() ([]byte, []int) {\n\treturn file_go_chromium_org_luci_server_internal_gae_base_api_base_proto_rawDescGZIP(), []int{6}\n}", "title": "" }, { "docid": "fd81d1b4c3cf5ddeb4d780cc3a3c2a49", "score": "0.60484546", "text": "func (*Info_Node) Descriptor() ([]byte, []int) {\n\treturn file_apis_proto_v1_payload_payload_proto_rawDescGZIP(), []int{9, 2}\n}", "title": "" }, { "docid": "e61394de949458842d6041f4b94d63dd", "score": "0.60436934", "text": "func (*Telemetry) Descriptor() ([]byte, []int) {\n\treturn file_telemetry_bis_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "1c7d98d289138eb4c8d241f00cd52839", "score": "0.60381", "text": "func (*GetTreeRequest) Descriptor() ([]byte, []int) {\n\treturn file_build_bazel_remote_execution_v2_remote_execution_proto_rawDescGZIP(), []int{32}\n}", "title": "" }, { "docid": "de098558aef808743f7477b8f8218729", "score": "0.60364664", "text": "func (*GetLoadBalancerStateRequestPB) Descriptor() ([]byte, []int) {\n\treturn file_yb_master_master_proto_rawDescGZIP(), []int{94}\n}", "title": "" }, { "docid": "5b6bb16a7cdf076c27e04bb86fd45b61", "score": "0.60351443", "text": "func (*MatchLabel) Descriptor() ([]byte, []int) {\n\treturn file_tarianpb_types_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "74af090ad5706fe6bd95e905aa56232e", "score": "0.6034761", "text": "func (*InternalChecker) Descriptor() ([]byte, []int) {\n\treturn file_google_monitoring_v3_uptime_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "bbcd3e7745ad3352f1f78208ba513afb", "score": "0.6033784", "text": "func (RefType) EnumDescriptor() ([]byte, []int) {\n\treturn file_language_agent_Tracing_proto_rawDescGZIP(), []int{1}\n}", "title": "" }, { "docid": "fc9b7fd84612356c56312aa48b720553", "score": "0.6031982", "text": "func (*LabelsRemoveFromMessage) Descriptor() ([]byte, []int) {\n\treturn file_chat_labels_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "9b218d84bb7ccb3e75bb5d9f896ee325", "score": "0.60313785", "text": "func (*ConstantFetcherStatus) Descriptor() ([]byte, []int) {\n\treturn file_pkg_security_proto_api_api_proto_rawDescGZIP(), []int{22}\n}", "title": "" }, { "docid": "8f82a9aa526293efe42f8682861d88fc", "score": "0.60306174", "text": "func (*GetTreeResponse) Descriptor() ([]byte, []int) {\n\treturn file_build_bazel_remote_execution_v2_remote_execution_proto_rawDescGZIP(), []int{33}\n}", "title": "" }, { "docid": "d14db88b6fc949d0a509d7ce0ec6e310", "score": "0.6023579", "text": "func (*LabelRequest) Descriptor() ([]byte, []int) {\n\treturn file_logproto_proto_rawDescGZIP(), []int{6}\n}", "title": "" }, { "docid": "dfa4a0af2ffab8ad226bd03ddbdf06a4", "score": "0.6022781", "text": "func (*TokenInfo) Descriptor() ([]byte, []int) {\n\treturn file_types_basic_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "572aef7b25983bf1a67244428b544fb5", "score": "0.6021159", "text": "func (*BytesProto) Descriptor() ([]byte, []int) {\n\treturn file_api_base_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "5b380047ea26eb9fee98c4604a79b194", "score": "0.6020976", "text": "func (*Ref) Descriptor() ([]byte, []int) {\n\treturn file_constructsserver_pb_constructs_proto_rawDescGZIP(), []int{12}\n}", "title": "" }, { "docid": "d36e76ccd823c4ed8cd7552072f36e11", "score": "0.6018718", "text": "func (*Unbanned) Descriptor() ([]byte, []int) {\n\treturn file_proto_customers_events_proto_rawDescGZIP(), []int{7}\n}", "title": "" }, { "docid": "e2d07f7b2522f7ae872c133f32cf4e5c", "score": "0.60168123", "text": "func (*StatusUpdate) Descriptor() ([]byte, []int) {\n\treturn file_google_devtools_issuetracker_v1_issuetracker_proto_rawDescGZIP(), []int{10}\n}", "title": "" }, { "docid": "9e3485ce92767028d84b5baf42262bf3", "score": "0.6015839", "text": "func (*Verifiers_TreeStatus) Descriptor() ([]byte, []int) {\n\treturn file_go_chromium_org_luci_cv_api_config_v2_config_proto_rawDescGZIP(), []int{5, 1}\n}", "title": "" }, { "docid": "22db181d8c81156032af1088c2a73d8f", "score": "0.60128796", "text": "func (Bar) EnumDescriptor() ([]byte, []int) {\n\treturn file_constructsserver_pb_constructs_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "86b0c8f52238455466b9557b0b7eea85", "score": "0.6011008", "text": "func (*CheckpointCommandProto) Descriptor() ([]byte, []int) {\n\treturn file_HdfsServer_proto_rawDescGZIP(), []int{9}\n}", "title": "" }, { "docid": "f033df91fb92d4eab7618babf08e6434", "score": "0.6002735", "text": "func (*Verified) Descriptor() ([]byte, []int) {\n\treturn file_proto_customers_events_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "15c838ee9d2c11b3b9c43ba04e171a8d", "score": "0.600101", "text": "func (*Language) Descriptor() ([]byte, []int) {\n\treturn file_zeropsApiProtocol_proto_rawDescGZIP(), []int{42}\n}", "title": "" }, { "docid": "05d7d1c9f4a81d138b4ac28dbee9efb6", "score": "0.59979963", "text": "func (*LapNumber) Descriptor() ([]byte, []int) {\n\treturn file_reflector_proto_rawDescGZIP(), []int{1}\n}", "title": "" }, { "docid": "c494666d8ef4fade22473832fc7bb82a", "score": "0.5997584", "text": "func (*DependencyInfo) Descriptor() ([]byte, []int) {\n\treturn file_pulumi_language_proto_rawDescGZIP(), []int{2}\n}", "title": "" }, { "docid": "595043cc489b5177bee1cdf39aad46c7", "score": "0.5991965", "text": "func (*ChangeLoadBalancerStateResponsePB) Descriptor() ([]byte, []int) {\n\treturn file_yb_master_master_proto_rawDescGZIP(), []int{93}\n}", "title": "" }, { "docid": "48b77794e293d0af39b2ac7ab749e7de", "score": "0.5985364", "text": "func (Ref_Foo_En) EnumDescriptor() ([]byte, []int) {\n\treturn file_constructsserver_pb_constructs_proto_rawDescGZIP(), []int{12, 1, 0}\n}", "title": "" }, { "docid": "b13f4ec87c1fce24f83554b6e84cbe96", "score": "0.5984154", "text": "func (*ChangeStatus) Descriptor() ([]byte, []int) {\n\treturn file_google_ads_googleads_v10_resources_change_status_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "f401213465f1126c205f817271105d0c", "score": "0.5980416", "text": "func (*Trunk) Descriptor() ([]byte, []int) {\n\treturn file_wgtwo_callforward_v0_callforward_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "f2451b5a59f05ba1c2a40890eb04cafa", "score": "0.5979555", "text": "func (*Listener_DeprecatedV1) Descriptor() ([]byte, []int) {\n\treturn file_xds_lds_proto_rawDescGZIP(), []int{0, 0}\n}", "title": "" }, { "docid": "5361981173de8db3b175c9f4ce42c40b", "score": "0.5978927", "text": "func (*OnExtAddrChangeEvent) Descriptor() ([]byte, []int) {\n\treturn file_visualize_grpc_proto_rawDescGZIP(), []int{23}\n}", "title": "" }, { "docid": "4a66cca4a1490a80eb70d6f49ae1ba23", "score": "0.5977562", "text": "func (*FieldUpdate) Descriptor() ([]byte, []int) {\n\treturn file_google_devtools_issuetracker_v1_issuetracker_proto_rawDescGZIP(), []int{12}\n}", "title": "" }, { "docid": "62249d82ec730c11b6c9814821aef776", "score": "0.5976651", "text": "func (*DMLink) Descriptor() ([]byte, []int) {\n\treturn file_go_chromium_org_luci_luciexe_legacy_annotee_proto_annotations_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "25f6526e9a4b066b7ebd07f7d723bca0", "score": "0.5975684", "text": "func (*Link) Descriptor() ([]byte, []int) {\n\treturn file_go_chromium_org_luci_milo_api_config_project_proto_rawDescGZIP(), []int{2}\n}", "title": "" }, { "docid": "d109fd9980616cd469705bd2882c2344", "score": "0.5975588", "text": "func (*CustomExt) Descriptor() ([]byte, []int) {\n\treturn file_go_chromium_org_luci_common_proto_protowalk_fields_test_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "8496964f575bee7e781d0f5e345867dc", "score": "0.59736013", "text": "func (*ContractLoginfo) Descriptor() ([]byte, []int) {\n\treturn file_proto_ContractCallLocal_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "cf1df8c3b1a282100b651bd7d4992a91", "score": "0.59730697", "text": "func (*LabelInfoList) Descriptor() ([]byte, []int) {\n\treturn file_e2sm_kpm_v2_go_v2_e2sm_kpm_v2_go_proto_rawDescGZIP(), []int{45}\n}", "title": "" }, { "docid": "c8ec2b6c6d85cbc0dd302a423756cf3d", "score": "0.5972784", "text": "func (*VisibilityUpdate) Descriptor() ([]byte, []int) {\n\treturn file_all_proto_rawDescGZIP(), []int{2}\n}", "title": "" }, { "docid": "f24728f02ce314278b52648e6e86848f", "score": "0.5972771", "text": "func (*Step) Descriptor() ([]byte, []int) {\n\treturn file_go_chromium_org_luci_luciexe_legacy_annotee_proto_annotations_proto_rawDescGZIP(), []int{1}\n}", "title": "" }, { "docid": "ae52243519936f2a29869ff6616606df", "score": "0.5972439", "text": "func (*Info) Descriptor() ([]byte, []int) {\n\treturn file_apis_proto_v1_payload_payload_proto_rawDescGZIP(), []int{9}\n}", "title": "" }, { "docid": "e0a8af686b3299a2eaaf2b640f39e591", "score": "0.5970107", "text": "func (*VerificationRequest) Descriptor() ([]byte, []int) {\n\treturn file_trisa_gds_api_v1beta1_api_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "a27878d5f18d4ec1b09a069d7a02fa9a", "score": "0.5970013", "text": "func (*Peer) Descriptor() ([]byte, []int) {\n\treturn file_pkg_grpc_biz_biz_proto_rawDescGZIP(), []int{10}\n}", "title": "" }, { "docid": "f42f9134ad0d1248c59502d2cfc05ab5", "score": "0.5967209", "text": "func (*GetBranchBriefByIDRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_company_company_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "4bb3783c5fe9524ec8b34304bbe80db2", "score": "0.59644717", "text": "func (*ValidatorUpdate) Descriptor() ([]byte, []int) {\n\treturn file_core_abci_tendermint_abci_types_proto_rawDescGZIP(), []int{36}\n}", "title": "" }, { "docid": "1e98599ae6c33ffb553c184364507e05", "score": "0.59635943", "text": "func (*UpdateBranchStatsByIDResponse) Descriptor() ([]byte, []int) {\n\treturn file_proto_company_company_proto_rawDescGZIP(), []int{9}\n}", "title": "" } ]
49c32ab022d07b0329c25fe11c7f0ad3
verifyProofMASS verifies proof: (1) make sure BitLength is Valid. Should be integer even number in [24, 40]. (2) perform function P on x and x_prime, the corresponding result y and y_prime should be a bitflip pair. (3) perform function F on x and x_prime, the result z should be equal to the bitlengthcut challenge. It returns nil when proof is verified.
[ { "docid": "49244344e427b000bb56c9b683115b6f", "score": "0.49559355", "text": "func (proof *DefaultProof) Verify(pubKeyHash pocutil.Hash, challenge pocutil.Hash, filter bool) error {\n\tbl := proof.BL\n\tif !ProofTypeDefault.EnsureBitLength(bl) {\n\t\treturn ErrProofInvalidBitLength\n\t}\n\n\tif filter && !chiapos.PassPlotFilter(pubKeyHash, challenge) {\n\t\treturn ErrProofFilter\n\t}\n\n\ty := pocutil.PB(proof.X, bl, pubKeyHash)\n\typ := pocutil.PB(proof.XPrime, bl, pubKeyHash)\n\tif y != pocutil.FlipValue(yp, bl) {\n\t\treturn ErrProofInvalidFlipValue\n\t}\n\n\tcShort := pocutil.CutHash(challenge, bl)\n\tz := pocutil.FB(proof.X, proof.XPrime, bl, pubKeyHash)\n\tif cShort != z {\n\t\treturn ErrProofInvalidChallenge\n\t}\n\n\treturn nil\n}", "title": "" } ]
[ { "docid": "923008584835175ce41ea5f84abb151f", "score": "0.59169686", "text": "func pdp_verify_proof(key *PDP_key, challenge *PDP_challenge, proof *PDP_proof) int {\n\n\tvar tao *big.Int\n\tvar denom *big.Int\n\tvar coefficient_a *big.Int\n\tvar fdh_hash *big.Int\n\tvar tao_s *big.Int\n\tvar r0 *big.Int\n\tvar index_prf *string\n\tvar index_prf_size uint64 = 0\n\tvar prf_result *string\n\tvar prf_result_size uint64 = 0\n\tvar H_result *string\n\tvar H_result_size uint64 = 0\n\tvar j uint = 0\n\tvar result int = 0\n\tvar indices *uint\n\n\tif key == nil || challenge == nil || proof == nil {\n\t\treturn -1\n\t}\n\n\t/* Verify keys */\n\tif key.rsa == nil {\n\t\treturn 0\n\t}\n\tif key.rsa.E == 0 {\n\t\treturn 0\n\t}\n\tif key.rsa.N == nil {\n\t\treturn 0\n\t}\n\n\t/* Make sure we don't have a \"sanitized\" challenge */\n\tif challenge.s == nil {\n\t\treturn 0\n\t}\n\n\t/* Compute tao where tao = T^e */\n\ttao = new(big.Int).Exp(proof.T, new(big.Int).SetInt64(int64(key.rsa.E)), key.rsa.N)\n\tif tao == nil {\n\t\treturn 0\n\t}\n\n\t/* Compute the indices i_j = pi_k1(j); the indices of blocks to sample */\n\tindices = generate_prp_pi(challenge)\n\tfor j := 0; j < int(challenge.c); j++ {\n\n\t\t/* Perform the pseudo-random function Wi = w_v(i) */\n\t\tindex_prf = pdpCore.generate_prf_w(key, indices[j], &index_prf_size)\n\t\tif index_prf == nil {\n\t\t\treturn 0\n\t\t}\n\t\t/* Calculate the full-domain hash h(W_i) */\n\t\tfdh_hash = pdpCore.generate_fdh_h(key, index_prf, index_prf_size)\n\t\tif fdh_hash == nil {\n\t\t\treturn 0\n\t\t}\n\n\t\tif USE_E_PDP == 1 { /* Use E-PDP */\n\t\t\tif fdh_hash == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tr0.Set(fdh_hash)\n\t\t} else { /* Use S-PDP */\n\t\t\t/* Generate the coefficient for block index a = f_k2(j) */\n\t\t\tprf_result = pdpCore.generate_prf_f(challenge, j, &prf_result_size)\n\t\t\tif prf_result == nil {\n\t\t\t\treturn 0\n\t\t\t}\n\n\t\t\t/* Convert prf coefficient result to a BIGNUM */\n\t\t\tprf_result = new(big.Int).SetString(prf_result_size, coefficient_a)\n\t\t\tif prf_result == nil {\n\t\t\t\treturn 0\n\t\t\t}\n\n\t\t\t/* Calculate h(W_i)^a */\n\t\t\tr0 = new(big.Int).Exp(fdh_hash, coefficient_a, key.rsa.N)\n\t\t\tif r0 == nil {\n\t\t\t\treturn 0\n\t\t\t}\n\t\t}\n\n\t\t/* Calculate products of h(W_i)^a (no coefficeint a in E-PDP) */\n\t\tif denom.Cmp(big.NewInt(0)) == 1 {\n\t\t\tif r0 == nil {\n\t\t\t\treturn 0\n\t\t\t}\n\t\t\tdenom.Set(r0)\n\t\t} else {\n\t\t\tdenom = ModMul(denom, r0, key.rsa.N)\n\t\t\tif denom == nil {\n\t\t\t\treturn 0\n\t\t\t}\n\t\t}\n\n\t} /* end for */\n\n\t/* Calculate tao, where tao = tao/h(W_i)^a mod N */\n\t/* Inverse h(W_i)^a to create 1/h(W_i)^a */\n\tdenom = new(big.Int).ModInverse(denom, key.rsa.N)\n\tif denom == nil {\n\t\treturn 0\n\t}\n\t/* tao = tao * 1/h(W_i)^a mod N*/\n\ttao = new(big.Int).ModMul(tao, denom, key.rsa.N)\n\tif tao == nil {\n\t\treturn 0\n\t}\n\n\t/* Calculate tao^s mod N*/\n\ttao_s = new(big.Int).Exp(tao, challenge.s, key.rsa.N)\n\tif tao_s == nil {\n\t\treturn 0\n\t}\n\n\t/* Calculate H(tao^s mod N) */\n\tH_result = generate_H(tao_s, &(H_result_size))\n\tif H_result == nil {\n\t\treturn 0\n\t}\n\n\t/* The final verification step. Does rho == rho? */\n\tif H_result == proof.rho {\n\t\tresult = 1\n\t}\n\n\treturn result\n}", "title": "" }, { "docid": "a21101363a03ad3a66a1e6c55481b055", "score": "0.56574756", "text": "func VerifyPuzzleOutput(p *big.Int, q *big.Int, pz *PuzzleRSW, claimedKey []byte) (valid bool, err error) {\n\tif p == nil {\n\t\terr = fmt.Errorf(\"p pointer cannot be nil, please investigate\")\n\t\treturn\n\t}\n\tif q == nil {\n\t\terr = fmt.Errorf(\"q pointer cannot be nil, please investigate\")\n\t\treturn\n\t}\n\n\ttempN := new(big.Int)\n\ttempN.Mul(p, q)\n\tif tempN.Cmp(pz.N) != 0 {\n\t\terr = fmt.Errorf(\"The p and q given do not multiply to the puzzle modulus\")\n\t\treturn\n\t}\n\n\t// compute trapdoor\n\t// phi(n) = (p-1)(q-1). We assume p and q are prime, and n = pq.\n\tphi := new(big.Int).Mul(new(big.Int).Sub(p, big.NewInt(1)), new(big.Int).Sub(q, big.NewInt(1)))\n\n\t// e = 2^t mod phi()\n\te := new(big.Int).Exp(big.NewInt(2), pz.T, phi)\n\n\t// b = a^(e()) (mod n())\n\tb := new(big.Int).Exp(pz.A, e, pz.N)\n\n\t// now xor with ck, getting the bytes\n\t// if this is xor then the ck, err = blah like needs to be xor as well\n\tvar answer []byte\n\txorBytes := new(big.Int).Xor(pz.CK, b).Bytes()\n\tif len(xorBytes) <= 16 {\n\t\tanswerBacking := [16]byte{}\n\t\tanswer = answerBacking[:]\n\t} else {\n\t\tanswer = make([]byte, len(xorBytes))\n\t}\n\tcopy(answer, xorBytes)\n\n\tif res := bytes.Compare(answer, claimedKey); res != 0 {\n\t\terr = fmt.Errorf(\"The claimed key:\\n\\t%x\\nIs not equal to the puzzle solution:\\n\\t%x\\nSo the claimed solution is invalid\", claimedKey, answer)\n\t\treturn\n\t}\n\n\tvalid = true\n\treturn\n}", "title": "" }, { "docid": "56ed1a321ae7911f66ab8d82db4f72d6", "score": "0.54273754", "text": "func Valid_proof(last_proof uint64, proof uint64) bool {\n\treturn strings.HasPrefix(asSha256((strconv.FormatUint(last_proof, 10) + strconv.FormatUint(proof, 10))), \"0000\")\n}", "title": "" }, { "docid": "3285cba79578a498df4fc61ed230e0f2", "score": "0.5311382", "text": "func TestProof(t *testing.T) {\n\tb0 := Initial(16)\n\tb0.Mine(1)\n\tb1 := b0.Next(\"message\")\n\tb1.Mine(1)\n\n\tassert.Equal(t, b0.Proof, uint64(56231))\n\tassert.Equal(t,b1.Proof, uint64(2159))\n\n}", "title": "" }, { "docid": "f2225d02a80eefda9644db8584cf64fc", "score": "0.5288314", "text": "func VerifyProof(holder common.Address, storageRoot common.Hash,\n\tproofs []ethstorageproof.StorageResult, mapIndexSlot int, targetBalance,\n\ttargetBlock *big.Int) error {\n\t// Sanity checks\n\tif len(proofs) != 2 {\n\t\treturn fmt.Errorf(\"wrong length of storage proofs\")\n\t}\n\tfor i, p := range proofs {\n\t\t// proofs[1].Value can be nil when it's a non-existence proof\n\t\tif i == 0 && p.Value == nil {\n\t\t\treturn fmt.Errorf(\"value is nil\")\n\t\t}\n\t\tif len(p.Value) > 32 {\n\t\t\treturn fmt.Errorf(\"value length is wrong. Expected <= 32, got %v\",\n\t\t\t\tlen(p.Value))\n\t\t}\n\t\tif len(p.Key) != 32 {\n\t\t\treturn fmt.Errorf(\"key length is wrong. Expected 32, got %v\", len(p.Key))\n\t\t}\n\t}\n\tif targetBalance == nil {\n\t\treturn fmt.Errorf(\"target balance is nil\")\n\t}\n\tif targetBlock == nil {\n\t\treturn fmt.Errorf(\"target balance is nil\")\n\t}\n\n\t// Check the proof keys (should match with the holder)\n\tif err := CheckMinimeKeys(proofs[0].Key, proofs[1].Key, holder, mapIndexSlot); err != nil {\n\t\treturn fmt.Errorf(\"proof key and holder do not match: (%v)\", err)\n\t}\n\n\t// Extract balance and block from the minime proof\n\t_, proof0Balance, proof0Block := ParseMinimeValue(proofs[0].Value, 1)\n\t// Check balance matches with the provided balance\n\tif proof0Balance.Cmp(targetBalance) != 0 {\n\t\treturn fmt.Errorf(\"proof balance and provided balance mismatch (%v != %v)\",\n\t\t\tproof0Balance, targetBalance)\n\t}\n\n\t// Verify that `proof0Block <= targetBlock < proof1Block`\n\n\t// Proof 0 checkpoint block should be smaller or equal than target block\n\tif !(proof0Block.Cmp(targetBlock) <= 0) { // !(proof0Block <= targetBlock)\n\t\treturn fmt.Errorf(\"proof 0 block is not greater equal than target block\")\n\t}\n\t// Check if the proof1 is a proof of non existence (so proof0 is the last checkpoint).\n\t// If not the last, then check the target block is\n\tif len(proofs[1].Value) != 0 {\n\t\t_, _, proof1Block := ParseMinimeValue(proofs[1].Value, 1)\n\t\tif !(proof0Block.Cmp(proof1Block) < 0) { // !(proof0Block < proof1Block)\n\t\t\treturn fmt.Errorf(\"proof 0 block is not behind proof 1 block\")\n\t\t}\n\t\tif !(targetBlock.Cmp(proof1Block) < 0) { // !(targetBlock < proof1Block)\n\t\t\treturn fmt.Errorf(\"target block is not smaller than proof 1 block\")\n\t\t}\n\t}\n\n\t// Check both merkle proofs against the storage root hash\n\tfor i, p := range proofs {\n\t\tvalid, err := ethstorageproof.VerifyEthStorageProof(\n\t\t\t&ethstorageproof.StorageResult{\n\t\t\t\tKey: p.Key,\n\t\t\t\tProof: p.Proof,\n\t\t\t\tValue: p.Value,\n\t\t\t},\n\t\t\tstorageRoot,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !valid {\n\t\t\treturn fmt.Errorf(\"proof %d is not valid\", i)\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "13afa2445e99a036c86ea8e99221439c", "score": "0.52786946", "text": "func (pow *ProofOfWork) ValidateProof() bool {\n\t// Storage variable for initial hash\n\tvar ih big.Int\n\n\t// Pass the current counter on the block to InitialiseData\n\td := pow.InitialiseData(pow.Block.Counter)\n\n\t// Create a hash with sha256\n\th := sha256.Sum256(d)\n\n\t// Set the bytes of the hash to the initial hash variable\n\tih.SetBytes(h[:])\n\n\t// Compare the hash with the target to check if it has been validated\n\treturn ih.Cmp(pow.Target) == -1\n}", "title": "" }, { "docid": "6f34cf027d636d0ad29b5d36cdaa3f41", "score": "0.52469206", "text": "func TestCheckProofOfWork(t *testing.T) {\n\ttests := []struct {\n\t\tname string // test description\n\t\thash string // proof of work hash to test\n\t\tbits uint32 // compact target difficulty bits to test\n\t\tpowLimit string // proof of work limit\n\t\terr error // expected error\n\t}{{\n\t\tname: \"mainnet block 1 pow hash\",\n\t\thash: \"000000000000437482b6d47f82f374cde539440ddb108b0a76886f0d87d126b9\",\n\t\tbits: 0x1b01ffff,\n\t\tpowLimit: mockMainNetPowLimit(),\n\t\terr: nil,\n\t}, {\n\t\tname: \"mainnet block 288 pow hash\",\n\t\thash: \"000000000000e0ab546b8fc19f6d94054d47ffa5fe79e17611d170662c8b702b\",\n\t\tbits: 0x1b01330e,\n\t\tpowLimit: mockMainNetPowLimit(),\n\t\terr: nil,\n\t}, {\n\t\tname: \"max allowed (exactly the pow limit)\",\n\t\thash: \"0000000000001ffff00000000000000000000000000000000000000000000000\",\n\t\tbits: 0x1b01ffff,\n\t\tpowLimit: mockMainNetPowLimit(),\n\t\terr: nil,\n\t}, {\n\t\tname: \"high hash (pow limit + 1)\",\n\t\thash: \"000000000001ffff000000000000000000000000000000000000000000000001\",\n\t\tbits: 0x1b01ffff,\n\t\tpowLimit: mockMainNetPowLimit(),\n\t\terr: ErrHighHash,\n\t}, {\n\t\tname: \"hash satisfies target, but target too high at pow limit + 1\",\n\t\thash: \"0000000000000000000000000000000000000000000000000000000000000001\",\n\t\tbits: 0x1d010000,\n\t\tpowLimit: mockMainNetPowLimit(),\n\t\terr: ErrUnexpectedDifficulty,\n\t}, {\n\t\tname: \"zero target difficulty\",\n\t\thash: \"0000000000000000000000000000000000000000000000000000000000000001\",\n\t\tbits: 0,\n\t\tpowLimit: mockMainNetPowLimit(),\n\t\terr: ErrUnexpectedDifficulty,\n\t}, {\n\t\tname: \"negative target difficulty\",\n\t\thash: \"0000000000000000000000000000000000000000000000000000000000000001\",\n\t\tbits: 0x1810000,\n\t\tpowLimit: mockMainNetPowLimit(),\n\t\terr: ErrUnexpectedDifficulty,\n\t}}\n\n\tfor _, test := range tests {\n\t\thash, err := chainhash.NewHashFromStr(test.hash)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"%q: unexpected err parsing test hash: %v\", test.name, err)\n\t\t\tcontinue\n\t\t}\n\n\t\tpowLimit, success := new(big.Int).SetString(test.powLimit, 16)\n\t\tif !success {\n\t\t\tt.Errorf(\"%q: unexpected err parsing test pow limit\", test.name)\n\t\t\tcontinue\n\t\t}\n\n\t\terr = CheckProofOfWork(hash, test.bits, powLimit)\n\t\tif !errors.Is(err, test.err) {\n\t\t\tt.Errorf(\"%q: unexpected err -- got %v, want %v\", test.name, err,\n\t\t\t\ttest.err)\n\t\t\tcontinue\n\t\t}\n\t}\n}", "title": "" }, { "docid": "44e7da39d8777ce48cd521147e19a779", "score": "0.51430464", "text": "func GenerateProof(directory string, pubkey string, bl int, challenge pocutil.Hash) (result string, proof *poc.Proof, err error) {\n\tpkByte, _ := hex.DecodeString(pubkey)\n\tpk, _ := pocec.ParsePubKey(pkByte, pocec.S256())\n\tmdb, err := massdb_v1.NewMassDBV1(directory, engine.UnknownOrdinal, pk, bl)\n\tif err != nil {\n\t\tfmt.Println(\"Couldn't open massdb\")\n\t\treturn \"\", nil, err\n\t}\n\n\tcShort := pocutil.CutHash(challenge, mdb.BitLength())\n\tproof = &poc.Proof{BitLength: mdb.BitLength()}\n\tproof.X, proof.XPrime, err = mdb.HashMapB.Get(cShort)\n\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\tfmt.Println()\n\txString := ByteArrayToString(proof.X)\n\txPrimeString := ByteArrayToString(proof.XPrime)\n\tresult = xString + xPrimeString\n\treturn result, proof, nil\n\n}", "title": "" }, { "docid": "175546be420aecd88864ca156871331e", "score": "0.51347524", "text": "func makeProof(payId pay.PayId, payNonce reservoir.PayNonce, difficulty string, verbose bool, handle io.Writer) string {\n\n\tnonce := uint64(12345)\n\tnonceBuffer := make([]byte, 8)\n\n\tstart := time.Now()\n\thashCount := 0\n\n\tfor {\n\t\thashCount += 1\n\t\tnonce += 113113\n\t\tbinary.BigEndian.PutUint64(nonceBuffer, nonce)\n\n\t\t// compute hash\n\t\th := sha3.New256()\n\t\th.Write(payId[:])\n\t\th.Write(payNonce[:])\n\t\th.Write(nonceBuffer)\n\t\tvar digest [32]byte\n\t\th.Sum(digest[:0])\n\t\tif 0 == digest[0]|digest[1] {\n\t\t\tif verbose {\n\t\t\t\thps := float64(hashCount) / time.Since(start).Seconds() / 1.0e6\n\t\t\t\tfmt.Fprintf(handle, \"%f MH/s: possible nonce: %x with digest: %x\\n\", hps, nonceBuffer, digest)\n\t\t\t}\n\t\t\thexDigest := hex.EncodeToString(digest[:])\n\t\t\tif hexDigest <= difficulty {\n\t\t\t\treturn hex.EncodeToString(nonceBuffer)\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "b417fcadde93f9427ff14d1f8ccf8980", "score": "0.50635177", "text": "func verifySinature(bpr *balanceProofRequest, peerAddress common.Address, partner common.Address,chainID int) (err error) {\n\ttmpBuf := new(bytes.Buffer)\n\terr = binary.Write(tmpBuf, binary.BigEndian, bpr.BalanceProof.Nonce) //nonce\n\t_, err = tmpBuf.Write(utils.BigIntTo32Bytes(bpr.BalanceProof.TransferAmount)) //transfer_amount\n\t_, err = tmpBuf.Write(bpr.BalanceProof.LocksRoot[:]) //locksroot\n\t_, err = tmpBuf.Write(bpr.BalanceProof.ChannelID[:]) //channel_id\n\terr = binary.Write(tmpBuf, binary.BigEndian, bpr.BalanceProof.OpenBlockNumber) //open_block_number\n\t_, err = tmpBuf.Write(bpr.BalanceProof.AdditionalHash[:]) //additional_hash\n\n\t//检查是谁的balance proof\n\tbpBuf := new(bytes.Buffer)\n\t_, err = bpBuf.Write(smparams.ContractSignaturePrefix)\n\t_, err = bpBuf.Write([]byte(smparams.ContractBalanceProofMessageLength))\n\t_, err = bpBuf.Write(utils.BigIntTo32Bytes(bpr.BalanceProof.TransferAmount))\n\t_, err = bpBuf.Write(bpr.BalanceProof.LocksRoot[:])\n\terr = binary.Write(bpBuf, binary.BigEndian, bpr.BalanceProof.Nonce)\n\t_, err = bpBuf.Write(bpr.BalanceProof.AdditionalHash[:])\n\t_, err = bpBuf.Write(bpr.BalanceProof.ChannelID[:])\n\terr = binary.Write(bpBuf, binary.BigEndian, bpr.BalanceProof.OpenBlockNumber)\n\t_, err = bpBuf.Write(utils.BigIntTo32Bytes(big.NewInt(int64(chainID)))) //smparams.ChainID\n\tbalanceProofHash := utils.Sha3(bpBuf.Bytes())\n\tbalanceProofSignature := bpr.BalanceProof.Signature\n\tbalanceProofSigner, err := utils.Ecrecover(balanceProofHash, balanceProofSignature)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"Illegal balance proof signature\")\n\t\treturn err\n\t}\n\tif balanceProofSigner != partner {\n\t\terr = fmt.Errorf(\"Illegal balance proof signature,must give partner's balance proof\")\n\t\treturn err\n\t}\n\n\t_, err = tmpBuf.Write(bpr.BalanceProof.Signature)\n\t_, err = tmpBuf.Write(utils.BigIntTo32Bytes(bpr.LocksAmount)) //locks_amount\n\tmessageHash := utils.Sha3(tmpBuf.Bytes())\n\tmessageSignature := bpr.BalanceSignature\n\tsigner, err := utils.Ecrecover(messageHash, messageSignature)\n\tif signer != peerAddress {\n\t\terr = fmt.Errorf(\"Illegal signature of balance message\")\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "7923560df16d87850009507bc669d7bb", "score": "0.5056717", "text": "func validateProofOfStake(diff uint8,\n\tprevProofs [][crypto.COMM_PROOF_LENGTH]byte,\n\theight uint32,\n\tbalance uint64,\n\tcommitmentProof [crypto.COMM_PROOF_LENGTH]byte,\n\ttimestamp int64) bool {\n\n\tvar (\n\t\theightBuf [4]byte\n\t\ttimestampBuf [8]byte\n\t\thashArgs []byte\n\t)\n\n\t// allocate memory\n\t// n * COMM_PROOF_LENGTH bytes (prevProofs) + COMM_PROOF_LENGTH bytes (commitmentProof)+ 4 bytes (height) + 8 bytes (count)\n\thashArgs = make([]byte, len(prevProofs)*crypto.COMM_PROOF_LENGTH+crypto.COMM_PROOF_LENGTH+4+8)\n\n\tbinary.BigEndian.PutUint32(heightBuf[:], height)\n\tbinary.BigEndian.PutUint64(timestampBuf[:], uint64(timestamp))\n\n\tindex := 0\n\tfor _, prevProof := range prevProofs {\n\t\tcopy(hashArgs[index:index + crypto.COMM_PROOF_LENGTH], prevProof[:])\n\t\tindex += crypto.COMM_PROOF_LENGTH\n\t}\n\n\tcopy(hashArgs[index:index + crypto.COMM_PROOF_LENGTH], commitmentProof[:]) // COMM_KEY_LENGTH bytes\n\tindex += crypto.COMM_PROOF_LENGTH\n\tcopy(hashArgs[index:index + 4], heightBuf[:]) \t\t// 4 bytes\n\tindex += 4\n\n\tcopy(hashArgs[index:index+8], timestampBuf[:])\n\n\t//calculate the hash\n\tpos := sha3.Sum256(hashArgs[:])\n\n\tdata := binary.BigEndian.Uint64(pos[:])\n\tdata = data / balance\n\tvar buf bytes.Buffer\n\tbinary.Write(&buf, binary.BigEndian, data)\n\n\tcopy(pos[0:32], buf.Bytes())\n\n\tvar byteNr uint8\n\t//Bytes check\n\tfor byteNr = 0; byteNr < (uint8)(diff/8); byteNr++ {\n\t\tif pos[byteNr] != 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\t//Bits check\n\tif diff%8 != 0 && pos[byteNr] >= 1<<(8-diff%8) {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "8ec17e6d26b84f6eb1435ada96a19e31", "score": "0.5013662", "text": "func (blockchain *Blockchain) ValidProof(lastProof int64, proof int64) bool {\n\tguess := fmt.Sprintf(\"%d%d\", lastProof, proof)\n\tguessHash := fmt.Sprintf(\"%x\", sha256.Sum256([]byte(guess)))\n\tlog.Println(guessHash)\n\treturn guessHash[:4] == \"0000\"\n}", "title": "" }, { "docid": "c7533a50f065ddd99b86cc3b7c9e12c4", "score": "0.4962463", "text": "func (bc *Blockchain) ValidProof(nonce int, previousHash [32]byte, transactions []*Transaction, difficulty int) bool {\n\tzeros := strings.Repeat(\"0\", difficulty)\n\tguessBlock := Block{nonce, previousHash, 0, transactions}\n\tguessHashStr := fmt.Sprintf(\"%x\", guessBlock.Hash())\n\treturn guessHashStr[:difficulty] == zeros\n}", "title": "" }, { "docid": "d89686b1613f338380cc43c890387b72", "score": "0.49614835", "text": "func (v *Verifier) Verify(z *big.Int) bool {\n\tleft := v.Homomorphism(z)\n\tright := v.H.Exp(v.u, v.challenge)\n\tright = v.H.Mul(v.x, right)\n\treturn left.Cmp(right) == 0\n}", "title": "" }, { "docid": "6c3054b3ddffd9d62eba27ca009a991a", "score": "0.49336976", "text": "func p256SqrtCandidate(z, x *fiat.P256Element) {\n\t// Since p = 3 mod 4, exponentiation by (p + 1) / 4 yields a square root candidate.\n\t//\n\t// The sequence of 7 multiplications and 253 squarings is derived from the\n\t// following addition chain generated with github.com/mmcloughlin/addchain v0.4.0.\n\t//\n\t//\t_10 = 2*1\n\t//\t_11 = 1 + _10\n\t//\t_1100 = _11 << 2\n\t//\t_1111 = _11 + _1100\n\t//\t_11110000 = _1111 << 4\n\t//\t_11111111 = _1111 + _11110000\n\t//\tx16 = _11111111 << 8 + _11111111\n\t//\tx32 = x16 << 16 + x16\n\t//\treturn ((x32 << 32 + 1) << 96 + 1) << 94\n\t//\n\tvar t0 = new(fiat.P256Element)\n\n\tz.Square(x)\n\tz.Mul(x, z)\n\tt0.Square(z)\n\tfor s := 1; s < 2; s++ {\n\t\tt0.Square(t0)\n\t}\n\tz.Mul(z, t0)\n\tt0.Square(z)\n\tfor s := 1; s < 4; s++ {\n\t\tt0.Square(t0)\n\t}\n\tz.Mul(z, t0)\n\tt0.Square(z)\n\tfor s := 1; s < 8; s++ {\n\t\tt0.Square(t0)\n\t}\n\tz.Mul(z, t0)\n\tt0.Square(z)\n\tfor s := 1; s < 16; s++ {\n\t\tt0.Square(t0)\n\t}\n\tz.Mul(z, t0)\n\tfor s := 0; s < 32; s++ {\n\t\tz.Square(z)\n\t}\n\tz.Mul(x, z)\n\tfor s := 0; s < 96; s++ {\n\t\tz.Square(z)\n\t}\n\tz.Mul(x, z)\n\tfor s := 0; s < 94; s++ {\n\t\tz.Square(z)\n\t}\n}", "title": "" }, { "docid": "d2faeb9bcd807dd0356da8d702d7b2a7", "score": "0.49086717", "text": "func (bc Blockchain) proofOfWork(previousProof int) int {\r\n\tnewProof := 1\r\n\tcheckProof := false\r\n\tfor !checkProof {\r\n\t\t//Hash Operation\r\n\t\thashBytes := sha256.Sum256([]byte(strconv.Itoa(int(math.Pow(float64(newProof), 2) - math.Pow(float64(previousProof), 2)))))\r\n\t\thash := hex.EncodeToString(hashBytes[:])\r\n\t\tif string(hash[:4]) == \"0000\" {\r\n\t\t\tcheckProof = true\r\n\t\t} else {\r\n\t\t\tnewProof++\r\n\t\t}\r\n\r\n\t}\r\n\treturn newProof\r\n}", "title": "" }, { "docid": "719607a3414bf5c3eb8c23bb78a466ce", "score": "0.4872992", "text": "func VerifyProof(email string, proof, salt, storedVerificationHash []byte) bool {\n\tcomputedVerificationHash := VerificationHash(email, proof, salt)\n\treturn bytes.Equal(computedVerificationHash, storedVerificationHash)\n}", "title": "" }, { "docid": "8ac2459d8895bff1386b60829dcd199b", "score": "0.48693234", "text": "func (p *Pythia) Prove(transformedPassword, blindedPassword, transformedTweak, transformationPrivateKey, transformationPublicKey []byte) (proofValueC, proofValueU []byte, err error) {\n\n defer func() {\n if r := recover(); r != nil {\n var ok bool\n err, ok = r.(error)\n if !ok {\n err = fmt.Errorf(\"pkg: %v\", r)\n }\n }\n }()\n\n C.vscp_pythia_init(p.ctx)\n defer C.vscp_pythia_cleanup(p.ctx)\n\n proofValueCBuf := NewBuf(C.vscp_pythia_proof_value_buf_len())\n proofValueUBuf := NewBuf(C.vscp_pythia_proof_value_buf_len())\n\n pErr := C.vscp_pythia_prove(p.ctx, WrapData(transformedPassword), WrapData(blindedPassword), WrapData(transformedTweak), WrapData(transformationPrivateKey), WrapData(transformationPublicKey), proofValueCBuf.ctx, proofValueUBuf.ctx)\n if pErr != C.vscp_SUCCESS {\n err = errors.New(\"Internal Pythia error\")\n return\n }\n\n proofValueC = proofValueCBuf.GetData()\n proofValueU = proofValueUBuf.GetData()\n return\n}", "title": "" }, { "docid": "1cec5ba1787141fa8e2cfeff656c8d6a", "score": "0.48606494", "text": "func TestCheckProofOfWorkHash(t *testing.T) {\n\ttests := []struct {\n\t\tname string // test description\n\t\thash string // proof of work hash to test\n\t\tbits uint32 // compact target difficulty bits to test\n\t\terr error // expected error\n\t}{{\n\t\tname: \"mainnet block 1 pow hash\",\n\t\thash: \"000000000000437482b6d47f82f374cde539440ddb108b0a76886f0d87d126b9\",\n\t\tbits: 0x1b01ffff,\n\t\terr: nil,\n\t}, {\n\t\tname: \"mainnet block 288 pow hash\",\n\t\thash: \"000000000000e0ab546b8fc19f6d94054d47ffa5fe79e17611d170662c8b702b\",\n\t\tbits: 0x1b01330e,\n\t\terr: nil,\n\t}, {\n\t\tname: \"high hash\",\n\t\thash: \"000000000001ffff000000000000000000000000000000000000000000000001\",\n\t\tbits: 0x1b01ffff,\n\t\terr: ErrHighHash,\n\t}}\n\n\tfor _, test := range tests {\n\t\thash, err := chainhash.NewHashFromStr(test.hash)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"%q: unexpected err parsing test hash: %v\", test.name, err)\n\t\t\tcontinue\n\t\t}\n\n\t\terr = CheckProofOfWorkHash(hash, test.bits)\n\t\tif !errors.Is(err, test.err) {\n\t\t\tt.Errorf(\"%q: unexpected err -- got %v, want %v\", test.name, err,\n\t\t\t\ttest.err)\n\t\t\tcontinue\n\t\t}\n\t}\n}", "title": "" }, { "docid": "ecf32d9d90b4508f9e1315c08ae173ec", "score": "0.4840855", "text": "func (pow *PoW) ComputeProof(){\n\tnonce := int64(0)\n\ttarget := newTarget(pow.TargetBits)\n\tmaxNonce := int64(math.MaxInt64)\n\tfor nonce <= maxNonce{\n\t\t\t\tvar hashInt big.Int\n\t\thashInt.SetBytes(Hash(pow.Block.Serialize()))\n\t\tif hashInt.Cmp(target) == -1 {\n\t\t\tpow.Nonce = nonce\n\t\t\tpow.Block.Nonce = nonce\n\t\t\tbreak\n\t\t}\n\t\tnonce++\n\t\tpow.Block.Nonce = nonce\n\t}\n}", "title": "" }, { "docid": "9488afcf41e859ebe537b464aab7378a", "score": "0.48172408", "text": "func Verify(password, phc string) error {\n\tif len(password) == 0 || len(phc) == 0 {\n\t\treturn errors.New(\"arguments len cannot be zero\")\n\t}\n\tparts := strings.Split(phc[1:], \"$\")\n\tif len(parts) != 4 {\n\t\treturn errors.New(\"invalid hash format\")\n\t}\n\tvar (\n\t\tpid = parts[0]\n\t\tparams = parts[1]\n\t\tsalt = parts[2]\n\t\tencodedHash = parts[3]\n\t)\n\tif pid != id {\n\t\treturn errors.New(\"unknown password hashing function identifier\")\n\t}\n\thash, err := base64.StdEncoding.DecodeString(encodedHash)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tre := regexp.MustCompile(`^m=([0-9]+),t=([0-9]+),p=([0-9]+)$`)\n\tvalues := re.FindStringSubmatch(params)\n\tif len(values) != 4 {\n\t\treturn errors.New(\"incorrect params length\")\n\t}\n\n\tvar (\n\t\t// The first match is the match of the entire expression.\n\t\tm, _ = strconv.ParseUint(values[1], 10, 32)\n\t\tt, _ = strconv.ParseUint(values[2], 10, 32)\n\t\tp, _ = strconv.ParseUint(values[3], 10, 8)\n\t)\n\n\tcomputedHash := argon2.IDKey([]byte(password), []byte(salt), uint32(t), uint32(m), uint8(p), keyLen)\n\tif subtle.ConstantTimeCompare(hash, computedHash) != 1 {\n\t\treturn errors.New(\"password do not match\")\n\t}\n\treturn nil\n\n}", "title": "" }, { "docid": "328d356dc196d839f7310bb04d6d1283", "score": "0.48139256", "text": "func tryProof(payId pay.PayId, clientNonce []byte) TrackingStatus {\n\n\tglobalData.RLock()\n\tr, ok := globalData.pendingFreeIssues[payId]\n\tglobalData.RUnlock()\n\n\tif !ok {\n\t\tglobalData.log.Debugf(\"tryProof: issue item not found\")\n\t\treturn TrackingNotFound\n\t}\n\n\tif nil == r.difficulty { // only payment tracking; proof not allowed\n\t\tglobalData.log.Debugf(\"tryProof: item with out a difficulty\")\n\t\treturn TrackingInvalid\n\t}\n\n\t// convert difficulty\n\tbigDifficulty := r.difficulty.BigInt()\n\n\tglobalData.log.Infof(\"tryProof: difficulty: 0x%064x\", bigDifficulty)\n\n\t// compute hash with all possible payNonces\n\th := sha3.New256()\n\n\t// start with the current rounded height and\n\t// later decrement it by the delta value\n\theight := PayNonceRoundedHeight()\n\n\t// at 2 min/block 128 blocks is 4 hours\n\t// so 6 loops is 1 day\ntry_loop:\n\tfor i := uint64(0); i < 6; i += 1 {\n\n\t\tpayNonce := PayNonceFromBlock(height)\n\n\t\tglobalData.log.Debugf(\"tryProof: payNonce[%d]@%d: %x\", i, height, payNonce)\n\n\t\th.Reset()\n\t\th.Write(payId[:])\n\t\th.Write(payNonce[:])\n\t\th.Write(clientNonce)\n\t\tvar digest [32]byte\n\t\th.Sum(digest[:0])\n\n\t\t//globalData.log.Debugf(\"tryProof: digest: %x\", digest)\n\n\t\t// convert to big integer from BE byte slice\n\t\tbigDigest := new(big.Int).SetBytes(digest[:])\n\n\t\tglobalData.log.Debugf(\"tryProof: digest: 0x%064x\", bigDigest)\n\n\t\t// check difficulty and verify if ok\n\t\tif bigDigest.Cmp(bigDifficulty) <= 0 {\n\t\t\tglobalData.log.Debugf(\"tryProof: success: pay id: %s\", payId)\n\t\t\tverifyIssueByNonce(payId, clientNonce)\n\t\t\treturn TrackingAccepted\n\t\t}\n\n\t\tif height < PayNonceHeightDelta {\n\t\t\tbreak try_loop\n\t\t}\n\t\theight -= PayNonceHeightDelta\n\t}\n\n\treturn TrackingInvalid\n}", "title": "" }, { "docid": "ad3f2b13dc68f4c4c9f3e8e66bf9294c", "score": "0.48135236", "text": "func (_Airdrop *AirdropSession) VerifyProof(_h [32]byte, _v uint8, _r [32]byte, _s [32]byte) (common.Address, error) {\n\treturn _Airdrop.Contract.VerifyProof(&_Airdrop.CallOpts, _h, _v, _r, _s)\n}", "title": "" }, { "docid": "9824c492291d8c675c976199de33c2f1", "score": "0.48084918", "text": "func TestProver_GenerateProof(t *testing.T) {\n\tr := require.New(t)\n\n\tfor numUnits := uint(cfg.MinNumUnits); numUnits < 6; numUnits++ {\n\t\tnewOpts := opts\n\t\tnewOpts.NumUnits = numUnits\n\n\t\tinit, err := NewInitializer(cfg, newOpts, id)\n\t\tr.NoError(err)\n\t\terr = init.Initialize()\n\t\tr.NoError(err)\n\n\t\tp, err := NewProver(cfg, opts.DataDir, id)\n\t\tr.NoError(err)\n\t\tif *log {\n\t\t\tp.SetLogger(smlog.AppLog)\n\t\t}\n\n\t\tbinary.BigEndian.PutUint64(ch, uint64(numUnits))\n\t\tproof, proofMetaData, err := p.GenerateProof(ch)\n\t\tr.NoError(err, fmt.Sprintf(\"numUnits: %d\", numUnits))\n\t\tr.NotNil(proof)\n\t\tr.NotNil(proofMetaData)\n\n\t\tr.Equal(id, proofMetaData.ID)\n\t\tr.Equal(ch, proofMetaData.Challenge)\n\t\tr.Equal(cfg.BitsPerLabel, proofMetaData.BitsPerLabel)\n\t\tr.Equal(cfg.LabelsPerUnit, proofMetaData.LabelsPerUnit)\n\t\tr.Equal(numUnits, proofMetaData.NumUnits)\n\t\tr.Equal(cfg.K1, proofMetaData.K1)\n\t\tr.Equal(cfg.K2, proofMetaData.K2)\n\n\t\tnumLabels := uint64(cfg.LabelsPerUnit * numUnits)\n\t\tindexBitSize := uint(shared.NumBits(numLabels))\n\t\tr.Equal(shared.Size(indexBitSize, p.cfg.K2), uint(len(proof.Indices)))\n\n\t\tif *debug {\n\t\t\tfmt.Printf(\"numLabels: %v, indices size: %v\\n\", numLabels, len(proof.Indices))\n\t\t}\n\n\t\terr = verifying.Verify(proof, proofMetaData)\n\t\tr.NoError(err)\n\n\t\t// Cleanup.\n\t\terr = init.Reset()\n\t\tr.NoError(err)\n\t}\n}", "title": "" }, { "docid": "13d094b6c65e08a00cd076eca6ca4a4d", "score": "0.48042545", "text": "func (p *MembershipProver) Prove() (*MembershipProof, error) {\n\tproof := &MembershipProof{}\n\tproof.Commitment = p.CommitmentToValue\n\n\tvar err error\n\t// obfuscate Pointcheval-Sanders signature\n\tobfuscatedSignature, err := p.obfuscateSignature()\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to generate membership proof\")\n\t}\n\t// compute hash of value\n\tif p.witness.value == nil {\n\t\treturn nil, errors.New(\"failed to generate membership proof: nil value\")\n\t}\n\tp.witness.hash = p.Curve.HashToZr(p.witness.value.Bytes())\n\n\t// compute randomness and commitment to randomness\n\tcommitment, randomness, err := p.computeCommitment(obfuscatedSignature.randomizedWitnessSignature)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to generate membership proof\")\n\t}\n\n\t// compute challenge\n\tproof.Challenge, err = p.computeChallenge(proof.Commitment, commitment, obfuscatedSignature.obfuscatedSig)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to generate membership proof\")\n\t}\n\n\tif p.witness == nil {\n\t\treturn nil, errors.New(\"please initialize witness of membership proof\")\n\t}\n\t// generate ZK proof\n\tsp := &common.SchnorrProver{Witness: []*math.Zr{p.witness.value, p.witness.comBlindingFactor, p.witness.hash, obfuscatedSignature.blindingFactor}, Randomness: []*math.Zr{randomness.value, randomness.comBlindingFactor, randomness.hash, randomness.sigBlindingFactor}, Challenge: proof.Challenge, SchnorrVerifier: &common.SchnorrVerifier{Curve: p.Curve}}\n\tproofs, err := sp.Prove()\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to generate membership proof\")\n\t}\n\n\t// instantiate proof\n\tproof.Signature = obfuscatedSignature.obfuscatedSig\n\tproof.Value = proofs[0]\n\tproof.ComBlindingFactor = proofs[1]\n\tproof.Hash = proofs[2]\n\tproof.SigBlindingFactor = proofs[3]\n\n\treturn proof, nil\n}", "title": "" }, { "docid": "939ba69f1149a3663a1de7b435f343fd", "score": "0.4782406", "text": "func (p *Proof) VerifyVRFProof() (bool, error) {\n\tif !p.WellFormed() {\n\t\treturn false, fmt.Errorf(\"badly-formatted proof\")\n\t}\n\th, err := HashToCurve(p.PublicKey, p.Seed, func(*big.Int) {})\n\tif err != nil {\n\t\treturn false, err\n\t}\n\terr = checkCGammaNotEqualToSHash(p.C, p.Gamma, p.S, h)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"c*γ = s*hash (disallowed in solidity verifier)\")\n\t}\n\t// publicKey = secretKey*Generator. See GenerateProof for u, v, m, s\n\t// c*secretKey*Generator + (m - c*secretKey)*Generator = m*Generator = u\n\tuPrime := linearCombination(p.C, p.PublicKey, p.S, Generator)\n\t// c*secretKey*h + (m - c*secretKey)*h = m*h = v\n\tvPrime := linearCombination(p.C, p.Gamma, p.S, h)\n\tuWitness := secp256k1.EthereumAddress(uPrime)\n\tcPrime := ScalarFromCurvePoints(h, p.PublicKey, p.Gamma, uWitness, vPrime)\n\toutput := utils.MustHash(string(append(\n\t\tvrfRandomOutputHashPrefix, secp256k1.LongMarshal(p.Gamma)...)))\n\treturn equal(p.C, cPrime) && equal(p.Output, output.Big()), nil\n}", "title": "" }, { "docid": "da9a11673e3b6b2cf1c85a47002b846d", "score": "0.47772565", "text": "func (bc *Blockchain) ValidProof(lastProof, proof int64) bool {\n\tguess := fmt.Sprintf(\"%d%d\", lastProof, proof)\n\tguessHash := CalHashSha256([]byte(guess))\n\treturn guessHash[:4] == \"0000\"\n}", "title": "" }, { "docid": "2e1ce53d1947c4cacfc2a98e27b027be", "score": "0.47577283", "text": "func (_Airdrop *AirdropCaller) VerifyProof(opts *bind.CallOpts, _h [32]byte, _v uint8, _r [32]byte, _s [32]byte) (common.Address, error) {\n\tvar (\n\t\tret0 = new(common.Address)\n\t)\n\tout := ret0\n\terr := _Airdrop.contract.Call(opts, out, \"verifyProof\", _h, _v, _r, _s)\n\treturn *ret0, err\n}", "title": "" }, { "docid": "c4723a22905e945391ff089f292950b1", "score": "0.4751205", "text": "func Milenage_check(opc, k, sqn, _rand, autn, ik, ck, res []uint8, res_len *uint, auts []uint8) int {\n\n\tmac_a, ak, rx_sqn := make([]uint8, 8), make([]uint8, 6), make([]uint8, 6)\n\tvar amf []uint8\n\n\t// fmt.Println(mac_a, amf)\n\n\t/* TODO\n\td_trace(1, \"Milenage: AUTN\\n\"); d_trace_hex(1, autn, 16);\n\td_trace(1, \"Milenage: RAND\\n\"); d_trace_hex(1, _rand, 16);\n\t*/\n\n\tif milenageF2345(opc, k, _rand, res, ck, ik, ak, nil) != nil {\n\t\treturn -1\n\t}\n\t/*\n\t\tif (milenage_f2345(opc, k, _rand, res, ck, ik, ak, NULL))\n\t\t\treturn -1;\n\t*/\n\n\t*res_len = 8\n\t/* TODO\n\td_trace(1, \"Milenage: RES\\n\"); d_trace_hex(1, res, *res_len);\n\td_trace(1, \"Milenage: CK\\n\"); d_trace_hex(1, ck, 16);\n\td_trace(1, \"Milenage: IK\\n\"); d_trace_hex(1, ik, 16);\n\td_trace(1, \"Milenage: AK\\n\"); d_trace_hex(1, ak, 6);\n\t*/\n\n\t/* AUTN = (SQN ^ AK) || AMF || MAC */\n\tfor i := 0; i < 6; i++ {\n\t\trx_sqn[i] = autn[i] ^ ak[i]\n\t}\n\t/*\n\t\tfor (i = 0; i < 6; i++)\n\t\t\trx_sqn[i] = autn[i] ^ ak[i];\n\t*/\n\n\t//TODO d_trace(1, \"Milenage: SQN\\n\"); d_trace_hex(1, rx_sqn, 6);\n\n\tif os_memcmp(rx_sqn, sqn, 6) <= 0 {\n\t\tauts_amf := []uint8{0x00, 0x00} // TS 33.102 v7.0.0, 6.3.3\n\n\t\tif milenageF2345(opc, k, _rand, nil, nil, nil, nil, ak) != nil {\n\t\t\treturn -1\n\t\t}\n\n\t\t//TODO d_trace(1, \"Milenage: AK*\\n\"); d_trace_hex(1, ak, 6);\n\n\t\tfor i := 0; i < 6; i++ {\n\t\t\tauts[i] = sqn[i] ^ ak[i]\n\t\t}\n\n\t\tif milenageF1(opc, k, _rand, sqn, auts_amf, nil, auts[6:]) != nil {\n\t\t\treturn -1\n\t\t}\n\n\t\t// TODO d_trace(1, \"Milenage: AUTS*\\n\"); d_trace_hex(1, auts, 14);\n\n\t\treturn -2\n\t}\n\t/*\n\t\tif (os_memcmp(rx_sqn, sqn, 6) <= 0) {\n\t\t\tc_uint8_t auts_amf[2] = { 0x00, 0x00 }; // TS 33.102 v7.0.0, 6.3.3\n\t\t\tif (milenage_f2345(opc, k, _rand, NULL, NULL, NULL, NULL, ak))\n\t\t\treturn -1;\n\t\t\td_trace(1, \"Milenage: AK*\\n\"); d_trace_hex(1, ak, 6);\n\n\n\n\t\t\tfor (i = 0; i < 6; i++)\n\t\t\t\tauts[i] = sqn[i] ^ ak[i];\n\t\t\tif (milenage_f1(opc, k, _rand, sqn, auts_amf, NULL, auts + 6))\n\t\t\t\treturn -1;\n\t\t\td_trace(1, \"Milenage: AUTS*\\n\"); d_trace_hex(1, auts, 14);\n\t\treturn -2;\n\t\t}\n\t*/\n\n\tamf = autn[6:]\n\t//TODO d_trace(1, \"Milenage: AMF\\n\"); d_trace_hex(1, amf, 2);\n\n\tif milenageF1(opc, k, _rand, rx_sqn, amf, mac_a, nil) != nil {\n\t\treturn -1\n\t}\n\t//TODO d_trace(1, \"Milenage: MAC_A\\n\"); d_trace_hex(1, mac_a, 8);\n\n\tif os_memcmp(mac_a, autn[8:], 8) != 0 {\n\t\t//TODO d_trace(1, \"Milenage: MAC mismatch\\n\");\n\t\t//TODO d_trace(1, \"Milenage: Received MAC_A\\n\"); d_trace_hex(1, autn + 8, 8);\n\n\t\treturn -1\n\t}\n\t/*\n\t\tamf = autn + 6;\n\t\td_trace(1, \"Milenage: AMF\\n\"); d_trace_hex(1, amf, 2);\n\t\tif (milenage_f1(opc, k, _rand, rx_sqn, amf, mac_a, NULL))\n\t\t\treturn -1;\n\n\t\td_trace(1, \"Milenage: MAC_A\\n\"); d_trace_hex(1, mac_a, 8);\n\n\t\tif (os_memcmp_const(mac_a, autn + 8, 8) != 0) {\n\t\t\td_trace(1, \"Milenage: MAC mismatch\\n\");\n\t\t\td_trace(1, \"Milenage: Received MAC_A\\n\"); d_trace_hex(1, autn + 8, 8);\n\t\t\treturn -1;\n\t\t}\n\t*/\n\n\treturn 0\n}", "title": "" }, { "docid": "ed1f51981db093e2647b116bc7238c4f", "score": "0.47449118", "text": "func (setup *SetupServerController) handlePairVerify(in util.Container) (util.Container, error) {\n\tsetup.step = PairStepVerifyResponse\n\tout := util.NewTLV8Container()\n\tout.SetByte(TagSequence, setup.step.Byte())\n\n\tclientPublicKey := in.GetBytes(TagPublicKey)\n\tlog.Debug.Println(\"-> A:\", hex.EncodeToString(clientPublicKey))\n\n\terr := setup.session.SetupPrivateKeyFromClientPublicKey(clientPublicKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclientProof := in.GetBytes(TagProof)\n\tlog.Debug.Println(\"-> M1:\", hex.EncodeToString(clientProof))\n\n\tproof, err := setup.session.ProofFromClientProof(clientProof)\n\tif err != nil || len(proof) == 0 { // proof `M1` is wrong\n\t\tlog.Debug.Println(\"Proof M1 is wrong\")\n\t\tsetup.reset()\n\t\tout.SetByte(TagErrCode, ErrCodeAuthenticationFailed.Byte()) // return error 2\n\t} else {\n\t\tlog.Debug.Println(\"Proof M1 is valid\")\n\t\terr := setup.session.SetupEncryptionKey([]byte(\"Pair-Setup-Encrypt-Salt\"), []byte(\"Pair-Setup-Encrypt-Info\"))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// Return proof `M2`\n\t\tout.SetBytes(TagProof, proof)\n\t}\n\n\tlog.Debug.Println(\"<- M2:\", hex.EncodeToString(out.GetBytes(TagProof)))\n\tlog.Debug.Println(\" S:\", hex.EncodeToString(setup.session.PrivateKey))\n\tlog.Debug.Println(\" K:\", hex.EncodeToString(setup.session.EncryptionKey[:]))\n\n\treturn out, nil\n}", "title": "" }, { "docid": "8609138cb18c815c4179232ae653bb57", "score": "0.47408685", "text": "func (dag *BlockDAG) checkProofOfWork(header *domainmessage.BlockHeader, flags BehaviorFlags) error {\n\t// The target difficulty must be larger than zero.\n\ttarget := util.CompactToBig(header.Bits)\n\tif target.Sign() <= 0 {\n\t\tstr := fmt.Sprintf(\"block target difficulty of %064x is too low\",\n\t\t\ttarget)\n\t\treturn ruleError(ErrUnexpectedDifficulty, str)\n\t}\n\n\t// The target difficulty must be less than the maximum allowed.\n\tif target.Cmp(dag.Params.PowMax) > 0 {\n\t\tstr := fmt.Sprintf(\"block target difficulty of %064x is \"+\n\t\t\t\"higher than max of %064x\", target, dag.Params.PowMax)\n\t\treturn ruleError(ErrUnexpectedDifficulty, str)\n\t}\n\n\t// The block hash must be less than the claimed target unless the flag\n\t// to avoid proof of work checks is set.\n\tif flags&BFNoPoWCheck != BFNoPoWCheck {\n\t\t// The block hash must be less than the claimed target.\n\t\thash := header.BlockHash()\n\t\thashNum := daghash.HashToBig(hash)\n\t\tif hashNum.Cmp(target) > 0 {\n\t\t\tstr := fmt.Sprintf(\"block hash of %064x is higher than \"+\n\t\t\t\t\"expected max of %064x\", hashNum, target)\n\t\t\treturn ruleError(ErrHighHash, str)\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "08340f85071954722e29eeebf0b42ea4", "score": "0.47254962", "text": "func TestCheckProofOfWorkRange(t *testing.T) {\n\ttests := []struct {\n\t\tname string // test description\n\t\tbits uint32 // compact target difficulty bits to test\n\t\tpowLimit string // proof of work limit\n\t\terr error // expected error\n\t}{{\n\t\tname: \"mainnet block 1\",\n\t\tbits: 0x1b01ffff,\n\t\tpowLimit: mockMainNetPowLimit(),\n\t\terr: nil,\n\t}, {\n\t\tname: \"mainnet block 288\",\n\t\tbits: 0x1b01330e,\n\t\tpowLimit: mockMainNetPowLimit(),\n\t\terr: nil,\n\t}, {\n\t\tname: \"smallest allowed\",\n\t\tbits: 0x1010000,\n\t\tpowLimit: mockMainNetPowLimit(),\n\t\terr: nil,\n\t}, {\n\t\tname: \"max allowed (exactly the pow limit)\",\n\t\tbits: 0x1d00ffff,\n\t\tpowLimit: mockMainNetPowLimit(),\n\t\terr: nil,\n\t}, {\n\t\tname: \"zero\",\n\t\tbits: 0,\n\t\tpowLimit: mockMainNetPowLimit(),\n\t\terr: ErrUnexpectedDifficulty,\n\t}, {\n\t\tname: \"negative\",\n\t\tbits: 0x1810000,\n\t\tpowLimit: mockMainNetPowLimit(),\n\t\terr: ErrUnexpectedDifficulty,\n\t}, {\n\t\tname: \"pow limit + 1\",\n\t\tbits: 0x1d010000,\n\t\tpowLimit: mockMainNetPowLimit(),\n\t\terr: ErrUnexpectedDifficulty,\n\t}}\n\n\tfor _, test := range tests {\n\t\tpowLimit, success := new(big.Int).SetString(test.powLimit, 16)\n\t\tif !success {\n\t\t\tt.Errorf(\"%q: unexpected err parsing test pow limit\", test.name)\n\t\t\tcontinue\n\t\t}\n\n\t\terr := CheckProofOfWorkRange(test.bits, powLimit)\n\t\tif !errors.Is(err, test.err) {\n\t\t\tt.Errorf(\"%q: unexpected err -- got %v, want %v\", test.name, err,\n\t\t\t\ttest.err)\n\t\t\tcontinue\n\t\t}\n\t}\n}", "title": "" }, { "docid": "43791cf03ead9b21dea10363193c53b0", "score": "0.47253695", "text": "func (_Airdrop *AirdropCallerSession) VerifyProof(_h [32]byte, _v uint8, _r [32]byte, _s [32]byte) (common.Address, error) {\n\treturn _Airdrop.Contract.VerifyProof(&_Airdrop.CallOpts, _h, _v, _r, _s)\n}", "title": "" }, { "docid": "27348d682e6feccbfc2e6f5298457a06", "score": "0.47022846", "text": "func (s *scram) checkProof(proof []byte) bool {\n\tif len(s.salted_password) == 0 {\n\t\tpanic(\"Salt password first\") // TODO refactor this\n\t}\n\n\tstorek := s.getHash(s.getClientKey())\n\n\tclient_sig := s.getClientSignature(s.authMessage(), storek)\n\n\trck := byteXOR(client_sig, proof)\n\n\treturn bytes.Equal(s.getHash(rck), storek)\n}", "title": "" }, { "docid": "fd7df80125dfc6197efb7c902e0775d3", "score": "0.46892282", "text": "func (prover *SchnorrProver) GetProofData(challenge *big.Int) (*big.Int, *big.Int) {\n\t// z = r + challenge * w\n\tz := new(big.Int)\n\tz.Mul(challenge, prover.secret)\n\tz.Add(z, prover.r)\n\tz.Mod(z, prover.Group.Q)\n\n\tif prover.protocolType != protocoltypes.ZKPOK {\n\t\treturn z, nil\n\t} else {\n\t\ttrapdoor := prover.PedersenReceiver.GetTrapdoor()\n\t\treturn z, trapdoor\n\t}\n}", "title": "" }, { "docid": "14bab030cb67d3b1706267dc5034f24a", "score": "0.4680899", "text": "func ProveUL(x, r *big.Int, cm *bn256.G2, p paramsUL) (proofUL, error) {\n\tvar (\n\t\ti int64\n\t\tv []*big.Int\n\t\tproof_out proofUL\n\t)\n\tdecx, _ := Decompose(x, p.u, p.l)\n\n\t// Initialize variables\n\tv = make([]*big.Int, p.l, p.l)\n\tproof_out.V = make([]*bn256.G2, p.l, p.l)\n\tproof_out.a = make([]*bn256.GT, p.l, p.l)\n\tproof_out.s = make([]*big.Int, p.l, p.l)\n\tproof_out.t = make([]*big.Int, p.l, p.l)\n\tproof_out.zsig = make([]*big.Int, p.l, p.l)\n\tproof_out.zv = make([]*big.Int, p.l, p.l)\n\tproof_out.D = new(bn256.G2)\n\tproof_out.D.SetInfinity()\n\tproof_out.m, _ = rand.Int(rand.Reader, bn256.Order)\n\n\t// D = H^m\n\tD := new(bn256.G2).ScalarMult(p.H, proof_out.m)\n\tfor i = 0; i < p.l; i++ {\n\t\tv[i], _ = rand.Int(rand.Reader, bn256.Order)\n\t\tA, ok := p.signatures[strconv.FormatInt(decx[i], 10)]\n\t\tif ok {\n\t\t\tproof_out.V[i] = new(bn256.G2).ScalarMult(A, v[i])\n\t\t\tproof_out.s[i], _ = rand.Int(rand.Reader, bn256.Order)\n\t\t\tproof_out.t[i], _ = rand.Int(rand.Reader, bn256.Order)\n\t\t\tproof_out.a[i] = bn256.Pair(G1, proof_out.V[i])\n\t\t\tproof_out.a[i].ScalarMult(proof_out.a[i], proof_out.s[i])\n\t\t\tproof_out.a[i].Invert(proof_out.a[i])\n\t\t\tproof_out.a[i].Add(proof_out.a[i], new(bn256.GT).ScalarMult(E, proof_out.t[i]))\n\n\t\t\tui := new(big.Int).Exp(new(big.Int).SetInt64(p.u), new(big.Int).SetInt64(i), nil)\n\t\t\tmuisi := new(big.Int).Mul(proof_out.s[i], ui)\n\t\t\tmuisi = Mod(muisi, bn256.Order)\n\t\t\taux := new(bn256.G2).ScalarBaseMult(muisi)\n\t\t\tD.Add(D, aux)\n\t\t} else {\n\t\t\treturn proof_out, errors.New(\"Could not generate proof. Element does not belong to the interval.\")\n\t\t}\n\t}\n\tproof_out.D.Add(proof_out.D, D)\n\n\t// Consider passing C as input,\n\t// so that it is possible to delegate the commitment computation to an external party.\n\tproof_out.C = cm //Commit(x, r, p.H)\n\t// Fiat-Shamir heuristic\n\tproof_out.c, _ = Hash(proof_out.a, proof_out.D)\n\tproof_out.c = Mod(proof_out.c, bn256.Order)\n\n\tproof_out.zr = Sub(proof_out.m, Multiply(r, proof_out.c))\n\tproof_out.zr = Mod(proof_out.zr, bn256.Order)\n\tfor i = 0; i < p.l; i++ {\n\t\tproof_out.zsig[i] = Sub(proof_out.s[i], Multiply(new(big.Int).SetInt64(decx[i]), proof_out.c))\n\t\tproof_out.zsig[i] = Mod(proof_out.zsig[i], bn256.Order)\n\t\tproof_out.zv[i] = Sub(proof_out.t[i], Multiply(v[i], proof_out.c))\n\t\tproof_out.zv[i] = Mod(proof_out.zv[i], bn256.Order)\n\t}\n\treturn proof_out, nil\n}", "title": "" }, { "docid": "e2fd691101bd2bc19241d20015ec8ef8", "score": "0.4678513", "text": "func VerifyProof(h hash.Hash, merkleRoot []byte, proofSet [][]byte, proofIndex uint64, numLeaves uint64) bool {\n\t// Return false for nonsense input. A switch statement is used so that the\n\t// cover tool will reveal if a case is not covered by the test suite. This\n\t// would not be possible using a single if statement due to the limitations\n\t// of the cover tool.\n\tswitch {\n\tcase merkleRoot == nil:\n\t\treturn false\n\tcase proofIndex >= numLeaves:\n\t\treturn false\n\t}\n\n\t// In a Merkle tree, every node except the root node has a sibling.\n\t// Combining the two siblings in the correct order will create the parent\n\t// node. Each of the remaining hashes in the proof set is a sibling to a\n\t// node that can be built from all of the previous elements of the proof\n\t// set. The next node is built by taking:\n\t//\n\t//\t\tH(0x01 || sibling A || sibling B)\n\t//\n\t// The difficulty of the algorithm lies in determining whether the supplied\n\t// hash is sibling A or sibling B. This information can be determined by\n\t// using the proof index and the total number of leaves in the tree.\n\t//\n\t// A pair of two siblings forms a subtree. The subtree is complete if it\n\t// has 1 << height total leaves. When the subtree is complete, the position\n\t// of the proof index within the subtree can be determined by looking at\n\t// the bounds of the subtree and determining if the proof index is in the\n\t// first or second half of the subtree.\n\t//\n\t// When the subtree is not complete, either 1 or 0 of the remaining hashes\n\t// will be sibling B. All remaining hashes after that will be sibling A.\n\t// This is true because of the way that orphans are merged into the Merkle\n\t// tree - an orphan at height n is elevated to height n + 1, and only\n\t// hashed when it is no longer an orphan. Each subtree will therefore merge\n\t// with at most 1 orphan to the right before becoming an orphan itself.\n\t// Orphan nodes are always merged with larger subtrees to the left.\n\t//\n\t// One vulnerability with the proof verification is that the proofSet may\n\t// not be long enough. Before looking at an element of proofSet, a check\n\t// needs to be made that the element exists.\n\n\t// The first element of the set is the original data. A sibling at height 1\n\t// is created by getting the leafSum of the original data.\n\theight := 0\n\tif len(proofSet) <= height {\n\t\treturn false\n\t}\n\tsum := leafSum(h, proofSet[height])\n\theight++\n\n\t// While the current subtree (of height 'height') is complete, determine\n\t// the position of the next sibling using the complete subtree algorithm.\n\t// 'stableEnd' tells us the ending index of the last full subtree. It gets\n\t// initialized to 'proofIndex' because the first full subtree was the\n\t// subtree of height 1, created above (and had an ending index of\n\t// 'proofIndex').\n\tstableEnd := proofIndex\n\tfor {\n\t\t// Determine if the subtree is complete. This is accomplished by\n\t\t// rounding down the proofIndex to the nearest 1 << 'height', adding 1\n\t\t// << 'height', and comparing the result to the number of leaves in the\n\t\t// Merkle tree.\n\t\tsubTreeStartIndex := (proofIndex / (1 << uint(height))) * (1 << uint(height)) // round down to the nearest 1 << height\n\t\tsubTreeEndIndex := subTreeStartIndex + (1 << (uint(height))) - 1 // subtract 1 because the start index is inclusive\n\t\tif subTreeEndIndex >= numLeaves {\n\t\t\t// If the Merkle tree does not have a leaf at index\n\t\t\t// 'subTreeEndIndex', then the subtree of the current height is not\n\t\t\t// a complete subtree.\n\t\t\tbreak\n\t\t}\n\t\tstableEnd = subTreeEndIndex\n\n\t\t// Determine if the proofIndex is in the first or the second half of\n\t\t// the subtree.\n\t\tif len(proofSet) <= height {\n\t\t\treturn false\n\t\t}\n\t\tif proofIndex-subTreeStartIndex < 1<<uint(height-1) {\n\t\t\tsum = nodeSum(h, sum, proofSet[height])\n\t\t} else {\n\t\t\tsum = nodeSum(h, proofSet[height], sum)\n\t\t}\n\t\theight++\n\t}\n\n\t// Determine if the next hash belongs to an orphan that was elevated. This\n\t// is the case IFF 'stableEnd' (the last index of the largest full subtree)\n\t// is equal to the number of leaves in the Merkle tree.\n\tif stableEnd != numLeaves-1 {\n\t\tif len(proofSet) <= height {\n\t\t\treturn false\n\t\t}\n\t\tsum = nodeSum(h, sum, proofSet[height])\n\t\theight++\n\t}\n\n\t// All remaining elements in the proof set will belong to a left sibling.\n\tfor height < len(proofSet) {\n\t\tsum = nodeSum(h, proofSet[height], sum)\n\t\theight++\n\t}\n\n\t// Compare our calculated Merkle root to the desired Merkle root.\n\tif bytes.Compare(sum, merkleRoot) == 0 {\n\t\treturn true\n\t}\n\treturn false\n}", "title": "" }, { "docid": "990cf1f8d4ccfa94b0aba45efeae1461", "score": "0.4673888", "text": "func (p *Pythia) Verify(transformedPassword, blindedPassword, tweak, transformationPublicKey, proofValueC, proofValueU []byte) (err error) {\n\n defer func() {\n if r := recover(); r != nil {\n var ok bool\n err, ok = r.(error)\n if !ok {\n err = fmt.Errorf(\"pkg: %v\", r)\n }\n }\n }()\n\n C.vscp_pythia_init(p.ctx)\n defer C.vscp_pythia_cleanup(p.ctx)\n\n pErr := C.vscp_pythia_verify(p.ctx, WrapData(transformedPassword), WrapData(blindedPassword), WrapData(tweak), WrapData(transformationPublicKey), WrapData(proofValueC), WrapData(proofValueU))\n\n if pErr == C.vscp_error_VERIFICATION_FAIL {\n return errors.New(\"Verification failed\")\n }\n\n if pErr != C.vscp_SUCCESS {\n return errors.New(\"Internal Pythia error\")\n }\n\n return nil\n}", "title": "" }, { "docid": "cc2df0f5c1295790ecd196edafc4f026", "score": "0.4650328", "text": "func C38MITM(in, out chan []byte) {\n\tp, _ := big.NewInt(0).SetString(NIST1536GroupSize, 16)\n\trnd := rand.New(rand.NewSource(time.Now().UnixNano()))\n\tb := GenerateNISTDHPrivateKey1536(rnd)\n\tB := GenerateNISTDHPublicKey1536(b)\n\tsalt := GenerateRandomByteSlice(16)\n\tu := big.NewInt(0).SetBytes(GenerateRandomByteSlice(16))\n\n\t<-in //ignore username for this example\n\tA := big.NewInt(0).SetBytes(<-in)\n\tout <- salt\n\tout <- B.Bytes()\n\tout <- u.Bytes()\n\n\ttargetHmac := <-in\n\n\tdhKey := big.NewInt(0).Exp(A, b, p)\n\n\ttestPW := []byte{97, 97, 97, 97, 97, 97}\n\tfor {\n\t\tfmt.Printf(\"Testing password %v\\n\", string(testPW))\n\t\tsalted := append(salt, testPW...)\n\t\txH := sha256.Sum256(salted)\n\t\tx := big.NewInt(0).SetBytes(xH[:])\n\t\texp := big.NewInt(0).Mul(u, x)\n\t\tS := big.NewInt(0).Exp(B, exp, p)\n\t\tS.Mul(S, dhKey)\n\t\tS.Mod(S, p)\n\t\tK := sha256.Sum256(S.Bytes())\n\t\thasher := hmac.New(sha256.New, K[:])\n\t\ttestHmac := hasher.Sum(salt)\n\t\tif hmac.Equal(targetHmac, testHmac) {\n\t\t\tfmt.Printf(\"Found password: %v\\n\", string(testPW))\n\t\t\tout <- []byte(\"ERROR\")\n\t\t\treturn\n\t\t}\n\t\ttestPW[0]++\n\t\tif testPW[0] > 122 {\n\t\t\ttestPW[0] = 97\n\t\t\ttestPW[1]++\n\t\t\tif testPW[1] > 122 {\n\t\t\t\ttestPW[1] = 97\n\t\t\t\ttestPW[2]++\n\t\t\t\tif testPW[2] > 122 {\n\t\t\t\t\ttestPW[2] = 97\n\t\t\t\t\ttestPW[3]++\n\t\t\t\t\tif testPW[3] > 122 {\n\t\t\t\t\t\ttestPW[3] = 97\n\t\t\t\t\t\ttestPW[4]++\n\t\t\t\t\t\tif testPW[4] > 122 {\n\t\t\t\t\t\t\ttestPW[4] = 97\n\t\t\t\t\t\t\ttestPW[5]++\n\t\t\t\t\t\t\tif testPW[5] > 122 {\n\t\t\t\t\t\t\t\tfmt.Printf(\"Failed to find password\\n\")\n\t\t\t\t\t\t\t\tout <- []byte(\"ERROR\")\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n}", "title": "" }, { "docid": "5ab10566a23100dee457769561bd2314", "score": "0.4638752", "text": "func (p *Prover) GetProofData(challenge *big.Int) *big.Int {\n\t// z = r * v^challenge\n\tz := p.H.Exp(p.v, challenge)\n\tz = p.H.Mul(p.r, z)\n\treturn z\n}", "title": "" }, { "docid": "f86d374121b8ad593c5b024eb78a51a3", "score": "0.46237427", "text": "func VerifyBurnProof(p *CoinsProof, address []byte, merkleRoot chainhash.Hash) error {\n\tif err := verifyMerkleRoot(merkleRoot, p); err != nil {\n\t\treturn err\n\t}\n\n\tif err := verifyScript(p); err != nil {\n\t\treturn err\n\t}\n\n\tif err := verifyPkhMatchesAddress(p.Transaction.TxOut[0].PkScript, address); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "8c51e7e7f10919b5c303faa7e2e60b9e", "score": "0.46220154", "text": "func ProofFromBytes(input []byte) (proof *Proof) {\n\tvar marshal proofMarshal\n\tasn1.Unmarshal(input, &marshal)\n\n\tproof = &Proof{}\n\n\tproof.c = FP256BN.FromBytes(marshal.C)\n\tproof.resCsk = FP256BN.FromBytes(marshal.ResCsk)\n\tproof.resNym = FP256BN.FromBytes(marshal.ResNym)\n\n\tproof.rPrime = make([]interface{}, len(marshal.RPrime))\n\tfor i := 0; i < len(marshal.RPrime); i++ {\n\t\tproof.rPrime[i], _ = pointFromBytes(marshal.RPrime[i])\n\t}\n\n\tproof.resS = make([]interface{}, len(marshal.ResS))\n\tfor i := 0; i < len(marshal.ResS); i++ {\n\t\tproof.resS[i], _ = pointFromBytes(marshal.ResS[i])\n\t}\n\n\tproof.resCpk = make([]interface{}, len(marshal.ResCpk))\n\tfor i := 0; i < len(marshal.ResCpk); i++ {\n\t\tproof.resCpk[i], _ = pointFromBytes(marshal.ResCpk[i])\n\t}\n\n\tproof.resT = make([][]interface{}, len(marshal.ResT))\n\tfor i := 0; i < len(marshal.ResT); i++ {\n\t\tproof.resT[i] = make([]interface{}, len(marshal.ResT[i]))\n\t\tfor j := 0; j < len(marshal.ResT[i]); j++ {\n\t\t\tproof.resT[i][j], _ = pointFromBytes(marshal.ResT[i][j])\n\t\t}\n\t}\n\n\tproof.resA = make([][]interface{}, len(marshal.ResA))\n\tfor i := 0; i < len(marshal.ResA); i++ {\n\t\tproof.resA[i] = make([]interface{}, len(marshal.ResA[i]))\n\t\tfor j := 0; j < len(marshal.ResA[i]); j++ {\n\t\t\tproof.resA[i][j], _ = pointFromBytes(marshal.ResA[i][j])\n\t\t}\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "71057a2d7c95984743552dd4b797219b", "score": "0.45873764", "text": "func ExampleCheckProofOfWork() {\n\t// This is the pow limit for mainnet and would ordinarily come from chaincfg\n\t// params, however, it is hard coded here for the purposes of the example.\n\tl := \"00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff\"\n\tpowLimit, success := new(big.Int).SetString(l, 16)\n\tif !success {\n\t\tfmt.Println(\"invalid pow limit\")\n\t\treturn\n\t}\n\n\t// Check the proof of work for block 1 in the main chain.\n\th := \"000000000000437482b6d47f82f374cde539440ddb108b0a76886f0d87d126b9\"\n\thash, err := chainhash.NewHashFromStr(h)\n\tif err != nil {\n\t\tfmt.Printf(\"failed to parse hash: %v\\n\", err)\n\t\treturn\n\t}\n\tbits := uint32(453115903)\n\n\tif err := standalone.CheckProofOfWork(hash, bits, powLimit); err != nil {\n\t\tfmt.Printf(\"proof of work check failed: %v\\n\", err)\n\t\treturn\n\t}\n\n\t// Output:\n\t//\n}", "title": "" }, { "docid": "140521a1f71252d8e74a69ae8a30a16a", "score": "0.45689112", "text": "func (pow *proofOfWork) Validate() bool {\n\tvar intHash big.Int\n\n\tdata := pow.prepareData(pow.Block.Nonce)\n\n\thash := sha256.Sum256(data)\n\tintHash.SetBytes(hash[:])\n\n\treturn intHash.Cmp(pow.Target) == -1\n}", "title": "" }, { "docid": "fa00d09c53b980f0a34019d6df4ba68b", "score": "0.4564405", "text": "func (sk PrivateKey) Prove(m []byte) (vrf, proof []byte) {\n\tproof = sk.Sign(m)\n\tvar V [32]byte\n\tcopy(V[:], proof[:32])\n\tv := computeVrfFromV(V)\n\tvrf = make([]byte, 32)\n\tcopy(vrf, v[:])\n\treturn\n}", "title": "" }, { "docid": "9b7d96f554ad8c84b10b5ca12e0c608f", "score": "0.45316148", "text": "func OptimizedVerifyAggRangeProof(params AggRangeParams, v []*utils.ECPoint, proof *AggRangeProof) bool {\n\tn := params.Curve().Params().N\n\tm := params.Aggsize()\n\tbitsize := params.Bitsize()\n\tsize := m * bitsize\n\ty, err := utils.ComputeChallenge(n, proof.A.X, proof.A.Y, proof.S.X, proof.S.Y)\n\tif err != nil {\n\t\tlog.Warn(\"compute challenge y failed\", \"error\", err)\n\t\treturn false\n\t}\n\tymnInverse := utils.PowVector(new(big.Int).ModInverse(y, n), n, size)\n\n\tz, err := utils.ComputeChallenge(n, proof.S.X, proof.S.Y, proof.A.X, proof.A.Y)\n\tif err != nil {\n\t\tlog.Warn(\"compute challenge z failed\", \"error\", err)\n\t\treturn false\n\t}\n\tzNeg := new(big.Int).Neg(z)\n\tzNeg.Mod(zNeg, n)\n\tzSquare := new(big.Int).Exp(z, utils.Two, n)\n\n\tx, err := utils.ComputeChallenge(n, proof.T1.X, proof.T1.Y, proof.T2.X, proof.T2.Y)\n\tif err != nil {\n\t\tlog.Warn(\"compute challenge x failed\", \"error\", err)\n\t\treturn false\n\t}\n\tx2 := new(big.Int).Exp(x, utils.Two, n)\n\n\th := params.H()\n\tg := params.G()\n\tgv := params.GV()\n\thv := params.HV()\n\n\t// check g*tx + h*t ?= v*(z^2 * z^m) + g*delta + T1*x + T2*x^2. (z^m is a vector)\n\tzm := utils.PowVector(z, n, m).Times(zSquare)\n\texpect := utils.NewGeneratorVector(v).Commit(zm.GetVector())\n\n\texpect.Add(expect, new(utils.ECPoint).ScalarMult(proof.T1, x))\n\texpect.Add(expect, new(utils.ECPoint).ScalarMult(proof.T2, x2))\n\tdelta := utils.DeltaMN(y, z, n, m, bitsize)\n\texpect.Add(expect, new(utils.ECPoint).ScalarMult(g, delta))\n\n\tactual := new(utils.ECPoint).ScalarMult(g, proof.t)\n\tactual.Add(actual, new(utils.ECPoint).ScalarMult(h, proof.tx))\n\tif !expect.Equal(actual) {\n\t\tlog.Warn(\"point not equal\", \"expect x\", expect.X, \"expect y\", expect.Y, \"actual x\", actual.X, \"actual y\", actual.Y)\n\t\treturn false\n\t}\n\n\tright := new(utils.ECPoint).ScalarMult(proof.S, x)\n\tright.Add(right, proof.A)\n\n\txj := make([]*big.Int, 0)\n\txj2 := make([]*big.Int, 0)\n\txj2Inv := make([]*big.Int, 0)\n\n\tfor i := 0; i < len(proof.ipProof.l); i++ {\n\t\tl := proof.ipProof.l[i]\n\t\tr := proof.ipProof.r[i]\n\t\ttmpx, err := utils.ComputeChallenge(n, l.X, l.Y, r.X, r.Y)\n\t\tif err != nil {\n\t\t\tlog.Warn(\"compute challenge for l, r failed\", \"err\", err)\n\t\t\treturn false\n\t\t}\n\n\t\txj = append(xj, tmpx)\n\t\ttmpx2 := new(big.Int).Mul(tmpx, tmpx)\n\t\ttmpx2.Mod(tmpx2, n)\n\t\txj2 = append(xj2, tmpx2)\n\n\t\ttmpx2Inv := new(big.Int).ModInverse(tmpx2, n)\n\t\txj2Inv = append(xj2Inv, tmpx2Inv)\n\n\t\ttmpp := new(utils.ECPoint).ScalarMult(l, tmpx2)\n\t\tright.Add(right, tmpp)\n\t\ttmpp = new(utils.ECPoint).ScalarMult(r, tmpx2Inv)\n\t\tright.Add(right, tmpp)\n\t}\n\n\t// scalar mul, add.\n\ttl := make([]*big.Int, size)\n\ttr := make([]*big.Int, size)\n\trl := make([]*big.Int, size)\n\tll := make([]*big.Int, size)\n\n\tchallengeLen := len(proof.ipProof.l)\n\tn2 := utils.PowVector(new(big.Int).SetUint64(2), n, bitsize)\n\tfor i := 0; i < size; i++ {\n\t\tif i == 0 {\n\t\t\tfor j := 0; j < len(proof.ipProof.l); j++ {\n\t\t\t\tif j == 0 {\n\t\t\t\t\ttl[i] = new(big.Int).Set(xj[j])\n\t\t\t\t} else {\n\t\t\t\t\ttl[i].Mul(tl[i], xj[j])\n\t\t\t\t\ttl[i].Mod(tl[i], n)\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\ttr[i] = new(big.Int).Set(tl[i])\n\t\t\ttl[i] = tl[i].ModInverse(tl[i], n)\n\t\t} else {\n\t\t\tk := utils.GetBiggestPos(i, challengeLen)\n\t\t\ttl[i] = new(big.Int).Mul(tl[i-utils.Pow(k-1)], xj2[challengeLen-k])\n\t\t\ttl[i].Mod(tl[i], n)\n\n\t\t\ttr[i] = new(big.Int).Mul(tr[i-utils.Pow(k-1)], xj2Inv[challengeLen-k])\n\t\t\ttr[i].Mod(tr[i], n)\n\t\t}\n\n\t\tll[i] = new(big.Int).Set(tl[i])\n\t\trl[i] = new(big.Int).Set(tr[i])\n\n\t\tll[i] = ll[i].Mul(ll[i], proof.ipProof.a)\n\t\tll[i].Mod(ll[i], n)\n\t\tll[i].Add(ll[i], z)\n\t\tll[i].Mod(ll[i], n)\n\n\t\trl[i] = rl[i].Mul(rl[i], proof.ipProof.b)\n\t\trl[i].Mod(rl[i], n)\n\n\t\tzj := new(big.Int).Exp(z, new(big.Int).SetUint64(uint64(i/bitsize+2)), n)\n\n\t\tindex := i % bitsize\n\t\tzjn2 := new(big.Int).Mul(zj, n2.Get(index))\n\t\tzjn2.Mod(zjn2, n)\n\t\trl[i].Sub(rl[i], zjn2)\n\t\trl[i].Mod(rl[i], n)\n\t\trl[i].Mul(rl[i], ymnInverse.Get(i))\n\t\trl[i].Mod(rl[i], n)\n\t\trl[i].Sub(rl[i], z)\n\t\trl[i].Mod(rl[i], n)\n\t}\n\n\txu, err := utils.ComputeChallenge(n, proof.t)\n\tif err != nil {\n\t\tlog.Warn(\"compute challenge for xu failed\", \"err\", err)\n\t\treturn false\n\t}\n\n\tleft := gv.Commit(ll)\n\tleft.Add(left, hv.Commit(rl))\n\tuBase := params.U()\n\n\txabt := new(big.Int).Mul(proof.ipProof.a, proof.ipProof.b)\n\txabt.Mod(xabt, n)\n\txabt.Sub(xabt, proof.t)\n\txabt.Mod(xabt, n)\n\txabt.Mul(xabt, xu)\n\txabt.Mod(xabt, n)\n\n\tleft.Add(left, new(utils.ECPoint).ScalarMult(uBase, xabt))\n\tleft.Add(left, new(utils.ECPoint).ScalarMult(h, proof.u))\n\n\treturn left.Equal(right)\n}", "title": "" }, { "docid": "d187393431ae224ba96f93e4931fd6d5", "score": "0.45204175", "text": "func TestCSievePrimality(t *testing.T) {\n testXSievePrimality(CSieve, t)\n}", "title": "" }, { "docid": "ef916ba8e92a0fa45fc22ffce4712028", "score": "0.4517392", "text": "func VerifyAggRangeProof(params AggRangeParams, v []*utils.ECPoint, proof *AggRangeProof) bool {\n\tn := params.Curve().Params().N\n\tm := params.Aggsize()\n\tbitsize := params.Bitsize()\n\tsize := m * bitsize\n\ty, err := utils.ComputeChallenge(n, proof.A.X, proof.A.Y, proof.S.X, proof.S.Y)\n\tif err != nil {\n\t\tlog.Warn(\"compute challenge y failed\", \"error\", err)\n\t\treturn false\n\t}\n\tymn := utils.PowVector(y, n, size)\n\n\tz, err := utils.ComputeChallenge(n, proof.S.X, proof.S.Y, proof.A.X, proof.A.Y)\n\tif err != nil {\n\t\tlog.Warn(\"compute challenge z failed\", \"error\", err)\n\t\treturn false\n\t}\n\tzNeg := new(big.Int).Neg(z)\n\tzNeg.Mod(zNeg, n)\n\tzSquare := new(big.Int).Exp(z, utils.Two, n)\n\n\tx, err := utils.ComputeChallenge(n, proof.T1.X, proof.T1.Y, proof.T2.X, proof.T2.Y)\n\tif err != nil {\n\t\tlog.Warn(\"compute challenge x failed\", \"error\", err)\n\t\treturn false\n\t}\n\tx2 := new(big.Int).Exp(x, utils.Two, n)\n\n\th := params.H()\n\tg := params.G()\n\tgv := params.GV()\n\thv := params.HV()\n\n\t// check g*tx + h*t ?= v*(z^2 * z^m) + g*delta + T1*x + T2*x^2. (z^m is a vector)\n\tzm := utils.PowVector(z, n, m).Times(zSquare)\n\texpect := utils.NewGeneratorVector(v).Commit(zm.GetVector())\n\n\texpect.Add(expect, new(utils.ECPoint).ScalarMult(proof.T1, x))\n\texpect.Add(expect, new(utils.ECPoint).ScalarMult(proof.T2, x2))\n\tdelta := utils.DeltaMN(y, z, n, m, bitsize)\n\texpect.Add(expect, new(utils.ECPoint).ScalarMult(g, delta))\n\n\tactual := new(utils.ECPoint).ScalarMult(g, proof.t)\n\tactual.Add(actual, new(utils.ECPoint).ScalarMult(h, proof.tx))\n\n\tif !expect.Equal(actual) {\n\t\tlog.Warn(\"point not equal\", \"expect x\", expect.X, \"expect y\", expect.Y, \"actual x\", actual.X, \"actual y\", actual.Y)\n\t\treturn false\n\t}\n\n\thPrime := hv.Hadamard(ymn.ModInverse().GetVector())\n\t// compute p point. p = A + S*x + gv*-z + h'*(z*y^mn) + hj'^(z^j+1 * 2^n). (hj=h'[(j-1)*n:j*n-1], j=[1, m])\n\tp := proof.A.Copy()\n\tp.Add(p, new(utils.ECPoint).ScalarMult(proof.S, x))\n\tp.Add(p, new(utils.ECPoint).ScalarMult(gv.Sum(), zNeg))\n\tp.Add(p, hPrime.Commit(ymn.Times(z).GetVector()))\n\n\tn2 := utils.PowVector(new(big.Int).SetUint64(2), n, bitsize)\n\tfor j := 1; j <= m; j++ {\n\t\thtmp := hPrime.SubVector((j-1)*bitsize, j*bitsize)\n\t\tzj := new(big.Int).Exp(z, new(big.Int).SetUint64(uint64(j+1)), n)\n\t\tzjn2 := n2.Times(zj)\n\t\tp.Add(p, htmp.Commit(zjn2.GetVector()))\n\t}\n\n\t// compute p'. p' = p - h*u. == g*l + h'*r.(this could be applied on inner product).\n\tnewP := p.Sub(p, new(utils.ECPoint).ScalarMult(h, proof.u))\n\n\treturn OptimizedVerifyIPProof(NewIPParams(gv, hPrime, params.U()), newP, proof.t, proof.ipProof)\n}", "title": "" }, { "docid": "b941f5ad2a8a2c059e5a965605b25426", "score": "0.4514024", "text": "func (bc *BlockChain) ProofOfWork(block *Block) int {\n newProof := 0\n for {\n block.Proof = newProof\n if block.isProofValid() {\n block.Hash = block.GenerateHash()\n return newProof\n }\n newProof++\n }\n}", "title": "" }, { "docid": "5f8eef918f1b801d5518f7b2e8684a4d", "score": "0.4513371", "text": "func proofOfStake(diff uint8,\n\tprevHash [32]byte,\n\tprevProofs [][crypto.COMM_PROOF_LENGTH]byte,\n\theight uint32,\n\tbalance uint64,\n\tcommitmentProof [crypto.COMM_PROOF_LENGTH]byte) (int64, error) {\n\n\tvar (\n\t\tpos [32]byte\n\t\tbyteNr uint8\n\t\tabort bool\n\n\t\ttimestampBuf [8]byte\n\t\theightBuf [4]byte\n\n\t\ttimestamp int64\n\n\t\thashArgs []byte\n\t)\n\n\t// allocate memory\n\t// n * COMM_KEY_LENGTH bytes (prevProofs) + COMM_KEY_LENGTH bytes (localCommPubKey)+ 4 bytes (height) + 8 bytes (count)\n\thashArgs = make([]byte, len(prevProofs)*crypto.COMM_PROOF_LENGTH+crypto.COMM_PROOF_LENGTH+4+8)\n\n\tbinary.BigEndian.PutUint32(heightBuf[:], height)\n\n\t// all required parameters are concatenated in the following order:\n\t// ([PrevProofs] ⋅ CommitmentProof ⋅ CurrentBlockHeight ⋅ Seconds)\n\tindex := 0\n\tfor _, prevProof := range prevProofs {\n\t\tcopy(hashArgs[index:index + crypto.COMM_PROOF_LENGTH], prevProof[:])\n\t\tindex += crypto.COMM_PROOF_LENGTH\n\t}\n\n\tcopy(hashArgs[index:index + crypto.COMM_PROOF_LENGTH], commitmentProof[:]) // COMM_KEY_LENGTH bytes\n\tindex += crypto.COMM_PROOF_LENGTH\n\tcopy(hashArgs[index:index + 4], heightBuf[:]) \t\t// 4 bytes\n\tindex += 4\n\n\ttimestampBufIndexStart := index\n\ttimestampBufIndexEnd := index + 8\n\n\tfor range time.Tick(time.Second) {\n\t\t// lastBlock is a global variable which points to the last block. This check makes sure we abort if another\n\t\t// block has been validated\n\t\tif prevHash != lastBlock.Hash {\n\t\t\treturn -1, errors.New(\"Abort mining, another block has been successfully validated in the meantime\")\n\t\t}\n\n\t\tabort = false\n\n\t\t//add the number of seconds that have passed since the Unix epoch (00:00:00 UTC, 1 January 1970)\n\t\ttimestamp = time.Now().Unix()\n\t\tbinary.BigEndian.PutUint64(timestampBuf[:], uint64(timestamp))\n\t\tcopy(hashArgs[timestampBufIndexStart:timestampBufIndexEnd], timestampBuf[:]) //8 bytes\n\n\t\t//calculate the hash\n\t\tpos = sha3.Sum256(hashArgs[:])\n\n\t\t//divide the hash by the balance (should not happen but possible in a testing environment)\n\t\tdata := binary.BigEndian.Uint64(pos[:])\n\t\tif balance == 0 {\n\t\t\treturn -1, errors.New(\"Zero division: Account owns 0 coins.\")\n\t\t}\n\t\tdata = data / balance\n\t\tvar buf bytes.Buffer\n\t\tbinary.Write(&buf, binary.BigEndian, data)\n\n\t\tcopy(pos[0:32], buf.Bytes())\n\n\t\t//TODO @simibac What do you do here?\n\t\t//Byte check\n\t\tfor byteNr = 0; byteNr < (uint8)(diff/8); byteNr++ {\n\t\t\tif pos[byteNr] != 0 {\n\t\t\t\t//continue begins the next iteration of the innermost\n\t\t\t\tabort = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif abort {\n\t\t\tcontinue\n\t\t}\n\t\t//Bit check\n\t\tif diff%8 != 0 && pos[byteNr] >= 1<<(8-diff%8) {\n\t\t\tcontinue\n\t\t}\n\t\tbreak\n\t}\n\n\treturn timestamp, nil\n}", "title": "" }, { "docid": "967eb88acfd7fb2f4ef49413dd80e829", "score": "0.44924346", "text": "func NewProof(targetBits, maxNonce int) *Proof {\n\ttarget := big.NewInt(1)\n\ttarget.Lsh(target, uint(256-targetBits))\n\n\tp := &Proof{\n\t\ttarget: target,\n\t\ttargetBits: targetBits,\n\t\tmaxNonce: maxNonce,\n\t}\n\treturn p\n}", "title": "" }, { "docid": "df7bea73bbbd62c7d1e688f98b2c0b3f", "score": "0.44888476", "text": "func (p *Proof) Validate() bool {\n\tvar hashInt big.Int\n\n\tdata := p.prepareData(p.block.Nonce)\n\thash := sha256.Sum256(data)\n\thashInt.SetBytes(hash[:])\n\n\treturn hashInt.Cmp(p.target) == -1\n}", "title": "" }, { "docid": "e28e590cfadeb731f9186ee1886d26b3", "score": "0.44757825", "text": "func TestBlameProofEqual(t *testing.T) {\n\tp := new(signature).init(suite, []byte(\"Test\"))\n\tbp := new(blameProof).init(suite, DealerKey.Public, []byte(\"Test\"), p)\n\tif !bp.Equal(bp) {\n\t\tt.Error(\"blameProof should equal itself.\")\n\t}\n\n\t// Error cases\n\tbp2 := new(blameProof).init(nil, DealerKey.Public, []byte(\"Test\"), p)\n\tif bp.Equal(bp2) {\n\t\tt.Error(\"blameProof differ in key suites.\")\n\t}\n\tbp2 = new(blameProof).init(suite, suite.Point().Base(), []byte(\"Test\"), p)\n\tif bp.Equal(bp2) {\n\t\tt.Error(\"blameProof differ in diffie-keys.\")\n\t}\n\tbp2 = new(blameProof).init(suite, DealerKey.Public, []byte(\"Differ\"), p)\n\tif bp.Equal(bp2) {\n\t\tt.Error(\"blameProof differ in hash proof.\")\n\t}\n\tp2 := new(signature).init(suite, []byte(\"Differ\"))\n\tbp2 = new(blameProof).init(suite, DealerKey.Public, []byte(\"Test\"), p2)\n\tif bp.Equal(bp2) {\n\t\tt.Error(\"blameProof differ in signatures.\")\n\t}\n}", "title": "" }, { "docid": "ba4e1945f7555d9825d416e8923f760b", "score": "0.44731453", "text": "func TestValidHash(t *testing.T) {\n\tassertUtil := assert.New(t)\n\tb0 := Initial(2)\n\tb0.Hash = b0.CalcHash()\n\n\t// Proof 0 is invalid\n\tassertUtil.False(b0.ValidHash())\n\n\t// Proof 242278 is valid\n\tb0.Proof = 242278\n\tb0.Hash = b0.CalcHash()\n\tassertUtil.True(b0.ValidHash())\n}", "title": "" }, { "docid": "c3ac839841c1e27bc0528afb98299b77", "score": "0.44713324", "text": "func sm2P256Square(a sm2P256FieldElement) (x sm2P256FieldElement) {\n\tvar tmp sm2P256LargeFieldElement\n\tvar b sm2P256FieldElement\n\n\ttmp[0] = uint64(a[0]) * uint64(a[0])\n\ttmp[1] = uint64(a[0]) * (uint64(a[1]) << 1)\n\ttmp[2] = uint64(a[0])*(uint64(a[2])<<1) +\n\t\tuint64(a[1])*(uint64(a[1])<<1)\n\ttmp[3] = uint64(a[0])*(uint64(a[3])<<1) +\n\t\tuint64(a[1])*(uint64(a[2])<<1)\n\ttmp[4] = uint64(a[0])*(uint64(a[4])<<1) +\n\t\tuint64(a[1])*(uint64(a[3])<<2) +\n\t\tuint64(a[2])*uint64(a[2])\n\ttmp[5] = uint64(a[0])*(uint64(a[5])<<1) +\n\t\tuint64(a[1])*(uint64(a[4])<<1) +\n\t\tuint64(a[2])*(uint64(a[3])<<1)\n\ttmp[6] = uint64(a[0])*(uint64(a[6])<<1) +\n\t\tuint64(a[1])*(uint64(a[5])<<2) +\n\t\tuint64(a[2])*(uint64(a[4])<<1) +\n\t\tuint64(a[3])*(uint64(a[3])<<1)\n\ttmp[7] = uint64(a[0])*(uint64(a[7])<<1) +\n\t\tuint64(a[1])*(uint64(a[6])<<1) +\n\t\tuint64(a[2])*(uint64(a[5])<<1) +\n\t\tuint64(a[3])*(uint64(a[4])<<1)\n\t// tmp[8] has the greatest value of 2**61 + 2**60 + 2**61 + 2**60 + 2**60,\n\t// which is < 2**64 as required.\n\ttmp[8] = uint64(a[0])*(uint64(a[8])<<1) +\n\t\tuint64(a[1])*(uint64(a[7])<<2) +\n\t\tuint64(a[2])*(uint64(a[6])<<1) +\n\t\tuint64(a[3])*(uint64(a[5])<<2) +\n\t\tuint64(a[4])*uint64(a[4])\n\ttmp[9] = uint64(a[1])*(uint64(a[8])<<1) +\n\t\tuint64(a[2])*(uint64(a[7])<<1) +\n\t\tuint64(a[3])*(uint64(a[6])<<1) +\n\t\tuint64(a[4])*(uint64(a[5])<<1)\n\ttmp[10] = uint64(a[2])*(uint64(a[8])<<1) +\n\t\tuint64(a[3])*(uint64(a[7])<<2) +\n\t\tuint64(a[4])*(uint64(a[6])<<1) +\n\t\tuint64(a[5])*(uint64(a[5])<<1)\n\ttmp[11] = uint64(a[3])*(uint64(a[8])<<1) +\n\t\tuint64(a[4])*(uint64(a[7])<<1) +\n\t\tuint64(a[5])*(uint64(a[6])<<1)\n\ttmp[12] = uint64(a[4])*(uint64(a[8])<<1) +\n\t\tuint64(a[5])*(uint64(a[7])<<2) +\n\t\tuint64(a[6])*uint64(a[6])\n\ttmp[13] = uint64(a[5])*(uint64(a[8])<<1) +\n\t\tuint64(a[6])*(uint64(a[7])<<1)\n\ttmp[14] = uint64(a[6])*(uint64(a[8])<<1) +\n\t\tuint64(a[7])*(uint64(a[7])<<1)\n\ttmp[15] = uint64(a[7]) * (uint64(a[8]) << 1)\n\ttmp[16] = uint64(a[8]) * uint64(a[8])\n\treturn sm2P256ReduceDegree(b, tmp)\n}", "title": "" }, { "docid": "ca9c59e999591350444ce2ca4bb002e6", "score": "0.44669682", "text": "func (m *MMR) InclusionProof(leafIdx, size uint64) (hashes []HashType, err error) {\n\tif leafIdx >= size {\n\t\terr = fmt.Errorf(\"wrong parameters\")\n\t\treturn\n\t} else if m.size < size {\n\t\terr = ErrRootNotAvailableYet\n\t\treturn\n\t} else if m.store == nil {\n\t\terr = ErrHashStoreNotAvailable\n\t\treturn\n\t}\n\n\tvar (\n\t\toffset uint64\n\t\tleftPeakHash HashType\n\t)\n\t// need no proof if size is 1\n\t//\n\t// for size > 1, we want to:\n\t// 1. locate the target moutain M leafIdx is in\n\t// 2. bag the right peaks of moutain M\n\t// 3. collect the preceding leaks of moutain M\n\t// 4. collect the proof of leafIdx within moutain M\n\tfor size > 1 {\n\t\t// if size is not 2^n, left peak of size/size-1 is the same\n\t\t// if size is 2^n, left peak of size-1 decomposes to the left sub peak\n\t\t//\n\t\t// this trick unifies the process of finding proofs within one moutain and amoung mountains.\n\t\t//\n\t\t// it's based on the invariant that the graph can always be decomposed into a sub left mountain Msub and right side\n\t\t//\n\t\t// as long as there're no fewer than 2 leaves, whether it's completely balanced or not.\n\t\t//\n\t\t// if leafIdx is within Msub, we find the proof for Msub and bag it with the right side\n\t\t//\n\t\t// if leafIdx is out of Msub, we find the proof for the right side and bag it with the peak of Msub\n\t\tlpLeaf := leftPeakLeaf(size - 1) // -1 for a proper one\n\t\tif leafIdx < lpLeaf {\n\t\t\trightPeaks := getMoutainPeaks(size - lpLeaf)\n\t\t\trightHashes := make([]HashType, len(rightPeaks), len(rightPeaks))\n\t\t\tfor i := range rightPeaks {\n\t\t\t\trightPeaks[i] += offset + 2*lpLeaf - 1\n\t\t\t\trightHashes[i], err = m.store.GetHash(rightPeaks[i] - 1)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tbaggedRightHash := bagPeaks(m.hasher, rightHashes)\n\t\t\thashes = append(hashes, baggedRightHash)\n\t\t\tsize = lpLeaf\n\t\t} else {\n\t\t\toffset += 2*lpLeaf - 1\n\t\t\tleftPeakHash, err = m.store.GetHash(offset - 1)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\thashes = append(hashes, leftPeakHash)\n\t\t\tleafIdx -= lpLeaf\n\t\t\tsize -= lpLeaf\n\t\t}\n\t}\n\n\t// reverse\n\t// https://github.com/golang/go/wiki/SliceTricks#reversing\n\tlength := len(hashes)\n\tfor i := length/2 - 1; i >= 0; i-- {\n\t\topp := length - 1 - i\n\t\thashes[i], hashes[opp] = hashes[opp], hashes[i]\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "95de9ac1cb5d70ac7fe670aaf230d26c", "score": "0.44656712", "text": "func (t HistoryTree) VerifyMembershipProof(index int, rootHash common.Hash, eventHash common.Hash) bool {\n\tdepth := computeDepth(t.version)\n\troot := common.NewPosition(0, depth)\n\tcomputedRootHash := t.computeHashPostOrder(depth, root)\n\treturn bytes.Equal(computedRootHash, rootHash)\n}", "title": "" }, { "docid": "9b020af40a4c39776aef9459d399ff2c", "score": "0.4462592", "text": "func WBBVerify(pk *FP256BN.ECP2, sig *FP256BN.ECP, m *FP256BN.BIG) error {\n\tif pk == nil || sig == nil || m == nil {\n\t\treturn errors.Errorf(\"Weak-BB signature invalid: received nil input\")\n\t}\n\t// Set P = pk * g2^m\n\tP := FP256BN.NewECP2()\n\tP.Copy(pk)\n\tP.Add(GenG2.Mul(m))\n\tP.Affine()\n\t// check that e(sig, pk * g2^m) = e(g1, g2)\n\tif !FP256BN.Fexp(FP256BN.Ate(P, sig)).Equals(GenGT) {\n\t\treturn errors.Errorf(\"Weak-BB signature is invalid\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "b9c69b84fdf09d79ebb53aa3b90a0f93", "score": "0.44599143", "text": "func (bc *Blockchain) ProofOfWork(lastProof int64) int64 {\n\tvar proof int64 = 0\n\tfor !bc.ValidProof(lastProof, proof) {\n\t\tproof += 1\n\t}\n\treturn proof\n}", "title": "" }, { "docid": "a5cbd093a2f5cd87e1360796a128cb7c", "score": "0.44568413", "text": "func VerifyProof(root *helper.UInt256, id int, key []byte, proof [][]byte) ([]byte, error) {\n\tsKey := blockchain.StorageKey{\n\t\tId: id,\n\t\tKey: key,\n\t}\n\tvkey, err := nio.ToArray(&sKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tproofdb := NewProofDb(proof)\n\ttrie, err := NewTrie(root, proofdb)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvalue, err := trie.Get(vkey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn resolveValue(value)\n}", "title": "" }, { "docid": "c9b6f2191138b783c9b3de733901503d", "score": "0.44516855", "text": "func (blockchain *Blockchain) ProofOfWork(lastProof int64) int64 {\n\tvar proof int64 = 0\n\tfor !blockchain.ValidProof(lastProof, proof) {\n\t\tproof++\n\t}\n\n\treturn int64(proof)\n}", "title": "" }, { "docid": "e8fb59f36cf9254aad8722a97286fe3e", "score": "0.44484472", "text": "func XX32(input []byte, seed uint32) uint32 {\n\tn := len(input)\n\tif n == 0 {\n\t\treturn 0\n\t}\n\n\th32 := uint32(n)\n\tif n < 16 {\n\t\th32 += seed + xxPrime32_5\n\t} else {\n\t\tv1 := seed + xxPrime32_1 + xxPrime32_2\n\t\tv2 := seed + xxPrime32_2\n\t\tv3 := seed\n\t\tv4 := seed - xxPrime32_1\n\t\tp := 0\n\t\tfor n := n - 16; p <= n; p += 16 {\n\t\t\tsub := input[p:][:16] //BCE hint for compiler\n\t\t\tv1 = rol32(v1+u32(sub[:])*xxPrime32_2, 13) * xxPrime32_1\n\t\t\tv2 = rol32(v2+u32(sub[4:])*xxPrime32_2, 13) * xxPrime32_1\n\t\t\tv3 = rol32(v3+u32(sub[8:])*xxPrime32_2, 13) * xxPrime32_1\n\t\t\tv4 = rol32(v4+u32(sub[12:])*xxPrime32_2, 13) * xxPrime32_1\n\t\t}\n\t\tinput = input[p:]\n\t\tn -= p\n\t\th32 += rol32(v1, 1) + rol32(v2, 7) + rol32(v3, 12) + rol32(v4, 18)\n\t}\n\n\tp := 0\n\tfor n := n - 4; p <= n; p += 4 {\n\t\th32 += u32(input[p:p+4]) * xxPrime32_3\n\t\th32 = rol32(h32, 17) * xxPrime32_4\n\t}\n\tfor p < n {\n\t\th32 += uint32(input[p]) * xxPrime32_5\n\t\th32 = rol32(h32, 11) * xxPrime32_1\n\t\tp++\n\t}\n\n\th32 ^= h32 >> 15\n\th32 *= xxPrime32_2\n\th32 ^= h32 >> 13\n\th32 *= xxPrime32_3\n\th32 ^= h32 >> 16\n\n\treturn h32\n}", "title": "" }, { "docid": "82431d9c2fb4fd2b7016bcc214d43f56", "score": "0.44437444", "text": "func newProof(b *Block) *proofOfWork {\n\ttarget := big.NewInt(1)\n\ttarget.Lsh(target, uint(256-difficulty))\n\n\tpow := &proofOfWork{b, target}\n\n\treturn pow\n}", "title": "" }, { "docid": "1f02d6304bc2c622e4ae6e879e9aac16", "score": "0.44406185", "text": "func Verify(proof Proof, publicData PublicData, publicWitness frontend.Circuit) error {\n\n\tswitch _proof := proof.(type) {\n\n\tcase *plonkbn254.ProofRaw:\n\t\t_publicData := publicData.(*plonkbn254.PublicRaw)\n\t\tw := bn254witness.Witness{}\n\t\tif err := w.FromPublicAssignment(publicWitness); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn plonkbn254.VerifyRaw(_proof, _publicData, w)\n\n\tcase *plonkbls12381.ProofRaw:\n\t\t_publicData := publicData.(*plonkbls12381.PublicRaw)\n\t\tw := bls12381witness.Witness{}\n\t\tif err := w.FromPublicAssignment(publicWitness); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn plonkbls12381.VerifyRaw(_proof, _publicData, w)\n\n\tcase *plonkbls12377.ProofRaw:\n\t\t_publicData := publicData.(*plonkbls12377.PublicRaw)\n\t\tw := bls12377witness.Witness{}\n\t\tif err := w.FromPublicAssignment(publicWitness); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn plonkbls12377.VerifyRaw(_proof, _publicData, w)\n\n\tcase *plonkbw6761.ProofRaw:\n\t\t_publicData := publicData.(*plonkbw6761.PublicRaw)\n\t\tw := bw6761witness.Witness{}\n\t\tif err := w.FromPublicAssignment(publicWitness); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn plonkbw6761.VerifyRaw(_proof, _publicData, w)\n\n\tdefault:\n\t\tpanic(\"unrecognized proof type\")\n\t}\n}", "title": "" }, { "docid": "8eed90c93ab719c265ec86c8be077335", "score": "0.44356197", "text": "func (_InboxTopChallenge *InboxTopChallengeSession) OneStepProof(_lowerHash [32]byte, _value [32]byte) (*types.Transaction, error) {\n\treturn _InboxTopChallenge.Contract.OneStepProof(&_InboxTopChallenge.TransactOpts, _lowerHash, _value)\n}", "title": "" }, { "docid": "585da04c0887bd86269ded7c54948728", "score": "0.44272128", "text": "func (pv *PVSS) Verify(H abstract.Point, X []abstract.Point, sH []abstract.Point, sX []abstract.Point, core []ProofCore) (good, bad []int, err error) {\n\n\tn := len(X)\n\tY := make([]abstract.Point, n)\n\tfor i := 0; i < n; i++ {\n\t\tY[i] = H\n\t}\n\tproof, err := NewProof(pv.suite, Y, X, core)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\treturn proof.Verify(sH, sX)\n}", "title": "" }, { "docid": "e78b69f5faab4d9e517cda31413c3c46", "score": "0.44259033", "text": "func (lbdc *localBitcoinDifficultyChain) ProofLength() (uint64, error) {\n\treturn lbdc.proofLength, nil\n}", "title": "" }, { "docid": "f34cd4bf60a9a9483e6b9afc43dc792b", "score": "0.44190615", "text": "func CheckProofOfWorkByBits(header externalapi.MutableBlockHeader) bool {\n\treturn CheckProofOfWorkWithTarget(header, difficulty.CompactToBig(header.Bits()))\n}", "title": "" }, { "docid": "13ef37e6f59d54cfef5309aa13dc4b3f", "score": "0.44104722", "text": "func TestBlameProofInit(t *testing.T) {\n\tproof := []byte(\"This is a test\")\n\tsig := []byte(\"This too is a test\")\n\tp := new(signature).init(suite, sig)\n\tbp := new(blameProof).init(suite, DealerKey.Public, proof, p)\n\tif suite != bp.suite {\n\t\tt.Error(\"Suite not properly initialized.\")\n\t}\n\tif !bp.diffieKey.Equal(DealerKey.Public) {\n\t\tt.Error(\"Diffie-Hellman key not properly initialized.\")\n\t}\n\tif !reflect.DeepEqual(bp.proof, proof) {\n\t\tt.Error(\"Diffie-Hellman proof not properly initialized.\")\n\t}\n\tif !p.Equal(&bp.signature) {\n\t\tt.Error(\"PromisSignature not properly initialized.\")\n\t}\n}", "title": "" }, { "docid": "fa7f2b3abb7d04f90523d6745f8bb895", "score": "0.43951154", "text": "func TestCalcHash(t *testing.T) {\n\tassertUtil := assert.New(t)\n\tb0 := Initial(2)\n\tb0.Proof = 242278\n\n\tb0hash := hex.EncodeToString(b0.CalcHash())\n\tassertUtil.Equal(\"29528aaf90e167b2dc248587718caab237a81fd25619a5b18be4986f75f30000\", b0hash)\n}", "title": "" }, { "docid": "8e5cddc8ad7bc84c3c450cca6f4c6dcc", "score": "0.4394064", "text": "func RSA_OAEP_DECODE(sha int, p []byte, f []byte, RFS int) []byte {\n\tolen := RFS - 1\n\n\thlen := sha\n\tSEED := make([]byte, hlen)\n\tseedlen := hlen\n\tCHASH := make([]byte, hlen)\n\n\tif olen < seedlen+hlen+1 {\n\t\treturn nil\n\t}\n\tDBMASK := make([]byte, olen-seedlen)\n\tfor i := 0; i < olen-seedlen; i++ {\n\t\tDBMASK[i] = 0\n\t}\n\n\tif len(f) < RFS {\n\t\td := RFS - len(f)\n\t\tfor i := RFS - 1; i >= d; i-- {\n\t\t\tf[i] = f[i-d]\n\t\t}\n\t\tfor i := d - 1; i >= 0; i-- {\n\t\t\tf[i] = 0\n\t\t}\n\t}\n\n\th := SPhashit(MC_SHA2,sha,p)\n\t//h := hashit(sha, p, -1)\n\tfor i := 0; i < hlen; i++ {\n\t\tCHASH[i] = h[i]\n\t}\n\n\tx := f[0]\n\n\tfor i := seedlen; i < olen; i++ {\n\t\tDBMASK[i-seedlen] = f[i+1]\n\t}\n\n\tMGF1(sha, DBMASK, seedlen, SEED)\n\tfor i := 0; i < seedlen; i++ {\n\t\tSEED[i] ^= f[i+1]\n\t}\n\tMGF1(sha, SEED, olen-seedlen, f)\n\tfor i := 0; i < olen-seedlen; i++ {\n\t\tDBMASK[i] ^= f[i]\n\t}\n\n\tcomp := true\n\tfor i := 0; i < hlen; i++ {\n\t\tif CHASH[i] != DBMASK[i] {\n\t\t\tcomp = false\n\t\t}\n\t}\n\n\tfor i := 0; i < olen-seedlen-hlen; i++ {\n\t\tDBMASK[i] = DBMASK[i+hlen]\n\t}\n\n\tfor i := 0; i < hlen; i++ {\n\t\tSEED[i] = 0\n\t\tCHASH[i] = 0\n\t}\n\n\tvar k int\n\tfor k = 0; ; k++ {\n\t\tif k >= olen-seedlen-hlen {\n\t\t\treturn nil\n\t\t}\n\t\tif DBMASK[k] != 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tt := DBMASK[k]\n\tif !comp || x != 0 || t != 0x01 {\n\t\tfor i := 0; i < olen-seedlen; i++ {\n\t\t\tDBMASK[i] = 0\n\t\t}\n\t\treturn nil\n\t}\n\n\tvar r = make([]byte, olen-seedlen-hlen-k-1)\n\n\tfor i := 0; i < olen-seedlen-hlen-k-1; i++ {\n\t\tr[i] = DBMASK[i+k+1]\n\t}\n\n\tfor i := 0; i < olen-seedlen; i++ {\n\t\tDBMASK[i] = 0\n\t}\n\n\treturn r\n}", "title": "" }, { "docid": "a90648fb8703984cbd42ba967b60352c", "score": "0.43906462", "text": "func (proof *DefaultProof) Decode(data []byte) error {\n\tif len(data) != massProofByteLength {\n\t\treturn ErrProofDecodeDataSize\n\t}\n\tproof.BL = int(data[16])\n\tproof.X = pocutil.PoCValue2Bytes(pocutil.PoCValue(binary.LittleEndian.Uint64(data[:8])), proof.BL)\n\tproof.XPrime = pocutil.PoCValue2Bytes(pocutil.PoCValue(binary.LittleEndian.Uint64(data[8:16])), proof.BL)\n\treturn nil\n}", "title": "" }, { "docid": "23d5886d1943acb91e8118b4302341f3", "score": "0.43896356", "text": "func GetSafePrime(bits int) (p *big.Int, err error) {\n\tp1 := GetGermainPrime(bits - 1)\n\tp = big.NewInt(0)\n\tp.Mul(p1, big.NewInt(2))\n\tp.Add(p, big.NewInt(1))\n\n\tif p.BitLen() != bits {\n\t\terr := fmt.Errorf(\"bit length not correct\")\n\t\treturn nil, err\n\t}\n\n\treturn p, nil\n}", "title": "" }, { "docid": "f33989d29d283c76e80f6f4aec4511c2", "score": "0.43873194", "text": "func (c *certManager) VerifyServerProof(proof, chlo, serverConfigData []byte) bool {\n\tif len(c.chain) == 0 {\n\t\treturn false\n\t}\n\n\treturn verifyServerProof(proof, c.chain[0], chlo, serverConfigData)\n}", "title": "" }, { "docid": "598a77e1cc3c412fa7ddefee042ec959", "score": "0.43659946", "text": "func (pdpCore *PDPCore) pdp_generate_proof_final(key *PDP_key, challenge *PDP_challenge, proof *PDP_proof) *PDP_proof {\n\n\tif proof == nil {\n\t\treturn nil\n\t}\n\tif key == nil || challenge == nil || proof.rho_temp == nil || proof.rho_temp.Cmp(big.NewInt(0)) == 1 {\n\t\treturn nil\n\t}\n\tif key.rsa.N == nil || challenge.g_s == nil {\n\t\treturn nil\n\t}\n\n\t/* Compute g_s^ (M1 + M2 + ... + Mc) mod N*/\n\tproof.rho_temp = new(big.Int).Exp(challenge.g_s, proof.rho_temp, key.rsa.N)\n\tif proof.rho_temp == nil {\n\t\treturn nil\n\t}\n\n\t/* Compute H(g_s^(M1 + M2 + ... + Mc)) */\n\tproof.rho = pdpCore.generate_H(proof.rho_temp, proof.rho_size)\n\tif proof.rho == nil {\n\t\treturn nil\n\t}\n\n\treturn proof\n\n}", "title": "" }, { "docid": "83eb1ac9e6a056dfe952e5a034598b3d", "score": "0.43658176", "text": "func (pow *ProofOfWork) Validate() bool {\n\tvar hashInt big.Int\n\n\tdata := pow.prepareData(pow.block.Nonce)\n\thash := sha256.Sum256(data)\n\thashInt.SetBytes(hash[:])\n\n\tisValid := hashInt.Cmp(pow.target) == -1\n\n\treturn isValid\n}", "title": "" }, { "docid": "c32556adfce3d229d64f94fdfe2bc89d", "score": "0.43613753", "text": "func (p *Proof) WellFormed() bool {\n\treturn (secp256k1.ValidPublicKey(p.PublicKey) &&\n\t\tsecp256k1.ValidPublicKey(p.Gamma) && secp256k1.RepresentsScalar(p.C) &&\n\t\tsecp256k1.RepresentsScalar(p.S) && p.Output.BitLen() <= 256)\n}", "title": "" }, { "docid": "07ebdb69aef5e62d619731dc53249af4", "score": "0.4349965", "text": "func Check2FA(secret string, token string) error {\n\tif totp.Validate(token, secret) {\n\t\treturn nil\n\t}\n\n\treturn errors.New(\"invalid token\")\n}", "title": "" }, { "docid": "e89d0f888ee39adbba5ce5b04c248b32", "score": "0.4343386", "text": "func CheckModuli(q, p []uint64, logN int) error {\n\n\tif len(q) > MaxModuliCount {\n\t\treturn fmt.Errorf(\"#Qi is larger than %d\", MaxModuliCount)\n\t}\n\n\tif len(p) > MaxModuliCount {\n\t\treturn fmt.Errorf(\"#Pi is larger than %d\", MaxModuliCount)\n\t}\n\n\tfor i, qi := range q {\n\t\tif uint64(bits.Len64(qi)-1) > MaxModuliSize+1 {\n\t\t\treturn fmt.Errorf(\"Qi bit-size (i=%d) is larger than %d\", i, MaxModuliSize)\n\t\t}\n\t}\n\n\tfor i, pi := range p {\n\t\tif uint64(bits.Len64(pi)-1) > MaxModuliSize+2 {\n\t\t\treturn fmt.Errorf(\"Pi bit-size (i=%d) is larger than %d\", i, MaxModuliSize)\n\t\t}\n\t}\n\n\tN := uint64(1 << logN)\n\n\tfor i, qi := range q {\n\t\tif !ring.IsPrime(qi) || qi&((N<<1)-1) != 1 {\n\t\t\treturn fmt.Errorf(\"Qi (i=%d) is not an NTT prime\", i)\n\t\t}\n\t}\n\n\tfor i, pi := range p {\n\t\tif !ring.IsPrime(pi) || pi&((N<<1)-1) != 1 {\n\t\t\treturn fmt.Errorf(\"Pi (i=%d) is not an NTT prime\", i)\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "cb4baa4c7bdbb88221024774723b9171", "score": "0.4343216", "text": "func (crc *CasbinRuleCreate) check() error {\n\tif _, ok := crc.mutation.PType(); !ok {\n\t\treturn &ValidationError{Name: \"PType\", err: errors.New(\"ent: missing required field \\\"PType\\\"\")}\n\t}\n\tif v, ok := crc.mutation.PType(); ok {\n\t\tif err := casbinrule.PTypeValidator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"PType\", err: fmt.Errorf(\"ent: validator failed for field \\\"PType\\\": %w\", err)}\n\t\t}\n\t}\n\tif v, ok := crc.mutation.V0(); ok {\n\t\tif err := casbinrule.V0Validator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"v0\", err: fmt.Errorf(\"ent: validator failed for field \\\"v0\\\": %w\", err)}\n\t\t}\n\t}\n\tif v, ok := crc.mutation.V1(); ok {\n\t\tif err := casbinrule.V1Validator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"v1\", err: fmt.Errorf(\"ent: validator failed for field \\\"v1\\\": %w\", err)}\n\t\t}\n\t}\n\tif v, ok := crc.mutation.V2(); ok {\n\t\tif err := casbinrule.V2Validator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"v2\", err: fmt.Errorf(\"ent: validator failed for field \\\"v2\\\": %w\", err)}\n\t\t}\n\t}\n\tif v, ok := crc.mutation.V3(); ok {\n\t\tif err := casbinrule.V3Validator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"v3\", err: fmt.Errorf(\"ent: validator failed for field \\\"v3\\\": %w\", err)}\n\t\t}\n\t}\n\tif v, ok := crc.mutation.V4(); ok {\n\t\tif err := casbinrule.V4Validator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"v4\", err: fmt.Errorf(\"ent: validator failed for field \\\"v4\\\": %w\", err)}\n\t\t}\n\t}\n\tif v, ok := crc.mutation.V5(); ok {\n\t\tif err := casbinrule.V5Validator(v); err != nil {\n\t\t\treturn &ValidationError{Name: \"v5\", err: fmt.Errorf(\"ent: validator failed for field \\\"v5\\\": %w\", err)}\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "40689ba2f0669893e880f60d6d822f87", "score": "0.4342619", "text": "func (bc *Blockchain) ProofOfWork() int {\n\ttransactions := bc.CopyTransactionPool()\n\tpreviousHash := bc.LastBlock().Hash()\n\tnonce := 0\n\tfor !bc.ValidProof(nonce, previousHash, transactions, MINING_DIFFICULTY) {\n\t\tnonce++\n\t}\n\treturn nonce\n}", "title": "" }, { "docid": "770b3b2427377f4467efc11b6aec6222", "score": "0.43233296", "text": "func (pow *ProofOfWork) Validate() bool {\n\tvar intHash big.Int\n\n\tdata := pow.InitData(pow.Block.Nonce)\n\n\thash := sha256.Sum256(data)\n\tintHash.SetBytes(hash[:])\n\n\treturn intHash.Cmp(pow.Target) == -1\n}", "title": "" }, { "docid": "5c8f74d87660be7bb80961ef1325bc6c", "score": "0.4323151", "text": "func verifyPasswordHash(hashKey []byte, password string) bool {\n\t// if length not match\n\tif len(hashKey) < 3 {\n\t\treturn false\n\t}\n\n\tif int(hashKey[0]+hashKey[1]+hashKey[2]+3) != len(hashKey) {\n\t\treturn false\n\t}\n\n\t// parse hashKey\n\tvar parseCursor = 3\n\tvar newCursor = parseCursor\n\tvar parseArr = [][]byte{}\n\n\tfor i := 0; i < 3; i++ {\n\t\tnewCursor = parseCursor + int(hashKey[i])\n\t\tparseArr = append(parseArr, hashKey[parseCursor:newCursor])\n\t\tparseCursor = newCursor\n\t}\n\n\titerations, err := strconv.Atoi(string(parseArr[0]))\n\n\t// silent fail\n\tif err != nil {\n\t\treturn false\n\t}\n\tkeyLen := int(hashKey[1])\n\tkey := parseArr[1]\n\tsalt := parseArr[2]\n\t// generate raw hash using new input password\n\tnewKey := pbkdf2.Key([]byte(password), salt, iterations, keyLen, sha256.New)\n\treturn subtle.ConstantTimeCompare(newKey, key) == 1\n}", "title": "" }, { "docid": "4dd6f34952b5773da16341c9e7d2f781", "score": "0.43211427", "text": "func (_InboxTopChallenge *InboxTopChallengeTransactorSession) OneStepProof(_lowerHash [32]byte, _value [32]byte) (*types.Transaction, error) {\n\treturn _InboxTopChallenge.Contract.OneStepProof(&_InboxTopChallenge.TransactOpts, _lowerHash, _value)\n}", "title": "" }, { "docid": "a29f75fca88a25591fb448899e4fe54d", "score": "0.43006986", "text": "func p256Sqrt(out, in []uint64) bool {\n\tvar xp, a0, a1 [4]uint64\n\tp256Mul(xp[:], in, rr)\n\tp256ExpQuadP(a1[:], xp[:])\n\tp256Mul(out, a1[:], xp[:])\n\tp256Mul(a0[:], out, a1[:])\n\tp256FromMont(out, out)\n\treturn a0 == p256MontOneA\n\t/*\n\t\treturn a0[0] == p256MontOne[0] && a0[1] == p256MontOne[1] &&\n\t\t\ta0[2] == p256MontOne[2] && a0[3] == p256MontOne[3]\n\t*/\n}", "title": "" }, { "docid": "1349178544f3c034fc9a3633800737c8", "score": "0.42915955", "text": "func TestSievePrimality(t *testing.T) {\n testXSievePrimality(Sieve, t)\n}", "title": "" }, { "docid": "24f66bbdc3ced0b79b857aa9b340d507", "score": "0.42906326", "text": "func VerifyProof(rootHash common.Hash, key []byte, proofDb DatabaseReader) (value []byte, nodes int, err error) {\n\tkey = keybytesToHex(key)\n\twantHash := rootHash\n\tfor i := 0; ; i++ {\n\t\tbuf, _ := proofDb.Load(wantHash[:])\n\t\tif buf == nil {\n\t\t\treturn nil, i, fmt.Errorf(\"proof node %d (hash %064x) missing\", i, wantHash)\n\t\t}\n\t\tn, err := decodeNode(wantHash[:], buf, 0)\n\t\tif err != nil {\n\t\t\treturn nil, i, fmt.Errorf(\"bad proof node %d: %v\", i, err)\n\t\t}\n\t\tkeyrest, cld := get(n, key)\n\t\tswitch cld := cld.(type) {\n\t\tcase nil:\n\t\t\t// The trie doesn't contain the key.\n\t\t\treturn nil, i, nil\n\t\tcase hashNode:\n\t\t\tkey = keyrest\n\t\t\tcopy(wantHash[:], cld)\n\t\tcase valueNode:\n\t\t\treturn cld, i + 1, nil\n\t\t}\n\t}\n}", "title": "" }, { "docid": "4378a306248a929c57385ce903ed1fb3", "score": "0.42656532", "text": "func TestVerifySignatureMalleable(t *testing.T) {\n\tassert := assert.New(t)\n\n\tsig := cu.MustDecode(\"0x638a54215d80a6713c8d523a6adc4e6e73652d859103a36b700851cb0e61b66b8ebfc1a610c57d732ec6e0a8f06a9a7a28df5051ece514702ff9cdff0b11f454\")\n\tkey := cu.MustDecode(\"0x03ca634cae0d49acb401d8a4c6b6fe8c55b70d115bf400769cc1400f3258cd3138\")\n\tmsg := cu.MustDecode(\"0xd301ce462d3e639518f482c7f03821fec1e602018630ce621e1e7851c12343a6\")\n\tassert.False(VerifySignature(key, msg, sig))\n}", "title": "" }, { "docid": "08da35e9a9fe0c8619d624226dbecb3f", "score": "0.42623842", "text": "func (pow *ProofOfWork) Validate() bool {\n\tvar hashInt big.Int\n\n\tdata := pow.prepare(pow.block.Nonce)\n\thash := sha256.Sum256(data)\n\thashInt.SetBytes(hash[:])\n\n\treturn hashInt.Cmp(pow.target) == -1\n}", "title": "" }, { "docid": "fe7294911ce1ba042887fdc1e36d7638", "score": "0.42584184", "text": "func VerifyPassword(serverKeypair []byte, req *VerifyPasswordRequest) (response *VerifyPasswordResponse, err error) {\n\n\tkp, err := unmarshalKeypair(serverKeypair)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif req == nil || len(req.NS) > 32 || len(req.NS) == 0 {\n\t\terr = errors.New(\"Invalid password verify request\")\n\t\treturn\n\t}\n\n\tns := req.NS\n\n\tc0, err := PointUnmarshal(req.C0)\n\tif err != nil {\n\t\treturn\n\t}\n\n\ths0 := hashToPoint(ns, dhs0)\n\ths1 := hashToPoint(ns, dhs1)\n\n\tif hs0.ScalarMult(kp.PrivateKey).Equal(c0) {\n\t\t//password is ok\n\n\t\tc1 := hs1.ScalarMult(kp.PrivateKey)\n\n\t\tresponse = &VerifyPasswordResponse{\n\t\t\tRes: true,\n\t\t\tC1: c1.Marshal(),\n\t\t\tProofSuccess: proveSuccess(kp, hs0, hs1, c0, c1),\n\t\t}\n\t\treturn\n\t}\n\n\t//password is invalid\n\n\tc1, proof, err := proveFailure(kp, c0, hs0)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tresponse = &VerifyPasswordResponse{\n\t\tRes: false,\n\t\tC1: c1.Marshal(),\n\t\tProofFail: proof,\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "5ca63e6cadea03598d263bf74c2630fe", "score": "0.42498454", "text": "func hashLen(u uint64, length, mls uint8) uint32 {\n\tswitch mls {\n\tcase 3:\n\t\treturn (uint32(u<<8) * prime3bytes) >> (32 - length)\n\tcase 5:\n\t\treturn uint32(((u << (64 - 40)) * prime5bytes) >> (64 - length))\n\tcase 6:\n\t\treturn uint32(((u << (64 - 48)) * prime6bytes) >> (64 - length))\n\tcase 7:\n\t\treturn uint32(((u << (64 - 56)) * prime7bytes) >> (64 - length))\n\tcase 8:\n\t\treturn uint32((u * prime8bytes) >> (64 - length))\n\tdefault:\n\t\treturn (uint32(u) * prime4bytes) >> (32 - length)\n\t}\n}", "title": "" }, { "docid": "08d6d61b8895eec6ca4790906dc03f2a", "score": "0.4248951", "text": "func getPrimes(limit int) *[]int {\n\tif limit < 2 {\n\t\treturn &[]int{}\n\t}\n\tif limit == 2 {\n\t\treturn &[]int{2}\n\t}\n\tif limit == 3 {\n\t\treturn &[]int{2, 3}\n\t}\n\tsieve := make([]bool, limit+1)\n\n\ttestingLimit := math.Ceil(math.Sqrt(float64(limit)))\n\n\tfor i := float64(0); i < testingLimit; i++ {\n\t\tfor j := float64(0); j < testingLimit; j++ {\n\n\t\t\tn := 4*int(math.Pow(i, 2)) + int(math.Pow(j, 2))\n\t\t\tif n <= limit && (n%12 == 1 || n%12 == 5) {\n\t\t\t\tsieve[n] = !sieve[n]\n\t\t\t}\n\n\t\t\tn = int(3*math.Pow(i, 2)) + int(math.Pow(j, 2))\n\t\t\tif n <= limit && n%12 == 7 {\n\t\t\t\tsieve[n] = !sieve[n]\n\t\t\t}\n\n\t\t\tn = int(3*math.Pow(i, 2)) - int(math.Pow(j, 2))\n\t\t\tif n <= limit && i > j && n%12 == 11 {\n\t\t\t\tsieve[n] = !sieve[n]\n\t\t\t}\n\t\t}\n\t}\n\n\tfor i := 5; i < int(testingLimit); i++ {\n\t\tif sieve[i] == true {\n\t\t\tk := int(math.Pow(float64(i), 2))\n\t\t\tfor j := k; j <= limit; j += k {\n\t\t\t\tsieve[j] = false\n\t\t\t}\n\t\t}\n\t}\n\n\tprimes := []int{2, 3}\n\tfor i, isprime := range sieve {\n\t\tif isprime && i >= 5 {\n\t\t\tprimes = append(primes, i)\n\t\t}\n\t}\n\treturn &primes\n}", "title": "" }, { "docid": "d74712b9533b9863439b52ca5622e909", "score": "0.42471984", "text": "func F(x *big.Int) (*big.Int, error) {\n\t// Compute x^2\n\tx3p7 := Multiply(x, x)\n\tx3p7 = Mod(x3p7, CURVE.P)\n\t// Compute x^3\n\tx3p7 = Multiply(x3p7, x)\n\tx3p7 = Mod(x3p7, CURVE.P)\n\t// Compute X^3 + 7\n\tx3p7 = Add(x3p7, new(big.Int).SetInt64(7))\n\tx3p7 = Mod(x3p7, CURVE.P)\n\treturn x3p7, nil\n}", "title": "" }, { "docid": "e72732c9130a74032f6e727a68fac56a", "score": "0.42415357", "text": "func TestProverWithChallenge(t *testing.T) {\n\tdebugLog.SetOutput(os.Stdout)\n\tdefer debugLog.SetOutput(ioutil.Discard)\n\tn = 5\n\tp := NewProver(false)\n\tb := []byte(\"this is a commitment\")\n\t_, err := p.Write(b)\n\tif err != nil {\n\t\tt.Error(\"Error Writing Commitment: \", err)\n\t}\n\tres := make([]byte, Size)\n\t_, err = p.Read(res)\n\tif err != nil {\n\t\tt.Error(\"Error Reading Commitment Proof: \", err)\n\t}\n\tsrc := []byte(\"f1418ee0a1c3cd9b8a248334f2549a78bb967a4796efd638b870a0434b479254\")\n\texpected := make([]byte, hex.DecodedLen(len(src)))\n\t_, err = hex.Decode(expected, src)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tif !bytes.Equal(res, expected) {\n\t\tt.Error(\"Commitment Proof Not Correct.\\nResult: \", hex.EncodeToString(res), \"\\nExpected: \", hex.EncodeToString(expected))\n\t}\n}", "title": "" }, { "docid": "9464e3439bb11312e9db93028f3afed5", "score": "0.42292494", "text": "func checkPrime(input int) bool {\n\t//we create the factorCount variable\n\tfactorCount := 0\n\t//We loop through all the numbers from 1 to the input\n\tfor i := 1; i <= input; i++ {\n\t\t//If the input is perfectly divisible by i, i is a factor of the input. This could easily be changed to add the value of i, which is a factor of the input to a slice which stores all the factors of the input.\n\t\tif input%i == 0 {\n\t\t\tfactorCount++\n\t\t}\n\t}\n\t//if there are only two factors of the input, the input is prime so the checkprime function should return the bool true. This could also be done using the len() of a slice if you decided to add the factors of the input to a slice.\n\tif factorCount == 2 {\n\t\treturn true\n\t} else {\n\t\t//Otherwise return false\n\t\treturn false\n\t}\n}", "title": "" }, { "docid": "9e08210d50f2d476523e0b89661fa565", "score": "0.42274395", "text": "func verifyMac(h hash.Hash, mac []byte, value []byte) error {\n\th.Write(value)\n\tif hmac.Equal(h.Sum(nil), mac) {\n\t\treturn nil\n\t}\n\treturn errors.New(\"securecookie: the value is not valid\")\n}", "title": "" }, { "docid": "1a19f1efd3ecc444241c2fe969ce4a22", "score": "0.42247796", "text": "func (v *Verifier) Verify(proof []byte) error {\n\tif v.RangeCorrectness == nil || v.WellFormedness == nil {\n\t\treturn errors.New(\"please initialize issue action verifier correctly\")\n\t}\n\tip := &Proof{}\n\t// unmarshal proof\n\terr := ip.Deserialize(proof)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// verify WellFormedness proof\n\terr = v.WellFormedness.Verify(ip.WellFormedness)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"invalid issue proof\")\n\t}\n\t// verify RangeCorrectness proof\n\terr = v.RangeCorrectness.Verify(ip.RangeCorrectness)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"invalid issue proof\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "ea28873e61a2cbcc9bc7169983dd31b7", "score": "0.4224073", "text": "func Prove(m []byte, sk *[SecretKeySize]byte) (vrf, proof []byte) {\n\tvar pk [PublicKeySize]byte\n\tcopy(pk[:], sk[PublicKeySize:])\n\tpi, err := vrf_ed25519.ECVRF_prove(pk[:], sk[:], m)\n\tif err != nil {\n\t\treturn nil, nil\n\t}\n\treturn vrf_ed25519.ECVRF_proof2hash(pi), pi\n}", "title": "" }, { "docid": "e6399b7d2861ce60c64a8bf9806b65b7", "score": "0.4223615", "text": "func (s *SMT) verifyMerkleProof(ap [][]byte, height int, key, value []byte) []byte {\n\tif height == 0 {\n\t\treturn value\n\t}\n\tif bitIsSet(key, s.TrieHeight-height) {\n\t\treturn s.hash(ap[height-1], s.verifyMerkleProof(ap, height-1, key, value))\n\t}\n\treturn s.hash(s.verifyMerkleProof(ap, height-1, key, value), ap[height-1])\n}", "title": "" }, { "docid": "c3e2edcb048d5714c20a181abce771fd", "score": "0.421705", "text": "func CheckMagicNums(m *Message) error {\n\n // Verify the two numbers are correct.\n if m.First == 'P' && m.Second == 'O' {\n return nil\n }\n\n // Return an error that they are different.\n return errors.New(\"Magic nums different!\\n\")\n}", "title": "" } ]
c8603fb38500157595f353cf143882d6
Deprecated: Use ReplicationFactor.Descriptor instead.
[ { "docid": "67c18ac466572cf25d58c1db75ad87aa", "score": "0.57460284", "text": "func (ReplicationFactor) EnumDescriptor() ([]byte, []int) {\n\treturn file_hdds_proto_rawDescGZIP(), []int{7}\n}", "title": "" } ]
[ { "docid": "a1cd4c469a6161f3bafb235a264699b8", "score": "0.5644701", "text": "func (*RemoveReplicaRequest) Descriptor() ([]byte, []int) {\n\treturn file_peering_proto_rawDescGZIP(), []int{12}\n}", "title": "" }, { "docid": "6377ddd5b28e469c387deb6485931370", "score": "0.5598179", "text": "func (*MembershipFeatureSpec) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_gkehub_v1alpha_feature_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "60e0d546b3a8b91137831ab6fe2c6f96", "score": "0.55769175", "text": "func (*RestoreClusterRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{17}\n}", "title": "" }, { "docid": "a760a792c82237dcf065fb4d7b3b56a1", "score": "0.5516938", "text": "func (*RestoreClusterMetadata) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{18}\n}", "title": "" }, { "docid": "1110839885e9ae7c6a0b21971bff372c", "score": "0.5508173", "text": "func (*Replication) Descriptor() ([]byte, []int) {\n\treturn file_full_snapshot_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "63711c66c161cdc653c72886aaa919d8", "score": "0.54862404", "text": "func (*RemoveReplicaRequest) Descriptor() ([]byte, []int) {\n\treturn file_middleware_proto_rawDescGZIP(), []int{13}\n}", "title": "" }, { "docid": "a5559eef44ad56648cebc0de41d94b4a", "score": "0.546122", "text": "func (*CoreFactorReference) Descriptor() ([]byte, []int) {\n\treturn file_dps_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "d88210dfe6c9ad2990c5fe67afbbfb13", "score": "0.54236823", "text": "func (*ClusterSpecifierPlugin) Descriptor() ([]byte, []int) {\n\treturn file_envoy_config_route_v3_route_components_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "6c23a809795df24fd29b83da97f2841d", "score": "0.54135376", "text": "func (*ClusterDetails) Descriptor() ([]byte, []int) {\n\treturn file_proto_resource_manager_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "4176ecf3bb9afec3759d3ef4e6f623f8", "score": "0.54091793", "text": "func (*AddReplicaRequest) Descriptor() ([]byte, []int) {\n\treturn file_peering_proto_rawDescGZIP(), []int{11}\n}", "title": "" }, { "docid": "5c5e288adedfcc9cf101eba1c53c0f61", "score": "0.539239", "text": "func (*PatchDatasetVersionsRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{89}\n}", "title": "" }, { "docid": "983cc53f9247c26367dbd9ec911ef8a0", "score": "0.5389075", "text": "func (*PatchCollaboratorsRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{23}\n}", "title": "" }, { "docid": "01e125d364e24914f4f1b170582c1755", "score": "0.53810865", "text": "func (*RestoreClusterRequest_RecoveryTargetSpec) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{17, 1}\n}", "title": "" }, { "docid": "44aeba3f263d63b0fc92080835b5d0c4", "score": "0.534815", "text": "func (*DeleteK8SClusterRes) Descriptor() ([]byte, []int) {\n\treturn file_proto_resource_manager_proto_rawDescGZIP(), []int{62}\n}", "title": "" }, { "docid": "e18c7e49fda1a199d98787301b9d67f7", "score": "0.53352934", "text": "func (*KeygroupReplica) Descriptor() ([]byte, []int) {\n\treturn file_middleware_proto_rawDescGZIP(), []int{12}\n}", "title": "" }, { "docid": "c9ac399b63293e16c9c0e6df4d40f548", "score": "0.5335246", "text": "func (*DiscoveryOverride) Descriptor() ([]byte, []int) {\n\treturn file_github_com_solo_io_gloo_projects_gloo_api_v1_enterprise_options_extauth_v1_extauth_proto_rawDescGZIP(), []int{13}\n}", "title": "" }, { "docid": "db4537daeeb2a9efa382f5017815e8b0", "score": "0.5332069", "text": "func (*PlanAssignmentChange_Removed) Descriptor() ([]byte, []int) {\n\treturn edgelq_limits_proto_v1alpha2_plan_assignment_change_proto_rawDescGZIP(), []int{0, 3}\n}", "title": "" }, { "docid": "f046de814d7c2a7aa450bf570b07c4d5", "score": "0.53247666", "text": "func (*MaintenanceOperation) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_postgresql_v1_maintenance_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "0c8776d71d8619e75970f87d5353c16c", "score": "0.53236026", "text": "func (*RecordSetDiff) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_dns_v1_dns_zone_service_proto_rawDescGZIP(), []int{16}\n}", "title": "" }, { "docid": "13cada07e34adbd394d41bd8b4a34468", "score": "0.5315675", "text": "func (*RenameInstanceRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_baremetalsolution_v2_instance_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "2caa057923a164592c7a94f8edd5001e", "score": "0.5303407", "text": "func (*DeleteClusterMetadata) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "70525233580fc77ebbe6476e329cf5de", "score": "0.52970827", "text": "func (*Subscription) Descriptor() ([]byte, []int) {\n\treturn file_study_service_study_service_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "c4561845f83ae0389f1299135c5696fa", "score": "0.5295473", "text": "func (*PrivateCloud_ManagementCluster) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_vmwareengine_v1_vmwareengine_resources_proto_rawDescGZIP(), []int{2, 0}\n}", "title": "" }, { "docid": "209fbf68bf4ab20d712ed1e096a15fa8", "score": "0.52869177", "text": "func (*UpdateClusterRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "769dc7352cf8796289e56ab8a6101b07", "score": "0.5284599", "text": "func (*Subscription) Descriptor() ([]byte, []int) {\n\treturn file_pkg_api_v1_scdpb_scd_proto_rawDescGZIP(), []int{52}\n}", "title": "" }, { "docid": "d6132d7cb36c5520b7a7cba4c8f84827", "score": "0.5282128", "text": "func (*AddReplicaRequest) Descriptor() ([]byte, []int) {\n\treturn file_middleware_proto_rawDescGZIP(), []int{9}\n}", "title": "" }, { "docid": "01e9ce8279e905edfc2b4c4d5228dbbc", "score": "0.5281918", "text": "func (*MembershipFeatureState) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_gkehub_v1alpha_feature_proto_rawDescGZIP(), []int{6}\n}", "title": "" }, { "docid": "67afee121021d1e86fa5c7384933b71d", "score": "0.5279868", "text": "func (*PatchCollectorsRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{244}\n}", "title": "" }, { "docid": "0e209ef935e85d9f02fdee37f546e3ed", "score": "0.5277465", "text": "func (*UpdateClusterMetadata) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{6}\n}", "title": "" }, { "docid": "8f77d9b628526e0c0a64ea175ac6dc35", "score": "0.5262924", "text": "func (*DeleteClusterRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{7}\n}", "title": "" }, { "docid": "ba6e028852c07a5e6406d1133a1f3a25", "score": "0.52608454", "text": "func (*TcpClusterRewrite) Descriptor() ([]byte, []int) {\n\treturn file_envoy_config_filter_network_tcp_cluster_rewrite_v2alpha1_config_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "f7569b136bc56d52e3fb159220efff4d", "score": "0.5257853", "text": "func (*DeprecateDomainRequest) Descriptor() ([]byte, []int) {\n\treturn file_uber_cadence_api_v1_service_domain_proto_rawDescGZIP(), []int{9}\n}", "title": "" }, { "docid": "bc9ccd7e1ff1f1cf45198c7bcf3068fd", "score": "0.52482754", "text": "func (*Cluster) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_vmwareengine_v1_vmwareengine_resources_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "82d86a078f3c10368c984c2cfb49d8d9", "score": "0.52423507", "text": "func (*ResetupHostsRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{45}\n}", "title": "" }, { "docid": "17c5584eda6fe1291a55a23196715d74", "score": "0.5238295", "text": "func (*ReplToken_ReplID) Descriptor() ([]byte, []int) {\n\treturn file_client_proto_rawDescGZIP(), []int{3, 1}\n}", "title": "" }, { "docid": "8f9d2290dba860f33dc01f58f071facb", "score": "0.5236557", "text": "func (*LimitChange_Removed) Descriptor() ([]byte, []int) {\n\treturn edgelq_limits_proto_v1alpha2_limit_change_proto_rawDescGZIP(), []int{0, 3}\n}", "title": "" }, { "docid": "8f279c17a5b262ec45c3d11732ea02d8", "score": "0.5228207", "text": "func (*UpgradeInstanceRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_datafusion_v1beta1_v1beta1_proto_rawDescGZIP(), []int{14}\n}", "title": "" }, { "docid": "1b90bb949b9395f22a10c0d3ba186d03", "score": "0.5227771", "text": "func (*ListClusterOperationsRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{26}\n}", "title": "" }, { "docid": "8709f4bbb2911f95484ed8709f284799", "score": "0.5224505", "text": "func (*ListClustersRes) Descriptor() ([]byte, []int) {\n\treturn file_proto_resource_manager_proto_rawDescGZIP(), []int{11}\n}", "title": "" }, { "docid": "795f1acc1e39e055774b9f0c31289dc8", "score": "0.5218389", "text": "func (*CUPSRedirection_ClientTLS) Descriptor() ([]byte, []int) {\n\treturn file_ttn_lorawan_v3_deviceclaimingserver_proto_rawDescGZIP(), []int{9, 0}\n}", "title": "" }, { "docid": "3ae7d5fa4aad66fdca6133b8aa99bfa2", "score": "0.521116", "text": "func (*GetReplicaRequest) Descriptor() ([]byte, []int) {\n\treturn file_middleware_proto_rawDescGZIP(), []int{14}\n}", "title": "" }, { "docid": "6ddf86a133f78144bd02a38cc50be1e9", "score": "0.5193293", "text": "func (*Warning_ReplacedId) Descriptor() ([]byte, []int) {\n\treturn file_ncbi_datasets_v1alpha1_datasets_proto_rawDescGZIP(), []int{35, 0}\n}", "title": "" }, { "docid": "87b9fc1ef1fb43e9944e68d0ee4ad279", "score": "0.5192757", "text": "func (*ChangeOperationReferenceResponse) Descriptor() ([]byte, []int) {\n\treturn file_pkg_api_v1_scdpb_scd_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "cba1197f463ef0800bcdc7202499d102", "score": "0.5189328", "text": "func (*ConfigRequest_V1_Deprecated) Descriptor() ([]byte, []int) {\n\treturn file_config_elasticsearch_config_request_proto_rawDescGZIP(), []int{0, 0, 23}\n}", "title": "" }, { "docid": "2961c3d9b547fcbbe0132270ab96155a", "score": "0.51885045", "text": "func (*DeleteK8SClusterReq) Descriptor() ([]byte, []int) {\n\treturn file_proto_resource_manager_proto_rawDescGZIP(), []int{61}\n}", "title": "" }, { "docid": "ed13664c1b414e3693dd0850d43a064a", "score": "0.51881796", "text": "func (*ResourceChange_Removed) Descriptor() ([]byte, []int) {\n\treturn edgelq_meta_proto_v1alpha2_resource_change_proto_rawDescGZIP(), []int{0, 3}\n}", "title": "" }, { "docid": "4bc72f72a3e7f66aef88d34d7be431a2", "score": "0.51872706", "text": "func (a *Adapter) setDescriptor(ctx context.Context, project, name string, desc *metricpb.MetricDescriptor) error {\n\tdesc.Name = fmt.Sprintf(\"projects/%s/metricDescriptors/%s\", project, desc.Type)\n\n\tcurrent, err := a.getDescriptor(ctx, project, name)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error while getting descriptor for %s: %s\", name, err)\n\t}\n\t// Metric descriptors cannot be updated in-place, and deleting a descriptor requries the metric\n\t// to not be used for alerts. This is why the descriptor is only deleted and recreated if absolutely\n\t// necessary, i.e. when metric kind or value type is different.\n\tif current.GetMetricKind() == desc.GetMetricKind() && current.GetValueType() == desc.GetValueType() {\n\t\treturn nil\n\t}\n\tif current != nil {\n\t\tlog.WithContext(ctx).Infof(\"Deleting existing metric descriptor (%v) which is different from desired (%v)\", current, desc)\n\t\terr = a.c.DeleteMetricDescriptor(ctx, &monitoringpb.DeleteMetricDescriptorRequest{Name: current.Name})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"DeleteMetricDescriptor error: %s\", err)\n\t\t}\n\t}\n\tlog.WithContext(ctx).Infof(\"Creating a new metric descriptor: %v\", desc.Name)\n\t_, err = a.c.CreateMetricDescriptor(ctx, &monitoringpb.CreateMetricDescriptorRequest{\n\t\tName: fmt.Sprintf(\"projects/%s\", project),\n\t\tMetricDescriptor: desc,\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"CreateMetricDescriptor error: %s, descriptor: %v\", err, desc)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "68127e3e8962402b6673dba8f057810f", "score": "0.5185365", "text": "func (*CopyReplicaRequest) Descriptor() ([]byte, []int) {\n\treturn file_fileservice_definition_proto_rawDescGZIP(), []int{19}\n}", "title": "" }, { "docid": "4d3e6fa59489809326054a83afe19aa8", "score": "0.51850253", "text": "func (*RestartHostsRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{47}\n}", "title": "" }, { "docid": "d989746877a7e6db9571a0a23120047e", "score": "0.5184625", "text": "func (*Subscription_Channel) Descriptor() ([]byte, []int) {\n\treturn file_proto_google_fhir_proto_stu3_resources_proto_rawDescGZIP(), []int{108, 0}\n}", "title": "" }, { "docid": "d65db8dd1f24b867094d20b2ce49a2e2", "score": "0.5183895", "text": "func (*DeleteDatasetVersion) Descriptor() ([]byte, []int) {\n\treturn file_modeldb_DatasetVersionService_proto_rawDescGZIP(), []int{9}\n}", "title": "" }, { "docid": "eb21c24d3436a4e4720f04d8cd73854f", "score": "0.51819617", "text": "func (*PortSelector) Descriptor() ([]byte, []int) {\n\treturn file_authentication_v1alpha1_policy_proto_rawDescGZIP(), []int{7}\n}", "title": "" }, { "docid": "229b36654d2a0be256cc94e0642907a3", "score": "0.5170378", "text": "func (*PatchConceptsRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{37}\n}", "title": "" }, { "docid": "af1007373a0a03b88085067b932e2049", "score": "0.5166026", "text": "func (*StepdownHostsRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{49}\n}", "title": "" }, { "docid": "7aade83cf9a548a1ce9264845f4f0f40", "score": "0.51640785", "text": "func (*SubscriberToNotify) Descriptor() ([]byte, []int) {\n\treturn file_pkg_api_v1_scdpb_scd_proto_rawDescGZIP(), []int{51}\n}", "title": "" }, { "docid": "c29e98391c146d39e70c4d6bc9fcc701", "score": "0.5162321", "text": "func (*DeleteClusterHostsMetadata) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{35}\n}", "title": "" }, { "docid": "1496a51cc771e3dc9d72e104d9c890fb", "score": "0.5158183", "text": "func (*BackupClusterRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{15}\n}", "title": "" }, { "docid": "d95a9e9958ff7708b464912b07d51036", "score": "0.5158135", "text": "func (*DeleteDatasetVersions) Descriptor() ([]byte, []int) {\n\treturn file_modeldb_DatasetVersionService_proto_rawDescGZIP(), []int{10}\n}", "title": "" }, { "docid": "08acdf7f69cb87ee497faa6d2866c26e", "score": "0.51537716", "text": "func (*RescheduleMaintenanceRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{19}\n}", "title": "" }, { "docid": "96931703ecc06fd09ea2f916f536736f", "score": "0.515352", "text": "func (*StreamClusterLogsRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{25}\n}", "title": "" }, { "docid": "0dcc5ccf72b7449ab805c52fb8c53999", "score": "0.5149985", "text": "func (*ChangeConstraintReferenceResponse) Descriptor() ([]byte, []int) {\n\treturn file_pkg_api_v1_scdpb_scd_proto_rawDescGZIP(), []int{2}\n}", "title": "" }, { "docid": "10c06b8dc4081e2d66a73d5facc4d20e", "score": "0.5148917", "text": "func (*ListClustersRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{1}\n}", "title": "" }, { "docid": "023907a94b4482e8d7f6a2933615580d", "score": "0.514775", "text": "func (*PSMDBClusterParams_ReplicaSet) Descriptor() ([]byte, []int) {\n\treturn file_controller_psmdb_cluster_proto_rawDescGZIP(), []int{0, 0}\n}", "title": "" }, { "docid": "60469ef1333a948ef8209b9c9ec7584c", "score": "0.514765", "text": "func (*MeshExpansionConfiguration_ClusterServices) Descriptor() ([]byte, []int) {\n\treturn file_api_v1alpha1_istiocontrolplane_proto_rawDescGZIP(), []int{4, 2}\n}", "title": "" }, { "docid": "e375339c7a0e88a2500f857579b1f5bf", "score": "0.51448685", "text": "func (x *fastReflection_Subspace) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_Subspace\n}", "title": "" }, { "docid": "b6df4a1a3516eceaec9255fe7f765c7a", "score": "0.51437217", "text": "func (*Cluster) Descriptor() ([]byte, []int) {\n\treturn file_cloud_visionai_v1_data_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "7eb186cf35590c4afddaacc72382d6f8", "score": "0.51433545", "text": "func (*DeleteFeatureRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_gkehub_v1beta_service_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "03927bcc90dd6a7a75382933f8852da8", "score": "0.5141554", "text": "func (*NotificationSubscriptions) Descriptor() ([]byte, []int) {\n\treturn file_study_service_study_service_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "daabb07faf0915fb83fd6a4a95da5168", "score": "0.5140678", "text": "func (*DeleteIDPConnectorRequest) Descriptor() ([]byte, []int) {\n\treturn file_identity_identity_proto_rawDescGZIP(), []int{15}\n}", "title": "" }, { "docid": "c5b261114c18ece4f758012cc53d9b99", "score": "0.5134363", "text": "func (*ListClusterOperationsResponse) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{27}\n}", "title": "" }, { "docid": "566a6d6d1a53cabedbfd24213c0d3765", "score": "0.5127458", "text": "func (*Candidate) Descriptor() ([]byte, []int) {\n\treturn file_grpc_service_candidate_service_proto_rawDescGZIP(), []int{7}\n}", "title": "" }, { "docid": "3dde2619d7f5cfe856d5318eed8a7ca0", "score": "0.5125242", "text": "func (*RescheduleMaintenanceMetadata) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{20}\n}", "title": "" }, { "docid": "5da229d7591afa2f06aca847d4eca0a2", "score": "0.5121432", "text": "func (*MoveClusterRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{13}\n}", "title": "" }, { "docid": "8a2cdb97180809fef1c0f625f585a32a", "score": "0.5120813", "text": "func (*ResetupHostsMetadata) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{46}\n}", "title": "" }, { "docid": "d96ec58ee75e73e5abbf61e475691d93", "score": "0.51197356", "text": "func (*Features) Descriptor() ([]byte, []int) {\n\treturn file_messages_management_proto_rawDescGZIP(), []int{2}\n}", "title": "" }, { "docid": "bceae7c796f4b6fe1bd16e9b8164cad3", "score": "0.51139355", "text": "func (*DomainRegistrarChange) Descriptor() ([]byte, []int) {\n\treturn file_nominet_nominet_proto_rawDescGZIP(), []int{9}\n}", "title": "" }, { "docid": "a6c6228d8e755cd7af53434cf08563b1", "score": "0.51128244", "text": "func (ReplicationType) EnumDescriptor() ([]byte, []int) {\n\treturn file_hdds_proto_rawDescGZIP(), []int{6}\n}", "title": "" }, { "docid": "73b5b85de95d9e3348b6196ea2fd8021", "score": "0.511264", "text": "func (*ListClustersReq) Descriptor() ([]byte, []int) {\n\treturn file_proto_resource_manager_proto_rawDescGZIP(), []int{10}\n}", "title": "" }, { "docid": "6f3b7f81aaa04a100c3830ee4022e363", "score": "0.5111813", "text": "func (*TopicGroup) Descriptor() ([]byte, []int) {\n\treturn file_server_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "5f937b5ac87aae3ff3d1f4b0f195d5d4", "score": "0.5111515", "text": "func (*MoveClusterMetadata) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{14}\n}", "title": "" }, { "docid": "1eef6ca01dba79ca21e26615df8430b8", "score": "0.51102394", "text": "func (*DeleteSubscriptionRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_api_v1_scdpb_scd_proto_rawDescGZIP(), []int{10}\n}", "title": "" }, { "docid": "08677c93282b92a2ac49e5f66288675e", "score": "0.5103898", "text": "func (*DeleteClusterHostsRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{34}\n}", "title": "" }, { "docid": "14269b0c346ee1b2bc288ba31cad0871", "score": "0.51034707", "text": "func (*DeleteDatasetVersionsRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{90}\n}", "title": "" }, { "docid": "0b0a7b00e75cea405e8bc1859fa64178", "score": "0.5101741", "text": "func (*PlanAssignmentChange_Added) Descriptor() ([]byte, []int) {\n\treturn edgelq_limits_proto_v1alpha2_plan_assignment_change_proto_rawDescGZIP(), []int{0, 0}\n}", "title": "" }, { "docid": "5b6b6363747c5d2583d7c9cd87c9bde7", "score": "0.5099872", "text": "func (*AddClusterHostsRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{32}\n}", "title": "" }, { "docid": "cfb682fbb3212b3d4f8e71cb553244c4", "score": "0.5091923", "text": "func (*GetKeygroupReplicaRequest) Descriptor() ([]byte, []int) {\n\treturn file_middleware_proto_rawDescGZIP(), []int{10}\n}", "title": "" }, { "docid": "e7016f70777108f7548ac0ef6cab54e5", "score": "0.5091442", "text": "func (*OperationReference) Descriptor() ([]byte, []int) {\n\treturn file_pkg_api_v1_scdpb_scd_proto_rawDescGZIP(), []int{29}\n}", "title": "" }, { "docid": "75d67b4acd63590b7760fe43865357be", "score": "0.5087818", "text": "func (*PlanAssignmentChange_Modified) Descriptor() ([]byte, []int) {\n\treturn edgelq_limits_proto_v1alpha2_plan_assignment_change_proto_rawDescGZIP(), []int{0, 1}\n}", "title": "" }, { "docid": "70563f0696c94cd795e247e77aeae63a", "score": "0.50829786", "text": "func (*RateLimit_Action_SourceCluster) Descriptor() ([]byte, []int) {\n\treturn file_envoy_config_route_v3_route_components_proto_rawDescGZIP(), []int{17, 0, 0}\n}", "title": "" }, { "docid": "267e6074742dfc634915946cc0e30d1a", "score": "0.50778246", "text": "func (*ListClustersResponse) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{2}\n}", "title": "" }, { "docid": "b15408c0ea50eb4bad8e52953b2c6ce3", "score": "0.5076589", "text": "func (*ClusterMetadata) Descriptor() ([]byte, []int) {\n\treturn file_proto_resource_manager_proto_rawDescGZIP(), []int{12}\n}", "title": "" }, { "docid": "d2c7fb0179a5e1e4b010031fef46007d", "score": "0.5073464", "text": "func (*CDNCluster) Descriptor() ([]byte, []int) {\n\treturn file_pkg_rpc_manager_manager_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "2229bd4970eded19cf95e280fa7b5745", "score": "0.50710934", "text": "func (*ClientConnectorService) Descriptor() ([]byte, []int) {\n\treturn file_cloud_beyondcorp_clientconnectorservices_v1_data_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "71a8edb36273b4dec917713581826175", "score": "0.5070303", "text": "func (*GetClusterDetailsRes) Descriptor() ([]byte, []int) {\n\treturn file_proto_resource_manager_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "8c7847dc5719bac3dd48722bb1eb77fe", "score": "0.5064197", "text": "func (*GetClusterRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "50f4430e823adfc6783cb2f0a279b33c", "score": "0.5061372", "text": "func (*BackupClusterMetadata) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_mdb_mongodb_v1_cluster_service_proto_rawDescGZIP(), []int{16}\n}", "title": "" }, { "docid": "787e83b171e1aa10916b2ec9536d8aca", "score": "0.50612634", "text": "func (*DeprecateDomainResponse) Descriptor() ([]byte, []int) {\n\treturn file_uber_cadence_api_v1_service_domain_proto_rawDescGZIP(), []int{10}\n}", "title": "" }, { "docid": "86d9be39bcb8a387ea33cc49931235d6", "score": "0.50603306", "text": "func (*ScalePolicy_FixedScale) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_ydb_v1_database_proto_rawDescGZIP(), []int{5, 0}\n}", "title": "" }, { "docid": "7f3cd24dedd8d35bf198eccfbb35286e", "score": "0.5057995", "text": "func (*ReadFeatureValuesResponse_FeatureDescriptor) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_aiplatform_v1beta1_featurestore_online_service_proto_rawDescGZIP(), []int{4, 0}\n}", "title": "" }, { "docid": "fff44a74e8471b16dbb6fc233c470269", "score": "0.50551176", "text": "func (*IDPConnector) Descriptor() ([]byte, []int) {\n\treturn file_identity_identity_proto_rawDescGZIP(), []int{6}\n}", "title": "" } ]
46e3520f0b59afb097b751efb6f1979b
ValidateBasic does a simple and lightweight validation check that doesn't require access to any other information.
[ { "docid": "f5966fc508bd92954ef1703e4de15164", "score": "0.7006532", "text": "func (tx StdTx) ValidateBasic() sdk.Error {\n\tstdSigs := tx.GetSignature()\n\tif tx.Fee.IsValid() == false {\n\t\treturn sdk.ErrInsufficientFee(fmt.Sprintf(\"invalid fee %s amount provided\", tx.Fee.String()))\n\t}\n\tif len(stdSigs.Signature) == 0 {\n\t\treturn sdk.ErrUnauthorized(\"empty signature\")\n\t}\n\treturn nil\n}", "title": "" } ]
[ { "docid": "bf7137d012adec693dd5fb36dc5cc1ef", "score": "0.82066107", "text": "func (v *Validator) ValidateBasic() error {\n\tif v == nil {\n\t\treturn errors.New(\"nil validator\")\n\t}\n\n\tif v.ProTxHash == nil {\n\t\treturn errors.New(\"validator does not have a provider transaction hash\")\n\t}\n\n\tif v.VotingPower < 0 {\n\t\treturn errors.New(\"validator has negative voting power\")\n\t}\n\n\tif len(v.ProTxHash) != crypto.DefaultHashSize {\n\t\treturn fmt.Errorf(\"validator proTxHash is the wrong size: %v\", len(v.ProTxHash))\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "f08faf5443e0d1367783a00eb506b3b0", "score": "0.7627422", "text": "func (proof MerkleProof) ValidateBasic() error {\n\tif proof.IsEmpty() {\n\t\treturn ErrInvalidProof\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "9598760d68ee71520481149d09670338", "score": "0.7612281", "text": "func (p *Params) ValidateBasic() error {\n\tif err := validateVotePeriod(p.VotePeriod); err != nil {\n\t\treturn err\n\t}\n\tif err := validateVoteThreshold(p.VoteThreshold); err != nil {\n\t\treturn err\n\t}\n\tif err := validateSlashWindow(p.SlashWindow); err != nil {\n\t\treturn err\n\t}\n\tif err := validateMinValidPerWindow(p.MinValidPerWindow); err != nil {\n\t\treturn err\n\t}\n\tif err := validateSlashFraction(p.SlashFraction); err != nil {\n\t\treturn err\n\t}\n\tif err := validateTargetThreshold(p.TargetThreshold); err != nil {\n\t\treturn err\n\t}\n\n\treturn validateDataTypes(p.DataTypes)\n}", "title": "" }, { "docid": "3cceaaea9f51396f925a71c227f76d93", "score": "0.7603115", "text": "func (p Params) ValidateBasic() error {\n\tif err := validateBeansPerUnit(p.BeansPerUnit); err != nil {\n\t\treturn err\n\t}\n\tif err := validateFeeUnitPrice(p.FeeUnitPrice); err != nil {\n\t\treturn err\n\t}\n\tif err := validateBootstrapVatConfig(p.BootstrapVatConfig); err != nil {\n\t\treturn err\n\t}\n\tif err := validatePowerFlagFees(p.PowerFlagFees); err != nil {\n\t\treturn err\n\t}\n\tif err := validateQueueMax(p.QueueMax); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "f193b3b70b334bf86b7147a2a2c6d84a", "score": "0.7469424", "text": "func (msg MsgLoad) ValidateBasic() sdk.Error {\n\tif len(msg.Account) == 0 {\n\t\treturn sdk.ErrInvalidAddress(\"Account address is empty\")\n\t}\n\n\tif !msg.Amount.IsPositive() {\n\t\treturn sdk.ErrInvalidCoins(\"Amount is not positive\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "e7ed72fa76e2d21fb97e02ad96f2d886", "score": "0.745858", "text": "func (msg MsgCreateValidator) ValidateBasic() error {\n\tif len(msg.Name) == 0 {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, \"Name and/or Value cannot be empty\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "ef3ff8db39c1449321442d738cdd88d1", "score": "0.74378884", "text": "func (msg MsgClaimHardRewardVVesting) ValidateBasic() error {\n\tif msg.Sender.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"sender address cannot be empty\")\n\t}\n\tif msg.Receiver.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"receiver address cannot be empty\")\n\t}\n\treturn MultiplierName(strings.ToLower(msg.MultiplierName)).IsValid()\n}", "title": "" }, { "docid": "2d8727d4fc750f1b79942ee0f57c8887", "score": "0.74153566", "text": "func (msg MsgClaimDelegatorRewardVVesting) ValidateBasic() error {\n\tif msg.Sender.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"sender address cannot be empty\")\n\t}\n\tif msg.Receiver.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"receiver address cannot be empty\")\n\t}\n\treturn MultiplierName(strings.ToLower(msg.MultiplierName)).IsValid()\n}", "title": "" }, { "docid": "2ecf44517c7259576b8e43eee6d3f099", "score": "0.74125236", "text": "func (msg MsgBeginUnstake) ValidateBasic() sdk.Error {\n\tif msg.Address.Empty() {\n\t\treturn ErrNilApplicationAddr(DefaultCodespace)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "8fdd7e92eee11c07e7f631496ad68647", "score": "0.7376119", "text": "func (msg MsgUnVoteFact) ValidateBasic() sdk.Error {\n\tif msg.Voter.Empty() {\n\t\treturn sdk.ErrInvalidAddress(msg.Voter.String())\n\t}\n\tif len(msg.Title) == 0 {\n\t\treturn sdk.ErrUnknownRequest(\"Title cannot be empty\")\n\t}\n\tif len(msg.Title) >= 60 {\n\t\treturn sdk.ErrUnknownRequest(\"title cannot be more than 60 words\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "cf9261e34955ecf491625a188a96f34a", "score": "0.7367009", "text": "func (msg AddDidMsg) ValidateBasic() sdk.Error {\n\treturn nil\n}", "title": "" }, { "docid": "306af4fa8433088b8898ec77e57839b9", "score": "0.73651135", "text": "func (m MsgSubmitEvidenceBase) ValidateBasic() error {\n\tif m.Submitter.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, m.Submitter.String())\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "896c5d130389cdca8c2209b25e49939c", "score": "0.73620975", "text": "func (msg MsgClaimUSDXMintingRewardVVesting) ValidateBasic() error {\n\tif msg.Sender.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"sender address cannot be empty\")\n\t}\n\tif msg.Receiver.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"receiver address cannot be empty\")\n\t}\n\treturn MultiplierName(strings.ToLower(msg.MultiplierName)).IsValid()\n}", "title": "" }, { "docid": "6aa9329f7e66ea3a524f41551256591e", "score": "0.7355552", "text": "func (msg MsgUnjail) ValidateBasic() error {\n\tif _, err := sdk.ValAddressFromBech32(msg.ValidatorAddr); err != nil {\n\t\treturn sdkerrors.ErrInvalidAddress.Wrapf(\"validator input address: %s\", err)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "aacc4a0ccb119bc63877ec8f9adeff9f", "score": "0.73450553", "text": "func (msg MsgUpdateWhiteListValidator) ValidateBasic() error {\n\tif msg.CosmosSender == \"\" {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.CosmosSender)\n\t}\n\n\tif msg.Validator == \"\" {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Validator)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "ea6ea1fa6a2a350f0c7b1e288263739f", "score": "0.730863", "text": "func (msg MsgLike) ValidateBasic() sdk.Error {\n\tif msg.Liker.Empty() {\n\t\treturn sdk.ErrInvalidAddress(msg.Liker.String())\n\t}\n\tif len(msg.PostID) == 0 || msg.Created.IsZero() {\n\t\treturn sdk.ErrUnknownRequest(\"Post id, and/or time cannot be empty\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "3e47fd8c4dc3e1652a43bf944b6b70e1", "score": "0.72944474", "text": "func (rp RelayProof) ValidateBasic() sdk.Error {\n\t// verify the session block height is positive\n\tif rp.SessionBlockHeight < 1 {\n\t\treturn NewInvalidBlockHeightError(ModuleName)\n\t}\n\t// verify the public key format for the leaf\n\tif err := PubKeyVerification(rp.ServicerPubKey); err != nil {\n\t\treturn err\n\t}\n\t// verify the blockchain addr format\n\tif err := NetworkIdentifierVerification(rp.Blockchain); err != nil {\n\t\treturn err\n\t}\n\t// verify the request merkleHash format\n\tif err := HashVerification(rp.RequestHash); err != nil {\n\t\treturn err\n\t}\n\t// verify non negative index\n\tif rp.Entropy < 0 { // todo this is inefficient\n\t\treturn NewInvalidEntropyError(ModuleName)\n\t}\n\t// verify a valid token\n\tif err := rp.Token.Validate(); err != nil {\n\t\treturn NewInvalidTokenError(ModuleName, err)\n\t}\n\t// verify the client signature on the Proof\n\tif err := SignatureVerification(rp.Token.ClientPublicKey, rp.HashString(), rp.Signature); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "cc009a30eb4ad824b37b577295c2fe05", "score": "0.728844", "text": "func (msg MsgUnjail) ValidateBasic() sdk.Error {\n\tif msg.AppAddr.Empty() {\n\t\treturn ErrBadApplicationAddr(DefaultCodespace)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "ac4d19aaa0ed72c1ce3043aac521a78e", "score": "0.72792214", "text": "func (m *HasVoteMessage) ValidateBasic() error {\n\tif m.Height < 0 {\n\t\treturn errors.New(\"negative Height\")\n\t}\n\tif m.Round < 0 {\n\t\treturn errors.New(\"negative Round\")\n\t}\n\tif !types3.IsVoteTypeValid(m.Type) {\n\t\treturn errors.New(\"invalid Type\")\n\t}\n\tif m.Index < 0 {\n\t\treturn errors.New(\"negative Index\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "037f852a053c266b94785fdb73977123", "score": "0.7262067", "text": "func (m *VoteMessage) ValidateBasic() error {\n\treturn nil\n}", "title": "" }, { "docid": "5c1a4211cea9b566b02e8b3b56a32f78", "score": "0.72578293", "text": "func (msg MsgVoteFact) ValidateBasic() sdk.Error {\n\tif msg.Voter.Empty() {\n\t\treturn sdk.ErrInvalidAddress(msg.Voter.String())\n\t}\n\tif len(msg.Title) == 0 {\n\t\treturn sdk.ErrUnknownRequest(\"Title cannot be empty\")\n\t}\n\tif len(msg.Title) >= 60 {\n\t\treturn sdk.ErrUnknownRequest(\"title cannot be more than 60 words\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "1ae0ccc1b2c2256bb5e0dd1c2fcfa69f", "score": "0.72488457", "text": "func (tx StdTx) ValidateBasic() error {\n\tstdSigs := tx.GetSignatures()\n\n\tif tx.Fee.Gas > maxGasWanted {\n\t\treturn errors.Wrapf(ErrGasOverflow, \"%d > %d\", tx.Fee.Gas, maxGasWanted)\n\t}\n\n\tif tx.Fee.Amount.IsAnyNegative() {\n\t\treturn errors.Wrapf(ErrInsufficientFee, \"%s amount provided\", tx.Fee.Amount)\n\t}\n\n\tif len(stdSigs) == 0 {\n\t\treturn ErrNoSignatures\n\t}\n\n\tif len(stdSigs) != len(tx.GetSigners()) {\n\t\treturn ErrUnauthorized\n\t}\n\n\tif len(tx.Memo) > keys.DefaultMaxMemoCharacters {\n\t\treturn sdkerrors.ErrMemoTooLarge\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "b32821f2c2cbae1ea059373f86602107", "score": "0.7241285", "text": "func (msg AddEthWalletMsg) ValidateBasic() sdk.Error {\n\treturn nil\n}", "title": "" }, { "docid": "c2eebdf1841ae96861ee836921f9ff4b", "score": "0.72369194", "text": "func (m *HasVoteMessage) ValidateBasic() error {\n\tif m.Height < 0 {\n\t\treturn errors.New(\"Negative Height\")\n\t}\n\tif m.Round < 0 {\n\t\treturn errors.New(\"Negative Round\")\n\t}\n\t// if !types.IsVoteTypeValid(m.Type) {\n\t// \treturn errors.New(\"Invalid Type\")\n\t// }\n\tif m.Index < 0 {\n\t\treturn errors.New(\"Negative Index\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "f76c6f3b2012a26f3cff97814f39c166", "score": "0.7224133", "text": "func (msg MsgBurnToken) ValidateBasic() error {\n\treturn nil\n}", "title": "" }, { "docid": "453b49a842888e2a3863fdcd7362f6f4", "score": "0.720153", "text": "func (msg MsgImport) ValidateBasic() sdk.Error {\n\tif msg.FromAddress.Empty() {\n\t\treturn sdk.ErrInvalidAddress(msg.FromAddress.String())\n\t}\n\tif msg.ToAddress.Empty() {\n\t\treturn sdk.ErrInvalidAddress(msg.ToAddress.String())\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "47e6c664dc1e1268abc006b658bbcf21", "score": "0.71991926", "text": "func (msg MsgReg) ValidateBasic() sdk.Error {\n\tif len(msg.Sender) == 0 {\n\t\treturn sdk.NewError(DefaultCodespace, CodeInvalidInput, \"nil sender address\")\n\t}\n\tif msg.Ident == nil {\n\t\treturn sdk.NewError(DefaultCodespace, CodeInvalidInput, \"nil address address\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "2862d4a86b663bba05acf64bde727253", "score": "0.71741015", "text": "func (msg MsgLiquidate) ValidateBasic() error {\n\t_, err := sdk.AccAddressFromBech32(msg.Keeper)\n\tif err != nil {\n\t\treturn errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, \"invalid keeper address %s\", err)\n\t}\n\t_, err = sdk.AccAddressFromBech32(msg.Borrower)\n\tif err != nil {\n\t\treturn errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, \"invalid borrower address %s\", err)\n\t}\n\n\tif strings.TrimSpace(msg.CollateralType) == \"\" {\n\t\treturn errorsmod.Wrap(ErrInvalidCollateral, \"collateral type cannot be empty\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "5619bb3ab2aa2f52d557ee89ab038ee8", "score": "0.7156538", "text": "func (msg MsgBuyGold) ValidateBasic() error {\n\tif msg.Buyer.Empty() {\n\t\treturn sdkerrors.Wrapf(ErrInvalidBasicMsg, \"MsgBuyGold: Sender address must not be empty.\")\n\t}\n\tif msg.Amount.Empty() {\n\t\treturn sdkerrors.Wrapf(ErrInvalidBasicMsg, \"MsgBuyGold: Amount must not be empty.\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "d8e3f547b5014530535790e905ebfb06", "score": "0.7155359", "text": "func (msg MsgCoinSwap) ValidateBasic() sdk.Error {\n\n\treturn nil\n}", "title": "" }, { "docid": "7ef52752529432c91ecaf8ff0209fab2", "score": "0.7146692", "text": "func (msg MsgSend) ValidateBasic() sdk.Error {\n\tif len(msg.To) == 0 {\n\t\treturn sdk.ErrInvalidAddress(\"To address is empty\")\n\t}\n\tif !msg.Amount.IsPositive() {\n\t\treturn sdk.ErrInvalidCoins(\"Amount is not positive\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "d79f51bdaa9c9deb4e158b2f7685cd48", "score": "0.7143858", "text": "func (msg MsgCreateNFT) ValidateBasic() sdk.Error {\n\tif msg.Owner.Empty() {\n\t\treturn sdk.ErrInvalidAddress(msg.Owner.String())\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "92acae310f7e86d7ea5e6dd1a4360902", "score": "0.7127061", "text": "func (in Input) ValidateBasic() error {\n\tif _, err := sdk.AccAddressFromBech32(in.Address); err != nil {\n\t\treturn sdkerrors.ErrInvalidAddress.Wrapf(\"invalid input address: %s\", err)\n\t}\n\n\tif !in.Coins.IsValid() {\n\t\treturn errorsmod.Wrap(sdkerrors.ErrInvalidCoins, in.Coins.String())\n\t}\n\n\tif !in.Coins.IsAllPositive() {\n\t\treturn errorsmod.Wrap(sdkerrors.ErrInvalidCoins, in.Coins.String())\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "d1b34d2199ccae41a4d40434a9196925", "score": "0.71235293", "text": "func (m *NewRoundStepMessage) ValidateBasic() error {\n\tif m.Height < 0 {\n\t\treturn errors.New(\"Negative Height\")\n\t}\n\tif m.Round < 0 {\n\t\treturn errors.New(\"Negative Round\")\n\t}\n\t// if !m.Step.IsValid() {\n\t// \treturn errors.New(\"Invalid Step\")\n\t// }\n\n\t// NOTE: SecondsSinceStartTime may be negative\n\n\tif (m.Height == 1 && m.LastCommitRound != -1) ||\n\t\t(m.Height > 1 && m.LastCommitRound < -1) {\n\t\treturn errors.New(\"Invalid LastCommitRound (for 1st block: -1, for others: >= 0)\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "17bfbe8bb3255d4d22b7cf08ca0e7418", "score": "0.7120639", "text": "func (p PostPacketTx) ValidateBasic() error {\n\t// TODO\n\treturn nil\n}", "title": "" }, { "docid": "d682dae97e2e5b1eaca522a7f0fbf0fc", "score": "0.7120414", "text": "func (msg MsgPostPrice) ValidateBasic() error {\n\tif len(msg.From) == 0 {\n\t\treturn errorsmod.Wrap(sdkerrors.ErrInvalidAddress, \"sender address cannot be empty\")\n\t}\n\tif strings.TrimSpace(msg.MarketID) == \"\" {\n\t\treturn errors.New(\"market id cannot be blank\")\n\t}\n\tif msg.Price.IsNegative() {\n\t\treturn fmt.Errorf(\"price cannot be negative: %s\", msg.Price.String())\n\t}\n\tif msg.Expiry.Unix() <= 0 {\n\t\treturn errors.New(\"must set an expiration time\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "dc38c954f3ac558508a93773d386c61f", "score": "0.71176374", "text": "func (msg MsgUnfreezeToken) ValidateBasic() error {\n\treturn nil\n}", "title": "" }, { "docid": "ca3c58d75bed0fbc96c674ce3600223b", "score": "0.71038634", "text": "func (msg MsgSetVersion) ValidateBasic() error {\n\tif msg.Signer.Empty() {\n\t\treturn cosmos.ErrInvalidAddress(msg.Signer.String())\n\t}\n\tif err := msg.Version.Validate(); err != nil {\n\t\treturn cosmos.ErrUnknownRequest(err.Error())\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "e88ee8159a2d98f8f13ea5c41cd80440", "score": "0.7102574", "text": "func (m *VoteSetMaj23Message) ValidateBasic() error {\n\tif m.Height < 0 {\n\t\treturn errors.New(\"Negative Height\")\n\t}\n\tif m.Round < 0 {\n\t\treturn errors.New(\"Negative Round\")\n\t}\n\t// if !types.IsVoteTypeValid(m.Type) {\n\t// \treturn errors.New(\"Invalid Type\")\n\t// }\n\t// if err := m.BlockID.ValidateBasic(); err != nil {\n\t// \treturn fmt.Errorf(\"Wrong BlockID: %v\", err)\n\t// }\n\treturn nil\n}", "title": "" }, { "docid": "7a4543576319b96b8632737cb8e3d4b9", "score": "0.709384", "text": "func (p ECredentialPacketData) ValidateBasic() error {\n\n\t// TODO: Validate the packet data\n\n\treturn nil\n}", "title": "" }, { "docid": "9abf76ff26c424f46fd2b2ffd0434742", "score": "0.70841223", "text": "func (u UpdateChainTx) ValidateBasic() error {\n\terr := u.Commit.ValidateBasic(u.ChainID())\n\tif err != nil {\n\t\terr = ErrInvalidCommit(err)\n\t}\n\treturn err\n}", "title": "" }, { "docid": "12b2b18d68bad9fe81fb56d331351cfc", "score": "0.7082123", "text": "func (msg MsgEditFact) ValidateBasic() sdk.Error {\n\tif msg.Editor.Empty() {\n\t\treturn sdk.ErrInvalidAddress(msg.Editor.String())\n\t}\n\tif len(msg.Title) == 0 {\n\t\treturn sdk.ErrUnknownRequest(\"Title cannot be empty\")\n\t}\n\tif len(msg.Title) >= 60 {\n\t\treturn sdk.ErrUnknownRequest(\"title cannot be more than 60 words\")\n\t}\n\tif len(msg.Description) == 0 {\n\t\treturn sdk.ErrUnknownRequest(\"description cannot be empty\")\n\t}\n\tif len(msg.Description) >= 280 {\n\t\treturn sdk.ErrUnknownRequest(\"description cannot be more than 280 words\")\n\t}\n\tif msg.Time == 0 {\n\t\treturn sdk.ErrUnknownRequest(\"Time cannot be empty\")\n\t}\n\tif len(msg.Place) == 0 {\n\t\treturn sdk.ErrUnknownRequest(\"Place cannot be empty\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "9a77d012e1632a32101a74d639cbb3cb", "score": "0.70724803", "text": "func (msg MsgLock) ValidateBasic() error {\n\tif strconv.Itoa(msg.EthereumChainID) == \"\" {\n\t\treturn sdkerrors.Wrapf(ErrInvalidEthereumChainID, \"%d\", msg.EthereumChainID)\n\t}\n\n\tif msg.CosmosSender.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.CosmosSender.String())\n\t}\n\n\tif msg.EthereumReceiver.String() == \"\" {\n\t\treturn ErrInvalidEthAddress\n\t}\n\n\tif !gethCommon.IsHexAddress(msg.EthereumReceiver.String()) {\n\t\treturn ErrInvalidEthAddress\n\t}\n\n\tif msg.Amount <= 0 {\n\t\treturn ErrInvalidAmount\n\t}\n\n\tif len(msg.Symbol) == 0 {\n\t\treturn ErrInvalidSymbol\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "0677f62134d5c23cdafe60329b3889f8", "score": "0.70471746", "text": "func (msg MsgSubmitMisbehaviour) ValidateBasic() error {\n\t_, err := sdk.AccAddressFromBech32(msg.Signer)\n\tif err != nil {\n\t\treturn sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, \"string could not be parsed as address: %v\", err)\n\t}\n\tmisbehaviour, err := UnpackMisbehaviour(msg.Misbehaviour)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := misbehaviour.ValidateBasic(); err != nil {\n\t\treturn err\n\t}\n\tif misbehaviour.GetClientID() != msg.ClientId {\n\t\treturn sdkerrors.Wrapf(\n\t\t\tErrInvalidMisbehaviour,\n\t\t\t\"misbehaviour client-id doesn't match client-id from message (%s ≠ %s)\",\n\t\t\tmisbehaviour.GetClientID(), msg.ClientId,\n\t\t)\n\t}\n\n\treturn host.ClientIdentifierValidator(msg.ClientId)\n}", "title": "" }, { "docid": "323b7d3dc353fd2fbe0a60ef5146465d", "score": "0.7036934", "text": "func (r RegisterChainTx) ValidateBasic() error {\n\terr := r.Commit.ValidateBasic(r.ChainID())\n\tif err != nil {\n\t\terr = ErrInvalidCommit(err)\n\t}\n\treturn err\n}", "title": "" }, { "docid": "29fbad84c59343a0b62070d242b9ef2c", "score": "0.70312065", "text": "func (p VerifiableCredentialPacketData) ValidateBasic() error {\n\n\t// TODO: Validate the packet data\n\n\treturn nil\n}", "title": "" }, { "docid": "c1a993fe7c5f6f14f11379c7883eea92", "score": "0.70287895", "text": "func (msg MsgInfo) ValidateBasic() sdk.Error {\n\tif msg.Sender.Empty() {\n\t\treturn sdk.ErrInvalidAddress(msg.Sender.String())\n\t}\n\n\tif msg.Receiver.Empty() {\n\t\treturn sdk.ErrInvalidAddress(msg.Receiver.String())\n\t}\n\n\tif msg.Receiver.Equals(msg.Sender) {\n\t\treturn ErrCantShareWithSelf(\"cannot share info with self\")\n\t}\n\n\tif len(msg.Data) == 0 {\n\t\treturn ErrDataCannotBeEmpty(\"info data cannot be empty\")\n\t}\n\n\tif len(msg.Data) > MaxDataSize {\n\t\treturn ErrDataSizeOverLimit(\"info data size is over the limit of %d bytes\", MaxDataSize)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "f6762a709d50468f89f1df02b6ee3ac0", "score": "0.70184755", "text": "func (m *VoteMessage) ValidateBasic() error {\n\treturn m.Vote.ValidateBasic()\n}", "title": "" }, { "docid": "6fedd4bd17a36544065777b68e553913", "score": "0.7015792", "text": "func (m *MsgUpsertTokenAlias) ValidateBasic() error {\n\treturn nil\n}", "title": "" }, { "docid": "8f2bb001c1da29a37a61d6f7c1613561", "score": "0.7010447", "text": "func (msg MsgCreateScavenge) ValidateBasic() error {\n\tif msg.Creator.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"create is empty\")\n\t}\n\n\tif msg.SolutionHash == \"\" {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, \"solution hash is empty\")\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "10e0ff095245d3c105811ec7a2cbdf43", "score": "0.69922775", "text": "func (m *MsgRegisterRequest) ValidateBasic() error {\n\tif m.From == \"\" {\n\t\treturn sdkerrors.Wrap(ErrorInvalidMessage, \"from cannot be empty\")\n\t}\n\tif _, err := sdk.AccAddressFromBech32(m.From); err != nil {\n\t\treturn sdkerrors.Wrap(ErrorInvalidMessage, err.Error())\n\t}\n\tif m.Name == \"\" {\n\t\treturn sdkerrors.Wrap(ErrorInvalidMessage, \"name cannot be empty\")\n\t}\n\tif len(m.Name) > 64 {\n\t\treturn sdkerrors.Wrapf(ErrorInvalidMessage, \"name length cannot be greater than %d chars\", 64)\n\t}\n\tif len(m.Identity) > 64 {\n\t\treturn sdkerrors.Wrapf(ErrorInvalidMessage, \"identity length cannot be greater than %d chars\", 64)\n\t}\n\tif len(m.Website) > 64 {\n\t\treturn sdkerrors.Wrapf(ErrorInvalidMessage, \"website length cannot be greater than %d chars\", 64)\n\t}\n\tif m.Website != \"\" {\n\t\tif _, err := url.ParseRequestURI(m.Website); err != nil {\n\t\t\treturn sdkerrors.Wrap(ErrorInvalidMessage, err.Error())\n\t\t}\n\t}\n\tif len(m.Description) > 256 {\n\t\treturn sdkerrors.Wrapf(ErrorInvalidMessage, \"description length cannot be greater than %d chars\", 256)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "d382e5234134e55cd7d8d63de394dae5", "score": "0.6964949", "text": "func (msg MsgSignTx) ValidateBasic() error {\n\tif len(msg.Signers) == 0 {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"missing signers\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "9a2181c83b8f791797100534e9a0a9a8", "score": "0.6964785", "text": "func (msg MsgSetSourceChannel) ValidateBasic() error {\n\t// TODO: Add validate basic\n\treturn nil\n}", "title": "" }, { "docid": "7cdf50b6bbce2560f7ecacb785b41f55", "score": "0.69642544", "text": "func (msg MsgUnlike) ValidateBasic() sdk.Error {\n\tif msg.Liker.Empty() {\n\t\treturn sdk.ErrInvalidAddress(msg.Liker.String())\n\t}\n\tif len(msg.ID) == 0 || msg.Time.IsZero() {\n\t\treturn sdk.ErrUnknownRequest(\"Like id, and/or time cannot be empty\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "6f729d83a858cf09c37449c42cfe6570", "score": "0.69595265", "text": "func (p CreatePacketTx) ValidateBasic() error {\n\tif p.DestChain == \"\" {\n\t\treturn ErrWrongDestChain(p.DestChain)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "caae9a5b9f905e24160b52b94ee74f58", "score": "0.69414794", "text": "func (msg MsgClaimHardReward) ValidateBasic() error {\n\tif msg.Sender.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"sender address cannot be empty\")\n\t}\n\treturn MultiplierName(strings.ToLower(msg.MultiplierName)).IsValid()\n}", "title": "" }, { "docid": "b0b38ef3af7fba52677f746f2fb0dc02", "score": "0.69391", "text": "func (msg MsgFreezeAccount) ValidateBasic() error {\n\treturn nil\n}", "title": "" }, { "docid": "792451ed9bff24be18a590f44ec4b1e5", "score": "0.69375634", "text": "func (msg MsgTrade) ValidateBasic() sdk.Error {\n\tif len(msg.Sender) == 0 {\n\t\treturn sdk.ErrUnknownAddress(msg.Sender.String()).TraceSDK(\"\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "e2cb81fc86d6eccf475d4aa06323fe26", "score": "0.69356644", "text": "func (msg MsgSetTrust) ValidateBasic() sdk.Error {\n\tif msg.Trustor == nil {\n\t\treturn ErrNilTrustorAddr(DefaultCodespace)\n\t}\n\tif msg.Trusting == nil {\n\t\treturn ErrNilTrustingAddr(DefaultCodespace)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "36bc87b64a03be2b66c44b8361cb2214", "score": "0.69324833", "text": "func (m *ProposalMessage) ValidateBasic() error {\n\treturn nil\n}", "title": "" }, { "docid": "738f88ae12e23a03fbd4effa4f609ed7", "score": "0.6929472", "text": "func (m *bcNoBlockResponseMessage) ValidateBasic() error {\n\tif m.Height < 0 {\n\t\treturn errors.New(\"negative Height\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "47f88c2a461fde9ce8c410a08fe8af86", "score": "0.69217265", "text": "func (msg MsgLock) ValidateBasic() error {\n\tif strconv.FormatInt(msg.EthereumChainId, 10) == \"\" {\n\t\treturn sdkerrors.Wrapf(ErrInvalidEthereumChainID, \"%d\", msg.EthereumChainId)\n\t}\n\n\tif msg.CosmosSender == \"\" {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.CosmosSender)\n\t}\n\n\tif msg.EthereumReceiver == \"\" {\n\t\treturn ErrInvalidEthAddress\n\t}\n\n\tif !gethCommon.IsHexAddress(msg.EthereumReceiver) {\n\t\treturn ErrInvalidEthAddress\n\t}\n\n\tif msg.Amount.LTE(sdk.NewInt(0)) {\n\t\treturn ErrInvalidAmount\n\t}\n\n\t// if you don't pay enough gas, this tx won't go through\n\tif msg.CethAmount.LT(sdk.NewInt(lockGasCost)) {\n\t\treturn ErrCethAmount\n\t}\n\n\tif len(msg.Symbol) == 0 {\n\t\treturn ErrInvalidSymbol\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "2fe7965bdf42b390bd9524e144c263b0", "score": "0.69185734", "text": "func (msg MsgClaimUSDXMintingReward) ValidateBasic() error {\n\tif msg.Sender.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"sender address cannot be empty\")\n\t}\n\treturn MultiplierName(strings.ToLower(msg.MultiplierName)).IsValid()\n}", "title": "" }, { "docid": "23a24162d1ee795a735f4a5c198bb8a1", "score": "0.6915822", "text": "func (m MsgAuthenticated) ValidateBasic() error {\n\treturn nil\n}", "title": "" }, { "docid": "9f724457869b22c6e06fd7fc0d912e65", "score": "0.69137585", "text": "func (msg MsgCreateDeployment) ValidateBasic() error {\n\tif err := msg.ID.Validate(); err != nil {\n\t\treturn err\n\t}\n\tif len(msg.Groups) == 0 {\n\t\treturn ErrInvalidGroups\n\t}\n\n\tif len(msg.Version) == 0 {\n\t\treturn ErrEmptyVersion\n\t}\n\n\tif len(msg.Version) != ManifestVersionLength {\n\t\treturn ErrInvalidVersion\n\t}\n\n\tfor _, gs := range msg.Groups {\n\t\terr := gs.ValidateBasic()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c9d3800cf6449286d760b179ea4a1e7b", "score": "0.6901654", "text": "func (msc MsgDeleteMasterNode) ValidateBasic() sdk.Error {\n\tif msc.Address == nil {\n\t\treturn sdk.ErrInvalidAddress(\"Address type is Invalid\")\n\t}\n\tif msc.Maddr == nil {\n\t\treturn sdk.ErrInvalidAddress(\"VPN Address type is Invalid\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "e9d990d3b904bf63adc4d84b4cbbc90f", "score": "0.6896595", "text": "func (msg MsgPostResponse) ValidateBasic() error {\n\tif msg.From.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"sender address cannot be empty\")\n\t}\n\tif strings.TrimSpace(msg.RequestID) == \"\" {\n\t\treturn errors.New(\"request id cannot be blank\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "f9b85289dffa3fc48e0cb3fa073719aa", "score": "0.68853736", "text": "func (msg MsgCreateFact) ValidateBasic() sdk.Error {\n\tif msg.Creator.Empty() {\n\t\treturn sdk.ErrInvalidAddress(msg.Creator.String())\n\t}\n\tif len(msg.Title) == 0 {\n\t\treturn sdk.ErrUnknownRequest(\"Title cannot be empty\")\n\t}\n\tif len(msg.Title) >= 60 {\n\t\treturn sdk.ErrUnknownRequest(\"title cannot be more than 60 words\")\n\t}\n\tif len(msg.Description) == 0 {\n\t\treturn sdk.ErrUnknownRequest(\"description cannot be empty\")\n\t}\n\tif len(msg.Description) >= 280 {\n\t\treturn sdk.ErrUnknownRequest(\"description cannot be more than 280 words\")\n\t}\n\tif msg.Time == 0 {\n\t\treturn sdk.ErrUnknownRequest(\"Time cannot be empty\")\n\t}\n\tif len(msg.Place) == 0 {\n\t\treturn sdk.ErrUnknownRequest(\"Place cannot be empty\")\n\t}\n\tif !msg.Bid.IsAllPositive() {\n\t\treturn sdk.ErrInsufficientCoins(\"Bids must be positive\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "e354a059dacfe21d7d8a5e48ca6df226", "score": "0.6884293", "text": "func (msg MsgRescueCeth) ValidateBasic() error {\n\tif msg.CosmosSender == \"\" {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.CosmosSender)\n\t}\n\n\tif msg.CosmosReceiver == \"\" {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.CosmosReceiver)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "4e6ec666707ea9e9ea45e75f15da7426", "score": "0.6873064", "text": "func (msg MsgDelete) ValidateBasic() sdk.Error {\n\tif msg.Address.Empty() {\n\t\treturn sdk.ErrInvalidAddress(msg.Address.String())\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "4ec3a295e112e5e4d058a8b7c1e84797", "score": "0.68730104", "text": "func (msg MsgDeposit) ValidateBasic() error {\n\tif msg.Owner.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"owner address cannot be empty\")\n\t}\n\tif msg.Depositor.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"sender address cannot be empty\")\n\t}\n\tif !msg.Collateral.IsValid() || msg.Collateral.IsZero() {\n\t\treturn sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, \"collateral amount %s\", msg.Collateral)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "038832dcc1e23f9137d294641b3b1d95", "score": "0.68599284", "text": "func (msg MsgPostSign) ValidateBasic() sdk.Error {\n\tif msg.Sender.Empty() {\n\t\treturn sdk.ErrInvalidAddress(msg.Sender.String())\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c76525d8e7cbcc5dcdbbc85620080309", "score": "0.6857447", "text": "func (msg MsgDecideSell) ValidateBasic() error {\n\tif msg.Signer.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer.String())\n\t}\n\tif len(msg.ReservationID) == 0 {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, \"ReservationID cannot be empty\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "e3f7e44dfd2b58cd76831f9a975861d9", "score": "0.6835822", "text": "func (m *bcStatusRequestMessage) ValidateBasic() error {\n\tif m.Height < 0 {\n\t\treturn errors.New(\"negative Height\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "b49ed68fe92a00bc46cc65caa1f01c16", "score": "0.68296665", "text": "func (msg *MsgUpdateParams) ValidateBasic() error {\n\tif _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil {\n\t\treturn sdkerrors.Wrap(err, \"invalid authority address\")\n\t}\n\n\tif err := msg.Params.Validate(); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "d6d980b199660f6fa09eaf483b607fc4", "score": "0.68255126", "text": "func (m *BlockPartMessage) ValidateBasic() error {\n\tif m.Height < 0 {\n\t\treturn errors.New(\"Negative Height\")\n\t}\n\tif m.Round < 0 {\n\t\treturn errors.New(\"Negative Round\")\n\t}\n\t// if err := m.Part.ValidateBasic(); err != nil {\n\t// \treturn fmt.Errorf(\"Wrong Part: %v\", err)\n\t// }\n\treturn nil\n}", "title": "" }, { "docid": "4a87bc428231786287be62d19097fe86", "score": "0.68253076", "text": "func (msg MsgPostPrice) ValidateBasic() sdk.Error {\n\tif msg.From.Empty() {\n\t\treturn sdk.ErrInternal(\"invalid (empty) bidder address\")\n\t}\n\tif len(msg.AssetCode) == 0 {\n\t\treturn sdk.ErrInternal(\"invalid (empty) asset code\")\n\t}\n\tif msg.Price.LT(sdk.ZeroDec()) {\n\t\treturn sdk.ErrInternal(\"invalid (negative) price\")\n\t}\n\tif msg.Expiry.LT(sdk.ZeroInt()) {\n\t\treturn sdk.ErrInternal(\"invalid (negative) expiry\")\n\t}\n\t// TODO check coin denoms\n\treturn nil\n}", "title": "" }, { "docid": "e10ed27c6c98188700e42eecbada3a0d", "score": "0.682253", "text": "func (msg MsgClaimDelegatorReward) ValidateBasic() error {\n\tif msg.Sender.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"sender address cannot be empty\")\n\t}\n\treturn MultiplierName(strings.ToLower(msg.MultiplierName)).IsValid()\n}", "title": "" }, { "docid": "7ac837e4d5fac315d83e0c4510e8c59e", "score": "0.6822073", "text": "func (msg MsgWithdraw) ValidateBasic() error {\n\tif msg.Owner.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"owner address cannot be empty\")\n\t}\n\tif msg.Depositor.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"sender address cannot be empty\")\n\t}\n\tif !msg.Collateral.IsValid() || msg.Collateral.IsZero() {\n\t\treturn sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, \"collateral amount %s\", msg.Collateral)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "d9622b3d26eb5828768c4f0a18c5ed2a", "score": "0.6821979", "text": "func (msg MsgCloseGroup) ValidateBasic() error {\n\tif err := msg.ID.Validate(); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "7ccdc8fe354373c77e0d38112aed4d2d", "score": "0.6816694", "text": "func (m MsgUpdateBasketFee) ValidateBasic() error {\n\tif _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {\n\t\treturn errors.Wrapf(err, \"invalid authority address\")\n\t}\n\n\tif m.Fee != nil {\n\t\tif err := m.Fee.Validate(); err != nil {\n\t\t\treturn sdkerrors.ErrInvalidRequest.Wrapf(\"%s\", err)\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "0ae05144def99e09cf5aae05d1917db5", "score": "0.68160117", "text": "func (msg MsgDrawDebt) ValidateBasic() error {\n\tif msg.Sender.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"sender address cannot be empty\")\n\t}\n\tif strings.TrimSpace(msg.CdpDenom) == \"\" {\n\t\treturn errors.New(\"cdp denom cannot be blank\")\n\t}\n\tif msg.Principal.IsZero() || !msg.Principal.IsValid() {\n\t\treturn sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, \"principal amount %s\", msg.Principal)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "f4130f15092854b6480a3da2793402c9", "score": "0.6810884", "text": "func (msg MsgMimir) ValidateBasic() sdk.Error {\n\tif msg.Key == \"\" {\n\t\treturn sdk.ErrUnknownRequest(\"key cannot be empty\")\n\t}\n\tif msg.Signer.Empty() {\n\t\treturn sdk.ErrInvalidAddress(msg.Signer.String())\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "42df2f5f3eef38871f4d3f6636f5d6f0", "score": "0.6809229", "text": "func (m *BlockPartMessage) ValidateBasic() error {\n\tif m.Height < 0 {\n\t\treturn errors.New(\"negative Height\")\n\t}\n\tif m.Round < 0 {\n\t\treturn errors.New(\"negative Round\")\n\t}\n\tif err := m.Part.ValidateBasic(); err != nil {\n\t\treturn fmt.Errorf(\"wrong Part: %v\", err)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "56908f494b015aa95d85160937e58950", "score": "0.6802223", "text": "func (msg MsgDeposit) ValidateBasic() error {\n\t_, err := sdk.AccAddressFromBech32(msg.Owner)\n\tif err != nil {\n\t\treturn errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, \"invalid owner address %s\", err)\n\t}\n\t_, err = sdk.AccAddressFromBech32(msg.Depositor)\n\tif err != nil {\n\t\treturn errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, \"invalid depositor address %s\", err)\n\t}\n\n\tif !msg.Collateral.IsValid() || msg.Collateral.IsZero() {\n\t\treturn errorsmod.Wrapf(sdkerrors.ErrInvalidCoins, \"collateral amount %s\", msg.Collateral)\n\t}\n\tif strings.TrimSpace(msg.CollateralType) == \"\" {\n\t\treturn fmt.Errorf(\"collateral type cannot be empty\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "4111842062f8a15fcf102f9447f020ab", "score": "0.6800766", "text": "func (msg MsgCreatePost) ValidateBasic() error {\n\tif msg.Creator.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, fmt.Sprintf(\"invalid creator address: %s\", msg.Creator))\n\t}\n\n\tif len(strings.TrimSpace(msg.Message)) == 0 && len(msg.Attachments) == 0 && msg.PollData == nil {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidRequest,\n\t\t\t\"post message, attachments or poll are required and cannot be all blank or empty\")\n\t}\n\n\tif !commons.IsValidSubspace(msg.Subspace) {\n\t\treturn sdkerrors.Wrap(postserrors.ErrInvalidSubspace, \"post subspace must be a valid sha-256 hash\")\n\t}\n\n\tif msg.Attachments != nil {\n\t\tif err := msg.Attachments.Validate(); err != nil {\n\t\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())\n\t\t}\n\t}\n\n\tif msg.PollData != nil {\n\t\tif err := msg.PollData.Validate(); err != nil {\n\t\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "ba05fb65be6f76d45f0a51c79d93839a", "score": "0.6800553", "text": "func (msg MsgIBCSignTx) ValidateBasic() error {\n\tif len(msg.Signers) == 0 {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, \"missing signers\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "46af01d7e76da45c3c3a955ca6ec293b", "score": "0.6790856", "text": "func (msg MsgUpdateDeployment) ValidateBasic() error {\n\tif err := msg.ID.Validate(); err != nil {\n\t\treturn err\n\t}\n\n\tif len(msg.Version) == 0 {\n\t\treturn ErrEmptyVersion\n\t}\n\n\tif len(msg.Version) != ManifestVersionLength {\n\t\treturn ErrInvalidVersion\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "41135d538f8e4e77cb4cb8c6adf75642", "score": "0.67868465", "text": "func (out Output) ValidateBasic() error {\n\tif _, err := sdk.AccAddressFromBech32(out.Address); err != nil {\n\t\treturn sdkerrors.ErrInvalidAddress.Wrapf(\"invalid output address: %s\", err)\n\t}\n\n\tif !out.Coins.IsValid() {\n\t\treturn errorsmod.Wrap(sdkerrors.ErrInvalidCoins, out.Coins.String())\n\t}\n\n\tif !out.Coins.IsAllPositive() {\n\t\treturn errorsmod.Wrap(sdkerrors.ErrInvalidCoins, out.Coins.String())\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "38be89e0cd93e7a54a915dd0db3506df", "score": "0.67844707", "text": "func (msg MsgSetSale) ValidateBasic() error {\n\tif msg.Owner.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Owner.String())\n\t}\n\tif len(msg.Name) == 0 ||\n\t\t!IsSaleTypeValid(msg.SaleType) ||\n\t\tmsg.Price.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, \"Illegal parameters\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "15112df05fc05770e0651fc782778ec6", "score": "0.67839074", "text": "func (msg MsgCreatePost) ValidateBasic() sdk.Error {\n\tif msg.Owner.Empty() {\n\t\treturn sdk.ErrInvalidAddress(msg.Owner.String())\n\t}\n\tif len(msg.Message) == 0 {\n\t\treturn sdk.ErrUnknownRequest(\"Post message cannot be empty\")\n\t}\n\tif msg.Created.IsZero() {\n\t\treturn sdk.ErrUnknownRequest(\"The created time cannot be empty\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "04418a1ed00ae3fc949b22dd1e9df357", "score": "0.6780195", "text": "func (msg MsgStake) ValidateBasic() sdk.Error {\n\tif msg.PubKey == nil || msg.PubKey.RawString() == \"\" {\n\t\treturn ErrNilApplicationAddr(DefaultCodespace)\n\t}\n\tif msg.Value.LTE(sdk.ZeroInt()) {\n\t\treturn ErrBadStakeAmount(DefaultCodespace)\n\t}\n\tif len(msg.Chains) == 0 {\n\t\treturn ErrNoChains(DefaultCodespace)\n\t}\n\tfor _, chain := range msg.Chains {\n\t\tif err := ValidateNetworkIdentifier(chain); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "7f8a9683650a3c407bd8ea31055b14f0", "score": "0.6779457", "text": "func (msg MsgCloseDeployment) ValidateBasic() error {\n\tif err := msg.ID.Validate(); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "e24a84d2c1ea45b5e52804c3419c1a37", "score": "0.6774622", "text": "func (msg MsgReportPost) ValidateBasic() error {\n\tif !msg.PostID.Valid() {\n\t\treturn sdkerrors.Wrap(postserrors.ErrInvalidPostID, msg.PostID.String())\n\t}\n\n\tif err := msg.Report.Validate(); err != nil {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "c66ce80c929d2d4a74a04df1d9b6575e", "score": "0.6773912", "text": "func (msg MsgCreateSell) ValidateBasic() error {\n\tif msg.Signer.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer.String())\n\t}\n\tif len(msg.SellID) == 0 || len(msg.ProductID) == 0 || msg.MinPrice.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, \"ProductID and/or SellID and/or MinPrice cannot be empty\")\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "56bb03298818c95e7f2526a6dbd426fd", "score": "0.6766704", "text": "func (p StoreCodeProposal) ValidateBasic() error {\n\tif err := validateProposalCommons(p.Title, p.Description); err != nil {\n\t\treturn err\n\t}\n\tif _, err := sdk.AccAddressFromBech32(p.RunAs); err != nil {\n\t\treturn sdkerrors.Wrap(err, \"run as\")\n\t}\n\n\tif err := validateWasmCode(p.WASMByteCode); err != nil {\n\t\treturn sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, \"code bytes %s\", err.Error())\n\t}\n\n\tif p.InstantiatePermission != nil {\n\t\tif err := p.InstantiatePermission.ValidateBasic(); err != nil {\n\t\t\treturn sdkerrors.Wrap(err, \"instantiate permission\")\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "d96460b08d0a3807b346948aa916b511", "score": "0.6758074", "text": "func (msg MsgWithdraw) ValidateBasic() error {\n\t_, err := sdk.AccAddressFromBech32(msg.Owner)\n\tif err != nil {\n\t\treturn errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, \"invalid owner address %s\", err)\n\t}\n\t_, err = sdk.AccAddressFromBech32(msg.Depositor)\n\tif err != nil {\n\t\treturn errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, \"invalid depositor address %s\", err)\n\t}\n\n\tif !msg.Collateral.IsValid() || msg.Collateral.IsZero() {\n\t\treturn errorsmod.Wrapf(sdkerrors.ErrInvalidCoins, \"collateral amount %s\", msg.Collateral)\n\t}\n\tif strings.TrimSpace(msg.CollateralType) == \"\" {\n\t\treturn fmt.Errorf(\"collateral type cannot be empty\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "2eae32a9f69498044636368bd8f4b2bb", "score": "0.6756417", "text": "func (msg MsgEditPost) ValidateBasic() error {\n\tif !msg.PostID.Valid() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf(\"Invalid post id: %s\", msg.PostID))\n\t}\n\n\tif msg.Editor.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, fmt.Sprintf(\"Invalid editor address: %s\", msg.Editor))\n\t}\n\n\tif len(strings.TrimSpace(msg.Message)) == 0 && len(msg.Attachments) == 0 && msg.PollData == nil {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidRequest,\n\t\t\t\"post message, attachments or poll are required and cannot be all blank or empty\")\n\t}\n\n\tif msg.Attachments != nil {\n\t\tif err := msg.Attachments.Validate(); err != nil {\n\t\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())\n\t\t}\n\t}\n\n\tif msg.PollData != nil {\n\t\tif err := msg.PollData.Validate(); err != nil {\n\t\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "4622ed79fe1ca2213898a9d110bd77dc", "score": "0.6749508", "text": "func (m *bcStatusResponseMessage) ValidateBasic() error {\n\tif m.Height < 0 {\n\t\treturn errors.New(\"negative Height\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "3620686cabdc1288adabe9415c03f881", "score": "0.6749398", "text": "func (msg MsgDeleteSell) ValidateBasic() error {\n\tif msg.Signer.Empty() {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer.String())\n\t}\n\tif len(msg.SellID) == 0 {\n\t\treturn sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, \"SellID cannot be empty\")\n\t}\n\treturn nil\n}", "title": "" } ]
3ec306e5dc86ac38d22a527d56eccef8
ErrUnknownValidators ErrUnknownValidators indicates that some validator set was missing or unknown.
[ { "docid": "e24631c4830b86506477ab4754382e1c", "score": "0.79265296", "text": "func ErrUnknownValidators(chainID string, height int64) error {\n\treturn cmn.ErrorWrap(errUnknownValidators{chainID, height}, \"\")\n}", "title": "" } ]
[ { "docid": "0313281f107d770f4a712772edf71ea5", "score": "0.67514795", "text": "func ErrUnexpectedValidators(got, want []byte) error {\n\treturn cmn.ErrorWrap(errUnexpectedValidators{\n\t\tgot: got,\n\t\twant: want,\n\t}, \"\")\n}", "title": "" }, { "docid": "1971fbb2dcd1b0bb899626a3075d0150", "score": "0.6062824", "text": "func (_Valset *ValsetSession) Validators(arg0 *big.Int) (common.Address, error) {\n\treturn _Valset.Contract.Validators(&_Valset.CallOpts, arg0)\n}", "title": "" }, { "docid": "f6dbff3957fe394b707b91d81e904ddc", "score": "0.5946219", "text": "func (_Valset *ValsetCaller) Validators(opts *bind.CallOpts, arg0 *big.Int) (common.Address, error) {\n\tvar (\n\t\tret0 = new(common.Address)\n\t)\n\tout := ret0\n\terr := _Valset.contract.Call(opts, out, \"validators\", arg0)\n\treturn *ret0, err\n}", "title": "" }, { "docid": "2ddcba352cc2fb6e3996d9e3eb0cfa1e", "score": "0.5938129", "text": "func (_Valset *ValsetCallerSession) Validators(arg0 *big.Int) (common.Address, error) {\n\treturn _Valset.Contract.Validators(&_Valset.CallOpts, arg0)\n}", "title": "" }, { "docid": "c0f77a099c4fe6e349f660b392f7e14b", "score": "0.5878656", "text": "func GetValidatorsMeta(c *gin.Context) {\n\texplorer := c.MustGet(\"explorer\").(*core.Explorer)\n\n\t// fetch validators\n\tvalidators := explorer.Cache.Get(\"validators-meta\", func() interface{} {\n\t\tvalidators := explorer.ValidatorRepository.GetValidators()\n\t\treturn resource.TransformCollection(validators, validator.Resource{})\n\t}, 120).([]resource.Interface)\n\n\tc.JSON(http.StatusOK, gin.H{\"data\": validators})\n}", "title": "" }, { "docid": "ddabaf088c4d736005d91f99923b710c", "score": "0.5669914", "text": "func WriteValidators(ctx sdk.Context, k keeper.Keeper) (vals []tmtypes.GenesisValidator, err error) {\n\tk.IterateLastValidators(ctx, func(_ int64, validator types.Validator) (stop bool) {\n\t\tpk, err := validator.ConsPubKey()\n\t\tif err != nil {\n\t\t\treturn true\n\t\t}\n\t\ttmPk, err := cryptocodec.ToTmPubKeyInterface(pk)\n\t\tif err != nil {\n\t\t\treturn true\n\t\t}\n\n\t\tmoniker, err := k.GetMonikerByAddress(ctx, sdk.AccAddress(validator.ValKey))\n\t\tif err != nil {\n\t\t\treturn false\n\t\t}\n\t\tvals = append(vals, tmtypes.GenesisValidator{\n\t\t\tAddress: sdk.ConsAddress(tmPk.Address()).Bytes(),\n\t\t\tPubKey: tmPk,\n\t\t\tName: moniker,\n\t\t})\n\n\t\treturn false\n\t})\n\n\treturn\n}", "title": "" }, { "docid": "b37086a3dcf129fd20d3ed24a8dfcef3", "score": "0.55910665", "text": "func GetValidators(\n\theight int64, stakingClient stakingtypes.QueryClient, cdc codec.Codec,\n) ([]stakingtypes.Validator, []types.Validator, error) {\n\treturn GetValidatorsWithStatus(height, \"\", stakingClient, cdc)\n}", "title": "" }, { "docid": "7c5e197d90f4f4c743b0ce01b880e59c", "score": "0.5570445", "text": "func UnknownValidator(name string) error {\n\treturn fmt.Errorf(\"unknown type [%s]\", name)\n}", "title": "" }, { "docid": "7c5e197d90f4f4c743b0ce01b880e59c", "score": "0.5570445", "text": "func UnknownValidator(name string) error {\n\treturn fmt.Errorf(\"unknown type [%s]\", name)\n}", "title": "" }, { "docid": "73bd9ec34e59433dfd8f2a0cc66729b7", "score": "0.5570244", "text": "func (state *Metastate) GetValidators() (validators []abci.Validator, err error) {\n\tfor pubkeyB64, power := range state.Validators {\n\t\tpkB, err := base64.StdEncoding.DecodeString(pubkeyB64)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"Metastate.GetValidators->decode pubkey b64\")\n\t\t}\n\t\tpk := abci.PubKey{}\n\t\terr = pk.Unmarshal(pkB)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"GetValidators: unmarshal public key\")\n\t\t}\n\n\t\t// transform pubkey to address\n\t\t// note that this conversion function is specifically marked as UNSTABLE\n\t\t// in the TM source, so we should expect this to break.\n\t\t// OTOH, there's apparently no stable way to make this conversion happen,\n\t\t// so here we are.\n\t\t// https://github.com/tendermint/tendermint/blob/0c9c3292c918617624f6f3fbcd95eceade18bcd5/types/protobuf.go#L170-L171\n\t\tvar tcpk crypto.PubKey\n\t\ttcpk, err = tmconv.PB2TM.PubKey(pk)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"GetValidators: convert tm.abci pk into tm.crypto pk\")\n\t\t}\n\t\taddress := tcpk.Address()\n\n\t\t// finish\n\t\tvalidators = append(validators, abci.Validator{\n\t\t\tAddress: address,\n\t\t\tPower: power,\n\t\t})\n\t}\n\treturn\n}", "title": "" }, { "docid": "820298c2438634a38ad033e4ee9544dc", "score": "0.55527776", "text": "func WriteValidators(ctx sdk.Context, keeper Keeper) (vals []tmtypes.GenesisValidator) {\n\tkeeper.IterateLastValidators(ctx, func(validator types.Validator) (stop bool) {\n\t\tvals = append(vals, tmtypes.GenesisValidator{\n\t\t\tPubKey: validator.GetConsPubKey(),\n\t\t\tPower: validator.GetPower(),\n\t\t\tName: validator.GetName(),\n\t\t})\n\n\t\treturn false\n\t})\n\n\treturn\n}", "title": "" }, { "docid": "fa05afac8157074cf8b9d0102c833c38", "score": "0.5497412", "text": "func GetAllValidators(rootDir, node, chainID string) string {\n\tkey := stake.ValidatorsKey\n\t//init a context\n\tcliCtx := newCLIContext(rootDir,node,chainID).\n\t\tWithCodec(cdc)\n\n\tresKVs, err := cliCtx.QuerySubspace(key, storeStake)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\t// parse out the validators\n\tvar validators []stake.Validator\n\tfor _, kv := range resKVs {\n\t\taddr := kv.Key[1:]\n\t\tvalidator := types.MustUnmarshalValidator(cdc, addr, kv.Value)\n\t\tvalidators = append(validators, validator)\n\t}\n\n\toutput, err := codec.MarshalJSONIndent(cdc, validators)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\treturn string(output)\n}", "title": "" }, { "docid": "6328fab440a5393fd1a898947895506c", "score": "0.5463031", "text": "func GetValidators(c *gin.Context) {\n\texplorer := c.MustGet(\"explorer\").(*core.Explorer)\n\n\t// fetch validators\n\tvalidators := explorer.Cache.Get(\"validators\", func() interface{} {\n\t\tvalidators := explorer.ValidatorRepository.GetValidatorsAndStakes()\n\n\t\tactiveValidatorIDs := getActiveValidatorIDs(explorer)\n\t\ttotalStake := getTotalStakeByActiveValidators(explorer, activeValidatorIDs)\n\n\t\t// add params to each model resource\n\t\tresourceCallback := func(model resource.ParamInterface) resource.ParamsInterface {\n\t\t\tv := model.(models.Validator)\n\t\t\tminStake := explorer.ValidatorService.GetMinStakesByValidator(&v)\n\n\t\t\tparams := validator.Params{\n\t\t\t\tMinStake: minStake,\n\t\t\t\tTotalStake: totalStake,\n\t\t\t\tActiveValidatorsIDs: activeValidatorIDs,\n\t\t\t}\n\n\t\t\treturn resource.ParamsInterface{params}\n\t\t}\n\n\t\treturn resource.TransformCollectionWithCallback(\n\t\t\tvalidators,\n\t\t\tvalidator.ResourceDetailed{},\n\t\t\tresourceCallback,\n\t\t)\n\t}, CacheBlocksCount).([]resource.Interface)\n\n\tc.JSON(http.StatusOK, gin.H{\"data\": validators})\n}", "title": "" }, { "docid": "f323df5a14230a2afacfde05f0847d1b", "score": "0.5457794", "text": "func (k Keeper) MaxValidators(sdk.Context) uint32 {\n\t// TODO: this needs to be calculated dynamically by code by looking around validator iterator?\n\t// This number was discussed with @asmo\n\treturn 1000\n}", "title": "" }, { "docid": "6f78cbecb544e7873e6ed110bb2686e7", "score": "0.53735095", "text": "func FilterValidators(\n\tindices set.Bits,\n\tvdrs []*Validator,\n) ([]*Validator, error) {\n\t// Verify that all alleged signers exist\n\tif indices.BitLen() > len(vdrs) {\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"%w: NumIndices (%d) >= NumFilteredValidators (%d)\",\n\t\t\tErrUnknownValidator,\n\t\t\tindices.BitLen()-1, // -1 to convert from length to index\n\t\t\tlen(vdrs),\n\t\t)\n\t}\n\n\tfilteredVdrs := make([]*Validator, 0, len(vdrs))\n\tfor i, vdr := range vdrs {\n\t\tif !indices.Contains(i) {\n\t\t\tcontinue\n\t\t}\n\n\t\tfilteredVdrs = append(filteredVdrs, vdr)\n\t}\n\treturn filteredVdrs, nil\n}", "title": "" }, { "docid": "94231f20f769e799be44625592d249b8", "score": "0.5322388", "text": "func (v Validators) Valid() bool {\n\tfor _, validator := range v {\n\t\tif !validator.Valid() {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "title": "" }, { "docid": "e5c76648a861ad4fbb41f1af62684d78", "score": "0.53155845", "text": "func validateSet(set DefinitionSet) error {\n\terrors := &ValidationErrors{}\n\tfor _, def := range set {\n\t\tif validate, ok := def.(Validate); ok {\n\t\t\tif err := validate.Validate(); err != nil {\n\t\t\t\terrors.AddError(def, err)\n\t\t\t}\n\t\t}\n\t}\n\terr := errors.AsError()\n\tif err != nil {\n\t\tErrors = append(Errors, &Error{GoError: err})\n\t}\n\treturn err\n}", "title": "" }, { "docid": "e478fac915e01219d76a0dcdcb7a960d", "score": "0.5295823", "text": "func (b SetNestedBlock) SetValidators() []validator.Set {\n\treturn b.Validators\n}", "title": "" }, { "docid": "bea61d8140abab4af6a1366d782f7842", "score": "0.52645147", "text": "func EncodeValidators(v ...Validator) EncoderOption {\n\treturn func(o *encoderOptions) {\n\t\to.validators = v\n\t}\n}", "title": "" }, { "docid": "363b9df0dffd4390377456a988370da6", "score": "0.5248988", "text": "func (k Keeper) MaxValidators(ctx sdk.Context) (res uint16) {\n\tk.paramstore.Get(ctx, types.KeyMaxValidators, &res)\n\treturn\n}", "title": "" }, { "docid": "f8fd1225e334a754fb385ab5ce3d1f42", "score": "0.522573", "text": "func (svc *Service) ListValidators(_ client.ListValidatorsRequest, reply *client.ListValidatorsReply) error {\n\tvalidators, err := svc.validators.GetValidatorSet()\n\tif err != nil {\n\t\tsvc.logger.Error(\"error listing validators\")\n\t\treturn codes.ErrListValidators\n\t}\n\n\tvMap := svc.evidenceStore.GetValidatorMap()\n\tfMap := svc.evidenceStore.GetFrozenMap()\n\n\t*reply = client.ListValidatorsReply{\n\t\tValidators: validators,\n\t\tHeight: svc.balances.State.Version(),\n\t\tVMap: vMap,\n\t\tFMap: fMap,\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "e2a616356eecb427dac26bbbe113720f", "score": "0.5199449", "text": "func (c Client) GetValidatorSet(height int64) (*tmctypes.ResultValidators, error) {\n\treturn c.rpcClient.Validators(context.Background(), &height, nil, nil)\n}", "title": "" }, { "docid": "4dcb52ce9e0526e0d299d74b85febcab", "score": "0.5187289", "text": "func (k Keeper) MaxValidators(ctx sdk.Ctx) (res uint64) {\n\tk.Paramstore.Get(ctx, types.KeyMaxValidators, &res)\n\treturn\n}", "title": "" }, { "docid": "e8d786e7d2d1e7cb53f8be29264e5b37", "score": "0.51501113", "text": "func (validators Validators) Validate(objs ...interface{}) (results []errors.ManifestResult) {\n\tfor _, validator := range validators {\n\t\tresults = append(results, validator.Validate(objs...)...)\n\t}\n\treturn results\n}", "title": "" }, { "docid": "446c42cf1d33b7aa53ed60fe20e351c8", "score": "0.5146976", "text": "func (ic *InquiringCertifier) Validators() *types.ValidatorSet {\n\treturn ic.cert.cert.vSet\n}", "title": "" }, { "docid": "06d589c4d097d216fb1a78dfdd569819", "score": "0.51375973", "text": "func addValidatorSet(ctx *server.Context, cdc *codec.Codec, genState genesis.GenesisState, startIndex int, validator []string) (genesis.GenesisState, error) {\n\tfor _, val := range validator {\n\t\tgenState.MaintenanceState.ValidatorSet = append(genState.MaintenanceState.ValidatorSet, val)\n\t}\n\treturn genState, nil\n}", "title": "" }, { "docid": "868fd2edee67ba87476e9fb0f55cf48b", "score": "0.51150054", "text": "func (x *fastReflection_QueryDelegatorValidatorsResponse) GetUnknown() protoreflect.RawFields {\n\treturn x.unknownFields\n}", "title": "" }, { "docid": "5b626683c85a2cccd9b00f41db5bff30", "score": "0.5113925", "text": "func (m Mappings) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tfor i := 0; i < len(m); i++ {\n\t\tif swag.IsZero(m[i]) { // not required\n\t\t\tcontinue\n\t\t}\n\n\t\tif m[i] != nil {\n\t\t\tif err := m[i].Validate(formats); err != nil {\n\t\t\t\tif ve, ok := err.(*errors.Validation); ok {\n\t\t\t\t\treturn ve.ValidateName(strconv.Itoa(i))\n\t\t\t\t}\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "376188af0b600fc831f4962172fec7c9", "score": "0.5096188", "text": "func (v *Validator) Errors() []*ValidationError { return v.errs }", "title": "" }, { "docid": "8e85b3cc7309decff9f89c9dddbd6b9e", "score": "0.5079815", "text": "func (k Keeper) IterateValidators(ctx sdk.Context,\n\thandler func(index int64, validator *types.Validator) (stop bool)) {\n\tvalidators := k.GetValidatorSet(ctx)\n\tfor i, val := range validators {\n\t\tif handler(int64(i), &val) {\n\t\t\tbreak\n\t\t}\n\t}\n}", "title": "" }, { "docid": "065bd62b902be313427c2dae2efd8eb0", "score": "0.50750667", "text": "func NewValidatorsBook() (v *ValidatorsBook) {\n\tvalsWithdraw := make(map[string]*protobufs.Transaction)\n\tvalsArray := make(map[string]*Validator)\n\treturn &ValidatorsBook{\n\t\tvalsWithdraw: valsWithdraw,\n\t\tvalsArray: valsArray,\n\t}\n}", "title": "" }, { "docid": "ee917304c042f21cbb57bc97963bea9f", "score": "0.5059", "text": "func (c Client) GetValidators() ([]*types.Validator, error) {\n\tstakingCli := staking.NewQueryClient(c.cosmosClient.QueryClient())\n\tresp, err := stakingCli.Validators(context.Background(), &staking.QueryValidatorsRequest{})\n\tif err != nil {\n\t\terr = errors.Wrap(err, \"failed to query validators from staking module\")\n\t\treturn nil, err\n\t}\n\n\tvals := make([]*types.Validator, 0, len(resp.Validators))\n\tfor _, val := range resp.Validators {\n\n\t\tv := &types.Validator{\n\t\t\tOperatorAddress: val.OperatorAddress, // string\n\t\t\tJailed: val.Jailed, // bool\n\t\t\tStatus: val.Status.String(), // string\n\t\t\tTokens: val.Tokens.String(), // string\n\t\t\tPower: val.ConsensusPower(sdk.NewInt(1000000000000000000)),\n\t\t\tDelegatorShares: val.DelegatorShares.String(), // string\n\t\t\tDescription: types.Description{\n\t\t\t\tMoniker: val.Description.Moniker,\n\t\t\t\tIdentity: val.Description.Identity,\n\t\t\t\tWebsite: val.Description.Website,\n\t\t\t\tDetails: val.Description.Details,\n\t\t\t}, // Description\n\t\t\tUnbondingHeight: val.UnbondingHeight, // int64\n\t\t\tUnbondingTime: val.UnbondingTime, // time.Time\n\t\t\tCommission: types.Commission{\n\t\t\t\tRate: val.Commission.Rate.String(),\n\t\t\t\tMaxRate: val.Commission.MaxRate.String(),\n\t\t\t\tMaxChangeRate: val.Commission.MaxChangeRate.String(),\n\t\t\t\tUpdateTime: val.Commission.UpdateTime,\n\t\t\t}, // Commission\n\t\t}\n\n\t\tvar pubKey cryptotypes.PubKey\n\t\tif err := c.ctx.InterfaceRegistry.UnpackAny(val.ConsensusPubkey, &pubKey); err != nil {\n\t\t\terr = errors.Wrap(err, \"failed to unpack val cons pubkey\")\n\t\t\treturn nil, err\n\t\t}\n\n\t\tv.ConsensusPubKey = sdk.MustBech32ifyAddressBytes(chaintypes.Bech32PrefixConsPub, pubKey.Bytes())\n\n\t\tvals = append(vals, v)\n\t}\n\n\treturn vals, nil\n}", "title": "" }, { "docid": "0a7a6545d6ee73ddc0928f5ecb2e1d33", "score": "0.5058314", "text": "func getBech32Validators(storeName string, cliCtx context.CLIContext, cdc *wire.Codec) (\n\tvalidators []types.BechValidator, httpStatusCode int, errMsg string, err error) {\n\n\t// Get all validators using key\n\tkvs, err := cliCtx.QuerySubspace(stake.ValidatorsKey, storeName)\n\tif err != nil {\n\t\treturn nil, http.StatusInternalServerError, \"couldn't query validators. Error: \", err\n\t}\n\n\t// the query will return empty if there are no validators\n\tif len(kvs) == 0 {\n\t\treturn nil, http.StatusNoContent, \"\", nil\n\t}\n\n\tvalidators, err = getValidators(kvs, cdc)\n\tif err != nil {\n\t\treturn nil, http.StatusInternalServerError, \"Error: \", err\n\t}\n\treturn validators, http.StatusOK, \"\", nil\n}", "title": "" }, { "docid": "4253221abb31a0b55857ae234fa28753", "score": "0.5022745", "text": "func UpdateValidators(\n\theight int64, client stakingtypes.QueryClient, cdc codec.Codec, db *database.Db,\n) ([]stakingtypes.Validator, error) {\n\tlog.Debug().Str(\"module\", \"staking\").Int64(\"height\", height).\n\t\tMsg(\"updating validators\")\n\n\tvals, validators, err := GetValidators(height, client, cdc)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = db.SaveValidatorsData(validators)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn vals, err\n}", "title": "" }, { "docid": "35e3c7c9c96650fd487ba13f9eb05ab2", "score": "0.50106096", "text": "func getAuthValidators(config *serverConfig) *validator.Validators {\n\tvalidators := validator.NewValidators()\n\n\tif config.OpenID.JWKS.URL != nil {\n\t\tvalidators.Add(validator.NewJWT(config.OpenID.JWKS))\n\t}\n\n\treturn validators\n}", "title": "" }, { "docid": "9eb91399af0d4ef4e93c29099aecd1e8", "score": "0.49875137", "text": "func (validators Validators) WithValidators(vals ...Validator) Validators {\n\treturn append(vals, validators...)\n}", "title": "" }, { "docid": "53602f4725f85eecbcf04be3f8944615", "score": "0.4984199", "text": "func (x *fastReflection_GetLatestValidatorSetResponse) GetUnknown() protoreflect.RawFields {\n\treturn x.unknownFields\n}", "title": "" }, { "docid": "cd41f159b2b11032426ed3ce68bc8829", "score": "0.49603453", "text": "func CombinedValidator(validators ...Validator) Validator {\n\treturn Validators(validators)\n}", "title": "" }, { "docid": "aa47756daac4c205224e0f5aced0c216", "score": "0.4954491", "text": "func GetErrorMessages(err error) string {\n\tvar msg string\n\tfor _, errz := range err.(validator.ValidationErrors) {\n\t\t// Build the custom errors here\n\t\tswitch tag := errz.ActualTag(); tag {\n\t\tcase \"required\":\n\t\t\tmsg = errz.StructField() + \" is required.\"\n\t\tcase \"email\":\n\t\t\tmsg = errz.StructField() + \" is an invalid email address.\"\n\t\tcase \"min\":\n\t\t\tif errz.Type().Kind() == reflect.String {\n\t\t\t\tmsg = errz.StructField() + \" must be more than or equal to \" + errz.Param() + \" character(s).\"\n\t\t\t} else {\n\t\t\t\tmsg = errz.StructField() + \" must be larger than \" + errz.Param() + \".\"\n\t\t\t}\n\t\tcase \"max\":\n\t\t\tif errz.Type().Kind() == reflect.String {\n\t\t\t\tmsg = errz.StructField() + \" must be lesser than or equal to \" + errz.Param() + \" character(s).\"\n\t\t\t} else {\n\t\t\t\tmsg = errz.StructField() + \" must be smaller than \" + errz.Param() + \".\"\n\t\t\t}\n\t\tdefault:\n\t\t\tmsg = errz.StructField() + \" is invalid.\"\n\t\t}\n\t}\n\n\treturn msg\n}", "title": "" }, { "docid": "d8ced9d3eea75be01769fada554cd413", "score": "0.49502483", "text": "func (v ValidatErrs) Validate() error {\n\tfor _, validatErr := range v {\n\t\tif err := validatErr.Validate(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "2bd7fc83f8390a3f9ef4d1544b702ffb", "score": "0.494553", "text": "func RandValidatorSet(numValidators int, votingPower int64) (*ValidatorSet, []PrivValidator) {\n\tvals := make([]*Validator, numValidators)\n\tprivValidators := make([]PrivValidator, numValidators)\n\tfor i := 0; i < numValidators; i++ {\n\t\tval, privValidator := RandValidator(false, votingPower)\n\t\tvals[i] = val\n\t\tprivValidators[i] = privValidator\n\t}\n\tvalSet := NewValidatorSet(vals)\n\tsort.Sort(PrivValidatorsByAddress(privValidators))\n\treturn valSet, privValidators\n}", "title": "" }, { "docid": "d574960dc754cbe96a8a90dd4ee00a54", "score": "0.49404326", "text": "func (x *fastReflection_QueryDelegatorValidatorsRequest) GetUnknown() protoreflect.RawFields {\n\treturn x.unknownFields\n}", "title": "" }, { "docid": "58d6bc365f83d560c1d97a0a5fbfba00", "score": "0.493506", "text": "func init() {\n\tvalidators = make(map[string]int8)\n\tvalidatorMetas = make(map[string]*funcMeta)\n\n\tfor n, fv := range validatorValues {\n\t\tvalidators[n] = validatorTypeBuiltin\n\t\tvalidatorMetas[n] = newFuncMeta(n, true, fv)\n\t}\n}", "title": "" }, { "docid": "7b88cfdbba5bc17689d56beb30b77908", "score": "0.49332875", "text": "func initValidators(collectionSchema *schemapb.CollectionSchema, validators map[storage.FieldID]*Validator) error {\n\tif collectionSchema == nil {\n\t\treturn errors.New(\"collection schema is nil\")\n\t}\n\n\tfor i := 0; i < len(collectionSchema.Fields); i++ {\n\t\tschema := collectionSchema.Fields[i]\n\n\t\tvalidators[schema.GetFieldID()] = &Validator{}\n\t\tvalidators[schema.GetFieldID()].primaryKey = schema.GetIsPrimaryKey()\n\t\tvalidators[schema.GetFieldID()].autoID = schema.GetAutoID()\n\t\tvalidators[schema.GetFieldID()].fieldName = schema.GetName()\n\t\tvalidators[schema.GetFieldID()].fieldID = schema.GetFieldID()\n\t\tvalidators[schema.GetFieldID()].isString = false\n\n\t\tswitch schema.DataType {\n\t\tcase schemapb.DataType_Bool:\n\t\t\tvalidators[schema.GetFieldID()].convertFunc = func(obj interface{}, field storage.FieldData) error {\n\t\t\t\tif value, ok := obj.(bool); ok {\n\t\t\t\t\tfield.(*storage.BoolFieldData).Data = append(field.(*storage.BoolFieldData).Data, value)\n\t\t\t\t} else {\n\t\t\t\t\treturn fmt.Errorf(\"illegal value '%v' for bool type field '%s'\", obj, schema.GetName())\n\t\t\t\t}\n\n\t\t\t\treturn nil\n\t\t\t}\n\t\tcase schemapb.DataType_Float:\n\t\t\tvalidators[schema.GetFieldID()].convertFunc = func(obj interface{}, field storage.FieldData) error {\n\t\t\t\tif num, ok := obj.(json.Number); ok {\n\t\t\t\t\tvalue, err := parseFloat(string(num), 32, schema.GetName())\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tfield.(*storage.FloatFieldData).Data = append(field.(*storage.FloatFieldData).Data, float32(value))\n\t\t\t\t} else {\n\t\t\t\t\treturn fmt.Errorf(\"illegal value '%v' for float type field '%s'\", obj, schema.GetName())\n\t\t\t\t}\n\n\t\t\t\treturn nil\n\t\t\t}\n\t\tcase schemapb.DataType_Double:\n\t\t\tvalidators[schema.GetFieldID()].convertFunc = func(obj interface{}, field storage.FieldData) error {\n\t\t\t\tif num, ok := obj.(json.Number); ok {\n\t\t\t\t\tvalue, err := parseFloat(string(num), 64, schema.GetName())\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tfield.(*storage.DoubleFieldData).Data = append(field.(*storage.DoubleFieldData).Data, value)\n\t\t\t\t} else {\n\t\t\t\t\treturn fmt.Errorf(\"illegal value '%v' for double type field '%s'\", obj, schema.GetName())\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\t\tcase schemapb.DataType_Int8:\n\t\t\tvalidators[schema.GetFieldID()].convertFunc = func(obj interface{}, field storage.FieldData) error {\n\t\t\t\tif num, ok := obj.(json.Number); ok {\n\t\t\t\t\tvalue, err := strconv.ParseInt(string(num), 0, 8)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"failed to parse value '%v' for int8 field '%s', error: %w\", num, schema.GetName(), err)\n\t\t\t\t\t}\n\t\t\t\t\tfield.(*storage.Int8FieldData).Data = append(field.(*storage.Int8FieldData).Data, int8(value))\n\t\t\t\t} else {\n\t\t\t\t\treturn fmt.Errorf(\"illegal value '%v' for int8 type field '%s'\", obj, schema.GetName())\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\t\tcase schemapb.DataType_Int16:\n\t\t\tvalidators[schema.GetFieldID()].convertFunc = func(obj interface{}, field storage.FieldData) error {\n\t\t\t\tif num, ok := obj.(json.Number); ok {\n\t\t\t\t\tvalue, err := strconv.ParseInt(string(num), 0, 16)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"failed to parse value '%v' for int16 field '%s', error: %w\", num, schema.GetName(), err)\n\t\t\t\t\t}\n\t\t\t\t\tfield.(*storage.Int16FieldData).Data = append(field.(*storage.Int16FieldData).Data, int16(value))\n\t\t\t\t} else {\n\t\t\t\t\treturn fmt.Errorf(\"illegal value '%v' for int16 type field '%s'\", obj, schema.GetName())\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\t\tcase schemapb.DataType_Int32:\n\t\t\tvalidators[schema.GetFieldID()].convertFunc = func(obj interface{}, field storage.FieldData) error {\n\t\t\t\tif num, ok := obj.(json.Number); ok {\n\t\t\t\t\tvalue, err := strconv.ParseInt(string(num), 0, 32)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"failed to parse value '%v' for int32 field '%s', error: %w\", num, schema.GetName(), err)\n\t\t\t\t\t}\n\t\t\t\t\tfield.(*storage.Int32FieldData).Data = append(field.(*storage.Int32FieldData).Data, int32(value))\n\t\t\t\t} else {\n\t\t\t\t\treturn fmt.Errorf(\"illegal value '%v' for int32 type field '%s'\", obj, schema.GetName())\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\t\tcase schemapb.DataType_Int64:\n\t\t\tvalidators[schema.GetFieldID()].convertFunc = func(obj interface{}, field storage.FieldData) error {\n\t\t\t\tif num, ok := obj.(json.Number); ok {\n\t\t\t\t\tvalue, err := strconv.ParseInt(string(num), 0, 64)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"failed to parse value '%v' for int64 field '%s', error: %w\", num, schema.GetName(), err)\n\t\t\t\t\t}\n\t\t\t\t\tfield.(*storage.Int64FieldData).Data = append(field.(*storage.Int64FieldData).Data, value)\n\t\t\t\t} else {\n\t\t\t\t\treturn fmt.Errorf(\"illegal value '%v' for int64 type field '%s'\", obj, schema.GetName())\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\t\tcase schemapb.DataType_BinaryVector:\n\t\t\tdim, err := getFieldDimension(schema)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tvalidators[schema.GetFieldID()].dimension = dim\n\n\t\t\tvalidators[schema.GetFieldID()].convertFunc = func(obj interface{}, field storage.FieldData) error {\n\t\t\t\tarr, ok := obj.([]interface{})\n\t\t\t\tif !ok {\n\t\t\t\t\treturn fmt.Errorf(\"'%v' is not an array for binary vector field '%s'\", obj, schema.GetName())\n\t\t\t\t}\n\t\t\t\t// we use uint8 to represent binary vector in json file, each uint8 value represents 8 dimensions.\n\t\t\t\tif len(arr)*8 != dim {\n\t\t\t\t\treturn fmt.Errorf(\"bit size %d doesn't equal to vector dimension %d of field '%s'\", len(arr)*8, dim, schema.GetName())\n\t\t\t\t}\n\n\t\t\t\tfor i := 0; i < len(arr); i++ {\n\t\t\t\t\tif num, ok := arr[i].(json.Number); ok {\n\t\t\t\t\t\tvalue, err := strconv.ParseUint(string(num), 0, 8)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"failed to parse value '%v' for binary vector field '%s', error: %w\", num, schema.GetName(), err)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfield.(*storage.BinaryVectorFieldData).Data = append(field.(*storage.BinaryVectorFieldData).Data, byte(value))\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn fmt.Errorf(\"illegal value '%v' for binary vector field '%s'\", obj, schema.GetName())\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn nil\n\t\t\t}\n\t\tcase schemapb.DataType_FloatVector:\n\t\t\tdim, err := getFieldDimension(schema)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tvalidators[schema.GetFieldID()].dimension = dim\n\n\t\t\tvalidators[schema.GetFieldID()].convertFunc = func(obj interface{}, field storage.FieldData) error {\n\t\t\t\tarr, ok := obj.([]interface{})\n\t\t\t\tif !ok {\n\t\t\t\t\treturn fmt.Errorf(\"'%v' is not an array for float vector field '%s'\", obj, schema.GetName())\n\t\t\t\t}\n\t\t\t\tif len(arr) != dim {\n\t\t\t\t\treturn fmt.Errorf(\"array size %d doesn't equal to vector dimension %d of field '%s'\", len(arr), dim, schema.GetName())\n\t\t\t\t}\n\n\t\t\t\tfor i := 0; i < len(arr); i++ {\n\t\t\t\t\tif num, ok := arr[i].(json.Number); ok {\n\t\t\t\t\t\tvalue, err := parseFloat(string(num), 32, schema.GetName())\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfield.(*storage.FloatVectorFieldData).Data = append(field.(*storage.FloatVectorFieldData).Data, float32(value))\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn fmt.Errorf(\"illegal value '%v' for float vector field '%s'\", obj, schema.GetName())\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn nil\n\t\t\t}\n\t\tcase schemapb.DataType_String, schemapb.DataType_VarChar:\n\t\t\tvalidators[schema.GetFieldID()].isString = true\n\n\t\t\tvalidators[schema.GetFieldID()].convertFunc = func(obj interface{}, field storage.FieldData) error {\n\t\t\t\tif value, ok := obj.(string); ok {\n\t\t\t\t\tfield.(*storage.StringFieldData).Data = append(field.(*storage.StringFieldData).Data, value)\n\t\t\t\t} else {\n\t\t\t\t\treturn fmt.Errorf(\"illegal value '%v' for varchar type field '%s'\", obj, schema.GetName())\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\t\tcase schemapb.DataType_JSON:\n\t\t\tvalidators[schema.GetFieldID()].convertFunc = func(obj interface{}, field storage.FieldData) error {\n\t\t\t\t// for JSON data, we accept two kinds input: string and map[string]interface\n\t\t\t\t// user can write JSON content as {\"FieldJSON\": \"{\\\"x\\\": 8}\"} or {\"FieldJSON\": {\"x\": 8}}\n\t\t\t\tif value, ok := obj.(string); ok {\n\t\t\t\t\tvar dummy interface{}\n\t\t\t\t\terr := json.Unmarshal([]byte(value), &dummy)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"failed to parse value '%v' for JSON field '%s', error: %w\", value, schema.GetName(), err)\n\t\t\t\t\t}\n\t\t\t\t\tfield.(*storage.JSONFieldData).Data = append(field.(*storage.JSONFieldData).Data, []byte(value))\n\t\t\t\t} else if mp, ok := obj.(map[string]interface{}); ok {\n\t\t\t\t\tbs, err := json.Marshal(mp)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"failed to parse value for JSON field '%s', error: %w\", schema.GetName(), err)\n\t\t\t\t\t}\n\t\t\t\t\tfield.(*storage.JSONFieldData).Data = append(field.(*storage.JSONFieldData).Data, bs)\n\t\t\t\t} else {\n\t\t\t\t\treturn fmt.Errorf(\"illegal value '%v' for JSON type field '%s'\", obj, schema.GetName())\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unsupport data type: %s\", getTypeName(collectionSchema.Fields[i].DataType))\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "9633ba12bbce5d944674ca74b731bcbe", "score": "0.4928114", "text": "func RemoveValidator(validators []string, removedValidators []string) ([]string, error) {\n\t// if number of pending validator is less or equal than offset, set offset equal to number of pending validator\n\tif len(removedValidators) > len(validators) {\n\t\treturn validators, errors.New(\"trying to remove too many validators\")\n\t}\n\tfor index, validator := range removedValidators {\n\t\tif strings.Compare(validators[index], validator) == 0 {\n\t\t\tvalidators = validators[1:]\n\t\t} else {\n\t\t\t// not found wanted validator\n\t\t\treturn validators, errors.New(\"remove Validator with Wrong Format\")\n\t\t}\n\t}\n\treturn validators, nil\n}", "title": "" }, { "docid": "c57889c669c6906a3ab6f9c802aedbc1", "score": "0.48947975", "text": "func (m *MockAPIGatewayAPI) GetRequestValidators(arg0 *apigateway.GetRequestValidatorsInput) (*apigateway.GetRequestValidatorsOutput, error) {\n\tret := m.ctrl.Call(m, \"GetRequestValidators\", arg0)\n\tret0, _ := ret[0].(*apigateway.GetRequestValidatorsOutput)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "ce3835821b122b7f66e3cc7ac05841fa", "score": "0.48789862", "text": "func ReturnFirst(validators ...Validator) error {\n\tvar err error\n\tfor _, validator := range validators {\n\t\tif err = validator(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "68c4ced2b5283efd90560d77ada517bc", "score": "0.48487866", "text": "func (x *fastReflection_GetLatestValidatorSetRequest) GetUnknown() protoreflect.RawFields {\n\treturn x.unknownFields\n}", "title": "" }, { "docid": "0e2503403b12414f4b79589b4ac95954", "score": "0.4844127", "text": "func SupportedValidator(validator string) bool {\n\tvalidators := config.Read().Settings.Validators\n\n\tfor _, val := range validators {\n\t\tif val == validator {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "8f57932c26270bd133d3a0a0ae3c90e7", "score": "0.4830763", "text": "func (x *fastReflection_QueryDelegatorValidatorsResponse) SetUnknown(fields protoreflect.RawFields) {\n\tx.unknownFields = fields\n}", "title": "" }, { "docid": "320d4e0496e299dcc5f75e9944fa6875", "score": "0.4813518", "text": "func MetricsValid(metrics []string) error {\n\tfor _, v := range metrics {\n\t\tif !metricPossibleMap[v] {\n\t\t\treturn fmt.Errorf(\"metric-INVALID:%q\", v)\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "3b11237eeec3592cb64ef4d380c296f9", "score": "0.48132542", "text": "func (x *fastReflection_GetLatestValidatorSetResponse) SetUnknown(fields protoreflect.RawFields) {\n\tx.unknownFields = fields\n}", "title": "" }, { "docid": "b26d7fb5d59911334415c220db15034e", "score": "0.4770642", "text": "func (a *TicketAPI) getTopValidators(params interface{}) (resp *rpc.Response) {\n\treturn rpc.Success(util.Map{\n\t\t\"tickets\": a.mods.Ticket.GetTopValidators(cast.ToInt(params)),\n\t})\n}", "title": "" }, { "docid": "3f62986df28cb53f27540347a98718f1", "score": "0.47649297", "text": "func (_Statereceiver *StatereceiverCaller) ValidatorSet(opts *bind.CallOpts) (common.Address, error) {\n\tvar (\n\t\tret0 = new(common.Address)\n\t)\n\tout := ret0\n\terr := _Statereceiver.contract.Call(opts, out, \"validatorSet\")\n\treturn *ret0, err\n}", "title": "" }, { "docid": "0c8f5cd529c45969aef40b7be71ecd42", "score": "0.47619316", "text": "func (_Statereceiver *StatereceiverSession) ValidatorSet() (common.Address, error) {\n\treturn _Statereceiver.Contract.ValidatorSet(&_Statereceiver.CallOpts)\n}", "title": "" }, { "docid": "3340d8c09ec7a8ec7c74fd92d5f04772", "score": "0.4756945", "text": "func (m *ValidationErrorErrorsItems0) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "title": "" }, { "docid": "38bb583a8f01b530cb56da98b13659c8", "score": "0.47537783", "text": "func (m *mappingsRequest) Valid() error {\n\tif m.Provider == \"\" {\n\t\treturn fmt.Errorf(\"mapping must specify provider\")\n\t}\n\tif m.Scheme == \"\" {\n\t\treturn fmt.Errorf(\"mapping must specify scheme\")\n\t}\n\tif m.ProviderOrganization == \"\" {\n\t\treturn fmt.Errorf(\"mapping must specify group\")\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "729e0e4f672705418448c76ce0aa4dcb", "score": "0.47521564", "text": "func (x *fastReflection_GetLatestValidatorSetResponse) IsValid() bool {\n\treturn x != nil\n}", "title": "" }, { "docid": "7cdfa3fb74c00e9847282c12cba95338", "score": "0.47508538", "text": "func (x *fastReflection_QueryDelegatorValidatorsRequest) SetUnknown(fields protoreflect.RawFields) {\n\tx.unknownFields = fields\n}", "title": "" }, { "docid": "a59d4ecf67a0afee4bc5060228052092", "score": "0.47501254", "text": "func ListErrs() []string {\n\treturn []string{\"[GOWRTR-1] struct name must not be empty, but it gets empty (caused at %s)\", \"[GOWRTR-2] field name must not be empty, but it gets empty (caused at %s)\", \"[GOWRTR-3] field type must not be empty, but it gets empty (caused at %s)\", \"[GOWRTR-4] func parameter name must not be empty, but it gets empty (caused at %s)\", \"[GOWRTR-5] the last func parameter type must not be empty, but it gets empty (caused at %s)\", \"[GOWRTR-6] name of func must not be empty, but it gets empty (caused at %s)\", \"[GOWRTR-7] name of interface must not be empty, but it gets empty (caused at %s)\", \"[GOWRTR-8] name of func receiver must not be empty, but it gets empty (caused at %s)\", \"[GOWRTR-9] type of func receiver must not be empty, but it gets empty (caused at %s)\", \"[GOWRTR-10] func signature must not be nil, bit it gets nil (caused at %s)\", \"[GOWRTR-11] anonymous func signature must not be nil, bit it gets nil (caused at %s)\", \"[GOWRTR-12] a parameter of function invocation must not be nil, but it gets nil (caused at %s)\", \"[GOWRTR-13] code formatter raises error: command='%s', err='%s', msg='%s'\", \"[GOWRTR-14] condition of case must not be empty, but it gets empty (caused at %s)\", \"[GOWRTR-15] condition of if must not be empty, but it gets empty (caused at %s)\", \"[GOWRTR-16] unnamed return type appears after named return type (caused at %s)\", \"[GOWRTR-17] a value of composite literal must not be empty, but it gets empty (caused at %s)\", \"[GOWRTR-18] type-parameter's parameter must not be empty, but it gets empty (caused at %s)\", \"[GOWRTR-19] type-parameter's type must not be empty, but it gets empty (caused at %s)\"}\n}", "title": "" }, { "docid": "c7c2465ba8404714155ed2e4126d207f", "score": "0.47478902", "text": "func (o *GetUndelegationsOfValidatorOKBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.validateResult(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "0f0bb017de9ea20594a405c79a1e03f6", "score": "0.47389564", "text": "func Validate(st interface{}, messages map[string]map[string]string) (returnedErrors []error) {\n\tif st == nil {\n\t\treturn append(returnedErrors, errors.New(\"The interface passed is nil\"))\n\t}\n\tflagTag := true\n\tstValue := reflect.ValueOf(st)\n\t// mount message input list\n\tmessagesInput := make([]MessageInput, 0)\n\tfor i := 0; i < stValue.NumField(); i++ {\n\t\tfield := stValue.Field(i)\n\t\tvar interfaceValue interface{}\n\t\tif fieldKind := field.Type().Kind(); (reflect.Int <= fieldKind && fieldKind <= reflect.Int64) || fieldKind == reflect.Float32 || fieldKind == reflect.Float64 {\n\t\t\tif fieldKind == reflect.Float32 || fieldKind == reflect.Float64 {\n\t\t\t\tinterfaceValue = field.Float()\n\t\t\t} else {\n\t\t\t\t//convert int type to float64\n\t\t\t\tinterfaceValue = float64(field.Int())\n\t\t\t}\n\t\t} else if reflect.Uint <= fieldKind && fieldKind <= reflect.Uintptr {\n\t\t\t//convert uint type to uint64\n\t\t\tinterfaceValue = field.Uint()\n\t\t} else {\n\t\t\t//anothers types\n\t\t\tinterfaceValue = field.Interface()\n\t\t}\n\t\tmessagesInput = append(messagesInput, MessageInput{\n\t\t\tFieldName: stValue.Type().Field(i).Name,\n\t\t\tFieldValue: interfaceValue,\n\t\t\tCustomMessages: messages,\n\t\t\tFieldType: field.Type(),\n\t\t\tValidatorKeyType: getValidatorKeyType(field.Type().String()),\n\t\t})\n\t}\n\t//get errors\n\tfor i := 0; i < stValue.NumField(); i++ {\n\t\t_, tagLookup := stValue.Type().Field(i).Tag.Lookup(TagName)\n\t\tif tagLookup {\n\t\t\tflagTag = false\n\t\t}\n\t\tmessagesInput[i].OthersMessageInput = messagesInput\n\t\ttags := strings.Replace(stValue.Type().Field(i).Tag.Get(TagName), \" \", \"\", -1)\n\t\t// get validator key\n\t\tif messagesInput[i].ValidatorKeyType == \"\" || len(tags) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\t//get errors\n\t\treturnedErrors = append(returnedErrors, checkValidations(tags, messagesInput[i])...)\n\t}\n\tif flagTag {\n\t\treturn append(returnedErrors, errors.New(\"Not found TAG: \"+TagName))\n\t}\n\treturn returnedErrors\n}", "title": "" }, { "docid": "4715a9dd5417357c4d52f978c96f9a9a", "score": "0.4736754", "text": "func (r *ResponsePages) Validate() error {\n\tcatcher := grip.NewCatcher()\n\tfor _, p := range []*Page{r.Next, r.Prev} {\n\t\tif p == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tcatcher.Add(p.Validate())\n\t}\n\n\treturn catcher.Resolve()\n}", "title": "" }, { "docid": "f125291892dde0f1a9a950d5eca5a9e9", "score": "0.47359768", "text": "func ValidateOrChain(validators ...Validator) Validator {\n\treturn func(s interface{}) error {\n\t\tvar errors []string\n\t\tfor _, vd := range validators {\n\t\t\terr := vd(s)\n\t\t\tif err != nil {\n\t\t\t\terrors = append(errors, err.Error())\n\t\t\t} else {\n\t\t\t\t// Just need one in chain to pass for this to be fine\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\n\t\t// Happens if there are no validators\n\t\tif len(errors) == 0 {\n\t\t\treturn nil\n\t\t}\n\n\t\treturn fmt.Errorf(strings.Join(errors, \" or \"))\n\t}\n}", "title": "" }, { "docid": "8eb1241702db877078fedd6129ea8edf", "score": "0.47325686", "text": "func validateServices(s yaml.ServiceSlice) error {\n\tfor _, service := range s {\n\t\tif len(service.Name) == 0 {\n\t\t\treturn fmt.Errorf(\"no name provided for service\")\n\t\t}\n\n\t\tif len(service.Image) == 0 {\n\t\t\treturn fmt.Errorf(\"no image provided for service %s\", service.Name)\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "8eb1241702db877078fedd6129ea8edf", "score": "0.47325686", "text": "func validateServices(s yaml.ServiceSlice) error {\n\tfor _, service := range s {\n\t\tif len(service.Name) == 0 {\n\t\t\treturn fmt.Errorf(\"no name provided for service\")\n\t\t}\n\n\t\tif len(service.Image) == 0 {\n\t\t\treturn fmt.Errorf(\"no image provided for service %s\", service.Name)\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "1648b88f532aaa8b45be075537515ce6", "score": "0.47291273", "text": "func (_Statereceiver *StatereceiverCallerSession) ValidatorSet() (common.Address, error) {\n\treturn _Statereceiver.Contract.ValidatorSet(&_Statereceiver.CallOpts)\n}", "title": "" }, { "docid": "57c7e5e890598df221f8634c37e29e55", "score": "0.47248223", "text": "func (x *fastReflection_GetLatestValidatorSetRequest) SetUnknown(fields protoreflect.RawFields) {\n\tx.unknownFields = fields\n}", "title": "" }, { "docid": "68bf3724d466bf750d2f4d6b59053c40", "score": "0.4718059", "text": "func validateSlice(rv reflect.Value) error {\n\terrs := Errors{}\n\tl := rv.Len()\n\tfor i := 0; i < l; i++ {\n\t\tif ev := rv.Index(i).Interface(); ev != nil {\n\t\t\tif err := ev.(Validatable).Validate(); err != nil {\n\t\t\t\terrs[strconv.Itoa(i)] = err\n\t\t\t}\n\t\t}\n\t}\n\tif len(errs) > 0 {\n\t\treturn errs\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "68bf3724d466bf750d2f4d6b59053c40", "score": "0.4718059", "text": "func validateSlice(rv reflect.Value) error {\n\terrs := Errors{}\n\tl := rv.Len()\n\tfor i := 0; i < l; i++ {\n\t\tif ev := rv.Index(i).Interface(); ev != nil {\n\t\t\tif err := ev.(Validatable).Validate(); err != nil {\n\t\t\t\terrs[strconv.Itoa(i)] = err\n\t\t\t}\n\t\t}\n\t}\n\tif len(errs) > 0 {\n\t\treturn errs\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "bf2f87d0e5e32344756293b012061a45", "score": "0.47108757", "text": "func (sr *ServiceResolver) Validate() {\n defined := 0\n if (sr.Yaml != nil && sr.Yaml.Content != \"\") {\n \n defined ++\n }\n if (sr.Lua != nil && sr.Lua.Content != \"\") {\n defined ++\n }\n if defined != 1 {\n panic(mutils.BadRequest.WithUserMessage(\"Please define only one resolver, you have not define one!! or have multiples defined\"))\n }\n}", "title": "" }, { "docid": "5a8ba8eab619bb2e83679514a0ec134a", "score": "0.4710645", "text": "func (_Valset *ValsetSession) ActiveValidators(arg0 common.Address) (bool, error) {\n\treturn _Valset.Contract.ActiveValidators(&_Valset.CallOpts, arg0)\n}", "title": "" }, { "docid": "1fe6ea29701a311844cf25a54cc52145", "score": "0.46986815", "text": "func (valSet *ValidatorSet) Size() int {\n\treturn len(valSet.Validators)\n}", "title": "" }, { "docid": "b09089e1222386b4b861d6e808f82349", "score": "0.46658355", "text": "func updateValidators(t *testing.T, app *App, updates ...CommandValidatorChange) {\n\tmetatxs := make([]metatx.Transactable, len(updates))\n\tfor i := 0; i < len(updates); i++ {\n\t\tmetatxs[i] = metatx.Transactable(&updates[i])\n\t}\n\n\tresps, ebResp := deliverTxsContext(t, app, metatxs, ddc(t))\n\tfor _, resp := range resps {\n\t\trequire.Equal(t, code.OK, code.ReturnCode(resp.Code))\n\t}\n\n\tstate := app.GetState().(*backing.State)\n\tactual := ebResp.GetValidatorUpdates()\n\texpect := make([]abci.ValidatorUpdate, len(updates))\n\tfor i := 0; i < len(updates); i++ {\n\t\tvup, err := updates[i].ToValidator(state)\n\t\trequire.NoError(t, err)\n\t\trequire.NotNil(t, vup)\n\t\texpect[i] = *vup\n\t}\n\n\tt.Logf(\"expect: %q\", expect)\n\tt.Logf(\"actual: %q\", actual)\n\trequire.ElementsMatch(t, expect, ebResp.GetValidatorUpdates())\n\n\tapp.Commit()\n}", "title": "" }, { "docid": "f06c63d68a295f3702cfc7288e6d35df", "score": "0.46625698", "text": "func (m *FpolicyEngines) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateBufferSize(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateCertificate(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateFormat(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateMaxServerRequests(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateResiliency(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateSslOption(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateType(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "64dc4b11a7dbb1cfb0cc9f9fb73ef230", "score": "0.46566954", "text": "func (_Valset *ValsetCallerSession) ActiveValidators(arg0 common.Address) (bool, error) {\n\treturn _Valset.Contract.ActiveValidators(&_Valset.CallOpts, arg0)\n}", "title": "" }, { "docid": "7a834b0ae8691b7bab242601cd4658fd", "score": "0.46534503", "text": "func (m UnexpectedError) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "title": "" }, { "docid": "b326fd37dc71fe065d6c4b127745fe69", "score": "0.4631988", "text": "func (x *fastReflection_QueryDelegatorValidatorsResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.QueryDelegatorValidatorsResponse.validators\":\n\t\treturn len(x.Validators) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.QueryDelegatorValidatorsResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.QueryDelegatorValidatorsResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "title": "" }, { "docid": "d26b7570b6dde5f588f4b4c00613603d", "score": "0.4610312", "text": "func Init(validatorConfs []*configpb.Validator, l *logger.Logger) ([]*ValidatorWithName, error) {\n\tvar validators []*ValidatorWithName\n\tnames := make(map[string]bool)\n\n\tfor _, vc := range validatorConfs {\n\t\tif names[vc.GetName()] {\n\t\t\treturn nil, fmt.Errorf(\"validator %s is defined twice\", vc.GetName())\n\t\t}\n\n\t\tv, err := initValidator(vc, l)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tvalidators = append(validators, &ValidatorWithName{vc.GetName(), v})\n\t\tnames[vc.GetName()] = true\n\t}\n\n\treturn validators, nil\n}", "title": "" }, { "docid": "37f828892501a36b5b5e9cbe4ae23cf2", "score": "0.46051508", "text": "func (k Keeper) IterateLastValidators(ctx sdk.Context, fn func(index int64, validator types.Validator) (stop bool)) {\n\tstore := ctx.KVStore(k.storeKey)\n\titerator := sdk.KVStorePrefixIterator(store, LastValidatorPowerKey)\n\tdefer iterator.Close()\n\n\ti := int64(0)\n\n\tfor ; iterator.Valid(); iterator.Next() {\n\t\taddress := AddressFromLastValidatorPowerKey(iterator.Key())\n\n\t\tvalidator, err := k.GetValidator(ctx, address)\n\t\tif err != nil {\n\t\t\tpanic(fmt.Sprintf(\"validator record not found for address: %v\\n\", address))\n\t\t}\n\n\t\tstop := fn(i, validator) // XXX is this safe will the validator unexposed fields be able to get written to?\n\t\tif stop {\n\t\t\tbreak\n\t\t}\n\t\ti++\n\t}\n}", "title": "" }, { "docid": "3f0127ef22e9ba8054ae51eab03168c3", "score": "0.4602003", "text": "func (_Valset *ValsetCaller) ActiveValidators(opts *bind.CallOpts, arg0 common.Address) (bool, error) {\n\tvar (\n\t\tret0 = new(bool)\n\t)\n\tout := ret0\n\terr := _Valset.contract.Call(opts, out, \"activeValidators\", arg0)\n\treturn *ret0, err\n}", "title": "" }, { "docid": "b9693f853f38cb51689d01d72b77030a", "score": "0.4601571", "text": "func (x *fastReflection_QueryDelegatorValidatorsResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {\n\tif len(x.Validators) != 0 {\n\t\tvalue := protoreflect.ValueOfList(&_QueryDelegatorValidatorsResponse_1_list{list: &x.Validators})\n\t\tif !f(fd_QueryDelegatorValidatorsResponse_validators, value) {\n\t\t\treturn\n\t\t}\n\t}\n}", "title": "" }, { "docid": "9a425bcea25d28562ae425006af66e4d", "score": "0.46005455", "text": "func (jot *JWT) Validate(validators ...ValidatorFunc) error {\n\tfor _, v := range validators {\n\t\tif err := v(jot); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "55f1578737ac3aa41860dc9f5b4d8b17", "score": "0.45967954", "text": "func ValidChoices() []Choice {\n\treturn Choices[Min:]\n}", "title": "" }, { "docid": "1a6c2b563585bd8ee8c9870b0b664af3", "score": "0.45950273", "text": "func (_m *Client) Validators(ctx context.Context, height *int64, page *int, perPage *int) (*coretypes.ResultValidators, error) {\n\tret := _m.Called(ctx, height, page, perPage)\n\n\tvar r0 *coretypes.ResultValidators\n\tif rf, ok := ret.Get(0).(func(context.Context, *int64, *int, *int) *coretypes.ResultValidators); ok {\n\t\tr0 = rf(ctx, height, page, perPage)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(*coretypes.ResultValidators)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(context.Context, *int64, *int, *int) error); ok {\n\t\tr1 = rf(ctx, height, page, perPage)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "title": "" }, { "docid": "500e84fbf31316a51b7584e567302a54", "score": "0.45924017", "text": "func (p *jsiiProxy_Pipeline) Validate() *[]*string {\n\tvar returns *[]*string\n\n\t_jsii_.Invoke(\n\t\tp,\n\t\t\"validate\",\n\t\tnil, // no parameters\n\t\t&returns,\n\t)\n\n\treturn returns\n}", "title": "" }, { "docid": "a892b9fcf2e70bc8345c6cd2d44ff59a", "score": "0.4592279", "text": "func (v *nandValidation) Validate() error {\n\t// evaluate validators inside nand-group\n\terrs := Validate(v.validators...)\n\n\t// no error -> all have passed -> error\n\tif errs == nil {\n\t\treturn validators.ReturnGenericError(notAllMsg)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "b0b017d0e5340068bab11bbc2421cf36", "score": "0.45908147", "text": "func (_Statereceiver *StatereceiverTransactor) ValidateValidatorSet(opts *bind.TransactOpts, vote []byte, sigs []byte, txBytes []byte, proof []byte) (*types.Transaction, error) {\n\treturn _Statereceiver.contract.Transact(opts, \"validateValidatorSet\", vote, sigs, txBytes, proof)\n}", "title": "" }, { "docid": "98167c6b73e768226a55cb0b22c1fed1", "score": "0.45882785", "text": "func validateMap(rv reflect.Value) error {\n\terrs := Errors{}\n\tfor _, key := range rv.MapKeys() {\n\t\tif mv := rv.MapIndex(key).Interface(); mv != nil {\n\t\t\tif err := mv.(Validatable).Validate(); err != nil {\n\t\t\t\terrs[fmt.Sprintf(\"%v\", key.Interface())] = err\n\t\t\t}\n\t\t}\n\t}\n\tif len(errs) > 0 {\n\t\treturn errs\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "98167c6b73e768226a55cb0b22c1fed1", "score": "0.45882785", "text": "func validateMap(rv reflect.Value) error {\n\terrs := Errors{}\n\tfor _, key := range rv.MapKeys() {\n\t\tif mv := rv.MapIndex(key).Interface(); mv != nil {\n\t\t\tif err := mv.(Validatable).Validate(); err != nil {\n\t\t\t\terrs[fmt.Sprintf(\"%v\", key.Interface())] = err\n\t\t\t}\n\t\t}\n\t}\n\tif len(errs) > 0 {\n\t\treturn errs\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "964e6a29250d024484d972f3eb386aa9", "score": "0.45877525", "text": "func (c *Config) Validate() error {\n\n\tvar knownTypes []string\n\tdrivers := make(map[string]int)\n\tfor _, name := range provider.Drivers(provider.TypeStd) {\n\t\tdrivers[name] = int(provider.TypeStd)\n\t\tknownTypes = append(knownTypes, name)\n\t}\n\tfor _, name := range provider.Drivers(provider.TypeMvt) {\n\t\tdrivers[name] = int(provider.TypeMvt)\n\t\tknownTypes = append(knownTypes, name)\n\t}\n\t// mvtproviders maps a known provider name to whether that provider is\n\t// an mvt provider or not.\n\tmvtproviders := make(map[string]bool, len(c.Providers))\n\tfor i, prvd := range c.Providers {\n\t\tname, _ := prvd.String(\"name\", nil)\n\t\tif name == \"\" {\n\t\t\treturn ErrProviderNameRequired{Pos: i}\n\t\t}\n\t\ttyp, _ := prvd.String(\"type\", nil)\n\t\tif typ == \"\" {\n\t\t\treturn ErrProviderTypeRequired{Pos: i}\n\t\t}\n\t\t// Check to see if the name has already been seen before.\n\t\tif _, ok := mvtproviders[name]; ok {\n\t\t\treturn ErrProviderNameDuplicate{Pos: i}\n\t\t}\n\t\tdrv, ok := drivers[typ]\n\t\tif !ok {\n\t\t\treturn ErrUnknownProviderType{\n\t\t\t\tName: name,\n\t\t\t\tType: typ,\n\t\t\t\tKnownProviders: knownTypes,\n\t\t\t}\n\t\t}\n\t\tmvtproviders[name] = drv == int(provider.TypeMvt)\n\t}\n\t// check for map layer name / zoom collisions\n\t// map of layers to providers\n\tmapLayers := map[string]map[string]MapLayer{}\n\tfor mapKey, m := range c.Maps {\n\t\tif _, ok := mapLayers[string(m.Name)]; !ok {\n\t\t\tmapLayers[string(m.Name)] = map[string]MapLayer{}\n\t\t}\n\n\t\t// Set current provider to empty, for MVT providers\n\t\t// we can only have the same provider for all layers.\n\t\t// This allow us to track what the first found provider\n\t\t// is.\n\t\tprovider := \"\"\n\t\tisMVTProvider := false\n\t\tfor layerKey, l := range m.Layers {\n\t\t\tpname, _, err := l.ProviderLayerName()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif provider == \"\" {\n\t\t\t\t// This is the first provider we found.\n\t\t\t\t// For MVTProviders all others need to be the same, so store it\n\t\t\t\t// so we can check later\n\t\t\t\tprovider = pname\n\t\t\t}\n\n\t\t\tisMvt, doesExists := mvtproviders[pname]\n\t\t\tif !doesExists {\n\t\t\t\treturn ErrInvalidProviderForMap{\n\t\t\t\t\tMapName: string(m.Name),\n\t\t\t\t\tProviderName: pname,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// check to see if any of the prior provider or this one is\n\t\t\t// an mvt provider. If it is, then the mvtProvider check needs\n\t\t\t// to be done\n\t\t\tisMVTProvider = isMVTProvider || isMvt\n\n\t\t\t// only need to do this check if we are dealing with MVTProviders\n\t\t\tif isMVTProvider && pname != provider {\n\t\t\t\t// for mvt_providers we can only have the same provider\n\t\t\t\t// for all layers\n\t\t\t\t// check to see\n\t\t\t\tif mvtproviders[pname] || isMVTProvider {\n\t\t\t\t\treturn ErrMVTDifferentProviders{\n\t\t\t\t\t\tOriginal: provider,\n\t\t\t\t\t\tCurrent: pname,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tname, err := l.GetName()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t// MaxZoom default\n\t\t\tif l.MaxZoom == nil {\n\t\t\t\tph := env.Uint(tegola.MaxZ)\n\t\t\t\t// set in iterated value\n\t\t\t\tl.MaxZoom = &ph\n\t\t\t\t// set in underlying config struct\n\t\t\t\tc.Maps[mapKey].Layers[layerKey].MaxZoom = &ph\n\t\t\t}\n\t\t\t// MinZoom default\n\t\t\tif l.MinZoom == nil {\n\t\t\t\tph := env.Uint(0)\n\t\t\t\t// set in iterated value\n\t\t\t\tl.MinZoom = &ph\n\t\t\t\t// set in underlying config struct\n\t\t\t\tc.Maps[mapKey].Layers[layerKey].MinZoom = &ph\n\t\t\t}\n\n\t\t\t// check if we already have this layer\n\t\t\tif val, ok := mapLayers[string(m.Name)][name]; ok {\n\t\t\t\t// we have a hit. check for zoom range overlap\n\t\t\t\tif uint(*val.MinZoom) <= uint(*l.MaxZoom) && uint(*l.MinZoom) <= uint(*val.MaxZoom) {\n\t\t\t\t\treturn ErrOverlappingLayerZooms{\n\t\t\t\t\t\tProviderLayer1: string(val.ProviderLayer),\n\t\t\t\t\t\tProviderLayer2: string(l.ProviderLayer),\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// add the MapLayer to our map\n\t\t\tmapLayers[string(m.Name)][name] = l\n\t\t}\n\t}\n\n\t// check for blacklisted headers\n\tfor k := range c.Webserver.Headers {\n\t\tfor _, v := range blacklistHeaders {\n\t\t\tif v == strings.ToLower(k) {\n\t\t\t\treturn ErrInvalidHeader{Header: k}\n\t\t\t}\n\t\t}\n\t}\n\n\t// check if webserver.uri_prefix is set and if so\n\t// confirm it starts with a forward slash \"/\"\n\tif string(c.Webserver.URIPrefix) != \"\" {\n\t\turiPrefix := string(c.Webserver.URIPrefix)\n\t\tif string(uriPrefix[0]) != \"/\" {\n\t\t\treturn ErrInvalidURIPrefix(uriPrefix)\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "ade770064f8d135c7a7901a57666127e", "score": "0.45787734", "text": "func (_Valset *ValsetSession) ValidatorCount() (*big.Int, error) {\n\treturn _Valset.Contract.ValidatorCount(&_Valset.CallOpts)\n}", "title": "" }, { "docid": "2ee09ea881f43985070550436083a857", "score": "0.45734376", "text": "func (_Valset *ValsetCallerSession) ValidatorCount() (*big.Int, error) {\n\treturn _Valset.Contract.ValidatorCount(&_Valset.CallOpts)\n}", "title": "" }, { "docid": "612ecf0f352d6958fba994385ced3cb4", "score": "0.45706958", "text": "func newErrConfigurationInvalid(errs []error) error {\n\tswitch len(errs) {\n\tcase 0:\n\t\treturn nil\n\tdefault:\n\t\treturn errConfigurationInvalid(errs)\n\t}\n}", "title": "" }, { "docid": "9525b39ac25a57f9458c2c71297f36be", "score": "0.45699897", "text": "func (f ValidatorFunc) WithValidators(vals ...Validator) Validators {\n\treturn append(vals, f)\n}", "title": "" }, { "docid": "9a45f44f39ce5a304ee62b9053bb8cf9", "score": "0.4565537", "text": "func (m MacInterfaceMap) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tfor i := 0; i < len(m); i++ {\n\t\tif swag.IsZero(m[i]) { // not required\n\t\t\tcontinue\n\t\t}\n\n\t\tif m[i] != nil {\n\t\t\tif err := m[i].Validate(formats); err != nil {\n\t\t\t\tif ve, ok := err.(*errors.Validation); ok {\n\t\t\t\t\treturn ve.ValidateName(strconv.Itoa(i))\n\t\t\t\t} else if ce, ok := err.(*errors.CompositeError); ok {\n\t\t\t\t\treturn ce.ValidateName(strconv.Itoa(i))\n\t\t\t\t}\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c30ce6b8c921cc33c3d713a0e69969a7", "score": "0.45652288", "text": "func (v *xorValidation) Validate() error {\n\t// evaluate validators inside xor-group\n\terrs := Validate(v.validators...)\n\n\tif errs == nil || len(v.validators)-len(errs.(Errors).ValidationErrors()) != 1 {\n\t\treturn validators.ReturnGenericError(onlyOneMsg)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "1ff057fb307388db08708ae763cfffdc", "score": "0.45630994", "text": "func (s *KubeControllerManagerOptions) Validate(allControllers []string, disabledByDefaultControllers []string) error {\n\tvar errs []error\n\n\tallControllersSet := sets.NewString(allControllers...)\n\tfor _, controller := range s.Generic.Controllers {\n\t\tif controller == \"*\" {\n\t\t\tcontinue\n\t\t}\n\t\tif strings.HasPrefix(controller, \"-\") {\n\t\t\tcontroller = controller[1:]\n\t\t}\n\n\t\tif !allControllersSet.Has(controller) {\n\t\t\terrs = append(errs, fmt.Errorf(\"%q is not in the list of known controllers\", controller))\n\t\t}\n\t}\n\n\treturn utilerrors.NewAggregate(errs)\n}", "title": "" }, { "docid": "aa446941492c2a45018044520ad99ae6", "score": "0.45582685", "text": "func (v *validatorRule) Valid(ctx *context.Context) bool {\n\t// check if it's a valid response, if it's not then just return.\n\tfor _, valid := range v.postValidators {\n\t\tif !valid(ctx) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "title": "" }, { "docid": "049cb01e08d6ced65027d89bc64d49c7", "score": "0.45502844", "text": "func ValidTrits(trits Trits) error {\n\tfor i, trit := range trits {\n\t\tif !ValidTrit(trit) {\n\t\t\treturn errors.Wrapf(ErrInvalidTrit, \"at index %d\", i)\n\t\t}\n\t}\n\treturn nil\n}", "title": "" } ]
8a29fa1534346a59e3d65d250eb813cd
initRouters init usermanager http router
[ { "docid": "72dd232b9d9e0244e0c3e80fb624f1a6", "score": "0.797023", "text": "func (u *UserManager) initRouters(ws *restful.WebService) {\n\tv1http.InitV1Routers(ws)\n}", "title": "" } ]
[ { "docid": "687e079678c780f3b73f8a57d4781bdb", "score": "0.706909", "text": "func (a *App) setRouters() {\n\n\ta.GetSocket(\"/socket.io/\", a.Socket)\n\ta.Post(\"/api/user\", a.CreateUser)\n\ta.Get(\"/api/user\", a.ValidateMiddleware(a.GetUser))\n\n\ta.Post(\"/api/plan/test\", a.GetPlan)\n\ta.Get(\"/api/plan\", a.GetPlans)\n\ta.Post(\"/api/plan\", a.CreatePlan)\n\ta.Delete(\"/api/plan\", a.DeletePlan)\n\n\n}", "title": "" }, { "docid": "9f6beac29e4e530f70786055790fab97", "score": "0.6975394", "text": "func (a *Server) setRouters() {\n\tauthExceptions = map[string]bool{\n\t\t\"/healthcheck\": true,\n\t\t\"/auth\": true,\n\t\t\"/auth/bearer\": true,\n\t\t\"/auth/register\": true,\n\t}\n\n\ta.Head(\"/healthcheck\", a.handleRequest(api.HeadHealthcheck))\n\n\ta.Post(\"/auth\", a.handleRequest(api.PostAuth))\n\ta.Post(\"/auth/bearer\", a.handleRequest(api.PostAuthToken))\n\ta.Post(\"/auth/register\", a.handleRequest(api.PostAuthRegister))\n\n\ta.Get(\"/users\", a.handleRequest(api.GetUsers))\n\ta.Put(\"/users\", a.handleRequest(api.PutUser))\n\ta.Get(\"/users/{id}\", a.handleRequest(api.GetUser))\n\n\ta.Get(\"/chat/channels\", a.handleRequest(api.GetChatChannel))\n\ta.Get(\"/chat/channels/{id}\", a.handleRequest(api.GetChatChannelID))\n\ta.Get(\"/chat/messages/{channelID}\", a.handleRequest(api.GetChatMessages))\n\n\ta.Get(\"/stats/\", a.handleRequest(api.GetStats))\n\ta.Get(\"/stats/history\", a.handleRequest(api.GetHistory))\n\n\ta.Post(\"/games\", a.handleRequest(api.PostGame))\n\ta.Get(\"/games/{id}\", a.handleRequest(api.GetGame))\n\ta.Delete(\"/games/{id}\", a.handleRequest(api.DeleteGame))\n\ta.Post(\"/games/{id}/image\", a.handleRequest(api.PostGameImage))\n\ta.Put(\"/games/{id}/image\", a.handleRequest(api.PutGameImage))\n\n\ta.Post(\"/groups\", a.handleRequest(api.PostGroup))\n\ta.Get(\"/groups\", a.handleRequest(api.GetGroups))\n\ta.Get(\"/groups/{id}\", a.handleRequest(api.GetGroup))\n}", "title": "" }, { "docid": "abbd0cf72cec2c0fd96aa70d1a3bc793", "score": "0.69530296", "text": "func (a *App) setRouters() {\n\t// Routing for handling the projects\n\ta.Get(\"/users\", a.GetAllUsers)\n\ta.Get(\"/users/{userid}\", a.FindUserById)\n\ta.Post(\"/create-user\", a.CreateUser)\n\ta.Delete(\"/users/{userid}\", a.DeleteUser)\n\ta.Put(\"/users/{userid}\", a.ModifyUser)\n\ta.Post(\"/users/search\", a.SearchUsers)\n}", "title": "" }, { "docid": "d1f501cb41ef14f26129b03d280f19db", "score": "0.6942079", "text": "func (a *App) setRouters() {\n\t// Routing for handling the projects\n\ta.Get(\"/users\", a.GetAllUsers)\n\ta.Post(\"/users\", a.CreateUser)\n\ta.Get(\"/users/id\", a.GetUser)\n\ta.Put(\"/users/id\", a.UpdateUser)\n\ta.Delete(\"/users/id\", a.DeleteUser)\n\n}", "title": "" }, { "docid": "475b2c05032c5cd3472557418867b114", "score": "0.6903293", "text": "func (a *App) setRouters() {\n\t// Routing for handling the Users\n\ta.Get(\"/api/users\", a.handleRequest(handler.GetAllUsers))\n\ta.Post(\"/api/user\", a.handleRequest(handler.CreateUser))\n\ta.Get(\"/api/user/{id}\", a.handleRequest(handler.GetUser))\n\ta.Put(\"/api/user/{id}\", a.handleRequest(handler.UpdateUser))\n\ta.Delete(\"/api/user/{id}\", a.handleRequest(handler.DeleteUser))\n\n\t// Routing for handling the Customers\n\ta.Get(\"/api/customers\", a.handleRequest(handler.GetAllCustomers))\n\ta.Post(\"/api/customer\", a.handleRequest(handler.CreateCustomer))\n\ta.Get(\"/api/customer/{id}\", a.handleRequest(handler.GetCustomer))\n\ta.Get(\"/api/customers/{uid}\", a.handleRequest(handler.GetCustomersByUser))\n\ta.Put(\"/api/customer/{id}\", a.handleRequest(handler.UpdateCustomer))\n\ta.Delete(\"/api/customer/{id}\", a.handleRequest(handler.DeleteCustomer))\n\n\t// Routing for handling the Customers\n\ta.Get(\"/api/products\", a.handleRequest(handler.GetAllProducts))\n\ta.Post(\"/api/product\", a.handleRequest(handler.CreateProduct))\n\ta.Get(\"/api/product/{id}\", a.handleRequest(handler.GetProduct))\n\ta.Get(\"/api/products/{uid}\", a.handleRequest(handler.GetProductsByUser))\n\ta.Put(\"/api/product/{id}\", a.handleRequest(handler.UpdateProduct))\n\ta.Delete(\"/api/product/{id}\", a.handleRequest(handler.DeleteProduct))\n\n\ta.Get(\"/api/orders\", a.handleRequest(handler.GetAllOrders))\n\ta.Post(\"/api/order\", a.handleRequest(handler.CreateOrder))\n\ta.Get(\"/api/order/{id}\", a.handleRequest(handler.GetOrder))\n\ta.Get(\"/api/orders/{uid}\", a.handleRequest(handler.GetOrdersByUser))\n\ta.Put(\"/api/order/{id}\", a.handleRequest(handler.UpdateOrder))\n\ta.Delete(\"/api/order/{id}\", a.handleRequest(handler.DeleteOrder))\n\n\t// Routing for handling the Customers\n\ta.Get(\"/api/cart_items\", a.handleRequest(handler.GetAllCartItems))\n\ta.Post(\"/api/cart_item\", a.handleRequest(handler.CreateCartItem))\n\ta.Get(\"/api/cart_item/{id}\", a.handleRequest(handler.GetCartItem))\n\ta.Get(\"/api/cart_items/{uid}\", a.handleRequest(handler.GetCartItemsByUser))\n\ta.Put(\"/api/cart_item/{id}\", a.handleRequest(handler.UpdateCartItem))\n\ta.Delete(\"/api/cart_item/{id}\", a.handleRequest(handler.DeleteCartItem))\n\n\t// Routing for handling the Customers\n\ta.Get(\"/api/holdcart_items\", a.handleRequest(handler.GetAllHoldCartItems))\n\ta.Post(\"/api/holdcart_item\", a.handleRequest(handler.CreateHoldCartItem))\n\ta.Get(\"/api/holdcart_item/{id}\", a.handleRequest(handler.GetHoldCartItem))\n\ta.Get(\"/api/holdcart_items/{uid}\", a.handleRequest(handler.GetHoldCartItemsByUser))\n\ta.Put(\"/api/holdcart_item/{id}\", a.handleRequest(handler.UpdateHoldCartItem))\n\ta.Delete(\"/api/holdcart_item/{id}\", a.handleRequest(handler.DeleteHoldCartItem))\n\n\t// Routing for handling the Category\n\ta.Get(\"/api/categories\", a.handleRequest(handler.GetAllCustomers))\n\ta.Post(\"/api/category\", a.handleRequest(handler.CreateCustomer))\n\ta.Get(\"/api/category/{id}\", a.handleRequest(handler.GetCustomer))\n\ta.Get(\"/api/customers/{uid}\", a.handleRequest(handler.GetCustomersByUser))\n\ta.Put(\"/api/category/{id}\", a.handleRequest(handler.UpdateCustomer))\n\ta.Delete(\"/api/category/{id}\", a.handleRequest(handler.DeleteCustomer))\n\n\t// \t// Routing for handling the tasks\n\t// \ta.Get(\"/api/projects/{title}/tasks\", a.handleRequest(handler.GetAllTasks))\n\t// \ta.Post(\"/api/projects/{title}/tasks\", a.handleRequest(handler.CreateTask))\n\t// \ta.Get(\"/api/projects/{title}/tasks/{id:[0-9]+}\", a.handleRequest(handler.GetTask))\n\t// \ta.Put(\"/api/projects/{title}/tasks/{id:[0-9]+}\", a.handleRequest(handler.UpdateTask))\n\t// \ta.Delete(\"/api/projects/{title}/tasks/{id:[0-9]+}\", a.handleRequest(handler.DeleteTask))\n\t// \ta.Put(\"/api/projects/{title}/tasks/{id:[0-9]+}/complete\", a.handleRequest(handler.CompleteTask))\n\t// \ta.Delete(\"/api/projects/{title}/tasks/{id:[0-9]+}/complete\", a.handleRequest(handler.UndoTask))\n}", "title": "" }, { "docid": "f260e8ffbb6883aa9fd65d91d1bdddd4", "score": "0.6838002", "text": "func initRouters() {\n\t// Index page\n\trouter.GET(\"/\", showIndexPage)\n\trouter.StaticFile(\"/favicon.ico\", \"./resources/favicon.ico\")\n\n\t// Vue try data\n\trouter.GET(\"/api/try\", getTryData)\n\trouter.POST(\"/api/upload\", getUploadFile)\n\trouter.POST(\"/api/detect\", getDetectResult)\n}", "title": "" }, { "docid": "8d82dbce7663123c3cbab56557437a1d", "score": "0.6825167", "text": "func InitRouters(dataStore *store.DataStore, recordRotationThreshold int) error {\n\t// New pipeline record manager\n\tpipelineRecordManager, err := manager.NewPipelineRecordManager(dataStore, recordRotationThreshold)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// New pipeline manager\n\tpipelineManager, err := manager.NewPipelineManager(dataStore, pipelineRecordManager)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// New project manager\n\tprojectManager, err := manager.NewProjectManager(dataStore, pipelineManager)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// New event manager\n\teventManager, err := manager.NewEventManager(dataStore)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// New cloud manager\n\tcloudManager, err := manager.NewCloudManager(dataStore)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\trouter := &router{\n\t\tdataStore,\n\t\tprojectManager,\n\t\tpipelineManager,\n\t\tpipelineRecordManager,\n\t\teventManager,\n\t\tcloudManager,\n\t}\n\n\tws := new(restful.WebService)\n\tws.Filter(NCSACommonLogFormatLogger())\n\n\trouter.registerProjectAPIs(ws)\n\trouter.registerPipelineAPIs(ws)\n\trouter.registerPipelineRecordAPIs(ws)\n\trouter.registerEventAPIs(ws)\n\trouter.registerCloudAPIs(ws)\n\trouter.registerHealthCheckAPI(ws)\n\trouter.registerWebhookAPIs(ws)\n\n\trestful.Add(ws)\n\n\treturn nil\n}", "title": "" }, { "docid": "adbcef47aa07b1328e8db1dce39cc6f7", "score": "0.67381", "text": "func (s *userRouter) initRoutes() router.Router {\n\tr := chi.NewRouter()\n\tr.Post(\"/{userID}/tracks\", s.upload)\n\tr.Get(\"/{userID}/tracks\", s.findAll)\n\tr.Get(\"/{userID}/tracks/{trackName}\", s.getPresignedURL)\n\tr.Delete(\"/{userID}/tracks/{trackName}\", s.deleteObject)\n\treturn router.NewRouter(\"/users\", r)\n}", "title": "" }, { "docid": "d0c1eb866b1c48d18448e9af36c10c24", "score": "0.6712002", "text": "func init() {\n\n //GET get user info\n UserMux.HandleFunc(\"/user/\", getUser)\n\n //GET, POST & PUT add and removed saved\n UserMux.HandleFunc(\"/user/saved\", saved)\n\n //POST change user's name\n UserMux.HandleFunc(\"/user/name\", name)\n\n //POST search usernames and users' names\n UserMux.HandleFunc(\"/user/search\", searchUsers)\n\n //POST get user's threads\n UserMux.HandleFunc(\"/user/threads\", threads)\n\n //POST add a username, PUT to change it, DELETE to remove it\n UserMux.HandleFunc(\"/user/username\", username)\n\n //GET get all notifications\n UserMux.HandleFunc(\"/user/notifications\", notifications)\n\n //GET -- gets friends list, POST add a friend -- creates request, PUT accept it, DELETE to remove it,\n UserMux.HandleFunc(\"/user/friends\", friends)\n}", "title": "" }, { "docid": "98e002fb225f859b45d4959c6516f571", "score": "0.6708898", "text": "func initRouter(e *bm.Engine) {\n\t// health check\n\te.Ping(ping)\n\te.Register(register)\n\t// new defined api lists\n\tg := e.Group(\"/x/passport-game\")\n\t{\n\t\tg.GET(\"/oauth\", verify, oauth)\n\t\tg.GET(\"/myinfo\", verify, myInfo)\n\t\tg.GET(\"/info\", verify, info)\n\t\tg.GET(\"/key\", verify, getKeyProxy)\n\t\tg.GET(\"/login\", verify, loginProxy)\n\t\tg.GET(\"/renewtoken\", verify, renewToken)\n\t\tg.GET(\"/regions\", verify, regions)\n\t\tg.POST(\"/reg/v3\", verify, regV3)\n\t\tg.POST(\"/reg/v2\", verify, regV2)\n\t\tg.POST(\"/reg\", verify, reg)\n\t\tg.POST(\"/reg/byTel\", verify, byTel)\n\n\t\tg.GET(\"/captcha\", verify, captcha)\n\t\tg.POST(\"/sendSms\", verify, sendSms)\n\t}\n\n\tinner := e.Group(\"/cache/pb\")\n\t{\n\t\tinner.GET(\"/token\", tokenPBCache)\n\t\tinner.GET(\"/info\", infoPBCache)\n\t}\n\n}", "title": "" }, { "docid": "38dbcbcdc1ed2a7b52d74eb1276402d5", "score": "0.66627264", "text": "func initRouter(e *bm.Engine) {\n\t// init api\n\te.Ping(ping)\n\te.Register(register)\n\tmg := e.Group(\"/x/admin/member\")\n\t{\n\t\tmg.GET(\"/list\", authSvc.Permit(\"ACCOUNT_REVIEW\"), members)\n\t\tmg.POST(\"/exp/set\", authSvc.Permit(\"ACCOUNT_REVIEW_SET_EXP\"), expSet)\n\t\tmg.POST(\"/moral/set\", authSvc.Permit(\"ACCOUNT_REVIEW\"), moralSet)\n\t\tmg.POST(\"/rank/set\", authSvc.Permit(\"ACCOUNT_REVIEW_SET_RANK\"), rankSet)\n\t\tmg.POST(\"/coin/set\", authSvc.Permit(\"ACCOUNT_REVIEW\"), coinSet)\n\t\tmg.POST(\"/addit/remark/set\", authSvc.Permit(\"ACCOUNT_REVIEW\"), additRemarkSet)\n\t\tmg.GET(\"/profile\", authSvc.Permit(\"ACCOUNT_REVIEW\"), memberProfile)\n\t\tmg.GET(\"/exp/log\", authSvc.Permit(\"ACCOUNT_EXP_LOG\"), expLog)\n\t\tmg.GET(\"/face/history\", authSvc.Permit(\"ACCOUNT_FACE_HISTORY\"), faceHistory)\n\t\tmg.POST(\"/batch/formal\", authSvc.Permit(\"ACCOUNT_BATCH_FORMAL\"), batchFormal)\n\t\tmg.GET(\"/moral/log\", moralLog)\n\t\tmg.POST(\"/sign/del\", delSign)\n\t\tmg.POST(\"/pub/exp/msg\", authSvc.Permit(\"ACCOUNT_PUB_EXP_MSG\"), pubExpMsg)\n\n\t\t//个人信息审核\n\t\tmg.GET(\"/base/review\", authSvc.Permit(\"ACCOUNT_REVIEW_AUDIT\"), baseReview)\n\t\tmg.POST(\"/face/clear\", authSvc.Permit(\"ACCOUNT_REVIEW_AUDIT\"), clearFace)\n\t\tmg.POST(\"/sign/clear\", authSvc.Permit(\"ACCOUNT_REVIEW_AUDIT\"), clearSign)\n\t\tmg.POST(\"/name/clear\", authSvc.Permit(\"ACCOUNT_REVIEW_AUDIT\"), clearName)\n\n\t\tog := mg.Group(\"/official\")\n\t\t{\n\t\t\tog.GET(\"/list\", authSvc.Permit(\"OFFICIAL_VIEW\"), officials)\n\t\t\tog.GET(\"/list/excel\", authSvc.Permit(\"OFFICIAL_VIEW\"), officialsExcel)\n\t\t\tog.GET(\"/doc\", authSvc.Permit(\"OFFICIAL_VIEW\"), officialDoc)\n\t\t\tog.GET(\"/docs\", authSvc.Permit(\"OFFICIAL_VIEW\"), officialDocs)\n\t\t\tog.GET(\"/docs/excel\", authSvc.Permit(\"OFFICIAL_VIEW\"), officialDocsExcel)\n\t\t\tog.GET(\"/doc/audit\", authSvc.Permit(\"OFFICIAL_AUDIT\"), officialDocAudit)\n\t\t\tog.GET(\"/doc/edit\", authSvc.Permit(\"OFFICIAL_MNG\"), officialDocEdit)\n\n\t\t\tex := og.Group(\"/internal\")\n\t\t\tex.GET(\"/doc\", vfySvc.Verify, officialDoc)\n\t\t\tex.POST(\"/doc/audit\", vfySvc.Verify, officialDocAudit)\n\t\t\tex.POST(\"/doc/submit\", vfySvc.Verify, officialDocSubmit)\n\t\t}\n\n\t\trw := mg.Group(\"/review\")\n\t\t{\n\t\t\trw.GET(\"\", authSvc.Permit(\"ACCOUNT_PROPERTY_REVIEW_AUDIT\"), review)\n\t\t\trw.GET(\"/list\", authSvc.Permit(\"ACCOUNT_PROPERTY_REVIEW_AUDIT\"), reviewList)\n\t\t\trw.POST(\"/audit\", authSvc.Permit(\"ACCOUNT_PROPERTY_REVIEW_AUDIT\"), reviewAudit)\n\n\t\t\trw.GET(\"/face/list\", authSvc.Permit(\"ACCOUNT_PROPERTY_REVIEW_FACE_AUDIT\"), reviewFaceList)\n\t\t\trw.POST(\"/face/audit\", authSvc.Permit(\"ACCOUNT_PROPERTY_REVIEW_FACE_AUDIT\"), reviewAudit)\n\t\t}\n\n\t\tmn := mg.Group(\"/monitor\")\n\t\t{\n\t\t\tmn.GET(\"/list\", authSvc.Permit(\"ACCOUNT_MONITOR_REVIEW\"), monitors)\n\t\t\tmn.POST(\"/add\", authSvc.Permit(\"ACCOUNT_MONITOR_MNG\"), addMonitor)\n\t\t\tmn.POST(\"/del\", authSvc.Permit(\"ACCOUNT_MONITOR_MNG\"), delMonitor)\n\t\t}\n\n\t\trn := mg.Group(\"/realname\")\n\t\t{\n\t\t\trn.GET(\"/list\", authSvc.Permit(\"REALNAME_QUERY\"), realnameList)\n\t\t\trn.GET(\"/list/pending\", authSvc.Permit(\"REALNAME_AUDIT\"), realnamePendingList)\n\t\t\trn.GET(\"/image\", authSvc.Permit(\"REALNAME_AUDIT\"), realnameImage)\n\t\t\trn.GET(\"/image/preview\", realnameImagePreview)\n\t\t\trn.POST(\"/apply/audit\", authSvc.Permit(\"REALNAME_AUDIT\"), realnameAuditApply)\n\t\t\trn.GET(\"/reason\", authSvc.Permit(\"REALNAME_AUDIT\"), realnameReasonList)\n\t\t\trn.POST(\"/reason/set\", authSvc.Permit(\"REALNAME_SET_REASON\"), realnameSetReason)\n\t\t\trn.POST(\"/search/card\", vfySvc.Verify, realnameSearchCard)\n\t\t\trn.POST(\"/unbind\", authSvc.Permit(\"ACCOUNT_REVIEW\"), realnameUnbind)\n\t\t\trn.GET(\"/excel\", authSvc.Permit(\"REALNAME_EXPORT\"), realnameExport)\n\t\t\trn.POST(\"/file/upload\", authSvc.Permit(\"REALNAME_SUBMIT\"), realnameFileUpload)\n\t\t\trn.POST(\"/submit\", authSvc.Permit(\"REALNAME_SUBMIT\"), realnameSubmit)\n\n\t\t\tex := rn.Group(\"/internal\", vfySvc.Verify)\n\t\t\tex.GET(\"/list\", realnameList)\n\t\t\tex.GET(\"/list/pending\", realnamePendingList)\n\t\t\tex.GET(\"/image\", realnameImage)\n\t\t\tex.GET(\"/image/preview\", realnameImagePreview)\n\t\t\tex.POST(\"/apply/audit\", realnameAuditApply)\n\t\t\tex.GET(\"/reason\", realnameReasonList)\n\t\t\tex.POST(\"/reason/set\", realnameSetReason)\n\t\t\tex.POST(\"/search/card\", realnameSearchCard)\n\t\t\tex.POST(\"/unbind\", realnameUnbind)\n\t\t\tex.GET(\"/excel\", realnameExport)\n\t\t\tex.POST(\"/file/upload\", realnameFileUpload)\n\t\t\tex.POST(\"/submit\", realnameSubmit)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "d6625fd7e907ff0936aa6ced4eaf8ed7", "score": "0.66569096", "text": "func (a *Application) setRouters() {\n\n\t// Routing for Web Socket\n\ta.Handler.WebSocket(\"/ws\", a.Handler.HandleRequest(handler.GetWsService))\n\n\t// Routing for handling the matrix\n\ta.Handler.Get(\"/matrix\", a.Handler.HandleRequest(handler.GetMatrix))\n\n\t// Routing for handling the vectors\n\ta.Handler.Get(\"/vector/{id}\", a.Handler.HandleRequest(handler.GetVector))\n}", "title": "" }, { "docid": "8bac23c5ba14bb1943a0a164baf789c3", "score": "0.6629854", "text": "func initRoutes(config internal.Config, panicsWrapper panics.Panics, ucase *internal.Usecase) http.Handler {\n\n\t// Get environment\n\t// var isDevelopment = config.Server.Env == internal.Development\n\n\t// Middlewares\n\t// var mw router.Middleware\n\n\t// Init ROUTER\n\tapiRouter := api.NewRouter(api.RouterConfig{\n\t\tTimeout: time.Duration(config.Environment.GlobalTimeout) * time.Second,\n\t})\n\n\t// -- Set Panics handler TODO\n\tapiRouter.PanicsHandler(panicsWrapper.RouterHandler)\n\n\t// -----------------------------------------------------------\n\t// START - ADD ROUTE\n\t// WARNING! Duplicate routes will cause a panic!\n\t// -----------------------------------------------------------\n\n\t// -- Initialize API Module\n\tapiTest := apitest.New()\n\n\t// -- Routes WITHOUT authentication\n\tapiRouter.AddRoute(http.MethodGet, \"testing/getdata\", apiTest.Test)\n\n\t// -- Routes WITH authentication\n\n\t// -----------------------------------------------------------\n\t// END - ADD ROUTE\n\t// -----------------------------------------------------------\n\n\treturn apiRouter.GetHandler()\n\n}", "title": "" }, { "docid": "570ed8f895bbb71cfc2de397053421e1", "score": "0.6619925", "text": "func (a *App) setRouters() {\n\t// Routing for handling the projects\n\n\ta.Get(\"/user/\", a.GetUser, a.ValidateMiddleware)\n\ta.Post(\"/user/\", a.CreateUser, nil)\n\ta.Put(\"/user/\", a.UpdateUser, a.ValidateMiddleware)\n\ta.Post(\"/user/pic/\", a.UploadPrifilePicture, a.ValidateMiddleware)\n\ta.Get(\"/user/referral/\", a.GetReferral, a.ValidateMiddleware)\n\ta.Get(\"/user/contact/\", a.GetContact, a.ValidateMiddleware)\n\ta.Post(\"/user/message/\", a.GetMessage, a.ValidateMiddleware)\n\ta.Get(\"/user/member/{id}/\", a.GetUserEmail, nil)\n\n\ta.Get(\"/payment/history/\", a.GetPaymentHistory, a.ValidateMiddleware)\n\n\ta.Get(\"/plan/{id}/\", a.GetSinglePlan, nil)\n\ta.Get(\"/plan/\", a.GetPlan, nil)\n\ta.Post(\"/plan/\", a.CreatePlan, nil)\n\ta.Put(\"/plan/\", a.UpdatePlan, nil)\n\ta.Delete(\"/plan/\", a.DeletePlan, nil)\n\n\ta.Get(\"/partner/\", a.GetPartner, nil)\n\ta.Post(\"/partner/\", a.CreatePartner, nil)\n\ta.Put(\"/partner/\", a.UpdatePartner, nil)\n\ta.Delete(\"/partner/\", a.DeletePartner, nil)\n\n\ta.Get(\"/benefit/\", a.GetBenefit, nil)\n\ta.Get(\"/benefit/{id}/\", a.GetBenefitDetails, nil)\n\n\ta.Post(\"/benefit/\", a.CreateBenefit, nil)\n\ta.Put(\"/benefit/\", a.UpdateBenefit, nil)\n\ta.Delete(\"/benefit/\", a.DeleteBenefit, nil)\n\n\ta.Post(\"/contact/us/\", a.ContactUs, nil)\n}", "title": "" }, { "docid": "b1572423eeef720437d10384ceda0d2a", "score": "0.6571136", "text": "func initRouter(e *bm.Engine) {\n\te.Ping(ping)\n\te.Register(register)\n\te.GET(\"/databus/consumer/addrs\", consumerAddrs)\n\te.POST(\"/databus/pub\", pub)\n}", "title": "" }, { "docid": "10940cfd032b7be6e36d43a0e259ed2e", "score": "0.65548414", "text": "func SetupRouter() *gin.Engine {\n\tr := gin.Default()\n\tgrp1 := r.Group(\"/user-api\")\n\t{\n\n\t\tgrp1.GET(\"user\", Controllers.GetUsers)\n\t\tgrp1.POST(\"user\", Controllers.CreateUser)\n\t\tgrp1.GET(\"user/:id\", Controllers.GetUserByID)\n\t\tgrp1.PUT(\"user/:id\", Controllers.UpdateUser)\n\t\tgrp1.DELETE(\"user/:id\", Controllers.DeleteUser)\n\t}\n\treturn r\n}", "title": "" }, { "docid": "dac14f7404fc186602ef32f7a46b598e", "score": "0.65535325", "text": "func (w *Web) InitRoutes(e *echo.Echo) {\n\t// Routes that does not require auth\n\te.POST(\"/user/register\", w.CreateUser, utils.CheckToken)\n\te.POST(\"/user/login\", w.LoginUser, utils.CheckToken)\n\te.PUT(\"/user/update/:id\", w.UpdateUser)\n\n\t// Routes that require auth\n\tuserAuthRequired := e.Group(\"/user\")\n\tuserAuthRequired.Use(middleware.JWT([]byte(viper.GetString(\"jwt_key\"))))\n\tuserAuthRequired.GET(\"/couple/invite\", w.PartnerInvite)\n\tuserAuthRequired.GET(\"/expenses\", w.FindExpenses)\n\tuserAuthRequired.GET(\"/income\", w.FindMonthlyIncome)\n\tuserAuthRequired.GET(\"/products\", w.FindProducts)\n\tuserAuthRequired.POST(\"/expense\", w.UpsertExpense)\n\tuserAuthRequired.POST(\"/income\", w.UpsertMonthlyIncome)\n\tuserAuthRequired.POST(\"/product\", w.UpsertProduct)\n\tuserAuthRequired.PUT(\"/expense/:id\", w.UpsertExpense)\n\tuserAuthRequired.PUT(\"/income\", w.UpsertMonthlyIncome)\n\tuserAuthRequired.PUT(\"/product/:id\", w.UpsertProduct)\n}", "title": "" }, { "docid": "7b27e53960220c7b0e1c473460c6143a", "score": "0.6538747", "text": "func InitRouters() *mux.Router {\n\trouter := mux.NewRouter()\n\trouter = MovieRoutes(router)\n\treturn router\n}", "title": "" }, { "docid": "1bb1767e2ab8040912cd0ffc0d02457d", "score": "0.65203714", "text": "func InitRoutes(db *sql.DB, jwtAdminSecret string, jwtUserSecret string) *chi.Mux {\n\trouter := chi.NewRouter()\n\trouter.Use(\n\t\trender.SetContentType(render.ContentTypeJSON),\n\t\tmiddleware.RealIP,\n\t\tmiddleware.Timeout(30*time.Second),\n\t\tmiddleware.Logger,\n\t\tmiddleware.DefaultCompress,\n\t\tmiddleware.RedirectSlashes,\n\t\tmiddleware.Recoverer,\n\t\tmiddleware.Timeout(60*time.Second),\n\t\tmiddleware.WithValue(\"DBCONN\", db),\n\t\tmiddleware.WithValue(\"JWTADMINSECRET\", jwtAdminSecret),\n\t\tmiddleware.WithValue(\"JWTUSERSECRET\", jwtUserSecret),\n\t)\n\n\trouter.Route(\"/v1\", func(r chi.Router) {\n\t\tr.Mount(\"/api/user\", user.Routes())\n\t\tr.Mount(\"/api/admin\", admin.Routes())\n\t})\n\n\treturn router\n}", "title": "" }, { "docid": "e542261882c23910758a962b12c4e016", "score": "0.6518462", "text": "func init(){\n\tr := Router()\n\thttp.Handle(\"/\", r)\n}", "title": "" }, { "docid": "8b0314d64788cf6bec1f9dc3810eff9c", "score": "0.6509523", "text": "func InitRouter() *echo.Echo {\n\n\te := echo.New()\n\n\te.GET(\"/\", base.RootView)\n\n\t// Routings\n\n\t/*\n\t\tu1 := e.Group(\"/utility/api/v1\")\n\t\t{\n\t\t\tUtilityAPIRoutings(u1)\n\t\t}\n\t*/\n\n\treturn e\n}", "title": "" }, { "docid": "03543857ba3dacc4316c78c3178fe21e", "score": "0.6474453", "text": "func InitRouter(deps Dependencies) (router *mux.Router) {\n\trouter = mux.NewRouter()\n\n\t// No version requirement for /ping\n\trouter.HandleFunc(\"/ping\", pingHandler).Methods(http.MethodGet)\n\t// Version 1 API management\n\tv1 := fmt.Sprintf(\"application/vnd.%s.v1\", config.AppName())\n\n\trouter.HandleFunc(\"/users\", listUsersHandler(deps)).Methods(http.MethodGet).Headers(versionHeader, v1)\n\trouter.HandleFunc(\"/organizations\", listOrganizationHandler(deps)).Methods(http.MethodGet).Headers(versionHeader, v1)\n\trouter.HandleFunc(\"/organizations/{id:[0-9]+}\", getOrganizationHandler(deps)).Methods(http.MethodGet).Headers(versionHeader, v1)\n\trouter.HandleFunc(\"/organizations\", createOrganizationHandler(deps)).Methods(http.MethodPost).Headers(versionHeader, v1)\n\trouter.HandleFunc(\"/organizations/{id:[0-9]+}\", deleteOrganizationHandler(deps)).Methods(http.MethodDelete).Headers(versionHeader, v1)\n\trouter.HandleFunc(\"/organizations/{id:[0-9]+}\", updateOrganizationHandler(deps)).Methods(http.MethodPut).Headers(versionHeader, v1)\n\treturn\n}", "title": "" }, { "docid": "b775f34c6769fafb5059328272b838c8", "score": "0.64525515", "text": "func InitAPIRoutes(r chi.Router) {\n\t/*\n\t\t|--------------------------------------------------------------------------\n\t\t| Users Routes\n\t\t|--------------------------------------------------------------------------\n\t\t|\n\t*/\n\tr.Route(\"/pertanyaan\", func(r chi.Router) {\n\t\tr.Get(\"/\", GetJawaban)\n\t\tr.Post(\"/\", StoreQNA)\n\t\tr.Get(\"/hewo\", HelloWorld)\n\t})\n\n\tr.Route(\"/pengguna\", func(r chi.Router) {\n\t\tr.Get(\"/\", GetPengguna)\n\t\tr.Post(\"/\", StorePengguna)\n\t})\n\n\tr.Route(\"/keluhan\", func(r chi.Router) {\n\t\tr.Post(\"/\", StoreKeluhan)\n\t})\n\n\tr.Route(\"/employee\", func(r chi.Router) {\n\t\tr.Get(\"/\", GetAllEmployee)\n\t})\n}", "title": "" }, { "docid": "00c5a059a6b6cb4ac37e4fc6b31b8a15", "score": "0.64225036", "text": "func initRouter(router *gin.Engine) {\n\tswaggerRoute(router)\n\tv1.GameRoutesGroup(restRoute(router))\n}", "title": "" }, { "docid": "32d8b9222a129ad62f6e98ade2328fa0", "score": "0.6412095", "text": "func Routers(w http.ResponseWriter, r *http.Request) {\n\tnumReg, _ := regexp.Compile(\"\\\\d+\")\n\turlPaths := strings.Split(r.RequestURI, \"/\")\n\tlastPath := urlPaths[len(urlPaths)-1]\n\n\troutes := routes{\n\t\tRoute{\n\t\t\tName: \"home\",\n\t\t\tHandler: controllers.Index,\n\t\t\tPattern: \"/\",\n\t\t\tMethod: \"GET\",\n\t\t},\n\t\tRoute{\n\t\t\tName: \"user\",\n\t\t\tHandler: controllers.CreateUser,\n\t\t\tPattern: baseURL + \"/user\",\n\t\t\tMethod: \"POST\",\n\t\t},\n\t\tRoute{\n\t\t\tName: \"user\",\n\t\t\tHandler: controllers.Login,\n\t\t\tPattern: baseURL + \"/login\",\n\t\t\tMethod: \"POST\",\n\t\t},\n\t\tRoute{\n\t\t\tName: \"categories\",\n\t\t\tHandler: controllers.CreateCategory,\n\t\t\tPattern: baseURL + \"/category\",\n\t\t\tMethod: \"POST\",\n\t\t\tMiddleware: middlewares.AuthMiddleware(middlewares.AuthAdminMiddleware(http.HandlerFunc(controllers.CreateCategory))),\n\t\t},\n\t\tRoute{\n\t\t\tName: \"subjects\",\n\t\t\tHandler: controllers.CreateSubject,\n\t\t\tPattern: baseURL + \"/subject\",\n\t\t\tMethod: \"POST\",\n\t\t\tMiddleware: middlewares.AuthMiddleware(http.HandlerFunc(controllers.CreateSubject)),\n\t\t},\n\t\tRoute{\n\t\t\tName: \"questions\",\n\t\t\tHandler: controllers.CreateQuestion,\n\t\t\tPattern: baseURL + \"/question\",\n\t\t\tMethod: \"POST\",\n\t\t\tMiddleware: middlewares.AuthMiddleware(http.HandlerFunc(controllers.CreateQuestion)),\n\t\t},\n\t\tRoute{\n\t\t\tName: \"options\",\n\t\t\tHandler: controllers.CreateOption,\n\t\t\tPattern: baseURL + \"/option\",\n\t\t\tMethod: \"POST\",\n\t\t\tMiddleware: middlewares.AuthMiddleware(http.HandlerFunc(controllers.CreateOption)),\n\t\t},\n\t\tRoute{\n\t\t\tName: \"subjects\",\n\t\t\tHandler: controllers.GetSubjects,\n\t\t\tPattern: baseURL + \"/subject\",\n\t\t\tMethod: \"GET\",\n\t\t},\n\t\tRoute{\n\t\t\tName: \"subject\",\n\t\t\tHandler: controllers.GetSubject,\n\t\t\tPattern: baseURL + \"/subject/\" + numReg.FindString(lastPath),\n\t\t\tMethod: \"GET\",\n\t\t},\n\t\tRoute{\n\t\t\tName: \"category\",\n\t\t\tHandler: controllers.GetCategories,\n\t\t\tPattern: baseURL + \"/category\",\n\t\t\tMethod: \"GET\",\n\t\t},\n\t}\n\n\tfor _, route := range routes {\n\t\tif r.URL.Path == route.Pattern && r.Method == route.Method {\n\t\t\tif route.Middleware != nil {\n\t\t\t\troute.Middleware.ServeHTTP(w, r)\n\t\t\t} else {\n\t\t\t\troute.Handler(w, r)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}\n\n\thttp.NotFound(w, r)\n}", "title": "" }, { "docid": "c51330eafe2b02722836c1a33895bc0b", "score": "0.64108944", "text": "func (s *Server) configureRouters() {\n\tvar appPath = s.cfg.App.Frontend.Admin\n\n\ts.addRouter(static.NewRouter(appPath))\n\ts.addRouter(auth.NewRouter())\n\ts.addRouter(user.NewRouter())\n\ts.addRouter(student.NewRouter())\n}", "title": "" }, { "docid": "6c6b9652cb6ab452c381c34212bcc133", "score": "0.6390558", "text": "func SetupRouter() *gin.Engine {\n\tr := gin.Default()\n\tgrp1 := r.Group(\"/student-api\")\n\t{\n\t\tgrp1.GET(\"student\", Controllers.GetUsers)\n\t\tgrp1.POST(\"student\", Controllers.CreateUser)\n\t\tgrp1.GET(\"student/:id\", Controllers.GetUserByID)\n\t\tgrp1.PUT(\"student/:id\", Controllers.UpdateUser)\n\t\tgrp1.DELETE(\"student/:id\", Controllers.DeleteUser)\n\t}\n\treturn r\n}", "title": "" }, { "docid": "2f533c4a3b1b8f31327ac50c82d9749b", "score": "0.63660884", "text": "func SetUserRoutes(router *mux.Router) *mux.Router {\n\n\t// Get a UserController instance\n\tuserController := controllers.NewUserController(common.GetSession())\n\ttokenController := controllers.NewTokenController()\n\n\trouter.Handle(\"/\",\n\t\tnegroni.New(\n\t\t\tnegroni.HandlerFunc(userController.Index),\n\t\t)).Methods(\"GET\")\n\n\trouter.Handle(\"/users\",\n\t\tnegroni.New(\n\t\t\tnegroni.HandlerFunc(tokenController.ValidateTokenHandler),\n\t\t\tnegroni.HandlerFunc(userController.GetUsers),\n\t\t)).Methods(\"GET\")\n\n\trouter.Handle(\"/users/{id}\",\n\t\tnegroni.New(\n\t\t\tnegroni.HandlerFunc(tokenController.ValidateTokenHandler),\n\t\t\tnegroni.HandlerFunc(userController.GetUser),\n\t\t)).Methods(\"GET\")\n\n\trouter.Handle(\"/users\",\n\t\tnegroni.New(\n\t\t\tnegroni.HandlerFunc(tokenController.ValidateTokenHandler),\n\t\t\tnegroni.HandlerFunc(userController.CreateUser),\n\t\t)).Methods(\"POST\")\n\n\trouter.Handle(\"/users/{id}\",\n\t\tnegroni.New(\n\t\t\tnegroni.HandlerFunc(tokenController.ValidateTokenHandler),\n\t\t\tnegroni.HandlerFunc(userController.UpdateUser),\n\t\t)).Methods(\"PUT\")\n\n\trouter.Handle(\"/users/{id}\",\n\t\tnegroni.New(\n\t\t\tnegroni.HandlerFunc(tokenController.ValidateTokenHandler),\n\t\t\tnegroni.HandlerFunc(userController.RemoveUser),\n\t\t)).Methods(\"DELETE\")\n\n\treturn router\n}", "title": "" }, { "docid": "2754cbdb5f9ecfbb082022abbf08eee2", "score": "0.63385385", "text": "func (u *UserController) InitializeRoute(e *echo.Echo) {\n\te.GET(\"/users/:email\", u.GetProfile, middlewares.GetJWTMiddleware())\n\te.GET(\"/users/:email/history\", u.GetUserOrderHistory, middlewares.GetJWTMiddleware())\n}", "title": "" }, { "docid": "3e9eeac9b794fca0aff2f65e861c5991", "score": "0.62990654", "text": "func initRoute(router *gin.Engine, db *pg.DB, config conf.Configuration, adsFetcher ads.Fetcher) {\n\trouter.GET(\"/ping\", func(c *gin.Context) { c.JSON(200, \"pong\") })\n\trouter.POST(\"/sign-up\", http.SignUpHandler(db, usecase.SignUp()))\n\trouter.POST(\"/sign-in\", http.SignInHandler(db, usecase.SignIn(config)))\n\trouter.DELETE(\"/delete-me\", http.AuthMiddleware(db, config), http.DeleteMeHandler(db, usecase.DeleteMe(adsFetcher)))\n\trouter.PATCH(\"/update-me\", http.AuthMiddleware(db, config), http.UpdateMeHandler(db, usecase.UpdateMe()))\n\trouter.GET(\"/get-me\", http.AuthMiddleware(db, config), http.GetMeHandler(db, usecase.GetMe(adsFetcher)))\n\trouter.POST(\"/add-funds\", http.AuthMiddleware(db, config), http.AddFundsHandler(db, usecase.AddFunds()))\n\trouter.GET(\"/info/:email\", http.AuthMiddleware(db, config), http.GetUserHandler(db, usecase.GetUser(adsFetcher)))\n\trouter.GET(\"/info/byId/:id\", http.AuthMiddleware(db, config), http.GetUserByIdHandler(db, usecase.GetUserById(adsFetcher)))\n\trouter.POST(\"/update-balance/byId/:id\", http.AuthMiddleware(db, config), http.UpdateBalanceByIdHandler(db, usecase.UpdateBalanceById()))\n\trouter.GET(\"/\", http.AuthAdminMiddleware(db, config), http.AdminGetAllUsersHandler(db, usecase.AdminGetAllUsers()))\n\trouter.GET(\"/:id\", http.AuthAdminMiddleware(db, config), http.AdminGetUserHandler(db, usecase.AdminGetUser()))\n\trouter.DELETE(\"/:id\", http.AuthAdminMiddleware(db, config), http.AdminDeleteUserHandler(db, usecase.AdminDeleteUser()))\n\trouter.PATCH(\"/:id\", http.AuthAdminMiddleware(db, config), http.AdminUpdateUserHandler(db, usecase.AdminUpdateUser()))\n}", "title": "" }, { "docid": "5e4470b29e6bf7efc596c5170922798f", "score": "0.6287725", "text": "func (a *App) setRouters() {\n\t// Routing for handling the projects\n\ta.Get(\"/projects\", a.ProjectController.GetAllProjects)\n\ta.Post(\"/projects\", a.ProjectController.CreateProject)\n\ta.Get(\"/projects/{title}\", a.ProjectController.GetProject)\n\ta.Put(\"/projects/{title}\", a.ProjectController.UpdateProject)\n\ta.Delete(\"/projects/{title}\", a.ProjectController.DeleteProject)\n\n\t// Routing for handling the tasks\n\ta.Get(\"/projects/{title}/tasks\", a.TaskController.GetAllTasks)\n\ta.Post(\"/projects/{title}/tasks\", a.TaskController.CreateTask)\n\ta.Get(\"/projects/{title}/tasks/{id:[0-9]+}\", a.TaskController.GetTask)\n\ta.Put(\"/projects/{title}/tasks/{id:[0-9]+}\", a.TaskController.UpdateTask)\n\ta.Delete(\"/projects/{title}/tasks/{id:[0-9]+}\", a.TaskController.DeleteTask)\n}", "title": "" }, { "docid": "dd692d07f70023c61cf4a9622e5d27cd", "score": "0.62840915", "text": "func initRoutes(mx *mux.Router, formatter *render.Render) {\n\tmx.HandleFunc(\"/status\", Status(formatter))\n\tmx.HandleFunc(\"/cars\", Cars(formatter))\n\tmx.HandleFunc(\"/journey\", Journey(formatter))\n\tmx.HandleFunc(\"/dropoff\", Dropoff(formatter))\n\tmx.HandleFunc(\"/locate\", Locate(formatter))\n}", "title": "" }, { "docid": "076b2ea0b6a6283510a2c5c056c9ff86", "score": "0.6275445", "text": "func InitRoutes(c HandlerConfig) {\n\th := Handler{\n\t\tUserService: c.UserService,\n\t\tLang: c.Lang,\n\t}\n\t//Set api group\n\tg := c.R.Group(c.BaseURL)\n\n\tg.GET(\"/users/:id\", h.GetUser)\n\tg.POST(\"/users/:id\", h.UpdateUser)\n\tg.PATCH(\"/users/:id\", h.PatchUser)\n\tg.DELETE(\"/users/:id\", h.DeleteUser)\n\tg.POST(\"/users\", h.AddUser)\n\tg.GET(\"/users\", h.ListUsers)\n\tg.POST(\"/adminLogin\", h.AdminLogin)\n\tg.POST(\"/tokenRefresh\", h.TokenRefresh)\n\tg.POST(\"/authorize\", h.Authorize)\n}", "title": "" }, { "docid": "672f619ab03d031d7efa31c1b0e6cc83", "score": "0.62633526", "text": "func (s *Server) InitRouters(routers ...router.Router) {\n\ts.routers = append(s.routers, routers...)\n}", "title": "" }, { "docid": "bf6ad32c4b21322f08590dcafb73e43c", "score": "0.62526995", "text": "func InitRouter() *mux.Router {\n\t//Create the router\n\tr := mux.NewRouter()\n\n\t//Add endpoint\n\tr.HandleFunc(\"/student\", c.GatAllStudents).Methods(http.MethodGet)\n\tr.HandleFunc(\"/student\", c.AddRegister).Methods(http.MethodPost)\n\tr.HandleFunc(\"/class\", c.GatAllClasses).Methods(http.MethodGet)\n\tr.HandleFunc(\"/average\", c.GetGeneralAverage).Methods(http.MethodGet)\n\tr.HandleFunc(\"/average/student/{name}\", c.GetStudentAvegare).Methods(http.MethodGet)\n\tr.HandleFunc(\"/average/class/{name}\", c.GetAverageByClass).Methods(http.MethodGet)\n\n\treturn r\n}", "title": "" }, { "docid": "c3c79a7155720705e61b44f0119ab07d", "score": "0.6238945", "text": "func registerUsersRoutes(usersRouter iris.Party) {\n\t// GET: /users\n\tusersRouter.Get(\"/\", getAllUsersHandler)\n\tusersRouter.Party(\"/{name}\").ConfigureContainer(registerUserRoutes)\n}", "title": "" }, { "docid": "a39da96514a459f52cf4a3ab3842e4a7", "score": "0.6229023", "text": "func SetUserRoutes(router *mux.Router) *mux.Router{\n\trouter.HandleFunc(\"/users/registration\", controllers.Register).Methods(\"POST\")\n\trouter.HandleFunc(\"/users/login\",controllers.Login).Methods(\"POST\")\n\trouter.HandleFunc(\"/users/{id}\",controllers.GetUserByID).Methods(\"GET\")\n\n\n\treturn router\n}", "title": "" }, { "docid": "e4d24b22195716fa18f83f1889a14e8d", "score": "0.6226109", "text": "func createSubRouters(r *mux.Router) {\n\n\t// map wiki pages\n\twikiSubRouter := r.Host(WIKI + \".\" + config.DomainName()).Subrouter()\n\twikiSubRouter.HandleFunc(\"/login\", api.LoginFunc)\n\twikiSubRouter.HandleFunc(\"/logout\", api.LogoutFunc)\n\tmapStaticFiles(wikiSubRouter)\n\twikiSubRouter.PathPrefix(\"/files/\").Handler(middleware.Middleware(\n\t\thttp.StripPrefix(\"/files/\", http.FileServer(http.Dir(config.FilesDir()))),\n\t\tmiddleware.RequiresLogin,\n\t\tmiddleware.RedirectHTTPS,\n\t))\n\t// html pages by default are private, except for blog pages.\n\twikiSubRouter.PathPrefix(\"/\").Handler(middleware.Middleware(\n\t\thttp.StripPrefix(\"/\", http.FileServer(http.Dir(\"../html\"))),\n\t\tmiddleware.RequiresLogin,\n\t\tmiddleware.RedirectHTTPS,\n\t))\n\n\ttaskConfig := config.TaskConfiguration()\n\tif taskConfig.IsNotEmpty() {\n\t\tlog.Println(\"Creating task server...\")\n\t\ttaskSubRouter := r.Host(\"task.\" + config.DomainName()).Subrouter()\n\t\tmapTaskServer(taskSubRouter, taskConfig)\n\t}\n\n\t// map blog pages\n\tif config.DeployBlog() {\n\t\tblogSubrouter := r.Host(BLOG + \".\" + config.DomainName()).Subrouter()\n\t\tmapStaticFiles(blogSubrouter)\n\n\t\tblogSubrouter.PathPrefix(\"/files/\").Handler(middleware.Middleware(\n\t\t\thttp.StripPrefix(\"/files/\", http.FileServer(http.Dir(\"../blog/files/\"))),\n\t\t\tmiddleware.RedirectHTTPS,\n\t\t))\n\n\t\tblogSubrouter.PathPrefix(\"/\").Handler(middleware.Middleware(\n\t\t\thttp.StripPrefix(\"/\", http.FileServer(http.Dir(\"../html/blog\"))),\n\t\t\tmiddleware.RedirectHTTPS,\n\t\t))\n\n\t\t// map \"/\" to go to blogSbrouter by default\n\t\tif config.HTTPSMode() {\n\t\t\tr.Handle(\"/\", http.RedirectHandler(\"https://\"+BLOG+\".\"+config.DomainName()+\"/\", 301))\n\t\t} else {\n\t\t\tif config.HTTPPort() != \"\" {\n\t\t\t\tr.Handle(\"/\", http.RedirectHandler(\"http://\"+BLOG+\".\"+config.DomainName()+config.HTTPPort()+\"/\", 301))\n\t\t\t} else {\n\t\t\t\tr.Handle(\"/\", http.RedirectHandler(\"http://\"+BLOG+\".\"+config.DomainName()+\"/\", 301))\n\t\t\t}\n\t\t}\n\n\t}\n\n}", "title": "" }, { "docid": "f0044478daa49d708314b7989f930be1", "score": "0.62182724", "text": "func (a *App) setRouters() {\n\t// Routing for handling the projects\n\ta.Get(\"/employees\", a.GetAllEmployees)\n\ta.Post(\"/employees\", a.CreateEmployee)\n\ta.Get(\"/employees/{title}\", a.GetEmployee)\n\ta.Put(\"/employees/{title}\", a.UpdateEmployee)\n\ta.Delete(\"/employees/{title}\", a.DeleteEmployee)\n\ta.Put(\"/employees/{title}/disable\", a.DisableEmployee)\n\ta.Put(\"/employees/{title}/enable\", a.EnableEmployee)\n}", "title": "" }, { "docid": "50704c556938a9c9702ecbb57d8a299b", "score": "0.6204612", "text": "func setupUserRoutes(r *gin.RouterGroup, mws *mw.MiddlewareSet, userCtrl *ctrl.UserController) {\n\tpermsConfig := mws.PermissionsConfigurer()\n\n\tpermsEntry := permsConfig.ConfigureEntry(\"CUD_USERS\")\n\taccess := permsEntry.AccessDecisionAgent()\n\n\tupdateUserFunc := access.DecideControllerFunc(updateUser(userCtrl))\n\n\tr.POST(\"/users\", access.DecideHandlerFunc(), createUser(userCtrl))\n\tr.GET(\"/users\", getAllUsers(userCtrl))\n\tr.GET(\"/users/:uid\", getUserByID(userCtrl))\n\tr.PATCH(\"/users/:uid\", updateUserFunc)\n\tr.PUT(\"/users/:uid\", updateUserFunc)\n\tr.DELETE(\"/users/:uid\", access.DecideHandlerFunc(), deleteUser(userCtrl))\n}", "title": "" }, { "docid": "87edb0154df504fc5d22006dbc9fa325", "score": "0.6193162", "text": "func initApiHandlers(router *itineris.ApiRouter) {\n\trouter.SetHandler(\"info\", apiInfo)\n\trouter.SetHandler(\"login\", apiLogin)\n\trouter.SetHandler(\"verifyLoginToken\", apiVerifyLoginToken)\n\trouter.SetHandler(\"systemInfo\", apiSystemInfo)\n\n\trouter.SetHandler(\"myFeed\", apiMyFeed)\n\trouter.SetHandler(\"myBlog\", apiMyBlog)\n\trouter.SetHandler(\"createBlogPost\", apiCreateBlogPost)\n\trouter.SetHandler(\"getBlogPost\", apiGetBlogPost)\n\trouter.SetHandler(\"updateBlogPost\", apiUpdateBlogPost)\n\trouter.SetHandler(\"deleteBlogPost\", apiDeleteBlogPost)\n\n\trouter.SetHandler(\"getUserVoteForPost\", apiGetUserVoteForPost)\n\trouter.SetHandler(\"voteForPost\", apiVoteForPost)\n}", "title": "" }, { "docid": "aa8a072ee025249348f91b1d82aeafc4", "score": "0.6169702", "text": "func InitRouter() http.Handler {\n\tr := mux.NewRouter()\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlogger.Error(\"Recover:\", r)\n\t\t}\n\t}()\n\n\tr.HandleFunc(\"/service-info\", func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Write([]byte(\"API-Service\"))\n\t}).Methods(\"GET\")\n\n\tr.HandleFunc(\"/api/testtoken\", controller.TestToken).Methods(\"POST\")\n\t\n\tr.HandleFunc(\"/api/v1/admin/login\", controller.LoginAdmin).Methods(\"POST\")\n\n\tHandleAdmin(r)\n\n\tc := cors.New(cors.Options{\n\t\tAllowedOrigins: []string{\"*\"},\n\t\tAllowedHeaders: []string{\"*\"},\n\t\tAllowedMethods: []string{\"GET\", \"POST\", \"PUT\", \"DELETE\"},\n\t})\n\treturn c.Handler(r)\n}", "title": "" }, { "docid": "ec8bf30eb07ede8a910979248d858c28", "score": "0.61672074", "text": "func initRoutes(mx *mux.Router, formatter *render.Render) {\n\tmx.HandleFunc(\"/ping\", pingHandler(formatter)).Methods(\"GET\")\n\tmx.HandleFunc(\"/apis\", getKongApisHandler(formatter)).Methods(\"GET\")\n\tmx.HandleFunc(\"/apis\", createNewKongApiHandler(formatter)).Methods(\"POST\")\n mx.HandleFunc(\"/apis\", createNewKongApiHandler(formatter)).Methods(\"DELETE\")\n}", "title": "" }, { "docid": "294331c3f7d51554850c09afedf8e133", "score": "0.61668354", "text": "func InitRouter(router *mux.Router) {\n\t// Resources files\n\trouter.PathPrefix(\"/res\").Handler(http.StripPrefix(\"/res/\",\n\t\thttp.FileServer(http.Dir(resDir))))\n\n\tinitAuthorizationRouter(router)\n\tinitCollectionUsersRouter(router)\n\tinitCollectionActivitiesRouter(router)\n\tinitCollectionActivityStagesRouter(router)\n\tinitCollectionPhotoLivesRouter(router)\n\tinitCollectionPhotosRouter(router)\n\tinitCollectionOrganizationsRouter(router)\n\tinitCollectionMomentsRouter(router)\n}", "title": "" }, { "docid": "16d69a738d7ddf46abdd3f5b08db93df", "score": "0.615533", "text": "func Routers() {\n\n\t// mux.Handle(\"/\", http.HandlerFunc(controller.index))\n\tMux.HandleFunc(\"/\", controller.Index)\n\tMux.HandleFunc(\"/create\", controller.Add)\n\tMux.HandleFunc(\"/update\", controller.Update)\n\tMux.HandleFunc(\"/delete\", controller.Delete)\n\tMux.HandleFunc(\"/getbyid\", controller.GetById)\n\tMux.HandleFunc(\"/getall\", controller.GetAll)\n}", "title": "" }, { "docid": "0730f3a6691d585c2b0f590dd56e6591", "score": "0.61553067", "text": "func SetupRouter() *gin.Engine {\n\tr := gin.Default()\n\tv1 := r.Group(\"/api\")\n\t{\n\t\t//user\n\t\tv1.GET(\"user\", controllers.GetUsers)\n\t\tv1.POST(\"user\", controllers.CreateUser)\n\t\tv1.GET(\"user/:id\", controllers.GetUserByID)\n\t\tv1.PUT(\"user/:id\", controllers.UpdateUser)\n\t\tv1.DELETE(\"user/:id\", controllers.DeleteUser)\n\n\t\t//activities\n\t\tv1.GET(\"activities\", controllers.GetActivities)\n\n\t\t//activities\n\t\tv1.GET(\"categories\", controllers.GetCategories)\n\t}\n\treturn r\n}", "title": "" }, { "docid": "2e1e014489c1c9f49ba82329ac98096b", "score": "0.6142585", "text": "func init() {\n\trouter = mux.NewRouter().StrictSlash(true)\n\t/**\n\t* Static route pah for assets (CSS, JS, Images and fonts)\n\t */\n\trouter.PathPrefix(\"/assets/\").Handler(\n\t\thttp.StripPrefix(\n\t\t\t\"/assets/\",\n\t\t\thttp.FileServer(\n\t\t\t\thttp.Dir(\n\t\t\t\t\tfilepath.Join(os.Getenv(\"goventy_ROOT\"), config.ENV()[\"PUBLIC_ASSETS\"])))))\n\n\t/**\n\t* Index\n\t */\n\trouter.HandleFunc(\"/\", controllers.Home)\n\n\t/**\n\t* Authentication\n\t */\n\tauth := router.PathPrefix(\"/auth\").Subrouter()\n\tauth.HandleFunc(\"/register\", AuthController.Register).Methods(\"POST\")\n\tauth.HandleFunc(\"/login\", AuthController.Login).Methods(\"POST\")\n\n\t/**\n\t* The following routes require a valid JWT token to get access to them\n\t */\n\tgJam := &middleware.JwtAuthMiddleware{}\n\n\t/**\n\t* Event routes\n\t */\n\teventGaurded := router.PathPrefix(\"/events\").Subrouter()\n\teventUngaurded := router.PathPrefix(\"/events\").Subrouter()\n\t//event routes that require authentication\n\teventGaurded.Use(gJam.GeneralAuthentication)\n\teventGaurded.HandleFunc(\"\", EventController.Create).Methods(\"POST\")\n\teventGaurded.HandleFunc(\"/{id}\", EventController.Update).Methods(\"PUT\")\n\t//event routes that do not require authentication\n\teventUngaurded.HandleFunc(\"\", EventController.Find).Methods(\"GET\")\n\teventUngaurded.HandleFunc(\"/{id}\", EventController.Get).Methods(\"GET\")\n\teventUngaurded.HandleFunc(\"/{event_id}/tickets\", EventController.Tickets).Methods(\"GET\")\n\teventUngaurded.HandleFunc(\"/{event_id}/presenters\", EventController.Presenters).Methods(\"GET\")\n\n\t/**\n\t* Ticket routes\n\t */\n\tticketGaurded := router.PathPrefix(\"/tickets\").Subrouter()\n\tticketUngaurded := router.PathPrefix(\"/tickets\").Subrouter()\n\t//ticket routes that require authentication\n\tticketGaurded.Use(gJam.GeneralAuthentication)\n\tticketGaurded.HandleFunc(\"\", TicketController.Create).Methods(\"POST\")\n\tticketGaurded.HandleFunc(\"/{id}\", TicketController.Update).Methods(\"PUT\")\n\t//ticket routes that do not require authentication\n\tticketUngaurded.HandleFunc(\"/{id}\", TicketController.Get).Methods(\"GET\")\n\t/**\n\t* Presenter routes\n\t */\n\tpresenterGaurded := router.PathPrefix(\"/presenters\").Subrouter()\n\tpresenterUngaurded := router.PathPrefix(\"/presenters\").Subrouter()\n\t//presenter routes that require authentication\n\tpresenterGaurded.Use(gJam.GeneralAuthentication)\n\tpresenterGaurded.HandleFunc(\"\", PresenterController.Create).Methods(\"POST\")\n\tpresenterGaurded.HandleFunc(\"/{id}\", PresenterController.Update).Methods(\"PUT\")\n\t//presenter routes that do not require authentication\n\tpresenterUngaurded.HandleFunc(\"/{id}\", PresenterController.Get).Methods(\"GET\")\n\n\t/**\n\t* Image routes\n\t */\n\timageGuarded := router.PathPrefix(\"/images\").Subrouter()\n\timageGuarded.Use(gJam.GeneralAuthentication)\n\timageGuarded.HandleFunc(\"\", ImageController.Append).Methods(\"POST\") //appends image to the parent\n\timageGuarded.HandleFunc(\"/{id}\", ImageController.Update).Methods(\"PATCH\")\n\timageGuarded.HandleFunc(\"/{id}\", ImageController.Delete).Methods(\"DELETE\")\n\n\t/**\n\t* Tag routes\n\t */\n\ttagUnGuarded := router.PathPrefix(\"/tags\").Subrouter()\n\ttagUnGuarded.HandleFunc(\"\", TagController.Find).Methods(\"GET\")\n\n\t/**\n\t* User routes\n\t */\n\tuserUnGuarded := router.PathPrefix(\"/users\").Subrouter()\n\t//userGuarded := router.PathPrefix(\"/users\").Subrouter()\n\t//userGuarded.Use(gJam.GeneralAuthentication)\n\tuserUnGuarded.HandleFunc(\"/{id}/events\", UserController.Events).Methods(\"GET\")\n\n\t/**\n\t* Payment routes\n\t */\n\tpaymentUnGuarded := router.PathPrefix(\"/payments\").Subrouter()\n\tpaymentUnGuarded.HandleFunc(\"/webhooks/paystack\", PaymentController.ProcessPaystackWebhook).Methods(\"POST\")\n}", "title": "" }, { "docid": "2f1ed4b35c6fe7d494b68f1cc0cf3586", "score": "0.6126663", "text": "func init() {\n\thttp.HandleFunc(\"/\", handleRoot)\n\thttp.HandleFunc(\"/s/\", handleRedirect)\n\thttp.HandleFunc(\"/new\", handleNewUrl)\n}", "title": "" }, { "docid": "9f180e670cda1a5b1f3164b1b021dc90", "score": "0.61214197", "text": "func SetupRouter() *gin.Engine {\n\tr := gin.Default()\n\tr.Use(CORS)\n\n\tvar authorized_api_account = make(gin.Accounts)\n\tfor _, user := range system.SystemConfigVar.MRZ_SSO.Security.HttpAuthUsers {\n\t\tauthorized_api_account[user.Username] = user.Password\n\t}\n\n\tvar authorized_mgmt_account = make(gin.Accounts)\n\tfor _, user := range system.SystemConfigVar.MRZ_SSO.Security.MGMTAuthUsers {\n\t\tauthorized_mgmt_account[user.Username] = user.Password\n\t}\n\n\tauthorized_api := r.Group(apiRootPath, gin.BasicAuth(authorized_api_account))\n\tauthorized_api.POST(\"/authentication\", v1beta.Authentication)\n\n\tauthorized_mgmt := r.Group(mgmtRootPath, gin.BasicAuth(authorized_mgmt_account))\n\tauthorized_mgmt.POST(\"/add/userinfo\", v1beta.AddUserInformation)\n\tauthorized_mgmt.POST(\"/add/authentication\", v1beta.AddAuthentication)\n\t// authorized_mgmt.POST(\"/delete/userinfo\", v1beta.Authentication)\n\t// authorized_mgmt.POST(\"/delete/authentication\", v1beta.Authentication)\n\n\treturn r\n}", "title": "" }, { "docid": "f9f48a2ce2eeb8593ab26c6b0c81648e", "score": "0.6119442", "text": "func SetupRoutes(rootPath string, router chi.Router) {\n\trouter.Get(\"/\"+rootPath, homePage)\n\trouter.Get(\n\t\t\"/\"+path.Join(rootPath, \"resources/*\"),\n\t\thttp.StripPrefix(\n\t\t\t\"/\"+rootPath,\n\t\t\thttp.FileServer(http.FS(frontendResourcesFS)),\n\t\t).ServeHTTP,\n\t)\n\trouter.Get(\"/\"+path.Join(rootPath, \"ssrEnterLobby/{lobby_id}\"), ssrEnterLobby)\n\trouter.Post(\"/\"+path.Join(rootPath, \"ssrCreateLobby\"), ssrCreateLobby)\n}", "title": "" }, { "docid": "f593c498b0444b86cf1941547b8c2f13", "score": "0.6116056", "text": "func Init() *mux.Router {\n\tr := mux.NewRouter()\n\tr.HandleFunc(\"/create\", createHandler).Methods(http.MethodPost)\n\tr.HandleFunc(\"/get/{id}\", getAccountDetailsHandler).Methods(http.MethodGet)\n\tr.HandleFunc(\"/update/{id}\", updateAccountHandler).Methods(http.MethodPut)\n\tr.HandleFunc(\"/delete/{id}\", deleteAccountHandler).Methods(http.MethodDelete)\n\n\thttp.ListenAndServe(viper.GetString(config.PortNumber), r)\n\treturn r\n}", "title": "" }, { "docid": "1d94d85676583331f8302497af8f7d23", "score": "0.60884297", "text": "func InitRouter() *gin.Engine {\n\tr := gin.New()\n\tr.Use(gin.Logger())\n\tr.Use(gin.Recovery())\n\n\tr.GET(\"auth\", controller.Auth)\n\n\tapiV1 := r.Group(\"/api/v1\")\n\tapiV1.Use(jwt.JWT())\n\t{\n\t\t//获取用户列表\n\t\tapiV1.GET(\"/users\", v1.GetUsers)\n\t\t//新建用户\n\t\tapiV1.POST(\"/user\", v1.CreateUser)\n\n\t\t//标签列表\n\t\tapiV1.GET(\"/tags\", v1.GetTags)\n\t\t//新建标签\n\t\tapiV1.POST(\"/tag\", v1.AddTag)\n\t}\n\treturn r\n}", "title": "" }, { "docid": "ea00bc1451fbf8436149d8a8952b180c", "score": "0.60865104", "text": "func (s *Server) initializeRoutes() {\n\n\ts.Router.Use(middlewares.SetMiddlewareJSON()) //adds json content type on request\n\ts.Router.Use(middlewares.SetMiddlewareLogger()) //Add logger middleware\n\ts.Router.Use(gin.Recovery()) //recovers from crashes\n\n\t// Home Route\n\ts.Router.GET(\"/\", s.Home)\n\n\t// Channel authorization routes\n\ts.Router.POST(\"/channelAuth\", s.ChannelAuth)\n\n\t//channel routes\n\t//channelsGroup := s.Router.Group(\"/channels\")\n\ts.Router.POST(\"/channels\", middlewares.SetMiddlewareLogger(), s.CreateChannel)\n\ts.Router.GET(\"/GetChannels\", s.GetChannels)\n\n\t//Customer routes\n\tcustomersGroup := s.Router.Group(\"/customers\")\n\tcustomersGroup.Use(middlewares.SetMiddlewareAuthentication()) //must be authenticated.\n\t{\n\t\tcustomersGroup.POST(\"/create\", s.CreateCustomer)\n\t\tcustomersGroup.GET(\"/get\", s.GetCustomers)\n\t\tcustomersGroup.GET(\"/get/:accountno\", s.GetCustomer)\n\t\tcustomersGroup.PUT(\"/update/:id\", s.UpdateCustomer)\n\n\t}\n\t//Transactions route\n\ts.Router.POST(\"/transactions\", middlewares.SetMiddlewareAuthentication(), s.IncomingRequest)\n\n}", "title": "" }, { "docid": "5beb6aacccf3bfe282f2df512106e5eb", "score": "0.60864943", "text": "func init() {\n\t// setup the http handlers\n\thttp.HandleFunc(\"/\", handler_redirect)\n\thttp.HandleFunc(\"/time\", handler_time)\n}", "title": "" }, { "docid": "61e3f3a7b5bf14268c70fbd79aa767fd", "score": "0.6085302", "text": "func Routers() {\n\tr := mux.NewRouter()\n\tfs := http.FileServer(http.Dir(\"assets/\"))\n\tr.PathPrefix(\"/static/\").Handler(http.StripPrefix(\"/static/\", fs))\n\n\tr.HandleFunc(\"/\", models.IndexLogin).Methods(\"GET\")\n\tr.HandleFunc(\"/register\", models.Register).Methods(\"GET\")\n\tr.HandleFunc(\"/register-user\", models.RegisterUser)\n\n\tr.HandleFunc(\"/login\", models.Login)\n\tr.HandleFunc(\"/logout\", models.Logout)\n\tr.HandleFunc(\"/home\", models.Shorten)\n\tr.HandleFunc(\"/encurt-url\", models.Shorten)\n\tr.HandleFunc(\"/{token}\", models.Redirection).Methods(\"GET\")\n\tr.HandleFunc(\"/analytics-wd/{id}\", models.AnalyticsResults)\n\tr.HandleFunc(\"/check-cad/{email}\", models.CheckCad)\n\tr.HandleFunc(\"/new-token/{newToken}/{tkn}\", models.CheckToken)\n\n\tr.HandleFunc(\"/list/\", models.ListResults)\n\tr.HandleFunc(\"/info/{id}\", models.Info)\n\tr.HandleFunc(\"/analyticsChar/{id}\", models.AnalytcsChart)\n\tr.HandleFunc(\"/info-browser/{id}\", models.GetBrowsersReferer)\n\n\thelpers.Runn(r)\n}", "title": "" }, { "docid": "6e80b9d727324d359be188b390456e79", "score": "0.6071854", "text": "func init() {\n\n\t// init root URL and handler function\n\troutes = append(routes, Route{\n\t\tName: \"Index\",\n\t\tMethods: []string{\"GET\"},\n\t\tPattern: \"/\",\n\t\tHandlerFunc: handlers.Index,\n\t})\n\n\t/* init /payments/{id} URL and handler function.\n\tOne handler function for three type of requests */\n\troutes = append(routes, Route{\n\t\tName: \"Payment\",\n\t\tMethods: []string{\"DELETE\", \"GET\", \"POST\"},\n\t\tPattern: \"/payments/{id}\",\n\t\tHandlerFunc: handlers.HandlePayment,\n\t})\n\n\t/* init /payments URL and handler function. */\n\troutes = append(routes, Route{\n\t\tName: \"Payments\",\n\t\tMethods: []string{\"GET\"},\n\t\tPattern: \"/payments\",\n\t\tHandlerFunc: handlers.HandlePayments,\n\t})\n}", "title": "" }, { "docid": "0ead912194db35e94d86580fe617e758", "score": "0.6061649", "text": "func Routers(router *gin.Engine) {\n\tv1 := router.Group(\"/api/v1\")\n\t{\n\t\t// v1.GET(\"/user/:name\", Path)\n\t\t// v1.GET(\"/user/:name/*action\", Path)\n\t\t// curl -i http://localhost:8080/api/v1/welcome\\?firstname=Jane\\&lastname=Doe\n\t\tv1.GET(\"/welcome\", QueryString)\n\t\t// curl -v -X POST \\\n\t\t// http://localhost:8080/api/v1/login \\\n\t\t// -H 'content-type: application/json' \\\n\t\t// -d '{ \"user\": \"manu\",\"password\":\"123\" }'\n\t\tv1.POST(\"/login\", Login)\n\t\tv1.GET(\"/user/:pname/:id\", URIBind)\n\t}\n\n}", "title": "" }, { "docid": "b11ad6a5d896c62a6103a31c75393e4f", "score": "0.60613346", "text": "func initRouter() http.Handler {\n\trouter := mux.NewRouter()\n\n\tfor _, value := range routes {\n\t\tlog.Debug(\"bunding %v %v\", value.method, value.path)\n\t\trouter.HandleFunc(value.path, value.handler).Methods(value.method)\n\t}\n\n\treturn router\n}", "title": "" }, { "docid": "df1ecdee6aaa4ff2a2df192afa1b2c17", "score": "0.6058545", "text": "func SetUpRouting(mySQL *db.MySQL) *http.ServeMux {\n\ttodoHandler := &todoHandler{\n\t\trepository: mySQL,\n\t}\n\n\tmux := http.NewServeMux()\n\t//only 1 endpoint, handles GET, POST, PUT, and DELETE\n\tmux.HandleFunc(\"/todo\", todoHandler.Todo)\n\n\treturn mux\n}", "title": "" }, { "docid": "eb7ffc2dc4c23966ddfe672bfab45c42", "score": "0.6055396", "text": "func (a *App) initialiseRoutes() {\n\tprefix := \"/api/v1\"\n\ta.Router.HandleFunc(fmt.Sprintf(\"%s/resources\", prefix),\n\t\ta.getResources).Methods(http.MethodGet)\n\ta.Router.HandleFunc(fmt.Sprintf(\"%s/resources\", prefix),\n\t\ta.addResources).Methods(http.MethodPost)\n\ta.Router.HandleFunc(fmt.Sprintf(\"%s/resources\", prefix),\n\t\ta.removeResources).Methods(http.MethodDelete)\n}", "title": "" }, { "docid": "dad88628448dade2e3150df6e2104023", "score": "0.605111", "text": "func initializeRouter() *httprouter.Router {\n\trouter := httprouter.New()\n\n\t// enables CORS preflight-requests for all routes and all sources\n\trouter.HandleOPTIONS = true\n\trouter.OPTIONS(\"/cities/:all\", options)\n\trouter.OPTIONS(\"/city/:all\", options)\n\trouter.OPTIONS(\"/temp/:all\", options)\n\n\t// root route\n\trouter.GET(\"/\", index)\n\n\t// routes for 'controllers/citiescontroller'\n\trouter.GET(\n\t\t\"/cities/all\", controller.CollectionIndex)\n\trouter.GET(\n\t\t\"/city/:id\", controller.ReadCollection)\n\trouter.POST(\n\t\t\"/city/:id\", options)\n\trouter.POST(\n\t\t\"/city/:id/:cityId\", controller.UpdateCollection)\n\trouter.PUT(\n\t\t\"/city/:name\", controller.CreateCollection)\n\trouter.DELETE(\n\t\t\"/city/:id\", controller.DeleteCollection)\n\n\t// routes for 'controllers/tempcontroller'\n\trouter.GET(\n\t\t\"/temp/:id\", controller.GetTemperatures)\n\n\tmid.LogInfo(\"initialized routing module\")\n\n\treturn router\n}", "title": "" }, { "docid": "3b3c536f3ccba00394e78067259a0bbf", "score": "0.6033407", "text": "func init() {\n\tmodule := lite.NewBaseModule()\n\tmodule.Register(\"\", &user.Controller{BaseController: mw.NewBaseController()})\n\tlite.Register(\"auth\", module)\n}", "title": "" }, { "docid": "293137dd7c1fbf9e7b14a9ef27f7829e", "score": "0.6027679", "text": "func usersRouter(gin *gin.Engine) {\n\tgin.GET(\"/users\", controllers.GetUsers)\n\tgin.GET(\"/users/:id\", controllers.GetUser)\n\tgin.POST(\"/users\", controllers.CreateUser)\n}", "title": "" }, { "docid": "09c1c20ccd80a107a217b77860c06da8", "score": "0.6019353", "text": "func Initialize(router *gin.RouterGroup) {\n\tv1router := router.Group(\"v1\")\n\tv1router.PATCH(\"/user\", middleware.AppAndJWTAuthMiddleware(false, \"user.patch\"), middleware.JSONBodyParseMiddleware, PatchUser)\n\tv1router.PATCH(\"/user/lol\", middleware.AppAndJWTAuthMiddleware(false, \"user.patch\"), middleware.JSONBodyParseMiddleware, PatchUserLolName)\n\tv1router.GET(\"/user/:id\", middleware.AppAndJWTAuthMiddleware(true, \"user.get\"), GetUser)\n\tv1router.GET(\"/user\", middleware.AppAndJWTAuthMiddleware(false, \"user.get\"), GetMe)\n\tv1router.GET(\"/userlist\", middleware.AppAndJWTAuthMiddleware(false, \"user.get\"), GetUserList)\n\n\tv1router.GET(\"/images\", middleware.AppAndJWTAuthMiddleware(true, \"imagelist.get\"), GetImageList)\n\tv1router.POST(\"/image\", middleware.AppAndJWTAuthMiddleware(false, \"image.post\"), middleware.JSONBodyParseMiddleware, PostImage)\n\tv1router.GET(\"/image/:id\", GetImage)\n\tv1router.DELETE(\"/image/:id\", middleware.AppAndJWTAuthMiddleware(false, \"image.delete\"), DelImage)\n\n\tv1router.GET(\"/states/:id\", middleware.AppAndJWTAuthMiddleware(true, \"states.get\"), GetStateHistory)\n\tv1router.GET(\"/states\", middleware.AppAndJWTAuthMiddleware(false, \"states.get\"), GetOwnStateHistory)\n\tv1router.POST(\"/state\", middleware.AppAndJWTAuthMiddleware(false, \"states.post\"), middleware.JSONBodyParseMiddleware, PostState)\n\n\tv1router.GET(\"/announces/all\", middleware.AppAndJWTAuthMiddleware(true, \"announces.get\"), GetAllAnnounceList)\n\tv1router.GET(\"/announces/current\", middleware.AppAndJWTAuthMiddleware(true, \"announces.get\"), GetCurrentAnnounceList)\n\tv1router.GET(\"/announces/user/:id\", middleware.AppAndJWTAuthMiddleware(true, \"announces.get\"), GetAnnounceList)\n\tv1router.POST(\"/announce\", middleware.AppAndJWTAuthMiddleware(false, \"announce.post\"), middleware.JSONBodyParseMiddleware, PostAnnounce)\n\tv1router.GET(\"/announces/me\", middleware.AppAndJWTAuthMiddleware(false, \"announces.get\"), GetAnnounceListMe)\n\tv1router.GET(\"/announce/:id\", middleware.AppAndJWTAuthMiddleware(true, \"announce.get\"), GetAnnounce)\n\tv1router.DELETE(\"/announce/:id\", middleware.AppAndJWTAuthMiddleware(false, \"announce.delete\"), DelAnnounce)\n\tv1router.PATCH(\"/announce/:id\", middleware.AppAndJWTAuthMiddleware(false, \"announce.patch\"), middleware.JSONBodyParseMiddleware, PatchAnnounce)\n\n\tv1router.POST(\"/application/token\", middleware.AppAndJWTAuthMiddleware(false, \"admin.token.create\"), PostAppicationToken)\n\tv1router.PATCH(\"/application/riot/access\", middleware.AppAndJWTAuthMiddleware(false, \"admin.token.create\"), middleware.JSONBodyParseMiddleware, PatchRiotAccessToken)\n\tv1router.POST(\"/lol/history/updater\", middleware.VerifyApplicationTokenMiddleware, PostLolHistoryUpdate)\n\tv1router.POST(\"/lol/history/migration\", middleware.VerifyApplicationTokenMiddleware, PostMigrationHistoryFrom)\n\tv1router.GET(\"/lol/histories\", GetLolHistoryList)\n\tv1router.GET(\"/lol/datelogs\", GetLolHistoryPerDate)\n\tv1router.GET(\"/lol/history/:id\", GetLolHistory)\n}", "title": "" }, { "docid": "ca129c059e0ddecfe6847fed3d4462f0", "score": "0.60171", "text": "func setupRoutes() {\n\trouter := mux.NewRouter().StrictSlash(true)\n\trouter.HandleFunc(\"/create\", createContainerHandler).Methods(\"POST\")\n\trouter.HandleFunc(\"/state\", getClusterStateHandler).Methods(\"GET\")\n\trouter.HandleFunc(\"/\", homeHandler)\n\thttp.ListenAndServe(\":8080\", router)\n}", "title": "" }, { "docid": "395f33e4be8cc5f2410d6f1618b6049c", "score": "0.6015165", "text": "func initializeRouter(itemsDB *db.Items) *mux.Router {\n\tr := mux.NewRouter()\n\t// add search GET endpoint to the router\n\tr.HandleFunc(searchEndpoint, func(w http.ResponseWriter, r *http.Request) {\n\t\thandler.SearchHandler(w, r, itemsDB)\n\t}).Methods(http.MethodGet)\n\treturn r\n}", "title": "" }, { "docid": "02ce07687d38b8c3070e644799e2e2a1", "score": "0.60082704", "text": "func SetupRouter() *gin.Engine {\n\tr := gin.Default()\n\tgrp1 := r.Group(\"/student-api\")\n\t{\n\t\tgrp1.GET(\"student\", Controllers.GetStudent)\n\t\tgrp1.POST(\"student\", Controllers.CreateStudent)\n\t\tgrp1.GET(\"student/:id\", Controllers.GetStudentByID)\n\t\tgrp1.PUT(\"student/:id\", Controllers.UpdateStudent)\n\t\tgrp1.DELETE(\"student/:id\", Controllers.DeleteStudent)\n\t}\n\treturn r\n}", "title": "" }, { "docid": "a96491d829440b2d90c1c86220141cb2", "score": "0.6003256", "text": "func (cr *Router) initRoutes(router *gin.Engine) {\n\trouter.GET(\"/info\", cr.Info)\n\trouter.GET(\"/version\", cr.Version)\n\trouter.GET(\"/_ping\", cr.Ping)\n\trouter.HEAD(\"/_ping\", cr.Ping)\n\n\trouter.POST(\"/containers/create\", cr.ContainerCreate)\n\trouter.POST(\"/containers/:id/start\", cr.ContainerStart)\n\trouter.POST(\"/containers/:id/attach\", cr.ContainerAttach)\n\trouter.POST(\"/containers/:id/exec\", cr.ContainerExec)\n\trouter.POST(\"/containers/:id/stop\", cr.ContainerStop)\n\trouter.POST(\"/containers/:id/restart\", cr.ContainerRestart)\n\trouter.POST(\"/containers/:id/kill\", cr.ContainerKill)\n\trouter.POST(\"/containers/:id/wait\", cr.ContainerWait)\n\trouter.DELETE(\"/containers/:id\", cr.ContainerDelete)\n\trouter.GET(\"/containers/json\", cr.ContainerList)\n\trouter.GET(\"/containers/:id/json\", cr.ContainerInfo)\n\trouter.GET(\"/containers/:id/logs\", cr.ContainerLogs)\n\trouter.GET(\"/containers/:id/archive\", cr.GetArchive)\n\trouter.PUT(\"/containers/:id/archive\", cr.PutArchive)\n\n\trouter.POST(\"/exec/:id/start\", cr.ExecStart)\n\trouter.GET(\"/exec/:id/json\", cr.ExecInfo)\n\n\trouter.POST(\"/networks/create\", cr.NetworksCreate)\n\trouter.POST(\"/networks/:id/connect\", cr.NetworksConnect)\n\trouter.POST(\"/networks/:id/disconnect\", cr.NetworksDisconnect)\n\trouter.GET(\"/networks\", cr.NetworksList)\n\trouter.GET(\"/networks/:id\", cr.NetworksInfo)\n\trouter.DELETE(\"/networks/:id\", cr.NetworksDelete)\n\n\trouter.POST(\"/images/create\", cr.ImageCreate)\n\trouter.GET(\"/images/json\", cr.ImageList)\n\trouter.GET(\"/images/:image/*json\", cr.ImageJSON)\n\n\t// not supported at the moment\n\trouter.GET(\"/containers/:id/top\", httputil.NotImplemented)\n\trouter.GET(\"/containers/:id/changes\", httputil.NotImplemented)\n\trouter.GET(\"/containers/:id/export\", httputil.NotImplemented)\n\trouter.GET(\"/containers/:id/stats\", httputil.NotImplemented)\n\trouter.POST(\"/containers/:id/resize\", httputil.NotImplemented)\n\trouter.POST(\"/containers/:id/update\", httputil.NotImplemented)\n\trouter.POST(\"/containers/:id/rename\", httputil.NotImplemented)\n\trouter.POST(\"/containers/:id/pause\", httputil.NotImplemented)\n\trouter.POST(\"/containers/:id/unpause\", httputil.NotImplemented)\n\trouter.GET(\"/containers/:id/attach/ws\", httputil.NotImplemented)\n\trouter.HEAD(\"/containers/:id/archive\", httputil.NotImplemented)\n\trouter.POST(\"/containers/prune\", httputil.NotImplemented)\n\trouter.GET(\"/networks/reaper_default\", httputil.NotImplemented)\n\trouter.POST(\"/build\", httputil.NotImplemented)\n}", "title": "" }, { "docid": "6c0cdb9db276244c17f203947b9cb68d", "score": "0.60022557", "text": "func init() {\n\n\t// init root URL and handler function \n\troutes = append(routes, Route{\n\t\tName: \"Index\",\n\t\tMethods: []string{\"GET\"},\n\t\tPattern: \"/\",\n\t\tHandlerFunc: handlers.Index,\n\t})\n\n\t/* init /channel/{id} URL and handler function. \n\tOne handler function for three type of requests */\n\troutes = append(routes, Route{\n\t\tName: \"Channel\",\n\t\tMethods: []string{\"DELETE\", \"GET\", \"POST\"},\n\t\tPattern: \"/channel/{id}\",\n\t\tHandlerFunc: handlers.HandleChannel,\n\t})\n\n\t/* init /channels URL and handler function. */\n\troutes = append(routes, Route{\n\t\tName: \"Channels\",\n\t\tMethods: []string{\"GET\"},\n\t\tPattern: \"/channels\",\n\t\tHandlerFunc: handlers.HandleChannels,\n\t})\n\n\t/* init /channel/{id}/{time} URL and handler function. */\n\troutes = append(routes, Route{\n\t\tName: \"ChannelTime\",\n\t\tMethods: []string{\"DELETE\", \"GET\", \"POST\"},\n\t\tPattern: \"/channel/{id}/{time}\",\n\t\tHandlerFunc: handlers.HandleChannelTime,\n\t})\n\n\t/* init /newrleases URL and handler function. */\n\troutes = append(routes, Route{\n\t\tName: \"ChannelReleases\",\n\t\tMethods: []string{\"DELETE\", \"GET\", \"POST\"},\n\t\tPattern: \"/newreleases/\",\n\t\tHandlerFunc: handlers.HandleNewReleases,\n\t})\n}", "title": "" }, { "docid": "a372ac01cdec712e9598980437c25a7c", "score": "0.5998794", "text": "func NewRouter() *mux.Router {\n\tfs := http.FileServer(http.Dir(\"./public/\"))\n\tr := mux.NewRouter()\n\n\t/*\n\t\tuser subrouter\n\t\thandle REST-api /user here\n\t*/\n\n\tuserRouter := r.PathPrefix(\"/api/v1/user\").Subrouter()\n\tuserRouter.HandleFunc(\"/\", UserController.GetAll).Methods(\"GET\")\n\tuserRouter.HandleFunc(\"/{id}\", UserController.GetOne).Methods(\"GET\")\n\tuserRouter.HandleFunc(\"/\", UserController.Create).Methods(\"POST\")\n\tuserRouter.HandleFunc(\"/search/\", UserController.Search).Methods(\"GET\")\n\n\t/*\n\t\tbill subrouter\n\t\thandle REST-api /user here\n\t*/\n\n\tbillsRouter := r.PathPrefix(\"/api/v1/bill\").Subrouter()\n\tbillsRouter.HandleFunc(\"/\", BillController.GetAll).Methods(\"GET\")\n\tbillsRouter.HandleFunc(\"/{id}\", BillController.GetOne).Methods(\"GET\")\n\tbillsRouter.HandleFunc(\"/\", BillController.Create).Methods(\"POST\")\n\tbillsRouter.HandleFunc(\"/search/\", BillController.Search).Methods(\"GET\")\n\n\toauthRouter := r.PathPrefix(\"/api/v1/oauth\").Subrouter()\n\toauthRouter.HandleFunc(\"/\", OauthController.OauthHandler).Methods(\"GET\")\n\toauthRouter.HandleFunc(\"/google/login\", OauthController.GloginHandler).Methods(\"GET\")\n\toauthRouter.HandleFunc(\"/google/callback\", OauthController.GcallbackHandler).Methods(\"GET\")\n\n\tr.PathPrefix(\"/public/\").Handler(http.StripPrefix(\"/public/\", fs))\n\treturn r\n}", "title": "" }, { "docid": "06b359d1ca724473c2150093169e81e2", "score": "0.59985465", "text": "func InitializeRouter(router *mux.Router) {\n\tfor path := range api.StaticResources {\n\t\trouter.HandleFunc(path, api.ServeStatic).Methods(\"GET\")\n\t}\n\tfor _, ep := range Endpoints {\n\t\trouter.HandleFunc(ep.PathPattern, ep.HandleFunction).Methods(FlagToListMethod(ep.AllowedMethodFlag)...)\n\t}\n}", "title": "" }, { "docid": "6f251b6252762664b3a246adc1a76bc4", "score": "0.5995207", "text": "func initApiRoutes(e *echo.Echo) {\n\t// JWT configuration\n\t// -----------------\n\tjwtConfiguration := middleware.JWTConfig{\n\t\tContextKey: \"user\",\n\t\tTokenLookup: \"header:\" + echo.HeaderAuthorization,\n\t\tAuthScheme: \"Bearer\",\n\t\tClaims: &apiHandler.JwtClaims{},\n\t\tSigningKey: []byte(viper.GetString(\"jwt.secret\")),\n\t}\n\n\t// Version de l'API\n\t// ----------------\n\tversionGroup := e.Group(\"/v1\")\n\n\t// Liste des routes non protégées (à placer avant les routes protégées)\n\t// --------------------------------------------------------------------\n\tapi.NewApiAuthRoute(versionGroup).AuthRoutes()\n\tapi.NewApiBenchmarkRoute(versionGroup).BenchmarkRoutes()\n\n\t// Liste des routes protégées\n\t// --------------------------\n\tversionGroup.Use(middleware.JWTWithConfig(jwtConfiguration))\n\tapi.NewApiUserRoute(versionGroup).UsersRoutes()\n}", "title": "" }, { "docid": "8e8fd6a72ac22410f7893407b5d9490f", "score": "0.59924394", "text": "func InitRoutes() *mux.Router {\n\trouter := mux.NewRouter().StrictSlash(false)\n\tSetMemberRoutes(router)\n\tSetCustomerRoutes(router)\n\treturn router\n}", "title": "" }, { "docid": "5670c89b5048d361cae464aa64463f6e", "score": "0.59837866", "text": "func SetupRouter() *gin.Engine {\n\tr := gin.Default()\n\tgrp1 := r.Group(\"/first-api\")\n\t{\n\t\tgrp1.GET(\"courses\", Controllers.GetCourses)\n\t\tgrp1.POST(\"course\", Controllers.CreateCourse)\n\t\tgrp1.GET(\"course/:id\", Controllers.GetCourseByID)\n\t\tgrp1.PUT(\"course/:id\", Controllers.UpdateCourse)\n\t\tgrp1.DELETE(\"course/:id\", Controllers.DeleteCourse)\n\t}\n\treturn r\n}", "title": "" }, { "docid": "5f735b76aff971785b256be8a3224301", "score": "0.59836125", "text": "func (c *Controller) SetupRouter(router chi.Router) error {\n\n\t// Register admin endpoints\n\trouter.Route(\"/admin/loc\", func(r chi.Router) {\n\t\tr.Post(\"/create\", c.CreateLocation)\n\t\tr.Get(\"/{id}\", c.GetLocation)\n\t\tr.Put(\"/update\", c.UpdateLocation)\n\t\tr.Delete(\"/{id}/delete\", c.DeleteLocation)\n\t})\n\n\t// Register client endpoints\n\trouter.Route(\"/client\", func(r chi.Router) {\n\t\tr.Post(\"/register\", c.Register)\n\t\tr.Post(\"/login\", c.Login)\n\t\tr.With(middleware.IsClientAllowed(c.jwtAuther)).Post(\"/loc/send\", c.SendLocation)\n\t\tr.With(middleware.IsClientAllowed(c.jwtAuther)).Put(\"/update-name\", c.UpdateName)\n\t\tr.With(middleware.IsClientAllowed(c.jwtAuther)).Get(\"/loc/get\", c.GetClientLocation)\n\t})\n\n\treturn nil\n}", "title": "" }, { "docid": "f2dec7be6acbd7564cb18869ffa4c16e", "score": "0.59790057", "text": "func InitRouter() *chi.Mux {\n\tr := chi.NewRouter()\n\n\tdb := database.GetDatabase()\n\n\tr.Use(\n\t\tmiddleware.Recoverer,\n\t\tmiddleware.Logger,\n\t)\n\n\tr.Mount(\"/api/v1\", apiRouter(db))\n\n\treturn r\n}", "title": "" }, { "docid": "3f9b447383249087948f93f1a0a617c8", "score": "0.5962213", "text": "func initWebRoutes(e *echo.Echo) {\n\tgroup := e.Group(\"\")\n\n\t// Routes\n\t// ------\n\tweb.NewWebExampleRoute(group).ExampleRoutes()\n\n\t// Protection des routes par une Basic Auth\n\t// ----------------------------------------\n\tprotectedGroup := e.Group(\"\")\n\n\tprotectedGroup.Use(middleware.BasicAuth(\n\t\tfunc(username, password string, c echo.Context) (bool, error) {\n\t\t\tbasicAuthUsername := viper.GetString(\"debug.basicAuthUsername\")\n\t\t\tbasicAuthPassword := viper.GetString(\"debug.basicAuthPassword\")\n\n\t\t\tif basicAuthUsername == \"\" || basicAuthPassword == \"\" {\n\t\t\t\treturn false, nil\n\t\t\t} else if username == basicAuthUsername && password == basicAuthPassword {\n\t\t\t\treturn true, nil\n\t\t\t}\n\n\t\t\treturn false, nil\n\t\t},\n\t))\n\n\t// Profilage\n\t// ---------\n\tif viper.GetBool(\"debug.pprof\") {\n\t\tweb.NewWebPprofRoute(protectedGroup).PprofRoutes()\n\t}\n\n\t// Interface de visualisation des logs\n\t// -----------------------------------\n\tweb.NewWebLogsRoute(protectedGroup).LogsRoutes()\n}", "title": "" }, { "docid": "aba06130fd2d6fcfd843ea7557f40473", "score": "0.5958224", "text": "func MainRouters(r *mux.Router) {\r\n\tr.HandleFunc(\"/\", Home).Methods(\"GET\")\r\n}", "title": "" }, { "docid": "6c403d7e8b0342769f85e948a8d6152a", "score": "0.595812", "text": "func init() {\n\troute.AddRoute(\"GET\", \"/get/:id\", GetPromo, []string{}, \"promo_get\", PromoRoutePrefix)\n\troute.AddRoute(\"GET\", \"/all\", AllPromos, []string{}, \"promo_all\", PromoRoutePrefix)\n\troute.AddRoute(\"POST\", \"/add\", AddPromo, []string{}, \"promo_add\", PromoRoutePrefix)\n\troute.AddRoute(\"POST\", \"/edit\", EditPromo, []string{}, \"promo_edit\", PromoRoutePrefix)\n\troute.AddRoute(\"POST\", \"/delete\", DeletePromo, []string{}, \"promo_delete\", PromoRoutePrefix)\n\troute.AddRoute(\"POST\", \"/changeOrder\", ChangeOrderPromo, []string{}, \"promo_change_order\", PromoRoutePrefix)\n\troute.AddRoute(\"POST\", \"/activate\", ActivatePromo, []string{}, \"promo_activate\", PromoRoutePrefix)\n}", "title": "" }, { "docid": "4aae81d1852dd02cd2fe029dcace3cd0", "score": "0.5943518", "text": "func StartRouters() {\n\te.Debug = true\n\t// Middleware\n\te.Use(middleware.Logger())\n\te.Use(middleware.Recover())\n\te.Pre(middleware.RemoveTrailingSlash())\n\te.GET(\"/pilots\", handlers.GetAllPilots)\n\te.GET(\"/pilot/:id\", handlers.GetOnePilots)\n\te.POST(\"/pilot\", handlers.CreatePilot)\n\te.DELETE(\"/pilot/:id\", handlers.DeletePilot)\n\te.PUT(\"/pilot/:id\", handlers.UpdatePilot)\n\te.POST(\"/register\", handlers.UserRegister)\n\te.POST(\"/login\", handlers.UserLogin)\n\tr := e.Group(\"/restricted\")\n\t// Configure middleware with the custom claims type\n\tconfig := middleware.JWTConfig{\n\t\tClaims: &jwtModelsClaims.JwtCustomClaims{},\n\t\tSigningKey: []byte(\"secretToken\"),\n\t}\n\tr.Use(middleware.JWTWithConfig(config))\n\tstatikFS, err := fs.New()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\th := http.FileServer(statikFS)\n\te.GET(\"/*\", echo.WrapHandler(http.StripPrefix(\"/\", h)))\n\t// // Serve the contents over HTTP.\n\t// http.Handle(\"/app/\", http.StripPrefix(\"/app/\", http.FileServer(statikFS)))\n\t// http.ListenAndServe(\":8080\", nil)\n\n\t//e.GET(\"/generate-hash/:password\", controllers.GenerateHashPassword)\n\te.Logger.Print(fmt.Sprintf(\"Listening on prot: %d\\n\", conf.Port))\n\te.Logger.Fatal(e.Start(fmt.Sprintf(\"localhost:%d\", conf.Port)))\n}", "title": "" }, { "docid": "61b93c36ddafeea7a6ec27330bff620b", "score": "0.59434944", "text": "func SetupRoutes() {\n\tapp := echo.New()\n\n\tapi := app.Group(\"/api\")\n\tapi.GET(\"/\", hello)\n\n\t// authen\n\tAuth := api.Group(\"/auth\")\n\tAuth.POST(\"/signin\", controller.Login)\n\tAuth.POST(\"/signup\", controller.Register)\n\n\t// user and require token\n\tUSER := api.Group(\"/user\", filter.CheckAuth)\n\tUSER.GET(\"/list\", controller.ListUser)\n\n\tapp.Start(\":3000\")\n}", "title": "" }, { "docid": "c906a02e6423077d153df692e36b28d8", "score": "0.5939864", "text": "func registerRouters() *httprouter.Router{\n\n\tr := httprouter.New()\n\n\tfor _,val := range routers{\n\t\tr.Handle(val.Method,val.Path,val.Handle)\n\t}\n\treturn r\n}", "title": "" }, { "docid": "ab1941b6eb97a7e60ca2dce6ec3664a9", "score": "0.59333295", "text": "func SetupRouter() *gin.Engine {\n\trouter := gin.Default()\n\n\trouter.GET(\"/hostname\", GetHostnameMethod)\n\trouter.GET(\"/kernel\", GetKernelMethod)\n\n\treturn router\n}", "title": "" }, { "docid": "ce7a8772cc626a8cc48b5183782cfecd", "score": "0.5923971", "text": "func initRoutes(mx *mux.Router, formatter *render.Render) {\n\tmx.HandleFunc(\"/ping\", pingHandler(formatter)).Methods(\"GET\")\n\tmx.HandleFunc(\"/comments\", newCommentHandler(formatter)).Methods(\"POST\").\n\t\tHeaders(\"Content-Type\", \"application/vnd.api+json\").\n\t\tHeaders(\"Accept\", \"application/vnd.api+json\")\n\tmx.HandleFunc(\"/_ah/warmup\", pingHandler(formatter)).Methods(\"GET\")\n}", "title": "" }, { "docid": "66aa246ce3fccba3f0c9c7f03fd64fcb", "score": "0.59214973", "text": "func InitRoutes(r *mux.Router) {\n\n\tr.HandleFunc(\"/events\", GetAllEvents).Methods(\"GET\")\n\tr.HandleFunc(\"/events/{id}\", GetEventByID).Methods(\"GET\")\n\tr.HandleFunc(\"/events\", AddEvent).Methods(\"POST\")\n\tr.HandleFunc(\"/events\", UpdateEvent).Methods(\"PUT\")\n\tr.HandleFunc(\"/events/{id}\", DeleteEvent).Methods(\"DELETE\")\n\tr.HandleFunc(\"/events/{eventid}/users\", GetUsersForEvent).Methods(\"GET\")\n\n\t// User routes\n\tr.HandleFunc(\"/users\", AddUser).Methods(\"POST\")\n\tr.HandleFunc(\"/users\", GetAllUsers).Methods(\"GET\")\n\tr.HandleFunc(\"/users/login\", Login).Methods(\"POST\")\n\tr.HandleFunc(\"/users/{userid}/events\", GetEventsOfUsers).Methods(\"GET\")\n\tr.HandleFunc(\"/users/{userid}/events/{eventid}/register\", AddRegistration).Methods(\"POST\")\n\tr.HandleFunc(\"/users/{userid}/events/{eventid}/cancel\", CancelRegistration).Methods(\"DELETE\")\n\tr.HandleFunc(\"/users/{userid}/events/{eventid}/check\", CheckIfUserRegisteredForEvent).Methods(\"GET\")\n\tr.HandleFunc(\"/users/{mongoid}/events/{eventid}/checkMongoID\", CheckIfUserRegisteredForEventByMongoID).Methods(\"GET\")\n}", "title": "" }, { "docid": "bea97168ca9eb6494b46df96ee3078d6", "score": "0.5917586", "text": "func Init(gRouter *echo.Group) {\n\n\t// all book routes will be inside bookRouter\n\tbookRouter(gRouter.Group(\"/book\"))\n\n\t// all author routes will be inside authorRouter\n\tauthorRouter(gRouter.Group(\"/author\"))\n\n\t// all category routes will be inside categoryRouter\n\tcategoryRouter(gRouter.Group(\"/category\"))\n\n\t// all user routes will be inside userRouter\n\tuserRouter(gRouter.Group(\"/user\"))\n\n\t// all page routes will be inside pageRouter\n\tpageRouter(gRouter.Group(\"/page\"))\n}", "title": "" }, { "docid": "8f86a831c0f748be90c68450cbb52393", "score": "0.59133977", "text": "func SetupRoutesPermiso(muxRouter *mux.Router) {\n\t/*\n\t\tDefino driver de base de datos\n\t*/\n\tdriver := database.Postgres\n\tdatabase.New(driver)\n\tdb := database.DB()\n\n\t/*\n\t\tConexión entidad Permiso\n\t*/\n\trPermiso := permiso.NewPermisoRepository(db)\n\tsPermiso := permiso.NewPermisoService(rPermiso)\n\tcPermiso := permiso.NewPermisoController(sPermiso)\n\tpermiso.NewPermisoRouter(muxRouter.PathPrefix(\"/v1/permiso\").Subrouter(), cPermiso)\n}", "title": "" }, { "docid": "67051b94071b06dd614d0c95628421fe", "score": "0.5906096", "text": "func (_m *Base) SetUpRoutes(_a0 *chi.Mux) {\n\t_m.Called(_a0)\n}", "title": "" }, { "docid": "ad8a2df13c06f0b21b0b31a40efdab52", "score": "0.59038216", "text": "func (h *Handler) SetupRoutes(db *gorm.DB) {\n\t// print message to console\n\tfmt.Println(\"Setting up routes....\")\n\n\t// initialize new mux router\n\th.Router = mux.NewRouter()\n\n\t//initialize controllers\n\tarticleController := controllers.NewArticleController(db)\n\n\t// define handler for health check endpoin\n\th.Router.HandleFunc(\"/api/health\", func(res http.ResponseWriter, req *http.Request) {\n\t\tutil.JSON(res, http.StatusOK, map[string]string{\"message\": \"All services green....\"})\n\t})\n\n\th.Router.HandleFunc(\"/api/articles\", articleController.GetAllArticles).Methods(\"GET\")\n}", "title": "" }, { "docid": "530f3d0beaa8f4ed0ded698e9ed469f3", "score": "0.58987486", "text": "func Init(confUser, confPass, confServer string) {\n\t// Initialize nmcjson\n\tnmcjson.Init()\n\t// Initialize node\n\tnode.Init(confUser, confPass, confServer)\n\n\tr := mux.NewRouter().StrictSlash(true)\n\t// Register HTML routes\n\t//r.PathPrefix(\"/\").Handler(http.FileServer(http.Dir(\"public/\")))\n\t// Register API routes\n\tapi := r.PathPrefix(\"/api\").Subrouter()\n\tfor _, route := range apiRoutes {\n\t\tapi.\n\t\t\tMethods(route.Method).\n\t\t\tPath(route.Pattern).\n\t\t\tName(route.Name).\n\t\t\tHandlerFunc(route.HandlerFunc)\n\t}\n\tr.PathPrefix(\"/\").Handler(http.FileServer(http.Dir(\"public/\")))\n\n\t//api.HandleFunc(\"/names\", ListNames)\n\t//http.Handle(\"/\", r)\n\n\tlog.Fatal(http.ListenAndServe(\":8000\", r))\n}", "title": "" }, { "docid": "0fd69f8713d51f85c2a1ce03aec21e46", "score": "0.58938813", "text": "func InitRouter() *gin.Engine {\n\tr := gin.New()\n\n\tr.Use(logger.LogMiddleware())\n\tr.Use(gin.Recovery())\n\tgin.SetMode(gin.DebugMode)\n\n\tapiv1 := r.Group(\"/api/v1\")\n\t{\n\t\tapiv1.GET(\"/test/middleware\", middleware.AuthRequired(), func(c *gin.Context) {\n\t\t\tuid, _ := c.Get(\"uid\")\n\t\t\tc.JSON(http.StatusOK, gin.H{\n\t\t\t\t\"uid\": uid,\n\t\t\t\t\"msg\": \"ok\",\n\t\t\t})\n\t\t})\n\n\t\tapiv1.GET(\"/test\", func(c *gin.Context) {\n\t\t\tc.JSON(http.StatusOK, gin.H{\n\t\t\t\t\"msg\": \"ok\",\n\t\t\t})\n\t\t})\n\t\t// 上传.b文件\n\t\tapiv1.POST(\"/bfile\", middleware.AuthRequired(), controller.UploadBFile)\n\t\t// 获取.b文件信息\n\t\tapiv1.GET(\"/bfile/:bfile_id\", middleware.AuthRequired(), controller.GetBFileInfoByID)\n\t\t// 下载.b文件\n\t\tapiv1.GET(\"/bfile/:bfile_id/download\", middleware.AuthRequired(), controller.DownloadBFile)\n\t\t// 获取所有.b文件名列表\n\t\tapiv1.GET(\"/bfiles\", middleware.AuthRequired(), controller.GetBFileNameList)\n\t\t// 获取某个文件名的.b文件列表\n\t\tapiv1.GET(\"/bfiles/:filename\", middleware.AuthRequired(), controller.GetBFileList)\n\t\t// 上报状态\n\t\tapiv1.POST(\"/task/:task_id\", middleware.AuthRequired(), controller.ReportFinishTask)\n\t\t// 根据key获取任务列表\n\t\tapiv1.GET(\"/tasks\", middleware.AuthRequired(), controller.GetTaskList)\n\t\t// 回滚.b文件\n\t\tapiv1.POST(\"/rollback/:bfile_id\", middleware.AuthRequired(), controller.RollbackBFile)\n\n\t\t// 登录\n\t\tapiv1.POST(\"/login\", controller.Login)\n\t\t// 创建用户\n\t\tapiv1.POST(\"/user\", middleware.AuthRequired(), controller.CreateUser)\n\t\t// 获取用户信息\n\t\tapiv1.GET(\"/user/:uid\", middleware.AuthRequired(), controller.GetUserByUID)\n\t\t// 修改用户信息\n\t\tapiv1.PUT(\"/user/:uid\", middleware.AuthRequired(), controller.UpdateUserByUID)\n\t\t// 删除用户\n\t\tapiv1.DELETE(\"/user/:uid\", middleware.AuthRequired(), controller.DeleteUserByUID)\n\t\t// 获取用户信息\n\t\tapiv1.GET(\"/my\", middleware.AuthRequired(), controller.GetMyInfo)\n\t\t// 修改密码\n\t\tapiv1.PUT(\"/password\", middleware.AuthRequired(), controller.ChangePassword)\n\t\t// 登出\n\t\tapiv1.GET(\"/logout\", middleware.AuthRequired(), controller.Logout)\n\t\t// 获取用户列表\n\t\tapiv1.GET(\"/users\", middleware.AuthRequired(), controller.GetUserList)\n\n\t\t// 获取角色列表\n\t\tapiv1.GET(\"/roles\", middleware.AuthRequired(), controller.GetRoleList)\n\t\t// 获取指定角色\n\t\tapiv1.GET(\"/role/:role_id\", middleware.AuthRequired(), controller.GetRoleByID)\n\t\t// 创建角色\n\t\tapiv1.POST(\"/role\", middleware.AuthRequired(), controller.CreateRole)\n\t\t// 修改角色\n\t\tapiv1.PUT(\"/role/:role_id\", middleware.AuthRequired(), controller.UpdateRole)\n\t\t// 删除角色\n\t\tapiv1.DELETE(\"/role/:role_id\", middleware.AuthRequired(), controller.DeleteRole)\n\t}\n\t// webhook test\n\tr.POST(\"/webhook/test\", func(c *gin.Context) {\n\t\tc.String(http.StatusOK, \"success.\")\n\t})\n\treturn r\n}", "title": "" }, { "docid": "3dc5d9291c70ff4041e2a861e89bea00", "score": "0.5888466", "text": "func SetupRouter() *gin.Engine {\n\tr := gin.Default()\n\n\tauth := usecase.NewAuth()\n\n\tvalidator := middleware.NewValidator()\n\n\tconfigCors := cors.DefaultConfig()\n\tconfigCors.AllowOrigins = []string{os.Getenv(\"CLIENT_URL\"), os.Getenv(\"CLIENT_MOBILE_URL\")}\n\n\tclothes := usecase.NewClothes()\n\tuser := usecase.NewUser()\n\tcategory := usecase.NewCategory()\n\n\tconfigCors.AllowCredentials = true\n\tr.Use(cors.New(configCors))\n\tr.Use(gin.Logger())\n\tr.Use(gin.Recovery())\n\n\tdir, _ := os.Getwd()\n\tr.Use(static.Serve(\"/static/\", static.LocalFile(dir+\"src/static/images\", true)))\n\n\tr.GET(\"/ZooArk/static/*any\", ginSwagger.WrapHandler(swaggerFiles.Handler))\n\tr.GET(\"/is-authenticated\", auth.IsAuthenticated)\n\tr.POST(\"/login\", middleware.Passport().LoginHandler)\n\tr.GET(\"/logout\", middleware.Passport().LogoutHandler)\n\n\tauthRequired := r.Group(\"/\")\n\tauthRequired.Use(middleware.Passport().MiddlewareFunc())\n\t{\n\t\tadmin := authRequired.Group(\"/\")\n\t\tadmin.Use(validator.ValidateRoles(\n\t\t\ttypes.UserRoleEnum.SuperAdmin,\n\t\t))\n\t\t{\n\t\t\t// Products\n\t\t\tadmin.POST(\"/products/clothes\", clothes.Add)\n\t\t\tadmin.DELETE(\"/products/clothes/:id\", clothes.Delete)\n\n\t\t\t// Categories\n\t\t\tadmin.POST(\"/categories\", category.Add)\n\t\t\tadmin.DELETE(\"/categories/:id\", category.Delete)\n\t\t\tadmin.PUT(\"/categories/:id\", category.Update)\n\t\t}\n\n\t\tallUsers := authRequired.Group(\"/\")\n\t\tallUsers.Use(validator.ValidateRoles(\n\t\t\ttypes.UserRoleEnum.User,\n\t\t\ttypes.UserRoleEnum.SuperAdmin,\n\t\t))\n\t\t{\n\t\t\t// Products\n\t\t\tallUsers.GET(\"/products/clothes\", clothes.Get)\n\t\t\t// Users\n\t\t\tallUsers.POST(\"/users\", user.Add)\n\t\t\tallUsers.DELETE(\"/users/:id\", user.Delete)\n\t\t\tallUsers.PUT(\"/users/:id\", user.Update)\n\t\t\tallUsers.GET(\"/categories\", category.Get)\n\t\t}\n\t}\n\treturn r\n}", "title": "" }, { "docid": "67bc26ea78669873b6a27260ca1d6406", "score": "0.5887861", "text": "func routesUser(handler *v1User.UserRouter) http.Handler {\n\trouter := chi.NewRouter()\n\n\trouter.With(middleware.AuthMiddleware).Get(\"/\", handler.GetAllUserHandler)\n\trouter.With(middleware.AuthMiddleware).Get(\"/{id}\", handler.GetOneHandler)\n\trouter.Post(\"/\", handler.CreateHandler)\n\trouter.With(middleware.AuthMiddleware).Put(\"/{id}\", handler.UpdateHandler)\n\n\treturn router\n}", "title": "" }, { "docid": "63d23b34db51df6eef1ec13d5cd40c7b", "score": "0.5885286", "text": "func (r *Router) addUsersRouterHandlers() {\n\tr.HandleFunc(\"/users/auth\", LoginHandler).Methods(\"POST\")\n\tr.HandleFunc(\"/users/auth/logout\", LogoutHandler).Methods(\"GET\")\n\tr.HandleFunc(\"/users/signup\", RegisterHandler).Methods(\"POST\")\n\tr.HandleFunc(\"/users/settings\", UserSettingsHandler).Methods(\"GET\")\n}", "title": "" }, { "docid": "6433dade1d32a4f71787fb36af47f9a5", "score": "0.5866864", "text": "func InitRouter() *gin.Engine {\n\trouter := gin.Default()\n\n\trouter.GET(\"/health\", api.HealthCheck)\n\n\treturn router\n}", "title": "" }, { "docid": "011ed92df66c414e185e12f78aedfc13", "score": "0.5863026", "text": "func SetupUserRoutes(app *fiber.App) {\n\troute := app.Group(\"/user\")\n\troute.Post(\"/login\", controllers.Login)\n\troute.Post(\"/register\", controllers.RegisterUser)\n}", "title": "" }, { "docid": "0d4432cdaa7e164634931d888749bdfa", "score": "0.5861043", "text": "func (a *API) InitRouter() {\n\t// Resource and Relationship Read-only Operations\n\ta.Router.GET(a.BaseURI+\":resource\", a.Wrap(a.EntryFindDefault))\n\ta.Router.GET(a.BaseURI+\":resource/:id\", a.Wrap(a.EntryFindRecordByResourceAndId))\n\ta.Router.GET(a.BaseURI+\":resource/:id/:linkname\", a.Wrap(a.EntryFindRelationshipsByResourceId))\n\ta.Router.GET(a.BaseURI+\":resource/:id/:linkname/:secondlinkname\", a.Wrap(a.EntryFindRelationshipByNameAndResourceId))\n\n\t// Record Create\n\ta.Router.POST(a.BaseURI+\":resource\", a.Wrap(a.EntryCreate))\n\ta.Router.POST(a.BaseURI+\":resource/:id\", a.Wrap(a.EntryCreate))\n\n\t// Record Delete\n\ta.Router.DELETE(a.BaseURI+\":resource/:id\", a.Wrap(a.EntryDelete))\n\t//a.Router.DELETE(a.BaseURI+\":resource\", a.Wrap(a.EntryDelete));\n\n\t// Record Update\n\ta.Router.PATCH(a.BaseURI+\":resource/:id\", a.Wrap(a.EntryUpdate))\n}", "title": "" }, { "docid": "f44cf6e3f7baa2889380930f954f86ba", "score": "0.5859776", "text": "func InitializeRouter(clients *common.ClientContainer,\n\thandler common.HandlerInterface, secret string) *chi.Mux {\n\trootRouter := chi.NewRouter()\n\trootRouter.Mount(v1ApiPrefix, v1Api.InitializeRouter(clients, handler,\n\t\tsecret))\n\treturn rootRouter\n}", "title": "" }, { "docid": "4d71bc5e7df43eb619209007b6506b11", "score": "0.585946", "text": "func (app *application) routes() http.Handler {\n\tstandardMiddleware := alice.New(app.recoverPanic, app.logRequest, secureHeader)\n\tdynamicMiddleware := alice.New(app.sessions.Enable, noSurf, app.authenticate)\n\tmux := pat.New()\n\t// mux := http.NewServeMux()\n\tmux.Get(\"/\", dynamicMiddleware.ThenFunc(http.HandlerFunc(app.home)))\n\tmux.Get(\"/snippet/create\", dynamicMiddleware.Append(app.requireAuthentication).ThenFunc(http.HandlerFunc(app.createSnippetForm)))\n\tmux.Post(\"/snippet/create\", dynamicMiddleware.Append(app.requireAuthentication).ThenFunc(http.HandlerFunc(app.createSnippet)))\n\tmux.Get(\"/snippet/:id\", dynamicMiddleware.ThenFunc(http.HandlerFunc(app.showSnippet)))\n\n\t// \tGET /user/signup signupUserForm Display the user signup form\n\t// POST /user/signup signupUser Create a new user\n\t// GET /user/login loginUserForm Display the user login form\n\t// POST /user/login loginUser Authenticate and login the user\n\t// POST /user/logout logoutUser Logout the user\n\n\tmux.Get(\"/user/signup\", dynamicMiddleware.ThenFunc(http.HandlerFunc(app.signupUserForm)))\n\tmux.Post(\"/user/signup\", dynamicMiddleware.ThenFunc(http.HandlerFunc(app.signupUser)))\n\tmux.Get(\"/user/login\", dynamicMiddleware.ThenFunc(http.HandlerFunc(app.loginUserForm)))\n\tmux.Post(\"/user/login\", dynamicMiddleware.ThenFunc(http.HandlerFunc(app.loginUser)))\n\tmux.Post(\"/user/logout\", dynamicMiddleware.Append(app.requireAuthentication).ThenFunc(http.HandlerFunc(app.logoutUser)))\n\n\tfileServer := http.FileServer(http.Dir(\"./ui/static/\"))\n\tmux.Get(\"/static/\", http.StripPrefix(\"/static\", fileServer))\n\t// Pass the servemux as the 'next' parameter to the secureHeaders middleware.\n\t// Because secureHeaders is just a function, and the function returns a\n\t// http.Handler we don't need to do anything else.\n\n\treturn standardMiddleware.Then(mux)\n}", "title": "" }, { "docid": "9a82bac6b7e9671826057a6dfaf92918", "score": "0.58578587", "text": "func Init(router *gin.Engine) {\n\tbaseRoutes := router.Group(\"/login\")\n\n\t// Setup a rate limit to avoid user enumeration\n\trate := limiter.Rate{\n\t\tPeriod: 1 * time.Minute,\n\t\tLimit: 10,\n\t}\n\n\t// // Then, create the limiter instance which takes the store and the rate as arguments.\n\t// // Now, you can give this instance to any supported middleware.\n\t// limitedRoute := router.Group(\"/ui/v1\")\n\tlimitedMiddleware := mgin.NewMiddleware(limiter.New(store, rate), mgin.WithLimitReachedHandler(func(c *gin.Context) {\n\t\tsession := sessions.Default(c)\n\t\tsession.AddFlash(\"You have exceeded your login attempts. Please wait a minute and try again.\")\n\t\tsession.Save()\n\t\tc.Redirect(http.StatusTemporaryRedirect, \"/login\")\n\t\treturn\n\t}))\n\n\tbaseRoutes.Use(limitedMiddleware)\n\n\tbaseRoutes.GET(\"/\", GetLogin)\n\tbaseRoutes.GET(\"/invalidate\", GetLogout)\n\tbaseRoutes.GET(\"/oauth\", OAuthRedirect)\n}", "title": "" } ]
566e01ac4ba7860caec4d32e1f963bf9
evalInt evals a builtinToSecondsSig. See
[ { "docid": "4d49b87344ca18b7fe9a5ad82bec03b4", "score": "0.76627815", "text": "func (b *builtinToSecondsSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1696)\n\targ, isNull, err := b.args[0].EvalTime(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1699)\n\t\treturn 0, true, handleInvalidTimeError(b.ctx, err)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1697)\n\tret := types.TimestampDiff(\"SECOND\", types.ZeroDate, arg)\n\tif ret == 0 {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1700)\n\t\treturn 0, true, handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(arg.String()))\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1698)\n\treturn ret, false, nil\n}", "title": "" } ]
[ { "docid": "c95e592a707f3bd71577e2d67651c741", "score": "0.6800142", "text": "func (b *builtinTimeToSecSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1648)\n\tduration, isNull, err := b.args[0].EvalDuration(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1651)\n\t\treturn 0, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1649)\n\tvar sign int\n\tif duration.Duration >= 0 {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1652)\n\t\tsign = 1\n\t} else {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1653)\n\t\t{\n\t\t\tsign = -1\n\t\t}\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1650)\n\treturn int64(sign * (duration.Hour()*3600 + duration.Minute()*60 + duration.Second())), false, nil\n}", "title": "" }, { "docid": "adbaf043d80c4e95c4eddebec0674357", "score": "0.6794577", "text": "func (b *builtinSecondSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 179)\n\tdur, isNull, err := b.args[0].EvalDuration(b.ctx, row)\n\t// ignore error and return NULL\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 181)\n\t\treturn 0, true, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 180)\n\treturn int64(dur.Second()), false, nil\n}", "title": "" }, { "docid": "26f48c231bfc6ad81b87f8de74d6b657", "score": "0.67599046", "text": "func (b *builtinMicroSecondSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 186)\n\tdur, isNull, err := b.args[0].EvalDuration(b.ctx, row)\n\t// ignore error and return NULL\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 188)\n\t\treturn 0, true, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 187)\n\treturn int64(dur.MicroSecond()), false, nil\n}", "title": "" }, { "docid": "df4cabf9117558ebaca8e8a6023622e7", "score": "0.59511375", "text": "func execNsecToTimeval(_ int, p *gop.Context) {\n\targs := p.GetArgs(1)\n\tret := syscall.NsecToTimeval(args[0].(int64))\n\tp.Ret(1, ret)\n}", "title": "" }, { "docid": "4b2cdb1465409d82dfa026e16162d51f", "score": "0.5890476", "text": "func execTimevalToNsec(_ int, p *gop.Context) {\n\targs := p.GetArgs(1)\n\tret := syscall.TimevalToNsec(args[0].(syscall.Timeval))\n\tp.Ret(1, ret)\n}", "title": "" }, { "docid": "f08f36b0475ae1c9f387cdea864dd32c", "score": "0.5730188", "text": "func (b *builtinSecToTimeSig) evalDuration(row chunk.Row) (types.Duration, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1512)\n\tsecondsFloat, isNull, err := b.args[0].EvalReal(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1517)\n\t\treturn types.Duration{}, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1513)\n\tvar (\n\t\thour int64\n\t\tminute int64\n\t\tsecond int64\n\t\tdemical float64\n\t\tsecondDemical float64\n\t\tnegative string\n\t)\n\n\tif secondsFloat < 0 {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1518)\n\t\tnegative = \"-\"\n\t\tsecondsFloat = math.Abs(secondsFloat)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1514)\n\tseconds := int64(secondsFloat)\n\tdemical = secondsFloat - float64(seconds)\n\n\thour = seconds / 3600\n\tif hour > 838 {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1519)\n\t\thour = 838\n\t\tminute = 59\n\t\tsecond = 59\n\t} else {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1520)\n\t\t{\n\t\t\tminute = seconds % 3600 / 60\n\t\t\tsecond = seconds % 60\n\t\t}\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1515)\n\tsecondDemical = float64(second) + demical\n\n\tvar dur types.Duration\n\tdur, err = types.ParseDuration(b.ctx.GetSessionVars().StmtCtx, fmt.Sprintf(\"%s%02d:%02d:%v\", negative, hour, minute, secondDemical), b.tp.Decimal)\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1521)\n\t\treturn types.Duration{}, err != nil, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1516)\n\treturn dur, false, nil\n}", "title": "" }, { "docid": "df4ca157b4208b931e89df17b1c483c5", "score": "0.5598539", "text": "func (b *builtinTimestampDiffSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1059)\n\tunit, isNull, err := b.args[0].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1064)\n\t\treturn 0, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1060)\n\tlhs, isNull, err := b.args[1].EvalTime(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1065)\n\t\treturn 0, isNull, handleInvalidTimeError(b.ctx, err)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1061)\n\trhs, isNull, err := b.args[2].EvalTime(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1066)\n\t\treturn 0, isNull, handleInvalidTimeError(b.ctx, err)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1062)\n\tif invalidLHS, invalidRHS := lhs.InvalidZero(), rhs.InvalidZero(); invalidLHS || invalidRHS {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1067)\n\t\tif invalidLHS {\n\t\t\ttrace_util_0.Count(_builtin_time_00000, 1070)\n\t\t\terr = handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(lhs.String()))\n\t\t}\n\t\ttrace_util_0.Count(_builtin_time_00000, 1068)\n\t\tif invalidRHS {\n\t\t\ttrace_util_0.Count(_builtin_time_00000, 1071)\n\t\t\terr = handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(rhs.String()))\n\t\t}\n\t\ttrace_util_0.Count(_builtin_time_00000, 1069)\n\t\treturn 0, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1063)\n\treturn types.TimestampDiff(unit, lhs, rhs), false, nil\n}", "title": "" }, { "docid": "42dc899daf18d37d09cd49cf23ec76d6", "score": "0.55612165", "text": "func (b *builtinExtractDurationSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 639)\n\tunit, isNull, err := b.args[0].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 642)\n\t\treturn 0, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 640)\n\tdur, isNull, err := b.args[1].EvalDuration(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 643)\n\t\treturn 0, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 641)\n\tres, err := types.ExtractDurationNum(&dur, unit)\n\treturn res, err != nil, err\n}", "title": "" }, { "docid": "a67e076976476b72e737ce1e8b6b687e", "score": "0.542656", "text": "func (b *builtinToDaysSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1687)\n\targ, isNull, err := b.args[0].EvalTime(b.ctx, row)\n\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1690)\n\t\treturn 0, true, handleInvalidTimeError(b.ctx, err)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1688)\n\tret := types.TimestampDiff(\"DAY\", types.ZeroDate, arg)\n\tif ret == 0 {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1691)\n\t\treturn 0, true, handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(arg.String()))\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1689)\n\treturn ret, false, nil\n}", "title": "" }, { "docid": "ec5d8b3a47cb3a30ac8cd508f9008eed", "score": "0.5390139", "text": "func (b *builtinUnixTimestampIntSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1112)\n\tval, isNull, err := b.args[0].EvalTime(b.ctx, row)\n\tif err != nil && terror.ErrorEqual(types.ErrInvalidTimeFormat.GenWithStackByArgs(val), err) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1117)\n\t\t// Return 0 for invalid date time.\n\t\treturn 0, false, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1113)\n\tif isNull {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1118)\n\t\treturn 0, true, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1114)\n\tt, err := val.Time.GoTime(getTimeZone(b.ctx))\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1119)\n\t\treturn 0, false, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1115)\n\tdec, err := goTimeToMysqlUnixTimestamp(t, 1)\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1120)\n\t\treturn 0, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1116)\n\tintVal, err := dec.ToInt()\n\tterror.Log(err)\n\treturn intVal, false, nil\n}", "title": "" }, { "docid": "94b89432e0234d2ee3cef96cad79db81", "score": "0.5287567", "text": "func (b *builtinUnixTimestampCurrentSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1106)\n\tvar nowTs = &b.ctx.GetSessionVars().StmtCtx.NowTs\n\tif nowTs.Equal(time.Time{}) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1109)\n\t\t*nowTs = time.Now()\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1107)\n\tdec, err := goTimeToMysqlUnixTimestamp(*nowTs, 1)\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1110)\n\t\treturn 0, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1108)\n\tintVal, err := dec.ToInt()\n\tterror.Log(err)\n\treturn intVal, false, nil\n}", "title": "" }, { "docid": "f88d7f38d13e0d3149fe01a0d508efbf", "score": "0.5281", "text": "func (b *builtinTimeLiteralSig) evalDuration(row chunk.Row) (types.Duration, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 547)\n\treturn b.duration, false, nil\n}", "title": "" }, { "docid": "eabd0963b6fc695aea2ff19830dfbd13", "score": "0.52544", "text": "func (b *builtinExtractDatetimeSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 633)\n\tunit, isNull, err := b.args[0].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 636)\n\t\treturn 0, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 634)\n\tdt, isNull, err := b.args[1].EvalTime(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 637)\n\t\treturn 0, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 635)\n\tres, err := types.ExtractDatetimeNum(&dt, unit)\n\treturn res, err != nil, err\n}", "title": "" }, { "docid": "26060ead47a09efadb7bf89a43c7b31f", "score": "0.52245253", "text": "func (b *builtinTimeSig) evalDuration(row chunk.Row) (res types.Duration, isNull bool, err error) {\n\ttrace_util_0.Count(_builtin_time_00000, 524)\n\texpr, isNull, err := b.args[0].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 529)\n\t\treturn res, isNull, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 525)\n\tfsp := 0\n\tif idx := strings.Index(expr, \".\"); idx != -1 {\n\t\ttrace_util_0.Count(_builtin_time_00000, 530)\n\t\tfsp = len(expr) - idx - 1\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 526)\n\tif fsp, err = types.CheckFsp(fsp); err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 531)\n\t\treturn res, isNull, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 527)\n\tsc := b.ctx.GetSessionVars().StmtCtx\n\tres, err = types.ParseDuration(sc, expr, fsp)\n\tif types.ErrTruncatedWrongVal.Equal(err) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 532)\n\t\terr = sc.HandleTruncate(err)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 528)\n\treturn res, isNull, err\n}", "title": "" }, { "docid": "a5931eb78e330dfd61f1397e000b7941", "score": "0.5209767", "text": "func (b *builtinMinuteSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 172)\n\tdur, isNull, err := b.args[0].EvalDuration(b.ctx, row)\n\t// ignore error and return NULL\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 174)\n\t\treturn 0, true, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 173)\n\treturn int64(dur.Minute()), false, nil\n}", "title": "" }, { "docid": "307c535372c9b453280d7094d85733db", "score": "0.51104504", "text": "func (b *builtinTidbParseTsoSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1753)\n\targ, isNull, err := b.args[0].EvalInt(b.ctx, row)\n\tif isNull || err != nil || arg <= 0 {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1756)\n\t\treturn types.Time{}, true, handleInvalidTimeError(b.ctx, err)\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 1754)\n\tt := oracle.GetTimeFromTS(uint64(arg))\n\tresult := types.Time{\n\t\tTime: types.FromGoTime(t),\n\t\tType: mysql.TypeDatetime,\n\t\tFsp: types.MaxFsp,\n\t}\n\terr = result.ConvertTimeZone(time.Local, b.ctx.GetSessionVars().Location())\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1757)\n\t\treturn types.Time{}, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1755)\n\treturn result, false, nil\n}", "title": "" }, { "docid": "ba2b950b83fa5ce624bff67256417e4e", "score": "0.5069136", "text": "func UnixSeconds(tm time.Time) Arg {\n\treturn Arg{\n\t\ttyp: argInt,\n\t\tnum: uint64(tm.Unix()),\n\t}\n}", "title": "" }, { "docid": "ec49e319ab9ad83b72b954e479d65047", "score": "0.5062044", "text": "func (b *builtinDayOfYearSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 253)\n\targ, isNull, err := b.args[0].EvalTime(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 256)\n\t\treturn 0, isNull, handleInvalidTimeError(b.ctx, err)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 254)\n\tif arg.InvalidZero() {\n\t\ttrace_util_0.Count(_builtin_time_00000, 257)\n\t\treturn 0, true, handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(arg.String()))\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 255)\n\treturn int64(arg.Time.YearDay()), false, nil\n}", "title": "" }, { "docid": "d4b77ad01841a6583ed8f2d68158fa7f", "score": "0.5060213", "text": "func execTimespecToNsec(_ int, p *gop.Context) {\n\targs := p.GetArgs(1)\n\tret := syscall.TimespecToNsec(args[0].(syscall.Timespec))\n\tp.Ret(1, ret)\n}", "title": "" }, { "docid": "1e47abe326c3620738648d31fdc08d19", "score": "0.50121087", "text": "func (b *builtinSubDateIntIntSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 968)\n\tunit, isNull, err := b.args[2].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 972)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 969)\n\tdate, isNull, err := b.getDateFromInt(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 973)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 970)\n\tinterval, isNull, err := b.getIntervalFromInt(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 974)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 971)\n\tresult, isNull, err := b.sub(b.ctx, date, interval, unit)\n\treturn result, isNull || err != nil, err\n}", "title": "" }, { "docid": "444714c376a868029e735c7f42d18a72", "score": "0.50017697", "text": "func execNsecToTimespec(_ int, p *gop.Context) {\n\targs := p.GetArgs(1)\n\tret := syscall.NsecToTimespec(args[0].(int64))\n\tp.Ret(1, ret)\n}", "title": "" }, { "docid": "d7aa65bb6ae822b3688e9f5cec78c425", "score": "0.4995458", "text": "func Seconds(d time.Duration) Arg {\n\treturn Arg{\n\t\ttyp: argInt,\n\t\tnum: uint64(d / time.Second),\n\t}\n}", "title": "" }, { "docid": "62b41172ad154a3c2fcd06733cb17ace", "score": "0.4975891", "text": "func (b *builtinTimestamp2ArgsSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1160)\n\targ0, isNull, err := b.args[0].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1168)\n\t\treturn types.Time{}, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1161)\n\tvar tm types.Time\n\tsc := b.ctx.GetSessionVars().StmtCtx\n\tif b.isFloat {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1169)\n\t\ttm, err = types.ParseTimeFromFloatString(sc, arg0, mysql.TypeDatetime, types.GetFsp(arg0))\n\t} else {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1170)\n\t\t{\n\t\t\ttm, err = types.ParseTime(sc, arg0, mysql.TypeDatetime, types.GetFsp(arg0))\n\t\t}\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1162)\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1171)\n\t\treturn types.Time{}, true, handleInvalidTimeError(b.ctx, err)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1163)\n\targ1, isNull, err := b.args[1].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1172)\n\t\treturn types.Time{}, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1164)\n\tif !isDuration(arg1) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1173)\n\t\treturn types.Time{}, true, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1165)\n\tduration, err := types.ParseDuration(sc, arg1, types.GetFsp(arg1))\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1174)\n\t\treturn types.Time{}, true, handleInvalidTimeError(b.ctx, err)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1166)\n\ttmp, err := tm.Add(sc, duration)\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1175)\n\t\treturn types.Time{}, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1167)\n\treturn tmp, false, nil\n}", "title": "" }, { "docid": "143e18917c22c949f439fc21aa088730", "score": "0.49223447", "text": "func (b *builtinTimestampAddSig) evalString(row chunk.Row) (string, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1658)\n\tunit, isNull, err := b.args[0].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1665)\n\t\treturn \"\", isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1659)\n\tv, isNull, err := b.args[1].EvalInt(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1666)\n\t\treturn \"\", isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1660)\n\targ, isNull, err := b.args[2].EvalTime(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1667)\n\t\treturn \"\", isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1661)\n\ttm1, err := arg.Time.GoTime(time.Local)\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1668)\n\t\treturn \"\", isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1662)\n\tvar tb time.Time\n\tfsp := types.DefaultFsp\n\tswitch unit {\n\tcase \"MICROSECOND\":\n\t\ttrace_util_0.Count(_builtin_time_00000, 1669)\n\t\ttb = tm1.Add(time.Duration(v) * time.Microsecond)\n\t\tfsp = types.MaxFsp\n\tcase \"SECOND\":\n\t\ttrace_util_0.Count(_builtin_time_00000, 1670)\n\t\ttb = tm1.Add(time.Duration(v) * time.Second)\n\tcase \"MINUTE\":\n\t\ttrace_util_0.Count(_builtin_time_00000, 1671)\n\t\ttb = tm1.Add(time.Duration(v) * time.Minute)\n\tcase \"HOUR\":\n\t\ttrace_util_0.Count(_builtin_time_00000, 1672)\n\t\ttb = tm1.Add(time.Duration(v) * time.Hour)\n\tcase \"DAY\":\n\t\ttrace_util_0.Count(_builtin_time_00000, 1673)\n\t\ttb = tm1.AddDate(0, 0, int(v))\n\tcase \"WEEK\":\n\t\ttrace_util_0.Count(_builtin_time_00000, 1674)\n\t\ttb = tm1.AddDate(0, 0, 7*int(v))\n\tcase \"MONTH\":\n\t\ttrace_util_0.Count(_builtin_time_00000, 1675)\n\t\ttb = tm1.AddDate(0, int(v), 0)\n\tcase \"QUARTER\":\n\t\ttrace_util_0.Count(_builtin_time_00000, 1676)\n\t\ttb = tm1.AddDate(0, 3*int(v), 0)\n\tcase \"YEAR\":\n\t\ttrace_util_0.Count(_builtin_time_00000, 1677)\n\t\ttb = tm1.AddDate(int(v), 0, 0)\n\tdefault:\n\t\ttrace_util_0.Count(_builtin_time_00000, 1678)\n\t\treturn \"\", true, types.ErrInvalidTimeFormat.GenWithStackByArgs(unit)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1663)\n\tr := types.Time{Time: types.FromGoTime(tb), Type: b.resolveType(arg.Type, unit), Fsp: fsp}\n\tif err = r.Check(b.ctx.GetSessionVars().StmtCtx); err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1679)\n\t\treturn \"\", true, handleInvalidTimeError(b.ctx, err)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1664)\n\treturn r.String(), false, nil\n}", "title": "" }, { "docid": "f3abb5da95aa9802173ddb1844e78d35", "score": "0.49097115", "text": "func (b *builtinTimestampLiteralSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1192)\n\treturn b.tm, false, nil\n}", "title": "" }, { "docid": "ceae375f6b9de8c167cfea83f58ea252", "score": "0.486551", "text": "func (b *builtinFromUnixTime1ArgSig) evalTime(row chunk.Row) (res types.Time, isNull bool, err error) {\n\ttrace_util_0.Count(_builtin_time_00000, 378)\n\treturn evalFromUnixTime(b.ctx, b.tp.Decimal, row, b.args[0])\n}", "title": "" }, { "docid": "4667bfc58b6f5f800df194a25142a68a", "score": "0.48412317", "text": "func (b *builtinHourSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 165)\n\tdur, isNull, err := b.args[0].EvalDuration(b.ctx, row)\n\t// ignore error and return NULL\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 167)\n\t\treturn 0, true, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 166)\n\treturn int64(dur.Hour()), false, nil\n}", "title": "" }, { "docid": "4836fd5ca690fe0cf6ee5e56227065cb", "score": "0.4775189", "text": "func (b *builtinFromDaysSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 158)\n\tn, isNull, err := b.args[0].EvalInt(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 160)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 159)\n\treturn types.TimeFromDays(n), false, nil\n}", "title": "" }, { "docid": "e53f3c1c829fafa5e95e192e35bd2367", "score": "0.47513703", "text": "func (b *builtinMakeTimeSig) evalDuration(row chunk.Row) (types.Duration, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1427)\n\tdur := types.ZeroDuration\n\tdur.Fsp = types.MaxFsp\n\thour, isNull, err := b.getIntParam(b.args[0], row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1438)\n\t\treturn dur, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1428)\n\tminute, isNull, err := b.getIntParam(b.args[1], row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1439)\n\t\treturn dur, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1429)\n\tif minute < 0 || minute >= 60 {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1440)\n\t\treturn dur, true, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1430)\n\tsecond, isNull, err := b.args[2].EvalReal(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1441)\n\t\treturn dur, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1431)\n\tif second < 0 || second >= 60 {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1442)\n\t\treturn dur, true, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1432)\n\tvar overflow bool\n\t// MySQL TIME datatype: https://dev.mysql.com/doc/refman/5.7/en/time.html\n\t// ranges from '-838:59:59.000000' to '838:59:59.000000'\n\tif hour < 0 && mysql.HasUnsignedFlag(b.args[0].GetType().Flag) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1443)\n\t\thour = 838\n\t\toverflow = true\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1433)\n\tif hour < -838 {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1444)\n\t\thour = -838\n\t\toverflow = true\n\t} else {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1445)\n\t\tif hour > 838 {\n\t\t\ttrace_util_0.Count(_builtin_time_00000, 1446)\n\t\t\thour = 838\n\t\t\toverflow = true\n\t\t}\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1434)\n\tif hour == -838 || hour == 838 {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1447)\n\t\tif second > 59 {\n\t\t\ttrace_util_0.Count(_builtin_time_00000, 1448)\n\t\t\tsecond = 59\n\t\t}\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1435)\n\tif overflow {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1449)\n\t\tminute = 59\n\t\tsecond = 59\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1436)\n\tfsp := b.tp.Decimal\n\tdur, err = types.ParseDuration(b.ctx.GetSessionVars().StmtCtx, fmt.Sprintf(\"%02d:%02d:%v\", hour, minute, second), fsp)\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1450)\n\t\treturn dur, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1437)\n\treturn dur, false, nil\n}", "title": "" }, { "docid": "9eeec9828a13f369f9456be518e933dc", "score": "0.47457665", "text": "func (b *builtinSubDatetimeAndStringSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1553)\n\targ0, isNull, err := b.args[0].EvalTime(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1560)\n\t\treturn types.ZeroDatetime, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1554)\n\ts, isNull, err := b.args[1].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1561)\n\t\treturn types.ZeroDatetime, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1555)\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1562)\n\t\treturn types.ZeroDatetime, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1556)\n\tif !isDuration(s) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1563)\n\t\treturn types.ZeroDatetime, true, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1557)\n\tsc := b.ctx.GetSessionVars().StmtCtx\n\targ1, err := types.ParseDuration(sc, s, types.GetFsp(s))\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1564)\n\t\treturn types.ZeroDatetime, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1558)\n\targ1time, err := arg1.ConvertToTime(sc, mysql.TypeDatetime)\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1565)\n\t\treturn types.ZeroDatetime, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1559)\n\ttmpDuration := arg0.Sub(sc, &arg1time)\n\tresult, err := tmpDuration.ConvertToTime(sc, mysql.TypeDatetime)\n\treturn result, err != nil, err\n}", "title": "" }, { "docid": "cc64f9cfa12f56945951da7846c63c02", "score": "0.47342846", "text": "func (b *builtinSubDateIntStringSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 960)\n\tunit, isNull, err := b.args[2].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 964)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 961)\n\tdate, isNull, err := b.getDateFromInt(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 965)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 962)\n\tinterval, isNull, err := b.getIntervalFromString(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 966)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 963)\n\tresult, isNull, err := b.sub(b.ctx, date, interval, unit)\n\treturn result, isNull || err != nil, err\n}", "title": "" }, { "docid": "ed15893b597c5bbbe0736977cb027a3b", "score": "0.47290307", "text": "func (b *builtinSubDatetimeAndDurationSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1545)\n\targ0, isNull, err := b.args[0].EvalTime(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1549)\n\t\treturn types.ZeroDatetime, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1546)\n\targ1, isNull, err := b.args[1].EvalDuration(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1550)\n\t\treturn types.ZeroDatetime, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1547)\n\tsc := b.ctx.GetSessionVars().StmtCtx\n\targ1time, err := arg1.ConvertToTime(sc, mysql.TypeDatetime)\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1551)\n\t\treturn arg1time, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1548)\n\ttmpDuration := arg0.Sub(sc, &arg1time)\n\tresult, err := tmpDuration.ConvertToTime(sc, arg0.Type)\n\treturn result, err != nil, err\n}", "title": "" }, { "docid": "757554abcc1ebbae0f733773917a4755", "score": "0.4726936", "text": "func (b *builtinTimestamp1ArgSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1151)\n\ts, isNull, err := b.args[0].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1155)\n\t\treturn types.Time{}, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1152)\n\tvar tm types.Time\n\tsc := b.ctx.GetSessionVars().StmtCtx\n\tif b.isFloat {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1156)\n\t\ttm, err = types.ParseTimeFromFloatString(sc, s, mysql.TypeDatetime, types.GetFsp(s))\n\t} else {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1157)\n\t\t{\n\t\t\ttm, err = types.ParseTime(sc, s, mysql.TypeDatetime, types.GetFsp(s))\n\t\t}\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1153)\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1158)\n\t\treturn types.Time{}, true, handleInvalidTimeError(b.ctx, err)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1154)\n\treturn tm, false, nil\n}", "title": "" }, { "docid": "713ce8201e16517f5b7ee8c9a5e2274d", "score": "0.47265244", "text": "func (b *builtinYearSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 305)\n\tdate, isNull, err := b.args[0].EvalTime(b.ctx, row)\n\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 308)\n\t\treturn 0, true, handleInvalidTimeError(b.ctx, err)\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 306)\n\tif date.IsZero() {\n\t\ttrace_util_0.Count(_builtin_time_00000, 309)\n\t\tif b.ctx.GetSessionVars().SQLMode.HasNoZeroDateMode() {\n\t\t\ttrace_util_0.Count(_builtin_time_00000, 311)\n\t\t\treturn 0, true, handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(date.String()))\n\t\t}\n\t\ttrace_util_0.Count(_builtin_time_00000, 310)\n\t\treturn 0, false, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 307)\n\treturn int64(date.Time.Year()), false, nil\n}", "title": "" }, { "docid": "adb3e9bc93c1f9f3b612b36e70a8cf9b", "score": "0.4708348", "text": "func (b *builtinSubDateStringIntSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 936)\n\tunit, isNull, err := b.args[2].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 940)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 937)\n\tdate, isNull, err := b.getDateFromString(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 941)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 938)\n\tinterval, isNull, err := b.getIntervalFromInt(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 942)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 939)\n\tresult, isNull, err := b.sub(b.ctx, date, interval, unit)\n\treturn result, isNull || err != nil, err\n}", "title": "" }, { "docid": "53784d974eefe1969749c0cead24930b", "score": "0.47054523", "text": "func execmTimevalUnix(_ int, p *gop.Context) {\n\targs := p.GetArgs(1)\n\tret, ret1 := args[0].(*syscall.Timeval).Unix()\n\tp.Ret(1, ret, ret1)\n}", "title": "" }, { "docid": "2533b9090aa3a4749e6656e717b37979", "score": "0.46907434", "text": "func (b *builtinValuesDurationSig) evalDuration(_ chunk.Row) (types.Duration, bool, error) {\n\ttrace_util_0.Count(_builtin_other_00000, 190)\n\tif !b.ctx.GetSessionVars().StmtCtx.InInsertStmt {\n\t\ttrace_util_0.Count(_builtin_other_00000, 194)\n\t\treturn types.Duration{}, true, nil\n\t}\n\ttrace_util_0.Count(_builtin_other_00000, 191)\n\trow := b.ctx.GetSessionVars().CurrInsertValues\n\tif row.IsEmpty() {\n\t\ttrace_util_0.Count(_builtin_other_00000, 195)\n\t\treturn types.Duration{}, true, errors.New(\"Session current insert values is nil\")\n\t}\n\ttrace_util_0.Count(_builtin_other_00000, 192)\n\tif b.offset < row.Len() {\n\t\ttrace_util_0.Count(_builtin_other_00000, 196)\n\t\tif row.IsNull(b.offset) {\n\t\t\ttrace_util_0.Count(_builtin_other_00000, 198)\n\t\t\treturn types.Duration{}, true, nil\n\t\t}\n\t\ttrace_util_0.Count(_builtin_other_00000, 197)\n\t\tduration := row.GetDuration(b.offset, b.getRetTp().Decimal)\n\t\treturn duration, false, nil\n\t}\n\ttrace_util_0.Count(_builtin_other_00000, 193)\n\treturn types.Duration{}, true, errors.Errorf(\"Session current insert values len %d and column's offset %v don't match\", row.Len(), b.offset)\n}", "title": "" }, { "docid": "c08d70c19a2a21e3356854d07b4faeaa", "score": "0.4674338", "text": "func (b *builtinPeriodDiffSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1481)\n\tp1, isNull, err := b.args[0].EvalInt(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1486)\n\t\treturn 0, isNull, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 1482)\n\tp2, isNull, err := b.args[1].EvalInt(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1487)\n\t\treturn 0, isNull, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 1483)\n\tif !validPeriod(p1) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1488)\n\t\treturn 0, false, errIncorrectArgs.GenWithStackByArgs(\"period_diff\")\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 1484)\n\tif !validPeriod(p2) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1489)\n\t\treturn 0, false, errIncorrectArgs.GenWithStackByArgs(\"period_diff\")\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 1485)\n\treturn int64(period2Month(uint64(p1)) - period2Month(uint64(p2))), false, nil\n}", "title": "" }, { "docid": "c1017cbcf02e4c6de47d83d69d9dedbc", "score": "0.4670278", "text": "func (b *builtinSubDurationAndStringSig) evalDuration(row chunk.Row) (types.Duration, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1603)\n\targ0, isNull, err := b.args[0].EvalDuration(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1608)\n\t\treturn types.ZeroDuration, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1604)\n\ts, isNull, err := b.args[1].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1609)\n\t\treturn types.ZeroDuration, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1605)\n\tif !isDuration(s) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1610)\n\t\treturn types.ZeroDuration, true, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1606)\n\targ1, err := types.ParseDuration(b.ctx.GetSessionVars().StmtCtx, s, types.GetFsp(s))\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1611)\n\t\treturn types.ZeroDuration, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1607)\n\tresult, err := arg0.Sub(arg1)\n\treturn result, err != nil, err\n}", "title": "" }, { "docid": "adf41dba349132b5a9d83b4e39b8f4da", "score": "0.46684912", "text": "func (b *builtinDateDiffSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 36)\n\tlhs, isNull, err := b.args[0].EvalTime(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 40)\n\t\treturn 0, true, handleInvalidTimeError(b.ctx, err)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 37)\n\trhs, isNull, err := b.args[1].EvalTime(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 41)\n\t\treturn 0, true, handleInvalidTimeError(b.ctx, err)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 38)\n\tif invalidLHS, invalidRHS := lhs.InvalidZero(), rhs.InvalidZero(); invalidLHS || invalidRHS {\n\t\ttrace_util_0.Count(_builtin_time_00000, 42)\n\t\tif invalidLHS {\n\t\t\ttrace_util_0.Count(_builtin_time_00000, 45)\n\t\t\terr = handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(lhs.String()))\n\t\t}\n\t\ttrace_util_0.Count(_builtin_time_00000, 43)\n\t\tif invalidRHS {\n\t\t\ttrace_util_0.Count(_builtin_time_00000, 46)\n\t\t\terr = handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(rhs.String()))\n\t\t}\n\t\ttrace_util_0.Count(_builtin_time_00000, 44)\n\t\treturn 0, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 39)\n\treturn int64(types.DateDiff(lhs.Time, rhs.Time)), false, nil\n}", "title": "" }, { "docid": "1c785bc4ad64f6d0b297e62c9c280791", "score": "0.46444404", "text": "func (b *builtinSubDateIntDecimalSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 984)\n\tunit, isNull, err := b.args[2].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 988)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 985)\n\tdate, isNull, err := b.getDateFromInt(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 989)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 986)\n\tinterval, isNull, err := b.getIntervalFromDecimal(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 990)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 987)\n\tresult, isNull, err := b.sub(b.ctx, date, interval, unit)\n\treturn result, isNull || err != nil, err\n}", "title": "" }, { "docid": "2940e22657d3efe6f2877cf18eadf514", "score": "0.46302313", "text": "func TestTimestampToSeconds(t *testing.T) {\n\tfakeTime := int64(1000000000)\n\texpected := float64(1)\n\tresult := TimestampToSeconds(fakeTime)\n\tif expected != result {\n\t\tt.Errorf(\"%v != %v\", expected, result)\n\t}\n}", "title": "" }, { "docid": "7c004b3dd0cdd36cfe1f8346e524726d", "score": "0.457779", "text": "func (b *builtinUTCTimeWithArgSig) evalDuration(row chunk.Row) (types.Duration, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1726)\n\tfsp, isNull, err := b.args[0].EvalInt(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1731)\n\t\treturn types.Duration{}, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1727)\n\tif fsp > int64(types.MaxFsp) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1732)\n\t\treturn types.Duration{}, true, errors.Errorf(\"Too-big precision %v specified for 'utc_time'. Maximum is %v.\", fsp, types.MaxFsp)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1728)\n\tif fsp < int64(types.MinFsp) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1733)\n\t\treturn types.Duration{}, true, errors.Errorf(\"Invalid negative %d specified, must in [0, 6].\", fsp)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1729)\n\tvar nowTs = &b.ctx.GetSessionVars().StmtCtx.NowTs\n\tif nowTs.Equal(time.Time{}) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1734)\n\t\t*nowTs = time.Now()\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1730)\n\tv, err := types.ParseDuration(b.ctx.GetSessionVars().StmtCtx, nowTs.UTC().Format(types.TimeFSPFormat), int(fsp))\n\treturn v, false, err\n}", "title": "" }, { "docid": "346901554a9820eed40df377e7783b2e", "score": "0.4531617", "text": "func IntervalValueFromMicroseconds(v int64) Value { return internal.IntervalValue(v) }", "title": "" }, { "docid": "3f02f863900725b1aea8d8f72e389318", "score": "0.45270756", "text": "func (b *builtinSubDateIntRealSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 976)\n\tunit, isNull, err := b.args[2].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 980)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 977)\n\tdate, isNull, err := b.getDateFromInt(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 981)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 978)\n\tinterval, isNull, err := b.getIntervalFromReal(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 982)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 979)\n\tresult, isNull, err := b.sub(b.ctx, date, interval, unit)\n\treturn result, isNull || err != nil, err\n}", "title": "" }, { "docid": "6008b9f6aa913c92edd4c9f87860ecce", "score": "0.45270717", "text": "func (b *builtinSubDateDatetimeIntSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1000)\n\tunit, isNull, err := b.args[2].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1004)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 1001)\n\tdate, isNull, err := b.getDateFromDatetime(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1005)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 1002)\n\tinterval, isNull, err := b.getIntervalFromInt(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1006)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 1003)\n\tresult, isNull, err := b.sub(b.ctx, date, interval, unit)\n\treturn result, isNull || err != nil, err\n}", "title": "" }, { "docid": "a7d0c89d27fc374d1b1a92944615970d", "score": "0.4505614", "text": "func seconds(days Days) int64 {\n\treturn int64(days*SecondsInDay)\n}", "title": "" }, { "docid": "d88cdeb90316439a4a46428c02243186", "score": "0.44961494", "text": "func ttlToSeconds(ttl time.Duration) int32 {\n\treturn int32((ttl + time.Second - 1) / time.Second)\n}", "title": "" }, { "docid": "2e71fab61347f95b2e0ad936b8152e25", "score": "0.44929084", "text": "func (b *builtinUTCTimestampWithArgSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 582)\n\tnum, isNull, err := b.args[0].EvalInt(b.ctx, row)\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 586)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 583)\n\tif !isNull && num > int64(types.MaxFsp) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 587)\n\t\treturn types.Time{}, true, errors.Errorf(\"Too-big precision %v specified for 'utc_timestamp'. Maximum is %v.\", num, types.MaxFsp)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 584)\n\tif !isNull && num < int64(types.MinFsp) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 588)\n\t\treturn types.Time{}, true, errors.Errorf(\"Invalid negative %d specified, must in [0, 6].\", num)\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 585)\n\tresult, isNull, err := evalUTCTimestampWithFsp(b.ctx, int(num))\n\treturn result, isNull, err\n}", "title": "" }, { "docid": "c7e00f00b59ffd49cecc998beb567ff8", "score": "0.44861075", "text": "func (b *builtinSubTimeDurationNullSig) evalDuration(row chunk.Row) (types.Duration, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1613)\n\treturn types.ZeroDuration, true, nil\n}", "title": "" }, { "docid": "2533876fb95c908335b50f5d555c1ed7", "score": "0.44575104", "text": "func (b *builtinValuesTimeSig) evalTime(_ chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_other_00000, 180)\n\tif !b.ctx.GetSessionVars().StmtCtx.InInsertStmt {\n\t\ttrace_util_0.Count(_builtin_other_00000, 184)\n\t\treturn types.Time{}, true, nil\n\t}\n\ttrace_util_0.Count(_builtin_other_00000, 181)\n\trow := b.ctx.GetSessionVars().CurrInsertValues\n\tif row.IsEmpty() {\n\t\ttrace_util_0.Count(_builtin_other_00000, 185)\n\t\treturn types.Time{}, true, errors.New(\"Session current insert values is nil\")\n\t}\n\ttrace_util_0.Count(_builtin_other_00000, 182)\n\tif b.offset < row.Len() {\n\t\ttrace_util_0.Count(_builtin_other_00000, 186)\n\t\tif row.IsNull(b.offset) {\n\t\t\ttrace_util_0.Count(_builtin_other_00000, 188)\n\t\t\treturn types.Time{}, true, nil\n\t\t}\n\t\ttrace_util_0.Count(_builtin_other_00000, 187)\n\t\treturn row.GetTime(b.offset), false, nil\n\t}\n\ttrace_util_0.Count(_builtin_other_00000, 183)\n\treturn types.Time{}, true, errors.Errorf(\"Session current insert values len %d and column's offset %v don't match\", row.Len(), b.offset)\n}", "title": "" }, { "docid": "a4f4061941d96643d93cf258213b5a73", "score": "0.44331354", "text": "func (b *builtinUTCTimeWithoutArgSig) evalDuration(row chunk.Row) (types.Duration, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1722)\n\tvar nowTs = &b.ctx.GetSessionVars().StmtCtx.NowTs\n\tif nowTs.Equal(time.Time{}) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1724)\n\t\t*nowTs = time.Now()\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1723)\n\tv, err := types.ParseDuration(b.ctx.GetSessionVars().StmtCtx, nowTs.UTC().Format(types.TimeFormat), 0)\n\treturn v, false, err\n}", "title": "" }, { "docid": "cee8eb53a8cf7d595ee4705b374fc1e0", "score": "0.44316936", "text": "func execUtimes(_ int, p *gop.Context) {\n\targs := p.GetArgs(2)\n\tret := syscall.Utimes(args[0].(string), args[1].([]syscall.Timeval))\n\tp.Ret(2, ret)\n}", "title": "" }, { "docid": "93195b487024dedca1e7fdb5f5c46173", "score": "0.44135752", "text": "func (e *Estimator) Seconds(name string) (float64, error) {\n\text := filepath.Ext(name)\n\tif ext == \".wav\" {\n\t\treturn e.estFunc(fmt.Sprintf(\"sox --i -D %s\", name))\n\t}\n\treturn e.estFunc(fmt.Sprintf(\"ffprobe -i %s -show_entries format=duration -v quiet -of csv=p=0\", name))\n}", "title": "" }, { "docid": "b0db24828177a46d3f5e95fd5294d749", "score": "0.44067588", "text": "func parseExecutionTime(s string) (float64, error) {\n\telements := strings.Split(s, \":\")\n\tif len(elements) != 4 {\n\t\treturn 0.0, fmt.Errorf(\"wrong execution time \\\"%s\\\"\", s)\n\t}\n\tvar result float64\n\n\tfactor := []float64{ 86400.0, 3600.0, 60.0, 1.0 }\n\tfor idx, curElem := range elements {\n\t\tcurVal, err := strconv.Atoi(curElem)\n\t\tif err != nil {\n\t\t\treturn 0.0, fmt.Errorf(\"wrong execution time \\\"%s\\\" near \\\"%s\\\"\", s, curElem)\n\t\t}\n\t\tresult += float64(curVal) * factor[idx]\n\t}\n\n\treturn result, nil\n}", "title": "" }, { "docid": "66a0724edbc76eda9da5d89449afc8b0", "score": "0.43788078", "text": "func (b *builtinAddDatetimeAndDurationSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1273)\n\targ0, isNull, err := b.args[0].EvalTime(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1276)\n\t\treturn types.ZeroDatetime, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1274)\n\targ1, isNull, err := b.args[1].EvalDuration(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1277)\n\t\treturn types.ZeroDatetime, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1275)\n\tresult, err := arg0.Add(b.ctx.GetSessionVars().StmtCtx, arg1)\n\treturn result, err != nil, err\n}", "title": "" }, { "docid": "69256e3f7bf0786b21c52b78dc1ba653", "score": "0.4355698", "text": "func (b *builtinYearWeekWithModeSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 321)\n\tdate, isNull, err := b.args[0].EvalTime(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 327)\n\t\treturn 0, isNull, handleInvalidTimeError(b.ctx, err)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 322)\n\tif date.IsZero() {\n\t\ttrace_util_0.Count(_builtin_time_00000, 328)\n\t\treturn 0, true, handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(date.String()))\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 323)\n\tmode, isNull, err := b.args[1].EvalInt(b.ctx, row)\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 329)\n\t\treturn 0, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 324)\n\tif isNull {\n\t\ttrace_util_0.Count(_builtin_time_00000, 330)\n\t\tmode = 0\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 325)\n\tyear, week := date.Time.YearWeek(int(mode))\n\tresult := int64(week + year*100)\n\tif result < 0 {\n\t\ttrace_util_0.Count(_builtin_time_00000, 331)\n\t\treturn int64(math.MaxUint32), false, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 326)\n\treturn result, false, nil\n}", "title": "" }, { "docid": "061afd651103e31aa9d7f39e5b8d8845", "score": "0.43515685", "text": "func (b *builtinAddDateIntIntSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 805)\n\tunit, isNull, err := b.args[2].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 809)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 806)\n\tdate, isNull, err := b.getDateFromInt(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 810)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 807)\n\tinterval, isNull, err := b.getIntervalFromInt(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 811)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 808)\n\tresult, isNull, err := b.add(b.ctx, date, interval, unit)\n\treturn result, isNull || err != nil, err\n}", "title": "" }, { "docid": "e4e8ed974fb2283f40a62830014501d6", "score": "0.4348767", "text": "func genSecFromDuration(t string) (int, error) {\n\tt = strings.TrimSpace(t)\n\n\tif len(t) == 0 {\n\t\treturn 0, nil\n\t}\n\t//if the last value is a digit use the value passed\n\tif unicode.IsNumber(rune(t[len(t)-1])) {\n\t\treturn strconv.Atoi(t)\n\t}\n\n\td, err := time.ParseDuration(t)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn int(d.Seconds()), nil\n}", "title": "" }, { "docid": "0936f2b2d8b473e3766de9ab3a06b81a", "score": "0.43471116", "text": "func (b *builtinSubDurationAndDurationSig) evalDuration(row chunk.Row) (types.Duration, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1595)\n\targ0, isNull, err := b.args[0].EvalDuration(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1599)\n\t\treturn types.ZeroDuration, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1596)\n\targ1, isNull, err := b.args[1].EvalDuration(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1600)\n\t\treturn types.ZeroDuration, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1597)\n\tresult, err := arg0.Sub(arg1)\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1601)\n\t\treturn types.ZeroDuration, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1598)\n\treturn result, false, nil\n}", "title": "" }, { "docid": "56b7ad6d9edd71a33be203770266e922", "score": "0.4333119", "text": "func (b *builtinPeriodAddSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1470)\n\tp, isNull, err := b.args[0].EvalInt(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1474)\n\t\treturn 0, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 1471)\n\tn, isNull, err := b.args[1].EvalInt(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1475)\n\t\treturn 0, true, err\n\t}\n\n\t// in MySQL, if p is invalid but n is NULL, the result is NULL, so we have to check if n is NULL first.\n\ttrace_util_0.Count(_builtin_time_00000, 1472)\n\tif !validPeriod(p) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1476)\n\t\treturn 0, false, errIncorrectArgs.GenWithStackByArgs(\"period_add\")\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 1473)\n\tsumMonth := int64(period2Month(uint64(p))) + n\n\treturn int64(month2Period(uint64(sumMonth))), false, nil\n}", "title": "" }, { "docid": "f07f6d6071199dfde8d787f5cde3155a", "score": "0.431268", "text": "func (b *builtinYearWeekWithoutModeSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 333)\n\tdate, isNull, err := b.args[0].EvalTime(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 337)\n\t\treturn 0, true, handleInvalidTimeError(b.ctx, err)\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 334)\n\tif date.InvalidZero() {\n\t\ttrace_util_0.Count(_builtin_time_00000, 338)\n\t\treturn 0, true, handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(date.String()))\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 335)\n\tyear, week := date.Time.YearWeek(0)\n\tresult := int64(week + year*100)\n\tif result < 0 {\n\t\ttrace_util_0.Count(_builtin_time_00000, 339)\n\t\treturn int64(math.MaxUint32), false, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 336)\n\treturn result, false, nil\n}", "title": "" }, { "docid": "504fa359696a8c9c1be6b48305c1ff80", "score": "0.43073356", "text": "func (b *builtinSubDateAndDurationSig) evalString(row chunk.Row) (string, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1615)\n\targ0, isNull, err := b.args[0].EvalDuration(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1618)\n\t\treturn \"\", isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1616)\n\targ1, isNull, err := b.args[1].EvalDuration(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1619)\n\t\treturn \"\", isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1617)\n\tresult, err := arg0.Sub(arg1)\n\treturn result.String(), err != nil, err\n}", "title": "" }, { "docid": "3039856bc4a7fb06102b735078ccb9e7", "score": "0.42987418", "text": "func (b *builtinNowWithoutArgSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 621)\n\tresult, isNull, err := evalNowWithFsp(b.ctx, 0)\n\treturn result, isNull, err\n}", "title": "" }, { "docid": "49fc629463f82e5607b763ad89e30d4c", "score": "0.42967314", "text": "func (o TransferJobScheduleStartTimeOfDayOutput) Seconds() pulumi.IntOutput {\n\treturn o.ApplyT(func(v TransferJobScheduleStartTimeOfDay) int { return v.Seconds }).(pulumi.IntOutput)\n}", "title": "" }, { "docid": "80e74c55567decbbe6779a9fa11b93c9", "score": "0.42928916", "text": "func (b *builtinDayOfWeekSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 244)\n\targ, isNull, err := b.args[0].EvalTime(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 247)\n\t\treturn 0, true, handleInvalidTimeError(b.ctx, err)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 245)\n\tif arg.InvalidZero() {\n\t\ttrace_util_0.Count(_builtin_time_00000, 248)\n\t\treturn 0, true, handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(arg.String()))\n\t}\n\t// 1 is Sunday, 2 is Monday, .... 7 is Saturday\n\ttrace_util_0.Count(_builtin_time_00000, 246)\n\treturn int64(arg.Time.Weekday() + 1), false, nil\n}", "title": "" }, { "docid": "f6783b4170396687a8969cd278fb6bc8", "score": "0.42859247", "text": "func execSetsockoptTimeval(_ int, p *gop.Context) {\n\targs := p.GetArgs(4)\n\tret := syscall.SetsockoptTimeval(args[0].(int), args[1].(int), args[2].(int), args[3].(*syscall.Timeval))\n\tp.Ret(4, ret)\n}", "title": "" }, { "docid": "73a632bf042d32a96a4520e55afd8714", "score": "0.4261175", "text": "func (o PrometheusExporterSpecLivenessProbeOutput) PeriodSeconds() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v PrometheusExporterSpecLivenessProbe) *int { return v.PeriodSeconds }).(pulumi.IntPtrOutput)\n}", "title": "" }, { "docid": "fb800097254626136f3935dea1c60d44", "score": "0.42493793", "text": "func (b *builtinNowWithArgSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 611)\n\tfsp, isNull, err := b.args[0].EvalInt(b.ctx, row)\n\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 614)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 612)\n\tif isNull {\n\t\ttrace_util_0.Count(_builtin_time_00000, 615)\n\t\tfsp = 0\n\t} else {\n\t\ttrace_util_0.Count(_builtin_time_00000, 616)\n\t\tif fsp > int64(types.MaxFsp) {\n\t\t\ttrace_util_0.Count(_builtin_time_00000, 617)\n\t\t\treturn types.Time{}, true, errors.Errorf(\"Too-big precision %v specified for 'now'. Maximum is %v.\", fsp, types.MaxFsp)\n\t\t} else {\n\t\t\ttrace_util_0.Count(_builtin_time_00000, 618)\n\t\t\tif fsp < int64(types.MinFsp) {\n\t\t\t\ttrace_util_0.Count(_builtin_time_00000, 619)\n\t\t\t\treturn types.Time{}, true, errors.Errorf(\"Invalid negative %d specified, must in [0, 6].\", fsp)\n\t\t\t}\n\t\t}\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 613)\n\tresult, isNull, err := evalNowWithFsp(b.ctx, int(fsp))\n\treturn result, isNull, err\n}", "title": "" }, { "docid": "8bb19c83d9f88c61e5cd8c3602787c54", "score": "0.42471647", "text": "func (b *builtinAddDatetimeAndStringSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1279)\n\targ0, isNull, err := b.args[0].EvalTime(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1284)\n\t\treturn types.ZeroDatetime, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1280)\n\ts, isNull, err := b.args[1].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1285)\n\t\treturn types.ZeroDatetime, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1281)\n\tif !isDuration(s) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1286)\n\t\treturn types.ZeroDatetime, true, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1282)\n\tsc := b.ctx.GetSessionVars().StmtCtx\n\targ1, err := types.ParseDuration(sc, s, types.GetFsp(s))\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1287)\n\t\treturn types.ZeroDatetime, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1283)\n\tresult, err := arg0.Add(sc, arg1)\n\treturn result, err != nil, err\n}", "title": "" }, { "docid": "46b661a44f1ccb69d8b137fd3abbb65f", "score": "0.42451003", "text": "func OfUnixSecondsRef(sec *int) TimeUnixSeconds {\n\tif sec == nil {\n\t\treturn TimeUnixSeconds{}\n\t}\n\n\treturn OfUnixSeconds(*sec)\n}", "title": "" }, { "docid": "351777184c8a298b2b9f484b3a7093f6", "score": "0.42360997", "text": "func toSecondsOrDefault(duration *types.Duration, defaultValue int32) int32 { //nolint: unparam\n\tif duration == nil {\n\t\treturn defaultValue\n\t}\n\treturn int32(time.Duration(*duration).Seconds())\n}", "title": "" }, { "docid": "e4b16f1391f6241b27af34e8eb1fdf8f", "score": "0.42283824", "text": "func (a *ArgBuilder) Seconds(d time.Duration) {\n\ta.args = append(a.args, Seconds(d))\n}", "title": "" }, { "docid": "a7ac165e4b0f04b29511cc6a3b4cea8b", "score": "0.4226662", "text": "func (b *builtinSysDateWithoutFspSig) evalTime(row chunk.Row) (d types.Time, isNull bool, err error) {\n\ttrace_util_0.Count(_builtin_time_00000, 482)\n\ttz := b.ctx.GetSessionVars().Location()\n\tnow := time.Now().In(tz)\n\tresult, err := convertTimeToMysqlTime(now, 0, types.ModeHalfEven)\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 484)\n\t\treturn types.Time{}, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 483)\n\treturn result, false, nil\n}", "title": "" }, { "docid": "72c097a7bc6be85488cba8af6a2e300e", "score": "0.42173743", "text": "func healthCheckIntervalSeconds(service *v1.Service) (int, error) {\n\tvalStr, ok := service.Annotations[annDOHealthCheckIntervalSeconds]\n\tif !ok {\n\t\treturn 3, nil\n\t}\n\n\tval, err := strconv.Atoi(valStr)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"failed to parse health check interval annotation %q: %s\", annDOHealthCheckIntervalSeconds, err)\n\t}\n\n\treturn val, nil\n}", "title": "" }, { "docid": "f9338d2fe034c8d465c8d37c8d33cab6", "score": "0.42162246", "text": "func (b *builtinSysDateWithFspSig) evalTime(row chunk.Row) (d types.Time, isNull bool, err error) {\n\ttrace_util_0.Count(_builtin_time_00000, 476)\n\tfsp, isNull, err := b.args[0].EvalInt(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 479)\n\t\treturn types.Time{}, isNull, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 477)\n\tloc := b.ctx.GetSessionVars().Location()\n\tnow := time.Now().In(loc)\n\tresult, err := convertTimeToMysqlTime(now, int(fsp), types.ModeHalfEven)\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 480)\n\t\treturn types.Time{}, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 478)\n\treturn result, false, nil\n}", "title": "" }, { "docid": "1b81cb4d3c54662ff49af792b93e41b8", "score": "0.4197063", "text": "func (b *builtinDayOfMonthSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 233)\n\targ, isNull, err := b.args[0].EvalTime(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 236)\n\t\treturn 0, true, handleInvalidTimeError(b.ctx, err)\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 234)\n\tif arg.IsZero() {\n\t\ttrace_util_0.Count(_builtin_time_00000, 237)\n\t\tif b.ctx.GetSessionVars().SQLMode.HasNoZeroDateMode() {\n\t\t\ttrace_util_0.Count(_builtin_time_00000, 239)\n\t\t\treturn 0, true, handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(arg.String()))\n\t\t}\n\t\ttrace_util_0.Count(_builtin_time_00000, 238)\n\t\treturn 0, false, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 235)\n\treturn int64(arg.Time.Day()), false, nil\n}", "title": "" }, { "docid": "85a253ba8971aa18d0f778a363ab0760", "score": "0.41929966", "text": "func (o SubmarinerSpecConnectionHealthCheckOutput) IntervalSeconds() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v SubmarinerSpecConnectionHealthCheck) *int { return v.IntervalSeconds }).(pulumi.IntPtrOutput)\n}", "title": "" }, { "docid": "07bd1528b788b727ec8229e2ddc2cc7d", "score": "0.4186176", "text": "func (b *builtinUTCTimestampWithoutArgSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 590)\n\tresult, isNull, err := evalUTCTimestampWithFsp(b.ctx, 0)\n\treturn result, isNull, err\n}", "title": "" }, { "docid": "1ba2084a6b6a1ea7d8631b82b99eda56", "score": "0.41815254", "text": "func stdFracSecond(code, n, c int) int {\n\t// Use 0xfff to make the failure case even more absurd.\n\tif c == '.' {\n\t\treturn code | ((n & 0xfff) << stdArgShift)\n\t}\n\treturn code | ((n & 0xfff) << stdArgShift) | 1<<stdSeparatorShift\n}", "title": "" }, { "docid": "4966f1bc034eef2b7db851ffd8872af4", "score": "0.41784796", "text": "func (b *builtinAddDurationAndStringSig) evalDuration(row chunk.Row) (types.Duration, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1299)\n\targ0, isNull, err := b.args[0].EvalDuration(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1305)\n\t\treturn types.ZeroDuration, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1300)\n\ts, isNull, err := b.args[1].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1306)\n\t\treturn types.ZeroDuration, isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1301)\n\tif !isDuration(s) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1307)\n\t\treturn types.ZeroDuration, true, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1302)\n\targ1, err := types.ParseDuration(b.ctx.GetSessionVars().StmtCtx, s, types.GetFsp(s))\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1308)\n\t\treturn types.ZeroDuration, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1303)\n\tresult, err := arg0.Add(arg1)\n\tif err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1309)\n\t\treturn types.ZeroDuration, true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1304)\n\treturn result, false, nil\n}", "title": "" }, { "docid": "117e5cc7e8a6ec031cd68b6252f757fc", "score": "0.4174022", "text": "func (cvr Converter) MinutesToSeconds(m Minutes) Seconds {\r\n\tvar mes = Seconds(m * 60)\r\n\treturn mes\r\n}", "title": "" }, { "docid": "63449eb932073c2e17909ce727e7a539", "score": "0.41706565", "text": "func (b *builtinSubTimeDateTimeNullSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1567)\n\treturn types.ZeroDatetime, true, nil\n}", "title": "" }, { "docid": "dcd1be57119dcf771df402886b4b9277", "score": "0.41645792", "text": "func floorSeconds(seconds int) int {\n\treturn (seconds / dateRangeInterval) * dateRangeInterval\n}", "title": "" }, { "docid": "47585b0f3c2c5b4ee3bce7651d0ba880", "score": "0.41302502", "text": "func convertTimes(times []string) ([]int, error) {\n\tvar returnInt []int\n\n\tfor i := 0; i < len(times); i++ {\n\t\tsplit := strings.Split(times[i], \":\")\n\t\tremovedColon := split[0] + split[1]\n\t\tconvertedInt, err := strconv.Atoi(removedColon)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"Error converting to int \", err)\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// Translate 15 minute increments into a more workable base-10 model\n\t\tlastTwoDigits := convertedInt % 100\n\t\tif lastTwoDigits == 15 {\n\t\t\tconvertedInt -= 15\n\t\t\tconvertedInt += 25\n\t\t}\n\t\tif lastTwoDigits == 30 {\n\t\t\tconvertedInt -= 30\n\t\t\tconvertedInt += 50\n\t\t}\n\t\tif lastTwoDigits == 45 {\n\t\t\tconvertedInt -= 45\n\t\t\tconvertedInt += 75\n\t\t}\n\t\treturnInt = append(returnInt, convertedInt)\n\t}\n\treturn returnInt, nil\n}", "title": "" }, { "docid": "84cd3c82935dc66f685a28d17c926203", "score": "0.41237995", "text": "func execmIntSub(_ int, p *gop.Context) {\n\targs := p.GetArgs(3)\n\tret := args[0].(*big.Int).Sub(args[1].(*big.Int), args[2].(*big.Int))\n\tp.Ret(3, ret)\n}", "title": "" }, { "docid": "8b9cd6e0520d17a3cb0298038402209c", "score": "0.41227913", "text": "func Seconds() rlogc.Timer {\n\toff := time.Now().Unix()\n\treturn func() int64 {\n\t\treturn time.Now().Unix()-off\n\t}\n}", "title": "" }, { "docid": "e4f08f3363b9b3183ada041545e4ac24", "score": "0.4115809", "text": "func execGettimeofday(_ int, p *gop.Context) {\n\targs := p.GetArgs(1)\n\tret := syscall.Gettimeofday(args[0].(*syscall.Timeval))\n\tp.Ret(1, ret)\n}", "title": "" }, { "docid": "7e6da90d6091b29c8ef574d16aba87f4", "score": "0.41100055", "text": "func (b *builtinValuesIntSig) evalInt(_ chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_other_00000, 136)\n\tif !b.ctx.GetSessionVars().StmtCtx.InInsertStmt {\n\t\ttrace_util_0.Count(_builtin_other_00000, 140)\n\t\treturn 0, true, nil\n\t}\n\ttrace_util_0.Count(_builtin_other_00000, 137)\n\trow := b.ctx.GetSessionVars().CurrInsertValues\n\tif row.IsEmpty() {\n\t\ttrace_util_0.Count(_builtin_other_00000, 141)\n\t\treturn 0, true, errors.New(\"Session current insert values is nil\")\n\t}\n\ttrace_util_0.Count(_builtin_other_00000, 138)\n\tif b.offset < row.Len() {\n\t\ttrace_util_0.Count(_builtin_other_00000, 142)\n\t\tif row.IsNull(b.offset) {\n\t\t\ttrace_util_0.Count(_builtin_other_00000, 144)\n\t\t\treturn 0, true, nil\n\t\t}\n\t\ttrace_util_0.Count(_builtin_other_00000, 143)\n\t\treturn row.GetInt64(b.offset), false, nil\n\t}\n\ttrace_util_0.Count(_builtin_other_00000, 139)\n\treturn 0, true, errors.Errorf(\"Session current insert values len %d and column's offset %v don't match\", row.Len(), b.offset)\n}", "title": "" }, { "docid": "a3a42604bf6f8d6f19016c141e7848f6", "score": "0.41081148", "text": "func execSettimeofday(_ int, p *gop.Context) {\n\targs := p.GetArgs(1)\n\tret := syscall.Settimeofday(args[0].(*syscall.Timeval))\n\tp.Ret(1, ret)\n}", "title": "" }, { "docid": "9ba1dbcb214c4ce8f48573a24fa532ef", "score": "0.4104845", "text": "func execUtimesNano(_ int, p *gop.Context) {\n\targs := p.GetArgs(2)\n\tret := syscall.UtimesNano(args[0].(string), args[1].([]syscall.Timespec))\n\tp.Ret(2, ret)\n}", "title": "" }, { "docid": "02450879d0b628d5a8fca8d6619c8246", "score": "0.41030627", "text": "func (b *builtinSubStringAndDurationSig) evalString(row chunk.Row) (result string, isNull bool, err error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1569)\n\tvar (\n\t\targ0 string\n\t\targ1 types.Duration\n\t)\n\targ0, isNull, err = b.args[0].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1573)\n\t\treturn \"\", isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1570)\n\targ1, isNull, err = b.args[1].EvalDuration(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1574)\n\t\treturn \"\", isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1571)\n\tsc := b.ctx.GetSessionVars().StmtCtx\n\tif isDuration(arg0) {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1575)\n\t\tresult, err = strDurationSubDuration(sc, arg0, arg1)\n\t\tif err != nil {\n\t\t\ttrace_util_0.Count(_builtin_time_00000, 1577)\n\t\t\treturn \"\", true, err\n\t\t}\n\t\ttrace_util_0.Count(_builtin_time_00000, 1576)\n\t\treturn result, false, nil\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 1572)\n\tresult, err = strDatetimeSubDuration(sc, arg0, arg1)\n\treturn result, err != nil, err\n}", "title": "" }, { "docid": "7979faf1112b453b2bc913d3ff007858", "score": "0.40942243", "text": "func (b *builtinFromUnixTime2ArgSig) evalString(row chunk.Row) (res string, isNull bool, err error) {\n\ttrace_util_0.Count(_builtin_time_00000, 380)\n\tformat, isNull, err := b.args[1].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 383)\n\t\treturn \"\", true, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 381)\n\tt, isNull, err := evalFromUnixTime(b.ctx, b.tp.Decimal, row, b.args[0])\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 384)\n\t\treturn \"\", isNull, err\n\t}\n\ttrace_util_0.Count(_builtin_time_00000, 382)\n\tres, err = t.DateFormat(format)\n\treturn res, err != nil, err\n}", "title": "" }, { "docid": "f789a6ed97e8c9637ad9fa2450cbd9f7", "score": "0.40864903", "text": "func (b *builtinAddDateIntDecimalSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 821)\n\tunit, isNull, err := b.args[2].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 825)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 822)\n\tdate, isNull, err := b.getDateFromInt(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 826)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 823)\n\tinterval, isNull, err := b.getIntervalFromDecimal(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 827)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 824)\n\tresult, isNull, err := b.add(b.ctx, date, interval, unit)\n\treturn result, isNull || err != nil, err\n}", "title": "" }, { "docid": "8d9d73fabee5ecc00a65995c8775e7be", "score": "0.4079668", "text": "func (b *builtinLikeSig) evalInt(row chunk.Row) (int64, bool, error) {\n\tvalStr, isNull, err := b.args[0].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\treturn 0, isNull, err\n\t}\n\n\tpatternStr, isNull, err := b.args[1].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\treturn 0, isNull, err\n\t}\n\tescape, isNull, err := b.args[2].EvalInt(b.ctx, row)\n\tif isNull || err != nil {\n\t\treturn 0, isNull, err\n\t}\n\tmemorization := func() {\n\t\tif b.pattern == nil {\n\t\t\tb.pattern = b.collator().Pattern()\n\t\t\tif b.args[1].ConstItem(b.ctx.GetSessionVars().StmtCtx) && b.args[2].ConstItem(b.ctx.GetSessionVars().StmtCtx) {\n\t\t\t\tb.pattern.Compile(patternStr, byte(escape))\n\t\t\t\tb.isMemorizedPattern = true\n\t\t\t}\n\t\t}\n\t}\n\t// Only be executed once to achieve thread-safe\n\tb.once.Do(memorization)\n\tif !b.isMemorizedPattern {\n\t\t// Must not use b.pattern to avoid data race\n\t\tpattern := b.collator().Pattern()\n\t\tpattern.Compile(patternStr, byte(escape))\n\t\treturn boolToInt64(pattern.DoMatch(valStr)), false, nil\n\t}\n\treturn boolToInt64(b.pattern.DoMatch(valStr)), false, nil\n}", "title": "" }, { "docid": "9a669f5098dc69eed9b8dd2e67295d4d", "score": "0.40753013", "text": "func integerValue(tls *libc.TLS, zArg uintptr) int32 { /* speedtest1.c:212:12: */\n\tvar v sqlite3_int64 = int64(0)\n\tvar i int32\n\tvar isNeg int32 = 0\n\tif int32(*(*int8)(unsafe.Pointer(zArg))) == '-' {\n\t\tisNeg = 1\n\t\tzArg++\n\t} else if int32(*(*int8)(unsafe.Pointer(zArg))) == '+' {\n\t\tzArg++\n\t}\n\tif (int32(*(*int8)(unsafe.Pointer(zArg))) == '0') && (int32(*(*int8)(unsafe.Pointer(zArg + 1))) == 'x') {\n\t\tvar x int32\n\t\tzArg += uintptr(2)\n\t\tfor (libc.AssignInt32(&x, hexDigitValue(tls, *(*int8)(unsafe.Pointer(zArg))))) >= 0 {\n\t\t\tv = ((v << 4) + sqlite3_int64(x))\n\t\t\tzArg++\n\t\t}\n\t} else {\n\t\tfor libc.Xisdigit(tls, int32(*(*int8)(unsafe.Pointer(zArg)))) != 0 {\n\t\t\tv = (((v * int64(10)) + sqlite3_int64(*(*int8)(unsafe.Pointer(zArg)))) - int64('0'))\n\t\t\tzArg++\n\t\t}\n\t}\n\tfor i = 0; uint64(i) < (uint64(unsafe.Sizeof(aMult)) / uint64(unsafe.Sizeof(struct {\n\t\tzSuffix uintptr\n\t\tiMult int32\n\t\t_ [4]byte\n\t}{}))); i++ {\n\t\tif sqlite3.Xsqlite3_stricmp(tls, aMult[i].zSuffix, zArg) == 0 {\n\t\t\tv = v * (sqlite3_int64(aMult[i].iMult))\n\t\t\tbreak\n\t\t}\n\t}\n\tif v > int64(0x7fffffff) {\n\t\tfatal_error(tls, ts+2213 /* \"parameter too la...\" */, 0)\n\t}\n\treturn func() int32 {\n\t\tif isNeg != 0 {\n\t\t\treturn int32(-v)\n\t\t}\n\t\treturn int32(v)\n\t}()\n}", "title": "" }, { "docid": "02b756e2c96b9fda45641ccf2f04ff16", "score": "0.40743914", "text": "func timeToTimeval(nowinms int64) (ret syscall.Timeval) {\n\tret.Sec = (int32)(nowinms / 1000)\n\tret.Usec = (int32)(((int32)(nowinms) - (int32)(ret.Sec)*(int32)(1000)) * (int32)(1000))\n\treturn\n}", "title": "" }, { "docid": "3cf59e060e4e5b78818b786b6aaca195", "score": "0.40729722", "text": "func (b *builtinSubDateDatetimeDecimalSig) evalTime(row chunk.Row) (types.Time, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1016)\n\tunit, isNull, err := b.args[2].EvalString(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1020)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 1017)\n\tdate, isNull, err := b.getDateFromDatetime(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1021)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 1018)\n\tinterval, isNull, err := b.getIntervalFromDecimal(b.ctx, b.args, row, unit)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1022)\n\t\treturn types.Time{}, true, err\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 1019)\n\tresult, isNull, err := b.sub(b.ctx, date, interval, unit)\n\treturn result, isNull || err != nil, err\n}", "title": "" }, { "docid": "b52cdf063124a014780bd4542f4ae21e", "score": "0.40669948", "text": "func castToPrimitive(rawValue interface{}, targetType reflect.Type) (interface{}, error) {\n\ttypeOfValue := reflect.TypeOf(rawValue)\n\n\tif targetType == reflect.TypeOf(time.Second) {\n\t\tdur, err := cast.ToDurationE(rawValue)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"Casting '%v' to duration\", rawValue)\n\t\t}\n\t\trawValue = dur\n\t\ttypeOfValue = reflect.TypeOf(rawValue)\n\t}\n\n\tisConvertible := typeOfValue.ConvertibleTo(targetType)\n\tif isConvertible {\n\t\treturn reflect.ValueOf(rawValue).Convert(targetType).Interface(), nil\n\t}\n\n\t// last resort, do a simple cast\n\treturn castSimple(rawValue, targetType)\n}", "title": "" }, { "docid": "3c82c9e41d7632ed76e518d4043e4d3e", "score": "0.405991", "text": "func (b *builtinQuarterSig) evalInt(row chunk.Row) (int64, bool, error) {\n\ttrace_util_0.Count(_builtin_time_00000, 1494)\n\tdate, isNull, err := b.args[0].EvalTime(b.ctx, row)\n\tif isNull || err != nil {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1497)\n\t\treturn 0, true, handleInvalidTimeError(b.ctx, err)\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 1495)\n\tif date.IsZero() {\n\t\ttrace_util_0.Count(_builtin_time_00000, 1498)\n\t\treturn 0, true, handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(date.String()))\n\t}\n\n\ttrace_util_0.Count(_builtin_time_00000, 1496)\n\treturn int64((date.Time.Month() + 2) / 3), false, nil\n}", "title": "" } ]
1cec8b1cc7c725bf8eadfec33da02a79
WriteToRequest writes these params to a swagger request
[ { "docid": "6d915f5cb4bec1c8b08533ad93f07f96", "score": "0.0", "text": "func (o *GetVoicesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" } ]
[ { "docid": "267ed5f2cd5517ffaa2fc13e86dc2200", "score": "0.72620404", "text": "func (o *GoParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param guid\n\tif err := r.SetPathParam(\"guid\", o.GUID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "714f43ecbd74b76768485e75e9040879", "score": "0.7239197", "text": "func (o *GetAPIVersionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param resourceId\n\tif err := r.SetPathParam(\"resourceId\", o.ResourceID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c6f6c7e4ef5f519d648ca0b992dceeb1", "score": "0.71290636", "text": "func (o *EventExampleParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param eventType\n\tif err := r.SetPathParam(\"eventType\", o.EventType); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "5a6b98a727439da827feeedfee28a755", "score": "0.7074339", "text": "func (o *CreateInputParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.JSONBody != nil {\n\t\tif err := r.SetBodyParam(o.JSONBody); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "8fc591381d6db9bc605b9737eba38015", "score": "0.7052204", "text": "func (o *EndpointAccessUpdateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt64(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "7a4911a1368dd8e9e71b916a7c464285", "score": "0.7044064", "text": "func (o *BikePointGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "235d66a2d586ccca86809f44fb8c4318", "score": "0.7025917", "text": "func (o *GetActivationsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tr.SetTimeout(o.timeout)\n\tvar res []error\n\n\tif o.Docs != nil {\n\n\t\t// query param docs\n\t\tvar qrDocs bool\n\t\tif o.Docs != nil {\n\t\t\tqrDocs = *o.Docs\n\t\t}\n\t\tqDocs := swag.FormatBool(qrDocs)\n\t\tif qDocs != \"\" {\n\t\t\tif err := r.SetQueryParam(\"docs\", qDocs); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int64\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt64(qrLimit)\n\t\tif qLimit != \"\" {\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Name != nil {\n\n\t\t// query param name\n\t\tvar qrName string\n\t\tif o.Name != nil {\n\t\t\tqrName = *o.Name\n\t\t}\n\t\tqName := qrName\n\t\tif qName != \"\" {\n\t\t\tif err := r.SetQueryParam(\"name\", qName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param namespace\n\tif err := r.SetPathParam(\"namespace\", o.Namespace); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Since != nil {\n\n\t\t// query param since\n\t\tvar qrSince int64\n\t\tif o.Since != nil {\n\t\t\tqrSince = *o.Since\n\t\t}\n\t\tqSince := swag.FormatInt64(qrSince)\n\t\tif qSince != \"\" {\n\t\t\tif err := r.SetQueryParam(\"since\", qSince); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Skip != nil {\n\n\t\t// query param skip\n\t\tvar qrSkip int64\n\t\tif o.Skip != nil {\n\t\t\tqrSkip = *o.Skip\n\t\t}\n\t\tqSkip := swag.FormatInt64(qrSkip)\n\t\tif qSkip != \"\" {\n\t\t\tif err := r.SetQueryParam(\"skip\", qSkip); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Upto != nil {\n\n\t\t// query param upto\n\t\tvar qrUpto int64\n\t\tif o.Upto != nil {\n\t\t\tqrUpto = *o.Upto\n\t\t}\n\t\tqUpto := swag.FormatInt64(qrUpto)\n\t\tif qUpto != \"\" {\n\t\t\tif err := r.SetQueryParam(\"upto\", qUpto); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "ccfb4b60f6974ac7c58efc6386e1a7b6", "score": "0.70013434", "text": "func (o *APIUpdateApikeyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Apikey != nil {\n\t\tif err := r.SetBodyParam(o.Apikey); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param apikey_id\n\tif err := r.SetPathParam(\"apikey_id\", swag.FormatInt64(o.ApikeyID)); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "3e5b7dc8b31ec9afc33d79d7fcda64e2", "score": "0.69986963", "text": "func (o *PutDataParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param accessOption\n\tqrAccessOption := o.AccessOption\n\tqAccessOption := qrAccessOption\n\tif qAccessOption != \"\" {\n\t\tif err := r.SetQueryParam(\"accessOption\", qAccessOption); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// query param data\n\tqrData := o.Data\n\tqData := qrData\n\tif qData != \"\" {\n\t\tif err := r.SetQueryParam(\"data\", qData); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// query param expectedVersion\n\tqrExpectedVersion := o.ExpectedVersion\n\tqExpectedVersion := qrExpectedVersion\n\tif qExpectedVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"expectedVersion\", qExpectedVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// query param path\n\tqrPath := o.Path\n\tqPath := qrPath\n\tif qPath != \"\" {\n\t\tif err := r.SetQueryParam(\"path\", qPath); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c1299b5d9293ca8c45ed41ea2227fa1c", "score": "0.6981006", "text": "func (o *ChangeTagParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param repository\n\tif err := r.SetPathParam(\"repository\", o.Repository); err != nil {\n\t\treturn err\n\t}\n\n\t// path param tag\n\tif err := r.SetPathParam(\"tag\", o.Tag); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "45492e614e107ac5271d1554ca8a8946", "score": "0.6971309", "text": "func (o *GetMaybeParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param environment\n\tqrEnvironment := o.Environment\n\tqEnvironment := qrEnvironment\n\tif qEnvironment != \"\" {\n\t\tif err := r.SetQueryParam(\"environment\", qEnvironment); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "4766c3c692c5fd2f8a3ff400634fab8c", "score": "0.69569653", "text": "func (o *ExtractionGetV1Params) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param id\n\tqrID := o.ID\n\tqID := qrID\n\tif qID != \"\" {\n\n\t\tif err := r.SetQueryParam(\"id\", qID); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.IncludeFiles != nil {\n\n\t\t// query param include_files\n\t\tvar qrIncludeFiles bool\n\n\t\tif o.IncludeFiles != nil {\n\t\t\tqrIncludeFiles = *o.IncludeFiles\n\t\t}\n\t\tqIncludeFiles := swag.FormatBool(qrIncludeFiles)\n\t\tif qIncludeFiles != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"include_files\", qIncludeFiles); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "ccb5714576cdcc9ab5cfcc8af70e1479", "score": "0.6931449", "text": "func (o *AddSleepParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param date\n\tqrDate := o.Date\n\tqDate := qrDate.String()\n\tif qDate != \"\" {\n\t\tif err := r.SetQueryParam(\"date\", qDate); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// query param duration\n\tqrDuration := o.Duration\n\tqDuration := swag.FormatInt64(qrDuration)\n\tif qDuration != \"\" {\n\t\tif err := r.SetQueryParam(\"duration\", qDuration); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// query param startTime\n\tqrStartTime := o.StartTime\n\tqStartTime := qrStartTime\n\tif qStartTime != \"\" {\n\t\tif err := r.SetQueryParam(\"startTime\", qStartTime); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "e8146bd23fb3c68d1adf7ca626874e1b", "score": "0.68989146", "text": "func (o *QueryPublishersParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param api-version\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\tif qAPIVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"api-version\", qAPIVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param organization\n\tif err := r.SetPathParam(\"organization\", o.Organization); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "398301c3c55cedfe15ae1269b59a90b2", "score": "0.68928015", "text": "func (o *ListParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param api-version\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\tif qAPIVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"api-version\", qAPIVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.MaxResults != nil {\n\n\t\t// query param maxResults\n\t\tvar qrMaxResults int32\n\t\tif o.MaxResults != nil {\n\t\t\tqrMaxResults = *o.MaxResults\n\t\t}\n\t\tqMaxResults := swag.FormatInt32(qrMaxResults)\n\t\tif qMaxResults != \"\" {\n\t\t\tif err := r.SetQueryParam(\"maxResults\", qMaxResults); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param organization\n\tif err := r.SetPathParam(\"organization\", o.Organization); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Result != nil {\n\n\t\t// query param result\n\t\tvar qrResult string\n\t\tif o.Result != nil {\n\t\t\tqrResult = *o.Result\n\t\t}\n\t\tqResult := qrResult\n\t\tif qResult != \"\" {\n\t\t\tif err := r.SetQueryParam(\"result\", qResult); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Status != nil {\n\n\t\t// query param status\n\t\tvar qrStatus string\n\t\tif o.Status != nil {\n\t\t\tqrStatus = *o.Status\n\t\t}\n\t\tqStatus := qrStatus\n\t\tif qStatus != \"\" {\n\t\t\tif err := r.SetQueryParam(\"status\", qStatus); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param subscriptionId\n\tif err := r.SetPathParam(\"subscriptionId\", o.SubscriptionID.String()); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "8d36271ded70bd4ce311a0e8bd75fff3", "score": "0.6889015", "text": "func (o *StatPathParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tr.SetTimeout(o.timeout)\n\tvar res []error\n\n\tif o.OpID != nil {\n\n\t\t// header param Op-ID\n\t\tif err := r.SetHeaderParam(\"Op-ID\", *o.OpID); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\t// query param deviceID\n\tqrDeviceID := o.DeviceID\n\tqDeviceID := qrDeviceID\n\tif qDeviceID != \"\" {\n\t\tif err := r.SetQueryParam(\"deviceID\", qDeviceID); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.FilterSpec != nil {\n\n\t\t// query param filterSpec\n\t\tvar qrFilterSpec string\n\t\tif o.FilterSpec != nil {\n\t\t\tqrFilterSpec = *o.FilterSpec\n\t\t}\n\t\tqFilterSpec := qrFilterSpec\n\t\tif qFilterSpec != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filterSpec\", qFilterSpec); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param store\n\tqrStore := o.Store\n\tqStore := qrStore\n\tif qStore != \"\" {\n\t\tif err := r.SetQueryParam(\"store\", qStore); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "4fdd27e1814a1af6fb91a74a563aae0f", "score": "0.68868345", "text": "func (o *CreatePacketGeneratorParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\tif o.Generator != nil {\n\t\tif err := r.SetBodyParam(o.Generator); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "3e88b542d71877e76714e23473c05230", "score": "0.6872372", "text": "func (o *GetProjectDeviceParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param deviceId\n\tif err := r.SetPathParam(\"deviceId\", o.DeviceID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param projectId\n\tif err := r.SetPathParam(\"projectId\", o.ProjectID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "93318ed80ad68540a8f2507593f44c2c", "score": "0.68562156", "text": "func (o *CreateRuntimeParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "cc01d11813e8dc1214fdb15b5ba44d72", "score": "0.6849701", "text": "func (o *CreateAppParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\tif o.CreateOrUpdateAppRequest != nil {\n\t\tif err := r.SetBodyParam(o.CreateOrUpdateAppRequest); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "44898e7b16df27ca5efa0d479288cbf3", "score": "0.6841271", "text": "func (o *CreateCodesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param campaignId\n\tif err := r.SetPathParam(\"campaignId\", o.CampaignID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param namespace\n\tif err := r.SetPathParam(\"namespace\", o.Namespace); err != nil {\n\t\treturn err\n\t}\n\n\t// setting the default header value\n\tif err := r.SetHeaderParam(\"User-Agent\", utils.UserAgentGen()); err != nil {\n\t\treturn err\n\t}\n\n\tif err := r.SetHeaderParam(\"X-Amzn-Trace-Id\", utils.AmazonTraceIDGen()); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "8daca62b82ff93dd48a280f02ec59120", "score": "0.68409634", "text": "func (o *PutIPAMvlansParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Description != nil {\n\n\t\t// form param description\n\t\tvar frDescription string\n\t\tif o.Description != nil {\n\t\t\tfrDescription = *o.Description\n\t\t}\n\t\tfDescription := frDescription\n\t\tif fDescription != \"\" {\n\t\t\tif err := r.SetFormParam(\"description\", fDescription); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Groups != nil {\n\n\t\t// form param groups\n\t\tvar frGroups string\n\t\tif o.Groups != nil {\n\t\t\tfrGroups = *o.Groups\n\t\t}\n\t\tfGroups := frGroups\n\t\tif fGroups != \"\" {\n\t\t\tif err := r.SetFormParam(\"groups\", fGroups); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt64(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Name != nil {\n\n\t\t// form param name\n\t\tvar frName string\n\t\tif o.Name != nil {\n\t\t\tfrName = *o.Name\n\t\t}\n\t\tfName := frName\n\t\tif fName != \"\" {\n\t\t\tif err := r.SetFormParam(\"name\", fName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Notes != nil {\n\n\t\t// form param notes\n\t\tvar frNotes string\n\t\tif o.Notes != nil {\n\t\t\tfrNotes = *o.Notes\n\t\t}\n\t\tfNotes := frNotes\n\t\tif fNotes != \"\" {\n\t\t\tif err := r.SetFormParam(\"notes\", fNotes); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Number != nil {\n\n\t\t// form param number\n\t\tvar frNumber string\n\t\tif o.Number != nil {\n\t\t\tfrNumber = *o.Number\n\t\t}\n\t\tfNumber := frNumber\n\t\tif fNumber != \"\" {\n\t\t\tif err := r.SetFormParam(\"number\", fNumber); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.SwitchID != nil {\n\n\t\t// form param switch_id\n\t\tvar frSwitchID string\n\t\tif o.SwitchID != nil {\n\t\t\tfrSwitchID = *o.SwitchID\n\t\t}\n\t\tfSwitchID := frSwitchID\n\t\tif fSwitchID != \"\" {\n\t\t\tif err := r.SetFormParam(\"switch_id\", fSwitchID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "a2e6e8a44702f0c9a8a249f5ac365e12", "score": "0.683832", "text": "func (o *GetServiceRequestAttributeParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID.String()); err != nil {\n\t\treturn err\n\t}\n\n\tif o.IncludeProcessGroupReferences != nil {\n\n\t\t// query param includeProcessGroupReferences\n\t\tvar qrIncludeProcessGroupReferences bool\n\t\tif o.IncludeProcessGroupReferences != nil {\n\t\t\tqrIncludeProcessGroupReferences = *o.IncludeProcessGroupReferences\n\t\t}\n\t\tqIncludeProcessGroupReferences := swag.FormatBool(qrIncludeProcessGroupReferences)\n\t\tif qIncludeProcessGroupReferences != \"\" {\n\t\t\tif err := r.SetQueryParam(\"includeProcessGroupReferences\", qIncludeProcessGroupReferences); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "b0e860788d1002458a1800dd376f2308", "score": "0.6837619", "text": "func (o *GetPatientParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param ID\n\tif err := r.SetPathParam(\"ID\", o.ID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "991f0235898c9621dd28fb8a81e42edc", "score": "0.6836285", "text": "func (o *StopPointGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tvaluesIds := o.Ids\n\n\tjoinedIds := swag.JoinByFormat(valuesIds, \"\")\n\t// path array param ids\n\t// SetPathParam does not support variadric arguments, since we used JoinByFormat\n\t// we can send the first item in the array as it's all the items of the previous\n\t// array joined together\n\tif len(joinedIds) > 0 {\n\t\tif err := r.SetPathParam(\"ids\", joinedIds[0]); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.IncludeCrowdingData != nil {\n\n\t\t// query param includeCrowdingData\n\t\tvar qrIncludeCrowdingData bool\n\t\tif o.IncludeCrowdingData != nil {\n\t\t\tqrIncludeCrowdingData = *o.IncludeCrowdingData\n\t\t}\n\t\tqIncludeCrowdingData := swag.FormatBool(qrIncludeCrowdingData)\n\t\tif qIncludeCrowdingData != \"\" {\n\t\t\tif err := r.SetQueryParam(\"includeCrowdingData\", qIncludeCrowdingData); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "81f787bee3ff8a611a15961659d43630", "score": "0.6831626", "text": "func (o *PostRequestDetailsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param extra\n\tif err := r.SetPathParam(\"extra\", o.Extra); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "61dd4057f56c1dc80da1ff80d064226c", "score": "0.68270516", "text": "func (o *UpdateWaterLogParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param amount\n\tqrAmount := o.Amount\n\tqAmount := qrAmount\n\tif qAmount != \"\" {\n\t\tif err := r.SetQueryParam(\"amount\", qAmount); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Unit != nil {\n\n\t\t// query param unit\n\t\tvar qrUnit string\n\t\tif o.Unit != nil {\n\t\t\tqrUnit = *o.Unit\n\t\t}\n\t\tqUnit := qrUnit\n\t\tif qUnit != \"\" {\n\t\t\tif err := r.SetQueryParam(\"unit\", qUnit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param water-log-id\n\tif err := r.SetPathParam(\"water-log-id\", o.WaterLogID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "5f108fbb4f079554f73aa9570394a438", "score": "0.682503", "text": "func (o *GetBuildTypesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Locator != nil {\n\n\t\t// query param locator\n\t\tvar qrLocator string\n\t\tif o.Locator != nil {\n\t\t\tqrLocator = *o.Locator\n\t\t}\n\t\tqLocator := qrLocator\n\t\tif qLocator != \"\" {\n\t\t\tif err := r.SetQueryParam(\"locator\", qLocator); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "fdb1995b078a083d8759e4f5d4355479", "score": "0.6821358", "text": "func (o *RepoAddTopícParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param owner\n\tif err := r.SetPathParam(\"owner\", o.Owner); err != nil {\n\t\treturn err\n\t}\n\n\t// path param repo\n\tif err := r.SetPathParam(\"repo\", o.Repo); err != nil {\n\t\treturn err\n\t}\n\n\t// path param topic\n\tif err := r.SetPathParam(\"topic\", o.Topic); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "d584567a725d95abf7eab68c1c31c8c0", "score": "0.6817103", "text": "func (o *RecommendConfigParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "85c8c57edd8a09e1648c9d334304f9d9", "score": "0.68144774", "text": "func (o *ModifyTokenInfoParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif err := r.SetBodyParam(o.Info); err != nil {\n\t\treturn err\n\t}\n\n\t// path param symbol\n\tif err := r.SetPathParam(\"symbol\", o.Symbol); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "d7e8dacfb68cbc587f5699fb2a31106b", "score": "0.68096536", "text": "func (o *GetAPI24DrivesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Authorization != nil {\n\n\t\t// header param Authorization\n\t\tif err := r.SetHeaderParam(\"Authorization\", *o.Authorization); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\tif o.XRequestID != nil {\n\n\t\t// header param X-Request-ID\n\t\tif err := r.SetHeaderParam(\"X-Request-ID\", *o.XRequestID); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\tif o.ContinuationToken != nil {\n\n\t\t// query param continuation_token\n\t\tvar qrContinuationToken string\n\t\tif o.ContinuationToken != nil {\n\t\t\tqrContinuationToken = *o.ContinuationToken\n\t\t}\n\t\tqContinuationToken := qrContinuationToken\n\t\tif qContinuationToken != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"continuation_token\", qContinuationToken); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filter != nil {\n\n\t\t// query param filter\n\t\tvar qrFilter string\n\t\tif o.Filter != nil {\n\t\t\tqrFilter = *o.Filter\n\t\t}\n\t\tqFilter := qrFilter\n\t\tif qFilter != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"filter\", qFilter); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int32\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt32(qrLimit)\n\t\tif qLimit != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tvaluesNames := o.Names\n\n\tjoinedNames := swag.JoinByFormat(valuesNames, \"csv\")\n\t// query array param names\n\tif err := r.SetQueryParam(\"names\", joinedNames...); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Offset != nil {\n\n\t\t// query param offset\n\t\tvar qrOffset int32\n\t\tif o.Offset != nil {\n\t\t\tqrOffset = *o.Offset\n\t\t}\n\t\tqOffset := swag.FormatInt32(qrOffset)\n\t\tif qOffset != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"offset\", qOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tvaluesSort := o.Sort\n\n\tjoinedSort := swag.JoinByFormat(valuesSort, \"csv\")\n\t// query array param sort\n\tif err := r.SetQueryParam(\"sort\", joinedSort...); err != nil {\n\t\treturn err\n\t}\n\n\tif o.TotalItemCount != nil {\n\n\t\t// query param total_item_count\n\t\tvar qrTotalItemCount bool\n\t\tif o.TotalItemCount != nil {\n\t\t\tqrTotalItemCount = *o.TotalItemCount\n\t\t}\n\t\tqTotalItemCount := swag.FormatBool(qrTotalItemCount)\n\t\tif qTotalItemCount != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"total_item_count\", qTotalItemCount); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "13956e04d99cef38909d0d93ac20cbfb", "score": "0.6808726", "text": "func (o *GetWorkItemTemplateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.DollarExpand != nil {\n\n\t\t// query param $expand\n\t\tvar qrNrDollarExpand string\n\t\tif o.DollarExpand != nil {\n\t\t\tqrNrDollarExpand = *o.DollarExpand\n\t\t}\n\t\tqNrDollarExpand := qrNrDollarExpand\n\t\tif qNrDollarExpand != \"\" {\n\t\t\tif err := r.SetQueryParam(\"$expand\", qNrDollarExpand); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param api-version\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\tif qAPIVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"api-version\", qAPIVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.AsOf != nil {\n\n\t\t// query param asOf\n\t\tvar qrAsOf strfmt.DateTime\n\t\tif o.AsOf != nil {\n\t\t\tqrAsOf = *o.AsOf\n\t\t}\n\t\tqAsOf := qrAsOf.String()\n\t\tif qAsOf != \"\" {\n\t\t\tif err := r.SetQueryParam(\"asOf\", qAsOf); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param organization\n\tif err := r.SetPathParam(\"organization\", o.Organization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param project\n\tif err := r.SetPathParam(\"project\", o.Project); err != nil {\n\t\treturn err\n\t}\n\n\t// path param type\n\tif err := r.SetPathParam(\"type\", o.Type); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "7a02cfc3f4a07c770025d319bddcc1df", "score": "0.6804636", "text": "func (o *GetPreviewParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Encode != nil {\n\n\t\t// query param encode\n\t\tvar qrEncode string\n\t\tif o.Encode != nil {\n\t\t\tqrEncode = *o.Encode\n\t\t}\n\t\tqEncode := qrEncode\n\t\tif qEncode != \"\" {\n\t\t\tif err := r.SetQueryParam(\"encode\", qEncode); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param file\n\tif err := r.SetPathParam(\"file\", o.File); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "5940b65e5af00119c7283fe5fffe54e3", "score": "0.67999566", "text": "func (o *HealthchechServiceParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param appId\n\tif err := r.SetPathParam(\"appId\", o.AppID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "2bda3a4eb2b79b81c7f70d45826c53da", "score": "0.6796876", "text": "func (o *GetWorkspaceUsingGETParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID.String()); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "da2df65aaf42c1e21d16058161739c7d", "score": "0.6794796", "text": "func (o *GetFlowDiffParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param bucketId\n\tif err := r.SetPathParam(\"bucketId\", o.BucketID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param flowId\n\tif err := r.SetPathParam(\"flowId\", o.FlowID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param versionA\n\tif err := r.SetPathParam(\"versionA\", swag.FormatInt32(o.VersionA)); err != nil {\n\t\treturn err\n\t}\n\n\t// path param versionB\n\tif err := r.SetPathParam(\"versionB\", swag.FormatInt32(o.VersionB)); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "1ddb4a305079c5f1d74ef6d2dd4cd34d", "score": "0.67945004", "text": "func (o *DeviceControlParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\tif err := r.SetBodyParam(o.Request); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "615b5b99ff4b9b4d9f5fb0bd5827fd56", "score": "0.67944634", "text": "func (o *AddWeightLogParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param date\n\tqrDate := o.Date\n\tqDate := qrDate.String()\n\tif qDate != \"\" {\n\t\tif err := r.SetQueryParam(\"date\", qDate); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Time != nil {\n\n\t\t// query param time\n\t\tvar qrTime string\n\t\tif o.Time != nil {\n\t\t\tqrTime = *o.Time\n\t\t}\n\t\tqTime := qrTime\n\t\tif qTime != \"\" {\n\t\t\tif err := r.SetQueryParam(\"time\", qTime); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param weight\n\tqrWeight := o.Weight\n\tqWeight := swag.FormatInt64(qrWeight)\n\tif qWeight != \"\" {\n\t\tif err := r.SetQueryParam(\"weight\", qWeight); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "017fd2ec18bdd05c3140f0b01ac1714a", "score": "0.67923486", "text": "func (o *AllUserAttributesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Sorts != nil {\n\n\t\t// query param sorts\n\t\tvar qrSorts string\n\n\t\tif o.Sorts != nil {\n\t\t\tqrSorts = *o.Sorts\n\t\t}\n\t\tqSorts := qrSorts\n\t\tif qSorts != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"sorts\", qSorts); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "1a7d1fb249b8f9f8001928049ba8b0e6", "score": "0.67898434", "text": "func (o *SecurityAuditLogCollectionGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Application != nil {\n\n\t\t// query param application\n\t\tvar qrApplication string\n\n\t\tif o.Application != nil {\n\t\t\tqrApplication = *o.Application\n\t\t}\n\t\tqApplication := qrApplication\n\t\tif qApplication != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"application\", qApplication); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.CommandID != nil {\n\n\t\t// query param command_id\n\t\tvar qrCommandID string\n\n\t\tif o.CommandID != nil {\n\t\t\tqrCommandID = *o.CommandID\n\t\t}\n\t\tqCommandID := qrCommandID\n\t\tif qCommandID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"command_id\", qCommandID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Fields != nil {\n\n\t\t// binding items for fields\n\t\tjoinedFields := o.bindParamFields(reg)\n\n\t\t// query array param fields\n\t\tif err := r.SetQueryParam(\"fields\", joinedFields...); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Index != nil {\n\n\t\t// query param index\n\t\tvar qrIndex int64\n\n\t\tif o.Index != nil {\n\t\t\tqrIndex = *o.Index\n\t\t}\n\t\tqIndex := swag.FormatInt64(qrIndex)\n\t\tif qIndex != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"index\", qIndex); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Input != nil {\n\n\t\t// query param input\n\t\tvar qrInput string\n\n\t\tif o.Input != nil {\n\t\t\tqrInput = *o.Input\n\t\t}\n\t\tqInput := qrInput\n\t\tif qInput != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"input\", qInput); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Location != nil {\n\n\t\t// query param location\n\t\tvar qrLocation string\n\n\t\tif o.Location != nil {\n\t\t\tqrLocation = *o.Location\n\t\t}\n\t\tqLocation := qrLocation\n\t\tif qLocation != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"location\", qLocation); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.MaxRecords != nil {\n\n\t\t// query param max_records\n\t\tvar qrMaxRecords int64\n\n\t\tif o.MaxRecords != nil {\n\t\t\tqrMaxRecords = *o.MaxRecords\n\t\t}\n\t\tqMaxRecords := swag.FormatInt64(qrMaxRecords)\n\t\tif qMaxRecords != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"max_records\", qMaxRecords); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Message != nil {\n\n\t\t// query param message\n\t\tvar qrMessage string\n\n\t\tif o.Message != nil {\n\t\t\tqrMessage = *o.Message\n\t\t}\n\t\tqMessage := qrMessage\n\t\tif qMessage != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"message\", qMessage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.NodeName != nil {\n\n\t\t// query param node.name\n\t\tvar qrNodeName string\n\n\t\tif o.NodeName != nil {\n\t\t\tqrNodeName = *o.NodeName\n\t\t}\n\t\tqNodeName := qrNodeName\n\t\tif qNodeName != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"node.name\", qNodeName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.NodeUUID != nil {\n\n\t\t// query param node.uuid\n\t\tvar qrNodeUUID string\n\n\t\tif o.NodeUUID != nil {\n\t\t\tqrNodeUUID = *o.NodeUUID\n\t\t}\n\t\tqNodeUUID := qrNodeUUID\n\t\tif qNodeUUID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"node.uuid\", qNodeUUID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.OrderBy != nil {\n\n\t\t// binding items for order_by\n\t\tjoinedOrderBy := o.bindParamOrderBy(reg)\n\n\t\t// query array param order_by\n\t\tif err := r.SetQueryParam(\"order_by\", joinedOrderBy...); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.ReturnRecords != nil {\n\n\t\t// query param return_records\n\t\tvar qrReturnRecords bool\n\n\t\tif o.ReturnRecords != nil {\n\t\t\tqrReturnRecords = *o.ReturnRecords\n\t\t}\n\t\tqReturnRecords := swag.FormatBool(qrReturnRecords)\n\t\tif qReturnRecords != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"return_records\", qReturnRecords); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ReturnTimeout != nil {\n\n\t\t// query param return_timeout\n\t\tvar qrReturnTimeout int64\n\n\t\tif o.ReturnTimeout != nil {\n\t\t\tqrReturnTimeout = *o.ReturnTimeout\n\t\t}\n\t\tqReturnTimeout := swag.FormatInt64(qrReturnTimeout)\n\t\tif qReturnTimeout != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"return_timeout\", qReturnTimeout); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Scope != nil {\n\n\t\t// query param scope\n\t\tvar qrScope string\n\n\t\tif o.Scope != nil {\n\t\t\tqrScope = *o.Scope\n\t\t}\n\t\tqScope := qrScope\n\t\tif qScope != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"scope\", qScope); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.SessionID != nil {\n\n\t\t// query param session_id\n\t\tvar qrSessionID string\n\n\t\tif o.SessionID != nil {\n\t\t\tqrSessionID = *o.SessionID\n\t\t}\n\t\tqSessionID := qrSessionID\n\t\tif qSessionID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"session_id\", qSessionID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.State != nil {\n\n\t\t// query param state\n\t\tvar qrState string\n\n\t\tif o.State != nil {\n\t\t\tqrState = *o.State\n\t\t}\n\t\tqState := qrState\n\t\tif qState != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"state\", qState); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.SvmName != nil {\n\n\t\t// query param svm.name\n\t\tvar qrSvmName string\n\n\t\tif o.SvmName != nil {\n\t\t\tqrSvmName = *o.SvmName\n\t\t}\n\t\tqSvmName := qrSvmName\n\t\tif qSvmName != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"svm.name\", qSvmName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Timestamp != nil {\n\n\t\t// query param timestamp\n\t\tvar qrTimestamp string\n\n\t\tif o.Timestamp != nil {\n\t\t\tqrTimestamp = *o.Timestamp\n\t\t}\n\t\tqTimestamp := qrTimestamp\n\t\tif qTimestamp != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"timestamp\", qTimestamp); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.User != nil {\n\n\t\t// query param user\n\t\tvar qrUser string\n\n\t\tif o.User != nil {\n\t\t\tqrUser = *o.User\n\t\t}\n\t\tqUser := qrUser\n\t\tif qUser != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"user\", qUser); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "0674ae33be39c8b9ffa98efededb62de", "score": "0.6788291", "text": "func (o *GetDeploysParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\tif o.RequestBody != nil {\n\t\tif err := r.SetBodyParam(o.RequestBody); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "3b8f32611d140e13933e6cf968b5a227", "score": "0.6786868", "text": "func (o *GetByDateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param access_key\n\tqrAccessKey := o.AccessKey\n\tqAccessKey := qrAccessKey\n\tif qAccessKey != \"\" {\n\n\t\tif err := r.SetQueryParam(\"access_key\", qAccessKey); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Base != nil {\n\n\t\t// query param base\n\t\tvar qrBase string\n\n\t\tif o.Base != nil {\n\t\t\tqrBase = *o.Base\n\t\t}\n\t\tqBase := qrBase\n\t\tif qBase != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"base\", qBase); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// path param date\n\tif err := r.SetPathParam(\"date\", o.Date.String()); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Symbols != nil {\n\n\t\t// binding items for symbols\n\t\tjoinedSymbols := o.bindParamSymbols(reg)\n\n\t\t// query array param symbols\n\t\tif err := r.SetQueryParam(\"symbols\", joinedSymbols...); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "9a12b0699ca86f315b0527b4f4bca7f8", "score": "0.6785725", "text": "func (o *GetAdapterParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param idOrName\n\tif err := r.SetPathParam(\"idOrName\", o.IDOrName); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "e738b136a9d0c0e482e362ec51862330", "score": "0.67769057", "text": "func (o *AdminUpdateTagParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param namespace\n\tif err := r.SetPathParam(\"namespace\", o.Namespace); err != nil {\n\t\treturn err\n\t}\n\n\t// path param tagId\n\tif err := r.SetPathParam(\"tagId\", o.TagID); err != nil {\n\t\treturn err\n\t}\n\n\t// setting the default header value\n\tif err := r.SetHeaderParam(\"User-Agent\", utils.UserAgentGen()); err != nil {\n\t\treturn err\n\t}\n\n\tif err := r.SetHeaderParam(\"X-Amzn-Trace-Id\", utils.AmazonTraceIDGen()); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "079fb7df6ba22fa60cd5f560552f833f", "score": "0.67765653", "text": "func (o *PostModelParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// form file param manifest\n\tif err := r.SetFileParam(\"manifest\", &o.Manifest); err != nil {\n\t\treturn err\n\t}\n\n\tif o.ModelDefinition != nil {\n\n\t\tif o.ModelDefinition != nil {\n\n\t\t\t// form file param model_definition\n\t\t\tif err := r.SetFileParam(\"model_definition\", o.ModelDefinition); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\t// query param version\n\tqrVersion := o.Version\n\tqVersion := qrVersion\n\tif qVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"version\", qVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "24defd5101f4b4bc3cf33276599e21c7", "score": "0.67729586", "text": "func (o *PostWalletSiagkeyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param encryptionpassword\n\tqrEncryptionpassword := o.Encryptionpassword\n\tqEncryptionpassword := qrEncryptionpassword\n\tif qEncryptionpassword != \"\" {\n\n\t\tif err := r.SetQueryParam(\"encryptionpassword\", qEncryptionpassword); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// query param keyfiles\n\tqrKeyfiles := o.Keyfiles\n\tqKeyfiles := qrKeyfiles\n\tif qKeyfiles != \"\" {\n\n\t\tif err := r.SetQueryParam(\"keyfiles\", qKeyfiles); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "a47bc8412f9f3f52b57f350c95e081c4", "score": "0.67706305", "text": "func (o *TmchMarkDocumentInfoParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\treturn err\n\t}\n\n\tvaluesKeys := o.Keys\n\n\tjoinedKeys := swag.JoinByFormat(valuesKeys, \"multi\")\n\t// query array param keys\n\tif err := r.SetQueryParam(\"keys\", joinedKeys...); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "8b2288723e869b3b454b8f3013b1df52", "score": "0.6768137", "text": "func (o *GetDevicesNameParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param device-name\n\tif err := r.SetPathParam(\"device-name\", o.DeviceName.String()); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Follow != nil {\n\n\t\t// query param follow\n\t\tvar qrFollow string\n\t\tif o.Follow != nil {\n\t\t\tqrFollow = *o.Follow\n\t\t}\n\t\tqFollow := qrFollow\n\t\tif qFollow != \"\" {\n\t\t\tif err := r.SetQueryParam(\"follow\", qFollow); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.IncludeCols != nil {\n\n\t\t// query param include_cols\n\t\tvar qrIncludeCols string\n\t\tif o.IncludeCols != nil {\n\t\t\tqrIncludeCols = *o.IncludeCols\n\t\t}\n\t\tqIncludeCols := qrIncludeCols\n\t\tif qIncludeCols != \"\" {\n\t\t\tif err := r.SetQueryParam(\"include_cols\", qIncludeCols); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c6f7634ad8baaf1b2d1bf3ae1259f7fb", "score": "0.676801", "text": "func (o *GetInstancesDocs2Params) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt64(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.OperationID != nil {\n\n\t\t// query param operationId\n\t\tvar qrOperationID string\n\t\tif o.OperationID != nil {\n\t\t\tqrOperationID = *o.OperationID\n\t\t}\n\t\tqOperationID := qrOperationID\n\t\tif qOperationID != \"\" {\n\t\t\tif err := r.SetQueryParam(\"operationId\", qOperationID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Version != nil {\n\n\t\t// query param version\n\t\tvar qrVersion string\n\t\tif o.Version != nil {\n\t\t\tqrVersion = *o.Version\n\t\t}\n\t\tqVersion := qrVersion\n\t\tif qVersion != \"\" {\n\t\t\tif err := r.SetQueryParam(\"version\", qVersion); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "658e495477bb4a353a2d8d0b03b43754", "score": "0.67672104", "text": "func (o *GetExtensionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID); err != nil {\n\t\treturn err\n\t}\n\n\tvaluesInclude := o.Include\n\n\tjoinedInclude := swag.JoinByFormat(valuesInclude, \"multi\")\n\t// query array param include[]\n\tif err := r.SetQueryParam(\"include[]\", joinedInclude...); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "f1351ad5bab1538e61b02ee7448ea4fd", "score": "0.6758796", "text": "func (o *GetMetricsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Follow != nil {\n\n\t\t// query param follow\n\t\tvar qrFollow bool\n\t\tif o.Follow != nil {\n\t\t\tqrFollow = *o.Follow\n\t\t}\n\t\tqFollow := swag.FormatBool(qrFollow)\n\t\tif qFollow != \"\" {\n\t\t\tif err := r.SetQueryParam(\"follow\", qFollow); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param model_id\n\tif err := r.SetPathParam(\"model_id\", o.ModelID); err != nil {\n\t\treturn err\n\t}\n\n\tif o.SinceTime != nil {\n\n\t\t// query param since_time\n\t\tvar qrSinceTime string\n\t\tif o.SinceTime != nil {\n\t\t\tqrSinceTime = *o.SinceTime\n\t\t}\n\t\tqSinceTime := qrSinceTime\n\t\tif qSinceTime != \"\" {\n\t\t\tif err := r.SetQueryParam(\"since_time\", qSinceTime); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param version\n\tqrVersion := o.Version\n\tqVersion := qrVersion\n\tif qVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"version\", qVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "ecd1ac91a6807570d03e2f8e7fb2af42", "score": "0.6755563", "text": "func (o *CreateVersionStageParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param entity\n\tif err := r.SetPathParam(\"entity\", o.Entity); err != nil {\n\t\treturn err\n\t}\n\n\t// path param kind\n\tif err := r.SetPathParam(\"kind\", o.Kind); err != nil {\n\t\treturn err\n\t}\n\n\t// path param name\n\tif err := r.SetPathParam(\"name\", o.Name); err != nil {\n\t\treturn err\n\t}\n\n\t// path param owner\n\tif err := r.SetPathParam(\"owner\", o.Owner); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "886e6e4397db9b90a289068f23583085", "score": "0.67533094", "text": "func (o *GetReleaseTemplateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "3a5e389ab85823cbf20d3ec601cc0e44", "score": "0.6748013", "text": "func (o *PutThingsIDParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Thing != nil {\n\t\tif err := r.SetBodyParam(o.Thing); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "e48da98438d1fcd6ae82e26917cb0be2", "score": "0.674463", "text": "func (o *GetFileParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param fid\n\tif err := r.SetPathParam(\"fid\", swag.FormatInt32(o.Fid)); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "7f97f1721b9e9667638eeeb94e44cbb2", "score": "0.67446005", "text": "func (o *GetTenantByAPIKeyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.APIKey != nil {\n\n\t\t// query param apiKey\n\t\tvar qrAPIKey string\n\n\t\tif o.APIKey != nil {\n\t\t\tqrAPIKey = *o.APIKey\n\t\t}\n\t\tqAPIKey := qrAPIKey\n\t\tif qAPIKey != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"apiKey\", qAPIKey); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// header param WithProfilingInfo\n\tif o.WithProfilingInfo != nil && len(*o.WithProfilingInfo) > 0 {\n\t\tif err := r.SetHeaderParam(\"X-Killbill-Profiling-Req\", *o.WithProfilingInfo); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// header param withStackTrace\n\tif o.WithStackTrace != nil && *o.WithStackTrace {\n\t\tif err := r.SetQueryParam(\"withStackTrace\", \"true\"); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "39ba41ea43365f977621c6389f760c30", "score": "0.6742888", "text": "func (o *TestParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param alarmCallbackId\n\tif err := r.SetPathParam(\"alarmCallbackId\", o.AlarmCallbackID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "4e0f2d4f35f1627db0cd9dd36978c255", "score": "0.67411023", "text": "func (o *UpdateNetscanParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\treturn err\n\t}\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt32(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Reason != nil {\n\n\t\t// query param reason\n\t\tvar qrReason string\n\t\tif o.Reason != nil {\n\t\t\tqrReason = *o.Reason\n\t\t}\n\t\tqReason := qrReason\n\t\tif qReason != \"\" {\n\t\t\tif err := r.SetQueryParam(\"reason\", qReason); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "7af9deac56e9b2f4fd1f8a19994eb713", "score": "0.67348963", "text": "func (o *TeamUpdateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt64(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "47019447480cfb53360c3ccc8994a924", "score": "0.67336875", "text": "func (o *InvoicePostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.PaidAmount != nil {\n\n\t\t// query param paidAmount\n\t\tvar qrPaidAmount float64\n\t\tif o.PaidAmount != nil {\n\t\t\tqrPaidAmount = *o.PaidAmount\n\t\t}\n\t\tqPaidAmount := swag.FormatFloat64(qrPaidAmount)\n\t\tif qPaidAmount != \"\" {\n\t\t\tif err := r.SetQueryParam(\"paidAmount\", qPaidAmount); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.PaymentTypeID != nil {\n\n\t\t// query param paymentTypeId\n\t\tvar qrPaymentTypeID int32\n\t\tif o.PaymentTypeID != nil {\n\t\t\tqrPaymentTypeID = *o.PaymentTypeID\n\t\t}\n\t\tqPaymentTypeID := swag.FormatInt32(qrPaymentTypeID)\n\t\tif qPaymentTypeID != \"\" {\n\t\t\tif err := r.SetQueryParam(\"paymentTypeId\", qPaymentTypeID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.SendToCustomer != nil {\n\n\t\t// query param sendToCustomer\n\t\tvar qrSendToCustomer bool\n\t\tif o.SendToCustomer != nil {\n\t\t\tqrSendToCustomer = *o.SendToCustomer\n\t\t}\n\t\tqSendToCustomer := swag.FormatBool(qrSendToCustomer)\n\t\tif qSendToCustomer != \"\" {\n\t\t\tif err := r.SetQueryParam(\"sendToCustomer\", qSendToCustomer); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "18347b836c8fd2eec8178d394e77e676", "score": "0.6726254", "text": "func (o *GetUsedByAppResourcesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.AppID != nil {\n\n\t\t// query param appId\n\t\tvar qrAppID int32\n\t\tif o.AppID != nil {\n\t\t\tqrAppID = *o.AppID\n\t\t}\n\t\tqAppID := swag.FormatInt32(qrAppID)\n\t\tif qAppID != \"\" {\n\t\t\tif err := r.SetQueryParam(\"appId\", qAppID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param user\n\tif err := r.SetPathParam(\"user\", o.User); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c09bdc928ebd76442f89d2c36131f0e1", "score": "0.6722548", "text": "func (o *OutletsGetAllOutletsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Devid != nil {\n\n\t\t// query param devid\n\t\tvar qrDevid string\n\t\tif o.Devid != nil {\n\t\t\tqrDevid = *o.Devid\n\t\t}\n\t\tqDevid := qrDevid\n\t\tif qDevid != \"\" {\n\t\t\tif err := r.SetQueryParam(\"devid\", qDevid); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.MaxResults != nil {\n\n\t\t// query param max_results\n\t\tvar qrMaxResults int32\n\t\tif o.MaxResults != nil {\n\t\t\tqrMaxResults = *o.MaxResults\n\t\t}\n\t\tqMaxResults := swag.FormatInt32(qrMaxResults)\n\t\tif qMaxResults != \"\" {\n\t\t\tif err := r.SetQueryParam(\"max_results\", qMaxResults); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Signature != nil {\n\n\t\t// query param signature\n\t\tvar qrSignature string\n\t\tif o.Signature != nil {\n\t\t\tqrSignature = *o.Signature\n\t\t}\n\t\tqSignature := qrSignature\n\t\tif qSignature != \"\" {\n\t\t\tif err := r.SetQueryParam(\"signature\", qSignature); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Token != nil {\n\n\t\t// query param token\n\t\tvar qrToken string\n\t\tif o.Token != nil {\n\t\t\tqrToken = *o.Token\n\t\t}\n\t\tqToken := qrToken\n\t\tif qToken != \"\" {\n\t\t\tif err := r.SetQueryParam(\"token\", qToken); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "71f307d2465235bd21bbcba222a1e118", "score": "0.6713836", "text": "func (o *CreateLinkParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Expiration != nil {\n\n\t\t// query param expiration\n\t\tvar qrExpiration int64\n\t\tif o.Expiration != nil {\n\t\t\tqrExpiration = *o.Expiration\n\t\t}\n\t\tqExpiration := swag.FormatInt64(qrExpiration)\n\t\tif qExpiration != \"\" {\n\t\t\tif err := r.SetQueryParam(\"expiration\", qExpiration); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param node\n\tif err := r.SetPathParam(\"node\", o.Node); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Password != nil {\n\n\t\t// query param password\n\t\tvar qrPassword string\n\t\tif o.Password != nil {\n\t\t\tqrPassword = *o.Password\n\t\t}\n\t\tqPassword := qrPassword\n\t\tif qPassword != \"\" {\n\t\t\tif err := r.SetQueryParam(\"password\", qPassword); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c2de48e420d6726d1868e44eabbc5a1d", "score": "0.6710904", "text": "func (o *FormatSeriesServiceUpdateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param object.id\n\tif err := r.SetPathParam(\"object.id\", o.ObjectID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "8981c6ce1ba8a990ed74c5e7b6ea53be", "score": "0.6706226", "text": "func (o *LunModifyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.DataOffset != nil {\n\n\t\t// query param data.offset\n\t\tvar qrDataOffset int64\n\n\t\tif o.DataOffset != nil {\n\t\t\tqrDataOffset = *o.DataOffset\n\t\t}\n\t\tqDataOffset := swag.FormatInt64(qrDataOffset)\n\t\tif qDataOffset != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"data.offset\", qDataOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\tif o.Info != nil {\n\t\tif err := r.SetBodyParam(o.Info); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param uuid\n\tif err := r.SetPathParam(\"uuid\", o.UUID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "668e47281ee4e01d8dfc609948bc4c32", "score": "0.67059755", "text": "func (o *UpdateGatewayParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.UpdateGatewayBody != nil {\n\t\tif err := r.SetBodyParam(o.UpdateGatewayBody); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param gw\n\tif err := r.SetPathParam(\"gw\", o.Gw); err != nil {\n\t\treturn err\n\t}\n\n\t// path param tid\n\tif err := r.SetPathParam(\"tid\", o.Tid); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "e041f5597bd21c39887f521be70dbd95", "score": "0.67036146", "text": "func (o *GetServiceCredentialSchemaForPlanParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param kind\n\tif err := r.SetPathParam(\"kind\", o.Kind); err != nil {\n\t\treturn err\n\t}\n\n\t// path param name\n\tif err := r.SetPathParam(\"name\", o.Name); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "236322786031fe119ec2a0757420db73", "score": "0.67025685", "text": "func (o *UpdateAttributeDefinitionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt64(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Resource != nil {\n\t\tif err := r.SetBodyParam(o.Resource); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "8ef14a211f98cb945912c8ab267f46c9", "score": "0.6702023", "text": "func (o *GetHTTPCheckParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt32(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "338c3111f4812bd7752e00e66f90f16f", "score": "0.6699822", "text": "func (o *GetOverviewParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.TimeRange != nil {\n\n\t\t// query param timeRange\n\t\tvar qrTimeRange int64\n\t\tif o.TimeRange != nil {\n\t\t\tqrTimeRange = *o.TimeRange\n\t\t}\n\t\tqTimeRange := swag.FormatInt64(qrTimeRange)\n\t\tif qTimeRange != \"\" {\n\t\t\tif err := r.SetQueryParam(\"timeRange\", qTimeRange); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "ad72403d9cd2d388105a72e30bc7a343", "score": "0.6692823", "text": "func (o *GetV1InfrastructuresParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.OmitFor != nil {\n\n\t\t// query param omit_for\n\t\tvar qrOmitFor string\n\n\t\tif o.OmitFor != nil {\n\t\t\tqrOmitFor = *o.OmitFor\n\t\t}\n\t\tqOmitFor := qrOmitFor\n\t\tif qOmitFor != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"omit_for\", qOmitFor); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Page != nil {\n\n\t\t// query param page\n\t\tvar qrPage int32\n\n\t\tif o.Page != nil {\n\t\t\tqrPage = *o.Page\n\t\t}\n\t\tqPage := swag.FormatInt32(qrPage)\n\t\tif qPage != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"page\", qPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.PerPage != nil {\n\n\t\t// query param per_page\n\t\tvar qrPerPage int32\n\n\t\tif o.PerPage != nil {\n\t\t\tqrPerPage = *o.PerPage\n\t\t}\n\t\tqPerPage := swag.FormatInt32(qrPerPage)\n\t\tif qPerPage != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"per_page\", qPerPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Query != nil {\n\n\t\t// query param query\n\t\tvar qrQuery string\n\n\t\tif o.Query != nil {\n\t\t\tqrQuery = *o.Query\n\t\t}\n\t\tqQuery := qrQuery\n\t\tif qQuery != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"query\", qQuery); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Type != nil {\n\n\t\t// query param type\n\t\tvar qrType string\n\n\t\tif o.Type != nil {\n\t\t\tqrType = *o.Type\n\t\t}\n\t\tqType := qrType\n\t\tif qType != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"type\", qType); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "dabc2f25822ce27ebc74022a61b657a6", "score": "0.6692445", "text": "func (o *CreateMergeQueryParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "aea114d64fd7cd1e12a5ac86216d71e2", "score": "0.66833526", "text": "func (o *AddDevicePropertyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param deviceId\n\tif err := r.SetPathParam(\"deviceId\", swag.FormatInt32(o.DeviceID)); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "aceb1e876ac8c9eb509e4f81e569fa39", "score": "0.6677139", "text": "func (o *CloudStoreModifyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param aggregate.uuid\n\tif err := r.SetPathParam(\"aggregate.uuid\", o.AggregateUUID); err != nil {\n\t\treturn err\n\t}\n\tif o.Info != nil {\n\t\tif err := r.SetBodyParam(o.Info); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.ReturnTimeout != nil {\n\n\t\t// query param return_timeout\n\t\tvar qrReturnTimeout int64\n\n\t\tif o.ReturnTimeout != nil {\n\t\t\tqrReturnTimeout = *o.ReturnTimeout\n\t\t}\n\t\tqReturnTimeout := swag.FormatInt64(qrReturnTimeout)\n\t\tif qReturnTimeout != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"return_timeout\", qReturnTimeout); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// path param target.uuid\n\tif err := r.SetPathParam(\"target.uuid\", o.TargetUUID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "f6cda6939ba2e393d627ed6ce8b8653d", "score": "0.6676354", "text": "func (o *GetSnapshotDepParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param btLocator\n\tif err := r.SetPathParam(\"btLocator\", o.BtLocator); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param snapshotDepLocator\n\tif err := r.SetPathParam(\"snapshotDepLocator\", o.SnapshotDepLocator); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "3b57b56adc38a1a2c7109e90317cc9e4", "score": "0.66757596", "text": "func (o *CreateCustomImageParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.AccountID != nil {\n\n\t\t// query param accountId\n\t\tvar qrAccountID string\n\t\tif o.AccountID != nil {\n\t\t\tqrAccountID = *o.AccountID\n\t\t}\n\t\tqAccountID := qrAccountID\n\t\tif qAccountID != \"\" {\n\t\t\tif err := r.SetQueryParam(\"accountId\", qAccountID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param name\n\tif err := r.SetPathParam(\"name\", o.Name); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "aa07e79892a26d3abeab1fd71f55cf55", "score": "0.6670894", "text": "func (o *GetBillServicesFullParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param login\n\tqrLogin := o.Login\n\tqLogin := qrLogin\n\tif qLogin != \"\" {\n\t\tif err := r.SetQueryParam(\"login\", qLogin); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// query param pwd\n\tqrPwd := o.Pwd\n\tqPwd := qrPwd\n\tif qPwd != \"\" {\n\t\tif err := r.SetQueryParam(\"pwd\", qPwd); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "a23593eb4378a012589a0bdcda2a0c71", "score": "0.6670338", "text": "func (o *MessagingServiceVersionGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param addr\n\tqrAddr := o.Addr\n\tqAddr := qrAddr\n\tif qAddr != \"\" {\n\t\tif err := r.SetQueryParam(\"addr\", qAddr); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "9537ed713adb771221a2875f21140a42", "score": "0.666377", "text": "func (o *PostAPIPublicV1UserParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param X-VO-Api-Id\n\tif err := r.SetHeaderParam(\"X-VO-Api-Id\", o.XVOAPIID); err != nil {\n\t\treturn err\n\t}\n\n\t// header param X-VO-Api-Key\n\tif err := r.SetHeaderParam(\"X-VO-Api-Key\", o.XVOAPIKey); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "109cbecd30a79b032077ab75c2323020", "score": "0.66631514", "text": "func (o *GetPublicSecurityGroupParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param name\n\tif err := r.SetPathParam(\"name\", o.Name); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "314d8da709aee3d44d6f8370b7184fd1", "score": "0.66508704", "text": "func (o *TestReadParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param organization\n\tif err := r.SetPathParam(\"organization\", o.Organization); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "dde82ea10b44882cb49118c8deb72c35", "score": "0.66508293", "text": "func (o *IndexTagSetsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Skip != nil {\n\n\t\t// query param skip\n\t\tvar qrSkip int32\n\t\tif o.Skip != nil {\n\t\t\tqrSkip = *o.Skip\n\t\t}\n\t\tqSkip := swag.FormatInt32(qrSkip)\n\t\tif qSkip != \"\" {\n\t\t\tif err := r.SetQueryParam(\"skip\", qSkip); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Take != nil {\n\n\t\t// query param take\n\t\tvar qrTake int32\n\t\tif o.Take != nil {\n\t\t\tqrTake = *o.Take\n\t\t}\n\t\tqTake := swag.FormatInt32(qrTake)\n\t\tif qTake != \"\" {\n\t\t\tif err := r.SetQueryParam(\"take\", qTake); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "9cea941695ed8e9c88a2391b95657594", "score": "0.6650779", "text": "func (o *GetPrivateWithdrawParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param address\n\tqrAddress := o.Address\n\tqAddress := qrAddress\n\tif qAddress != \"\" {\n\t\tif err := r.SetQueryParam(\"address\", qAddress); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// query param amount\n\tqrAmount := o.Amount\n\tqAmount := swag.FormatFloat64(qrAmount)\n\tif qAmount != \"\" {\n\t\tif err := r.SetQueryParam(\"amount\", qAmount); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// query param currency\n\tqrCurrency := o.Currency\n\tqCurrency := qrCurrency\n\tif qCurrency != \"\" {\n\t\tif err := r.SetQueryParam(\"currency\", qCurrency); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Priority != nil {\n\n\t\t// query param priority\n\t\tvar qrPriority string\n\t\tif o.Priority != nil {\n\t\t\tqrPriority = *o.Priority\n\t\t}\n\t\tqPriority := qrPriority\n\t\tif qPriority != \"\" {\n\t\t\tif err := r.SetQueryParam(\"priority\", qPriority); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Tfa != nil {\n\n\t\t// query param tfa\n\t\tvar qrTfa string\n\t\tif o.Tfa != nil {\n\t\t\tqrTfa = *o.Tfa\n\t\t}\n\t\tqTfa := qrTfa\n\t\tif qTfa != \"\" {\n\t\t\tif err := r.SetQueryParam(\"tfa\", qTfa); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "069e38073e1fa0b5eb4b0d7422f1fa83", "score": "0.66506386", "text": "func (o *QueryScansParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param filter\n\tqrFilter := o.Filter\n\tqFilter := qrFilter\n\n\tif err := r.SetQueryParam(\"filter\", qFilter); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int64\n\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt64(qrLimit)\n\t\tif qLimit != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Offset != nil {\n\n\t\t// query param offset\n\t\tvar qrOffset int64\n\n\t\tif o.Offset != nil {\n\t\t\tqrOffset = *o.Offset\n\t\t}\n\t\tqOffset := swag.FormatInt64(qrOffset)\n\t\tif qOffset != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"offset\", qOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// query param sort\n\tqrSort := o.Sort\n\tqSort := qrSort\n\n\tif err := r.SetQueryParam(\"sort\", qSort); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "977b935c96af31f761997befaa5f5cf1", "score": "0.6646305", "text": "func (o *FrozenAllParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Addresses != nil {\n\n\t\t// binding items for addresses\n\t\tjoinedAddresses := o.bindParamAddresses(reg)\n\n\t\t// query array param addresses\n\t\tif err := r.SetQueryParam(\"addresses\", joinedAddresses...); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.CoinIds != nil {\n\n\t\t// binding items for coin_ids\n\t\tjoinedCoinIds := o.bindParamCoinIds(reg)\n\n\t\t// query array param coin_ids\n\t\tif err := r.SetQueryParam(\"coin_ids\", joinedCoinIds...); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.EndHeight != nil {\n\n\t\t// query param end_height\n\t\tvar qrEndHeight uint64\n\n\t\tif o.EndHeight != nil {\n\t\t\tqrEndHeight = *o.EndHeight\n\t\t}\n\t\tqEndHeight := swag.FormatUint64(qrEndHeight)\n\t\tif qEndHeight != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"end_height\", qEndHeight); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Height != nil {\n\n\t\t// query param height\n\t\tvar qrHeight uint64\n\n\t\tif o.Height != nil {\n\t\t\tqrHeight = *o.Height\n\t\t}\n\t\tqHeight := swag.FormatUint64(qrHeight)\n\t\tif qHeight != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"height\", qHeight); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.StartHeight != nil {\n\n\t\t// query param start_height\n\t\tvar qrStartHeight uint64\n\n\t\tif o.StartHeight != nil {\n\t\t\tqrStartHeight = *o.StartHeight\n\t\t}\n\t\tqStartHeight := swag.FormatUint64(qrStartHeight)\n\t\tif qStartHeight != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"start_height\", qStartHeight); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "7deb568b2efcc18175c87603dfb7426c", "score": "0.66451526", "text": "func (o *UpdateVersionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param owner\n\tif err := r.SetPathParam(\"owner\", o.Owner); err != nil {\n\t\treturn err\n\t}\n\n\t// path param project\n\tif err := r.SetPathParam(\"project\", o.Project); err != nil {\n\t\treturn err\n\t}\n\n\t// path param version.kind\n\tif err := r.SetPathParam(\"version.kind\", o.VersionKind); err != nil {\n\t\treturn err\n\t}\n\n\t// path param version.name\n\tif err := r.SetPathParam(\"version.name\", o.VersionName); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "a0c3c318bc3fdc1c789092eaba5ab0f9", "score": "0.6643473", "text": "func (o *CatalogsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Query != nil {\n\n\t\t// query param query\n\t\tvar qrQuery string\n\t\tif o.Query != nil {\n\t\t\tqrQuery = *o.Query\n\t\t}\n\t\tqQuery := qrQuery\n\t\tif qQuery != \"\" {\n\t\t\tif err := r.SetQueryParam(\"query\", qQuery); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Sort != nil {\n\n\t\t// query param sort\n\t\tvar qrSort string\n\t\tif o.Sort != nil {\n\t\t\tqrSort = *o.Sort\n\t\t}\n\t\tqSort := qrSort\n\t\tif qSort != \"\" {\n\t\t\tif err := r.SetQueryParam(\"sort\", qSort); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "289516362bb53ca2fba5f97a4e549aef", "score": "0.6633983", "text": "func (o *PullRequestsReadParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt64(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "ffd49bcecf51405d20ef1218ad7833be", "score": "0.66324997", "text": "func (o *CloudTargetCollectionGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.AccessKey != nil {\n\n\t\t// query param access_key\n\t\tvar qrAccessKey string\n\n\t\tif o.AccessKey != nil {\n\t\t\tqrAccessKey = *o.AccessKey\n\t\t}\n\t\tqAccessKey := qrAccessKey\n\t\tif qAccessKey != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"access_key\", qAccessKey); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.AuthenticationType != nil {\n\n\t\t// query param authentication_type\n\t\tvar qrAuthenticationType string\n\n\t\tif o.AuthenticationType != nil {\n\t\t\tqrAuthenticationType = *o.AuthenticationType\n\t\t}\n\t\tqAuthenticationType := qrAuthenticationType\n\t\tif qAuthenticationType != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"authentication_type\", qAuthenticationType); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.AzureAccount != nil {\n\n\t\t// query param azure_account\n\t\tvar qrAzureAccount string\n\n\t\tif o.AzureAccount != nil {\n\t\t\tqrAzureAccount = *o.AzureAccount\n\t\t}\n\t\tqAzureAccount := qrAzureAccount\n\t\tif qAzureAccount != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"azure_account\", qAzureAccount); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.CapURL != nil {\n\n\t\t// query param cap_url\n\t\tvar qrCapURL string\n\n\t\tif o.CapURL != nil {\n\t\t\tqrCapURL = *o.CapURL\n\t\t}\n\t\tqCapURL := qrCapURL\n\t\tif qCapURL != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"cap_url\", qCapURL); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.CertificateValidationEnabled != nil {\n\n\t\t// query param certificate_validation_enabled\n\t\tvar qrCertificateValidationEnabled bool\n\n\t\tif o.CertificateValidationEnabled != nil {\n\t\t\tqrCertificateValidationEnabled = *o.CertificateValidationEnabled\n\t\t}\n\t\tqCertificateValidationEnabled := swag.FormatBool(qrCertificateValidationEnabled)\n\t\tif qCertificateValidationEnabled != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"certificate_validation_enabled\", qCertificateValidationEnabled); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ClusterName != nil {\n\n\t\t// query param cluster.name\n\t\tvar qrClusterName string\n\n\t\tif o.ClusterName != nil {\n\t\t\tqrClusterName = *o.ClusterName\n\t\t}\n\t\tqClusterName := qrClusterName\n\t\tif qClusterName != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"cluster.name\", qClusterName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ClusterUUID != nil {\n\n\t\t// query param cluster.uuid\n\t\tvar qrClusterUUID string\n\n\t\tif o.ClusterUUID != nil {\n\t\t\tqrClusterUUID = *o.ClusterUUID\n\t\t}\n\t\tqClusterUUID := qrClusterUUID\n\t\tif qClusterUUID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"cluster.uuid\", qClusterUUID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Container != nil {\n\n\t\t// query param container\n\t\tvar qrContainer string\n\n\t\tif o.Container != nil {\n\t\t\tqrContainer = *o.Container\n\t\t}\n\t\tqContainer := qrContainer\n\t\tif qContainer != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"container\", qContainer); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Fields != nil {\n\n\t\t// binding items for fields\n\t\tjoinedFields := o.bindParamFields(reg)\n\n\t\t// query array param fields\n\t\tif err := r.SetQueryParam(\"fields\", joinedFields...); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.IpspaceName != nil {\n\n\t\t// query param ipspace.name\n\t\tvar qrIpspaceName string\n\n\t\tif o.IpspaceName != nil {\n\t\t\tqrIpspaceName = *o.IpspaceName\n\t\t}\n\t\tqIpspaceName := qrIpspaceName\n\t\tif qIpspaceName != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ipspace.name\", qIpspaceName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.IpspaceUUID != nil {\n\n\t\t// query param ipspace.uuid\n\t\tvar qrIpspaceUUID string\n\n\t\tif o.IpspaceUUID != nil {\n\t\t\tqrIpspaceUUID = *o.IpspaceUUID\n\t\t}\n\t\tqIpspaceUUID := qrIpspaceUUID\n\t\tif qIpspaceUUID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ipspace.uuid\", qIpspaceUUID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.MaxRecords != nil {\n\n\t\t// query param max_records\n\t\tvar qrMaxRecords int64\n\n\t\tif o.MaxRecords != nil {\n\t\t\tqrMaxRecords = *o.MaxRecords\n\t\t}\n\t\tqMaxRecords := swag.FormatInt64(qrMaxRecords)\n\t\tif qMaxRecords != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"max_records\", qMaxRecords); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Name != nil {\n\n\t\t// query param name\n\t\tvar qrName string\n\n\t\tif o.Name != nil {\n\t\t\tqrName = *o.Name\n\t\t}\n\t\tqName := qrName\n\t\tif qName != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"name\", qName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.OrderBy != nil {\n\n\t\t// binding items for order_by\n\t\tjoinedOrderBy := o.bindParamOrderBy(reg)\n\n\t\t// query array param order_by\n\t\tif err := r.SetQueryParam(\"order_by\", joinedOrderBy...); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Owner != nil {\n\n\t\t// query param owner\n\t\tvar qrOwner string\n\n\t\tif o.Owner != nil {\n\t\t\tqrOwner = *o.Owner\n\t\t}\n\t\tqOwner := qrOwner\n\t\tif qOwner != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"owner\", qOwner); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Port != nil {\n\n\t\t// query param port\n\t\tvar qrPort int64\n\n\t\tif o.Port != nil {\n\t\t\tqrPort = *o.Port\n\t\t}\n\t\tqPort := swag.FormatInt64(qrPort)\n\t\tif qPort != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"port\", qPort); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ProviderType != nil {\n\n\t\t// query param provider_type\n\t\tvar qrProviderType string\n\n\t\tif o.ProviderType != nil {\n\t\t\tqrProviderType = *o.ProviderType\n\t\t}\n\t\tqProviderType := qrProviderType\n\t\tif qProviderType != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"provider_type\", qProviderType); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ReturnRecords != nil {\n\n\t\t// query param return_records\n\t\tvar qrReturnRecords bool\n\n\t\tif o.ReturnRecords != nil {\n\t\t\tqrReturnRecords = *o.ReturnRecords\n\t\t}\n\t\tqReturnRecords := swag.FormatBool(qrReturnRecords)\n\t\tif qReturnRecords != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"return_records\", qReturnRecords); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ReturnTimeout != nil {\n\n\t\t// query param return_timeout\n\t\tvar qrReturnTimeout int64\n\n\t\tif o.ReturnTimeout != nil {\n\t\t\tqrReturnTimeout = *o.ReturnTimeout\n\t\t}\n\t\tqReturnTimeout := swag.FormatInt64(qrReturnTimeout)\n\t\tif qReturnTimeout != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"return_timeout\", qReturnTimeout); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Scope != nil {\n\n\t\t// query param scope\n\t\tvar qrScope string\n\n\t\tif o.Scope != nil {\n\t\t\tqrScope = *o.Scope\n\t\t}\n\t\tqScope := qrScope\n\t\tif qScope != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"scope\", qScope); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Server != nil {\n\n\t\t// query param server\n\t\tvar qrServer string\n\n\t\tif o.Server != nil {\n\t\t\tqrServer = *o.Server\n\t\t}\n\t\tqServer := qrServer\n\t\tif qServer != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"server\", qServer); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ServerSideEncryption != nil {\n\n\t\t// query param server_side_encryption\n\t\tvar qrServerSideEncryption string\n\n\t\tif o.ServerSideEncryption != nil {\n\t\t\tqrServerSideEncryption = *o.ServerSideEncryption\n\t\t}\n\t\tqServerSideEncryption := qrServerSideEncryption\n\t\tif qServerSideEncryption != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"server_side_encryption\", qServerSideEncryption); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.SnapmirrorUse != nil {\n\n\t\t// query param snapmirror_use\n\t\tvar qrSnapmirrorUse string\n\n\t\tif o.SnapmirrorUse != nil {\n\t\t\tqrSnapmirrorUse = *o.SnapmirrorUse\n\t\t}\n\t\tqSnapmirrorUse := qrSnapmirrorUse\n\t\tif qSnapmirrorUse != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"snapmirror_use\", qSnapmirrorUse); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.SslEnabled != nil {\n\n\t\t// query param ssl_enabled\n\t\tvar qrSslEnabled bool\n\n\t\tif o.SslEnabled != nil {\n\t\t\tqrSslEnabled = *o.SslEnabled\n\t\t}\n\t\tqSslEnabled := swag.FormatBool(qrSslEnabled)\n\t\tif qSslEnabled != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ssl_enabled\", qSslEnabled); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.SvmName != nil {\n\n\t\t// query param svm.name\n\t\tvar qrSvmName string\n\n\t\tif o.SvmName != nil {\n\t\t\tqrSvmName = *o.SvmName\n\t\t}\n\t\tqSvmName := qrSvmName\n\t\tif qSvmName != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"svm.name\", qSvmName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.SvmUUID != nil {\n\n\t\t// query param svm.uuid\n\t\tvar qrSvmUUID string\n\n\t\tif o.SvmUUID != nil {\n\t\t\tqrSvmUUID = *o.SvmUUID\n\t\t}\n\t\tqSvmUUID := qrSvmUUID\n\t\tif qSvmUUID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"svm.uuid\", qSvmUUID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.URLStyle != nil {\n\n\t\t// query param url_style\n\t\tvar qrURLStyle string\n\n\t\tif o.URLStyle != nil {\n\t\t\tqrURLStyle = *o.URLStyle\n\t\t}\n\t\tqURLStyle := qrURLStyle\n\t\tif qURLStyle != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"url_style\", qURLStyle); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.UseHTTPProxy != nil {\n\n\t\t// query param use_http_proxy\n\t\tvar qrUseHTTPProxy bool\n\n\t\tif o.UseHTTPProxy != nil {\n\t\t\tqrUseHTTPProxy = *o.UseHTTPProxy\n\t\t}\n\t\tqUseHTTPProxy := swag.FormatBool(qrUseHTTPProxy)\n\t\tif qUseHTTPProxy != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"use_http_proxy\", qUseHTTPProxy); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Used != nil {\n\n\t\t// query param used\n\t\tvar qrUsed int64\n\n\t\tif o.Used != nil {\n\t\t\tqrUsed = *o.Used\n\t\t}\n\t\tqUsed := swag.FormatInt64(qrUsed)\n\t\tif qUsed != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"used\", qUsed); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.UUID != nil {\n\n\t\t// query param uuid\n\t\tvar qrUUID string\n\n\t\tif o.UUID != nil {\n\t\t\tqrUUID = *o.UUID\n\t\t}\n\t\tqUUID := qrUUID\n\t\tif qUUID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"uuid\", qUUID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "173977d290de1bb764b96cda4f2e38c0", "score": "0.66306597", "text": "func (o *QueryIOCsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.CreatedBy != nil {\n\n\t\t// query param created_by\n\t\tvar qrCreatedBy string\n\n\t\tif o.CreatedBy != nil {\n\t\t\tqrCreatedBy = *o.CreatedBy\n\t\t}\n\t\tqCreatedBy := qrCreatedBy\n\t\tif qCreatedBy != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"created_by\", qCreatedBy); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.DeletedBy != nil {\n\n\t\t// query param deleted_by\n\t\tvar qrDeletedBy string\n\n\t\tif o.DeletedBy != nil {\n\t\t\tqrDeletedBy = *o.DeletedBy\n\t\t}\n\t\tqDeletedBy := qrDeletedBy\n\t\tif qDeletedBy != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"deleted_by\", qDeletedBy); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.FromExpirationTimestamp != nil {\n\n\t\t// query param from.expiration_timestamp\n\t\tvar qrFromExpirationTimestamp string\n\n\t\tif o.FromExpirationTimestamp != nil {\n\t\t\tqrFromExpirationTimestamp = *o.FromExpirationTimestamp\n\t\t}\n\t\tqFromExpirationTimestamp := qrFromExpirationTimestamp\n\t\tif qFromExpirationTimestamp != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"from.expiration_timestamp\", qFromExpirationTimestamp); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.IncludeDeleted != nil {\n\n\t\t// query param include_deleted\n\t\tvar qrIncludeDeleted string\n\n\t\tif o.IncludeDeleted != nil {\n\t\t\tqrIncludeDeleted = *o.IncludeDeleted\n\t\t}\n\t\tqIncludeDeleted := qrIncludeDeleted\n\t\tif qIncludeDeleted != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"include_deleted\", qIncludeDeleted); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Policies != nil {\n\n\t\t// query param policies\n\t\tvar qrPolicies string\n\n\t\tif o.Policies != nil {\n\t\t\tqrPolicies = *o.Policies\n\t\t}\n\t\tqPolicies := qrPolicies\n\t\tif qPolicies != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"policies\", qPolicies); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ShareLevels != nil {\n\n\t\t// query param share_levels\n\t\tvar qrShareLevels string\n\n\t\tif o.ShareLevels != nil {\n\t\t\tqrShareLevels = *o.ShareLevels\n\t\t}\n\t\tqShareLevels := qrShareLevels\n\t\tif qShareLevels != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"share_levels\", qShareLevels); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Sources != nil {\n\n\t\t// query param sources\n\t\tvar qrSources string\n\n\t\tif o.Sources != nil {\n\t\t\tqrSources = *o.Sources\n\t\t}\n\t\tqSources := qrSources\n\t\tif qSources != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"sources\", qSources); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ToExpirationTimestamp != nil {\n\n\t\t// query param to.expiration_timestamp\n\t\tvar qrToExpirationTimestamp string\n\n\t\tif o.ToExpirationTimestamp != nil {\n\t\t\tqrToExpirationTimestamp = *o.ToExpirationTimestamp\n\t\t}\n\t\tqToExpirationTimestamp := qrToExpirationTimestamp\n\t\tif qToExpirationTimestamp != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"to.expiration_timestamp\", qToExpirationTimestamp); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Types != nil {\n\n\t\t// query param types\n\t\tvar qrTypes string\n\n\t\tif o.Types != nil {\n\t\t\tqrTypes = *o.Types\n\t\t}\n\t\tqTypes := qrTypes\n\t\tif qTypes != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"types\", qTypes); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Values != nil {\n\n\t\t// query param values\n\t\tvar qrValues string\n\n\t\tif o.Values != nil {\n\t\t\tqrValues = *o.Values\n\t\t}\n\t\tqValues := qrValues\n\t\tif qValues != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"values\", qValues); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "5a8b32ee41f199ff9be9524a78c089bc", "score": "0.6626234", "text": "func (o *RegisterUsingPUTParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID.String()); err != nil {\n\t\treturn err\n\t}\n\tif o.NamespaceState != nil {\n\t\tif err := r.SetBodyParam(o.NamespaceState); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "609bd5831541bfb5a44d72917e8ef9c1", "score": "0.6625113", "text": "func (o *PatchDCParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Patch != nil {\n\t\tif err := r.SetBodyParam(o.Patch); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param dc\n\tif err := r.SetPathParam(\"dc\", o.DCToPatch); err != nil {\n\t\treturn err\n\t}\n\n\t// path param seed_name\n\tif err := r.SetPathParam(\"seed_name\", o.Seed); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "9c4d797024f1a34e8e03832a1a0e791b", "score": "0.66206205", "text": "func (o *CreateWorkflowParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param namespace\n\tif err := r.SetPathParam(\"namespace\", o.Namespace); err != nil {\n\t\treturn err\n\t}\n\n\t// query param op\n\tqrOp := o.Op\n\tqOp := qrOp\n\tif qOp != \"\" {\n\n\t\tif err := r.SetQueryParam(\"op\", qOp); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param workflow\n\tif err := r.SetPathParam(\"workflow\", o.Workflow); err != nil {\n\t\treturn err\n\t}\n\tif err := r.SetBodyParam(o.WorkflowData); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "0154509d1d3c0a447f43a522dca9b469", "score": "0.6615323", "text": "func (o *CreateGetThumbnailsFormEncodedParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tr.SetTimeout(o.timeout)\n\tvar res []error\n\n\tif o.Accept != nil {\n\n\t\t// query param Accept\n\t\tvar qrAccept string\n\t\tif o.Accept != nil {\n\t\t\tqrAccept = *o.Accept\n\t\t}\n\t\tqAccept := qrAccept\n\t\tif qAccept != \"\" {\n\t\t\tif err := r.SetQueryParam(\"Accept\", qAccept); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.DefaultAllowed != nil {\n\n\t\t// query param defaultAllowed\n\t\tvar qrDefaultAllowed bool\n\t\tif o.DefaultAllowed != nil {\n\t\t\tqrDefaultAllowed = *o.DefaultAllowed\n\t\t}\n\t\tqDefaultAllowed := swag.FormatBool(qrDefaultAllowed)\n\t\tif qDefaultAllowed != \"\" {\n\t\t\tif err := r.SetQueryParam(\"defaultAllowed\", qDefaultAllowed); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "d1313e5afc0e611bf35ece4edfb45c94", "score": "0.6613047", "text": "func (o *LunMapCreateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.AdditionalReportingNodeName != nil {\n\n\t\t// query param additional_reporting_node.name\n\t\tvar qrAdditionalReportingNodeName string\n\n\t\tif o.AdditionalReportingNodeName != nil {\n\t\t\tqrAdditionalReportingNodeName = *o.AdditionalReportingNodeName\n\t\t}\n\t\tqAdditionalReportingNodeName := qrAdditionalReportingNodeName\n\t\tif qAdditionalReportingNodeName != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"additional_reporting_node.name\", qAdditionalReportingNodeName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.AdditionalReportingNodeUUID != nil {\n\n\t\t// query param additional_reporting_node.uuid\n\t\tvar qrAdditionalReportingNodeUUID string\n\n\t\tif o.AdditionalReportingNodeUUID != nil {\n\t\t\tqrAdditionalReportingNodeUUID = *o.AdditionalReportingNodeUUID\n\t\t}\n\t\tqAdditionalReportingNodeUUID := qrAdditionalReportingNodeUUID\n\t\tif qAdditionalReportingNodeUUID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"additional_reporting_node.uuid\", qAdditionalReportingNodeUUID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\tif o.Info != nil {\n\t\tif err := r.SetBodyParam(o.Info); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.ReturnRecords != nil {\n\n\t\t// query param return_records\n\t\tvar qrReturnRecords bool\n\n\t\tif o.ReturnRecords != nil {\n\t\t\tqrReturnRecords = *o.ReturnRecords\n\t\t}\n\t\tqReturnRecords := swag.FormatBool(qrReturnRecords)\n\t\tif qReturnRecords != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"return_records\", qReturnRecords); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "57f85af3f84a000ed15a025ca5e36d89", "score": "0.6613045", "text": "func (o *ReplaceTemplateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param api-version\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\tif qAPIVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"api-version\", qAPIVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param organization\n\tif err := r.SetPathParam(\"organization\", o.Organization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param project\n\tif err := r.SetPathParam(\"project\", o.Project); err != nil {\n\t\treturn err\n\t}\n\n\t// path param team\n\tif err := r.SetPathParam(\"team\", o.Team); err != nil {\n\t\treturn err\n\t}\n\n\t// path param templateId\n\tif err := r.SetPathParam(\"templateId\", o.TemplateID.String()); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "db6585320b6769f429be083d0934ca4c", "score": "0.6606277", "text": "func (o *EmployeeNextOfKinPostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "e237f7b2e1dd67873eed40e97b2f6686", "score": "0.6602107", "text": "func (o *FoodWeightNamesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param foodId\n\tif err := r.SetPathParam(\"foodId\", swag.FormatInt32(o.FoodID)); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "f9972f2fff85fd89960fee32dc6bd16a", "score": "0.659938", "text": "func (o *GetSearchUsersParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.After != nil {\n\n\t\t// query param after\n\t\tvar qrAfter int64\n\t\tif o.After != nil {\n\t\t\tqrAfter = *o.After\n\t\t}\n\t\tqAfter := swag.FormatInt64(qrAfter)\n\t\tif qAfter != \"\" {\n\t\t\tif err := r.SetQueryParam(\"after\", qAfter); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param environmentKey\n\tif err := r.SetPathParam(\"environmentKey\", o.EnvironmentKey); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int64\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt64(qrLimit)\n\t\tif qLimit != \"\" {\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Offset != nil {\n\n\t\t// query param offset\n\t\tvar qrOffset int64\n\t\tif o.Offset != nil {\n\t\t\tqrOffset = *o.Offset\n\t\t}\n\t\tqOffset := swag.FormatInt64(qrOffset)\n\t\tif qOffset != \"\" {\n\t\t\tif err := r.SetQueryParam(\"offset\", qOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param projectKey\n\tif err := r.SetPathParam(\"projectKey\", o.ProjectKey); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Q != nil {\n\n\t\t// query param q\n\t\tvar qrQ string\n\t\tif o.Q != nil {\n\t\t\tqrQ = *o.Q\n\t\t}\n\t\tqQ := qrQ\n\t\tif qQ != \"\" {\n\t\t\tif err := r.SetQueryParam(\"q\", qQ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "82cc79a94484ea9c9be58e9f1c7eda0f", "score": "0.6596722", "text": "func (o *DescribeTCPLbParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param tl\n\tif err := r.SetPathParam(\"tl\", o.Tl); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "title": "" } ]
5e4d8c3d46bf2546d96b57048009eed4
Union connect p and q
[ { "docid": "e8a26506300d83413fd63962e32946b1", "score": "0.73244655", "text": "func (qu *QuickUnion) Union(p int, q int) error {\n\tif p < 0 || q < 0 {\n\t\treturn errors.New(\"p and q must be greater or equal to 0\")\n\t}\n\tif p > len(qu.ids) || q > len(qu.ids) {\n\t\treturn fmt.Errorf(\"p and q must be smaller or equal to %d\", len(qu.ids))\n\t}\n\tpRoot := qu.findRoot(p)\n\tqRoot := qu.findRoot(q)\n\tqu.ids[pRoot] = qRoot\n\treturn nil\n}", "title": "" } ]
[ { "docid": "ff5be4ed50be8525e292f1639aee85b1", "score": "0.7430226", "text": "func Union(p, q int) {\n\tpid := id[p]\n\tqid := id[q]\n\n\tfor i := range id {\n\t\tif id[i] == pid {\n\t\t\tid[i] = qid\n\t\t}\n\t}\n}", "title": "" }, { "docid": "fc62665183a9bb6ee4abac745ece1fb2", "score": "0.7306076", "text": "func (qf *QuickFind) Union(p uint64, q uint64) {\n\tpid := qf.ID[p]\n\tqid := qf.ID[q]\n\n\tfor i := range qf.ID {\n\t\tif qf.ID[i] == pid {\n\t\t\tqf.ID[i] = qid\n\t\t}\n\t}\n}", "title": "" }, { "docid": "f2309baed4b11353f1e81dac2d6f75af", "score": "0.6831706", "text": "func (uf *UnionFind) Union(p int, q int) {\n\trootP := uf.Root(p)\n\trootQ := uf.Root(q)\n\n\tif rootP == rootQ {\n\t\treturn\n\t}\n\n\tif uf.size[rootP] < uf.size[rootQ] {\n\t\tuf.store[rootP] = rootQ\n\t\tuf.size[rootP] += uf.size[rootQ]\n\t} else {\n\t\tuf.store[rootQ] = rootP\n\t\tuf.size[rootQ] += uf.size[rootP]\n\t}\n\tuf.count--\n}", "title": "" }, { "docid": "a3e11cba0193996852cc8e728380423b", "score": "0.6660194", "text": "func (uf *UnionFind) Union(p, q int) {\n\trootP := uf.Find(p)\n\trootQ := uf.Find(q)\n\tif rootP == rootQ {\n\t\treturn\n\t}\n\tif uf.rank[rootP] < uf.rank[rootQ] {\n\t\tuf.parent[rootP] = rootQ\n\t} else if uf.rank[rootQ] < uf.rank[rootP] {\n\t\tuf.parent[rootQ] = rootP\n\t} else {\n\t\tuf.parent[rootQ] = rootP\n\t\tuf.rank[rootP]++\n\t}\n\tuf.count--\n}", "title": "" }, { "docid": "58239322532b94123bc2e82dbaa671be", "score": "0.6599259", "text": "func (qu *UnionFindMax) Union(p int, q int) {\n\trootP := qu.getRoot(p)\n\trootQ := qu.getRoot(q)\n\n\tmaxPQ := func() int {\n\t\tif qu.maxArr[rootP] > qu.maxArr[rootQ] {\n\t\t\treturn qu.maxArr[rootP]\n\t\t}\n\t\treturn qu.maxArr[rootQ]\n\t}()\n\n\tif qu.sizeArr[p] < qu.sizeArr[q] {\n\t\tqu.rootArr[rootP] = rootQ\n\t\tqu.sizeArr[rootQ] = qu.sizeArr[rootQ] + qu.sizeArr[rootP]\n\t\tqu.maxArr[rootQ] = maxPQ\n\t} else {\n\t\tqu.rootArr[rootQ] = rootP\n\t\tqu.sizeArr[rootP] = qu.sizeArr[rootP] + qu.sizeArr[rootQ]\n\t\tqu.maxArr[rootP] = maxPQ\n\n\t}\n}", "title": "" }, { "docid": "ef6472be21e33fe86ffb8a03bacf55f4", "score": "0.64909464", "text": "func (qu quickUnion) unite(p, q int) {\n\ti := qu.root(p)\n\tj := qu.root(q)\n\tif qu.sz[i] < qu.sz[j] {\n\t\tqu.ID[i] = j\n\t\tqu.sz[j] += qu.sz[i]\n\t} else {\n\t\tqu.ID[j] = i\n\t\tqu.sz[i] += qu.sz[j]\n\t}\n}", "title": "" }, { "docid": "1f4700eb8c0c09230931564848c7573e", "score": "0.5836876", "text": "func (s *DisJointSet) Union(i, j int) {\n\t// Root node of i, j\n\tiRoot := s.Find(i)\n\tjRoot := s.Find(j)\n\t// Elements are in the same set, no need to unite anything.\n\tif iRoot == jRoot {\n\t\treturn\n\t}\n\n\t// Rank of i, j's tree\n iRank := s.rank[iRoot]\n jRank := s.rank[jRoot]\n\n\ts.setCount--\n\n\t// If i's rank is less than j's rank\n\tif iRank < jRank {\n\t\t// Then move i under j\n\t\ts.parent[iRoot] = jRoot\n\t\ts.sizeOfSet[jRoot] += s.sizeOfSet[iRoot]\n\t} else if jRank < iRank {\n\t\t// Then move j under i\n\t\ts.parent[jRoot] = iRoot\n\t\ts.sizeOfSet[iRoot] += s.sizeOfSet[jRoot]\n\t} else { // Same rank\n\t\t// Then move i under j (doesn't matter which one goes where)\n\t\ts.parent[iRoot] = jRoot\n\t\ts.sizeOfSet[jRoot] += s.sizeOfSet[iRoot]\n\t\t// And increment the the result tree's rank by 1\n\t\ts.rank[iRoot]++\n\t}\n}", "title": "" }, { "docid": "48dba203f05f1c93c07e6de46de713ec", "score": "0.5809764", "text": "func Union(u Interface, a, b interface{}) {\n\taa := Find(u, a)\n\tbb := Find(u, b)\n\n\tif g, ok := u.(RankInterface); ok {\n\t\tra := g.GetRank(aa)\n\t\trb := g.GetRank(bb)\n\t\tif ra > rb {\n\t\t\tu.SetParent(bb, aa)\n\t\t} else if ra < rb {\n\t\t\tu.SetParent(aa, bb)\n\t\t} else {\n\t\t\tg.SetRank(aa, ra+1)\n\t\t\tu.SetParent(bb, aa)\n\t\t}\n\t} else {\n\t\tu.SetParent(aa, bb)\n\t}\n}", "title": "" }, { "docid": "66dfcc3f5feff5ee9c97b07da91a4342", "score": "0.5801811", "text": "func (ss stateSet) union(other stateSet) {\n\tfor q := range other {\n\t\tss[q] = true\n\t}\n}", "title": "" }, { "docid": "3fca7697584d29e901e219c74415c992", "score": "0.5726773", "text": "func union(e1, e2 *element) {\n\t// Ensure the two elements aren't already part of the same union.\n\te1Root := e1.find()\n\te2Root := e2.find()\n\tif e1Root == e2Root {\n\t\treturn\n\t}\n\n\t// Create a union by making the shorter tree point to the root of the\n\t// larger tree.\n\tswitch {\n\tcase e1Root.rank < e2Root.rank:\n\t\te1Root.parent = e2Root\n\tcase e1Root.rank > e2Root.rank:\n\t\te2Root.parent = e1Root\n\tdefault:\n\t\te2Root.parent = e1Root\n\t\te1Root.rank++\n\t}\n}", "title": "" }, { "docid": "baff0f90c28fabc920bb0642ff1e296b", "score": "0.5659257", "text": "func Union[E comparable, S ~[]E](x, y S) S {\n\tif len(x) == 0 {\n\t\treturn slices.Clip(y) // so append won't share\n\t}\n\tif len(y) == 0 {\n\t\treturn slices.Clip(x) // so append won't share\n\t}\n\tz := make(S, 0, len(x)+len(y))\n\tz = append(z, x...)\nouter:\n\tfor _, ye := range y {\n\t\tfor _, xe := range x {\n\t\t\tif xe == ye {\n\t\t\t\tcontinue outer\n\t\t\t}\n\t\t}\n\t\tz = append(z, ye)\n\t}\n\treturn z\n}", "title": "" }, { "docid": "eeb55f56cfd91f4f05376d0e8e8f4efc", "score": "0.5632336", "text": "func (set *LockSet) Union(o *LockSet) *LockSet {\n\tvar new big.Int\n\tnew.AndNot(&o.bits, &set.bits)\n\tif new.Sign() == 0 {\n\t\t// Nothing to add.\n\t\treturn set\n\t}\n\n\tout := set.clone().withLCA(o.lca)\n\tout.bits.Or(&out.bits, &o.bits)\n\tfor k, v := range o.stacks {\n\t\tif out.stacks[k] == nil {\n\t\t\tout.stacks[k] = v\n\t\t}\n\t}\n\treturn out\n}", "title": "" }, { "docid": "949156177eaa1162d752b217386ff6ce", "score": "0.5629402", "text": "func Union(left geom.T, right geom.T) (geom.T, error) {\n\tleftChain := InitChain(left)\n\treturn leftChain.Union(InitChain(right)).Execute()\n}", "title": "" }, { "docid": "5c108b620de0a6ced2089281ea461367", "score": "0.5579748", "text": "func (t Term) Union(args ...interface{}) Term {\n\treturn constructMethodTerm(t, \"Union\", p.Term_UNION, args, map[string]interface{}{})\n}", "title": "" }, { "docid": "d2a97aecc8e111f79b64b302c6ae74da", "score": "0.55402184", "text": "func (u *DisjointSet) Union(x, y int) bool {\n\tx, y = u.find(x), u.find(y)\n\tif x == y {\n\t\treturn false\n\t}\n\tif u.parent[x] > u.parent[y] {\n\t\tx, y = y, x\n\t}\n\tu.parent[x] += u.parent[y]\n\tu.parent[y] = x\n\tu.count--\n\treturn true\n}", "title": "" }, { "docid": "418fcabe71c3efbc25b5e08f6885ae48", "score": "0.55133873", "text": "func Union(x, y *Vertex) {\n\tswitch {\n\tcase x.rank < y.rank:\n\t\tx.leader = y\n\t\tdelete(LeaderMap, x.val)\n\tcase x.rank == y.rank:\n\t\tx.rank++\n\t\tfallthrough\n\tcase x.rank > y.rank:\n\t\ty.leader = x\n\t\tdelete(LeaderMap, y.val)\n\t}\n}", "title": "" }, { "docid": "38bafb0682d3476ad697818f2f1ac566", "score": "0.54939234", "text": "func (set DisjointIDSet) Union(id1, id2 string) {\n\tset.getOrCreateSet(id1).Add(id2)\n\tset.getOrCreateSet(id2).Add(id1)\n}", "title": "" }, { "docid": "e959b2f395fc69364b8f83381eba9b0e", "score": "0.54756016", "text": "func (s podSet) Union(o podSet) podSet {\n\tresult := podSet{}\n\tfor key := range s {\n\t\tresult.Insert(key)\n\t}\n\tfor key := range o {\n\t\tresult.Insert(key)\n\t}\n\treturn result\n}", "title": "" }, { "docid": "1e902d73e030b0689161f6258e42fe46", "score": "0.54670435", "text": "func (p *qProp) combine(q qProp) {\n\tswitch {\n\tcase p.err != nil:\n\t\t// Do nothing\n\tcase q.err != nil:\n\t\tp.err = q.err\n\tdefault:\n\t\tp.isAggregation = p.isAggregation || q.isAggregation\n\t\tp.isRowFunc = p.isRowFunc || q.isRowFunc\n\t\tif p.isAggregation && p.isRowFunc {\n\t\t\tp.err = errNestedAggregation\n\t\t}\n\t}\n}", "title": "" }, { "docid": "0aa7ab1cc97957097383a1202b72db2a", "score": "0.5461799", "text": "func (qg *queryGenerator) createUnion() {\n\tunion := &sqlparser.Union{}\n\n\tif qg.selGen.r.Intn(2) < 1 {\n\t\tunion.Distinct = true\n\t}\n\n\t// specify between 1-4 columns\n\tqg.selGen.genConfig.NumCols = qg.selGen.r.Intn(4) + 1\n\n\tqg.randomQuery()\n\tunion.Left = qg.stmt\n\tqg.randomQuery()\n\tunion.Right = qg.stmt\n\n\tqg.stmt = union\n}", "title": "" }, { "docid": "0f2ef5bc6f081278bd92d9d3c47e1d4c", "score": "0.5460854", "text": "func Union(args ...interface{}) Term {\n\treturn constructRootTerm(\"Union\", p.Term_UNION, args, map[string]interface{}{})\n}", "title": "" }, { "docid": "89bee29ab17904567aebba29ba974617", "score": "0.5459094", "text": "func (u *SparseUnionFind) Union(x, y int) {\n\tu.Create(x)\n\tu.Create(y)\n\txx, yy := u.find(x), u.find(y)\n\tif xx == yy {\n\t\treturn\n\t}\n\tif u.parent[x] > u.parent[y] {\n\t\tx, y = y, x\n\t}\n\tu.parent[x] += u.parent[y]\n\tu.parent[y] = x\n\tu.count--\n}", "title": "" }, { "docid": "8446a6617d4a874c97a0508dad2bad98", "score": "0.54432654", "text": "func union(lhs *Span, rhs *Span) *Span {\n\tif lhs != nil {\n\t\treturn lhs.union(rhs)\n\t}\n\tif rhs != nil {\n\t\treturn rhs\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "60709ce5b3166dc30cad316c8caf1f2b", "score": "0.54233354", "text": "func (set Set[T]) Union(other Set[T]) Set[T] {\n\tret := NewSet(set.Collect()...)\n\tret.Insert(other.Collect()...)\n\treturn ret\n}", "title": "" }, { "docid": "32f9b8ba9315d0f6841570a53fa8ee6c", "score": "0.5386998", "text": "func (ec *executionContext) _PubQ(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, pubQImplementors)\n\n\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\tObject: \"PubQ\",\n\t})\n\n\tvar wg sync.WaitGroup\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\n\tfor i, field := range fields {\n\t\tout.Keys[i] = field.Alias\n\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString(\"PubQ\")\n\t\tcase \"country\":\n\t\t\twg.Add(1)\n\t\t\tgo func(i int, field graphql.CollectedField) {\n\t\t\t\tout.Values[i] = ec._PubQ_country(ctx, field)\n\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\tinvalid = true\n\t\t\t\t}\n\t\t\t\twg.Done()\n\t\t\t}(i, field)\n\t\tcase \"__type\":\n\t\t\tout.Values[i] = ec._PubQ___type(ctx, field)\n\t\tcase \"__schema\":\n\t\t\tout.Values[i] = ec._PubQ___schema(ctx, field)\n\t\tdefault:\n\t\t\tpanic(\"unknown field \" + strconv.Quote(field.Name))\n\t\t}\n\t}\n\twg.Wait()\n\tif invalid {\n\t\treturn graphql.Null\n\t}\n\treturn out\n}", "title": "" }, { "docid": "54652ed71f2948ca20e1099291ea1725", "score": "0.5373507", "text": "func (h *HLL) Union(other *HLL) error {\n\tif h.P != other.P {\n\t\treturn ErrSameP\n\t}\n\tif other.format == NORMAL {\n\t\tif h.format == SPARSE {\n\t\t\th.ToNormal()\n\t\t}\n\t\tfor i := uint(0); i < h.m1; i++ {\n\t\t\tif other.registers[i] > h.registers[i] {\n\t\t\t\th.registers[i] = other.registers[i]\n\t\t\t}\n\t\t}\n\t} else if h.format == NORMAL && other.format == SPARSE {\n\t\tother.mergeSparse()\n\t\tfor _, value := range other.sparseList.Data {\n\t\t\tindex, rho := decodeHash(value, h.P)\n\t\t\tif h.registers[index] < rho {\n\t\t\t\th.registers[index] = rho\n\t\t\t}\n\t\t}\n\t} else if h.format == SPARSE && other.format == SPARSE {\n\t\th.mergeSparse()\n\t\tother.mergeSparse()\n\t\th.sparseList.Merge(other.sparseList)\n\t\th.checkModeChange()\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "45283afd1c72881067258d683ff53706", "score": "0.53681886", "text": "func (p Pt) Add(q Pt) Pt {\n\treturn Pt{p.L + q.L, p.O + q.O}\n}", "title": "" }, { "docid": "7ffa0931122dac535e926d4bfb63c0bb", "score": "0.53592193", "text": "func (c Circ) Union(o Circ) Circ {\n\td := c.C.To(o.C)\n\tl := d.Len()\n\n\tc.C.AddE(Rad(d.Angle(), l*.5+o.R-c.R))\n\tc.R += l + o.R\n\n\treturn c\n}", "title": "" }, { "docid": "74a45760b6cf393dd912756b9cf48406", "score": "0.53158176", "text": "func Union(mD chan *Element, nD chan *Element) chan *Element {\n\tout := make(chan *Element)\n\tgo func() {\n\t\tdefer close(out)\n\n\t\trecvM := recv(mD)\n\t\trecvN := recv(nD)\n\n\t\tmHi, mMore := recvM()\n\t\tnHi, nMore := recvN()\n\n\t\tfor mMore || nMore {\n\t\t\tswitch {\n\t\t\tcase mHi.LessThan(nHi):\n\t\t\t\tout <- mHi\n\t\t\t\tmHi, mMore = recvM()\n\n\t\t\tcase nHi.LessThan(mHi):\n\t\t\t\tout <- nHi\n\t\t\t\tnHi, nMore = recvN()\n\n\t\t\tcase mHi.Equals(nHi):\n\t\t\t\tout <- mHi\n\t\t\t\tmHi, mMore = recvM()\n\t\t\t\tnHi, nMore = recvN()\n\n\t\t\tcase mMore:\n\t\t\t\tout <- mHi\n\t\t\t\tmHi, mMore = recvM()\n\n\t\t\tcase nMore:\n\t\t\t\tout <- nHi\n\t\t\t\tnHi, nMore = recvN()\n\n\t\t\tdefault:\n\t\t\t\tpanic(\"assumption violation: comparison semantics have changed\")\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn out\n}", "title": "" }, { "docid": "37fac1bf0bdfc41579b70b15d2b02d28", "score": "0.5271344", "text": "func (self *Set) union(other Set) Set {\n\tfor key, _ := range self.items {\n\t\tother.add(key)\n\t}\n\treturn other\n}", "title": "" }, { "docid": "2ac01efd6a03a2ac3ccaf0d4f9a0f2f2", "score": "0.52607477", "text": "func (l TagValues) Union(r TagValues) {\n\tfor v, _ := range r {\n\t\tl[v] = true\n\t}\n}", "title": "" }, { "docid": "1119128a368b3b912af6204fd15983c1", "score": "0.52575046", "text": "func TestUnion(t *T) {\n\t// Degenerate case\n\tempty := NewSet()\n\tassertEmpty(empty.Union(empty), t)\n\n\tints1 := []interface{}{0, 1, 2}\n\tints2 := []interface{}{3, 4, 5}\n\tintsu := append(ints1, ints2...)\n\ts1 := NewSet(ints1...)\n\ts2 := NewSet(ints2...)\n\n\tassertSeqContentsSet(s1.Union(empty), ints1, t)\n\tassertSeqContentsSet(empty.Union(s1), ints1, t)\n\n\tsu := s1.Union(s2)\n\tassertSeqContentsSet(s1, ints1, t)\n\tassertSeqContentsSet(s2, ints2, t)\n\tassertSeqContentsSet(su, intsu, t)\n}", "title": "" }, { "docid": "8c6fb918151b9d35fad387d0d9905b38", "score": "0.5240711", "text": "func (s *HashSet[T, H]) Union(o *HashSet[T, H]) *HashSet[T, H] {\n\tresult := NewHashSet[T, H](s.Size())\n\tfor key, item := range s.items {\n\t\tresult.items[key] = item\n\t}\n\tfor key, item := range o.items {\n\t\tresult.items[key] = item\n\t}\n\treturn result\n}", "title": "" }, { "docid": "c3e6308b8686e71886e32c0d8f7eea7c", "score": "0.5239615", "text": "func Union(s1, s2 Set) Set {\n\tif len(s1) == 0 {\n\t\treturn s2\n\t}\n\n\tif len(s2) == 0 {\n\t\treturn s1\n\t}\n\n\tfor e2 := range s2 {\n\t\ts1.Add(e2)\n\t}\n\n\treturn s1\n}", "title": "" }, { "docid": "aa35ced0a735c36c769c5238be204ba6", "score": "0.52215815", "text": "func (s *Set) Union(s2 *Set) {\n\t*s = uniq_merge(*s, *s2)\n}", "title": "" }, { "docid": "d56091c7252d358035d7a678daa3355c", "score": "0.5186158", "text": "func ap(p PiIdent, q PiIdent, r PiIdent) Pi {\n\treturn PIn{\n\t\tChannel: q,\n\t\tValue: \"yy\",\n\t\tBody: PNew{\n\t\t\tName: \"vv\",\n\t\t\tBody: POut{\n\t\t\t\tChannel: \"yy\",\n\t\t\t\tValue: \"vv\",\n\t\t\t\tBody: PIn{\n\t\t\t\t\tChannel: r,\n\t\t\t\t\tValue: \"zz\",\n\t\t\t\t\tBody: POut{\n\t\t\t\t\t\tChannel: \"vv\",\n\t\t\t\t\t\tValue: \"zz\",\n\t\t\t\t\t\tBody: POut{\n\t\t\t\t\t\t\tChannel: \"vv\",\n\t\t\t\t\t\t\tValue: \"pp\",\n\t\t\t\t\t\t\tBody: PNull{},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n}", "title": "" }, { "docid": "8b3ca950c416aa5584de9a128a36cb4a", "score": "0.51805526", "text": "func (u *UnionFind) Union(a, b int) error {\n\tif a < 0 || a >= u.n {\n\t\treturn u.outOfBoundsError(a)\n\t}\n\tif b < 0 || b >= u.n {\n\t\treturn u.outOfBoundsError(b)\n\t}\n\trootA := u.root(a)\n\trootB := u.root(b)\n\tif u.size[rootA] < u.size[rootB] {\n\t\tu.arr[rootA] = u.arr[rootB]\n\t\tu.size[rootB] += u.size[rootA]\n\t} else {\n\t\tu.arr[rootB] = u.arr[rootA]\n\t\tu.size[rootA] += u.size[rootB]\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "6e0fe6320b81203492a0c4150c434d0e", "score": "0.5173176", "text": "func (s *PathElementSet) Union(s2 *PathElementSet) *PathElementSet {\n\tout := &PathElementSet{}\n\n\ti, j := 0, 0\n\tfor i < len(s.members) && j < len(s2.members) {\n\t\tif s.members[i].Less(s2.members[j]) {\n\t\t\tout.members = append(out.members, s.members[i])\n\t\t\ti++\n\t\t} else {\n\t\t\tout.members = append(out.members, s2.members[j])\n\t\t\tif !s2.members[j].Less(s.members[i]) {\n\t\t\t\ti++\n\t\t\t}\n\t\t\tj++\n\t\t}\n\t}\n\n\tif i < len(s.members) {\n\t\tout.members = append(out.members, s.members[i:]...)\n\t}\n\tif j < len(s2.members) {\n\t\tout.members = append(out.members, s2.members[j:]...)\n\t}\n\treturn out\n}", "title": "" }, { "docid": "c5bea586fe2b3d97f9ebdf73fe584f13", "score": "0.5162659", "text": "func Union(a, b geom.Geometry, opts ...geom.ConstructorOption) (geom.Geometry, error) {\n\treturn binaryOperation(a, b, opts, func(ctx C.GEOSContextHandle_t, a, b *C.GEOSGeometry) *C.GEOSGeometry {\n\t\treturn C.GEOSUnion_r(ctx, a, b)\n\t})\n}", "title": "" }, { "docid": "6ad4f2f1dedb99f984db972b86f54cdf", "score": "0.5150441", "text": "func (s *HashSet) Union(o Set) Set {\n\ts.CheckInit()\n\n\tresult := s.Copy()\n\n\to.Map(func(item interface{}) bool {\n\t\tresult.Insert(item)\n\t\treturn true\n\t})\n\n\treturn result\n}", "title": "" }, { "docid": "9a2f12ce95ebb3e13b75d91dcd43b9d8", "score": "0.51366526", "text": "func mergeRawQueries(q1, q2 string) string {\n\tif q1 == \"\" {\n\t\treturn q2\n\t}\n\tif q2 == \"\" {\n\t\treturn q1\n\t}\n\treturn q1 + \"&\" + q2\n}", "title": "" }, { "docid": "a3457366a9918de2e6ca27e925a38d8c", "score": "0.5120396", "text": "func (x *UnionFind) Union(i, j int) {\n\tx.Parent[x.Find(i)] = x.newIndex\n\tx.Parent[x.Find(j)] = x.newIndex\n\tx.newIndex++\n}", "title": "" }, { "docid": "aaacc9823c30dfd6ea44c13aa2bec958", "score": "0.5118665", "text": "func (s *Set) Union(t *Set) *Set {\n\tu := New()\n\tfor _, v := range s.Slice() {\n\t\tu.Add(v)\n\t}\n\tfor _, v := range t.Slice() {\n\t\tu.Add(v)\n\t}\n\treturn u\n}", "title": "" }, { "docid": "a9c90039c61088788df802ac37f53757", "score": "0.51185995", "text": "func (s *Selector) Union(t TableView) *Selector {\n\ts.setOps = append(s.setOps, setOp{\n\t\tType: setOpTypeUnion,\n\t\tTableView: t,\n\t})\n\treturn s\n}", "title": "" }, { "docid": "52623392907273ba8417f71693f237f4", "score": "0.51118743", "text": "func Union(set1, set2 *Set, setItems ...*Set) *Set {\n\tu := set1.Copy()\n\tfor item := range set2.m {\n\t\tu.Add(item)\n\t}\n\n\tfor _, setItem := range setItems {\n\t\tfor item := range setItem.m {\n\t\t\tu.Add(item)\n\t\t}\n\t}\n\treturn u\n}", "title": "" }, { "docid": "40e62b79bdca213863983b891fc2d684", "score": "0.5106203", "text": "func Union(selects ...squirrel.SelectBuilder) (squirrel.SelectBuilder, error) {\n\tfail := func(err error) (squirrel.SelectBuilder, error) {\n\t\treturn squirrel.SelectBuilder{}, err\n\t}\n\n\tif len(selects) == 0 {\n\t\treturn fail(ErrNoSelects)\n\t}\n\tif len(selects) == 1 {\n\t\treturn selects[0], nil\n\t}\n\n\tfirst := selects[0]\n\tselects = selects[1:]\n\n\tfor i, s := range selects {\n\t\tsql, args, err := s.ToSql()\n\t\tif err != nil {\n\t\t\treturn fail(InvalidUnionError{\n\t\t\t\tBaseError: err,\n\t\t\t\tIndex: i,\n\t\t\t})\n\t\t}\n\t\tfirst = first.Prefix(\"(\"+sql+\") UNION\", args...)\n\t}\n\treturn first, nil\n}", "title": "" }, { "docid": "97ac1a98606d846a4153cb1e952ab998", "score": "0.5081919", "text": "func (r Rect) Union(s Rect) Rect {\n\treturn R(\n\t\tmath.Min(r.Min.X, s.Min.X),\n\t\tmath.Min(r.Min.Y, s.Min.Y),\n\t\tmath.Max(r.Max.X, s.Max.X),\n\t\tmath.Max(r.Max.Y, s.Max.Y),\n\t)\n}", "title": "" }, { "docid": "23efdb4eabd176cf4225d4c20dda18d9", "score": "0.50558525", "text": "func NewUnion(left, right sql.Node, distinct bool, limit, offset sql.Expression, sortFields sql.SortFields) *Union {\n\treturn &Union{\n\t\tBinaryNode: BinaryNode{left: left, right: right},\n\t\tDistinct: distinct,\n\t\tLimit: limit,\n\t\tOffset: offset,\n\t\tSortFields: sortFields,\n\t}\n}", "title": "" }, { "docid": "259f3d8e6b1f3f2ed6e9fe3e5c951d5d", "score": "0.50316197", "text": "func (set TargetIDSet) Union(sset TargetIDSet) TargetIDSet {\n\tnset := set.Clone()\n\n\tfor k := range sset {\n\t\tnset.add(k)\n\t}\n\n\treturn nset\n}", "title": "" }, { "docid": "9edc8ef38e0fce33f2747c6f53375c4a", "score": "0.5030162", "text": "func Union(ssArgs ...StringerSet) StringerSet {\n\tu := New()\n\tfor _, ss := range ssArgs {\n\t\tfor m, _ := range ss {\n\t\t\tu[m] = struct{}{}\n\t\t}\n\t}\n\treturn u\n}", "title": "" }, { "docid": "9cec9f2dcecf64ffd6bd51ad3bec7804", "score": "0.5028866", "text": "func (qu quickUnion) find(p, q int) bool {\n\treturn qu.root(p) == qu.root(q)\n}", "title": "" }, { "docid": "2a3f6ca42bb834b8276262864e760d9d", "score": "0.50181174", "text": "func PointUnion(a, b []Point) []Point {\n\tvar res []Point\n\tfor _, aa := range a {\n\t\tif aa.X == 0 && aa.Y == 0 { // center doesn't count, the rules said so\n\t\t\tcontinue\n\t\t}\n\t\tfor _, bb := range b {\n\t\t\tif aa.X == bb.X && aa.Y == bb.Y {\n\t\t\t\tsteps := aa.Steps + bb.Steps\n\t\t\t\tp := Point{aa.X, bb.Y, steps}\n\t\t\t\tres = append(res, p)\n\t\t\t}\n\t\t}\n\t}\n\treturn res\n}", "title": "" }, { "docid": "9a588c63331293d135dd271c856e0ed6", "score": "0.5003939", "text": "func (s *Bitset) Union(b *Bitset) *Bitset {\n\treturn s.bitsetOp(\n\t\tb,\n\n\t\tfunc(s, b *Bitset, length *uint) {\n\t\t\tbl, l := s.Length(0), *length\n\n\t\t\tif bl < l {\n\t\t\t\ts.unsetTop()\n\t\t\t\ts.Length(l)\n\t\t\t} else if bl > l {\n\t\t\t\tb.unsetTop()\n\t\t\t}\n\t\t},\n\n\t\tfunc(s, b *Bitset, index uint) {\n\t\t\ts.set[index] |= b.set[index]\n\t\t},\n\t)\n}", "title": "" }, { "docid": "057572c4ea660d65f107b6115a725898", "score": "0.49969137", "text": "func (rs RegisterSet) regSetUnion(other RegisterSet) RegisterSet {\n\treturn rs | other\n}", "title": "" }, { "docid": "7c092473561fcf352e850adefd54285d", "score": "0.4993171", "text": "func (s Int8Set) Union(t Int8Set) Int8Set {\n\tr := make(Int8Set, len(s)+len(t))\n\tfor e := range s {\n\t\tr[e] = struct{}{}\n\t}\n\tfor e := range t {\n\t\tr[e] = struct{}{}\n\t}\n\treturn r\n}", "title": "" }, { "docid": "562b843609a6046162d756eb8e6c59d9", "score": "0.49892217", "text": "func (p Point) Add(q Point) Point {\n\treturn Point{p.X + q.X, p.Y + q.Y}\n}", "title": "" }, { "docid": "562b843609a6046162d756eb8e6c59d9", "score": "0.49892217", "text": "func (p Point) Add(q Point) Point {\n\treturn Point{p.X + q.X, p.Y + q.Y}\n}", "title": "" }, { "docid": "562b843609a6046162d756eb8e6c59d9", "score": "0.49892217", "text": "func (p Point) Add(q Point) Point {\n\treturn Point{p.X + q.X, p.Y + q.Y}\n}", "title": "" }, { "docid": "562b843609a6046162d756eb8e6c59d9", "score": "0.49892217", "text": "func (p Point) Add(q Point) Point {\n\treturn Point{p.X + q.X, p.Y + q.Y}\n}", "title": "" }, { "docid": "562b843609a6046162d756eb8e6c59d9", "score": "0.49892217", "text": "func (p Point) Add(q Point) Point {\n\treturn Point{p.X + q.X, p.Y + q.Y}\n}", "title": "" }, { "docid": "18377820e161790ed05605dc5de41448", "score": "0.49786478", "text": "func (ttts TTTSet) Union(other TTTSet) TTTSet {\n\tif len(ttts) == 0 {\n\t\treturn other\n\t}\n\tif len(other) == 0 {\n\t\treturn ttts\n\t}\n\tvar (\n\t\ti, j int\n\t\tresult TTTSet\n\t)\n\tfor i < len(ttts) && j < len(other) {\n\t\tswitch {\n\t\tcase ttts[i].Less(other[j]):\n\t\t\tresult = append(result, ttts[i])\n\t\t\ti++\n\t\tcase other[j].Less(ttts[i]):\n\t\t\tresult = append(result, other[j])\n\t\t\tj++\n\t\tdefault:\n\t\t\tresult = append(result, ttts[i])\n\t\t\ti++\n\t\t\tj++\n\t\t}\n\t}\n\tresult = append(result, ttts[i:]...)\n\tresult = append(result, other[j:]...)\n\treturn result\n}", "title": "" }, { "docid": "d0245e090b540230cffe7bf944cf7c06", "score": "0.49694026", "text": "func (s EntrySet) Union(r EntrySet) EntrySet {\n\tu := make(EntrySet)\n\tfor e := range s {\n\t\tu.Add(e)\n\t}\n\tfor e := range r {\n\t\tu.Add(e)\n\t}\n\treturn u\n}", "title": "" }, { "docid": "1d955d6eb5bdf309cb42fa76aef25575", "score": "0.49682185", "text": "func unionPrepare(tls *libc.TLS, pRc uintptr, db uintptr, zSql uintptr, pzErr uintptr) uintptr { /* unionvtab.c:341:21: */\n\tbp := tls.Alloc(16)\n\tdefer tls.Free(16)\n\n\t*(*uintptr)(unsafe.Pointer(bp + 8 /* pRet */)) = uintptr(0)\n\n\tif *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK {\n\t\tvar rc int32 = sqlite3.Xsqlite3_prepare_v2(tls, db, zSql, -1, bp+8 /* &pRet */, uintptr(0))\n\t\tif rc != SQLITE_OK {\n\t\t\t*(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+7894 /* \"sql error: %s\" */, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, db)))\n\t\t\t*(*int32)(unsafe.Pointer(pRc)) = rc\n\t\t}\n\t}\n\treturn *(*uintptr)(unsafe.Pointer(bp + 8 /* pRet */))\n}", "title": "" }, { "docid": "0fd436d7e45a662c573b9bdd16cc3390", "score": "0.49634442", "text": "func (s GroupMemberPodSet) Union(o GroupMemberPodSet) GroupMemberPodSet {\n\tresult := GroupMemberPodSet{}\n\tfor key, item := range s {\n\t\tresult[key] = item\n\t}\n\tfor key, item := range o {\n\t\tresult[key] = item\n\t}\n\treturn result\n}", "title": "" }, { "docid": "db8c78fb046d6a63f4ddb76b02738ee3", "score": "0.4955768", "text": "func (b Box2) Union(other Box2) Box2 {\n\tother.Min.SetMin(b.Min)\n\tother.Max.SetMax(b.Max)\n\treturn other\n}", "title": "" }, { "docid": "28462203743ff4ae0b0ce830014a2586", "score": "0.4950524", "text": "func (set NowaSet) Union(other NowaSet) NowaSet {\n\tunionedSet := NewNowaSet()\n\n\tfor elem := range set {\n\t\tunionedSet.Add(elem)\n\t}\n\tfor elem := range other {\n\t\tunionedSet.Add(elem)\n\t}\n\treturn unionedSet\n}", "title": "" }, { "docid": "0404152ef39c8282cee66662616beb6b", "score": "0.4944332", "text": "func (this *Set) Union(other *Set) *Set {\n\tres := EmptySet()\n\tfor k, _ := range this.elements {\n\t\tres.Add(k)\n\t}\n\tfor k, _ := range other.elements {\n\t\tres.Add(k)\n\t}\n\treturn res\n}", "title": "" }, { "docid": "490c7902a912f7bcf7a9a97e4d3d4375", "score": "0.4936648", "text": "func (h *Hll) Union(other Hll) {\n\tif err := h.union(other, false); err != nil {\n\t\t// since the above union call passes false to strict, the only way an\n\t\t// error could pop up would be due to a bug in code. handling\n\t\t// explicitly nonetheless b/c it was flagged by gosec.\n\t\tpanic(err)\n\t}\n}", "title": "" }, { "docid": "8ba568995e1176db2469f669480dfea8", "score": "0.4935639", "text": "func (s *Set) Union(g *Set) *Set {\n\tunion := NewEmptySet(len(s.values) + len(g.values))\n\n\tfor v := range s.values {\n\t\tunion.Add(v)\n\t}\n\n\tfor v := range g.values {\n\t\tunion.Add(v)\n\t}\n\n\treturn union\n}", "title": "" }, { "docid": "a12f861e3c31e6bf931bc3d599fea35c", "score": "0.49147668", "text": "func (set *Set) Union(s Seq) *Set {\n\tif set == nil {\n\t\treturn ToSet(s)\n\t}\n\n\tcset := set.clone()\n\tvar el interface{}\n\tvar ok bool\n\tfor {\n\t\tif el, s, ok = s.FirstRest(); !ok {\n\t\t\treturn cset\n\t\t} else if cset, ok = cset.SetVal(el); ok {\n\t\t\tcset.size++\n\t\t}\n\t}\n}", "title": "" }, { "docid": "52cfb407a37e8b57074ba785e7bd61b6", "score": "0.49127418", "text": "func (u *UnionFind) Union(a, b int) {\n\tbValue := u.Items[b]\n\taKey := a\n\tfor key, val := range u.Items {\n\t\tif val == bValue {\n\t\t\tu.Items[key] = aKey\n\t\t}\n\t}\n}", "title": "" }, { "docid": "b61afcb0252874c18309b32fcba51324", "score": "0.49040663", "text": "func getParamUnion(keyValArrAnnots whisk.KeyValueArr, keyValArrParams whisk.KeyValueArr, key string) []string {\n\tvar res []string\n\ttag := \"*\"\n\tif getValueBool(keyValArrAnnots, \"final\") {\n\t\ttag = \"**\"\n\t}\n\tboundParams := getKeys(keyValArrParams)\n\tannotatedParams := getChildValueStrings(keyValArrAnnots, \"parameters\", key)\n\tres = append(boundParams, annotatedParams...) // Create union of boundParams and annotatedParams with duplication\n\tfor i := 0; i < len(res); i++ {\n\t\tfor j := i + 1; j < len(res); j++ {\n\t\t\tif res[i] == res[j] {\n\t\t\t\tres = append(res[:j], res[j+1:]...) // Remove duplicate entry\n\t\t\t}\n\t\t}\n\t}\n\tsort.Strings(res)\n\tres = tagBoundParams(boundParams, res, tag)\n\treturn res\n}", "title": "" }, { "docid": "b666009e30afb916ea83bc80f5013212", "score": "0.49025038", "text": "func (F *FP4) qmul(s *FP) {\n\tF.a.pmul(s)\n\tF.b.pmul(s)\n}", "title": "" }, { "docid": "f50b1edba1f50effd755f2b54a8fdd69", "score": "0.4900146", "text": "func opTestUnion(lhit, inL, inR bool) bool {\n\treturn (lhit && !inR) || (!lhit && !inL)\n}", "title": "" }, { "docid": "ad87cf210412328be7ef8cbb96c8f1c8", "score": "0.4891484", "text": "func (d *Dataset) Union(other *Dataset) *Dataset {\n\treturn d.withCompound(exp.UnionCompoundType, other.CompoundFromSelf())\n}", "title": "" }, { "docid": "4719ec947007a96c39e9d42aac2cbf62", "score": "0.48881596", "text": "func (s *SeqSet) Union(other *SeqSet) *SeqSet {\n\tif s == nil {\n\t\treturn other\n\t}\n\tif other == nil {\n\t\treturn s\n\t}\n\tif s == ContainsAllSeqSet || other == ContainsAllSeqSet {\n\t\treturn ContainsAllSeqSet\n\t}\n\tunion := &SeqSet{}\n\tfor i := range union.subSeqSets {\n\t\tunion.subSeqSets[i] = s.subSeqSets[i].Union(other.subSeqSets[i])\n\t}\n\treturn union\n}", "title": "" }, { "docid": "af495d81486504a121112970613ab23c", "score": "0.4884059", "text": "func Or(queries ...Q) Q {\n\torRtvl := make(or, len(queries))\n\tfor index, q := range queries {\n\t\torRtvl[index] = q\n\t}\n\treturn &orRtvl\n}", "title": "" }, { "docid": "aaa69e2ce3a08880302d2db308b3ec2e", "score": "0.48839393", "text": "func (env Envelope) Union(other Envelope) Envelope {\n\tif env.IsInit() {\n\t\tenv.cval.MinX = min(env.cval.MinX, other.cval.MinX)\n\t\tenv.cval.MinY = min(env.cval.MinY, other.cval.MinY)\n\t\tenv.cval.MaxX = max(env.cval.MaxX, other.cval.MaxX)\n\t\tenv.cval.MaxY = max(env.cval.MaxY, other.cval.MaxY)\n\t} else {\n\t\tenv.cval.MinX = other.cval.MinX\n\t\tenv.cval.MinY = other.cval.MinY\n\t\tenv.cval.MaxX = other.cval.MaxX\n\t\tenv.cval.MaxY = other.cval.MaxY\n\t}\n\treturn env\n}", "title": "" }, { "docid": "4a1f2179cc00cd14d240e008ceb5bee8", "score": "0.48801756", "text": "func (ivt *intervalTree) Union(inIvt IntervalTree, ivl Interval) {\n\tf := func(n *IntervalValue) bool {\n\t\tivt.Insert(n.Ivl, n.Val)\n\t\treturn true\n\t}\n\tinIvt.Visit(ivl, f)\n}", "title": "" }, { "docid": "b2c62eb9c2865999108cda703df8a312", "score": "0.4877373", "text": "func (s1 Set) Union(s2 Set) Set {\n\tmustHaveSameRules(s1, s2)\n\trs := NewSet(s1.rules)\n\ts1.EachValue(func(v interface{}) {\n\t\trs.Add(v)\n\t})\n\ts2.EachValue(func(v interface{}) {\n\t\trs.Add(v)\n\t})\n\treturn rs\n}", "title": "" }, { "docid": "b091473d8ebe6010ed484b54241c197c", "score": "0.48630893", "text": "func (c *column) Union(dst *bitmap.Bitmap) {\n\tc.RLock()\n\tdst.Or(*c.Index())\n\tc.RUnlock()\n}", "title": "" }, { "docid": "94b4a48ffe5f03b43d312dac754568f2", "score": "0.48605633", "text": "func (b BBox) Union(other BBox) BBox {\n\tXmin := math.Min(b.Xmin, other.Xmin)\n\tXmax := math.Max(b.Xmax, other.Xmax)\n\tYmin := math.Min(b.Ymin, other.Ymin)\n\tYmax := math.Max(b.Ymax, other.Ymax)\n\tbbox := BBox{Xmin, Ymin, Xmax, Ymax}\n\treturn bbox\n}", "title": "" }, { "docid": "2f7f475f7a1dcb17703d16e8ea08fe10", "score": "0.4850407", "text": "func unionDequote(tls *libc.TLS, z uintptr) { /* unionvtab.c:297:13: */\n\tif z != 0 {\n\t\tvar q int8 = *(*int8)(unsafe.Pointer(z))\n\n\t\t// Set stack variable q to the close-quote character\n\t\tif (((int32(q) == '[') || (int32(q) == '\\'')) || (int32(q) == '\"')) || (int32(q) == '`') {\n\t\t\tvar iIn int32 = 1\n\t\t\tvar iOut int32 = 0\n\t\t\tif int32(q) == '[' {\n\t\t\t\tq = int8(']')\n\t\t\t}\n\t\t\tfor *(*int8)(unsafe.Pointer(z + uintptr(iIn))) != 0 {\n\t\t\t\tif int32(*(*int8)(unsafe.Pointer(z + uintptr(iIn)))) == int32(q) {\n\t\t\t\t\tif int32(*(*int8)(unsafe.Pointer(z + uintptr((iIn + 1))))) != int32(q) {\n\t\t\t\t\t\t// Character iIn was the close quote.\n\t\t\t\t\t\tiIn++\n\t\t\t\t\t\tbreak\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Character iIn and iIn+1 form an escaped quote character. Skip\n\t\t\t\t\t\t// the input cursor past both and copy a single quote character\n\t\t\t\t\t\t// to the output buffer.\n\t\t\t\t\t\tiIn = iIn + (2)\n\t\t\t\t\t\t*(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iOut, 1)))) = q\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t*(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iOut, 1)))) = *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iIn, 1))))\n\t\t\t\t}\n\t\t\t}\n\t\t\t*(*int8)(unsafe.Pointer(z + uintptr(iOut))) = int8(0)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "0c268dba2064a694cd58b6155949d72f", "score": "0.4834006", "text": "func union(a, b []int) []int {\n\tif len(a) == 0 {\n\t\treturn b\n\t}\n\n\tif len(b) == 0 {\n\t\treturn a\n\t}\n\n\tresult := make([]int, 0, len(a))\n\ti, j := 0, 0\n\tfor i < len(a) && j < len(b) {\n\t\tswitch {\n\t\tcase a[i] < b[j]:\n\t\t\tresult = append(result, a[i])\n\t\t\ti++\n\t\tcase a[i] > b[j]:\n\t\t\tresult = append(result, b[j])\n\t\t\tj++\n\t\tcase a[i] == b[j]:\n\t\t\tresult = append(result, a[i])\n\t\t\ti++\n\t\t\tj++\n\t\t}\n\t}\n\n\tvar tail []int\n\tif len(a[i:]) > len(b[j:]) {\n\t\ttail = a[i:]\n\t} else {\n\t\ttail = b[j:]\n\t}\n\n\treturn append(result, tail...)\n}", "title": "" }, { "docid": "23a09c262f57d6b2480b402f89fd91f6", "score": "0.4831858", "text": "func (r *Rectangle) Union(other *Rectangle) *Rectangle {\n\treturn Union(r, other, r)\n}", "title": "" }, { "docid": "aa1afac7c20ea03f1d19574236106ba6", "score": "0.48311523", "text": "func Union(x, y [][]string) [][]string {\n\tif len(x) == 0 {\n\t\treturn y[:len(y):len(y)] // so append won't share\n\t}\n\tif len(y) == 0 {\n\t\treturn x[:len(x):len(x)] // so append won't share\n\t}\n\tz := make([][]string, 0, len(x)+len(y))\n\tz = append(z, x...)\nouter:\n\tfor _, ys := range y {\n\t\tfor _, xs := range x {\n\t\t\tif eq(xs, ys) {\n\t\t\t\tcontinue outer\n\t\t\t}\n\t\t}\n\t\tz = append(z, ys)\n\t}\n\treturn z\n}", "title": "" }, { "docid": "f6e85cc25f09556503858223f62109b7", "score": "0.4812603", "text": "func (qu *QuickUnion) Connected(p int, q int) bool {\n\tif qu.findRoot(p) == qu.findRoot(q) {\n\t\treturn true\n\t}\n\treturn false\n}", "title": "" }, { "docid": "2ef62a47714c2d27e19cbc33d0c69d33", "score": "0.47932103", "text": "func (b *BitSet) Union(compare *BitSet) (result *BitSet) {\n\tpanicIfNull(b)\n\tpanicIfNull(compare)\n\tb, compare = sortByLength(b, compare)\n\tresult = compare.Clone()\n\tfor i, word := range b.set {\n\t\tresult.set[i] = word | compare.set[i]\n\t}\n\treturn\n}", "title": "" }, { "docid": "1692c78f6713aa159a34ee7ec38f5c26", "score": "0.4786514", "text": "func (qr *QueryResult) Merge(other *QueryResult) {\n\tqr.Bm.Merge(other.Bm)\n\tqr.Oa.Merge(other.Oa)\n}", "title": "" }, { "docid": "3cc5dc8c6afa28c5502324e0f5c4c686", "score": "0.4780065", "text": "func (tidis *Tidis) SUnion(txn interface{}, keys ...[]byte) ([]interface{}, error) {\n\treturn tidis.SAction(txn, Union, keys...)\n}", "title": "" }, { "docid": "a0abadd39d9abbfd72534ce8a5b6dfc7", "score": "0.4773063", "text": "func (p *NewUnion) Copy() PhysicalPlan {\n\tnp := *p\n\treturn &np\n}", "title": "" }, { "docid": "53144a8650abce12cc4b86b9bc8a538f", "score": "0.47701797", "text": "func (cte IntermediateCTE) Union(queries ...Query) CTE {\n\tif !CTE(cte).IsRecursive() {\n\t\treturn CTE(cte)\n\t}\n\treturn cte.union(queries, QueryUnion)\n}", "title": "" }, { "docid": "52e97dc6c7f3212e57508424f02442f8", "score": "0.47692996", "text": "func (rs Regions) Union(otherRegions Regions) Regions {\n\t// Short circuit if any of the region sets are empty\n\tif len(rs) == 0 {\n\t\treturn otherRegions\n\t}\n\tif len(otherRegions) == 0 {\n\t\treturn rs\n\t}\n\n\t// The two sides of the union\n\tleftSet := rs\n\trightSet := otherRegions\n\n\tresult := make(Regions, 0, len(leftSet)+len(rightSet))\n\n\t// The region we are building, the next to be added to the result\n\tvar next *Region\n\n\tfor len(leftSet) > 0 || len(rightSet) > 0 {\n\t\tvar left *Region\n\t\tvar right *Region\n\t\tif len(leftSet) > 0 {\n\t\t\tleft = &leftSet[0]\n\t\t} else {\n\t\t\tleft = nil\n\t\t}\n\t\tif len(rightSet) > 0 {\n\t\t\tright = &rightSet[0]\n\t\t} else {\n\t\t\tright = nil\n\t\t}\n\t\tif next == nil {\n\t\t\tif left == nil {\n\t\t\t\tif right == nil {\n\t\t\t\t\t// We're done\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\t// If next was nil, and also left is nil, just add the rest of the rightSet\n\t\t\t\tresult = append(result, rightSet...)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif right == nil {\n\t\t\t\t// left is !nil, but next is nil, so just flush the leftSet\n\t\t\t\tresult = append(result, leftSet...)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif left.Start < right.Start {\n\t\t\t\tclone := (*left).Clone()\n\t\t\t\tnext = &clone\n\t\t\t\tleftSet = leftSet[1:]\n\t\t\t} else {\n\t\t\t\tclone := (*right).Clone()\n\t\t\t\tnext = &clone\n\t\t\t\trightSet = rightSet[1:]\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\t// next is not nil, we need to see if we can build on it\n\t\tif left != nil {\n\t\t\tif (*next).Overlap(*left) {\n\t\t\t\t*next = (*next).Join(*left)\n\t\t\t\tleftSet = leftSet[1:]\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Make sure 0 length regions (that by definition never overlap) are not represented more than once\n\t\t\tif (*next).Equal(*left) {\n\t\t\t\tleftSet = leftSet[1:]\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tif right != nil {\n\t\t\tif (*next).Overlap(*right) {\n\t\t\t\t*next = (*next).Join(*right)\n\t\t\t\trightSet = rightSet[1:]\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Make sure 0 length regions (that by definition never overlap) are not represented more than once\n\t\t\tif (*next).Equal(*right) {\n\t\t\t\trightSet = rightSet[1:]\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\t// next is not nil, and neither left nor right overlap next\n\t\t// time to add next to the result, and move on\n\t\tresult = append(result, *next)\n\t\tnext = nil\n\t}\n\tif next != nil {\n\t\tresult = append(result, *next)\n\t}\n\treturn result\n}", "title": "" }, { "docid": "cc1c1fa6da65495b6b5ad205e6507024", "score": "0.4746866", "text": "func UnionSet(x, y Set) Set {\n\tvar ret Set\n\tret.infinite = x.infinite || y.infinite\n\tif ret.infinite {\n\t\treturn ret\n\t}\n\tret.items = make(stringSet, len(x.items)+len(y.items))\n\tfor k := range x.items {\n\t\tret.Add(k)\n\t}\n\tfor k := range y.items {\n\t\tret.Add(k)\n\t}\n\tret.minimumLen = x.minimumLen\n\tif x.minimumLen > y.minimumLen {\n\t\tret.minimumLen = y.minimumLen\n\t}\n\treturn ret\n}", "title": "" }, { "docid": "12c273878ee2c1a2f3d5fee34685b501", "score": "0.4733278", "text": "func DigraphUnion(graphs ...*DirectedGraph) *DirectedGraph {\n\tdg := NewDirectedGraph()\n\tfor _, g := range graphs {\n\t\tvertices := g.Vertices()\n\t\tfor _, x := range vertices {\n\t\t\tfor y, rels := range g.Outs[x] {\n\t\t\t\tfor _, rel := range rels {\n\t\t\t\t\tdg.Link(x, y, rel)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn dg\n}", "title": "" }, { "docid": "2cddd087a42cc715d25603fd8d05fce4", "score": "0.47328025", "text": "func (b *Bits64) Union(s Bits64) {\n\t*b |= s\n}", "title": "" }, { "docid": "17f49c8eb7180bc0bc227a0eeb0d82d3", "score": "0.47302258", "text": "func (seg *GpxTrkseg) Join(seg2 *GpxTrkseg) {\n\tseg.Points = append(seg.Points, seg2.Points...)\n}", "title": "" }, { "docid": "f97e59b8b212d2ca2c30b1a2f4aca082", "score": "0.47296783", "text": "func (h *Hll) StrictUnion(other Hll) error {\n\treturn h.union(other, true)\n}", "title": "" }, { "docid": "94c450233a930b7bf28d3678f2f13fbf", "score": "0.47264823", "text": "func (h *HexSet) Union(x *HexSet) *HexSet {\n\trv := h.Clone()\n\trv.InPlaceUnion(x)\n\treturn rv\n}", "title": "" }, { "docid": "8bd30f84400aeef04262e6ed39fefbc1", "score": "0.4724311", "text": "func (s *Set) Union(s2 *Set) *Set {\n\treturn &Set{\n\t\tMembers: *s.Members.Union(&s2.Members),\n\t\tChildren: *s.Children.Union(&s2.Children),\n\t}\n}", "title": "" } ]
b9611ce73b0e5a7b9724c869c0968da0
printJson output apps list as json format.
[ { "docid": "34f3c793dffac91d607df3a0fcab0dd4", "score": "0.8822457", "text": "func printJson(apps []*types.App) error {\n\tdata, err := json.Marshal(&apps)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Fprintln(os.Stdout, string(data))\n\n\treturn nil\n}", "title": "" } ]
[ { "docid": "f49a6cb502a347bf7baf07e582fce9bd", "score": "0.6094565", "text": "func (o AutoLoginOutput) AppLinksJson() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *AutoLogin) pulumi.StringPtrOutput { return v.AppLinksJson }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "fcbc6819657d5726b8672d63cb4f53b9", "score": "0.60779715", "text": "func printApps(apps []string) {\n\tfmt.Printf(\"Found %d apps\\n\\n\", len(apps))\n\tfor _, app := range apps {\n\t\tfmt.Printf(\" > %s\\n\", app)\n\t}\n}", "title": "" }, { "docid": "c484f271df2664b0fe3c26eb61d82ffd", "score": "0.60581726", "text": "func (r *Result) printJSON(w io.Writer) error {\n\tprettyJSON, err := json.MarshalIndent(r, \"\", \" \")\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Fprintf(w, \"%s\\n\", string(prettyJSON))\n\treturn nil\n}", "title": "" }, { "docid": "caa86977db278bfa2979ac8c869929ad", "score": "0.5848951", "text": "func PrintJSON(data interface{}) {\n\tfprintJSON(os.Stdout, data)\n}", "title": "" }, { "docid": "1890f5056f471b45b8319150f5e29e3b", "score": "0.58116484", "text": "func (c *AuthorizationRoles) JSON(w io.Writer, listView bool) error {\n\tif !listView && len(c.items) == 1 {\n\t\treturn displayJSON(w, c.items[0])\n\t}\n\n\treturn displayJSON(w, c.items)\n}", "title": "" }, { "docid": "fcafe94fa74936ff0dc6915268fa6c84", "score": "0.5774055", "text": "func (d *Droplet) JSONPrint() {\n\toutput, err := json.MarshalIndent(d, \"\", \" \")\n\tif err != nil {\n\t\tfmt.Println(\"Error parsing to JSON\")\n\t}\n\tos.Stdout.Write(output)\n}", "title": "" }, { "docid": "c14b1c64a172f7ecf818d376f4395ee4", "score": "0.57673365", "text": "func (t *App) WriteJSON(w io.Writer, indent ...bool) error {\n\tif indent != nil && len(indent) > 0 {\n\t\tbuf, err := json.MarshalIndent(t, \"\", \"\\t\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif _, err := w.Write(buf); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif _, err := w.Write([]byte(\"\\n\")); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}\n\tbuf, err := json.Marshal(t)\n\tif err != nil {\n\t\treturn nil\n\t}\n\tif _, err := w.Write(buf); err != nil {\n\t\treturn err\n\t}\n\tif _, err := w.Write([]byte(\"\\n\")); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "f9b5309f7e7a42404d4bc9899b1670c8", "score": "0.57566714", "text": "func (c *AuthorizationRules) JSON(w io.Writer, listView bool) error {\n\tif !listView && len(c.items) == 1 {\n\t\treturn displayJSON(w, c.items[0])\n\t}\n\n\treturn displayJSON(w, c.items)\n}", "title": "" }, { "docid": "ac2f81c0f36f984b2e9b0af630b8c7b9", "score": "0.5751594", "text": "func listApplications(c *cli.Context) error {\n\thttpClient := NewHTTPClient(\"/apps\")\n\tresp, err := httpClient.Get()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Unable to do request: %s\", err.Error())\n\t}\n\tdefer resp.Body.Close()\n\n\tvar apps []*types.App\n\tif err := json.NewDecoder(resp.Body).Decode(&apps); err != nil {\n\t\treturn err\n\t}\n\n\tlistApps := make([]*types.App, 0)\n\tif !c.Bool(\"all\") {\n\t\tfor _, app := range apps {\n\t\t\tif app.State == \"normal\" {\n\t\t\t\tlistApps = append(listApps, app)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tlistApps = apps\n\t}\n\n\tif c.IsSet(\"json\") {\n\t\tprintJson(listApps)\n\t} else {\n\t\tprintTable(listApps)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "1c96aaf7cf064acba7273f7efdcbf689", "score": "0.57321477", "text": "func PrintJSON(data interface{}) {\n\tjson, err := json.Marshal(data)\n\tif err != nil {\n\t\tExitWithError(err)\n\t}\n\n\tfmt.Println(string(json))\n}", "title": "" }, { "docid": "a32afb1a312da01f0f372c260a2aae7f", "score": "0.5726087", "text": "func Print(appConfig *AppConfig) {\n\tb, err := json.MarshalIndent(appConfig, \"\", \" \")\n\tif err != nil {\n\t\tfmt.Printf(\"\\n#> Failed to read app config! error: %s\\n\", err.Error())\n\t\tos.Exit(1)\n\t}\n\tfmt.Printf(\"\\n#> Current app config:\\n%s\\n\", string(b))\n}", "title": "" }, { "docid": "cb52c4e0cecc423b20549edd36998a66", "score": "0.5713612", "text": "func (o IAppOutput) Jsonfile() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *IApp) pulumi.StringOutput { return v.Jsonfile }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "6f4680b86ad949c877729cba9ddb8bf8", "score": "0.5699162", "text": "func (a *apps) List() ([]string, error) {\n\tres, err := a.c.baseRequest(http.MethodGet, routes.apps, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar r appListResponse\n\tres.JSON(&r)\n\treturn r.Ocs.Data.Apps, nil\n}", "title": "" }, { "docid": "c2cd1c903a618eeedf2b9c6a82350a5f", "score": "0.5691343", "text": "func PrintJson(jsn []byte) {\n\tfmt.Printf(\"{\\n\")\n\tfor key, valA := range getJsonUnmarsh(jsn) {\n\t\tparseInterface(key, valA, 1)\n\t}\n\tfmt.Printf(\"}\\n\")\n}", "title": "" }, { "docid": "24a995f6345cc63319abacaa98f4d53e", "score": "0.5687786", "text": "func (m *ComponentCollection) PrintJSON() string {\n\tm.filterMetrics()\n\treturn PrettyPrintJSON(m)\n}", "title": "" }, { "docid": "611c6ea9a708c17526057cd2cde9a17a", "score": "0.56040525", "text": "func (a *Applications) String() string {\n\tjson, _ := json.Marshal(a)\n\treturn string(json)\n}", "title": "" }, { "docid": "c98d08d19d2b02ceeb1df9ce7baae3ce", "score": "0.5599935", "text": "func App(w http.ResponseWriter, r *http.Request) {\n\tpayload := map[string]interface{}{\n\t\t\"runtime\": os.Getenv(\"GCF_RUNTIME\"),\n\t\t\"key\": \"value\",\n\t\t\"array\": []int{1, 2, 3},\n\t}\n\toutput, _ := json.Marshal(payload)\n\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusOK)\n\n\tmw := io.MultiWriter(w, os.Stdout)\n\tfmt.Fprintf(mw, \"%s\\n\", output)\n}", "title": "" }, { "docid": "004f0f220dd6cda10d28c12e4ce7ca69", "score": "0.5585513", "text": "func PrintJSON(filename string, data interface{}) {\n\tfile, err := os.OpenFile(filename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer file.Close()\n\n\tenc := json.NewEncoder(file)\n\tenc.Encode(data)\n}", "title": "" }, { "docid": "f4cfd34b88ff885f8fea3fa67bb53c3d", "score": "0.5573469", "text": "func writeJSON(w http.ResponseWriter, thing interface{}, indent bool) {\n\twriteJSONWithStatus(w, thing, http.StatusOK, indent)\n}", "title": "" }, { "docid": "83acd0bc4880bfd0d1fce0331cb82d46", "score": "0.5546152", "text": "func PrintJSON(body interface{}) error {\n\tswitch {\n\tcase cfg.Silent:\n\t\t// Keep quiet\n\tcase cfg.Verbose:\n\t\t// Verbose printing is handled by the http client\n\t\t// since it prints details like the url and response\n\t\t// codes.\n\tcase cfg.RawJSON:\n\t\t// Print raw JSON with no formatting\n\t\tb, err := json.Marshal(body)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Marshal: %v\", err)\n\t\t}\n\t\tfmt.Printf(\"%v\\n\", string(b))\n\tdefault:\n\t\t// Pretty print the body\n\t\tb, err := json.MarshalIndent(body, \"\", \" \")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"MarshalIndent: %v\", err)\n\t\t}\n\t\tfmt.Fprintf(os.Stdout, \"%s\\n\", b)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "e2144b8200e7a2dab5ae93498b3f9565", "score": "0.55441344", "text": "func fprintJSON(w io.Writer, data interface{}) {\n\tencoder := json.NewEncoder(w)\n\tencoder.SetIndent(\"\", \" \")\n\tif err := encoder.Encode(data); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "title": "" }, { "docid": "3b4e340ee8df5fea9e99ffbabe7a8706", "score": "0.5530491", "text": "func (s *Server) applicationList(w http.ResponseWriter, r *http.Request) {\n\t// GET returns a JSON array with applications.\n\tapplications, err := s.context.Storage.Application.GetList(s.connectUserID(r))\n\tif err != nil {\n\t\tlogging.Warning(\"Unable to read application list: %v\", err)\n\t\thttp.Error(w, \"Unable to load applications\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\tappList := newApplicationList()\n\tfor application := range applications {\n\t\tappList.Applications = append(appList.Applications, newAppFromModel(application))\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusOK)\n\tif err := json.NewEncoder(w).Encode(appList); err != nil {\n\t\tlogging.Warning(\"Unable to marshal application object: %v\", err)\n\t}\n}", "title": "" }, { "docid": "1bb640615a1ccc4eb21659387a970323", "score": "0.5523318", "text": "func DumpJSON(j interface{}) {\n\tout, err := json.MarshalIndent(j, \"\", \" \")\n\tMaybeDie(err, \"unable to json marshal response: %v\", err)\n\tfmt.Printf(\"%s\\n\", out)\n}", "title": "" }, { "docid": "1bb640615a1ccc4eb21659387a970323", "score": "0.5523318", "text": "func DumpJSON(j interface{}) {\n\tout, err := json.MarshalIndent(j, \"\", \" \")\n\tMaybeDie(err, \"unable to json marshal response: %v\", err)\n\tfmt.Printf(\"%s\\n\", out)\n}", "title": "" }, { "docid": "5b5d6a20e2b7361cd0dd339c569937ac", "score": "0.5478041", "text": "func readjson(res http.ResponseWriter, req *http.Request) {\r\n\tp := Test{\"123456\", \"Songwut\"}\r\n\tijson, _ := json.Marshal(p)\r\n\tfmt.Fprintln(res, string(ijson))\r\n}", "title": "" }, { "docid": "73a2a6edb104f07da6bf7e702c2e5c2a", "score": "0.54719114", "text": "func PrintJson(v interface{}) error {\n\tjsonMsg, err := json.MarshalIndent(v, \"\", \" \")\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Print(string(jsonMsg))\n\treturn nil\n}", "title": "" }, { "docid": "6bff78ff6c294c20dcbc7a508abcffe9", "score": "0.5471319", "text": "func (v App) MarshalJSON() ([]byte, error) {\n\tw := jwriter.Writer{}\n\teasyjsonB27eec76EncodeGithubComAtomxCoreOpenrtb24(&w, v)\n\treturn w.Buffer.BuildBytes(), w.Error\n}", "title": "" }, { "docid": "13ec2ebf3d5b16240f93a6fff2a2214f", "score": "0.5469204", "text": "func AppList(fn core.AppListFunc) Handler {\n\treturn func(ctx context.Context, w http.ResponseWriter, r *http.Request) {\n\t\tas, err := fn()\n\t\tif err != nil {\n\t\t\trespondError(w, 0, err)\n\t\t\treturn\n\t\t}\n\n\t\trespondJSON(w, http.StatusOK, &payloadApps{apps: as})\n\t}\n}", "title": "" }, { "docid": "21ba19b20916db2e45fd4772f1c1f3a1", "score": "0.5450259", "text": "func (app *application) writeJSON(w http.ResponseWriter, status int, data interface{}, headers http.Header) error {\n js, err := json.Marshal(data)\n if err != nil {\n return err\n }\n\n // Append a newline to make it easier to view in terminal applications.\n js = append(js, '\\n')\n\n // Writer headers\n for key, value := range headers {\n w.Header()[key] = value\n }\n\n w.Header().Set(\"Content-Type\", \"application/json\")\n w.WriteHeader(status)\n w.Write(js)\n\n return nil\n}", "title": "" }, { "docid": "3cfec675029ce6fbe9a5ff883835daef", "score": "0.5447351", "text": "func (l JSONLibrary) JSON() ([]byte, error) {\n\treturn json.MarshalIndent(l, \"\", \" \")\n}", "title": "" }, { "docid": "b7df3aad28292cdd1cd55ec81433e6e6", "score": "0.54439557", "text": "func (a App) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"id\", a.ID)\n\tpopulate(objectMap, \"location\", a.Location)\n\tpopulate(objectMap, \"name\", a.Name)\n\tpopulate(objectMap, \"properties\", a.Properties)\n\tpopulate(objectMap, \"tags\", a.Tags)\n\tpopulate(objectMap, \"type\", a.Type)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "16042590623574c51e6aa1bd12b8bb2f", "score": "0.5408786", "text": "func listApps(path string, token string) (list AppList, err error) {\n\n\ttask := http.Client{}\n\treq, err := http.NewRequest(\"GET\",\n\t\tpath+\"/appbundles\",\n\t\tnil,\n\t)\n\n\treq.Header.Set(\"Authorization\", \"Bearer \"+token)\n\tresponse, err := task.Do(req)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer response.Body.Close()\n\n\tif response.StatusCode != http.StatusOK {\n\t\tcontent, _ := ioutil.ReadAll(response.Body)\n\t\terr = errors.New(\"[\" + strconv.Itoa(response.StatusCode) + \"] \" + string(content))\n\t\treturn\n\t}\n\n\tdecoder := json.NewDecoder(response.Body)\n\terr = decoder.Decode(&list)\n\n\treturn\n}", "title": "" }, { "docid": "d2f3500a1e4778d13ddc1a1cc8702370", "score": "0.5402893", "text": "func listApplication(app *meta.Application) {\n\tfmt.Printf(\" application ID: %x\\n\", string(app.ID))\n\tfmt.Println(\" data contents:\")\n\tif len(app.Data) > 0 {\n\t\tfmt.Println(string(app.Data))\n\t}\n}", "title": "" }, { "docid": "81ac2b205698c37d4bfa655c6188c38f", "score": "0.5378768", "text": "func PrintJSON(in interface{}) error {\n\tj := []byte{}\n\terr := errors.New(\"\")\n\tif JSONPretty {\n\t\tj, err = json.MarshalIndent(in, JSONPrefix, JSONIndent)\n\t} else {\n\t\tj, err = json.Marshal(in)\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Printf(\"%+v\\n\", string(j))\n\treturn nil\n}", "title": "" }, { "docid": "518659126a1afc249461675bab4dff76", "score": "0.5372388", "text": "func printTable(apps []*types.App) {\n\ttb := tablewriter.NewWriter(os.Stdout)\n\ttb.SetHeader([]string{\n\t\t\"ID\",\n\t\t\"Name\",\n\t\t\"Instances\",\n\t\t\"RunAS\",\n\t\t\"ClusterID\",\n\t\t\"State\",\n\t\t\"Created\",\n\t\t\"Updated\",\n\t})\n\tfor _, app := range apps {\n\t\ttb.Append([]string{\n\t\t\tapp.ID,\n\t\t\tapp.Name,\n\t\t\tfmt.Sprintf(\"%d\", app.Instances),\n\t\t\tapp.RunAs,\n\t\t\tapp.ClusterID,\n\t\t\tapp.State,\n\t\t\tapp.Created.Format(\"2006-01-02 15:04:05\"),\n\t\t\tapp.Updated.Format(\"2006-01-02 15:04:05\"),\n\t\t})\n\t}\n\ttb.Render()\n}", "title": "" }, { "docid": "a60249a68e162caf736ff26dcaf61ca5", "score": "0.53713924", "text": "func PrintJobs(cl client.Client, pretty bool) error {\n\n\t// Get jobs\n\tjobs, err := Jobs(cl, true, true, true, true)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Parse jobs\n\tvar buf []byte\n\n\t// If pretty is true then\n\tif pretty {\n\t\tbuf, err = json.MarshalIndent(jobs, \"\", \" \")\n\t} else {\n\t\t// Otherwise just parse it\n\t\tbuf, err = json.Marshal(jobs)\n\t}\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tos.Stdout.Write(buf)\n\n\treturn nil\n}", "title": "" }, { "docid": "8279e1936ba9165f0a7467d465ac2f8e", "score": "0.5333425", "text": "func printMyJSON(data []byte) {\n\tvar prettyJSON bytes.Buffer\n\terr := json.Indent(&prettyJSON, data, \"\", \" \")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Println(string(prettyJSON.Bytes()))\n}", "title": "" }, { "docid": "9479342e48b388cb8972c2a956f0c8ae", "score": "0.52953124", "text": "func (o AutoLoginOutput) AppSettingsJson() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *AutoLogin) pulumi.StringPtrOutput { return v.AppSettingsJson }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "340ad1b8ea524adbaa83db11a9bb1fc5", "score": "0.52903223", "text": "func (v App) MarshalEasyJSON(w *jwriter.Writer) {\n\teasyjsonB27eec76EncodeGithubComAtomxCoreOpenrtb24(w, v)\n}", "title": "" }, { "docid": "bd78da448166be680a2198a7d22a83c3", "score": "0.52783906", "text": "func (ps *Projects) ExportJSON() (string, error) {\n\toutput, err := json.MarshalIndent(ps, \"\", \" \")\n\treturn string(output[:]), err\n}", "title": "" }, { "docid": "2e1cf19dcd02239254bc434de6930304", "score": "0.5265687", "text": "func printJson(fileName string) error {\n\tjsonFile, err := ioutil.ReadFile(fileName)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tb := []byte(jsonFile)\n\tb, err = jsonBytes(b)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Printf(\"%s\\n\", b)\n\treturn nil\n}", "title": "" }, { "docid": "04f032d0b3c10e968e71d67feb6812ff", "score": "0.5259733", "text": "func writeJSON(i interface{}, w io.Writer) {\n\tb, _ := json.MarshalIndent(i, \"\", \" \")\n\tb = append(b, []byte(\"\\n\")...)\n\t_, err := w.Write(b)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "title": "" }, { "docid": "24d3e4d239645eb92794eef4a8c5fd14", "score": "0.5235624", "text": "func (n *AgentNotify) DumpJSON() {\n\tfmt.Println(n.getJSON())\n}", "title": "" }, { "docid": "50b85f939a297c48402c77465dac7264", "score": "0.52237064", "text": "func (s JSONSerializer) SerializeApplication(app api.Application) ([]byte, error) {\n\tjson, marshalErr := json.Marshal(app)\n\tif marshalErr != nil {\n\t\treturn []byte{}, marshalErr\n\t}\n\n\treturn json, nil\n}", "title": "" }, { "docid": "bdd0f9933edaaa6762f87ea54cf7e622", "score": "0.522233", "text": "func (hv *Hypervisor) getApps() http.HandlerFunc {\n\treturn hv.withCtx(hv.visorCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) {\n\t\tapps, err := ctx.API.Apps()\n\t\tif err != nil {\n\t\t\thttputil.WriteJSON(w, r, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\n\t\thttputil.WriteJSON(w, r, http.StatusOK, apps)\n\t})\n}", "title": "" }, { "docid": "d5a193a435197adcab052cceb692e18d", "score": "0.5206091", "text": "func (v DeveloperApp) MarshalEasyJSON(w *jwriter.Writer) {\n\teasyjsonCaf77204EncodeGithubComTarbBfapi4(w, v)\n}", "title": "" }, { "docid": "5ab4b19adc618f8e961244670d2e7d0c", "score": "0.5186647", "text": "func GetPrograms(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tjson.NewEncoder(w).Encode(programs)\n}", "title": "" }, { "docid": "2455b284b1d8c19c26eeea6d2e410797", "score": "0.51852655", "text": "func printProtoJSON(w io.Writer, result *skylab_test_runner.Result) error {\n\tm := jsonpb.Marshaler{\n\t\tEnumsAsInts: false,\n\t\tIndent: \"\\t\",\n\t}\n\treturn m.Marshal(w, result)\n}", "title": "" }, { "docid": "c4479ba3286e1c5116e5b3e0ce6635d9", "score": "0.5177308", "text": "func (a Application) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"id\", a.ID)\n\tpopulate(objectMap, \"identity\", a.Identity)\n\tpopulate(objectMap, \"kind\", a.Kind)\n\tpopulate(objectMap, \"location\", a.Location)\n\tpopulate(objectMap, \"managedBy\", a.ManagedBy)\n\tpopulate(objectMap, \"name\", a.Name)\n\tpopulate(objectMap, \"plan\", a.Plan)\n\tpopulate(objectMap, \"properties\", a.Properties)\n\tpopulate(objectMap, \"sku\", a.SKU)\n\tpopulate(objectMap, \"systemData\", a.SystemData)\n\tpopulate(objectMap, \"tags\", a.Tags)\n\tpopulate(objectMap, \"type\", a.Type)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "b167bfd814f787caf9286197d99ebe06", "score": "0.5175952", "text": "func DumpJSON(fo *os.File, item interface{}) error {\n\tdata, err := json.MarshalIndent(item, \"\", \" \")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = fo.Write(data)\n\treturn err\n}", "title": "" }, { "docid": "23063dc8fd30ba1fa21d31d43115fbd8", "score": "0.51643044", "text": "func writeGurumeJSON(gurumeList []*model.Gurume) {\n\tf, err := os.Create(resultJSONFile)\n\tif err != nil {\n\t\tlogger.WithError(err).Error(\"error\")\n\t\tf.Close()\n\t\treturn\n\t}\n\n\tfor _, gurume := range gurumeList {\n\t\tbytes, _ := json.Marshal(gurume)\n\t\tfmt.Fprintln(f, string(bytes))\n\t\tif err != nil {\n\t\t\tlogger.WithError(err).Error(\"error\")\n\t\t\treturn\n\t\t}\n\t}\n\n\terr = f.Close()\n\tif err != nil {\n\t\tlogger.WithError(err).Error(\"error\")\n\t\treturn\n\t}\n\tlogger.Infof(\"file written successfully: %s\", resultJSONFile)\n}", "title": "" }, { "docid": "0282a323c2e09c38fdf7c2c31bece4d7", "score": "0.5139774", "text": "func writeJSON(w http.ResponseWriter, code int, v interface{}) error {\n\t// Set content type as json\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\t// write the HTTP status code\n\tw.WriteHeader(code)\n\n\t// Write the Json output\n\treturn json.NewEncoder(w).Encode(v)\n}", "title": "" }, { "docid": "7449c6369604d09cbc1c0d0b97fb6850", "score": "0.51382416", "text": "func OutputJSON(data interface{}, pretty bool) error {\n\tvar output []byte\n\tvar err error\n\n\tif pretty {\n\t\toutput, err = json.MarshalIndent(data, \"\", \"\\t\")\n\t} else {\n\t\toutput, err = json.Marshal(data)\n\t}\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error outputting JSON: %s\", err)\n\t}\n\n\tif string(output) == \"null\" {\n\t\tfmt.Println(\"[]\")\n\t} else {\n\t\tfmt.Println(string(output))\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "7a268c2ebe69954837bfaf058414d3ad", "score": "0.51308167", "text": "func writeJSON(Pcaps []AbridgedPcapInfo) {\n\tjsonBuf := new(bytes.Buffer)\n\tenc := json.NewEncoder(jsonBuf)\n\tenc.SetEscapeHTML(false)\n\tenc.SetIndent(\"\", \" \")\n\terr := enc.Encode(Pcaps)\n\tif err != nil {\n\t\tfmt.Println(\"Error in converting JSON:\", err)\n\t\tfmt.Println(\"JSON:\", Pcaps)\n\t}\n\tdir, err := os.Getwd()\n\tif err != nil {\n\t\tfmt.Println(\"Could not read current directory\", err)\n\t\tos.Exit(1)\n\t}\n\tjsonPath := dir + \"/build/abridged_captures.json\"\n\terr = ioutil.WriteFile(jsonPath, jsonBuf.Bytes(), 0644)\n\tif err != nil {\n\t\tfmt.Println(\"Error in writing JSON to file:\", err)\n\t\tfmt.Println(\"Filepath:\", jsonPath)\n\t}\n}", "title": "" }, { "docid": "08637f1d1fcd5fcc776c796de88a0b7b", "score": "0.5115125", "text": "func (i *InterfaceList) JSONPretty() []byte {\n\tb, _ := json.MarshalIndent(i, \"\", \" \")\n\treturn b\n}", "title": "" }, { "docid": "187a315a99056ad369c4c402dcc3ab7d", "score": "0.51132125", "text": "func JSON(w io.Writer, f *parser.File) error {\n\tvar result = make(map[string][]string, len(f.Methods))\n\tfor _, method := range f.Methods {\n\t\tresult[method.Name] = method.Scopes\n\t}\n\treturn json.NewEncoder(w).Encode(result)\n}", "title": "" }, { "docid": "79f2acdd48550a27cf67905364294c40", "score": "0.5107107", "text": "func home(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusOK)\n\treportRequest(\"\", w, r)\n\tw.Write([]byte(\"\\\"\" + appName + \"\\\"\"))\n}", "title": "" }, { "docid": "a44e89387048ca3fbc97287c3421ce28", "score": "0.51063883", "text": "func (m *Node) getApps() http.HandlerFunc {\n\treturn m.withCtx(m.nodeCtx, func(w http.ResponseWriter, r *http.Request, ctx *httpCtx) {\n\t\tapps, err := ctx.RPC.Apps()\n\t\tif err != nil {\n\t\t\thttputil.WriteJSON(w, r, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\t\thttputil.WriteJSON(w, r, http.StatusOK, apps)\n\t})\n}", "title": "" }, { "docid": "12df5deef057a8d534864915ffc068b4", "score": "0.5106158", "text": "func PrettyPrintJSON(theJSON []byte) {\n\tdst := new(bytes.Buffer)\n\tjson.Indent(dst, theJSON, \"\", \"\\t\")\n\tlog.Info(dst)\n}", "title": "" }, { "docid": "fdd8fefd4a9aa3fe5e5054283922ca86", "score": "0.5091259", "text": "func (ctx *Context) JSON(jsonObjectOrArray interface{}) error {\n\treturn ctx.WriteJSON(http.StatusOK, jsonObjectOrArray)\n}", "title": "" }, { "docid": "08ae8768ce6ab6a055d05fa0eb542ff0", "score": "0.50840217", "text": "func JSON(w io.Writer, b *bundlev1.Bundle) error {\n\t// Check parameters\n\tif types.IsNil(w) {\n\t\treturn fmt.Errorf(\"unable to process nil writer\")\n\t}\n\tif b == nil {\n\t\treturn fmt.Errorf(\"unable to process nil bundle\")\n\t}\n\n\t// Initialize marshaller\n\tm := &protojson.MarshalOptions{}\n\n\t// Marshal bundle\n\tout, err := m.Marshal(b)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to produce JSON from bundle object: %w\", err)\n\t}\n\n\t// Write to writer\n\tif _, err := fmt.Fprintf(w, \"%s\", string(out)); err != nil {\n\t\treturn fmt.Errorf(\"unable to write JSON bundle: %w\", err)\n\t}\n\n\t// No error\n\treturn nil\n}", "title": "" }, { "docid": "b9e310c02741e0cd764e6ce466155441", "score": "0.5081433", "text": "func writeJSON(w http.ResponseWriter, v interface{}) error {\n\t// Return \"[]\" instead of \"null\" if v is a nil slice.\n\tif reflect.TypeOf(v).Kind() == reflect.Slice && reflect.ValueOf(v).IsNil() {\n\t\tv = []interface{}{}\n\t}\n\n\t// MarshalIndent takes about 30-50% longer, which\n\t// significantly increases the time it takes to handle and return\n\t// large HTTP API responses.\n\tw.Header().Set(\"content-type\", \"application/json; charset=utf-8\")\n\treturn json.NewEncoder(w).Encode(v)\n}", "title": "" }, { "docid": "316d5923bca356126a788c215dd04805", "score": "0.5070848", "text": "func saveInJSON(){\n\tjsonData, err := json.Marshal(PhBook.pList)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tsaveToFile(jsonData)\n}", "title": "" }, { "docid": "2bacedc691fa29cb90adf35edb33c44e", "score": "0.5065824", "text": "func writeJSON(w http.ResponseWriter, data interface{}) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tresult, err := json.Marshal(data)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tio.WriteString(w, string(result))\n}", "title": "" }, { "docid": "8a2eb1e22420c03feb8c8897777bf7cf", "score": "0.5065174", "text": "func (items Items) Json(of io.Writer) error {\n\tenc := json.NewEncoder(of)\n\terr := enc.Encode(items)\n\n\tif err != nil {\n\t\treturn errors.New(\"could not convert xml to json ⇒ \" + err.Error())\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "3d4cb5e28756f17ee9641c41ac102d9d", "score": "0.504825", "text": "func writeJSON(w http.ResponseWriter, data JSON) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tjson.NewEncoder(w).Encode(data)\n}", "title": "" }, { "docid": "a3988fb9974ad13bbc9124faaae1e45a", "score": "0.5044117", "text": "func prettyPrintJSON(jsonBody string) {\n\tjsonStr := prettifyJSON(jsonBody)\n\tfmt.Printf(\"Result: %s\\n\", jsonStr)\n}", "title": "" }, { "docid": "4ee824c9e0990c6ced94888b52c73986", "score": "0.5039049", "text": "func (o FastHttpsAppOutput) FastHttpsJson() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *FastHttpsApp) pulumi.StringOutput { return v.FastHttpsJson }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "00358713b3ae21190ee1aec7d392d688", "score": "0.50386405", "text": "func (p *Resource) AppsListHandler(req *restful.Request,\n\tresp *restful.Response) {\n\t// logrus.Infof(\"AppsListHandler is called!\")\n\tx_auth_token := req.HeaderParameter(\"X-Auth-Token\")\n\tcode, err := services.TokenValidation(x_auth_token)\n\tif err != nil {\n\t\tresponse.WriteStatusError(code, err, resp)\n\t\treturn\n\t}\n\n\tvar skip int = queryIntParam(req, \"skip\", 0)\n\tvar limit int = queryIntParam(req, \"limit\", 0)\n\n\ttotal, apps, code, err := services.GetAppService().QueryAll(skip, limit, x_auth_token)\n\tif err != nil {\n\t\tresponse.WriteStatusError(code, err, resp)\n\t\treturn\n\t}\n\tres := response.QueryStruct{Success: true, Data: apps}\n\tif c, _ := strconv.ParseBool(req.QueryParameter(\"count\")); c {\n\t\tres.Count = total\n\t\tresp.AddHeader(\"X-Object-Count\", strconv.Itoa(total))\n\t}\n\tresp.WriteEntity(res)\n\treturn\n}", "title": "" }, { "docid": "017a6616080c940c0f16095936470190", "score": "0.50350523", "text": "func OutputAsJSON(resource interface{}, err error) {\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t}\n\n\tjsonData := octopusdeploy.PrettyJSON(resource)\n\tfmt.Println(jsonData)\n\tfmt.Println()\n}", "title": "" }, { "docid": "21b316e1a3e632f15cc6e0fec0659617", "score": "0.503188", "text": "func WriteJSON(w http.ResponseWriter, code int, v interface{}) {\n\tdata, err := json.Marshal(v)\n\tif err != nil {\n\t\tpanic(\"error jsonizing your data\")\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tfmt.Fprintf(w, string(data))\n}", "title": "" }, { "docid": "3e7c0c7688d01d996df830d91d6de2ff", "score": "0.5016094", "text": "func (c *SmartThingsClient) AppList() (*AppList, error) {\n\treq, err := c.newRequest(http.MethodGet, fmt.Sprintf(\"/v1/apps\"), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar appList AppList\n\t_, err = c.do(req, &appList)\n\treturn &appList, err\n}", "title": "" }, { "docid": "0a6293af8571e2374000383602de7b38", "score": "0.5014854", "text": "func PrettyPrintJSON(data interface{}, tab string) ([]byte, error) {\n\tunformatted, err := json.Marshal(data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar buffer bytes.Buffer\n\tif err := json.Indent(&buffer, unformatted, \"\", \"\\t\"); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn buffer.Bytes(), nil\n}", "title": "" }, { "docid": "d89049521d6c784d951983631f4d4e20", "score": "0.50119257", "text": "func (a *ApplicationInfo) String() string {\n\tjson, _ := json.Marshal(a)\n\treturn string(json)\n}", "title": "" }, { "docid": "67db00344b3af55662747d9cd14cffc5", "score": "0.50113356", "text": "func (pt *PingTimes) DumpJson(file *os.File) error {\n\tenc := json.NewEncoder(file)\n\tenc.SetIndent(\"\", \" \")\n\tenc.Encode(pt)\n\treturn nil\n}", "title": "" }, { "docid": "c28936fd988e1e699cf9f0811ab487dd", "score": "0.5009052", "text": "func PrintJSONReport(w http.ResponseWriter, req *http.Request, releaseReports map[string][]v12.TestReport, endDay, jobTestCount int) {\n\treportObjects := make(map[string]interface{})\n\tfor _, reports := range releaseReports {\n\t\treport := reports[0]\n\t\tprevReport := reports[1]\n\t\treportObjects[report.Release] = formatJSONReport(report, prevReport, endDay, jobTestCount)\n\t}\n\tenc := json.NewEncoder(w)\n\tenc.SetEscapeHTML(false)\n\tenc.SetIndent(\"\", \" \")\n\terr := enc.Encode(reportObjects)\n\tif err != nil {\n\t\tklog.Errorf(\"unable to render json %v\", err)\n\t}\n}", "title": "" }, { "docid": "654dc67cf8162b6858ee15c178c0ecae", "score": "0.5003158", "text": "func renderJson(w http.ResponseWriter, data interface{}) {\n\tjs, err := json.MarshalIndent(data, \"\", \" \")\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t_, _ = w.Write(js)\n}", "title": "" }, { "docid": "7e2138ed900bb312619e2fa10ffbd636", "score": "0.49988708", "text": "func GetContainersJson(w http.ResponseWriter, req *http.Request) {\n\tjson.NewEncoder(w).Encode(GetContainers())\n}", "title": "" }, { "docid": "b75cd12f6bc9e7b089910a23db74785b", "score": "0.49942783", "text": "func (c ContainerApp) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\tpopulate(objectMap, \"id\", c.ID)\n\tpopulate(objectMap, \"kind\", c.Kind)\n\tpopulate(objectMap, \"location\", c.Location)\n\tpopulate(objectMap, \"name\", c.Name)\n\tpopulate(objectMap, \"properties\", c.Properties)\n\tpopulate(objectMap, \"tags\", c.Tags)\n\tpopulate(objectMap, \"type\", c.Type)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "02a8fe065cfd23d9f470de0ee4b5ae7a", "score": "0.49880573", "text": "func (w *StandardWriter) formatJSON(output *ResultEvent) ([]byte, error) {\n\tif !w.jsonReqResp { // don't show request-response in json if not asked\n\t\toutput.Request = \"\"\n\t\toutput.Response = \"\"\n\t}\n\treturn jsoniter.Marshal(output)\n}", "title": "" }, { "docid": "b070ce5a25891c500bfe03f44aab77b7", "score": "0.4980291", "text": "func (av *AppVersion) ToJson() []byte {\n\tbuf, _ := json.Marshal(av)\n\treturn buf\n}", "title": "" }, { "docid": "69dae04e6f843eb3f2db2d32d95de4af", "score": "0.4969814", "text": "func writeJSON(w http.ResponseWriter, code int, indent bool, v interface{}) error {\n\tdata, err := marshal(indent, v)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t// This is almost certainly a developer error.\n\t\tlog.Println(\"json marshal error: \", err)\n\t\treturn err\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tw.WriteHeader(code)\n\tif _, err = w.Write(data); err != nil {\n\t\tlog.Printf(\"error writing response (maybe not returned to user): %v\", err)\n\t}\n\treturn err\n}", "title": "" }, { "docid": "f89001c3afe10c56bb8df326828b0e71", "score": "0.49698088", "text": "func (a Application) MarshalJSON() ([]byte, error) {\n\ta.ObjectType = ObjectTypeApplication\n\tobjectMap := make(map[string]interface{})\n\tif a.AppID != nil {\n\t\tobjectMap[\"appId\"] = a.AppID\n\t}\n\tif a.AllowGuestsSignIn != nil {\n\t\tobjectMap[\"allowGuestsSignIn\"] = a.AllowGuestsSignIn\n\t}\n\tif a.AllowPassthroughUsers != nil {\n\t\tobjectMap[\"allowPassthroughUsers\"] = a.AllowPassthroughUsers\n\t}\n\tif a.AppLogoURL != nil {\n\t\tobjectMap[\"appLogoUrl\"] = a.AppLogoURL\n\t}\n\tif a.AppRoles != nil {\n\t\tobjectMap[\"appRoles\"] = a.AppRoles\n\t}\n\tif a.AppPermissions != nil {\n\t\tobjectMap[\"appPermissions\"] = a.AppPermissions\n\t}\n\tif a.AvailableToOtherTenants != nil {\n\t\tobjectMap[\"availableToOtherTenants\"] = a.AvailableToOtherTenants\n\t}\n\tif a.DisplayName != nil {\n\t\tobjectMap[\"displayName\"] = a.DisplayName\n\t}\n\tif a.ErrorURL != nil {\n\t\tobjectMap[\"errorUrl\"] = a.ErrorURL\n\t}\n\tif a.GroupMembershipClaims != \"\" {\n\t\tobjectMap[\"groupMembershipClaims\"] = a.GroupMembershipClaims\n\t}\n\tif a.Homepage != nil {\n\t\tobjectMap[\"homepage\"] = a.Homepage\n\t}\n\tif a.IdentifierUris != nil {\n\t\tobjectMap[\"identifierUris\"] = a.IdentifierUris\n\t}\n\tif a.InformationalUrls != nil {\n\t\tobjectMap[\"informationalUrls\"] = a.InformationalUrls\n\t}\n\tif a.IsDeviceOnlyAuthSupported != nil {\n\t\tobjectMap[\"isDeviceOnlyAuthSupported\"] = a.IsDeviceOnlyAuthSupported\n\t}\n\tif a.KeyCredentials != nil {\n\t\tobjectMap[\"keyCredentials\"] = a.KeyCredentials\n\t}\n\tif a.KnownClientApplications != nil {\n\t\tobjectMap[\"knownClientApplications\"] = a.KnownClientApplications\n\t}\n\tif a.LogoutURL != nil {\n\t\tobjectMap[\"logoutUrl\"] = a.LogoutURL\n\t}\n\tif a.Oauth2AllowImplicitFlow != nil {\n\t\tobjectMap[\"oauth2AllowImplicitFlow\"] = a.Oauth2AllowImplicitFlow\n\t}\n\tif a.Oauth2AllowURLPathMatching != nil {\n\t\tobjectMap[\"oauth2AllowUrlPathMatching\"] = a.Oauth2AllowURLPathMatching\n\t}\n\tif a.Oauth2Permissions != nil {\n\t\tobjectMap[\"oauth2Permissions\"] = a.Oauth2Permissions\n\t}\n\tif a.Oauth2RequirePostResponse != nil {\n\t\tobjectMap[\"oauth2RequirePostResponse\"] = a.Oauth2RequirePostResponse\n\t}\n\tif a.OrgRestrictions != nil {\n\t\tobjectMap[\"orgRestrictions\"] = a.OrgRestrictions\n\t}\n\tif a.OptionalClaims != nil {\n\t\tobjectMap[\"optionalClaims\"] = a.OptionalClaims\n\t}\n\tif a.PasswordCredentials != nil {\n\t\tobjectMap[\"passwordCredentials\"] = a.PasswordCredentials\n\t}\n\tif a.PreAuthorizedApplications != nil {\n\t\tobjectMap[\"preAuthorizedApplications\"] = a.PreAuthorizedApplications\n\t}\n\tif a.PublicClient != nil {\n\t\tobjectMap[\"publicClient\"] = a.PublicClient\n\t}\n\tif a.PublisherDomain != nil {\n\t\tobjectMap[\"publisherDomain\"] = a.PublisherDomain\n\t}\n\tif a.ReplyUrls != nil {\n\t\tobjectMap[\"replyUrls\"] = a.ReplyUrls\n\t}\n\tif a.RequiredResourceAccess != nil {\n\t\tobjectMap[\"requiredResourceAccess\"] = a.RequiredResourceAccess\n\t}\n\tif a.SamlMetadataURL != nil {\n\t\tobjectMap[\"samlMetadataUrl\"] = a.SamlMetadataURL\n\t}\n\tif a.SignInAudience != nil {\n\t\tobjectMap[\"signInAudience\"] = a.SignInAudience\n\t}\n\tif a.WwwHomepage != nil {\n\t\tobjectMap[\"wwwHomepage\"] = a.WwwHomepage\n\t}\n\tif a.ObjectType != \"\" {\n\t\tobjectMap[\"objectType\"] = a.ObjectType\n\t}\n\tfor k, v := range a.AdditionalProperties {\n\t\tobjectMap[k] = v\n\t}\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "89eb39eef21d41df8a1b77601b6b095d", "score": "0.49657157", "text": "func writeJSONResponse(w http.ResponseWriter, status int, body interface{}) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(status)\n\tb, _ := json.MarshalIndent(body, \"\", \" \")\n\tw.Write(append(b, []byte(\"\\n\")...))\n}", "title": "" }, { "docid": "aaafc18b11f7aad9a79347b4e794a0a8", "score": "0.49547035", "text": "func WriteJSON(w http.ResponseWriter, b []byte) {\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\tw.WriteHeader(http.StatusOK)\n\tw.Write(b)\n}", "title": "" }, { "docid": "12098f634607f114bbc57d70db1c7394", "score": "0.49461272", "text": "func Print(v ...interface{}) {\n\tfor _, value := range v {\n\t\tb, err := json.MarshalIndent(value, \"\", \" \")\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\t\tfmt.Println(string(b))\n\t}\n}", "title": "" }, { "docid": "4d768d9495f315a54eb236ee242d9c68", "score": "0.4943782", "text": "func main() {\n\tp1 := persona{\n\t\tNombre: \"James\",\n\t\tApellido: \"Bond\",\n\t\tedad: 32,\n\t}\n\tp2 := persona{\n\t\tNombre: \"Miss \",\n\t\tApellido: \"Money Penny\",\n\t\tedad: 27,\n\t}\n\tpersonas := []persona{\n\t\tp1,\n\t\tp2,\n\t}\n\tfmt.Println(personas)\n\n\tsb, err := json.Marshal(personas)\n\tif err != nil {\n\t\tfmt.Println(\"Error \", err)\n\t}\n\tfmt.Println(string(sb))\n}", "title": "" }, { "docid": "f645f828d5d89176e77360c4565bf9f1", "score": "0.4940273", "text": "func writeJSON(w http.ResponseWriter, payload interface{}) {\n\tbytes, err := json.Marshal(payload)\n\thelpers.ErrorCheck(err, false)\n\tif err != nil {\n\t\treturn\n\t}\n\tw.WriteHeader(http.StatusOK)\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Write(bytes)\n}", "title": "" }, { "docid": "7a37a91499453717506bce29df9e1159", "score": "0.493625", "text": "func writeJSONOutput(r *buildResult, out string) error {\n\tb, err := json.MarshalIndent(r, \"\", \" \")\n\tif err != nil {\n\t\treturn errors.Annotate(err, \"failed to marshal to JSON: %v\", r).Err()\n\t}\n\tif out == \"-\" {\n\t\tfmt.Printf(\"%s\\n\", b)\n\t\treturn nil\n\t}\n\treturn errors.Annotate(ioutil.WriteFile(out, b, 0600), \"failed to write %q\", out).Err()\n}", "title": "" }, { "docid": "97f0f68eafdf59df41d43247f9836a6a", "score": "0.4925887", "text": "func PrintJson(path string) {\n\tbuff, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Unmarshal json string\n\tvar str map[string]interface{}\n\terr = json.Unmarshal(buff, &str)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tTraverseMap(str)\n}", "title": "" }, { "docid": "9d4cc7af8d7a3dbedea940b19063cfba", "score": "0.49251902", "text": "func writeJSONToBrowser(w http.ResponseWriter, message string) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Write([]byte(message))\n}", "title": "" }, { "docid": "6f8d23919625201b7bee84b41e666aa6", "score": "0.49223486", "text": "func (h *HttpServer) findApps(w http.ResponseWriter, req *http.Request) {\n\terr := req.ParseForm()\n\tif err != nil {\n\t\tlog.Println(\"agent http: findApps - \", err)\n\t\treturn\n\t}\n\tpattern := req.FormValue(\"pattern\")\n\tinfos, err := FindApps(pattern)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tenc := json.NewEncoder(w)\n\terr = enc.Encode(map[string]interface{}{\n\t\t\"Data\": infos})\n\tif err != nil {\n\t\tlog.Println(\"agent http: findApps - \", err)\n\t\treturn\n\t}\n}", "title": "" }, { "docid": "c6d4fb1e52d9521ab08e59bea3dcdf38", "score": "0.49077895", "text": "func (v DeveloperApp) MarshalJSON() ([]byte, error) {\n\tw := jwriter.Writer{}\n\teasyjsonCaf77204EncodeGithubComTarbBfapi4(&w, v)\n\treturn w.Buffer.BuildBytes(), w.Error\n}", "title": "" }, { "docid": "da3ffe7b9c49f02f0fd7e35ac4f1af8f", "score": "0.4896355", "text": "func WriteJSON(w http.ResponseWriter, i interface{}) error {\n\tb, err := json.MarshalIndent(i, \"\", \" \")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\tw.Write(b)\n\n\treturn nil\n}", "title": "" }, { "docid": "5c8f940b7950af7de11101d9fc420801", "score": "0.4888877", "text": "func commGetApps(wConn *wconn.WrapppedConn, data glob.J) {\n\tapps := make([]glob.J, 0)\n\n\tfor id, app := range apps_list.GetApps() {\n\t\tapps = append(apps, glob.J{\n\t\t\t\"id\": id,\n\t\t\t\"name\": app.GetData()[\"name\"],\n\t\t\t\"state\": app.GetData()[\"is_registered\"],\n\t\t\t\"running\": app.Running,\n\t\t})\n\t}\n\n\twConn.Send(glob.J{\n\t\t\"type\": \"res\",\n\t\t\"pipeID\": data[\"pipeID\"],\n\t\t\"apps\": apps,\n\t})\n}", "title": "" }, { "docid": "3c374fe7c1dab6f2fa1747cd5256dd25", "score": "0.48792395", "text": "func writeJSON(w http.ResponseWriter, obj interface{}) error {\n\twriteContentType(w, jsonContentType)\n\tjsonBytes, err := Marshal(obj)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = w.Write(jsonBytes)\n\treturn err\n}", "title": "" }, { "docid": "6177dc0beeadc03f1ed2af184fa71c4a", "score": "0.48703337", "text": "func (f *Faker) JSON(jo *JSONOptions) ([]byte, error) { return jsonFunc(f, jo) }", "title": "" }, { "docid": "1c1ed5c96b7622164ba08851d8d03bc1", "score": "0.48676473", "text": "func WrapApplicationJSON(h http.HandlerFunc) http.HandlerFunc {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Add(\"Content-Type\", \"application/json\")\n\t\th.ServeHTTP(w, r)\n\t})\n}", "title": "" }, { "docid": "86fc46be7bc4dc59011abb87e5b10a29", "score": "0.48661578", "text": "func (a ApplicationListResult) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]any)\n\tpopulate(objectMap, \"nextLink\", a.NextLink)\n\tpopulate(objectMap, \"value\", a.Value)\n\treturn json.Marshal(objectMap)\n}", "title": "" }, { "docid": "68a0ccc55e348d14de6c2a5ce87e09f1", "score": "0.48660517", "text": "func WriteJSON(w http.ResponseWriter, status int, v interface{}) {\n\tj, err := json.Marshal(v)\n\tif err != nil {\n\t\thttp.Error(w, fmt.Sprintf(`WriteJSON error: %v`, err), http.StatusInternalServerError)\n\t\treturn\n\t}\n\t//fmt.Println(string(j))\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(status)\n\tfmt.Fprint(w, string(j))\n}", "title": "" } ]
56f4867392e351ed3d7489dcc864f973
NUMACPUsOfNode Get CPU slice from the specified Node
[ { "docid": "565358572b218366b1da1e30ac051b9e", "score": "0.73151845", "text": "func NUMACPUsOfNode(node string) ([]string, error) {\n\tif !IsNumaAvailable() {\n\t\treturn nil, ErrNumaNotAvailable\n\t}\n\tnodei, err := strconv.Atoi(node)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"node %s is invalid\", node)\n\t}\n\n\tmask := C.numa_allocate_cpumask()\n\tdefer C.numa_free_cpumask(mask)\n\trc := C.numa_node_to_cpus(C.int(nodei), mask)\n\tmaxCpus := NUMAConfiguredCPUs()\n\tcpus := make([]string, 0, maxCpus)\n\tif rc >= 0 {\n\t\tfor i := 0; i < maxCpus; i++ {\n\t\t\tif C.numa_bitmask_isbitset(mask, C.uint(i)) > 0 {\n\t\t\t\tcpus = append(cpus, strconv.Itoa(i))\n\t\t\t}\n\t\t}\n\t} else {\n\t\treturn cpus, ErrNumaNotAvailable\n\t}\n\treturn cpus, nil\n}", "title": "" } ]
[ { "docid": "5f67c14af939318e49809b70114e4ea0", "score": "0.6243569", "text": "func (o *SubscriptionMetrics) ComputeNodesCpu() *ClusterResource {\n\tif o != nil && o.bitmap_&2 != 0 {\n\t\treturn o.computeNodesCpu\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "49bb32c512692c6cad4caaa0f4b28e3f", "score": "0.59608066", "text": "func availCpu(c clientset.Interface, node *v1.Node) (int64, error) {\n\tpodClient := c.Core().Pods(metav1.NamespaceAll)\n\n\tselector := fields.Set{\"spec.nodeName\": node.Name}.AsSelector().String()\n\toptions := metav1.ListOptions{FieldSelector: selector}\n\tpods, err := podClient.List(options)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"failed to retrieve all the pods on node %s: %v\", node.Name, err)\n\t}\n\tavail := node.Status.Capacity.Cpu().MilliValue()\n\tfor _, pod := range pods.Items {\n\t\tfor _, cont := range pod.Spec.Containers {\n\t\t\tavail -= cont.Resources.Requests.Cpu().MilliValue()\n\t\t}\n\t}\n\treturn avail, nil\n}", "title": "" }, { "docid": "e78170ec3443569f80d17263a62990da", "score": "0.5949228", "text": "func gpuInNode(node v1.Node) int64 {\n\tval, ok := node.Status.Capacity[NVIDIAGPUResourceName]\n\n\tif !ok {\n\t\treturn gpuInNodeDeprecated(node)\n\t}\n\n\treturn val.Value()\n}", "title": "" }, { "docid": "f72732898aa3685075b515d60366610c", "score": "0.5929117", "text": "func (m *magnesium) SelectCPUNodes(nodes []types.NodeInfo, quota float64, need int) (map[string][]types.CPUMap, map[string]types.CPUMap, error) {\n\tm.Lock()\n\tdefer m.Unlock()\n\n\tresult := make(map[string][]types.CPUMap)\n\tchanged := make(map[string]types.CPUMap)\n\tif len(nodes) == 0 {\n\t\treturn result, nil, fmt.Errorf(\"No nodes provide to choose some\")\n\t}\n\n\tif quota > 0 {\n\t\ttotal := totalQuota(nodes)\n\t\trequiredCPU := need * int(quota)\n\t\tif total < requiredCPU {\n\t\t\treturn result, nil, fmt.Errorf(\"Not enough CPUs, total: %d, require: %d\", total, need)\n\t\t}\n\t}\n\ndone:\n\tfor {\n\t\tfor _, node := range nodes {\n\t\t\tnodename := node.Name\n\t\t\tr, err := getQuota(node.CpuMap, int(quota))\n\t\t\tif err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tresult[nodename] = append(result[nodename], r)\n\t\t\tif resultLength(result) == need {\n\t\t\t\tbreak done\n\t\t\t}\n\t\t}\n\t}\n\n\t// 只把有修改的返回回去就可以了, 返回还剩下多少\n\tfor _, node := range nodes {\n\t\tnodename := node.Name\n\t\tif _, ok := result[nodename]; ok {\n\t\t\tchanged[nodename] = node.CpuMap\n\t\t}\n\t}\n\treturn result, changed, nil\n}", "title": "" }, { "docid": "3fe12b7561260b7463da872a30073432", "score": "0.59243786", "text": "func CPUNode(url string) (values map[string]interface{}) {\n\tqueryurl := url + path + \"?\" + \"query=\" + u.QueryEscape(cpuNode)\n\n\tvalues = utils.HTTPGetNodeMetric(queryurl)\n\n\treturn values\n}", "title": "" }, { "docid": "675dbcc3c9ba2e5f4fcabcff83046dd8", "score": "0.5878195", "text": "func (o *SubscriptionMetrics) GetComputeNodesCpu() (value *ClusterResource, ok bool) {\n\tok = o != nil && o.bitmap_&2 != 0\n\tif ok {\n\t\tvalue = o.computeNodesCpu\n\t}\n\treturn\n}", "title": "" }, { "docid": "05334d91f5db10a67833fef212a5e063", "score": "0.55764496", "text": "func (a *cpuAccumulator) freeCPUs() []int {\n\tresult := []int{}\n\tcores := a.details.Cores().ToSlice()\n\n\tsort.Slice(\n\t\tcores,\n\t\tfunc(i, j int) bool {\n\t\t\tiCore := cores[i]\n\t\t\tjCore := cores[j]\n\n\t\t\tiCPUs := a.topo.CPUDetails.CPUsInCores(iCore).ToSlice()\n\t\t\tjCPUs := a.topo.CPUDetails.CPUsInCores(jCore).ToSlice()\n\n\t\t\tiSocket := a.topo.CPUDetails[iCPUs[0]].SocketID\n\t\t\tjSocket := a.topo.CPUDetails[jCPUs[0]].SocketID\n\n\t\t\t// Compute the number of CPUs in the result reside on the same socket\n\t\t\t// as each core.\n\t\t\tiSocketColoScore := a.topo.CPUDetails.CPUsInSockets(iSocket).Intersection(a.result).Size()\n\t\t\tjSocketColoScore := a.topo.CPUDetails.CPUsInSockets(jSocket).Intersection(a.result).Size()\n\n\t\t\t// Compute the number of available CPUs available on the same socket\n\t\t\t// as each core.\n\t\t\tiSocketFreeScore := a.details.CPUsInSockets(iSocket).Size()\n\t\t\tjSocketFreeScore := a.details.CPUsInSockets(jSocket).Size()\n\n\t\t\t// Compute the number of available CPUs on each core.\n\t\t\tiCoreFreeScore := a.details.CPUsInCores(iCore).Size()\n\t\t\tjCoreFreeScore := a.details.CPUsInCores(jCore).Size()\n\n\t\t\treturn iSocketColoScore > jSocketColoScore ||\n\t\t\t\tiSocketFreeScore < jSocketFreeScore ||\n\t\t\t\tiCoreFreeScore < jCoreFreeScore ||\n\t\t\t\tiSocket < jSocket ||\n\t\t\t\tiCore < jCore\n\t\t})\n\n\t// For each core, append sorted CPU IDs to result.\n\tfor _, core := range cores {\n\t\tresult = append(result, a.details.CPUsInCores(core).ToSlice()...)\n\t}\n\treturn result\n}", "title": "" }, { "docid": "0e919abf6a341e99ff1be962ede2f638", "score": "0.55089164", "text": "func (client *KubeletClient) GetNodeCpuFrequency(node *v1.Node) (float64, error) {\n\tip, err := util.GetNodeIPForMonitor(node, types.KubeletSource)\n\tif err != nil {\n\t\tglog.Errorf(\"Failed to get IP for node %s: %s\", node.Name, err)\n\t\treturn 0, err\n\t}\n\tos, arch := util.GetNodeOSArch(node)\n\tglog.Infof(\"Node %s is running with %s/%s.\", node.Name, os, arch)\n\t// Get value from cache if exists\n\tclient.cacheLock.Lock()\n\tentry, entryPresent := client.cache[ip]\n\tif entryPresent {\n\t\tif entry.nodeCpuFreq != nil {\n\t\t\tnodeFreq := *entry.nodeCpuFreq\n\t\t\tclient.cacheLock.Unlock()\n\t\t\treturn nodeFreq, nil\n\t\t}\n\t}\n\tclient.cacheLock.Unlock()\n\n\t// We could not get a valid cpu frequency from cache, discover it.\n\tvar nodeFreq float64\n\tvar freqDiscovered = true\n\tif mInfo, err := client.GetMachineInfo(ip, node.Name); err == nil {\n\t\tnodeFreq = util.MetricKiloToMega(float64(mInfo.CpuFrequency))\n\t} else {\n\t\tglog.Warningf(\"Failed to get CPU frequency for node %s from kubelet: %v. Will try job based getter.\",\n\t\t\tnode.Name, err)\n\t\tnodeFreq, freqDiscovered = client.GetCpuFrequencyFromJob(node, os+\".\"+arch)\n\t}\n\n\tif !freqDiscovered {\n\t\t// We probably could not discover the cpufreq by any means and default\n\t\t// value is what we need to stick to. However, we might be able to discover\n\t\t// a valid one in the next discovery cycle.\n\t\treturn client.defaultCpuFreq, nil\n\t}\n\n\t// We optimistically set a cpu frequency of last discovered node as default.\n\t// Clusters more often then not have similar nodes.\n\tclient.defaultCpuFreq = nodeFreq\n\n\t// Update cache\n\tclient.cacheLock.Lock()\n\tdefer client.cacheLock.Unlock()\n\tif entryPresent {\n\t\tclient.cache[ip].nodeCpuFreq = &nodeFreq\n\t} else {\n\t\tentry := &CacheEntry{\n\t\t\tstatsSummary: nil,\n\t\t\tnodeCpuFreq: &nodeFreq,\n\t\t}\n\t\tclient.cache[ip] = entry\n\t}\n\n\treturn nodeFreq, nil\n}", "title": "" }, { "docid": "99fd1bb84c96a9c5b16e2513c3a932c5", "score": "0.5498776", "text": "func (n *Node) CPUCores() float64 {\n\t// [core*hr]*([min/hr]*[1/min]) = [core*hr]/[hr] = core\n\treturn n.CPUCoreHours * (60.0 / n.Minutes())\n}", "title": "" }, { "docid": "3ce62ae0e4712e355c5c04e14b087bb3", "score": "0.54664326", "text": "func (o *SubscriptionMetrics) Cpu() *ClusterResource {\n\tif o != nil && o.bitmap_&32 != 0 {\n\t\treturn o.cpu\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "67486d836c64c36d5dd0822c2edf6277", "score": "0.54536575", "text": "func CollectNodeMetrics(nodeAllocatableResources map[string]int64,\n namespace string, podListOptions *metav1.ListOptions) []int {\n // prepare node allocatable&allocated resources\n nodeResources := map[string][]int64{}\n for nodeName, allocatableResourceValue := range nodeAllocatableResources {\n nodeResources[nodeName] = []int64{allocatableResourceValue, 0}\n }\n // get pods & update node metrics\n pods, _ := kubeclient.GetPods(namespace, podListOptions)\n if pods != nil {\n for _, pod := range pods.Items {\n nodeName := pod.Spec.NodeName\n if _, ok := nodeResources[nodeName]; ok {\n var allocatedResource int64\n if mem, ok := pod.Labels[cache.KeyMemRequest]; ok {\n quantity := resource.MustParse(mem)\n allocatedResource += quantity.MilliValue()\n }\n nodeResources[nodeName][1] += allocatedResource\n }\n }\n } else {\n fmt.Println(\"Get nil nodes\")\n }\n // calculate node metrics\n buckets := []int{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}\n for nodeName, nodeResourceValues := range nodeResources {\n if len(nodeResourceValues) == 2 {\n ratio := float32(nodeResourceValues[1] * 10) / float32(nodeResourceValues[0])\n bucketIndex := int(ratio)\n buckets[bucketIndex] += 1\n } else {\n fmt.Println(\"No \", nodeName, len(nodeResourceValues))\n }\n }\n return buckets\n}", "title": "" }, { "docid": "bf666fe311390c02bc01b6c1b6d2b57b", "score": "0.5421323", "text": "func getContainerCPU(options getMetricsOptions) (int64, error) {\n\toptions.command = \"cat /sys/fs/cgroup/cpuacct/cpuacct.usage\"\n\treturn getContainerIntMetric(options)\n}", "title": "" }, { "docid": "d1be8138376db3b87ff0801df4281aa8", "score": "0.5414693", "text": "func (o *SubscriptionMetrics) GetCpu() (value *ClusterResource, ok bool) {\n\tok = o != nil && o.bitmap_&32 != 0\n\tif ok {\n\t\tvalue = o.cpu\n\t}\n\treturn\n}", "title": "" }, { "docid": "f6f8c3066f9c9086ebf52ff72b567c51", "score": "0.5375512", "text": "func GetCPUMetricsSlice(numMetrics int) []string {\n\tif numMetrics <= 0 {\n\t\tfatal(errNoMetrics)\n\t\treturn nil\n\t}\n\tif numMetrics > len(cpuMetrics) {\n\t\tfatal(errTooManyMetrics)\n\t\treturn nil\n\t}\n\treturn cpuMetrics[:numMetrics]\n}", "title": "" }, { "docid": "0a943c63262b2a4d605d8495233a3baf", "score": "0.5351492", "text": "func (p *podpools) availableMilliCPUs(pool *Pool) int64 {\n\tcpuAvail := int64(pool.CPUs.Size() * 1000)\n\tcpuRequested := int64(0)\n\tfor podID := range pool.PodIDs {\n\t\tcpuRequested += p.getPodMilliCPU(podID)\n\t}\n\treturn cpuAvail - cpuRequested\n}", "title": "" }, { "docid": "d31c5f548ad432818ede97292703a12d", "score": "0.5346366", "text": "func (nodeProbe *NodeProbe) getNodeResourceStat(slaveInfo *util.Slave, useMap map[string]*util.CalculatedUse) (*NodeResourceStat, error) {\n\t// The return cpu frequency is in KHz, we need MHz\n\t// TODO pam , how to get slave frequency?\n\t//\tcpuFrequency := 400 // machineInfo.CpuFrequency / 1000\n\t// TODO pam\tnodeMachineInfoMap[node.Name] = machineInfo\n\n\t// Here we only need the root container.\n\t// To get a valid cpu usage, there must be at least 2 valid stats.\n\t//\tintervalInNs := currentStat.Timestamp.Sub(prevStat.Timestamp).Nanoseconds()\n\t//\tglog.V(4).Infof(\"interval is %d\", intervalInNs)\n\t//\tcurrentStat := containerStats[len(containerStats)-1]\n\t//\tprevStat := containerStats[len(containerStats)-2]\n\t//\trawUsage := int64(currentStat.Cpu.Usage.Total - prevStat.Cpu.Usage.Total)\n\t//\tglog.V(4).Infof(\"rawUsage is %d\", rawUsage)\n\t//\tintervalInNs := currentStat.Timestamp.Sub(prevStat.Timestamp).Nanoseconds()\n\t//\tglog.V(4).Infof(\"interval is %d\", intervalInNs)\n\t//\trootCurCpu := slaveInfo.UsedResouces.CPUs//float64(rawUsage) * 1.0 / float64(intervalInNs)\n\t//\trootCurMem := slaveInfo.UsedResources.Mem//float64(currentStat.Memory.Usage) / 1024 // Mem is returned in B\n\n\t// Get the node Cpu and Mem capacity.\n\tnodeCpuCapacity := slaveInfo.Resources.CPUs * float64(2000) //float64(slaveInfo.Resources.CPUs) * float64(cpuFrequency)\n\t// Mem is returned in B\n\tnodeMemCapacity := slaveInfo.Resources.Mem\n\tnodeDiskCapacity := slaveInfo.Resources.Disk\n\tglog.V(4).Infof(\"Discovered node is %f\\n\", slaveInfo.Id)\n\tglog.V(4).Infof(\"Node CPU capacity is %f \\n\", nodeCpuCapacity)\n\tglog.V(4).Infof(\"Node Mem capacity is %f \\n\", nodeMemCapacity)\n\tglog.V(4).Infof(\"Node Disk capacity is %f \\n\", nodeDiskCapacity)\n\n\t// Find out the used value for each commodity\n\tcpuUsed := useMap[slaveInfo.Id].CPUs\n\tmemUsed := useMap[slaveInfo.Id].Mem\n\tdiskUsed := slaveInfo.UsedResources.Disk\n\tglog.V(4).Infof(\"Discovered node is %f\\n\", slaveInfo.Id)\n\tglog.V(4).Infof(\"=======> Node CPU used is %f \\n\", cpuUsed)\n\tglog.V(4).Infof(\"Node Mem used is %f \\n\", memUsed)\n\tglog.V(4).Infof(\"Node Disk used is %f \\n\", diskUsed)\n\n\treturn &NodeResourceStat{\n\t\tdiskAllocationCapacity: nodeDiskCapacity,\n\t\tdiskAllocationUsed: diskUsed,\n\t\tcpuAllocationCapacity: nodeCpuCapacity,\n\t\tcpuAllocationUsed: cpuUsed,\n\t\tmemAllocationCapacity: nodeMemCapacity,\n\t\tmemAllocationUsed: memUsed,\n\t\tvCpuCapacity: nodeCpuCapacity,\n\t\tvCpuUsed: cpuUsed,\n\t\tvMemCapacity: nodeMemCapacity,\n\t\tvMemUsed: memUsed,\n\t}, nil\n\n}", "title": "" }, { "docid": "beb1b777fa28943f4a9ee7dff7f5527a", "score": "0.53418916", "text": "func NewCPUCollector() (Collector, error) {\n\treturn &cpuCollector{\n\t\tcpuCount: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, nodeCollectorSubsystem, \"cpu_count\"),\n\t\t\t\"Count of number of cpu a node contains.\",\n\t\t\t[]string{\"node\"}, ConstLabels,\n\t\t),\n\t\tcpuIdle: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, nodeCollectorSubsystem, \"cpu_idle_avg\"),\n\t\t\t\"Current cpu idle percentage for the node.\",\n\t\t\t[]string{\"node\"}, ConstLabels,\n\t\t),\n\t\tcpuUser: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, nodeCollectorSubsystem, \"cpu_user_avg\"),\n\t\t\t\"Current cpu busy percentage for user mode represented in 0.0-1.0.\",\n\t\t\t[]string{\"node\"}, ConstLabels,\n\t\t),\n\t\tcpuSys: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, nodeCollectorSubsystem, \"cpu_sys_avg\"),\n\t\t\t\"Current cpu busy percentage for sys mode represented in 0.0-1.0.\",\n\t\t\t[]string{\"node\"}, ConstLabels,\n\t\t),\n\t\tload1min: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, nodeCollectorSubsystem, \"load_1min\"),\n\t\t\t\"Current 1min node load.\",\n\t\t\t[]string{\"node\"}, ConstLabels,\n\t\t),\n\t\tload5min: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, nodeCollectorSubsystem, \"load_5min\"),\n\t\t\t\"Current 5min node load.\",\n\t\t\t[]string{\"node\"}, ConstLabels,\n\t\t),\n\t\tload15min: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, nodeCollectorSubsystem, \"load_15min\"),\n\t\t\t\"Current 15min node load.\",\n\t\t\t[]string{\"node\"}, ConstLabels,\n\t\t),\n\t}, nil\n}", "title": "" }, { "docid": "cc8734fa3b31672d422c9252f039e712", "score": "0.5320113", "text": "func (p *CoreProvider) GetNodeMetrics(nodes ...string) ([]api.TimeInfo, []corev1.ResourceList, error) {\n\ttimeInfo := make([]api.TimeInfo, len(nodes))\n\tcoreMetrics := make([]corev1.ResourceList, len(nodes))\n\tresourceNames := make([]string, len(nodes))\n\n\tfor i := range nodes {\n\t\tresourceNames[i] = fmt.Sprintf(\"%q\", nodes[i])\n\t}\n\n\tcpuMetrics, cpuTimeInfo, err := p.client.getNodeCPU(nodes)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tramMetrics, _, err := p.client.getNodeRAM(nodes)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tfor i, name := range nodes {\n\t\tcpu, ok := cpuMetrics[name]\n\t\tif !ok {\n\t\t\tklog.V(4).Infof(\"Metric cpu not found for node '%s'\", name)\n\t\t\tcontinue\n\t\t}\n\t\tram, ok := ramMetrics[name]\n\t\tif !ok {\n\t\t\tklog.V(4).Infof(\"Metric ram not found for node '%s'\", name)\n\t\t\tcontinue\n\t\t}\n\t\tcoreMetrics[i] = corev1.ResourceList{\n\t\t\tcorev1.ResourceCPU: cpu,\n\t\t\tcorev1.ResourceMemory: ram,\n\t\t}\n\t\ttimeInfo[i] = cpuTimeInfo[name]\n\t\tif !ok {\n\t\t\treturn nil, nil, apierr.NewInternalError(fmt.Errorf(\"TimeInfo should be set for every node with metrics\"))\n\t\t}\n\t}\n\treturn timeInfo, coreMetrics, nil\n}", "title": "" }, { "docid": "b5007763f0690386021e7b2fdacada2a", "score": "0.5274605", "text": "func (o *SubscriptionMetrics) ComputeNodesMemory() *ClusterResource {\n\tif o != nil && o.bitmap_&4 != 0 {\n\t\treturn o.computeNodesMemory\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "3c8b642e6e08d5704325bb3b817326bf", "score": "0.52571166", "text": "func PodCPU(pod *api.Pod) *resource.Quantity {\n\tval := int64(0)\n\tfor j := range pod.Spec.Containers {\n\t\tval = val + pod.Spec.Containers[j].Resources.Limits.Cpu().MilliValue()\n\t}\n\treturn resource.NewMilliQuantity(int64(val), resource.DecimalSI)\n}", "title": "" }, { "docid": "1527c3b452e5291070eb2316b45556f4", "score": "0.52437353", "text": "func (app *ApplicationConfig) GetCPULimit() int64 {\n\tif app.Resources.CPU == 0 {\n\t\tapp.Resources.CPU = DefaultCPUs\n\t}\n\treturn int64(app.Resources.CPU * math.Pow(10, 9))\n}", "title": "" }, { "docid": "6c87a8a8b838f17dc162e5f74e97d13f", "score": "0.5229705", "text": "func (nodeProbe *NodeProbe) getNodeResourceStat(node *api.Node, nodePodsMap map[string][]*api.Pod) (*NodeResourceStat, error) {\n\tsource := &vmtAdvisor.CadvisorSource{}\n\n\thost := nodeProbe.getHost(node.Name)\n\tmachineInfo, err := source.GetMachineInfo(*host)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Error getting machineInfo for %s: %s\", node.Name, err)\n\t}\n\t// The return cpu frequency is in KHz, we need MHz\n\tcpuFrequency := machineInfo.CpuFrequency / 1000\n\tnodeMachineInfoMap[node.Name] = machineInfo\n\n\t// Here we only need the root container.\n\t_, root, err := source.GetAllContainers(*host, time.Now(), time.Now())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Error getting root container info for %s: %s\", node.Name, err)\n\t}\n\tcontainerStats := root.Stats\n\t// To get a valid cpu usage, there must be at least 2 valid stats.\n\tif len(containerStats) < 2 {\n\t\tglog.Warning(\"Not enough data\")\n\t\treturn nil, fmt.Errorf(\"Not enough status data of current node %s.\", node.Name)\n\t}\n\tcurrentStat := containerStats[len(containerStats)-1]\n\tprevStat := containerStats[len(containerStats)-2]\n\trawUsage := int64(currentStat.Cpu.Usage.Total - prevStat.Cpu.Usage.Total)\n\tglog.V(4).Infof(\"rawUsage is %d\", rawUsage)\n\tintervalInNs := currentStat.Timestamp.Sub(prevStat.Timestamp).Nanoseconds()\n\tglog.V(4).Infof(\"interval is %d\", intervalInNs)\n\trootCurCpu := float64(rawUsage) * 1.0 / float64(intervalInNs)\n\trootCurMem := float64(currentStat.Memory.Usage) / 1024 // Mem is returned in B\n\n\t// Get the node Cpu and Mem capacity.\n\tnodeCpuCapacity := float64(machineInfo.NumCores) * float64(cpuFrequency)\n\tnodeMemCapacity := float64(machineInfo.MemoryCapacity) / 1024 // Mem is returned in B\n\tglog.V(3).Infof(\"Discovered node is \" + node.Name)\n\tglog.V(4).Infof(\"Node CPU capacity is %f\", nodeCpuCapacity)\n\tglog.V(4).Infof(\"Node Mem capacity is %f\", nodeMemCapacity)\n\t// Find out the used value for each commodity\n\tcpuUsed := float64(rootCurCpu) * float64(cpuFrequency)\n\tmemUsed := float64(rootCurMem)\n\n\t// TODO we will re-include provisioned commodities sold by node later.\n\t//cpuProvisionedUsed := float64(0)\n\t//memProvisionedUsed := float64(0)\n\t//\n\t//if podList, exist := nodePodsMap[node.Name]; exist {\n\t//\tfor _, pod := range podList {\n\t//\t\tcpuRequest, memRequest, err := GetResourceRequest(pod)\n\t//\t\tif err != nil {\n\t//\t\t\treturn nil, fmt.Errorf(\"Error getting provisioned resource consumption: %s\", err)\n\t//\t\t}\n\t//\t\tcpuProvisionedUsed += cpuRequest\n\t//\t\tmemProvisionedUsed += memRequest\n\t//\t}\n\t//}\n\t//cpuProvisionedUsed *= float64(cpuFrequency)\n\n\treturn &NodeResourceStat{\n\t\tvCpuCapacity: nodeCpuCapacity,\n\t\tvCpuUsed: cpuUsed,\n\t\tvMemCapacity: nodeMemCapacity,\n\t\tvMemUsed: memUsed,\n\t\t// TODO we will re-include provisioned commodities sold by node later.\n\t\t//cpuProvisionedCapacity: nodeCpuCapacity,\n\t\t//cpuProvisionedUsed: cpuProvisionedUsed,\n\t\t//memProvisionedCapacity: nodeMemCapacity,\n\t\t//memProvisionedUsed: memProvisionedUsed,\n\t}, nil\n}", "title": "" }, { "docid": "0f4d01bab47861b9802d7b79e107839e", "score": "0.52067983", "text": "func (o *PrivateHostPlan) GetCPU() int {\n\treturn o.CPU\n}", "title": "" }, { "docid": "502bbee65190afa3f78a9ffdd872fd65", "score": "0.5161824", "text": "func GetNodes(client kubernetes.Interface) (*types.KurlNodes, error) {\n\tnodes, err := client.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"list nodes\")\n\t}\n\n\ttoReturn := types.KurlNodes{}\n\n\tfor _, node := range nodes.Items {\n\t\tcpuCapacity := types.CapacityAvailable{}\n\t\tmemoryCapacity := types.CapacityAvailable{}\n\t\tpodCapacity := types.CapacityAvailable{}\n\n\t\tmemoryCapacity.Capacity = float64(node.Status.Capacity.Memory().Value()) / math.Pow(2, 30) // capacity in GB\n\n\t\tcpuCapacity.Capacity, err = strconv.ParseFloat(node.Status.Capacity.Cpu().String(), 64)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"parse CPU capacity %q for node %s\", node.Status.Capacity.Cpu().String(), node.Name)\n\t\t}\n\n\t\tpodCapacity.Capacity = float64(node.Status.Capacity.Pods().Value())\n\n\t\tnodeIP := \"\"\n\t\tfor _, address := range node.Status.Addresses {\n\t\t\tif address.Type == v1.NodeInternalIP {\n\t\t\t\tnodeIP = address.Address\n\t\t\t}\n\t\t}\n\n\t\tif nodeIP == \"\" {\n\t\t\tlogger.Infof(\"Did not find address for node %s, %+v\", node.Name, node.Status.Addresses)\n\t\t} else {\n\t\t\tnodeMetrics, err := getNodeMetrics(nodeIP)\n\t\t\tif err != nil {\n\t\t\t\tlogger.Infof(\"Got error retrieving stats for node %q: %v\", node.Name, err)\n\t\t\t} else {\n\t\t\t\tif nodeMetrics.Node.Memory != nil && nodeMetrics.Node.Memory.AvailableBytes != nil {\n\t\t\t\t\tmemoryCapacity.Available = float64(*nodeMetrics.Node.Memory.AvailableBytes) / math.Pow(2, 30)\n\t\t\t\t}\n\n\t\t\t\tif nodeMetrics.Node.CPU != nil && nodeMetrics.Node.CPU.UsageNanoCores != nil {\n\t\t\t\t\tcpuCapacity.Available = cpuCapacity.Capacity - (float64(*nodeMetrics.Node.CPU.UsageNanoCores) / math.Pow(10, 9))\n\t\t\t\t}\n\n\t\t\t\tpodCapacity.Available = podCapacity.Capacity - float64(len(nodeMetrics.Pods))\n\t\t\t}\n\t\t}\n\n\t\tnodeLabelArray := []string{}\n\t\tfor k, v := range node.Labels {\n\t\t\tnodeLabelArray = append(nodeLabelArray, fmt.Sprintf(\"%s:%s\", k, v))\n\t\t}\n\n\t\ttoReturn.Nodes = append(toReturn.Nodes, types.Node{\n\t\t\tName: node.Name,\n\t\t\tIsConnected: isConnected(node),\n\t\t\tIsReady: isReady(node),\n\t\t\tIsPrimaryNode: isPrimary(node),\n\t\t\tCanDelete: node.Spec.Unschedulable && !isConnected(node),\n\t\t\tKubeletVersion: node.Status.NodeInfo.KubeletVersion,\n\t\t\tCPU: cpuCapacity,\n\t\t\tMemory: memoryCapacity,\n\t\t\tPods: podCapacity,\n\t\t\tLabels: nodeLabelArray,\n\t\t\tConditions: findNodeConditions(node.Status.Conditions),\n\t\t})\n\t}\n\n\tkurlConf, err := ReadConfigMap(client)\n\tif err != nil {\n\t\tif kuberneteserrors.IsNotFound(err) {\n\t\t\ttoReturn.IsKurlEnabled = false\n\t\t\treturn &toReturn, nil\n\t\t}\n\t\treturn nil, errors.Wrap(err, \"get kurl config\")\n\t}\n\n\ttoReturn.IsKurlEnabled = true\n\n\tif val, ok := kurlConf.Data[\"ha\"]; ok && val != \"\" {\n\t\tparsedBool, err := strconv.ParseBool(val)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"parse 'ha' entry in kurl config %q\", val)\n\t\t}\n\t\ttoReturn.HA = parsedBool\n\t}\n\n\treturn &toReturn, nil\n}", "title": "" }, { "docid": "ad1cb995e4d722298017522a75827f47", "score": "0.5147307", "text": "func (a *cpuAccumulator) freeCPUs() []int {\n\treturn a.sortAvailableCPUs()\n}", "title": "" }, { "docid": "22aa4c8b9be62c28a0143a8616110b1f", "score": "0.51454526", "text": "func calculateNodeGPU(nodeInfo NodeInfo) (totalGPU int64, allocatedGPU int64) {\n\tnode := nodeInfo.node\n\ttotalGPU = gpuInNode(node)\n\t// allocatedGPU = gpuInPod()\n\n\tfor _, pod := range nodeInfo.pods {\n\t\tallocatedGPU += gpuInPod(pod)\n\t}\n\n\treturn totalGPU, allocatedGPU\n}", "title": "" }, { "docid": "1b2aa706f095c8f5b38249bd389dbc53", "score": "0.5143688", "text": "func (rl *ResourceList) CPU() *resource.Quantity {\n\treturn rl.Name(ResourceCPU, resource.DecimalSI)\n}", "title": "" }, { "docid": "053225d44eff8938b6fadb3acfb8365f", "score": "0.513438", "text": "func getCPUNum() int {\n\treturn runtime.NumCPU()\n}", "title": "" }, { "docid": "17db98bd3f69b07a1fcbbcfebfb6671e", "score": "0.5132751", "text": "func guaranteedCPUs(container *v1.Container) int {\n\tcpuQuantity := container.Resources.Requests[v1.ResourceCPU]\n\tif cpuQuantity.Value()*1000 != cpuQuantity.MilliValue() {\n\t\treturn 0\n\t}\n\n\treturn int(cpuQuantity.Value())\n}", "title": "" }, { "docid": "ae5c6e717ca65b910260ddaf0e3d91df", "score": "0.51110977", "text": "func getIrqBalanceBannedCPUs(node *corev1.Node) (cpuset.CPUSet, error) {\n\tcmd := []string{\"cat\", \"/rootfs/etc/sysconfig/irqbalance\"}\n\tconf, err := nodes.ExecCommandOnNode(cmd, node)\n\tif err != nil {\n\t\treturn cpuset.New(), err\n\t}\n\n\tkeyValue := findIrqBalanceBannedCPUsVarFromConf(conf)\n\tif len(keyValue) == 0 {\n\t\t// can happen: everything commented out (default if no tuning ever)\n\t\ttestlog.Warningf(\"cannot find the CPU ban list in the configuration (\\n%s)\\n\", conf)\n\t\treturn cpuset.New(), nil\n\t}\n\n\ttestlog.Infof(\"banned CPUs setting: %q\", keyValue)\n\n\titems := strings.FieldsFunc(keyValue, func(c rune) bool {\n\t\treturn c == '='\n\t})\n\tif len(items) == 1 {\n\t\treturn cpuset.New(), nil\n\t}\n\tif len(items) != 2 {\n\t\treturn cpuset.New(), fmt.Errorf(\"malformed CPU ban list in the configuration\")\n\t}\n\n\tbannedCPUs := unquote(strings.TrimSpace(items[1]))\n\ttestlog.Infof(\"banned CPUs: %q\", bannedCPUs)\n\n\tbanned, err := components.CPUMaskToCPUSet(bannedCPUs)\n\tif err != nil {\n\t\treturn cpuset.New(), fmt.Errorf(\"failed to parse the banned CPUs: %v\", err)\n\t}\n\n\treturn banned, nil\n}", "title": "" }, { "docid": "7ffb6c1ec1e3b7c8af1b9141845108fa", "score": "0.5103641", "text": "func NodePodsStats(node string) ([]*PodStats, float64, error) {\n\tpods, err := coreclient.GetNodePods(node)\n\tif err != nil {\n\t\treturn nil, 0, err\n\t}\n\n\tres := make([]*PodStats, 0, len(pods))\n\n\t// 1 CPU core == 1000 m\n\ttotalRequestCpu := int64(0)\n\n\tfor _, pod := range pods {\n\t\tif pod.Status.Phase != \"Running\" {\n\t\t\tcontinue\n\t\t}\n\t\tif _, ok := pod.Annotations[\"dist\"]; !ok {\n\t\t\tfor _, c := range pod.Spec.Containers {\n\t\t\t\tcpuMCores, ok := c.Resources.Requests.Cpu().AsInt64()\n\t\t\t\tif !ok {\n\t\t\t\t\tcpuMCores = c.Resources.Requests.Cpu().AsDec().UnscaledBig().Int64()\n\t\t\t\t}\n\t\t\t\ttotalRequestCpu += cpuMCores\n\t\t\t\t//glog.Errorf(\"[%q] pod %q, cont %q, status %v occupies %fM cpu\", node, pod.Name, c.Name, pod.Status.Phase, cpuMCores)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tstats, err := PodMeanStd(&pod)\n\t\tif err != nil {\n\t\t\treturn nil, 0, err\n\t\t}\n\t\tres = append(res, stats)\n\t}\n\n\treturn res, float64(totalRequestCpu) / 1000, nil\n}", "title": "" }, { "docid": "ffb01fbae3393ac36293cba42f4864db", "score": "0.5077244", "text": "func (p *podpools) getPodMilliCPU(podID string) int64 {\n\tcpuRequested := int64(0)\n\tfor _, c := range p.cch.GetContainers() {\n\t\tif c.GetPodID() == podID {\n\t\t\tif reqCpu, ok := c.GetResourceRequirements().Requests[corev1.ResourceCPU]; ok {\n\t\t\t\tcpuRequested += reqCpu.MilliValue()\n\t\t\t}\n\t\t}\n\t}\n\treturn cpuRequested\n}", "title": "" }, { "docid": "ca81d404d0c11860d4a5a1787c8c35b2", "score": "0.5044747", "text": "func (o *PrivateHost) GetCPU() int {\n\treturn o.CPU\n}", "title": "" }, { "docid": "8cb21543a12977cddae65de101b95bc4", "score": "0.5042583", "text": "func (o *V0037JobResponseProperties) GetMinimumCpusPerNode() int32 {\n\tif o == nil || o.MinimumCpusPerNode == nil {\n\t\tvar ret int32\n\t\treturn ret\n\t}\n\treturn *o.MinimumCpusPerNode\n}", "title": "" }, { "docid": "9754a79bbebcc5fbf582b1cfcf14e944", "score": "0.5037737", "text": "func (f *framework) GetNodeUsageFactor(nodeName string) (int){\r\n return f.nodeUsageMap[nodeName]\r\n}", "title": "" }, { "docid": "e396343369b3fe99e19cb8754c636865", "score": "0.5020615", "text": "func BenchmarkGetNode_10000_Nodes(b *testing.B) {\n\tbaselineBenchmark(2500, 5)(b)\n}", "title": "" }, { "docid": "46400079143f64b122501d0941b64541", "score": "0.5019332", "text": "func (n *NodeInfo) AllocatedCPU() resource.Quantity {\n\tvar totalCPU resource.Quantity\n\tfor _, pod := range n.Pods {\n\t\tfor _, container := range pod.Spec.Containers {\n\t\t\trequestedCPU := container.Resources.Requests[\"cpu\"]\n\t\t\ttotalCPU.Add(requestedCPU)\n\t\t\tglog.V(8).Infof(\"pod %s, container %s requested %s cpu\", pod.Name, container.Name, requestedCPU.String())\n\t\t}\n\t}\n\treturn totalCPU\n}", "title": "" }, { "docid": "c58a4e9c615e9522153ba38c83d79534", "score": "0.5018575", "text": "func (ns *node) NodeGetCapabilities(\n\tctx context.Context,\n\treq *csi.NodeGetCapabilitiesRequest,\n) (*csi.NodeGetCapabilitiesResponse, error) {\n\n\tlogrus.Infof(\"NodeGetCapabilities: called with args %+v\", *req)\n\tvar caps []*csi.NodeServiceCapability\n\tfor _, cap := range nodeCaps {\n\t\tc := &csi.NodeServiceCapability{\n\t\t\tType: &csi.NodeServiceCapability_Rpc{\n\t\t\t\tRpc: &csi.NodeServiceCapability_RPC{\n\t\t\t\t\tType: cap,\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t\tcaps = append(caps, c)\n\t}\n\treturn &csi.NodeGetCapabilitiesResponse{Capabilities: caps}, nil\n}", "title": "" }, { "docid": "690e6d140276a4fa3b8a088daf4ab454", "score": "0.5013452", "text": "func (m *Monitor) QueryCpus() (ret []CPUInfo, err error) {\n\tcmd := struct {\n\t}{}\n\tbs, err := json.Marshal(map[string]interface{}{\n\t\t\"execute\": \"query-cpus\",\n\t\t\"arguments\": cmd,\n\t})\n\tif err != nil {\n\t\treturn\n\t}\n\tbs, err = m.mon.Run(bs)\n\tif err != nil {\n\t\treturn\n\t}\n\tres := struct {\n\t\tRes json.RawMessage `json:\"return\"`\n\t}{}\n\tif err = json.Unmarshal(bs, &res); err != nil {\n\t\treturn\n\t}\n\tvar reslist []json.RawMessage\n\tif err = json.Unmarshal([]byte(res.Res), &reslist); err != nil {\n\t\treturn\n\t}\n\tfor _, r := range reslist {\n\t\tv, err := decodeCPUInfo(r)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tret = append(ret, v)\n\t}\n\treturn\n}", "title": "" }, { "docid": "2851717470e6c06290bd14208097558e", "score": "0.49962184", "text": "func (v *VirtualizationTool) getVcpusInRequest(lcr *kubeapi.LinuxContainerResources) int64 {\n\treturn lcr.CpuQuota / lcr.CpuPeriod\n}", "title": "" }, { "docid": "f7f1c7971b347dabfdedf6b94815c481", "score": "0.49894887", "text": "func (o *SubscriptionMetrics) Nodes() *ClusterMetricsNodes {\n\tif o != nil && o.bitmap_&512 != 0 {\n\t\treturn o.nodes\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "be7af5be38425c5d90402ecd954de192", "score": "0.49891096", "text": "func (cs *supply) hintCpus(h topology.Hint) cpuset.CPUSet {\n\tvar cpus cpuset.CPUSet\n\n\tswitch {\n\tcase h.CPUs != \"\":\n\t\tcpus = cpuset.MustParse(h.CPUs)\n\n\tcase h.NUMAs != \"\":\n\t\tfor _, idstr := range strings.Split(h.NUMAs, \",\") {\n\t\t\tif id, err := strconv.ParseInt(idstr, 0, 0); err == nil {\n\t\t\t\tif node := cs.node.System().Node(idset.ID(id)); node != nil {\n\t\t\t\t\tcpus = cpus.Union(node.CPUSet())\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\tcase h.Sockets != \"\":\n\t\tfor _, idstr := range strings.Split(h.Sockets, \",\") {\n\t\t\tif id, err := strconv.ParseInt(idstr, 0, 0); err == nil {\n\t\t\t\tif pkg := cs.node.System().Package(idset.ID(id)); pkg != nil {\n\t\t\t\t\tcpus = cpus.Union(pkg.CPUSet())\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn cpus\n}", "title": "" }, { "docid": "600bd6ea9b67368a1b018cbbd8f76571", "score": "0.4970587", "text": "func (r ResourceProfiler) getCPU() (string, *cerror.CError) {\n\tcpuPercent, err := cpu.Percent(0, false)\n\tif err != nil {\n\t\tcErr := cerror.NewCError(cerror.GOPSUTIL_CPU_ERR, err.Error())\n\t\treturn \"\", cErr\n\t}\n\tcpuUsage := strconv.FormatFloat(cpuPercent[0], 'f', 2, 64)\n\treturn cpuUsage, nil\n}", "title": "" }, { "docid": "2bdce2a7c6805f6503794bf5f68e09f7", "score": "0.4952252", "text": "func CPU(lower float64, upper float64, pollingInterval time.Duration, windowSize int) Option {\n\treturn func(m *Loadshed) *Loadshed {\n\t\tm.aggregators = append(m.aggregators, rolling.NewPercentageRollup(newAvgCPU(pollingInterval, windowSize), lower, upper, \"ChanceCPU\"))\n\t\treturn m\n\t}\n}", "title": "" }, { "docid": "391c950c639ba3c446eff86085801433", "score": "0.4949308", "text": "func takeByTopology(topo *topology.CPUTopology, availableCPUs cpuset.CPUSet, numCPUs int) (cpuset.CPUSet, error) {\n\tacc := newCPUAccumulator(topo, availableCPUs, numCPUs)\n\tif acc.isSatisfied() {\n\t\treturn acc.result, nil\n\t}\n\tif acc.isFailed() {\n\t\treturn cpuset.NewCPUSet(), fmt.Errorf(\"not enough cpus available to satisfy request\")\n\t}\n\n\t// Algorithm: topology-aware best-fit\n\t// 1. Acquire whole sockets, if available and the container requires at\n\t// least a socket's-worth of CPUs.\n\tif acc.needs(acc.topo.CPUsPerSocket()) {\n\t\tfor _, s := range acc.freeSockets() {\n\t\t\tklog.V(4).Infof(\"[cpumanager] takeByTopology: claiming socket [%d]\", s)\n\t\t\tacc.take(acc.details.CPUsInSockets(s))\n\t\t\tif acc.isSatisfied() {\n\t\t\t\treturn acc.result, nil\n\t\t\t}\n\t\t\tif !acc.needs(acc.topo.CPUsPerSocket()) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\t// 2. Acquire whole cores, if available and the container requires at least\n\t// a core's-worth of CPUs.\n\tif acc.needs(acc.topo.CPUsPerCore()) {\n\t\tfor _, c := range acc.freeCores() {\n\t\t\tklog.V(4).Infof(\"[cpumanager] takeByTopology: claiming core [%d]\", c)\n\t\t\tacc.take(acc.details.CPUsInCores(c))\n\t\t\tif acc.isSatisfied() {\n\t\t\t\treturn acc.result, nil\n\t\t\t}\n\t\t\tif !acc.needs(acc.topo.CPUsPerCore()) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\t// 3. Acquire single threads, preferring to fill partially-allocated cores\n\t// on the same sockets as the whole cores we have already taken in this\n\t// allocation.\n\tfor _, c := range acc.freeCPUs() {\n\t\tklog.V(4).Infof(\"[cpumanager] takeByTopology: claiming CPU [%d]\", c)\n\t\tif acc.needs(1) {\n\t\t\tacc.take(cpuset.NewCPUSet(c))\n\t\t}\n\t\tif acc.isSatisfied() {\n\t\t\treturn acc.result, nil\n\t\t}\n\t}\n\n\treturn cpuset.NewCPUSet(), fmt.Errorf(\"failed to allocate cpus\")\n}", "title": "" }, { "docid": "0cb252b5129c4966e99cc4213db7471d", "score": "0.49459606", "text": "func CPU(Interval time.Duration) []float64 {\n\tCPUPercent, Err := cpu.Percent(Interval*time.Second, false)\n\tif Err != nil {\n\t\tLog(Err)\n\t\tpanic(Err)\n\t}\n\treturn CPUPercent\n}", "title": "" }, { "docid": "1f4e28be67a9c678d5d61478c182c98a", "score": "0.494426", "text": "func (o *SubscriptionMetrics) GetComputeNodesMemory() (value *ClusterResource, ok bool) {\n\tok = o != nil && o.bitmap_&4 != 0\n\tif ok {\n\t\tvalue = o.computeNodesMemory\n\t}\n\treturn\n}", "title": "" }, { "docid": "8af58de3b378b4dbf7ff80d52265e7e6", "score": "0.49402186", "text": "func (d *jsiiProxy_Domain) MetricCPUUtilization(props *awscloudwatch.MetricOptions) awscloudwatch.Metric {\n\tvar returns awscloudwatch.Metric\n\n\t_jsii_.Invoke(\n\t\td,\n\t\t\"metricCPUUtilization\",\n\t\t[]interface{}{props},\n\t\t&returns,\n\t)\n\n\treturn returns\n}", "title": "" }, { "docid": "1060b86373a819cb692491a06684625b", "score": "0.49334618", "text": "func (s *KubernetesCommandService) RunKubernetesNodePoolGet(c *CmdConfig) error {\n\tif len(c.Args) != 2 {\n\t\treturn doctl.NewMissingArgsErr(c.NS)\n\t}\n\tclusterID, err := clusterIDize(c, c.Args[0])\n\tif err != nil {\n\t\treturn err\n\t}\n\tnodePool, err := poolByIDorName(c.Kubernetes(), clusterID, c.Args[1])\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn displayNodePools(c, *nodePool)\n}", "title": "" }, { "docid": "641ea02ca04f79d7f77a3a91ab681d8d", "score": "0.493137", "text": "func gpuInNodeDeprecated(node v1.Node) int64 {\n\tval, ok := node.Status.Capacity[DeprecatedNVIDIAGPUResourceName]\n\n\tif !ok {\n\t\treturn 0\n\t}\n\n\treturn val.Value()\n}", "title": "" }, { "docid": "d1b1c2a438abfc2eed030ce268b310b7", "score": "0.49283805", "text": "func (o *ServerPlan) GetCPU() int {\n\treturn o.CPU\n}", "title": "" }, { "docid": "72f543dda4b6fe295473eaf60d11f311", "score": "0.49257243", "text": "func (t *sngCapacityThreshold) NodeLimit(nodeGroup cloudprovider.NodeGroup, context EstimationContext) int {\n\tif context == nil {\n\t\treturn 0\n\t}\n\ttotalAvailableCapacity := t.computeNodeGroupCapacity(nodeGroup)\n\tfor _, sng := range context.SimilarNodeGroups() {\n\t\ttotalAvailableCapacity += t.computeNodeGroupCapacity(sng)\n\t}\n\tif totalAvailableCapacity <= 0 {\n\t\treturn -1\n\t}\n\treturn totalAvailableCapacity\n}", "title": "" }, { "docid": "18c0b7324654f79e2f9b047f4e8c91b6", "score": "0.49239278", "text": "func (c CPUSet) ToSlice() []uint16 {\n\tcpus := []uint16{}\n\tfor k := range c.cpus {\n\t\tcpus = append(cpus, k)\n\t}\n\tsort.Slice(cpus, func(i, j int) bool { return cpus[i] < cpus[j] })\n\treturn cpus\n}", "title": "" }, { "docid": "2c664b5b520b76a1dd0f09b6101d5709", "score": "0.49229005", "text": "func GetCPUData() (CPU, error) {\r\n\tvar cpu CPU\r\n\tvar errstr string\r\n\tvar wg sync.WaitGroup\r\n\twg.Add(2)\r\n\tgo getUsageData(&wg, &cpu, &errstr)\r\n\tgo getTempData(&wg, &cpu, &errstr)\r\n\twg.Wait()\r\n\tif errstr != \"\" {\r\n\t\treturn cpu, errors.New(errstr)\r\n\t}\r\n\r\n\treturn cpu, nil\r\n}", "title": "" }, { "docid": "49713dc9ee6160885264e6910d8ff257", "score": "0.49148932", "text": "func ParseCPUs(s string, coresNumber uint) ([]uint, error) {\n\tvar startRange, k int\n\tnums := make([]uint, 0, 256)\n\tif s == \"\" {\n\t\treturn nums, nil\n\t}\n\tstartRange = -1\n\tvar err error\n\tfor i, j := 0, 0; i <= len(s); i++ {\n\t\tif i != len(s) && s[i] == '-' {\n\t\t\tstartRange, err = strconv.Atoi(s[j:i])\n\t\t\tif err != nil {\n\t\t\t\treturn nums, WrapWithNFError(err, \"parsing of CPU list failed\", ParseCPUListErr)\n\t\t\t}\n\t\t\tj = i + 1\n\t\t}\n\n\t\tif i == len(s) || s[i] == ',' {\n\t\t\tr, err := strconv.Atoi(s[j:i])\n\t\t\tif err != nil {\n\t\t\t\treturn nums, WrapWithNFError(err, \"parsing of CPU list failed\", ParseCPUListErr)\n\t\t\t}\n\t\t\tif startRange != -1 {\n\t\t\t\tif startRange > r {\n\t\t\t\t\treturn nums, WrapWithNFError(nil, \"CPU range is invalid, min should not exceed max\", InvalidCPURangeErr)\n\t\t\t\t}\n\t\t\t\tfor k = startRange; k <= r; k++ {\n\t\t\t\t\tnums = append(nums, uint(k))\n\t\t\t\t}\n\t\t\t\tstartRange = -1\n\t\t\t} else {\n\t\t\t\tnums = append(nums, uint(r))\n\t\t\t}\n\t\t\tif i == len(s) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tj = i + 1\n\t\t}\n\t}\n\n\tnums = removeDuplicates(nums)\n\n\tnumCPU := uint(runtime.NumCPU())\n\tfor _, cpu := range nums {\n\t\tif cpu >= numCPU {\n\t\t\treturn []uint{}, WrapWithNFError(nil, \"requested cpu exceeds maximum cores number on machine\", MaxCPUExceedErr)\n\t\t}\n\t}\n\tif len(nums) > int(coresNumber) {\n\t\treturn nums[:coresNumber], nil\n\t}\n\n\treturn nums, nil\n}", "title": "" }, { "docid": "1cff6f10a24a69cf966ed45b950620c4", "score": "0.49123365", "text": "func (n *NodeInfo) FreeCPU() resource.Quantity {\n\tfree := n.AllocatableCPU().DeepCopy()\n\tfree.Sub(n.AllocatedCPU())\n\treturn free\n}", "title": "" }, { "docid": "38428ac3de32e1522340a2e1187bf8a1", "score": "0.4909626", "text": "func takeByTopologyNUMADistributed(topo *topology.CPUTopology, availableCPUs cpuset.CPUSet, numCPUs int, cpuGroupSize int) (cpuset.CPUSet, error) {\n\t// If the number of CPUs requested cannot be handed out in chunks of\n\t// 'cpuGroupSize', then we just call out the packing algorithm since we\n\t// can't distribute CPUs in this chunk size.\n\tif (numCPUs % cpuGroupSize) != 0 {\n\t\treturn takeByTopologyNUMAPacked(topo, availableCPUs, numCPUs)\n\t}\n\n\t// Otherwise build an accumulator to start allocating CPUs from.\n\tacc := newCPUAccumulator(topo, availableCPUs, numCPUs)\n\tif acc.isSatisfied() {\n\t\treturn acc.result, nil\n\t}\n\tif acc.isFailed() {\n\t\treturn cpuset.New(), fmt.Errorf(\"not enough cpus available to satisfy request\")\n\t}\n\n\t// Get the list of NUMA nodes represented by the set of CPUs in 'availableCPUs'.\n\tnumas := acc.sortAvailableNUMANodes()\n\n\t// Calculate the minimum and maximum possible number of NUMA nodes that\n\t// could satisfy this request. This is used to optimize how many iterations\n\t// of the loop we need to go through below.\n\tminNUMAs, maxNUMAs := acc.rangeNUMANodesNeededToSatisfy(cpuGroupSize)\n\n\t// Try combinations of 1,2,3,... NUMA nodes until we find a combination\n\t// where we can evenly distribute CPUs across them. To optimize things, we\n\t// don't always start at 1 and end at len(numas). Instead, we use the\n\t// values of 'minNUMAs' and 'maxNUMAs' calculated above.\n\tfor k := minNUMAs; k <= maxNUMAs; k++ {\n\t\t// Iterate through the various n-choose-k NUMA node combinations,\n\t\t// looking for the combination of NUMA nodes that can best have CPUs\n\t\t// distributed across them.\n\t\tvar bestBalance float64 = math.MaxFloat64\n\t\tvar bestRemainder []int = nil\n\t\tvar bestCombo []int = nil\n\t\tacc.iterateCombinations(numas, k, func(combo []int) LoopControl {\n\t\t\t// If we've already found a combo with a balance of 0 in a\n\t\t\t// different iteration, then don't bother checking any others.\n\t\t\tif bestBalance == 0 {\n\t\t\t\treturn Break\n\t\t\t}\n\n\t\t\t// Check that this combination of NUMA nodes has enough CPUs to\n\t\t\t// satisfy the allocation overall.\n\t\t\tcpus := acc.details.CPUsInNUMANodes(combo...)\n\t\t\tif cpus.Size() < numCPUs {\n\t\t\t\treturn Continue\n\t\t\t}\n\n\t\t\t// Check that CPUs can be handed out in groups of size\n\t\t\t// 'cpuGroupSize' across the NUMA nodes in this combo.\n\t\t\tnumCPUGroups := 0\n\t\t\tfor _, numa := range combo {\n\t\t\t\tnumCPUGroups += (acc.details.CPUsInNUMANodes(numa).Size() / cpuGroupSize)\n\t\t\t}\n\t\t\tif (numCPUGroups * cpuGroupSize) < numCPUs {\n\t\t\t\treturn Continue\n\t\t\t}\n\n\t\t\t// Check that each NUMA node in this combination can allocate an\n\t\t\t// even distribution of CPUs in groups of size 'cpuGroupSize',\n\t\t\t// modulo some remainder.\n\t\t\tdistribution := (numCPUs / len(combo) / cpuGroupSize) * cpuGroupSize\n\t\t\tfor _, numa := range combo {\n\t\t\t\tcpus := acc.details.CPUsInNUMANodes(numa)\n\t\t\t\tif cpus.Size() < distribution {\n\t\t\t\t\treturn Continue\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Calculate how many CPUs will be available on each NUMA node in\n\t\t\t// the system after allocating an even distribution of CPU groups\n\t\t\t// of size 'cpuGroupSize' from each NUMA node in 'combo'. This will\n\t\t\t// be used in the \"balance score\" calculation to help decide if\n\t\t\t// this combo should ultimately be chosen.\n\t\t\tavailableAfterAllocation := make(mapIntInt, len(numas))\n\t\t\tfor _, numa := range numas {\n\t\t\t\tavailableAfterAllocation[numa] = acc.details.CPUsInNUMANodes(numa).Size()\n\t\t\t}\n\t\t\tfor _, numa := range combo {\n\t\t\t\tavailableAfterAllocation[numa] -= distribution\n\t\t\t}\n\n\t\t\t// Check if there are any remaining CPUs to distribute across the\n\t\t\t// NUMA nodes once CPUs have been evenly distributed in groups of\n\t\t\t// size 'cpuGroupSize'.\n\t\t\tremainder := numCPUs - (distribution * len(combo))\n\n\t\t\t// Get a list of NUMA nodes to consider pulling the remainder CPUs\n\t\t\t// from. This list excludes NUMA nodes that don't have at least\n\t\t\t// 'cpuGroupSize' CPUs available after being allocated\n\t\t\t// 'distribution' number of CPUs.\n\t\t\tvar remainderCombo []int\n\t\t\tfor _, numa := range combo {\n\t\t\t\tif availableAfterAllocation[numa] >= cpuGroupSize {\n\t\t\t\t\tremainderCombo = append(remainderCombo, numa)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Declare a set of local variables to help track the \"balance\n\t\t\t// scores\" calculated when using different subsets of\n\t\t\t// 'remainderCombo' to allocate remainder CPUs from.\n\t\t\tvar bestLocalBalance float64 = math.MaxFloat64\n\t\t\tvar bestLocalRemainder []int = nil\n\n\t\t\t// If there aren't any remainder CPUs to allocate, then calculate\n\t\t\t// the \"balance score\" of this combo as the standard deviation of\n\t\t\t// the values contained in 'availableAfterAllocation'.\n\t\t\tif remainder == 0 {\n\t\t\t\tbestLocalBalance = standardDeviation(availableAfterAllocation.Values())\n\t\t\t\tbestLocalRemainder = nil\n\t\t\t}\n\n\t\t\t// Otherwise, find the best \"balance score\" when allocating the\n\t\t\t// remainder CPUs across different subsets of NUMA nodes in 'remainderCombo'.\n\t\t\t// These remainder CPUs are handed out in groups of size 'cpuGroupSize'.\n\t\t\t// We start from k=len(remainderCombo) and walk down to k=1 so that\n\t\t\t// we continue to distribute CPUs as much as possible across\n\t\t\t// multiple NUMA nodes.\n\t\t\tfor k := len(remainderCombo); remainder > 0 && k >= 1; k-- {\n\t\t\t\tacc.iterateCombinations(remainderCombo, k, func(subset []int) LoopControl {\n\t\t\t\t\t// Make a local copy of 'remainder'.\n\t\t\t\t\tremainder := remainder\n\n\t\t\t\t\t// Make a local copy of 'availableAfterAllocation'.\n\t\t\t\t\tavailableAfterAllocation := availableAfterAllocation.Clone()\n\n\t\t\t\t\t// If this subset is not capable of allocating all\n\t\t\t\t\t// remainder CPUs, continue to the next one.\n\t\t\t\t\tif sum(availableAfterAllocation.Values(subset...)) < remainder {\n\t\t\t\t\t\treturn Continue\n\t\t\t\t\t}\n\n\t\t\t\t\t// For all NUMA nodes in 'subset', walk through them,\n\t\t\t\t\t// removing 'cpuGroupSize' number of CPUs from each\n\t\t\t\t\t// until all remainder CPUs have been accounted for.\n\t\t\t\t\tfor remainder > 0 {\n\t\t\t\t\t\tfor _, numa := range subset {\n\t\t\t\t\t\t\tif remainder == 0 {\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif availableAfterAllocation[numa] < cpuGroupSize {\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tavailableAfterAllocation[numa] -= cpuGroupSize\n\t\t\t\t\t\t\tremainder -= cpuGroupSize\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Calculate the \"balance score\" as the standard deviation\n\t\t\t\t\t// of the number of CPUs available on all NUMA nodes in the\n\t\t\t\t\t// system after the remainder CPUs have been allocated\n\t\t\t\t\t// across 'subset' in groups of size 'cpuGroupSize'.\n\t\t\t\t\tbalance := standardDeviation(availableAfterAllocation.Values())\n\t\t\t\t\tif balance < bestLocalBalance {\n\t\t\t\t\t\tbestLocalBalance = balance\n\t\t\t\t\t\tbestLocalRemainder = subset\n\t\t\t\t\t}\n\n\t\t\t\t\treturn Continue\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// If the best \"balance score\" for this combo is less than the\n\t\t\t// lowest \"balance score\" of all previous combos, then update this\n\t\t\t// combo (and remainder set) to be the best one found so far.\n\t\t\tif bestLocalBalance < bestBalance {\n\t\t\t\tbestBalance = bestLocalBalance\n\t\t\t\tbestRemainder = bestLocalRemainder\n\t\t\t\tbestCombo = combo\n\t\t\t}\n\n\t\t\treturn Continue\n\t\t})\n\n\t\t// If we made it through all of the iterations above without finding a\n\t\t// combination of NUMA nodes that can properly balance CPU allocations,\n\t\t// then move on to the next larger set of NUMA node combinations.\n\t\tif bestCombo == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Otherwise, start allocating CPUs from the NUMA node combination\n\t\t// chosen. First allocate an even distribution of CPUs in groups of\n\t\t// size 'cpuGroupSize' from 'bestCombo'.\n\t\tdistribution := (numCPUs / len(bestCombo) / cpuGroupSize) * cpuGroupSize\n\t\tfor _, numa := range bestCombo {\n\t\t\tcpus, _ := takeByTopologyNUMAPacked(acc.topo, acc.details.CPUsInNUMANodes(numa), distribution)\n\t\t\tacc.take(cpus)\n\t\t}\n\n\t\t// Then allocate any remaining CPUs in groups of size 'cpuGroupSize'\n\t\t// from each NUMA node in the remainder set.\n\t\tremainder := numCPUs - (distribution * len(bestCombo))\n\t\tfor remainder > 0 {\n\t\t\tfor _, numa := range bestRemainder {\n\t\t\t\tif remainder == 0 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tif acc.details.CPUsInNUMANodes(numa).Size() < cpuGroupSize {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tcpus, _ := takeByTopologyNUMAPacked(acc.topo, acc.details.CPUsInNUMANodes(numa), cpuGroupSize)\n\t\t\t\tacc.take(cpus)\n\t\t\t\tremainder -= cpuGroupSize\n\t\t\t}\n\t\t}\n\n\t\t// If we haven't allocated all of our CPUs at this point, then something\n\t\t// went wrong in our accounting and we should error out.\n\t\tif acc.numCPUsNeeded > 0 {\n\t\t\treturn cpuset.New(), fmt.Errorf(\"accounting error, not enough CPUs allocated, remaining: %v\", acc.numCPUsNeeded)\n\t\t}\n\n\t\t// Likewise, if we have allocated too many CPUs at this point, then something\n\t\t// went wrong in our accounting and we should error out.\n\t\tif acc.numCPUsNeeded < 0 {\n\t\t\treturn cpuset.New(), fmt.Errorf(\"accounting error, too many CPUs allocated, remaining: %v\", acc.numCPUsNeeded)\n\t\t}\n\n\t\t// Otherwise, return the result\n\t\treturn acc.result, nil\n\t}\n\n\t// If we never found a combination of NUMA nodes that we could properly\n\t// distribute CPUs across, fall back to the packing algorithm.\n\treturn takeByTopologyNUMAPacked(topo, availableCPUs, numCPUs)\n}", "title": "" }, { "docid": "3e93db3815ecab582ad7162bfe0f9a60", "score": "0.4909117", "text": "func PCPU() float64 {\n\treturn pcpu\n}", "title": "" }, { "docid": "de3e81c4ad89ef66d16a8285f4eba14c", "score": "0.48911756", "text": "func (o *ServerChangePlanRequest) GetCPU() int {\n\treturn o.CPU\n}", "title": "" }, { "docid": "9e2f0d672aafb0722488ff88cf09a477", "score": "0.48747814", "text": "func (o *LinodeType) GetVcpus() int32 {\n\tif o == nil || o.Vcpus == nil {\n\t\tvar ret int32\n\t\treturn ret\n\t}\n\treturn *o.Vcpus\n}", "title": "" }, { "docid": "7cc6f001203c827e3877d0eee649146a", "score": "0.4870845", "text": "func NewCIDRRangeAllocator(client clientset.Interface, clusterCIDR *net.IPNet, serviceCIDR *net.IPNet, subNetMaskSize int, nodeList *v1.NodeList) (CIDRAllocator, error) {\n\teventBroadcaster := record.NewBroadcaster()\n\trecorder := eventBroadcaster.NewRecorder(api.Scheme, clientv1.EventSource{Component: \"cidrAllocator\"})\n\teventBroadcaster.StartLogging(glog.Infof)\n\tif client != nil {\n\t\tglog.V(0).Infof(\"Sending events to api server.\")\n\t\teventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: v1core.New(client.Core().RESTClient()).Events(\"\")})\n\t} else {\n\t\tglog.Fatalf(\"kubeClient is nil when starting NodeController\")\n\t}\n\n\tra := &rangeAllocator{\n\t\tclient: client,\n\t\tcidrs: newCIDRSet(clusterCIDR, subNetMaskSize),\n\t\tclusterCIDR: clusterCIDR,\n\t\tnodeCIDRUpdateChannel: make(chan nodeAndCIDR, cidrUpdateQueueSize),\n\t\trecorder: recorder,\n\t\tnodesInProcessing: sets.NewString(),\n\t}\n\n\tif serviceCIDR != nil {\n\t\tra.filterOutServiceRange(serviceCIDR)\n\t} else {\n\t\tglog.V(0).Info(\"No Service CIDR provided. Skipping filtering out service addresses.\")\n\t}\n\n\tif nodeList != nil {\n\t\tfor _, node := range nodeList.Items {\n\t\t\tif node.Spec.PodCIDR == \"\" {\n\t\t\t\tglog.Infof(\"Node %v has no CIDR, ignoring\", node.Name)\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\tglog.Infof(\"Node %v has CIDR %s, occupying it in CIDR map\",\n\t\t\t\t\tnode.Name, node.Spec.PodCIDR)\n\t\t\t}\n\t\t\tif err := ra.occupyCIDR(&node); err != nil {\n\t\t\t\t// This will happen if:\n\t\t\t\t// 1. We find garbage in the podCIDR field. Retrying is useless.\n\t\t\t\t// 2. CIDR out of range: This means a node CIDR has changed.\n\t\t\t\t// This error will keep crashing controller-manager.\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t}\n\tfor i := 0; i < cidrUpdateWorkers; i++ {\n\t\tgo func(stopChan <-chan struct{}) {\n\t\t\tfor {\n\t\t\t\tselect {\n\t\t\t\tcase workItem, ok := <-ra.nodeCIDRUpdateChannel:\n\t\t\t\t\tif !ok {\n\t\t\t\t\t\tglog.Warning(\"NodeCIDRUpdateChannel read returned false.\")\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tra.updateCIDRAllocation(workItem)\n\t\t\t\tcase <-stopChan:\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}(wait.NeverStop)\n\t}\n\n\treturn ra, nil\n}", "title": "" }, { "docid": "109f00b7275a946bf35d7fc6675c7a45", "score": "0.48649883", "text": "func (e *aoeEngine) Node(ip string) *engine.NodeInfo {\n\tt0 := time.Now()\n\tdefer func() {\n\t\tlogutil.Debugf(\"time cost %d ms\", time.Since(t0).Milliseconds())\n\t}()\n\tvar ni *engine.NodeInfo\n\te.catalog.Driver.RaftStore().GetRouter().Every(uint64(pb.AOEGroup), true, func(shard *bhmetapb.Shard, store bhmetapb.Store) {\n\t\tif ni != nil {\n\t\t\treturn\n\t\t}\n\t\tif strings.HasPrefix(store.ClientAddr, ip) {\n\t\t\tstats := e.catalog.Driver.RaftStore().GetRouter().GetStoreStats(store.ID)\n\t\t\tcpuCnt := len(stats.GetCpuUsages())\n\t\t\tif cpuCnt < 1 {\n\t\t\t\tcpuCnt = 1\n\t\t\t}\n\t\t\tni = &engine.NodeInfo{\n\t\t\t\tMcpu: cpuCnt,\n\t\t\t}\n\t\t}\n\t})\n\treturn ni\n}", "title": "" }, { "docid": "afe787da56ff5e3667fde764cfdfb3b6", "score": "0.48537645", "text": "func (c *esClient) GetNodeAndThreadPoolStats() (*NodeStatsOutput, error) {\n\turl := fmt.Sprintf(\"%s://%s:%s/%s\", c.scheme, c.host, c.port, nodeStatsEndpoint)\n\n\tvar nodeStatsOutput NodeStatsOutput\n\n\terr := c.fetchJSON(url, &nodeStatsOutput)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &nodeStatsOutput, nil\n}", "title": "" }, { "docid": "f1a68f6372206572e874988007daba61", "score": "0.4849795", "text": "func (o ApplicationMaximumAllowedResourcesPtrOutput) Cpu() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ApplicationMaximumAllowedResources) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.Cpu\n\t}).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "320792184b52115727ffe8e1ddae9526", "score": "0.48323482", "text": "func (m *HostMetrics) GetCPU() int64 {\n\tbefore, err := cpu.Get()\n\tif err != nil {\n\t\tlog.Info(\"[ OS Metrics ] failed to get cpu Metrics\")\n\t\treturn 0\n\t}\n\ttime.Sleep(time.Duration(1) * time.Second)\n\tafter, err := cpu.Get()\n\tif err != nil {\n\t\tlog.Info(\"[ OS Metrics ] failed to get cpu Metrics\")\n\t\treturn 0\n\t}\n\ttotal := float64(after.Total - before.Total)\n\t// user + system\n\treturn int64(100 - float64(after.Idle-before.Idle)/total*100)\n}", "title": "" }, { "docid": "3783b9286681938dab0657eae28f84f1", "score": "0.48215735", "text": "func getMinionNodes(c *kubernetes.Clientset) *api.NodeList {\n\tnodes, err := c.Core().Nodes().List(\n\t\tmetav1.ListOptions{\n\t\t\tFieldSelector: \"spec.unschedulable=false\",\n\t\t})\n\tif err != nil {\n\t\tfmt.Println(\"Failed to fetch nodes\", err)\n\t\treturn nil\n\t}\n\treturn nodes\n}", "title": "" }, { "docid": "dafe5aa7ca56d101ded78feb01887bf0", "score": "0.48103717", "text": "func (o *VM) GetVcpus() int32 {\n\tif o == nil || o.Vcpus == nil {\n\t\tvar ret int32\n\t\treturn ret\n\t}\n\treturn *o.Vcpus\n}", "title": "" }, { "docid": "bd8ddd4eba833b6ac43edc423b917ff0", "score": "0.4799351", "text": "func NUMAConfiguredCPUs() int {\n\treturn int(C.numa_num_configured_cpus())\n}", "title": "" }, { "docid": "9142ed05bbdb117967013fac356dcb97", "score": "0.47938392", "text": "func predicateGPU(pod *v1.Pod, node *api.NodeInfo) int {\n\tgpuRequest := api.GetGPUResourceOfPod(pod)\n\tallocatableGPUs := node.GetDevicesIdleGPUMemory()\n\n\tfor devID := 0; devID < len(allocatableGPUs); devID++ {\n\t\tavailableGPU, ok := allocatableGPUs[devID]\n\t\tif ok {\n\t\t\tif availableGPU >= gpuRequest {\n\t\t\t\treturn devID\n\t\t\t}\n\t\t}\n\t}\n\n\treturn -1\n}", "title": "" }, { "docid": "e8a888f9299ff29afa980c7a6b62c562", "score": "0.4784952", "text": "func (o GetServiceMeshesMeshMeshConfigOpaOutput) LimitCpu() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetServiceMeshesMeshMeshConfigOpa) string { return v.LimitCpu }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "d09576f6cc446ccdf1bbace0508a59e7", "score": "0.4777972", "text": "func (m *NodeNetworkMock) GetWorkingNodesByRoleMinimockPreCounter() uint64 {\n\treturn atomic.LoadUint64(&m.GetWorkingNodesByRolePreCounter)\n}", "title": "" }, { "docid": "7299717ff34263cc060d63b53d563fcc", "score": "0.47741213", "text": "func (o *ServerCreateRequest) GetCPU() int {\n\treturn o.CPU\n}", "title": "" }, { "docid": "e993a855c859da0168a336feaeab21e4", "score": "0.4772116", "text": "func (o *V0037JobResponseProperties) SetMinimumCpusPerNode(v int32) {\n\to.MinimumCpusPerNode = &v\n}", "title": "" }, { "docid": "439ef29621a4a8fcd766b68d8f6f9ee2", "score": "0.47717774", "text": "func (spnp *SimplePreferredNodeProvider) Node() (*apiv1.Node, error) {\n\tnodes, err := spnp.nodeLister.List()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsize := len(nodes)\n\n\tcpu := int64(1000)\n\n\t// Double node size with every time the cluster size increases 3x.\n\tif size <= 2 {\n\t\treturn buildNode(1*cpu, 3750*units.MiB), nil\n\t} else if size <= 6 {\n\t\treturn buildNode(2*cpu, 7500*units.MiB), nil\n\t} else if size <= 20 {\n\t\treturn buildNode(4*cpu, 15000*units.MiB), nil\n\t} else if size <= 60 {\n\t\treturn buildNode(8*cpu, 30000*units.MiB), nil\n\t} else if size <= 200 {\n\t\treturn buildNode(16*cpu, 60000*units.MiB), nil\n\t}\n\treturn buildNode(32*cpu, 120000*units.MiB), nil\n}", "title": "" }, { "docid": "4fe5d01746a29414c14cdcd082abd610", "score": "0.4766467", "text": "func GetContainerCPUMetric(ctx context.Context, serverClient k8sclient.Client, l l.Logger) (string, error) {\n\tbefore49, err := resources.ClusterVersionBefore49(ctx, serverClient, l)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif before49 {\n\t\treturn \"node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate\", nil\n\t} else {\n\t\treturn \"node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate\", nil\n\t}\n}", "title": "" }, { "docid": "8afea89ebacea205c4b8300531e1291e", "score": "0.47586724", "text": "func GinkgoParallelNode() int {\n\tdeprecationTracker.TrackDeprecation(\n\t\ttypes.Deprecations.ParallelNode(),\n\t\ttypes.NewCodeLocation(1),\n\t)\n\treturn GinkgoParallelProcess()\n}", "title": "" }, { "docid": "897a0a5ac019f47d67e280d0e8618593", "score": "0.47533232", "text": "func (o *PrivateHost) GetAssignedCPU() int {\n\treturn o.AssignedCPU\n}", "title": "" }, { "docid": "d7e5049f297ee6aca904093788870b03", "score": "0.47494683", "text": "func (client *KubeletClient) GetCpuFrequencyFromJob(node *v1.Node, osArch string) (nodeFreq float64, discovered bool) {\n\tnodeFreq = 0.0\n\tdiscovered = false\n\tif !util.NodeIsReady(node) {\n\t\tglog.Warningf(\"Skip getting CPU frequency from job on node %s because the node is not ready.\", node.Name)\n\t\treturn\n\t}\n\tif util.NodeMatchesLabels(node, client.cpufreqJobExcludeNodeLabels) {\n\t\tglog.Warningf(\"Skip getting CPU frequency from job on node %s because the node is excluded by labels.\",\n\t\t\tnode.Name)\n\t\treturn\n\t}\n\tif !supportedOSArch.Contains(osArch) {\n\t\tglog.Warningf(\"Skip getting CPU frequency from job on node %s because the OS/Arch %s is not supported.\",\n\t\t\tnode.Name, osArch)\n\t\treturn\n\t}\n\n\tvar err error\n\tif nodeFreq, err = client.fallbkCpuFreqGetter.GetFrequency(node.Name); err != nil {\n\t\tglog.Errorf(\"Failed to get CPU frequency from job on node %s: %v.\", node.Name, err)\n\t\treturn\n\t}\n\tdiscovered = true\n\tglog.Infof(\"CPU frequency of node %s: %v MHz.\", node.Name, nodeFreq)\n\treturn\n}", "title": "" }, { "docid": "313b18c8e951ca897b09b4df6027fac2", "score": "0.474936", "text": "func (o WorkerResourceOutput) Cpu() pulumi.Float64PtrOutput {\n\treturn o.ApplyT(func(v WorkerResource) *float64 { return v.Cpu }).(pulumi.Float64PtrOutput)\n}", "title": "" }, { "docid": "900edab71e54627434faabd175fc3ee8", "score": "0.47421518", "text": "func (o *VmTemplate) GetCpuCores() int32 {\n\tif o == nil {\n\t\tvar ret int32\n\t\treturn ret\n\t}\n\n\treturn o.CpuCores\n}", "title": "" }, { "docid": "ae5ae24c35d8232108a5f8d01eff73ba", "score": "0.4741067", "text": "func (vc *Config) GetCPU() int {\n\treturn int(vc.Option.CPU)\n}", "title": "" }, { "docid": "30dd369210a6b439658124abb2cc69f6", "score": "0.4738999", "text": "func (c *Controller) ComputeNodes(ctx context.Context, qtid dax.QualifiedTableID, shards dax.ShardNums) ([]dax.ComputeNode, error) {\n\trole := &dax.ComputeRole{\n\t\tTableKey: qtid.Key(),\n\t\tShards: shards,\n\t}\n\tqdbid := qtid.QualifiedDatabaseID\n\n\ttx, err := c.Transactor.BeginTx(ctx, false)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"beginning tx\")\n\t}\n\tdefer tx.Rollback()\n\n\t// If no shards are provided, get the nodes responsible for the entire\n\t// table.\n\tif len(role.Shards) == 0 {\n\t\tassignedNodes, err := c.nodesForTable(tx, dax.RoleTypeCompute, qtid)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"getting nodes for table\")\n\t\t}\n\t\tcomputeNodes, err := c.assignedToComputeNodes(assignedNodes)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"converting assigned to compute nodes\")\n\t\t}\n\t\treturn computeNodes, nil\n\t}\n\n\tassignedNodes, _, _, err := c.nodesComputeReadOrWrite(tx, role, qdbid, false, false)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"getting compute nodes read or write\")\n\t}\n\n\treturn c.assignedToComputeNodes(assignedNodes)\n}", "title": "" }, { "docid": "aef313a67772d38e762cee84e08b35cc", "score": "0.47389817", "text": "func (c *CPUInfo) SocketCPUs(socket int) ([]int, error) {\n\tvar result []int\n\tif socket >= len(c.sockets) || socket < 0 {\n\t\treturn nil, errors.New(\"socket ID is out of bound\")\n\t}\n\n\tfor _, core := range c.sockets[socket].cores {\n\t\tresult = append(result, core.processors...)\n\t}\n\n\tsort.Ints(result)\n\treturn result, nil\n}", "title": "" }, { "docid": "80c8e1dcbb6195493819131c84c72bf3", "score": "0.47379327", "text": "func (c *Controller) scaleNodeGroup(nodegroup string, nodeGroup *NodeGroupState) (int, error) {\n\t// list all pods\n\tpods, err := nodeGroup.Pods.List()\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to list pods: %v\", err)\n\t\treturn 0, err\n\t}\n\n\t// List all nodes\n\tallNodes, err := nodeGroup.Nodes.List()\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to list nodes: %v\", err)\n\t\treturn 0, err\n\t}\n\n\t// store a cached version of node capacity\n\tif len(allNodes) > 0 {\n\t\tnodeGroup.cpuCapacity = *allNodes[0].Status.Allocatable.Cpu()\n\t\tnodeGroup.memCapacity = *allNodes[0].Status.Allocatable.Memory()\n\t}\n\n\t// Filter into untainted and tainted nodes\n\tuntaintedNodes, taintedNodes, cordonedNodes := c.filterNodes(nodeGroup, allNodes)\n\n\t// Metrics and Logs\n\tlog.WithField(\"nodegroup\", nodegroup).Infof(\"pods total: %v\", len(pods))\n\tlog.WithField(\"nodegroup\", nodegroup).Infof(\"nodes remaining total: %v\", len(allNodes))\n\tlog.WithField(\"nodegroup\", nodegroup).Infof(\"cordoned nodes remaining total: %v\", len(cordonedNodes))\n\tlog.WithField(\"nodegroup\", nodegroup).Infof(\"nodes remaining untainted: %v\", len(untaintedNodes))\n\tlog.WithField(\"nodegroup\", nodegroup).Infof(\"nodes remaining tainted: %v\", len(taintedNodes))\n\tlog.WithField(\"nodegroup\", nodegroup).Infof(\"Minimum Node: %v\", nodeGroup.Opts.MinNodes)\n\tlog.WithField(\"nodegroup\", nodegroup).Infof(\"Maximum Node: %v\", nodeGroup.Opts.MaxNodes)\n\tmetrics.NodeGroupNodes.WithLabelValues(nodegroup).Set(float64(len(allNodes)))\n\tmetrics.NodeGroupNodesCordoned.WithLabelValues(nodegroup).Set(float64(len(cordonedNodes)))\n\tmetrics.NodeGroupNodesUntainted.WithLabelValues(nodegroup).Set(float64(len(untaintedNodes)))\n\tmetrics.NodeGroupNodesTainted.WithLabelValues(nodegroup).Set(float64(len(taintedNodes)))\n\tmetrics.NodeGroupPods.WithLabelValues(nodegroup).Set(float64(len(pods)))\n\n\t// We want to be really simple right now so we don't do anything if we are outside the range of allowed nodes\n\t// We assume it is a config error or something bad has gone wrong in the cluster\n\n\tif len(allNodes) == 0 && len(pods) == 0 {\n\t\tlog.WithField(\"nodegroup\", nodegroup).Info(\"no pods requests and remain 0 node for node group\")\n\t\treturn 0, nil\n\t}\n\n\tif len(allNodes) < nodeGroup.Opts.MinNodes {\n\t\terr = errors.New(\"node count less than the minimum\")\n\t\tlog.WithField(\"nodegroup\", nodegroup).Warningf(\n\t\t\t\"Node count of %v less than minimum of %v\",\n\t\t\tlen(allNodes),\n\t\t\tnodeGroup.Opts.MinNodes,\n\t\t)\n\t\treturn 0, err\n\t}\n\tif len(allNodes) > nodeGroup.Opts.MaxNodes {\n\t\terr = errors.New(\"node count larger than the maximum\")\n\t\tlog.WithField(\"nodegroup\", nodegroup).Warningf(\n\t\t\t\"Node count of %v larger than maximum of %v\",\n\t\t\tlen(allNodes),\n\t\t\tnodeGroup.Opts.MaxNodes,\n\t\t)\n\t\treturn 0, err\n\t}\n\n\t// update the map of node to nodeinfo\n\t// for working out which pods are on which nodes\n\tnodeGroup.NodeInfoMap = k8s.CreateNodeNameToInfoMap(pods, allNodes)\n\n\t// Calc capacity for untainted nodes\n\tpodRequests, err := k8s.CalculatePodsRequestedUsage(pods)\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to calculate requests: %v\", err)\n\t\treturn 0, err\n\t}\n\n\tnodeCapacity, err := k8s.CalculateNodesCapacity(untaintedNodes, pods)\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to calculate capacity: %v\", err)\n\t\treturn 0, err\n\t}\n\n\t// Metrics\n\tmetrics.NodeGroupCPURequest.WithLabelValues(nodegroup).Set(float64(podRequests.Total.GetCPUQuantity().MilliValue()))\n\tmetrics.NodeGroupCPUCapacity.WithLabelValues(nodegroup).Set(float64(nodeCapacity.Total.GetCPUQuantity().MilliValue()))\n\tmetrics.NodeGroupMemCapacity.WithLabelValues(nodegroup).Set(float64(nodeCapacity.Total.GetMemoryQuantity().MilliValue() / 1000))\n\tmetrics.NodeGroupMemRequest.WithLabelValues(nodegroup).Set(float64(podRequests.Total.GetMemoryQuantity().MilliValue() / 1000))\n\tmetrics.NodeGroupCPURequestLargestPendingCPU.WithLabelValues(nodegroup).Set(float64(podRequests.LargestPendingCPU.GetCPUQuantity().MilliValue()))\n\tmetrics.NodeGroupMemRequestLargestPendingCPU.WithLabelValues(nodegroup).Set(float64(podRequests.LargestPendingCPU.GetMemoryQuantity().MilliValue() / 1000))\n\tmetrics.NodeGroupCPURequestLargestPendingMem.WithLabelValues(nodegroup).Set(float64(podRequests.LargestPendingMemory.GetCPUQuantity().MilliValue()))\n\tmetrics.NodeGroupMemRequestLargestPendingMem.WithLabelValues(nodegroup).Set(float64(podRequests.LargestPendingMemory.GetMemoryQuantity().MilliValue() / 1000))\n\tmetrics.NodeGroupCPUCapacityLargestAvailableCPU.WithLabelValues(nodegroup).Set(float64(nodeCapacity.LargestAvailableCPU.GetCPUQuantity().MilliValue()))\n\tmetrics.NodeGroupMemCapacityLargestAvailableCPU.WithLabelValues(nodegroup).Set(float64(nodeCapacity.LargestAvailableCPU.GetMemoryQuantity().MilliValue() / 1000))\n\tmetrics.NodeGroupCPUCapacityLargestAvailableMem.WithLabelValues(nodegroup).Set(float64(nodeCapacity.LargestAvailableMemory.GetCPUQuantity().MilliValue()))\n\tmetrics.NodeGroupMemCapacityLargestAvailableMem.WithLabelValues(nodegroup).Set(float64(nodeCapacity.LargestAvailableMemory.GetMemoryQuantity().MilliValue() / 1000))\n\n\t// If we ever get into a state where we have less nodes than the minimum\n\tif len(untaintedNodes) < nodeGroup.Opts.MinNodes {\n\t\tlog.WithField(\"nodegroup\", nodegroup).Warn(\"There are less untainted nodes than the minimum\")\n\t\tresult, err := c.ScaleUp(scaleOpts{\n\t\t\tnodes: allNodes,\n\t\t\tnodesDelta: nodeGroup.Opts.MinNodes - len(untaintedNodes),\n\t\t\tnodeGroup: nodeGroup,\n\t\t\ttaintedNodes: taintedNodes,\n\t\t\tuntaintedNodes: untaintedNodes,\n\t\t})\n\t\tif err != nil {\n\t\t\tlog.WithField(\"nodegroup\", nodegroup).Error(err)\n\t\t}\n\t\treturn result, err\n\t}\n\n\t// Calc %\n\t// both cpu and memory capacity are based on number of untainted nodes\n\t// pass number of untainted nodes in to help make decision if it's a scaling-up-from-0\n\tcpuPercent, memPercent, err := calcPercentUsage(\n\t\t*podRequests.Total.GetCPUQuantity(),\n\t\t*podRequests.Total.GetMemoryQuantity(),\n\t\t*nodeCapacity.Total.GetCPUQuantity(),\n\t\t*nodeCapacity.Total.GetMemoryQuantity(),\n\t\tint64(len(untaintedNodes)))\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to calculate percentages: %v\", err)\n\t\treturn 0, err\n\t}\n\n\t// Metrics\n\tlog.WithField(\"nodegroup\", nodegroup).Infof(\"cpu: %v, memory: %v\", cpuPercent, memPercent)\n\n\t// on the case that we're scaling up from 0, emit 0 as the metrics to keep metrics sane\n\tif cpuPercent == math.MaxFloat64 || memPercent == math.MaxFloat64 {\n\t\tmetrics.NodeGroupsCPUPercent.WithLabelValues(nodegroup).Set(0)\n\t\tmetrics.NodeGroupsMemPercent.WithLabelValues(nodegroup).Set(0)\n\t} else {\n\t\tmetrics.NodeGroupsCPUPercent.WithLabelValues(nodegroup).Set(cpuPercent)\n\t\tmetrics.NodeGroupsMemPercent.WithLabelValues(nodegroup).Set(memPercent)\n\t}\n\n\tlocked := nodeGroup.scaleUpLock.locked()\n\tif locked {\n\t\t// don't do anything else until we're unlocked again\n\t\tlog.WithField(\"nodegroup\", nodegroup).Info(nodeGroup.scaleUpLock)\n\t\tlog.WithField(\"nodegroup\", nodegroup).Info(\"Waiting for scale to finish\")\n\t\treturn nodeGroup.scaleUpLock.requestedNodes, nil\n\t}\n\n\tc.calculateNewNodeMetrics(nodegroup, nodeGroup)\n\n\t// Perform the scaling decision\n\tmaxPercent := math.Max(cpuPercent, memPercent)\n\tnodesDelta := 0\n\n\t// Determine if we want to scale up or down. Selects the first condition that is true\n\tswitch {\n\t// --- Scale Down conditions ---\n\t// reached very low %. aggressively remove nodes\n\tcase maxPercent < float64(nodeGroup.Opts.TaintLowerCapacityThresholdPercent):\n\t\tnodesDelta = -nodeGroup.Opts.FastNodeRemovalRate\n\t// reached medium low %. slowly remove nodes\n\tcase maxPercent < float64(nodeGroup.Opts.TaintUpperCapacityThresholdPercent):\n\t\tnodesDelta = -nodeGroup.Opts.SlowNodeRemovalRate\n\t// --- Scale Up conditions ---\n\t// Need to scale up so capacity can handle requests\n\tcase maxPercent > float64(nodeGroup.Opts.ScaleUpThresholdPercent):\n\t\t// if ScaleUpThresholdPercent is our \"max target\" or \"slack capacity\"\n\t\t// we want to add enough nodes such that the maxPercentage cluster util\n\t\t// drops back below ScaleUpThresholdPercent\n\t\tnodesDelta, err = calcScaleUpDelta(\n\t\t\tuntaintedNodes,\n\t\t\tcpuPercent,\n\t\t\tmemPercent,\n\t\t\t*podRequests.Total.GetCPUQuantity(),\n\t\t\t*podRequests.Total.GetMemoryQuantity(),\n\t\t\tnodeGroup)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Failed to calculate node delta: %v\", err)\n\t\t\treturn nodesDelta, err\n\t\t}\n\t}\n\n\tif c.isScaleOnStarve(nodeGroup, podRequests, nodeCapacity, untaintedNodes) {\n\t\tlog.WithField(\"nodegroup\", nodegroup).Info(\"Setting scale to minimum of 1 due to a starved pod\")\n\t\tnodesDelta = int(math.Max(float64(nodesDelta), 1))\n\t}\n\n\tlog.WithField(\"nodegroup\", nodegroup).Debugf(\"Delta: %v\", nodesDelta)\n\n\tscaleOptions := scaleOpts{\n\t\tnodes: allNodes,\n\t\ttaintedNodes: taintedNodes,\n\t\tuntaintedNodes: untaintedNodes,\n\t\tnodeGroup: nodeGroup,\n\t}\n\n\t// Perform a scale up, do nothing or scale down based on the nodes delta\n\tvar nodesDeltaResult int\n\t// actionErr keeps the error of any action below and checked after action\n\t// make sure shadowing variable won't be created for it\n\tvar actionErr error\n\tswitch {\n\tcase nodesDelta < 0:\n\t\t// Try to scale down\n\t\tscaleOptions.nodesDelta = -nodesDelta\n\t\tnodesDeltaResult, actionErr = c.ScaleDown(scaleOptions)\n\tcase nodesDelta > 0:\n\t\t// Try to scale up\n\t\tscaleOptions.nodesDelta = nodesDelta\n\t\tnodesDeltaResult, actionErr = c.ScaleUp(scaleOptions)\n\t\tnodeGroup.lastScaleOut = time.Now()\n\tdefault:\n\t\tlog.WithField(\"nodegroup\", nodegroup).Info(\"No need to scale\")\n\t\t// reap any expired nodes\n\t\tvar removed int\n\t\tremoved, actionErr = c.TryRemoveTaintedNodes(scaleOptions)\n\t\tlog.WithField(\"nodegroup\", nodegroup).Infof(\"Reaper: There were %v empty nodes deleted this round\", removed)\n\t}\n\n\tif actionErr != nil {\n\t\tswitch actionErr.(type) {\n\t\t// early return when node is NOT in expected node group\n\t\tcase *cloudprovider.NodeNotInNodeGroup:\n\t\t\treturn 0, actionErr\n\t\tdefault:\n\t\t\tlog.WithField(\"nodegroup\", nodegroup).Error(actionErr)\n\t\t}\n\t}\n\n\tlog.WithField(\"nodegroup\", nodegroup).Debugf(\"DeltaScaled: %v\", nodesDeltaResult)\n\treturn nodesDelta, err\n}", "title": "" }, { "docid": "1971b75c06d90c453169ea0b3c02b685", "score": "0.47313935", "text": "func GCENumCPU(machineType string) int {\n\tif strings.HasSuffix(machineType, \"e2-medium\") || strings.HasSuffix(machineType, \"e2-small\") || strings.HasSuffix(machineType, \"e2-micro\") {\n\t\treturn 2\n\t}\n\tn, _ := strconv.Atoi(machineType[strings.LastIndex(machineType, \"-\")+1:])\n\treturn n\n}", "title": "" }, { "docid": "1730897149e32327b27f6b0da3305313", "score": "0.47311294", "text": "func getScalablePropertyForNode(ctx context.Context, deploymentID, nodeName, propertyName string) (uint32, error) {\n\n\t// TODO: Large part of GetDefaultNbInstancesForNode GetMaxNbInstancesForNode GetMinNbInstancesForNode could be factorized\n\tnodeType, err := GetNodeType(ctx, deploymentID, nodeName)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tcapabilities, err := GetCapabilitiesOfType(ctx, deploymentID, nodeType, \"tosca.capabilities.Scalable\")\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tif len(capabilities) > 0 {\n\t\tfor _, capability := range capabilities {\n\t\t\tnbInst, err := GetCapabilityPropertyValue(ctx, deploymentID, nodeName, capability, propertyName)\n\t\t\tif err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\tif nbInst != nil {\n\t\t\t\tvar val uint64\n\t\t\t\tval, err = strconv.ParseUint(nbInst.RawString(), 10, 32)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn 0, errors.Errorf(\"Not a valid integer for property %q of %q capability for node %q. Error: %v\", propertyName, capability, nodeName, err)\n\t\t\t\t}\n\t\t\t\treturn uint32(val), nil\n\t\t\t}\n\t\t}\n\t}\n\t// So we have to traverse the hosted on relationships...\n\t// Lets inspect the requirements to found hosted on relationships\n\thostNode, err := GetHostedOnNode(ctx, deploymentID, nodeName)\n\tif err != nil {\n\t\treturn 0, err\n\t} else if hostNode != \"\" {\n\t\treturn getScalablePropertyForNode(ctx, deploymentID, hostNode, propertyName)\n\t}\n\t// Not hosted on a node having the Scalable capability lets assume one instance\n\treturn 1, nil\n}", "title": "" }, { "docid": "2b56dbec06ab3999bee9135b2404cd13", "score": "0.47311237", "text": "func (cg *CgroupV1) GetCPUData(pid int, cgPath string) (*rspec.LinuxCPU, error) {\n\tif filepath.IsAbs(cgPath) {\n\t\tpath := filepath.Join(cg.MountPath, \"cpu\", cgPath)\n\t\tif _, err := os.Stat(path); err != nil {\n\t\t\tif os.IsNotExist(err) {\n\t\t\t\treturn nil, specerror.NewError(specerror.CgroupsAbsPathRelToMount, fmt.Errorf(\"In the case of an absolute path, the runtime MUST take the path to be relative to the cgroups mount point\"), rspec.Version)\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tlc := &rspec.LinuxCPU{}\n\tnames := []string{\"shares\", \"cfs_quota_us\", \"cfs_period_us\"}\n\tfor i, name := range names {\n\t\tfileName := strings.Join([]string{\"cpu\", name}, \".\")\n\t\tfilePath := filepath.Join(cg.MountPath, \"cpu\", cgPath, fileName)\n\t\tif !filepath.IsAbs(cgPath) {\n\t\t\tsubPath, err := GetSubsystemPath(pid, \"cpu\")\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif !strings.Contains(subPath, cgPath) {\n\t\t\t\treturn nil, fmt.Errorf(\"cgroup subsystem %s is not mounted as expected\", \"cpu\")\n\t\t\t}\n\t\t\tfilePath = filepath.Join(cg.MountPath, \"cpu\", subPath, fileName)\n\t\t}\n\t\tcontents, err := os.ReadFile(filePath)\n\t\tif err != nil {\n\t\t\tif os.IsNotExist(err) {\n\t\t\t\treturn nil, specerror.NewError(specerror.CgroupsPathAttach, fmt.Errorf(\"The runtime MUST consistently attach to the same place in the cgroups hierarchy given the same value of `cgroupsPath`\"), rspec.Version)\n\t\t\t}\n\n\t\t\treturn nil, err\n\t\t}\n\t\tswitch i {\n\t\tcase 0:\n\t\t\tres, err := strconv.ParseUint(strings.TrimSpace(string(contents)), 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tshares := res\n\t\t\tlc.Shares = &shares\n\t\tcase 1:\n\t\t\tres, err := strconv.ParseInt(strings.TrimSpace(string(contents)), 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tquota := res\n\t\t\tlc.Quota = &quota\n\t\tcase 2:\n\t\t\tres, err := strconv.ParseUint(strings.TrimSpace(string(contents)), 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tperiod := res\n\t\t\tlc.Period = &period\n\t\t}\n\t}\n\t// CONFIG_RT_GROUP_SCHED may be not set\n\t// Can always get rt data from /proc\n\tcontents, err := os.ReadFile(\"/proc/sys/kernel/sched_rt_period_us\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trtPeriod, err := strconv.ParseUint(strings.TrimSpace(string(contents)), 10, 64)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlc.RealtimePeriod = &rtPeriod\n\tcontents, err = os.ReadFile(\"/proc/sys/kernel/sched_rt_runtime_us\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trtQuota, err := strconv.ParseInt(strings.TrimSpace(string(contents)), 10, 64)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlc.RealtimeRuntime = &rtQuota\n\n\tnames = []string{\"cpus\", \"mems\"}\n\tfor i, name := range names {\n\t\tfileName := strings.Join([]string{\"cpuset\", name}, \".\")\n\t\tfilePath := filepath.Join(cg.MountPath, \"cpuset\", cgPath, fileName)\n\t\tif !filepath.IsAbs(cgPath) {\n\t\t\tsubPath, err := GetSubsystemPath(pid, \"cpuset\")\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif !strings.Contains(subPath, cgPath) {\n\t\t\t\treturn nil, fmt.Errorf(\"cgroup subsystem %s is not mounted as expected\", \"cpuset\")\n\t\t\t}\n\t\t\tfilePath = filepath.Join(cg.MountPath, \"cpuset\", subPath, fileName)\n\t\t}\n\t\tcontents, err := os.ReadFile(filePath)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tswitch i {\n\t\tcase 0:\n\t\t\tlc.Cpus = strings.TrimSpace(string(contents))\n\t\tcase 1:\n\t\t\tlc.Mems = strings.TrimSpace(string(contents))\n\t\t}\n\t}\n\n\treturn lc, nil\n}", "title": "" }, { "docid": "20cc9a1f39b8adb7469810ccb74c2df2", "score": "0.47221467", "text": "func (self *ClusterAgent) getNodeSpec() altaspec.NodeSpec {\n\t// Get the number of CPU\n\tnumCpu, _ := psutil.CPUCounts(true)\n\n\t// CPU speed\n\tcpuInfo, _ := psutil.CPUInfo()\n\tcpuMhz := cpuInfo[0].Mhz\n\n\t// Get the total memory\n\tmemInfo, _ := psutil.VirtualMemory()\n\tmemTotal := memInfo.Total\n\n\t// Get the host name\n\thostName, _ := os.Hostname()\n\n\t// Create response\n\tnodeSpec := altaspec.NodeSpec{\n\t\tHostName: hostName,\n\t\tResources: []altaspec.Resource{\n\t\t\t{\n\t\t\t\tType: \"cpu\",\n\t\t\t\tUnitType: \"fluid\",\n\t\t\t\tNumRsrc: float64(numCpu),\n\t\t\t},\n\t\t\t{\n\t\t\t\tType: \"memory\",\n\t\t\t\tUnitType: \"fluid\",\n\t\t\t\tNumRsrc: float64(memTotal),\n\t\t\t},\n\t\t},\n\t\tAttributes: map[string]string{\n\t\t\t\"hostname\": hostName,\n\t\t\t\"cpu-mhz\": fmt.Sprintf(\"%f\", cpuMhz),\n\t\t},\n\t}\n\n\treturn nodeSpec\n}", "title": "" }, { "docid": "1fe834762e39c191ab652715b53c5abf", "score": "0.47153372", "text": "func (o *ConnectorTargetSpecification) GetCpuLimit() string {\n\tif o == nil || o.CpuLimit == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.CpuLimit\n}", "title": "" }, { "docid": "a48ecb1f16354598afc1b48efa2b3767", "score": "0.4714218", "text": "func (o GetServiceMeshesMeshMeshConfigProxyOutput) RequestCpu() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetServiceMeshesMeshMeshConfigProxy) string { return v.RequestCpu }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "097348e1d58465a3376ad82bd2d69554", "score": "0.47118354", "text": "func listCPUs() (map[string]interface{}, error) {\n\tlines, _ := common.ReadLines(common.GetEnv(\"HOST_PROC\", \"/proc\", \"cpuinfo\"))\n\n\tvar cpus []cpuStat\n\tvar processorName string\n\n\tc := cpuStat{CPU: -1, Cores: 1}\n\n\ttryFinalizeCurrentCPU := func() {\n\t\tif c.CPU >= 0 {\n\t\t\tc.finalize()\n\t\t\tcpus = append(cpus, c)\n\t\t}\n\t}\n\n\tfor _, line := range lines {\n\t\tfields := strings.Split(line, \":\")\n\t\tif len(fields) < 2 {\n\t\t\tcontinue\n\t\t}\n\t\tkey := strings.TrimSpace(fields[0])\n\t\tvalue := strings.TrimSpace(fields[1])\n\n\t\tswitch key {\n\t\tcase \"Processor\":\n\t\t\tprocessorName = value\n\t\tcase \"processor\":\n\t\t\ttryFinalizeCurrentCPU()\n\t\t\tc = cpuStat{Cores: 1, ModelName: processorName}\n\t\t\tif err := c.parseFieldProcessor(value); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\tcase \"vendorId\", \"vendor_id\":\n\t\t\tc.VendorID = value\n\t\tcase \"cpu family\":\n\t\t\tc.Family = value\n\t\tcase \"model\":\n\t\t\tc.Model = value\n\t\tcase \"model name\", \"cpu\":\n\t\t\tc.parseFieldModelName(value)\n\t\tcase \"stepping\", \"revision\":\n\t\t\tif err := c.parseFieldStepping(key, value); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\tcase \"cpu MHz\", \"clock\":\n\t\t\tc.parseFieldClock(value)\n\t\tcase \"cache size\":\n\t\t\tif err := c.parseFieldCacheSize(value); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\tcase \"physical id\":\n\t\t\tc.PhysicalID = value\n\t\tcase \"core id\":\n\t\t\tc.CoreID = value\n\t\tcase \"flags\", \"Features\":\n\t\t\tc.Flags = strings.FieldsFunc(value, func(r rune) bool {\n\t\t\t\treturn r == ',' || r == ' '\n\t\t\t})\n\t\tcase \"cpu cores\":\n\t\t\tif err := c.parseFieldCPUCores(value); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\tcase \"microcode\":\n\t\t\tc.Microcode = value\n\t\tcase \"siblings\":\n\t\t\tif err := c.parseFieldSiblings(value); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t}\n\n\ttryFinalizeCurrentCPU()\n\n\treturn encodeCPUs(cpus), nil\n}", "title": "" }, { "docid": "52e6f39a830f74b48f21929d8b11752d", "score": "0.470518", "text": "func (n *NodeInfo) AllocatableCPU() resource.Quantity {\n\treturn n.Status.Allocatable[\"cpu\"]\n}", "title": "" }, { "docid": "7cbb1e6efd2017dfb3b8350322c8a59d", "score": "0.4705086", "text": "func selectNode() (*serviceNode, error) {\r\n\r\n\tvar mtx sync.Mutex\r\n\r\n\tif len(nodes) == 0 {\r\n\t\treturn nil, fmt.Errorf(\"No nodes specified\")\r\n\t}\r\n\r\n\tmtx.Lock()\r\n\r\n\told := atomic.AddUint64(&c, 1) - 1\r\n\r\n\tnode := nodes[old%uint64(len(nodes))]\r\n\tmtx.Unlock()\r\n\r\n\treturn node, nil\r\n\r\n}", "title": "" }, { "docid": "4793bb7fc2af5760afd1491178320ce2", "score": "0.47043183", "text": "func (dm *DrainManager) getPodsAssignedToNode(nodeName string) ([]v1.Pod, error) {\n\tselector := fields.SelectorFromSet(fields.Set{\"spec.nodeName\": nodeName})\n\tpods, err := dm.client.CoreV1().Pods(v1.NamespaceAll).List(metav1.ListOptions{\n\t\tFieldSelector: selector.String(),\n\t\tLabelSelector: labels.Everything().String(),\n\t})\n\tfor i := 0; i < retries && err != nil; i++ {\n\t\tpods, err = dm.client.CoreV1().Pods(v1.NamespaceAll).List(metav1.ListOptions{\n\t\t\tFieldSelector: selector.String(),\n\t\t\tLabelSelector: labels.Everything().String(),\n\t\t})\n\t\ttime.Sleep(100 * time.Millisecond)\n\t}\n\tif err != nil {\n\t\treturn []v1.Pod{}, fmt.Errorf(\"failed to get Pods assigned to node %v, error: %v\", nodeName, err)\n\t}\n\treturn pods.Items, nil\n}", "title": "" }, { "docid": "cd1e47022e9e7cd31427d2015b3d30c2", "score": "0.4698632", "text": "func (k *KfQuota) GetCPU() (resource.Quantity, bool) {\n\tquantity, quotaExists := k.Spec.Hard[v1.ResourceCPU]\n\treturn quantity, quotaExists\n}", "title": "" }, { "docid": "72b63c8d0246a183f6d574df8c71d13c", "score": "0.46942127", "text": "func (o GetServiceMeshesMeshMeshConfigProxyOutput) LimitCpu() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetServiceMeshesMeshMeshConfigProxy) string { return v.LimitCpu }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "b68a893b7c18fe170c01fb664e005914", "score": "0.46926898", "text": "func (r *rangeAllocator) occupyCIDRs(node *v1.Node) error {\n\tdefer r.removeNodeFromProcessing(node.Name)\n\tif len(node.Spec.PodCIDRs) == 0 {\n\t\treturn nil\n\t}\n\tfor idx, cidr := range node.Spec.PodCIDRs {\n\t\t_, podCIDR, err := netutils.ParseCIDRSloppy(cidr)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to parse node %s, CIDR %s\", node.Name, node.Spec.PodCIDR)\n\t\t}\n\t\t// If node has a pre allocate cidr that does not exist in our cidrs.\n\t\t// This will happen if cluster went from dualstack(multi cidrs) to non-dualstack\n\t\t// then we have now way of locking it\n\t\tif idx >= len(r.cidrSets) {\n\t\t\treturn fmt.Errorf(\"node:%s has an allocated cidr: %v at index:%v that does not exist in cluster cidrs configuration\", node.Name, cidr, idx)\n\t\t}\n\n\t\tif err := r.cidrSets[idx].Occupy(podCIDR); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to mark cidr[%v] at idx [%v] as occupied for node: %v: %v\", podCIDR, idx, node.Name, err)\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c0baa45d1cc71bf24d3c059fb466770f", "score": "0.46900225", "text": "func nodeCapacityTransformer(s sender.Sender, name string, metric ksmstore.DDMetric, hostname string, tags []string, _ time.Time) {\n\tsubmitNodeResourceMetric(s, name, metric, hostname, tags, \"capacity\")\n}", "title": "" }, { "docid": "0faebefc310376832e1c767bb28a3108", "score": "0.4683708", "text": "func NodeGetCapabilities(\n\tctx context.Context,\n\tc csi.NodeClient,\n\tversion *csi.Version,\n\tcallOpts ...grpc.CallOption) (\n\tcapabilties []*csi.NodeServiceCapability, err error) {\n\n\treq := &csi.NodeGetCapabilitiesRequest{\n\t\tVersion: version,\n\t}\n\n\tres, err := c.NodeGetCapabilities(ctx, req, callOpts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn res.GetResult().Capabilities, nil\n}", "title": "" }, { "docid": "4b2dfcc209d58ab9ef9217c8f8f5cbb7", "score": "0.4674806", "text": "func (m *NodeKeeperMock) GetActiveNodesByRoleMinimockPreCounter() uint64 {\n\treturn atomic.LoadUint64(&m.GetActiveNodesByRolePreCounter)\n}", "title": "" } ]
9647b873210526979d097a3177472b54
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be nonnil.
[ { "docid": "00bf3aefda65a8d915e005ad3db1b44a", "score": "0.0", "text": "func (in *StorageEndpointProperties) DeepCopyInto(out *StorageEndpointProperties) {\n\t*out = *in\n\tif in.AuthenticationType != nil {\n\t\tin, out := &in.AuthenticationType, &out.AuthenticationType\n\t\t*out = new(string)\n\t\t**out = **in\n\t}\n\tif in.ConnectionString != nil {\n\t\tin, out := &in.ConnectionString, &out.ConnectionString\n\t\t*out = new(genruntime.SecretReference)\n\t\t**out = **in\n\t}\n\tif in.ContainerName != nil {\n\t\tin, out := &in.ContainerName, &out.ContainerName\n\t\t*out = new(string)\n\t\t**out = **in\n\t}\n\tif in.Identity != nil {\n\t\tin, out := &in.Identity, &out.Identity\n\t\t*out = new(ManagedIdentity)\n\t\t(*in).DeepCopyInto(*out)\n\t}\n\tif in.PropertyBag != nil {\n\t\tin, out := &in.PropertyBag, &out.PropertyBag\n\t\t*out = make(genruntime.PropertyBag, len(*in))\n\t\tfor key, val := range *in {\n\t\t\t(*out)[key] = val\n\t\t}\n\t}\n\tif in.SasTtlAsIso8601 != nil {\n\t\tin, out := &in.SasTtlAsIso8601, &out.SasTtlAsIso8601\n\t\t*out = new(string)\n\t\t**out = **in\n\t}\n}", "title": "" } ]
[ { "docid": "6d3c7f706ada34b172e55056fd08da9b", "score": "0.82790315", "text": "func (in *Ipxe) DeepCopyInto(out *Ipxe) {\n\t*out = *in\n}", "title": "" }, { "docid": "1c2d70d782e9a1af879ef1c56794f835", "score": "0.82403153", "text": "func (in *Data) DeepCopyInto(out *Data) {\n\t*out = *in\n}", "title": "" }, { "docid": "c6850f95c4b786dfb720021fee99aac3", "score": "0.8106937", "text": "func (in *Version) DeepCopyInto(out *Version) {\n\t*out = *in\n}", "title": "" }, { "docid": "ba7c8360408ac096e3adb773d7271afe", "score": "0.8105304", "text": "func (in *Fluentd) DeepCopyInto(out *Fluentd) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "b819c01a4847e2b7250bf24ee066a2a6", "score": "0.809632", "text": "func (in *PachydermRestore) DeepCopyInto(out *PachydermRestore) {\n\t*out = *in\n}", "title": "" }, { "docid": "d25ee8020a516841733ada81b932cfb8", "score": "0.8091808", "text": "func (in *Osie) DeepCopyInto(out *Osie) {\n\t*out = *in\n}", "title": "" }, { "docid": "ca54ebd80220b5981408fecbbe316176", "score": "0.80906075", "text": "func (in *DBInfo) DeepCopyInto(out *DBInfo) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "fd68cc5c404d65fa5c03c64949665da7", "score": "0.80895203", "text": "func (in *Size) DeepCopyInto(out *Size) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "be58e6c182cda9967f881999acd59c2f", "score": "0.8078841", "text": "func (in *Debug) DeepCopyInto(out *Debug) {\n\t*out = *in\n}", "title": "" }, { "docid": "afe2a3f4b3b9253dedc6bb9e45e3d492", "score": "0.8077273", "text": "func (in *AchievedStep) DeepCopyInto(out *AchievedStep) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "566b517300fca63a0f999b4e20011d0f", "score": "0.8075916", "text": "func (in *Keto) DeepCopyInto(out *Keto) {\n\t*out = *in\n}", "title": "" }, { "docid": "0402379222701ce5cbc47a58147b675c", "score": "0.8074198", "text": "func (in *EclipseChe) DeepCopyInto(out *EclipseChe) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "8c157f4759e96806dd0b74060472d480", "score": "0.8062976", "text": "func (in *Node) DeepCopyInto(out *Node) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "8c157f4759e96806dd0b74060472d480", "score": "0.8062976", "text": "func (in *Node) DeepCopyInto(out *Node) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "a082503dcbc413c6f686bfa34ed34463", "score": "0.8056177", "text": "func (in *NodeInterface) DeepCopyInto(out *NodeInterface) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "d4907b7e87f96cc9f592e887afb9927d", "score": "0.80508256", "text": "func (in *Node) DeepCopyInto(out *Node) {\n\t*out = *in\n}", "title": "" }, { "docid": "bf7b4b522057ae01ab0d93d4522fe30a", "score": "0.80477524", "text": "func (in *ObjectRef) DeepCopyInto(out *ObjectRef) {\n\t*out = *in\n}", "title": "" }, { "docid": "4d63c7d1929a6b53ca46be5738e434a5", "score": "0.803112", "text": "func (in *OutputEntry) DeepCopyInto(out *OutputEntry) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "6eec4c5e3d639e136aafd047e93f99cd", "score": "0.80291724", "text": "func (in *JSONCheck) DeepCopyInto(out *JSONCheck) {\n\t*out = *in\n}", "title": "" }, { "docid": "1c3455c7f0a06e92261a5b10b622ca06", "score": "0.8024094", "text": "func (in *Fateflow) DeepCopyInto(out *Fateflow) {\n\t*out = *in\n}", "title": "" }, { "docid": "5b24c3ee0cabe62c71b4995b5197f3e8", "score": "0.8020912", "text": "func (in *ObjectSelector) DeepCopyInto(out *ObjectSelector) {\n\t*out = *in\n}", "title": "" }, { "docid": "554e9c3fc35ac1866e0c1f4c3107b730", "score": "0.8010812", "text": "func (in *PathTest) DeepCopyInto(out *PathTest) {\n\t*out = *in\n}", "title": "" }, { "docid": "2f2cf86d90535cd828decdd6d982e087", "score": "0.80035347", "text": "func (in *Output) DeepCopyInto(out *Output) {\n\t*out = *in\n\tif in.output != nil {\n\t\tin, out := &in.output, &out.output\n\t\t*out = make([]OutputEntry, len(*in))\n\t\tcopy(*out, *in)\n\t}\n\treturn\n}", "title": "" }, { "docid": "e1c2499dce71eea1ba530425d987e65d", "score": "0.79998404", "text": "func (in *OutputType) DeepCopyInto(out *OutputType) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "873314226084acb05455ef131ac0e4e6", "score": "0.79889876", "text": "func (in *Nodeport) DeepCopyInto(out *Nodeport) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "3dfe5656fa02ed58112cacdc9eac4f47", "score": "0.7979133", "text": "func (in *VMSpec) DeepCopyInto(out *VMSpec) {\n\t*out = *in\n}", "title": "" }, { "docid": "8edce588d322f861d4f46b2f3aae92a8", "score": "0.7977704", "text": "func (in *TaskRef) DeepCopyInto(out *TaskRef) {\n\t*out = *in\n}", "title": "" }, { "docid": "8edce588d322f861d4f46b2f3aae92a8", "score": "0.7977704", "text": "func (in *TaskRef) DeepCopyInto(out *TaskRef) {\n\t*out = *in\n}", "title": "" }, { "docid": "09a622ae41a2172d4fd07d376190f880", "score": "0.79725754", "text": "func (in *Runtime) DeepCopyInto(out *Runtime) {\n\t*out = *in\n}", "title": "" }, { "docid": "be82863d9978b104237d2472cfdf3614", "score": "0.79595494", "text": "func (in *CrossVersionObjectReference) DeepCopyInto(out *CrossVersionObjectReference) {\n\t*out = *in\n}", "title": "" }, { "docid": "fcd61e82f34db96b76efba6276644908", "score": "0.79563504", "text": "func (in *ObjectSelector) DeepCopyInto(out *ObjectSelector) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "b37c436bd18ef0f2ea068cd1e94529fb", "score": "0.7951803", "text": "func (in *Partitions) DeepCopyInto(out *Partitions) {\n\t*out = *in\n}", "title": "" }, { "docid": "ee7f1891e9e6a3a794787c1609ae9fd7", "score": "0.79513776", "text": "func (in *Exchange) DeepCopyInto(out *Exchange) {\n\t*out = *in\n}", "title": "" }, { "docid": "ac71660e3edf3bf0db01580f6440913a", "score": "0.79403526", "text": "func (in *L2FibEntry) DeepCopyInto(out *L2FibEntry) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "a62d2491925276d66a89576351b7bdb4", "score": "0.7939902", "text": "func (in *Replicas) DeepCopyInto(out *Replicas) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "77fc7d629fd026ad04ef51dfccebef4b", "score": "0.79396087", "text": "func (in *LiveRef) DeepCopyInto(out *LiveRef) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "9a15d89300bd7975c23b970cd7e97f3d", "score": "0.7928445", "text": "func (in *File) DeepCopyInto(out *File) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "bf6832a027499f414e4fefd23952a785", "score": "0.7925128", "text": "func (in *ZookeeperNode) DeepCopyInto(out *ZookeeperNode) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "b7c82ab7f0b3eea65c1bf495c6e516a5", "score": "0.79139805", "text": "func (in *BackupProgress) DeepCopyInto(out *BackupProgress) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "57d7989b793af6d5839b019cc8c81aaa", "score": "0.79125994", "text": "func (in *ZookeeperNode) DeepCopyInto(out *ZookeeperNode) {\n\t*out = *in\n}", "title": "" }, { "docid": "6a74df2be2dbe701a0ee65d8e03053f6", "score": "0.7912454", "text": "func (in *IPXE) DeepCopyInto(out *IPXE) {\n\t*out = *in\n}", "title": "" }, { "docid": "ebde97abbe9aa8149c7ca6159e15bd33", "score": "0.7901213", "text": "func (in *CPUAndMem) DeepCopyInto(out *CPUAndMem) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "0153348545a3d712d327a2aac1b6c396", "score": "0.7896226", "text": "func (in *HostPort) DeepCopyInto(out *HostPort) {\n\t*out = *in\n}", "title": "" }, { "docid": "6502eb4511d14b46184710050bf0959d", "score": "0.7894769", "text": "func (in *Docker) DeepCopyInto(out *Docker) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "8cb26178b91e9e46e2760b02c39719bd", "score": "0.78939056", "text": "func (in *FileInfo) DeepCopyInto(out *FileInfo) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "a00993b464b505c32d052ed0ac29e929", "score": "0.7892148", "text": "func (in *RolloutStrategyStep) DeepCopyInto(out *RolloutStrategyStep) {\n\t*out = *in\n\tout.Capacity = in.Capacity\n\tout.Traffic = in.Traffic\n\treturn\n}", "title": "" }, { "docid": "6ac1005d81e338e324c2b485bacbcd96", "score": "0.78901225", "text": "func (in *FileSourceCommandOutput) DeepCopyInto(out *FileSourceCommandOutput) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "dddf435977ebcd6bfaf0b4c062ea8042", "score": "0.7889666", "text": "func (in *Image) DeepCopyInto(out *Image) {\n\t*out = *in\n}", "title": "" }, { "docid": "dddf435977ebcd6bfaf0b4c062ea8042", "score": "0.7889666", "text": "func (in *Image) DeepCopyInto(out *Image) {\n\t*out = *in\n}", "title": "" }, { "docid": "7e9a1e6442b0e3e96a5fbeee635960c2", "score": "0.7885504", "text": "func (in *TiltBuild) DeepCopyInto(out *TiltBuild) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "23db226639df1ec5bfce6ed220d55ed3", "score": "0.7884866", "text": "func (in *Port) DeepCopyInto(out *Port) {\n\t*out = *in\n}", "title": "" }, { "docid": "a65c4b2c1d2be68d2c000a97d8eedfc2", "score": "0.78837895", "text": "func (in *Custom) DeepCopyInto(out *Custom) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "a80bfc6073fb7569830178e573ccf4ff", "score": "0.78830814", "text": "func (in *CanaryStepInfo) DeepCopyInto(out *CanaryStepInfo) {\n\t*out = *in\n\tif in.Pods != nil {\n\t\tin, out := &in.Pods, &out.Pods\n\t\t*out = make([]Pod, len(*in))\n\t\tcopy(*out, *in)\n\t}\n}", "title": "" }, { "docid": "834926315fc14d71c5b8c19960384fb8", "score": "0.7881545", "text": "func (in *NodeToDelete) DeepCopyInto(out *NodeToDelete) {\n\t*out = *in\n}", "title": "" }, { "docid": "df764ce7904760faaa8b2c0ff322edf9", "score": "0.7879411", "text": "func (in *NamespacedObjectReference) DeepCopyInto(out *NamespacedObjectReference) {\n\t*out = *in\n}", "title": "" }, { "docid": "b0f2d00d7b4d64e85270beb9b90cd6ab", "score": "0.78788966", "text": "func (in *KoupletObjectStorage) DeepCopyInto(out *KoupletObjectStorage) {\n\t*out = *in\n}", "title": "" }, { "docid": "786362133c8c7c161acd95331377635b", "score": "0.78758836", "text": "func (in *NoteAffectedVersionEnd) DeepCopyInto(out *NoteAffectedVersionEnd) {\n\t*out = *in\n\tif in.Epoch != nil {\n\t\tin, out := &in.Epoch, &out.Epoch\n\t\t*out = new(int)\n\t\t**out = **in\n\t}\n\tif in.FullName != nil {\n\t\tin, out := &in.FullName, &out.FullName\n\t\t*out = new(string)\n\t\t**out = **in\n\t}\n\tif in.Name != nil {\n\t\tin, out := &in.Name, &out.Name\n\t\t*out = new(string)\n\t\t**out = **in\n\t}\n\tif in.Revision != nil {\n\t\tin, out := &in.Revision, &out.Revision\n\t\t*out = new(string)\n\t\t**out = **in\n\t}\n\treturn\n}", "title": "" }, { "docid": "dfd9b82d38c6fee08dd3cf0209bd1133", "score": "0.78745437", "text": "func (in *Disk) DeepCopyInto(out *Disk) {\n\t*out = *in\n}", "title": "" }, { "docid": "fa756ae28922fed925a87b236587b156", "score": "0.78738964", "text": "func (in *Git) DeepCopyInto(out *Git) {\n\t*out = *in\n}", "title": "" }, { "docid": "d04effc735adc59932f839adb9a5fcca", "score": "0.787052", "text": "func (in *Target) DeepCopyInto(out *Target) {\n\t*out = *in\n}", "title": "" }, { "docid": "87da18a2ecb0daf97f6ceebabd38dbce", "score": "0.78703135", "text": "func (in *ArgoCDDexSpec) DeepCopyInto(out *ArgoCDDexSpec) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "c20aacaaa0cb697cdf50015f05812d0b", "score": "0.78681225", "text": "func (in *Persistent) DeepCopyInto(out *Persistent) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "a676d91e11264164f55179f00108d1a4", "score": "0.786427", "text": "func (in *IPamEntry) DeepCopyInto(out *IPamEntry) {\n\t*out = *in\n\tout.Config = in.Config\n\treturn\n}", "title": "" }, { "docid": "130014cc93330670791582c6062e4db7", "score": "0.78632116", "text": "func (in *RestoreOptions) DeepCopyInto(out *RestoreOptions) {\n\t*out = *in\n\tout.Pachyderm = in.Pachyderm\n}", "title": "" }, { "docid": "5186b8d1bfd3abf2fb983694f27e4aed", "score": "0.7863134", "text": "func (in *Image) DeepCopyInto(out *Image) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "1e1088954cae99b323e1b34730ad0490", "score": "0.7862752", "text": "func (in *Proxy) DeepCopyInto(out *Proxy) {\n\t*out = *in\n}", "title": "" }, { "docid": "249004da5f8f92f3538948abf74c7c43", "score": "0.7861986", "text": "func (in *ChainMatch) DeepCopyInto(out *ChainMatch) {\n\t*out = *in\n}", "title": "" }, { "docid": "e39896940442e2145aef5b05f65f5935", "score": "0.7861502", "text": "func (in *PodInfo) DeepCopyInto(out *PodInfo) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "7cc05f62bb39d146b68b80d858d6a207", "score": "0.7861456", "text": "func (in *Vector) DeepCopyInto(out *Vector) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "e6970237e6216981baddfbdbd7abccc6", "score": "0.7860582", "text": "func (in *Tap) DeepCopyInto(out *Tap) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "a510fbe7bc41427b104d0eaa08202270", "score": "0.7858568", "text": "func (in *Host) DeepCopyInto(out *Host) {\n\t*out = *in\n}", "title": "" }, { "docid": "e315197e0d9ead19327c6af4ed12a3cb", "score": "0.7854804", "text": "func (in *Run) DeepCopyInto(out *Run) {\n\t*out = *in\n\tin.CollectorMeta.DeepCopyInto(&out.CollectorMeta)\n\tif in.Command != nil {\n\t\tin, out := &in.Command, &out.Command\n\t\t*out = make([]string, len(*in))\n\t\tcopy(*out, *in)\n\t}\n\tif in.Args != nil {\n\t\tin, out := &in.Args, &out.Args\n\t\t*out = make([]string, len(*in))\n\t\tcopy(*out, *in)\n\t}\n\tif in.ImagePullSecret != nil {\n\t\tin, out := &in.ImagePullSecret, &out.ImagePullSecret\n\t\t*out = new(ImagePullSecrets)\n\t\t(*in).DeepCopyInto(*out)\n\t}\n}", "title": "" }, { "docid": "5e7b3746576fd5b9b7b41728c6111924", "score": "0.78544146", "text": "func (in *UnidleInfo) DeepCopyInto(out *UnidleInfo) {\n\t*out = *in\n\tout.CrossGroupObjectReference = in.CrossGroupObjectReference\n\treturn\n}", "title": "" }, { "docid": "96083041971f9626da3004536999b74d", "score": "0.7853779", "text": "func (in *Instance) DeepCopyInto(out *Instance) {\n\t*out = *in\n\tout.Info = in.Info\n\treturn\n}", "title": "" }, { "docid": "2a009d2984c86675e264e6dada29ff80", "score": "0.78527164", "text": "func (in *KV) DeepCopyInto(out *KV) {\n\t*out = *in\n}", "title": "" }, { "docid": "da7f24e673d9d09df8d3a9d9f9ee7150", "score": "0.78505605", "text": "func (in *ClusterObjectVersion) DeepCopyInto(out *ClusterObjectVersion) {\n\t*out = *in\n}", "title": "" }, { "docid": "ea91a35f5981150f1fd702f1fe925417", "score": "0.78501236", "text": "func (in *FFTEstimator) DeepCopyInto(out *FFTEstimator) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "e4913de28c2145467caf2d40a4f1654c", "score": "0.7848145", "text": "func (in *ConsoleType) DeepCopyInto(out *ConsoleType) {\n\t*out = *in\n}", "title": "" }, { "docid": "b0adf7eb2ad49b2db1b146fe5f0c63c8", "score": "0.78465587", "text": "func (in *DataToBackup) DeepCopyInto(out *DataToBackup) {\n\t*out = *in\n\tif in.Paths != nil {\n\t\tin, out := &in.Paths, &out.Paths\n\t\t*out = make([]string, len(*in))\n\t\tcopy(*out, *in)\n\t}\n\treturn\n}", "title": "" }, { "docid": "24bd47aa15850c3e5d10ce0c3cdb5c1a", "score": "0.7844129", "text": "func (in *TwinProperty) DeepCopyInto(out *TwinProperty) {\n\t*out = *in\n\tif in.Metadata != nil {\n\t\tin, out := &in.Metadata, &out.Metadata\n\t\t*out = make(map[string]string, len(*in))\n\t\tfor key, val := range *in {\n\t\t\t(*out)[key] = val\n\t\t}\n\t}\n\treturn\n}", "title": "" }, { "docid": "a79f2a418acb2bd0e96737a5c3c73fa6", "score": "0.784405", "text": "func (in *SetupNode) DeepCopyInto(out *SetupNode) {\n\t*out = *in\n\tout.Ccow = in.Ccow\n\tin.Ccowd.DeepCopyInto(&out.Ccowd)\n\tout.Auditd = in.Auditd\n\tif in.ClusterNodes != nil {\n\t\tin, out := &in.ClusterNodes, &out.ClusterNodes\n\t\t*out = make([]string, len(*in))\n\t\tcopy(*out, *in)\n\t}\n\tin.Rtrd.DeepCopyInto(&out.Rtrd)\n\tif in.RtrdSlaves != nil {\n\t\tin, out := &in.RtrdSlaves, &out.RtrdSlaves\n\t\t*out = make([]RTDevices, len(*in))\n\t\tfor i := range *in {\n\t\t\t(*in)[i].DeepCopyInto(&(*out)[i])\n\t\t}\n\t}\n\tin.Rtlfs.DeepCopyInto(&out.Rtlfs)\n\tin.Rtkvs.DeepCopyInto(&out.Rtkvs)\n\treturn\n}", "title": "" }, { "docid": "906c07db0ca76d2700f3f766a3da7142", "score": "0.7841533", "text": "func (in *ConfigLookup) DeepCopyInto(out *ConfigLookup) {\n\t*out = *in\n\tif in.Config != nil {\n\t\tin, out := &in.Config, &out.Config\n\t\t*out = new(Config)\n\t\t(*in).DeepCopyInto(*out)\n\t}\n\tout.Display = in.Display\n}", "title": "" }, { "docid": "7cae9d5836b9ff88d8f2685e755e15d2", "score": "0.78383315", "text": "func (in *Mirroring) DeepCopyInto(out *Mirroring) {\n\t*out = *in\n\tif in.MaxBodySize != nil {\n\t\tin, out := &in.MaxBodySize, &out.MaxBodySize\n\t\t*out = new(int64)\n\t\t**out = **in\n\t}\n\tif in.Mirrors != nil {\n\t\tin, out := &in.Mirrors, &out.Mirrors\n\t\t*out = make([]MirrorService, len(*in))\n\t\tcopy(*out, *in)\n\t}\n\tif in.HealthCheck != nil {\n\t\tin, out := &in.HealthCheck, &out.HealthCheck\n\t\t*out = new(HealthCheck)\n\t\t**out = **in\n\t}\n\treturn\n}", "title": "" }, { "docid": "2dc7abef201d917589f010f613212296", "score": "0.7837808", "text": "func (in *ArgoCDTLSSpec) DeepCopyInto(out *ArgoCDTLSSpec) {\n\t*out = *in\n\tout.CA = in.CA\n\treturn\n}", "title": "" }, { "docid": "87b2689ec313f65bf8b34547d5fe1c22", "score": "0.78362834", "text": "func (in *ImpersonationConfig) DeepCopyInto(out *ImpersonationConfig) {\n\t*out = *in\n\tif in.Groups != nil {\n\t\tin, out := &in.Groups, &out.Groups\n\t\t*out = make([]string, len(*in))\n\t\tcopy(*out, *in)\n\t}\n\tif in.Extra != nil {\n\t\tin, out := &in.Extra, &out.Extra\n\t\t*out = make(map[string][]string, len(*in))\n\t\tfor key, val := range *in {\n\t\t\tif val == nil {\n\t\t\t\t(*out)[key] = nil\n\t\t\t} else {\n\t\t\t\t(*out)[key] = make([]string, len(val))\n\t\t\t\tcopy((*out)[key], val)\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "title": "" }, { "docid": "a77814382dc5efa98656ab59390c4583", "score": "0.783529", "text": "func (in *KeyValue) DeepCopyInto(out *KeyValue) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "3ba2a8b441a37bfd038c30f2cd4bd608", "score": "0.78347754", "text": "func (in *NoteBuild) DeepCopyInto(out *NoteBuild) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "bef878ec968416a156e7ebe2543d4ca2", "score": "0.7832831", "text": "func (in *KeyToPath) DeepCopyInto(out *KeyToPath) {\n\t*out = *in\n}", "title": "" }, { "docid": "8fdfc31c802e3f9c9a872e578c5339d3", "score": "0.7830981", "text": "func (in *ArgoCDConfig) DeepCopyInto(out *ArgoCDConfig) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "f5023cb13be74cf25182a7183395c30a", "score": "0.7830146", "text": "func (in *ObjectFieldSelector) DeepCopyInto(out *ObjectFieldSelector) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "cbb68d49fd2c1144f25e0b31d5dc670a", "score": "0.7828108", "text": "func (in *BdInterface) DeepCopyInto(out *BdInterface) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "8e14ffa5d59641d2c993b17ea5ba3246", "score": "0.78271353", "text": "func (in *Delegate) DeepCopyInto(out *Delegate) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "74a105a690c14ec8e268cba9618912f1", "score": "0.7825447", "text": "func (in *K8sVersion) DeepCopyInto(out *K8sVersion) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "9ec11989c5ce05665e2c4f7c6180862a", "score": "0.78253746", "text": "func (in *NodepoolGvnic) DeepCopyInto(out *NodepoolGvnic) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "8ff4edb62aac78b649c6382f24a79f61", "score": "0.78250736", "text": "func (in *Database) DeepCopyInto(out *Database) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "783f47424c191839399d4e44b906dd71", "score": "0.7824875", "text": "func (in *Port) DeepCopyInto(out *Port) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "783f47424c191839399d4e44b906dd71", "score": "0.7824875", "text": "func (in *Port) DeepCopyInto(out *Port) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "783f47424c191839399d4e44b906dd71", "score": "0.7824875", "text": "func (in *Port) DeepCopyInto(out *Port) {\n\t*out = *in\n\treturn\n}", "title": "" }, { "docid": "0d0b1cb857e61e9b21e4a27a1ea1d959", "score": "0.7823346", "text": "func (in *ExternalData) DeepCopyInto(out *ExternalData) {\n\t*out = *in\n}", "title": "" }, { "docid": "dc9cccc7cfa6b224aed958820b379d64", "score": "0.7820955", "text": "func (in *Blob) DeepCopyInto(out *Blob) {\n\t*out = *in\n}", "title": "" }, { "docid": "5787cd6847ddd85de272065e4c4ef750", "score": "0.7819949", "text": "func (in *GitRef) DeepCopyInto(out *GitRef) {\n\t*out = *in\n\treturn\n}", "title": "" } ]
d50067066495b74bfdb0c50609f5d085
Deprecated: Use CMsgClientToGCCavernCrawlClaimRoomResponse.ProtoReflect.Descriptor instead.
[ { "docid": "f95220c12f9a78b92a932a78914ab088", "score": "0.7432274", "text": "func (*CMsgClientToGCCavernCrawlClaimRoomResponse) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{217}\n}", "title": "" } ]
[ { "docid": "3c805babb091503e6b319211be699d3c", "score": "0.73173636", "text": "func (*CMsgClientToGCCavernCrawlClaimRoom) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{216}\n}", "title": "" }, { "docid": "eca7e9f06ff1754b826c5f62c6bee0ff", "score": "0.66998565", "text": "func (CMsgClientToGCCavernCrawlClaimRoomResponse_Result) EnumDescriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{217, 0}\n}", "title": "" }, { "docid": "ed7bda4fced23063fc8f01d8e9cc3071", "score": "0.64721316", "text": "func (*CMsgClientToGCCavernCrawlGetClaimedRoomCountResponse) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{225}\n}", "title": "" }, { "docid": "d2b5c5417f5d6e3dfb0e82843bc14179", "score": "0.6470592", "text": "func (*CMsgClientToGCCavernCrawlUseItemOnRoomResponse) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{219}\n}", "title": "" }, { "docid": "4d3bc2b60bfc072e8d8b9a26dd721bc6", "score": "0.62059295", "text": "func (CMsgClientToGCCavernCrawlGetClaimedRoomCountResponse_Result) EnumDescriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{225, 0}\n}", "title": "" }, { "docid": "89808276203355a2949200969b992f2f", "score": "0.61848414", "text": "func (*CMsgClientToGCCavernCrawlGetClaimedRoomCount) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{224}\n}", "title": "" }, { "docid": "d81361ae1eb685a539bcceb750e805d0", "score": "0.61244094", "text": "func (CMsgClientToGCCavernCrawlUseItemOnRoomResponse_Result) EnumDescriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{219, 0}\n}", "title": "" }, { "docid": "6a1be95504942b21995177e423eee4b5", "score": "0.6124277", "text": "func (*DescribeClassroomV1Response) Descriptor() ([]byte, []int) {\n\treturn file_api_ocp_classroom_api_ocp_classroom_api_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "9981f75076316556afac9e4bd8b24cd9", "score": "0.6103292", "text": "func (x *fastReflection_MsgRevokeResponse) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_MsgRevokeResponse\n}", "title": "" }, { "docid": "73508a6c27a7a22149409d692f1ccfd0", "score": "0.60758895", "text": "func (*RemoveClassroomV1Response) Descriptor() ([]byte, []int) {\n\treturn file_api_ocp_classroom_api_ocp_classroom_api_proto_rawDescGZIP(), []int{11}\n}", "title": "" }, { "docid": "8fa20737eb8121775ef4930098602db5", "score": "0.60737914", "text": "func (*MsgDescriptor) Descriptor() ([]byte, []int) {\n\treturn file_cosmos_base_reflection_v2alpha1_reflection_proto_rawDescGZIP(), []int{10}\n}", "title": "" }, { "docid": "fbd020e9acee1974fa42b85e5c5bbaed", "score": "0.6038507", "text": "func (*ManagerCheckReviewingRoomResponse) Descriptor() ([]byte, []int) {\n\treturn file_room_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "b4de00d505956fd3a26c3a69f6d1a492", "score": "0.6021777", "text": "func (*DescribeClassroomV1Request) Descriptor() ([]byte, []int) {\n\treturn file_api_ocp_classroom_api_ocp_classroom_api_proto_rawDescGZIP(), []int{2}\n}", "title": "" }, { "docid": "2791818a92b1072afe14179038919ce0", "score": "0.60148734", "text": "func (*ManagerGetReviewingRoomResponse) Descriptor() ([]byte, []int) {\n\treturn file_room_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "9d553655f2d30beb2b42fd4f21655cc3", "score": "0.6009826", "text": "func (*CClanChatRooms_GetClanChatRoomInfo_Response) Descriptor() ([]byte, []int) {\n\treturn file_steammessages_chat_steamclient_proto_rawDescGZIP(), []int{111}\n}", "title": "" }, { "docid": "b12f4afb55675553421b4b6bc766cd90", "score": "0.6009744", "text": "func (*CMsgClientToGCGetOWMatchDetailsResponse_Marker) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{299, 0}\n}", "title": "" }, { "docid": "52d605ea9280d34c6dc3158dbd9780bf", "score": "0.60085475", "text": "func (*CMsgClientToGCCavernCrawlUseItemOnRoom) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{218}\n}", "title": "" }, { "docid": "8fbfd24b35bf01e6cf0dcd8c4e45dd8e", "score": "0.60072607", "text": "func (*CMsgRemoteDeviceProofResponse) Descriptor() ([]byte, []int) {\n\treturn file_steam_steammessages_remoteclient_discovery_proto_rawDescGZIP(), []int{12}\n}", "title": "" }, { "docid": "a93fb23da49944a0fa4c57ce96488d0e", "score": "0.60012376", "text": "func (*LeaveRoomReq) Descriptor() ([]byte, []int) {\n\treturn file_protos_protobuf_soup_SoupMessage_proto_rawDescGZIP(), []int{8}\n}", "title": "" }, { "docid": "14006967fe1d8a9f62c2cb2862b8a69d", "score": "0.5996471", "text": "func (*CMsgGCToClientCavernCrawlMapUpdated) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{215}\n}", "title": "" }, { "docid": "ca470b291bc66e053f88e94c8a77a74c", "score": "0.5994219", "text": "func (*CChatRoom_RenameChatRoom_Response) Descriptor() ([]byte, []int) {\n\treturn file_steammessages_chat_steamclient_proto_rawDescGZIP(), []int{66}\n}", "title": "" }, { "docid": "5e78b78e9125eecee2ff8d76fa870d1c", "score": "0.5974429", "text": "func (*CMsgRemoteDeviceProofRequest) Descriptor() ([]byte, []int) {\n\treturn file_steam_steammessages_remoteclient_discovery_proto_rawDescGZIP(), []int{11}\n}", "title": "" }, { "docid": "3c30b69eba22439b4505fee337649c4a", "score": "0.5962065", "text": "func (*GetPinnedMessagesResponse) Descriptor() ([]byte, []int) {\n\treturn file_discord_v1_rest_proto_rawDescGZIP(), []int{80}\n}", "title": "" }, { "docid": "1956f2e3f257ce89ee9722dad06d05fe", "score": "0.59606117", "text": "func (*RemoveClassroomV1Request) Descriptor() ([]byte, []int) {\n\treturn file_api_ocp_classroom_api_ocp_classroom_api_proto_rawDescGZIP(), []int{10}\n}", "title": "" }, { "docid": "7335282bcfca0fc8f40ee8636f748c0d", "score": "0.5957406", "text": "func (x *fastReflection_MsgRevoke) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_MsgRevoke\n}", "title": "" }, { "docid": "2a95de4cafc4b415689871e2f2768f89", "score": "0.59513026", "text": "func (*CChatRoom_RenameChatRoom_Request) Descriptor() ([]byte, []int) {\n\treturn file_steammessages_chat_steamclient_proto_rawDescGZIP(), []int{65}\n}", "title": "" }, { "docid": "48301e0d604bcb5ddf45fb4fd0ed42c9", "score": "0.594556", "text": "func (*CMsgClientToGCRecalibrateMMRResponse) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{296}\n}", "title": "" }, { "docid": "ca83f2660d6f02659a025c1dd6b033df", "score": "0.59334147", "text": "func (*CClanChatRooms_SetClanChatRoomPrivate_Response) Descriptor() ([]byte, []int) {\n\treturn file_steammessages_chat_steamclient_proto_rawDescGZIP(), []int{113}\n}", "title": "" }, { "docid": "13f0ee913ddac58e610247e419a78b08", "score": "0.59220093", "text": "func (*UpdateClassroomV1Response) Descriptor() ([]byte, []int) {\n\treturn file_api_ocp_classroom_api_ocp_classroom_api_proto_rawDescGZIP(), []int{9}\n}", "title": "" }, { "docid": "68dcf96cb454f3009530ce31a4297ad4", "score": "0.59208894", "text": "func (*AddStudentToRoomResponse) Descriptor() ([]byte, []int) {\n\treturn file_room_proto_rawDescGZIP(), []int{9}\n}", "title": "" }, { "docid": "f27c584787e191bc324d4c3cc683bd7e", "score": "0.5918176", "text": "func (*TeacherCheckStudentToRoomResponse) Descriptor() ([]byte, []int) {\n\treturn file_room_proto_rawDescGZIP(), []int{15}\n}", "title": "" }, { "docid": "4481464fc49056ae28811c747fc6f3dc", "score": "0.591251", "text": "func (*CMsgClientToGCTopFriendMatchesRequest) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_watch_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "3e1cd9001289c0e38aad1a9d28600ab0", "score": "0.5910695", "text": "func (*RoomMemberSeatRes) Descriptor() ([]byte, []int) {\n\treturn file_protos_protobuf_soup_SoupMessage_proto_rawDescGZIP(), []int{26}\n}", "title": "" }, { "docid": "b2bd132856cea6551b17031ee4c39d7e", "score": "0.5909698", "text": "func (*ManagerCheckReviewingRoomRequest) Descriptor() ([]byte, []int) {\n\treturn file_room_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "f9aafa65879591ab3138e66b96ddc215", "score": "0.5907193", "text": "func (*CMsgClientToGCTopLeagueMatchesRequest) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_watch_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "ef9ed12a11015ca3134f940721506018", "score": "0.59011436", "text": "func (*ManagerGetReviewingRoomRequest) Descriptor() ([]byte, []int) {\n\treturn file_room_proto_rawDescGZIP(), []int{2}\n}", "title": "" }, { "docid": "984e8335776243d3bd56de6fa40c9dfb", "score": "0.59010017", "text": "func (*CMsgSpectateFriendGameResponse) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_watch_proto_rawDescGZIP(), []int{11}\n}", "title": "" }, { "docid": "ebc8b05b84161f0b7c397233c2fceb20", "score": "0.589952", "text": "func (*C2CS_RoomLeaveReq) Descriptor() ([]byte, []int) {\n\treturn file_LogicPacket_proto_rawDescGZIP(), []int{14}\n}", "title": "" }, { "docid": "448c92a38346c00c9b4a9bd214b628f8", "score": "0.5898887", "text": "func (x *fastReflection_ResponseOfferSnapshot) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_ResponseOfferSnapshot\n}", "title": "" }, { "docid": "3f5f75c5a95bd8e99bbd96944e16a12a", "score": "0.5887448", "text": "func (*CMsgClientToGCUnderDraftRerollResponse) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{282}\n}", "title": "" }, { "docid": "7ddeac20d1ccbfbc9b5b4f8dc74a47f6", "score": "0.58862704", "text": "func (*LeaveRoomRes) Descriptor() ([]byte, []int) {\n\treturn file_protos_protobuf_soup_SoupMessage_proto_rawDescGZIP(), []int{9}\n}", "title": "" }, { "docid": "abb28b53c65aa4267c8b48b9fd20ebf0", "score": "0.58854294", "text": "func (*ListClassroomsV1Response) Descriptor() ([]byte, []int) {\n\treturn file_api_ocp_classroom_api_ocp_classroom_api_proto_rawDescGZIP(), []int{1}\n}", "title": "" }, { "docid": "da7cc1474e50dc5e4773fd611a8f2453", "score": "0.5884215", "text": "func (*OfflineReq) Descriptor() ([]byte, []int) {\n\treturn file_protos_protobuf_GameMessage_proto_rawDescGZIP(), []int{7}\n}", "title": "" }, { "docid": "0784e969a82af40f245b361b0d1a0371", "score": "0.58831584", "text": "func (*CMsgClientToGCRecalibrateMMR) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{295}\n}", "title": "" }, { "docid": "bb14808e453a1d2953d2c534757f88b4", "score": "0.58829635", "text": "func (*JoinRoomRes) Descriptor() ([]byte, []int) {\n\treturn file_protos_protobuf_soup_SoupMessage_proto_rawDescGZIP(), []int{7}\n}", "title": "" }, { "docid": "cc656af1ffbd03b860a72aeee6194bdc", "score": "0.58809566", "text": "func (x *fastReflection_RequestOfferSnapshot) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_RequestOfferSnapshot\n}", "title": "" }, { "docid": "845054d8d81b58e12b848e925762d08d", "score": "0.5859149", "text": "func (*RefreshProjectCLsResponse) Descriptor() ([]byte, []int) {\n\treturn file_go_chromium_org_luci_cv_internal_admin_api_admin_proto_rawDescGZIP(), []int{14}\n}", "title": "" }, { "docid": "815201d648b18712be706c4f6e9046e1", "score": "0.585907", "text": "func (*ManagerGetUseRoomResponse) Descriptor() ([]byte, []int) {\n\treturn file_room_proto_rawDescGZIP(), []int{21}\n}", "title": "" }, { "docid": "930cd99310dcf902ed6ce7192094da2b", "score": "0.58511376", "text": "func (*CClanChatRooms_GetClanChatRoomInfo_Request) Descriptor() ([]byte, []int) {\n\treturn file_steammessages_chat_steamclient_proto_rawDescGZIP(), []int{110}\n}", "title": "" }, { "docid": "ba2e4c730c4ae06a9a16323112136cf2", "score": "0.5845684", "text": "func (x *fastReflection_GetCodecDescriptorResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {\n\tswitch fd.FullName() {\n\tcase \"cosmos.base.reflection.v2alpha1.GetCodecDescriptorResponse.codec\":\n\t\tif x.Codec == nil {\n\t\t\tx.Codec = new(CodecDescriptor)\n\t\t}\n\t\treturn protoreflect.ValueOfMessage(x.Codec.ProtoReflect())\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.base.reflection.v2alpha1.GetCodecDescriptorResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.base.reflection.v2alpha1.GetCodecDescriptorResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "title": "" }, { "docid": "2372a6961b3cf3e8a8e8621056883198", "score": "0.58445925", "text": "func (*ChatResponse) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_ai_llm_v1alpha_llm_service_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "6b737e8db8c27b5ecc53ac06908ec7c2", "score": "0.5842719", "text": "func (*Classroom) Descriptor() ([]byte, []int) {\n\treturn file_api_ocp_classroom_api_ocp_classroom_api_proto_rawDescGZIP(), []int{12}\n}", "title": "" }, { "docid": "7e01d025a0bf2ce5d02cc150cd4fbd83", "score": "0.5840746", "text": "func (*GetPinnedMessagesRequest) Descriptor() ([]byte, []int) {\n\treturn file_discord_v1_rest_proto_rawDescGZIP(), []int{79}\n}", "title": "" }, { "docid": "f4d3de76f5bd72fbd4d5e0cbdafe1410", "score": "0.5839841", "text": "func (*OnTargetAudienceMetrics) Descriptor() ([]byte, []int) {\n\treturn file_google_ads_googleads_v14_services_reach_plan_service_proto_rawDescGZIP(), []int{19}\n}", "title": "" }, { "docid": "371e32ad9c43155291deaccacf40b77e", "score": "0.5836534", "text": "func (*ChatRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_ai_llm_v1alpha_llm_service_proto_rawDescGZIP(), []int{2}\n}", "title": "" }, { "docid": "793c8d97b463cc8c415e0018b0ced3ff", "score": "0.58302057", "text": "func (*ListMetricDescriptorsResponse) Descriptor() ([]byte, []int) {\n\treturn edgelq_monitoring_proto_v3_metric_descriptor_custom_proto_rawDescGZIP(), []int{1}\n}", "title": "" }, { "docid": "cb679b4a3eb4adf6a68582b564c7fda4", "score": "0.58259636", "text": "func (*JoinRoomReq) Descriptor() ([]byte, []int) {\n\treturn file_protos_protobuf_soup_SoupMessage_proto_rawDescGZIP(), []int{6}\n}", "title": "" }, { "docid": "b76a6da29ceb3d5f561d997315a49081", "score": "0.58240175", "text": "func (*CCommunity_GetClanAnnouncements_Response) Descriptor() ([]byte, []int) {\n\treturn file_gcsdk_gcmessages_proto_rawDescGZIP(), []int{44}\n}", "title": "" }, { "docid": "f1b847cdae870901017f3441f1ae6fcd", "score": "0.5820863", "text": "func (x *fastReflection_GetAuthnDescriptorResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {\n\tswitch fd.FullName() {\n\tcase \"cosmos.base.reflection.v2alpha1.GetAuthnDescriptorResponse.authn\":\n\t\tif x.Authn == nil {\n\t\t\tx.Authn = new(AuthnDescriptor)\n\t\t}\n\t\treturn protoreflect.ValueOfMessage(x.Authn.ProtoReflect())\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.base.reflection.v2alpha1.GetAuthnDescriptorResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.base.reflection.v2alpha1.GetAuthnDescriptorResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "title": "" }, { "docid": "867f19d34d5523d2f62f217368280275", "score": "0.5811268", "text": "func (*ClaimResponse) Descriptor() ([]byte, []int) {\n\treturn file_gobuildmaster_proto_rawDescGZIP(), []int{9}\n}", "title": "" }, { "docid": "c9367f19d30813036aa573b6c3cc4b2b", "score": "0.58081883", "text": "func (*TeacherGetReviewingRoomResponse) Descriptor() ([]byte, []int) {\n\treturn file_room_proto_rawDescGZIP(), []int{17}\n}", "title": "" }, { "docid": "7678a6c5ddf83e5237a8c0ba146c0ab8", "score": "0.5803152", "text": "func (*RoomKeepResponse) Descriptor() ([]byte, []int) {\n\treturn file_roomkeepService_proto_rawDescGZIP(), []int{2}\n}", "title": "" }, { "docid": "e666b1f28ebf785de1f1b9851f13c47b", "score": "0.58001626", "text": "func (*SliceMetrics) Descriptor() ([]byte, []int) {\n\treturn file_e2sm_rsm_v1_e2sm_rsm_v1_proto_rawDescGZIP(), []int{14}\n}", "title": "" }, { "docid": "43a44108072c9f5c6bfaf6a38157fb5b", "score": "0.5799815", "text": "func (*CMsgRemoteDeviceAuthorizationRequest) Descriptor() ([]byte, []int) {\n\treturn file_steam_steammessages_remoteclient_discovery_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "a1ca86702ecfcec342e0fac95e8a76ec", "score": "0.5799289", "text": "func (*CMsgClientToGCCavernCrawlRequestMapStateResponse) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{223}\n}", "title": "" }, { "docid": "d33fe897166528d6f75eb4ce386b81e3", "score": "0.5798859", "text": "func (*CMsgClientToGCJoinPlaytestResponse) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{173}\n}", "title": "" }, { "docid": "4a2bb4c12b8dda96f12d991e98dd1304", "score": "0.5795912", "text": "func (*GetCinemaMessageRsp) Descriptor() ([]byte, []int) {\n\treturn file_cinema_ext_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "48555ed4d6b4920b6f560e38dbbb389c", "score": "0.5795397", "text": "func (*DisallowSnapshotRequestProto) Descriptor() ([]byte, []int) {\n\treturn file_ClientNamenodeProtocol_proto_rawDescGZIP(), []int{151}\n}", "title": "" }, { "docid": "4e99fbb1a759058b49c307fef2adbe2c", "score": "0.579329", "text": "func (*CMsgClientToGCCavernCrawlRequestMapState) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{222}\n}", "title": "" }, { "docid": "09698b32d61eeb7b22a0d2d5fd2b167b", "score": "0.57919145", "text": "func (*CreateClassroomV1Response) Descriptor() ([]byte, []int) {\n\treturn file_api_ocp_classroom_api_ocp_classroom_api_proto_rawDescGZIP(), []int{5}\n}", "title": "" }, { "docid": "1a414a7fd687e5a44c8ff321ec7f9610", "score": "0.57918286", "text": "func (*CMsgClientToGCUnderDraftResponse) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{280}\n}", "title": "" }, { "docid": "0bf1f03601d7cad91c80acc571072412", "score": "0.57916903", "text": "func (*MovieDetailRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_v1_movie_detail_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "6807f9f5e63369eabb2d63346e87124c", "score": "0.57873476", "text": "func (*ListClassroomsV1Request) Descriptor() ([]byte, []int) {\n\treturn file_api_ocp_classroom_api_ocp_classroom_api_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "7ad467bd8f78f86119e4640deefada0c", "score": "0.5783668", "text": "func (*CMsgDOTADestroyLobbyResponse) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{192}\n}", "title": "" }, { "docid": "6c1f40affab7230c5b5a8676660e79c4", "score": "0.5778707", "text": "func (*CMsgProfileResponse) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{202}\n}", "title": "" }, { "docid": "dd4bd3521903fa9147c0ecc61ab44171", "score": "0.57693565", "text": "func (x *fastReflection_ResponseLoadSnapshotChunk) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_ResponseLoadSnapshotChunk\n}", "title": "" }, { "docid": "1723d5c569498bf3a259cd3ebeb5ff7a", "score": "0.57690096", "text": "func (*CMsgRemoteDeviceAuthorizationResponse) Descriptor() ([]byte, []int) {\n\treturn file_steam_steammessages_remoteclient_discovery_proto_rawDescGZIP(), []int{6}\n}", "title": "" }, { "docid": "2624b01e6d6c1550c50e499c07212de0", "score": "0.57685804", "text": "func (CMsgDOTADestroyLobbyResponse_Result) EnumDescriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{192, 0}\n}", "title": "" }, { "docid": "6319bd53957471f9dc1f62bc659c5c4e", "score": "0.576099", "text": "func (VideoMessage_VideoMessageAttribution) EnumDescriptor() ([]byte, []int) {\n\treturn file_def_proto_rawDescGZIP(), []int{25, 0}\n}", "title": "" }, { "docid": "37b6adcd8077b28f500ac7c02e06f005", "score": "0.57591826", "text": "func (*FetchAuctionBoardResponse) Descriptor() ([]byte, []int) {\n\treturn file_proto_command_proto_rawDescGZIP(), []int{12}\n}", "title": "" }, { "docid": "46813ee331e5ad73a9ca3c0abcb20f3a", "score": "0.5758401", "text": "func (*GetCinemaMessageByCidRsp) Descriptor() ([]byte, []int) {\n\treturn file_cinema_ext_proto_rawDescGZIP(), []int{7}\n}", "title": "" }, { "docid": "c3d5d05467141a86585753796253e46b", "score": "0.57574254", "text": "func (*CMsgFlipLobbyTeams) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{50}\n}", "title": "" }, { "docid": "c8255a5181e929deb2ecbbb92db089a1", "score": "0.5756333", "text": "func (*GetMetricDescriptorRequest) Descriptor() ([]byte, []int) {\n\treturn edgelq_monitoring_proto_v3_metric_descriptor_custom_proto_rawDescGZIP(), []int{2}\n}", "title": "" }, { "docid": "eef1f8cab52e672489f6822d5dda11d8", "score": "0.5753363", "text": "func (*CMsgClientToGCCavernCrawlGetClaimedRoomCountResponse_MapVariant) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{225, 0}\n}", "title": "" }, { "docid": "01a925670fc6cfaf2cc05ccf10bead8f", "score": "0.5747883", "text": "func (*CClanChatRooms_SetClanChatRoomPrivate_Request) Descriptor() ([]byte, []int) {\n\treturn file_steammessages_chat_steamclient_proto_rawDescGZIP(), []int{112}\n}", "title": "" }, { "docid": "6bab33f66d0d496150a35ec5ba733353", "score": "0.5742913", "text": "func (*TeacherGetReviewingRoomRequest) Descriptor() ([]byte, []int) {\n\treturn file_room_proto_rawDescGZIP(), []int{16}\n}", "title": "" }, { "docid": "d331be14f73611ffe4739fc0e08ff329", "score": "0.5741803", "text": "func (*CMsgProfileRequest) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{201}\n}", "title": "" }, { "docid": "4b32a3f973f8e335d4ee010444179a9a", "score": "0.57405394", "text": "func (*CMsgRemoteClientBroadcastDiscovery) Descriptor() ([]byte, []int) {\n\treturn file_steam_steammessages_remoteclient_discovery_proto_rawDescGZIP(), []int{2}\n}", "title": "" }, { "docid": "d9fb0f939479b1d7c3f0ea1710926e49", "score": "0.57397294", "text": "func (*CMsgDOTALobbyRichPresence) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{107}\n}", "title": "" }, { "docid": "c363f679e8930c2811515d3f5ec6990e", "score": "0.57351935", "text": "func (*CMsgClientToGCGetPlayerCardRosterResponse) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_fantasy_proto_rawDescGZIP(), []int{11}\n}", "title": "" }, { "docid": "be93a2ea724b63d41c4be87b11fbd5a0", "score": "0.5734227", "text": "func (*CMsgGCMatchDetailsRequest) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{15}\n}", "title": "" }, { "docid": "8b80d04945361ff653daabd3876d0710", "score": "0.57300264", "text": "func (*GetCodecDescriptorResponse) Descriptor() ([]byte, []int) {\n\treturn file_cosmos_base_reflection_v2alpha1_reflection_proto_rawDescGZIP(), []int{16}\n}", "title": "" }, { "docid": "1abe803ace28bf8a6c9d6fa5acceb6f4", "score": "0.57281107", "text": "func (*ComposeServerStatNodeClusterBoardResponse) Descriptor() ([]byte, []int) {\n\treturn file_service_server_stat_board_proto_rawDescGZIP(), []int{3}\n}", "title": "" }, { "docid": "881ac101146d19aaafa126b21cac0113", "score": "0.5725573", "text": "func (*GetDeviceRequest) Descriptor() ([]byte, []int) {\n\treturn file_public_api_proto_public_api_proto_rawDescGZIP(), []int{6}\n}", "title": "" }, { "docid": "46571298050803e08385cef866fe0ddf", "score": "0.572369", "text": "func (*CMsgClientToGCTransferSeasonalMMRRequest) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{169}\n}", "title": "" }, { "docid": "68c1d198cc416a040c4ee32e45aedd0d", "score": "0.5722775", "text": "func (*PatchTracesRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_devtools_cloudtrace_v1_trace_proto_rawDescGZIP(), []int{6}\n}", "title": "" }, { "docid": "78c989f5499f429347f0dcbfa9f3c343", "score": "0.57220227", "text": "func (x *fastReflection_ListResponse) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_ListResponse\n}", "title": "" }, { "docid": "bb6eb19d14147f341a1ff9266a05c726", "score": "0.57214695", "text": "func (*RoomHallReq) Descriptor() ([]byte, []int) {\n\treturn file_protos_protobuf_soup_SoupMessage_proto_rawDescGZIP(), []int{2}\n}", "title": "" }, { "docid": "e99e4b58fda99407bb8be3abfbd0e691", "score": "0.57206595", "text": "func (*GetAuthnDescriptorResponse) Descriptor() ([]byte, []int) {\n\treturn file_cosmos_base_reflection_v2alpha1_reflection_proto_rawDescGZIP(), []int{12}\n}", "title": "" }, { "docid": "48eee3c33731a17f25d857bce231c18a", "score": "0.5718328", "text": "func (*TeacherGetCanReviewingRoomListResponse) Descriptor() ([]byte, []int) {\n\treturn file_room_proto_rawDescGZIP(), []int{7}\n}", "title": "" } ]
8c0c2681048c9ebfecddb83f0749245b
Serialize serializes information the current object
[ { "docid": "5c81314ef579833986c2338d2edb4048", "score": "0.0", "text": "func (m *AppIdentity) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n {\n err := writer.WriteStringValue(\"appId\", m.GetAppId())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"displayName\", m.GetDisplayName())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"servicePrincipalId\", m.GetServicePrincipalId())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"servicePrincipalName\", m.GetServicePrincipalName())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" } ]
[ { "docid": "8e937d891d72008f03d5b45ac13d7f20", "score": "0.6859062", "text": "func (p Class) Serialize() common.JSON {\n\treturn common.JSON{\n\t\t\"ID\": p.ID,\n\t\t\"Name\": p.Name,\n\t}\n}", "title": "" }, { "docid": "135ee39a00187c9019f07b920f119c42", "score": "0.6671324", "text": "func (mi *MetaInfo) Serialize() ([]byte, error) {\n\treturn json.Marshal(&metaInfoJSON{mi.info})\n}", "title": "" }, { "docid": "545a202b50d43362c235e2fafb6f5cb4", "score": "0.6501807", "text": "func (tk *UtxoTracker) Serialize() ([]byte, error) {\n\treturn nil, nil\n}", "title": "" }, { "docid": "3477f50babdbe121fcdfe7df95d5c1f5", "score": "0.6407269", "text": "func Serialize(obj interface{}) []byte {\n\tbuf := new(bytes.Buffer)\n\tVarEncode(buf, obj)\n\treturn buf.Bytes()\n}", "title": "" }, { "docid": "2c9a5a0852afb9968bfd05e78278f936", "score": "0.63647896", "text": "func (f *FSMContext) Serialize(data interface{}) string {\n\treturn f.serialization.Serialize(data)\n}", "title": "" }, { "docid": "880df09136c69e5c0709bcebcd80a0a0", "score": "0.6320288", "text": "func (pay *Payment) Serialize() common.JSON {\n\treturn common.JSON{\n\t\t\"id\": pay.ID,\n\t\t\"status\": pay.Status,\n\t\t\"user_id\": pay.UserID,\n\t\t\"order_id\": pay.OrderID,\n\t\t\"order\": pay.Order.Serialize(),\n\t\t\"user\": pay.User.Serialize(),\n\t\t\"created_at\": pay.CreatedAt.Format(\"15:04 01-02-2006\"),\n\t\t\"updated_at\": pay.UpdatedAt.Format(\"15:04 01-02-2006\"),\n\t}\n}", "title": "" }, { "docid": "62f96fe9d324d65021ad2a9678f747f6", "score": "0.6283116", "text": "func (p *Product) Serialize() common.JSON {\n\treturn common.JSON{\n\t\t\"id\": p.ID,\n\t\t\"name\": p.Name,\n\t\t\"price\": p.Price,\n\t\t\"shop\": p.Shop.Serialize(),\n\t\t\"created_at\": p.CreatedAt.Format(\"15:04 01-02-2006\"),\n\t\t\"updated_at\": p.UpdatedAt.Format(\"15:04 01-02-2006\"),\n\t}\n}", "title": "" }, { "docid": "20f1cb94fa821187cd51a6cefa7a13fa", "score": "0.6265578", "text": "func (info *Info) serialize(builder *flatbuffers.Builder) flatbuffers.UOffsetT {\n\tid := builder.CreateString(info.id.String())\n\n\tdeclsNum := len(info.decls)\n\tvar declVecOffset flatbuffers.UOffsetT\n\tif declsNum > 0 {\n\t\tdeclsOffsets := make([]flatbuffers.UOffsetT, 0, declsNum)\n\t\tfor _, decl := range info.decls {\n\t\t\tdeclsOffsets = append(declsOffsets, decl.serialize(builder))\n\t\t}\n\t\tsymbol.InfoStartDeclsVector(builder, declsNum)\n\t\tfor i := declsNum - 1; i >= 0; i-- {\n\t\t\tbuilder.PrependUOffsetT(declsOffsets[i])\n\t\t}\n\t\tdeclVecOffset = builder.EndVector(declsNum)\n\t}\n\n\tdefOffset := info.def.serialize(builder)\n\n\tcallersNum := len(info.callers)\n\tvar callerVecOffset flatbuffers.UOffsetT\n\tif callersNum > 0 {\n\t\tcallersOffsets := make([]flatbuffers.UOffsetT, 0, callersNum)\n\t\tfor _, caller := range info.callers {\n\t\t\tcallersOffsets = append(callersOffsets, caller.serialize(builder))\n\t\t}\n\t\tsymbol.InfoStartCallersVector(builder, callersNum)\n\t\tfor i := callersNum - 1; i >= 0; i-- {\n\t\t\tbuilder.PrependUOffsetT(callersOffsets[i])\n\t\t}\n\t\tcallerVecOffset = builder.EndVector(callersNum)\n\t}\n\n\tsymbol.InfoStart(builder)\n\tsymbol.InfoAddID(builder, id)\n\tsymbol.InfoAddDecls(builder, declVecOffset)\n\tsymbol.InfoAddDef(builder, defOffset)\n\tsymbol.InfoAddCallers(builder, callerVecOffset)\n\n\treturn symbol.InfoEnd(builder)\n}", "title": "" }, { "docid": "969711666c65ebb76f8a59169ec92de7", "score": "0.624064", "text": "func Serialize(data interface{}) []byte {\n\tv := reflect.Indirect(reflect.ValueOf(data))\n\tsize := datasizeWrite(v)\n\tbuf := make([]byte, size)\n\te := &Encoder{\n\t\tBuffer: buf,\n\t}\n\te.value(v)\n\treturn buf\n}", "title": "" }, { "docid": "ee899022567bcdd9ae582c9c9c87c358", "score": "0.6237159", "text": "func (s *StateDescriptor) Serialize(w *io.BinaryWriter) {\n\tw.WriteLE(s.Type)\n\tw.WriteVarBytes(s.Key)\n\tw.WriteVarBytes(s.Value)\n\tw.WriteVarString(s.Field)\n}", "title": "" }, { "docid": "c5b5c38ccaf48e117b6609dc5414a853", "score": "0.6208787", "text": "func (m *UsageDetails) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n {\n err := writer.WriteTimeValue(\"lastAccessedDateTime\", m.GetLastAccessedDateTime())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteTimeValue(\"lastModifiedDateTime\", m.GetLastModifiedDateTime())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "e6ad49b74a1d0233f161642a056ff88d", "score": "0.6172183", "text": "func (m *Property) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n if m.GetAliases() != nil {\n err := writer.WriteCollectionOfStringValues(\"aliases\", m.GetAliases())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteBoolValue(\"isQueryable\", m.GetIsQueryable())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteBoolValue(\"isRefinable\", m.GetIsRefinable())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteBoolValue(\"isRetrievable\", m.GetIsRetrievable())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteBoolValue(\"isSearchable\", m.GetIsSearchable())\n if err != nil {\n return err\n }\n }\n if m.GetLabels() != nil {\n err := writer.WriteCollectionOfStringValues(\"labels\", SerializeLabel(m.GetLabels()))\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"name\", m.GetName())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n if m.GetType() != nil {\n cast := (*m.GetType()).String()\n err := writer.WriteStringValue(\"type\", &cast)\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "311b4f8b14a65542680e94b8f4385084", "score": "0.6167198", "text": "func (m Manager) Serialize() ([]byte, error) {\n\tbuf := new(bytes.Buffer)\n\n\t// Type (uint8)\n\t{\n\t\tif err := write(buf, m.Type); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Name (string)\n\t{\n\t\tif err := WriteVarChar(buf, m.Name, 8); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn buf.Bytes(), nil\n}", "title": "" }, { "docid": "e6de525eb5eca420448a167489afc1d4", "score": "0.6133925", "text": "func (o *OutPoint) Serialize(w io.Writer) error {\n\treturn o.BtcEncode(w, 0, BaseEncoding)\n}", "title": "" }, { "docid": "3db8d7dd9840e8a55b822af2ef325145", "score": "0.6096077", "text": "func (m *BookingPerson) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.BookingNamedEntity.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteStringValue(\"emailAddress\", m.GetEmailAddress())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "9ba1ff0050ddaaf28c875d0a4fde47d1", "score": "0.60856324", "text": "func (m *InformationProtectionLabel) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteStringValue(\"color\", m.GetColor())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"description\", m.GetDescription())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteBoolValue(\"isActive\", m.GetIsActive())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"name\", m.GetName())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"parent\", m.GetParent())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteInt32Value(\"sensitivity\", m.GetSensitivity())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"tooltip\", m.GetTooltip())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "df5cc98684f953031e3d8f0ed3243e1b", "score": "0.6080976", "text": "func (m *Person) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteStringValue(\"birthday\", m.GetBirthday())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"companyName\", m.GetCompanyName())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"department\", m.GetDepartment())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"displayName\", m.GetDisplayName())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"givenName\", m.GetGivenName())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"imAddress\", m.GetImAddress())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteBoolValue(\"isFavorite\", m.GetIsFavorite())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"jobTitle\", m.GetJobTitle())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"officeLocation\", m.GetOfficeLocation())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"personNotes\", m.GetPersonNotes())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"personType\", m.GetPersonType())\n if err != nil {\n return err\n }\n }\n if m.GetPhones() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetPhones())\n err = writer.WriteCollectionOfObjectValues(\"phones\", cast)\n if err != nil {\n return err\n }\n }\n if m.GetPostalAddresses() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetPostalAddresses())\n err = writer.WriteCollectionOfObjectValues(\"postalAddresses\", cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"profession\", m.GetProfession())\n if err != nil {\n return err\n }\n }\n if m.GetScoredEmailAddresses() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetScoredEmailAddresses())\n err = writer.WriteCollectionOfObjectValues(\"scoredEmailAddresses\", cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"surname\", m.GetSurname())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"userPrincipalName\", m.GetUserPrincipalName())\n if err != nil {\n return err\n }\n }\n if m.GetWebsites() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetWebsites())\n err = writer.WriteCollectionOfObjectValues(\"websites\", cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"yomiCompany\", m.GetYomiCompany())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "80ae839c9cddd0fc6e9f03a30fde0e72", "score": "0.6080473", "text": "func (s JSONSerializer) Serialize(ss interface{}) ([]byte, error) {\n\treturn json.Marshal(ss)\n}", "title": "" }, { "docid": "136a05624cc64e0debb9315da26477d2", "score": "0.60751796", "text": "func Serialize(b *fb.Builder, obj fb.UOffsetT) []byte {\n\tb.Finish(obj)\n\treturn b.FinishedBytes()\n}", "title": "" }, { "docid": "d11e829b1c62666cc59ce6d982528eaa", "score": "0.60697645", "text": "func (m *AddIn) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n {\n err := writer.WriteUUIDValue(\"id\", m.GetId())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n if m.GetProperties() != nil {\n cast := make([]i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, len(m.GetProperties()))\n for i, v := range m.GetProperties() {\n if v != nil {\n cast[i] = v.(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable)\n }\n }\n err := writer.WriteCollectionOfObjectValues(\"properties\", cast)\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"type\", m.GetTypeEscaped())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "17e41e36d6e19aa045e890872755f95b", "score": "0.60694957", "text": "func (n News) serialize() []byte {\n\tvar buffer bytes.Buffer\n\tenc := gob.NewEncoder(&buffer)\n\tenc.Encode(n)\n\treturn buffer.Bytes()\n}", "title": "" }, { "docid": "13824db437016d5480a795eca6ba0d8f", "score": "0.6060034", "text": "func (si ShareIdentity) Serialize() ([]byte, fail.Error) {\n\tr, err := json.Marshal(&si)\n\treturn r, fail.ConvertError(err)\n}", "title": "" }, { "docid": "90505f9e57d0efa4c5936f8720ddadfb", "score": "0.6053795", "text": "func (m *FileSystemInfo) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n {\n err := writer.WriteTimeValue(\"createdDateTime\", m.GetCreatedDateTime())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteTimeValue(\"lastAccessedDateTime\", m.GetLastAccessedDateTime())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteTimeValue(\"lastModifiedDateTime\", m.GetLastModifiedDateTime())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "453cf3c4eaff49dbba317f659e4d283d", "score": "0.60526365", "text": "func (self *Bookkeeper) Serialize(w io.Writer) error {\n\terr := serialization.WriteVarBytes(w, keypair.SerializePublicKey(self.PubKey))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"[Bookkeeper], serializing PubKey failed: %s\", err)\n\t}\n\terr = serialization.WriteVarBytes(w, []byte{byte(self.Action)})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"[Bookkeeper], serializing Action failed: %s\", err)\n\t}\n\terr = serialization.WriteVarBytes(w, self.Cert)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"[Bookkeeper], serializing Cert failed: %s\", err)\n\t}\n\terr = serialization.WriteVarBytes(w, keypair.SerializePublicKey(self.Issuer))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"[Bookkeeper], serializing Issuer failed: %s\", err)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "95686426d2e1af698b82c3f8ef50ff91", "score": "0.6047649", "text": "func (m *ServiceNowConnection) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteObjectValue(\"authenticationMethod\", m.GetAuthenticationMethod())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteTimeValue(\"createdDateTime\", m.GetCreatedDateTime())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"incidentApiUrl\", m.GetIncidentApiUrl())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"instanceUrl\", m.GetInstanceUrl())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteTimeValue(\"lastModifiedDateTime\", m.GetLastModifiedDateTime())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteTimeValue(\"lastQueriedDateTime\", m.GetLastQueriedDateTime())\n if err != nil {\n return err\n }\n }\n if m.GetServiceNowConnectionStatus() != nil {\n cast := (*m.GetServiceNowConnectionStatus()).String()\n err = writer.WriteStringValue(\"serviceNowConnectionStatus\", &cast)\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "13c448a69b9e02c16b9692c359e23ce6", "score": "0.6025337", "text": "func (k *SenderKeyState) Serialize() []byte {\n\treturn k.serializer.Serialize(k.structure())\n}", "title": "" }, { "docid": "eb7833c8da7db4a0e64cbee73b2eb516", "score": "0.6022822", "text": "func (m *Participant) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteObjectValue(\"info\", m.GetInfo())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteBoolValue(\"isInLobby\", m.GetIsInLobby())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteBoolValue(\"isMuted\", m.GetIsMuted())\n if err != nil {\n return err\n }\n }\n if m.GetMediaStreams() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetMediaStreams())\n err = writer.WriteCollectionOfObjectValues(\"mediaStreams\", cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"metadata\", m.GetMetadata())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"recordingInfo\", m.GetRecordingInfo())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "b51a5527137d15974c7d9ae80972a248", "score": "0.6014434", "text": "func (self *JobTransaction)Serialize()[]byte{\n data, err := json.Marshal(self)\n if err != nil {\n fmt.Println(err)\n }\n return data\n}", "title": "" }, { "docid": "1a1c7a48cba969684857433e244c1641", "score": "0.60133713", "text": "func (m *DataSource) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteObjectValue(\"createdBy\", m.GetCreatedBy())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteTimeValue(\"createdDateTime\", m.GetCreatedDateTime())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"displayName\", m.GetDisplayName())\n if err != nil {\n return err\n }\n }\n if m.GetHoldStatus() != nil {\n cast := (*m.GetHoldStatus()).String()\n err = writer.WriteStringValue(\"holdStatus\", &cast)\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "ce69896f65214aba686842733513c18d", "score": "0.6010948", "text": "func (m *CustomExtensionHandler) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteObjectValue(\"customExtension\", m.GetCustomExtension())\n if err != nil {\n return err\n }\n }\n if m.GetStage() != nil {\n cast := (*m.GetStage()).String()\n err = writer.WriteStringValue(\"stage\", &cast)\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "5f6fbe21b3c90a9ad3dea936aa95498a", "score": "0.6001694", "text": "func (m *Connector) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteStringValue(\"externalIp\", m.GetExternalIp())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"machineName\", m.GetMachineName())\n if err != nil {\n return err\n }\n }\n if m.GetMemberOf() != nil {\n cast := make([]i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, len(m.GetMemberOf()))\n for i, v := range m.GetMemberOf() {\n if v != nil {\n cast[i] = v.(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable)\n }\n }\n err = writer.WriteCollectionOfObjectValues(\"memberOf\", cast)\n if err != nil {\n return err\n }\n }\n if m.GetStatus() != nil {\n cast := (*m.GetStatus()).String()\n err = writer.WriteStringValue(\"status\", &cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"version\", m.GetVersion())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "2909aeced47943e767d85c11a5191447", "score": "0.60010123", "text": "func (p Result) Serialize() common.JSON {\n\treturn common.JSON{\n\t\t\"ID\": p.ID,\n\t\t\"TotalTime\": p.TotalTime,\n\t\t\"Place\": p.Place,\n\t\t\"RidersID\": p.RidersID,\n\t\t\"EventsID\": p.EventsID,\n\t\t\"Events\": p.Events,\n\t}\n}", "title": "" }, { "docid": "6e8ee19eb455f2187472932f301cc9e5", "score": "0.5990457", "text": "func (m *Session) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteObjectValue(\"callee\", m.GetCallee())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"caller\", m.GetCaller())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteTimeValue(\"endDateTime\", m.GetEndDateTime())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"failureInfo\", m.GetFailureInfo())\n if err != nil {\n return err\n }\n }\n if m.GetModalities() != nil {\n err = writer.WriteCollectionOfStringValues(\"modalities\", SerializeModality(m.GetModalities()))\n if err != nil {\n return err\n }\n }\n if m.GetSegments() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetSegments())\n err = writer.WriteCollectionOfObjectValues(\"segments\", cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteTimeValue(\"startDateTime\", m.GetStartDateTime())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "27349b2868b7d301487c73ef4f295d9f", "score": "0.5967983", "text": "func (c *Container) Serialize() string {\n\tout, err := json.MarshalIndent(c, \"\", \" \")\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\treturn string(out)\n}", "title": "" }, { "docid": "e734b1ede107838bfecd7f3c467e0b8c", "score": "0.59651476", "text": "func (j JSONStateSerializer) Serialize(state interface{}) (string, error) {\n\tvar b bytes.Buffer\n\tif err := json.NewEncoder(&b).Encode(state); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn b.String(), nil\n}", "title": "" }, { "docid": "55c895e422f290057fe50075ce729908", "score": "0.59538466", "text": "func (m *TimeSlot) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n {\n err := writer.WriteObjectValue(\"end\", m.GetEnd())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteObjectValue(\"start\", m.GetStart())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "61a0be225214817e0780df44131b5894", "score": "0.5952611", "text": "func (ds *DepositToStake) Serialize() []byte {\n\treturn byteutil.Must(proto.Marshal(ds.Proto()))\n}", "title": "" }, { "docid": "05c5a405881a3ade9c46b3b7d97b8487", "score": "0.59454083", "text": "func (m *MeetingRegistrantBase) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteStringValue(\"joinWebUrl\", m.GetJoinWebUrl())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "61c0f3cb7f47963c72e419b0dd7917b5", "score": "0.59451085", "text": "func (this *Item) Serialize(w io.Writer) error {\n\terr := serialization.WriteUint16(w, this.PrevIndex)\n\tif err != nil {\n\t\treturn NewDetailErr(err, ErrNoCode, \"[Items], PrevIndex serialize failed.\")\n\t}\n\terr = serialization.WriteUint32(w, this.EndHeight)\n\tif err != nil {\n\t\treturn NewDetailErr(err, ErrNoCode, \"[Items], EndHeight serialize failed.\")\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "612fee76306223d0a323d8e5763c059f", "score": "0.59337354", "text": "func (c Content) Serialize() common.JSON {\n\treturn common.JSON{\n\t\t\"id\": c.ID,\n\t\t\"description\": c.Description,\n\t\t\"user\": c.User.Serialize(),\n\t\t\"created_at\": c.CreatedAt,\n\t\t\"ContentName\": c.ContentName,\n\t\t\"Durations\": c.Durations,\n\t\t\"category\": c.Category,\n\t\t\"ContentThumbnailURL\": c.ContentThumbnailURL,\n\t\t\"ContentViewNum\": c.ContentViewNum,\n\t\t\"ContentStatus\": c.ContentStatus,\n\t\t\"PoseList\": c.PoseList,\n\t}\n}", "title": "" }, { "docid": "86833f1515a7b622564aa8295a8c7f2b", "score": "0.59299624", "text": "func (c *Cart) Serialize() common.JSON {\n\treturn common.JSON{\n\t\t\"id\": c.ID,\n\t\t\"shop\": c.Shop,\n\t\t\"created_at\": c.CreatedAt.Format(\"15:04 01-02-2006\"),\n\t\t\"updated_at\": c.UpdatedAt.Format(\"15:04 01-02-2006\"),\n\t}\n}", "title": "" }, { "docid": "44612e815e2405e9967665e7f58861fc", "score": "0.5921436", "text": "func (cp *CommercialPaper) Serialize() ([]byte, error) {\n\treturn json.Marshal(cp)\n}", "title": "" }, { "docid": "ac330165099463dddf36c88107f9c66a", "score": "0.59213245", "text": "func (provider *Provider) Serialize() (serialized map[string]interface{}) {\n\tserialized = make(map[string]interface{})\n\tserialized[\"provider\"] = \"password\"\n\tif provider.service != nil {\n\t\t// Serialize the service key\n\t\tserialized[\"key\"] = provider.service.Serialize()\n\t}\n\treturn\n}", "title": "" }, { "docid": "01d44c2865f78d59fbe0b6e5d5ba6171", "score": "0.5907884", "text": "func (k *SenderKey) Serialize() []byte {\n\treturn k.serializer.Serialize(k.Structure())\n}", "title": "" }, { "docid": "a6f50a153308dd5a21b0754f85703c81", "score": "0.58988214", "text": "func (t *Transaction) Serialize() interface{} {\n\tif t.signature == \"\" {\n\t\tlogger.Warning(\"this transaction is not signature\")\n\t}\n\tparam := make(map[string]interface{})\n\tparam[\"from\"] = t.from\n\n\tif !t.isDeploy || t.isMaintain {\n\t\tparam[\"to\"] = t.to\n\t}\n\n\tparam[\"timestamp\"] = t.timestamp\n\tparam[\"nonce\"] = t.nonce\n\n\tif !t.isMaintain {\n\t\tparam[\"simulate\"] = t.simulate\n\t}\n\n\tparam[\"type\"] = t.vmType\n\n\tif t.isValue {\n\t\tparam[\"value\"] = t.value\n\t} else if t.isMaintain && (t.opcode == 2 || t.opcode == 3) {\n\n\t} else {\n\t\tparam[\"payload\"] = t.payload\n\t}\n\n\tparam[\"signature\"] = t.signature\n\n\tif t.isMaintain {\n\t\tparam[\"opcode\"] = t.opcode\n\t}\n\n\tif t.hasExtra {\n\t\tparam[\"extra\"] = t.extra\n\t}\n\n\treturn param\n}", "title": "" }, { "docid": "83c5fe215a9b31fa28f14316e5be831c", "score": "0.58946353", "text": "func (mh *MetadataHandle) Serialize(metadata interface{}) {\n\tmh.metadata = metadata.(Metadata)\n\tmh.resetBuffer()\n\tif mh.GetFormat() == handle.JSON {\n\t\tenc := json.NewEncoder(mh)\n\t\tenc.Encode(mh.metadata)\n\t} else {\n\t\tenc := xml.NewEncoder(mh)\n\t\tenc.Encode(mh.metadata)\n\t}\n}", "title": "" }, { "docid": "232d6de6a9ec345c1961272ab04d92cb", "score": "0.58836466", "text": "func (p Property) Serialize() Data {\n\td := []byte{}\n\td = append(d, p.Code)\n\td = append(d, byte(p.Len))\n\td = append(d, p.Data...)\n\treturn d\n}", "title": "" }, { "docid": "f67a305796cba78b05f72fa96107b874", "score": "0.58806896", "text": "func (nid *nmqID) Serialize() []byte {\n\treturn SerializeNmqID(nid.messageID)\n}", "title": "" }, { "docid": "107eaa374d42eb9f25c0093a16c7f2fa", "score": "0.58727145", "text": "func (s *StoredChannel) serialize() ([]byte, error) {\n\tbuffer := &bytes.Buffer{}\n\tencoder := gob.NewEncoder(buffer)\n\terr := encoder.Encode(s)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn buffer.Bytes(), nil\n}", "title": "" }, { "docid": "70386dfd035f220cb85e105243b4c44e", "score": "0.58634484", "text": "func (ts *TransferStake) Serialize() []byte {\n\treturn byteutil.Must(proto.Marshal(ts.Proto()))\n}", "title": "" }, { "docid": "8f622e286bcbcf42657593d3885094e6", "score": "0.58624136", "text": "func (msg *ShootMessage) Serialize() []byte {\n\treturn []byte(fmt.Sprintf(\"%v %v\", msg.X, msg.Y))\n}", "title": "" }, { "docid": "3e1edbac82aadefe9f0cb76e9aa38910", "score": "0.58515835", "text": "func (c *Caller) serialize(builder *flatbuffers.Builder) flatbuffers.UOffsetT {\n\tlocOffset := c.location.serialize(builder)\n\n\tsymbol.CallerStart(builder)\n\n\tsymbol.CallerAddLocation(builder, locOffset)\n\tfuncCall := byte(0)\n\tif c.funcCall {\n\t\tfuncCall = byte(1)\n\t}\n\tsymbol.CallerAddFuncCall(builder, funcCall)\n\n\treturn symbol.CallerEnd(builder)\n}", "title": "" }, { "docid": "8c8235620f4eebadc3d22f52c5928c1c", "score": "0.58422226", "text": "func (m *FeatureTarget) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n {\n err := writer.WriteStringValue(\"id\", m.GetId())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n if m.GetTargetType() != nil {\n cast := (*m.GetTargetType()).String()\n err := writer.WriteStringValue(\"targetType\", &cast)\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "676ce310834a98f30f21994515640229", "score": "0.58322537", "text": "func (m *RecommendLabelAction) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.InformationProtectionAction.Serialize(writer)\n if err != nil {\n return err\n }\n if m.GetActions() != nil {\n cast := make([]i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, len(m.GetActions()))\n for i, v := range m.GetActions() {\n if v != nil {\n cast[i] = v.(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable)\n }\n }\n err = writer.WriteCollectionOfObjectValues(\"actions\", cast)\n if err != nil {\n return err\n }\n }\n if m.GetActionSource() != nil {\n cast := (*m.GetActionSource()).String()\n err = writer.WriteStringValue(\"actionSource\", &cast)\n if err != nil {\n return err\n }\n }\n if m.GetResponsibleSensitiveTypeIds() != nil {\n err = writer.WriteCollectionOfStringValues(\"responsibleSensitiveTypeIds\", m.GetResponsibleSensitiveTypeIds())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"sensitivityLabelId\", m.GetSensitivityLabelId())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "b07c0cb89c693e8c7f52ceb3864a9632", "score": "0.5823448", "text": "func Serialize(value interface{}) ([]byte, error) {\n\tvar b bytes.Buffer\n\tencoder := gob.NewEncoder(&b)\n\tif err := encoder.Encode(value); err != nil {\n\t\treturn nil, err\n\t}\n\treturn b.Bytes(), nil\n}", "title": "" }, { "docid": "3612549bcee1b318051a5fc9ef650276", "score": "0.5822678", "text": "func (r Store) Serialize() []byte {\n\tw := new(bytes.Buffer)\n\tenc := gob.NewEncoder(w)\n\terr := enc.Encode(r)\n\tif err != nil {\n\t\treturn nil\n\t}\n\n\treturn w.Bytes()\n}", "title": "" }, { "docid": "c7da4b20cd2578283ef6b0ca538cae97", "score": "0.58116716", "text": "func (p Address) Serialize() common.JSON {\n\treturn common.JSON{\n\t\t\"ID\": p.ID,\n\t\t\"Street\": p.Street,\n\t\t\"StreetNumber\": p.StreetNumber,\n\t\t\"PostalCode\": p.PostalCode,\n\t\t\"City\": p.City,\n\t\t\"Country\": p.Country,\n\t\t\"RidersID\": p.RidersID,\n\t\t\"EventsID\": p.EventsID,\n\t\t\"PlusCode\": p.PlusCode,\n\t\t\"Coordinate\": p.Coordinate,\n\t}\n}", "title": "" }, { "docid": "89c100443f241e17ee28072e6cbdeca0", "score": "0.58090997", "text": "func (acc *Account) Serialize() ([]byte, error) {\n\tif acc.Created.IsZero() {\n\t\tacc.Created = time.Now()\n\t}\n\tacc.RemoveOldAuthTokens()\n\treturn json.Marshal(acc)\n}", "title": "" }, { "docid": "fd6c9bf33cd7f89e4b1b293161995f6d", "score": "0.58089054", "text": "func (m *Macaroon) Serialize() (data []byte) {\n\t// Start data from version int\n\tdata = append(data, version)\n\n\t// Serialize Identity\n\tdata = serializePacket(data, packet{\n\t\tfieldType: fieldIdentifier,\n\t\tdata: m.head,\n\t})\n\tdata = append(data, 0)\n\n\t// Serialize caveats\n\tfor _, cav := range m.caveats {\n\t\tdata = serializePacket(data, packet{\n\t\t\tfieldType: fieldIdentifier,\n\t\t\tdata: cav,\n\t\t})\n\t\tdata = append(data, 0)\n\t}\n\n\tdata = append(data, 0)\n\n\t// Serialize tail\n\tdata = serializePacket(data, packet{\n\t\tfieldType: fieldSignature,\n\t\tdata: m.tail,\n\t})\n\n\treturn data\n}", "title": "" }, { "docid": "c01cd8e009fed1d0861cae0c250fcb07", "score": "0.58066136", "text": "func (this *Codec) serialize(root *TreeNode) string {\n\treturn \"\"\n}", "title": "" }, { "docid": "30ee2ef5bd49d5c6917cf0db6b516b16", "score": "0.5802525", "text": "func (m Administrator) Serialize() ([]byte, error) {\n\tbuf := new(bytes.Buffer)\n\n\t// Type (uint8)\n\t{\n\t\tif err := write(buf, m.Type); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Name (string)\n\t{\n\t\tif err := WriteVarChar(buf, m.Name, 8); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn buf.Bytes(), nil\n}", "title": "" }, { "docid": "ee3fed95d42b01375546ab622d0cfb6d", "score": "0.5797272", "text": "func (m *Admin) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteObjectValue(\"serviceAnnouncement\", m.GetServiceAnnouncement())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "0979dd695876ee2c5e8a17c18aec3786", "score": "0.5796929", "text": "func (tx *Transaction) Serialize() []byte {\n\tbytes, _ := proto.Marshal(tx)\n\treturn bytes\n}", "title": "" }, { "docid": "2385231ea9fa764e5b583f51df7bd53c", "score": "0.5794447", "text": "func (m *AccountModel) Serialize(value *Account) (int, error) {\n fbeBegin := m.CreateBegin()\n err := m.model.Set(value)\n fbeFullSize := m.CreateEnd(fbeBegin)\n return fbeFullSize, err\n}", "title": "" }, { "docid": "caf044ecdccee347e07da5d2ee5913bc", "score": "0.57695353", "text": "func (m *Call) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n if m.GetAudioRoutingGroups() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetAudioRoutingGroups())\n err = writer.WriteCollectionOfObjectValues(\"audioRoutingGroups\", cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"callbackUri\", m.GetCallbackUri())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"callChainId\", m.GetCallChainId())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"callOptions\", m.GetCallOptions())\n if err != nil {\n return err\n }\n }\n if m.GetCallRoutes() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetCallRoutes())\n err = writer.WriteCollectionOfObjectValues(\"callRoutes\", cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"chatInfo\", m.GetChatInfo())\n if err != nil {\n return err\n }\n }\n if m.GetContentSharingSessions() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetContentSharingSessions())\n err = writer.WriteCollectionOfObjectValues(\"contentSharingSessions\", cast)\n if err != nil {\n return err\n }\n }\n if m.GetDirection() != nil {\n cast := (*m.GetDirection()).String()\n err = writer.WriteStringValue(\"direction\", &cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"incomingContext\", m.GetIncomingContext())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"mediaConfig\", m.GetMediaConfig())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"mediaState\", m.GetMediaState())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"meetingInfo\", m.GetMeetingInfo())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"myParticipantId\", m.GetMyParticipantId())\n if err != nil {\n return err\n }\n }\n if m.GetOperations() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetOperations())\n err = writer.WriteCollectionOfObjectValues(\"operations\", cast)\n if err != nil {\n return err\n }\n }\n if m.GetParticipants() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetParticipants())\n err = writer.WriteCollectionOfObjectValues(\"participants\", cast)\n if err != nil {\n return err\n }\n }\n if m.GetRequestedModalities() != nil {\n err = writer.WriteCollectionOfStringValues(\"requestedModalities\", SerializeModality(m.GetRequestedModalities()))\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"resultInfo\", m.GetResultInfo())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"source\", m.GetSource())\n if err != nil {\n return err\n }\n }\n if m.GetState() != nil {\n cast := (*m.GetState()).String()\n err = writer.WriteStringValue(\"state\", &cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"subject\", m.GetSubject())\n if err != nil {\n return err\n }\n }\n if m.GetTargets() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetTargets())\n err = writer.WriteCollectionOfObjectValues(\"targets\", cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"tenantId\", m.GetTenantId())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"toneInfo\", m.GetToneInfo())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"transcription\", m.GetTranscription())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "0ee235725978c5cd9a99ec927bb1d11d", "score": "0.5762979", "text": "func (b *Buffer) Serialize() error {\n\tif !b.Settings[\"savecursor\"].(bool) && !b.Settings[\"saveundo\"].(bool) {\n\t\treturn nil\n\t}\n\n\tname := configDir + \"/buffers/\" + EscapePath(b.AbsPath)\n\n\treturn overwriteFile(name, func(file io.Writer) error {\n\t\treturn gob.NewEncoder(file).Encode(SerializedBuffer{\n\t\t\tb.EventHandler,\n\t\t\tb.Cursor,\n\t\t\tb.ModTime,\n\t\t})\n\t})\n}", "title": "" }, { "docid": "f341b90d6b84b29c9927ee0258157940", "score": "0.5751545", "text": "func (m *VulnerabilityState) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n {\n err := writer.WriteStringValue(\"cve\", m.GetCve())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"severity\", m.GetSeverity())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteBoolValue(\"wasRunning\", m.GetWasRunning())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "3c3db4cee100761302e6dfc2c71f3f43", "score": "0.575132", "text": "func (m *UserTrainingContentEventInfo) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n {\n err := writer.WriteStringValue(\"browser\", m.GetBrowser())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteTimeValue(\"contentDateTime\", m.GetContentDateTime())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"ipAddress\", m.GetIpAddress())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"osPlatformDeviceDetails\", m.GetOsPlatformDeviceDetails())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteFloat64Value(\"potentialScoreImpact\", m.GetPotentialScoreImpact())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "de651e548faf5e310cbbea11b09d0a4b", "score": "0.5742083", "text": "func (m *ChangeTrackedEntity) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n return nil\n}", "title": "" }, { "docid": "7d0fe9598fc39d546b4180a1a819b365", "score": "0.57268137", "text": "func (m *Program) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n if m.GetControls() != nil {\n cast := make([]i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, len(m.GetControls()))\n for i, v := range m.GetControls() {\n if v != nil {\n cast[i] = v.(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable)\n }\n }\n err = writer.WriteCollectionOfObjectValues(\"controls\", cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"description\", m.GetDescription())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"displayName\", m.GetDisplayName())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "0338fd75efcb09c8b3efbb0279f5f8dc", "score": "0.5726691", "text": "func (p ProtobufStateSerializer) Serialize(state interface{}) (string, error) {\n\tbin, err := proto.Marshal(state.(proto.Message))\n\tif err != nil {\n\t\treturn \"\", errors.Trace(err)\n\t}\n\treturn base64.StdEncoding.EncodeToString(bin), nil\n}", "title": "" }, { "docid": "efb7a77388a4c6e5441454a6d9f1f7be", "score": "0.57246155", "text": "func (t *Transaction) SerializeToString() string {\n\treturn \"\"\n}", "title": "" }, { "docid": "b575776f1692e57d58603d0ac195c033", "score": "0.5714848", "text": "func (m *FileSecurityState) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n {\n err := writer.WriteObjectValue(\"fileHash\", m.GetFileHash())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"name\", m.GetName())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"path\", m.GetPath())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"riskScore\", m.GetRiskScore())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "92a221a7040176aab9468bc050800e6a", "score": "0.57070374", "text": "func (m *CrossTenantUserSyncInbound) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n {\n err := writer.WriteBoolValue(\"isSyncAllowed\", m.GetIsSyncAllowed())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "9e5bc9458aea53c241405667447fba42", "score": "0.5705193", "text": "func (m *Privacy) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n if m.GetSubjectRightsRequests() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetSubjectRightsRequests())\n err := writer.WriteCollectionOfObjectValues(\"subjectRightsRequests\", cast)\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "1888b1f80eabdddc27f245ce9ae2dc6f", "score": "0.57051414", "text": "func (s *Data) Serialize() (string, error) {\n\tvar msg bytes.Buffer\n\n\tmsg.WriteByte(version)\n\tvar flagByte uint8\n\tif s.IsPlayer {\n\t\tflagByte |= playerFlag\n\t\tmsg.WriteByte(flagByte)\n\n\t\tsize := make([]byte, binary.MaxVarintLen64)\n\t\tn := binary.PutUvarint(size, uint64(len(s.PlayerID)))\n\t\tmsg.Write(size[:n])\n\n\t\tmsg.WriteString(s.PlayerID)\n\t}\n\n\treturn SignAndEncode(msg, config.CookieSignatureKey, config.CookieCryptKey)\n}", "title": "" }, { "docid": "5be554dd366c2da73bc6f9564143a486", "score": "0.570122", "text": "func (ps *paxosStorage) Serialize() ([]byte, error) {\n\tb := new(bytes.Buffer)\n\te := gob.NewEncoder(b)\n\n\t// Encoding the storage state\n\tps.mutex.RLock()\n\tps.listMutex.RLock()\n\terr := e.Encode(ps)\n\tps.listMutex.RUnlock()\n\tps.mutex.RUnlock()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn b.Bytes(), nil\n}", "title": "" }, { "docid": "c5c9ad4d0bec49e37fc007186f0b7596", "score": "0.56955475", "text": "func Serialize(w io.Writer, v interface{}) error {\n\tenc := json.NewEncoder(w)\n\tenc.SetIndent(\"\", \" \")\n\terr := enc.Encode(v)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "73c5a1f42e21cbae230ca8675e6fccc5", "score": "0.56923103", "text": "func (f Event) Serialize() string {\n\tb, err := json.Marshal(f)\n\tif err != nil {\n\t\tlogging.Errorf(\"Error serializing event [%v]: %v\", f, err)\n\t\treturn fmt.Sprintf(\"%v\", f)\n\t}\n\n\treturn string(b)\n}", "title": "" }, { "docid": "942001687874c213dcbdab9415a6618d", "score": "0.5688916", "text": "func (list *List) Serialize() common.JSON {\n\t// parse the item data\n\tserializedItems := make([]common.JSON, len(list.Items), len(list.Items))\n\tfor index := range list.Items {\n\t\tserializedItems[index] = list.Items[index].Serialize()\n\t}\n\n\treturn common.JSON{\n\t\t\"title\": list.Title,\n\t\t\"items\": serializedItems,\n\t\t\"uuid\": list.UUID,\n\t}\n}", "title": "" }, { "docid": "23cf145376ec9adfbe4f8a72ff39cceb", "score": "0.56888396", "text": "func (m *PlannerPlanDetails) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteObjectValue(\"categoryDescriptions\", m.GetCategoryDescriptions())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"sharedWith\", m.GetSharedWith())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "377e41f61e07f6b9f54e7019e6ced967", "score": "0.56863755", "text": "func (command TranscodeCommand) Serialize() ([]byte, error) {\n\treturn json.Marshal(command)\n}", "title": "" }, { "docid": "4854df7048dbcdd11fb125a112ec1c77", "score": "0.568465", "text": "func (b *FileSelect) Serialize(e page.Encoder) {\n\tb.ControlBase.Serialize(e)\n\n\tif err := e.Encode(b.fileInfos); err != nil {\n\t\tpanic(err)\n\t}\n\tif err := e.Encode(b.uploadEventID); err != nil {\n\t\tpanic(err)\n\t}\n}", "title": "" }, { "docid": "8125a3f9f1edd60b77be2f69eacf13ad", "score": "0.56817794", "text": "func (p *Post) Serialized() []byte {\n\treturn []byte{}\n}", "title": "" }, { "docid": "21607d0f3b7dd04f36daa65d5dfb80d6", "score": "0.56760913", "text": "func (serializerJSONImpl) Write(w io.Writer, tObject interface{}) error {\n\terr := Serialize(w, tObject)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c044389b7cc0a958ffdc13d0d778b949", "score": "0.5671427", "text": "func (m *Contract) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.DirectoryObject.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteStringValue(\"contractType\", m.GetContractType())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteUUIDValue(\"customerId\", m.GetCustomerId())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"defaultDomainName\", m.GetDefaultDomainName())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"displayName\", m.GetDisplayName())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "a9ca32f28817cb807291728d64502e5e", "score": "0.5664468", "text": "func (m Entity) Serialize() ([]byte, error) {\n\tbuf := new(bytes.Buffer)\n\n\t// Name (string)\n\t{\n\t\tif err := WriteVarChar(buf, m.Name, 8); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Type (byte)\n\t{\n\t\tif err := write(buf, m.Type); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// LEI (string)\n\t{\n\t\tif err := WriteFixedChar(buf, m.LEI, 20); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// AddressIncluded (bool)\n\t{\n\t\tif err := write(buf, m.AddressIncluded); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// UnitNumber (string)\n\tif m.AddressIncluded {\n\t\tif err := WriteVarChar(buf, m.UnitNumber, 8); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// BuildingNumber (string)\n\tif m.AddressIncluded {\n\t\tif err := WriteVarChar(buf, m.BuildingNumber, 8); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Street (string)\n\tif m.AddressIncluded {\n\t\tif err := WriteVarChar(buf, m.Street, 16); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// SuburbCity (string)\n\tif m.AddressIncluded {\n\t\tif err := WriteVarChar(buf, m.SuburbCity, 8); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// TerritoryStateProvinceCode (string)\n\tif m.AddressIncluded {\n\t\tif err := WriteFixedChar(buf, m.TerritoryStateProvinceCode, 5); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// CountryCode (string)\n\tif m.AddressIncluded {\n\t\tif err := WriteFixedChar(buf, m.CountryCode, 3); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// PostalZIPCode (string)\n\tif m.AddressIncluded {\n\t\tif err := WriteFixedChar(buf, m.PostalZIPCode, 12); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// EmailAddress (string)\n\t{\n\t\tif err := WriteVarChar(buf, m.EmailAddress, 8); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// PhoneNumber (string)\n\t{\n\t\tif err := WriteVarChar(buf, m.PhoneNumber, 8); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Administration ([]Administrator)\n\t{\n\t\tif err := WriteVariableSize(buf, uint64(len(m.Administration)), 8, 8); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tfor _, value := range m.Administration {\n\t\t\tb, err := value.Serialize()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tif err := write(buf, b); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t}\n\n\t// Management ([]Manager)\n\t{\n\t\tif err := WriteVariableSize(buf, uint64(len(m.Management)), 8, 8); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tfor _, value := range m.Management {\n\t\t\tb, err := value.Serialize()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tif err := write(buf, b); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn buf.Bytes(), nil\n}", "title": "" }, { "docid": "39181abdced14462892ab2e2945add0e", "score": "0.5662368", "text": "func serialize(src interface{}) ([]byte, error) {\n\tbuf := new(bytes.Buffer)\n\tenc := gob.NewEncoder(buf)\n\tif err := enc.Encode(src); err != nil {\n\t\treturn nil, err\n\t}\n\treturn buf.Bytes(), nil\n}", "title": "" }, { "docid": "1488fbc80b78c278be55ed5179b54ae6", "score": "0.5660354", "text": "func (m *DataSourceContainer) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteTimeValue(\"createdDateTime\", m.GetCreatedDateTime())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"displayName\", m.GetDisplayName())\n if err != nil {\n return err\n }\n }\n if m.GetHoldStatus() != nil {\n cast := (*m.GetHoldStatus()).String()\n err = writer.WriteStringValue(\"holdStatus\", &cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteTimeValue(\"lastModifiedDateTime\", m.GetLastModifiedDateTime())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteTimeValue(\"releasedDateTime\", m.GetReleasedDateTime())\n if err != nil {\n return err\n }\n }\n if m.GetStatus() != nil {\n cast := (*m.GetStatus()).String()\n err = writer.WriteStringValue(\"status\", &cast)\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "d2987b8d107c9fd76ac6123489415d66", "score": "0.56591034", "text": "func (m *UserIdentity) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Identity.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteStringValue(\"ipAddress\", m.GetIpAddress())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"userPrincipalName\", m.GetUserPrincipalName())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "5e414fb13c15a0c7de77da674f862760", "score": "0.5656513", "text": "func (s *MeasurementList) Serialize() (string, error) {\n\tb, err := json.Marshal(s)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(b), nil\n}", "title": "" }, { "docid": "5b7aae1e23936aa1ef7ab5664a9a54be", "score": "0.5655933", "text": "func (n *Node) Serialize() string {\n\tif n == nil {\n\t\treturn \"-\"\n\t}\n\treturn \"Node(\" + n.Value + \",\" + n.Left.Serialize() + \",\" + n.Right.Serialize() + \")\"\n}", "title": "" }, { "docid": "0815be08a32b7f3f5ea9057d9d6c4be7", "score": "0.5654231", "text": "func (m VotingSystem) Serialize() ([]byte, error) {\n\tbuf := new(bytes.Buffer)\n\n\t// Name (string)\n\t{\n\t\tif err := WriteVarChar(buf, m.Name, 8); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// VoteType (byte)\n\t{\n\t\tif err := write(buf, m.VoteType); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// TallyLogic (byte)\n\t{\n\t\tif err := write(buf, m.TallyLogic); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// ThresholdPercentage (uint8)\n\t{\n\t\tif err := write(buf, m.ThresholdPercentage); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// VoteMultiplierPermitted (bool)\n\t{\n\t\tif err := write(buf, m.VoteMultiplierPermitted); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// HolderProposalFee (uint64)\n\t{\n\t\tif err := write(buf, m.HolderProposalFee); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn buf.Bytes(), nil\n}", "title": "" }, { "docid": "0f8b75bfdcd628fe4f1d3dec82464f29", "score": "0.5652536", "text": "func (m *PlannerPlan) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n if m.GetBuckets() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetBuckets())\n err = writer.WriteCollectionOfObjectValues(\"buckets\", cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"container\", m.GetContainer())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"createdBy\", m.GetCreatedBy())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteTimeValue(\"createdDateTime\", m.GetCreatedDateTime())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"details\", m.GetDetails())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"owner\", m.GetOwner())\n if err != nil {\n return err\n }\n }\n if m.GetTasks() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetTasks())\n err = writer.WriteCollectionOfObjectValues(\"tasks\", cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"title\", m.GetTitle())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "ad0c975ee7bf6ad17e64ebbf66896242", "score": "0.5650169", "text": "func (u *User) Serialize() common.JSON {\n\treturn common.JSON{\n\t\t\"id\": u.ID,\n\t\t\"username\": u.Username,\n\t\t\"fullname\": u.Fullname,\n\t}\n}", "title": "" }, { "docid": "b3d4ab3fa2a38c2a717b10c68b21efaa", "score": "0.56469834", "text": "func (this *Codec) serialize(root *TreeNode) string {\n\tprintInTree(root, &this.inorder, map[int]int{})\n\tprintPreTree(root, &this.preorder, map[int]int{})\n\treturn this.inorder + \"||\" + this.preorder\n}", "title": "" }, { "docid": "26e31888a51ca5f19498082063d8265b", "score": "0.56461465", "text": "func (m *InferenceClassificationOverride) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n if m.GetClassifyAs() != nil {\n cast := (*m.GetClassifyAs()).String()\n err = writer.WriteStringValue(\"classifyAs\", &cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"senderEmailAddress\", m.GetSenderEmailAddress())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "fe7b9d78cbea4978befec1f3e431cd16", "score": "0.56433535", "text": "func (m *WindowsKioskUser) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "d2a4c927264b48c07fa7910bb219ce7b", "score": "0.5640998", "text": "func (m *Print) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n if m.GetConnectors() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetConnectors())\n err := writer.WriteCollectionOfObjectValues(\"connectors\", cast)\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n if m.GetOperations() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetOperations())\n err := writer.WriteCollectionOfObjectValues(\"operations\", cast)\n if err != nil {\n return err\n }\n }\n if m.GetPrinters() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetPrinters())\n err := writer.WriteCollectionOfObjectValues(\"printers\", cast)\n if err != nil {\n return err\n }\n }\n if m.GetServices() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetServices())\n err := writer.WriteCollectionOfObjectValues(\"services\", cast)\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteObjectValue(\"settings\", m.GetSettings())\n if err != nil {\n return err\n }\n }\n if m.GetShares() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetShares())\n err := writer.WriteCollectionOfObjectValues(\"shares\", cast)\n if err != nil {\n return err\n }\n }\n if m.GetTaskDefinitions() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetTaskDefinitions())\n err := writer.WriteCollectionOfObjectValues(\"taskDefinitions\", cast)\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "db6decc0f69b3c97d546dd366d85f28a", "score": "0.5637102", "text": "func (m *Term) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n if m.GetChildren() != nil {\n cast := make([]i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, len(m.GetChildren()))\n for i, v := range m.GetChildren() {\n if v != nil {\n cast[i] = v.(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable)\n }\n }\n err = writer.WriteCollectionOfObjectValues(\"children\", cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteTimeValue(\"createdDateTime\", m.GetCreatedDateTime())\n if err != nil {\n return err\n }\n }\n if m.GetDescriptions() != nil {\n cast := make([]i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, len(m.GetDescriptions()))\n for i, v := range m.GetDescriptions() {\n if v != nil {\n cast[i] = v.(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable)\n }\n }\n err = writer.WriteCollectionOfObjectValues(\"descriptions\", cast)\n if err != nil {\n return err\n }\n }\n if m.GetLabels() != nil {\n cast := make([]i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, len(m.GetLabels()))\n for i, v := range m.GetLabels() {\n if v != nil {\n cast[i] = v.(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable)\n }\n }\n err = writer.WriteCollectionOfObjectValues(\"labels\", cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteTimeValue(\"lastModifiedDateTime\", m.GetLastModifiedDateTime())\n if err != nil {\n return err\n }\n }\n if m.GetProperties() != nil {\n cast := make([]i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, len(m.GetProperties()))\n for i, v := range m.GetProperties() {\n if v != nil {\n cast[i] = v.(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable)\n }\n }\n err = writer.WriteCollectionOfObjectValues(\"properties\", cast)\n if err != nil {\n return err\n }\n }\n if m.GetRelations() != nil {\n cast := make([]i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, len(m.GetRelations()))\n for i, v := range m.GetRelations() {\n if v != nil {\n cast[i] = v.(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable)\n }\n }\n err = writer.WriteCollectionOfObjectValues(\"relations\", cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"set\", m.GetSet())\n if err != nil {\n return err\n }\n }\n return nil\n}", "title": "" }, { "docid": "a3b3bd2ff7f4e5baadd8aba589253d07", "score": "0.5635447", "text": "func Serialize(obj interface{}, escapeHTML ...bool) string {\n\tsetEscapeHTML := false\n\tif len(escapeHTML) >= 1 {\n\t\tsetEscapeHTML = escapeHTML[0]\n\t}\n\tvar buf bytes.Buffer\n\tenc := json.NewEncoder(&buf)\n\t// disabled the HTMLEscape for &, <, and > to \\u0026, \\u003c, and \\u003e in json string\n\tenc.SetEscapeHTML(setEscapeHTML)\n\terr := enc.Encode(obj)\n\tif err != nil {\n\t\tuniledgerlog.Error(err.Error())\n\t\treturn \"\"\n\t}\n\treturn strings.TrimSpace(buf.String())\n\t//return strings.Replace(strings.TrimSpace(buf.String()), \"\\n\", \"\", -1)\n}", "title": "" } ]
fc0c72ec131699a576f3c36e77acbf79
DropPtrTest returns a new list after dropping the given item
[ { "docid": "03a89266355145524170e888a26eb6a2", "score": "0.79129016", "text": "func DropPtrTest() string {\n\treturn `\nfunc TestDrop<FTYPE>Ptr(t *testing.T) {\n\tvar v1 <TYPE> = 1\n\tvar v2 <TYPE> = 2\n\tvar v3 <TYPE> = 3\n\n\texpectedList := []*<TYPE>{&v2, &v3}\n\tnewList := Drop<FTYPE>Ptr(&v1, []*<TYPE>{&v1, &v2, &v3, &v1})\n\n\tif *newList[0] != *expectedList[0] || *newList[1] != *expectedList[1] {\n\t\tt.Errorf(\"Drop<FTYPE>Ptr failed. Expected list=%v, actual list=%v\", expectedList, newList)\n\t}\n\n\tnewList = Drop<FTYPE>Ptr(&v1, []*<TYPE>{})\n\n\tif len(newList) != 0 {\n\t\tt.Errorf(\"Drop<FTYPE>Ptr failed. Expected list=%v, actual list=%v\", []*<TYPE>{}, newList)\n\t}\n\n\tnewList = Drop<FTYPE>Ptr(&v1, nil)\n\tif len(newList) != 0 {\n\t\tt.Errorf(\"Drop<FTYPE>Ptr failed. Expected list=%v, actual list=%v\", []*<TYPE>{}, newList)\n\t\tt.Errorf(reflect.String.String())\n\t}\n}\n\nfunc TestDrop<FTYPE>sPtr(t *testing.T) {\n\tvar v1 <TYPE> = 1\n\tvar v2 <TYPE> = 2\n\tvar v3 <TYPE> = 3\n\tvar v4 <TYPE> = 4\n\n\t// Test : Drop number from the list\n\texpectedList := []*<TYPE>{&v2, &v3}\n\tnewList := Drop<FTYPE>sPtr([]*<TYPE>{&v1, &v4}, []*<TYPE>{&v1, &v2, &v3, &v1, &v4})\n\n\tif *newList[0] != *expectedList[0] || *newList[1] != *expectedList[1] {\n\t\tt.Errorf(\"Drop<FTYPE>sPtr failed. Expected list=%v, actual list=%v\", expectedList, newList)\n\t}\n\n\tnewList = Drop<FTYPE>sPtr([]*<TYPE>{&v1, &v4}, []*<TYPE>{})\n\n\tif len(newList) != 0 {\n\t\tt.Errorf(\"Drop<FTYPE>sPtr failed. Expected list=%v, actual list=%v\", []*<TYPE>{}, newList)\n\t}\n\n\tnewList = Drop<FTYPE>sPtr([]*<TYPE>{&v1, &v4}, nil)\n\tif len(newList) != 0 {\n\t\tt.Errorf(\"Drop<FTYPE>sPtr failed. Expected list=%v, actual list=%v\", []*<TYPE>{}, newList)\n\t}\n\n\tnewList = Drop<FTYPE>sPtr(nil, nil)\n\tif len(newList) != 0 {\n\t\tt.Errorf(\"Drop<FTYPE>sPtr failed. Expected list=%v, actual list=%v\", []*<TYPE>{}, newList)\n\t}\n\n\tnewList = Drop<FTYPE>sPtr(nil, []*<TYPE>{&v1, &v4})\n\tif *newList[0] != 1 || *newList[1] != 4 {\n\t\tt.Errorf(\"Drop<FTYPE>s failed. Expected list=%v, actual list=%v\", expectedList, newList)\n\t}\n}\n`\n}", "title": "" } ]
[ { "docid": "41acf44fbfceee9b7a971a298b0f04d3", "score": "0.586426", "text": "func (avl *AVL) drop(item Comparable) *AVL {\n\tavl = avl.remove(item)\n\tavl = avl.rebalance()\n\treturn avl\n}", "title": "" }, { "docid": "f7d4b0410435c49d8ba1c68b8e02e1a6", "score": "0.5834948", "text": "func DropPtr(pred PtrPredicate, s <-chan uintptr) <-chan uintptr {\n\tch := make(chan uintptr, 1)\n\tgo func() {\n\t\tfor {\n\t\t\tif v, ok := <-s; !ok {\n\t\t\t\tbreak\n\t\t\t} else if !pred(v) {\n\t\t\t\tch <- v\n\t\t\t\tfor i := range s {\n\t\t\t\t\tch <- i\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tclose(ch)\n\t}()\n\treturn ch\n}", "title": "" }, { "docid": "a9bab2d0ea1a3d3c52acdf81c65c84cc", "score": "0.5476212", "text": "func TestDelete(t *testing.T) {\n\tfmt.Print(testList.visualiseList(), \"\\n\")\n\ttestList.DeleteRange(0, 130)\n\tfmt.Print(testList.visualiseList(), \"\\n\")\n}", "title": "" }, { "docid": "8266545b1174a8bd5c4c757dede5906f", "score": "0.5454307", "text": "func drop(list []string, drop []string) []string {\n\tdd := map[string]struct{}{}\n\tfor _, d := range drop {\n\t\tdd[d] = struct{}{}\n\t}\n\tres := []string{}\n\tfor _, x := range list {\n\t\tif _, f := dd[x]; !f {\n\t\t\tres = append(res, x)\n\t\t}\n\t}\n\treturn res\n}", "title": "" }, { "docid": "82f845afab72204c6695968210dedee9", "score": "0.5386109", "text": "func (list *IntList) Drop(n int) *IntList {\n\tif list == nil || n == 0 {\n\t\treturn list\n\t}\n\n\tlist.s.RLock()\n\tdefer list.s.RUnlock()\n\n\tif n >= len(list.m) {\n\t\treturn nil\n\t}\n\n\tresult := MakeIntList(0, 0)\n\tresult.m = list.m[n:]\n\treturn result\n}", "title": "" }, { "docid": "fe6099e3458e7150bad84f807830f1fc", "score": "0.53687847", "text": "func Drop() Matcher {\n\treturn matchFn(func(_ Tuple) Tuple { return nil })\n}", "title": "" }, { "docid": "ad8b12213f6fa40cd2787a3988e07722", "score": "0.52669513", "text": "func RemovePtr() string {\n\treturn `\nfunc Remove<CONDITIONAL_TYPE>Ptr(f func(*<TYPE>) bool, list []*<TYPE>) []*<TYPE> {\n\tif f == nil {\n\t\treturn []*<TYPE>{}\n\t}\n\tvar newList []*<TYPE>\n\tfor _, v := range list {\n\t\tif !f(v) {\n\t\t\tnewList = append(newList, v)\n\t\t}\n\t}\n\treturn newList\n}\n`\n}", "title": "" }, { "docid": "e2e91c82fd3ea68f4c032c2eb22bd692", "score": "0.5193525", "text": "func (l *Level) DropItem(x, y int, i *Item) bool {\n\n\tspaces := make([]coord, 0, 68) //dropradius is 5, 68 possible locations\n\tl.LevelMap.ShadowCast(x, y, 5, GetEmptySpacesCast(&spaces))\n\n\tif len(spaces) == 0 {\n\t\treturn false\n\t} else {\n\n\t\td := 25 //util.distance returns d^2, so 25 is max\n\t\tbest := 0\n\t\t//find closest open space\n\t\tfor i, c := range spaces {\n\t\t\tif util.Distance(c.x, x, c.y, y) < d {\n\t\t\t\td = util.Distance(c.x, x, c.y, y)\n\t\t\t\tbest = i\n\t\t\t}\n\t\t}\n\n\t\tl.LevelMap.AddItem(spaces[best].x, spaces[best].y, i)\n\t\treturn true\n\t}\n}", "title": "" }, { "docid": "c5d5b44afe2cdb4274c5cc883b93bcc8", "score": "0.5182563", "text": "func (list *IntList) DropWhile(p func(int) bool) *IntList {\n\tif list == nil {\n\t\treturn nil\n\t}\n\n\tlist.s.RLock()\n\tdefer list.s.RUnlock()\n\n\tresult := MakeIntList(0, 0)\n\tadding := false\n\n\tfor _, v := range list.m {\n\t\tif adding || !p(v) {\n\t\t\tadding = true\n\t\t\tresult.m = append(result.m, v)\n\t\t}\n\t}\n\n\treturn result\n}", "title": "" }, { "docid": "a2b9c0bed976b9b6d99f965bf430a405", "score": "0.51578355", "text": "func MethodChainStructForDropWhilePtr() string {\n\treturn `\n// DropWhilePtr - drops the items from the list as long as condition satisfies\nfunc (slice <NEWTYPE>SlicePtr) DropWhilePtr(functors ...<NEWTYPE>FunctorForFilterPtr) <NEWTYPE>SlicePtr {\n\n\ttmpSlice := slice\n\t\n\tfor _, f := range functors {\n\t\tif f == nil {\n\t\t\tcontinue\n\t\t}\n\t\ttmpSlice = DropWhile<CONDITIONAL_TYPE>Ptr(f, tmpSlice)\n\t}\n\n\treturn tmpSlice\n}\n`\n}", "title": "" }, { "docid": "dac86e0fdcbd5e941ba8fec6f2a21361", "score": "0.5145162", "text": "func (ad *Device) DropLink() {}", "title": "" }, { "docid": "57bb56aed633207f7c63ad33f8c02a5a", "score": "0.51366305", "text": "func (db *DB) Drop(item interface{}) error {\n\tref := reflect.ValueOf(item)\n\n\tif !ref.IsValid() || ref.Kind() != reflect.Ptr || ref.Elem().Kind() != reflect.Struct {\n\t\treturn ErrDataMustBeStructPointer\n\t}\n\n\tstructType := reflect.TypeOf(item)\n\tnamespace := structType.Elem().Name()\n\n\tupdateValue, err := sjson.Delete(db.db.Content.Raw, namespace)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdb.db.Content.Raw = updateValue\n\treturn db.write()\n}", "title": "" }, { "docid": "f4c18dc1733fe866f33f7d46d1fbc6ca", "score": "0.5028287", "text": "func TestToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "f4c18dc1733fe866f33f7d46d1fbc6ca", "score": "0.5028287", "text": "func TestToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "f4c18dc1733fe866f33f7d46d1fbc6ca", "score": "0.5028287", "text": "func TestToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "f4c18dc1733fe866f33f7d46d1fbc6ca", "score": "0.5028287", "text": "func TestToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "f4c18dc1733fe866f33f7d46d1fbc6ca", "score": "0.5028287", "text": "func TestToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "f4c18dc1733fe866f33f7d46d1fbc6ca", "score": "0.5028287", "text": "func TestToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "f4c18dc1733fe866f33f7d46d1fbc6ca", "score": "0.5028287", "text": "func TestToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "f4c18dc1733fe866f33f7d46d1fbc6ca", "score": "0.5028287", "text": "func TestToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "f4c18dc1733fe866f33f7d46d1fbc6ca", "score": "0.5028287", "text": "func TestToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "5e82e989007f0bc7c1f87a29a97c44c9", "score": "0.50278455", "text": "func (b *StandardBag) DropItem(slot int) (Item, error) {\n\tif slot < 0 || slot >= len(b.items) {\n\t\treturn nil, ErrInvalidBagSlot\n\t}\n\tif b.items[slot] == nil {\n\t\treturn nil, ErrEmptyBagSlot\n\t}\n\titem := b.items[slot]\n\tb.items[slot] = nil\n\treturn item, nil\n}", "title": "" }, { "docid": "85b79b102cc7f913095c3494bd2e97d1", "score": "0.50246763", "text": "func (s *StoriesTask) DropData() {}", "title": "" }, { "docid": "1d1cf45bd38d101f7ac9d9902d9a1e1c", "score": "0.500855", "text": "func Drop(pred Predicate, s <-chan interface{}) <-chan interface{} {\n\tch := make(chan interface{}, 1)\n\tgo func() {\n\t\tfor {\n\t\t\tif v, ok := <-s; !ok {\n\t\t\t\tbreak\n\t\t\t} else if !pred(v) {\n\t\t\t\tch <- v\n\t\t\t\tfor i := range s {\n\t\t\t\t\tch <- i\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tclose(ch)\n\t}()\n\treturn ch\n}", "title": "" }, { "docid": "a0786a0c9fbec72502381752fe522b0b", "score": "0.49911535", "text": "func (l *List) Remove(item interface{}) {\n\tcounter := 0\n\tnewItems := make([]interface{}, l.size)\n\n\tfor _, i := range l.items {\n\t\tif i != item {\n\t\t\tnewItems[counter] = i\n\t\t\tcounter++\n\t\t} else {\n\t\t\tl.pointer--\n\t\t}\n\t}\n\n\tl.items = newItems\n}", "title": "" }, { "docid": "98eaee91e766ca9de8dee4120f1742dc", "score": "0.49750504", "text": "func (item *Item) Remove(leftNext **Item) *Item {\n\t*leftNext = item.Next\n\treturn item.Next\n}", "title": "" }, { "docid": "0c9bc7fbde8a8633c9dfd1d7bc002a18", "score": "0.4963263", "text": "func FilterMapIONumberPtrTest() string {\n\treturn `\nfunc TestFilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr(t *testing.T) {\n\t// Test : some logic\n\tvar v1 <INPUT_TYPE> = 1\n\tvar v2 <INPUT_TYPE> = 2\n\tvar v3 <INPUT_TYPE> = 3\n\n\tvar vo3 <OUTPUT_TYPE> = 3\n\tvar vo4 <OUTPUT_TYPE> = 4\n\n\texpectedList := []*<OUTPUT_TYPE>{&vo3, &vo4}\n\tnewList := FilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr(notOne<FINPUT_TYPE><FOUTPUT_TYPE>Ptr, plusOne<FINPUT_TYPE><FOUTPUT_TYPE>Ptr, []*<INPUT_TYPE>{&v1, &v2, &v3})\n\n\tif *newList[0] != *expectedList[0] || *newList[1] != *expectedList[1] {\n\t\tt.Errorf(\"FilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr failed. expected=%v, actual=%v\", expectedList, newList)\n\t}\n\n\tif len(FilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr(nil, nil, nil)) > 0 {\n\t\tt.Errorf(\"FilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr failed\")\n\t}\n\n\tif len(FilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr(nil, nil, []*<INPUT_TYPE>{})) > 0 {\n\t\tt.Errorf(\"FilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr failed\")\n\t}\n\treflect.TypeOf(\"Nandeshwar\") // Leaving it here to make use of import reflect\n}\nfunc notOne<FINPUT_TYPE><FOUTPUT_TYPE>Ptr(num *<INPUT_TYPE>) bool {\n\treturn *num != 1\n}\nfunc plusOne<FINPUT_TYPE><FOUTPUT_TYPE>Ptr(num *<INPUT_TYPE>) *<OUTPUT_TYPE> {\n\tc := <OUTPUT_TYPE>(*num + 1)\n\treturn &c\n}\n`\n}", "title": "" }, { "docid": "4d63e54b559e65880509b0a2bf2a0abb", "score": "0.49392292", "text": "func drop(s *stack) error {\n\t_, err := s.pop()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "5f3fdadda190192b2a993354193b3aad", "score": "0.4930252", "text": "func Drop(num, coll interface{}) Expr { return fn2(\"drop\", num, \"collection\", coll) }", "title": "" }, { "docid": "af6917867fda8f60fbd33bb9bec6dfa0", "score": "0.4916559", "text": "func DropUint64(pred Uint64Predicate, s <-chan uint64) <-chan uint64 {\n\tch := make(chan uint64, 1)\n\tgo func() {\n\t\tfor {\n\t\t\tif v, ok := <-s; !ok {\n\t\t\t\tbreak\n\t\t\t} else if !pred(v) {\n\t\t\t\tch <- v\n\t\t\t\tfor i := range s {\n\t\t\t\t\tch <- i\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tclose(ch)\n\t}()\n\treturn ch\n}", "title": "" }, { "docid": "902ddf6e7e7e052376f48e54889f4ed1", "score": "0.48897505", "text": "func makeRemoveItemMutation(goodies Goodies, maxWeight float64) (makeRemoveItemMutation func(fitness wabisabi.Fitness, selection wabisabi.Selection, population wabisabi.Population) (children wabisabi.Population)) {\n\n\tmakeRemoveItemMutation = func(fitness wabisabi.Fitness, selection wabisabi.Selection, population wabisabi.Population) (children wabisabi.Population) {\n\t\tvictim := selection(population)\n\t\tvictimGenome := victim.Genome.(Genotype)\n\t\tk := len(victimGenome)\n\n\t\tnewGuyGenome := make(Genotype, k)\n\t\tcopy(newGuyGenome, victimGenome)\n\n\t\t//randomly choose where to start looking for an item to drop\n\t\tstartingPoint := rand.Intn(k)\n\n\t\t//modular scan over knapsack to find item to drop\n\t\tdone := false\n\t\tfor i := 0; i < k && !done; i++ {\n\t\t\tx := mod(startingPoint+i, k)\n\t\t\tif newGuyGenome[x] {\n\t\t\t\tnewGuyGenome[x] = false\n\t\t\t\tdone = true\n\t\t\t}\n\t\t}\n\t\tnewGuy := wabisabi.Individual{}\n\t\tnewGuyScore, newGuyMeta := fitness(newGuyGenome)\n\t\tnewGuy.Genome = newGuyGenome\n\t\tnewGuy.Score = newGuyScore\n\t\tnewGuy.Meta = newGuyMeta\n\t\tchildren = wabisabi.Population{newGuy}\n\t\treturn\n\t}\n\treturn\n}", "title": "" }, { "docid": "79f1237c86e32497d45d0192a366204a", "score": "0.4884075", "text": "func (s *Stack) Drop() {\n\ts.Lock()\n\tdefer s.Unlock()\n\n\t//\tvar p = s.stack[len(s.stack)-1]\n\ts.stack = s.stack[:len(s.stack)-1]\n\treturn // p\n}", "title": "" }, { "docid": "c9d714f85fdb8c5c744229f951dd24b1", "score": "0.4873441", "text": "func (ps Posts) Drop(n int) Posts {\n\treturn ps[n:]\n}", "title": "" }, { "docid": "908773931fe3cd2ff5ff61775fadafc3", "score": "0.48702356", "text": "func (p *PendingPool) UnsafeRemove(i *metaTx) {\n\tif p.Len() == 0 {\n\t\treturn\n\t}\n\tif p.Len() == 1 && i.bestIndex == 0 {\n\t\tp.worst.Pop()\n\t\tp.best = p.best.UnsafeRemove(i)\n\t\treturn\n\t}\n\t// manually call funcs instead of heap.Pop\n\tp.worst.Swap(i.worstIndex, p.worst.Len()-1)\n\tp.worst.Pop()\n\tp.best.Swap(i.bestIndex, p.best.Len()-1)\n\tp.best = p.best.UnsafeRemove(i)\n}", "title": "" }, { "docid": "9fc4fd0e61b195ffa0bf2b201bc9fbc1", "score": "0.4853525", "text": "func (*Int32) Drop(ints []int32, n ...int32) []int32 {\n\tvar start int32 = 1\n\tlenin := int32(len(ints))\n\n\tif len(n) > 0 && n[0] >= 0 {\n\t\tstart = n[0]\n\t}\n\n\tif start >= lenin {\n\t\treturn []int32{}\n\t}\n\tr := make([]int32, lenin-start)\n\tcopy(r, ints[start:])\n\treturn r\n}", "title": "" }, { "docid": "0dd511fd542fafff9257737a3c802d44", "score": "0.4831308", "text": "func (l *List) Removei(index int) {\n\tcounter := 0\n\tnewItems := make([]interface{}, l.size)\n\n\tfor i, item := range l.items {\n\t\tif i != index {\n\t\t\tnewItems[counter] = item\n\t\t\tcounter++\n\t\t} else {\n\t\t\tl.pointer--\n\t\t}\n\t}\n\n\tl.items = newItems\n}", "title": "" }, { "docid": "c99b18863f5e3931fece911b16fe82cc", "score": "0.48279598", "text": "func runDrop(sourceConfig *pgconn.Config, replicationSlot string) error {\n\terr := utils.PgDropReplicationSlot(context.Background(), sourceConfig, replicationSlot)\n\n\tif err != nil {\n\t\tlog.Errorf(\"Unable to drop replication slot '%s'\", replicationSlot)\n\t\treturn err\n\t}\n\n\tfmt.Printf(\"Dropped replication slot '%s'\\n\", replicationSlot)\n\treturn nil\n}", "title": "" }, { "docid": "3e60b7eafcfeead55046084cfd72d02f", "score": "0.48228142", "text": "func (l *List) Del(ver uint64, meth Find) *Item {\n\n\tl.lock.Lock()\n\tdefer l.lock.Unlock()\n\n\ti := l.find(ver, meth)\n\n\tif i != nil {\n\n\t\tif i.prev != nil && i.next != nil {\n\t\t\ti.prev.next = i.next\n\t\t\ti.next.prev = i.prev\n\t\t\ti.prev = nil\n\t\t\ti.next = nil\n\t\t} else if i.prev != nil {\n\t\t\ti.prev.next = nil\n\t\t\tl.max = i.prev\n\t\t\ti.prev = nil\n\t\t} else if i.next != nil {\n\t\t\ti.next.prev = nil\n\t\t\tl.min = i.next\n\t\t\ti.next = nil\n\t\t} else {\n\t\t\tl.min = nil\n\t\t\tl.max = nil\n\t\t}\n\n\t\ti.list = nil\n\n\t\tl.size--\n\n\t}\n\n\treturn i\n\n}", "title": "" }, { "docid": "b9567f32252093649ca0df6114c4a920", "score": "0.47984263", "text": "func (p *SubPool) UnsafeRemove(i *metaTx) {\n\tif p.Len() == 0 {\n\t\treturn\n\t}\n\tif p.Len() == 1 && i.bestIndex == 0 {\n\t\tp.worst.Pop()\n\t\tp.best.Pop()\n\t\treturn\n\t}\n\t// manually call funcs instead of heap.Pop\n\tp.worst.Swap(i.worstIndex, p.worst.Len()-1)\n\tp.worst.Pop()\n\tp.best.Swap(i.bestIndex, p.best.Len()-1)\n\tp.best.Pop()\n}", "title": "" }, { "docid": "022e6ed74d75a90a518d8679419858f6", "score": "0.47975639", "text": "func TestRemoveTwoLast(t *testing.T) {\n\tl := New()\n\tn1 := &Node{Value: \"test1\"}\n\tn2 := &Node{Value: \"test2\"}\n\n\tl.Append(n1)\n\tl.Append(n2)\n\tl.Remove(n2)\n\n\tif l.front.next != nil {\n\t\tt.Error(\"Expected nil, got \", l.front.next)\n\t}\n}", "title": "" }, { "docid": "e7f03b4f4f2167e974c276643c84a70d", "score": "0.47964945", "text": "func RemoveItem(pkg *packages.Package, pkglist []*packages.Package) []*packages.Package {\n\tfor x, val := range pkglist {\n\t\tif pkg == val {\n\t\t\tif util.Config.Debug {\n\t\t\t\tfmt.Printf(\"\\\"%s\\\" with errors:\\n\", pkg.Name)\n\t\t\t} else {\n\t\t\t\tfmt.Printf(\"- \\\"%s\\\"\\n\", pkg.PkgPath)\n\t\t\t}\n\n\t\t\tif util.Config.Debug {\n\t\t\t\tfor _, pkgError := range pkg.Errors {\n\t\t\t\t\tfmt.Printf(\"- %s\\n\", pkgError.Error())\n\t\t\t\t}\n\t\t\t}\n\t\t\tif len(pkglist) < 2 {\n\t\t\t\treturn pkglist[0:0]\n\t\t\t}\n\t\t\tpkglist[x] = pkglist[len(pkglist)-1]\n\t\t\treturn pkglist[0 : len(pkglist)-2]\n\t\t}\n\t}\n\treturn pkglist\n}", "title": "" }, { "docid": "0667631ff3e51033ce3bc8631092f2c2", "score": "0.47713906", "text": "func TestRemoveTwofront(t *testing.T) {\n\tl := New()\n\tn1 := &Node{Value: \"test1\"}\n\tn2 := &Node{Value: \"test2\"}\n\n\tl.Append(n1)\n\tl.Append(n2)\n\tl.Remove(n1)\n\n\tif l.Length() != 1 {\n\t\tt.Error(\"Expected 1, got \", l.Length())\n\t}\n\tif l.front != n2 {\n\t\tt.Error(\"Expected \", n2, \", got \", l.front)\n\t}\n}", "title": "" }, { "docid": "f53911e7a2341514a93858cbc606b64e", "score": "0.47680005", "text": "func TestRemoveOne(t *testing.T) {\n\tl := New()\n\tn1 := &Node{Value: \"test1\"}\n\n\tl.Append(n1)\n\tl.Remove(n1)\n\n\tif l.Length() != 0 {\n\t\tt.Error(\"Expected 0, got \", l.Length())\n\t}\n\tif l.front != nil {\n\t\tt.Error(\"Expected nil, got \", l.front)\n\t}\n}", "title": "" }, { "docid": "3d75fb4bbf598c1f837eba615f1ae182", "score": "0.47577143", "text": "func (beaverImpl *BeaverImpl) Drop(tile stumped.Tile, resource string, amount int64) bool {\n\treturn beaverImpl.RunOnServer(\"drop\", map[string]interface{}{\n\t\t\"tile\": tile,\n\t\t\"resource\": resource,\n\t\t\"amount\": amount,\n\t}).(bool)\n}", "title": "" }, { "docid": "bac5492d36ec2351cf8555eecbf95545", "score": "0.47565717", "text": "func (p_list *List) Remove(p_node *Node) interface{} {\n if p_node.list == p_list {\n // if p_node.list == l, l must have been initialized when e was inserted\n // in l or l == nil (e is a zero Node) and l.remove will crash\n p_list.remove(p_node)\n }\n return p_node.Value\n}", "title": "" }, { "docid": "09dc6aa7baa28202398bb9a483f4e8de", "score": "0.4755042", "text": "func DropInt64(pred Int64Predicate, s <-chan int64) <-chan int64 {\n\tch := make(chan int64, 1)\n\tgo func() {\n\t\tfor {\n\t\t\tif v, ok := <-s; !ok {\n\t\t\t\tbreak\n\t\t\t} else if !pred(v) {\n\t\t\t\tch <- v\n\t\t\t\tfor i := range s {\n\t\t\t\t\tch <- i\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tclose(ch)\n\t}()\n\treturn ch\n}", "title": "" }, { "docid": "b297de5d9b4b5e81f1ff4b2f34c18115", "score": "0.47456437", "text": "func (list *IntList) DropLast(n int) *IntList {\n\tif list == nil || n == 0 {\n\t\treturn list\n\t}\n\n\tlist.s.RLock()\n\tdefer list.s.RUnlock()\n\n\tl := len(list.m)\n\tif n >= l {\n\t\treturn nil\n\t}\n\n\tresult := MakeIntList(0, 0)\n\tresult.m = list.m[:l-n]\n\treturn result\n}", "title": "" }, { "docid": "6434390c12f6578f9e887311f702ecf7", "score": "0.4745458", "text": "func (p_list *List) remove(p_node *Node) *Node {\n p_node.prev.next = p_node.next\n p_node.next.prev = p_node.prev\n p_node.next = nil // avoid memory leaks\n p_node.prev = nil // avoid memory leaks\n p_node.list = nil\n p_list.len--\n return p_node\n}", "title": "" }, { "docid": "c5b31daabe76dacbe484328fc9065b10", "score": "0.47293168", "text": "func (s *SingleLedgerStateReaderTestSuite) TestRemoved() {\n\tcurr1 := createXdrStream(\n\t\tentryAccount(xdr.BucketEntryTypeDeadentry, \"GC3C4AKRBQLHOJ45U4XG35ESVWRDECWO5XLDGYADO6DPR3L7KIDVUMML\", 1),\n\t)\n\n\tsnap1 := createXdrStream(\n\t\tentryAccount(xdr.BucketEntryTypeLiveentry, \"GC3C4AKRBQLHOJ45U4XG35ESVWRDECWO5XLDGYADO6DPR3L7KIDVUMML\", 1),\n\t)\n\n\tnextBucket := s.getNextBucketChannel()\n\n\t// Return curr1 and snap1 stream for the first two bucket...\n\ts.mockArchive.\n\t\tOn(\"GetXdrStreamForHash\", <-nextBucket).\n\t\tReturn(curr1, nil).Once()\n\n\ts.mockArchive.\n\t\tOn(\"GetXdrStreamForHash\", <-nextBucket).\n\t\tReturn(snap1, nil).Once()\n\n\t// ...and empty streams for the rest of the buckets.\n\tfor hash := range nextBucket {\n\t\ts.mockArchive.\n\t\t\tOn(\"GetXdrStreamForHash\", hash).\n\t\t\tReturn(createXdrStream(), nil).Once()\n\t}\n\n\t_, err := s.reader.Read()\n\ts.Require().Equal(err, io.EOF)\n}", "title": "" }, { "docid": "78a080ee9ace6ebcdce3007dc5b77797", "score": "0.47183788", "text": "func FilterMapIONumberStrPtrTest() string {\n\treturn `\nfunc TestFilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr(t *testing.T) {\n\t// Test : someLogic\n\tvar ov10 <OUTPUT_TYPE> = \"10\"\n\tvar iv1 <INPUT_TYPE> = 1\n\tvar iv10 <INPUT_TYPE> = 10\n\texpectedList := []*<OUTPUT_TYPE>{&ov10}\n\tnewList := FilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr(notOne<FINPUT_TYPE><FOUTPUT_TYPE>NumPtr, someLogic<FINPUT_TYPE><FOUTPUT_TYPE>NumPtr, []*<INPUT_TYPE>{&iv1, &iv10})\n\n\tif *newList[0] != *expectedList[0] {\n\t\tt.Errorf(\"FilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr failed. expected=%v, actual=%v\", expectedList, newList)\n\t}\n\n\tif len(FilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr(nil, nil, nil)) > 0 {\n\t\tt.Errorf(\"FilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr failed\")\n\t}\n\n\tif len(FilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr(nil, nil, []*<INPUT_TYPE>{})) > 0 {\n\t\tt.Errorf(\"FilterMap<FINPUT_TYPE><FOUTPUT_TYPE> failed\")\n\t}\n\treflect.TypeOf(\"Nandeshwar\") // Leaving it here to make use of import reflect\n}\nfunc notOne<FINPUT_TYPE><FOUTPUT_TYPE>NumPtr(num *<INPUT_TYPE>) bool {\n\treturn *num != 1\n}\n\nfunc someLogic<FINPUT_TYPE><FOUTPUT_TYPE>NumPtr(num *<INPUT_TYPE>) *<OUTPUT_TYPE> {\n\tvar r <OUTPUT_TYPE> = <OUTPUT_TYPE>(0)\n\tif *num == 10 {\n\t\tr = \"10\"\n\t\treturn &r\n\t}\n\treturn &r\n}\n`\n}", "title": "" }, { "docid": "bd864908dded3a857857c55ea0c0dac8", "score": "0.4718011", "text": "func(list *List) Delete(item *Item) {\n if list.length == 0 {\n\t\treturn\n\t}\n if list.head == item {\n\t\tlist.head = item.next\n\t\tlist.head.prev = nil\n\t\tlist.length--\n\t\treturn\n\t}\n\tif list.tail == item {\n\t\tlist.tail = item.prev\n\t\tlist.tail.next = nil\n\t\tlist.length--\n\t\treturn\n\t}\n\tprevItem := item.prev\n\tnextItem := item.next\n\tprevItem.next = item.next\n\tnextItem.prev = item.prev\n\tlist.length--\n}", "title": "" }, { "docid": "01695ebcf30fb50975ad604a56aeb2d0", "score": "0.46891364", "text": "func (gen *MoveGen) remove() *MoveGen {\n\tcopy(gen.list[gen.head-1:], gen.list[gen.head:])\n\tgen.head--\n\tgen.tail--\n\treturn gen\n}", "title": "" }, { "docid": "e8c9a52006dca1aedb81bd76b0bd51dc", "score": "0.4689047", "text": "func FilterMapIONumberBoolPtrTest() string {\n\treturn `\nfunc TestFilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr(t *testing.T) {\n\t// Test : someLogic\n\tvar vto <OUTPUT_TYPE> = true\n\tvar vfo <OUTPUT_TYPE> = false\n\n\tvar vi1 <INPUT_TYPE> = 1\n\tvar vi10 <INPUT_TYPE> = 10\n\tvar vi0 <INPUT_TYPE> = 0\n\n\texpectedList := []*<OUTPUT_TYPE>{&vto, &vfo}\n\tnewList := FilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr(notOne<FINPUT_TYPE><FOUTPUT_TYPE>Ptr, someLogic<FINPUT_TYPE><FOUTPUT_TYPE>Ptr, []*<INPUT_TYPE>{&vi1, &vi10, &vi0})\n\n\tif *newList[0] != *expectedList[0] || *newList[1] != *expectedList[1] {\n\t\tt.Errorf(\"FilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr failed. expected=%v, actual=%v\", expectedList, newList)\n\t}\n\n\tif len(FilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr(nil, nil, nil)) > 0 {\n\t\tt.Errorf(\"FilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr failed\")\n\t}\n\n\tif len(FilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr(nil, nil, []*<INPUT_TYPE>{})) > 0 {\n\t\tt.Errorf(\"FilterMap<FINPUT_TYPE><FOUTPUT_TYPE>Ptr failed\")\n\t}\n\treflect.TypeOf(\"Nandeshwar\") // Leaving it here to make use of import reflect\n}\nfunc notOne<FINPUT_TYPE><FOUTPUT_TYPE>Ptr(num *<INPUT_TYPE>) bool {\n\treturn *num != 1\n}\n\nfunc someLogic<FINPUT_TYPE><FOUTPUT_TYPE>Ptr(num *<INPUT_TYPE>) *bool {\n\tr := *num > 0\n\treturn &r\n}\n`\n}", "title": "" }, { "docid": "56663928c73258155877c28799108430", "score": "0.46732858", "text": "func DistinctPtr2() string {\n\treturn `\nfunc Distinct<FTYPE>Ptr(list []*<TYPE>) []*<TYPE> {\n\tif len(list) == 0 {\n\t\treturn []*<TYPE>{}\n\t}\n\n\tnewList := []*<TYPE>{list[0]}\n\n\tfor i := 1; i < len(list); i++ {\n\t\tfound := false\n\t\tfor j := 0; j < len(newList); j++ {\n\t\t\tif reflect.DeepEqual(*list[i], *newList[j]) {\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\tnewList = append(newList, list[i])\n\t\t}\n\t}\n\treturn newList\n}\n`\n}", "title": "" }, { "docid": "40f79ac1e8e43934c8e444c6c51d2f87", "score": "0.46717772", "text": "func TestBLPop(t *testing.T) {\n\trc.Del(\"list1\", \"list2\")\n\tdefer rc.Del(\"list1\", \"list2\")\n\trc.RPush(\"list1\", \"a\", \"b\", \"c\")\n\tif k, v, err := rc.BLPop(0, \"list1\", \"list2\"); err != nil {\n\t\tt.Fatal(err)\n\t} else if k != \"list1\" || v != \"a\" {\n\t\tt.Fatalf(errUnexpected, \"k=\"+k+\" v=\"+v)\n\t}\n}", "title": "" }, { "docid": "a5de00d5fa14b97dca30c76f162d0f84", "score": "0.46673602", "text": "func (m *MockEdge) Drop() interfaces.QueryBuilder {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Drop\")\n\tret0, _ := ret[0].(interfaces.QueryBuilder)\n\treturn ret0\n}", "title": "" }, { "docid": "2ac735e113c308b0c885c9df63aa86bf", "score": "0.4663768", "text": "func NewDrops(session *config.Session) error {\n\n\tlog.Info().Msg(util.Shark + \" .\")\n\tlog.Info().Msg(util.Shark + \" ..\")\n\tlog.Info().Msg(util.Shark + \" ... trade --drop\")\n\tlog.Info().Msg(util.Shark + \" ..\")\n\n\tfor _, productID := range session.UsdSelectionProductIDs() {\n\n\t\tlog.Info().Msg(util.Shark + \" ... \" + productID)\n\n\t\torders, err := cbp.GetOrders(productID)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfor _, order := range *orders {\n\t\t\tif err := cbp.CancelOrder(order.ID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tlog.Info().Msg(util.Shark + \" ... dropped\")\n\t\t}\n\t\tlog.Info().Msg(util.Shark + \" ..\")\n\t}\n\tlog.Info().Msg(util.Shark + \" .\")\n\n\treturn nil\n\n}", "title": "" }, { "docid": "471dc05370bb51e594e5e48286bedeb1", "score": "0.46598524", "text": "func TestOneToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "471dc05370bb51e594e5e48286bedeb1", "score": "0.46598524", "text": "func TestOneToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "471dc05370bb51e594e5e48286bedeb1", "score": "0.46598524", "text": "func TestOneToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "471dc05370bb51e594e5e48286bedeb1", "score": "0.46598524", "text": "func TestOneToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "471dc05370bb51e594e5e48286bedeb1", "score": "0.46598524", "text": "func TestOneToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "471dc05370bb51e594e5e48286bedeb1", "score": "0.46598524", "text": "func TestOneToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "471dc05370bb51e594e5e48286bedeb1", "score": "0.46598524", "text": "func TestOneToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "471dc05370bb51e594e5e48286bedeb1", "score": "0.46598524", "text": "func TestOneToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "471dc05370bb51e594e5e48286bedeb1", "score": "0.46598524", "text": "func TestOneToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "471dc05370bb51e594e5e48286bedeb1", "score": "0.46598524", "text": "func TestOneToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "471dc05370bb51e594e5e48286bedeb1", "score": "0.46598524", "text": "func TestOneToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "471dc05370bb51e594e5e48286bedeb1", "score": "0.46598524", "text": "func TestOneToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "471dc05370bb51e594e5e48286bedeb1", "score": "0.46598524", "text": "func TestOneToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "471dc05370bb51e594e5e48286bedeb1", "score": "0.46598524", "text": "func TestOneToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "471dc05370bb51e594e5e48286bedeb1", "score": "0.46598524", "text": "func TestOneToOneRemove(t *testing.T) {}", "title": "" }, { "docid": "04ea4a7ed76fb2985f45d48cd818df64", "score": "0.46532965", "text": "func FzDropDisplayList(ctx *FzContext, list *FzDisplayList) {\n\tcctx, _ := (*C.fz_context)(unsafe.Pointer(ctx)), cgoAllocsUnknown\n\tclist, _ := (*C.fz_display_list)(unsafe.Pointer(list)), cgoAllocsUnknown\n\tC.fz_drop_display_list(cctx, clist)\n}", "title": "" }, { "docid": "eb26a3eb1f0d82ef41212980807d2578", "score": "0.46475244", "text": "func MethodChainStructForRemovePtr() string {\n\treturn `\n// RemovePtr - removes the items from the given list based on supplied function and returns new list\nfunc (slice <NEWTYPE>SlicePtr) RemovePtr(functors ...<NEWTYPE>FunctorForFilterPtr) <NEWTYPE>SlicePtr {\n\n\ttmpSlice := slice\n\t\n\tfor _, f := range functors {\n\t\tif f == nil {\n\t\t\tcontinue\n\t\t}\n\t\ttmpSlice = Remove<CONDITIONAL_TYPE>Ptr(f, tmpSlice)\n\t}\n\n\treturn tmpSlice\n}\n`\n}", "title": "" }, { "docid": "307cbaa5437b40ad0c14741e339c5cbe", "score": "0.46463966", "text": "func (p *earlyTermNoTraversalPoll) Drop(vdr ids.ShortID) {\n\tp.polled.Remove(vdr)\n}", "title": "" }, { "docid": "896f35cd616c6379acf55b94afd907bb", "score": "0.46360433", "text": "func dropItemRandomly(player *Player, chance int) {\n\n\tvar randInt = rand.Intn(101)\n\n\tvar openSlot = getNextOpenSlotInInventory(player.inventory)\n\n\tif randInt <= chance {\n\t\tvar itemType = rand.Intn(3)\n\t\tif itemType == 0 {\n\t\t\t//hull\n\t\t\tvar randItem = rand.Intn(NUMBER_OF_HULL_ITEMS) + 1\n\t\t\tvar randItemID = \"H\" + strconv.Itoa(randItem)\n\t\t\taddItemToInventory(&player.inventory, openSlot, randItemID)\n\t\t} else if itemType == 1 {\n\t\t\t//wings\n\t\t\tvar randItem = rand.Intn(NUMBER_OF_WING_ITEMS) + 1\n\t\t\tvar randItemID = \"W\" + strconv.Itoa(randItem)\n\t\t\taddItemToInventory(&player.inventory, openSlot, randItemID)\n\t\t} else if itemType == 2 {\n\t\t\t//lasers\n\t\t}\n\n\t}\n}", "title": "" }, { "docid": "92f3e5ff0fd2bf87d82e6d94a3add353", "score": "0.46340793", "text": "func TestRingWriteDropBehaviour(t *testing.T) {\n\tvar (\n\t\ttestValueGo = []byte(\"Hello World\")\n\t\ttestValueDrop = []byte(\"Dropping\")\n\t\tbuf = make([]byte, 128)\n\t\tr = NewRingBuffer(1)\n\t)\n\n\tfor i := 0; i < 512; i++ {\n\t\tn, err := r.Write(testValueDrop)\n\t\tif err != nil {\n\t\t\tt.Fatal(\"Failed writing (drop):\", err)\n\t\t} else if n != len(testValueDrop) {\n\t\t\tt.Fatal(\"Write (drop) was too short\")\n\t\t}\n\n\t\tn, err = r.Write(testValueGo)\n\t\tif err != nil {\n\t\t\tt.Fatal(\"Failed writing (go):\", err)\n\t\t} else if n != len(testValueGo) {\n\t\t\tt.Fatal(\"Write (go) was too short\")\n\t\t}\n\n\t\tn, err = r.Read(buf)\n\t\tif err != nil {\n\t\t\tt.Fatal(\"Failed reading:\", err)\n\t\t}\n\n\t\tif string(buf[:n]) != string(testValueGo) {\n\t\t\tt.Fatal(\"Received different value than expected\")\n\t\t}\n\t}\n}", "title": "" }, { "docid": "63d59a51be8c36393aa117c33d8d37f8", "score": "0.46271828", "text": "func (slice Lists) Keep(fn func([]int) bool) (out Lists) {\n\tfor _, item := range slice {\n\t\tif fn(item) {\n\t\t\tout = append(out, item)\n\t\t}\n\t}\n\treturn\n}", "title": "" }, { "docid": "59a9ccafa2bbccbfa1982d3357c7444e", "score": "0.46035922", "text": "func (sl *SkipList) RemoveByData(v Interface) interface{} {\n\tx := sl.find(v) // x.Value >= v\n\tif x != nil && !v.Less(x.Value) { // v >= x.Value\n\t\tsl.deleteElement(x, sl.update)\n\t\treturn x.Value\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "99d697b42bc5b28063f57f7f4ac646c3", "score": "0.4602007", "text": "func (a *ofFlowAction) Drop() FlowBuilder {\n\tdropAction := a.builder.Flow.Table.Switch.DropAction()\n\ta.builder.ofFlow.lastAction = dropAction\n\treturn a.builder\n}", "title": "" }, { "docid": "40e380260dbeb5f322efdc93c645b99f", "score": "0.46012533", "text": "func (list List_f64) RemoveByIndex(i int) List_f64 {\n list, list[len(list)-1] = append(list[:i], list[i+1:]...), 0\n return list\n}", "title": "" }, { "docid": "7725e438136b0e6da8961664fb2f77d9", "score": "0.45988622", "text": "func (s *Stack) FakePop() *Node {\n\tif len(s.items) < 1 {\n\t\treturn nil\n\t}\n\ts.lock.Lock()\n\titem := s.items[len(s.items)-1]\n\ts.lock.Unlock()\n\treturn &item\n}", "title": "" }, { "docid": "e33322ad9ece555e0cd0d4dee9943edb", "score": "0.4590807", "text": "func TestMoveUnknownMark() {\n\tvar l1 _List[int]\n\te1 := l1.PushBack(1)\n\n\tvar l2 _List[int]\n\te2 := l2.PushBack(2)\n\n\tl1.MoveAfter(e1, e2)\n\tcheckList(&l1, []interface{}{1})\n\tcheckList(&l2, []interface{}{2})\n\n\tl1.MoveBefore(e1, e2)\n\tcheckList(&l1, []interface{}{1})\n\tcheckList(&l2, []interface{}{2})\n}", "title": "" }, { "docid": "12a72f14a6d5887fb12e6e721801efdc", "score": "0.45880345", "text": "func TestBRPopTimeout2(t *testing.T) {\n\trc.Del(\"list1\", \"list2\")\n\tdefer rc.Del(\"list1\", \"list2\")\n\tgo func() {\n\t\ttime.Sleep(100 * time.Millisecond)\n\t\trc.LPush(\"list1\", \"a\", \"b\", \"c\")\n\t}()\n\tif k, v, err := rc.BRPop(1, \"list1\", \"list2\"); err != nil {\n\t\tt.Fatal(err)\n\t} else if k != \"list1\" || v != \"a\" {\n\t\tt.Fatalf(errUnexpected, \"k=\"+k+\" v=\"+v)\n\t}\n}", "title": "" }, { "docid": "dcdf430581c66fab578b3c3f92d9ee9f", "score": "0.45837185", "text": "func (slice Ints) Discard(fn pred) (out Ints) {\n\tfor _, item := range slice {\n\t\tif !fn(item) {\n\t\t\tout = append(out, item)\n\t\t}\n\t}\n\treturn\n}", "title": "" }, { "docid": "95342e916d47e4fd7278c1a215af5a13", "score": "0.4578156", "text": "func TestToOneRemove(t *testing.T) {\n\tt.Run(\"OrderItemToOrderItemUsingMainOrderItemOrderItems\", testOrderItemToOneRemoveOpOrderItemUsingMainOrderItem)\n}", "title": "" }, { "docid": "3018ab8e81b5e63f2819106064f44b4f", "score": "0.4558639", "text": "func (l *LinkedList) removeDupsRunner() {\n\tcurrent := l.Head\n\tfor current != nil {\n\t\trunner := current\n\t\tfor runner.Next != nil {\n\t\t\tif runner.Next.Data == current.Data {\n\t\t\t\trunner.Next = runner.Next.Next\n\t\t\t} else {\n\t\t\t\trunner = runner.Next\n\t\t\t}\n\t\t}\n\t\tcurrent = current.Next\n\t}\n}", "title": "" }, { "docid": "8ec58e3355b0522b04ffb77222d54542", "score": "0.4558191", "text": "func removePlayerFromList(l *list.List, b *Bomberman) {\n\telement := l.Front()\n\tif element != nil {\n\t\t//log.Println(b)\n\t\t//log.Println(element.Value.(*Bomberman))\n\t\t//log.Println(element.Value.(*Bomberman).UserID == b.UserID)\n\t\tif element.Value.(*Bomberman).UserID == b.UserID {\n\t\t\tl.Remove(element)\n\t\t\treturn\n\t\t}\n\t\tfor element.Next() != nil {\n\t\t\telement = element.Next()\n\t\t\tif element.Value.(*Bomberman).UserID == b.UserID {\n\t\t\t\tl.Remove(element)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tlog.Println(\"Player not found in list\")\n}", "title": "" }, { "docid": "9d0202c2c4c178280920939eab3c48ca", "score": "0.45453033", "text": "func (a *ofFlowAction) Drop() FlowBuilder {\n\ta.builder.Drop()\n\ta.builder.isDropFlow = true\n\treturn a.builder\n}", "title": "" }, { "docid": "50a960a0e88fcdd8a1778613f7d02092", "score": "0.4542893", "text": "func (*CCSUsrMsg_ItemDrop) Descriptor() ([]byte, []int) {\n\treturn file_csgo_cstrike15_usermessages_proto_rawDescGZIP(), []int{55}\n}", "title": "" }, { "docid": "d24736cfa92b542aa7edba4ef52861ca", "score": "0.45407337", "text": "func TestRemoveLinkedListElements(t *testing.T) {\n\tl := &ListNode{Val: 1, Next: &ListNode{Val: 2, Next: &ListNode{Val: 6, Next: &ListNode{Val: 4, Next: &ListNode{Val: 6}}}}}\n\ts, _ := json.Marshal(removeElements(l, 6))\n\tfmt.Printf(string(s))\n}", "title": "" }, { "docid": "b00dfce7535f22d5fde42a1411454be5", "score": "0.45336744", "text": "func (s) TestDropByCategory(t *testing.T) {\n\tctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)\n\tdefer cancel()\n\n\tdefer xdsclient.ClearCounterForTesting(testClusterName, testServiceName)\n\txdsC := fakeclient.NewClient()\n\n\tbuilder := balancer.Get(Name)\n\tcc := testutils.NewTestClientConn(t)\n\tb := builder.Build(cc, balancer.BuildOptions{})\n\tdefer b.Close()\n\n\tconst (\n\t\tdropReason = \"test-dropping-category\"\n\t\tdropNumerator = 1\n\t\tdropDenominator = 2\n\t)\n\tif err := b.UpdateClientConnState(balancer.ClientConnState{\n\t\tResolverState: xdsclient.SetClient(resolver.State{Addresses: testBackendAddrs}, xdsC),\n\t\tBalancerConfig: &LBConfig{\n\t\t\tCluster: testClusterName,\n\t\t\tEDSServiceName: testServiceName,\n\t\t\tLoadReportingServer: testLRSServerConfig,\n\t\t\tDropCategories: []DropConfig{{\n\t\t\t\tCategory: dropReason,\n\t\t\t\tRequestsPerMillion: million * dropNumerator / dropDenominator,\n\t\t\t}},\n\t\t\tChildPolicy: &internalserviceconfig.BalancerConfig{\n\t\t\t\tName: roundrobin.Name,\n\t\t\t},\n\t\t},\n\t}); err != nil {\n\t\tt.Fatalf(\"unexpected error from UpdateClientConnState: %v\", err)\n\t}\n\n\tgot, err := xdsC.WaitForReportLoad(ctx)\n\tif err != nil {\n\t\tt.Fatalf(\"xdsClient.ReportLoad failed with error: %v\", err)\n\t}\n\tif got.Server != testLRSServerConfig {\n\t\tt.Fatalf(\"xdsClient.ReportLoad called with {%q}: want {%q}\", got.Server, testLRSServerConfig)\n\t}\n\n\tsc1 := <-cc.NewSubConnCh\n\tsc1.UpdateState(balancer.SubConnState{ConnectivityState: connectivity.Connecting})\n\t// This should get the connecting picker.\n\tif err := cc.WaitForPickerWithErr(ctx, balancer.ErrNoSubConnAvailable); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tsc1.UpdateState(balancer.SubConnState{ConnectivityState: connectivity.Ready})\n\t// Test pick with one backend.\n\n\tconst rpcCount = 20\n\tif err := cc.WaitForPicker(ctx, func(p balancer.Picker) error {\n\t\tfor i := 0; i < rpcCount; i++ {\n\t\t\tgotSCSt, err := p.Pick(balancer.PickInfo{})\n\t\t\t// Even RPCs are dropped.\n\t\t\tif i%2 == 0 {\n\t\t\t\tif err == nil || !strings.Contains(err.Error(), \"dropped\") {\n\t\t\t\t\treturn fmt.Errorf(\"pick.Pick, got %v, %v, want error RPC dropped\", gotSCSt, err)\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif err != nil || gotSCSt.SubConn != sc1 {\n\t\t\t\treturn fmt.Errorf(\"picker.Pick, got %v, %v, want SubConn=%v\", gotSCSt, err, sc1)\n\t\t\t}\n\t\t\tif gotSCSt.Done != nil {\n\t\t\t\tgotSCSt.Done(balancer.DoneInfo{})\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\t// Dump load data from the store and compare with expected counts.\n\tloadStore := xdsC.LoadStore()\n\tif loadStore == nil {\n\t\tt.Fatal(\"loadStore is nil in xdsClient\")\n\t}\n\tconst dropCount = rpcCount * dropNumerator / dropDenominator\n\twantStatsData0 := []*load.Data{{\n\t\tCluster: testClusterName,\n\t\tService: testServiceName,\n\t\tTotalDrops: dropCount,\n\t\tDrops: map[string]uint64{dropReason: dropCount},\n\t\tLocalityStats: map[string]load.LocalityData{\n\t\t\tassertString(xdsinternal.LocalityID{}.ToString): {RequestStats: load.RequestData{Succeeded: rpcCount - dropCount}},\n\t\t},\n\t}}\n\n\tgotStatsData0 := loadStore.Stats([]string{testClusterName})\n\tif diff := cmp.Diff(gotStatsData0, wantStatsData0, cmpOpts); diff != \"\" {\n\t\tt.Fatalf(\"got unexpected reports, diff (-got, +want): %v\", diff)\n\t}\n\n\t// Send an update with new drop configs.\n\tconst (\n\t\tdropReason2 = \"test-dropping-category-2\"\n\t\tdropNumerator2 = 1\n\t\tdropDenominator2 = 4\n\t)\n\tif err := b.UpdateClientConnState(balancer.ClientConnState{\n\t\tResolverState: xdsclient.SetClient(resolver.State{Addresses: testBackendAddrs}, xdsC),\n\t\tBalancerConfig: &LBConfig{\n\t\t\tCluster: testClusterName,\n\t\t\tEDSServiceName: testServiceName,\n\t\t\tLoadReportingServer: testLRSServerConfig,\n\t\t\tDropCategories: []DropConfig{{\n\t\t\t\tCategory: dropReason2,\n\t\t\t\tRequestsPerMillion: million * dropNumerator2 / dropDenominator2,\n\t\t\t}},\n\t\t\tChildPolicy: &internalserviceconfig.BalancerConfig{\n\t\t\t\tName: roundrobin.Name,\n\t\t\t},\n\t\t},\n\t}); err != nil {\n\t\tt.Fatalf(\"unexpected error from UpdateClientConnState: %v\", err)\n\t}\n\n\tif err := cc.WaitForPicker(ctx, func(p balancer.Picker) error {\n\t\tfor i := 0; i < rpcCount; i++ {\n\t\t\tgotSCSt, err := p.Pick(balancer.PickInfo{})\n\t\t\t// Even RPCs are dropped.\n\t\t\tif i%4 == 0 {\n\t\t\t\tif err == nil || !strings.Contains(err.Error(), \"dropped\") {\n\t\t\t\t\treturn fmt.Errorf(\"pick.Pick, got %v, %v, want error RPC dropped\", gotSCSt, err)\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif err != nil || gotSCSt.SubConn != sc1 {\n\t\t\t\treturn fmt.Errorf(\"picker.Pick, got %v, %v, want SubConn=%v\", gotSCSt, err, sc1)\n\t\t\t}\n\t\t\tif gotSCSt.Done != nil {\n\t\t\t\tgotSCSt.Done(balancer.DoneInfo{})\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tconst dropCount2 = rpcCount * dropNumerator2 / dropDenominator2\n\twantStatsData1 := []*load.Data{{\n\t\tCluster: testClusterName,\n\t\tService: testServiceName,\n\t\tTotalDrops: dropCount2,\n\t\tDrops: map[string]uint64{dropReason2: dropCount2},\n\t\tLocalityStats: map[string]load.LocalityData{\n\t\t\tassertString(xdsinternal.LocalityID{}.ToString): {RequestStats: load.RequestData{Succeeded: rpcCount - dropCount2}},\n\t\t},\n\t}}\n\n\tgotStatsData1 := loadStore.Stats([]string{testClusterName})\n\tif diff := cmp.Diff(gotStatsData1, wantStatsData1, cmpOpts); diff != \"\" {\n\t\tt.Fatalf(\"got unexpected reports, diff (-got, +want): %v\", diff)\n\t}\n}", "title": "" }, { "docid": "42cd6b0c606d6318a5d902908b2fc9a4", "score": "0.4529549", "text": "func (i *Inventory) DeathDrops(keep int) []*GroundItem {\n\t// clone so we don't modify the players inventory during the sorting process\n\tvar pile []*GroundItem\n\tif keep <= 0 {\n\t\ti.Lock.RLock()\n\t\tfor _, item := range i.List {\n\t\t\tpile = append(pile, NewGroundItem(item.ID, item.Amount, i.Owner.X(), i.Owner.Y()))\n\t\t}\n\t\ti.Lock.RUnlock()\n\t} else {\n\t\tdeathItems := i.Clone()\n\t\tsort.Sort(itemSorter(deathItems.List))\n\t\tif len(deathItems.List) < keep {\n\t\t\tkeep = len(deathItems.List)\n\t\t}\n\t\tfor idx := keep; idx > 0; idx-- {\n\t\t\tif deathItems.List[idx-1].Stackable() {\n\t\t\t\tkeep--\n\t\t\t}\n\t\t}\n\t\tfor _, item := range deathItems.List[keep:] {\n\t\t\tpile = append(pile, NewGroundItem(item.ID, item.Amount, i.Owner.X(), i.Owner.Y()))\n\t\t}\n\t}\n\treturn pile\n}", "title": "" }, { "docid": "09f9a43884309585c9f1102ba36befe6", "score": "0.4527226", "text": "func DropUint(pred UintPredicate, s <-chan uint) <-chan uint {\n\tch := make(chan uint, 1)\n\tgo func() {\n\t\tfor {\n\t\t\tif v, ok := <-s; !ok {\n\t\t\t\tbreak\n\t\t\t} else if !pred(v) {\n\t\t\t\tch <- v\n\t\t\t\tfor i := range s {\n\t\t\t\t\tch <- i\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tclose(ch)\n\t}()\n\treturn ch\n}", "title": "" }, { "docid": "ffbb113494a13c47bad8ffab71731de6", "score": "0.45268965", "text": "func (l *list) Shift() (interface{}, bool) {\n\tr := l.removeNode(l.first)\n\n\treturn r, r != nil\n}", "title": "" }, { "docid": "b9dcba5de2112fe181ec95481c37c921", "score": "0.45202592", "text": "func DropUint32(pred Uint32Predicate, s <-chan uint32) <-chan uint32 {\n\tch := make(chan uint32, 1)\n\tgo func() {\n\t\tfor {\n\t\t\tif v, ok := <-s; !ok {\n\t\t\t\tbreak\n\t\t\t} else if !pred(v) {\n\t\t\t\tch <- v\n\t\t\t\tfor i := range s {\n\t\t\t\t\tch <- i\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tclose(ch)\n\t}()\n\treturn ch\n}", "title": "" }, { "docid": "d3cf1fc91380e92ad9639536067c6076", "score": "0.4510594", "text": "func (m *MockVertex) Drop() interfaces.QueryBuilder {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Drop\")\n\tret0, _ := ret[0].(interfaces.QueryBuilder)\n\treturn ret0\n}", "title": "" }, { "docid": "3f6c4a227db1dd301dbe2fe2befb096d", "score": "0.45006922", "text": "func (b *Belt) Drop(s *stats.Stats) {\n\ts.Wc -= (2 + (b.Attr() << 1))\n}", "title": "" }, { "docid": "cb081449c79727b0990d441d094e019f", "score": "0.4500395", "text": "func DropFloat64(pred Float64Predicate, s <-chan float64) <-chan float64 {\n\tch := make(chan float64, 1)\n\tgo func() {\n\t\tfor {\n\t\t\tif v, ok := <-s; !ok {\n\t\t\t\tbreak\n\t\t\t} else if !pred(v) {\n\t\t\t\tch <- v\n\t\t\t\tfor i := range s {\n\t\t\t\t\tch <- i\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tclose(ch)\n\t}()\n\treturn ch\n}", "title": "" }, { "docid": "cde7617313121f5ea835869220f3fec8", "score": "0.45000386", "text": "func (list Ints) Discard(pred func(int) bool) (out Ints) {\n\tfor _, v := range list {\n\t\tif !pred(v) {\n\t\t\tout = append(out, v)\n\t\t}\n\t}\n\treturn\n}", "title": "" } ]
e6a8dd8d98e3afcb38c471a61bbc870c
Applications is a free data retrieval call binding the contract method 0xdfefadff. Solidity: function applications(uint256 ) view returns(address)
[ { "docid": "6452fd2897b6bf7b0f81ed8ba803b936", "score": "0.7691369", "text": "func (_TokenStaking *TokenStakingCallerSession) Applications(arg0 *big.Int) (common.Address, error) {\n\treturn _TokenStaking.Contract.Applications(&_TokenStaking.CallOpts, arg0)\n}", "title": "" } ]
[ { "docid": "13ba43c4e5c00d430d6f4a7465f7ca32", "score": "0.817542", "text": "func (_TokenStaking *TokenStakingCaller) Applications(opts *bind.CallOpts, arg0 *big.Int) (common.Address, error) {\n\tvar out []interface{}\n\terr := _TokenStaking.contract.Call(opts, &out, \"applications\", arg0)\n\n\tif err != nil {\n\t\treturn *new(common.Address), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)\n\n\treturn out0, err\n\n}", "title": "" }, { "docid": "872ef5e4b0d3f744f62644a3baebbf0b", "score": "0.77040446", "text": "func (_TokenStaking *TokenStakingSession) Applications(arg0 *big.Int) (common.Address, error) {\n\treturn _TokenStaking.Contract.Applications(&_TokenStaking.CallOpts, arg0)\n}", "title": "" }, { "docid": "fb1fb20c18fcb157889a8c7b8fb3da55", "score": "0.7037712", "text": "func (m *GraphBaseServiceClient) Applications()(*ie1b2fd35e4b1f7cbc7bd808e462c966c4ec16a274923b50216bdd8a2ae0a3129.ApplicationsRequestBuilder) {\n return ie1b2fd35e4b1f7cbc7bd808e462c966c4ec16a274923b50216bdd8a2ae0a3129.NewApplicationsRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)\n}", "title": "" }, { "docid": "3c4d71cc2eab206f1d66ec4579d539b2", "score": "0.6812107", "text": "func (s *ApplicationsService) Applications(applicationsQueryParams *ApplicationsQueryParams) (*ApplicationsResponse, *resty.Response, error) {\n\n\tpath := \"/dna/intent/api/v1/application-health\"\n\n\tqueryString, _ := query.Values(applicationsQueryParams)\n\n\tresponse, err := RestyClient.R().\n\t\tSetQueryString(queryString.Encode()).\n\t\tSetResult(&ApplicationsResponse{}).\n\t\tSetError(&Error{}).\n\t\tGet(path)\n\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tif response.IsError() {\n\t\treturn nil, response, fmt.Errorf(\"Error with operation applications\")\n\t}\n\n\tresult := response.Result().(*ApplicationsResponse)\n\treturn result, response, err\n}", "title": "" }, { "docid": "5898309201bb565e6bffd83a4bdcfbbf", "score": "0.6745999", "text": "func (_m *Resolver) ApplicationsQuery(ctx context.Context, namespace *string, first *int, offset *int) ([]*gqlschema.Application, error) {\n\tvar r0 []*gqlschema.Application\n\tvar r1 error\n\tr1 = _m.err\n\n\treturn r0, r1\n}", "title": "" }, { "docid": "36de71d90c01f0bfb4368a55ce56f050", "score": "0.65277493", "text": "func (a *ApplicationAPI) List(ctx context.Context, req *pb.ListApplicationRequest) (*pb.ListApplicationResponse, error) {\n\tif err := a.validator.Validate(ctx,\n\t\tauth.ValidateApplicationsAccess(auth.List, req.OrganizationID),\n\t); err != nil {\n\t\treturn nil, grpc.Errorf(codes.Unauthenticated, \"authentication failed: %s\", err)\n\t}\n\n\tisAdmin, err := a.validator.GetIsAdmin(ctx)\n\tif err != nil {\n\t\treturn nil, errToRPCError(err)\n\t}\n\n\tusername, err := a.validator.GetUsername(ctx)\n\tif err != nil {\n\t\treturn nil, errToRPCError(err)\n\t}\n\n\tvar count int\n\tvar apps []storage.ApplicationListItem\n\n\tif req.OrganizationID == 0 {\n\t\tif isAdmin {\n\t\t\tapps, err = storage.GetApplications(config.C.PostgreSQL.DB, int(req.Limit), int(req.Offset), req.Search)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errToRPCError(err)\n\t\t\t}\n\t\t\tcount, err = storage.GetApplicationCount(config.C.PostgreSQL.DB, req.Search)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errToRPCError(err)\n\t\t\t}\n\t\t} else {\n\t\t\tapps, err = storage.GetApplicationsForUser(config.C.PostgreSQL.DB, username, 0, int(req.Limit), int(req.Offset), req.Search)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errToRPCError(err)\n\t\t\t}\n\t\t\tcount, err = storage.GetApplicationCountForUser(config.C.PostgreSQL.DB, username, 0, req.Search)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errToRPCError(err)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif isAdmin {\n\t\t\tapps, err = storage.GetApplicationsForOrganizationID(config.C.PostgreSQL.DB, req.OrganizationID, int(req.Limit), int(req.Offset), req.Search)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errToRPCError(err)\n\t\t\t}\n\t\t\tcount, err = storage.GetApplicationCountForOrganizationID(config.C.PostgreSQL.DB, req.OrganizationID, req.Search)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errToRPCError(err)\n\t\t\t}\n\t\t} else {\n\t\t\tapps, err = storage.GetApplicationsForUser(config.C.PostgreSQL.DB, username, req.OrganizationID, int(req.Limit), int(req.Offset), req.Search)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errToRPCError(err)\n\t\t\t}\n\t\t\tcount, err = storage.GetApplicationCountForUser(config.C.PostgreSQL.DB, username, req.OrganizationID, req.Search)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errToRPCError(err)\n\t\t\t}\n\t\t}\n\t}\n\n\tresp := pb.ListApplicationResponse{\n\t\tTotalCount: int64(count),\n\t}\n\tfor _, app := range apps {\n\t\titem := pb.ApplicationListItem{\n\t\t\tId: app.ID,\n\t\t\tName: app.Name,\n\t\t\tDescription: app.Description,\n\t\t\tOrganizationID: app.OrganizationID,\n\t\t\tServiceProfileID: app.ServiceProfileID,\n\t\t\tServiceProfileName: app.ServiceProfileName,\n\t\t}\n\n\t\tresp.Result = append(resp.Result, &item)\n\t}\n\n\treturn &resp, nil\n}", "title": "" }, { "docid": "1381feea12dc0839d7e82730b13dc882", "score": "0.6514196", "text": "func (c *CongressClient) Applications() ([]Application, error) {\n\ttype appList struct {\n\t\tApps []Application `json:\"applications\"`\n\t}\n\n\tlist, err := c.genericGet(\"/applications\", &appList{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn list.(*appList).Apps, nil\n}", "title": "" }, { "docid": "e1d63bc2f694fe64da411fd9fe14ac7f", "score": "0.6475006", "text": "func GetAllApplications(limit string) *ApplicationList {\n\tvar s ApplicationList\n\n\tgetAPIAddress()\n\turl := \"https://\" + IPAddressOfAPIServer + \"/api/applications?limit=\" + limit\n\t//url := \"https://\" + anotherIPAddress + \"/api/applications?limit=\" + limit\n\n\tresponse, err := MakeAPIRequest(url, \"GET\")\n\tif err != nil {\n\t\tlogs.Error(\"Error while making API request to GetAllApplications: %v\", err.Error())\n\t\treturn nil\n\t}\n\tdefer response.Body.Close()\n\n\tif response.StatusCode == 200 {\n\t\tbodyByte, _ := ioutil.ReadAll(response.Body)\n\t\tjson.Unmarshal(bodyByte, &s)\n\t}else {\n\t\tlogs.Warn(\"GetAllApplications response is NOT OK: %v\", response.StatusCode)\n\t\treturn nil\n\t}\n\n\treturn &s\n}", "title": "" }, { "docid": "2eeeca37361f8c7cb084ead57db6405e", "score": "0.64746165", "text": "func (b *GraphServiceRequestBuilder) Applications() *GraphServiceApplicationsCollectionRequestBuilder {\n\tbb := &GraphServiceApplicationsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}\n\tbb.baseURL += \"/applications\"\n\treturn bb\n}", "title": "" }, { "docid": "93229db75bc85059f3127c1e7becf6f5", "score": "0.64621234", "text": "func (r *Registry) GetApplications(noarg int, reply *[]models.Application) error {\n\tdb, err := getDB()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn db.Find(reply).Error\n}", "title": "" }, { "docid": "0d8effc326bb72f8cbf7751a92725da8", "score": "0.64611745", "text": "func (a *Client) QueryApplications(params *QueryApplicationsParams, opts ...ClientOption) (*QueryApplicationsOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewQueryApplicationsParams()\n\t}\n\top := &runtime.ClientOperation{\n\t\tID: \"query-applications\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/discover/queries/applications/v1\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &QueryApplicationsReader{formats: a.formats},\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t}\n\tfor _, opt := range opts {\n\t\topt(op)\n\t}\n\n\tresult, err := a.transport.Submit(op)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*QueryApplicationsOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for query-applications: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "title": "" }, { "docid": "9c14fdb386a5fdc00de0f12539ff4479", "score": "0.6406755", "text": "func (s *ApplicationsService) List() ([]*pulsar.Application, *http.Response, error) {\n\treq, err := s.client.NewRequest(\"GET\", \"pulsar/apps\", nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tvar al []*pulsar.Application\n\tresp, err := s.client.Do(req, &al)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn al, resp, nil\n}", "title": "" }, { "docid": "2edcb2840ef57cc58f6c63794b0bde4b", "score": "0.637886", "text": "func (e *Encoder) Application() int {\n\tvar x int32\n\te.ctl_int32_ptr(C.OPUS_GET_APPLICATION_REQUEST, &x)\n\treturn int(x)\n}", "title": "" }, { "docid": "e577d754c69c72b5cb76cc388a27520b", "score": "0.6329064", "text": "func (k Keeper) burnApplications(ctx sdk.Context) {\n\tstore := ctx.KVStore(k.storeKey)\n\titerator := sdk.KVStorePrefixIterator(store, types.BurnApplicationKey)\n\tdefer iterator.Close()\n\tfor ; iterator.Valid(); iterator.Next() {\n\t\tseverity := sdk.Dec{}\n\t\taddress := sdk.Address(types.AddressFromKey(iterator.Key()))\n\t\tamino.MustUnmarshalBinaryBare(iterator.Value(), &severity)\n\t\tval := k.mustGetApplication(ctx, address)\n\t\tk.slash(ctx, address, ctx.BlockHeight(), val.ConsensusPower(), severity)\n\t\t// remove from the burn store\n\t\tstore.Delete(iterator.Key())\n\t}\n}", "title": "" }, { "docid": "0969341606758ce8aeac8bd9ea075bc6", "score": "0.6315856", "text": "func ApplicationsAll(q string) ([]Application, error) {\n\treturn nil, nil\n}", "title": "" }, { "docid": "44b2ea3ac2838e42c4045bd280d5cdd2", "score": "0.63053954", "text": "func (s *ApplicationsServiceOp) List(args ...interface{}) ([]Application, *ListParams, error) {\n\tendpoint := fmt.Sprintf(\"tenants/%s/applications\", s.client.tenantId)\n\treturn s.ListByLink(endpoint, args...)\n}", "title": "" }, { "docid": "f60027d1b0586a1eaba2151156932093", "score": "0.6278642", "text": "func Applications() {\n\tvar acntname, uname, fname, lname, uname2, fname2, lname2 string\n\tvar acntnum int\n\tvar joint bool\n\n\tdb := opendb.OpenDB()\n\tdefer db.Close()\n\tfmt.Println(\"----------------------LISTED APPLICATIONS----------------------\")\n\tfmt.Println()\n\trows, err := db.Query(\"SELECT * FROM applications\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfor rows.Next() {\n\t\trows.Scan(&acntnum, &uname, &fname, &lname, &acntname, &joint, &uname2, &fname2, &lname2)\n\t\tif joint {\n\t\t\tfmt.Println(\"Account #:\", acntnum, \"|Type: Joint\", \"|Username1:\", uname,\n\t\t\t\t\"|First name:\", fname, \"|Last name:\", lname, \"|Username2:\", uname2,\n\t\t\t\t\"|First name:\", fname2, \"|Last name\", lname2)\n\t\t} else {\n\t\t\tfmt.Println(\"Account #:\", acntnum, \"|Type: Solo \", \"|Username:\", uname,\n\t\t\t\t\" |First name:\", fname, \"|Last name:\", lname)\n\t\t}\n\t}\n\tfmt.Println()\n\tfmt.Println(\"---------------------------------------------------------------\")\n\tEmployeePage()\n}", "title": "" }, { "docid": "2cc8904763cbe09ddb2cdde9a77462b7", "score": "0.62692183", "text": "func (_CollateralAssetHolder *CollateralAssetHolderCaller) App(opts *bind.CallOpts) (common.Address, error) {\n\tvar out []interface{}\n\terr := _CollateralAssetHolder.contract.Call(opts, &out, \"app\")\n\n\tif err != nil {\n\t\treturn *new(common.Address), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)\n\n\treturn out0, err\n\n}", "title": "" }, { "docid": "91c4904506f3586e99b6cc7245e7c351", "score": "0.6258124", "text": "func (g Graph) ListApplications(w http.ResponseWriter, r *http.Request) {\n\tlogger := g.logger.SubloggerWithRequestID(r.Context())\n\tlogger.Info().Interface(\"query\", r.URL.Query()).Msg(\"calling list applications\")\n\n\tlbr, err := g.roleService.ListRoles(r.Context(), &settingssvc.ListBundlesRequest{})\n\tif err != nil {\n\t\tlogger.Error().Err(err).Msg(\"could not list roles: transport error\")\n\t\terrorcode.GeneralException.Render(w, r, http.StatusInternalServerError, err.Error())\n\t\treturn\n\t}\n\n\troles := make([]libregraph.AppRole, 0, len(lbr.Bundles))\n\tfor _, bundle := range lbr.GetBundles() {\n\t\trole := libregraph.NewAppRole(bundle.GetId())\n\t\trole.SetDisplayName(bundle.GetDisplayName())\n\t\troles = append(roles, *role)\n\t}\n\n\tapplication := libregraph.NewApplication(g.config.Application.ID)\n\tapplication.SetDisplayName(g.config.Application.DisplayName)\n\tapplication.SetAppRoles(roles)\n\n\tapplications := []*libregraph.Application{\n\t\tapplication,\n\t}\n\n\trender.Status(r, http.StatusOK)\n\trender.JSON(w, r, &ListResponse{Value: applications})\n}", "title": "" }, { "docid": "facf0282fb43159b7bbe562d37a0a475", "score": "0.62385154", "text": "func (r *GraphServiceApplicationsCollectionRequest) Get(ctx context.Context) ([]Application, error) {\n\treturn r.GetN(ctx, 0)\n}", "title": "" }, { "docid": "91941cf9ac52aa70aac182867136e8e9", "score": "0.6220715", "text": "func GetAppraiserApplications(stub shim.ChaincodeStubInterface, callerId string, callerAffiliation int, args[]string) ([]byte, error){\n\tfmt.Println(\"Entering GetAppraiserApplications\")\n\n\tif callerAffiliation == APPRAISER_A {\n\t\tkey, err := GetStateKey(callerId, USER)\n\t\tvar mas[] string\n\t\tvar appraiserApplications[] AppraiserApplication\n\t\t\t\n\t\t\tvar user Appraiser\n\t\t\tbytes, err := stub.GetState(key)\n\t\t\tif err != nil{\n\t\t\t\tfmt.Println(\"GetAppraiserApplications: Could not get bytes for buyer \",err)\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\terr = json.Unmarshal(bytes, &user)\n\t\t\tif err != nil{\n\t\t\t\tfmt.Println(\"GetAppraiserApplications: Could not unmarshal buyer \",err)\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tmas = user.AppraiserApplications\n\n\t\tfor i:=0 ; i<len(mas) ; i++ {\n\t\t\tma, _, err := GetAppraiserApplication(stub, callerId, callerAffiliation, []string{mas[i]})\n\t\t\tif err != nil{\n\t\t\t\tfmt.Println(\"GetAppraiserApplications: Could not get appraiserApplication for id: \"+mas[i]+\" \",err)\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tappraiserApplications = append(appraiserApplications, ma)\n\t\t}\n\n\t\tmasBytes, err := json.Marshal(&appraiserApplications)\n\t\tif err != nil{\n\t\t\t\tfmt.Println(\"GetAppraiserApplications: Could not marshal mas bytes \",err)\n\t\t\t\treturn nil, err\n\t\t}\n\n\t\treturn masBytes, nil\n\n\t}\n\n\treturn nil, errors.New(\"GetAppraiserApplications: callerId \"+callerId+ \" cannot access appraiser applications\")\n}", "title": "" }, { "docid": "518c4cf34ec2f24f6394db1f16296208", "score": "0.6200327", "text": "func responseGetApplications(\n\tresponse http.ResponseWriter,\n\tcode int,\n\tmessage string,\n\tapplications applications) {\n\n\tappRes := AppDataRespone{Code: code, Desc: message, Applications: applications}\n\tresponse.Header().Set(CONTENT_TYPE_KEY, CONTENT_TYPE_VALUE)\n\tresponse.WriteHeader(code)\n\tjson.NewEncoder(response).Encode(appRes)\n}", "title": "" }, { "docid": "aaf18d9a962bc71703a17107290ebf99", "score": "0.61953187", "text": "func GetApplications(w http.ResponseWriter, r *http.Request) {\n\tapplicationService := services.ApplicationService{Orm:orm.NewOrm()}\n\tapplications, err := applicationService.GetAll()\n\tif err != nil{\n\t\tcommon.DisplayAppError(w, err, err.Error(), http.StatusNoContent)\n\t\treturn\n\t}\n\tcommon.SendResult(w, resources.ResponseResource{Data:applications, Success:true}, http.StatusOK)\n}", "title": "" }, { "docid": "04185fe884f0e09f4cbaf6faf868e4e4", "score": "0.6178284", "text": "func CollectApplications(i *integration.Integration, client *client.F5Client, wg *sync.WaitGroup, pathFilter *arguments.PathMatcher, hostPort string, args arguments.ArgumentList) {\n\tdefer wg.Done()\n\n\tif !args.HasInventory() {\n\t\treturn\n\t}\n\n\tvar appResponse definition.SysApplicationService\n\tif err := client.Request(\"/mgmt/tm/sys/application/service\", &appResponse); err != nil {\n\t\tlog.Error(\"Couldn't get application service listing from API: %v\", err)\n\t\treturn\n\t}\n\n\tfor _, applicationItem := range appResponse.Items {\n\t\tif !pathFilter.Matches(applicationItem.FullPath) {\n\t\t\tcontinue\n\t\t}\n\n\t\tapplicationPathIDAttr := integration.NewIDAttribute(\"application\", applicationItem.FullPath)\n\t\tappEntity, err := i.EntityReportedVia(hostPort, hostPort, \"f5-application\", applicationPathIDAttr)\n\t\tif err != nil {\n\t\t\tlog.Error(\"Couldn't create entity for application object: %v\", err)\n\t\t}\n\n\t\tfor k, v := range map[string]interface{}{\n\t\t\t\"deviceGroup\": applicationItem.DeviceGroup,\n\t\t\t\"kind\": applicationItem.Kind,\n\t\t\t\"name\": applicationItem.Name,\n\t\t\t\"template\": applicationItem.Template,\n\t\t\t\"templateModified\": applicationItem.TemplateModified,\n\t\t\t\"trafficGroup\": applicationItem.TrafficGroup,\n\t\t} {\n\t\t\tif err := appEntity.SetInventoryItem(k, \"value\", v); err != nil {\n\t\t\t\tlog.Error(\"Couldn't set inventory item '%s' on application entity '%s': %v\", k, applicationItem.Name, err)\n\t\t\t}\n\t\t}\n\n\t\t// find pool to use variable\n\t\tfor _, variable := range applicationItem.Variables {\n\t\t\tif variable.Name != \"pool__pool_to_use\" {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif err := appEntity.SetInventoryItem(\"poolToUse\", \"value\", variable.Value); err != nil {\n\t\t\t\tlog.Error(\"Couldn't set inventory item 'poolToUse' on application entity '%s': %v\", applicationItem.Name, err)\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "aabe6da3b646f98a21594b089bf8a27f", "score": "0.6137139", "text": "func (h *ApplicationHandler) GetApplications(ctx *gin.Context) {\n\tuser := authentication.GetUser(ctx)\n\tif user == nil {\n\t\treturn\n\t}\n\n\tapplications, err := h.DB.GetApplications(user)\n\tif success := successOrAbort(ctx, http.StatusInternalServerError, err); !success {\n\t\treturn\n\t}\n\n\tctx.JSON(http.StatusOK, &applications)\n}", "title": "" }, { "docid": "09761782ea57c16469d8c5aa0148a811", "score": "0.61295986", "text": "func (a *ApplicationsService) GetApplications(opt *GetApplicationsOptions, options ...OptionFunc) ([]*Application, *Response, error) {\n\treq, err := a.client.newRequest(IDM, \"GET\", \"authorize/identity/Application\", opt, options)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\treq.Header.Set(\"api-version\", applicationAPIVersion)\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tvar bundleResponse struct {\n\t\tTotal int\n\t\tEntry []*Application\n\t}\n\n\tresp, err := a.client.do(req, &bundleResponse)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\tif bundleResponse.Total == 0 {\n\t\treturn nil, resp, ErrEmptyResults\n\t}\n\n\treturn bundleResponse.Entry, resp, nil\n}", "title": "" }, { "docid": "4fcd0a069ac61d9c13c5c76bdc2a790a", "score": "0.61204445", "text": "func GetMortgageApplications(stub shim.ChaincodeStubInterface, callerId string, callerAffiliation int, args[]string) ([]byte, error){\n\tfmt.Println(\"Entering GetMortgageApplications\")\n\n\tif callerAffiliation == BUYER_A || callerAffiliation == BANK_A {\n\t\tkey, err := GetStateKey(callerId, USER)\n\t\tvar mas[] string\n\t\tvar mortgageApplications[] MortgageApplication\n\n\t\tif callerAffiliation == BUYER_A {\n\t\t\t\n\t\t\tvar user Buyer\n\t\t\tbytes, err := stub.GetState(key)\n\t\t\tif err != nil{\n\t\t\t\tfmt.Println(\"GetMortgageApplications: Could not get bytes for buyer \",err)\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\terr = json.Unmarshal(bytes, &user)\n\t\t\tif err != nil{\n\t\t\t\tfmt.Println(\"GetMortgageApplications: Could not unmarshal buyer \",err)\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tmas = user.MortgageApplications\n\n\t\t}else if callerAffiliation == BANK_A {\n\t\t\t\n\t\t\tvar user Bank\n\t\t\tbytes, err := stub.GetState(key)\n\t\t\tif err != nil{\n\t\t\t\tfmt.Println(\"GetMortgageApplications: Could not get bytes for bank \",err)\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\terr = json.Unmarshal(bytes, &user)\n\t\t\tif err != nil{\n\t\t\t\tfmt.Println(\"GetMortgageApplications: Could not unmarshal bank \",err)\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tmas = user.MortgageApplications\n\n\t\t}\n\n\t\tfor i:=0 ; i<len(mas) ; i++ {\n\t\t\tma, _, err := GetMortgageApplication(stub, callerId, callerAffiliation, []string{mas[i]})\n\t\t\tif err != nil{\n\t\t\t\tfmt.Println(\"GetMortgageApplications: Could not get mortgageApplication for id: \"+mas[i]+\" \",err)\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tmortgageApplications = append(mortgageApplications, ma)\n\t\t}\n\n\t\tmasBytes, err := json.Marshal(&mortgageApplications)\n\t\tif err != nil{\n\t\t\t\tfmt.Println(\"GetMortgageApplications: Could not marshal mas bytes \",err)\n\t\t\t\treturn nil, err\n\t\t}\n\n\t\treturn masBytes, nil\n\n\t}\n\n\treturn nil, errors.New(\"GetMortgageApplications: callerId \"+callerId+ \" cannot access mortgage applications\")\n}", "title": "" }, { "docid": "cdf6552d1bb30873243066f891d9e566", "score": "0.6099597", "text": "func (api *API) AccessApplications(zoneID string, pageOpts PaginationOptions) ([]AccessApplication, ResultInfo, error) {\n\tv := url.Values{}\n\tif pageOpts.PerPage > 0 {\n\t\tv.Set(\"per_page\", strconv.Itoa(pageOpts.PerPage))\n\t}\n\tif pageOpts.Page > 0 {\n\t\tv.Set(\"page\", strconv.Itoa(pageOpts.Page))\n\t}\n\n\turi := \"/zones/\" + zoneID + \"/access/apps\"\n\tif len(v) > 0 {\n\t\turi = uri + \"?\" + v.Encode()\n\t}\n\n\tres, err := api.makeRequest(\"GET\", uri, nil)\n\tif err != nil {\n\t\treturn []AccessApplication{}, ResultInfo{}, errors.Wrap(err, errMakeRequestError)\n\t}\n\n\tvar accessApplicationListResponse AccessApplicationListResponse\n\terr = json.Unmarshal(res, &accessApplicationListResponse)\n\tif err != nil {\n\t\treturn []AccessApplication{}, ResultInfo{}, errors.Wrap(err, errUnmarshalError)\n\t}\n\n\treturn accessApplicationListResponse.Result, accessApplicationListResponse.ResultInfo, nil\n}", "title": "" }, { "docid": "393d62f5de2b51fc78b7af63ed0715b7", "score": "0.60908175", "text": "func (r *RPC) Apps(_ *struct{}, reply *[]*appserver.AppState) (err error) {\n\tdefer rpcutil.LogCall(r.log, \"Apps\", nil)(reply, &err)\n\n\tapps, err := r.visor.Apps()\n\t*reply = apps\n\n\treturn err\n}", "title": "" }, { "docid": "00f2d7b0e3505c8a56811d5de89ffe7c", "score": "0.6075721", "text": "func (k Keeper) Application(ctx sdk.Context, address sdk.Address) exported.ApplicationI {\n\tapp, found := k.GetApplication(ctx, address)\n\tif !found {\n\t\treturn nil\n\t}\n\treturn app\n}", "title": "" }, { "docid": "b60b8315ce99a150adec9e445052df85", "score": "0.6070789", "text": "func (imageCreator EcsImageCreator) GetApplications(repository string) (*[]string, error) {\n\tapplicationResult := newApplicationResult(repository)\n\n\terr := imageCreator.getResults(applicationResult)\n\n\treturn applicationResult.getResults(), err\n\n}", "title": "" }, { "docid": "aca740d7fde8e663030b7c78f4f0f5d8", "score": "0.6032936", "text": "func (store *managerStore) ListApplications(runAs string) ([]*types.Application, error) {\n\tif cacheMgr.isOK {\n\t\treturn listCacheRunAsApplications(runAs)\n\t}\n\n\tclient := store.BkbcsClient.Applications(runAs)\n\tv2Apps, err := client.List(context.Background(), metav1.ListOptions{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tapps := make([]*types.Application, 0, len(v2Apps.Items))\n\tfor _, app := range v2Apps.Items {\n\t\tobj := app.Spec.Application\n\t\tobj.ResourceVersion = app.ResourceVersion\n\t\tapps = append(apps, &obj)\n\t}\n\treturn apps, nil\n}", "title": "" }, { "docid": "c2d16120733912837beb12771a6e9417", "score": "0.60246474", "text": "func (k *Kf) Apps(ctx context.Context) map[string]AppInfo {\n\tLogf(k.t, \"listing apps...\")\n\tdefer Logf(k.t, \"done listing apps.\")\n\tk.t.Helper()\n\toutput, errs := k.kf(ctx, k.t, KfTestConfig{\n\t\tArgs: []string{\n\t\t\t\"apps\",\n\t\t\t\"--namespace\", SpaceFromContext(ctx),\n\t\t},\n\t})\n\tPanicOnError(ctx, k.t, \"apps\", errs)\n\tapps := CombineOutputStr(ctx, k.t, output)\n\n\tif len(apps) == 0 {\n\t\treturn nil\n\t}\n\n\tresults := map[string]AppInfo{}\n\tfor _, app := range apps[1:] {\n\t\tf := strings.Fields(app)\n\t\tif len(f) <= 1 {\n\t\t\tcontinue\n\t\t}\n\n\t\tname := f[0]\n\t\trequestedState := f[1]\n\t\tinstances := f[2]\n\t\tmemory := f[3]\n\t\tdisk := f[4]\n\t\tvar urls []string\n\t\tif len(f) > 5 {\n\t\t\turls = strings.Split(f[5], \",\")\n\t\t}\n\n\t\tresults[name] = AppInfo{\n\t\t\tName: name,\n\t\t\tRequestedState: requestedState,\n\t\t\tInstances: instances,\n\t\t\tMemory: memory,\n\t\t\tDisk: disk,\n\t\t\tURLs: urls,\n\t\t}\n\t}\n\n\treturn results\n}", "title": "" }, { "docid": "8d9673811dd372e6979cda6178d5eff0", "score": "0.6017856", "text": "func List() (*http.Response, string, []error) {\n\tk := kumoru.New()\n\n\tk.Get(fmt.Sprintf(\"%s/v1/applications/\", k.EndPoint.Application))\n\tk.SignRequest(true)\n\treturn k.End()\n}", "title": "" }, { "docid": "dac0af97e0e2b801f0ddde0b0cf4c6d5", "score": "0.5996632", "text": "func (r *registry) getApplications() []*Application {\n\tr.RLock()\n\tdefer r.RUnlock()\n\tif len(r.apps) == 0 {\n\t\treturn make([]*Application, 0)\n\t}\n\n\tapps := make([]*Application, 0)\n\n\tfor _, app := range r.apps {\n\t\tapps = append(apps, app)\n\t}\n\treturn apps\n}", "title": "" }, { "docid": "0d5fc92b542cb2571ea0a7840a570611", "score": "0.5992336", "text": "func (o AppProjectSpecSyncWindowsOutput) Applications() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v AppProjectSpecSyncWindows) []string { return v.Applications }).(pulumi.StringArrayOutput)\n}", "title": "" }, { "docid": "159d2ad34e9f336bc0b04be5574b38bb", "score": "0.5981605", "text": "func (api *API) appsQuery() *dat.SelectDocBuilder {\n\treturn api.dbR.\n\t\tSelectDoc(\"id, name, description, created_ts\").\n\t\tOne(\"instances\", api.appInstancesQuery()).\n\t\tMany(\"groups\", api.appGroupsQuery()).\n\t\tMany(\"channels\", api.appChannelsQuery()).\n\t\tMany(\"packages\", api.appPackagesQuery()).\n\t\tFrom(\"application\").\n\t\tOrderBy(\"created_ts DESC\")\n}", "title": "" }, { "docid": "65c381b6a7ec5bf06e946301148581b4", "score": "0.5974504", "text": "func (_m *Resolver) ApplicationQuery(ctx context.Context, name string) (*gqlschema.Application, error) {\n\tvar r0 *gqlschema.Application\n\tvar r1 error\n\tr1 = _m.err\n\n\treturn r0, r1\n}", "title": "" }, { "docid": "a98c0f9cc474b567c63028b2b8a6c6ee", "score": "0.5957532", "text": "func (a *ApplicationsService) GetApplications(opt *GetApplicationsOptions, options ...OptionFunc) (*[]Application, *Response, error) {\n\treq, err := a.NewRequest(http.MethodGet, \"/Application\", opt, options...)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\treq.Header.Set(\"api-version\", applicationAPIVersion)\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tvar bundleResponse internal.Bundle\n\n\tresp, err := a.Do(req, &bundleResponse)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\tvar apps []Application\n\tfor _, a := range bundleResponse.Entry {\n\t\tvar app Application\n\t\tif err := json.Unmarshal(a.Resource, &app); err == nil {\n\t\t\tapps = append(apps, app)\n\t\t}\n\t}\n\treturn &apps, resp, nil\n}", "title": "" }, { "docid": "1bcdac76cb608004af42ed0d44e05e23", "score": "0.5951617", "text": "func Application(appName string) *sysl.Application {\n\treturn &sysl.Application{\n\t\tName: AppName(appName),\n\t\tEndpoints: map[string]*sysl.Endpoint{},\n\t\tTypes: map[string]*sysl.Type{},\n\t\tAttrs: map[string]*sysl.Attribute{},\n\t}\n}", "title": "" }, { "docid": "a2071ce578ff7c0ae4a1f62c9c143440", "score": "0.5951403", "text": "func (a *Application) Show() (*Application, *http.Response, []error) {\n\tk := kumoru.New()\n\n\tk.Get(fmt.Sprintf(\"%s/v1/applications/%s\", k.EndPoint.Application, a.UUID))\n\tk.SignRequest(true)\n\n\tresp, body, errs := k.End()\n\n\tif len(errs) > 0 {\n\t\treturn a, resp, errs\n\t}\n\n\tif resp.StatusCode >= 400 {\n\t\terrs = append(errs, fmt.Errorf(\"%s\", resp.Status))\n\t}\n\n\terr := json.Unmarshal([]byte(body), &a)\n\n\tif err != nil {\n\t\terrs = append(errs, fmt.Errorf(\"%s\", err))\n\t\treturn a, resp, errs\n\t}\n\n\treturn a, resp, nil\n}", "title": "" }, { "docid": "fe975d38519d4fbf747cf624791c2c89", "score": "0.5945368", "text": "func (g *Guestfs) Inspect_list_applications (root string) (*[]Application, *GuestfsError) {\n if g.g == nil {\n return nil, closed_handle_error (\"inspect_list_applications\")\n }\n\n c_root := C.CString (root)\n defer C.free (unsafe.Pointer (c_root))\n\n r := C.guestfs_inspect_list_applications (g.g, c_root)\n\n if r == nil {\n return nil, get_error_from_handle (g, \"inspect_list_applications\")\n }\n defer C.guestfs_free_application_list (r)\n return return_Application_list (r), nil\n}", "title": "" }, { "docid": "73740ec25526d91a0d1da16dbefa3255", "score": "0.59274536", "text": "func List(kubeClient *kubernetes.Cluster, org string) (ApplicationList, error) {\n\tlistOptions := metav1.ListOptions{\n\t\tLabelSelector: \"app.kubernetes.io/component=application,app.kubernetes.io/managed-by=epinio\",\n\t}\n\n\tresult := ApplicationList{}\n\n\texists, err := organizations.Exists(kubeClient, org)\n\tif err != nil {\n\t\treturn result, err\n\t}\n\tif !exists {\n\t\treturn result, fmt.Errorf(\"organization %s does not exist\", org)\n\t}\n\n\tdeployments, err := kubeClient.Kubectl.AppsV1().Deployments(org).List(context.Background(), listOptions)\n\tif err != nil {\n\t\treturn result, err\n\t}\n\n\tfor _, deployment := range deployments.Items {\n\t\tappEpinio, err := (&Application{\n\t\t\tOrganization: org,\n\t\t\tName: deployment.ObjectMeta.Name,\n\t\t\tkubeClient: kubeClient,\n\t\t}).Complete()\n\t\tif err != nil {\n\t\t\treturn result, err\n\t\t}\n\n\t\tresult = append(result, *appEpinio)\n\t}\n\n\treturn result, nil\n}", "title": "" }, { "docid": "20720d46ba81386a690f9d1af61012ff", "score": "0.5923767", "text": "func (o FastApplicationOutput) Application() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *FastApplication) pulumi.StringOutput { return v.Application }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "8fe4bf9052a3cf1add700eb00e3880a9", "score": "0.59219074", "text": "func (a *ApplicationsApiService) ApplicationsGet(ctx _context.Context, localVarOptionals *ApplicationsGetOpts) ([]Application, *_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = _nethttp.MethodGet\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue []Application\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/applications\"\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\tif localVarOptionals != nil && localVarOptionals.Field.IsSet() {\n\t\tt := localVarOptionals.Field.Value()\n\t\tif reflect.TypeOf(t).Kind() == reflect.Slice {\n\t\t\ts := reflect.ValueOf(t)\n\t\t\tfor i := 0; i < s.Len(); i++ {\n\t\t\t\tlocalVarQueryParams.Add(\"field\", parameterToString(s.Index(i), \"multi\"))\n\t\t\t}\n\t\t} else {\n\t\t\tlocalVarQueryParams.Add(\"field\", parameterToString(t, \"multi\"))\n\t\t}\n\t}\n\tif localVarOptionals != nil && localVarOptionals.Op.IsSet() {\n\t\tt := localVarOptionals.Op.Value()\n\t\tif reflect.TypeOf(t).Kind() == reflect.Slice {\n\t\t\ts := reflect.ValueOf(t)\n\t\t\tfor i := 0; i < s.Len(); i++ {\n\t\t\t\tlocalVarQueryParams.Add(\"op\", parameterToString(s.Index(i), \"multi\"))\n\t\t\t}\n\t\t} else {\n\t\t\tlocalVarQueryParams.Add(\"op\", parameterToString(t, \"multi\"))\n\t\t}\n\t}\n\tif localVarOptionals != nil && localVarOptionals.Value.IsSet() {\n\t\tt := localVarOptionals.Value.Value()\n\t\tif reflect.TypeOf(t).Kind() == reflect.Slice {\n\t\t\ts := reflect.ValueOf(t)\n\t\t\tfor i := 0; i < s.Len(); i++ {\n\t\t\t\tlocalVarQueryParams.Add(\"value\", parameterToString(s.Index(i), \"multi\"))\n\t\t\t}\n\t\t} else {\n\t\t\tlocalVarQueryParams.Add(\"value\", parameterToString(t, \"multi\"))\n\t\t}\n\t}\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)\n\tif localVarHTTPContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHTTPContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHTTPHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\n\tif localVarHTTPHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHTTPHeaderAccept\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tif localVarHTTPResponse.StatusCode >= 300 {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHTTPResponse.Status,\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 200 {\n\t\t\tvar v []Application\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\tif err != nil {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: err.Error(),\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\treturn localVarReturnValue, localVarHTTPResponse, nil\n}", "title": "" }, { "docid": "0a2dc75c39956cd7e76c84a3a974f589", "score": "0.5919619", "text": "func (s *ApplicationService) ListApplications(request ListApplicationsRequest) (*ListApplicationsResponse, *http.Response, error) {\n\ts.authSet.ApplyAPICredentials(&request)\n\tresponse := new(ListApplicationsResponse)\n\thttpResponse, err := s.sling.New().\n\t\tGet(\"\").\n\t\tQueryStruct(request).\n\t\tReceiveSuccess(response)\n\treturn response, httpResponse, err\n}", "title": "" }, { "docid": "0942c024e890f5cd00ee82e779c36788", "score": "0.5890166", "text": "func GetApplications(db *sqlx.DB, limit, offset int) ([]Application, error) {\n\tvar apps []Application\n\terr := db.Select(&apps, \"select * from application order by name limit $1 offset $2\", limit, offset)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"get applications error: %s\", err)\n\t}\n\treturn apps, nil\n}", "title": "" }, { "docid": "3dd65ed7e73cb7afabf911bcb9f030ec", "score": "0.5889285", "text": "func AppList(fn controller.AppListFunc) Handler {\n\treturn func(ctx context.Context, w http.ResponseWriter, r *http.Request) {\n\t\tcurrentOrg := orgFromContext(ctx)\n\n\t\topts, err := extractAppOpts(r)\n\t\tif err != nil {\n\t\t\trespondError(w, 0, wrapError(ErrBadRequest, err.Error()))\n\t\t\treturn\n\t\t}\n\n\t\topts.Before, err = extractTimeCursorBefore(r)\n\t\tif err != nil {\n\t\t\trespondError(w, 0, wrapError(ErrBadRequest, err.Error()))\n\t\t\treturn\n\t\t}\n\n\t\topts.Limit, err = extractLimit(r)\n\t\tif err != nil {\n\t\t\trespondError(w, 0, wrapError(ErrBadRequest, err.Error()))\n\t\t\treturn\n\t\t}\n\n\t\tas, err := fn(currentOrg, opts)\n\t\tif err != nil {\n\t\t\trespondError(w, 0, err)\n\t\t\treturn\n\t\t}\n\n\t\tif len(as) == 0 {\n\t\t\trespondJSON(w, http.StatusNoContent, nil)\n\t\t\treturn\n\t\t}\n\n\t\trespondJSON(w, http.StatusOK, &payloadApps{\n\t\t\tapps: as,\n\t\t\tpagination: pagination(\n\t\t\t\tr,\n\t\t\t\topts.Limit,\n\t\t\t\tappCursorAfter(as, opts.Limit),\n\t\t\t\tappCursorBefore(as, opts.Limit),\n\t\t\t\tnil,\n\t\t\t),\n\t\t})\n\t}\n}", "title": "" }, { "docid": "f2232ea0873118b8088db524f0c48b1f", "score": "0.58862704", "text": "func (a *Client) GetApplications(params *GetApplicationsParams, opts ...ClientOption) (*GetApplicationsOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewGetApplicationsParams()\n\t}\n\top := &runtime.ClientOperation{\n\t\tID: \"get-applications\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/discover/entities/applications/v1\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &GetApplicationsReader{formats: a.formats},\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t}\n\tfor _, opt := range opts {\n\t\topt(op)\n\t}\n\n\tresult, err := a.transport.Submit(op)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*GetApplicationsOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for get-applications: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "title": "" }, { "docid": "e4dc1b05c3f63d72b16da96ca27c80b9", "score": "0.5877494", "text": "func (o ServiceBindingRequestStatusOutput) Applications() ServiceBindingRequestStatusApplicationsArrayOutput {\n\treturn o.ApplyT(func(v ServiceBindingRequestStatus) []ServiceBindingRequestStatusApplications { return v.Applications }).(ServiceBindingRequestStatusApplicationsArrayOutput)\n}", "title": "" }, { "docid": "19444555dec59e49fea6e3f9466af6d0", "score": "0.58490074", "text": "func (o *Site) Application(mods ...qm.QueryMod) applicationQuery {\n\tqueryMods := []qm.QueryMod{\n\t\tqm.Where(\"`id` = ?\", o.ApplicationID),\n\t}\n\n\tqueryMods = append(queryMods, mods...)\n\n\tquery := Applications(queryMods...)\n\tqueries.SetFrom(query.Query, \"`applications`\")\n\n\treturn query\n}", "title": "" }, { "docid": "85d3a8312627730de8448cb22fbbcabb", "score": "0.58194506", "text": "func (s *applicationLister) Applications(namespace string) ApplicationNamespaceLister {\n\treturn applicationNamespaceLister{indexer: s.indexer, namespace: namespace}\n}", "title": "" }, { "docid": "cf77a69a603a1cfdb80e62a33091c204", "score": "0.58170086", "text": "func (k Keeper) applicationByConsAddr(ctx sdk.Context, addr sdk.Address) exported.ApplicationI {\n\tapp, found := k.GetApplication(ctx, addr)\n\tif !found {\n\t\treturn nil\n\t}\n\treturn app\n}", "title": "" }, { "docid": "2456a8ee8bc8c8a134d495c3289eacaf", "score": "0.58025426", "text": "func ExampleApplicationsClient_List() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armservicefabric.NewClientFactory(\"<subscription-id>\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tres, err := clientFactory.NewApplicationsClient().List(ctx, \"resRg\", \"myCluster\", nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\t// You could use response here. We use blank identifier for just demo purposes.\n\t_ = res\n\t// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t// res.ApplicationResourceList = armservicefabric.ApplicationResourceList{\n\t// \tValue: []*armservicefabric.ApplicationResource{\n\t// \t\t{\n\t// \t\t\tName: to.Ptr(\"myCluster\"),\n\t// \t\t\tType: to.Ptr(\"applications\"),\n\t// \t\t\tEtag: to.Ptr(\"W/\\\"636462502180261858\\\"\"),\n\t// \t\t\tID: to.Ptr(\"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApp\"),\n\t// \t\t\tLocation: to.Ptr(\"eastus\"),\n\t// \t\t\tTags: map[string]*string{\n\t// \t\t\t},\n\t// \t\t\tProperties: &armservicefabric.ApplicationResourceProperties{\n\t// \t\t\t\tMetrics: []*armservicefabric.ApplicationMetricDescription{\n\t// \t\t\t\t\t{\n\t// \t\t\t\t\t\tName: to.Ptr(\"metric1\"),\n\t// \t\t\t\t\t\tMaximumCapacity: to.Ptr[int64](3),\n\t// \t\t\t\t\t\tReservationCapacity: to.Ptr[int64](1),\n\t// \t\t\t\t\t\tTotalApplicationCapacity: to.Ptr[int64](5),\n\t// \t\t\t\t}},\n\t// \t\t\t\tRemoveApplicationCapacity: to.Ptr(false),\n\t// \t\t\t\tTypeVersion: to.Ptr(\"1.0\"),\n\t// \t\t\t\tProvisioningState: to.Ptr(\"Succeeded\"),\n\t// \t\t\t\tTypeName: to.Ptr(\"myAppType\"),\n\t// \t\t\t},\n\t// \t}},\n\t// }\n}", "title": "" }, { "docid": "8faae912333b4bc61873c5ae680760bd", "score": "0.57966596", "text": "func (recv *RecentInfo) GetApplications() ([]string, uint64) {\n\tvar c_length C.gsize\n\n\tretC := C.gtk_recent_info_get_applications((*C.GtkRecentInfo)(recv.native), &c_length)\n\tretGo := []string{}\n\tfor p := retC; *p != nil; p = (**C.char)(C.gpointer((uintptr(C.gpointer(p)) + uintptr(C.sizeof_gpointer)))) {\n\t\ts := C.GoString(*p)\n\t\tretGo = append(retGo, s)\n\t}\n\tdefer C.g_strfreev(retC)\n\n\tlength := (uint64)(c_length)\n\n\treturn retGo, length\n}", "title": "" }, { "docid": "8cc38ba1cdf6445c6d1cd37d83ca9c24", "score": "0.57859635", "text": "func getApplications(ctx context.Context, client *okta.Client, signOnMode string) ([]*okta.Application, error) {\n\tsupportedApps, err := getAllApplications(ctx, client)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar filterApps []*okta.Application\n\tfor _, app := range supportedApps {\n\t\tif app.SignOnMode == signOnMode {\n\t\t\tfilterApps = append(filterApps, app)\n\t\t}\n\t}\n\treturn filterApps, nil\n}", "title": "" }, { "docid": "8521fe743ffe96961796c4133cd4d074", "score": "0.57822", "text": "func (s service) QueryApps(ctx context.Context, query string, offset, limit int64) (*auth.ListAppsResponse, error) {\n\titems, count, err := s.repo.QueryApps(ctx, query, offset, limit)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &auth.ListAppsResponse{\n\t\tApps: entity.AppToProtoList(items),\n\t\tTotalCount: int64(count),\n\t\tOffset: offset,\n\t\tLimit: limit,\n\t}, nil\n}", "title": "" }, { "docid": "96602a35fade6b479ea30ff012595c6e", "score": "0.57692873", "text": "func (m *ApiApplication) GetKnownClientApplications()([]i561e97a8befe7661a44c8f54600992b4207a3a0cf6770e5559949bc276de2e22.UUID) {\n val, err := m.GetBackingStore().Get(\"knownClientApplications\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.([]i561e97a8befe7661a44c8f54600992b4207a3a0cf6770e5559949bc276de2e22.UUID)\n }\n return nil\n}", "title": "" }, { "docid": "be507390b49f29a7b16912fa1b29ee6a", "score": "0.5767809", "text": "func (this *SmartContract) AppCall(address common.Address, method string, codes, args []byte, isLoad bool) error {\n\tvar code []byte\n\tif isLoad {\n\t\tc, err := this.getContract(address[:]); if err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcode = c.Code.Code\n\t}\n\n\tvmType := stypes.VmType(address[0])\n\n\tswitch vmType {\n\tcase stypes.Native:\n\t\tbf := new(bytes.Buffer)\n\t\tc := states.Contract{\n\t\t\tAddress: address,\n\t\t\tMethod: method,\n\t\t\tArgs: args,\n\t\t}\n\t\tif err := c.Serialize(bf); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcode = bf.Bytes()\n\tcase stypes.NEOVM:\n\t\tvar temp []byte\n\t\tbuild := vm.NewParamsBuilder(new(bytes.Buffer))\n\t\tif method != \"\" {\n\t\t\tbuild.EmitPushByteArray([]byte(method))\n\t\t}\n\t\ttemp = append(args, build.ToArray()...)\n\t\tif isLoad {\n\t\t\tcode = append(temp, code...)\n\t\t} else {\n\t\t\tcode = append(temp, codes...)\n\t\t}\n\tcase stypes.WASMVM:\n\t}\n\n\tthis.PushContext(&context.Context{\n\t\tCode: stypes.VmCode{\n\t\t\tCode: code,\n\t\t\tVmType: vmType,\n\t\t},\n\t\tContractAddress: address,\n\t})\n\n\tif err := this.Execute(); err != nil {\n\t\treturn err\n\t}\n\n\tthis.PopContext()\n\treturn nil\n}", "title": "" }, { "docid": "e928ba5017ef557a1f06f6f4718def32", "score": "0.5763763", "text": "func (a App) All() (AppsResponse, error) {\n\tvar apps AppsResponse\n\tres, err := a.client.Request(\"GET\", \"/v2/apps\", nil)\n\tif err != nil {\n\t\treturn apps, err\n\t}\n\tdefer res.Body.Close()\n\tbody, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn apps, err\n\t}\n\tjson.Unmarshal(body, &apps)\n\treturn apps, nil\n}", "title": "" }, { "docid": "5d8bc71082311a3118548c9d6f91b8b7", "score": "0.5762439", "text": "func (ctx *State) Applications() []*AppInstState {\n\tv := make([]*AppInstState, 0, len(ctx.applications))\n\tfor _, value := range ctx.applications {\n\t\tif !value.deleted {\n\t\t\tv = append(v, value)\n\t\t}\n\t}\n\treturn v\n}", "title": "" }, { "docid": "2f534fd0499ddac64e1754819630919b", "score": "0.5760014", "text": "func (s Service) All(ctx context.Context, req *pb.ReadApplications) (*pb.ApplicationsRead, error) {\n\tif err := s.auth.Authorize(ctx, auth.Reader); err != nil {\n\t\treturn nil, tw.ToTwirpError(err, \"not authorized\")\n\t}\n\n\tresponse := &pb.ApplicationsRead{}\n\tresponseLock := &sync.Mutex{}\n\n\tclusters, err := s.cl.All()\n\tif err != nil {\n\t\tlogger.Error(\"error from cluster service\", \"error\", err)\n\t\treturn nil, err\n\t}\n\n\twg := &sync.WaitGroup{}\n\tfor _, cl := range clusters {\n\t\twg.Add(1)\n\t\tgo func(c *cluster.Cluster) {\n\t\t\tdefer wg.Done()\n\t\t\tstatus, err := s.getClusterStatus(c)\n\t\t\tif err != nil {\n\t\t\t\tlogger.Error(\"error getting Cluster status\", \"error\", err, \"cluster\", c.Name())\n\t\t\t}\n\n\t\t\tif status {\n\t\t\t\tdeps, err := s.getDeployments(c)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tfor _, dep := range deps {\n\t\t\t\t\tready := deploymentIsReady(&dep)\n\t\t\t\t\tresponseLock.Lock()\n\t\t\t\t\taddApplication(response, dep.Labels, c.Name(), dep.Namespace, ready)\n\t\t\t\t\tresponseLock.Unlock()\n\t\t\t\t}\n\n\t\t\t\tsets, err := s.getStatefulSets(c)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tfor _, set := range sets {\n\t\t\t\t\tready := statefulSetIsReady(&set)\n\t\t\t\t\tresponseLock.Lock()\n\t\t\t\t\taddApplication(response, set.Labels, c.Name(), set.Namespace, ready)\n\t\t\t\t\tresponseLock.Unlock()\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlogger.Warn(\"could not get applications for cluster as it is not ready\", \"cluster\", c.Name)\n\t\t\t}\n\t\t}(cl)\n\t}\n\n\twg.Wait()\n\treturn response, nil\n}", "title": "" }, { "docid": "fd91a3374b282890616ce05409936e30", "score": "0.5749798", "text": "func (s *ApplicationService) GetApplications() ([]*Application, error) {\n\n\turl := \"controller/rest/applications?output=json\"\n\n\tvar apps []*Application\n\terr := s.client.Rest(\"GET\", url, &apps, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn apps, nil\n}", "title": "" }, { "docid": "78af3b3285693ff1808c78a68ae4099d", "score": "0.573519", "text": "func (c Client) ListApplications(location string) (*responses.ListApplications, error) {\n\turl := fmt.Sprintf(\"%s/PasswordVault/WebServices/PIMServices.svc/Applications?Location=%s\", c.BaseURL, location)\n\tresponse, err := httpJson.Get(url, c.SessionToken, c.InsecureTLS, c.Logger)\n\tif err != nil {\n\t\treturn &responses.ListApplications{}, fmt.Errorf(\"Error listing applications in location '%s'. %s\", location, err)\n\t}\n\tjsonString, _ := json.Marshal(response)\n\tListApplicationsResponse := responses.ListApplications{}\n\terr = json.Unmarshal(jsonString, &ListApplicationsResponse)\n\treturn &ListApplicationsResponse, err\n}", "title": "" }, { "docid": "ef2d30ebc8ff8813b55e87e0a86178c9", "score": "0.5724387", "text": "func (m *GraphBaseServiceClient) ApplicationsWithAppId(appId *string)(*i1feaf5e7874bc1012d47d3fb9128ea97140f17a0526b7e8dd267bdb120026eae.ApplicationsWithAppIdRequestBuilder) {\n return i1feaf5e7874bc1012d47d3fb9128ea97140f17a0526b7e8dd267bdb120026eae.NewApplicationsWithAppIdRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter, appId)\n}", "title": "" }, { "docid": "cf277f7177e31a29b1ccf88347971edb", "score": "0.57240057", "text": "func (g Graph) GetApplication(w http.ResponseWriter, r *http.Request) {\n\tlogger := g.logger.SubloggerWithRequestID(r.Context())\n\tlogger.Info().Interface(\"query\", r.URL.Query()).Msg(\"calling get application\")\n\n\tapplicationID := chi.URLParam(r, \"applicationID\")\n\n\tif applicationID != g.config.Application.ID {\n\t\terrorcode.ItemNotFound.Render(w, r, http.StatusNotFound, fmt.Sprintf(\"requested id %s does not match expected application id %v\", applicationID, g.config.Application.ID))\n\t\treturn\n\t}\n\n\tlbr, err := g.roleService.ListRoles(r.Context(), &settingssvc.ListBundlesRequest{})\n\tif err != nil {\n\t\tlogger.Error().Err(err).Msg(\"could not list roles: transport error\")\n\t\terrorcode.GeneralException.Render(w, r, http.StatusInternalServerError, err.Error())\n\t\treturn\n\t}\n\n\troles := make([]libregraph.AppRole, 0, len(lbr.Bundles))\n\tfor _, bundle := range lbr.GetBundles() {\n\t\trole := libregraph.NewAppRole(bundle.GetId())\n\t\trole.SetDisplayName(bundle.GetDisplayName())\n\t\troles = append(roles, *role)\n\t}\n\n\tapplication := libregraph.NewApplication(applicationID)\n\tapplication.SetDisplayName(g.config.Application.DisplayName)\n\tapplication.SetAppRoles(roles)\n\n\trender.Status(r, http.StatusOK)\n\trender.JSON(w, r, application)\n}", "title": "" }, { "docid": "17eb6a6770ad9babe9a818f654545220", "score": "0.57238626", "text": "func AppsGet(w http.ResponseWriter, r *http.Request, store *str.Store) {\n\tsub, err := contextimpl.GetSub(r.Context())\n\tif err != nil {\n\t\thelper.RespondWithMessage(w, r, http.StatusInternalServerError, err.Error())\n\t\treturn\n\t}\n\tlog.GeneralLogger.Println(\"User id from jwt \", sub)\n\n\tuserApps := []getApp{}\n\n\t//1. Get apps list from db\n\tusersService := service.NewUsersService(store)\n\tapps, status, message := usersService.GetUserApplications(sub)\n\tif status != http.StatusOK {\n\t\thelper.RespondWithMessage(w, r, status, message)\n\t\treturn\n\t}\n\n\tfor _, app := range apps {\n\t\tuserApp := new(getApp)\n\t\tuserApp.ID = app.Id.Hex()\n\n\t\tuserApp.Name = app.Name\n\t\t//2. read VHOST for each\n\t\tuserApp.URLs = common.GetAppUrls(app.Name)\n\t\t// 3. GetRunningImageTag for each app\n\t\tuserApp.Status = ps.GetAppStatus(app.Name)\n\n\t\t// 4. run scheduler ap status for each app\n\t\tif instances := common.GetAppInstances(app.Name); instances >= 0 {\n\t\t\tuserApp.Instances = instances\n\t\t}\n\n\t\t// 5. read DOCKER_OPTIONS_DEPLOY file for each app\n\t\tif restartPolicy, err := ps.GetRestartPolicy(app.Name); err == nil {\n\t\t\tuserApp.RestartPolicy = restartPolicy\n\t\t}\n\n\t\tuserApps = append(userApps, *userApp)\n\t}\n\thelper.RespondWithData(w, r, http.StatusOK, userApps)\n}", "title": "" }, { "docid": "a72e2d241caa56a9cc11333e31a38da7", "score": "0.57191736", "text": "func (o ServiceBindingRequestStatusPtrOutput) Applications() ServiceBindingRequestStatusApplicationsArrayOutput {\n\treturn o.ApplyT(func(v *ServiceBindingRequestStatus) []ServiceBindingRequestStatusApplications {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Applications\n\t}).(ServiceBindingRequestStatusApplicationsArrayOutput)\n}", "title": "" }, { "docid": "40ec83d15e01cb83df035c9b9d8feef6", "score": "0.5706695", "text": "func (page ListApplicationsResultPage) Values() []Application {\n\tif page.lar.IsEmpty() {\n\t\treturn nil\n\t}\n\treturn *page.lar.Value\n}", "title": "" }, { "docid": "6c9b759b58ef759cdb9d79c83f855ad8", "score": "0.5696645", "text": "func ListApplications(c *cli.Context) error {\n\ttype appList struct {\n\t\tName string `json:\"name\"`\n\t\tUUID string `json:\"uuid\"`\n\t}\n\n\tbody, err := HTTPGet(\"/api/v1/applications\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar apps []appList\n\terr = json.Unmarshal([]byte(body), &apps)\n\tif err != nil {\n\t\treturn errors.New(\"Unable to read JSON response.\")\n\t}\n\n\ttable := tablewriter.NewWriter(os.Stdout)\n\ttable.SetHeader([]string{\"Name\", \"UUID\"})\n\tfor _, app := range apps {\n\t\ttable.Append([]string{app.Name, app.UUID})\n\t}\n\ttable.Render()\n\n\treturn nil\n}", "title": "" }, { "docid": "25498cf58a412892d415330f45e4c3ae", "score": "0.5690471", "text": "func getAppForRefree(stub shim.ChaincodeStubInterface, refreeEmail string) ([]byte, error) {\n\tlogger.Info(\"getAppForRefree called\")\n\tvar recordList []string\n\tvar allApp []map[string]string\n\trecBytes, _ := stub.GetState(ALL_ELEMENENTS)\n\tjson.Unmarshal(recBytes, &recordList)\n\n\tfor _, value := range recordList {\n\t\tlogger.Info(\"inside getAppForRefree range func\")\n\t\trecBytes, _ := getAppById(stub, value)\n\t\tvar record map[string]string\n\t\tjson.Unmarshal(recBytes, &record)\n\n\t\tif record[\"referee1email\"] == refreeEmail {\n\t\t\trecord[\"applicationNumber\"] = value\n\t\t\tallApp = append(allApp, record)\n\t\t} else if record[\"referee2email\"] == refreeEmail {\n\t\t\trecord[\"applicationNumber\"] = value\n\t\t\tallApp = append(allApp, record)\n\t\t}\n\t}\n\toutputBytes, _ := json.Marshal(allApp)\n\treturn outputBytes, nil\n}", "title": "" }, { "docid": "0e7ada1291c31ed40aed34a7e76af97e", "score": "0.5688219", "text": "func (a *ApplicationAPI) Get(ctx context.Context, req *pb.GetApplicationRequest) (*pb.GetApplicationResponse, error) {\n\tif err := a.validator.Validate(ctx,\n\t\tauth.ValidateApplicationAccess(req.Id, auth.Read),\n\t); err != nil {\n\t\treturn nil, grpc.Errorf(codes.Unauthenticated, \"authentication failed: %s\", err)\n\t}\n\n\tapp, err := storage.GetApplication(config.C.PostgreSQL.DB, req.Id)\n\tif err != nil {\n\t\treturn nil, errToRPCError(err)\n\t}\n\tresp := pb.GetApplicationResponse{\n\t\tId: app.ID,\n\t\tName: app.Name,\n\t\tDescription: app.Description,\n\t\tOrganizationID: app.OrganizationID,\n\t\tServiceProfileID: app.ServiceProfileID,\n\t\tPayloadCodec: string(app.PayloadCodec),\n\t\tPayloadEncoderScript: app.PayloadEncoderScript,\n\t\tPayloadDecoderScript: app.PayloadDecoderScript,\n\t}\n\n\treturn &resp, nil\n}", "title": "" }, { "docid": "bec17f16e9cf33c63bcd72a09f00b74c", "score": "0.56852", "text": "func (k Keeper) GetAllApplications(ctx sdk.Context) (applications []types.Vote) {\n\tstore := ctx.KVStore(k.storeKey)\n\n\titerator := sdk.KVStorePrefixIterator(store, types.ApplicationPoolKey)\n\tdefer iterator.Close()\n\n\tfor ; iterator.Valid(); iterator.Next() {\n\t\tapplication := types.MustUnmarshalVote(k.cdc, iterator.Value())\n\t\tapplications = append(applications, application)\n\t}\n\n\treturn applications\n}", "title": "" }, { "docid": "38b477fe51a4a97b729e5d7e5752855f", "score": "0.5680785", "text": "func (am *AppchainManager) Appchains() (bool, []byte) {\n\tok, value := am.Query(PREFIX)\n\tif !ok {\n\t\treturn true, nil\n\t}\n\n\tret := make([]*Appchain, 0)\n\tfor _, data := range value {\n\t\tchain := &Appchain{}\n\t\tif err := json.Unmarshal(data, chain); err != nil {\n\t\t\treturn false, []byte(err.Error())\n\t\t}\n\t\tret = append(ret, chain)\n\t}\n\n\tdata, err := json.Marshal(ret)\n\tif err != nil {\n\t\treturn false, []byte(err.Error())\n\t}\n\treturn true, data\n}", "title": "" }, { "docid": "74289f15bfa698fedeb76065448e8f63", "score": "0.5673619", "text": "func (_CollateralAssetHolder *CollateralAssetHolderCallerSession) App() (common.Address, error) {\n\treturn _CollateralAssetHolder.Contract.App(&_CollateralAssetHolder.CallOpts)\n}", "title": "" }, { "docid": "4b929d306f3c853a155d4d2ba92f25f4", "score": "0.56557703", "text": "func GetAllApplications(application *[]Application, offset int, limit int) (int, error) {\n\tvar count = 0\n\tif err := config.DB.Model(&Application{}).Count(&count).Order(\"created_at desc\").Offset(offset).Limit(limit).Find(application).Error; err != nil {\n\t\treturn count, err\n\t}\n\treturn count, nil\n}", "title": "" }, { "docid": "be61a3f3dbc44911cc8fc8e8c04a7f8c", "score": "0.5647682", "text": "func (o ApplicationApiOutput) KnownClientApplications() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v ApplicationApi) []string { return v.KnownClientApplications }).(pulumi.StringArrayOutput)\n}", "title": "" }, { "docid": "4bd8f8b02d69b58a46175dd928c45ea9", "score": "0.564749", "text": "func GetCmdQueryApplications(queryRoute string, cdc *codec.Codec) *cobra.Command {\n\treturn &cobra.Command{\n\t\tUse: \"applications\",\n\t\tShort: \"Query the applications to become validator\",\n\t\tArgs: cobra.NoArgs,\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tcliCtx := context.NewCLIContext().WithCodec(cdc)\n\n\t\t\tres, _, err := cliCtx.QueryWithData(fmt.Sprintf(\"custom/%s/%s\", queryRoute, types.QueryApplications), nil)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"could not resolve %s \\n\", types.QueryApplications)\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\tvar out []types.Vote\n\t\t\tcdc.MustUnmarshalJSON(res, &out)\n\t\t\treturn cliCtx.PrintOutput(out)\n\t\t},\n\t}\n}", "title": "" }, { "docid": "8c122ea7d59b61b6601ee859d75738ae", "score": "0.56372094", "text": "func GetApps() []j {\n\trows := Query(\"SELECT * FROM apps;\")\n\tdefer rows.Close()\n\tresponse := make([]j, 0)\n\n\tfor rows.Next() {\n\t\tvar id, data string\n\n\t\terr := rows.Scan(&id, &data)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"Some error occurred: \", err, \"Possibly corrupted data skipping...\")\n\t\t\tcontinue\n\t\t}\n\n\t\tdataMap := Decrypt(data)\n\n\t\tdataMap[\"id\"] = id\n\t\tresponse = append(response, dataMap)\n\t}\n\n\treturn response\n}", "title": "" }, { "docid": "a625b60efbcfe5b69cca3bd8688b8751", "score": "0.56365246", "text": "func (m *TransitiveMembersRequestBuilder) Application()(*i2ff12bb0273f0398126710f0aaff76c96e0476da5e02f0aec51fe60c03355b90.ApplicationRequestBuilder) {\n return i2ff12bb0273f0398126710f0aaff76c96e0476da5e02f0aec51fe60c03355b90.NewApplicationRequestBuilderInternal(m.pathParameters, m.requestAdapter);\n}", "title": "" }, { "docid": "7c949649f5dab22e81237ef384c4c1eb", "score": "0.56026375", "text": "func AppList(w http.ResponseWriter, r *http.Request) {\n\tparams := mux.Vars(r)\n\n\t// Get business layer\n\tbusiness, err := getBusiness(r)\n\tif err != nil {\n\t\tRespondWithError(w, http.StatusInternalServerError, \"Apps initialization error: \"+err.Error())\n\t\treturn\n\t}\n\tnamespace := params[\"namespace\"]\n\n\t// Fetch and build apps\n\tappList, err := business.App.GetAppList(namespace, true)\n\tif err != nil {\n\t\thandleErrorResponse(w, err)\n\t\treturn\n\t}\n\n\tRespondWithJSON(w, http.StatusOK, appList)\n}", "title": "" }, { "docid": "8abd39fc11cb5cc5c9b45502da151eb6", "score": "0.55995095", "text": "func (svc *V2Service) Query(query *AppsQuery) ([]App, error) {\n\tresp, err := svc.Repository.Read(olhttp.OLHTTPRequest{\n\t\tURL: svc.Endpoint,\n\t\tHeaders: map[string]string{\"Content-Type\": \"application/json\"},\n\t\tAuthMethod: \"bearer\",\n\t\tPayload: query,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar apps []App\n\tjson.Unmarshal(resp, &apps)\n\n\treturn apps, nil\n}", "title": "" }, { "docid": "41b9938c9e5f23f3eede4d1f97bd6fcf", "score": "0.5593786", "text": "func ExampleApplicationsClient_Get() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armservicefabric.NewClientFactory(\"<subscription-id>\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tres, err := clientFactory.NewApplicationsClient().Get(ctx, \"resRg\", \"myCluster\", \"myApp\", nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\t// You could use response here. We use blank identifier for just demo purposes.\n\t_ = res\n\t// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t// res.ApplicationResource = armservicefabric.ApplicationResource{\n\t// \tName: to.Ptr(\"myCluster\"),\n\t// \tType: to.Ptr(\"applications\"),\n\t// \tEtag: to.Ptr(\"W/\\\"636462502180261859\\\"\"),\n\t// \tID: to.Ptr(\"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApp\"),\n\t// \tLocation: to.Ptr(\"eastus\"),\n\t// \tTags: map[string]*string{\n\t// \t},\n\t// \tProperties: &armservicefabric.ApplicationResourceProperties{\n\t// \t\tMaximumNodes: to.Ptr[int64](3),\n\t// \t\tMetrics: []*armservicefabric.ApplicationMetricDescription{\n\t// \t\t\t{\n\t// \t\t\t\tName: to.Ptr(\"metric1\"),\n\t// \t\t\t\tMaximumCapacity: to.Ptr[int64](3),\n\t// \t\t\t\tReservationCapacity: to.Ptr[int64](1),\n\t// \t\t\t\tTotalApplicationCapacity: to.Ptr[int64](5),\n\t// \t\t}},\n\t// \t\tMinimumNodes: to.Ptr[int64](1),\n\t// \t\tParameters: map[string]*string{\n\t// \t\t\t\"param1\": to.Ptr(\"value1\"),\n\t// \t\t},\n\t// \t\tRemoveApplicationCapacity: to.Ptr(false),\n\t// \t\tTypeVersion: to.Ptr(\"1.0\"),\n\t// \t\tUpgradePolicy: &armservicefabric.ApplicationUpgradePolicy{\n\t// \t\t\tApplicationHealthPolicy: &armservicefabric.ArmApplicationHealthPolicy{\n\t// \t\t\t\tConsiderWarningAsError: to.Ptr(true),\n\t// \t\t\t\tDefaultServiceTypeHealthPolicy: &armservicefabric.ArmServiceTypeHealthPolicy{\n\t// \t\t\t\t\tMaxPercentUnhealthyPartitionsPerService: to.Ptr[int32](0),\n\t// \t\t\t\t\tMaxPercentUnhealthyReplicasPerPartition: to.Ptr[int32](0),\n\t// \t\t\t\t\tMaxPercentUnhealthyServices: to.Ptr[int32](0),\n\t// \t\t\t\t},\n\t// \t\t\t\tMaxPercentUnhealthyDeployedApplications: to.Ptr[int32](0),\n\t// \t\t\t},\n\t// \t\t\tForceRestart: to.Ptr(false),\n\t// \t\t\tRollingUpgradeMonitoringPolicy: &armservicefabric.ArmRollingUpgradeMonitoringPolicy{\n\t// \t\t\t\tFailureAction: to.Ptr(armservicefabric.ArmUpgradeFailureActionRollback),\n\t// \t\t\t\tHealthCheckRetryTimeout: to.Ptr(\"00:10:00\"),\n\t// \t\t\t\tHealthCheckStableDuration: to.Ptr(\"00:05:00\"),\n\t// \t\t\t\tHealthCheckWaitDuration: to.Ptr(\"00:02:00\"),\n\t// \t\t\t\tUpgradeDomainTimeout: to.Ptr(\"1.06:00:00\"),\n\t// \t\t\t\tUpgradeTimeout: to.Ptr(\"01:00:00\"),\n\t// \t\t\t},\n\t// \t\t\tUpgradeMode: to.Ptr(armservicefabric.RollingUpgradeModeMonitored),\n\t// \t\t\tUpgradeReplicaSetCheckTimeout: to.Ptr(\"01:00:00\"),\n\t// \t\t},\n\t// \t\tProvisioningState: to.Ptr(\"Succeeded\"),\n\t// \t\tTypeName: to.Ptr(\"myAppType\"),\n\t// \t},\n\t// }\n}", "title": "" }, { "docid": "56fa34ed3258bb9c183385ff47cfafb5", "score": "0.55840164", "text": "func (_CollateralAssetHolder *CollateralAssetHolderSession) App() (common.Address, error) {\n\treturn _CollateralAssetHolder.Contract.App(&_CollateralAssetHolder.CallOpts)\n}", "title": "" }, { "docid": "e05b1d4e3d5001c204a25524f50c288e", "score": "0.55736953", "text": "func Lookup(kubeClient *kubernetes.Cluster, org, lookupApp string) (*Application, error) {\n\tapps, err := List(kubeClient, org)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, app := range apps {\n\t\tif app.Name == lookupApp {\n\t\t\treturn &app, nil // It's already \"Complete()\" by the List call above\n\t\t}\n\t}\n\n\treturn nil, nil\n}", "title": "" }, { "docid": "e88298afd3163a4af25b7e115c933872", "score": "0.5569964", "text": "func (o DeveloperOutput) Apps() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *Developer) pulumi.StringArrayOutput { return v.Apps }).(pulumi.StringArrayOutput)\n}", "title": "" }, { "docid": "a88ae515d739920877bbec9504d7d51d", "score": "0.5565097", "text": "func (a *PlaidApiService) ApplicationGet(ctx _context.Context) ApiApplicationGetRequest {\n\treturn ApiApplicationGetRequest{\n\t\tApiService: a,\n\t\tctx: ctx,\n\t}\n}", "title": "" }, { "docid": "2b03db2b3f2080d4478dcdf00ad7460d", "score": "0.55620164", "text": "func (s *Service) ListApp(c context.Context, t *model.AppListParams) (res []*model.App, total int64, err error) {\n\tif res, err = s.dao.ListApp(c, t); err != nil {\n\t\tlog.Error(\"s.dao.ListApp error (%v)\", err)\n\t\treturn\n\t}\n\t// output the data\n\ttotal = int64(len(res))\n\tstart := (t.PN - 1) * t.PS\n\tif start >= total {\n\t\tres = []*model.App{}\n\t\treturn\n\t}\n\tend := start + t.PS\n\tif end > total {\n\t\tend = total\n\t}\n\tres = res[start:end]\n\treturn\n}", "title": "" }, { "docid": "da512155c6288900ed366968ddedf4a3", "score": "0.5558845", "text": "func (store *managerStore) ListAllApplications() ([]*types.Application, error) {\n\tif cacheMgr.isOK {\n\t\treturn listCacheApplications()\n\t}\n\n\tclient := store.BkbcsClient.Applications(\"\")\n\tv2Apps, err := client.List(context.Background(), metav1.ListOptions{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tapps := make([]*types.Application, 0, len(v2Apps.Items))\n\tfor _, app := range v2Apps.Items {\n\t\tobj := app.Spec.Application\n\t\tobj.ResourceVersion = app.ResourceVersion\n\t\tapps = append(apps, &obj)\n\t}\n\treturn apps, nil\n}", "title": "" }, { "docid": "7b56ac2f3e51e643979a71388c1a12aa", "score": "0.55542845", "text": "func RetrieveApplicationsByName(ctx context.Context, c client.Client, applicationName string, namespace string) ([]ApplicationMeta, error) {\n\tvar applicationMetaList []ApplicationMeta\n\n\tif namespace == \"\" {\n\t\tnamespace = \"default\"\n\t}\n\n\tvar applicationList corev1alpha2.ApplicationConfigurationList\n\n\tif applicationName != \"\" {\n\t\tvar application corev1alpha2.ApplicationConfiguration\n\t\terr := c.Get(ctx, client.ObjectKey{Name: applicationName, Namespace: namespace}, &application)\n\n\t\tif err != nil {\n\t\t\treturn applicationMetaList, err\n\t\t}\n\n\t\tapplicationList.Items = append(applicationList.Items, application)\n\t} else {\n\t\terr := c.List(ctx, &applicationList)\n\t\tif err != nil {\n\t\t\treturn applicationMetaList, err\n\t\t}\n\t}\n\n\tfor _, a := range applicationList.Items {\n\t\tcomponentName := a.Spec.Components[0].ComponentName\n\n\t\tcomponent, err := GetComponent(ctx, c, componentName, namespace)\n\t\tif err != nil {\n\t\t\treturn applicationMetaList, err\n\t\t}\n\n\t\tvar workload corev1alpha2.WorkloadDefinition\n\t\tjson.Unmarshal(component.Spec.Workload.Raw, &workload)\n\t\tworkloadName := workload.TypeMeta.Kind\n\n\t\ttraitNames := GetTraitNamesByApplicationConfiguration(a)\n\n\t\tapplicationMetaList = append(applicationMetaList, ApplicationMeta{\n\t\t\tName: a.Name,\n\t\t\tWorkload: workloadName,\n\t\t\tTraits: traitNames,\n\t\t\tStatus: string(a.Status.Conditions[0].Status),\n\t\t\tCreatedTime: a.ObjectMeta.CreationTimestamp.String(),\n\t\t})\n\t}\n\n\treturn applicationMetaList, nil\n}", "title": "" }, { "docid": "a4f6dfe18fa2c7d9996c5693cc6751e5", "score": "0.5548935", "text": "func Get_app_list() {\n\n\tfor i,v := range apps {\n\t\tfmt.Printf(\"[ %s ] : %s\\n\", i, v.desp)\n\t}\n\n}", "title": "" }, { "docid": "d8ecb2a3f359afaf77a958ab54e4bc98", "score": "0.5542291", "text": "func (d *Apikey) ApplicationsLink() (bool, string) {\n return (d.Applications != nil), d.applications\n}", "title": "" }, { "docid": "c0510899d0df0de90408a64589f209a1", "score": "0.5540696", "text": "func (s *applicationLister) List(selector labels.Selector) (ret []*v2.Application, err error) {\n\terr = cache.ListAll(s.indexer, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v2.Application))\n\t})\n\treturn ret, err\n}", "title": "" }, { "docid": "7981055d1e76494638b64acbaf54f25b", "score": "0.5532975", "text": "func (a *Application) All(db *gorm.DB) (*[]Application, error) {\n\tvar err error\n\tapplications := []Application{}\n\terr = db.Debug().Model(&Application{}).Where(\"status >= ?\", 0).Find(&applications).Error\n\tif err != nil {\n\t\treturn &[]Application{}, err\n\t}\n\tfor i := range applications {\n\t\terr := db.Debug().Model(&User{}).Where(\"id = ?\", applications[i].ApplicantID).Take(&applications[i].Applicant).Error\n\t\tif err != nil {\n\t\t\treturn &[]Application{}, err\n\t\t}\n\t}\n\treturn &applications, nil\n}", "title": "" }, { "docid": "0a384239aea20edb25c4cd25acc83e2e", "score": "0.55209965", "text": "func appList(w http.ResponseWriter, r *http.Request, t auth.Token) error {\n\tctx := r.Context()\n\tfilter := &app.Filter{}\n\tif name := r.URL.Query().Get(\"name\"); name != \"\" {\n\t\tfilter.NameMatches = name\n\t}\n\tif platform := r.URL.Query().Get(\"platform\"); platform != \"\" {\n\t\tfilter.Platform = platform\n\t}\n\tif teamOwner := r.URL.Query().Get(\"teamOwner\"); teamOwner != \"\" {\n\t\tfilter.TeamOwner = teamOwner\n\t}\n\tif owner := r.URL.Query().Get(\"owner\"); owner != \"\" {\n\t\tfilter.UserOwner = owner\n\t}\n\tif pool := r.URL.Query().Get(\"pool\"); pool != \"\" {\n\t\tfilter.Pool = pool\n\t}\n\tlocked, _ := strconv.ParseBool(r.URL.Query().Get(\"locked\"))\n\tif locked {\n\t\tfilter.Locked = true\n\t}\n\tif status, ok := r.URL.Query()[\"status\"]; ok {\n\t\tfilter.Statuses = status\n\t}\n\tif tags, ok := r.URL.Query()[\"tag\"]; ok {\n\t\tfilter.Tags = tags\n\t}\n\tcontexts := permission.ContextsForPermission(t, permission.PermAppRead)\n\tcontexts = append(contexts, permission.ContextsForPermission(t, permission.PermAppReadInfo)...)\n\tif len(contexts) == 0 {\n\t\tw.WriteHeader(http.StatusNoContent)\n\t\treturn nil\n\t}\n\tapps, err := app.List(ctx, appFilterByContext(contexts, filter))\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(apps) == 0 {\n\t\tw.WriteHeader(http.StatusNoContent)\n\t\treturn nil\n\t}\n\tsimple, _ := strconv.ParseBool(r.URL.Query().Get(\"simplified\"))\n\textended, _ := strconv.ParseBool(r.URL.Query().Get(\"extended\"))\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tminiApps := make([]miniApp, len(apps))\n\tif simple {\n\t\tfor i, ap := range apps {\n\t\t\tur := app.AppUnitsResponse{Units: nil, Err: nil}\n\t\t\tminiApps[i], err = minifyApp(ap, ur, extended)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn json.NewEncoder(w).Encode(miniApps)\n\t}\n\tappUnits, err := app.Units(ctx, apps)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor i, app := range apps {\n\t\tminiApps[i], err = minifyApp(app, appUnits[app.Name], extended)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn json.NewEncoder(w).Encode(miniApps)\n}", "title": "" }, { "docid": "c258b48df98162ad51a4ed08f27ae0e3", "score": "0.5512178", "text": "func (dbobj dbcon) listUserApps(userTOKEN string, conf Config) ([]byte, error) {\n\t//_, err = collection.InsertOne(context.TODO(), bson.M{\"name\": \"The Go Language2\", \"genre\": \"Coding\", \"authorId\": \"4\"})\n\trecord, err := dbobj.lookupUserRecord(userTOKEN)\n\tif record == nil || err != nil {\n\t\t// not found\n\t\treturn nil, err\n\t}\n\tvar result []string\n\tif conf.Generic.UseSeparateAppTables == true {\n\t\tallCollections, err := dbobj.store.GetAllTables()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tvar result []string\n\t\tfor _, colName := range allCollections {\n\t\t\tif strings.HasPrefix(colName, \"app_\") {\n\t\t\t\trecord, err := dbobj.store.GetRecordFromTable(colName, \"token\", userTOKEN)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif record != nil {\n\t\t\t\t\tresult = append(result, colName[4:])\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\trecords, err := dbobj.store.GetList(storage.TblName.Userapps, \"token\", userTOKEN, 0, 0, \"appname\")\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tcount := len(records)\n\t\tif count == 0 {\n\t\t\treturn []byte(\"[]\"), nil\n\t\t}\n\t\tfor _, rec := range records {\n\t\t\tappname := rec[\"appname\"].(string)\n\t\t\tresult = append(result, appname)\n\t\t}\n\t}\n\tif len(result) == 0 {\n\t\treturn []byte(\"[]\"), nil\n\t}\n\tresultJSON, err := json.Marshal(result)\n\treturn resultJSON, err\n}", "title": "" }, { "docid": "b4df36ae677047b2c2de37b7d1cba857", "score": "0.5507292", "text": "func (obj *program) Application() Application {\n\treturn obj.app\n}", "title": "" }, { "docid": "11a8a875ac46e81d34ae7ad7f3cfba45", "score": "0.55003256", "text": "func Query(eurekaURL string, appName string) ([]string, error) {\n\t// url := \"http://20.26.33.122:32010/eureka/apps/com.automationrhapsody.eureka.app/WKS-SOF-L011\"\n\n\turl := eurekaURL + \"/eureka/apps/\" + appName\n\tlog.I(\"Query:\", url)\n\n\tclient := &http.Client{}\n\trequest, e := http.NewRequest(\"GET\", url, nil)\n\trequest.Header.Add(\"Accept\", \"text/html,application/json;q=0.9,*/*;q=0.8\")\n\n\tif e != nil {\n\t\tlog.E(e)\n\t\treturn nil, e\n\t}\n\n\tresp, e := client.Do(request)\n\tif e != nil {\n\t\treturn nil, e\n\t}\n\tdefer resp.Body.Close()\n\n\tlog.I(\"resp: \", resp.Status)\n\n\tbody, e := ioutil.ReadAll(resp.Body)\n\tif e != nil {\n\t\treturn nil, e\n\t}\n\tif len(body) != 0 {\n\t\tlog.E(string(body))\n\t}\n\n\tapp := APP{}\n\te = json.ToObj(body, &app)\n\tif e != nil {\n\t\tlog.E(e)\n\t}\n\t// log.E(\"Show IP:\", app.Application.Name)\n\n\tcount := len(app.Application.Instance)\n\tresult := make([]string, count)\n\n\tfor i := 0; i < count; i++ {\n\t\tresult[i] = app.Application.Instance[i].HostName + \":\" + strconv.Itoa(app.Application.Instance[i].Port.Pt)\n\t}\n\n\treturn result, nil\n}", "title": "" }, { "docid": "f669f8bd8e2133441566e3494dca7890", "score": "0.54959655", "text": "func (dm *DataManager) QueryAppList(ctx context.Context, req *pb.QueryAppListReq) (*pb.QueryAppListResp, error) {\n\trtime := time.Now()\n\tlogger.V(2).Infof(\"QueryAppList[%d]| input[%+v]\", req.Seq, req)\n\tresponse := &pb.QueryAppListResp{Seq: req.Seq, ErrCode: pbcommon.ErrCode_E_OK, ErrMsg: \"OK\"}\n\n\tdefer func() {\n\t\tcost := dm.collector.StatRequest(\"QueryAppList\", response.ErrCode, rtime, time.Now())\n\t\tlogger.V(2).Infof(\"QueryAppList[%d]| output[%dms][%+v]\", req.Seq, cost, response)\n\t}()\n\n\taction := appaction.NewListAction(dm.viper, dm.smgr, req, response)\n\tdm.executor.Execute(action)\n\n\treturn response, nil\n}", "title": "" }, { "docid": "a92195a67f0a564bf5372954ebff6240", "score": "0.5481845", "text": "func (a *ApplicationsApiService) ApplicationsPost(ctx _context.Context, localVarOptionals *ApplicationsPostOpts) (Application, *_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = _nethttp.MethodPost\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue Application\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/applications\"\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{\"application/json\"}\n\n\t// set Content-Type header\n\tlocalVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)\n\tif localVarHTTPContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHTTPContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHTTPHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\n\tif localVarHTTPHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHTTPHeaderAccept\n\t}\n\t// body params\n\tif localVarOptionals != nil && localVarOptionals.Body.IsSet() {\n\t\tlocalVarOptionalBody, localVarOptionalBodyok := localVarOptionals.Body.Value().(ApplicationRequest)\n\t\tif !localVarOptionalBodyok {\n\t\t\treturn localVarReturnValue, nil, reportError(\"body should be ApplicationRequest\")\n\t\t}\n\t\tlocalVarPostBody = &localVarOptionalBody\n\t}\n\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tif localVarHTTPResponse.StatusCode >= 300 {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHTTPResponse.Status,\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 201 {\n\t\t\tvar v Application\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\tif err != nil {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: err.Error(),\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\treturn localVarReturnValue, localVarHTTPResponse, nil\n}", "title": "" } ]
72c24554059fb7abfa29de965ce45036
ArrayLenEquals fails if the path is not an array type with a length matching the provided len
[ { "docid": "73dd176b67b3f0244e4d92ae38de1de8", "score": "0.7126142", "text": "func ArrayLenEquals(l int) CheckFunc {\n\treturn func(n *node) (string, bool) {\n\t\tif n.typ != typeArray {\n\t\t\treturn \"ArrayLenEquals: not array type\", false\n\t\t}\n\t\tif n.arrayLen != l {\n\t\t\treturn fmt.Sprintf(\"ArrayLenEquals: len != %d\", l), false\n\t\t}\n\t\treturn \"\", true\n\t}\n}", "title": "" } ]
[ { "docid": "3839408e33b6a1be7be90c029cf6daf5", "score": "0.6309233", "text": "func arrLen(env *Environ, expr *parser.Node) object.Object {\n\tarrObj := eval(env, expr)\n\tif arrObj.Type() != object.ArrayType {\n\t\treturn &object.Error{Err: fmt.Errorf(\"expected array, got %v\", arrObj.Type())}\n\t}\n\tarr := arrObj.(*object.Array)\n\treturn &object.Integer{Value: int64(len(arr.Value))}\n}", "title": "" }, { "docid": "86e6323792ada9a4b614e1dc400ff1d3", "score": "0.62363005", "text": "func JsonPathArrayLength(args []string, item *gabs.Container) (interface{}, error) {\n\treturn len(item.Path(args[0]).Children()), nil\n}", "title": "" }, { "docid": "b6d58cf3dad95bdb8e7e1755cd61dea1", "score": "0.6148167", "text": "func matchLen(x, y string) int {\n\tif pathKind(x) != pathKind(y) {\n\t\treturn -1\n\t}\n\n\ti := 0\n\tfor i < len(x) && i < len(y) && x[i] == y[i] {\n\t\ti++\n\t}\n\treturn i\n}", "title": "" }, { "docid": "bd56dc80b05b3c21c521fd998225b909", "score": "0.5996627", "text": "func (a *AnyAssertions) HasLen(expected int) bool {\n\tlength := reflect.ValueOf(a.actual).Len()\n\tif expected == length {\n\t\treturn true\n\t}\n\terr := fmt.Errorf(\"HasLen assertion failed. \\n Expected: \\n\\t\\t %d \\n Actual: \\n\\t\\t %d\", expected, length)\n\tcurrentT.Error(err)\n\treturn false\n}", "title": "" }, { "docid": "1d70113d63669b00291c8952156507e3", "score": "0.59609026", "text": "func (a *Array) Len() int64 {}", "title": "" }, { "docid": "cbac80f956540c38c917bf57eb6aacf4", "score": "0.5947276", "text": "func checkArrayLengths(rval reflect.Value, abiType abi.Type) error {\n\tif rval.Kind() == reflect.Interface {\n\t\trval = rval.Elem()\n\t}\n\n\tswitch abiType.T {\n\tcase abi.SliceTy:\n\t\tswitch rval.Kind() {\n\t\tcase reflect.Slice, reflect.Array:\n\t\t\tfor i := 0; i < rval.Len(); i++ {\n\t\t\t\terr := checkArrayLengths(rval.Index(i), *abiType.Elem)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Sprintf(\"invariant violation: abi specifies slice, got %T\", rval.Interface()))\n\t\t}\n\tcase abi.ArrayTy:\n\t\tswitch rval.Kind() {\n\t\tcase reflect.Slice, reflect.Array:\n\t\t\tif abiType.Size != rval.Len() {\n\t\t\t\treturn errors.Wrapf(ErrBadInput, \"ETHABIEncode: input array length does not match ABI type\")\n\t\t\t}\n\t\t\tfor i := 0; i < rval.Len(); i++ {\n\t\t\t\terr := checkArrayLengths(rval.Index(i), *abiType.Elem)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Sprintf(\"invariant violation: abi specifies array, got %T (%v)\", rval.Interface(), rval.Kind()))\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "b358468ed59cf10f008c89e16f19854c", "score": "0.59258187", "text": "func LenArr(rt *Runtime, i int64) int64 {\n\treturn int64(len(rt.Objects[i].([]int64)))\n}", "title": "" }, { "docid": "375047a1405f6524dfcd2c691de25f1f", "score": "0.5765372", "text": "func (g *Container) ArrayOfSizeP(size int, path string) (*Container, error) {\n\treturn g.ArrayOfSize(size, DotPathToSlice(path)...)\n}", "title": "" }, { "docid": "7889dcce0abb6b08c9e35b689d79a4d9", "score": "0.5758761", "text": "func (arr ArrDot) Len() int {\n\treturn len(arr)\n}", "title": "" }, { "docid": "273fb6df81c5c60b7199d878157c310d", "score": "0.57470745", "text": "func (r *RefExp) ArrayLength() int {\n\tif r == nil || len(r.MergeOver) == 0 {\n\t\treturn -1\n\t}\n\treturn r.MergeOver[0].ArrayLength()\n}", "title": "" }, { "docid": "741cc925b8d9706574f7ba16ed0fb8df", "score": "0.5725984", "text": "func Len(t *testing.T, got interface{}, exp int, args ...interface{}) {\n\tequal(t, Length(got), exp, 1, args...)\n}", "title": "" }, { "docid": "4380d241456d9c53e1e447999e90259a", "score": "0.57211155", "text": "func ArrayLenGT(l int) CheckFunc {\n\treturn func(n *node) (string, bool) {\n\t\tif n.typ != typeArray {\n\t\t\treturn \"ArrayLenGT: not array type\", false\n\t\t}\n\t\tif n.arrayLen > l {\n\t\t\treturn \"\", true\n\t\t}\n\t\treturn fmt.Sprintf(\"ArrayLenGT: not greater than %d\", l), false\n\t}\n}", "title": "" }, { "docid": "f62bb2ad286750751fbadfadc9e13764", "score": "0.57206655", "text": "func (a BucketByPath) Len() int { return len(a) }", "title": "" }, { "docid": "acecd35049966933ed4db38535f79f8b", "score": "0.5705508", "text": "func ArrayLenGTE(l int) CheckFunc {\n\treturn func(n *node) (string, bool) {\n\t\tif n.typ != typeArray {\n\t\t\treturn \"ArrayLenGTE: not array type\", false\n\t\t}\n\t\tif n.arrayLen >= l {\n\t\t\treturn \"\", true\n\t\t}\n\t\treturn fmt.Sprintf(\"ArrayLenGTE: not greater than or equal to %d\", l), false\n\t}\n}", "title": "" }, { "docid": "b7dfd182d863858846c09a3b949b3202", "score": "0.56216204", "text": "func (r *ReferenceMappingSource) ArrayLength() int {\n\treturn r.Ref.ArrayLength()\n}", "title": "" }, { "docid": "1e94c649a18e809f4995357f7c264206", "score": "0.56026435", "text": "func ArrayLenLTE(l int) CheckFunc {\n\treturn func(n *node) (string, bool) {\n\t\tif n.typ != typeArray {\n\t\t\treturn \"ArrayLenLTE: not array type\", false\n\t\t}\n\t\tif n.arrayLen <= l {\n\t\t\treturn \"\", true\n\t\t}\n\t\treturn fmt.Sprintf(\"ArrayLenLTE: not less than or equal to %d\", l), false\n\t}\n}", "title": "" }, { "docid": "9d66a546fc220ac7295b6cf82663b0fa", "score": "0.5577201", "text": "func len2(x, y []byte) int {\n\tl := len(x)\n\tif len(y) != l {\n\t\tpanic(\"input slices must be the same length\")\n\t}\n\treturn l\n}", "title": "" }, { "docid": "e1bb315d51e8bd252443418d45f1823e", "score": "0.55767053", "text": "func EqualLengths(slices ...[]complex128) bool {\n\t// This length check is needed: http://play.golang.org/p/sdty6YiLhM\n\tif len(slices) == 0 {\n\t\treturn true\n\t}\n\tl := len(slices[0])\n\tfor i := 1; i < len(slices); i++ {\n\t\tif len(slices[i]) != l {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "title": "" }, { "docid": "6311fa2c45faf30459007b420bbae421", "score": "0.55273753", "text": "func (a KVArray) Len() int { return len(a.raw) }", "title": "" }, { "docid": "81de2fdccb4fc9e74246bf21f7762646", "score": "0.54921377", "text": "func ArrayLenLT(l int) CheckFunc {\n\treturn func(n *node) (string, bool) {\n\t\tif n.typ != typeArray {\n\t\t\treturn \"ArrayLenLT: not array type\", false\n\t\t}\n\t\tif n.arrayLen < l {\n\t\t\treturn \"\", true\n\t\t}\n\t\treturn fmt.Sprintf(\"ArrayLenLT: not less than %d\", l), false\n\t}\n}", "title": "" }, { "docid": "38057d2ba8d2153cc24f4e99dedbd867", "score": "0.5459059", "text": "func assertLen(t *testing.T, object interface{}, expected int) {\n\tt.Helper()\n\tactual := reflect.ValueOf(object).Len()\n\tif actual != expected {\n\t\tt.Fatalf(\"lengths were not equal: \\n\"+\n\t\t\t\"expected: %d\\n\"+\n\t\t\t\"actual : %d\", expected, actual)\n\t}\n}", "title": "" }, { "docid": "fc8c98556ec5ce241915d3e7f2dbbdd6", "score": "0.54575014", "text": "func (c extArr) Len() int { return len(c) }", "title": "" }, { "docid": "cf7bc716001e52e9d702946a128cbf9c", "score": "0.5444198", "text": "func ExampleSliceLength() {\n\tassert := assert.To(nil)\n\tvar nilSlice []string\n\temptySlice := []string{}\n\tnonEmptySlice := []string{\"one\"}\n\tassert.For(\"nil is empty\").ThatSlice(nilSlice).IsEmpty()\n\tassert.For(\"nil is not empty\").ThatSlice(nilSlice).IsNotEmpty()\n\tassert.For(\"nil is length 0\").ThatSlice(nilSlice).IsLength(0)\n\tassert.For(\"nil is length 1\").ThatSlice(nilSlice).IsLength(1)\n\tassert.For(\"{} is empty\").ThatSlice(emptySlice).IsEmpty()\n\tassert.For(\"{} is not empty\").ThatSlice(emptySlice).IsNotEmpty()\n\tassert.For(\"{} is length 0\").ThatSlice(emptySlice).IsLength(0)\n\tassert.For(\"{} is length 1\").ThatSlice(emptySlice).IsLength(1)\n\tassert.For(\"values is empty\").ThatSlice(nonEmptySlice).IsEmpty()\n\tassert.For(\"values is not empty\").ThatSlice(nonEmptySlice).IsNotEmpty()\n\tassert.For(\"values is length 0\").ThatSlice(nonEmptySlice).IsLength(0)\n\tassert.For(\"values is length 1\").ThatSlice(nonEmptySlice).IsLength(1)\n\t// Output:\n\t// Error:nil is not empty\n\t// Got 0\n\t// Expect length > 0\n\t// Error:nil is length 1\n\t// Got 0\n\t// Expect length == 1\n\t// Error:{} is not empty\n\t// Got 0\n\t// Expect length > 0\n\t// Error:{} is length 1\n\t// Got 0\n\t// Expect length == 1\n\t// Error:values is empty\n\t// Got 1\n\t// Expect is empty\n\t// Error:values is length 0\n\t// Got 1\n\t// Expect length == 0\n}", "title": "" }, { "docid": "747ab74f129c70db2628fb8ed885508b", "score": "0.5408397", "text": "func Length(length int) *charmset.MatcherType {\n\treturn charmset.NewMatcher(\n\t\tfmt.Sprintf(\"length equal to %d\", length),\n\t\tfunc(actual interface{}) error {\n\t\t\tactualValue := reflect.ValueOf(actual)\n\t\t\tswitch actualValue.Kind() {\n\t\t\tcase reflect.Array, reflect.Slice, reflect.Map, reflect.String:\n\t\t\t\tactualLength := actualValue.Len()\n\t\t\t\tif actualLength == length {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\treturn fmt.Errorf(\"length was <%v>\", actualLength)\n\t\t\tdefault:\n\t\t\t\treturn errors.New(\"was not a array, slice, map or string\")\n\t\t\t}\n\t\t},\n\t)\n}", "title": "" }, { "docid": "152264d2ac21633607f23b4bb87d8c8c", "score": "0.53745735", "text": "func checkArrayQueueSize(q *ArrayQueue[int], expect int) {\n\tif q.Len() != expect {\n\t\tpanic(fmt.Sprintf(\"size check failed, got %d, expect %d\", q.Len(), expect))\n\t}\n}", "title": "" }, { "docid": "edbeb9fa76ac50af66d8ce3469af4f8f", "score": "0.536804", "text": "func TestFindListElementHasMaxLength1Case2(t *testing.T) {\n\tassert := assert.New(t)\n\tlistElementHasMaxLength, _ := FindListElementHasMaxLength1([]string{})\n\tassert.ElementsMatch(listElementHasMaxLength, []string{})\n}", "title": "" }, { "docid": "aeee9d7fddfb44e4e53e3a7e039e6cee", "score": "0.5352971", "text": "func (a *ImmutableArray) Len() (uint16, error) {\n\tv, err := a.kvr.Get(a.getSizeKey())\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tif v == nil {\n\t\treturn 0, nil\n\t}\n\treturn util.MustUint16From2Bytes(v), nil\n}", "title": "" }, { "docid": "e0daff821b7a2c338c0ac1031086f555", "score": "0.5348498", "text": "func (p *PropertyJsonPointer) EqualsPath(other []string) bool {\n\tif p == nil || *p == \"\" {\n\t\treturn false\n\t}\n\n\tpath := p.Path()\n\n\tif len(path) != len(other) {\n\t\treturn false\n\t}\n\n\tfor i, segment := range path {\n\t\tif segment != other[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "title": "" }, { "docid": "1518275cff8cb4a60d35f2f7458cbf4e", "score": "0.530626", "text": "func Len(in interface{}) int {\n\tin = typeutil.ResolveValue(in)\n\n\tif typeutil.IsKind(in, reflect.Array, reflect.Slice, reflect.String) {\n\t\tinV := reflect.ValueOf(in)\n\t\treturn inV.Len()\n\t}\n\n\treturn 0\n}", "title": "" }, { "docid": "1fb07df621e77f4cb305b6adfd8d64d8", "score": "0.5287601", "text": "func (aa AssetArray) Len() int { return len(aa) }", "title": "" }, { "docid": "f90e85d40f631d3a2990e233053dcd39", "score": "0.52786344", "text": "func (v *ArrayValue) Len() int\t{ return v.typ.(*ArrayType).Len() }", "title": "" }, { "docid": "d42deb169b67e21fd2ad9966793f0550", "score": "0.52775764", "text": "func checkSameSize(values ...[]float64) {\n\tif len(values) < 2 {\n\t\treturn\n\t}\n\n\tn := len(values[0])\n\n\tfor i := 1; i < len(values); i++ {\n\t\tif len(values[i]) != n {\n\t\t\tpanic(\"not all same size\")\n\t\t}\n\t}\n}", "title": "" }, { "docid": "89fb1a7be0d2110fa295ed08f866e9b2", "score": "0.5272913", "text": "func (p LocalPath) Len() int { return len(p) }", "title": "" }, { "docid": "b7799f5a2803df1e7e6618d6ce87ae29", "score": "0.5266079", "text": "func (asserter Asserter) Len(obj any, length int, a ...any) {\n\tok, l := getLen(obj)\n\tif !ok {\n\t\tpanic(\"cannot get length\")\n\t}\n\n\tif l != length {\n\t\tdefMsg := fmt.Sprintf(\"got %d, want %d\", l, length)\n\t\tasserter.reportAssertionFault(defMsg, a...)\n\t}\n}", "title": "" }, { "docid": "fe5b342645dcf079b1b15c0adcb184c5", "score": "0.52654", "text": "func NotLen(t *testing.T, got interface{}, exp int, args ...interface{}) {\n\tnotEqual(t, Length(got), exp, 1, args...)\n}", "title": "" }, { "docid": "4997ea738767b8c662417f8633bf029d", "score": "0.5264278", "text": "func CheckLen(expected int, args []string) error {\n\tif len(args) < expected {\n\t\tmes := fmt.Sprintf(\n\t\t\t\"not enough number of arguments: %d given, %d expected\",\n\t\t\tlen(args),\n\t\t\texpected,\n\t\t)\n\t\treturn errors.New(mes)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "98219ac15256153184b1cda74915c2ed", "score": "0.5247432", "text": "func TestFindListElementHasMaxLength2Case2(t *testing.T) {\n\tassert := assert.New(t)\n\tlistElementHasMaxLength, _ := FindListElementHasMaxLength2([]string{})\n\tassert.ElementsMatch(listElementHasMaxLength, []string{})\n}", "title": "" }, { "docid": "748f1429b6af6b0e9e40a5ba5f55aeb1", "score": "0.52433234", "text": "func (paths *blockTarPaths) Len() int {\n\treturn len(*paths)\n}", "title": "" }, { "docid": "5fd8a7fe9f0f834b470e90e3bb2b4e7d", "score": "0.52353954", "text": "func EqualsArrays(a []model.Node, b []model.Node) bool {\n\n\tvar al = len(a)\n\tvar bl = len(b)\n\n\tif al != bl {\n\t\treturn false\n\t}\n\n\tfor i := 0; i < al; i++ {\n\t\tif a[i] != b[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n\n}", "title": "" }, { "docid": "ab924a6691727669e904a6642d9c2496", "score": "0.52348906", "text": "func (p pathSet) Len() int { return len(p) }", "title": "" }, { "docid": "3e91c7f301f0525a35e3865f8e9f2b81", "score": "0.523332", "text": "func arrayLengthCombination(x *gen.Type, y *gen.Type) bool {\n\treturn x.PointerLevel == 1 && y.PointerLevel == 0 &&\n\t\t!gen.IsInteger(x) && gen.IsInteger(y)\n}", "title": "" }, { "docid": "2012f769f73570cc278430513085a925", "score": "0.52250856", "text": "func Len(t *testing.T, obj interface{}, l int) {\n\tt.Helper()\n\n\tobjV := reflect.ValueOf(obj)\n\tif objV.Kind() == reflect.Slice {\n\t\tif objV.Len() != l {\n\t\t\tt.Fatalf(\"Length of array is %v, but it should be %v\", objV.Len(), l)\n\t\t}\n\t} else if objV.Kind() == reflect.Map {\n\t\tif objV.Len() != l {\n\t\t\tt.Fatalf(\"Length of map is %v, but it should be %v\", objV.Len(), l)\n\t\t}\n\t} else {\n\t\tt.Fatalf(\"Second argument must be a slice or a map, and not %v\", objV.Kind())\n\t}\n}", "title": "" }, { "docid": "5f7d733db861ea0f6adcbc6ff5e745d2", "score": "0.52237105", "text": "func EqualsString(arr1, arr2 []string) bool {\n if len(arr1) != len(arr2) {\n return false\n }\n if (arr1 == nil) != (arr2 == nil) {\n return false\n }\n arr2 = arr2[:len(arr1)]\n for i, v := range arr1 {\n if v != arr2[i] {\n return false\n }\n }\n return true\n}", "title": "" }, { "docid": "409f55207e749ecf3b1aecfd5ee50b18", "score": "0.5210026", "text": "func IsArray(ty string) bool {\n\treturn strings.HasPrefix(ty, \"[]\")\n}", "title": "" }, { "docid": "1323f38d31ea6c091182f93623aefcaf", "score": "0.5204687", "text": "func isDataEqual(a, b []byte) bool {\r\n\tif len(a) != len(b) {\r\n\t\treturn false // the length of the slices to not match\r\n\t}\r\n\tfor i := range a { // the arrays have the same length, so we can index over either\r\n\t\tif a[i] != b[i] { // this byte is different\r\n\t\t\treturn false\r\n\t\t}\r\n\t}\r\n\t// everything matched\r\n\treturn true\r\n}", "title": "" }, { "docid": "2db517e540125b77f12337548851160b", "score": "0.52037966", "text": "func TestFindListElementHasMaxLength2Case1(t *testing.T) {\n\tassert := assert.New(t)\n\tlistElementHasMaxLength, _ := FindListElementHasMaxLength2([]string{\"aba\", \"aa\", \"ad\", \"c\", \"vcd\"})\n\tassert.ElementsMatch(listElementHasMaxLength, []string{\"aba\", \"vcd\"})\n}", "title": "" }, { "docid": "f75349b917510e7c0c0e8f046b46f30c", "score": "0.518708", "text": "func (p *PatchableValues) ArrayCount(path string) (int, error) {\n\tv := p.values.Get(path)\n\tif !v.IsArray() {\n\t\treturn 0, fmt.Errorf(\"value at %q path is not an array\", path)\n\t}\n\n\treturn len(v.Array()), nil\n}", "title": "" }, { "docid": "8d5faebb8b19a0b1eaae10835e1f2b27", "score": "0.5180953", "text": "func StrEnsureLen(ref *[]string, length int) {\r\n\tif len(*ref) < length {\r\n\t\tStrSetLen(ref, length)\r\n\t}\r\n}", "title": "" }, { "docid": "c43054d69cd25580b162d60f1f88af80", "score": "0.51782703", "text": "func (diff *ArrayDiff) Len() int {\n\tlength := 0\n\tfor i := range diff.Adds {\n\t\tif i+1 > length {\n\t\t\tlength = i + 1\n\t\t}\n\t}\n\tfor i := range diff.Deletes {\n\t\tif i+1 > length {\n\t\t\tlength = i + 1\n\t\t}\n\t}\n\tfor i := range diff.Sames {\n\t\tif i+1 > length {\n\t\t\tlength = i + 1\n\t\t}\n\t}\n\tfor i := range diff.Updates {\n\t\tif i+1 > length {\n\t\t\tlength = i + 1\n\t\t}\n\t}\n\treturn length\n}", "title": "" }, { "docid": "496523160ef9cb7974c080bd86733c37", "score": "0.51731044", "text": "func sliceDeepEq(a, b [][]string) bool {\n\tif len(a) != len(b) {\n\t\treturn false\n\t}\n\tcount := 0\n\tseen := map[string]struct{}{}\n\tfor i, vs := range a {\n\t\tif len(vs) != len(b[i]) {\n\t\t\treturn false\n\t\t}\n\t\tfor _, v := range vs {\n\t\t\tcount++\n\t\t\tseen[v] = struct{}{}\n\t\t}\n\t}\n\tfor _, vs := range b {\n\t\tfor _, v := range vs {\n\t\t\tseen[v] = struct{}{}\n\t\t}\n\t}\n\treturn len(seen) == count\n}", "title": "" }, { "docid": "16607650ce66bc620c65b7bb552da6f8", "score": "0.5162861", "text": "func (g *Container) ArrayOfSize(size int, hierarchy ...string) (*Container, error) {\n\ta := make([]interface{}, size)\n\treturn g.Set(a, hierarchy...)\n}", "title": "" }, { "docid": "30cca76e4ac4bcfd8d0f9303bf88cf96", "score": "0.51528937", "text": "func execLen(state *ExecutionState, instr *ssa.Call) error {\n\t_, args := state.ExtractCall(instr)\n\targ := args[0].(*Array)\n\n\tswitch typ := instr.Call.Args[0].Type().(type) {\n\tcase *types.Slice:\n\t\tv, ok := state.selectIntAt(arg, 1).(*ConstantExpr)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"glee: len() expects constant slice len\")\n\t\t}\n\t\tstate.Frame().bind(instr, v)\n\t\treturn nil\n\tcase *types.Basic:\n\t\tstate.Frame().bind(instr, NewConstantExpr64(uint64(arg.Size)))\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"glee: invalid len() arg type: %s\", typ)\n\t}\n}", "title": "" }, { "docid": "4bbb33e6f87e4dea36f890022c107874", "score": "0.514035", "text": "func hasSameLength(a, b string) bool {\n\treturn len(a) == len(b)\n}", "title": "" }, { "docid": "003508e8f311c4e1de42fc558083fc18", "score": "0.513912", "text": "func (walker *MapWalker) GetMaxArrayLength() int { return walker.arrayLength }", "title": "" }, { "docid": "ec92b77efff285b281b170a5d6958b16", "score": "0.51340586", "text": "func (eq EqSlice) Len() int {\n\treturn len(eq.slice)\n}", "title": "" }, { "docid": "f3bf16965592e0bfa10362341a121346", "score": "0.5129959", "text": "func TestFindListElementHasMaxLength1Case1(t *testing.T) {\n\tassert := assert.New(t)\n\tlistElementHasMaxLength, _ := FindListElementHasMaxLength1([]string{\"aba\", \"aa\", \"ad\", \"c\", \"vcd\"})\n\tassert.ElementsMatch(listElementHasMaxLength, []string{\"aba\", \"vcd\"})\n}", "title": "" }, { "docid": "90ada14fb35ac61444d191b670ebb54d", "score": "0.5127943", "text": "func ExampleSliceDeepEquals() {\n\t// TODO: slices of a more complext type\n\tassert := assert.To(nil)\n\tslice := []string{\"a1\", \"a2\"}\n\ttheSame := []string{\"a1\", \"a2\"}\n\tlonger := []string{\"a1\", \"a2\", \"a3\"}\n\tdifferent := []string{\"a1\", \"a3\"}\n\tassert.For(\"the same\").ThatSlice(slice).DeepEquals(theSame)\n\tassert.For(\"longer\").ThatSlice(slice).DeepEquals(longer)\n\tassert.For(\"different\").ThatSlice(slice).DeepEquals(different)\n\t// Output:\n\t// Error:longer\n\t// 0 string `a1` ;\n\t// 1 string `a2` ;\n\t// - 2 ==> string `a3`\n\t// Error:different\n\t// 0 string `a1` ;\n\t// * 1 string `a2` ==> string `a3`\n}", "title": "" }, { "docid": "9241d43dde44e6f558d6232ab6d85c4c", "score": "0.51155734", "text": "func areArraysEquals(a, b [][]int) bool {\n\treturn reflect.DeepEqual(a, b)\n}", "title": "" }, { "docid": "06152856d6718ceb001162db87b31c72", "score": "0.50935096", "text": "func (s LtOrEqSlice) Len() int {\n\treturn s.LtSlice.Len()\n}", "title": "" }, { "docid": "2d67ba269716f66e07f0791970c64983", "score": "0.5087585", "text": "func areSlicesEqual(a []byte, b []byte) bool {\n\n\t/*\n\t * Check whether the two slices are of the same size.\n\t */\n\tif len(a) != len(b) {\n\t\treturn false\n\t} else {\n\t\tc := true\n\n\t\t/*\n\t\t * Iterate over the arrays to compare values.\n\t\t */\n\t\tfor i, elem := range a {\n\t\t\tc = c && (elem == b[i])\n\t\t}\n\n\t\treturn c\n\t}\n\n}", "title": "" }, { "docid": "3b871e6224fcb21a95ab74605498b88e", "score": "0.5084265", "text": "func (arr Array) Equal(other Value) bool {\n\tswitch other := other.(type) {\n\tcase Array:\n\t\treturn termSliceEqual(arr, other)\n\t}\n\treturn false\n}", "title": "" }, { "docid": "a677e6354579418cf62a564c33fb155f", "score": "0.50817436", "text": "func TestEnsurePrivateKeySizePadsLessThanRequiredSizeArrays(t *testing.T) {\n\tshortByteArray := make([]byte, ecdsaPrivateKeySize/2)\n\tfor i := range shortByteArray {\n\t\tshortByteArray[i] = byte(1)\n\t}\n\n\texpected := append(\n\t\tmake([]byte, ecdsaPrivateKeySize-ecdsaPrivateKeySize/2),\n\t\tshortByteArray...)\n\n\tresult := EnsurePrivateKeySize(shortByteArray)\n\trequire.True(t, reflect.DeepEqual(expected, result))\n}", "title": "" }, { "docid": "ce5710736f30ba497ac8fa3811c7f484", "score": "0.5073424", "text": "func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) {\n\tif !assert.Len(t, object, length, msgAndArgs...) {\n\t\tt.FailNow()\n\t}\n}", "title": "" }, { "docid": "7d5bc6b1818d62b3e2c35a78872423d0", "score": "0.50618345", "text": "func (s GtOrEqSlice) Len() int {\n\treturn s.LtSlice.Len()\n}", "title": "" }, { "docid": "76d9e27b97568173ec7272bcd143e817", "score": "0.5057657", "text": "func (pa *Array) Length() int {\n\treturn len(*pa)\n}", "title": "" }, { "docid": "c57d74472ff5988eff4fa40723a86287", "score": "0.5054865", "text": "func (arr marshallerArray) ArrayLength() int {\n\treturn len(arr)\n}", "title": "" }, { "docid": "1eb2a35c774cb9062572ef9fd1e9929d", "score": "0.50422204", "text": "func (paths *Paths) Len() int {\n\treturn len(paths.list)\n}", "title": "" }, { "docid": "bae44382865b6cfac599d7270a683d2f", "score": "0.50366503", "text": "func (m LengthMatcher) Match(chain []string) bool {\n\treturn int(m) == len(chain)\n}", "title": "" }, { "docid": "de3e4a364eb3d713586b9dc7d113c437", "score": "0.50354135", "text": "func compatibleArrayDimensions(constraintArrayDimensionsSize uint, constraintArrayDimensions []UA_UInt32, testArrayDimensionsSize uint, testArrayDimensions []UA_UInt32) UA_Boolean {\n\tif constraintArrayDimensionsSize == uint((0)) {\n\t\t// No array dimensions defined -> everything is permitted if the value rank fits\n\t\treturn 1\n\t}\n\tif testArrayDimensionsSize != constraintArrayDimensionsSize {\n\t\t// Dimension count must match\n\t\treturn 0\n\t}\n\t{\n\t\tvar i uint\n\t\tfor ; i < constraintArrayDimensionsSize; i++ {\n\t\t\tif constraintArrayDimensions[i] != testArrayDimensions[i] && constraintArrayDimensions[i] != UA_UInt32((uint32_t((uint32((0)))))) {\n\t\t\t\t// Dimension lengths must match; zero in the constraint is a wildcard\n\t\t\t\treturn 0\n\t\t\t}\n\t\t}\n\t}\n\treturn 1\n}", "title": "" }, { "docid": "be4267baf54c388bc98e17f1214a85f4", "score": "0.5022249", "text": "func (t Array) Len() int {\n\treturn len(t)\n}", "title": "" }, { "docid": "ceec78bf50658b6cb682521406d2f711", "score": "0.5018951", "text": "func (v Variable) ArrayLength() uint {\n\t//log.Printf(\"actualElements=%d allocatedElements=%d\", v.actualElements, v.allocatedElements)\n\treturn uint(v.actualElements)\n}", "title": "" }, { "docid": "c45b34c64dd8135ceb5021378dba0845", "score": "0.5016929", "text": "func Len(val interface{}) TestDeep {\n\tvval := reflect.ValueOf(val)\n\tif vval.IsValid() {\n\t\tl := tdLen{\n\t\t\ttdSmuggler: newSmuggler(val),\n\t\t}\n\n\t\tif l.isTestDeeper {\n\t\t\treturn &l\n\t\t}\n\n\t\t// A len is always an int\n\t\tif vval.Type() == intType {\n\t\t\tl.expectedValue = vval\n\t\t\treturn &l\n\t\t}\n\t}\n\tpanic(\"usage: Len(TESTDEEP_OPERATOR|INT)\")\n}", "title": "" }, { "docid": "d9c0ea5526d9e34afb6ec202a150f4d3", "score": "0.5014703", "text": "func CheckNonIndexedArrayAppend1(t *testing.T) {\n\t// Add 3 new items to array 'numbers'\n\tres1, err := DB.Query(fieldsUpdateNs).SetExpression(\"numbers\", \"numbers || [11,22,33]\").Update().AllowUnsafe(true).FetchAll()\n\trequire.NoError(t, err)\n\trequire.NotEqual(t, len(res1), 0, \"No items updated\")\n\n\t// Make sure results container is not empty\n\tresults, err := DB.Query(fieldsUpdateNs).Exec(t).AllowUnsafe(true).FetchAll()\n\trequire.NoError(t, err)\n\trequire.NotEqual(t, len(results), 0, \"No results found\")\n\n\tfor i := 0; i < len(results); i++ {\n\t\tok := true\n\t\tnumbers := results[i].(*TestItemComplexObject).Numbers\n\t\tnewSize := len(numbers)\n\t\tfirst := newSize - 3\n\t\titem := 1\n\t\t// Make sure last 3 values of array are equal to [11,22,33]\n\t\tfor j := first; j < newSize; j++ {\n\t\t\tok = (numbers[j] == 11*item)\n\t\t\tif !ok {\n\t\t\t\tfmt.Printf(\"%+v, %d\\n\", numbers, j)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\titem++\n\t\t}\n\t\trequire.True(t, ok, \"Extending of array field 'numbers' has shown wrong results\")\n\n\t}\n}", "title": "" }, { "docid": "4a959bac10b5acbf622df0a5c43bf5cf", "score": "0.50061625", "text": "func Length(len int) Validator {\n\treturn ValidatorFunc(func(ctx Context) (error, error) {\n\t\tval := indirect(ctx.Value)\n\t\tswitch val.Kind() {\n\t\tcase reflect.String, reflect.Array, reflect.Slice, reflect.Map:\n\t\t\tif val.Len() != len {\n\t\t\t\treturn newErrorf(\"must be of length %d\", len), nil\n\t\t\t}\n\t\t\treturn nil, nil\n\t\tcase reflect.Ptr:\n\t\t\treturn newErrorf(\"must be of length %d\", len), nil\n\t\tdefault:\n\t\t\treturn isLengthAllowed(val.Type(), \"length\", nil), nil\n\t\t}\n\t})\n}", "title": "" }, { "docid": "bc816bff9be62707012819b2b05d742c", "score": "0.500137", "text": "func (s ILikeOrSlice) Len() int {\n\treturn s.EqSlice.Len()\n}", "title": "" }, { "docid": "8be306cc75a15fc23a56ab72b6e55d25", "score": "0.49983224", "text": "func matchLen(x, y string) int {\n\ti := 0\n\tfor i < len(x) && i < len(y) && x[i] == y[i] {\n\t\ti++\n\t}\n\treturn i\n}", "title": "" }, { "docid": "90c054ec0f4e0c229b7f85475d3f71ba", "score": "0.49974102", "text": "func ReadArray(src []byte) ([]byte, bool) { return readLengthBytes(src) }", "title": "" }, { "docid": "dacff8a2bd77a0a3f9f3f42c568d4cba", "score": "0.4995964", "text": "func (s EqOrSlice) Len() int {\n\treturn s.EqSlice.Len()\n}", "title": "" }, { "docid": "945b8fb7864611b531c76b61383e20d5", "score": "0.49847263", "text": "func TestArraySameType(t *testing.T) {\n //mapper, err := New(TestStructIndexed{}, TestStructIndexed{}, structToIndexedArrayMapping)\n //require.NotNil(t, err)\n //require.Nil(t, mapper)\n //\n //mapper, err = New(arrayTyped, arrayTyped, structToIndexedArrayMapping)\n //require.NotNil(t, err)\n //require.Nil(t, mapper)\n}", "title": "" }, { "docid": "f8416e4632e51f13b3078eb5580d6dac", "score": "0.4982675", "text": "func tryLen(v interface{}) (length int, ok bool) {\n\tdefer func() {\n\t\tif e := recover(); e != nil {\n\t\t\tlog.Printf(\"[PANIC] tryLen(%v): %v\\n\", v, e)\n\t\t\tok = false\n\t\t}\n\t}()\n\n\trval := reflect.ValueOf(v)\n\tlength = rval.Len()\n\tok = true\n\treturn\n}", "title": "" }, { "docid": "f3350443180c95e899d8b5174c9c045a", "score": "0.4981538", "text": "func (l *ListType) Len() (int, bool) {\n\tif l.Kind() == Slice {\n\t\treturn -1, false\n\t}\n\tcnt, _ := strconv.Atoi(l.ArrayType.Len.(*ast.BasicLit).Value)\n\treturn cnt, true\n}", "title": "" }, { "docid": "71387d351448ec3b0321e4129396716d", "score": "0.49776134", "text": "func (ls LGESlice) Len() int { return len(ls) }", "title": "" }, { "docid": "d96ab9d67f15e185b4bf662c0210b5d3", "score": "0.49759436", "text": "func (path Path) Equal(other Path) bool {\n\tif len(path) != len(other) {\n\t\treturn false\n\t}\n\tfor i, f := range path {\n\t\tif f != other[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "title": "" }, { "docid": "37b03867be5e1a200e64c186bb66a840", "score": "0.49693483", "text": "func TestHashHashArrayInterface(t *testing.T) {\n\tdata := []interface{}{\n\t\t[]byte{1, 2, 3, 4},\n\t\t[]string{\"1\", \"2\", \"3\", \"4\"},\n\t\t[]string{\"a\", \"b\", \"c\", \"d\"},\n\t}\n\n\tfor _, item := range data {\n\t\thash, err := HashArrayInterface(item)\n\t\tassert.Equal(t, nil, err)\n\t\tassert.Equal(t, HashSize, len(hash[:]))\n\t}\n}", "title": "" }, { "docid": "d1f04e46e24ccc01bd77783cbf335523", "score": "0.49592662", "text": "func (o OnSlice) IsLength(length int) bool {\n\tvalue := reflect.ValueOf(o.slice)\n\treturn o.Compare(value.Len(), \"length ==\", length).Test(value.Len() == length)\n}", "title": "" }, { "docid": "c79e161d16c54718384dbdf75fdef1b4", "score": "0.4957137", "text": "func (arr marshallerArray) KnownLength() bool {\n\treturn true\n}", "title": "" }, { "docid": "ec017cbb7bdf248659a3af044eb897e8", "score": "0.49544185", "text": "func assertRefSliceEq(t *testing.T, exp, result []ast.Ref) {\n\tif len(result) != len(exp) {\n\t\tt.Fatalf(\"Expected refs %v, got %v\", exp, result)\n\t}\n\n\tfor i, e := range exp {\n\t\tr := result[i]\n\t\tif e.Compare(r) != 0 {\n\t\t\tt.Fatalf(\"Expected refs %v, got %v\", exp, result)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "b193f517d15b04fb51bd61693628fbe2", "score": "0.49512866", "text": "func checkParam(arr []string, length int) bool {\n\tif arr == nil || len(arr) < length {\n\t\treturn false\n\t}\n\treturn true\n}", "title": "" }, { "docid": "565fdbd53f62c0ab2ebfd1aa64b17184", "score": "0.49409813", "text": "func CheckArrayArgs(bArray []byte, offset int16, length int16) error {\n\tln := int16(len(bArray) - 1)\n\tif offset < 0 && offset > ln && length <= ln-offset {\n\t\treturn nil\n\t}\n\treturn errors.New(\"Array arguments exception\")\n}", "title": "" }, { "docid": "dd9669b8cb3780124c789ad082c5280a", "score": "0.49383438", "text": "func ExampleSliceEquals() {\n\tassert := assert.To(nil)\n\tslice := []string{\"a1\", \"a2\"}\n\ttheSame := []string{\"a1\", \"a2\"}\n\tlonger := []string{\"a1\", \"a2\", \"a3\"}\n\tdifferent := []string{\"a1\", \"a3\"}\n\tassert.For(\"the same\").ThatSlice(slice).Equals(theSame)\n\tassert.For(\"longer\").ThatSlice(slice).Equals(longer)\n\tassert.For(\"shorter\").ThatSlice(longer).Equals(slice)\n\tassert.For(\"different\").ThatSlice(slice).Equals(different)\n\t// Output:\n\t// Error:longer\n\t// 0 string `a1` ;\n\t// 1 string `a2` ;\n\t// - 2 ==> string `a3`\n\t// Error:shorter\n\t// 0 string `a1` ;\n\t// 1 string `a2` ;\n\t// + 2 string `a3` ;\n\t// Error:different\n\t// 0 string `a1` ;\n\t// * 1 string `a2` ==> string `a3`\n}", "title": "" }, { "docid": "40d2d03f3b898a0bb92a9e306d9eee76", "score": "0.49346143", "text": "func TestLength(t *testing.T) {\n\terr := Multi()\n\terr.Append(ErrorSample...)\n\n\t//fmt.Println(\"Total\", err.List())\n\n\tif len(err.List()) != 3 {\n\t\tt.Error(\"Error Lenght does not match\")\n\t}\n\n\tif len(err.List()) != err.Len() {\n\t\tt.Error(\"List Lenght & Len should be same value\")\n\t}\n\n\tif !err.HasError() {\n\t\tt.Error(\"HasError Failed to detect error\")\n\t}\n\n}", "title": "" }, { "docid": "effffd72eb718212bac884854b1ef133", "score": "0.49342507", "text": "func matchLenSSE4(a, b []byte, max int) int", "title": "" }, { "docid": "cf097ec2143acef9018a5a113b0ab042", "score": "0.49335864", "text": "func (n *JSONNode) Len() int {\n\tif !n.IsArray() {\n\n\t\tpanic(\"Not array\")\n\t}\n\tarr := n.interf.([]interface{})\n\n\treturn len(arr)\n}", "title": "" }, { "docid": "409043220a79a043cc7906ff5852f962", "score": "0.49321127", "text": "func (p StringSlice) Len() int { return len(p) }", "title": "" }, { "docid": "11f776845f3d1a87351a60b827a6a1b6", "score": "0.4932009", "text": "func (p Path) Equal(other Path) bool {\n\tif len(p) != len(other) {\n\t\treturn false\n\t}\n\tfor i := range p {\n\t\tif p[i] != other[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "title": "" }, { "docid": "28cc146700933ee7f485c37b8e10d251", "score": "0.49285257", "text": "func (jo *JSONData) validPathCheck(pathArr []string, node *JSONNode) bool {\n\tif len(pathArr) == 0 && (node.IsString() || node.IsInt() || node.IsFloat() || node.IsBool()) {\n\n\t\treturn true\n\t}\n\tpath := pathArr[0]\n\tif len(path) == 0 {\n\n\t\treturn false\n\t}\n\tif path[:1] == \"[\" && path[len(path)-1:] == \"]\" {\n\t\tif node.IsArray() {\n\t\t\tpn := path[1 : len(path)-1]\n\t\t\tif len(pn) == 0 {\n\n\t\t\t\treturn false\n\t\t\t}\n\t\t\ttheInt, err := strconv.Atoi(pn)\n\t\t\tif err != nil {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif theInt < 0 || theInt >= node.Len() {\n\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tnNode := node.GetNodeAt(theInt)\n\t\t\tnPathArr := pathArr[1:]\n\n\t\t\treturn jo.validPathCheck(nPathArr, nNode)\n\t\t}\n\n\t\treturn false\n\t}\n\tif node.IsMap() {\n\t\tif strings.Contains(path, \"[\") {\n\t\t\tk := path[:strings.Index(path, \"[\")]\n\t\t\tif !node.HaveKey(k) {\n\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tnNode := node.Get(k)\n\t\t\tnPathArr := []string{path[strings.Index(path, \"[\"):]}\n\t\t\tnPathArr = append(nPathArr, pathArr[1:]...)\n\n\t\t\treturn jo.validPathCheck(nPathArr, nNode)\n\t\t}\n\t\tif node.HaveKey(path) {\n\t\t\tnNode := node.Get(path)\n\t\t\tnPathArr := pathArr[1:]\n\n\t\t\treturn jo.validPathCheck(nPathArr, nNode)\n\t\t}\n\n\t\treturn false\n\t}\n\n\treturn false\n}", "title": "" }, { "docid": "872d6907b311c70756ffab3895b92bb8", "score": "0.49235713", "text": "func checkPathInArray(path string) bool {\n\tfor _, p := range fileArr {\n\t\tif p == path {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "title": "" }, { "docid": "1df46557dfafe8d816510f772f5d27b7", "score": "0.49234703", "text": "func ByteSliceEquals(left ByteSliceReference, leftInput Input, right ByteSliceReference, rightInput Input) bool {\n\tif left.Length() != right.Length() {\n\t\treturn false\n\t}\n\tlength := int(left.Length())\n\tfor i := 0; i < length; i++ {\n\t\tif leftInput.RawBytes[int(left.Start)+i] != rightInput.RawBytes[int(right.Start)+i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "title": "" }, { "docid": "4eb75d2a5330777cfc037e4b19a876d7", "score": "0.49209467", "text": "func checkLength(q Queue, len int) error {\n\tif q.Len() != len {\n\t\treturn fmt.Errorf(\"q.Len() = %d; want %d\", q.Len(), len)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "117cbc3abf8ffafa10e18761903b17e7", "score": "0.49198085", "text": "func (p Float64Slice) Len() int { return len(p) }", "title": "" } ]
4e53d16f5359899e4c8f6c81b22a6cb0
Publish adds message into history hub and calls node ClientMsg method to handle message. We don't have any PUB/SUB here as Memory Engine is single node only.
[ { "docid": "53e8558d8407f4c56011f4d25b55d03e", "score": "0.6297986", "text": "func (e *MemoryEngine) publish(ch string, pub *Publication, opts *ChannelOptions) <-chan error {\n\n\tif opts != nil && opts.HistorySize > 0 && opts.HistoryLifetime > 0 {\n\t\terr := e.historyHub.add(ch, pub, opts)\n\t\tif err != nil {\n\t\t\teChan := make(chan error, 1)\n\t\t\teChan <- err\n\t\t\treturn eChan\n\t\t}\n\t}\n\n\teChan := make(chan error, 1)\n\teChan <- e.eventHandler.HandlePublication(ch, pub)\n\treturn eChan\n}", "title": "" } ]
[ { "docid": "f0dd0957f32956123eef588943482070", "score": "0.6997897", "text": "func (h *historyTopic) Publish(msg []byte) error {\n\th.add(msg)\n\th.Topic.Publish(msg)\n\treturn nil\n}", "title": "" }, { "docid": "bc38e54648751c97708bc66ae025138e", "score": "0.63474315", "text": "func (h *Handler) Publish(w http.ResponseWriter, r *http.Request) {\n\tvar msg broker.Message\n\n\tvars := mux.Vars(r)\n\tchannelID := vars[\"channel\"]\n\tclientID := vars[\"client\"]\n\n\tif err := json.NewDecoder(r.Body).Decode(&msg); err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif err := h.broker.Publish(channelID, clientID, msg); err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n}", "title": "" }, { "docid": "d03060bf7bf839a5fa117f369d97e813", "score": "0.6297247", "text": "func (e *handler) Publish(c *session.Client, topic *string, payload *[]byte) {\n\tif c == nil {\n\t\te.logger.Error(\"Nil client publish\")\n\t\treturn\n\t}\n\te.logger.Info(\"Publish - client ID \" + c.ID + \" to the topic: \" + *topic)\n\t// Topics are in the format:\n\t// channels/<channel_id>/messages/<subtopic>/.../ct/<content_type>\n\n\tchannelParts := channelRegExp.FindStringSubmatch(*topic)\n\tif len(channelParts) < 1 {\n\t\te.logger.Info(\"Error in mqtt publish %s\" + errMalformedData.Error())\n\t\treturn\n\t}\n\n\tchanID := channelParts[1]\n\tsubtopic := channelParts[2]\n\n\tsubtopic, err := parseSubtopic(subtopic)\n\tif err != nil {\n\t\te.logger.Info(\"Error in mqtt publish: \" + err.Error())\n\t\treturn\n\t}\n\n\tcreated, err := ptypes.TimestampProto(time.Now())\n\tif err != nil {\n\t\te.logger.Info(\"Error in mqtt publish: \" + err.Error())\n\t\treturn\n\t}\n\n\tmsg := broker.Message{\n\t\tProtocol: protocol,\n\t\tChannel: chanID,\n\t\tSubtopic: subtopic,\n\t\tPublisher: c.Username,\n\t\tPayload: *payload,\n\t\tCreated: created,\n\t}\n\n\tif err := e.broker.Publish(context.TODO(), \"\", msg); err != nil {\n\t\te.logger.Info(\"Error publishing to Mainflux \" + err.Error())\n\t}\n}", "title": "" }, { "docid": "ae9ae0cf8ed5fb43be75635b0641896e", "score": "0.62701964", "text": "func (s *clientWrapper) Publish(ctx context.Context, p client.Message, opts ...client.PublishOption) error {\n\tname := fmt.Sprintf(\"Pub to %s\", p.Topic())\n\tspan, err := s.sw.CreateExitSpan(ctx, name, p.ContentType(), func(key, value string) error {\n\t\tmda, _ := metadata.FromContext(ctx)\n\t\tmd := metadata.Copy(mda)\n\t\tmd[key] = value\n\t\tctx = metadata.NewContext(ctx, md)\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tspan.SetComponent(componentIDGoMicroClient)\n\tspan.SetSpanLayer(agentv3.SpanLayer_RPCFramework)\n\n\tdefer span.End()\n\tfor _, k := range s.reportTags {\n\t\tif v, ok := metadata.Get(ctx, k); ok {\n\t\t\tspan.Tag(go2sky.Tag(k), v)\n\t\t}\n\t}\n\tif err = s.Client.Publish(ctx, p, opts...); err != nil {\n\t\tspan.Error(time.Now(), err.Error())\n\t}\n\treturn err\n}", "title": "" }, { "docid": "65800bcb9aa7f474db6dba3d6f46603e", "score": "0.62597454", "text": "func publishMsg(msg *MonitoringEvt){\n\tif msg.MsgId.String() == \"measureNotify\"{\n\t\t//Serialize in JSON format\n\t\tjsonMeasures, err := json.Marshal(msg)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t\t//Send the JSON structure on \"mon_event_measure.top\"\n\t\tclient.Publish(\"mon_event_measure.top\", nil, []interface{}{string(jsonMeasures)}, nil)\n\t}else if msg.MsgId.String() == \"alarmNotify\"{\n\t\t//Construct the alarm structure\n\t\taEnd, aStart := getAlarmMessages(msg)\n\t\t//Serialize in JSON format\n\t\taEndJson, err := json.Marshal(aEnd)\n\t\tif err != nil {\n\t\t\tlog.Print(\"[\"+time.Now().String()+\"] - Log message : \")\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\t\taStartJson, err := json.Marshal(aStart)\n\t\tif err != nil {\n\t\t\tlog.Print(\"[\"+time.Now().String()+\"] - Log message : \")\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\t\t//Send the JSON structure on \"mon_event_alarm.top\"\n\t\tclient.Publish(\"mon_event_alarm.top\", nil, []interface{}{string(aEndJson)}, nil)\n\t\tclient.Publish(\"mon_event_alarm.top\", nil, []interface{}{string(aStartJson)}, nil)\n\t}\n}", "title": "" }, { "docid": "98636d92fca0e2f93b883e263d855bb1", "score": "0.6198545", "text": "func (app *Application) Publish(pk ProjectKey, ch Channel, data []byte, client ConnID, info *ClientInfo) error {\n\n\tif string(ch) == \"\" || len(data) == 0 {\n\t\treturn ErrInvalidMessage\n\t}\n\n\tchOpts, err := app.channelOpts(pk, ch)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = app.pubClient(pk, ch, chOpts, data, client, info)\n\tif err != nil {\n\t\tlogger.ERROR.Println(err)\n\t\treturn ErrInternalServerError\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "49c8c0c6748b5df0e34f24b977276701", "score": "0.6174114", "text": "func (client *Client) Publish(topic *pubsub.Topic, msg string) (err error) {\n result := topic.Publish(client.ctx, &pubsub.Message{\n Data: []byte(msg),\n })\n id, err := result.Get(client.ctx)\n fmt.Printf(\"Published a message; msg ID: %v\\n\", id)\n return err\n}", "title": "" }, { "docid": "678ec793215f393cc31dabd2f583863b", "score": "0.6162939", "text": "func (c *Client) Publish(ctx context.Context, messages []Message) error {\n\t// TODO:\n\t// * Locking mechanism to ensure only one outstanding Publish request at a\n\t// time\n\t// * Ensure that this separate from Start()/poll()\n\t// * Implement Publish() in *BayeuxClient\n\tpanic(\"Publish() is not yet implemented\")\n}", "title": "" }, { "docid": "ad60c7176d68786400fd29be577e9a5f", "score": "0.61254114", "text": "func (c *Client) Publish(topic string, dat []byte) error {\n\tvar msg ClientMessage\n\tmsg.Kind = \"Publish\"\n\tmsg.Topic = topic\n\tmsg.Payload = dat\n\traw, err := proto.Marshal(&msg)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = c.con.Write(send(raw))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// get response\n\tmessage := make([]byte, 4096)\n\tlength, err := c.con.Read(message)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tc.nm.write(message[0:length])\n\n\treturn nil\n}", "title": "" }, { "docid": "89b81cc3c765df498d2ef8b818be831d", "score": "0.6104576", "text": "func (tc *TrainControl) PublishMessage(msg Message) {\n\ttc.message <- msg\n}", "title": "" }, { "docid": "cbe86271b7ef27b390325343a6e49432", "score": "0.61038524", "text": "func (c Client) Publish(message types.MessageEnvelope, topic string) error {\n\tif c.publishClient == nil {\n\t\treturn pkg.NewMissingConfigurationErr(\"PublishHostInfo\", \"Unable to create a connection for publishing\")\n\t}\n\n\tif topic == \"\" {\n\t\t// Empty streams are not allowed for Redis\n\t\treturn pkg.NewInvalidTopicErr(\"\", \"Unable to publish to the invalid topic\")\n\t}\n\tvalues := map[string]interface{}{\n\t\t\"CorrelationID\": message.CorrelationID,\n\t\t\"Payload\": message.Payload,\n\t\t\"Checksum\": message.Checksum,\n\t\t\"ContentType\": message.ContentType,\n\t}\n\n\treturn c.publishClient.AddToStream(fmt.Sprintf(GoModMessagingNamespaceFormat, topic), values)\n}", "title": "" }, { "docid": "3f7206cb7be47b77bd58faaaa59989ef", "score": "0.6101762", "text": "func (m *RedisManager) Publish(uID string, channel string, data interface{}) {\n\tredisConn := m.redis.Get()\n\tdefer redisConn.Close()\n\tjsonWSMessage, _ := json.Marshal(websocket.Message{Type: channel, Data: data})\n\tredisConn.Do(\n\t\t\"PUBLISH\",\n\t\tfmt.Sprintf(\"user:%s\", uID),\n\t\tjsonWSMessage,\n\t)\n\tm.cacheLogger.Printf(\"Published %s to user:%s\", channel, uID)\n}", "title": "" }, { "docid": "0e0f39489e62b04c2cc86173e4ea678b", "score": "0.60972106", "text": "func Publish(node *core.IpfsNode, cInfo ClientInfo, h hash.Hash) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tdbg.Debug(\"Publish failed, error: %s\", r)\n\t\t}\n\t}()\n\tmsgData := cInfo.Delegate.GenMessageData(cInfo, h)\n\tm, err := json.Marshal(map[string]string{\"user\": cInfo.Username, \"data\": msgData})\n\tif err != nil {\n\n\t}\n\td.PanicIfError(err)\n\tdbg.Debug(\"publishing to topic: %s, msg: %s\", cInfo.Topic, m)\n\tnode.Floodsub.Publish(cInfo.Topic, append(m, []byte(\"\\r\\n\")...))\n\n\tdefer lockSeenF()()\n\tseenHash[h] = true\n}", "title": "" }, { "docid": "45ab1929752b2dfe25d5aa31b8a94d8a", "score": "0.60699326", "text": "func Publish(command string) {\n\tcreateClient(&client)\n\tclient.c.Publish(\"sub\", 0, false, command)\n\tclient.c.Disconnect(250)\n}", "title": "" }, { "docid": "ab45e7a03d35c99257bd2d2ab8429b6e", "score": "0.6057264", "text": "func (client *Client) Publish(produce *commander.Message) error {\n\tclient.production.Add(1)\n\tdefer client.production.Done()\n\n\tmessage := metadata.MessageToMessage(produce)\n\t_, _, err := client.producer.SendMessage(message)\n\treturn err\n}", "title": "" }, { "docid": "94e8eb3c879aa455a22b49f02ffff6e4", "score": "0.60119665", "text": "func (l *LoopbackClient) Publish(m *Message) (uint64, error) {\n\tl.index++\n\tm.Index = l.index\n\n\tl.c <- m\n\treturn m.Index, nil\n}", "title": "" }, { "docid": "3052714f151a1ebaf79a4875829c17d4", "score": "0.60075104", "text": "func (s *Server) NotifyPublish(prc protobase.ProtoConnection, msg protobase.MsgInterface) {\n\tconst fn = \"NotifyPublish\"\n\tvar (\n\t\ttopic string = msg.Envelope().Route()\n\t\tmessage []byte = msg.Envelope().Payload()\n\t)\n\tm, _ := s.Router.Find(topic)\n\tfor k, wqos := range m {\n\t\tcl := s.State.get(k)\n\t\tlogger.FDebug(fn, \"* [Publish] client found.\", cl)\n\t\tif cl != nil {\n\t\t\tvar (\n\t\t\t\tuser protobase.ClientInterface = cl.proto.GetClient()\n\t\t\t\tclid string = cl.uid\n\t\t\t)\n\t\t\tif cl.proto == prc {\n\t\t\t\tlogger.FDebug(fn, \"? [Publish] cl.proto==prc ? \", \"userId\", clid)\n\t\t\t}\n\t\t\tprclid := prc.GetClient().GetIdentifier()\n\t\t\tif wqos == 0 && cl.proto.GetStatus() != protobase.STATONLINE {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlogger.FDebugf(fn, \"+ [Publish] prc(%s) - client(%s) is [Online], sending message(%s) from route(%s), QoS(%d).\",\n\t\t\t\tprclid, clid, message, clid, msg.QoS())\n\t\t\tnpb := msg.Clone(protobase.MDOutbound)\n\t\t\tnpb.SetWishQoS(wqos)\n\t\t\tlogger.Infof(\"+ [Publish ] Routing Topic(%s)-> Message(%s) for Client(%s) [ WishQoS(%d), wqos(%d) ].\", topic, message, clid, npb.QoS(), wqos)\n\t\t\t// logger.Infof(fn, \"+ [Publish ] Routing Topic(%s)-> Message(%s) for Client(%s) with QoS(%d).\", topic, message, clid, npb.QoS())\n\t\t\tcl.proto.SendMessage(npb, cl.proto == prc)\n\t\t\tuser.Publish(npb)\n\t\t}\n\t}\n\treturn\n}", "title": "" }, { "docid": "86c5e59440ad68c4e1fd4a741b778f95", "score": "0.5998779", "text": "func (h *Hub) Publish(m PublishMessage) {\n\t// notify each subscriber of a topic\n\tif len(m.Topic) > 0 {\n\t\th.emit <- m\n\t}\n}", "title": "" }, { "docid": "9d8de7f5efe2512048738d4ee853d593", "score": "0.5993991", "text": "func (device *Device) PublishMessage(message report.IMessage) error {\n\n\tif config.Config.GetBase().Storage != \"\" {\n\t\tmessage.SetValue(\"storage\", config.Config.GetBase().Storage)\n\t}\n\n\tmessage.SetValue(\"PrevSourceId\", device.Activity.LastMessageID)\n\therr := device.saveMessageHistory(message)\n\taerr := device.Self.SaveActivity(message)\n\tif herr != nil || aerr != nil {\n\t\tjMessage, _ := json.Marshal(message)\n\t\tlog.Fatalf(\"[PublishMessage | Save history] Error : %v. Message: %v\", herr, string(jMessage))\n\t\treturn herr\n\t}\n\tif aerr != nil {\n\t\tlog.Fatalf(\"[PublishMessage | Save activity] Error : %v \", aerr)\n\t\treturn aerr\n\t}\n\tdevice.Self.SendSystemMessage(message, models.GetMessageHistoryTableName(device.Identity))\n\treturn nil\n}", "title": "" }, { "docid": "7170a06646488e6cea70fca6e984ee54", "score": "0.59671926", "text": "func (p *Service) PublishMsg(message string) (err error) {\n\tnotification := Notification{\n\t\tAppName: \"Go Prowl\",\n\t\tEventName: \"Message\",\n\t\tMessage: message,\n\t}\n\n\treturn p.Publish(notification)\n}", "title": "" }, { "docid": "40bc6fde632470c32b4cb5072ddcc3c9", "score": "0.5966811", "text": "func (c *Channel) Publish(ctx context.Context, message string) error {\n\tmsg := &pb.ChannelMessage{\n\t\tMessage: message,\n\t\tTopic: c.topic,\n\t\tPeerID: c.identity.Pretty(),\n\t\tTimestamp: ptypes.TimestampNow(),\n\t}\n\tser, err := proto.Marshal(msg)\n\tif err != nil {\n\t\treturn err\n\t}\n\tsig, err := c.privKey.Sign(ser)\n\tif err != nil {\n\t\treturn err\n\t}\n\tmsg.Signature = sig\n\n\tserializedMsg, err := proto.Marshal(msg)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tnd, err := c.object.New(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tpth, err := c.object.SetData(ctx, path.IpldPath(nd.Cid()), bytes.NewReader(serializedMsg))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar channelRec models.Channel\n\terr = c.db.View(func(tx database.Tx) error {\n\t\treturn tx.Read().Where(\"topic=?\", c.topic).First(&channelRec).Error\n\t})\n\tif err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {\n\t\treturn err\n\t}\n\tif err == nil {\n\t\tlinks, err := channelRec.GetHead()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfor i, link := range links {\n\t\t\tpth, err = c.object.AddLink(ctx, pth, \"previousMessage\"+strconv.Itoa(i), path.IpldPath(link))\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tind, err := c.object.Get(ctx, pth)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tpnd, ok := ind.(*merkledag.ProtoNode)\n\tif !ok {\n\t\treturn errors.New(\"protoNode type assertion error\")\n\t}\n\tserializedObj, err := pnd.Marshal()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn c.pubsub.Publish(ctx, topicPrefix+c.topic, serializedObj)\n}", "title": "" }, { "docid": "482b22c725a564159627215e7ee95308", "score": "0.5943703", "text": "func (g *AggregatingGateway) OnPublish(client MQTT.Client, msg MQTT.Message) {\n\tif env.DEBUG {\n\t\tlog.Println(\"on publish. Receive message from broker.\")\n\t}\n\n\tg.mutex.Lock()\n\tdefer g.mutex.Unlock()\n\n\t// get subscribers\n\ttopic := msg.Topic()\n\tsubscribers := GetTopicEntry().GetSubscriber(topic)\n\n\t// for each subscriber\n\tfor _, subscriber := range subscribers {\n\t\t// TODO: check subscriber(MqttSnSession)'s state.\n\t\t// if subscriber is sleep, gateway must buffer the message.\n\n\t\tvar m *message.Publish\n\t\tsession := subscriber.Session\n\n\t\t// get TopicID Type\n\t\ttidType := subscriber.TidType\n\t\tswitch tidType {\n\t\tcase message.MQTTSN_TIDT_NORMAL:\n\t\t\t// get topicid\n\t\t\ttopicId, ok := session.LoadTopicId(topic)\n\n\t\t\t// if not found\n\t\t\tif !ok {\n\t\t\t\t// TODO: implement\n\t\t\t\tlog.Println(\"INFO : Normal topic id was not found for \", topic, \".\")\n\n\t\t\t\t// TODO: implement wildcarded route\n\t\t\t\tcontinue\n\n\t\t\t} else {\n\t\t\t\t// process as fixed topicid\n\t\t\t\t// qos, retain, topicId, msgId, data\n\t\t\t\tmsgId := session.NextMsgId()\n\t\t\t\tm = message.NewPublishNormal(\n\t\t\t\t\t1, false, topicId, msgId, msg.Payload())\n\t\t\t}\n\n\t\tcase message.MQTTSN_TIDT_PREDEFINED:\n\t\t\t// get topicid\n\t\t\ttopicId, ok := LoadPredefTopicId(topic)\n\n\t\t\t// if not found\n\t\t\tif !ok {\n\t\t\t\t// PREDEFINED TOPIC is must be fixed\n\t\t\t\tlog.Println(\"ERROR : Predefined topic id was not found for \", topic, \".\")\n\t\t\t\tcontinue\n\n\t\t\t} else {\n\t\t\t\t// process as fixed topicid\n\t\t\t\t// qos, retain, topicId, msgId, data\n\t\t\t\tmsgId := session.NextMsgId()\n\t\t\t\tm = message.NewPublishPredefined(\n\t\t\t\t\t1, false, topicId, msgId, msg.Payload())\n\t\t\t}\n\n\t\tcase message.MQTTSN_TIDT_SHORT_NAME:\n\t\t\t// TODO: implement\n\t\t}\n\n\t\t// send message\n\t\tsession.Conn.WriteToUDP(m.Marshall(), session.Remote)\n\t}\n}", "title": "" }, { "docid": "f2ac57bc60f43ad0dca6f71945b86d2f", "score": "0.594289", "text": "func (c *client) Emit(event string, data interface{}) error {\n\tmessage, err := websocketMessageSerialize(event, data)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// fmt.Printf(\"Message %s\\n\", string(message))\n\tc.wchan <- []byte(message)\n\treturn nil\n}", "title": "" }, { "docid": "4ed549a099b018a687265d51476db0f4", "score": "0.59294534", "text": "func (a *PubSub) Publish(msg interface{}) error {\n\ta.backlog <- msg\n\treturn nil\n}", "title": "" }, { "docid": "212e620877a782580420874578ce98de", "score": "0.59183735", "text": "func Publish(message Message) int {\n\treturn defaultHub.Publish(message)\n}", "title": "" }, { "docid": "873c71c4f692ac26bf0970f21b148824", "score": "0.58781016", "text": "func(h *Handler) publish(topic string) {\n\tfor client, ok := range h.hub.clients[topic] {\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\t\tclient.hub.broadcast <- TopicMessage{message: space, topic: topic}\n\t}\n}", "title": "" }, { "docid": "effba4150d7925b2829a353b401c5b2e", "score": "0.58735156", "text": "func (c *YamqClient) Publish(name string, value []byte) {\n\t// TODO\n}", "title": "" }, { "docid": "47d38d995369c14416815969ea46dd5e", "score": "0.5844794", "text": "func (wq *memWQ) Publish(msg *Message) error {\n\tif !wq.open {\n\t\treturn errors.New(\"queue is not open\")\n\t}\n\tdata, err := msg.ToJSON()\n\tif err != nil {\n\t\treturn err\n\t}\n\tselect {\n\tcase wq.topic.Incoming <- data:\n\t\treturn nil\n\tdefault:\n\t\treturn errors.New(\"queue is full\")\n\t}\n}", "title": "" }, { "docid": "c247209fea8949ad16588632f8c8e516", "score": "0.5821647", "text": "func (c *client) EmitMessage(nativeMessage []byte) error {\n\tc.wchan <- nativeMessage\n\treturn nil\n}", "title": "" }, { "docid": "0806ef384e763efc7380aa1728c1210f", "score": "0.58083296", "text": "func (c *Client) Publish(channel string, data []byte) error {\n\treturn c.publish(channel, data)\n}", "title": "" }, { "docid": "4af25008780b0872bec2959fe52cdce5", "score": "0.5789778", "text": "func (b broker) handleMsg(c mqtt.Client, msg mqtt.Message) {\n\tm := lora.Message{}\n\tif err := json.Unmarshal(msg.Payload(), &m); err != nil {\n\t\tb.logger.Warn(fmt.Sprintf(\"Failed to Unmarshal message: %s\", err.Error()))\n\t\treturn\n\t}\n\n\tb.svc.Publish(context.Background(), \"\", m)\n\treturn\n}", "title": "" }, { "docid": "71abba249d80d76b9115197d24c10b6e", "score": "0.57860327", "text": "func (c Client) Publish(message types.MessageEnvelope, topic string) error {\n\tif c.publishClient == nil {\n\t\treturn pkg.NewMissingConfigurationErr(\"PublishHostInfo\", \"Unable to create a connection for publishing\")\n\t}\n\n\tif topic == \"\" {\n\t\t// Empty topics are not allowed for Redis\n\t\treturn pkg.NewInvalidTopicErr(\"\", \"Unable to publish to the invalid topic\")\n\t}\n\n\ttopic = convertToRedisTopicScheme(topic)\n\tvar err error\n\tif err = c.publishClient.Send(topic, message); err != nil && strings.Contains(err.Error(), \"EOF\") {\n\t\t// Redis may have been restarted and the first attempt will fail with EOF, so need to try again\n\t\terr = c.publishClient.Send(topic, message)\n\t}\n\n\treturn err\n}", "title": "" }, { "docid": "a516a5983c1b497cc0551144101faff4", "score": "0.57704663", "text": "func (b *MemoryBus) Publish(msg interface{}) error {\n\tif msg == nil {\n\t\treturn errors.New(\"got nil message\")\n\t}\n\tvar action string\n\tvar msgID string\n\n\tswitch v := msg.(type) {\n\tcase model.Cmd:\n\t\taction = v.Action().String()\n\t\tmsgID = v.ID()\n\tcase model.Event:\n\t\taction = v.Action().String()\n\t\tmsgID = v.ID()\n\tdefault:\n\t\treturn errors.New(\"received message of unknown type\")\n\t}\n\n\tlogPrefix := fmt.Sprintf(\"[Publish]: [Action: %s]:\", action)\n\n\tb.terminateLock.RLock()\n\tif b.isTerminating {\n\t\tb.terminateLock.RUnlock()\n\t\treturn errors.New(\"bus is terminating\")\n\t}\n\tb.terminateLock.RUnlock()\n\n\tb.ensureActionChan(action)\n\tlogPrefix = fmt.Sprintf(\"%s [%s]:\", logPrefix, msgID)\n\tb.log.Debugf(\"%s Received message\", logPrefix)\n\n\tb.log.Tracef(\"%s Acquiring locks\", logPrefix)\n\tb.subsMapLock.RLock()\n\tsubs := b.subscriptions[action]\n\tb.subsMapLock.RUnlock()\n\tb.log.Tracef(\"%s Releasing locks\", logPrefix)\n\n\tb.log.Tracef(\"%s Subscribers count: %d\", logPrefix, len(subs))\n\tif len(subs) == 0 {\n\t\tb.log.Warn(\"No subscribers found for action\")\n\t}\n\n\tfor _, sub := range subs {\n\t\tsub.lock.RLock()\n\t\tif sub.isOpen {\n\t\t\tb.log.Tracef(\"%s Publishing event\", logPrefix)\n\t\t\tsub.channel <- msg\n\t\t\tb.log.Tracef(\"%s Published event\", logPrefix)\n\t\t}\n\t\tsub.lock.RUnlock()\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "a7b45248121ab9a930b9f462138852cf", "score": "0.5769408", "text": "func (c *Client) Publish(message string) error {\n\tc.commLock.Lock()\n\tpkt := packet{}\n\tpkt.configurePublish(c.topic, message, false, c.qos)\n\tsendBytes := pkt.FormulateMQTTOutputData()\n\tc.conn.Write(sendBytes)\n\tc.commLock.Unlock()\n\treturn nil\n}", "title": "" }, { "docid": "df6d2b5516630b2da50b478ef718b46f", "score": "0.5761373", "text": "func publish(client MQTT.Client, msg Msg) {\n\ttoken := client.Publish(msg.Topic(), qos1, false, msg.Payload())\n\tif token.Wait() && token.Error() != nil {\n\t\tpanic(token.Error())\n\t}\n}", "title": "" }, { "docid": "19195881e2dfd1039bd966c87f7902a4", "score": "0.57560456", "text": "func (app *Application) pubClient(pk ProjectKey, ch Channel, chOpts ChannelOptions, data []byte, client ConnID, info *ClientInfo) error {\n\n\tmessage, err := newMessage(ch, data, client, info)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif chOpts.Watch {\n\t\tresp := newResponse(\"message\")\n\t\tresp.Body = &AdminMessageBody{\n\t\t\tProject: pk,\n\t\t\tMessage: message,\n\t\t}\n\t\tmessageBytes, err := json.Marshal(resp)\n\t\tif err != nil {\n\t\t\tlogger.ERROR.Println(err)\n\t\t} else {\n\t\t\terr = app.pubAdmin(messageBytes)\n\t\t\tif err != nil {\n\t\t\t\tlogger.ERROR.Println(err)\n\t\t\t}\n\t\t}\n\t}\n\n\tchID := app.channelID(pk, ch)\n\n\tresp := newResponse(\"message\")\n\tresp.Body = message\n\n\tbyteMessage, err := json.Marshal(resp)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = app.engine.publish(chID, byteMessage)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif chOpts.HistorySize > 0 && chOpts.HistoryLifetime > 0 {\n\t\terr := app.addHistory(pk, ch, message, chOpts.HistorySize, chOpts.HistoryLifetime)\n\t\tif err != nil {\n\t\t\tlogger.ERROR.Println(err)\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "0bd16f457dea6e0bb122a7031d0023c1", "score": "0.57485515", "text": "func (c *Client) Publish(subscription string, data message.Data) (err error) {\n\treturn c.dispatcher.Publish(subscription, data)\n}", "title": "" }, { "docid": "528a68ef55b75b17e7c66f83435f0227", "score": "0.57476956", "text": "func (a *AMQP) Publish(event string, data []byte) error {\n\terr := a.publishChannel.Publish(\n\t\ta.Group,\n\t\tevent,\n\t\tfalse,\n\t\tfalse,\n\t\tamqp.Publishing{\n\t\t\tBody: data,\n\t\t\tContentType: \"application/json\",\n\t\t},\n\t)\n\treturn err\n}", "title": "" }, { "docid": "789ba63dc0aa6a2f133f917eb38fbe05", "score": "0.5746041", "text": "func Publish(channel string, message interface{}) error {\n\treturn mustGetDefaultClient().Publish(channel, message)\n}", "title": "" }, { "docid": "464e456a16f5b62ed042dd2a7fb5b38f", "score": "0.5740226", "text": "func (c *InnerChannel) PushMsg(m *Message, key string) error {\n\tc.mutex.Lock()\n\tdefer c.mutex.Unlock()\n\tsubscriberStats.IncrAddedMessage()\n\t// check message expired\n\tif m.Expired() {\n\t\tsubscriberStats.IncrExpiredMessage()\n\t\tLog.Printf(\"device %s: message %d has already expired\", key, m.MsgID)\n\t\treturn ErrMsgExpired\n\t}\n\n\t// check exceed the max message length\n\tif c.message.Length+1 > c.MaxMessage {\n\t\t// remove the first node cause that's the smallest node\n\t\tn := c.message.Head.Next()\n\t\tif n == nil {\n\t\t\t// never happen\n\t\t\tLog.Printf(\"the subscriber touch a impossiable place\")\n\t\t\tpanic(\"Skiplist head nil\")\n\t\t}\n\n\t\tc.message.Delete(n.Score)\n\t\tLog.Printf(\"device %s: message %d exceed the max message (%d) setting, trim the subscriber\", key, n.Score, c.MaxMessage)\n\t\tsubscriberStats.IncrDeletedMessage()\n\t}\n\n\terr := c.message.Insert(m.MsgID, m)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// send message to all the clients\n\tfor conn, _ := range c.conn {\n\t\tif err := subRetWrite(conn, m.Msg, m.MsgID, key); err != nil {\n\t\t\t// remove exists conn\n\t\t\tsubscriberStats.IncrFailedMessage()\n\t\t\tLog.Printf(\"subRetWrite() failed (%s)\", err.Error())\n\t\t\tcontinue\n\t\t}\n\n\t\tsubscriberStats.IncrSentMessage()\n\t\tLog.Printf(\"push message \\\"%s\\\":%d to device %s\", m.Msg, m.MsgID, key)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "8a2c00a9980471bc5493caf05369ce66", "score": "0.57247436", "text": "func (p *Producer) Publish(exchange string, msg *core.Message) error {\n\traw, err := json.Marshal(msg)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Error marshalling message\")\n\t}\n\n\treturn p.client.Publish(exchange, msg.Key, raw)\n}", "title": "" }, { "docid": "9ea6eee932d729a9c1a04888fa68639c", "score": "0.5711695", "text": "func (p *redisPublisher) Publish(channel string, data []byte) {\n\tselect {\n\tcase p.messages <- &message{channel: channel, data: data}:\n\tdefault:\n\t\tp.handler.OnPublishError(ErrPublishWouldBlock, channel, data)\n\t}\n}", "title": "" }, { "docid": "3225517bb9b3001f45f8cf7c0c2fceb0", "score": "0.57100344", "text": "func (p *Client) Publish(topic string, data []byte) error {\n\treturn p.Conn.Publish(topic, data)\n}", "title": "" }, { "docid": "c5f8dc8f5440699d1ed3ecf4404f3140", "score": "0.5689188", "text": "func (r *Ref) Publish(msg interface{}) {\n\tr.inbox <- msg\n}", "title": "" }, { "docid": "bdd31a7f8ad8a729d89fbac6cc9e7f0e", "score": "0.5680659", "text": "func (n *Node) Publish(topic []byte, message []byte) {\n\t// TODO validate input\n\tevent := newEvent(topic, message, n.cfg.DefaultEventTTL)\n\tn.route(event)\n\tn.log.eventPublished(n, event)\n}", "title": "" }, { "docid": "0bf30b15c76372513a4814c981ab1518", "score": "0.5676098", "text": "func publish(topic string, data string) error {\n\tlog.Printf(\"[DEBUG] publish - Publishing to topic %s\\n\", topic)\n\terror := cbBroker.client.Publish(topic, []byte(data), cbBroker.qos)\n\tif error != nil {\n\t\tlog.Printf(\"[ERROR] publish - Unable to publish to topic: %s due to error: %s\\n\", topic, error.Error())\n\t\treturn error\n\t}\n\n\tlog.Printf(\"[DEBUG] publish - Successfully published message to = %s\\n\", topic)\n\treturn nil\n}", "title": "" }, { "docid": "4162706af6375726fed5974c8eae06c2", "score": "0.5652462", "text": "func (b *redisBroker) Publish(topic string, msg *broker.Message, opts ...broker.PublishOption) error {\n\tv, err := b.opts.Codec.Marshal(msg)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tconn := b.pool.Get()\n\t_, err = redis.Int(conn.Do(\"PUBLISH\", topic, v))\n\tconn.Close()\n\n\treturn err\n}", "title": "" }, { "docid": "1d5c9a9b4cff518937367e8a4a15c88f", "score": "0.5649573", "text": "func publish(client MQTT.Client, topic string, bytes []byte) error {\n\n\tlog.Infof(\"sending to topic %s\", topic)\n\n\tif token := client.Publish(topic, 0, false, bytes); token.Wait() && token.Error() != nil {\n\t\tlog.Errorf(\"publish error: %s\", token.Error())\n\t\treturn token.Error()\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "5823e55a2dc6b552f7aec148b3917060", "score": "0.5646475", "text": "func (ps *PubySuby) Push(topic string, message string) int64 {\n\ttopicCommandChannel := ps.getTopicRequestChannel(topic)\n\tmyListenChannel := make(chan []TopicItem)\n\ttopicCommandChannel <- topicRequest{Cmd: \"pub\", content: message, subscriberListenChannel: myListenChannel}\n\tresults, ok := <-myListenChannel\n\tif !ok {\n\t\tlog.Fatal(\"Blew up during Push because myListenChannel was closed\")\n\t}\n\treturn results[0].MessageId\n}", "title": "" }, { "docid": "b970953deaf973de9e21ca60ea933807", "score": "0.5641196", "text": "func (p *PublisherZmq) SendMessage(msg []byte, topic string) {\n\tp.socket.SendBytes([]byte(topic), zmq.SNDMORE)\n\tp.socket.SendBytes(msg, 0)\n}", "title": "" }, { "docid": "c3dbc5e9fff5392eaf349c5fbf32ef9e", "score": "0.56267184", "text": "func Libmqtt_publish(client C.int, topic *C.char, qos C.int, payload *C.char, payloadSize C.int) {\n\tif c := getClient(int(client)); c != nil {\n\t\tc.Publish(&mqtt.PublishPacket{\n\t\t\tTopicName: C.GoString(topic),\n\t\t\tQos: mqtt.QosLevel(qos),\n\t\t\tPayload: C.GoBytes(unsafe.Pointer(payload), payloadSize),\n\t\t})\n\t}\n}", "title": "" }, { "docid": "2b86652d1ed69d842c233a4490a87f66", "score": "0.5616786", "text": "func (a *APIClient) PublishMessage(req *PublishMessageRequestV3) (*NoContentResponse, error) {\n\tpayload, err := json.Marshal(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar resp NoContentResponse\n\terr = a.makeRequest(http.MethodPost, \"api/v3/mqtt/publish\", payload, &resp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resp, nil\n}", "title": "" }, { "docid": "6ecfd9ade9b0df3d109b27e89e90f7aa", "score": "0.5614646", "text": "func (q *natsQueue) Publish(event string, payload []byte) error {\n\treturn q.conn.Publish(event, payload)\n}", "title": "" }, { "docid": "1df6ce1220b501d3e80a2e289a6ca13a", "score": "0.5598269", "text": "func (c *client) Publish(ctx context.Context, message *Message, exchangeName string) error {\n\tp := *c.publisher\n\treturn p.Publish(ctx, message, exchangeName)\n}", "title": "" }, { "docid": "065cc2c559f6836418b70f3282566906", "score": "0.5593736", "text": "func (app *Application) publish(pk ProjectKey, ch Channel, data []byte, client ConnID, info *ClientInfo, fromClient bool) error {\n\n\tif string(ch) == \"\" || len(data) == 0 {\n\t\treturn ErrInvalidMessage\n\t}\n\n\tchOpts, err := app.channelOpts(pk, ch)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tapp.RLock()\n\tinsecure := app.config.Insecure\n\tapp.RUnlock()\n\n\tif fromClient && !chOpts.Publish && !insecure {\n\t\treturn ErrPermissionDenied\n\t}\n\n\tif app.mediator != nil {\n\t\t// If mediator is set then we don't need to publish message\n\t\t// immediately as mediator will decide itself what to do with it.\n\t\tpass := app.mediator.Message(pk, ch, data, client, info)\n\t\tif !pass {\n\t\t\treturn nil\n\t\t}\n\t}\n\n\terr = app.pubClient(pk, ch, chOpts, data, client, info)\n\tif err != nil {\n\t\tlogger.ERROR.Println(err)\n\t\treturn ErrInternalServerError\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "23a8d9c8070792366e69b03c64d0096e", "score": "0.5590145", "text": "func publish(message domain.TtnMessage, bus domain.MessageBus) error {\n\tid, err := uuid.NewUUID()\n\tif err != nil {\n\t\tlogrus.Errorf(\"unable to generate uuid: %v\", err)\n\t\treturn err\n\t}\n\n\tloraEvent := cloudevents.NewEvent()\n\tloraEvent.SetID(id.String())\n\tloraEvent.SetSource(fmt.Sprintf(cloudEventSource, message.AppID))\n\tloraEvent.SetType(\"lora.ttn.message\")\n\tloraEvent.SetTime(message.Metadata.Time)\n\n\terr = loraEvent.SetData(cloudevents.ApplicationJSON, message)\n\tif err != nil {\n\t\tlogrus.Errorf(\"unable to set CloudEvent data: %v\", err)\n\t\treturn err\n\t}\n\n\tdata, err := loraEvent.MarshalJSON()\n\tif err != nil {\n\t\tlogrus.Errorf(\"unable to marshal the cloud event: %v\", err)\n\t\treturn err\n\t}\n\treturn bus.Send(loraEvent.ID(), data)\n}", "title": "" }, { "docid": "a6937a45c41a1b8250fa7e56561e04c7", "score": "0.557478", "text": "func (databus *Databus) Publish(topic string, message interface{}) error {\n\ttoken := databus.client.Publish(topic, 1, false, message)\n\ttoken.Wait()\n\treturn token.Error()\n}", "title": "" }, { "docid": "af398d008882d8ee91e0a35ee8f2f9a2", "score": "0.5550972", "text": "func (s *SSEHub) publishEventToClient(msg *messagerooms.PublishEvent) {\n\tif client, ok := s.OpenConnections[msg.ConnectionID]; ok {\n\t\tevent := messagerooms.EventMessage{\n\t\t\tEvent: messagerooms.MessageRoomEvent,\n\t\t\tDestinationID: client.ConnectionID,\n\t\t\tData: msg,\n\t\t}\n\t\tclient.PublishEvent(event)\n\t}\n}", "title": "" }, { "docid": "c87a6444b7e1d39729cfaf24a0bbcb94", "score": "0.5540297", "text": "func (c *Client) Publish(pub *Publisher) {\n\tc.l.Lock()\n\tc.publishers[pub] = struct{}{}\n\tc.l.Unlock()\n\n\tgo pub.serve(c.channel)\n}", "title": "" }, { "docid": "762dea73c2e51f4ad615aaa3dddc3447", "score": "0.55313563", "text": "func PublishMessage(conn *amqp.Connection) {\n\n\t//now creating the channel for publishing our msg\n\tch, err := conn.Channel()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tdefer ch.Close()\n\n\t//declaring a queue for our RMQ\n\tqueue, err := ch.QueueDeclare(\n\t\t\"PaymentQueue\",\n\t\tfalse,\n\t\tfalse,\n\t\tfalse,\n\t\tfalse,\n\t\tnil,\n\t)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tpanic(err)\n\t}\n\tfmt.Println(queue)\n\n\t//getting the msg to publish\n\tdata := util.GetMessages()\n\tfmt.Println(len(data))\n\n\t//publishing msgs over loop\n\tfor _, value := range data {\n\t\tfmt.Println(value)\n\t\t// marshelling the data before publishing it\n\t\tjson_data2, err := json.Marshal(value)\n\n\t\t//now publishing our queue\n\t\terr = ch.Publish(\n\t\t\t\"\",\n\t\t\t\"PaymentQueue\",\n\t\t\tfalse,\n\t\t\tfalse,\n\t\t\tamqp.Publishing{\n\t\t\t\tContentType: \"application/json\",\n\t\t\t\tBody: []byte(json_data2),\n\t\t\t},\n\t\t)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\tpanic(err)\n\t\t}\n\t}\n\tfmt.Println(\"Successfully Published the message\")\n\n}", "title": "" }, { "docid": "9c72ba3d2ee924fc2ac00ac5b809deba", "score": "0.5527409", "text": "func (a Api) PublishMessage(w rest.ResponseWriter, r *rest.Request) {\n\tpayload := struct {\n\t\tHandle string\n\t\tSessionid string\n\t\tLastSaved time.Time\n\t\tCircle string\n\t}{}\n\terr := r.DecodeJsonPayload(&payload)\n\tif err != nil {\n\t\trest.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\ta.authenticate(w, payload.Handle, payload.Sessionid)\n\n\tif !a.circleExists(payload.Handle, payload.Circle) {\n\t\tw.WriteHeader(400)\n\t\tw.WriteJson(map[string]string{\n\t\t\t\"Response\": \"Bad Request, could not find specified circle to publish to\",\n\t\t})\n\t\treturn\n\t}\n\n\tif !a.messageExists(payload.Handle, payload.LastSaved) {\n\t\tw.WriteHeader(400)\n\t\tw.WriteJson(map[string]string{\n\t\t\t\"Response\": \"Bad Request, could not find intended message for publishing\",\n\t\t})\n\t\treturn\n\t}\n\n\tcreated := []struct {\n\t\tCount int `json:\"count(r)\"`\n\t}{}\n\terr = a.Svc.Db.Cypher(&neoism.CypherQuery{\n\t\tStatement: `\n MATCH (u:User)\n WHERE u.handle={handle}\n MATCH (u)-[:CHIEF_OF]->(c:Circle)\n WHERE c.name={name}\n MATCH (u)-[:WROTE]->(m:Message)\n WHERE m.lastsaved={lastsaved}\n CREATE (m)-[r:PUB_TO]->(c)\n SET r.publishedat={date}\n RETURN count(r)\n `,\n\t\tParameters: neoism.Props{\n\t\t\t\"handle\": payload.Handle,\n\t\t\t\"name\": payload.Circle,\n\t\t\t\"lastsaved\": payload.LastSaved,\n\t\t\t\"date\": time.Now().Local(),\n\t\t},\n\t\tResult: &created,\n\t})\n\tpanicErr(err)\n\n\tif created[0].Count > 0 {\n\t\tw.WriteHeader(201)\n\t\tw.WriteJson(map[string]string{\n\t\t\t\"Response\": \"Success! Published message to \" + payload.Circle,\n\t\t})\n\t} else {\n\t\tw.WriteHeader(400)\n\t\tw.WriteJson(map[string]string{\n\t\t\t\"Response\": \"Bad request, no message published\",\n\t\t})\n\t}\n}", "title": "" }, { "docid": "521706e9a8f0210156d7f01ad631f392", "score": "0.5515084", "text": "func (ps *PubSub) Publish(channel, message string) error {\n\treturn ps.conn.SendCommand(\"PUBLISH\", channel, message)\n}", "title": "" }, { "docid": "d59d534638f757e84be70ccfb08a355e", "score": "0.5505187", "text": "func (p *LocalNetwork) Publish(m proto.Message, sender *localEndpoint) error {\n\tif sender == nil || m == nil {\n\t\treturn errors.New(\"invalid parameter\")\n\t}\n\n\tp.RLock()\n\tdefer p.RUnlock()\n\tfor k, v := range p.nodes {\n\t\tif k != sender.index {\n\t\t\t//mailbox\n\t\t\tv.mailbox <- &MsgHeader{\n\t\t\t\tsender: string(sender.index),\n\t\t\t\tmessage: m,\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "9ee0d3fe4fe86763cc4c8eff2396927d", "score": "0.5482283", "text": "func (w *Producer) Publish(topic string, body []byte) error {\n\t_, err := w.sendCommand(Publish(topic, body))\n\treturn err\n}", "title": "" }, { "docid": "1085a672facde7578cf139ae2e1fb028", "score": "0.54764324", "text": "func (redisUtil *RedisUtil) Publish(topic, message string) (err error) {\n\t_, err = redisUtil.DB.Do(\"publish\", topic, message)\n\tif err != nil {\n\t\tlog.Get().Errorf(\"redis publish message fail: %s\\n\", err)\n\t\treturn err\n\t}\n\treturn\n}", "title": "" }, { "docid": "5ac5663f4c7f12d3089ad2a23d21b353", "score": "0.5468609", "text": "func (p *Publisher) Publish(val MsgSchema) {\n\tp.m.Lock()\n\tdefer p.m.Unlock()\n\n\tmsg := newMsg(val)\n\tif p.lastMsg != nil {\n\t\tp.lastMsg.next <- msg\n\t}\n\tp.lastMsg = msg\n}", "title": "" }, { "docid": "f51f9a9d8041ba5434950738b6c21366", "score": "0.54669243", "text": "func (ps *PushSum) OnMessage(msg Message) {\n\tps.msgCh <- msg\n}", "title": "" }, { "docid": "7d39baa0daf5d8d0a32cd44ac07412e9", "score": "0.5460861", "text": "func (conn *Connection) Publish(msg inter.Message) error {\n\ttransport, err := msg.Transport(conn.ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttransport.RecordNetworkHop(conn.ConnectedServer(), conn.config.Identity, conn.ConnectedServer())\n\n\tif msg.CustomTarget() != \"\" {\n\t\treturn conn.publishConnectedBroadcast(msg, transport)\n\t}\n\n\tif conn.fw.IsFederated() {\n\t\treturn conn.publishFederated(msg, transport)\n\t}\n\n\treturn conn.publishConnected(msg, transport)\n}", "title": "" }, { "docid": "e11a191c39bb93c885ef1d5167e16945", "score": "0.54366094", "text": "func (c *InnerChannel) SendMsg(conn net.Conn, mid int64, key string) error {\n\tc.mutex.Lock()\n\tdefer c.mutex.Unlock()\n\t// find the next node\n\tfor n := c.message.Greate(mid); n != nil; n = n.Next() {\n\t\tm, ok := n.Member.(*Message)\n\t\tif !ok {\n\t\t\t// never happen\n\t\t\tpanic(ErrAssertType)\n\t\t}\n\n\t\t// check message expired\n\t\tif m.Expired() {\n\t\t\tif err := subRetWrite(conn, m.Msg, n.Score, key); err != nil {\n\t\t\t\tsubscriberStats.IncrFailedMessage()\n\t\t\t\tLog.Printf(\"subRetWrite() failed (%s)\", err.Error())\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tsubscriberStats.IncrSentMessage()\n\t\t} else {\n\t\t\t// WARN:though the node deleted, can access the next node\n\t\t\tc.message.Delete(n.Score)\n\t\t\tsubscriberStats.IncrExpiredMessage()\n\t\t\tLog.Printf(\"delete the expired message %d for device %s\", n.Score, key)\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "5ebc491d6f9fdb78b65f0457db1e7180", "score": "0.54308987", "text": "func (c *client) publish(body []byte) error {\n\treturn c.channel.Publish(c.config.Exchange, c.config.RoutingKey, false, false, c.msg(body))\n}", "title": "" }, { "docid": "268ba02b54599f97f30024951d4286d3", "score": "0.5409736", "text": "func (client *Client) Publish(batch publisher.Batch) error {\n\tevents := batch.Events()\n\tif outputEventProcessor != nil {\n\t\tupdatedEvents := outputEventProcessor.Process(events)\n\t\tif len(updatedEvents) > 0 {\n\t\t\tupdateEvent(batch, updatedEvents)\n\t\t} else {\n\t\t\tbatch.ACK()\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tpublishCount := len(batch.Events())\n\tlogp.Info(\"Publishing %d events\", publishCount)\n\terr := client.transportClient.Publish(batch)\n\tif err != nil {\n\t\treturn err\n\t}\n\tlogp.Info(\"Published %d events\", publishCount-len(batch.Events()))\n\treturn nil\n}", "title": "" }, { "docid": "5ba5eda269ae37c0413bf20313a4bec6", "score": "0.54055595", "text": "func (c *Connection) SendMessage(ex, key, msg string) error {\n\tch, err := c.c.Channel()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = ch.Publish(ex, key, false, false,\n\t\tamqp.Publishing{\n\t\t\tDeliveryMode: amqp.Persistent,\n\t\t\tContentType: \"text/plain\",\n\t\t\tBody: []byte(msg),\n\t\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ch.Close()\n}", "title": "" }, { "docid": "6d2acee9778cca3f45d6bd67ff940059", "score": "0.5405182", "text": "func sendMessageToSubscriber(h *DraftHub, c *Subscriber, message []byte) {\n select {\n case c.send <- message:\n default:\n close(c.send)\n delete(h.clients, c)\n }\n}", "title": "" }, { "docid": "ea130aa90eb49d117616376501f90f6d", "score": "0.54000664", "text": "func publishTelemetry(gatewayID string, client qtt.Client, mqttMsg *models.MQTTMessage) error {\n\ttelemetry := fmt.Sprintf(\"/devices/%v/events\", gatewayID)\n\n\tmqttBytes, err := json.Marshal(mqttMsg)\n\tif err != nil {\n\t\tg.Log.Error(\"failed to marshal mqtt message\", err)\n\t\treturn err\n\t}\n\n\tif token := client.Publish(telemetry, 1, true, mqttBytes); token.WaitTimeout(time.Second*5) && token.Error() != nil {\n\t\tg.Log.Info(\"failed to publish initial gateway payload\", token.Error())\n\t\treturn token.Error()\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c6c2ec9d11ccb48f574365bd3160440f", "score": "0.5396728", "text": "func (ctx *LegscContext) SendMessage(msg message.Message) {\n\tmsgBytes, err := message.Marshal(msg)\n\tif err != nil {\n\t\tlog.Error(\"error in encode message: \", err)\n\t\treturn\n\t}\n\n\tif msg.GetMessageType() != \"console\" {\n\t\tlog.Info(fmt.Sprintf(\"send message to server. msg_type: %s, msg_model: %s\", msg.GetMessageType(), msg.GetModel()))\n\t}\n\n\tconnMutex.Lock()\n\tdefer connMutex.Unlock()\n\t_ = ctx.Connection.WriteMessage(websocket.BinaryMessage, msgBytes)\n}", "title": "" }, { "docid": "fd1dab93f9f03553481811ccd5c4af69", "score": "0.53957134", "text": "func (h *Hub) doEmit(m PublishMessage) {\n\tdefer h.Unlock()\n\th.Lock()\n\n\th.Notify(\"emit\")\n\n\t// get topic subscribers\n\tclients, ok := h.topics[m.Topic]\n\tif !ok {\n\t\th.log.Println(\"[DEBUG] there are no subscriptions from:\", m.Topic)\n\t\treturn\n\t}\n\n\th.log.Printf(\"[DEBUG] Sending message to topic %v. Client count %d\", m.Topic, len(clients))\n\tfor _, c := range clients {\n\t\tc.send <- m.Payload\n\t}\n}", "title": "" }, { "docid": "58dbd89c252235f86d3ef421a98cfac8", "score": "0.53951925", "text": "func (m *MessageHub) OnMessage(callback func(header *js.Object, sender *js.Object, sendResponse func(interface{})) bool) {\n\tm.handlers = append(m.handlers, callback)\n}", "title": "" }, { "docid": "b108a9dce1aa57525926e5ed15d105c1", "score": "0.5393288", "text": "func (m *mqttv5) Publish(topic string, payload interface{}) error {\n\tp, err := m.checkPayload(payload)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = m.client.Publish(context.Background(), &paho.Publish{\n\t\tTopic: topic,\n\t\tQoS: byte(m.config.QoS),\n\t\tRetain: m.config.Retained,\n\t\tPayload: p,\n\t})\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "5d8c7ad26851b1530521db092e720b54", "score": "0.5388548", "text": "func (c *mqttclient) Publish(topic string, qos byte, retained bool, payload interface{}) Token {\n\tif !c.IsConnected() {\n\t\treturn &mqtttoken{err: errors.New(\"MQTT client not connected\")}\n\t}\n\n\tpub := packets.NewControlPacket(packets.Publish).(*packets.PublishPacket)\n\tpub.Qos = qos\n\tpub.TopicName = topic\n\tpub.Retain = retained\n\n\tswitch payload.(type) {\n\tcase string:\n\t\tpub.Payload = []byte(payload.(string))\n\tcase []byte:\n\t\tpub.Payload = payload.([]byte)\n\tdefault:\n\t\treturn &mqtttoken{err: errors.New(\"Unknown payload type\")}\n\t}\n\tpub.MessageID = c.mid\n\tc.mid++\n\n\terr := pub.Write(c.conn)\n\tif err != nil {\n\t\treturn &mqtttoken{err: err}\n\t}\n\t// update this for every control message that is sent successfully, for keepalive\n\tc.lastSend = time.Now()\n\n\treturn &mqtttoken{}\n}", "title": "" }, { "docid": "b1e4af878612ab1021bdf00f80a94f27", "score": "0.53880197", "text": "func publish(pubSocket *zmq4.Socket, update ClientUpdate, message []byte) {\n\tupdateType := reflect.TypeOf(update.state).String()\n\ttag := update.tag\n\tif _, ok := nopublishMessages[tag]; ok {\n\t\treturn\n\t}\n\tif _, ok := nologMessages[tag]; !ok {\n\t\tlog.Printf(\"SEND %v %v\\n\\tmessage body: %v\\n\", tag, updateType, string(message))\n\t}\n\t// Send the 2-part message to all subscribers (clients).\n\t// If there are errors, retry up to `maxSendAttempts` times with a sleep between.\n\tfullmessage := [][]byte{[]byte(tag), message}\n\tconst maxSendAttempts = 5\n\tvar err error\n\tfor iter := 0; iter < maxSendAttempts; iter++ {\n\t\tif _, err = pubSocket.SendMessage(fullmessage); err == nil {\n\t\t\tbreak\n\t\t}\n\t\ttime.Sleep(time.Millisecond)\n\t}\n\tif err != nil {\n\t\tfmt.Printf(\"Could not send a %s message even with %d attempts in client_updater.publish\", tag, maxSendAttempts)\n\t\tpanic(err)\n\t}\n}", "title": "" }, { "docid": "eaa39f89408d0f9414c1e66ba41bbf74", "score": "0.5386193", "text": "func PublishToRedis(rdb *redis.Client, deviceID string, operation models.MQTTProcessOperation, processType string, customMessage []byte) error {\n\t// publish to chrysalis cloud the change\n\tpubSubMsg := &models.MQTTMessage{\n\t\tDeviceID: deviceID,\n\t\tCreated: time.Now().UTC().Unix() * 1000,\n\t\tProcessOperation: operation,\n\t\tProcessType: models.MQTTProcessType(processType),\n\t\tMessage: customMessage,\n\t}\n\tpubSubMsgBytes, imsgErr := json.Marshal(pubSubMsg)\n\tif imsgErr != nil {\n\t\tg.Log.Error(\"failed to publish redis internally\", imsgErr)\n\t\treturn imsgErr\n\t} else {\n\t\trCmd := rdb.Publish(models.RedisLocalMQTTChannel, string(pubSubMsgBytes))\n\t\tif rCmd.Err() != nil {\n\t\t\tg.Log.Error(\"failed to publish change to redis internally\", rCmd.Err())\n\t\t\treturn rCmd.Err()\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "34f4f6562c549b2a3dd81d1d928ff539", "score": "0.5385614", "text": "func (aeh *AzureEventHubs) Publish(req *pubsub.PublishRequest) error {\n\terr := aeh.hub.Send(context.Background(), &eventhub.Event{Data: req.Data})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error from publish: %s\", err)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "c8d5f1df66f997099dea2e9ddd4bbc4c", "score": "0.5383724", "text": "func PublishMessage(ariMessage string, producer chan []byte) {\n\t// unmarshal into an ari.Event so we can append some extra information\n\tvar info eventInfo\n\tvar message ari.Event\n\tvar pi *proxyInstance\n\tvar exists bool = false\n\tjson.Unmarshal([]byte(ariMessage), &message)\n\tjson.Unmarshal([]byte(ariMessage), &info)\n\tmessage.ServerID = config.ServerID\n\tmessage.Timestamp = time.Now()\n\tmessage.ARI_Body = ariMessage\n\n\tswitch {\n\tcase info.Type == \"StasisStart\":\n\n\t\t// Check to see if the new channel was already in the map, which means it\n\t\t// was created by an originate with ID\n\t\tpi, exists = proxyInstances.Get(info.Channel.ID)\n\t\tif exists {\n\t\t\tbreak\n\t\t}\n\t\t// since we're starting a new application instance, create the proxy side\n\t\tdialogID := ari.UUID()\n\t\tInfo.Println(\"New StasisStart found. Created new dialogID of \", dialogID)\n\t\tas, err := json.Marshal(ari.AppStart{Application: info.Application, DialogID: dialogID, ServerID: config.ServerID})\n\t\tproducer <- as\n\n\t\t// TODO: this sleep is required to allow the application time to spin up. In the future we likely want\n\t\t// to implement some sort of feedback mechanism in order to remove this sleep timer.\n\t\ttime.Sleep(50 * time.Millisecond)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tInfo.Printf(\"Created new proxy instance mapping for dialog '%s' and channel '%s'\", dialogID, info.Channel.ID)\n\t\tpi = NewProxyInstance(dialogID) // create new proxy instance for the dialog\n\t\tproxyInstances.Add(info.Channel.ID, pi) // add the dialog to the proxyInstances map to track its life\n\t\texists = true\n\n\tcase info.Type == \"StasisEnd\":\n\t\tInfo.Printf(\"Ending application instance for channel '%s'\", info.Channel.ID)\n\t\t// on application end, perform clean up checks\n\t\tpi, exists = proxyInstances.Get(info.Channel.ID)\n\t\tif exists {\n\t\t\tpi.removeAllObjects()\n\t\t}\n\n\tcase info.Type == \"BridgeDestroyed\":\n\t\tpi, exists = proxyInstances.Get(info.Bridge.ID)\n\t\tif exists {\n\t\t\tpi.removeObject(info.Bridge.ID)\n\t\t}\n\n\tcase info.Type == \"ChannelDestroyed\":\n\t\tpi, exists = proxyInstances.Get(info.Channel.ID)\n\t\tif exists {\n\t\t\tpi.removeObject(info.Channel.ID)\n\t\t}\n\n\t// check if prefix is part of the minChan{} struct\n\tcase strings.HasPrefix(info.Type, \"Channel\"):\n\t\tpi, exists = proxyInstances.Get(info.Channel.ID)\n\n\t// check if prefix is part of the minBridge{} struct\n\tcase strings.HasPrefix(message.Type, \"Bridge\"):\n\t\tpi, exists = proxyInstances.Get(info.Bridge.ID)\n\n\t// check if prefix is part of the minPlay{} struct\n\tcase strings.HasPrefix(message.Type, \"Playback\"):\n\t\tpi, exists = proxyInstances.Get(info.Playback.ID)\n\n\t// check if prefix is part of the minRec{} struct (this one uses a Name instead of ID for some reason)\n\tcase strings.HasPrefix(message.Type, \"Recording\"):\n\t\tpi, exists = proxyInstances.Get(info.Recording.Name)\n\n\tdefault:\n\t\tWarning.Println(\"No handler for event type\")\n\t\t//pi, exists = proxyInstances[]\n\t\t// if not matching, then we need to perform checks against the\n\t\t// existing map to determine where to send this ARI message.\n\t}\n\n\t// marshal the message back into a string\n\tbusMessage, err := json.Marshal(message)\n\tif err != nil {\n\t\tError.Println(err)\n\t\treturn\n\t}\n\tDebug.Printf(\"Bus Data:\\n%s\\n\", busMessage)\n\n\t// push the busMessage onto the producer channel\n\tif exists {\n\t\tpi.Events <- busMessage\n\t}\n}", "title": "" }, { "docid": "4fc5a224cdf76645e6c8011f9463d302", "score": "0.53824735", "text": "func (rConn *RabbitConnection) SendMessageOnTopic(message interface{}, topic string) {\n\tswitch message.(type) {\n\tcase error:\n\t\treturn\n\t}\n\tbitifyMessage, err := json.Marshal(message)\n\tif err != nil {\n\t\tlogger.Error(\"while marshaling \\\"get\\\" :\", err)\n\t\treturn\n\t}\n\terr = rConn.partiesChannel.Publish(\n\t\t\"parties_topic\", // exchange\n\t\ttopic, // routing key\n\t\tfalse, // mandatory\n\t\tfalse, // immediate\n\t\tamqp.Publishing{\n\t\t\tContentType: \"application/json\",\n\t\t\tBody: bitifyMessage,\n\t\t})\n\tif err != nil {\n\t\tlogger.Error(\"error while sending message :\", err)\n\t}\n}", "title": "" }, { "docid": "a01b03ddb30ea792af6580687dafda2b", "score": "0.53694284", "text": "func (a *Adaptor) Publish(topic string, message []byte) bool {\n\tif a.client == nil {\n\t\treturn false\n\t}\n\ta.client.Publish(topic, message)\n\treturn true\n}", "title": "" }, { "docid": "8634c1ddbbe82e1f869b8061596394dd", "score": "0.53672135", "text": "func (monitor *Monitor) Publish(handler Publisher) {\n\tmonitor.Publisher = handler\n}", "title": "" }, { "docid": "b381c3529bb9d2810fd4af2c5cc4dd9d", "score": "0.5367048", "text": "func (mqc *MQTTConnection) Publish(topic string, payload []byte) error {\n\t//compressed := snappy.Encode(nil, payload)\n\ttoken := mqc.conn.Publish(topic, 1, false, payload)\n\ttoken.Wait()\n\treturn token.Error()\n}", "title": "" }, { "docid": "8977ca35e5ba4283b8ce66153ee55959", "score": "0.53651947", "text": "func (t *Topic) Publish(jsonObj interface{}) error {\n\tbs, err := json.Marshal(jsonObj)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Fail to marshal the json object to be produced for the topic %s\", t.name)\n\t}\n\n\tmsg := &proto.Message{Value: bs}\n\n\tif _, err := t.distributer.Distribute(t.name, msg); err != nil {\n\t\treturn fmt.Errorf(\"Fail to produce messages for the topic %s\", t.name)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "2714fc15a70ff4a07fcc021119cc7563", "score": "0.53646153", "text": "func (t *Topic) Publish(msg string) error {\n\treturn t.svc.Publish(t.arn, msg, nil)\n}", "title": "" }, { "docid": "96527e372a470b91dfd9b99a5ddf8448", "score": "0.53632444", "text": "func (c *Channel) SendMessage(message *Message) {\n c.lastEventId = message.id\n\n for c, open := range c.clients {\n if open {\n c.send <- message\n }\n }\n\n log.Printf(\"go-sse: message sent to channel '%s'.\", c.name)\n}", "title": "" }, { "docid": "74a311a63a7148c1789905fe098e0716", "score": "0.53505856", "text": "func (g *goRedisWrapper) Send(topic string, message types.MessageEnvelope) error {\n\tencoded, err := json.Marshal(message)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = g.wrappedClient.Publish(topic, encoded).Result()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "960ccb8e14ed2a1ec8d9196373a8092c", "score": "0.53475785", "text": "func (p *Producer) publish(ctx context.Context, msg api.Message) {\n\tpayload, err := cloudevents.AsJSON(ctx, msg)\n\tif err != nil {\n\t\tmsg.SetError(errors.Wrap(err, \"error converting message to CloudEvent JSON format\"))\n\t\treturn\n\t}\n\n\tt := p.client.Publish(\n\t\tp.endpoint.config.Remaining,\n\t\tp.endpoint.config.QoS,\n\t\tp.endpoint.config.Retained,\n\t\tpayload)\n\n\tt.Wait()\n\n\tif err := t.Error(); err != nil {\n\t\tmsg.SetError(errors.Wrapf(\n\t\t\terr,\n\t\t\t\"error while publishing to topic '%s' on server '%s'\",\n\t\t\tp.endpoint.config.Remaining,\n\t\t\tp.endpoint.config.Broker),\n\t\t)\n\t}\n}", "title": "" }, { "docid": "dd1791c4f7941756ac74708d7659442f", "score": "0.5346369", "text": "func Publish(sc *stan.Conn, subj string, msg *[]byte) (err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = fmt.Errorf(\"recovered from: %v\", r)\n\t\t\tlog.Printf(\"Publish(): %v\\n\", err.Error())\n\t\t}\n\t}()\n\n\tif sc == nil {\n\t\terr = errors.New(\"cant'publish on empty stan connection\")\n\t\treturn\n\t}\n\terr = (*sc).Publish(subj, *msg)\n\tif err != nil {\n\t\tlog.Printf(\"Error during publish: %v\\n\", err)\n\t}\n\treturn\n}", "title": "" }, { "docid": "6059bfe89221d554ee8a87da5b1b0dfc", "score": "0.5340462", "text": "func (r *Room) PushMessage(from, msg string) error {\n\tmsg = r.formatMessage(msg)\n\tresponse := msgFromUserToChatroom{\n\t\tmsgCommon{\n\t\t\tCmd: \"newchatmsg\",\n\t\t\tData: msg,\n\t\t},\n\t\tuuid.NewV4().String(),\n\t\ttime.Now().Unix(),\n\t\tfrom,\n\t}\n\ttoSend, err := json.Marshal(response)\n\tif err != nil {\n\t\treturn err\n\t}\n\tr.archive(toSend)\n\tfor e := r.subscribers.Front(); e != nil; e = e.Next() {\n\t\tgo func(sub *subscriber) {\n\t\t\tif _, err := sub.WS.Write(toSend); err != nil {\n\t\t\t\tr.Unsub(sub.Nic)\n\t\t\t}\n\t\t}(e.Value.(*subscriber))\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "3754ae542c471aaf04d875fc3af716fa", "score": "0.53392416", "text": "func (c *pulsarConnection) Publish(topic string, payload []byte) error {\n\n\tproducer, err := c.Client.CreateProducer(pulsar.ProducerOptions{\n\t\tTopic: topic,\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not create producer, err = %w\", err)\n\t}\n\n\t_, err = producer.Send(context.Background(), &pulsar.ProducerMessage{\n\t\tPayload: payload,\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not publish message, err = %w\", err)\n\t}\n\tproducer.Close()\n\n\treturn nil\n}", "title": "" }, { "docid": "ea5f906fcea5951eb8bcc962f815eb08", "score": "0.5336585", "text": "func (ps *Client) Publish(ctx context.Context, message []byte) error {\n\tmsg := &pubsub.Message{\n\t\tBody: message,\n\t}\n\n\terr := ps.sendWithRetry(ctx, msg, 5)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Cloud not publish message to topic\")\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "d4ca5f6a8b0f63ad285572987d1bf29e", "score": "0.5336215", "text": "func (s *Standalone) Publish(publishAppID, pubsubName, topic string, payload []byte, socket string, metadata map[string]interface{}) error {\n\tif publishAppID == \"\" {\n\t\treturn errors.New(\"publishAppID is missing\")\n\t}\n\n\tif pubsubName == \"\" {\n\t\treturn errors.New(\"pubsubName is missing\")\n\t}\n\n\tif topic == \"\" {\n\t\treturn errors.New(\"topic is missing\")\n\t}\n\n\tqueryParams := getQueryParams(metadata)\n\n\tl, err := s.process.List()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tinstance, err := getDaprInstance(l, publishAppID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\turl := fmt.Sprintf(\"http://unix/v%s/publish/%s/%s%s\", api.RuntimeAPIVersion, pubsubName, topic, queryParams)\n\n\tvar httpc http.Client\n\tif socket != \"\" {\n\t\thttpc.Transport = &http.Transport{\n\t\t\tDialContext: func(_ context.Context, _, _ string) (net.Conn, error) {\n\t\t\t\treturn net.Dial(\"unix\", utils.GetSocket(socket, publishAppID, \"http\"))\n\t\t\t},\n\t\t}\n\t} else {\n\t\turl = fmt.Sprintf(\"http://localhost:%s/v%s/publish/%s/%s%s\", fmt.Sprintf(\"%v\", instance.HTTPPort), api.RuntimeAPIVersion, pubsubName, topic, queryParams)\n\t}\n\n\tcontentType := \"application/json\"\n\n\t// Detect publishing with CloudEvents envelope.\n\tvar cloudEvent map[string]interface{}\n\tif json.Unmarshal(payload, &cloudEvent); err == nil {\n\t\t_, hasID := cloudEvent[\"id\"]\n\t\t_, hasSource := cloudEvent[\"source\"]\n\t\t_, hasSpecVersion := cloudEvent[\"specversion\"]\n\t\t_, hasType := cloudEvent[\"type\"]\n\t\t_, hasData := cloudEvent[\"data\"]\n\t\tif hasID && hasSource && hasSpecVersion && hasType && hasData {\n\t\t\tcontentType = \"application/cloudevents+json\"\n\t\t}\n\t}\n\n\tr, err := httpc.Post(url, contentType, bytes.NewBuffer(payload))\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer r.Body.Close()\n\tif r.StatusCode >= 300 || r.StatusCode < 200 {\n\t\tfmt.Println(url)\n\t\treturn fmt.Errorf(\"unexpected status code %d on publishing to %s in %s\", r.StatusCode, topic, pubsubName)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "d3fa5bb93aecadcc912a8f21121fc7ac", "score": "0.53348696", "text": "func (mb *MyBroker) SendMsg(objectToSend []byte, header map[string]string, topic string) error {\n\n\tvar message broker.Message\n\tmessage.Header = header\n\tmessage.Body = objectToSend\n\n\tif mb.Br == nil {\n\t\terr1 := errors.New(\"broker is not defined or connected\")\n\t\tlog.Printf(glErr.BrkNoMessageSent(topic, err1))\n\t\treturn err1\n\n\t}\n\terr := mb.Br.Connect()\n\tif err != nil {\n\t\t// log.Printf(\"unable to connect to broker: Error: %v\" , err)\n\t\treturn err\n\t}\n\n\terr = mb.Br.Publish(topic, &message)\n\tif err != nil {\n\t\tlog.Printf(glErr.BrkNoMessageSent(topic, err))\n\t\treturn err\n\t}\n\tlog.Printf(\"sent message to Topic %s. Message %v\", topic, &header)\n\treturn nil\n}", "title": "" }, { "docid": "22e03813aa030fafcd1c94f7a09e95a9", "score": "0.5332281", "text": "func (p *Publisher) Publish(ctx context.Context, m *Message) error {\n\tid, err := p.xAdd(ctx, m.Stream, m.ID, m.Values)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tm.ID = id\n\treturn nil\n}", "title": "" }, { "docid": "5b8eab68019fd254b8bbbd32680db38f", "score": "0.5327847", "text": "func (h *Messaging) Publish(queue string, message []byte) error {\n\topLog := ctrl.Log.WithName(\"handlers\").WithName(\"LagoonTasks\")\n\t// no need to re-try here, this is on a cron schedule and the error is returned, cron will try again whenever it is set to run next\n\tmessageQueue, err := mq.New(h.Config)\n\tif err != nil {\n\t\topLog.Info(fmt.Sprintf(\"Failed to initialize message queue manager: %v\", err))\n\t\treturn err\n\t}\n\tdefer messageQueue.Close()\n\n\tproducer, err := messageQueue.AsyncProducer(queue)\n\tif err != nil {\n\t\topLog.Info(fmt.Sprintf(\"Failed to get async producer: %v\", err))\n\t\treturn err\n\t}\n\tproducer.Produce([]byte(fmt.Sprintf(\"%s\", message)))\n\treturn nil\n}", "title": "" } ]
9497372dc8689679283a09be7ada28cb
convert nanosecond to millisecond
[ { "docid": "04456a56eaf0b0862e2db0397e32a6ef", "score": "0.7237843", "text": "func to_ms(nano int64) int64 {\n\treturn nano / int64(time.Millisecond)\n}", "title": "" } ]
[ { "docid": "adf21eb6a627edf8eb797883b8cde027", "score": "0.704143", "text": "func (t Time) Nanosecond() int {}", "title": "" }, { "docid": "cd4eee1de9ec3ff6ae8c414f4ea62e45", "score": "0.701448", "text": "func tickspersecond() int64", "title": "" }, { "docid": "9ed2b7b5ddb9d248eaf6d974d8af00b5", "score": "0.691119", "text": "func nanotime() int64", "title": "" }, { "docid": "9ed2b7b5ddb9d248eaf6d974d8af00b5", "score": "0.691119", "text": "func nanotime() int64", "title": "" }, { "docid": "9ed2b7b5ddb9d248eaf6d974d8af00b5", "score": "0.691119", "text": "func nanotime() int64", "title": "" }, { "docid": "9ed2b7b5ddb9d248eaf6d974d8af00b5", "score": "0.691119", "text": "func nanotime() int64", "title": "" }, { "docid": "bbf6c2d0486ad6e67518d2ac0b58326f", "score": "0.6844626", "text": "func timeToMillis(t time.Time) float64 {\n\treturn float64(t.UnixNano() / 1000000)\n}", "title": "" }, { "docid": "ad758207f803638ce1551bc3b701bdb9", "score": "0.6655809", "text": "func ConvertNanosecondsToHz(val float64) float64 {\n\treturn val / 1e7\n}", "title": "" }, { "docid": "de65a868654cef06eeae238d78919c10", "score": "0.6604753", "text": "func msToTime(t int64) time.Time {\n\treturn time.Unix(t/int64(1000), (t%int64(1000))*int64(1000000))\n}", "title": "" }, { "docid": "7891ee5a3502c1833a928fd0715458f7", "score": "0.64512867", "text": "func millisToTime(millis float64) time.Time {\n\treturn time.Unix(0, int64(millis*1000000.0))\n}", "title": "" }, { "docid": "17017704fdcb5c6c494ecf9f9eac53d8", "score": "0.6443521", "text": "func ToMillis(t time.Time) int64 {\n\treturn t.UnixNano() / 1e6\n}", "title": "" }, { "docid": "dcda003c8f51e0ec16047bf16e04487d", "score": "0.6423488", "text": "func toMilliseconds(duration time.Duration) float64 {\n\tif duration < time.Microsecond*10 {\n\t\treturn 0\n\t}\n\n\tms := float64(duration) / float64(time.Millisecond)\n\t// Round time to 0.02 precision\n\treturn math.Round(ms*100) / 100\n}", "title": "" }, { "docid": "2dbedbaa0330d7f9a1ea9e9327eedf14", "score": "0.6403525", "text": "func UnixMilliseconds(t time.Time) float64 {\n\tnanosPerSecond := float64(time.Second) / float64(time.Nanosecond)\n\treturn float64(t.UnixNano()) / nanosPerSecond\n}", "title": "" }, { "docid": "c1a8d5b6c14e1c624cdd461546f509b3", "score": "0.63540626", "text": "func timeToUnixMS(t time.Time) int64 {\n\treturn t.UnixNano() / int64(time.Millisecond)\n}", "title": "" }, { "docid": "75ab9e3fc68fb3b7d4dc85c5701288a0", "score": "0.62803787", "text": "func NsMicroseconds(count int64) int64 { return count * 1e3 }", "title": "" }, { "docid": "b4c1d75628f0b3c4ec98b87d4be02ac2", "score": "0.62732005", "text": "func GetMonoTime() int64 {\n\tsec, nsec := getRawMonoTime()\n\n\t// to milliseconds\n\treturn sec * 1000 + (nsec / (1 * 1000 * 1000))\n}", "title": "" }, { "docid": "c6bb22026ab71dc199c785781f60ef94", "score": "0.6255375", "text": "func currentTimeMillis() int64 {\n\tresult := time.Nanoseconds()\n\treturn result / 1e6\n}", "title": "" }, { "docid": "afe45fdd24b196fc2ab3cac8b0804599", "score": "0.62530565", "text": "func NsMilliseconds(count int64) int64 { return NsMicroseconds(count * 1e3) }", "title": "" }, { "docid": "c713b604d87ee17726a1f816bf2bff95", "score": "0.62319535", "text": "func milliTime() (r []byte) {\n\tbuf := new(bytes.Buffer)\n\tt := time.Now().UnixNano()\n\tm := t / 1e6\n\tbinary.Write(buf, binary.BigEndian, m)\n\treturn buf.Bytes()[2:]\n}", "title": "" }, { "docid": "c713b604d87ee17726a1f816bf2bff95", "score": "0.62319535", "text": "func milliTime() (r []byte) {\n\tbuf := new(bytes.Buffer)\n\tt := time.Now().UnixNano()\n\tm := t / 1e6\n\tbinary.Write(buf, binary.BigEndian, m)\n\treturn buf.Bytes()[2:]\n}", "title": "" }, { "docid": "f9eff746558dd217020e3511b22583e5", "score": "0.62128305", "text": "func ToUnixMillis(t time.Time) int64 {\n\treturn t.UnixNano() / (int64(time.Millisecond) / int64(time.Nanosecond))\n}", "title": "" }, { "docid": "fc6b9e65ffdaa200f4a63bedfc82b167", "score": "0.6201359", "text": "func humanToNanoTime(value []byte) ([]byte) {\n\tdura, err := time.ParseDuration(string(value))\n\tif err != nil {\n\t\treturn value\n\t}\n\treturn []byte(strconv.FormatInt(dura.Nanoseconds(), 10))\n}", "title": "" }, { "docid": "0e20474d41a65a0d5c6185507fc0a795", "score": "0.61722803", "text": "func TimeUnitNano(unit string) int64 {\n\tswitch unit {\n\tcase TimeUnitSeconds:\n\t\treturn int64(time.Second)\n\tcase TimeUnitMilliseconds:\n\t\treturn int64(time.Millisecond)\n\tcase TimeUnitMicroseconds:\n\t\treturn int64(time.Microsecond)\n\tdefault:\n\t\treturn int64(time.Nanosecond)\n\t}\n}", "title": "" }, { "docid": "15211d11bacb2931bfb3d5f8b12331a9", "score": "0.61362135", "text": "func toMSTimestamp(t time.Time) int64 {\n\treturn t.UnixNano() / 1e6\n}", "title": "" }, { "docid": "2a0589c9f1cf80905ce95d6a031db771", "score": "0.6124202", "text": "func msToTime(ms int64) time.Time {\n\treturn time.Unix(0, ms*int64(time.Millisecond))\n}", "title": "" }, { "docid": "2e56df26a6103b84c8d4516b93a185b0", "score": "0.61083215", "text": "func unixMilli(msec int64) time.Time {\n\treturn time.Unix(msec/1e3, (msec%1e3)*1e6)\n}", "title": "" }, { "docid": "06c38d461602c3b407edbf89b022b206", "score": "0.6103269", "text": "func (xt XSDTime) Nanosecond() int {\n\treturn xt.innerTime.Nanosecond()\n}", "title": "" }, { "docid": "f6f737d0a725e3558c31ef7e77f8d4c5", "score": "0.60836166", "text": "func TimevalToNsec(tv Timeval) int64 { return tv.Nano() }", "title": "" }, { "docid": "693ef5703e0d348ff6a52d080302aaeb", "score": "0.60576683", "text": "func convertTimeStamp(timestamp uint64) int64 {\n\treturn int64(timestamp / uint64(int64(time.Millisecond)/int64(time.Nanosecond)))\n}", "title": "" }, { "docid": "4845fd8876079091d1a412c9752ed2ab", "score": "0.60510296", "text": "func Ms(duration time.Duration) float64 {\n\treturn float64(duration / time.Millisecond)\n}", "title": "" }, { "docid": "45de0eea75dcb8d98886e60c7382d235", "score": "0.60488033", "text": "func millisI(nanos int64) float64 {\n\treturn millisF(float64(nanos))\n}", "title": "" }, { "docid": "c0d003951f8185c7a37785bb30257398", "score": "0.60484606", "text": "func (t Time) Milliseconds() int64 {\n\treturn time.Time(t).UnixNano() / DivideMilliseconds\n}", "title": "" }, { "docid": "24f8a9a723f06375af84d1c250f63647", "score": "0.60430205", "text": "func fromUnixMilli(ms int64) time.Time {\n\treturn time.Unix(ms/int64(millisInSecond), (ms%int64(millisInSecond))*int64(nsInSecond))\n}", "title": "" }, { "docid": "481dd05d944ddda2cdb1371f22b3008b", "score": "0.60389954", "text": "func (t Time) Microseconds() int64 {\n\treturn time.Time(t).UnixNano() / DivideMicroseconds\n}", "title": "" }, { "docid": "eecdd1798beef46b00a7ba4fec719c30", "score": "0.60209626", "text": "func (e PrecisionTiming) durationToMs(x time.Duration) float64 {\n\treturn float64(x) / float64(time.Millisecond)\n}", "title": "" }, { "docid": "b1024787006736bdb2018add02b4e255", "score": "0.60071933", "text": "func ToMilliSec(date time.Time) int64 {\n\treturn date.UnixNano() / 1000000\n}", "title": "" }, { "docid": "0cefff1d07b14b77af043b07c9b47a69", "score": "0.59829223", "text": "func run_timeNano() int64", "title": "" }, { "docid": "dd1f7d882b9ca6c353547cd96fd5a385", "score": "0.5964353", "text": "func (cvr Converter) SecondsToMilliseconds(s Seconds) Milliseconds {\n\tMs := Milliseconds(float64(s) * 1000)\n\treturn Ms\n}", "title": "" }, { "docid": "f2778c0752d97a3941330bfe28957827", "score": "0.59530365", "text": "func timeToEpochMS(t time.Time) int64 {\n\treturn t.UnixNano() / 1000000\n}", "title": "" }, { "docid": "218e664d4485b2f1d8574a96ded912d8", "score": "0.59424645", "text": "func timeFromMillis(millis int64) time.Time {\n\treturn time.Unix(0, millis*1e6)\n}", "title": "" }, { "docid": "d5f71d0b0843f6117f9cdfee39f6a7c2", "score": "0.59361166", "text": "func AsMillis(t time.Time, offset int) int {\n\treturn int(t.UTC().UnixNano()/1000000) + offset*1000\n}", "title": "" }, { "docid": "ca81810c51b21ab23f7f5904c6301833", "score": "0.5919824", "text": "func durationToMilliseconds(d time.Duration) (uint64, error) {\n\tif d < 0 {\n\t\treturn 0, fmt.Errorf(\"report period cannot be negative: %v\", d)\n\t}\n\n\treturn uint64(d / time.Millisecond), nil\n}", "title": "" }, { "docid": "c0f0a5b2e21afc433a17d83286b2db36", "score": "0.5899615", "text": "func DropMilliseconds(t time.Time) time.Time {\n\treturn t.Truncate(time.Second)\n}", "title": "" }, { "docid": "f6a6312724cb68fad19c88b151a4779e", "score": "0.58725154", "text": "func micros(d time.Duration) int {\n\treturn int(d.Seconds() * 1000000)\n}", "title": "" }, { "docid": "0fdd0fcb488c6eaca4be5d32b1e0dfcb", "score": "0.58702594", "text": "func (cvr Converter) SecondsToMilliseconds(s Seconds) Milliseconds {\n\treturn Milliseconds(s) * Milliseconds(60)\n}", "title": "" }, { "docid": "0d82533b996a6032664cef0cd3c916b3", "score": "0.5849817", "text": "func microsecondsPerPulse(bpm float32) time.Duration {\n\treturn time.Duration((float32(Minute) * float32(Microsecond)) / (float32(Ppqn) * bpm))\n}", "title": "" }, { "docid": "2c77b2a6e4a620bf0333747eec8645fc", "score": "0.583606", "text": "func NsSeconds(count int64) int64 { return NsMilliseconds(count * 1e3) }", "title": "" }, { "docid": "7b681292a831693f92dc5308ffbfd259", "score": "0.5831653", "text": "func CurrentNanosecond() int64 {\n\treturn CurrentMicrosecond() * 1e3\n}", "title": "" }, { "docid": "6377c384d6b0867c603904e79add0cd1", "score": "0.5810626", "text": "func FormatTimeMillis(ms int64) string {\n\treturn TimeFromMillis(ms).String()\n}", "title": "" }, { "docid": "5678cc1119c85b82c9c8190026c7e476", "score": "0.5808789", "text": "func TimeFromMillis(ms int64) time.Time {\n\treturn time.Unix(0, ms*nanosecondsInMillisecond)\n}", "title": "" }, { "docid": "5a9ccadf5d3c40b1c70be9b51b988b5a", "score": "0.58087754", "text": "func unixMilli(t time.Time) int64 {\n\treturn t.UnixNano() / int64(time.Millisecond)\n}", "title": "" }, { "docid": "a691a697b8e05cc4a3400d0daa90b30c", "score": "0.5794742", "text": "func SecondsToTime(n int64) Time {\n\treturn Time(n * 1e6)\n}", "title": "" }, { "docid": "73cb2bdf949a7a336c9219c0dc27a527", "score": "0.5794651", "text": "func makeTimestampMilli() int64 {\n\treturn time.Now().UnixNano() / int64(time.Millisecond)\n}", "title": "" }, { "docid": "73cb2bdf949a7a336c9219c0dc27a527", "score": "0.5794651", "text": "func makeTimestampMilli() int64 {\n\treturn time.Now().UnixNano() / int64(time.Millisecond)\n}", "title": "" }, { "docid": "532eb25aa72d000f58774b33a6b245b4", "score": "0.57921946", "text": "func toUnixMsec(t time.Time) int64 {\n\treturn t.UnixNano() / 1e6\n}", "title": "" }, { "docid": "1e865af45910a3b49ad21b9c995898f3", "score": "0.5776027", "text": "func MsSince(start time.Time) float64 {\n\treturn float64(time.Since(start) / time.Millisecond)\n}", "title": "" }, { "docid": "1e865af45910a3b49ad21b9c995898f3", "score": "0.5776027", "text": "func MsSince(start time.Time) float64 {\n\treturn float64(time.Since(start) / time.Millisecond)\n}", "title": "" }, { "docid": "b84023029ec800b766c7d817ea561dc1", "score": "0.57470995", "text": "func MakeTimestampMilli() int64 {\n\treturn time.Now().UnixNano() / int64(time.Millisecond)\n}", "title": "" }, { "docid": "4c808b36445d1e5b79ca1fc1f541a169", "score": "0.5739089", "text": "func fseconds(d time.Duration) float64 { return float64(d) / float64(time.Second) }", "title": "" }, { "docid": "104e1c4018cc68ba379813f029821d5a", "score": "0.5738594", "text": "func FormatTimeMillis(tsMillis uint64) string {\n\treturn time.Unix(0, int64(tsMillis*UnixTimeUnitOffset)).Format(TimeFormat)\n}", "title": "" }, { "docid": "74ccdcf34cf25c2e38c31d6b30360091", "score": "0.57341635", "text": "func getSeconds(data *speedTestData) float64 {\n\treturn float64(data.Milliseconds) / 1000\n}", "title": "" }, { "docid": "ded0eff2653d3687101844da503d3591", "score": "0.57137173", "text": "func getTimestreamTime(t time.Time) (timeUnit types.TimeUnit, timeValue string) {\n\tnanosTime := t.UnixNano()\n\tif nanosTime%1e9 == 0 {\n\t\ttimeUnit = types.TimeUnitSeconds\n\t\ttimeValue = strconv.FormatInt(nanosTime/1e9, 10)\n\t} else if nanosTime%1e6 == 0 {\n\t\ttimeUnit = types.TimeUnitMilliseconds\n\t\ttimeValue = strconv.FormatInt(nanosTime/1e6, 10)\n\t} else if nanosTime%1e3 == 0 {\n\t\ttimeUnit = types.TimeUnitMicroseconds\n\t\ttimeValue = strconv.FormatInt(nanosTime/1e3, 10)\n\t} else {\n\t\ttimeUnit = types.TimeUnitNanoseconds\n\t\ttimeValue = strconv.FormatInt(nanosTime, 10)\n\t}\n\treturn timeUnit, timeValue\n}", "title": "" }, { "docid": "2d055656a42e131c9f5280edbc7233ce", "score": "0.57046044", "text": "func ticks() timeUnit {\n\t// convert RTC counter from seconds to microseconds\n\ttimerCounter := uint64(stm32.RTC.CNTH.Get()<<16|stm32.RTC.CNTL.Get()) * 1000 * 1000\n\n\t// add the fractional part of current time using DIV register\n\ttimerCounter += uint64(0x8000-stm32.RTC.DIVL.Get()) * 31\n\n\t// change since last measurement\n\toffset := (timerCounter - timerLastCounter)\n\ttimerLastCounter = timerCounter\n\ttimestamp += timeUnit(offset)\n\treturn timestamp\n}", "title": "" }, { "docid": "775fe0835ae94d6104bc5dccde1aba44", "score": "0.5700969", "text": "func stampToTime(quadPart C.LONGLONG) time.Time {\n\tft := windows.Filetime{\n\t\tHighDateTime: uint32(quadPart >> 32),\n\t\tLowDateTime: uint32(quadPart & math.MaxUint32),\n\t}\n\treturn time.Unix(0, ft.Nanoseconds())\n}", "title": "" }, { "docid": "eb065e39d75d7880735408eb2b60d5c5", "score": "0.5697675", "text": "func TimespecToNsec(ts Timespec) int64 { return ts.Nano() }", "title": "" }, { "docid": "baec5af11d08249feba37afbb1c1f3c4", "score": "0.5693492", "text": "func NowMs() int64 {\n\treturn time.Now().UnixNano() / 1000000\n}", "title": "" }, { "docid": "3f5e28a1c715ca650b34db6f82fd4f4c", "score": "0.56685615", "text": "func FramesToMS(frames int, framerate float64) int {\n\treturn int((float64(frames) / float64(framerate)) * Second)\n}", "title": "" }, { "docid": "c5d99d4576b2c34a75347dd8bbfa15e7", "score": "0.56622696", "text": "func UnixMilli(t time.Time) int64 {\n\treturn t.Round(time.Millisecond).UnixNano() / (int64(time.Millisecond) / (int64(time.Millisecond)))\n}", "title": "" }, { "docid": "0a36c36d0223e464b78af8f1ba80457a", "score": "0.56599337", "text": "func TimestampToUnixMillisecondsString(time time.Time) string {\n\treturn strconv.FormatInt(time.Unix()*1000, 10)\n}", "title": "" }, { "docid": "47195aec7cc5b110d90fb4ea34ec3079", "score": "0.5647064", "text": "func milliseconds(ms int64) time.Duration {\n\treturn time.Duration(ms * 1000 * 1000)\n}", "title": "" }, { "docid": "afe42a1553b291ff16886c1c02f85942", "score": "0.5631193", "text": "func (dt DateTime) Nanosecond() int {\n\treturn dt.Time().Nanosecond()\n}", "title": "" }, { "docid": "ddddf44f803968debc1925c508c4291b", "score": "0.56265867", "text": "func Snotime() uint64 {\n\t// Note: Division is left here instead of being impl in asm since the compiler optimizes this\n\t// into mul+shift, which is easier to read when left in as simple division.\n\t// This doesn't affect performance. The asm won't get inlined anyway while this function\n\t// will.\n\t//\n\t// 4e4 instead of TimeUnit (4e6) because the time we get from the OS is in units of 100ns.\n\treturn ostime() / 4e4\n}", "title": "" }, { "docid": "f2a2f785c7246a148f347b988939c9b2", "score": "0.5610673", "text": "func dbToTime(t float64) time.Time {\n\tif t <= 0.0 {\n\t\tpanic(\"Don't expect negative time\")\n\t}\n\n\tsec := math.Trunc(t)\n\tnsec := (t - sec) * 1.0e9\n\n\treturn time.Unix(int64(sec), int64(nsec))\n}", "title": "" }, { "docid": "1e4107aecaea785658051b668359a737", "score": "0.5609938", "text": "func UnixMilli(ms int64) time.Time {\n\treturn time.Unix(0, ms*int64(time.Millisecond))\n}", "title": "" }, { "docid": "a9c9d723984ef70646d28c059268bde5", "score": "0.55763596", "text": "func NsecToTimeval(nsec int64) (tv Timeval) {\n\tnsec += 999 // round up to microsecond\n\ttv.Sec = nsec / 1e9\n\ttv.Usec = nsec % 1e9 / 1e3\n\treturn\n}", "title": "" }, { "docid": "636177b02f56794dab23717ed21cb133", "score": "0.5566936", "text": "func (dt *DateTime) Nanosecond() *Number {\n\topChain := dt.chain.enter(\"Nanosecond()\")\n\tdefer opChain.leave()\n\n\tif opChain.failed() {\n\t\treturn newNumber(opChain, float64(0))\n\t}\n\n\treturn newNumber(opChain, float64(dt.value.Nanosecond()))\n}", "title": "" }, { "docid": "248daa59b86a3f5bfe5c9e5f15077ca3", "score": "0.55641526", "text": "func getEpochMillis(timestamp time.Time) int64 {\n\treturn timestamp.UnixNano() / int64(time.Millisecond)\n}", "title": "" }, { "docid": "42444ebe3aadfb3bba25a131f174050b", "score": "0.5558837", "text": "func makeTimestamp() int64 {\n return time.Now().UnixNano() / int64(time.Millisecond)\n}", "title": "" }, { "docid": "5d0b0ee4eca182b30c19a2100ae0dda7", "score": "0.55538905", "text": "func DurationInMilliseconds(d time.Duration) string {\n\treturn fmt.Sprintf(\"%.0fms\", d.Seconds()*1e3)\n}", "title": "" }, { "docid": "39996164225bfb160b6bf2bb8f332065", "score": "0.553499", "text": "func (t Time) UnixMilli() int64 {\n\treturn (time.Time)(t).UnixNano() / int64(time.Millisecond)\n}", "title": "" }, { "docid": "d381eebb6c608ac2728e091c5208aab4", "score": "0.55278903", "text": "func SinceInMicroseconds(start time.Time) float64 {\n\treturn float64(time.Since(start).Nanoseconds() / time.Microsecond.Nanoseconds())\n}", "title": "" }, { "docid": "d381eebb6c608ac2728e091c5208aab4", "score": "0.55278903", "text": "func SinceInMicroseconds(start time.Time) float64 {\n\treturn float64(time.Since(start).Nanoseconds() / time.Microsecond.Nanoseconds())\n}", "title": "" }, { "docid": "710781466ca49fb17f4911b928999067", "score": "0.5525334", "text": "func GetTimestampMicroSec() int64 {\n\treturn time.Now().UnixNano() / int64(time.Microsecond)\n}", "title": "" }, { "docid": "7fab34ae4bc298384eb1ea934530f10d", "score": "0.55218494", "text": "func convertTime(time uint64, stream_uot, target_uot UnitOfTime) uint64 {\n\tunitmultiplier := map[UnitOfTime]uint64{\n\t\tUOT_NS: 1000000000,\n\t\tUOT_US: 1000000,\n\t\tUOT_MS: 1000,\n\t\tUOT_S: 1}\n\treturn time / unitmultiplier[stream_uot] * unitmultiplier[target_uot]\n}", "title": "" }, { "docid": "b31bfb804292e2ab83596f9d9e86642a", "score": "0.547965", "text": "func timeToDb(t time.Time) float64 {\n\treturn float64(t.Unix()) + float64(t.UnixNano())/1.0e9\n}", "title": "" }, { "docid": "dd5305bf0119d972f611bb683e946850", "score": "0.54795027", "text": "func UnixMilli(t time.Time) int64 {\n\treturn t.UTC().UnixNano() / 1000000\n}", "title": "" }, { "docid": "07a08991e31dc8571eceee92258f6c4e", "score": "0.5472317", "text": "func (dt *DateTime) GetNanosecond() *Number {\n\treturn dt.Nanosecond()\n}", "title": "" }, { "docid": "11b0505f2a869ec7ab526e3dd890cd1e", "score": "0.54710114", "text": "func TicksToUnixNano(ticks int64) int64 {\n\treturn TicksToTime(ticks).UnixNano()\n}", "title": "" }, { "docid": "2f63bba8131672549cd1a54763aea2bb", "score": "0.54571307", "text": "func Unix(sec int64, nsec int64) Time {}", "title": "" }, { "docid": "a90729e5413b7780a23ba9b8751bcde3", "score": "0.5447112", "text": "func UnixMilli() int64 {\n\treturn time.Now().UnixNano() / DivideMilliseconds\n}", "title": "" }, { "docid": "1a7ec874069cf6249be1f46c0a5139c0", "score": "0.5445948", "text": "func Time(t time.Time) int64 {\n\treturn t.UnixNano() / 1000000\n}", "title": "" }, { "docid": "05977f2961bf066df3da29563c9532a1", "score": "0.5434984", "text": "func GetCurrentTimeStampMilli() int64 {\n\treturn time.Now().UnixNano() / int64(time.Millisecond)\n}", "title": "" }, { "docid": "7df47cdae33d1a36f95392ae81bc483c", "score": "0.54200065", "text": "func NanoTime() int64", "title": "" }, { "docid": "5754b2817913b57d87b3afca035df73b", "score": "0.5396144", "text": "func (ft *filetime) Nanoseconds() int64 {\n\t// 100-nanosecond intervals since January 1, 1601\n\tnsec := int64(ft.HighDateTime)<<32 + int64(ft.LowDateTime)\n\t// change starting time to the Epoch (00:00:00 UTC, January 1, 1970)\n\tnsec -= 116444736000000000\n\t// convert into nanoseconds\n\tnsec *= 100\n\treturn nsec\n}", "title": "" }, { "docid": "7623acfd64a1f3724b50f192eb612bd8", "score": "0.53911775", "text": "func ExampleTime_TimestampMilli() {\n\tt := gtime.TimestampMilli()\n\n\tfmt.Println(t)\n\n\t// May output:\n\t// 1533686888000\n}", "title": "" }, { "docid": "75544d02f2cbd4ccc8326698cb6e6c50", "score": "0.5372606", "text": "func Nanotime() int64 {\n\treturn nanotime()\n}", "title": "" }, { "docid": "75544d02f2cbd4ccc8326698cb6e6c50", "score": "0.5372606", "text": "func Nanotime() int64 {\n\treturn nanotime()\n}", "title": "" }, { "docid": "b9b8f76d9b39e96a55b47e4de1f1b61d", "score": "0.5370099", "text": "func ToTime(t uint64) time.Time {\n\tseconds := (t & 0xFFFFFFFF00000000) >> 32\n\tfractional := float64(t&0x00000000FFFFFFFF) / float64(0xFFFFFFFF)\n\td := time.Duration(seconds)*time.Second + time.Duration(fractional*1e9)*time.Nanosecond\n\n\treturn time.Unix(0, 0).Add(-2208988800 * time.Second).Add(d)\n}", "title": "" }, { "docid": "7824753a08e8c6962ee32e6040d2f070", "score": "0.5362937", "text": "func getStartTimeMs(interval string) int64 {\n\tstartTime := roundTime(time.Now())\n\n\tswitch interval {\n\tcase TWOYEAR:\n\t\tstartTime = startTime.AddDate(-2, 0, 0)\n\tcase YEAR:\n\t\tstartTime = startTime.AddDate(-1, 0, 0)\n\tcase SIXMONTH:\n\t\tstartTime = startTime.AddDate(0, -6, 0)\n\tcase THREEMONTH:\n\t\tstartTime = startTime.AddDate(0, -3, 0)\n\tcase MONTH:\n\t\tstartTime = startTime.AddDate(0, -1, 0)\n\tcase WEEK:\n\t\tstartTime = startTime.AddDate(0, 0, -4)\n\tcase DAY:\n\t\tstartTime = startTime.AddDate(0, 0, -1)\n\tcase TWELVEHOUR:\n\t\tstartTime = startTime.Add(-12 * time.Hour)\n\tcase SIXHOUR:\n\t\tstartTime = startTime.Add(-6 * time.Hour)\n\tcase HOUR:\n\t\tstartTime = startTime.Add(-1 * time.Hour)\n\tcase THIRTYMINUTE:\n\t\tstartTime = startTime.Add(-30 * time.Minute)\n\t}\n\n\treturn startTime.Unix() * 1000\n}", "title": "" }, { "docid": "045fece86593cf72d5ecd3fec9388d39", "score": "0.53578067", "text": "func ticks() timeUnit {\n\t// milliseconds to microseconds\n\treturn tickCount * 1000\n}", "title": "" } ]
ae4c571b3cc9c341bdab09f92f0d0f87
List lists all AwsVpcEndpointRouteTableAssociations in the indexer.
[ { "docid": "e018c9ba10b014984860ffbe5e438985", "score": "0.77598995", "text": "func (s *awsVpcEndpointRouteTableAssociationLister) List(selector labels.Selector) (ret []*v1.AwsVpcEndpointRouteTableAssociation, err error) {\n\terr = cache.ListAll(s.indexer, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v1.AwsVpcEndpointRouteTableAssociation))\n\t})\n\treturn ret, err\n}", "title": "" } ]
[ { "docid": "5230fcc9e70ac1583d49b44a23266ad2", "score": "0.68626916", "text": "func (s awsVpcEndpointRouteTableAssociationNamespaceLister) List(selector labels.Selector) (ret []*v1.AwsVpcEndpointRouteTableAssociation, err error) {\n\terr = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v1.AwsVpcEndpointRouteTableAssociation))\n\t})\n\treturn ret, err\n}", "title": "" }, { "docid": "809531f9ec36bc5532ea30c82905fac6", "score": "0.66770136", "text": "func NewAwsVpcEndpointRouteTableAssociationLister(indexer cache.Indexer) AwsVpcEndpointRouteTableAssociationLister {\n\treturn &awsVpcEndpointRouteTableAssociationLister{indexer: indexer}\n}", "title": "" }, { "docid": "dbc119ab17c41bb02052f437c6d633b9", "score": "0.64228827", "text": "func (s *awsVpcEndpointRouteTableAssociationLister) AwsVpcEndpointRouteTableAssociations(namespace string) AwsVpcEndpointRouteTableAssociationNamespaceLister {\n\treturn awsVpcEndpointRouteTableAssociationNamespaceLister{indexer: s.indexer, namespace: namespace}\n}", "title": "" }, { "docid": "a385cd09258594a2eae1fbeeebe12710", "score": "0.6118408", "text": "func List(c *golangsdk.ServiceClient, opts ListOptsBuilder) pagination.Pager {\n\turl := rootURL(c)\n\n\tif opts != nil {\n\t\tquery, err := opts.ToRouteTableListQuery()\n\t\tif err != nil {\n\t\t\treturn pagination.Pager{Err: err}\n\t\t}\n\t\turl += query\n\t}\n\n\treturn pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page {\n\t\tp := RouteTablePage{pagination.MarkerPageBase{PageResult: r}}\n\t\tp.MarkerPageBase.Owner = p\n\t\treturn p\n\t})\n}", "title": "" }, { "docid": "90cd96bcfd58f1501f5fdf0890a9e89e", "score": "0.5669709", "text": "func (client *Client) ListTransitRouterRouteTableAssociationsWithOptions(request *ListTransitRouterRouteTableAssociationsRequest, runtime *util.RuntimeOptions) (_result *ListTransitRouterRouteTableAssociationsResponse, _err error) {\n\t_err = util.ValidateModel(request)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\tquery := map[string]interface{}{}\n\tif !tea.BoolValue(util.IsUnset(request.MaxResults)) {\n\t\tquery[\"MaxResults\"] = request.MaxResults\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.NextToken)) {\n\t\tquery[\"NextToken\"] = request.NextToken\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.OwnerAccount)) {\n\t\tquery[\"OwnerAccount\"] = request.OwnerAccount\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.OwnerId)) {\n\t\tquery[\"OwnerId\"] = request.OwnerId\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.ResourceOwnerAccount)) {\n\t\tquery[\"ResourceOwnerAccount\"] = request.ResourceOwnerAccount\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.ResourceOwnerId)) {\n\t\tquery[\"ResourceOwnerId\"] = request.ResourceOwnerId\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.Status)) {\n\t\tquery[\"Status\"] = request.Status\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.TransitRouterAttachmentId)) {\n\t\tquery[\"TransitRouterAttachmentId\"] = request.TransitRouterAttachmentId\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.TransitRouterAttachmentResourceId)) {\n\t\tquery[\"TransitRouterAttachmentResourceId\"] = request.TransitRouterAttachmentResourceId\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.TransitRouterAttachmentResourceType)) {\n\t\tquery[\"TransitRouterAttachmentResourceType\"] = request.TransitRouterAttachmentResourceType\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.TransitRouterRouteTableId)) {\n\t\tquery[\"TransitRouterRouteTableId\"] = request.TransitRouterRouteTableId\n\t}\n\n\treq := &openapi.OpenApiRequest{\n\t\tQuery: openapiutil.Query(query),\n\t}\n\tparams := &openapi.Params{\n\t\tAction: tea.String(\"ListTransitRouterRouteTableAssociations\"),\n\t\tVersion: tea.String(\"2017-09-12\"),\n\t\tProtocol: tea.String(\"HTTPS\"),\n\t\tPathname: tea.String(\"/\"),\n\t\tMethod: tea.String(\"POST\"),\n\t\tAuthType: tea.String(\"AK\"),\n\t\tStyle: tea.String(\"RPC\"),\n\t\tReqBodyType: tea.String(\"formData\"),\n\t\tBodyType: tea.String(\"json\"),\n\t}\n\t_result = &ListTransitRouterRouteTableAssociationsResponse{}\n\t_body, _err := client.CallApi(params, req, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_err = tea.Convert(_body, &_result)\n\treturn _result, _err\n}", "title": "" }, { "docid": "bbab55abf8543bf351a901eee2c8e6f7", "score": "0.53400373", "text": "func (_m *EC2API) DescribeRouteTables(_a0 *ec2.DescribeRouteTablesInput) (output *ec2.DescribeRouteTablesOutput, err error) {\r\n\toutput = &ec2.DescribeRouteTablesOutput{}\r\n\tif err := _m.recorder.CheckError(\"DescribeRouteTables\"); err != nil {\r\n\t\treturn output, err\r\n\t}\r\n\t_m.recorder.Record(\"DescribeRouteTables\")\r\n\treturns, exist := _m.recorder.giveRecordedOutput(\"DescribeRouteTables\", _a0)\r\n\tif exist {\r\n\t\tassertedErr, _ := returns[1].(error)\r\n\t\treturn returns[0].(*ec2.DescribeRouteTablesOutput), assertedErr\r\n\t}\r\n\r\n\tfilteredRouteTables := []*ec2.RouteTable{}\r\n\tfor _, filterId := range _a0.RouteTableIds {\r\n\t\tfor routeTableID, routeTable := range _m.routeTable {\r\n\t\t\tif routeTableID == *filterId {\r\n\t\t\t\tfilteredRouteTables = append(filteredRouteTables, routeTable)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif len(_a0.Filters) == 0 {\r\n\t\toutput.RouteTables = filteredRouteTables\r\n\t\treturn\r\n\t}\r\n\r\n\tif len(filteredRouteTables) == 0 {\r\n\t\tfor _, val := range _m.routeTable {\r\n\t\t\tfilteredRouteTables = append(filteredRouteTables, val)\r\n\t\t}\r\n\t}\r\n\r\n\tfurtherFilteredRouteTables := []*ec2.RouteTable{}\r\n\r\n\tfor _, val := range filteredRouteTables {\r\n\t\tfor _, filter := range _a0.Filters {\r\n\t\t\tif *filter.Name == \"vpc-id\" {\r\n\t\t\t\tfor _, vpcId := range filter.Values {\r\n\t\t\t\t\tif *val.VpcId == *vpcId {\r\n\t\t\t\t\t\tfurtherFilteredRouteTables = append(furtherFilteredRouteTables, val)\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\toutput.RouteTables = furtherFilteredRouteTables\r\n\treturn\r\n}", "title": "" }, { "docid": "df869d6ef9624e4d7ab0e40c012d0305", "score": "0.5246815", "text": "func (a *NetworkAPI) ListRouteTables(ctx *gin.Context) {\n\tlogger := correlationid.LogrusLogger(a.logger, ctx)\n\n\torganization := auth.GetCurrentOrganization(ctx.Request)\n\tprovider, ok := getRequiredProviderFromContext(ctx, logger)\n\tif !ok {\n\t\treturn\n\t}\n\tregion, resourceGroup, ok := getRequiredRegionOrResourceGroupFromContext(ctx, provider, logger)\n\tif !ok {\n\t\treturn\n\t}\n\tsecretID, ok := getRequiredSecretIDFromContext(ctx, logger)\n\tif !ok {\n\t\treturn\n\t}\n\tnetworkID := ctx.Param(\"id\")\n\n\tlogger = logger.WithFields(logrus.Fields{\n\t\t\"organization\": organization.ID,\n\t\t\"provider\": provider,\n\t\t\"region\": region,\n\t\t\"resourceGroup\": resourceGroup,\n\t\t\"secretID\": secretID,\n\t\t\"networkID\": networkID,\n\t})\n\n\tsir, err := secret.Store.Get(organization.ID, secretID)\n\tif err != nil {\n\t\treplyWithError(ctx, err)\n\t\treturn\n\t}\n\n\tif err := secret.ValidateSecretType(sir, provider); err != nil {\n\t\treplyWithError(ctx, err)\n\t\treturn\n\t}\n\n\tsvcParams := providers.ServiceParams{\n\t\tLogger: logger,\n\t\tProvider: provider,\n\t\tRegion: region,\n\t\tResourceGroupName: resourceGroup,\n\t\tSecret: sir,\n\t}\n\tsvc, err := providers.NewNetworkService(svcParams)\n\tif err != nil {\n\t\treplyWithError(ctx, err)\n\t\treturn\n\t}\n\trouteTables, err := svc.ListRouteTables(networkID)\n\tif err != nil {\n\t\treplyWithError(ctx, err)\n\t\treturn\n\t}\n\n\trouteTableInfos := make([]RouteTableInfo, len(routeTables))\n\tfor i := range routeTables {\n\t\trouteTableInfos[i].ID = routeTables[i].ID()\n\t\trouteTableInfos[i].Name = routeTables[i].Name()\n\t}\n\tctx.JSON(http.StatusOK, routeTableInfos)\n}", "title": "" }, { "docid": "c3fd463da5fedc296f7830253632c64d", "score": "0.5207833", "text": "func (client *Client) ListTransitRouterRouteTableAssociations(request *ListTransitRouterRouteTableAssociationsRequest) (_result *ListTransitRouterRouteTableAssociationsResponse, _err error) {\n\truntime := &util.RuntimeOptions{}\n\t_result = &ListTransitRouterRouteTableAssociationsResponse{}\n\t_body, _err := client.ListTransitRouterRouteTableAssociationsWithOptions(request, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_result = _body\n\treturn _result, _err\n}", "title": "" }, { "docid": "c7a26dd8929ba10064b231d97f6d5a3d", "score": "0.5181082", "text": "func (t *Template) GetAllEC2GatewayRouteTableAssociationResources() map[string]*ec2.GatewayRouteTableAssociation {\n\tresults := map[string]*ec2.GatewayRouteTableAssociation{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase *ec2.GatewayRouteTableAssociation:\n\t\t\tresults[name] = resource\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "ac7af0bfe0340f2a4633ea015812a72a", "score": "0.5146137", "text": "func (cl *AgentClient) EndpointList() ([]netproto.Endpoint, error) {\n\tvar endpointList []netproto.Endpoint\n\n\terr := netutils.HTTPGet(\"http://\"+cl.agentURL+\"/api/endpoints/\", &endpointList)\n\n\treturn endpointList, err\n}", "title": "" }, { "docid": "7d55945d389586bbdfbcbd4c2205064a", "score": "0.513219", "text": "func (t *Template) GetAllEC2RouteTableResources() map[string]*ec2.RouteTable {\n\tresults := map[string]*ec2.RouteTable{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase *ec2.RouteTable:\n\t\t\tresults[name] = resource\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "df2b69db81b8cbb613b26d0adba5164c", "score": "0.51218194", "text": "func (s *awsVpcDhcpOptionsAssociationLister) List(selector labels.Selector) (ret []*v1.AwsVpcDhcpOptionsAssociation, err error) {\n\terr = cache.ListAll(s.indexer, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v1.AwsVpcDhcpOptionsAssociation))\n\t})\n\treturn ret, err\n}", "title": "" }, { "docid": "694bf4473523cf61f5eb61b811dcf5cc", "score": "0.50689644", "text": "func (s awsVpcEndpointRouteTableAssociationNamespaceLister) Get(name string) (*v1.AwsVpcEndpointRouteTableAssociation, error) {\n\tobj, exists, err := s.indexer.GetByKey(s.namespace + \"/\" + name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !exists {\n\t\treturn nil, errors.NewNotFound(v1.Resource(\"awsvpcendpointroutetableassociation\"), name)\n\t}\n\treturn obj.(*v1.AwsVpcEndpointRouteTableAssociation), nil\n}", "title": "" }, { "docid": "59d14ed357c0971a433bf8031a4761bd", "score": "0.5050315", "text": "func ListEndpoints(options OptionsDef, nsID string) error {\n\tdata, err := GetEndpoints(options, nsID)\n\tif err != nil {\n\t\treturn err\n\t}\n\tw := tabwriter.NewWriter(os.Stdout, 0, 0, 4, '\\t', tabwriter.AlignRight|tabwriter.Debug)\n\tfmt.Fprintf(w, \"%s\\t%s\\t%s\\t%s\\t%s\\n\", \"ID\", \"Name\", \"Kind\", \"Public\", \"Namespace\")\n\tfor _, ep := range data {\n\t\tfmt.Fprintf(w, \"%s\\t%s\\t%s\\t%t\\t%s\\n\", ep.ID.Hex(), ep.Name, ep.Kind, ep.Public, ep.Namespace)\n\t}\n\tw.Flush()\n\treturn nil\n}", "title": "" }, { "docid": "2b7e126bfed8a9bca4937e597acbd927", "score": "0.5040303", "text": "func (s *Stack) GetRouteTable() []tcpip.Route {\n\ts.routeMu.RLock()\n\tdefer s.routeMu.RUnlock()\n\treturn append([]tcpip.Route(nil), s.routeTable...)\n}", "title": "" }, { "docid": "d5db371e0410e223f6c290da608e7b64", "score": "0.49334607", "text": "func (v *version) SubnetRouteTableAssociations() SubnetRouteTableAssociationInformer {\n\treturn &subnetRouteTableAssociationInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}\n}", "title": "" }, { "docid": "a756017e3f5c44c98897642e64d1b5d9", "score": "0.49193597", "text": "func (s *vpnConnectionRouteLister) List(selector labels.Selector) (ret []*v1alpha1.VpnConnectionRoute, err error) {\n\terr = cache.ListAll(s.indexer, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v1alpha1.VpnConnectionRoute))\n\t})\n\treturn ret, err\n}", "title": "" }, { "docid": "7aa8664b6cd174b7625874859e9d6508", "score": "0.48649752", "text": "func (e *ecsTaskObserver) ListEndpoints() []observer.Endpoint { return nil }", "title": "" }, { "docid": "8b33221ec919f3f7bee58ffc52aaf711", "score": "0.48607385", "text": "func (t *Template) GetAllEC2SubnetRouteTableAssociationResources() map[string]*ec2.SubnetRouteTableAssociation {\n\tresults := map[string]*ec2.SubnetRouteTableAssociation{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase *ec2.SubnetRouteTableAssociation:\n\t\t\tresults[name] = resource\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "e64cb42af2405034693770e677756dbe", "score": "0.48393875", "text": "func EncodeGrpcRespRouteTableList(ctx context.Context, response interface{}) (interface{}, error) {\n\treturn response, nil\n}", "title": "" }, { "docid": "aed9345157c5e7fe9ae268b425cc61ea", "score": "0.48361364", "text": "func (this *APIServer) PrintRouteTable(w io.Writer) {\n\tthis.router.PrintRouteTable(w)\n}", "title": "" }, { "docid": "babe4fafb2eaa3604230eacbba54dccb", "score": "0.48347974", "text": "func (client *Client) ListVpcEndpointConnections(request *ListVpcEndpointConnectionsRequest) (response *ListVpcEndpointConnectionsResponse, err error) {\n\tresponse = CreateListVpcEndpointConnectionsResponse()\n\terr = client.DoAction(request, response)\n\treturn\n}", "title": "" }, { "docid": "ee67eedbb92c0158abae3db9712824a5", "score": "0.48136052", "text": "func (client AppServicePlansClient) ListRoutesForVnetSender(req *http.Request) (*http.Response, error) {\n\treturn client.Send(req, azure.DoRetryWithRegistration(client.Client))\n}", "title": "" }, { "docid": "86b4ab74ada31022d9c77212f27420ff", "score": "0.47964197", "text": "func DescribeRouteTables(cloud fi.Cloud, clusterName string) (map[string]*ec2.RouteTable, error) {\n\tc := cloud.(awsup.AWSCloud)\n\n\trouteTables := make(map[string]*ec2.RouteTable)\n\tklog.V(2).Info(\"Listing EC2 RouteTables\")\n\tfor _, filters := range buildEC2FiltersForCluster(clusterName) {\n\t\trequest := &ec2.DescribeRouteTablesInput{\n\t\t\tFilters: filters,\n\t\t}\n\t\tresponse, err := c.EC2().DescribeRouteTables(request)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error listing RouteTables: %v\", err)\n\t\t}\n\n\t\tfor _, rt := range response.RouteTables {\n\t\t\trouteTables[aws.StringValue(rt.RouteTableId)] = rt\n\t\t}\n\t}\n\n\treturn routeTables, nil\n}", "title": "" }, { "docid": "81cabd8878cc30b40e0e4777981953f9", "score": "0.4796229", "text": "func (s awsVpcDhcpOptionsAssociationNamespaceLister) List(selector labels.Selector) (ret []*v1.AwsVpcDhcpOptionsAssociation, err error) {\n\terr = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v1.AwsVpcDhcpOptionsAssociation))\n\t})\n\treturn ret, err\n}", "title": "" }, { "docid": "3c9faa8d051b97d0c6a7b365a4dfb383", "score": "0.4790585", "text": "func (s *awsDmsEndpointLister) List(selector labels.Selector) (ret []*v1.AwsDmsEndpoint, err error) {\n\terr = cache.ListAll(s.indexer, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v1.AwsDmsEndpoint))\n\t})\n\treturn ret, err\n}", "title": "" }, { "docid": "7aa37991fb7e68785e8692d577d2e4c2", "score": "0.4788219", "text": "func PrintInboundEndpointList(inboundEPList *artifactutils.InboundEndpointList, format string) {\n\tif inboundEPList.Count > 0 {\n\t\tinboundEPs := inboundEPList.InboundEndpoints\n\t\tinboundEPListContext := getContextWithFormat(format, defaultInboundEndpointListTableFormat)\n\n\t\trenderer := func(w io.Writer, t *template.Template) error {\n\t\t\tfor _, inboundEP := range inboundEPs {\n\t\t\t\tif err := t.Execute(w, inboundEP); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\t_, _ = w.Write([]byte{'\\n'})\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t\tinboundEPListTableHeaders := map[string]string{\n\t\t\t\"Name\": nameHeader,\n\t\t\t\"Type\": typeHeader,\n\t\t}\n\t\tif err := inboundEPListContext.Write(renderer, inboundEPListTableHeaders); err != nil {\n\t\t\tfmt.Println(\"Error executing template:\", err.Error())\n\t\t}\n\t} else {\n\t\tfmt.Println(\"No Inbound Endpoints found\")\n\t}\n}", "title": "" }, { "docid": "a6be015aa942777387a6ca8b6ab9ed17", "score": "0.47608685", "text": "func (c *FakeEc2ClientVPNEndpoints) List(opts v1.ListOptions) (result *v1alpha1.Ec2ClientVPNEndpointList, err error) {\n\tobj, err := c.Fake.\n\t\tInvokes(testing.NewListAction(ec2clientvpnendpointsResource, ec2clientvpnendpointsKind, c.ns, opts), &v1alpha1.Ec2ClientVPNEndpointList{})\n\n\tif obj == nil {\n\t\treturn nil, err\n\t}\n\n\tlabel, _, _ := testing.ExtractFromListOptions(opts)\n\tif label == nil {\n\t\tlabel = labels.Everything()\n\t}\n\tlist := &v1alpha1.Ec2ClientVPNEndpointList{ListMeta: obj.(*v1alpha1.Ec2ClientVPNEndpointList).ListMeta}\n\tfor _, item := range obj.(*v1alpha1.Ec2ClientVPNEndpointList).Items {\n\t\tif label.Matches(labels.Set(item.Labels)) {\n\t\t\tlist.Items = append(list.Items, item)\n\t\t}\n\t}\n\treturn list, err\n}", "title": "" }, { "docid": "0dfb2e0ed4147682ee964a7dddd254f6", "score": "0.47531304", "text": "func (v WaypointsResource) List(c buffalo.Context) error {\n\t// Get the DB connection from the context\n\ttx, ok := c.Value(\"tx\").(*pop.Connection)\n\tif !ok {\n\t\treturn fmt.Errorf(\"no transaction found\")\n\t}\n\n\twaypoints := &models.Waypoints{}\n\n\t// Paginate results. Params \"page\" and \"per_page\" control pagination.\n\t// Default values are \"page=1\" and \"per_page=20\".\n\tq := tx.PaginateFromParams(c.Params())\n\n\t// Retrieve all Waypoints from the DB\n\tif err := q.All(waypoints); err != nil {\n\t\treturn err\n\t}\n\n\treturn responder.Wants(\"html\", func(c buffalo.Context) error {\n\t\t// Add the paginator to the context so it can be used in the template.\n\t\tc.Set(\"pagination\", q.Paginator)\n\n\t\tc.Set(\"waypoints\", waypoints)\n\t\treturn c.Render(http.StatusOK, r.HTML(\"/waypoints/index.plush.html\"))\n\t}).Wants(\"json\", func(c buffalo.Context) error {\n\t\treturn c.Render(200, r.JSON(waypoints))\n\t}).Wants(\"xml\", func(c buffalo.Context) error {\n\t\treturn c.Render(200, r.XML(waypoints))\n\t}).Respond(c)\n}", "title": "" }, { "docid": "8866078bc73956e9e6f3c0097fbc5d86", "score": "0.4730105", "text": "func ListEndpoints(c *gin.Context) {\n\tconst traefik = \"traefik\"\n\tvar endpointList []*EndpointItem\n\tvar endpointURLs []*EndPointURLs\n\n\t// --- [ Get cluster ] ---- //\n\tbanzaiUtils.LogInfo(banzaiConstants.TagListDeployments, \"Get cluster\")\n\tcloudCluster, err := cloud.GetClusterFromDB(c)\n\tif err != nil {\n\t\treturn\n\t}\n\tbanzaiUtils.LogInfo(banzaiConstants.TagListDeployments, \"Getting cluster succeeded\")\n\n\tcloudType := cloudCluster.Cloud\n\n\t// --- [ Get K8S Config ] --- //\n\tkubeConfig, err := cloud.GetK8SConfig(cloudCluster, c)\n\tif err != nil {\n\t\treturn\n\t}\n\tapiconfig, _ := clientcmd.Load(kubeConfig)\n\tclientConfig := clientcmd.NewDefaultClientConfig(*apiconfig, &clientcmd.ConfigOverrides{})\n\tconfig, err := clientConfig.ClientConfig()\n\tif err != nil {\n\t\tbanzaiUtils.LogErrorf(banzaiConstants.TagKubernetes, \"Could not create kubernetes client from config. %+v\", config)\n\t\tbanzaiUtils.LogErrorf(banzaiConstants.TagKubernetes, \"Error message: %+v\", err)\n\t\tc.JSON(http.StatusBadRequest, ErrorResponse{\n\t\t\tCode: http.StatusBadRequest,\n\t\t\tMessage: fmt.Sprintf(\"create kubernetes client failed: %v\", err),\n\t\t})\n\t\treturn\n\t}\n\tclient, err := kubernetes.NewForConfig(config)\n\tif err != nil {\n\t\tbanzaiUtils.LogError(banzaiConstants.TagKubernetes, \"Could not create kubernetes client from config.\")\n\t\tbanzaiUtils.LogErrorf(banzaiConstants.TagKubernetes, \"Error message: %+v\", err)\n\t\tc.JSON(http.StatusBadRequest, ErrorResponse{\n\t\t\tCode: http.StatusBadRequest,\n\t\t\tMessage: fmt.Sprintf(\"create kubernetes client failed: %v\", err),\n\t\t})\n\t\treturn\n\t}\n\tserviceList, err := client.CoreV1().Services(\"\").List(meta_v1.ListOptions{})\n\tif err != nil {\n\t\tbanzaiUtils.LogErrorf(banzaiConstants.TagKubernetes, \"Could not list kubernetes services, %+v\", config)\n\t\tbanzaiUtils.LogErrorf(banzaiConstants.TagKubernetes, \"Error message: %+v\", err)\n\t\tc.JSON(http.StatusInternalServerError, ErrorResponse{\n\t\t\tCode: http.StatusInternalServerError,\n\t\t\tMessage: fmt.Sprintf(\"List kubernetes services failed: %+v\", err),\n\t\t})\n\t\treturn\n\t}\n\tfor _, service := range serviceList.Items {\n\t\tbanzaiUtils.LogDebugf(banzaiConstants.TagKubernetes, \"Service: %#v\", service.Status)\n\t\tif len(service.Status.LoadBalancer.Ingress) > 0 {\n\t\t\tvar publicIp string\n\t\t\tswitch cloudType {\n\t\t\tcase banzaiConstants.Amazon:\n\t\t\t\tpublicIp = service.Status.LoadBalancer.Ingress[0].Hostname\n\t\t\tcase banzaiConstants.Azure:\n\t\t\t\tpublicIp = service.Status.LoadBalancer.Ingress[0].IP\n\t\t\t}\n\t\t\tif strings.Contains(service.Spec.Selector[\"app\"], traefik) {\n\t\t\t\tingressList, err := client.ExtensionsV1beta1().Ingresses(\"\").List(meta_v1.ListOptions{})\n\t\t\t\tif err != nil {\n\t\t\t\t\tbanzaiUtils.LogErrorf(banzaiConstants.TagKubernetes, \"Could not list kubernetes ingresses, %+v\", config)\n\t\t\t\t\tbanzaiUtils.LogErrorf(banzaiConstants.TagKubernetes, \"Error message: %+v\", err)\n\t\t\t\t\tc.JSON(http.StatusInternalServerError, ErrorResponse{\n\t\t\t\t\t\tCode: http.StatusInternalServerError,\n\t\t\t\t\t\tMessage: fmt.Sprintf(\"List kubernetes ingresses failed: %+v\", err),\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tfor _, ingress := range ingressList.Items {\n\t\t\t\t\tbanzaiUtils.LogDebugf(banzaiConstants.TagKubernetes, \"Inspecting ingress: %s\", ingress.Name)\n\t\t\t\t\tif ingress.Annotations[\"kubernetes.io/ingress.class\"] == traefik {\n\t\t\t\t\t\tendpoints := getIngressEndpoints(publicIp, &ingress)\n\t\t\t\t\t\tfor i := 0; i < len(endpoints); i++ {\n\t\t\t\t\t\t\tendpointURLs = append(endpointURLs, &(endpoints[i]))\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tendpointList = append(endpointList, &EndpointItem{\n\t\t\t\tName: service.Name,\n\t\t\t\tHost: publicIp,\n\t\t\t\tEndPointURLs: endpointURLs,\n\t\t\t})\n\t\t}\n\t}\n\n\tc.JSON(http.StatusOK, EndpointResponse{\n\t\tEndpoints: endpointList,\n\t})\n}", "title": "" }, { "docid": "4fc9dd59735326412fcfcb30e49be547", "score": "0.47280142", "text": "func (c *Client) ListEndpoints(args *ListEndpointArgs) (*ListEndpointResult, error) {\n\tif args == nil {\n\t\treturn nil, fmt.Errorf(\"The ListEndpointArgs cannot be nil.\")\n\t}\n\tif args.MaxKeys == 0 {\n\t\targs.MaxKeys = 1000\n\t}\n\n\tresult := &ListEndpointResult{}\n\terr := bce.NewRequestBuilder(c).\n\t\tWithURL(getURLForEndpoint()).\n\t\tWithMethod(http.GET).\n\t\tWithQueryParam(\"vpcId\", args.VpcId).\n\t\tWithQueryParam(\"name\", args.Name).\n\t\tWithQueryParam(\"ipAddress\", args.IpAddress).\n\t\tWithQueryParam(\"status\", args.Status).\n\t\tWithQueryParam(\"subnetId\", args.SubnetId).\n\t\tWithQueryParam(\"service\", args.Service).\n\t\tWithQueryParamFilter(\"marker\", args.Marker).\n\t\tWithQueryParamFilter(\"maxKeys\", strconv.Itoa(args.MaxKeys)).\n\t\tWithResult(result).\n\t\tDo()\n\n\treturn result, err\n}", "title": "" }, { "docid": "cf87249db425f072c28e5634f0d90310", "score": "0.4720093", "text": "func ListVPCRoutes(clientMap map[string]*cosmic.CosmicClient, vpcID string) (StaticRoutes, error) {\n\tsrs := []*StaticRoute{}\n\twg := sync.WaitGroup{}\n\twg.Add(len(clientMap))\n\n\terrChannel := make(chan error, 1)\n\tfinished := make(chan bool, 1)\n\n\tfor client := range clientMap {\n\t\tgo func(client string) {\n\t\t\tdefer wg.Done()\n\n\t\t\tparams := clientMap[client].VPC.NewListStaticRoutesParams()\n\t\t\tparams.SetVpcid(vpcID)\n\t\t\tresp, err := clientMap[client].VPC.ListStaticRoutes(params)\n\t\t\tif err != nil {\n\t\t\t\tif strings.Contains(err.Error(), fmt.Sprintf(\"entity does not exist\")) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\terrChannel <- profileError{fmt.Sprintf(\"Error returned using profile \\\"%s\\\": %s\", client, err)}\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tfor _, sr := range resp.StaticRoutes {\n\t\t\t\tsrs = append(srs, &StaticRoute{\n\t\t\t\t\tStaticRoute: sr,\n\t\t\t\t})\n\t\t\t}\n\t\t}(client)\n\t}\n\n\tgo func() {\n\t\twg.Wait()\n\t\tclose(finished)\n\t}()\n\n\tselect {\n\tcase <-finished:\n\tcase err := <-errChannel:\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn srs, nil\n}", "title": "" }, { "docid": "f351a780e119dd24f4e7b2b3a2f4a161", "score": "0.47181875", "text": "func Endpoints() ([]string, error) {\n\tendpoints, err := objIndex.Endpoints()\n\treturn endpoints, err\n}", "title": "" }, { "docid": "bb58a8be96d7b62f2a19efab970ebeec", "score": "0.47095335", "text": "func (a *Client) ListRouteTables(params *ListRouteTablesParams) (*ListRouteTablesOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewListRouteTablesParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"ListRouteTables\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/routeTables\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"http\"},\n\t\tParams: params,\n\t\tReader: &ListRouteTablesReader{formats: a.formats},\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.(*ListRouteTablesOK), nil\n\n}", "title": "" }, { "docid": "408cd02a32805f94af7220b37ffeca50", "score": "0.4688156", "text": "func GetRouteTable(w http.ResponseWriter, r *http.Request) {\n\tjson.NewEncoder(w).Encode(util.RouteTable)\n}", "title": "" }, { "docid": "6136552e9ad50c9de5ae15aa9df07966", "score": "0.46831423", "text": "func (client AppServicePlansClient) ListRoutesForVnetResponder(resp *http.Response) (result ListVnetRoute, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result.Value),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "title": "" }, { "docid": "ee4fb073d1e0d9fa23392fa59bb948ad", "score": "0.4672652", "text": "func (r workloadEndpoints) List(ctx context.Context, opts options.ListOptions) (*libapiv3.WorkloadEndpointList, error) {\n\tres := &libapiv3.WorkloadEndpointList{}\n\tif err := r.client.resources.List(ctx, opts, libapiv3.KindWorkloadEndpoint, libapiv3.KindWorkloadEndpointList, res); err != nil {\n\t\treturn nil, err\n\t}\n\treturn res, nil\n}", "title": "" }, { "docid": "44fe4d19e7c673043bbe84f0d9f7d3f0", "score": "0.46664992", "text": "func DecodeGrpcRespRouteTableList(ctx context.Context, response interface{}) (interface{}, error) {\n\treturn response, nil\n}", "title": "" }, { "docid": "f31e4f2b86f16bf1365d645ab55cc51d", "score": "0.46608806", "text": "func (s vpnConnectionRouteNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.VpnConnectionRoute, err error) {\n\terr = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v1alpha1.VpnConnectionRoute))\n\t})\n\treturn ret, err\n}", "title": "" }, { "docid": "28fae44a71e6374117ecf19c4892a4ed", "score": "0.46574053", "text": "func (t *Template) GetAllEC2TransitGatewayRouteTableAssociationResources() map[string]*ec2.TransitGatewayRouteTableAssociation {\n\tresults := map[string]*ec2.TransitGatewayRouteTableAssociation{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase *ec2.TransitGatewayRouteTableAssociation:\n\t\t\tresults[name] = resource\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "5974b7a23083f9dbc653730738700a8d", "score": "0.46480325", "text": "func (r *RouteTable) Marshal(rt *ec2.RouteTable, region string) {\n\tr.Name = GetTagValue(\"Name\", rt.Tags)\n\tr.RouteTableID = aws.StringValue(rt.RouteTableId)\n\tr.VpcID = aws.StringValue(rt.VpcId)\n\tr.Region = region\n\tfor _, association := range rt.Associations {\n\t\tr.Associations = append(r.Associations, models.RouteTableAssociation{\n\t\t\tMain: aws.BoolValue(association.Main),\n\t\t\tAssociationID: aws.StringValue(association.RouteTableAssociationId),\n\t\t\tSubnetID: aws.StringValue(association.SubnetId),\n\t\t})\n\t}\n}", "title": "" }, { "docid": "a5623b4cd08c6c27da548a3c60892b73", "score": "0.46416232", "text": "func (c *Router) GetList() ([]string, error) {\n c.con.LogQuery(\"(get) list of virtual routers\")\n path := c.xpath(nil)\n return c.con.EntryListUsing(c.con.Get, path[:len(path) - 1])\n}", "title": "" }, { "docid": "99bd84c77e026661c7712a8474bb6098", "score": "0.4631852", "text": "func (v RoutesResource) List(c buffalo.Context) error {\n\n\troutes := &models.Routes{}\n\n\t// Retrieve all Routes from the DB\n\tif err := scope(c).Eager().All(routes); err != nil {\n\t\treturn err\n\t}\n\n\treturn c.Render(200, r.JSON(routes))\n}", "title": "" }, { "docid": "9b77e539dd748186f5a704cbee92a072", "score": "0.46047857", "text": "func ExampleVirtualHubsClient_BeginGetEffectiveVirtualHubRoutes_effectiveRoutesForARouteTableResource() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armnetwork.NewClientFactory(\"<subscription-id>\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tpoller, err := clientFactory.NewVirtualHubsClient().BeginGetEffectiveVirtualHubRoutes(ctx, \"rg1\", \"virtualHub1\", &armnetwork.VirtualHubsClientBeginGetEffectiveVirtualHubRoutesOptions{EffectiveRoutesParameters: &armnetwork.EffectiveRoutesParameters{\n\t\tResourceID: to.Ptr(\"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1\"),\n\t\tVirtualWanResourceType: to.Ptr(\"RouteTable\"),\n\t},\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\tres, err := poller.PollUntilDone(ctx, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to pull the result: %v\", err)\n\t}\n\t// You could use response here. We use blank identifier for just demo purposes.\n\t_ = res\n\t// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t// res.VirtualHubEffectiveRouteList = armnetwork.VirtualHubEffectiveRouteList{\n\t// }\n}", "title": "" }, { "docid": "8dde33a308a533f59ea076e7d8a5cfc3", "score": "0.46046966", "text": "func (c *previewClient) ListEndpoints(ctx context.Context, previewName string) ([]types.Endpoint, error) {\n\tqueryStruct := listPreviewEndpoints{}\n\tvariables := map[string]interface{}{\n\t\t\"id\": graphql.String(previewName),\n\t}\n\tendpoints := make([]types.Endpoint, 0)\n\n\terr := query(ctx, &queryStruct, variables, c.client)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar endpointsMap = map[graphql.String]bool{}\n\n\tfor _, endpoint := range queryStruct.Response.Endpoints {\n\t\tendpointsMap[endpoint.Url] = true\n\t}\n\n\t// @francisco - 2023//05/02\n\t// The backend Endpoints field was being return empty in okteto clusters <1.9\n\t// Lets make sure we correctly resolve the endpoints from the known resources\n\t// All this below should be safe to remove in newer versions of the okteto cli\n\t// <-- LEGACY START -->\n\tfor _, d := range queryStruct.Response.Deployments {\n\t\tfor _, endpoint := range d.Endpoints {\n\t\t\tendpointsMap[endpoint.Url] = true\n\t\t}\n\t}\n\tfor _, sfs := range queryStruct.Response.Statefulsets {\n\t\tfor _, endpoint := range sfs.Endpoints {\n\t\t\tendpointsMap[endpoint.Url] = true\n\t\t}\n\t}\n\tfor _, ext := range queryStruct.Response.Externals {\n\t\tfor _, endpoint := range ext.Endpoints {\n\t\t\tendpointsMap[endpoint.Url] = true\n\t\t}\n\t}\n\t// <-- LEGACY END -->\n\n\tfor url := range endpointsMap {\n\t\tendpoints = append(endpoints, types.Endpoint{\n\t\t\tURL: string(url),\n\t\t})\n\t}\n\treturn endpoints, nil\n}", "title": "" }, { "docid": "3223053d10a9a27814382c587f6c1a48", "score": "0.4589686", "text": "func (c *egressQoSes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.EgressQoSList, err error) {\n\tvar timeout time.Duration\n\tif opts.TimeoutSeconds != nil {\n\t\ttimeout = time.Duration(*opts.TimeoutSeconds) * time.Second\n\t}\n\tresult = &v1.EgressQoSList{}\n\terr = c.client.Get().\n\t\tNamespace(c.ns).\n\t\tResource(\"egressqoses\").\n\t\tVersionedParams(&opts, scheme.ParameterCodec).\n\t\tTimeout(timeout).\n\t\tDo(ctx).\n\t\tInto(result)\n\treturn\n}", "title": "" }, { "docid": "19dcb5124ab856f0dfa8957c80d4027c", "score": "0.45890728", "text": "func (v *infromerVersion) Endpoints() v1.EndpointsLister {\n\treturn v.factory.Core().V1().Endpoints().Lister()\n}", "title": "" }, { "docid": "89b6c0a3bbe1aa51560ab1d8dcd7b254", "score": "0.4585949", "text": "func (s *iothubRouteLister) List(selector labels.Selector) (ret []*v1alpha1.IothubRoute, err error) {\n\terr = cache.ListAll(s.indexer, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v1alpha1.IothubRoute))\n\t})\n\treturn ret, err\n}", "title": "" }, { "docid": "e7c8d7401828b6eadcf6670002e1c03c", "score": "0.45837006", "text": "func (a *Client) EndpointList(params *EndpointListParams, authInfo runtime.ClientAuthInfoWriter) (*EndpointListOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewEndpointListParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"EndpointList\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/endpoints\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"\"},\n\t\tSchemes: []string{\"http\", \"https\"},\n\t\tParams: params,\n\t\tReader: &EndpointListReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.(*EndpointListOK), nil\n\n}", "title": "" }, { "docid": "ffe9adc6a51c12cd7c04e14968e5fd97", "score": "0.45823616", "text": "func (s *gRPCRouteLister) List(selector labels.Selector) (ret []*v1alpha2.GRPCRoute, err error) {\n\terr = cache.ListAll(s.indexer, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v1alpha2.GRPCRoute))\n\t})\n\treturn ret, err\n}", "title": "" }, { "docid": "d57c6d74c8b1be9da1ab2743e0702db2", "score": "0.45747158", "text": "func KubeEndpointsList_Of(c constructs.IConstruct) cdk8s.ApiObject {\n\t_init_.Initialize()\n\n\tvar returns cdk8s.ApiObject\n\n\t_jsii_.StaticInvoke(\n\t\t\"k8s.KubeEndpointsList\",\n\t\t\"of\",\n\t\t[]interface{}{c},\n\t\t&returns,\n\t)\n\n\treturn returns\n}", "title": "" }, { "docid": "7ba31e384415e496c9a044ccb03b920c", "score": "0.4563533", "text": "func (t *Template) GetAllOpenSearchServerlessVpcEndpointResources() map[string]*opensearchserverless.VpcEndpoint {\n\tresults := map[string]*opensearchserverless.VpcEndpoint{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase *opensearchserverless.VpcEndpoint:\n\t\t\tresults[name] = resource\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "645a0c95fde326f801acbb8ce8bd4f69", "score": "0.45582345", "text": "func (rd *EC2VPCDeleter) RequestEC2RouteTablesFromVPCs() ([]*ec2.RouteTable, error) {\n\tif len(rd.ResourceNames) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tsize, chunk := len(rd.ResourceNames), 200\n\trtbs := make([]*ec2.RouteTable, 0)\n\tvar err error\n\t// Can only filter in batches of 200\n\tfor i := 0; i < size; i += chunk {\n\t\tstop := CalcChunk(i, size, chunk)\n\t\trtbs, err = rd.GetClient().requestEC2RouteTables(vpcFilterKey, rd.ResourceNames[i:stop], rtbs)\n\t\tif err != nil {\n\t\t\treturn rtbs, err\n\t\t}\n\t}\n\n\treturn rtbs, nil\n}", "title": "" }, { "docid": "020081df27276c7b5c66d13ff76db38d", "score": "0.4539104", "text": "func (opts ListOpts) ToRouteTableListQuery() (string, error) {\n\tq, err := golangsdk.BuildQueryString(opts)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn q.String(), nil\n}", "title": "" }, { "docid": "dd6766cc79a0cc6fc333151f5e09efc5", "score": "0.45372117", "text": "func (c *Router) ShowList() ([]string, error) {\n c.con.LogQuery(\"(show) list of virtual routeres\")\n path := c.xpath(nil)\n return c.con.EntryListUsing(c.con.Show, path[:len(path) - 1])\n}", "title": "" }, { "docid": "30f1f4f45e7478e3d893d6ecc71fa8b9", "score": "0.4532813", "text": "func (i *InternetGateways) PrintTable() {\n\tif len(*i) == 0 {\n\t\tterminal.ShowErrorMessage(\"Warning\", \"No Internet Gateways Found!\")\n\t\treturn\n\t}\n\n\tvar header []string\n\trows := make([][]string, len(*i))\n\n\tfor index, vpc := range *i {\n\t\tmodels.ExtractAwsmTable(index, vpc, &header, &rows)\n\t}\n\n\ttable := tablewriter.NewWriter(os.Stdout)\n\ttable.SetHeader(header)\n\ttable.AppendBulk(rows)\n\ttable.Render()\n}", "title": "" }, { "docid": "be04220f0f5a0c17335ffb7163db2708", "score": "0.45138752", "text": "func (s awsDmsEndpointNamespaceLister) List(selector labels.Selector) (ret []*v1.AwsDmsEndpoint, err error) {\n\terr = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v1.AwsDmsEndpoint))\n\t})\n\treturn ret, err\n}", "title": "" }, { "docid": "bd4bb5cbd366ccb27deeabf620983791", "score": "0.44894952", "text": "func (t *Template) GetAllEC2ClientVpnEndpointResources() map[string]*ec2.ClientVpnEndpoint {\n\tresults := map[string]*ec2.ClientVpnEndpoint{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase *ec2.ClientVpnEndpoint:\n\t\t\tresults[name] = resource\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "6d38f54f40ece9efc15aef67619ac309", "score": "0.44741228", "text": "func (*RouteTable) Descriptor() ([]byte, []int) {\n\treturn file_github_com_solo_io_solo_apis_api_gloo_fed_fed_rpc_v1_gateway_resources_proto_rawDescGZIP(), []int{2}\n}", "title": "" }, { "docid": "93be7c30d583be6d8bacd2cbca7c97a5", "score": "0.44710493", "text": "func (c *functionIngresses) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.FunctionIngressList, err error) {\n\tvar timeout time.Duration\n\tif opts.TimeoutSeconds != nil {\n\t\ttimeout = time.Duration(*opts.TimeoutSeconds) * time.Second\n\t}\n\tresult = &v1alpha2.FunctionIngressList{}\n\terr = c.client.Get().\n\t\tNamespace(c.ns).\n\t\tResource(\"functioningresses\").\n\t\tVersionedParams(&opts, scheme.ParameterCodec).\n\t\tTimeout(timeout).\n\t\tDo(ctx).\n\t\tInto(result)\n\treturn\n}", "title": "" }, { "docid": "5f35630f3afcf9d3a6f09e95c633f76b", "score": "0.44595236", "text": "func (s *IpsecServiceOp) List(ipsecConfig *IpsecConfig) (*[]IpsecInfo, error) {\n\tbody, err := s.client.Post(\"/cloudapi/ipsec/listTunnels\", *ipsecConfig, ModelActionTimeout)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tipsecList := new([]IpsecInfo)\n\terr = json.Unmarshal(body, &ipsecList)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn ipsecList, nil\n}", "title": "" }, { "docid": "2b4e802f07a1442b4fc1e49551df4281", "score": "0.44552365", "text": "func List(client *gophercloud.ServiceClient, projectID string) pagination.Pager {\n\tu := listURL(client, projectID)\n\treturn pagination.NewPager(client, u, func(r pagination.PageResult) pagination.Page {\n\t\treturn EndpointPage{pagination.LinkedPageBase{PageResult: r}}\n\t})\n}", "title": "" }, { "docid": "374a6ae7622262b7c6d7b23d4f66d09e", "score": "0.44438794", "text": "func ExampleEC2_AssociateRouteTable_shared00() {\n\tsvc := ec2.New(session.New())\n\tinput := &ec2.AssociateRouteTableInput{\n\t\tRouteTableId: aws.String(\"rtb-22574640\"),\n\t\tSubnetId: aws.String(\"subnet-9d4a7b6\"),\n\t}\n\n\tresult, err := svc.AssociateRouteTable(input)\n\tif err != nil {\n\t\tif aerr, ok := err.(awserr.Error); ok {\n\t\t\tswitch aerr.Code() {\n\t\t\tdefault:\n\t\t\t\tfmt.Println(aerr.Error())\n\t\t\t}\n\t\t} else {\n\t\t\t// Print the error, cast err to awserr.Error to get the Code and\n\t\t\t// Message from an error.\n\t\t\tfmt.Println(err.Error())\n\t\t}\n\t\treturn\n\t}\n\n\tfmt.Println(result)\n}", "title": "" }, { "docid": "833d2cde98fa9d0a91f931050367d14e", "score": "0.44334567", "text": "func (c *IngressImpl) List(opts api.ListOptions) (result *aci.IngressList, err error) {\n\tresult = &aci.IngressList{}\n\terr = c.r.Get().\n\t\tNamespace(c.ns).\n\t\tResource(\"ingresses\").\n\t\tVersionedParams(&opts, ExtendedCodec).\n\t\tDo().\n\t\tInto(result)\n\treturn\n}", "title": "" }, { "docid": "42b33f20ce6c14e41821df1dc251f8ed", "score": "0.44325554", "text": "func (opts ActionOpts) ToRouteTableActionMap() (map[string]interface{}, error) {\n\treturn golangsdk.BuildRequestBody(opts, \"routetable\")\n}", "title": "" }, { "docid": "25afa8c571da91954b1ef9ddd843dd86", "score": "0.44266787", "text": "func (t *Template) GetAllEC2LocalGatewayRouteTableVPCAssociationResources() map[string]*ec2.LocalGatewayRouteTableVPCAssociation {\n\tresults := map[string]*ec2.LocalGatewayRouteTableVPCAssociation{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase *ec2.LocalGatewayRouteTableVPCAssociation:\n\t\t\tresults[name] = resource\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "0774615abb8ee30a9a8dea62e9d58449", "score": "0.44225138", "text": "func (m *MockProvider) DescribeVPCRoutes(arg0 string) ([]*ec2.RouteTable, error) {\n\tret := m.ctrl.Call(m, \"DescribeVPCRoutes\", arg0)\n\tret0, _ := ret[0].([]*ec2.RouteTable)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "96bcd7852cec44a338f05ab93bef5ac7", "score": "0.44192395", "text": "func revokeAllRouteTableRules(defaultRouteTableId string, meta interface{}) error {\n\tconn := meta.(*AWSClient).ec2conn\n\tlog.Printf(\"\\n***\\nrevokeAllRouteTableRules\\n***\\n\")\n\n\tresp, err := conn.DescribeRouteTables(&ec2.DescribeRouteTablesInput{\n\t\tRouteTableIds: []*string{aws.String(defaultRouteTableId)},\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(resp.RouteTables) < 1 || resp.RouteTables[0] == nil {\n\t\treturn fmt.Errorf(\"Default Route table not found\")\n\t}\n\n\trt := resp.RouteTables[0]\n\n\t// Remove all Gateway association\n\tfor _, r := range rt.PropagatingVgws {\n\t\tlog.Printf(\n\t\t\t\"[INFO] Deleting VGW propagation from %s: %s\",\n\t\t\tdefaultRouteTableId, *r.GatewayId)\n\t\t_, err := conn.DisableVgwRoutePropagation(&ec2.DisableVgwRoutePropagationInput{\n\t\t\tRouteTableId: aws.String(defaultRouteTableId),\n\t\t\tGatewayId: r.GatewayId,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Delete all routes\n\tfor _, r := range rt.Routes {\n\t\t// you cannot delete the local route\n\t\tif r.GatewayId != nil && *r.GatewayId == \"local\" {\n\t\t\tcontinue\n\t\t}\n\t\tif r.DestinationPrefixListId != nil {\n\t\t\t// Skipping because VPC endpoint routes are handled separately\n\t\t\t// See aws_vpc_endpoint\n\t\t\tcontinue\n\t\t}\n\n\t\tif r.DestinationCidrBlock != nil {\n\t\t\tlog.Printf(\n\t\t\t\t\"[INFO] Deleting route from %s: %s\",\n\t\t\t\tdefaultRouteTableId, *r.DestinationCidrBlock)\n\t\t\t_, err := conn.DeleteRoute(&ec2.DeleteRouteInput{\n\t\t\t\tRouteTableId: aws.String(defaultRouteTableId),\n\t\t\t\tDestinationCidrBlock: r.DestinationCidrBlock,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\tif r.DestinationIpv6CidrBlock != nil {\n\t\t\tlog.Printf(\n\t\t\t\t\"[INFO] Deleting route from %s: %s\",\n\t\t\t\tdefaultRouteTableId, *r.DestinationIpv6CidrBlock)\n\t\t\t_, err := conn.DeleteRoute(&ec2.DeleteRouteInput{\n\t\t\t\tRouteTableId: aws.String(defaultRouteTableId),\n\t\t\t\tDestinationIpv6CidrBlock: r.DestinationIpv6CidrBlock,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "50a13d1c06fa4d6a3f03cf4bc696d214", "score": "0.4414557", "text": "func (t *Template) GetAllSageMakerEndpointResources() map[string]*sagemaker.Endpoint {\n\tresults := map[string]*sagemaker.Endpoint{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase *sagemaker.Endpoint:\n\t\t\tresults[name] = resource\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "47edfcda1c6d041f362496ec79094f7b", "score": "0.44116122", "text": "func (o VpcEndpointOutput) RouteTableIds() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *VpcEndpoint) pulumi.StringArrayOutput { return v.RouteTableIds }).(pulumi.StringArrayOutput)\n}", "title": "" }, { "docid": "f01af78acd91988f8af50526cbe2fa67", "score": "0.4411229", "text": "func EncodeGrpcReqRouteTableList(ctx context.Context, request interface{}) (interface{}, error) {\n\treq := request.(*RouteTableList)\n\treturn req, nil\n}", "title": "" }, { "docid": "702d49e0991fd1940e43ce36f2883834", "score": "0.43852597", "text": "func RouteTableTable(list []*v1.RouteTable, w io.Writer) {\n\ttable := tablewriter.NewWriter(w)\n\ttable.SetHeader([]string{\"Route Table\", \"Routes\", \"Status\"})\n\n\tfor _, rt := range list {\n\t\tname := rt.GetMetadata().GetName()\n\t\troutes := routeList(rt.GetRoutes())\n\t\tstatus := getAggregateRouteTableStatus(rt)\n\n\t\tif len(routes) == 0 {\n\t\t\troutes = []string{\"\"}\n\t\t}\n\t\tfor i, line := range routes {\n\t\t\tif i == 0 {\n\t\t\t\ttable.Append([]string{name, line, status})\n\t\t\t} else {\n\t\t\t\ttable.Append([]string{\"\", line, \"\"})\n\t\t\t}\n\t\t}\n\t}\n\n\ttable.SetAlignment(tablewriter.ALIGN_LEFT)\n\ttable.Render()\n}", "title": "" }, { "docid": "c8e5f84f692131c8a04c12ce769b414e", "score": "0.43839574", "text": "func (o *InstanceInfo) GetRoutes() []Route {\n\tif o == nil || IsNil(o.Routes) {\n\t\tvar ret []Route\n\t\treturn ret\n\t}\n\treturn o.Routes\n}", "title": "" }, { "docid": "f8c9166e287ad841412d1591b8f35b46", "score": "0.43570268", "text": "func ListResourcesEndpoint(c echo.Context) error {\n\tif status, err := auth.Authorized(c, \"ROLES\"); err != nil {\n\t\treturn api.ErrorResponse(c, status, err)\n\t}\n\n\tprod := c.Param(\"prod\")\n\tif prod == \"\" {\n\t\treturn api.ErrorResponse(c, http.StatusBadRequest, fmt.Errorf(\"invalid route, expected ':prod\"))\n\t}\n\tkind := c.Param(\"kind\")\n\tif kind == \"\" {\n\t\treturn api.ErrorResponse(c, http.StatusBadRequest, fmt.Errorf(\"invalid route, expected ':kind\"))\n\t}\n\n\tl, err := backend.ListResources(appengine.NewContext(c.Request()), prod, kind)\n\tif err != nil {\n\t\treturn api.ErrorResponse(c, http.StatusBadRequest, err)\n\t}\n\n\t// track api access for billing etc\n\tplatform.TrackEvent(c.Request(), \"api\", \"rsrc_list\", fmt.Sprintf(\"%s/%s\", prod, kind), 1)\n\n\treturn api.StandardResponse(c, http.StatusOK, &a.ResourceList{Resources: l})\n}", "title": "" }, { "docid": "958512b3670f8e48237a3c5f543967dd", "score": "0.43539456", "text": "func (s iothubRouteNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.IothubRoute, err error) {\n\terr = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v1alpha1.IothubRoute))\n\t})\n\treturn ret, err\n}", "title": "" }, { "docid": "14f60b8990604c48cb295f76cd3640bc", "score": "0.43495145", "text": "func GetRegionRouteTables(region string, rtList *RouteTables, search string) error {\n\n\tsess := session.Must(session.NewSession(&aws.Config{Region: aws.String(region)}))\n\tsvc := ec2.New(sess)\n\n\tresult, err := svc.DescribeRouteTables(&ec2.DescribeRouteTablesInput{})\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\trts := make(RouteTables, len(result.RouteTables))\n\tfor i, rt := range result.RouteTables {\n\t\trts[i].Marshal(rt, region)\n\t\t/*\n\t\t\tmainRt, err := GetVpcMainRouteTable(*rt.VpcId, region)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(err.Error())\n\t\t\t}\n\t\t\tfmt.Println(mainRt)\n\t\t*/\n\t}\n\n\tif search != \"\" {\n\t\tterm := regexp.MustCompile(search)\n\tLoop:\n\t\tfor i, v := range rts {\n\t\t\trIg := reflect.ValueOf(v)\n\n\t\t\tfor k := 0; k < rIg.NumField(); k++ {\n\t\t\t\tsVal := rIg.Field(k).String()\n\n\t\t\t\tif term.MatchString(sVal) {\n\t\t\t\t\t*rtList = append(*rtList, rts[i])\n\t\t\t\t\tcontinue Loop\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t*rtList = append(*rtList, rts[:]...)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "639ea6a3345f79f9503a76a71e209428", "score": "0.43456668", "text": "func (a EventController) List(ctx context.Context, pred *store.SelectionPredicate) ([]corev3.Resource, error) {\n\tvar results []*corev2.Event\n\tvar err error\n\n\t// propogate selector from request context\n\tif sel := request.SelectorFromContext(ctx); sel != nil {\n\t\tctx = storev2.EventContextWithSelector(ctx, sel)\n\t}\n\n\t// Fetch from store\n\tif pred.Subcollection != \"\" {\n\t\tresults, err = a.store.GetEventsByEntity(ctx, pred.Subcollection, pred)\n\t} else {\n\t\tresults, err = a.store.GetEvents(ctx, pred)\n\t}\n\n\tif err != nil {\n\t\treturn nil, NewError(InternalErr, err)\n\t}\n\n\tresources := make([]corev3.Resource, len(results))\n\tfor i, v := range results {\n\t\tresources[i] = corev3.Resource(v)\n\t}\n\n\treturn resources, nil\n}", "title": "" }, { "docid": "8da7271541ba7a4d1e817450e2ebce78", "score": "0.43426982", "text": "func (t *Template) GetAllEC2VPCEndpointResources() map[string]*ec2.VPCEndpoint {\n\tresults := map[string]*ec2.VPCEndpoint{}\n\tfor name, untyped := range t.Resources {\n\t\tswitch resource := untyped.(type) {\n\t\tcase *ec2.VPCEndpoint:\n\t\t\tresults[name] = resource\n\t\t}\n\t}\n\treturn results\n}", "title": "" }, { "docid": "347e72be23ed49c357a7304448c77693", "score": "0.43310237", "text": "func ListEndpoint(projectProvider provider.ProjectProvider, privilegedProjectProvider provider.PrivilegedProjectProvider, userInfoGetter provider.UserInfoGetter) endpoint.Endpoint {\n\treturn func(ctx context.Context, request interface{}) (interface{}, error) {\n\t\treq := request.(ListReq)\n\t\tclusterProvider := ctx.Value(middleware.ClusterProviderContextKey).(provider.ClusterProvider)\n\t\tapiClusters, err := handlercommon.GetExternalClusters(ctx, userInfoGetter, clusterProvider, projectProvider, privilegedProjectProvider, req.ProjectID)\n\t\tif err != nil {\n\t\t\treturn nil, common.KubernetesErrorToHTTPError(err)\n\t\t}\n\t\treturn apiClusters, nil\n\t}\n}", "title": "" }, { "docid": "8791acdb54c07684fc702694c568189f", "score": "0.43303755", "text": "func (c *Client) Endpoints() []string { return c.cfg.Endpoints }", "title": "" }, { "docid": "2f06c482ad493545c5c1a49c555bb4a0", "score": "0.43170962", "text": "func (*RouteTable) Descriptor() ([]byte, []int) {\n\treturn file_github_com_solo_io_gloo_projects_gateway_api_v1_route_table_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "c25e85451855241dfcdcc82f000b5fc2", "score": "0.43143898", "text": "func GetEndpoints() []Endpoint {\n\tendpoints := []Endpoint{\n\t\t// Home endpoints\n\t\t{\n\t\t\tPath: \"/\",\n\t\t\tFunction: home.Handler,\n\t\t\tMethod: \"GET\",\n\t\t},\n\t\t// Pet endpoints\n\t\t{\n\t\t\tPath: \"/api/pet/{name}\",\n\t\t\tFunction: pet.GetHandler,\n\t\t\tMethod: \"GET\",\n\t\t},\n\t\t{\n\t\t\tPath: \"/api/pet\",\n\t\t\tFunction: pet.PostHandler,\n\t\t\tMethod: \"POST\",\n\t\t},\n\t\t{\n\t\t\tPath: \"/api/pet/{name}\",\n\t\t\tFunction: pet.PutHandler,\n\t\t\tMethod: \"PUT\",\n\t\t},\n\t\t{\n\t\t\tPath: \"/api/pet/{name}\",\n\t\t\tFunction: pet.DeleteHandler,\n\t\t\tMethod: \"DELETE\",\n\t\t},\n\t\t// Pets endpoints\n\t\t{\n\t\t\tPath: \"/api/pets\",\n\t\t\tFunction: pets.GetHandler,\n\t\t\tMethod: \"GET\",\n\t\t},\n\t\t// Food endpoints\n\t\t{\n\t\t\tPath: \"/api/food/{name}\",\n\t\t\tFunction: food.GetHandler,\n\t\t\tMethod: \"GET\",\n\t\t},\n\t}\n\treturn endpoints\n}", "title": "" }, { "docid": "505f8919088073c345d88c062ec88440", "score": "0.4307371", "text": "func (Aws) ApiRoutes() []string {\n\treturn []string{\n\t\t\"/api/objects/aws/group/\",\n\t\t\"/api/objects/aws/group/{ref}\",\n\t\t\"/api/objects/aws/group/{ref}/usedby\",\n\t\t\"/api/objects/aws/instance_type/\",\n\t\t\"/api/objects/aws/instance_type/{ref}\",\n\t\t\"/api/objects/aws/instance_type/{ref}/usedby\",\n\t\t\"/api/objects/aws/region/\",\n\t\t\"/api/objects/aws/region/{ref}\",\n\t\t\"/api/objects/aws/region/{ref}/usedby\",\n\t}\n}", "title": "" }, { "docid": "0abc1eb56b954d512e9e3c754f66e1f8", "score": "0.43073598", "text": "func (rd *EC2RouteTableDeleter) RequestEC2RouteTables() ([]*ec2.RouteTable, error) {\n\tif len(rd.ResourceNames) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tsize, chunk := len(rd.ResourceNames), 200\n\trtbs := make([]*ec2.RouteTable, 0)\n\tvar err error\n\t// Can only filter in batches of 200\n\tfor i := 0; i < size; i += chunk {\n\t\tstop := CalcChunk(i, size, chunk)\n\t\trtbs, err = rd.GetClient().requestEC2RouteTables(rtbFilterKey, rd.ResourceNames[i:stop], rtbs)\n\t\tif err != nil {\n\t\t\treturn rtbs, err\n\t\t}\n\t}\n\n\treturn rtbs, nil\n}", "title": "" }, { "docid": "2726a295cfbf469e7e0a38a890074ddd", "score": "0.4302294", "text": "func (s *ACLsService) List(ctx context.Context) ([]ACL, *Response, error) {\n\tpath := fmt.Sprintf(\"%v/\", aclsBasePath)\n\n\treq, err := s.client.NewRequest(http.MethodGet, path, nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\troot := new(aclsRoot)\n\tresp, err := s.client.Do(ctx, req, root)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\tif m := root.Meta; m != nil {\n\t\tresp.Meta = m\n\t}\n\n\treturn root.ACLs, resp, nil\n}", "title": "" }, { "docid": "3e6721065705268c1da803b162dbcc59", "score": "0.42941886", "text": "func (s TransitGatewayRouteTable) String() string {\n\treturn awsutil.Prettify(s)\n}", "title": "" }, { "docid": "ad8e47c4eeea94cc8169b4002c2d623b", "score": "0.42885503", "text": "func (s gRPCRouteNamespaceLister) List(selector labels.Selector) (ret []*v1alpha2.GRPCRoute, err error) {\n\terr = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v1alpha2.GRPCRoute))\n\t})\n\treturn ret, err\n}", "title": "" }, { "docid": "861dc7b2ba68728b837290c1d06bc807", "score": "0.42819944", "text": "func (r *Router) ListPaths() map[string][]string {\n\treturn r.router.List()\n}", "title": "" }, { "docid": "f9c9513c03b8640da29ba08a9dec450b", "score": "0.4255459", "text": "func (f *NetlinkRouteFinder) RouteList(link netlink.Link, family int) ([]netlink.Route, error) {\n\treturn netlink.RouteList(link, family)\n}", "title": "" }, { "docid": "4b67cad45ce8d7d6cb7e8813d4839d1f", "score": "0.42551395", "text": "func (i *RouteTables) PrintTable() {\n\tif len(*i) == 0 {\n\t\tterminal.ShowErrorMessage(\"Warning\", \"No Route Tables Found!\")\n\t\treturn\n\t}\n\n\tvar header []string\n\trows := make([][]string, len(*i))\n\n\tfor index, vpc := range *i {\n\t\tmodels.ExtractAwsmTable(index, vpc, &header, &rows)\n\t}\n\n\ttable := tablewriter.NewWriter(os.Stdout)\n\ttable.SetHeader(header)\n\ttable.AppendBulk(rows)\n\ttable.Render()\n}", "title": "" }, { "docid": "4c8d3db25774862facd016aaf457114a", "score": "0.4253714", "text": "func ListAllEndpoint(projectProvider provider.ProjectProvider, privilegedProjectProvider provider.PrivilegedProjectProvider, seedsGetter provider.SeedsGetter, clusterProviderGetter provider.ClusterProviderGetter, userInfoGetter provider.UserInfoGetter) endpoint.Endpoint {\n\treturn func(ctx context.Context, request interface{}) (interface{}, error) {\n\t\treq := request.(common.GetProjectRq)\n\t\tallClusters := make([]*apiv1.Cluster, 0)\n\n\t\tseeds, err := seedsGetter()\n\t\tif err != nil {\n\t\t\treturn nil, common.KubernetesErrorToHTTPError(err)\n\t\t}\n\n\t\tfor _, seed := range seeds {\n\t\t\t// if a Seed is bad, do not forward that error to the user, but only log\n\t\t\tclusterProvider, err := clusterProviderGetter(seed)\n\t\t\tif err != nil {\n\t\t\t\tklog.Errorf(\"failed to create cluster provider for seed %s: %v\", seed.Name, err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tapiClusters, err := handlercommon.GetExternalClusters(ctx, userInfoGetter, clusterProvider, projectProvider, privilegedProjectProvider, req.ProjectID)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, common.KubernetesErrorToHTTPError(err)\n\t\t\t}\n\t\t\tallClusters = append(allClusters, apiClusters...)\n\t\t}\n\n\t\treturn allClusters, nil\n\t}\n}", "title": "" }, { "docid": "12c6929d5dd1416e388f5c7d30947322", "score": "0.42521408", "text": "func (client VirtualNetworkGatewayConnectionsClient) ListResponder(resp *http.Response) (result VirtualNetworkGatewayConnectionListResult, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "title": "" }, { "docid": "15c5d71a9d07524e11d56272f392597a", "score": "0.42421523", "text": "func GetRouteTables(search string) (*RouteTables, []error) {\n\tvar wg sync.WaitGroup\n\tvar errs []error\n\n\trtList := new(RouteTables)\n\tregions := GetRegionListWithoutIgnored()\n\n\tfor _, region := range regions {\n\t\twg.Add(1)\n\n\t\tgo func(region *ec2.Region) {\n\t\t\tdefer wg.Done()\n\t\t\terr := GetRegionRouteTables(*region.RegionName, rtList, search)\n\t\t\tif err != nil {\n\t\t\t\tterminal.ShowErrorMessage(fmt.Sprintf(\"Error gathering route tables list for region [%s]\", *region.RegionName), err.Error())\n\t\t\t\terrs = append(errs, err)\n\t\t\t}\n\t\t}(region)\n\t}\n\twg.Wait()\n\n\treturn rtList, errs\n}", "title": "" }, { "docid": "0750326f0cf748b3536e8d0a9880ad27", "score": "0.42407373", "text": "func (s GetTransitGatewayRouteTableAssociationsOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "title": "" }, { "docid": "b227adcde48a0af4952129f5866fc9c4", "score": "0.42372987", "text": "func (h *Hoster) filterRouteTables(tables []*ec2.RouteTable) []*ec2.RouteTable {\n\tvar rt []*ec2.RouteTable\n\tfor _, table := range tables {\n\t\tif h.conf.NoMain && isMainTableAssociated(table) {\n\t\t\tcontinue\n\t\t}\n\n\t\tif len(h.conf.RouteTables) == 0 {\n\t\t\trt = append(rt, table)\n\t\t\tcontinue\n\t\t}\n\n\t\tfor _, tbl := range h.conf.RouteTables {\n\t\t\tif table.RouteTableId != nil && *table.RouteTableId == tbl {\n\t\t\t\trt = append(rt, table)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn rt\n}", "title": "" }, { "docid": "5c6bdc0f7a3d37cf25f164ad9ad15c8a", "score": "0.4226294", "text": "func (r Routeview) GetRoutes() []oritatami.Route {\n\treturn r.routes\n}", "title": "" }, { "docid": "df4f80421de1302d7aed3a7c12850a17", "score": "0.42137718", "text": "func LocalGatewayRouteTableVpcAssociationAssociated(conn *ec2.EC2, localGatewayRouteTableVpcAssociationID string) (*ec2.LocalGatewayRouteTableVpcAssociation, error) {\n\tstateConf := &resource.StateChangeConf{\n\t\tPending: []string{ec2.RouteTableAssociationStateCodeAssociating},\n\t\tTarget: []string{ec2.RouteTableAssociationStateCodeAssociated},\n\t\tRefresh: LocalGatewayRouteTableVpcAssociationState(conn, localGatewayRouteTableVpcAssociationID),\n\t\tTimeout: LocalGatewayRouteTableVpcAssociationAssociatedTimeout,\n\t}\n\n\toutputRaw, err := stateConf.WaitForState()\n\n\tif output, ok := outputRaw.(*ec2.LocalGatewayRouteTableVpcAssociation); ok {\n\t\treturn output, err\n\t}\n\n\treturn nil, err\n}", "title": "" }, { "docid": "7f6cae98eeb44d93ace39f1346a4e6d2", "score": "0.42121664", "text": "func (ns *NetworkState) ListEndpoints() []*EndpointState {\n\tvar eplist []*EndpointState\n\n\t// lock the endpoint db\n\tns.Network.Lock()\n\tdefer ns.Network.Unlock()\n\n\t// walk all endpoints\n\tfor _, ep := range ns.endpointDB {\n\t\teplist = append(eplist, ep)\n\t}\n\n\treturn eplist\n}", "title": "" }, { "docid": "a0ff618d0c9f8c81fece298315572b01", "score": "0.42092896", "text": "func (rd *EC2RouteTableAssociationDeleter) DeleteResources(cfg *DeleteConfig) error {\n\tif len(rd.ResourceNames) == 0 {\n\t\treturn nil\n\t}\n\n\tfmtStr := \"Deleted RouteTable Association\"\n\n\tvar params *ec2.DisassociateRouteTableInput\n\tfor _, n := range rd.ResourceNames {\n\t\tparams = &ec2.DisassociateRouteTableInput{\n\t\t\tAssociationId: n.AWSString(),\n\t\t\tDryRun: aws.Bool(cfg.DryRun),\n\t\t}\n\n\t\tctx := aws.BackgroundContext()\n\t\t_, err := rd.GetClient().DisassociateRouteTableWithContext(ctx, params)\n\t\tif err != nil {\n\t\t\tif isDryRun(err) {\n\t\t\t\tfmt.Println(drStr, fmtStr, n)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tcfg.logRequestError(arn.EC2RouteTableAssociationRType, n, err)\n\t\t\tif cfg.IgnoreErrors {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\n\t\tcfg.logRequestSuccess(arn.EC2RouteTableAssociationRType, n)\n\t\tfmt.Println(fmtStr, n)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "b862eed267da2000fb6d7db0c07aa201", "score": "0.41950855", "text": "func (s GetTransitGatewayRouteTableAssociationsInput) String() string {\n\treturn awsutil.Prettify(s)\n}", "title": "" } ]
f215bcb124425e9bbc4cf4f0e321c238
The policy data generated by a `organizations.getIAMPolicy` data source.
[ { "docid": "bf8c50ddf465cf8362b956ec0a2396c0", "score": "0.62063134", "text": "func (o AutoscalingPolicyIamPolicyOutput) PolicyData() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *AutoscalingPolicyIamPolicy) pulumi.StringOutput { return v.PolicyData }).(pulumi.StringOutput)\n}", "title": "" } ]
[ { "docid": "5f49727d9348e6ce4b2e22057a50ba0d", "score": "0.6804252", "text": "func (o JobIAMPolicyOutput) PolicyData() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *JobIAMPolicy) pulumi.StringOutput { return v.PolicyData }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "8f38ecd14ccf293fcff7fb2930ccae3e", "score": "0.6488642", "text": "func (o IamPolicyOutput) PolicyData() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *IamPolicy) pulumi.StringOutput { return v.PolicyData }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "b20768efef2ddd6fc718c54580f54c2f", "score": "0.6471832", "text": "func (o FeatureIamPolicyOutput) PolicyData() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *FeatureIamPolicy) pulumi.StringOutput { return v.PolicyData }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "6a12363a44faa4f125b6bd0406ffd661", "score": "0.6449323", "text": "func (o WebRegionBackendServiceIamPolicyOutput) PolicyData() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *WebRegionBackendServiceIamPolicy) pulumi.StringOutput { return v.PolicyData }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "0d3448f61f7ae6cf4a7bd56a557d29ff", "score": "0.6434792", "text": "func (o GatewayIamPolicyOutput) PolicyData() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *GatewayIamPolicy) pulumi.StringOutput { return v.PolicyData }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "0b465fe473c3d939a75e640e03e8e7a0", "score": "0.64199364", "text": "func (o Hl7StoreIamPolicyOutput) PolicyData() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Hl7StoreIamPolicy) pulumi.StringOutput { return v.PolicyData }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "fd3698c228c66e8507186fe890601f62", "score": "0.63439786", "text": "func (o SecretIamPolicyOutput) PolicyData() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *SecretIamPolicy) pulumi.StringOutput { return v.PolicyData }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "fcaeb61d6d1bf1e3dd28fadafb2e795b", "score": "0.629511", "text": "func (o AccountIamPolicyOutput) PolicyData() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *AccountIamPolicy) pulumi.StringOutput { return v.PolicyData }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "c4190828f25d3094fc64d0dd8783c2b0", "score": "0.61960876", "text": "func (o CertificateTemplateIamPolicyOutput) PolicyData() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *CertificateTemplateIamPolicy) pulumi.StringOutput { return v.PolicyData }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "d1a5c57e63eced10907ece45de37ae73", "score": "0.6182479", "text": "func (s *stateEP) Policy() ([]byte, error) {\n\tspe, err := s.policyFromMSPIDs()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tspBytes, err := proto.Marshal(spe)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn spBytes, nil\n}", "title": "" }, { "docid": "8159495d866970aa6ed3a683b6824fee", "score": "0.61141837", "text": "func (o LookupServiceIamPolicyResultOutput) PolicyData() pulumi.StringOutput {\n\treturn o.ApplyT(func(v LookupServiceIamPolicyResult) string { return v.PolicyData }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "02ad2024b780f4386becc670229f5425", "score": "0.6089963", "text": "func (o AccessPointOutput) Policy() pulumi.AnyOutput {\n\treturn o.ApplyT(func(v *AccessPoint) pulumi.AnyOutput { return v.Policy }).(pulumi.AnyOutput)\n}", "title": "" }, { "docid": "670df3e96b94ddf19da47348feb4fb3e", "score": "0.60698116", "text": "func (o LookupImageIamPolicyResultOutput) PolicyData() pulumi.StringOutput {\n\treturn o.ApplyT(func(v LookupImageIamPolicyResult) string { return v.PolicyData }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "21637ba5fd3837b3d126b877c04c326d", "score": "0.6029969", "text": "func (o LookupListingIamPolicyResultOutput) PolicyData() pulumi.StringOutput {\n\treturn o.ApplyT(func(v LookupListingIamPolicyResult) string { return v.PolicyData }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "df9787ee8f7e71772fd81e7491a02d29", "score": "0.59353435", "text": "func (e *Engine) Policies() map[string]string {\n\tpolicies := make(map[string]string)\n\tfor m := range e.result.Modules {\n\t\tpolicies[e.result.Modules[m].Name] = string(e.result.Modules[m].Raw)\n\t}\n\n\treturn policies\n}", "title": "" }, { "docid": "2b2f937838973dfa33fa99ee2e18c9a6", "score": "0.58331215", "text": "func (o ExternalKeyOutput) Policy() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *ExternalKey) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "d9c8b064c88bbd1358b9bd1fbb3d7b56", "score": "0.5808946", "text": "func (r *ExternalKey) Policy() pulumi.StringOutput {\n\treturn (pulumi.StringOutput)(r.s.State[\"policy\"])\n}", "title": "" }, { "docid": "11b96241d57bdd05208f13d7e4be9966", "score": "0.57803494", "text": "func (o LookupDataExchangeIamPolicyResultOutput) PolicyData() pulumi.StringOutput {\n\treturn o.ApplyT(func(v LookupDataExchangeIamPolicyResult) string { return v.PolicyData }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "9ae4a3eab324389a06b7a99ea1724f62", "score": "0.5738258", "text": "func (o RestApiPolicyOutput) Policy() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *RestApiPolicy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "b91b035bc070ade2076ba15eb16d6279", "score": "0.5705776", "text": "func (o UserOutput) Policies() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *User) pulumi.StringArrayOutput { return v.Policies }).(pulumi.StringArrayOutput)\n}", "title": "" }, { "docid": "083cd90768a305e55df4e0d0afb62ef1", "score": "0.56214696", "text": "func (o LookupAccessPolicyResultOutput) Policy() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v LookupAccessPolicyResult) *string { return v.Policy }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "02e80076a1962272f1380d843226dd21", "score": "0.5604712", "text": "func (o LoadBalancerPoolOriginSteeringOutput) Policy() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v LoadBalancerPoolOriginSteering) *string { return v.Policy }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "b7f8d6b0a5a1e3cb99e9e1afda9d0baf", "score": "0.56007344", "text": "func (o LookupEntityResultOutput) Policies() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v LookupEntityResult) []string { return v.Policies }).(pulumi.StringArrayOutput)\n}", "title": "" }, { "docid": "5b0983e6fbbb7c9ce60c595388fd1759", "score": "0.55882967", "text": "func generateIAMPolicy(principalId string, effect string, resource string) events.APIGatewayCustomAuthorizerResponse {\n\tdefer track(time.Now(), \"generateIAMPolicy()\")\n\tauthResponse := events.APIGatewayCustomAuthorizerResponse{PrincipalID: principalId}\n\n\tif effect != \"\" && resource != \"\" {\n\t\tauthResponse.PolicyDocument = events.APIGatewayCustomAuthorizerPolicy{\n\t\t\tVersion: \"2012-10-17\",\n\t\t\tStatement: []events.IAMPolicyStatement{\n\t\t\t\t{\n\t\t\t\t\tAction: []string{\"execute-api:Invoke\"},\n\t\t\t\t\tEffect: effect,\n\t\t\t\t\tResource: []string{resource},\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t}\n\n\tauthResponse.Context = map[string]interface{}{}\n\treturn authResponse\n}", "title": "" }, { "docid": "7fb1974a9989a4cd2c04f5fa54552231", "score": "0.5578806", "text": "func (s *JunosSpace) Policies() (*Policies, error) {\n\tvar policies Policies\n\treq := &APIRequest{\n\t\tMethod: \"get\",\n\t\tURL: \"/api/juniper/sd/fwpolicy-management/firewall-policies\",\n\t}\n\tdata, err := s.APICall(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = xml.Unmarshal(data, &policies)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &policies, nil\n}", "title": "" }, { "docid": "3d3be6f8edf390502a58cffa497dbddd", "score": "0.5560959", "text": "func (r *PolicyAttachment) Policy() pulumi.StringOutput {\n\treturn (pulumi.StringOutput)(r.s.State[\"policy\"])\n}", "title": "" }, { "docid": "0f75b3e09cfa8e602b8285a9c1d574da", "score": "0.5548103", "text": "func (o LookupRestApiResultOutput) Policy() pulumi.StringOutput {\n\treturn o.ApplyT(func(v LookupRestApiResult) string { return v.Policy }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "eb7c04f7e9096f6b9dce4b551947aa97", "score": "0.5505726", "text": "func (o PasswordPolicyOutput) Policy() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *PasswordPolicy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "4ff556f5876d3daf1c2fcca561d94fbf", "score": "0.5467645", "text": "func (p *PolicyDocument) PolicyScheme() ([]byte, error) {\n\tb, err := json.Marshal(p)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn b, nil\n}", "title": "" }, { "docid": "2e9c6a6ca58d1ceb8b08882ead2d207f", "score": "0.54664856", "text": "func (c *Client) Policy() (*www.PolicyReply, error) {\n\tstatusCode, respBody, err := c.makeRequest(http.MethodGet,\n\t\twww.PoliteiaWWWAPIRoute, www.RoutePolicy, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif statusCode != http.StatusOK {\n\t\treturn nil, wwwError(respBody, statusCode)\n\t}\n\n\tvar pr www.PolicyReply\n\terr = json.Unmarshal(respBody, &pr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unmarshal PolicyReply: %v\", err)\n\t}\n\n\tif c.cfg.Verbose {\n\t\terr := prettyPrintJSON(pr)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn &pr, nil\n}", "title": "" }, { "docid": "fc386df2290dcf4398a2c255882a1ed8", "score": "0.5458472", "text": "func (o GetSubnetworkIamPolicyResultOutput) PolicyData() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetSubnetworkIamPolicyResult) string { return v.PolicyData }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "3e289b53cdad442d65fd21beca3525f6", "score": "0.5433041", "text": "func (User) Policy() ent.Policy {\n return privacy.Policy{\n Mutation: privacy.MutationPolicy{\n // Deny if not set otherwise. \n privacy.AlwaysDenyRule(),\n },\n Query: privacy.QueryPolicy{\n // Allow any viewer to read anything.\n privacy.AlwaysAllowRule(),\n },\n }\n}", "title": "" }, { "docid": "ac64b66bf041bc0a4c612a86fbe6edb2", "score": "0.5429868", "text": "func getIAMPolicy(ctx context.Context, h *iam.Handle) (*iam.Policy, error) {\n\tvar policy *iam.Policy\n\n\tif err := iamRetry(ctx, func(ctx context.Context) error {\n\t\trPolicy, err := h.Policy(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tpolicy = rPolicy\n\t\treturn nil\n\t}); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn policy, nil\n}", "title": "" }, { "docid": "816b9821eb572be100fc8e15c3c4d873", "score": "0.53987324", "text": "func cmdGetPolicies(ccmd *cobra.Command, args []string) {\n\taplSvc := apl.NewClient()\n\n\toutput := runGetCommand(args, aplSvc.Policies.Get)\n\n\tif output != nil {\n\t\tfields := []string{\"ID\", \"Name\", \"PolicyType\", \"PolicyGroup\", \"CreatedTime\"}\n\t\tprintTableResultsCustom(output.(apl.Policy), fields)\n\t}\n}", "title": "" }, { "docid": "07a9d6f32612bbd7556399ec07823ded", "score": "0.5392543", "text": "func PolicyToUnstructured(r *iamDCL.Policy) *unstructured.Resource {\n\tu := &unstructured.Resource{\n\t\tSTV: unstructured.ServiceTypeVersion{\n\t\t\tService: \"iam\",\n\t\t\tVersion: \"ga\",\n\t\t\tType: \"Policy\",\n\t\t},\n\t\tObject: make(map[string]interface{}),\n\t}\n\tvar rBindings []interface{}\n\tfor _, rBindingsVal := range r.Bindings {\n\t\trBindingsObject := make(map[string]interface{})\n\t\tif rBindingsVal.Role != nil {\n\t\t\trBindingsObject[\"role\"] = string(*rBindingsVal.Role)\n\t\t}\n\t\tif rBindingsVal.Members != nil {\n\t\t\tvar rBindingsValMembers []interface{}\n\t\t\tfor _, rBindingsValMembersVal := range rBindingsVal.Members {\n\t\t\t\trBindingsValMembers = append(rBindingsValMembers, rBindingsValMembersVal)\n\t\t\t}\n\t\t\trBindingsObject[\"members\"] = rBindingsValMembers\n\t\t}\n\t\tif rBindingsVal.Condition != nil {\n\t\t\trBindingsValCondition := make(map[string]interface{})\n\t\t\tif rBindingsVal.Condition.Title != nil {\n\t\t\t\trBindingsValCondition[\"title\"] = string(*rBindingsVal.Condition.Title)\n\t\t\t}\n\t\t\tif rBindingsVal.Condition.Description != nil {\n\t\t\t\trBindingsValCondition[\"description\"] = string(*rBindingsVal.Condition.Description)\n\t\t\t}\n\t\t\tif rBindingsVal.Condition.Expression != nil {\n\t\t\t\trBindingsValCondition[\"expression\"] = string(*rBindingsVal.Condition.Expression)\n\t\t\t}\n\t\t\trBindingsObject[\"condition\"] = rBindingsValCondition\n\t\t}\n\t\trBindings = append(rBindings, rBindingsObject)\n\t}\n\tu.Object[\"bindings\"] = rBindings\n\tif r.Etag != nil {\n\t\tu.Object[\"etag\"] = string(*r.Etag)\n\t}\n\tif r.Version != nil {\n\t\tu.Object[\"version\"] = int(*r.Version)\n\t}\n\treturn u\n}", "title": "" }, { "docid": "07ca8a8bad20c4b55121d6bf5d0f2436", "score": "0.5355887", "text": "func GetPiiFromPolicy(peerID string) ([]interface{}, error) {\n\tinput := map[string]interface{}{\"peerID\": peerID}\n\tlog.Printf(\"OPA Input: %v\", input)\n\n\t// load policy\n\tmodule, err := ioutil.ReadFile(policyFileName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read policy: %v\", err)\n\t}\n\n\tdecision, err := eval(context.Background(), \"data.example.pii\", input, module)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tswitch x := decision.(type) {\n\tcase []interface{}:\n\t\treturn x, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"illegal value for policy evaluation result: %T\", x)\n\t}\n}", "title": "" }, { "docid": "f9439ea641445aaaee086717ed6e8de0", "score": "0.5339275", "text": "func (c *Client) GenerateIAMPolicyReports() (reports []report.Report, err error) {\n\n\treports = []report.Report{}\n\ttyp := \"iam_policy\"\n\n\tfor _, p := range c.computeprojects {\n\t\tprojectID := p.Name()\n\t\tpolicy := c.policies[projectID]\n\t\tserviceAccounts := c.serviceaccounts[projectID]\n\n\t\tr := report.NewReport(\n\t\t\ttyp,\n\t\t\tfmt.Sprintf(\"Project %v IAM Policy\", projectID),\n\t\t)\n\t\tr.Data, err = policy.Marshal()\n\t\tif err != nil {\n\t\t\tglog.Fatalf(\"Failed to marshal IAM policy: %v\", err)\n\t\t}\n\n\t\t// Corporate login credentials should be used\n\t\tcorpCreds := report.NewCISControl(\n\t\t\t\"1.1\",\n\t\t\tfmt.Sprintf(\"Project %v should only allow corporate login credentials\", p.Name()),\n\t\t)\n\t\tif err := policy.PolicyViolatesUserDomainWhitelist(); err != nil {\n\t\t\tcorpCreds.Error = err.Error()\n\t\t} else {\n\t\t\tcorpCreds.Passed()\n\t\t}\n\t\tr.AddControls(corpCreds)\n\n\t\tfor _, sa := range serviceAccounts {\n\n\t\t\t// Service account keys should be GCP-managed\n\t\t\tsaManagedKeys := report.NewCISControl(\n\t\t\t\t\"1.3\",\n\t\t\t\tfmt.Sprintf(\"%v should not have user-managed keys\", sa.Email()),\n\t\t\t)\n\t\t\tif sa.HasUserManagedKeys() {\n\t\t\t\tsaManagedKeys.Error = \"Service account has user-managed keys\"\n\t\t\t} else {\n\t\t\t\tsaManagedKeys.Passed()\n\t\t\t}\n\t\t\tr.AddControls(saManagedKeys)\n\n\t\t\t// Service accounts should not have admin privileges\n\t\t\tsaAdminRole := report.NewCISControl(\n\t\t\t\t\"1.4\",\n\t\t\t\tfmt.Sprintf(\"%v should not have admin roles\", sa.Email()),\n\t\t\t)\n\t\t\tif err := policy.MemberHasAdminRole(fmt.Sprintf(\"serviceAccount:%v\", sa.Email())); err != nil {\n\t\t\t\tsaAdminRole.Error = err.Error()\n\t\t\t} else {\n\t\t\t\tsaAdminRole.Passed()\n\t\t\t}\n\t\t\tr.AddControls(saAdminRole)\n\n\t\t}\n\n\t\t// IAM Users should not be able to impersonate service accounts at the project level\n\t\tsaServiceAccountUserRole := report.NewCISControl(\n\t\t\t\"1.5\",\n\t\t\tfmt.Sprintf(\"Project %v should not allow project-wide use of Service Account User role\", p.Name()),\n\t\t)\n\t\tif err := policy.PolicyAllowsIAMUserServiceAccountUserRole(); err != nil {\n\t\t\tsaServiceAccountUserRole.Error = err.Error()\n\t\t} else {\n\t\t\tsaServiceAccountUserRole.Passed()\n\t\t}\n\t\tr.AddControls(saServiceAccountUserRole)\n\n\t\t// Service account keys should be rotated on a regular interval\n\t\tfor _, sa := range serviceAccounts {\n\t\t\tsaKeyExpired := report.NewCISControl(\n\t\t\t\t\"1.6\",\n\t\t\t\tfmt.Sprintf(\"%v should not have expired keys\", sa.Email()),\n\t\t\t)\n\t\t\tif err := sa.HasKeysNeedingRotation(); err != nil {\n\t\t\t\tsaKeyExpired.Error = err.Error()\n\t\t\t} else {\n\t\t\t\tsaKeyExpired.Passed()\n\t\t\t}\n\t\t\tr.AddControls(saKeyExpired)\n\t\t}\n\n\t\t// Users should not be allowed to administrate and impersonate service accounts\n\t\tsaSeperateDuties := report.NewCISControl(\n\t\t\t\"1.7\",\n\t\t\tfmt.Sprintf(\"Project %v should have separation of duties with respect to service account usage\", p.Name()),\n\t\t)\n\t\tif err := policy.PolicyViolatesServiceAccountSeparationoOfDuties(); err != nil {\n\t\t\tsaSeperateDuties.Error = err.Error()\n\t\t} else {\n\t\t\tsaSeperateDuties.Passed()\n\t\t}\n\t\tr.AddControls(saSeperateDuties)\n\n\t\t// Users should not be allowed to administrate and utilize KMS functionality\n\t\tkmsSeperateDuties := report.NewCISControl(\n\t\t\t\"1.9\",\n\t\t\tfmt.Sprintf(\"Project %v should have separation of duties with respect to KMS usage\", p.Name()),\n\t\t)\n\t\tif err := policy.PolicyViolatesKMSSeparationoOfDuties(); err != nil {\n\t\t\tkmsSeperateDuties.Error = err.Error()\n\t\t} else {\n\t\t\tkmsSeperateDuties.Passed()\n\t\t}\n\t\tr.AddControls(kmsSeperateDuties)\n\n\t\t// Project IAM Policies should define audit configurations\n\t\tauditConfig := report.NewCISControl(\n\t\t\t\"2.1\",\n\t\t\tfmt.Sprintf(\"Project %v should proper audit logging configurations\", p.Name()),\n\t\t)\n\t\tif err := policy.PolicyConfiguresAuditLogging(); err != nil {\n\t\t\tauditConfig.Error = err.Error()\n\t\t} else {\n\t\t\tif err := policy.PolicyDoesNotHaveAuditLogExceptions(); err != nil {\n\t\t\t\tauditConfig.Error = err.Error()\n\t\t\t} else {\n\t\t\t\tauditConfig.Passed()\n\t\t\t}\n\t\t}\n\t\tr.AddControls(auditConfig)\n\n\t\treports = append(reports, r)\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "bf3ef1ddcf8a1e3ad77a479453a70e0d", "score": "0.5299978", "text": "func (s *Service) Policy(c context.Context, id, mid int64) (item *model.Pitem, err error) {\n\tvar policy *model.Policy\n\tif policy, err = s.checkPolicy(id); err != nil {\n\t\tlog.Error(\"s.getPolicy(%d) err(%v)\", id, err)\n\t\treturn\n\t}\n\tswitch policy.Type {\n\tcase _userRandomType:\n\t\tif item, err = s.userPolicy(mid, policy); err != nil {\n\t\t\tlog.Error(\"s.userPolicy(%d) err(%v)\", mid, err)\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}", "title": "" }, { "docid": "59038aa3b335d7cbaf55069eb6e98d80", "score": "0.52969825", "text": "func (o RegistryPolicyOutput) Policy() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *RegistryPolicy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "cc05565a5c14e3f97bdbd02a95eec949", "score": "0.52908874", "text": "func (o GroupPolicyOutput) Policy() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *GroupPolicy) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "1c2fc21ed423e5e07db24ac49c4b8762", "score": "0.5271087", "text": "func (AccessPolicyType) Values() []AccessPolicyType {\n\treturn []AccessPolicyType{\n\t\t\"data\",\n\t}\n}", "title": "" }, { "docid": "d442533fe7ffca3153628d5d66a4950a", "score": "0.5265751", "text": "func (bbu *BBU) Policy() string {\n\treturn bbu.toParams().toPolicy()\n}", "title": "" }, { "docid": "36cf7e74863b90d02d373f3fce8ac93f", "score": "0.5229387", "text": "func (*Policy) Descriptor() ([]byte, []int) {\n\treturn file_google_iam_v1_policy_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "a605e2e45ae28eeea7eacc5bd259a2df", "score": "0.5205779", "text": "func (cli *IdentityClient) Policies() *PolicyClient {\n\treturn &PolicyClient{cli}\n}", "title": "" }, { "docid": "2a064daad9990114be01083413f67e76", "score": "0.51896083", "text": "func (p *PaloAlto) Policy(devicegroup ...string) (*Policy, error) {\n\tvar policy Policy\n\tvar prePolicy policyRules\n\tvar postPolicy policyRules\n\tvar localPolicy policyRules\n\n\tswitch p.DeviceType {\n\tcase \"panos\":\n\t\txpath := \"/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase/security/rules\"\n\n\t\tif len(devicegroup[0]) > 0 {\n\t\t\treturn nil, errors.New(\"you do not need to specify a device-group when connected to a fireawll\")\n\t\t}\n\n\t\t_, localPolicyData, errs := r.Get(p.URI).Query(fmt.Sprintf(\"type=config&action=get&xpath=%s&key=%s\", xpath, p.Key)).End()\n\t\tif errs != nil {\n\t\t\treturn nil, errs[0]\n\t\t}\n\n\t\tif err := xml.Unmarshal([]byte(localPolicyData), &localPolicy); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif localPolicy.Status != \"success\" {\n\t\t\treturn nil, fmt.Errorf(\"error code %s: %s\", localPolicy.Code, errorCodes[localPolicy.Code])\n\t\t}\n\n\t\tif len(localPolicy.Rules) == 0 {\n\t\t\treturn nil, errors.New(\"there are no rules created\")\n\t\t}\n\n\t\tpolicy.IncludedRules = \"local\"\n\t\tpolicy.Local = localPolicy.Rules\n\tcase \"panorama\":\n\t\tif len(devicegroup) == 0 {\n\t\t\treturn nil, errors.New(\"you must specify a device-group when viewing policies on a Panorama device\")\n\t\t}\n\n\t\tpreXpath := fmt.Sprintf(\"/config/devices/entry[@name='localhost.localdomain']/device-group/entry[@name='%s']/pre-rulebase/security/rules\", devicegroup[0])\n\t\tpostXpath := fmt.Sprintf(\"/config/devices/entry[@name='localhost.localdomain']/device-group/entry[@name='%s']/post-rulebase/security/rules\", devicegroup[0])\n\n\t\t_, prePolicyData, errs := r.Get(p.URI).Query(fmt.Sprintf(\"type=config&action=get&xpath=%s&key=%s\", preXpath, p.Key)).End()\n\t\tif errs != nil {\n\t\t\treturn nil, errs[0]\n\t\t}\n\n\t\tif err := xml.Unmarshal([]byte(prePolicyData), &prePolicy); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t_, postPolicyData, errs := r.Get(p.URI).Query(fmt.Sprintf(\"type=config&action=get&xpath=%s&key=%s\", postXpath, p.Key)).End()\n\t\tif errs != nil {\n\t\t\treturn nil, errs[0]\n\t\t}\n\n\t\tif err := xml.Unmarshal([]byte(postPolicyData), &postPolicy); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif len(prePolicy.Rules) == 0 && len(postPolicy.Rules) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"there are no rules created, or the device-group %s does not exist\", devicegroup[0])\n\t\t}\n\n\t\tif len(prePolicy.Rules) > 0 && len(postPolicy.Rules) > 0 {\n\t\t\tpolicy.IncludedRules = \"both\"\n\t\t}\n\n\t\tif len(prePolicy.Rules) > 0 && len(postPolicy.Rules) == 0 {\n\t\t\tpolicy.IncludedRules = \"pre\"\n\t\t}\n\n\t\tif len(prePolicy.Rules) == 0 && len(postPolicy.Rules) > 0 {\n\t\t\tpolicy.IncludedRules = \"post\"\n\t\t}\n\n\t\tif prePolicy.Status != \"success\" {\n\t\t\treturn nil, fmt.Errorf(\"error code %s: %s\", prePolicy.Code, errorCodes[prePolicy.Code])\n\t\t}\n\n\t\tif postPolicy.Status != \"success\" {\n\t\t\treturn nil, fmt.Errorf(\"error code %s: %s\", postPolicy.Code, errorCodes[postPolicy.Code])\n\t\t}\n\n\t\tpolicy.Pre = prePolicy.Rules\n\t\tpolicy.Post = postPolicy.Rules\n\t}\n\n\treturn &policy, nil\n}", "title": "" }, { "docid": "3d922c22c1cc2a0c2f29f1a6152b9947", "score": "0.51516837", "text": "func (r *VaultLock) Policy() pulumi.StringOutput {\n\treturn (pulumi.StringOutput)(r.s.State[\"policy\"])\n}", "title": "" }, { "docid": "ea53ccc2364d4cd7da75a3df71106dc4", "score": "0.5151358", "text": "func (o ServiceOutput) Policy() ServicePolicyOutput {\n\treturn o.ApplyT(func(v *Service) ServicePolicyOutput { return v.Policy }).(ServicePolicyOutput)\n}", "title": "" }, { "docid": "b52641d1da822cfa8679a828c44d5f94", "score": "0.5125202", "text": "func prepareOPAData(pkgPath string, ignorer ignore.IgnoreParser) (map[string]interface{}, error) {\n\t// Read policies files\n\tfiles, err := getFilesWithSuffix(opaPoliciesSuffix, pkgPath, ignorer)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting opa policies files: %w\", err)\n\t}\n\n\t// Return package data field\n\treturn map[string]interface{}{\n\t\tOPAPoliciesKey: files,\n\t}, nil\n}", "title": "" }, { "docid": "a7853505bf50b7190af1e8baac3edf1d", "score": "0.51063156", "text": "func GetPoliciesHandler(service GetPoliciesHandlerService, authBackend AuthorizationBackend) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tdefer errors.HandleRequest(\"GetPoliciesHandler\", w, r)\n\n\t\tctx, ok := authBackend.AuthorizeOAuth2(r, w, \"poi:policies:read\")\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\t\tr = r.WithContext(ctx)\n\n\t\t// Trace the service function handler execution\n\t\thandlerSpan, ctx := opentracing.StartSpanFromContext(r.Context(), \"GetPoliciesHandler\")\n\t\tdefer handlerSpan.Finish()\n\n\t\t// Setup context, response writer and request type\n\t\twriter := getPoliciesResponseWriter{\n\t\t\tResponseWriter: metrics.NewMetric(\"poi\", \"/beta/policies\", w, r),\n\t\t}\n\t\trequest := GetPoliciesRequest{\n\t\t\tRequest: r.WithContext(ctx),\n\t\t}\n\n\t\t// Scan and validate incoming request parameters\n\t\tif !runtime.ScanParameters(w, r, &runtime.ScanParameter{\n\t\t\tData: &request.ParamPageNumber,\n\t\t\tLocation: runtime.ScanInQuery,\n\t\t\tName: \"page[number]\",\n\t\t}, &runtime.ScanParameter{\n\t\t\tData: &request.ParamPageSize,\n\t\t\tLocation: runtime.ScanInQuery,\n\t\t\tName: \"page[size]\",\n\t\t}, &runtime.ScanParameter{\n\t\t\tData: &request.ParamFilterPoiType,\n\t\t\tLocation: runtime.ScanInQuery,\n\t\t\tName: \"filter[poiType]\",\n\t\t}, &runtime.ScanParameter{\n\t\t\tData: &request.ParamFilterCountryID,\n\t\t\tLocation: runtime.ScanInQuery,\n\t\t\tName: \"filter[countryId]\",\n\t\t}, &runtime.ScanParameter{\n\t\t\tData: &request.ParamFilterUserID,\n\t\t\tLocation: runtime.ScanInQuery,\n\t\t\tName: \"filter[userId]\",\n\t\t}) {\n\t\t\treturn\n\t\t}\n\t\tif !runtime.ValidateParameters(w, r, &request) {\n\t\t\treturn // invalid request stop further processing\n\t\t}\n\n\t\t// Invoke service that implements the business logic\n\t\terr := service.GetPolicies(ctx, &writer, &request)\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tif ctx.Err() != nil {\n\t\t\t\t// Context cancellation should not be reported if it's the request context\n\t\t\t\tw.WriteHeader(499)\n\t\t\t\tif err != nil && !(errors1.Is(err, context.Canceled) || errors1.Is(err, context.DeadlineExceeded)) {\n\t\t\t\t\t// Report unclean error handling (err != context err) to sentry\n\t\t\t\t\terrors.Handle(ctx, err)\n\t\t\t\t}\n\t\t\t}\n\t\tdefault:\n\t\t\tif err != nil {\n\t\t\t\terrors.HandleError(err, \"GetPoliciesHandler\", w, r)\n\t\t\t}\n\t\t}\n\t})\n}", "title": "" }, { "docid": "ff3a4faee372786d827409dc4dc5a883", "score": "0.5085476", "text": "func GetBootstrapPolicy(masterNamespace string) *authorizationapi.Policy {\n\treturn &authorizationapi.Policy{\n\t\tObjectMeta: kapi.ObjectMeta{\n\t\t\tName: authorizationapi.PolicyName,\n\t\t\tNamespace: masterNamespace,\n\t\t\tCreationTimestamp: util.Now(),\n\t\t},\n\t\tLastModified: util.Now(),\n\t\tRoles: map[string]authorizationapi.Role{\n\t\t\t\"cluster-admin\": {\n\t\t\t\tObjectMeta: kapi.ObjectMeta{\n\t\t\t\t\tName: \"cluster-admin\",\n\t\t\t\t\tNamespace: masterNamespace,\n\t\t\t\t},\n\t\t\t\tRules: []authorizationapi.PolicyRule{\n\t\t\t\t\t{\n\t\t\t\t\t\tVerbs: []string{authorizationapi.VerbAll},\n\t\t\t\t\t\tResources: []string{authorizationapi.ResourceAll},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"admin\": {\n\t\t\t\tObjectMeta: kapi.ObjectMeta{\n\t\t\t\t\tName: \"admin\",\n\t\t\t\t\tNamespace: masterNamespace,\n\t\t\t\t},\n\t\t\t\tRules: []authorizationapi.PolicyRule{\n\t\t\t\t\t{\n\t\t\t\t\t\tVerbs: []string{\"get\", \"list\", \"watch\", \"create\", \"update\", \"delete\"},\n\t\t\t\t\t\tResources: []string{authorizationapi.OpenshiftExposedGroupName, authorizationapi.PermissionGrantingGroupName, authorizationapi.KubeExposedGroupName},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tVerbs: []string{\"get\", \"list\", \"watch\"},\n\t\t\t\t\t\tResources: []string{authorizationapi.PolicyOwnerGroupName, authorizationapi.KubeAllGroupName},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"edit\": {\n\t\t\t\tObjectMeta: kapi.ObjectMeta{\n\t\t\t\t\tName: \"edit\",\n\t\t\t\t\tNamespace: masterNamespace,\n\t\t\t\t},\n\t\t\t\tRules: []authorizationapi.PolicyRule{\n\t\t\t\t\t{\n\t\t\t\t\t\tVerbs: []string{\"get\", \"list\", \"watch\", \"create\", \"update\", \"delete\"},\n\t\t\t\t\t\tResources: []string{authorizationapi.OpenshiftExposedGroupName, authorizationapi.KubeExposedGroupName},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tVerbs: []string{\"get\", \"list\", \"watch\"},\n\t\t\t\t\t\tResources: []string{authorizationapi.KubeAllGroupName},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"view\": {\n\t\t\t\tObjectMeta: kapi.ObjectMeta{\n\t\t\t\t\tName: \"view\",\n\t\t\t\t\tNamespace: masterNamespace,\n\t\t\t\t},\n\t\t\t\tRules: []authorizationapi.PolicyRule{\n\t\t\t\t\t{\n\t\t\t\t\t\tVerbs: []string{\"get\", \"list\", \"watch\"},\n\t\t\t\t\t\tResources: []string{authorizationapi.OpenshiftExposedGroupName, authorizationapi.KubeAllGroupName},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"system:deployer\": {\n\t\t\t\tObjectMeta: kapi.ObjectMeta{\n\t\t\t\t\tName: \"system:deployer\",\n\t\t\t\t\tNamespace: masterNamespace,\n\t\t\t\t},\n\t\t\t\tRules: []authorizationapi.PolicyRule{\n\t\t\t\t\t{\n\t\t\t\t\t\tVerbs: []string{authorizationapi.VerbAll},\n\t\t\t\t\t\tResources: []string{authorizationapi.ResourceAll},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"system:component\": {\n\t\t\t\tObjectMeta: kapi.ObjectMeta{\n\t\t\t\t\tName: \"system:component\",\n\t\t\t\t\tNamespace: masterNamespace,\n\t\t\t\t},\n\t\t\t\tRules: []authorizationapi.PolicyRule{\n\t\t\t\t\t{\n\t\t\t\t\t\tVerbs: []string{authorizationapi.VerbAll},\n\t\t\t\t\t\tResources: []string{authorizationapi.ResourceAll},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"system:delete-tokens\": {\n\t\t\t\tObjectMeta: kapi.ObjectMeta{\n\t\t\t\t\tName: \"system:delete-tokens\",\n\t\t\t\t\tNamespace: masterNamespace,\n\t\t\t\t},\n\t\t\t\tRules: []authorizationapi.PolicyRule{\n\t\t\t\t\t{\n\t\t\t\t\t\tVerbs: []string{\"delete\"},\n\t\t\t\t\t\tResources: []string{\"oauthaccesstoken\", \"oauthauthorizetoken\"},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n}", "title": "" }, { "docid": "59b979953e2a176bd7c85ec4111fd85c", "score": "0.50810987", "text": "func (n *AutoUpdatingCache) getPolicy(w http.ResponseWriter, r *http.Request) {\n\turlString, err := n.prepRequest(w, r)\n\tdefer func(err error) {\n\t\tif err != nil {\n\t\t\thttp.Error(w, \"Encode error: \"+err.Error(), http.StatusBadRequest)\n\t\t}\n\t}(err)\n\turlParts := strings.Split(urlString, \"/\")\n\tif len(urlParts) != 5 {\n\t\terr = errors.New(\"malformed request\")\n\t\tlog.Print(err)\n\t\treturn\n\t}\n\tnamespace, policyName := urlParts[3], urlParts[4]\n\tpolicy, err := n.ReadPolicy(namespace, policyName)\n\tif err != nil {\n\t\tlog.Print(err)\n\t\treturn\n\t}\n\tencoder := json.NewEncoder(w)\n\tif err := encoder.Encode(policy); err != nil {\n\t\thttp.Error(w, \"Encode error\", http.StatusBadRequest)\n\t}\n}", "title": "" }, { "docid": "0c494fe0e4808db07d8c94c466f0f195", "score": "0.5075786", "text": "func NewPolicy() *Policy {\n\treturn &Policy{}\n}", "title": "" }, { "docid": "de6d860b8ba607362fa372aa1894c066", "score": "0.50663584", "text": "func (Rule) Policy() ent.Policy {\n\t/*return authz.NewPolicy(\n\t\tauthz.WithMutationRules(\n\t\t\tauthz.AssuranceTemplatesWritePolicyRule(),\n\t\t),\n\t)*/\n\treturn authz.NewPolicy(\n\t\tauthz.WithMutationRules(\n\t\t\tprivacy.AlwaysAllowRule(),\n\t\t),\n\t)\n}", "title": "" }, { "docid": "b3f7cfeb9e4d2fe3716c3ca3aa3ba1b3", "score": "0.50663155", "text": "func (s *API) GetPolicy(req *GetPolicyRequest, opts ...scw.RequestOption) (*Policy, error) {\n\tvar err error\n\n\tif fmt.Sprint(req.PolicyID) == \"\" {\n\t\treturn nil, errors.New(\"field PolicyID cannot be empty in request\")\n\t}\n\n\tscwReq := &scw.ScalewayRequest{\n\t\tMethod: \"GET\",\n\t\tPath: \"/iam/v1alpha1/policies/\" + fmt.Sprint(req.PolicyID) + \"\",\n\t\tHeaders: http.Header{},\n\t}\n\n\tvar resp Policy\n\n\terr = s.client.Do(scwReq, &resp, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resp, nil\n}", "title": "" }, { "docid": "3ab51d9f856160b195a9215209befee3", "score": "0.5059826", "text": "func GetIAMPolicy(ctx *pulumi.Context,\n\tname string, id pulumi.IDInput, state *IAMPolicyState, opts ...pulumi.ResourceOption) (*IAMPolicy, error) {\n\tvar resource IAMPolicy\n\terr := ctx.ReadResource(\"gcp:serviceAccount/iAMPolicy:IAMPolicy\", name, id, state, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "title": "" }, { "docid": "2c3798fc8acf70a0000132a77840b333", "score": "0.50571257", "text": "func (n *node) Policy() *policy {\n\treturn n.policy\n}", "title": "" }, { "docid": "abb0cabe27ac67135302f7ea3cea778d", "score": "0.5017191", "text": "func PossibleDataPolicyValues() []DataPolicy {\n\treturn []DataPolicy{\n\t\tDataPolicyCloud,\n\t\tDataPolicyLocal,\n\t}\n}", "title": "" }, { "docid": "790c81834acb1f497acd59cd6189ee84", "score": "0.49987373", "text": "func (o ReusableConfigValuesOutput) PolicyIds() ObjectIdArrayOutput {\n\treturn o.ApplyT(func(v ReusableConfigValues) []ObjectId { return v.PolicyIds }).(ObjectIdArrayOutput)\n}", "title": "" }, { "docid": "468da5636bdc387b5104b1400d7861e2", "score": "0.49965888", "text": "func (p *BasePolicy) GetBasePolicy() *BasePolicy { return p }", "title": "" }, { "docid": "403ef3a65e7739e793dd87608a3c6104", "score": "0.49947357", "text": "func createPolicyDocument(resourceList []string, provider string) string {\n\tm := deserializeResourceMap(provider)\n\tactionSet := make(map[string]bool)\n\tfmt.Println(\"######### New Policy\")\n\n\t//add common actions that will be needed for every policy\n\tfor _, action := range awsCommonActions {\n\t\tactionSet[action] = true\n\t}\n\n\tfor _, resource := range resourceList {\n\t\t//fmt.Println(\"resource: \" + resource)\n\t\tresourceName := \"resource_\" + resource\n\t\tdataResourceName := \"data_source_\" + resource\n\n\t\tvar actions []string\n\t\tresourceActions, rOk := m[resourceName]\n\t\tdataResourceActions, dOk := m[dataResourceName]\n\t\t//Terraform state list does not make a distinction between data resources and regular resource\n\t\tif rOk && dOk {\n\t\t\tfmt.Printf(\"Indeterminate: \" + resource + \"\\n\")\n\t\t\tvalidText := false\n\t\t\tscanner := bufio.NewScanner(os.Stdin)\n\t\t\tfor !validText {\n\t\t\t\tfmt.Print(\"Select [r]esource or [d]ata resource: \")\n\t\t\t\tscanner.Scan()\n\t\t\t\ttext := scanner.Text()\n\t\t\t\tif text == \"r\" {\n\t\t\t\t\tactions = resourceActions\n\t\t\t\t\tvalidText = true\n\t\t\t\t} else if text == \"d\" {\n\t\t\t\t\tactions = dataResourceActions\n\t\t\t\t\tvalidText = true\n\t\t\t\t}\n\t\t\t}\n\t\t} else if rOk {\n\t\t\tactions = resourceActions\n\t\t} else if dOk {\n\t\t\tactions = dataResourceActions\n\t\t}\n\t\tfor _, action := range actions {\n\t\t\t//is this an add action that we need to account for?\n\t\t\tif val, ok := awsIdiosyncracyActionMap[action]; ok {\n\t\t\t\tif len(val) > 0 {\n\t\t\t\t\tfor _, v := range val {\n\t\t\t\t\t\tactionSet[v] = true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tactionSet[action] = true\n\t\t}\n\t}\n\t//convert set into slice\n\tkeys := make([]string, 0, len(actionSet))\n\tfor k := range actionSet {\n\t\tkeys = append(keys, `\"`+k+`\"`)\n\t}\n\t//sort alphabetically\n\tsort.Sort(sort.StringSlice(keys))\n\tpolicyActions := \"[\" + strings.Join(keys, \", \") + \"]\"\n\tpolicy := fmt.Sprintf(`\n\t{\n\t\t\"Version\": \"2012-10-17\",\n\t\t\"Statement\": [\n\t\t\t{\n\t\t\t\t\"Effect\": \"Allow\",\n\t\t\t\t\"Action\": %s,\n\t\t\t\t\"Resource\": \"*\"\n\t\t\t}\n\t\t]\n\t}\n\t`, policyActions)\n\t//Write output to file\n\tresourceFileName := fmt.Sprintf(\"%s_policy.json\", provider)\n\tos.Remove(resourceFileName)\n\tioutil.WriteFile(resourceFileName, []byte(policy), 0644)\n\tfmt.Printf(\"######### Policy created: %s\\n\", resourceFileName)\n\treturn policy\n}", "title": "" }, { "docid": "69840a111384626b741281c3c691fe05", "score": "0.49886075", "text": "func (b *Base) AccessPolicy() *accesspolicy.Kind {\n\treturn b.accesspolicy\n}", "title": "" }, { "docid": "2c339fbf339dabc480ef66dc336774b8", "score": "0.49824667", "text": "func (client *Client) GetPolicy(id int64, req *Request) (*Response, error) {\n\treturn client.Execute(&Request{\n\t\tMethod: \"GET\",\n\t\tPath: fmt.Sprintf(\"%s/%d\", PoliciesPath, id),\n\t\tQueryParams: req.QueryParams,\n\t\tResult: &GetPolicyResult{},\n\t})\n}", "title": "" }, { "docid": "542a379688c3709475315942f1ec1822", "score": "0.49787518", "text": "func (o ReusableConfigValuesResponseOutput) PolicyIds() ObjectIdResponseArrayOutput {\n\treturn o.ApplyT(func(v ReusableConfigValuesResponse) []ObjectIdResponse { return v.PolicyIds }).(ObjectIdResponseArrayOutput)\n}", "title": "" }, { "docid": "8ed7663840791e116247471a7806d461", "score": "0.4972237", "text": "func newPolicyStore() *policyStore {\n\treturn &policyStore{\n\t\traw: map[string][]byte{},\n\t\tmodules: map[string]*ast.Module{},\n\t}\n}", "title": "" }, { "docid": "e335ac3f1e42f92d84708eb0adb3bc9a", "score": "0.49702513", "text": "func PolicyType_Values() []string {\n\treturn []string{\n\t\tPolicyTypeInline,\n\t\tPolicyTypeManaged,\n\t}\n}", "title": "" }, { "docid": "f64a95285d328870827fedb448c369ab", "score": "0.49678633", "text": "func getSemiHardcodedPolicy(chainID string, mspMgr msp.MSPManager) ([]byte, error) {\n\t// 1) determine the MSP identifier for the first MSP in this chain\n\tvar msp msp.MSP\n\tmsps, err := mspMgr.GetMSPs()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Could not retrieve the MSPs for the chain manager, err %s\", err)\n\t}\n\tif len(msps) == 0 {\n\t\treturn nil, errors.New(\"At least one MSP was expected\")\n\t}\n\tfor _, m := range msps {\n\t\tmsp = m\n\t\tbreak\n\t}\n\tmspid, err := msp.GetIdentifier()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failure getting the msp identifier, err %s\", err)\n\t}\n\n\t// 2) get the policy\n\tp := cauthdsl.SignedByMspMember(mspid)\n\n\t// 3) marshal it and return it\n\tb, err := proto.Marshal(p)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Could not marshal policy, err %s\", err)\n\t}\n\n\treturn b, err\n}", "title": "" }, { "docid": "0ad0b61c1a5b6e4eb05ed13995f2dd27", "score": "0.49666634", "text": "func (o EndpointPolicyOutput) AuthorizationPolicy() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *EndpointPolicy) pulumi.StringOutput { return v.AuthorizationPolicy }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "a7a422a2a397fda507a43886a80ab265", "score": "0.4961069", "text": "func Policy() *Module { return &Module{ModuleBase: &pgs.ModuleBase{}} }", "title": "" }, { "docid": "ce72918998b87406f989d5c83cd344b1", "score": "0.49449253", "text": "func GetPolicy(ctx context.Context, clientsEndpoint string, clientID string, policyID string, protectionAPIToken string) (*KeycloakPolicy, error) {\n\tif policyID == \"\" {\n\t\tlog.Error(ctx, map[string]interface{}{}, \"policy-id is emtpy\")\n\t\treturn nil, errors.NewBadParameterError(\"policyID\", policyID)\n\t}\n\treq, err := http.NewRequest(\"GET\", clientsEndpoint+\"/\"+clientID+\"/authz/resource-server/policy/\"+policyID, nil)\n\tif err != nil {\n\t\tlog.Error(ctx, map[string]interface{}{\n\t\t\t\"err\": err.Error(),\n\t\t}, \"unable to create http request\")\n\t\treturn nil, errors.NewInternalError(errs.Wrap(err, \"unable to create http request\"))\n\t}\n\treq.Header.Add(\"Authorization\", \"Bearer \"+protectionAPIToken)\n\tres, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\tlog.Error(ctx, map[string]interface{}{\n\t\t\t\"client_id\": clientID,\n\t\t\t\"policy_id\": policyID,\n\t\t\t\"err\": err.Error(),\n\t\t}, \"unable to obtain a Keycloak policy\")\n\t\treturn nil, errors.NewInternalError(errs.Wrap(err, \"unable to obtain a Keycloak policy\"))\n\t}\n\tdefer res.Body.Close()\n\tswitch res.StatusCode {\n\tcase http.StatusOK:\n\t\t// OK\n\tcase http.StatusNotFound:\n\t\tlog.Error(ctx, map[string]interface{}{\n\t\t\t\"client_id\": clientID,\n\t\t\t\"policy_id\": policyID,\n\t\t}, \"Keycloak policy is not found\")\n\t\treturn nil, errors.NewNotFoundError(\"policy\", policyID)\n\tdefault:\n\t\tlog.Error(ctx, map[string]interface{}{\n\t\t\t\"client_id\": clientID,\n\t\t\t\"policy_id\": policyID,\n\t\t\t\"response_status\": res.Status,\n\t\t\t\"response_body\": rest.ReadBody(res.Body),\n\t\t}, \"unable to obtain a Keycloak policy\")\n\t\treturn nil, errors.NewInternalError(errs.New(\"unable to obtain a Keycloak policy. Response status: \" + res.Status + \". Responce body: \" + rest.ReadBody(res.Body)))\n\t}\n\tjsonString := rest.ReadBody(res.Body)\n\n\tvar r KeycloakPolicy\n\terr = json.Unmarshal([]byte(jsonString), &r)\n\tif err != nil {\n\t\tlog.Error(ctx, map[string]interface{}{\n\t\t\t\"client_id\": clientID,\n\t\t\t\"policy_id\": policyID,\n\t\t\t\"json_string\": jsonString,\n\t\t}, \"unable to unmarshal json with the get keycloak policy request result\")\n\t\treturn nil, errors.NewInternalError(errs.Wrapf(err, \"error when unmarshal json with get the keycloak policy request result %s \", jsonString))\n\t}\n\n\treturn &r, nil\n}", "title": "" }, { "docid": "bcb9939d34a1697815c58cd07e71b9f9", "score": "0.49414146", "text": "func ProfileEnrollmentPolicy() Policy {\n\tp := Policy{}\n\tp.Type = ProfileEnrollmentPolicyType\n\treturn p\n}", "title": "" }, { "docid": "162b978371d61d9cfadf36b7baaddf53", "score": "0.49332505", "text": "func (PolicyType) Values() []PolicyType {\n\treturn []PolicyType{\n\t\t\"TargetTrackingScaling\",\n\t}\n}", "title": "" }, { "docid": "76516c3eaf116fcf50ef4bda27311ffc", "score": "0.49331868", "text": "func (r *Policy) PolicyType() pulumi.StringOutput {\n\treturn (pulumi.StringOutput)(r.s.State[\"policyType\"])\n}", "title": "" }, { "docid": "80708497956fd18a0efa6cc63661c15e", "score": "0.4930173", "text": "func (s Policy) String() string {\n\treturn awsutil.Prettify(s)\n}", "title": "" }, { "docid": "fe92ee9190f45929f444e8236e1fce0e", "score": "0.4926563", "text": "func (s Policies) String() string {\n\treturn awsutil.Prettify(s)\n}", "title": "" }, { "docid": "973167e5720888a180509353958fa8ca", "score": "0.49165794", "text": "func (o BookmarkOutput) AuthenticationPolicy() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *Bookmark) pulumi.StringPtrOutput { return v.AuthenticationPolicy }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "3d8ea72e0917fdd9ba6ef08b6ecd53c4", "score": "0.49163023", "text": "func cmdListPolicies(ccmd *cobra.Command, args []string) {\n\taplSvc := apl.NewClient()\n\n\toutput := runListCommand(&policyParams, aplSvc.Policies.List)\n\n\tif output != nil {\n\t\tfields := []string{\"ID\", \"Name\", \"PolicyType\", \"PolicyGroup\", \"CreatedTime\"}\n\t\tprintTableResultsCustom(output.([]apl.Policy), fields)\n\t}\n}", "title": "" }, { "docid": "57521a1c42b0fe42de357ec126c70ed9", "score": "0.49104923", "text": "func (_e *LambdaApi_Expecter) GetPolicy(_a0 interface{}) *LambdaApi_GetPolicy_Call {\n\treturn &LambdaApi_GetPolicy_Call{Call: _e.mock.On(\"GetPolicy\", _a0)}\n}", "title": "" }, { "docid": "ddc84c06e05aa89436c4af4cc20a780f", "score": "0.491045", "text": "func (a *openshiftAuthorizer) getPolicy(namespace string) (*authorizationapi.Policy, error) {\n\tctx := kapi.WithNamespace(kapi.NewContext(), namespace)\n\tpolicy, err := a.policyRegistry.GetPolicy(ctx, authorizationapi.PolicyName)\n\tif err != nil && !strings.Contains(err.Error(), \"not found\") {\n\t\treturn nil, err\n\t}\n\n\treturn policy, nil\n}", "title": "" }, { "docid": "38975d0b5998392f03a0aa1baf1f06ce", "score": "0.49050027", "text": "func GetPolicy(ctx *pulumi.Context,\n\tname string, id pulumi.ID, state *PolicyState, opts ...pulumi.ResourceOpt) (*Policy, error) {\n\tinputs := make(map[string]interface{})\n\tif state != nil {\n\t\tinputs[\"adjustmentType\"] = state.AdjustmentType\n\t\tinputs[\"arn\"] = state.Arn\n\t\tinputs[\"autoscalingGroupName\"] = state.AutoscalingGroupName\n\t\tinputs[\"cooldown\"] = state.Cooldown\n\t\tinputs[\"estimatedInstanceWarmup\"] = state.EstimatedInstanceWarmup\n\t\tinputs[\"metricAggregationType\"] = state.MetricAggregationType\n\t\tinputs[\"minAdjustmentMagnitude\"] = state.MinAdjustmentMagnitude\n\t\tinputs[\"name\"] = state.Name\n\t\tinputs[\"policyType\"] = state.PolicyType\n\t\tinputs[\"scalingAdjustment\"] = state.ScalingAdjustment\n\t\tinputs[\"stepAdjustments\"] = state.StepAdjustments\n\t\tinputs[\"targetTrackingConfiguration\"] = state.TargetTrackingConfiguration\n\t}\n\ts, err := ctx.ReadResource(\"aws:autoscaling/policy:Policy\", name, id, inputs, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Policy{s: s}, nil\n}", "title": "" }, { "docid": "1d5fe071a04d0be1e674b19b969a0801", "score": "0.48984677", "text": "func (o AutoscalingPolicyIamPolicyOutput) PolicyId() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *AutoscalingPolicyIamPolicy) pulumi.StringOutput { return v.PolicyId }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "0f11a9de5dc8d057f4142c3c60b04882", "score": "0.4895337", "text": "func (User) Policy() ent.Policy {\n\treturn privacy.Policy{\n\t\tMutation: privacy.MutationPolicy{\n\t\t\trule.DenyIfNoViewer(),\n\t\t\trule.AllowIfAdmin(),\n\t\t\tprivacy.AlwaysDenyRule(),\n\t\t},\n\t\tQuery: privacy.QueryPolicy{\n\t\t\tprivacy.AlwaysAllowRule(),\n\t\t},\n\t}\n}", "title": "" }, { "docid": "a7315541b8b70e4afde5ef9dbc8737fe", "score": "0.48936453", "text": "func (user IAMUser) GetAllPolicies() map[string]string {\n\tresult := make(map[string]string)\n\tfor k, v := range user.InlinePolicies {\n\t\tresult[k] = v\n\t}\n\tfor k, v := range user.AttachedPolicies {\n\t\tresult[k] = v\n\t}\n\tfor k, v := range user.InlineGroupPolicies {\n\t\tresult[k] = v\n\t}\n\tfor k, v := range user.AttachedGroupPolicies {\n\t\tresult[k] = v\n\t}\n\treturn result\n}", "title": "" }, { "docid": "ba9d46397fa414c6ab37c2ddabb4a530", "score": "0.48899683", "text": "func (o *ExportPolicyInfoType) PolicyId() int {\n\tvar r int\n\tif o.PolicyIdPtr == nil {\n\t\treturn r\n\t}\n\tr = *o.PolicyIdPtr\n\treturn r\n}", "title": "" }, { "docid": "a36111dd0bed2c4ae2827aee8c20452c", "score": "0.4887456", "text": "func (db *Store) GetPolicy(ctx context.Context, txn storage.Transaction, id string) ([]byte, error) {\n\tunderlying, err := db.underlying(txn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn underlying.GetPolicy(ctx, id)\n}", "title": "" }, { "docid": "51a9387c61dd39e71aacdc41daf5280b", "score": "0.48817378", "text": "func (a *awsPolicyCreator) Details() string {\n\treturn a.formattedPolicy\n}", "title": "" }, { "docid": "af49d1f8982e714ef26c87af16f627e1", "score": "0.4875217", "text": "func (o PolicyOutput) PolicyName() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Policy) pulumi.StringOutput { return v.PolicyName }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "a14f2d19d983580b82b844595e668339", "score": "0.48721284", "text": "func (o OrganizationSecurityPolicyRuleOutput) PolicyId() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *OrganizationSecurityPolicyRule) pulumi.StringOutput { return v.PolicyId }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "eb6dbb505033c7029491d61b793ce0cb", "score": "0.48579386", "text": "func init() {\n\tallocationstrategy.Policy = privacy.NewPolicies(schema.AllocationStrategy{})\n\tallocationstrategy.Hooks[0] = func(next ent.Mutator) ent.Mutator {\n\t\treturn ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {\n\t\t\tif err := allocationstrategy.Policy.EvalMutation(ctx, m); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\treturn next.Mutate(ctx, m)\n\t\t})\n\t}\n\tallocationstrategyFields := schema.AllocationStrategy{}.Fields()\n\t_ = allocationstrategyFields\n\t// allocationstrategyDescName is the schema descriptor for name field.\n\tallocationstrategyDescName := allocationstrategyFields[0].Descriptor()\n\t// allocationstrategy.NameValidator is a validator for the \"name\" field. It is called by the builders before save.\n\tallocationstrategy.NameValidator = allocationstrategyDescName.Validators[0].(func(string) error)\n\t// allocationstrategyDescScript is the schema descriptor for script field.\n\tallocationstrategyDescScript := allocationstrategyFields[3].Descriptor()\n\t// allocationstrategy.ScriptValidator is a validator for the \"script\" field. It is called by the builders before save.\n\tallocationstrategy.ScriptValidator = allocationstrategyDescScript.Validators[0].(func(string) error)\n\tpoolproperties.Policy = privacy.NewPolicies(schema.PoolProperties{})\n\tpoolproperties.Hooks[0] = func(next ent.Mutator) ent.Mutator {\n\t\treturn ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {\n\t\t\tif err := poolproperties.Policy.EvalMutation(ctx, m); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\treturn next.Mutate(ctx, m)\n\t\t})\n\t}\n\tproperty.Policy = privacy.NewPolicies(schema.Property{})\n\tproperty.Hooks[0] = func(next ent.Mutator) ent.Mutator {\n\t\treturn ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {\n\t\t\tif err := property.Policy.EvalMutation(ctx, m); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\treturn next.Mutate(ctx, m)\n\t\t})\n\t}\n\tpropertytype.Policy = privacy.NewPolicies(schema.PropertyType{})\n\tpropertytype.Hooks[0] = func(next ent.Mutator) ent.Mutator {\n\t\treturn ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {\n\t\t\tif err := propertytype.Policy.EvalMutation(ctx, m); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\treturn next.Mutate(ctx, m)\n\t\t})\n\t}\n\tpropertytypeFields := schema.PropertyType{}.Fields()\n\t_ = propertytypeFields\n\t// propertytypeDescIsInstanceProperty is the schema descriptor for is_instance_property field.\n\tpropertytypeDescIsInstanceProperty := propertytypeFields[13].Descriptor()\n\t// propertytype.DefaultIsInstanceProperty holds the default value on creation for the is_instance_property field.\n\tpropertytype.DefaultIsInstanceProperty = propertytypeDescIsInstanceProperty.Default.(bool)\n\t// propertytypeDescEditable is the schema descriptor for editable field.\n\tpropertytypeDescEditable := propertytypeFields[14].Descriptor()\n\t// propertytype.DefaultEditable holds the default value on creation for the editable field.\n\tpropertytype.DefaultEditable = propertytypeDescEditable.Default.(bool)\n\t// propertytypeDescMandatory is the schema descriptor for mandatory field.\n\tpropertytypeDescMandatory := propertytypeFields[15].Descriptor()\n\t// propertytype.DefaultMandatory holds the default value on creation for the mandatory field.\n\tpropertytype.DefaultMandatory = propertytypeDescMandatory.Default.(bool)\n\t// propertytypeDescDeleted is the schema descriptor for deleted field.\n\tpropertytypeDescDeleted := propertytypeFields[16].Descriptor()\n\t// propertytype.DefaultDeleted holds the default value on creation for the deleted field.\n\tpropertytype.DefaultDeleted = propertytypeDescDeleted.Default.(bool)\n\tresource.Policy = privacy.NewPolicies(schema.Resource{})\n\tresource.Hooks[0] = func(next ent.Mutator) ent.Mutator {\n\t\treturn ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {\n\t\t\tif err := resource.Policy.EvalMutation(ctx, m); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\treturn next.Mutate(ctx, m)\n\t\t})\n\t}\n\tresourceFields := schema.Resource{}.Fields()\n\t_ = resourceFields\n\t// resourceDescUpdatedAt is the schema descriptor for updated_at field.\n\tresourceDescUpdatedAt := resourceFields[2].Descriptor()\n\t// resource.DefaultUpdatedAt holds the default value on creation for the updated_at field.\n\tresource.DefaultUpdatedAt = resourceDescUpdatedAt.Default.(func() time.Time)\n\t// resource.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.\n\tresource.UpdateDefaultUpdatedAt = resourceDescUpdatedAt.UpdateDefault.(func() time.Time)\n\tresourcepool.Policy = privacy.NewPolicies(schema.ResourcePool{})\n\tresourcepool.Hooks[0] = func(next ent.Mutator) ent.Mutator {\n\t\treturn ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {\n\t\t\tif err := resourcepool.Policy.EvalMutation(ctx, m); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\treturn next.Mutate(ctx, m)\n\t\t})\n\t}\n\tresourcepoolFields := schema.ResourcePool{}.Fields()\n\t_ = resourcepoolFields\n\t// resourcepoolDescName is the schema descriptor for name field.\n\tresourcepoolDescName := resourcepoolFields[0].Descriptor()\n\t// resourcepool.NameValidator is a validator for the \"name\" field. It is called by the builders before save.\n\tresourcepool.NameValidator = resourcepoolDescName.Validators[0].(func(string) error)\n\t// resourcepoolDescDealocationSafetyPeriod is the schema descriptor for dealocation_safety_period field.\n\tresourcepoolDescDealocationSafetyPeriod := resourcepoolFields[3].Descriptor()\n\t// resourcepool.DefaultDealocationSafetyPeriod holds the default value on creation for the dealocation_safety_period field.\n\tresourcepool.DefaultDealocationSafetyPeriod = resourcepoolDescDealocationSafetyPeriod.Default.(int)\n\tresourcetype.Policy = privacy.NewPolicies(schema.ResourceType{})\n\tresourcetype.Hooks[0] = func(next ent.Mutator) ent.Mutator {\n\t\treturn ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {\n\t\t\tif err := resourcetype.Policy.EvalMutation(ctx, m); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\treturn next.Mutate(ctx, m)\n\t\t})\n\t}\n\tresourcetypeFields := schema.ResourceType{}.Fields()\n\t_ = resourcetypeFields\n\t// resourcetypeDescName is the schema descriptor for name field.\n\tresourcetypeDescName := resourcetypeFields[0].Descriptor()\n\t// resourcetype.NameValidator is a validator for the \"name\" field. It is called by the builders before save.\n\tresourcetype.NameValidator = resourcetypeDescName.Validators[0].(func(string) error)\n\ttagFields := schema.Tag{}.Fields()\n\t_ = tagFields\n\t// tagDescTag is the schema descriptor for tag field.\n\ttagDescTag := tagFields[0].Descriptor()\n\t// tag.TagValidator is a validator for the \"tag\" field. It is called by the builders before save.\n\ttag.TagValidator = tagDescTag.Validators[0].(func(string) error)\n}", "title": "" }, { "docid": "44f490515e4af3c05e0eb4ba4aeae1b7", "score": "0.48564366", "text": "func (*AuthorizationPolicy) Descriptor() ([]byte, []int) {\n\treturn file_security_v1_authorization_policy_proto_rawDescGZIP(), []int{0}\n}", "title": "" }, { "docid": "938a4bfccd0df2ab0e36a275ac2a2cf3", "score": "0.48534885", "text": "func (PolicyType) Values() []PolicyType {\n\treturn []PolicyType{\n\t\t\"STATIC\",\n\t\t\"TEMPLATE_LINKED\",\n\t}\n}", "title": "" }, { "docid": "0e98e6989ddac8fc1838d5a511d6fedf", "score": "0.48516577", "text": "func ListPolicyGoals() {\n\tserviceFactories := hubbub.ServiceFactories()\n\tprettyTable(\"goals\", serviceFactories.Goals())\n}", "title": "" }, { "docid": "eefc6dff109b94808351e39fe3987692", "score": "0.48492044", "text": "func getAllPolicies(client *client.Client) ([]romanaApi.Policy, error) {\n\treturn client.ListPolicies()\n}", "title": "" }, { "docid": "5112879f7d4076391c1a8ef59ae24ac7", "score": "0.484481", "text": "func (s *API) ListPolicies(req *ListPoliciesRequest, opts ...scw.RequestOption) (*ListPoliciesResponse, error) {\n\tvar err error\n\n\tdefaultPageSize, exist := s.client.GetDefaultPageSize()\n\tif (req.PageSize == nil || *req.PageSize == 0) && exist {\n\t\treq.PageSize = &defaultPageSize\n\t}\n\n\tquery := url.Values{}\n\tparameter.AddToQuery(query, \"order_by\", req.OrderBy)\n\tparameter.AddToQuery(query, \"page_size\", req.PageSize)\n\tparameter.AddToQuery(query, \"page\", req.Page)\n\tparameter.AddToQuery(query, \"organization_id\", req.OrganizationID)\n\tparameter.AddToQuery(query, \"editable\", req.Editable)\n\tparameter.AddToQuery(query, \"user_ids\", req.UserIDs)\n\tparameter.AddToQuery(query, \"group_ids\", req.GroupIDs)\n\tparameter.AddToQuery(query, \"application_ids\", req.ApplicationIDs)\n\tparameter.AddToQuery(query, \"no_principal\", req.NoPrincipal)\n\tparameter.AddToQuery(query, \"policy_name\", req.PolicyName)\n\n\tscwReq := &scw.ScalewayRequest{\n\t\tMethod: \"GET\",\n\t\tPath: \"/iam/v1alpha1/policies\",\n\t\tQuery: query,\n\t\tHeaders: http.Header{},\n\t}\n\n\tvar resp ListPoliciesResponse\n\n\terr = s.client.Do(scwReq, &resp, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resp, nil\n}", "title": "" }, { "docid": "3e0feb33a92e6a9ad0b6b0c96d3c92f2", "score": "0.48408398", "text": "func PolicySourceType_Values() []string {\n\treturn []string{\n\t\tPolicySourceTypeUser,\n\t\tPolicySourceTypeGroup,\n\t\tPolicySourceTypeRole,\n\t\tPolicySourceTypeAwsManaged,\n\t\tPolicySourceTypeUserManaged,\n\t\tPolicySourceTypeResource,\n\t\tPolicySourceTypeNone,\n\t}\n}", "title": "" }, { "docid": "febc7e47a9844b8e88fc8870ae5fc195", "score": "0.48326412", "text": "func (a *DBAdapter) LoadPolicy(model casbin.Model) {\n\ta.open()\n\tdefer a.close()\n\n\tvar (\n\t\tptype string\n\t\tv1 string\n\t\tv2 string\n\t\tv3 string\n\t\tv4 string\n\t)\n\n\trows, err := a.db.Query(\"select * from policy\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer rows.Close()\n\tfor rows.Next() {\n\t\terr := rows.Scan(&ptype, &v1, &v2, &v3, &v4)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tline := ptype\n\t\tif v1 != \"\" {\n\t\t\tline += \", \" + v1\n\t\t}\n\t\tif v2 != \"\" {\n\t\t\tline += \", \" + v2\n\t\t}\n\t\tif v3 != \"\" {\n\t\t\tline += \", \" + v3\n\t\t}\n\t\tif v4 != \"\" {\n\t\t\tline += \", \" + v4\n\t\t}\n\n\t\tloadPolicyLine(line, model)\n\t\t// log.Println(ptype, v1, v2, v3, v4)\n\t}\n\terr = rows.Err()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}", "title": "" }, { "docid": "1ceb50f86c41d715d16626c53c3a65f8", "score": "0.48262006", "text": "func (o ReusableConfigValuesResponsePtrOutput) PolicyIds() ObjectIdResponseArrayOutput {\n\treturn o.ApplyT(func(v *ReusableConfigValuesResponse) []ObjectIdResponse {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.PolicyIds\n\t}).(ObjectIdResponseArrayOutput)\n}", "title": "" }, { "docid": "e2a037c19230dfcf3cbae03c7d6e5945", "score": "0.48255596", "text": "func LoadPolicyFromCustomResources() {\n\tvar apList AdmissionPolicyList\n\n\tgetAdmissionPolicies(&apList)\n\n\tAdmissionPolicies = append(AdmissionPolicies, apList.Items...)\n\n\tlogger.LogStuff(\"Existing admissionpolicies: \", AdmissionPolicies)\n\n}", "title": "" }, { "docid": "db40ac9927ce38717e9012e5ab1854df", "score": "0.48240495", "text": "func (o WafRuleOutput) PolicyId() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *WafRule) pulumi.StringOutput { return v.PolicyId }).(pulumi.StringOutput)\n}", "title": "" }, { "docid": "c01e689fb4e84974ea30e770eac5ac64", "score": "0.48213103", "text": "func (*PrincipalPolicy) Descriptor() ([]byte, []int) {\n\treturn file_cerbos_policy_v1_policy_proto_rawDescGZIP(), []int{4}\n}", "title": "" }, { "docid": "8c854b3649ed91c77fa914a3a02bd8ea", "score": "0.4814685", "text": "func (cli *OpsGenieClient) Policy() (*OpsGeniePolicyClient, error) {\n\tcli.makeHTTPTransportSettings()\n\n\tpolicyClient := new(OpsGeniePolicyClient)\n\tpolicyClient.SetOpsGenieClient(*cli)\n\n\tif cli.opsGenieAPIURL == \"\" {\n\t\tpolicyClient.SetOpsGenieAPIUrl(endpointURL)\n\t}\n\n\treturn policyClient, nil\n}", "title": "" } ]
37a5859c52bdf59b271e9ddcc2e56a32
NewGetUserAppEntitlementByAppIDParamsWithHTTPClient creates a new GetUserAppEntitlementByAppIDParams object with the default values initialized, and the ability to set a custom HTTPClient for a request
[ { "docid": "98f92c851bebb18e262e248929054a7e", "score": "0.82293993", "text": "func NewGetUserAppEntitlementByAppIDParamsWithHTTPClient(client *http.Client) *GetUserAppEntitlementByAppIDParams {\n\tvar (\n\t\tactiveOnlyDefault = bool(true)\n\t)\n\treturn &GetUserAppEntitlementByAppIDParams{\n\t\tActiveOnly: &activeOnlyDefault,\n\t\tHTTPClient: client,\n\t}\n}", "title": "" } ]
[ { "docid": "57e72d6246e0be9e6491bdaa3928a0b3", "score": "0.7976981", "text": "func (o *GetUserAppEntitlementByAppIDParams) WithHTTPClient(client *http.Client) *GetUserAppEntitlementByAppIDParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "title": "" }, { "docid": "9644c7d80ad45fb80f3aa59d135458e3", "score": "0.7136733", "text": "func NewGetUserAppEntitlementByAppIDParams() *GetUserAppEntitlementByAppIDParams {\n\tvar (\n\t\tactiveOnlyDefault = bool(true)\n\t)\n\treturn &GetUserAppEntitlementByAppIDParams{\n\t\tActiveOnly: &activeOnlyDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "title": "" }, { "docid": "15407759c4a84da3a1a618cd986101cb", "score": "0.67261887", "text": "func NewGetUserAppEntitlementByAppIDParamsWithTimeout(timeout time.Duration) *GetUserAppEntitlementByAppIDParams {\n\tvar (\n\t\tactiveOnlyDefault = bool(true)\n\t)\n\treturn &GetUserAppEntitlementByAppIDParams{\n\t\tActiveOnly: &activeOnlyDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "title": "" }, { "docid": "a0bf8ac9aa1823efb3e0b541cdfd240d", "score": "0.66803664", "text": "func (o *GetUserAppEntitlementByAppIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "334e0614a78acd7ad6d49cc68fbd098a", "score": "0.6267292", "text": "func (o *GetUserAppEntitlementByAppIDParams) WithContext(ctx context.Context) *GetUserAppEntitlementByAppIDParams {\n\to.SetContext(ctx)\n\treturn o\n}", "title": "" }, { "docid": "558e25eeab20850a5bd7f18d49eb2903", "score": "0.61872476", "text": "func NewGenerateAppOauthParamsWithHTTPClient(client *http.Client) *GenerateAppOauthParams {\n\tvar ()\n\treturn &GenerateAppOauthParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "7dac52c1566f7ecd822e377f9461e630", "score": "0.6098615", "text": "func NewUserInfoParamsWithHTTPClient(client *http.Client) *UserInfoParams {\n\tvar ()\n\treturn &UserInfoParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "f01122c6e7028ed1c044e1efc592405d", "score": "0.59404397", "text": "func NewAPICreateUserParamsWithHTTPClient(client *http.Client) *APICreateUserParams {\n\tvar ()\n\treturn &APICreateUserParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "fd17ffda5a75b6006a9e16650d737fd1", "score": "0.59112227", "text": "func NewGetResourceByIDUsingGETParamsWithHTTPClient(client *http.Client) *GetResourceByIDUsingGETParams {\n\tvar ()\n\treturn &GetResourceByIDUsingGETParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "cbad24bb57af31700c57b40f06479329", "score": "0.5889542", "text": "func (o *GetResourceByIDUsingGETParams) WithHTTPClient(client *http.Client) *GetResourceByIDUsingGETParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "title": "" }, { "docid": "5b035c9f7c016770b09e70a92fdfb818", "score": "0.58731294", "text": "func NewIntrospectParamsWithHTTPClient(client *http.Client) *IntrospectParams {\n\tvar ()\n\treturn &IntrospectParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "b9088f0af457ddbb9f83f24ab7493b90", "score": "0.5834737", "text": "func NewGetLicenseKeyParamsWithHTTPClient(client *http.Client) *GetLicenseKeyParams {\n\tvar ()\n\treturn &GetLicenseKeyParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "621c9a986f381b8476235389ecadcdfc", "score": "0.5809654", "text": "func NewGetUsageParamsWithHTTPClient(client *http.Client) *GetUsageParams {\n\tvar ()\n\treturn &GetUsageParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "dfdfb59bee437e18caf9344ed886ad4e", "score": "0.5809544", "text": "func NewGetUserByUserNameParamsWithHTTPClient(client *http.Client) *GetUserByUserNameParams {\n\tvar ()\n\treturn &GetUserByUserNameParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "0a36c806f5017ed31003b6b79a249495", "score": "0.5796999", "text": "func NewGetIOAUsersParamsWithHTTPClient(client *http.Client) *GetIOAUsersParams {\n\treturn &GetIOAUsersParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "eb3bcc7310dd82bdb07f2ae1f8f5cbfe", "score": "0.57953537", "text": "func (o *GenerateAppOauthParams) WithHTTPClient(client *http.Client) *GenerateAppOauthParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "title": "" }, { "docid": "f68c4314bbe54e5b743cbe32e8943c64", "score": "0.57594657", "text": "func (o *EmployeesByIDGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "fdf77811f4bceb14382e50661c372342", "score": "0.57562983", "text": "func NewAuthorizeParamsWithHTTPClient(client *http.Client) *AuthorizeParams {\n\tvar (\n\t\taidDefault = string(\"default\")\n\t\ttidDefault = string(\"default\")\n\t)\n\treturn &AuthorizeParams{\n\t\tAid: aidDefault,\n\t\tTid: tidDefault,\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "60179e00257c76de9f16bf4dc0ecf2bd", "score": "0.57449377", "text": "func NewGetUserAppEntitlementByAppIDParamsWithContext(ctx context.Context) *GetUserAppEntitlementByAppIDParams {\n\tvar (\n\t\tactiveOnlyDefault = bool(true)\n\t)\n\treturn &GetUserAppEntitlementByAppIDParams{\n\t\tActiveOnly: &activeOnlyDefault,\n\n\t\tContext: ctx,\n\t}\n}", "title": "" }, { "docid": "a568ba4c87bee442dcddea2476dd0a24", "score": "0.5726237", "text": "func NewGetItemByIDParamsWithHTTPClient(client *http.Client) *GetItemByIDParams {\n\treturn &GetItemByIDParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "44aa1fa4a65a31e20eb36037a9891819", "score": "0.5718124", "text": "func NewGetParamsWithHTTPClient(client *http.Client) *GetParams {\n\tvar ()\n\treturn &GetParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "2ac17b77edc1ce113851f39bfca923f9", "score": "0.57111806", "text": "func APICallContextOptionHTTPClient(httpClient *http.Client) APICallContextOptionFunc {\n\treturn func(options *APICallContextOptions) {\n\t\toptions.httpClient = httpClient\n\t}\n}", "title": "" }, { "docid": "f0734a197fdcde087cfbb8dd68982e68", "score": "0.568644", "text": "func (o *GetUserAppEntitlementByAppIDParams) WithUserID(userID string) *GetUserAppEntitlementByAppIDParams {\n\to.SetUserID(userID)\n\treturn o\n}", "title": "" }, { "docid": "b4f5d62f2fdc94c0d217b2f23d0bd703", "score": "0.5646066", "text": "func (o *GetUserAppEntitlementByAppIDParams) WithTimeout(timeout time.Duration) *GetUserAppEntitlementByAppIDParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "title": "" }, { "docid": "7aa201798ca89531592a72fcb58354f6", "score": "0.56400216", "text": "func WithHTTPClient(cl *http.Client) Param {\n\treturn httpParam{cl}\n}", "title": "" }, { "docid": "7db5aabbdf07ff1ac1d67c35690cd7e6", "score": "0.56187785", "text": "func NewGetFyiNotificationsParamsWithHTTPClient(client *http.Client) *GetFyiNotificationsParams {\n\tvar ()\n\treturn &GetFyiNotificationsParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "a9ebcc3cf5bc49c24684a3cca7c96582", "score": "0.56137455", "text": "func NewGetAccountAPIKeysClientIDParamsWithHTTPClient(client *http.Client) *GetAccountAPIKeysClientIDParams {\n\tvar ()\n\treturn &GetAccountAPIKeysClientIDParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "366186d882adf515dfbab011ad2e00d9", "score": "0.5611105", "text": "func (o *GetItemByIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "c38325264704c9365701bf0362638856", "score": "0.5609913", "text": "func NewUpdateAppOauthParamsWithHTTPClient(client *http.Client) *UpdateAppOauthParams {\n\tvar ()\n\treturn &UpdateAppOauthParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "edab8cee4188ed3a5635c62aecafde79", "score": "0.55937624", "text": "func NewGetAuthorizeParamsWithHTTPClient(client *http.Client) *GetAuthorizeParams {\n\tvar ()\n\treturn &GetAuthorizeParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "8909d22fade8c8e74ca65cae0eb4bed9", "score": "0.5586517", "text": "func NewIPMIDataParamsWithHTTPClient(client *http.Client) *IPMIDataParams {\n\tvar ()\n\treturn &IPMIDataParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "25a864bfd036ed99a9349abee7f9de8e", "score": "0.5575472", "text": "func (o *GetUserAppEntitlementByAppIDParams) WithAppID(appID string) *GetUserAppEntitlementByAppIDParams {\n\to.SetAppID(appID)\n\treturn o\n}", "title": "" }, { "docid": "1215fbb197696fbe8700966455da94f9", "score": "0.55741036", "text": "func NewGetEventitemsParamsWithHTTPClient(client *http.Client) *GetEventitemsParams {\n\tvar ()\n\treturn &GetEventitemsParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "8c97da0043129978e3df64994587c63f", "score": "0.5560346", "text": "func NewGetPageByIDParamsWithHTTPClient(client *http.Client) *GetPageByIDParams {\n\tvar ()\n\treturn &GetPageByIDParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "cc03b1601a38ae0500a9bdedde8057b9", "score": "0.55557483", "text": "func NewGetReleasesParamsWithHTTPClient(client *http.Client) *GetReleasesParams {\n\tvar (\n\t\ttillerHostDefault = string(\"None\")\n\t)\n\treturn &GetReleasesParams{\n\t\tTillerHost: &tillerHostDefault,\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "800053648e8c5325eb960e21d1a1a779", "score": "0.555172", "text": "func NewGetActivitiesByDateParamsWithHTTPClient(client *http.Client) *GetActivitiesByDateParams {\n\tvar ()\n\treturn &GetActivitiesByDateParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "4188e05546f9929757947db510ff628c", "score": "0.5541352", "text": "func NewSetKeyParamsWithHTTPClient(client *http.Client) *SetKeyParams {\n\treturn &SetKeyParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "149699ac6ec39652decbbadd09d4a157", "score": "0.5496218", "text": "func (o *GetResourceByIDUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "3ab11a23585202ccad57626895fb38fe", "score": "0.5496057", "text": "func NewGetDevicesParamsWithHTTPClient(client *http.Client) *GetDevicesParams {\n\tvar ()\n\treturn &GetDevicesParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "d142ea5d764b62d26b14db71f7c61645", "score": "0.5471288", "text": "func NewPageAlertsParamsWithHTTPClient(client *http.Client) *PageAlertsParams {\n\treturn &PageAlertsParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "bab18de4e7b6135302fa39e6eb4df9ef", "score": "0.5468326", "text": "func NewGetCapabilityUsingGETParamsWithHTTPClient(client *http.Client) *GetCapabilityUsingGETParams {\n\tvar ()\n\treturn &GetCapabilityUsingGETParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "2bdd4564802517e9e8b3bdb45568a398", "score": "0.54403114", "text": "func (o *EmployeesByIDGetParams) WithHTTPClient(client *http.Client) *EmployeesByIDGetParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "title": "" }, { "docid": "084c006eb2d6f4ba3c3645d2c2c67a9e", "score": "0.54365224", "text": "func NewFabricGetParamsWithHTTPClient(client *http.Client) *FabricGetParams {\n\treturn &FabricGetParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "e5290bb1ca13548012efb7c203d7945f", "score": "0.5422222", "text": "func NewAuthenticateParamsWithHTTPClient(client *http.Client) *AuthenticateParams {\n\treturn &AuthenticateParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "b135a541296b8e1a9831b0197a76b32c", "score": "0.5410114", "text": "func NewGetTimeParamsWithHTTPClient(client *http.Client) *GetTimeParams {\n\tvar ()\n\treturn &GetTimeParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "db20b4f00240decc6f89760b17c2cf94", "score": "0.5403078", "text": "func (o *GetProductCertificateUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "c7aeaffbb4fc4a616abde0043c6bd3b9", "score": "0.54001", "text": "func (o *GetAccountAPIKeysClientIDParams) WithHTTPClient(client *http.Client) *GetAccountAPIKeysClientIDParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "title": "" }, { "docid": "3d8893ad2ec7bd679441334e362f8ced", "score": "0.5393953", "text": "func NewGetProviderParamsWithHTTPClient(client *http.Client) *GetProviderParams {\n\tvar ()\n\treturn &GetProviderParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "50e14df1c5d7cfddd7d3a58b356ce301", "score": "0.53828377", "text": "func NewEmployeesByIDGetParamsWithHTTPClient(client *http.Client) *EmployeesByIDGetParams {\n\tvar ()\n\treturn &EmployeesByIDGetParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "1237190acf869805edc816ec4e6b2e96", "score": "0.53827226", "text": "func (o *GetAccountAPIKeysClientIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "95c5bb2801351ff68b366ff2bee8d24f", "score": "0.53789985", "text": "func NewGetActivitiesResourceByDateIntradayParamsWithHTTPClient(client *http.Client) *GetActivitiesResourceByDateIntradayParams {\n\tvar (\n\t\tdetailLevelDefault = string(\"1min\")\n\t\tresourcePathDefault = string(\"steps\")\n\t)\n\treturn &GetActivitiesResourceByDateIntradayParams{\n\t\tDetailLevel: detailLevelDefault,\n\t\tResourcePath: resourcePathDefault,\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "caf789773485d7bfdc463cf0e49e6272", "score": "0.5375022", "text": "func NewCheckUserAvailabilityParamsWithHTTPClient(client *http.Client) *CheckUserAvailabilityParams {\n\tvar ()\n\treturn &CheckUserAvailabilityParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "246c4f66153b7d91f56819e448c1dc3e", "score": "0.53708196", "text": "func (o *GetOpenbankingParticipantsRequest) WithHTTPClient(client *http.Client) *GetOpenbankingParticipantsRequest {\n\to.HTTPClient = client\n\treturn o\n}", "title": "" }, { "docid": "cb8e929f66108a458d4351364e75a2ea", "score": "0.5367986", "text": "func (o *GetProductsByIDOptionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "cea19c4e496ee780cc2a6806becda129", "score": "0.536213", "text": "func (o *GetaspecificInvoiceParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "804c2177123e5112fe23de6cc3f6c4fd", "score": "0.5346612", "text": "func (o *GetPageByIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "900be7d4148450152c2d5461ca0a2ab0", "score": "0.5346151", "text": "func (o *GetV1IncidentsIncidentIDEventsEventIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "ff26bde092bf87166dd9ccef312af409", "score": "0.5343143", "text": "func NewGetJobTypeParamsWithHTTPClient(client *http.Client) *GetJobTypeParams {\n\tvar ()\n\treturn &GetJobTypeParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "81c74e7f0bd4a18d6b73de42260b665a", "score": "0.53404367", "text": "func NewGetServiceCustomServiceParamsWithHTTPClient(client *http.Client) *GetServiceCustomServiceParams {\n\tvar (\n\t\tincludeProcessGroupReferencesDefault = bool(false)\n\t)\n\treturn &GetServiceCustomServiceParams{\n\t\tIncludeProcessGroupReferences: &includeProcessGroupReferencesDefault,\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "d574a0b9fddd3146b8210fcce0f5de61", "score": "0.5332118", "text": "func (o *GetRestapiV10AccountAccountIDExtensionExtensionIDMessageStoreMessageIDContentAttachmentIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "8bbdc2de43cb9ed5e7c6446335906277", "score": "0.53301954", "text": "func NewGetItemsParamsWithHTTPClient(client *http.Client) *GetItemsParams {\n\tvar (\n\t\trecursiveDefault = bool(false)\n\t)\n\treturn &GetItemsParams{\n\t\tRecursive: &recursiveDefault,\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "e10d515ee68cb083402756efddadfbe7", "score": "0.53069144", "text": "func (o *GetPromotionsByIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "68a0bbe3883ad68cf9cc9c008e041985", "score": "0.53013486", "text": "func (o *GetEventitemsParams) WithHTTPClient(client *http.Client) *GetEventitemsParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "title": "" }, { "docid": "2a142dee90f54c53e55032aee230965d", "score": "0.5297309", "text": "func (o *GetDeploymentByIDUsingGETParams) WithHTTPClient(client *http.Client) *GetDeploymentByIDUsingGETParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "title": "" }, { "docid": "2a142dee90f54c53e55032aee230965d", "score": "0.5297309", "text": "func (o *GetDeploymentByIDUsingGETParams) WithHTTPClient(client *http.Client) *GetDeploymentByIDUsingGETParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "title": "" }, { "docid": "d4ce0e98739592f54dbf8eeebd418a07", "score": "0.5295315", "text": "func (o *GetIOAUsersParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "f1ab59e5744bf916548f34e4ccdbdd2d", "score": "0.52914983", "text": "func NewCreateOrUpdateParamsWithHTTPClient(client *http.Client) *CreateOrUpdateParams {\n\tvar ()\n\treturn &CreateOrUpdateParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "f1ab59e5744bf916548f34e4ccdbdd2d", "score": "0.52914983", "text": "func NewCreateOrUpdateParamsWithHTTPClient(client *http.Client) *CreateOrUpdateParams {\n\tvar ()\n\treturn &CreateOrUpdateParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "e62c72a1f89d760fccd4a85908ea2ddd", "score": "0.5287429", "text": "func NewDigParamsWithHTTPClient(client *http.Client) *DigParams {\n\tvar ()\n\treturn &DigParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "df08e61c7ce82bdc4f59ef98ddf598b6", "score": "0.52860767", "text": "func (o *GetPbxDeviceProfileitemsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "82ff8c55f0f3732dea90d93f9da7192e", "score": "0.527904", "text": "func (o *PublicGetMyEntitlementOwnershipBySkuParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "4ebe2e0af90ab1879afe937449b894ac", "score": "0.52770615", "text": "func NewGetTagsParamsWithHTTPClient(client *http.Client) *GetTagsParams {\n\tvar ()\n\treturn &GetTagsParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "2fd040c9490327be6ff541962f9352ee", "score": "0.5276667", "text": "func (o *GetDeploymentByIDUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "2fd040c9490327be6ff541962f9352ee", "score": "0.5276667", "text": "func (o *GetDeploymentByIDUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "d7c4a242451923ba80308b2aecd80304", "score": "0.5272525", "text": "func (o *GetActivitiesResourceByDateIntradayParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "e3c7d204eb4371e4dc5ea2069885e322", "score": "0.5269902", "text": "func (o *GetUsageParams) WithHTTPClient(client *http.Client) *GetUsageParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "title": "" }, { "docid": "2b8bd1ceb88f9eb4f8c8e1f5d88b8606", "score": "0.52681065", "text": "func NewGetEntryParamsWithHTTPClient(client *http.Client) *GetEntryParams {\n\tvar ()\n\treturn &GetEntryParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "8cd195e8829598291beb5741ae24ce97", "score": "0.5267436", "text": "func (o *GenerateAppOauthParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "a2f5edc16dd6117ef0b93121d7d94fd6", "score": "0.5254769", "text": "func (o *PutProductsByIDProductOptionsByIDValuesByIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "66814151459ba2f4d11f167ce379aa50", "score": "0.5254208", "text": "func (o *GetPaymentRequestEDIParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "bf7ed2b6dfe912c74f229ba43ce0a832", "score": "0.52526146", "text": "func (o *GetAllSellerProfileUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "f55b96210471470d53ab45aef5320fbd", "score": "0.52483064", "text": "func (o *GetV1TicketingProjectsTicketingProjectIDConfigurationOptionsOptionsForFieldIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "5c8619b6fa5f2909cb80f4c1eb48103c", "score": "0.52434874", "text": "func (o *PostTaskByIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "0c0684a5233955fcbb401974b56c4e83", "score": "0.52417123", "text": "func (o *UserInfoParams) WithHTTPClient(client *http.Client) *UserInfoParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "title": "" }, { "docid": "89f0f463257fd9964330a8f2c4b9542b", "score": "0.5240737", "text": "func (o *GetPetByIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "d0bf765ce500c6a2d1533f322bd4ee80", "score": "0.52329516", "text": "func NewGetDeploymentByIDUsingGETParamsWithHTTPClient(client *http.Client) *GetDeploymentByIDUsingGETParams {\n\tvar ()\n\treturn &GetDeploymentByIDUsingGETParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "20f8db5d1534a5a61a6ee3d2941c9aa2", "score": "0.52306706", "text": "func (o *GetIPIPGameIPOnGameRuleIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "d815b145fbe09b33a0c68c24e93230e3", "score": "0.52289104", "text": "func (o *GetLicenseKeyParams) WithHTTPClient(client *http.Client) *GetLicenseKeyParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "title": "" }, { "docid": "07c6d0b600fffe032688436aff002a1c", "score": "0.522339", "text": "func (o *GetCustomersByIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "16aa60a7eb79f3587fe9f896259946cc", "score": "0.5221347", "text": "func (o *IntrospectParams) WithHTTPClient(client *http.Client) *IntrospectParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "title": "" }, { "docid": "f2185b18568d7f63a318485d460db3d6", "score": "0.52196777", "text": "func (o *GetParams) WithHTTPClient(client *http.Client) *GetParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "title": "" }, { "docid": "37b62d01ce91d539af698c22dc0993ab", "score": "0.5215245", "text": "func NewGetPaymentRequestEDIParamsWithHTTPClient(client *http.Client) *GetPaymentRequestEDIParams {\n\tvar ()\n\treturn &GetPaymentRequestEDIParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "b6b7a0d23e72ceffbec0d53db9b49edd", "score": "0.5212822", "text": "func (o *FilterItemsUsingGETParams) WithHTTPClient(client *http.Client) *FilterItemsUsingGETParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "title": "" }, { "docid": "57e7066b15102322e4273c2b04c4bc0c", "score": "0.52117556", "text": "func (o *GetUserAppEntitlementByAppIDParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param namespace\n\tif err := r.SetPathParam(\"namespace\", o.Namespace); err != nil {\n\t\treturn err\n\t}\n\n\t// path param userId\n\tif err := r.SetPathParam(\"userId\", o.UserID); err != nil {\n\t\treturn err\n\t}\n\n\tif o.ActiveOnly != nil {\n\n\t\t// query param activeOnly\n\t\tvar qrActiveOnly bool\n\t\tif o.ActiveOnly != nil {\n\t\t\tqrActiveOnly = *o.ActiveOnly\n\t\t}\n\t\tqActiveOnly := swag.FormatBool(qrActiveOnly)\n\t\tif qActiveOnly != \"\" {\n\t\t\tif err := r.SetQueryParam(\"activeOnly\", qActiveOnly); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param appId\n\tqrAppID := o.AppID\n\tqAppID := qrAppID\n\tif qAppID != \"\" {\n\t\tif err := r.SetQueryParam(\"appId\", qAppID); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// setting the default header value\n\tif err := r.SetHeaderParam(\"User-Agent\", utils.UserAgentGen()); err != nil {\n\t\treturn err\n\t}\n\n\tif err := r.SetHeaderParam(\"X-Amzn-Trace-Id\", utils.AmazonTraceIDGen()); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "00ab350225b2fe0abaf5e5575a7d8ccf", "score": "0.52084684", "text": "func NewPostInvoiceParamsWithHTTPClient(client *http.Client) *PostInvoiceParams {\n\tvar (\n\t\tsendToCustomerDefault = bool(true)\n\t)\n\treturn &PostInvoiceParams{\n\t\tSendToCustomer: &sendToCustomerDefault,\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "5aab43ac18c28c07c6302b9b4f01d908", "score": "0.52047306", "text": "func NewHandshakeParamsWithHTTPClient(client *http.Client) *HandshakeParams {\n\tvar ()\n\treturn &HandshakeParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "675d86504a90187964d4cd610406b370", "score": "0.52038956", "text": "func NewGetQueryParamsWithHTTPClient(client *http.Client) *GetQueryParams {\n\tvar ()\n\treturn &GetQueryParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "b8926b3598bc02855692d90adfe041e0", "score": "0.5197425", "text": "func (o *UpdateCognitoIDPParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "title": "" }, { "docid": "254953db17d429d1a6bae14808860e5a", "score": "0.51958704", "text": "func NewCustomerGetParamsWithHTTPClient(client *http.Client) *CustomerGetParams {\n\tvar ()\n\treturn &CustomerGetParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" }, { "docid": "8819d62851dd50bfbf056e014d350eef", "score": "0.5195153", "text": "func NewGetIamServiceProvidersMoidParamsWithHTTPClient(client *http.Client) *GetIamServiceProvidersMoidParams {\n\tvar ()\n\treturn &GetIamServiceProvidersMoidParams{\n\t\tHTTPClient: client,\n\t}\n}", "title": "" } ]
d50d83e4526fcd9bdcdb32b31a5c5598
GetAPIVersion returns the ARM API version of the resource. This is always "20211101"
[ { "docid": "9b15d59487ccc46b012f1d7c750360b8", "score": "0.808256", "text": "func (setting Servers_Databases_AuditingSetting_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" } ]
[ { "docid": "e83eeabee48ac3ffe6dc4b4158268a9b", "score": "0.82498366", "text": "func (cluster ManagedCluster_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "4430d3419d66c15cbf36d91e1dfc6321", "score": "0.82369787", "text": "func (factory Factory_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "e13a5d839a8783373125aea762836c18", "score": "0.82327443", "text": "func (compute Workspaces_Compute_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "64ad67aa16709e615761d968a528039a", "score": "0.8193791", "text": "func (account StorageAccount_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "c957a5d24b8de55e39714f747707302f", "score": "0.8109394", "text": "func (workspace Workspace_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "286c4187a1d46d013436a6ebc37e4f83", "score": "0.8096694", "text": "func (connection Workspaces_Connection_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "3410315714c279e922eb6a248a11069d", "score": "0.8094864", "text": "func (server FlexibleServer_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "f017de67ee8728195abbf7f678b292e4", "score": "0.8087663", "text": "func (group ResourceGroup_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "ce02ca65ab56572a4262971dc361d183", "score": "0.80849105", "text": "func (eventhub Namespaces_Eventhub_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "fe286f28c334841daa7ad7cdb5e1add5", "score": "0.8067088", "text": "func (schedule Redis_PatchSchedule_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "c844bc31ea1e83d5de46a7e988b4386e", "score": "0.8063173", "text": "func (rule Servers_FirewallRule_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "5f576db79c5b1cc4dde761831a5eed31", "score": "0.80536866", "text": "func (machine VirtualMachine_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "e80715e3889a4577a28cb29547e42a44", "score": "0.80203116", "text": "func (store ConfigurationStore_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "42b90e3ae3ae74ef56b28acb24c43bc4", "score": "0.8019166", "text": "func (rule Redis_FirewallRule_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "b4b48b6bf9b7dc21564b1293481d916d", "score": "0.8001653", "text": "func (policy Servers_Databases_BackupShortTermRetentionPolicy_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "684a6e923d55e68c7bfbc4dfa064adae", "score": "0.798899", "text": "func (policy Servers_ConnectionPolicy_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "88a5376a0cb09263c0a4131949c85c69", "score": "0.79616135", "text": "func (group Servers_FailoverGroup_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "14275743f2c1860f07113db882c0c76d", "score": "0.7960555", "text": "func (queue Namespaces_Queue_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "afd8c078ece80b26b37d17530772ab13", "score": "0.7953138", "text": "func (group NetworkSecurityGroup_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "f22b108a47a36d2a6c5596071a1d4112", "score": "0.79479027", "text": "func (rule DnsForwardingRulesets_ForwardingRule_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "399335ea94fedc64261e41bbfb1ab0b9", "score": "0.7946696", "text": "func (database DatabaseAccounts_SqlDatabase_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "9279010afe21e46a11cd4b1322380d0a", "score": "0.7901375", "text": "func (function DatabaseAccounts_SqlDatabases_Containers_UserDefinedFunction_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "8343d7386cd07d35e848da056775e746", "score": "0.7832694", "text": "func (collection DatabaseAccounts_MongodbDatabases_Collection_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "e52c03cd6b64a612ebd5f9342cbcae49", "score": "0.7823931", "text": "func (table StorageAccounts_TableServices_Table_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "822afaf4b78c4020d34a90edf18451a3", "score": "0.7819252", "text": "func (share StorageAccounts_FileServices_Share_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "9cf9b47ad4f9605715184c1e09444163", "score": "0.7789934", "text": "func (setting DatabaseAccounts_MongodbDatabases_Collections_ThroughputSetting_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "af8efa1dad1243cf87f2cd15f67d3051", "score": "0.77301055", "text": "func (binding ManagedClusters_TrustedAccessRoleBinding_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "096624664ece2409855dde459c62596e", "score": "0.772186", "text": "func (link PrivateDnsZones_VirtualNetworkLink_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "389f6d343dd1a5fb96862b330f125c48", "score": "0.7681504", "text": "func (farm ServerFarm) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "39f84779ccd5dc6e8c02af19db0cc68b", "score": "0.7602032", "text": "func (image Image) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "d5704dcf264ef6fd7c6a6c054ba37c3d", "score": "0.7599416", "text": "func (pool ServersElasticPool) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "79c84c3be9483585bb879d8b47227ceb", "score": "0.75708926", "text": "func (connection WorkspacesConnection) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "8a35e996fbf4696b1c37c79056a1f3a9", "score": "0.75418925", "text": "func GetAPIVersion() string {\n\treturn \"2.1.2\"\n}", "title": "" }, { "docid": "2e26f805dcc5f9eb06104ff43529e60a", "score": "0.75314885", "text": "func (compute WorkspacesCompute) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "2e26f805dcc5f9eb06104ff43529e60a", "score": "0.75314885", "text": "func (compute WorkspacesCompute) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "a0b8c8b6b1b99dfdf5dc8788241c2a6f", "score": "0.753037", "text": "func (enterprise RedisEnterprise) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "3934a3ca5d3d1eff1b40c4909a69c7a0", "score": "0.7519142", "text": "func (registry Registry) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "1680480022e8a1a0e9aefa722162a02d", "score": "0.7513504", "text": "func (group PrivateEndpoints_PrivateDnsZoneGroup_Spec_ARM) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "51bc11d996586f52b8627d6c23c7f640", "score": "0.7507153", "text": "func (account DatabaseAccount) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "042336b0378a92621ab73abfca945577", "score": "0.74911094", "text": "func (queue NamespacesQueue) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "a1a63d75f9d6b30605ce6581550c5d42", "score": "0.74778825", "text": "func (cluster ManagedCluster) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "d1894cb5a1330995144be10d265dcd7d", "score": "0.7463382", "text": "func (alias Alias) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "a677351f97db439c928f3eb2301a7e2c", "score": "0.74609095", "text": "func (device *REDBrick) GetAPIVersion() [3]uint8 {\n\treturn device.device.GetAPIVersion()\n}", "title": "" }, { "docid": "905c484ef9120971604cb420d949e1e2", "score": "0.74459976", "text": "func (service StorageAccountsQueueService) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "905c484ef9120971604cb420d949e1e2", "score": "0.74459976", "text": "func (service StorageAccountsQueueService) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "f245465096744181c6e97d967c159061", "score": "0.7432692", "text": "func (gateway VirtualNetworkGateway) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "4c4ddd9a956a8c69de0266fe04e86dc0", "score": "0.7404211", "text": "func (domain Domain) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "84413076718cc99c7d457297a9427676", "score": "0.73996997", "text": "func (workspace Workspace) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "84413076718cc99c7d457297a9427676", "score": "0.73996997", "text": "func (workspace Workspace) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "84413076718cc99c7d457297a9427676", "score": "0.73996997", "text": "func (workspace Workspace) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "04218df5fff1825d922f68dd0005c501", "score": "0.73818403", "text": "func (signalR SignalR) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "61373f330054a3fff0d9ec9a686af387", "score": "0.7376685", "text": "func (database RedisEnterpriseDatabase) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "7f8c913a9f85b53f53a13672e7798910", "score": "0.7375217", "text": "func (server FlexibleServer) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "ee127edc97628adabbeef859361ec0ba", "score": "0.7358993", "text": "func (c *Client) GetAPIVersion() (string, error) {\n\tversion := &struct {\n\t\tVersion string `json:\"version\"`\n\t}{}\n\terr := c.C.Get(c.GetURL()+\"/api/version\", version)\n\tif err == nil {\n\t\treturn version.Version, nil\n\t}\n\t// Harbor 1.x has no API version endpoint\n\tif e, ok := err.(*common_http.Error); ok && e.Code == http.StatusNotFound {\n\t\treturn \"\", nil\n\t}\n\treturn \"\", err\n}", "title": "" }, { "docid": "11ea30c5b1ea500f79c3c528e5dd36c9", "score": "0.73472047", "text": "func (vault BackupVault) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "6d186f9f39700ef605928fa09d5ac11b", "score": "0.73457706", "text": "func (device *ESP32Brick) GetAPIVersion() [3]uint8 {\n\treturn device.device.GetAPIVersion()\n}", "title": "" }, { "docid": "c4dd86ebea05fd809e379e96a926a0aa", "score": "0.7344185", "text": "func (namespace Namespace) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "c4dd86ebea05fd809e379e96a926a0aa", "score": "0.7344185", "text": "func (namespace Namespace) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "3ce1d767a2e6061a670a6a3bfd34fef1", "score": "0.733958", "text": "func (group NetworkSecurityGroup) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "50a879ad9491e92e8c63fb034ab2543e", "score": "0.7336632", "text": "func (policy StorageAccountsManagementPolicy) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "5ca6b5618b1166484175eb8e2fa6fa4e", "score": "0.733135", "text": "func (disk Disk) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "5ec16a2fa3f952c0cbc6ee5d04fafce0", "score": "0.7308916", "text": "func (group ContainerGroup) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "f491addac324d2f17e61e4283ed84719", "score": "0.7285602", "text": "func (queue StorageAccountsQueueServicesQueue) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "602047956b4c7fa62746aa0a546d6ed1", "score": "0.7270932", "text": "func (iotHub IotHub) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "5411f7f4e9334ade0b0eefe313e41e97", "score": "0.7266133", "text": "func (group NamespacesEventhubsConsumerGroup) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "c1565905ba072d6a043ea1052e199ede", "score": "0.72286624", "text": "func (device *LaserRangeFinderV2Bricklet) GetAPIVersion() [3]uint8 {\n\treturn device.device.GetAPIVersion()\n}", "title": "" }, { "docid": "034804a343b1493a74dc0de6b11415fe", "score": "0.7225321", "text": "func (zone PrivateDnsZone) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "cf87ecb843cbcf50ee6fac186ceaabcc", "score": "0.72194064", "text": "func (device *DCBrick) GetAPIVersion() [3]uint8 {\n\treturn device.device.GetAPIVersion()\n}", "title": "" }, { "docid": "7e49567b6d1a59f5fa930900be970589", "score": "0.72098285", "text": "func GetAPIVersion() string {\n\treturn \"0.6.0\"\n}", "title": "" }, { "docid": "08f137e2155b43be6f69038fab26e693", "score": "0.7201504", "text": "func GetAPIVersion(w http.ResponseWriter, r *http.Request) {\n\tif err := json.NewEncoder(w).Encode(&APIVersion{Version: version}); err != nil {\n\t\tlib_http.SendError(w, err)\n\t}\n}", "title": "" }, { "docid": "0d166aa0f51fc4d979a627ea0444080e", "score": "0.72012776", "text": "func (policy BackupVaultsBackupPolicy) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "d51e238dc7523a67a48a2a069a1de1b0", "score": "0.7181008", "text": "func (device *HATBrick) GetAPIVersion() [3]uint8 {\n\treturn device.device.GetAPIVersion()\n}", "title": "" }, { "docid": "be3eec5ce70f455d02cfbb885074b531", "score": "0.7166444", "text": "func (record DnsZonesSRVRecord) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "af7fb81355ccfe8a87d094b122eabaec", "score": "0.7164093", "text": "func (rule NamespacesTopicsSubscriptionsRule) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "d664dd4457a332d8d96ca17e07211a0a", "score": "0.71579504", "text": "func (table StorageAccountsTableServicesTable) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "f3d2e247a3774b444781a5e5dfe0ee32", "score": "0.7154686", "text": "func (device *MoistureBricklet) GetAPIVersion() [3]uint8 {\n\treturn device.device.GetAPIVersion()\n}", "title": "" }, { "docid": "3f34623b0d0d458a533b6e85be72cd8f", "score": "0.71156985", "text": "func (store ConfigurationStore) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "a572c17d097b3e14a4de7c68355d4e8b", "score": "0.710813", "text": "func (kr *PortRule) GetAPIVersion() int32 {\n\tif kr.APIVersion != \"\" {\n\t\tn, err := strconv.ParseInt(kr.APIVersion, 10, 16)\n\t\tif err != nil || n < 0 || n > math.MaxInt16 {\n\t\t\tpanic(fmt.Sprintf(\"Unsanitized Kafka PortRule: %v\", kr))\n\t\t}\n\t\treturn int32(n)\n\t}\n\treturn -1 // any version is allowed\n}", "title": "" }, { "docid": "7eb419c110c96ab575aa7d6845b347c1", "score": "0.71054435", "text": "func (p *CleanupPolicy) GetAPIVersion() string {\n\treturn p.APIVersion\n}", "title": "" }, { "docid": "132cbc7d00f49b297740ba8254d40b99", "score": "0.70201814", "text": "func (device *CO2Bricklet) GetAPIVersion() [3]uint8 {\n\treturn device.device.GetAPIVersion()\n}", "title": "" }, { "docid": "06f6db0a571705699eb6c2e58a2ce962", "score": "0.70116746", "text": "func (device *NFCRFIDBricklet) GetAPIVersion() [3]uint8 {\n\treturn device.device.GetAPIVersion()\n}", "title": "" }, { "docid": "1cb405ef691e022bfdf239f3ae0268e0", "score": "0.7007848", "text": "func (record PrivateDnsZonesTXTRecord) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "3a13422e0399ee509d2256d3e13794de", "score": "0.6980197", "text": "func (subscription NamespacesTopicsSubscription) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "010f2b5eea831f5b0a6eea2285c1865b", "score": "0.69680464", "text": "func (record PrivateDnsZonesCNAMERecord) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "255eaad479db3855c88901c1b367d52d", "score": "0.6964247", "text": "func (p *ClusterCleanupPolicy) GetAPIVersion() string {\n\treturn p.APIVersion\n}", "title": "" }, { "docid": "6c82ebf4d4f43bed15e07195871c6d88", "score": "0.6876992", "text": "func (device *LoadCellBricklet) GetAPIVersion() [3]uint8 {\n\treturn device.device.GetAPIVersion()\n}", "title": "" }, { "docid": "dee11f0ea5a7888da99e693d71e60fc0", "score": "0.6839932", "text": "func (setting MongodbDatabaseCollectionThroughputSetting) GetAPIVersion() string {\n\treturn string(APIVersion_Value)\n}", "title": "" }, { "docid": "cc0d336a86d2dc5097d2e35a75394062", "score": "0.6672748", "text": "func APIVersion(ctx context.Context) string {\n\tvalue := ctx.Value(apiVersionKey)\n\tif value != nil {\n\t\treturn value.(string)\n\t}\n\treturn \"\"\n}", "title": "" }, { "docid": "5236279891397eefd5ee2338dc2994bf", "score": "0.6615295", "text": "func IntializeAPIVersion() *v1.API {\n\treturn &v1.API{Api: APIVersion}\n}", "title": "" }, { "docid": "dc1e9fc9d97c4ae89bc7dcc9f9507341", "score": "0.6583973", "text": "func (v Vars) GetAPIVersion() (string, error) {\n\tgroup, ok := v[\"group\"]\n\tif !ok {\n\t\treturn \"\", errors.New(\"group not found\")\n\t}\n\n\tversion, ok := v[\"version\"]\n\tif !ok {\n\t\treturn \"\", errors.New(\"version not found\")\n\t}\n\n\treturn group + \"/\" + version, nil\n}", "title": "" }, { "docid": "4154baba0a2fcd0089b6815c3a80c605", "score": "0.6559973", "text": "func (k *Koji) GetAPIVersion() (int, error) {\n\tvar version int\n\terr := k.xmlrpc.Call(\"getAPIVersion\", nil, &version)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn version, nil\n}", "title": "" }, { "docid": "ef45b55b191404000f4b9af688a1caf7", "score": "0.6524523", "text": "func APIVersion(ctx context.Context) string {\n\tv := ctx.Value(apiVersion{})\n\tif v == nil {\n\t\treturn \"\"\n\t}\n\treturn v.(string)\n}", "title": "" }, { "docid": "bd8102f67ef5a72bca92c75a3a37c5f7", "score": "0.64666885", "text": "func (o CustomResourceDefinitionPatchOutput) ApiVersion() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *CustomResourceDefinitionPatch) pulumi.StringPtrOutput { return v.ApiVersion }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "c0c490baba610770d47816e6a53277b2", "score": "0.6458042", "text": "func (o CustomResourceDefinitionTypeOutput) ApiVersion() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v CustomResourceDefinitionType) *string { return v.ApiVersion }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "9ee34fe9eb410aed141d692b62da97c4", "score": "0.6348742", "text": "func (p *Provider) APIVersion() string {\n\treturn filepath.Join(p.Group(), p.Version())\n}", "title": "" }, { "docid": "e947098a58b0e3152fdba9bd31fa3897", "score": "0.6325803", "text": "func (m *WorkforceIntegration) GetApiVersion()(*int32) {\n val, err := m.GetBackingStore().Get(\"apiVersion\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*int32)\n }\n return nil\n}", "title": "" }, { "docid": "1c5155af9bb923a4727daacbe4f0a76a", "score": "0.6306182", "text": "func (o CustomResourceDefinitionPatchTypeOutput) ApiVersion() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v CustomResourceDefinitionPatchType) *string { return v.ApiVersion }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "bd92defad3760bdfb395126ae844dfea", "score": "0.6290446", "text": "func (o CustomResourceDefinitionListTypeOutput) ApiVersion() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v CustomResourceDefinitionListType) *string { return v.ApiVersion }).(pulumi.StringPtrOutput)\n}", "title": "" }, { "docid": "4d152a7792ad920496526bdfeec0314e", "score": "0.62684894", "text": "func Version() string {\n\treturn APIVersion\n}", "title": "" }, { "docid": "cad793a0b198a72b2832800f1dd7246e", "score": "0.6184301", "text": "func (o ResourceClaimTypeOutput) ApiVersion() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ResourceClaimType) *string { return v.ApiVersion }).(pulumi.StringPtrOutput)\n}", "title": "" } ]
89a8eb5b67e8b01bb462b8c363836053
ServeAndWait waits until the server is initialized, i.e. has a cluster ID, node ID and has permission to join the cluster. In the common case of restarting an existing node, this immediately returns. When starting with a blank slate (i.e. only empty engines), it waits for incoming Bootstrap request or for a successful outgoing Join RPC, whichever happens earlier. The returned initState reflects a bootstrapped cluster (i.e. it has a cluster ID and a node ID for this server). This method must be called only once. NB: A gotcha that may not immediately be obvious is that we can never hope to have all stores initialized by the time ServeAndWait returns. This is because if this server is already bootstrapped, it might hold a replica of the range backing the StoreID allocating counter, and letting this server start may be necessary to restore quorum to that range. So in general, after this method, we will always leave this method with at least one store initialized, but not necessarily all. This is fine, since initializing additional stores later is easy (see `initializeAdditionalStores`). `initialBoot` is true if this is a new node. This flag should only be used for logging and reporting. A newly bootstrapped singlenode cluster is functionally equivalent to one that restarted; any decisions should be made on persisted data instead of this flag.
[ { "docid": "ddacd316ba56f018b64bb47cd7b008ef", "score": "0.771961", "text": "func (s *initServer) ServeAndWait(\n\tctx context.Context, stopper *stop.Stopper, sv *settings.Values,\n) (state *initState, initialBoot bool, err error) {\n\t// If we're restarting an already bootstrapped node, return early.\n\tif s.inspectedDiskState.bootstrapped() {\n\t\treturn s.inspectedDiskState, false, nil\n\t}\n\n\tlog.Info(ctx, \"no stores initialized\")\n\tlog.Info(ctx, \"awaiting `cockroach init` or join with an already initialized node\")\n\n\t// If we end up joining a bootstrapped cluster, the resulting init state\n\t// will be passed through this channel.\n\tvar joinCh chan joinResult\n\tvar cancelJoin = func() {}\n\tvar wg sync.WaitGroup\n\n\tif len(s.config.resolvers) == 0 {\n\t\t// We're pointing to only ourselves or nothing at all, which (likely)\n\t\t// suggests that we're going to be bootstrapped by the operator. Since\n\t\t// we're not going to be sending out join RPCs, we don't bother spinning\n\t\t// up the join loop.\n\t} else {\n\t\tjoinCh = make(chan joinResult, 1)\n\t\twg.Add(1)\n\n\t\tvar joinCtx context.Context\n\t\tjoinCtx, cancelJoin = context.WithCancel(ctx)\n\t\tdefer cancelJoin()\n\n\t\terr := stopper.RunAsyncTask(joinCtx, \"init server: join loop\",\n\t\t\tfunc(ctx context.Context) {\n\t\t\t\tdefer wg.Done()\n\n\t\t\t\tstate, err := s.startJoinLoop(ctx, stopper)\n\t\t\t\tjoinCh <- joinResult{state: state, err: err}\n\t\t\t})\n\t\tif err != nil {\n\t\t\twg.Done()\n\t\t\treturn nil, false, err\n\t\t}\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase state := <-s.bootstrapReqCh:\n\t\t\t// Ensure we're draining out the join attempt, if any. We're not\n\t\t\t// going to need it anymore and it had no chance of joining\n\t\t\t// elsewhere (since we are the ones bootstrapping the new cluster\n\t\t\t// and have not started serving Join yet).\n\t\t\tcancelJoin()\n\t\t\twg.Wait()\n\n\t\t\t// Bootstrap() did its job. At this point, we know that the cluster\n\t\t\t// version will be the bootstrap version (aka the binary version[1]),\n\t\t\t// but the version setting does not know yet (it was initialized as\n\t\t\t// BinaryMinSupportedVersion because the engines were all\n\t\t\t// uninitialized). Given that the bootstrap version was persisted to\n\t\t\t// all the engines, it's now safe for us to bump the version setting\n\t\t\t// itself and start operating at the latest cluster version.\n\t\t\t//\n\t\t\t// TODO(irfansharif): We're calling Initialize a second time here.\n\t\t\t// There's no real reason to anymore, we can use\n\t\t\t// SetActiveClusterVersion instead. This will let us make\n\t\t\t// `Initialize` a bit stricter, which is a nice simplification to\n\t\t\t// have.\n\t\t\t//\n\t\t\t// [1]: See the top-level comment in pkg/clusterversion to make\n\t\t\t// sense of the many versions of ...versions.\n\t\t\tif err := clusterversion.Initialize(ctx, state.clusterVersion.Version, sv); err != nil {\n\t\t\t\treturn nil, false, err\n\t\t\t}\n\n\t\t\tlog.Infof(ctx, \"cluster %s has been created\", state.clusterID)\n\t\t\tlog.Infof(ctx, \"allocated node ID: n%d (for self)\", state.nodeID)\n\t\t\tlog.Infof(ctx, \"active cluster version: %s\", state.clusterVersion)\n\n\t\t\treturn state, true, nil\n\t\tcase result := <-joinCh:\n\t\t\t// Ensure we're draining out the join attempt.\n\t\t\twg.Wait()\n\n\t\t\tif err := result.err; err != nil {\n\t\t\t\tif errors.Is(err, ErrIncompatibleBinaryVersion) {\n\t\t\t\t\treturn nil, false, err\n\t\t\t\t}\n\n\t\t\t\t// We expect the join RPC to blindly retry on all\n\t\t\t\t// \"connection\" errors save for one above. If we're\n\t\t\t\t// here, we failed to initialize our first store after a\n\t\t\t\t// successful join attempt.\n\t\t\t\treturn nil, false, errors.NewAssertionErrorWithWrappedErrf(err, \"unexpected error: %v\", err)\n\t\t\t}\n\n\t\t\tstate := result.state\n\n\t\t\tlog.Infof(ctx, \"joined cluster %s through join rpc\", state.clusterID)\n\t\t\tlog.Infof(ctx, \"received node ID: %d\", state.nodeID)\n\t\t\tlog.Infof(ctx, \"received cluster version: %s\", state.clusterVersion)\n\n\t\t\treturn state, true, nil\n\t\tcase <-stopper.ShouldQuiesce():\n\t\t\treturn nil, false, stop.ErrUnavailable\n\t\t}\n\t}\n}", "title": "" } ]
[ { "docid": "921c91d486524c603a34416481da06a3", "score": "0.5697755", "text": "func (s *initServer) Bootstrap(\n\tctx context.Context, _ *serverpb.BootstrapRequest,\n) (*serverpb.BootstrapResponse, error) {\n\t// Bootstrap() only responds once. Everyone else gets an error, either\n\t// ErrClusterInitialized (in the success case) or errInternalBootstrapError.\n\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\n\tif s.mu.bootstrapped {\n\t\treturn nil, ErrClusterInitialized\n\t}\n\n\tif s.mu.rejectErr != nil {\n\t\treturn nil, s.mu.rejectErr\n\t}\n\n\tstate, err := s.tryBootstrap(ctx)\n\tif err != nil {\n\t\tlog.Errorf(ctx, \"bootstrap: %v\", err)\n\t\ts.mu.rejectErr = errInternalBootstrapError\n\t\treturn nil, s.mu.rejectErr\n\t}\n\n\t// We've successfully bootstrapped (we've initialized at least one engine).\n\t// We mark ourselves as bootstrapped to prevent future bootstrap attempts.\n\ts.mu.bootstrapped = true\n\ts.bootstrapReqCh <- state\n\n\treturn &serverpb.BootstrapResponse{}, nil\n}", "title": "" }, { "docid": "ad4bd3c603739c36698c5487e61f5873", "score": "0.5583021", "text": "func (stateTrie *StateTrie) Initialize(configs map[string]interface{}) error {\n\trootNode, err := fetchTrieNodeFromDB(stateTrie.OpenchainDB, rootTrieKey)\n\tif err != nil {\n\t\tpanic(fmt.Errorf(\"Error in fetching root node from DB while initializing state trie: %s\", err))\n\t}\n\tif rootNode != nil {\n\t\tstateTrie.persistedStateHash = rootNode.computeCryptoHash()\n\t\tstateTrie.lastComputedCryptoHash = stateTrie.persistedStateHash\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "1ce3c48764e8a37f58d47f2fc4596430", "score": "0.55240273", "text": "func (i *IndexNode) Init() error {\n\tvar initErr error\n\ti.initOnce.Do(func() {\n\t\ti.UpdateStateCode(commonpb.StateCode_Initializing)\n\t\tlog.Info(\"IndexNode init\", zap.String(\"state\", i.lifetime.GetState().String()))\n\t\terr := i.initSession()\n\t\tif err != nil {\n\t\t\tlog.Error(\"failed to init session\", zap.Error(err))\n\t\t\tinitErr = err\n\t\t\treturn\n\t\t}\n\t\tlog.Info(\"IndexNode init session successful\", zap.Int64(\"serverID\", i.session.ServerID))\n\n\t\ti.initSegcore()\n\t})\n\n\tlog.Info(\"Init IndexNode finished\", zap.Error(initErr))\n\n\treturn initErr\n}", "title": "" }, { "docid": "370d6dc945bc70f1aeea3c8453092432", "score": "0.5408918", "text": "func (s *ObjectStoreGRPCServer) Init(ctx context.Context, req *proto.ObjectStoreInitRequest) (response *proto.Empty, err error) {\n\tdefer func() {\n\t\tif recoveredErr := common.HandlePanic(recover()); recoveredErr != nil {\n\t\t\terr = recoveredErr\n\t\t}\n\t}()\n\n\timpl, err := s.getImpl(req.Plugin)\n\tif err != nil {\n\t\treturn nil, common.NewGRPCError(err)\n\t}\n\n\tif err := impl.Init(req.Config); err != nil {\n\t\treturn nil, common.NewGRPCError(err)\n\t}\n\n\treturn &proto.Empty{}, nil\n}", "title": "" }, { "docid": "6f22a65f2432b8d7cfb6706ea37fb8a9", "score": "0.53841805", "text": "func (c *Cluster) Init(req types.InitRequest) (string, error) {\n\tc.Lock()\n\tif node := c.node; node != nil {\n\t\tif !req.ForceNewCluster {\n\t\t\tc.Unlock()\n\t\t\treturn \"\", ErrSwarmExists\n\t\t}\n\t\tif err := c.stopNode(); err != nil {\n\t\t\tc.Unlock()\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\tif err := validateAndSanitizeInitRequest(&req); err != nil {\n\t\tc.Unlock()\n\t\treturn \"\", err\n\t}\n\n\tlistenHost, listenPort, err := resolveListenAddr(req.ListenAddr)\n\tif err != nil {\n\t\tc.Unlock()\n\t\treturn \"\", err\n\t}\n\n\tadvertiseHost, advertisePort, err := c.resolveAdvertiseAddr(req.AdvertiseAddr, listenPort)\n\tif err != nil {\n\t\tc.Unlock()\n\t\treturn \"\", err\n\t}\n\n\tlocalAddr := listenHost\n\n\t// If the advertise address is not one of the system's\n\t// addresses, we also require a listen address.\n\tlistenAddrIP := net.ParseIP(listenHost)\n\tif listenAddrIP != nil && listenAddrIP.IsUnspecified() {\n\t\tadvertiseIP := net.ParseIP(advertiseHost)\n\t\tif advertiseIP == nil {\n\t\t\t// not an IP\n\t\t\tc.Unlock()\n\t\t\treturn \"\", errMustSpecifyListenAddr\n\t\t}\n\n\t\tsystemIPs := listSystemIPs()\n\n\t\tfound := false\n\t\tfor _, systemIP := range systemIPs {\n\t\t\tif systemIP.Equal(advertiseIP) {\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\tc.Unlock()\n\t\t\treturn \"\", errMustSpecifyListenAddr\n\t\t}\n\t\tlocalAddr = advertiseIP.String()\n\t}\n\n\t// todo: check current state existing\n\tn, err := c.startNewNode(req.ForceNewCluster, localAddr, \"\", net.JoinHostPort(listenHost, listenPort), net.JoinHostPort(advertiseHost, advertisePort), \"\", \"\")\n\tif err != nil {\n\t\tc.Unlock()\n\t\treturn \"\", err\n\t}\n\tc.Unlock()\n\n\tselect {\n\tcase <-n.Ready():\n\t\tif err := initClusterSpec(n, req.Spec); err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tgo c.reconnectOnFailure(n)\n\t\treturn n.NodeID(), nil\n\tcase <-n.done:\n\t\tc.RLock()\n\t\tdefer c.RUnlock()\n\t\tif !req.ForceNewCluster { // if failure on first attempt don't keep state\n\t\t\tif err := c.clearState(); err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t}\n\t\treturn \"\", c.err\n\t}\n}", "title": "" }, { "docid": "d5042176466d5ea95cdd466475138893", "score": "0.533184", "text": "func (a *App) Bootstrap() error {\n\tdbusConn, err := dbus.New()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to connect to login1 dbus\")\n\t}\n\tdefer dbusConn.Close()\n\n\tif err := a.GatherState(); err != nil {\n\t\treturn err\n\t}\n\n\tif err := a.OSUpdate(); err != nil {\n\t\treturn err\n\t}\n\n\tosVersions := []string{}\n\tif a.CurrentOSVersion != \"\" {\n\t\tosVersions = append(osVersions, a.CurrentOSVersion)\n\t}\n\tif a.NextOSVersion != \"\" {\n\t\tosVersions = append(osVersions, a.NextOSVersion)\n\t}\n\n\t// TODO(cdc) When we have the list of available packages for an OS version,\n\t// pick the best one.\n\tif err := a.InstallAddon(\"docker\", a.DockerVersions[0], a.OSChannel, osVersions, MinimumRemoteDocker); err != nil {\n\t\treturn err\n\t}\n\n\tif a.Conf.KubeletEnvPath != \"\" {\n\t\terr = a.WriteKubeletEnv(a.Conf.KubeletEnvPath, a.K8sVersion)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif a.NeedReboot {\n\t\t// We trigger a reboot and block here, waiting for init to kill us.\n\t\tc := make(chan string)\n\t\tlogrus.Info(\"node updated, triggering reboot to apply changes\")\n\t\t_, err := dbusConn.StartUnit(\"reboot.target\", \"isolate\", c)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"failed to reboot\")\n\t\t}\n\t\treturn errors.Errorf(\"reboot result: %q\", <-c)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "b22f7ae173c6e509229ba3134c00e3c6", "score": "0.5271529", "text": "func (r *StateStore) Init(ctx context.Context, metadata state.Metadata) error {\n\tvar err error\n\tr.containerClient, _, err = storageinternal.CreateContainerStorageClient(ctx, r.logger, metadata.Properties)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "87a4a1d6b09cbf83460be3ef6c5ebaf0", "score": "0.52515614", "text": "func (s *server) Initialize(_ context.Context, _ *protocol.ParamInitialize) (*protocol.InitializeResult, error) {\n\ts.stateMu.Lock()\n\tdefer s.stateMu.Unlock()\n\n\tif s.state != serverCreated {\n\t\treturn nil, jsonrpc2.NewErrorf(jsonrpc2.CodeInvalidRequest, \"server already initialized\")\n\t}\n\n\ts.state = serverInitializing\n\n\ts.cache.Init()\n\n\treturn &protocol.InitializeResult{\n\t\tCapabilities: protocol.ServerCapabilities{\n\t\t\tTextDocumentSync: &protocol.TextDocumentSyncOptions{\n\t\t\t\tOpenClose: true,\n\t\t\t\t// Support incremental changes\n\t\t\t\tChange: 2,\n\t\t\t},\n\t\t\tHoverProvider: true,\n\t\t\tCompletionProvider: protocol.CompletionOptions{\n\t\t\t\tTriggerCharacters: []string{\n\t\t\t\t\t\" \", \"\\n\", \"\\t\", \"(\", \")\", \"[\", \"]\", \"{\", \"}\", \"+\", \"-\", \"*\", \"/\", \"!\", \"=\", \"\\\"\", \",\", \"'\", \"\\\"\", \"`\", \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"n\", \"m\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\", \"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\", \"K\", \"L\", \"N\", \"M\", \"O\", \"P\", \"Q\", \"R\", \"S\", \"T\", \"U\", \"V\", \"W\", \"X\", \"Y\", \"Z\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tSignatureHelpProvider: protocol.SignatureHelpOptions{\n\t\t\t\tTriggerCharacters: []string{\"(\", \",\"},\n\t\t\t},\n\t\t\tDefinitionProvider: true,\n\t\t},\n\t}, nil\n}", "title": "" }, { "docid": "fd0bc3a2cb35a5c27a477be4c2e0105d", "score": "0.5235246", "text": "func (store *Store) Init() error {\n\terr := store.checkOrCreateDefaultSettings()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = store.checkOrCreateDefaultSSLSettings()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn store.checkOrCreateDefaultData()\n}", "title": "" }, { "docid": "4201af70486bfddce38e2f42c659a845", "score": "0.52305317", "text": "func (gs *goGenServ) Init(args ...interface{}) (state interface{}) {\n\t// Self-registration with name SrvName\n\tgs.Node.Register(etf.Atom(gs.cfg.GenServerName), gs.Self)\n\treturn nil\n}", "title": "" }, { "docid": "bf52e6fdcafc657c4d73e542b69afe4e", "score": "0.5229728", "text": "func (s *Server) init() error {\n\ts.mtx.Lock()\n\tdefer s.mtx.Unlock()\n\n\tif s.isInitialized {\n\t\treturn nil\n\t}\n\ts.isInitialized = true\n\n\tif err := s.writePIDFile(); err != nil {\n\t\treturn err\n\t}\n\n\t// Initialize dskit modules.\n\tif err := s.moduleService.Init(s.context); err != nil {\n\t\treturn err\n\t}\n\n\tif err := metrics.SetEnvironmentInformation(s.cfg.MetricsGrafanaEnvironmentInfo); err != nil {\n\t\treturn err\n\t}\n\n\tif err := s.roleRegistry.RegisterFixedRoles(s.context); err != nil {\n\t\treturn err\n\t}\n\n\treturn s.provisioningService.RunInitProvisioners(s.context)\n}", "title": "" }, { "docid": "0c496a8f51cc1ff9313a8abfd7a9f1c6", "score": "0.52101517", "text": "func (sdb *ChainStateDB) Init(dbType string, dataDir string, bestBlock *types.Block, test bool) error {\n\tsdb.Lock()\n\tdefer sdb.Unlock()\n\n\tsdb.testmode = test\n\t// init db\n\tif sdb.store == nil {\n\t\tdbPath := common.PathMkdirAll(dataDir, stateName)\n\t\tsdb.store = db.NewDB(db.ImplType(dbType), dbPath)\n\t}\n\n\t// init trie\n\tif sdb.states == nil {\n\t\tvar sroot []byte\n\t\tif bestBlock != nil {\n\t\t\tsroot = bestBlock.GetHeader().GetBlocksRootHash()\n\t\t}\n\n\t\tsdb.states = NewStateDB(sdb.store, sroot, sdb.testmode)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "3d91516fb9f3d99d36836b0c71eba655", "score": "0.5209812", "text": "func Initialise(addresses []string, networkName string, publicKey string, privateKey string) error {\n\n\tglobalData.Lock()\n\tdefer globalData.Unlock()\n\n\t// no need to start if already started\n\tif globalData.initialised {\n\t\treturn fault.ErrAlreadyInitialised\n\t}\n\n\tglobalData.threads = []*thread{\n\t\t{name: \"client\", handler: globalData.client},\n\t\t{name: \"responder\", handler: globalData.responder},\n\t\t{name: \"announcer\", handler: globalData.announcer},\n\t}\n\n\tlog := logger.New(\"peer\")\n\tif nil == log {\n\t\treturn fault.ErrInvalidLoggerChannel\n\t}\n\n\tfor _, t := range globalData.threads {\n\n\t\tt.log = logger.New(t.name)\n\t\tif nil == t.log {\n\t\t\treturn fault.ErrInvalidLoggerChannel\n\t\t}\n\t\tt.stop = make(chan bool)\n\t\tt.done = make(chan bool)\n\t}\n\n\t// create the server\n\tglobalData.server = bilateralrpc.NewEncrypted(networkName, publicKey, privateKey)\n\n\t// listen on a port\n\tfor _, address := range addresses {\n\t\tif err := globalData.server.ListenOn(\"tcp://\" + address); nil != err {\n\t\t\tlog.Errorf(\"ListenOn: tcp://%s failed: %v\\n\", address, err)\n\t\t\t// ****** FIX THIS: currently just ignoring failed listens *****\n\t\t\tfmt.Printf(\"ListenOn: tcp://%s failed: %v\\n\", address, err)\n\t\t\t//globalData.server.Close()\n\t\t\t//return err\n\t\t}\n\t}\n\n\t// register server objects\n\t// -----------------------\n\n\t// not yet....see below....\n\t// peer := &Peer{\n\t// \tlog: log,\n\t// }\n\n\trpcs := &RPCs{\n\t\tlog: log,\n\t}\n\n\tcert := &Certificate{\n\t\tlog: log,\n\t}\n\n\tasset := &Asset{\n\t\tlog: log,\n\t}\n\n\tblock := &Block{\n\t\tlog: log,\n\t}\n\n\ttransaction := &Transaction{\n\t\tlog: log,\n\t}\n\n\t//globalData.server.Register(peer) // need some fixes first\n\tglobalData.server.Register(rpcs)\n\tglobalData.server.Register(cert)\n\tglobalData.server.Register(asset)\n\tglobalData.server.Register(block)\n\tglobalData.server.Register(transaction)\n\n\t// all data initialised\n\tglobalData.initialised = true\n\n\t// start backgrounds\n\tfor _, t := range globalData.threads {\n\t\tgo t.handler(t)\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "3dccb70ffd32af76c2b8631a7e84efbf", "score": "0.51872873", "text": "func (mb *Client) Init(database *db.Database, peerSub interfaces.PeerSubscription, app appClient) error {\n\tbackground := context.Background()\n\tctx, cf := context.WithCancel(background)\n\tmb.logger = logging.GetLogger(constants.LoggerGossipBus)\n\tmb.cancelCtx = cf\n\tmb.ctx = ctx\n\tmb.wg = sync.WaitGroup{}\n\tmb.database = database\n\tmb.peerSub = peerSub\n\tmb.app = app\n\tmb.sstore = &lstate.Store{}\n\terr := mb.sstore.Init(database)\n\tif err != nil {\n\t\tutils.DebugTrace(mb.logger, err)\n\t\treturn err\n\t}\n\tmb.gossipTimeout = constants.MsgTimeout\n\treturn nil\n}", "title": "" }, { "docid": "a6052b334dbd7f33731cc08195e78aa1", "score": "0.5174755", "text": "func (store Emotestore) Init() {\n\terr := os.MkdirAll(store.localDataPath(), 0755)\n\tcheck(err)\n}", "title": "" }, { "docid": "6523d439ff36258c32e383ce576e263a", "score": "0.5170157", "text": "func (ls *LifecycleState) MarkReadyAndWait() {\n\t// Start a diagnostics web server that exposes Prometheus\n\t// metrics and provides a health check endpoint.\n\tif ls.diagnosticsHTTPListenAddress == \"\" {\n\t\tselect {}\n\t} else {\n\t\trouter := mux.NewRouter()\n\t\trouter.Handle(\"/metrics\", promhttp.Handler())\n\t\trouter.HandleFunc(\"/-/healthy\", func(http.ResponseWriter, *http.Request) {})\n\t\trouter.PathPrefix(\"/debug/pprof/\").Handler(http.DefaultServeMux)\n\t\tlog.Fatal(http.ListenAndServe(ls.diagnosticsHTTPListenAddress, router))\n\t}\n}", "title": "" }, { "docid": "8a83b7cf24e4769c361814cb33697c7a", "score": "0.51623267", "text": "func (r *RedisService) Init() {\n\tr.shutdown.SetTo(false)\n\tr.wait = make(chan bool)\n}", "title": "" }, { "docid": "aad75dbdac70940e7e0994548943fc46", "score": "0.51472783", "text": "func (s *State) Init(config tapr.Config) {\n\tvar c tapr.Client\n\tvar m mgnt.Client\n\tif config != nil {\n\t\tc = client.New(config)\n\t\tm = client.NewManagementClient(config)\n\t}\n\n\ts.Config = config\n\ts.Management = m\n\ts.Client = c\n}", "title": "" }, { "docid": "ab5440a5f7c4740a6aeb86ab48eab9b8", "score": "0.5124641", "text": "func (s *Server) Init() {\n\ts.wire()\n\ts.serve()\n}", "title": "" }, { "docid": "b8781cef9b42a68be605445561b568ce", "score": "0.5118657", "text": "func (node *QueryNode) Init() error {\n\tvar initError error\n\tnode.initOnce.Do(func() {\n\t\t// ctx := context.Background()\n\t\tlog.Info(\"QueryNode session info\", zap.String(\"metaPath\", paramtable.Get().EtcdCfg.MetaRootPath.GetValue()))\n\t\terr := node.initSession()\n\t\tif err != nil {\n\t\t\tlog.Error(\"QueryNode init session failed\", zap.Error(err))\n\t\t\tinitError = err\n\t\t\treturn\n\t\t}\n\n\t\terr = node.initHook()\n\t\tif err != nil {\n\t\t\t// auto index cannot work if hook init failed\n\t\t\tif paramtable.Get().AutoIndexConfig.Enable.GetAsBool() {\n\t\t\t\tlog.Error(\"QueryNode init hook failed\", zap.Error(err))\n\t\t\t\tinitError = err\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tnode.factory.Init(paramtable.Get())\n\n\t\tlocalRootPath := paramtable.Get().LocalStorageCfg.Path.GetValue()\n\t\tlocalChunkManager := storage.NewLocalChunkManager(storage.RootPath(localRootPath))\n\t\tlocalUsedSize, err := segments.GetLocalUsedSize(localRootPath)\n\t\tif err != nil {\n\t\t\tlog.Warn(\"get local used size failed\", zap.Error(err))\n\t\t\tinitError = err\n\t\t\treturn\n\t\t}\n\t\tmetrics.QueryNodeDiskUsedSize.WithLabelValues(fmt.Sprint(paramtable.GetNodeID())).Set(float64(localUsedSize / 1024 / 1024))\n\t\tremoteChunkManager, err := node.factory.NewPersistentStorageChunkManager(node.ctx)\n\t\tif err != nil {\n\t\t\tlog.Warn(\"failed to init remote chunk manager\", zap.Error(err))\n\t\t\tinitError = err\n\t\t\treturn\n\t\t}\n\t\tnode.cacheChunkManager, err = storage.NewVectorChunkManager(node.ctx,\n\t\t\tlocalChunkManager,\n\t\t\tremoteChunkManager,\n\t\t\tparamtable.Get().QueryNodeCfg.CacheMemoryLimit.GetAsInt64(),\n\t\t\tparamtable.Get().QueryNodeCfg.CacheEnabled.GetAsBool(),\n\t\t)\n\t\tif err != nil {\n\t\t\tlog.Error(\"failed to init cache chunk manager\", zap.Error(err))\n\t\t\tinitError = err\n\t\t\treturn\n\t\t}\n\n\t\tnode.vectorStorage, err = node.factory.NewPersistentStorageChunkManager(node.ctx)\n\t\tif err != nil {\n\t\t\tlog.Error(\"QueryNode init vector storage failed\", zap.Error(err))\n\t\t\tinitError = err\n\t\t\treturn\n\t\t}\n\n\t\tlog.Info(\"queryNode try to connect etcd success\", zap.String(\"MetaRootPath\", paramtable.Get().EtcdCfg.MetaRootPath.GetValue()))\n\n\t\tschedulePolicy := paramtable.Get().QueryNodeCfg.SchedulePolicyName.GetValue()\n\t\tnode.scheduler = tasks.NewScheduler(\n\t\t\tschedulePolicy,\n\t\t)\n\t\tlog.Info(\"queryNode init scheduler\", zap.String(\"policy\", schedulePolicy))\n\n\t\tnode.clusterManager = cluster.NewWorkerManager(func(nodeID int64) (cluster.Worker, error) {\n\t\t\tif nodeID == paramtable.GetNodeID() {\n\t\t\t\treturn NewLocalWorker(node), nil\n\t\t\t}\n\n\t\t\tsessions, _, err := node.session.GetSessions(typeutil.QueryNodeRole)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\taddr := \"\"\n\t\t\tfor _, session := range sessions {\n\t\t\t\tif session.ServerID == nodeID {\n\t\t\t\t\taddr = session.Address\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tclient, err := grpcquerynodeclient.NewClient(node.ctx, addr, nodeID)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\treturn cluster.NewRemoteWorker(client), nil\n\t\t})\n\t\tnode.delegators = typeutil.NewConcurrentMap[string, delegator.ShardDelegator]()\n\t\tnode.subscribingChannels = typeutil.NewConcurrentSet[string]()\n\t\tnode.unsubscribingChannels = typeutil.NewConcurrentSet[string]()\n\t\tnode.manager = segments.NewManager()\n\t\tnode.loader = segments.NewLoader(node.manager, node.vectorStorage)\n\t\tnode.dispClient = msgdispatcher.NewClient(node.factory, typeutil.QueryNodeRole, paramtable.GetNodeID())\n\t\t// init pipeline manager\n\t\tnode.pipelineManager = pipeline.NewManager(node.manager, node.tSafeManager, node.dispClient, node.delegators)\n\n\t\terr = node.InitSegcore()\n\t\tif err != nil {\n\t\t\tlog.Error(\"QueryNode init segcore failed\", zap.Error(err))\n\t\t\tinitError = err\n\t\t\treturn\n\t\t}\n\t\tif paramtable.Get().QueryNodeCfg.GCEnabled.GetAsBool() {\n\t\t\tif paramtable.Get().QueryNodeCfg.GCHelperEnabled.GetAsBool() {\n\t\t\t\taction := func(GOGC uint32) {\n\t\t\t\t\tdebug.SetGCPercent(int(GOGC))\n\t\t\t\t}\n\t\t\t\tgc.NewTuner(paramtable.Get().QueryNodeCfg.OverloadedMemoryThresholdPercentage.GetAsFloat(), uint32(paramtable.Get().QueryNodeCfg.MinimumGOGCConfig.GetAsInt()), uint32(paramtable.Get().QueryNodeCfg.MaximumGOGCConfig.GetAsInt()), action)\n\t\t\t} else {\n\t\t\t\taction := func(uint32) {}\n\t\t\t\tgc.NewTuner(paramtable.Get().QueryNodeCfg.OverloadedMemoryThresholdPercentage.GetAsFloat(), uint32(paramtable.Get().QueryNodeCfg.MinimumGOGCConfig.GetAsInt()), uint32(paramtable.Get().QueryNodeCfg.MaximumGOGCConfig.GetAsInt()), action)\n\t\t\t}\n\t\t}\n\n\t\tlog.Info(\"query node init successfully\",\n\t\t\tzap.Int64(\"queryNodeID\", paramtable.GetNodeID()),\n\t\t\tzap.String(\"Address\", node.address),\n\t\t)\n\t})\n\n\treturn initError\n}", "title": "" }, { "docid": "d00a8d616c83b8d6989d83bff4c07fe5", "score": "0.51153904", "text": "func (s *initServer) NeedsBootstrap() bool {\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\n\treturn !s.mu.bootstrapped\n}", "title": "" }, { "docid": "f1b7ef14a9b385d6874afe6bc7a98c83", "score": "0.51136607", "text": "func (s *initServer) initializeFirstStoreAfterJoin(\n\tctx context.Context, resp *roachpb.JoinNodeResponse,\n) (*initState, error) {\n\tfirstEngine := s.inspectedDiskState.uninitializedEngines[0]\n\tclusterVersion := clusterversion.ClusterVersion{Version: *resp.ActiveVersion}\n\tif err := kvserver.WriteClusterVersion(ctx, firstEngine, clusterVersion); err != nil {\n\t\treturn nil, err\n\t}\n\n\tsIdent, err := resp.CreateStoreIdent()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err := kvserver.InitEngine(ctx, firstEngine, sIdent); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn inspectEngines(\n\t\tctx, s.inspectedDiskState.uninitializedEngines,\n\t\ts.config.binaryVersion, s.config.binaryMinSupportedVersion,\n\t)\n}", "title": "" }, { "docid": "f0f27ac78c8d940e63a7d1fc94411bd1", "score": "0.5077626", "text": "func (s *server) Initialized(ctx context.Context, _ *protocol.InitializedParams) error {\n\ts.stateMu.Lock()\n\tdefer s.stateMu.Unlock()\n\n\tif s.state != serverInitializing {\n\t\treturn errors.New(\"cannot initialize server: wrong server state\")\n\t}\n\n\tif len(s.prometheusURL) > 0 {\n\t\tif err := s.connectPrometheus(s.prometheusURL); err != nil {\n\t\t\t// nolint: errcheck\n\t\t\ts.client.LogMessage(ctx, &protocol.LogMessageParams{\n\t\t\t\tType: protocol.Info,\n\t\t\t\tMessage: err.Error(),\n\t\t\t})\n\t\t}\n\t} else {\n\t\t// nolint: errcheck\n\t\ts.client.LogMessage(ctx, &protocol.LogMessageParams{\n\t\t\tType: protocol.Info,\n\t\t\tMessage: \"No Prometheus\",\n\t\t})\n\t}\n\n\ts.state = serverInitialized\n\treturn nil\n}", "title": "" }, { "docid": "344c5c8b84f95df91e4b1c8879251c52", "score": "0.5068473", "text": "func (store *Hazelcast) Init(_ context.Context, metadata state.Metadata) error {\n\tmeta, err := validateAndParseMetadata(metadata)\n\tif err != nil {\n\t\treturn err\n\t}\n\tservers := meta.HazelcastServers\n\n\thzConfig := hazelcast.NewConfig()\n\thzConfig.NetworkConfig().AddAddress(strings.Split(servers, \",\")...)\n\n\tclient, err := hazelcast.NewClientWithConfig(hzConfig)\n\tif err != nil {\n\t\treturn err\n\t}\n\tstore.hzMap, err = client.GetMap(meta.HazelcastMap)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "e3c18bc145558fbf610ccc4f782ea9c2", "score": "0.5046644", "text": "func waitForInit(ctx context.Context, m *libvuln.Libvuln) error {\n\ttimer := time.NewTicker(5 * time.Second)\n\tdefer timer.Stop()\n\tfor ok, err := m.Initialized(ctx); ; ok, err = m.Initialized(ctx) {\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif ok {\n\t\t\tbreak\n\t\t}\n\t\tfmt.Fprintln(os.Stderr, \"waiting\")\n\t\tselect {\n\t\tcase <-timer.C:\n\t\t\tcontinue\n\t\tcase <-ctx.Done():\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "57a6f808b175d66c57f8c4baf3212162", "score": "0.5043179", "text": "func runInit(opts *standaloneClusterRegistryOptions, cmdOut io.Writer,\n\thostClientset client.Interface, pathOptions *clientcmd.PathOptions) error {\n\n\terr := opts.CreateNamespace(cmdOut, hostClientset)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tsvc, ips, hostnames, err := opts.CreateService(cmdOut, hostClientset)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcredentials, err := opts.GenerateCredentials(cmdOut, svc.Name, ips, hostnames,\n\t\topts.apiServerEnableHTTPBasicAuth, opts.apiServerEnableTokenAuth)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = opts.CreateAPIServerCredentialsSecret(hostClientset, credentials)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tpvc, err := opts.CreatePVC(cmdOut, hostClientset, svc.Name)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = opts.CreateAPIServer(cmdOut, hostClientset, opts.apiServerEnableHTTPBasicAuth,\n\t\topts.apiServerEnableTokenAuth, false, ips, pvc, \"default\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = opts.UpdateKubeconfig(cmdOut, pathOptions, svc, ips, hostnames,\n\t\tcredentials)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn opts.WaitForAPIServer(cmdOut, hostClientset, pathOptions, ips,\n\t\thostnames, svc)\n}", "title": "" }, { "docid": "fd3681bc51d3e7f60aa523a881a69b5a", "score": "0.50241166", "text": "func (s *state) Initialize() error {\n\t// set message routes\n\ts.messageChannel = make(chan *messages.Message, 20)\n\trouter.Router.AddRoute(messages.TypeBlockResponse, s.messageChannel)\n\trouter.Router.AddRoute(messages.TypeBlockWithVotesResponse, s.messageChannel)\n\ts.internalMessageChannel = make(chan *messages.InternalMessage, 150)\n\trouter.Router.AddInternalRoute(messages.TypeInternalDataStoreHeight, s.internalMessageChannel)\n\trouter.Router.AddInternalRoute(messages.TypeInternalBootstrapBlock, s.internalMessageChannel)\n\trouter.Router.AddInternalRoute(messages.TypeInternalExiting, s.internalMessageChannel)\n\ts.fastChainInitialization = s.ctxt.Preferences.Retrieve(configuration.FastChainInitializationKey, \"0\") == \"1\"\n\terr := s.loadGenesisBlock()\n\treturn err\n}", "title": "" }, { "docid": "22983c3789958b65ac15cd102ec56a6b", "score": "0.50170815", "text": "func InitServer(manager *manage.Manager) *server.Server {\n\tonce.Do(func() {\n\t\teServer = server.NewDefaultServer(manager)\n\t})\n\treturn eServer\n}", "title": "" }, { "docid": "8cba55e39343e0ba4d20e3df000f02bb", "score": "0.50036365", "text": "func (m *Manager) InitServer(data remote.ServerConfigurationResponse) (*Server, error) {\n\ts, err := New(m.client)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Setup the base server configuration data which will be used for all of the\n\t// remaining functionality in this call.\n\tif err := s.SyncWithConfiguration(data); err != nil {\n\t\treturn nil, errors.WithStackIf(err)\n\t}\n\n\ts.fs = filesystem.New(filepath.Join(config.Get().System.Data, s.ID()), s.DiskSpace(), s.Config().Egg.FileDenylist)\n\n\t// Right now we only support a Docker based environment, so I'm going to hard code\n\t// this logic in. When we're ready to support other environment we'll need to make\n\t// some modifications here, obviously.\n\tsettings := environment.Settings{\n\t\tMounts: s.Mounts(),\n\t\tAllocations: s.cfg.Allocations,\n\t\tLimits: s.cfg.Build,\n\t\tLabels: s.cfg.Labels,\n\t}\n\n\tenvCfg := environment.NewConfiguration(settings, s.GetEnvironmentVariables())\n\tmeta := docker.Metadata{\n\t\tImage: s.Config().Container.Image,\n\t}\n\n\tif env, err := docker.New(s.ID(), &meta, envCfg); err != nil {\n\t\treturn nil, err\n\t} else {\n\t\ts.Environment = env\n\t\ts.StartEventListeners()\n\t}\n\n\t// If the server's data directory exists, force disk usage calculation.\n\tif _, err := os.Stat(s.Filesystem().Path()); err == nil {\n\t\ts.Filesystem().HasSpaceAvailable(true)\n\t}\n\n\treturn s, nil\n}", "title": "" }, { "docid": "3224cbc1e4609d2ad3c94f1d1b1a349d", "score": "0.49869734", "text": "func ServerInitialization() {\n\n\tvar mServerListenerFileTransfer net.Listener\n\tvar mServerListenerRPC net.Listener\n\tvar mError error\n\n\t// PHASE 1 - Allocate needed \"Listener\" objects used for \"File-Transfer\"\n\t// \t\t and RPC postponing their closing) ...\n\t// ====================================================================== //\n\tmServerListenerFileTransfer, mError = net.Listen(core.DefaultNetwork, core.DefaultServerFileReceiverAddress)\n\tglobal.CheckError(mError)\n\tdefer func() {\n\t\tglobal.CheckError(mServerListenerFileTransfer.Close())\n\t}()\n\n\tmServerListenerRPC, mError = net.Listen(core.DefaultNetwork, core.DefaultServerRPCAddress)\n\tglobal.CheckError(mError)\n\tdefer func() {\n\t\tglobal.CheckError(mServerListenerRPC.Close())\n\t}()\n\n\t// Publish \"WorkCount\" and \"WorkerSubscribe\" task...\n\tglobal.CheckError(rpc.Register(&remote.WordCount{}))\n\tglobal.CheckError(rpc.Register(&remote.Subscription{}))\n\n\t// PHASE 2 - Start listening for \"File-Transfer\"...\n\t// ====================================================================== //\n\tgo func(x net.Listener) {\n\t\tfor {\n\t\t\tfmt.Println(\"Server: Waiting File!\")\n\t\t\t_, mError = file.Receive(x)\n\t\t\tglobal.CheckError(mError)\n\t\t}\n\t}(mServerListenerFileTransfer)\n\n\t// PHASE 3 - Start listening for RPC...\n\t// ====================================================================== //\n\tfor {\n\t\tfmt.Println(\"Server: Waiting RPC!\")\n\t\trpc.Accept(mServerListenerRPC)\n\t}\n}", "title": "" }, { "docid": "c3e7bbff9912a49c83f1c6abc43e7d35", "score": "0.49840245", "text": "func (m *SessionManager) Init() error {\n\tm.Lock()\n\tif m.numShards < 1 {\n\t\t_, err := m.GetRecommendedCount()\n\t\tif err != nil {\n\t\t\treturn errors.WithMessage(err, \"Start\")\n\t\t}\n\t}\n\n\tm.Sessions = make([]*discordgo.Session, m.numShards)\n\tfor i := 0; i < m.numShards; i++ {\n\t\terr := m.initSession(i)\n\t\tif err != nil {\n\t\t\tm.Unlock()\n\t\t\treturn errors.WithMessage(err, \"initSession\")\n\t\t}\n\t}\n\n\tif !m.statusUpdaterStarted {\n\t\tm.statusUpdaterStarted = true\n\t\tgo m.statusRoutine()\n\t}\n\n\tm.nextStatusUpdate = time.Now()\n\n\tm.Unlock()\n\n\treturn nil\n}", "title": "" }, { "docid": "d86aaf29c5ccadc3847f5c8ee4a7d799", "score": "0.49832475", "text": "func (sm *SysModel) Init(tb *testbed.TestBed, cfgType enterprise.CfgType, skipSetup bool) error {\n\n\terr := sm.SysModel.Init(tb, cfgType, skipSetup)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tsm.AutoDiscovery = true\n\tif os.Getenv(\"NO_AUTO_DISCOVERY\") != \"\" {\n\t\tsm.AutoDiscovery = false\n\t}\n\n\tsm.RandomTrigger = sm.RunRandomTrigger\n\tsm.RunVerifySystemHealth = sm.VerifySystemHealth\n\tsm.NoModeSwitchReboot = true\n\tsm.NoSetupDataPathAfterSwitch = true\n\n\tsm.CfgModel = enterprise.NewCfgModel(cfgType)\n\tif sm.CfgModel == nil {\n\t\treturn errors.New(\"could not initialize config objects\")\n\t}\n\n\terr = sm.SetupVeniceNaples()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t//Venice is up so init config model\n\terr = sm.InitCfgModel()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn sm.SetupNodes()\n}", "title": "" }, { "docid": "bb6fa5e82d3b94517f0374c066e6e3c2", "score": "0.496991", "text": "func (srv *server) Init(opts ...Options) (err error) {\n\tsrv.initOnce.Do(func() {\n\t\terr = srv.init(opts...)\n\t})\n\treturn err\n}", "title": "" }, { "docid": "49f1da052ddc64dbd17aa1253d335e21", "score": "0.4968559", "text": "func (s *Server) Init() error {\n\tvar err error\n\tvar clientconfig *rest.Config\n\tif len(s.opt.Kubeconfig) != 0 {\n\t\tclientconfig, err = clientcmd.BuildConfigFromFlags(s.opt.KubeMaster, s.opt.Kubeconfig)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"build configuration from %s, %s failed, err %s\",\n\t\t\t\ts.opt.KubeMaster, s.opt.Kubeconfig, err.Error())\n\t\t}\n\t} else {\n\t\tclientconfig, err = rest.InClusterConfig()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"init inCluster config failed, err %s\", err.Error())\n\t\t}\n\t}\n\n\tclientset, err := kubernetes.NewForConfig(clientconfig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create client set failed, err %s\", err.Error())\n\t}\n\n\tbcsClientset, err := bcsclientset.NewForConfig(clientconfig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create bcs client set failed, err %s\", err.Error())\n\t}\n\n\tvar infr datainformer.Interface\n\tswitch s.opt.ServiceRegistry {\n\tcase options.ServiceRegistryKubernetes:\n\t\tkInfr := infrk8s.New(s.opt)\n\t\tkInfr.Init(clientset)\n\t\tinfr = kInfr\n\tcase options.ServiceRegistryMesos:\n\t\tmInfr := infrmesos.New(s.opt)\n\t\tmInfr.Init(clientset, bcsClientset)\n\t\tinfr = mInfr\n\t}\n\n\tnpc, err := controller.NewNetworkPolicyController(clientset, infr, s.opt)\n\tif err != nil {\n\t\tblog.Errorf(\"create network policy controller failed, err %s\", err.Error())\n\t\treturn fmt.Errorf(\"create network policy controller failed, err %s\", err.Error())\n\t}\n\n\tinfr.AddPodEventHandler(npc.PodEventHandler)\n\tinfr.AddNamespaceEventHandler(npc.NamespaceEventHandler)\n\tinfr.AddNetworkpolicyEventHandler(npc.NetworkPolicyEventHandler)\n\n\ts.infr = infr\n\ts.netPolicyController = npc\n\n\t// init http server\n\thttpServer := httpserver.NewHttpServer(s.opt.Port, s.opt.Address, \"\")\n\tif len(s.opt.CAFile) != 0 || len(s.opt.ServerCertFile) != 0 || len(s.opt.ServerKeyFile) != 0 {\n\t\thttpServer.SetSsl(s.opt.CAFile, s.opt.ServerCertFile, s.opt.ServerKeyFile, static.ServerCertPwd)\n\t}\n\thttpServer.GetWebContainer().Handle(\"/metrics\", promhttp.Handler())\n\tif s.opt.Debug {\n\t\tdebugActions := []*httpserver.Action{\n\t\t\thttpserver.NewAction(\"GET\", \"/debug/pprof/\", nil, getRouteFunc(pprof.Index)),\n\t\t\thttpserver.NewAction(\"GET\", \"/debug/pprof/{uri:*}\", nil, getRouteFunc(pprof.Index)),\n\t\t\thttpserver.NewAction(\"GET\", \"/debug/pprof/cmdline\", nil, getRouteFunc(pprof.Cmdline)),\n\t\t\thttpserver.NewAction(\"GET\", \"/debug/pprof/profile\", nil, getRouteFunc(pprof.Profile)),\n\t\t\thttpserver.NewAction(\"GET\", \"/debug/pprof/symbol\", nil, getRouteFunc(pprof.Symbol)),\n\t\t\thttpserver.NewAction(\"GET\", \"/debug/pprof/trace\", nil, getRouteFunc(pprof.Trace)),\n\t\t}\n\t\thttpServer.RegisterWebServer(\"\", nil, debugActions)\n\t}\n\n\ts.httpServer = httpServer\n\n\treturn nil\n}", "title": "" }, { "docid": "4949be659adf29fabbff2daca1486dac", "score": "0.49660397", "text": "func (gs *Server) Init(process *ServerProcess, args ...etf.Term) error {\n\treturn nil\n}", "title": "" }, { "docid": "550a74715057990505cb081fc753ed18", "score": "0.49551144", "text": "func (stateImpl *StateImpl) Initialize(configs map[string]interface{}) error {\n\n\t//if this flag is set (no matter what value it is), always load all settings\n\t//from config file\n\t_, forceLoad := configs[\"forceload\"]\n\n\t//load config first, which will replace the configs in argument\n\tif cfgSaved, err := stateImpl.GetValue(db.StateCF, configDataKey); err != nil {\n\t\treturn err\n\t} else if len(cfgSaved) != 0 && !forceLoad {\n\t\tstateImpl.currentConfig, err = loadconfig(cfgSaved, configs)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"loading config fail: %s\", err)\n\t\t}\n\t} else {\n\t\tstateImpl.currentConfig = initConfig(configs)\n\t\tpersisted, err := stateImpl.currentConfig.persist()\n\t\tif err == nil {\n\t\t\terr = stateImpl.PutValue(db.StateCF, configDataKey, persisted)\n\t\t}\n\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"saving config fail: %s\", err)\n\t\t}\n\t}\n\n\trootBucketNode, err := fetchBucketNodeFromDB(stateImpl.OpenchainDB, constructRootBucketKey(stateImpl.currentConfig))\n\tif err != nil {\n\t\treturn err\n\t}\n\tif rootBucketNode != nil {\n\t\tstateImpl.persistedStateHash = rootBucketNode.computeCryptoHash()\n\t\tstateImpl.lastComputedCryptoHash = stateImpl.persistedStateHash\n\t}\n\n\tstateImpl.bucketCache = newBucketCache(stateImpl.currentConfig.bucketCacheMaxSize, stateImpl.OpenchainDB)\n\tstateImpl.bucketCache.loadAllBucketNodesFromDB(stateImpl.currentConfig)\n\n\tif syncSaved, err := stateImpl.GetValue(db.StateCF, partialStatusKey); err != nil {\n\t\treturn fmt.Errorf(\"reading syncing state fail: %s\", err)\n\t} else if len(syncSaved) != 0 {\n\n\t\tstateImpl.underSync, err = loadSyncProcess(stateImpl, syncSaved)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"loading syncing state fail: %s\", err)\n\t\t}\n\t\tstateImpl.lastComputedCryptoHash = stateImpl.underSync.targetStateHash\n\t\tstateImpl.recomputeCryptoHash = false\n\t\treturn stateImpl.underSync\n\t} else {\n\t\treturn nil\n\t}\n\n}", "title": "" }, { "docid": "8951024cb73101a80eeb181759bcbfdd", "score": "0.4947764", "text": "func (s *MockSchemaSyncer) Init(ctx context.Context) error {\n\ts.globalVerCh = make(chan clientv3.WatchResponse, 1)\n\ts.mockSession = make(chan struct{}, 1)\n\treturn nil\n}", "title": "" }, { "docid": "5e7b2b03f3a61449a7f9142a6e8ae5db", "score": "0.49429357", "text": "func (k Keeper) InitGenesis(ctx sdk.Context, state *types.GenesisState) {\n\t// VM writeSets\n\tfor genWOIdx, genWriteOp := range state.WriteSet {\n\t\taccessPath, value, err := genWriteOp.ToBytes()\n\t\tif err != nil {\n\t\t\tpanic(fmt.Errorf(\"writeSet [%d]: %w\", genWOIdx, err))\n\t\t}\n\n\t\tk.SetValue(ctx, accessPath, value)\n\t}\n\n\t// Edge-case: set storage context for DS before the BeginBlock occurs\n\tk.dsServer.SetContext(ctx)\n}", "title": "" }, { "docid": "3c1d0cb1fc2dadb1053f034a71964a37", "score": "0.49357012", "text": "func Initialise(recover bool) error {\n\tglobalData.Lock()\n\tdefer globalData.Unlock()\n\n\t// no need to start if already started\n\tif globalData.initialised {\n\t\treturn fault.ErrAlreadyInitialised\n\t}\n\n\tlog := logger.New(\"block\")\n\tglobalData.log = log\n\tlog.Info(\"starting…\")\n\n\t// check storage is initialised\n\tif nil == storage.Pool.Blocks {\n\t\tlog.Critical(\"storage pool is not initialised\")\n\t\treturn fault.ErrNotInitialised\n\t}\n\n\tif recover {\n\t\tlog.Warn(\"start index rebuild…\")\n\t\tglobalData.rebuild = true\n\t\tglobalData.Unlock()\n\t\terr := doRecovery()\n\t\tglobalData.Lock()\n\t\tif nil != err {\n\t\t\tlog.Criticalf(\"index rebuild error: %s\", err)\n\t\t\treturn err\n\t\t}\n\t\tlog.Warn(\"index rebuild completed\")\n\t}\n\n\t// ensure not in rebuild mode\n\tglobalData.rebuild = false\n\n\t// detect if any blocks on file\n\tif last, ok := storage.Pool.Blocks.LastElement(); ok {\n\n\t\t// start validating block indexes\n\t\theader, digest, err := validateAndReturnLastBlock(last)\n\t\tif nil != err {\n\t\t\tlog.Criticalf(\"failed to validate blocks from storage error: %s\", err)\n\t\t\treturn err\n\t\t}\n\n\t\theight := header.Number\n\t\tblockheader.Set(height, digest, header.Version, header.Timestamp)\n\n\t\tlog.Infof(\"highest block from storage: %d\", height)\n\t}\n\n\t// initialise background tasks\n\tif err := globalData.blk.initialise(); nil != err {\n\t\treturn err\n\t}\n\n\t// all data initialised\n\tglobalData.initialised = true\n\n\t// start background processes\n\tlog.Info(\"start background…\")\n\n\tprocesses := background.Processes{\n\t\t&globalData.blk,\n\t}\n\n\tglobalData.background = background.Start(processes, log)\n\n\treturn nil\n}", "title": "" }, { "docid": "6f480755cd87a6009b845e1e4fec51dc", "score": "0.4935214", "text": "func (s *SQLStore) Init(info *spb.ServerInfo) error {\n\ts.Lock()\n\tdefer s.Unlock()\n\tcount := 0\n\tr := s.db.QueryRow(sqlStmts[sqlHasServerInfoRow])\n\tif err := r.Scan(&count); err != nil && err != sql.ErrNoRows {\n\t\treturn sqlStmtError(sqlHasServerInfoRow, err)\n\t}\n\tinfoBytes, _ := info.Marshal()\n\tif count == 0 {\n\t\tif _, err := s.db.Exec(sqlStmts[sqlAddServerInfo], info.ClusterID, infoBytes, sqlVersion); err != nil {\n\t\t\treturn sqlStmtError(sqlAddServerInfo, err)\n\t\t}\n\t} else {\n\t\tif _, err := s.db.Exec(sqlStmts[sqlUpdateServerInfo], info.ClusterID, infoBytes, sqlVersion); err != nil {\n\t\t\treturn sqlStmtError(sqlUpdateServerInfo, err)\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c9d2465fa6865251d096b535e15a47c8", "score": "0.4934805", "text": "func (serverObj Server) Start() {\n\t// Already started?\n\tif atomic.AddInt32(&serverObj.started, 1) != 1 {\n\t\treturn\n\t}\n\n\tLogger.log.Debug(\"Starting server\")\n\tif common.CheckForce {\n\t\tserverObj.CheckForceUpdateSourceCode()\n\t}\n\tif cfg.TestNet {\n\t\tLogger.log.Critical(\"************************\" +\n\t\t\t\"* Testnet is active *\" +\n\t\t\t\"************************\")\n\t}\n\t// Server startup time. Used for the uptime command for uptime calculation.\n\tserverObj.startupTime = time.Now().Unix()\n\n\t// Start the peer handler which in turn starts the address and block\n\t// managers.\n\tserverObj.waitGroup.Add(1)\n\n\tgo serverObj.peerHandler()\n\tif !cfg.DisableRPC && serverObj.rpcServer != nil {\n\t\tserverObj.waitGroup.Add(1)\n\n\t\t// Start the rebroadcastHandler, which ensures user tx received by\n\t\t// the RPC server are rebroadcast until being included in a block.\n\t\t//go serverObj.rebroadcastHandler()\n\n\t\tserverObj.rpcServer.Start()\n\t}\n\tgo serverObj.blockChain.Synker.Start()\n\n\tif cfg.NodeMode != common.NODEMODE_RELAY {\n\t\terr := serverObj.consensusEngine.Start()\n\t\tif err != nil {\n\t\t\tLogger.log.Error(err)\n\t\t\tgo serverObj.Stop()\n\t\t\treturn\n\t\t}\n\t\tserverObj.memPool.IsBlockGenStarted = true\n\t\tserverObj.blockChain.SetIsBlockGenStarted(true)\n\t\tfor _, shardPool := range serverObj.shardPool {\n\t\t\tgo shardPool.Start(serverObj.cQuit)\n\t\t}\n\t\tgo serverObj.beaconPool.Start(serverObj.cQuit)\n\t}\n\n\tif serverObj.memPool != nil {\n\t\terr := serverObj.memPool.LoadOrResetDatabaseMempool()\n\t\tif err != nil {\n\t\t\tLogger.log.Error(err)\n\t\t}\n\t\tgo serverObj.TransactionPoolBroadcastLoop()\n\t\tgo serverObj.memPool.Start(serverObj.cQuit)\n\t}\n\tgo serverObj.pusubManager.Start()\n}", "title": "" }, { "docid": "bdc7e5fa23943923f90838d27b4daf1b", "score": "0.49333885", "text": "func (m *TargetsDiscovery) WaitInit(ctx context.Context) error {\n\tt := time.NewTicker(time.Second)\n\tflag := map[string]bool{}\nl1:\n\tfor {\n\t\tselect {\n\t\tcase <-t.C:\n\t\t\tm.targetsLock.Lock()\n\t\t\tfor job := range m.config {\n\t\t\t\tif _, exist := m.activeTargets[job]; !exist {\n\t\t\t\t\tm.targetsLock.Unlock()\n\t\t\t\t\tcontinue l1\n\t\t\t\t}\n\t\t\t\tif !flag[job] {\n\t\t\t\t\tm.log.Infof(\"job %s first service discovery done, active(%d) ,drop(%d)\", job, len(m.activeTargets[job]), len(m.dropTargets[job]))\n\t\t\t\t\tflag[job] = true\n\t\t\t\t}\n\t\t\t}\n\t\t\tm.log.Infof(\"all job first service discovery done\")\n\t\t\tm.targetsLock.Unlock()\n\t\t\treturn nil\n\t\tcase <-ctx.Done():\n\t\t\treturn nil\n\t\t}\n\t}\n}", "title": "" }, { "docid": "49049e461e126605ab736bc9e7cef769", "score": "0.49234864", "text": "func ServerInit(version string, build string) error {\n\tserver := Server{conf: &ServerConfig{}}\n\tserver.trapSignal()\n\tserver.conf.init(version, build)\n\tserver.start()\n\treturn nil\n}", "title": "" }, { "docid": "c47a9fcf1765838e49c35872e0db929d", "score": "0.48998436", "text": "func TestInit(t *testing.T) {\n\ttmp := tmpFolder()\n\tdefer os.RemoveAll(tmp)\n\tdefaultFolder = tmp\n\n\targs := toArgs(\"init\", \"--config\", tmp, \"--remote\", tmp, \"--local\", tmp)\n\trequire.NoError(t, app.Run(args))\n\tdefer func() {\n\t\tinput = os.Stdin\n\t}()\n\tvar in bytes.Buffer\n\tin.WriteString(\"YES\\n\")\n\tinput = &in\n\ttoSearch := \"BROU\"\n\targs = toArgs(\"init\", \"--config\", tmp, \"--clean\", \"--remote\", toSearch, \"--local\", tmp)\n\trequire.NoError(t, app.Run(args))\n\n\tlocalPath := getConfigFile(tmp)\n\tbc, err := Load(localPath)\n\trequire.NoError(t, err)\n\trequire.Equal(t, bc.LocalRoot, tmp)\n\trequire.Equal(t, bc.Remote, toSearch)\n\n\ttmp2 := tmpFolder()\n\tdefer os.RemoveAll(tmp2)\n\targs = toArgs(\"init\", \"--config\", tmp2, \"--from\", localPath)\n\trequire.NoError(t, app.Run(args))\n\tlocalPath2 := getConfigFile(tmp2)\n\tbc2, err := Load(localPath2)\n\trequire.NoError(t, err)\n\trequire.Equal(t, bc, bc2)\n}", "title": "" }, { "docid": "2e4a3e5ee307645b35ee6a09f014531f", "score": "0.48988336", "text": "func Initialize() error {\n\tif loadErr := LoadFromPersistedState(); loadErr != nil {\n\t\treturn loadErr\n\t}\n\n\treturn ensureListener()\n}", "title": "" }, { "docid": "417962191f2b5ffce2123356fb07bdce", "score": "0.48935992", "text": "func (st *Store) Init(path string, create, excl bool) error {\n\treturn st.vs.Init(path, create, excl)\n}", "title": "" }, { "docid": "d7358840bbd250c533996b256e2fc5a8", "score": "0.48745853", "text": "func (serv *Server) Initialise() error {\n\tdb, err := newDatabase(serv.config)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tserv.db = db\n\terr = db.initialiseDatabase()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = serv.InitialiseProviders()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "7870f413aafca4a14f43f48e87918e87", "score": "0.4861929", "text": "func (mm *MantlemintInstance) Init(genesis *tmtypes.GenesisDoc) error {\n\t// TODO: move this bit to mantle-compatibility\n\t// some config\n\tconfig := sdk.GetConfig()\n\tconfig.SetCoinType(core.CoinType)\n\tconfig.SetFullFundraiserPath(core.FullFundraiserPath)\n\tconfig.SetBech32PrefixForAccount(core.Bech32PrefixAccAddr, core.Bech32PrefixAccPub)\n\tconfig.SetBech32PrefixForValidator(core.Bech32PrefixValAddr, core.Bech32PrefixValPub)\n\tconfig.SetBech32PrefixForConsensusNode(core.Bech32PrefixConsAddr, core.Bech32PrefixConsPub)\n\tconfig.Seal()\n\n\t// loaded state has LastBlockHeight 0,\n\t// meaning chain was never initialized\n\t// run genesis\n\tlog.Printf(\"genesisTime=%v, chainId=%v\", genesis.GenesisTime, genesis.ChainID)\n\n\tif mm.lastState.IsEmpty() {\n\t\tlog.Print(\"initializing mantle from genesis\")\n\n\t\t// create default state from genesis\n\t\tvar genesisState, err = state.MakeGenesisState(genesis)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tlog.Printf(\"\\tgenesisTime=%v, chainId=%v\", genesis.GenesisTime, genesis.ChainID)\n\t\tlog.Printf(\"\\tappHash=%v\", genesis.AppHash)\n\n\t\tvalidators := make([]*tmtypes.Validator, len(genesis.Validators))\n\t\tfor i, val := range genesis.Validators {\n\t\t\tvalidators[i] = tmtypes.NewValidator(val.PubKey, val.Power)\n\t\t}\n\t\tvalidatorSet := tmtypes.NewValidatorSet(validators)\n\t\tnextVals := tmtypes.TM2PB.ValidatorUpdates(validatorSet)\n\n\t\tcsParams := tmtypes.TM2PB.ConsensusParams(genesis.ConsensusParams)\n\t\treq := abci.RequestInitChain{\n\t\t\tTime: genesis.GenesisTime,\n\t\t\tChainId: genesis.ChainID,\n\t\t\tAppStateBytes: genesis.AppState,\n\t\t\tConsensusParams: csParams,\n\t\t\tValidators: nextVals,\n\t\t}\n\n\t\tres, err := mm.conn.InitChainSync(req)\n\n\t\tlog.Printf(\"initChain finished\")\n\t\tlog.Printf(\"\\tvalidators: %v\", len(res.Validators))\n\t\tlog.Printf(\"\\tconsensusParams: %v\", res.ConsensusParams)\n\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// If the app returned validators or consensus params, update the state.\n\t\tif len(res.Validators) > 0 {\n\t\t\tvals, err := tmtypes.PB2TM.ValidatorUpdates(res.Validators)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\tgenesisState.Validators = tmtypes.NewValidatorSet(vals)\n\t\t\tgenesisState.NextValidators = tmtypes.NewValidatorSet(vals)\n\t\t} else if len(genesis.Validators) == 0 {\n\t\t\t// If validator set is not set in genesis and still empty after InitChain, exit.\n\t\t\tpanic(fmt.Errorf(\"validator set is nil in genesis and still empty after InitChain\"))\n\t\t}\n\n\t\tif res.ConsensusParams != nil {\n\t\t\tgenesisState.ConsensusParams = genesisState.ConsensusParams.Update(res.ConsensusParams)\n\t\t}\n\n\t\t// state needs to be saved\n\t\tstate.SaveState(mm.db, genesisState)\n\n\t\tlog.Print(\"genesis saved to db\")\n\n\t\tmm.lastState = genesisState\n\t\tmm.lastHeight = 0\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "f6b28e5fcd775ba25ba8bec4f4b6adef", "score": "0.4850042", "text": "func (c *Controller) handleStartupInit(cluster crv1.Pgcluster) error {\n\n\t// since the cluster is just being restarted, it can just be set to initialized once the\n\t// primary is ready\n\tif err := controller.SetClusterInitializedStatus(c.PodClient, cluster.Name,\n\t\tcluster.Namespace); err != nil {\n\t\tlog.Error(err)\n\t\treturn err\n\t}\n\n\t// now scale any replicas deployments to 1\n\tclusteroperator.ScaleClusterDeployments(c.PodClientset, cluster, 1, false, true, false, false)\n\n\treturn nil\n}", "title": "" }, { "docid": "faf1e0cf429cf25bf39e211cffdeb25d", "score": "0.48363316", "text": "func Initialize(dbtype string, config string) (bool, error) {\n\n\t//Initalize all the communication channels\n\tOfferList = list.New()\n\tOfferList.Init()\n\tCchan = make(chan TaskCreate)\n\tMchan = make(chan *TaskUpdate) //Channel for Maintainer\n\tDchan = make(chan TaskMsg) //Channel for Destroyer\n\n\tAgents = agentstate.NewState()\n\n\t//Initalize the Internal in-memory storage\n\tMemDb = NewInMem()\n\n\t//Initalize the store db\n\tswitch dbtype {\n\tcase \"etcd\":\n\t\tGdb = etcd.New()\n\t\terr := Gdb.Setup(config)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Failed to setup etcd database error:%v\", err)\n\t\t}\n\t\treturn Gdb.IsSetup(), nil\n\tcase \"zookeeper\":\n\t\tGdb = zookeeper.New()\n\t\terr := Gdb.Setup(config)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Failed to setup zookeeper database error:%v\", err)\n\t\t}\n\t\treturn Gdb.IsSetup(), nil\n\t}\n\n\treturn true, nil\n}", "title": "" }, { "docid": "babd9e4e83effa61e357ab86062982ee", "score": "0.48356032", "text": "func (s *universeTrieServer) init() error {\n\t// Load tries from s.metaDB\n\tlog.Print(\"Initializing trie server\")\n\tif err := s.loadTries(); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "e5991fbd78bf9ec2faa90e0ba939e8e9", "score": "0.48335007", "text": "func (c *Client) Init(rootJSON []byte) error {\n\terr := c.loadAndVerifyRootMeta(rootJSON, true /*ignoreExpiredCheck*/)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn c.local.SetMeta(\"root.json\", rootJSON)\n}", "title": "" }, { "docid": "c5afc5bf1198a4c7d69455c67a756139", "score": "0.4822169", "text": "func Init(c *conf.Config, s *service.Service) {\n\tspcSvc = s\n\tpermitSvc = permit.New(c.Permit)\n\tengine := bm.DefaultServer(c.BM)\n\tauthRouter(engine)\n\t// init internal server\n\tif err := engine.Start(); err != nil {\n\t\tlog.Error(\"engine.Start error(%v)\", err)\n\t\tpanic(err)\n\t}\n}", "title": "" }, { "docid": "8349fef6e54bbb1c013652fd628b6cbb", "score": "0.48164403", "text": "func Init() error {\n\tif e := initState(); e != nil {\n\t\treturn e\n\t}\n\tgo loop()\n\treturn nil\n}", "title": "" }, { "docid": "bd37e5ad2ee471ce9cc2d972c1596f37", "score": "0.4815328", "text": "func Init(c *conf.Config, s *service.Service) {\n\topenSvc = s\n\t// init inner router\n\tengineIn := bm.DefaultServer(nil)\n\tinnerRouter(engineIn)\n\t// init inner server\n\tif err := engineIn.Start(); err != nil {\n\t\tlog.Error(\"engineInner.Start error (%v)\", err)\n\t\tpanic(err)\n\t}\n}", "title": "" }, { "docid": "38294469b5947d92c3bfb1cc2ddef850", "score": "0.4809249", "text": "func (n *Network) Init() {\n\t// Spawn write flusher.\n\tgo n.flushLoop()\n\tgo n.waitExit()\n}", "title": "" }, { "docid": "f8d399c344433e914169bf68119c6e84", "score": "0.48062196", "text": "func (s *store) Initialize() (err error) {\n\tif s.initialized {\n\t\treturn nil\n\t}\n\tif _, err = os.Stat(s.path); os.IsNotExist(err) {\n\t\treturn os.MkdirAll(s.path, os.ModeDir)\n\t}\n\tif err != nil {\n\t\treturn\n\t}\n\n\tconf := metastore.NewConfig()\n\tconf.Bolt.BasePath = s.path\n\ts.kv, err = metastore.NewKVStore(metastore.KV_TYPE_BOLT, conf)\n\n\ts.keyWriter, _ = newDirectKey(s.GetKeyPath())\n\n\ts.st.run()\n\ts.initialized = true\n\tlog.Print(\"Getting stared at path:\", s.path)\n\n\treturn\n}", "title": "" }, { "docid": "4b4d528f17205dae523ae500573e434c", "score": "0.48048046", "text": "func Init(c *conf.Config, s *service.Service) {\n\tmngSvc = s\n\tvfySvc = verify.New(nil)\n\twardenConf := &warden.ClientConfig{\n\t\tNonBlock: true,\n\t}\n\tpermitSvc = permit.New2(wardenConf)\n\t// init inner router\n\tengine := bm.DefaultServer(c.HTTPServer)\n\tinnerRouter(engine)\n\t// init inner server\n\tif err := engine.Start(); err != nil {\n\t\tlog.Error(\"engine.Start error(%v)\", err)\n\t\tpanic(err)\n\t}\n}", "title": "" }, { "docid": "764550433dc8d2766e1aabe994e3621e", "score": "0.4803392", "text": "func (t *WorkerRegistry) Init(stub shim.ChaincodeStubInterface) pb.Response {\n\tlogger.Info(\"WorkerRegistry Init\")\n\treturn shim.Success(nil)\n}", "title": "" }, { "docid": "6e685674fe7c18c35a06c135a8862743", "score": "0.48014385", "text": "func Init() {\n\tmint.DefaultGenesisState = mintGenesisState\n\tstaking.DefaultGenesisState = stakingGenesisState\n\tgov.DefaultGenesisState = govGenesisState\n}", "title": "" }, { "docid": "1c38c19c9dbbb9b62d8c1f835c0654e0", "score": "0.47966564", "text": "func (s *Storage) Init() error {\n\treturn s.db.Update(func(tx *bolt.Tx) error {\n\t\tfor _, bucketName := range [][]byte{\n\t\t\trequestBucketName,\n\t\t\tcookieBucketName,\n\t\t\tqueueBucketName,\n\t\t} {\n\t\t\tif _, err := tx.CreateBucketIfNotExists(bucketName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n}", "title": "" }, { "docid": "b27e62af22f39cd61ae73e44c9e98ed1", "score": "0.47875908", "text": "func Init(cs *kubernetes.Clientset) {\n\tbackendLock.Lock()\n\tbackends = make(map[string]BackendStore)\n\tk8sClient = cs\n\tbackendLock.Unlock()\n}", "title": "" }, { "docid": "79db143200d8be94858471223cd3ee0b", "score": "0.4786552", "text": "func (g *Gossip) bootstrap() {\n\tg.server.stopper.RunWorker(func() {\n\t\tvar bootstrapTimer timeutil.Timer\n\t\tdefer bootstrapTimer.Stop()\n\t\tfor {\n\t\t\tif g.server.stopper.RunTask(func() {\n\t\t\t\tg.mu.Lock()\n\t\t\t\tdefer g.mu.Unlock()\n\t\t\t\thaveClients := g.outgoing.len() > 0\n\t\t\t\thaveSentinel := g.is.getInfo(KeySentinel) != nil\n\t\t\t\tif !haveClients || !haveSentinel {\n\t\t\t\t\t// Try to get another bootstrap address from the resolvers.\n\t\t\t\t\tif addr := g.getNextBootstrapAddress(); addr != nil {\n\t\t\t\t\t\tg.startClient(addr)\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// We couldn't start a client, signal that we're stalled so that\n\t\t\t\t\t\t// we'll retry.\n\t\t\t\t\t\tg.maybeSignalStalledLocked()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}) != nil {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Pause an interval before next possible bootstrap.\n\t\t\tbootstrapTimer.Reset(g.bootstrapInterval)\n\t\t\tselect {\n\t\t\tcase <-bootstrapTimer.C:\n\t\t\t\tbootstrapTimer.Read = true\n\t\t\t\t// break\n\t\t\tcase <-g.server.stopper.ShouldStop():\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// Block until we need bootstrapping again.\n\t\t\tselect {\n\t\t\tcase <-g.stalledCh:\n\t\t\t\t// break\n\t\t\tcase <-g.server.stopper.ShouldStop():\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t})\n}", "title": "" }, { "docid": "ab19acc6190aebcb87ce79c278bd1a69", "score": "0.47799766", "text": "func (sc ServerConfig) Initialize() error {\n\tif sc.StartWebhook == \"\" && sc.StartJaneliaConfig == \"\" {\n\t\treturn nil\n\t}\n\n\tdata := map[string]string{\n\t\t\"Host\": sc.Host,\n\t\t\"Note\": sc.Note,\n\t\t\"HTTP Address\": sc.HTTPAddress,\n\t\t\"RPC Address\": sc.RPCAddress,\n\t}\n\tjsonBytes, err := json.Marshal(data)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif sc.StartWebhook != \"\" {\n\t\treq, err := http.NewRequest(\"POST\", sc.StartWebhook, bytes.NewBuffer(jsonBytes))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\t\tclient := &http.Client{}\n\t\tresp, err := client.Do(req)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif resp.StatusCode != http.StatusOK {\n\t\t\treturn fmt.Errorf(\"called webhook specified in TOML (%q) and received bad status code: %d\", sc.StartWebhook, resp.StatusCode)\n\t\t}\n\t}\n\n\tif sc.StartJaneliaConfig != \"\" {\n\t\t// Janelia specific startup webhook; this format matches what's expected\n\t\t//\tby our local config server\n\t\t// new: format like config server wants\n\t\tresp, err := http.PostForm(sc.StartJaneliaConfig, url.Values{\"config\": {string(jsonBytes)}})\n\t\tif err != nil {\n\t\t return err\n\t\t}\n\t\tif resp.StatusCode != http.StatusOK {\n\t\t return fmt.Errorf(\"called webhook specified in TOML (%q) and received bad status code: %d\", sc.StartWebhook, resp.StatusCode)\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "4bef52d7ff37b57cb30ef8d3c1ecb6c2", "score": "0.47792011", "text": "func Init(machines []string) (*Cluster, error) {\n\tclient := etcd.NewClient(machines)\n\treturn &Cluster{client}, nil\n}", "title": "" }, { "docid": "36fee9748cca47b95b448396b7e439ba", "score": "0.4770463", "text": "func Init(c *conf.Config, s *service.Service) {\n\tauthSvr = auth.New(nil)\n\tmfSvc = s\n\t// engine\n\tengine := bm.DefaultServer(c.BM)\n\tinnerRouter(engine)\n\t// init inner server\n\tif err := engine.Start(); err != nil {\n\t\tlog.Error(\"engine.Start() error(%v)\", err)\n\t\tpanic(err)\n\t}\n}", "title": "" }, { "docid": "9a28183d6be66ff2747f5ddd4c1c7b39", "score": "0.47659245", "text": "func (app *BaseApp) Init() error {\n\tif app.sealed {\n\t\tpanic(\"cannot call initFromMainStore: baseapp already sealed\")\n\t}\n\n\temptyHeader := cmtproto.Header{ChainID: app.chainID}\n\n\t// needed for the export command which inits from store but never calls initchain\n\tapp.setState(execModeCheck, emptyHeader)\n\tapp.Seal()\n\n\tif app.cms == nil {\n\t\treturn errors.New(\"commit multi-store must not be nil\")\n\t}\n\n\treturn app.cms.GetPruning().Validate()\n}", "title": "" }, { "docid": "a67d7f866aab62cef8303de15b0a5883", "score": "0.47651777", "text": "func (s *FakeJujuService) Initialize() error {\n\n\t// Juju needs internet access to reach the charm store. This is\n\t// necessary to download charmstore charms (e.g. when adding a\n\t// service. In the case of downloading charms, the controller\n\t// does not try to download if the charm is already in the database.\n\t// So internet access could go back to disabled if we were to add\n\t// the charm directly before using any API methods that try to\n\t// download it. Here are some ideas on how to do that:\n\t// * use the API's \"upload charm\" HTTP endpoint (POST on /charms);\n\t// this requires disabling the prohibition against uploading\n\t// charmstore charms (which we've done already in fake-juju);\n\t// this could be accomplished using txjuju, python-jujuclient,\n\t// or manually with httplib (all have auth complexity)\n\t// * add an \"upload-charm\" command to fake-juju that forces a\n\t// charmstore charm into the DB\n\t// * add the service with a \"local\" charm schema and then forcibly\n\t// change the charm's schema to \"cs\" in the DB\n\t// In the meantime, we allow fake-juju to have internet access.\n\t// XXX (lp:1639276): Remove this special case.\n\tutils.OutgoingAccessAllowed = true\n\n\tports := s.api.APIHostPorts()\n\tports[0][0].SpaceName = \"dummy-provider-network\"\n\terr := s.state.SetAPIHostPorts(ports)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tconfig := map[string]interface{}{\"default-series\": s.options.Series}\n\terr = s.state.UpdateModelConfig(config, nil, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "78024abefa25db9a70468fa57ede1ad2", "score": "0.4762712", "text": "func (sm *SM) Init() {\n\tsm.lock = &sync.Mutex{}\n\tsm.Handlers = make(map[string]StateHandler)\n\tsm.Transitions = make(map[string]map[string]struct{})\n\tsm.ForcedStates = map[string]struct{}{\n\t\tmodels.JobError: struct{}{},\n\t\tmodels.JobStopped: struct{}{},\n\t\tmodels.JobCanceled: struct{}{},\n\t\tmodels.JobRetrying: struct{}{},\n\t}\n}", "title": "" }, { "docid": "621e0795f46aadf7c4dc1f582f72f793", "score": "0.47606605", "text": "func (blockchain *BlockChain) Init(config *Config) error {\n\t// Enforce required config fields.\n\tif config.DataBase == nil {\n\t\treturn NewBlockChainError(UnExpectedError, errors.New(\"Database is not config\"))\n\t}\n\tif config.ChainParams == nil {\n\t\treturn NewBlockChainError(UnExpectedError, errors.New(\"Chain parameters is not config\"))\n\t}\n\n\tblockchain.config = *config\n\n\t// Initialize the chain state from the passed database. When the db\n\t// does not yet contain any chain state, both it and the chain state\n\t// will be initialized to contain only the genesis block.\n\tif err := blockchain.initChainState(); err != nil {\n\t\treturn err\n\t}\n\n\tblockchain.cQuitSync = make(chan struct{})\n\tblockchain.syncStatus.Shards = make(map[byte]struct{})\n\tblockchain.syncStatus.PeersState = make(map[libp2p.ID]*peerState)\n\tblockchain.syncStatus.IsReady.Shards = make(map[byte]bool)\n\treturn nil\n}", "title": "" }, { "docid": "00fc9eb8a9d129e596d5653594294325", "score": "0.4759394", "text": "func Init(repo string) error {\n\tif err := subvolumeCreate(repo); err != nil {\n\t\treturn err\n\t}\n\tif err := subvolumeCreate(path.Join(repo, \"master\")); err != nil {\n\t\treturn err\n\t}\n\tif err := SetMeta(path.Join(repo, \"master\"), \"branch\", \"master\"); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "c479b57262b00af1f2c49a5a6b1ced9f", "score": "0.47583973", "text": "func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response {\n\n\t// TODO - Include all initialization to be complete before Invoke and Query\n\t// Uses aucTables to delete tables if they exist and re-create them\n\n\t//myLogger.Info(\"[Trade and Auction Application] Init\")\n\tfmt.Println(\"[Trade and Auction Application] Init\")\n\tfmt.Println(\"\\nInit() Initialization Complete \")\n\treturn shim.Success(nil)\n}", "title": "" }, { "docid": "227537f474734809e057ad06a88b4de3", "score": "0.4751284", "text": "func Setup(isCheckTx bool) *SimApp {\n\tdb := dbm.NewMemDB()\n\tapp := NewSimApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, MakeTestEncodingConfig(), EmptyAppOptions{})\n\tif !isCheckTx {\n\t\t// init chain must be called to stop deliverState from being nil\n\t\tgenesisState := NewDefaultGenesisState()\n\n\t\t// add root admin\n\t\tpermGenState := perm.GetGenesisStateFromAppState(app.appCodec, genesisState)\n\t\tpermGenState.RoleAccounts = append(permGenState.RoleAccounts,\n\t\t\tperm.RoleAccount{\n\t\t\t\tAddress: sdk.AccAddress(tmhash.SumTruncated([]byte(\"rootAdmin\"))).String(),\n\t\t\t\tRoles: []perm.Role{perm.RoleRootAdmin},\n\t\t\t})\n\t\tpermGenStateBz := app.cdc.MustMarshalJSON(permGenState)\n\t\tgenesisState[perm.ModuleName] = permGenStateBz\n\n\t\t// add root cert\n\t\tvalidatorGenState := node.GetGenesisStateFromAppState(app.appCodec, genesisState)\n\t\tvalidatorGenState.RootCert = rootCert\n\t\tvalidatorGenStateBz := app.cdc.MustMarshalJSON(validatorGenState)\n\t\tgenesisState[node.ModuleName] = validatorGenStateBz\n\n\t\tstateBytes, err := codec.MarshalJSONIndent(app.cdc, genesisState)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\t// Initialize the chain\n\t\tapp.InitChain(\n\t\t\tabci.RequestInitChain{\n\t\t\t\tValidators: []abci.ValidatorUpdate{},\n\t\t\t\tConsensusParams: DefaultConsensusParams,\n\t\t\t\tAppStateBytes: stateBytes,\n\t\t\t},\n\t\t)\n\t}\n\n\treturn app\n}", "title": "" }, { "docid": "3cc17db3716c38c59cd610019b026c67", "score": "0.47468528", "text": "func (bc *BeaconChain) InitRPCServer() {\n\tbc.rpcServer = beaconchain.NewServer(bc.GetShardLeaderMap)\n}", "title": "" }, { "docid": "e64997aefa6d0700aa2f6054a71b4104", "score": "0.47464964", "text": "func Init() *Server {\n\ts := &Server{\n\t\tGoServer: &goserver.GoServer{},\n\t\tconfig: &pb.Config{},\n\t}\n\treturn s\n}", "title": "" }, { "docid": "d54089f315a60586091a63b26604dd88", "score": "0.4740277", "text": "func (p *ProtocolV0) InitChainer(ctx sdk.Context, DeliverTx sdk.DeliverTx, req abci.RequestInitChain) abci.ResponseInitChain {\n\tstateJSON := req.AppStateBytes\n\n\tvar genesisFileState GenesisFileState\n\tp.cdc.MustUnmarshalJSON(stateJSON, &genesisFileState)\n\n\tgenesisState := convertToGenesisState(genesisFileState)\n\t// sort by account number to maintain consistency\n\tsort.Slice(genesisState.Accounts, func(i, j int) bool {\n\t\treturn genesisState.Accounts[i].AccountNumber < genesisState.Accounts[j].AccountNumber\n\t})\n\n\t// load the accounts\n\tfor _, gacc := range genesisState.Accounts {\n\t\tacc := gacc.ToAccount()\n\t\tacc.AccountNumber = p.accountMapper.GetNextAccountNumber(ctx)\n\t\tp.accountMapper.SetGenesisAccount(ctx, acc)\n\t}\n\n\t//upgrade.InitGenesis(ctx, p.upgradeKeeper, p.Router(), genesisState.UpgradeData)\n\n\t// load the initial stake information\n\tvalidators, err := stake.InitGenesis(ctx, p.StakeKeeper, genesisState.StakeData)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tgov.InitGenesis(ctx, p.govKeeper, genesisState.GovData)\n\tauth.InitGenesis(ctx, p.feeKeeper, p.accountMapper, genesisState.AuthData)\n\tslashing.InitGenesis(ctx, p.slashingKeeper, genesisState.SlashingData, genesisState.StakeData)\n\tmint.InitGenesis(ctx, p.mintKeeper, genesisState.MintData)\n\tdistr.InitGenesis(ctx, p.distrKeeper, genesisState.DistrData)\n\tservice.InitGenesis(ctx, p.serviceKeeper, genesisState.ServiceData)\n\tguardian.InitGenesis(ctx, p.guardianKeeper, genesisState.GuardianData)\n\tupgrade.InitGenesis(ctx, p.upgradeKeeper, genesisState.UpgradeData)\n\n\t// load the address to pubkey map\n\terr = IrisValidateGenesisState(genesisState)\n\tif err != nil {\n\t\tpanic(err) // TODO find a way to do this w/o panics\n\t}\n\n\tif len(genesisState.GenTxs) > 0 {\n\t\tfor _, genTx := range genesisState.GenTxs {\n\t\t\tvar tx auth.StdTx\n\t\t\terr = p.cdc.UnmarshalJSON(genTx, &tx)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\tbz := p.cdc.MustMarshalBinaryLengthPrefixed(tx)\n\t\t\tres := DeliverTx(bz)\n\t\t\tif !res.IsOK() {\n\t\t\t\tpanic(res.Log)\n\t\t\t}\n\t\t}\n\n\t\tvalidators = p.StakeKeeper.ApplyAndReturnValidatorSetUpdates(ctx)\n\t}\n\n\t// sanity check\n\tif len(req.Validators) > 0 {\n\t\tif len(req.Validators) != len(validators) {\n\t\t\tpanic(fmt.Errorf(\"len(RequestInitChain.Validators) != len(validators) (%d != %d)\",\n\t\t\t\tlen(req.Validators), len(validators)))\n\t\t}\n\t\tsort.Sort(abci.ValidatorUpdates(req.Validators))\n\t\tsort.Sort(abci.ValidatorUpdates(validators))\n\t\tfor i, val := range validators {\n\t\t\tif !val.Equal(req.Validators[i]) {\n\t\t\t\tpanic(fmt.Errorf(\"validators[%d] != req.Validators[%d] \", i, i))\n\t\t\t}\n\t\t}\n\t}\n\treturn abci.ResponseInitChain{\n\t\tValidators: validators,\n\t}\n}", "title": "" }, { "docid": "edfe598a207064ba7337479c0ce4246f", "score": "0.47398737", "text": "func InitSoftForks(req map[string]interface{}) (interface{}, error) {\n\n\treturn true, nil\n}", "title": "" }, { "docid": "0b0b78e527704a89589ee08f2acf95a6", "score": "0.47176853", "text": "func (m *MockStateStore) Init(metadata state.Metadata) error {\n\targs := m.Called(metadata)\n\treturn args.Error(0)\n}", "title": "" }, { "docid": "747724f62b4b46e54e48e171647e2fce", "score": "0.47152096", "text": "func (persist *NameToIdxPersist) Init() error {\n\tpersist.syncCh = make(chan bool)\n\tpersist.syncAckCh = make(chan error)\n\n\toffset := rand.Int63n(int64(persist.config.PersistentStorage.MaxSyncStartDelay))\n\tgo persist.periodicIdxMapSync(time.Duration(offset))\n\n\treturn nil\n}", "title": "" }, { "docid": "fc9ba7d33ebfc6384b0e2f887c223567", "score": "0.47148702", "text": "func InitWorkerServer() *WorkerServer {\n\treturn &WorkerServer{}\n}", "title": "" }, { "docid": "662395c2dd02d254ad51fa7d160b1548", "score": "0.47121254", "text": "func (s *Store) Start() {\n\tlog.Infof(\"bootstrap: begin to start store %d\", s.id)\n\n\tgo s.startTransfer()\n\t<-s.trans.server.Started()\n\tlog.Infof(\"bootstrap: transfer started\")\n\n\ts.startHandleNotifyMsg()\n\tlog.Infof(\"bootstrap: ready to handle raft message\")\n\n\ts.startStoreHeartbeatTask()\n\tlog.Infof(\"bootstrap: ready to handle store heartbeat\")\n\n\ts.startCellHeartbeatTask()\n\tlog.Infof(\"bootstrap: ready to handle cell heartbeat\")\n\n\ts.startGCTask()\n\tlog.Infof(\"bootstrap: ready to handle gc task\")\n\n\ts.startCellSplitCheckTask()\n\tlog.Infof(\"bootstrap: ready to handle split check task\")\n\n\ts.startCellReportTask()\n\tlog.Infof(\"bootstrap: ready to handle report cell task\")\n}", "title": "" }, { "docid": "79bafa6164b0ac4c98e68f99acf2ce7e", "score": "0.47111997", "text": "func Init(rootPath AbsPath, spec ClusterSpec) (Manager, error) {\n\treturn initManager(rootPath, spec, afero.NewOsFs())\n}", "title": "" }, { "docid": "7162d8d6be992ebe30ac39319427915a", "score": "0.47093868", "text": "func Init() {\n\t// utils\n\tutils.InitEnvVars()\n\n\t// services\n\tdb.InitService()\n\tdb.GetClient().FillSeedsInformation() // a bit ugly but everything is going to work, only needed to fill seeds information\n\n\t// workers\n\tcrawler.Start()\n\n\tr := NewRouter()\n\t// r.Run(\":6969\")\n\tr.Run(\":80\")\n}", "title": "" }, { "docid": "942f4e0433aeb88496c10e3646c75c31", "score": "0.47092608", "text": "func (f *TCPServer) Init() {\n\tf.syncMtx.Lock()\n\tf.clients = list.New()\n\tf.syncMtx.Unlock()\n}", "title": "" }, { "docid": "e6f2b83c31f120d54d3741ce8d58e03a", "score": "0.47064984", "text": "func (tc *Tester) InitServer(rawConfig string, configType string) {\n\tif err := tc.initServer(rawConfig, configType); err != nil {\n\t\ttc.t.Logf(\"failed to load config: %s\", err)\n\t\ttc.t.Fail()\n\t}\n\tif err := tc.ensureConfigRunning(rawConfig, configType); err != nil {\n\t\ttc.t.Logf(\"failed ensuring config is running: %s\", err)\n\t\ttc.t.Fail()\n\t}\n}", "title": "" }, { "docid": "94115631a1259a83f2761c1396f577d4", "score": "0.47064313", "text": "func Initialization(initialContext *context.InitialContext) (ctx *context.Context, err error) {\n\n\tctx = context.New()\n\tctx.DisableLimiter = initialContext.DisableLimiter\n\tctx.DisableRecaptcha = initialContext.DisableRecaptcha\n\tctx.DisableSend = initialContext.DisableSend\n\n\tif initialContext.LocalExecution {\n\t\tlog.Printf(\"loading from config file %s\", initialContext.ConfigFile)\n\t\tctx.Cfg, err = config.GetConfigFromFile(initialContext.ConfigFile)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tlog.Printf(\"loading config from environment variables\")\n\t\tctx.Cfg, err = config.GetConfigFromENV()\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\n\tprintCfg := *ctx.Cfg\n\tprintCfg.PrivateKey = redact(printCfg.PrivateKey)\n\tprintCfg.RedisEndpoint = redact(printCfg.RedisEndpoint)\n\tprintCfg.RedisPassword = redact(printCfg.RedisPassword)\n\tprintCfg.RecaptchaSecret = redact(printCfg.RecaptchaSecret)\n\tlog.Printf(\"%+v\", printCfg)\n\n\tif initialContext.DisableRDb {\n\t\tctx.Store, err = createMemStore()\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tctx.Store, err = createRedisStore(ctx)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\n\t}\n\n\tctx.Cdc = app.MakeCodec()\n\n\terr = ctx.GetTestnetName()\n\tif err != nil {\n\t\tlog.Print(\"underlying full node seems to have issues\")\n\t\treturn\n\t}\n\n\tlog.Printf(\"config loaded, testnet name: %s\", ctx.TestnetName)\n\n\tctx.SequenceMutex = sync.Mutex{\n\t\tName: fmt.Sprintf(\"%s-%s-sequence\", ctx.Cfg.ApiEnvironment, ctx.TestnetName),\n\t\tAWSRegion: ctx.Cfg.AWSRegion,\n\t\tExpiry: 60 * time.Second,\n\t}.WithTimeout(70 * time.Second)\n\n\tctx.AccountNumberMutex = sync.Mutex{\n\t\tName: fmt.Sprintf(\"%s-%s-accountnumber\", ctx.Cfg.ApiEnvironment, ctx.TestnetName),\n\t\tAWSRegion: ctx.Cfg.AWSRegion,\n\t\tExpiry: 1 * time.Second,\n\t}.WithTimeout(3 * time.Second)\n\n\tctx.BrokenFlagMutex = sync.Mutex{\n\t\tName: fmt.Sprintf(\"%s-%s-brokenflag\", ctx.Cfg.ApiEnvironment, ctx.TestnetName),\n\t\tAWSRegion: ctx.Cfg.AWSRegion,\n\t\tExpiry: 1 * time.Second,\n\t}.WithTimeout(3 * time.Second)\n\n\terr = ctx.CheckAndFixAccountDetails()\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// This is not really a Mutex. We use the Mutex as a database store:\n\t// read the value once and reuse it without checking the database.\n\tctx.AccountNumberMutex.Lock()\n\tctx.AccountNumberMutex.Unlock()\n\n\t// Create CLIContext\n\tcliContext := sdkCtx.NewCLIContext().\n\t\tWithCodec(ctx.Cdc).\n\t\tWithLogger(os.Stdout).\n\t\tWithAccountDecoder(authcmd.GetAccountDecoder(ctx.Cdc)).\n\t\tWithNodeURI(ctx.Cfg.Node)\n\tctx.CLIContext = &cliContext\n\n\t// Create TxContest\n\ttxCtx := authctx.TxContext{\n\t\tChainID: ctx.TestnetName,\n\t\tGas: 20000,\n\t}.WithCodec(ctx.Cdc)\n\tctx.TxContest = &txCtx\n\n\t// Create Throttled limiter\n\terr = createThrottledLimiter(ctx)\n\tif err != nil {\n\t\treturn\n\t}\n\n\trecaptcha.Init(ctx.Cfg.RecaptchaSecret)\n\n\tlog.Print(\"initialized context\")\n\n\treturn\n}", "title": "" }, { "docid": "e826c77125148dbd49248ffa633f6acb", "score": "0.4700007", "text": "func (self *StaticWorkloadServices) Init() *StaticWorkloadServices {\n\tif self.StaticWorkloadServices == nil {\n\t\tself.StaticWorkloadServices = make([]*StaticWorkloadService, 0)\n\t}\n\treturn self\n}", "title": "" }, { "docid": "54c74bb383050d111cbc4bfe940dff2c", "score": "0.46980122", "text": "func (s *StateMachine) Initialize() error {\n if s.Initialized == true {\n err := fmt.Errorf(\"StateMachine is already initialized.\")\n\n return err\n }\n\n errC := make(chan error)\n\n s.ExecSync(\"init::start\", s, errC)\n\n // Funcs are initialized\n s.Initialized = true\n s.State.Switch(FOLLOWER)\n s.Timer.Start()\n s.Exec(\"init::done\")\n\n // TODO: catch ERR\n // Catch optionnal errors\n // It will block if some functions blocks\n //for _, _ = range s.Init {\n //err := <- errC\n //if err != nil {\n //s.Initialized = false\n //return err\n //}\n //}\n\n return nil\n}", "title": "" }, { "docid": "e87dc85830ccd87c0e2441486c0069fa", "score": "0.46939966", "text": "func (t *SharedDataService) Init(stub shim.ChaincodeStubInterface) pb.Response {\n\treturn shim.Success(nil)\n}", "title": "" }, { "docid": "103535fce68cd6b8d9e04f8d50bb54b9", "score": "0.4693079", "text": "func (n *Network) Bootstrap(workspace string) error {\n\t// Network bootstrapping is disabled by default as it's intended to be run\n\t// on demand only but not by CI for now.\n\t// To enable it: go test -v ./... -args -enable\n\tif !*EnableHarness {\n\t\tlog.Println(\"Test Harness bootstrapping is disabled.\")\n\t\tlog.Println(\"To enable it: `go test -v ./... -args -enable`\")\n\t\treturn ErrDisabledHarness\n\t}\n\n\tinitProfiles()\n\n\t_, utilsExec, seederExec, err := n.getExec()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Start voucher seeder.\n\tif len(seederExec) > 0 {\n\t\tif err := n.start(workspace, seederExec); err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\t// If path not provided, then it's assumed that the seeder is already running.\n\t\tlog.Warnf(\"Seeder path not provided. Please, ensure dusk-seeder is already running\")\n\t}\n\n\tif MOCK_ADDRESS != \"\" {\n\t\t// Run mock process\n\t\tif bbErr := n.start(workspace, utilsExec, \"mock\",\n\t\t\t\"--grpcmockhost\", MOCK_ADDRESS,\n\t\t); bbErr != nil {\n\t\t\treturn bbErr\n\t\t}\n\t}\n\n\t// Foreach node read localNet.Nodes, configure and run new nodes\n\tfor i, node := range n.nodes {\n\t\tif err := n.StartNode(i, node, workspace); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// avoid stressing dusk-seeder\n\t\ttime.Sleep(time.Duration(1) * time.Second)\n\t}\n\n\tlog.Infof(\"Local network workspace: %s\", workspace)\n\tlog.Infof(\"Running %d nodes\", len(n.nodes))\n\n\t// Allow network nodes to complete their startup procedures\n\tdelay := 2 * len(n.nodes)\n\tif delay > 20 {\n\t\tdelay = 20\n\t}\n\n\ttime.Sleep(time.Duration(delay) * time.Second)\n\treturn nil\n}", "title": "" }, { "docid": "b159df72e9c98ca0d7224114ea9ebbe7", "score": "0.4692783", "text": "func (m *Machine) WaitForInitContainerRunning(namespace, podName, containerName string) error {\n\treturn wait.PollImmediate(m.PollInterval, m.PollTimeout, func() (bool, error) {\n\t\treturn m.InitContainerRunning(namespace, podName, containerName)\n\t})\n}", "title": "" }, { "docid": "4631bb8d3deba7353e7c3dae0b29cddf", "score": "0.4689545", "text": "func InitBoot() {\n\tfor k, pth := range directorys {\n\t\tif !path.Available(pth) {\n\t\t\tlog.Errorf(\"path[%s]: %s not accessible\", directorys[k], pth)\n\t\t\tlog.Infof(\"Creating Folder %s\", pth)\n\t\t\tif err := os.MkdirAll(pth, 0700); err != nil {\n\t\t\t\tlog.Errorf(\"path[%s]: %s cannot create folder\", k, pth)\n\t\t\t}\n\t\t} else {\n\t\t\tlog.Infof(\"path[%s]: %s\", directorys[k], pth)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "ab83c6d91ae53afeded428616a07474f", "score": "0.4688102", "text": "func (b *Bootstrapper) Startup() error {\n\tif b.pendingAcceptedFrontier.Len() == 0 {\n\t\tb.Ctx.Log.Info(\"Bootstrapping skipped due to no provided bootstraps\")\n\t\treturn b.Bootstrapable.ForceAccepted(ids.Set{})\n\t}\n\n\t// Ask each of the bootstrap validators to send their accepted frontier\n\tvdrs := ids.ShortSet{}\n\tvdrs.Union(b.pendingAcceptedFrontier)\n\n\tb.RequestID++\n\tb.Sender.GetAcceptedFrontier(vdrs, b.RequestID)\n\treturn nil\n}", "title": "" }, { "docid": "e1c6ec462a4af0c6b2167027ea21eb4c", "score": "0.46867496", "text": "func Init(ctx context.Context, input InitInput) {\n\tlog.Logf(\"clusterctl init --core %s --bootstrap %s --control-plane %s --infrastructure %s\",\n\t\tinput.CoreProvider,\n\t\tstrings.Join(input.BootstrapProviders, \", \"),\n\t\tstrings.Join(input.ControlPlaneProviders, \", \"),\n\t\tstrings.Join(input.InfrastructureProviders, \", \"),\n\t)\n\n\tinitOpt := clusterctlclient.InitOptions{\n\t\tKubeconfig: clusterctlclient.Kubeconfig{\n\t\t\tPath: input.KubeconfigPath,\n\t\t\tContext: \"\",\n\t\t},\n\t\tCoreProvider: input.CoreProvider,\n\t\tBootstrapProviders: input.BootstrapProviders,\n\t\tControlPlaneProviders: input.ControlPlaneProviders,\n\t\tInfrastructureProviders: input.InfrastructureProviders,\n\t\tLogUsageInstructions: true,\n\t}\n\n\tclusterctlClient, log := getClusterctlClientWithLogger(input.ClusterctlConfigPath, \"clusterctl-init.log\", input.LogFolder)\n\tdefer log.Close()\n\n\t_, err := clusterctlClient.Init(initOpt)\n\tExpect(err).ToNot(HaveOccurred(), \"failed to run clusterctl init\")\n}", "title": "" }, { "docid": "17dcd7d59604f68851c38e66a9436a01", "score": "0.46865538", "text": "func initalize(webPort string, isLocal bool, isDemo bool) {\n\tport = webPort\n\tisLocalhost = isLocal\n\n\t// for local box.\n\tif isLocal {\n\t\tmesos.Host = \"192.168.33.3\"\n\t\tdnsSufix = \"\"\n\t} else {\n\t\t// for gcp\n\t\tmesos.Host = \"localhost\"\n\t\t// clean sensitive data.\n\t}\n\n\tif isDemo {\n\t\t// clean sensitive data ...\n\t}\n\n\tfetcher.Init()\n}", "title": "" }, { "docid": "30af9936ea56652516f04705b10dc9c4", "score": "0.46862635", "text": "func (c *DaemonSetController) Initialize(cd *flaggerv1.Canary) (err error) {\n\terr = c.createPrimaryDaemonSet(cd, c.includeLabelPrefix)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"createPrimaryDaemonSet failed: %w\", err)\n\t}\n\n\tif cd.Status.Phase == \"\" || cd.Status.Phase == flaggerv1.CanaryPhaseInitializing {\n\t\tif !cd.SkipAnalysis() {\n\t\t\tif err := c.IsPrimaryReady(cd); err != nil {\n\t\t\t\treturn fmt.Errorf(\"%w\", err)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "5886de87964273a9f06ba75209eb3e04", "score": "0.46854433", "text": "func (cs *ChaincodeSupport) LaunchInit(ccci *ccprovider.ChaincodeContainerInfo) error {\n\tcname := ccci.Name + \":\" + ccci.Version\n\tif cs.HandlerRegistry.Handler(cname) != nil {\n\t\treturn nil\n\t}\n\n\treturn cs.Launcher.Launch(ccci)\n}", "title": "" }, { "docid": "7876488472d88991dfc60dfa58243452", "score": "0.46853638", "text": "func Init(c *conf.Config, s *service.Service) {\n\tsvr = s\n\tverifySvc = verify.New(c.Verify)\n\tengine := bm.DefaultServer(c.BM)\n\troute(engine)\n\tif err := engine.Start(); err != nil {\n\t\tlog.Error(\"engine.Start error(%v)\", err)\n\t\tpanic(err)\n\t}\n}", "title": "" }, { "docid": "dff5948a9dc2583505464a47a5416421", "score": "0.46845105", "text": "func (service *Generic) Init() error {\n\n\t// Make sure we have the binary we need\n\tif _, err := os.Stat(filepath.Join(service.Workspace(), service.Name())); err != nil {\n\t\tlog.Info().Msgf(\"Existing %s binary not found\", strings.Title(service.Name()))\n\t\terr := service.Download()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// create our datadir if it does not exist\n\tif _, err := os.Stat(service.Datadir); err != nil {\n\t\terr = os.Mkdir(service.Datadir, 0755)\n\t\tif err != nil {\n\t\t\tlog.Error().Err(err).Msgf(\"Could not create %s data dir:\", service.Name())\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n\n}", "title": "" }, { "docid": "21fc41aabf7b57731b35ad190d67186f", "score": "0.46825778", "text": "func (p *Peers) Init() {\n\tpeers := pex.NewPex(p.Config.Max)\n\tif p.Config.Ephemerial == false {\n\t\terr := peers.Load(p.Config.DataDirectory)\n\t\tif err != nil {\n\t\t\tlogger.Notice(\"Failed to load peer database\")\n\t\t\tlogger.Notice(\"Reason: %v\", err)\n\t\t}\n\t}\n\n\tlogger.Debug(\"Init peers\")\n\tp.Peers = peers\n}", "title": "" } ]
b543e3e838f6ee8658218f398bbfde8f
WriteResponse to the client
[ { "docid": "d6e8e4dd73b7b6710a1a7fbc57ff849f", "score": "0.0", "text": "func (o *ListCoreV1ResourceQuotaForAllNamespacesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(401)\n}", "title": "" } ]
[ { "docid": "5f54a58752c5b9126e950514c9674def", "score": "0.78442043", "text": "func WriteResponse(w http.ResponseWriter, httpStatus int, data model.GlobalResponse) {\n\tdata.Timestamp = time.Now()\n\tjs, err := json.MarshalIndent(data, \"\", \" \")\n\tif err != nil {\n\t\tlog.Error(\"Could not marshal http write data: \", data)\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Set response content type\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(httpStatus)\n\tw.Write(js)\n\treturn\n}", "title": "" }, { "docid": "5b2e333c49379bf963f5d4d1533c5e37", "score": "0.7788614", "text": "func (o *AddUserOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "5a5c3b712a0b4d1ced72e67adf660c94", "score": "0.7788584", "text": "func (o *AuthUserOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "9659ff6cb63492f2f7f0ff256182ecb6", "score": "0.7753117", "text": "func (o *PingOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "1be27a8fc6c890a74f4c21c46b821d40", "score": "0.77477926", "text": "func writeResponse(w http.ResponseWriter, message string, status int) {\n\tw.WriteHeader(status)\n\tjson.NewEncoder(w).Encode(Response{Message: message, HTTPStatus: status})\n}", "title": "" }, { "docid": "97ee3687ce31cecb416d8b12dea06dca", "score": "0.77178353", "text": "func WriteResponse(w http.ResponseWriter, code int, data interface{}) {\n\tj, _ := json.Marshal(data)\n\tw.WriteHeader(code)\n\tw.Write(j)\n}", "title": "" }, { "docid": "2e63c0ac6ad1cad49a2160e1d6ff594a", "score": "0.76838505", "text": "func writeResponse(w http.ResponseWriter, r *Response, code int) {\n\tif code == http.StatusNoContent || r == nil {\n\t\tw.WriteHeader(code)\n\t\treturn\n\t}\n\n\t// Marshal the data into a JSON string.\n\tjsonData, err := json.Marshal(r)\n\tif err != nil {\n\t\tlog.Printf(\"Request Error: marshaling response, %+v\", err)\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(jsonData)\n}", "title": "" }, { "docid": "fbb890e78880fb52fdf57e3d5decff26", "score": "0.7666609", "text": "func writeResponse(w http.ResponseWriter, r *Request, response interface{}, e error) (err error) {\n\n\t// Dump meta-data headers\n\tw.Header().Set(HeaderProcessingTime, fmt.Sprintf(\"%.03f\", time.Since(r.StartTime).Seconds()*1000))\n\tw.Header().Set(HeaderRequestId, r.RequestId)\n\n\t// Dump Error if the request failed\n\tif e != nil {\n\t\tcode, message := httpError(e)\n\t\thttp.Error(w, message, code)\n\t\treturn\n\t}\n\n\tvar buf []byte\n\tbuf, err = json.Marshal(response)\n\tif err == nil {\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\n\t\tif r.Callback != \"\" {\n\t\t\tif _, err = fmt.Fprintf(w, \"%s(\", r.Callback); err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif _, err = w.Write(buf); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tif r.Callback != \"\" {\n\t\t\tif _, err = fmt.Fprintln(w, \");\"); err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "1aa0af264c6d3d751aff1551a08c8f5c", "score": "0.7644964", "text": "func (o *AddDeviceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "a1fc63ad76c614fa6d0f615e627a4e9f", "score": "0.7639846", "text": "func writeResponse(w http.ResponseWriter, res Response) {\n\tif res.Error != nil {\n\t\tlog.Error(w, res.Error)\n\t}\n\n\tif res.Certificate != nil {\n\t\tapi.LogCertificate(w, res.Certificate)\n\t}\n\n\tw.Header().Set(\"Content-Type\", contentHeader(res))\n\t_, _ = w.Write(res.Data)\n}", "title": "" }, { "docid": "e43ef6751eaf2f436f83f781ee10523d", "score": "0.7634974", "text": "func WriteResponse(w http.ResponseWriter, data interface{}, code int) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tj, _ := json.Marshal(data)\n\tw.Write(j)\n}", "title": "" }, { "docid": "2ebfffed298870288645b91f221f493e", "score": "0.7625152", "text": "func (o *PutServiceIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "4fe6021430a5faeaf89825995e052690", "score": "0.762342", "text": "func (o *GetClusterByIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "0fa170e16e8978a5a4783be66e060767", "score": "0.7616826", "text": "func (o *UploadTaskFileCreated) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(201)\n}", "title": "" }, { "docid": "e04d5c9883404aada3fdfc56fd8d645f", "score": "0.76137096", "text": "func (o *PostOperationsCreateConnectivityServiceCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "title": "" }, { "docid": "e4fbd3349739f7a014861d279eccd112", "score": "0.76131016", "text": "func (r *Response) write(w http.ResponseWriter, httpStatus int) {\n\tr.Version = Version\n\tw.Header().Set(\"Content-Type\", \"application/json;charset=utf-8\")\n\tw.WriteHeader(httpStatus)\n\tdata, _ := json.Marshal(r)\n\tw.Write(data)\n}", "title": "" }, { "docid": "634642d01eae3719508ca9f4d7fb8f9d", "score": "0.75757974", "text": "func (o *PostOperationsComputeP2PPathCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "title": "" }, { "docid": "a74383c8a7d32d826c5b46bf543c473d", "score": "0.756636", "text": "func (o *PingDefault) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(o._statusCode)\n}", "title": "" }, { "docid": "40f8c2116e3818b04c0ad911fbfde8af", "score": "0.7563151", "text": "func (o *PostDataSomeKeyPathOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "d03533aee6759f7dde2042128cfa3cb6", "score": "0.75510406", "text": "func (o *PutComposersIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "4e8e052fbd1abe180d6fe0e5220a1be8", "score": "0.75469345", "text": "func (o *AddCarCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(201)\n}", "title": "" }, { "docid": "48917c1ea37e59ca56bdde0db6b7e8cb", "score": "0.7545381", "text": "func (c *Controller) writeResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\t// as of now, just log errors for writing response\n\tif err != nil {\n\t\t// logger.Errorf(\"Unable to send error response, %s\", err)\n\t\tfmt.Printf(\"Unable to send error response, %s\\n\", err)\n\t}\n}", "title": "" }, { "docid": "f1c20a7bb40097cab8e185680d3075ec", "score": "0.7543838", "text": "func (o *A1ControllerGetHealthcheckOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "af0862b70b0972dfb54b3824930931e6", "score": "0.7543638", "text": "func (o *PutPiecesIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "f7d477c2a48b3e38e9a70ac943803644", "score": "0.75382906", "text": "func (r codecRequest) WriteResponse(w http.ResponseWriter, x interface{}) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\trep := reply{\n\t\tCode: 200,\n\t\tData: x,\n\t}\n\tenc := json.NewEncoder(w)\n\tenc.Encode(&rep)\n}", "title": "" }, { "docid": "71585df58b6656f6b33895269e55b3ed", "score": "0.7529468", "text": "func Write(w http.ResponseWriter, response Response) error {\n\tw.WriteHeader(response.HTTPStatus())\n\tbody, err := response.Marshal()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Error marshaling response\")\n\t}\n\tw.Write(body)\n\treturn nil\n}", "title": "" }, { "docid": "c574648c6b8e21655fbf134f87297711", "score": "0.75257885", "text": "func (o *PostOperationsGetOamServiceEndPointCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "title": "" }, { "docid": "eb6c577dc1bcf7998fa28cb485d3769f", "score": "0.7521694", "text": "func (r *FileResponder) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\trw.Header().Set(\"Content-Type\", r.contType)\n\trw.Header().Set(\"Content-Length\", strconv.Itoa(len(r.content)))\n\trw.Header().Set(\"Content-Disposition\", `attachment; filename=\"`+r.name+`\"`)\n\trw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\trw.Header().Set(\"Access-Control-Allow-Methods\", \"POST, PUT, GET, OPTIONS, DELETE\")\n\trw.Header().Set(\"Access-Control-Allow-Headers\", \"X-Api-Key, Content-Type\")\n\n\trw.WriteHeader(http.StatusOK)\n\n\tif _, err := rw.Write(r.content); err != nil {\n\t\tpanic(err)\n\t}\n}", "title": "" }, { "docid": "47e64c56c1dd56e9a56111698c07b549", "score": "0.75206137", "text": "func (o *IsAuthOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "86b5abee4fff961cacbe247a80e1c0d1", "score": "0.7519822", "text": "func (o *PostControlMessageForDeviceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "1d76513e89352fac5e95428587218fc7", "score": "0.75196433", "text": "func (o *UpdateFacilityUserOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "bd6b9646e0a03854f5cc22a5dc7e2360", "score": "0.75160336", "text": "func writeResponse(w http.ResponseWriter, code int, body interface{}) error {\n\tb, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn err\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(b)\n\treturn nil\n}", "title": "" }, { "docid": "3ca67541918afe8a6722fed995c843cc", "score": "0.75110567", "text": "func (o *UploadTaskFileDefault) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(o._statusCode)\n}", "title": "" }, { "docid": "a181444bbc5226360c788f53191776bf", "score": "0.7504535", "text": "func WriteResponse(w http.ResponseWriter, code int, data interface{}) {\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\terr := json.NewEncoder(w).Encode(data)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}", "title": "" }, { "docid": "ce571106460fe70af06a4c39e9bc2bde", "score": "0.7494259", "text": "func (o *DeviceReadingsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "title": "" }, { "docid": "d61f22d7ee159c045f5bf437a466df07", "score": "0.74906754", "text": "func (o *PostOperationsGetConnectivityServiceAuditListCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "title": "" }, { "docid": "56e5ad7ce863e61097553a63583d1a9d", "score": "0.74882704", "text": "func WriteResponse(w http.ResponseWriter, r *http.Request, resp *discovery.Response, obj interface{}) {\n\tif resp != nil && resp.GetCode() != discovery.ResponseSuccess {\n\t\tWriteError(w, resp.GetCode(), resp.GetMessage())\n\t\treturn\n\t}\n\n\tif obj == nil {\n\t\tw.Header().Set(HeaderContentType, ContentTypeText)\n\t\tw.WriteHeader(http.StatusOK)\n\t\treturn\n\t}\n\n\tutil.SetRequestContext(r, CtxResponseObject, obj)\n\n\tvar (\n\t\tdata []byte\n\t\terr error\n\t)\n\tswitch body := obj.(type) {\n\tcase []byte:\n\t\tdata = body\n\tdefault:\n\t\tdata, err = codec.Encode(body)\n\t\tif err != nil {\n\t\t\tWriteError(w, discovery.ErrInternal, err.Error())\n\t\t\treturn\n\t\t}\n\t}\n\tw.Header().Set(HeaderContentType, ContentTypeJSON)\n\tw.WriteHeader(http.StatusOK)\n\t_, err = w.Write(data)\n\tif err != nil {\n\t\tlog.Error(\"write response failed\", err)\n\t}\n}", "title": "" }, { "docid": "a7947824ebccd6d0605da696056a17cb", "score": "0.7483943", "text": "func WriteResponse(c appengine.Context, w http.ResponseWriter,\n\tr *http.Request, bytes []byte) {\n\n\t_, err := w.Write(bytes)\n\n\tif err != nil {\n\t\tLog(c, r, \"error\", \"Failed to write: %v\", err.Error())\n\t\tLog(c, r, \"info\", \"Message was: %v\", string(bytes))\n\t}\n}", "title": "" }, { "docid": "3818b4e60d0132ba429540c868ffe5e5", "score": "0.7476084", "text": "func (o *PeerCreateCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Location\n\n\tlocation := o.Location\n\tif location != \"\" {\n\t\trw.Header().Set(\"Location\", location)\n\t}\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "title": "" }, { "docid": "c51af5128fc092e35ddf2ab1d8bd384b", "score": "0.7465029", "text": "func WriteResponse(rw http.ResponseWriter, res ferry.Response, contentType string) {\n\tif contentType != \"\" {\n\t\trw.Header().Set(\"Content-Type\", contentType)\n\t}\n\tstatus, payload := res.Response()\n\trw.WriteHeader(status)\n\trw.Write([]byte(payload))\n}", "title": "" }, { "docid": "bf310a747a18d5b278f71fe9b4f2fae2", "score": "0.7464533", "text": "func (o *UpdateDiscoveryIgnitionCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "title": "" }, { "docid": "3fce9a6fbfe15ad493b3c7b77effa301", "score": "0.74573857", "text": "func (o *SaleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "ac86ec021920d1cf5f4ef8adddfc964a", "score": "0.7452727", "text": "func writeResponse(w http.ResponseWriter, data interface{}, statusCode ...int) {\n\tstatus := 200\n\tif len(statusCode) > 0 && statusCode[0] != 0 {\n\t\tstatus = statusCode[0]\n\t}\n\n\tb, err := json.Marshal(data)\n\tif err != nil {\n\t\thttp.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.WriteHeader(status)\n\tw.Write(b)\n}", "title": "" }, { "docid": "70cdeb268dae2341b399bf4a88bb029f", "score": "0.7449866", "text": "func (o *PutServiceIDCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "title": "" }, { "docid": "aca2cc87482eb8efbae5898bb0dfff12", "score": "0.74490607", "text": "func (o *GetCharactersCharacterIDPlanetsPlanetIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "title": "" }, { "docid": "8555611fe13991b018c7197e156a8ce1", "score": "0.74480265", "text": "func (o *GetEventByIDDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(o._statusCode)\n}", "title": "" }, { "docid": "a54a030f6561b65c3dea3396bbe2f983", "score": "0.7446597", "text": "func (res APIResponse) Write(w http.ResponseWriter, r *http.Request) {\n\tif res.Status == \"ERROR\" {\n\t\tlog.Printf(\"[ERROR][API][PATH: %s]:: Error handling request. ERROR: %s. User agent: %s\", r.RequestURI, res.Error, r.Header.Get(\"User-Agent\"))\n\t}\n\tWriteJSON(w, res)\n}", "title": "" }, { "docid": "e158bf1aec8bdc308a36d9e081201a62", "score": "0.74443185", "text": "func (o *PostDataMessageForDeviceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "d7dc71323f4399f4160e056af7c6ed90", "score": "0.74392503", "text": "func (res *response) Write(b []byte) (int, error) {\n\tif !res.wroteHeader {\n\t\tres.WriteHeader(http.StatusOK)\n\t}\n\n\treturn res.ResponseWriter.Write(b)\n}", "title": "" }, { "docid": "b368f76767b9d3d85483f1d8caecf0df", "score": "0.74382955", "text": "func (o *DeleteComposersIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "cfd55b0299264c74848eaf1f6b447d60", "score": "0.7434204", "text": "func WriteResponse(w http.ResponseWriter, status int, payload interface{}) {\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(status)\n\t_ = json.NewEncoder(w).Encode(payload)\n}", "title": "" }, { "docid": "f18c08592413c3cf483092cc9ae44d60", "score": "0.7423474", "text": "func writeResponse(w http.ResponseWriter, response interface{}) error {\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\tjData, err := json.Marshal(response)\n\tif err != nil {\n\t\tlog.Printf(\"JSON marshalling for HTTP response failed. %s\", err)\n\t\treturn err\n\t}\n\n\tif _, err = w.Write(jData); err != nil {\n\t\tlog.Printf(\"Could not write response to HTTP ResponseWriter. %s\", err)\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "3d23cb60047a7a0a46bbc5457ad9331b", "score": "0.7420763", "text": "func WriteResponse(handler string, w http.ResponseWriter, v []byte, ct string, status int) {\n\t// Header must be set before status is written\n\tif len(v) > 0 {\n\t\tw.Header().Set(\"Content-Type\", ct)\n\t}\n\n\t// Header and status must be written before content is written\n\tw.WriteHeader(status)\n\tif len(v) > 0 {\n\t\tif _, err := w.Write(v); err != nil {\n\t\t\tLogAndReturnError(handler, http.StatusInternalServerError, err, w)\n\t\t}\n\t}\n}", "title": "" }, { "docid": "38c57f70e05068498a0b0e68fa8751e9", "score": "0.7419465", "text": "func (o *PostOperationsCreateConnectivityServiceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "title": "" }, { "docid": "992e4d4c42fc3ef15790965130dfc89f", "score": "0.74146134", "text": "func (w *response) Write(b []byte) (int, error) {\n\n\t// Default to 200 HTTP Status\n\tif !w.wroteHeader {\n\t\tw.WriteHeader(http.StatusOK)\n\t}\n\n\t// Append data to the body and set the wrote flag\n\tw.bodyBuffer.Write(b)\n\n\t// Done, return the response write function\n\treturn w.ResponseWriter.Write(b)\n}", "title": "" }, { "docid": "41255352af13f2dcb987b0aaae1946c9", "score": "0.7412214", "text": "func (o *PutKeysIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "9e835526803ebea2ee46ae440b9b3a15", "score": "0.74111885", "text": "func (r *Response) writeResponse(code int, v interface{}) error {\n\tif len(r.Headers) > 0 {\n\t\tr.writeHeaders()\n\t}\n\n\tr.writeStatusCode(code)\n\n\tif v != nil {\n\t\tbody, err := json.Marshal(v)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tif _, err := r.Writer.Write(body); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "439f8055639eb77513fe2d00987ec69f", "score": "0.7410203", "text": "func (o *PlacePurchaseCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "title": "" }, { "docid": "c074758fffe0b73aede914f9e8ae1e53", "score": "0.74101585", "text": "func (o *RefundsTidOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "0f2ab5251f7eeeaa54d462a22e3859ef", "score": "0.74100864", "text": "func (o *UpdatePaymentOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "21137a578f25b44ddc582dadd40fe088", "score": "0.7406279", "text": "func writeResponse(writer http.ResponseWriter, statusCode int, feedback string) {\n\twriter.WriteHeader(statusCode)\n\twriter.Write([]byte(feedback))\n}", "title": "" }, { "docid": "5d9b31e0c0c3531a82b262782ae57bc2", "score": "0.74059224", "text": "func (o *GetVmsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif err := producer.Produce(rw, o.Payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "title": "" }, { "docid": "2585f7c9058e83e61eb273754ab4e707", "score": "0.74039793", "text": "func (o *DeleteStockCompanyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "f2cd842ff03a9fcc4e9843167de3f74a", "score": "0.7403616", "text": "func (o *UpdateCertificateV3OK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "dc4ac890b9f6a61b35cb86b7d534123c", "score": "0.740121", "text": "func (o *PutChannelsViberChannelIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "title": "" }, { "docid": "57d34965eb3f0260d9dfd21d9b975eed", "score": "0.7400904", "text": "func (o *LoginUserOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Set-Cookie\n\n\tsetCookie := o.SetCookie\n\tif setCookie != \"\" {\n\t\trw.Header().Set(\"Set-Cookie\", setCookie)\n\t}\n\n\t// response header X-Request-Id\n\n\txRequestID := o.XRequestID\n\tif xRequestID != \"\" {\n\t\trw.Header().Set(\"X-Request-Id\", xRequestID)\n\t}\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "a039840fde770f512b93ed9aacf91fff", "score": "0.7395233", "text": "func WriteResponse(res http.ResponseWriter, status int, entity interface{}) {\n\tres.WriteHeader(status)\n\tif err := json.NewEncoder(res).Encode(entity); err != nil {\n\t\tlog.WithError(err).Error(\"unable to send response, the entity could not be encoded\")\n\t}\n}", "title": "" }, { "docid": "6c2f44af701b26539fbcdb067ee73b07", "score": "0.73931754", "text": "func (o *GetCredentialByIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "title": "" }, { "docid": "bb39cb9adf9dbcc77f4200adb09fa244", "score": "0.7387887", "text": "func (o *WeaviateThingsInsertNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "title": "" }, { "docid": "9ad0387cc484e99517fb9497cd5dcd12", "score": "0.73861986", "text": "func (o *PatchEndpointIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "a939d5664460d2116d4004b15dbaead1", "score": "0.7385323", "text": "func (o *ListPVCsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "title": "" }, { "docid": "7b451ac6b8eb331422c4c03a25b23547", "score": "0.73821056", "text": "func (o *PostOperationsGetConnectivityServiceAuditListOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "title": "" }, { "docid": "0acfe2ed4e0502a074923b6327190539", "score": "0.7382085", "text": "func (o *IndexTSPPsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Content-Range\n\n\tcontentRange := o.ContentRange\n\tif contentRange != \"\" {\n\t\trw.Header().Set(\"Content-Range\", contentRange)\n\t}\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\t// return empty array\n\t\tpayload = adminmessages.TransportationServiceProviderPerformances{}\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "title": "" }, { "docid": "7dae9192e5ff8e388271af394c7044c9", "score": "0.738177", "text": "func (o *GetCharactersCharacterIDClonesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "title": "" }, { "docid": "c6a4bc8bc0983b3529ccbf6b05ac6401", "score": "0.73757064", "text": "func (o *WeaviatePeersAnswersCreateNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "title": "" }, { "docid": "ce3e37a7d19b0c8386768d26ee3211eb", "score": "0.7375508", "text": "func (o *AddTagOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "807dbc75ec462b8bcc8159fc619b420c", "score": "0.73750913", "text": "func (o *PostPortsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "0b4b129732496d5bb56d79294285c00a", "score": "0.7373522", "text": "func (o *UpdatePostOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "85ec41458bc51d440158f1a4b317ddb4", "score": "0.73728293", "text": "func (o *PostOperationsCreateOamServiceEndPointCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "title": "" }, { "docid": "74fc8182b8350813f9abe8e7bb3a5c4f", "score": "0.7368112", "text": "func (o *GetMarketsRegionIDHistoryOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make(models.GetMarketsRegionIDHistoryOKBody, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "title": "" }, { "docid": "a54fe88769f6ed19ac3f3afe4fa88edd", "score": "0.7366081", "text": "func (w *responseWriter) Write(b []byte) (int, error) {\n\tif w.status == 0 {\n\t\tw.WriteHeader(http.StatusOK)\n\t}\n\treturn w.ResponseWriter.Write(b)\n}", "title": "" }, { "docid": "a05142a17ca07b63aae4c9203736c0d5", "score": "0.7364311", "text": "func (o *GetInventoryOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(200)\n\tif err := producer.Produce(rw, o.Payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "title": "" }, { "docid": "af5420d7101e9f6a65eb87b5e943e118", "score": "0.7363306", "text": "func (o *RegsitrarEntradaCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "title": "" }, { "docid": "fa10e644b2785c06fc855b9f7473ded5", "score": "0.73621273", "text": "func (o *AddTeamToTestOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "81f74e3421d70c7739d3ff5e2006a97d", "score": "0.73575866", "text": "func (o *GetTimeSlotsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "title": "" }, { "docid": "961f3fefa4f7dd02ce7006345a9e93d1", "score": "0.73532444", "text": "func (o *Operation) writeResponse(rw io.Writer, v interface{}) {\n\terr := json.NewEncoder(rw).Encode(v)\n\t// as of now, just log errors for writing response\n\tif err != nil {\n\t\tlogger.Errorf(\"Unable to send error response, %s\", err)\n\t}\n}", "title": "" }, { "docid": "0d357ef0ecdc257c3f78a36f3a576e68", "score": "0.7351236", "text": "func (o *GetClusterByIDOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tif err := producer.Produce(rw, o.Payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "title": "" }, { "docid": "d6ed16adbe85ca3e4a19e984601b7ae1", "score": "0.7348278", "text": "func (o *GetSpeakersDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(o._statusCode)\n}", "title": "" }, { "docid": "6a370c2de2854712d793832b049c3d68", "score": "0.73473805", "text": "func (o *SetQuestionCorrectedOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "8dae0eedf157534769616fd4b14699e1", "score": "0.7344473", "text": "func (o *AddVerysimpleCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "title": "" }, { "docid": "555dd75df0e725d3055e1b5825e3183b", "score": "0.7343157", "text": "func (o *PostOperationsCreateOamServiceCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(201)\n}", "title": "" }, { "docid": "8f3c98614c334c2661b4cc6ff5f3cbf2", "score": "0.7339136", "text": "func (o *PutLibrarianUsernameUserUserCheckoutOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "c339d7f7a2c857e84e8aebb201b8b10c", "score": "0.7335887", "text": "func (o *BookWriteOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "a4e51b58dc20f49186e7f163ed1f3dde", "score": "0.73301387", "text": "func (o *PostSendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "2d994ce86d331f5ba6709d4287445207", "score": "0.73247296", "text": "func (o *DeleteInventoryItemIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses\n\n\trw.WriteHeader(200)\n}", "title": "" }, { "docid": "24b0da3ad402d2bc0de7691fa206730c", "score": "0.73203826", "text": "func (o *WeaviateThingsListNotImplemented) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(501)\n}", "title": "" }, { "docid": "df8ee19345e63e97929b734a5879aa7c", "score": "0.7320352", "text": "func (o *UpdateUserPlantOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header X-Request-Id\n\n\txRequestID := o.XRequestID\n\tif xRequestID != \"\" {\n\t\trw.Header().Set(\"X-Request-Id\", xRequestID)\n\t}\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "title": "" }, { "docid": "ecbd4108f80196729fe7f522c7e9bfd9", "score": "0.7319448", "text": "func (o *WeaviatePeersAnswersCreateAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(202)\n}", "title": "" }, { "docid": "6423b652cf8af11a50fa58817ad12df7", "score": "0.73171353", "text": "func write(comm *RequestResponse) {\n\terr := comm.Resp.WriteHeaderAndJson(\n\t\tcomm.HTTPStatus,\n\t\tcomm.ResponseBody,\n\t\trestful.MIME_JSON,\n\t)\n\tif err != nil {\n\t\tlogrus.Warnf(\"Unable to write response. Error was %v\", err)\n\t}\n}", "title": "" }, { "docid": "4e91b2fdfe5de19e2d59f61e8d46d8c0", "score": "0.73154366", "text": "func (o *GetCharactersCharacterIDCalendarEventIDOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Cache-Control\n\n\tcacheControl := o.CacheControl\n\tif cacheControl != \"\" {\n\t\trw.Header().Set(\"Cache-Control\", cacheControl)\n\t}\n\n\t// response header Expires\n\n\texpires := o.Expires\n\tif expires != \"\" {\n\t\trw.Header().Set(\"Expires\", expires)\n\t}\n\n\t// response header Last-Modified\n\n\tlastModified := o.LastModified\n\tif lastModified != \"\" {\n\t\trw.Header().Set(\"Last-Modified\", lastModified)\n\t}\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "title": "" }, { "docid": "76c7cec493e51e14c581a04900fd5630", "score": "0.73117363", "text": "func (o *GetTaskDataOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make([]*models.URLResult, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "title": "" } ]
e8286e10a3e41d700e4c372dadc7cbd8
The IP address of the actor
[ { "docid": "64cf62752b228f9f0521b70985a60c90", "score": "0.71028167", "text": "func (this RepositoryVisibilityChangeEnableAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" } ]
[ { "docid": "50713fe2ff3a958a1347e452b326987b", "score": "0.72806215", "text": "func (this RepoConfigEnableSockpuppetDisallowedAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "b542905e173060baee74918decced11a", "score": "0.72677624", "text": "func (this RepoConfigDisableSockpuppetDisallowedAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "3346d45918402d77867aa18770a5d13e", "score": "0.72475004", "text": "func (a *InstanceMonitor) IP() string {\n\treturn a.ipAddress\n}", "title": "" }, { "docid": "55c0abfe0f82ffa15f87895caec07ddc", "score": "0.7207806", "text": "func (this RepoAddMemberAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "594745a73ae64b1a4676600e14e22a9b", "score": "0.7205694", "text": "func (this RepoAccessAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "f15db85c348c564a0b50903ab3b5b6da", "score": "0.7190909", "text": "func (this TeamAddMemberAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "05ef0f5489b93a978b81c5e8fbb9eecc", "score": "0.71899426", "text": "func (this OrgAddMemberAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "0dd66a3f28439dd56669756edd5c2f49", "score": "0.7182158", "text": "func (this OrgOauthAppAccessRequestedAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "e77c455f712d5c6a6a971be0de5eccfa", "score": "0.7161669", "text": "func (this OrgAddBillingManagerAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "988e4f628ba0e34f0dcffd0a9974c660", "score": "0.7161097", "text": "func (this OauthApplicationCreateAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "d1a2d8fa68b077d19551302dcfaeaa9b", "score": "0.71528155", "text": "func (this TeamAddRepositoryAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "b8ada750ee7a8284c0f93655560b0f08", "score": "0.7112088", "text": "func (c *Context) IP() string {\n\treturn c.Request.RemoteAddr\n}", "title": "" }, { "docid": "cb85e6bdc879765f4f4c824a4e57aae2", "score": "0.7104012", "text": "func (this OrgEnableOauthAppRestrictionsAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "b596b4bb1dcd4d3fb62338da60aba406", "score": "0.7073954", "text": "func (this OrgOauthAppAccessApprovedAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "b56536c6c5c663297491e57b86deaaee", "score": "0.70715517", "text": "func (this OrgInviteMemberAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "fce7e277e6ea62615076e100a713094e", "score": "0.7068354", "text": "func (ctx *Context) IP() string {\n\tproxy := []string{}\n\tif ips := ctx.Req().Header.Get(\"X-Forwarded-For\"); ips != \"\" {\n\t\tproxy = strings.Split(ips, \",\")\n\t}\n\tif len(proxy) > 0 && proxy[0] != \"\" {\n\t\treturn proxy[0]\n\t}\n\tip := strings.Split(ctx.Req().RemoteAddr, \":\")\n\tif len(ip) > 0 {\n\t\tif ip[0] != \"[\" {\n\t\t\treturn ip[0]\n\t\t}\n\t}\n\treturn \"127.0.0.1\"\n}", "title": "" }, { "docid": "bce1b2a62d71cf3e7b3edbcbe3ae9020", "score": "0.7058744", "text": "func (this RepoCreateAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "4edda77a44145cd1456b9e20e19617a1", "score": "0.7056663", "text": "func (this PrivateRepositoryForkingEnableAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "47da199639eb50c6daecc18f7a03709b", "score": "0.70493174", "text": "func (this RepoAddTopicAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "2acb1d6cdc050d9dd08aca2781bc6144", "score": "0.70454437", "text": "func (this OrgCreateAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "e7cf1b1a7bb1b637cfad3c4f2a6f2572", "score": "0.7035735", "text": "func (this OrgUpdateMemberAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "f4809e57a1fe5fda1dcfa162f9024e78", "score": "0.70235956", "text": "func (this OrgEnableSamlAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "464821deb63d072d35af06d77272d3b2", "score": "0.6992457", "text": "func (this OrgBlockUserAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "8ae8811e2bb146a56040ea50a0d261ac", "score": "0.69843656", "text": "func (this OrgInviteToBusinessAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "ac8d751d73400ebde0c0aedfe916f787", "score": "0.69487697", "text": "func (this OrgRestoreMemberAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "c2a4a579ab65aa5d3ef26cfe13512f43", "score": "0.69479644", "text": "func Addr() string {\n\treturn fmt.Sprintf(\"%s:%d\", IP(), Port())\n}", "title": "" }, { "docid": "75ff84f47e61048dfeba12ee9a07b040", "score": "0.6940261", "text": "func (m matchTicket) IP() string {\n\treturn sord(m.t.IPAddress())\n}", "title": "" }, { "docid": "4049b83fb7f7f66a1717bb085e64c497", "score": "0.692388", "text": "func (c *WSLink) IP() string {\n\treturn c.ip\n}", "title": "" }, { "docid": "65984c07f12a17933a5e0e30a7155365", "score": "0.6921653", "text": "func (this RepoConfigEnableAnonymousGitAccessAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "0219ba732137665be05e4dda88c8cf84", "score": "0.6916474", "text": "func (c Context) IP() string {\n\tip, _, err := net.SplitHostPort(c.Req.RemoteAddr)\n\tif err != nil {\n\t\treturn c.Req.RemoteAddr\n\t}\n\treturn ip\n}", "title": "" }, { "docid": "ee28d0fba7186cb10c2af8a4b3857024", "score": "0.69110703", "text": "func (ps *PeerStatus) IP() string {\n\treturn ps.IpnPeerStatus.TailAddr\n}", "title": "" }, { "docid": "28e39b17b637fe810d29c0d74e215fdb", "score": "0.6910994", "text": "func (this RepoArchivedAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "c405a30f3ee1ef8ce4b20a38fac213c9", "score": "0.69072914", "text": "func (this OrgDisableOauthAppRestrictionsAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "b53a7c721419901afefbfd987f4c4f6d", "score": "0.68989795", "text": "func (this RepoConfigLockAnonymousGitAccessAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "0e9adcb7982bb65926f1ac230c6d5a69", "score": "0.68896693", "text": "func (this OrgUpdateDefaultRepositoryPermissionAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "09f098cc5a481163e9058df0d746de9d", "score": "0.68767023", "text": "func (h *testHost) Address() modules.NetAddress { return h.ip }", "title": "" }, { "docid": "6c175e50b2ede8f44ca8f3c41a13125f", "score": "0.6850978", "text": "func (input *Input) IP() string {\n\tips := input.Proxy()\n\tif len(ips) > 0 && ips[0] != \"\" {\n\t\trip := strings.Split(ips[0], \":\")\n\t\treturn rip[0]\n\t}\n\tip := strings.Split(input.request.RemoteAddr, \":\")\n\tif len(ip) > 0 {\n\t\tif ip[0] != \"[\" {\n\t\t\treturn ip[0]\n\t\t}\n\t}\n\treturn \"127.0.0.1\"\n}", "title": "" }, { "docid": "c31f34d2a000ccb5977efcb73c7c41a7", "score": "0.6849867", "text": "func (this RepositoryVisibilityChangeDisableAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "53f450dd8cfc4a756ce88ceb94b65f67", "score": "0.68357766", "text": "func (this MembersCanDeleteReposEnableAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "c0b9fd7897bfc1e5dce77a1748e8d549", "score": "0.6826472", "text": "func (this MembersCanDeleteReposClearAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "6ac7226120940f2b80e6d69bee43d587", "score": "0.6800318", "text": "func (r *Request) IP(ctx context.Context) string {\n\treturn r.Get(ctx, \"x-forwarded-for\")\n}", "title": "" }, { "docid": "94e70bde980d343697cf72226868fa3e", "score": "0.67888874", "text": "func (this RepoConfigEnableContributorsOnlyAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "fc1d8147d0aae7d5d42f64cbe838827c", "score": "0.6787269", "text": "func (this RepoConfigDisableAnonymousGitAccessAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "f735b0f6484c14d544a92961f9fd5033", "score": "0.6784937", "text": "func (this PrivateRepositoryForkingDisableAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "70bdfd4fc28005ce389d1c06bda69ac8", "score": "0.6783591", "text": "func (cred *Credentials) IPAddress() string {\n\treturn cred.ipAddress\n}", "title": "" }, { "docid": "cb0dad50628c632701d358d3b8f8a5ff", "score": "0.67776567", "text": "func (this OrgEnableTwoFactorRequirementAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "6b23b09e1557ad02661a89b699c4e604", "score": "0.67718273", "text": "func (this RepoChangeMergeSettingAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "60c401b78ac2e7d9f3fbc8a1b8c7dfba", "score": "0.67635876", "text": "func (this OrgRemoveBillingManagerAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "0209fdfaccd89467e034b2c7492dd91e", "score": "0.67539984", "text": "func (this RepoDestroyAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "614d8bbc8d3720a69fc9060e62928f6f", "score": "0.674676", "text": "func (this TeamChangeParentTeamAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "d373abf7188da68469d5a2f93886a5de", "score": "0.66916806", "text": "func (this OrgConfigEnableCollaboratorsOnlyAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "67e09066b0a654e1d367c0979c521397", "score": "0.66815025", "text": "func (this OrgDisableSamlAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "31db376f53e6e3c82b39ec5e6a48bccb", "score": "0.6670447", "text": "func (this OrgOauthAppAccessDeniedAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "dc1b3ae4c669e24048e248a3bddbb8a7", "score": "0.6668776", "text": "func (this OrgUnblockUserAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "ec2d7c91353b60b6d098c608f89eda2f", "score": "0.66662556", "text": "func (this TeamRemoveRepositoryAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "91187d89dc381327fb06220435ceddc6", "score": "0.6647374", "text": "func (this RepoConfigEnableCollaboratorsOnlyAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "43abb770eb7dbe3c3b3869cf9ac2a248", "score": "0.663266", "text": "func (this RepoConfigDisableContributorsOnlyAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "3018324404fab5796c1d12ce62dfceec", "score": "0.6601471", "text": "func (this MembersCanDeleteReposDisableAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "5ebf9e94e56ee501c3a2a36901195741", "score": "0.6589117", "text": "func (this RepoRemoveMemberAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "fae74dfdf847e3b11d40563128c5bb7c", "score": "0.65752673", "text": "func (c *Client) IPAddr() string {\n\tc.lock.RLock()\n\tdefer c.lock.RUnlock()\n\n\treturn c.ipAddr\n}", "title": "" }, { "docid": "d75cbc13440459fc64736c96b550c89b", "score": "0.65644133", "text": "func (this TeamRemoveMemberAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "b77e8ca8177a7f10f6573396175c13a8", "score": "0.6543514", "text": "func (this OrgRemoveMemberAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "07368202c9842589761e2b4859ec973a", "score": "0.65431327", "text": "func (req *Request) RemoteAddr() string {\n\treturn fmt.Sprintf(\"%s:%d\", req.IP, req.Port)\n}", "title": "" }, { "docid": "604b38d6aabf7cf0632bba33945bf19c", "score": "0.6539647", "text": "func (info *endpointsInfo) IP() string {\n\treturn info.ip\n}", "title": "" }, { "docid": "29364ebb1f6bbf755c2a024a8b89dac7", "score": "0.6527195", "text": "func (this RepoRemoveTopicAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "912acb2dd891bc2f0051fc4f78242090", "score": "0.65209854", "text": "func getip() string {\n\treturn \"localhost\"\n}", "title": "" }, { "docid": "df5009796b43086001dc8a0bdcc4f4fb", "score": "0.65160364", "text": "func (c *connLinux) RemoteAddr() net.Addr { return c.remote }", "title": "" }, { "docid": "8ca31a2b70cb426891b9a97f0011038e", "score": "0.65091145", "text": "func (c *Context) RemoteAddr() string { return c.req.RemoteAddr }", "title": "" }, { "docid": "c0acee70ab09fc51407e69f8cfea3bbb", "score": "0.65026665", "text": "func (p *Pinger) Addr() string {\n\treturn p.addr\n}", "title": "" }, { "docid": "da5bbc04690017a9a577ec1a98ab4706", "score": "0.6469404", "text": "func (n *network) Address() string {\n\treturn n.Tunnel.Address()\n}", "title": "" }, { "docid": "dc8786dd96cee255c2fb7caaec964028", "score": "0.6466626", "text": "func (ctx *HttpContext) RemoteIP() string {\r\n\treturn ctx.request.RemoteIP()\r\n}", "title": "" }, { "docid": "181ad3bc25a25f838a7265e54cf7c72e", "score": "0.6464855", "text": "func (r *Request) IP() string {\n\treturn r.Context.IP()\n}", "title": "" }, { "docid": "2c14a14696b9d94004053bd589bcd746", "score": "0.6461245", "text": "func (this OrgConfigDisableCollaboratorsOnlyAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "671f73ac62395c05b2869c2d0b895fcf", "score": "0.6460916", "text": "func (this RepoConfigUnlockAnonymousGitAccessAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "208a189641a6285f8783fd082e82207a", "score": "0.6429426", "text": "func (this OrgDisableTwoFactorRequirementAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "f064abd1151c509c1b8a4f88a43a0114", "score": "0.64273274", "text": "func (this RepoConfigDisableCollaboratorsOnlyAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "fffb808c2bc03b0eaa8d6b5e76773f7f", "score": "0.6419127", "text": "func (c *Config) IP() string {\n\treturn c.ip\n}", "title": "" }, { "docid": "eceaac4b096875abf515260e9e8d8bd2", "score": "0.6412717", "text": "func (this OrgRemoveOutsideCollaboratorAuditEntry) GetActorIP() *string { return this.ActorIP }", "title": "" }, { "docid": "f55a712a5d9b45dd13ccd6e27218fde3", "score": "0.6408376", "text": "func (a *Remote) RemoteAddr() net.Addr { return nil }", "title": "" }, { "docid": "f03bf887601205df64f9767cead8952b", "score": "0.6399515", "text": "func (l *Listener) Addr() net.Addr { return l.pc.LocalAddr() }", "title": "" }, { "docid": "089fadee017efe72dde242d0dfe066dd", "score": "0.6384997", "text": "func (s *Keylookup) Addr() string {\n\treturn s.listener.Addr().String()\n}", "title": "" }, { "docid": "a1d1149bd5be3bccba3d8add3d036dd8", "score": "0.6382421", "text": "func (cred *Credentials) GetIPAddress() string {\n\treturn cred.ipAddress\n}", "title": "" }, { "docid": "32f9947c432441a686ec02ddf407dad5", "score": "0.6381305", "text": "func GetIPAddress(request *http.Request) string {\n\tipAddress := request.RemoteAddr\n\txForwardedFor := request.Header.Get(\"x-forwarded-for\")\n\tif xForwardedFor != \"\" {\n\t\tipAddress = xForwardedFor\n\t}\n\n\tcolon := strings.LastIndex(ipAddress, \":\")\n\tif colon >= 0 {\n\t\tipAddress = ipAddress[:colon]\n\t}\n\n\treturn ipAddress\n}", "title": "" }, { "docid": "a80c92d7f6528601cc4801f126247d4a", "score": "0.6374628", "text": "func (c Server) Addr() string {\n\treturn fmt.Sprintf(\"%s:%s\", c.Host, c.Port)\n}", "title": "" }, { "docid": "39d1e258f3d9ba8c7f0858eeacccbe1a", "score": "0.6332794", "text": "func (this *tcpCon) RemoteAddr() stdnet.Addr {\n return this.socket.RemoteAddr()\n}", "title": "" }, { "docid": "27481379399215838ab5cc92a3cd0550", "score": "0.63289195", "text": "func (conn TeeConn) RemoteAddr() net.Addr { return nil }", "title": "" }, { "docid": "54eef9385436322101eb1ee8993057ad", "score": "0.6322614", "text": "func (s *Socket) RemoteAddr() string {\n\treturn s.bs.RemoteAddr()\n}", "title": "" }, { "docid": "ba6f8af9f64b82155555ca5ab4ae8a5e", "score": "0.6316744", "text": "func (cc ClusterConfig) IP(name string) string {\n\tif name == cc.ID {\n\t\treturn cc.GatewayIP\n\t}\n\tfor _, peer := range cc.WatchedPeers {\n\t\tif name == peer.ID {\n\t\t\treturn peer.GatewayIP\n\t\t}\n\t}\n\treturn \"255.255.255.255\" // dummy value for unknown clusters\n}", "title": "" }, { "docid": "33c24e5dad11d1a7414aeab20f2f13f7", "score": "0.63119394", "text": "func masterAddr(info *mesos.MasterInfo) string {\n\tvar ip string\n\tvar port int64\n\tif info == nil {\n\t\treturn \"\"\n\t}\n\tif addr := info.GetAddress(); addr != nil { // Mesos >= 0.24.0\n\t\tip, port = addr.GetIp(), int64(addr.GetPort())\n\t} else { // Mesos < 0.24.0\n\t\tipv4 := make([]byte, net.IPv4len)\n\t\tbyteOrder.PutUint32(ipv4, info.GetIp())\n\t\tip, port = net.IP(ipv4).String(), int64(info.GetPort())\n\t}\n\treturn net.JoinHostPort(ip, strconv.FormatInt(port, 10))\n}", "title": "" }, { "docid": "63d8e99d67118a654a4e3e4027ed8a3b", "score": "0.63073295", "text": "func (c *client) Addr() string {\n\treturn c.addr\n}", "title": "" }, { "docid": "ba27beda24c56598e640305eac88a032", "score": "0.62876713", "text": "func (agent Agent) IPAddrWithPort() string {\n\treturn agent.IP + \":\" + agent.Port\n}", "title": "" }, { "docid": "041e92fcccbd1943367ddc37b02baf92", "score": "0.6269993", "text": "func (s *Stream) RemoteAddr() net.Addr { return s.m.conn.RemoteAddr() }", "title": "" }, { "docid": "36ba4ccf7a6c387e35fcc297988d6c67", "score": "0.62635326", "text": "func (o *Interface) GetUserIPAddress() string {\n\treturn o.UserIPAddress\n}", "title": "" }, { "docid": "95989999720f53014fab4515f39fcce8", "score": "0.6255389", "text": "func (s *Server) Addr() string {\n\treturn s.ip + \":\" + strconv.Itoa(s.port)\n}", "title": "" }, { "docid": "cfb208a2b1eaeafbef1216d7983f42b9", "score": "0.6239357", "text": "func Realip(ctx *fasthttp.RequestCtx) string {\n if xffb := ctx.Request.Header.Peek(\"X-Forwarded-For\"); len(xffb) > 0 {\n xff := string(xffb)\n for _, address := range strings.Split(xff, \",\") {\n address = strings.TrimSpace(address)\n isPrivate, err := isPrivateAddress(address)\n if !isPrivate && err == nil {\n return address\n }\n }\n }\n\n if xripb := ctx.Request.Header.Peek(\"X-Real-Ip\"); len(xripb) > 0 {\n return string(xripb)\n }\n\n return ctx.RemoteIP().String()\n}", "title": "" }, { "docid": "4605cfe900ff37df5ac6ff0cca6ea847", "score": "0.62386197", "text": "func (c *connector) RemoteIP() string {\n\taddr := c.RemoteAddr()\n\tif addr == \"\" {\n\t\treturn \"\"\n\t}\n\n\treturn strings.Split(addr, \":\")[0]\n}", "title": "" }, { "docid": "903690e47f665dcc39ed35f51158f33e", "score": "0.6225211", "text": "func ip (r *http.Request) string {\n var ip = ipRE.FindString(r.RemoteAddr)\n var realIP = getHeader(r, \"X-Forwarded-For\")\n if realIP != \"\" {\n return realIP\n }\n return ip\n}", "title": "" }, { "docid": "a8425995da8fb692e64a5a1bef69ec13", "score": "0.622163", "text": "func IPAddress(profileID string) string {\n\t// profile = toUserFriendlyName(profile)\n\n\tconst fallback = \"127.0.0.1\"\n\tinstance, err := getInstance(profileID)\n\tif err != nil {\n\t\treturn fallback\n\t}\n\n\tif len(instance.Network) > 0 {\n\t\treturn getIPAddress(profileID, instance.Network[0].Interface)\n\t}\n\n\treturn fallback\n}", "title": "" }, { "docid": "304a39e13ca4829e91dac219dde00970", "score": "0.622122", "text": "func (p *Peer) Addr() string {\r\n\treturn getAddress(p.cpeer.address)\r\n}", "title": "" }, { "docid": "828ed35d24d28b22f21c03f5da5c425f", "score": "0.6217339", "text": "func (s *Instance) GetIP() string {\n\treturn s.IClient.RemoteAddr().String()\n}", "title": "" } ]
8e7f5637ce54fb40fcb06b6ec4d57704
WithEvilScenario provides initWallet of spammer, if omitted spammer will prepare funds based on maxBlkSent parameter.
[ { "docid": "f9f4b524713a49c510094f830ae4ae35", "score": "0.5818867", "text": "func WithEvilScenario(scenario *evilwallet.EvilScenario) Options {\n\treturn func(s *Spammer) {\n\t\ts.EvilScenario = scenario\n\t}\n}", "title": "" } ]
[ { "docid": "45f72ec532b6cf30a6e2c58615cca51f", "score": "0.59646904", "text": "func WithEvilWallet(initWallets *evilwallet.EvilWallet) Options {\n\treturn func(s *Spammer) {\n\t\ts.EvilWallet = initWallets\n\t}\n}", "title": "" }, { "docid": "6380558c790e59598305084bb566cffb", "score": "0.54968894", "text": "func (app *current) Init(\n\tname string,\n\tpassword string,\n\tseed string,\n\twalletName string,\n\tamountUnits uint64,\n\tblockDifficultyBase uint,\n\tblockDifficultyIncreasePerTrx float64,\n\tlinkDifficulty uint,\n) error {\n\t_, err := app.genesisRepository.Retrieve()\n\tif err == nil {\n\t\treturn errors.New(\"the genesis block has already been created\")\n\t}\n\n\tidentity, err := app.identityRepository.Retrieve(name, seed, password)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcreatedOn := time.Now().UTC()\n\tpk := signature.NewPrivateKeyFactory().Create()\n\tpubKey := pk.PublicKey()\n\tpubKeyHash, err := app.hashAdapter.FromString(pubKey.String())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlock, err := app.lockBuilder.Create().WithPublicKeys([]hash.Hash{\n\t\t*pubKeyHash,\n\t}).CreatedOn(createdOn).Now()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tbill, err := app.billBuilder.Create().WithLock(lock).WithAmount(amountUnits).CreatedOn(createdOn).Now()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tgen, err := app.genesisBuilder.Create().\n\t\tWithBlockDifficultyBase(blockDifficultyBase).\n\t\tWithBlockDifficultyIncreasePerTrx(blockDifficultyIncreasePerTrx).\n\t\tWithLinkDifficulty(linkDifficulty).\n\t\tWithBill(bill).\n\t\tCreatedOn(createdOn).\n\t\tNow()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\twalletBill, err := app.walletBillBuilder.Create().WithBill(bill).WithPrivateKey(pk).CreatedOn(createdOn).Now()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\twallet, err := app.walletBuilder.Create().WithBills([]wallet_bills.Bill{\n\t\twalletBill,\n\t}).WithName(walletName).CreatedOn(createdOn).Now()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\troot := identity.Root()\n\tidentityCreatedOn := identity.CreatedOn()\n\tlastUpdatedOn := time.Now().UTC()\n\n\twallets := identity.Wallets().All()\n\twallets = append(wallets, wallet)\n\n\tbuckets := identity.Buckets().All()\n\tupdatedIdentity, err := app.identityBuilder.Create().\n\t\tWithSeed(seed).\n\t\tWithName(name).\n\t\tWithRoot(root).\n\t\tWithWallets(wallets).\n\t\tWithBuckets(buckets).\n\t\tCreatedOn(identityCreatedOn).\n\t\tLastUpdatedOn(lastUpdatedOn).\n\t\tNow()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = app.identityService.Update(identity.Hash(), updatedIdentity, password, password)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn app.genesisService.Save(gen)\n}", "title": "" }, { "docid": "82c98919ad11d911b964a5977e91b268", "score": "0.5373298", "text": "func WithScenarioInputWalletForDeepSpam(wallet *Wallet) ScenarioOption {\n\treturn func(options *EvilScenario) {\n\t\tif wallet.walletType == RestrictedReuse {\n\t\t\toptions.RestrictedInputWallet = wallet\n\t\t}\n\t}\n}", "title": "" }, { "docid": "0c06865c680b30b8c1144f5b3291c386", "score": "0.52834064", "text": "func TestInitWallet(t *testing.T) {\n\tt.Parallel()\n\n\t// testDir is empty, meaning wallet was not created from before.\n\ttestDir, err := ioutil.TempDir(\"\", \"testcreate\")\n\tif err != nil {\n\t\tt.Fatalf(\"unable to create temp directory: %v\", err)\n\t}\n\tdefer func() {\n\t\tos.RemoveAll(testDir)\n\t}()\n\n\t// Create new UnlockerService.\n\tservice := walletunlocker.New(testDir, testNetParams, true, nil)\n\n\t// Once we have the unlocker service created, we'll now instantiate a\n\t// new cipher seed instance.\n\tcipherSeed, err := aezeed.New(\n\t\tkeychain.KeyDerivationVersion, &testEntropy, time.Now(),\n\t)\n\tif err != nil {\n\t\tt.Fatalf(\"unable to create seed: %v\", err)\n\t}\n\n\t// With the new seed created, we'll convert it into a mnemonic phrase\n\t// that we'll send over to initialize the wallet.\n\tpass := []byte(\"test\")\n\tmnemonic, err := cipherSeed.ToMnemonic(pass)\n\tif err != nil {\n\t\tt.Fatalf(\"unable to create mnemonic: %v\", err)\n\t}\n\n\t// Now that we have all the necessary items, we'll now issue the Init\n\t// command to the wallet. This should check the validity of the cipher\n\t// seed, then send over the initialization information over the init\n\t// channel.\n\tctx := context.Background()\n\treq := &lnrpc.InitWalletRequest{\n\t\tWalletPassword: testPassword,\n\t\tCipherSeedMnemonic: []string(mnemonic[:]),\n\t\tAezeedPassphrase: pass,\n\t\tRecoveryWindow: int32(testRecoveryWindow),\n\t}\n\t_, err = service.InitWallet(ctx, req)\n\tif err != nil {\n\t\tt.Fatalf(\"InitWallet call failed: %v\", err)\n\t}\n\n\t// The same user passphrase, and also the plaintext cipher seed\n\t// should be sent over and match exactly.\n\tselect {\n\tcase msg := <-service.InitMsgs:\n\t\tif !bytes.Equal(msg.Passphrase, testPassword) {\n\t\t\tt.Fatalf(\"expected to receive password %x, \"+\n\t\t\t\t\"got %x\", testPassword, msg.Passphrase)\n\t\t}\n\t\tif msg.WalletSeed.InternalVersion != cipherSeed.InternalVersion {\n\t\t\tt.Fatalf(\"mismatched versions: expected %v, \"+\n\t\t\t\t\"got %v\", cipherSeed.InternalVersion,\n\t\t\t\tmsg.WalletSeed.InternalVersion)\n\t\t}\n\t\tif msg.WalletSeed.Birthday != cipherSeed.Birthday {\n\t\t\tt.Fatalf(\"mismatched birthday: expected %v, \"+\n\t\t\t\t\"got %v\", cipherSeed.Birthday,\n\t\t\t\tmsg.WalletSeed.Birthday)\n\t\t}\n\t\tif msg.WalletSeed.Entropy != cipherSeed.Entropy {\n\t\t\tt.Fatalf(\"mismatched versions: expected %x, \"+\n\t\t\t\t\"got %x\", cipherSeed.Entropy[:],\n\t\t\t\tmsg.WalletSeed.Entropy[:])\n\t\t}\n\t\tif msg.RecoveryWindow != testRecoveryWindow {\n\t\t\tt.Fatalf(\"mismatched recovery window: expected %v,\"+\n\t\t\t\t\"got %v\", testRecoveryWindow,\n\t\t\t\tmsg.RecoveryWindow)\n\t\t}\n\n\tcase <-time.After(3 * time.Second):\n\t\tt.Fatalf(\"password not received\")\n\t}\n\n\t// Create a wallet in testDir.\n\tcreateTestWallet(t, testDir, testNetParams)\n\n\t// Now calling InitWallet should fail, since a wallet already exists in\n\t// the directory.\n\t_, err = service.InitWallet(ctx, req)\n\tif err == nil {\n\t\tt.Fatalf(\"InitWallet did not fail as expected\")\n\t}\n\n\t// Similarly, if we try to do GenSeed again, we should get an error as\n\t// the wallet already exists.\n\t_, err = service.GenSeed(ctx, &lnrpc.GenSeedRequest{})\n\tif err == nil {\n\t\tt.Fatalf(\"seed generation should have failed\")\n\t}\n}", "title": "" }, { "docid": "ca7990fcf11aeaaa067ccb4b55e0cdd4", "score": "0.5152573", "text": "func (w *walletAPIHandler) initializeWallet(ctx context.Context, c Call, wr io.Writer) error {\n\tif err := w.cli.AcceptDisclaimerLocal(ctx, 0); err != nil {\n\t\treturn w.encodeErr(c, err, wr)\n\t}\n\tresult := map[string]string{\"disclaimer\": disclaimerText}\n\treturn w.encodeResult(c, result, wr)\n}", "title": "" }, { "docid": "6034e4557e8d6a7861ad7308d1fdce40", "score": "0.5129857", "text": "func (c *featureContext) initScenario(s *godog.ScenarioContext) {\n\ts.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) {\n\t\tc.env = nil\n\t\tc.cloud = nil\n\t\tc.apiKey = \"\"\n\t\tc.secretToken = \"\"\n\t\tc.span = nil\n\t\tc.transaction = nil\n\t\tc.httpHandler.panic = false\n\t\tc.httpHandler.statusCode = http.StatusOK\n\t\tc.httpRequestHeaders = nil\n\t\tc.grpcService.panic = false\n\t\tc.grpcService.err = nil\n\t\tc.tracer.ResetPayloads()\n\t\tfor _, k := range os.Environ() {\n\t\t\tif strings.HasPrefix(k, \"ELASTIC_APM\") {\n\t\t\t\tos.Unsetenv(k)\n\t\t\t}\n\t\t}\n\t\treturn ctx, nil\n\t})\n\n\ts.Step(\"^an agent$\", c.anAgent)\n\ts.Step(\"^an agent configured with$\", c.anAgentConfiguredWith)\n\ts.Step(\"^the agent sends a request to APM server$\", c.sendRequest)\n\ts.Step(\"^the Authorization header of the request is '(.*)'$\", c.checkAuthorizationHeader)\n\ts.Step(\"^the User-Agent header of the request matches regex '(.*)'$\", c.checkUserAgentHeader)\n\n\ts.Step(\"^an active span$\", c.anActiveSpan)\n\ts.Step(\"^an active transaction$\", c.anActiveTransaction)\n\n\t// Outcome\n\ts.Step(\"^a user sets the span outcome to '(.*)'$\", c.userSetsSpanOutcome)\n\ts.Step(\"^a user sets the transaction outcome to '(.*)'$\", c.userSetsTransactionOutcome)\n\ts.Step(\"^the agent sets the span outcome to '(.*)'$\", c.agentSetsSpanOutcome)\n\ts.Step(\"^the agent sets the transaction outcome to '(.*)'$\", c.agentSetsTransactionOutcome)\n\ts.Step(\"^an error is reported to the span$\", c.anErrorIsReportedToTheSpan)\n\ts.Step(\"^an error is reported to the transaction$\", c.anErrorIsReportedToTheTransaction)\n\ts.Step(\"^the span ends$\", c.spanEnds)\n\ts.Step(\"^the transaction ends$\", c.transactionEnds)\n\ts.Step(\"^the span outcome is '(.*)'$\", c.spanOutcomeIs)\n\ts.Step(\"^the transaction outcome is '(.*)'$\", c.transactionOutcomeIs)\n\n\t// HTTP\n\ts.Step(\"^a HTTP call is received that returns (.*)$\", c.anHTTPTransactionWithStatusCode)\n\ts.Step(\"^a HTTP call is made that returns (.*)$\", c.anHTTPSpanWithStatusCode)\n\n\t// gRPC\n\ts.Step(\"^a gRPC call is received that returns '(.*)'$\", c.aGRPCTransactionWithStatusCode)\n\ts.Step(\"^a gRPC call is made that returns '(.*)'$\", c.aGRPCSpanWithStatusCode)\n\n\t// Cloud metadata\n\ts.Step(\"an instrumented application is configured to collect cloud provider metadata for azure\", func() error {\n\t\treturn nil\n\t})\n\ts.Step(\"the following environment variables are present\", func(kv *godog.Table) error {\n\t\tfor _, row := range kv.Rows[1:] {\n\t\t\tc.env = append(c.env, row.Cells[0].Value+\"=\"+row.Cells[1].Value)\n\t\t}\n\t\treturn nil\n\t})\n\ts.Step(\"cloud metadata is collected\", func() error {\n\t\t_, _, _, cloud, _, err := getSubprocessMetadata(append([]string{\n\t\t\t\"ELASTIC_APM_CLOUD_PROVIDER=auto\", // Explicitly enable cloud metadata detection\n\t\t\t\"http_proxy=http://proxy.invalid\", // fail all HTTP requests\n\t\t}, c.env...)...)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif *cloud != (model.Cloud{}) {\n\t\t\tc.cloud = cloud\n\t\t}\n\t\treturn nil\n\t})\n\ts.Step(\"cloud metadata is not null\", func() error {\n\t\tif c.cloud == nil {\n\t\t\treturn errors.New(\"cloud metadata is empty\")\n\t\t}\n\t\treturn nil\n\t})\n\ts.Step(\"cloud metadata is null\", func() error {\n\t\tif c.cloud != nil {\n\t\t\treturn fmt.Errorf(\"cloud metadata is non-empty: %+v\", *c.cloud)\n\t\t}\n\t\treturn nil\n\t})\n\ts.Step(\"cloud metadata '(.*)' is '(.*)'\", func(field, expected string) error {\n\t\tvar actual string\n\t\tswitch field {\n\t\tcase \"account.id\":\n\t\t\tif c.cloud.Account == nil {\n\t\t\t\treturn errors.New(\"cloud.account is nil\")\n\t\t\t}\n\t\t\tactual = c.cloud.Account.ID\n\t\tcase \"provider\":\n\t\t\tactual = c.cloud.Provider\n\t\tcase \"instance.id\":\n\t\t\tif c.cloud.Instance == nil {\n\t\t\t\treturn errors.New(\"cloud.instance is nil\")\n\t\t\t}\n\t\t\tactual = c.cloud.Instance.ID\n\t\tcase \"instance.name\":\n\t\t\tif c.cloud.Instance == nil {\n\t\t\t\treturn errors.New(\"cloud.instance is nil\")\n\t\t\t}\n\t\t\tactual = c.cloud.Instance.Name\n\t\tcase \"project.name\":\n\t\t\tif c.cloud.Project == nil {\n\t\t\t\treturn errors.New(\"cloud.project is nil\")\n\t\t\t}\n\t\t\tactual = c.cloud.Project.Name\n\t\tcase \"region\":\n\t\t\tactual = c.cloud.Region\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unexpected field %q\", field)\n\t\t}\n\t\tif actual != expected {\n\t\t\treturn fmt.Errorf(\"expected %q to be %q, got %q\", field, expected, actual)\n\t\t}\n\t\treturn nil\n\t})\n}", "title": "" }, { "docid": "0b855659b199d9f93f7c1012fa23e268", "score": "0.5022372", "text": "func init() {\n\n\tif build.Release == \"dev\" {\n\t\t// 'dev' settings are for small developer testnets, usually on the same\n\t\t// computer. Settings are slow enough that a small team of developers\n\t\t// can coordinate their actions over a the developer testnets, but fast\n\t\t// enough that there isn't much time wasted on waiting for things to\n\t\t// happen.\n\t\tBlockFrequency = 12 // 12 seconds: slow enough for developers to see ~each block, fast enough that blocks don't waste time.\n\t\tMaturityDelay = 10 // 120 seconds before a delayed output matures.\n\n\t\t// Change as necessary. If not changed, the first few difficulty addaptions\n\t\t// will be wrong, but after some new difficulty calculations the error will\n\t\t// fade out.\n\t\tGenesisTimestamp = Timestamp(1424139000)\n\n\t\tTargetWindow = 20 // Difficulty is adjusted based on prior 20 blocks.\n\t\tMaxAdjustmentUp = big.NewRat(120, 100) // Difficulty adjusts quickly.\n\t\tMaxAdjustmentDown = big.NewRat(100, 120) // Difficulty adjusts quickly.\n\t\tFutureThreshold = 2 * 60 // 2 minutes.\n\t\tExtremeFutureThreshold = 4 * 60 // 4 minutes.\n\t\tStakeModifierDelay = 2000 // Number of blocks to take in history to calculate the stakemodifier\n\n\t\tBlockStakeAging = uint64(1 << 10) // Block stake aging if unspent block stake is not at index 0\n\n\t\tBlockCreatorFee = OneCoin.Mul64(100)\n\n\t\tbso := BlockStakeOutput{\n\t\t\tValue: NewCurrency64(1000000),\n\t\t\tUnlockHash: UnlockHash{},\n\t\t}\n\n\t\tco := CoinOutput{\n\t\t\tValue: OneCoin.Mul64(1000),\n\t\t}\n\n\t\t// Seed for this address:\n\t\t// across knife thirsty puck itches hazard enmity fainted pebbles unzip echo queen rarest aphid bugs yanks okay abbey eskimos dove orange nouns august ailments inline rebel glass tyrant acumen\n\t\tbso.UnlockHash.LoadString(\"e66bbe9638ae0e998641dc9faa0180c15a1071b1767784cdda11ad3c1d309fa692667931be66\")\n\t\tGenesisBlockStakeAllocation = append(GenesisBlockStakeAllocation, bso)\n\t\tco.UnlockHash.LoadString(\"e66bbe9638ae0e998641dc9faa0180c15a1071b1767784cdda11ad3c1d309fa692667931be66\")\n\t\tGenesisCoinDistribution = append(GenesisCoinDistribution, co)\n\n\t} else if build.Release == \"testing\" {\n\t\t// 'testing' settings are for automatic testing, and create much faster\n\t\t// environments than a human can interact with.\n\t\tBlockFrequency = 1 // As fast as possible\n\t\tMaturityDelay = 3\n\t\tGenesisTimestamp = CurrentTimestamp() - 1e6\n\t\tRootTarget = Target{128} // Takes an expected 2 hashes; very fast for testing but still probes 'bad hash' code.\n\n\t\t// A restrictive difficulty clamp prevents the difficulty from climbing\n\t\t// during testing, as the resolution on the difficulty adjustment is\n\t\t// only 1 second and testing mining should be happening substantially\n\t\t// faster than that.\n\t\tTargetWindow = 200\n\t\tMaxAdjustmentUp = big.NewRat(10001, 10000)\n\t\tMaxAdjustmentDown = big.NewRat(9999, 10000)\n\t\tFutureThreshold = 3 // 3 seconds\n\t\tExtremeFutureThreshold = 6 // 6 seconds\n\t\tStakeModifierDelay = 20\n\n\t\tBlockStakeAging = uint64(1 << 10)\n\n\t\tBlockCreatorFee = OneCoin.Mul64(100)\n\n\t\tGenesisBlockStakeAllocation = []BlockStakeOutput{\n\t\t\t{\n\t\t\t\tValue: NewCurrency64(2000),\n\t\t\t\tUnlockHash: UnlockHash{214, 166, 197, 164, 29, 201, 53, 236, 106, 239, 10, 158, 127, 131, 20, 138, 63, 221, 230, 16, 98, 247, 32, 77, 210, 68, 116, 12, 241, 89, 27, 223},\n\t\t\t},\n\t\t\t{\n\t\t\t\tValue: NewCurrency64(7000),\n\t\t\t\tUnlockHash: UnlockHash{209, 246, 228, 60, 248, 78, 242, 110, 9, 8, 227, 248, 225, 216, 163, 52, 142, 93, 47, 176, 103, 41, 137, 80, 212, 8, 132, 58, 241, 189, 2, 17},\n\t\t\t},\n\t\t\t{\n\t\t\t\tValue: NewCurrency64(1000),\n\t\t\t\tUnlockHash: UnlockConditions{}.UnlockHash(),\n\t\t\t},\n\t\t}\n\t} else if build.Release == \"standard\" {\n\t\t// 'standard' settings are for the full network. They are slow enough\n\t\t// that the network is secure in a real-world byzantine environment.\n\n\t\t// A block time of 1 block per 10 minutes is chosen to follow Bitcoin's\n\t\t// example. The security lost by lowering the block time is not\n\t\t// insignificant, and the convenience gained by lowering the blocktime\n\t\t// even down to 90 seconds is not significant. I do feel that 10\n\t\t// minutes could even be too short, but it has worked well for Bitcoin.\n\t\tBlockFrequency = 600\n\n\t\t// Payouts take 1 day to mature. This is to prevent a class of double\n\t\t// spending attacks parties unintentionally spend coins that will stop\n\t\t// existing after a blockchain reorganization. There are multiple\n\t\t// classes of payouts in Sia that depend on a previous block - if that\n\t\t// block changes, then the output changes and the previously existing\n\t\t// output ceases to exist. This delay stops both unintentional double\n\t\t// spending and stops a small set of long-range mining attacks.\n\t\tMaturityDelay = 144\n\n\t\t// The genesis timestamp is set to June 1st, 2017\n\t\tGenesisTimestamp = Timestamp(1496322000) // June 2nd, 2017 @ 1:00pm UTC.\n\n\t\t// The RootTarget was set such that the developers could reasonable\n\t\t// premine 100 blocks in a day. It was known to the developrs at launch\n\t\t// this this was at least one and perhaps two orders of magnitude too\n\t\t// small.\n\t\tRootTarget = Target{0, 0, 0, 0, 32}\n\n\t\t// When the difficulty is adjusted, it is adjusted by looking at the\n\t\t// timestamp of the 1000th previous block. This minimizes the abilities\n\t\t// of miners to attack the network using rogue timestamps.\n\t\tTargetWindow = 1e3\n\n\t\t// The difficutly adjustment is clamped to 2.5x every 500 blocks. This\n\t\t// corresponds to 6.25x every 2 weeks, which can be compared to\n\t\t// Bitcoin's clamp of 4x every 2 weeks. The difficulty clamp is\n\t\t// primarily to stop difficulty raising attacks. Sia's safety margin is\n\t\t// similar to Bitcoin's despite the looser clamp because Sia's\n\t\t// difficulty is adjusted four times as often. This does result in\n\t\t// greater difficulty oscillation, a tradeoff that was chosen to be\n\t\t// acceptable due to Sia's more vulnerable position as an altcoin.\n\t\tMaxAdjustmentUp = big.NewRat(25, 10)\n\t\tMaxAdjustmentDown = big.NewRat(10, 25)\n\n\t\t// Blocks will not be accepted if their timestamp is more than 3 hours\n\t\t// into the future, but will be accepted as soon as they are no longer\n\t\t// 3 hours into the future. Blocks that are greater than 5 hours into\n\t\t// the future are rejected outright, as it is assumed that by the time\n\t\t// 2 hours have passed, those blocks will no longer be on the longest\n\t\t// chain. Blocks cannot be kept forever because this opens a DoS\n\t\t// vector.\n\t\tFutureThreshold = 3 * 60 * 60 // 3 hours.\n\t\tExtremeFutureThreshold = 5 * 60 * 60 // 5 hours.\n\n\t\t// The stakemodifier is calculated from blocks in history. The stakemodifier\n\t\t// is calculated as: For x = 0 to 255\n\t\t// bit x of Stake Modifier = bit x of h(block N-(StakeModifierDelay+x))\n\t\tStakeModifierDelay = 2000\n\n\t\t// Blockstakeaging is the number of seconds to wait before blockstake can be\n\t\t// used to solve blocks. But only when the block stake output is not the\n\t\t// first transaction with the first index. (2^16s < 1 day < 2^17s)\n\t\tBlockStakeAging = uint64(1 << 17)\n\n\t\t// BlockCreatorFee is the asset you get when creating a block on top of the\n\t\t// other fee.\n\t\tBlockCreatorFee = OneCoin.Mul64(10)\n\n\t\tbso := BlockStakeOutput{\n\t\t\tValue: NewCurrency64(1000000),\n\t\t\tUnlockHash: UnlockHash{},\n\t\t}\n\n\t\tco := CoinOutput{\n\t\t\tValue: OneCoin.Mul64(100 * 1000 * 1000),\n\t\t}\n\n\t\tbso.UnlockHash.LoadString(\"b5e42056ef394f2ad9b511a61cec874d25bebe2095682dd37455cbafed4bec15c28ee7d7ed1d\")\n\t\tGenesisBlockStakeAllocation = append(GenesisBlockStakeAllocation, bso)\n\t\tco.UnlockHash.LoadString(\"b5e42056ef394f2ad9b511a61cec874d25bebe2095682dd37455cbafed4bec15c28ee7d7ed1d\")\n\t\tGenesisCoinDistribution = append(GenesisCoinDistribution, co)\n\t}\n\n\tCalculateGenesis()\n}", "title": "" }, { "docid": "3b7e143dfb383d41220958aff6b2a23e", "score": "0.49957615", "text": "func createMinerAndUpgradeASector(t *testing.T) (*vm.VM, *miner.SectorOnChainInfo, address.Address, *power.CreateMinerReturn, uint64, uint64, uint64) {\n\tctx := context.Background()\n\tblkStore := ipld.NewBlockStoreInMemory()\n\tv := vm.NewVMWithSingletons(ctx, t, blkStore)\n\taddrs := vm.CreateAccounts(ctx, t, v, 1, big.Mul(big.NewInt(100_000), big.NewInt(1e18)), 93837778)\n\n\t// create miner\n\tsealProof := abi.RegisteredSealProof_StackedDrg32GiBV1_1\n\tss, err := sealProof.SectorSize()\n\trequire.NoError(t, err)\n\n\twPoStProof, err := sealProof.RegisteredWindowPoStProof()\n\trequire.NoError(t, err)\n\towner, worker := addrs[0], addrs[0]\n\tminerAddrs := createMiner(t, v, owner, worker, wPoStProof, big.Mul(big.NewInt(10_000), vm.FIL))\n\n\t// advance vm so we can have seal randomness epoch in the past\n\tv, err = v.WithEpoch(abi.ChainEpoch(200))\n\trequire.NoError(t, err)\n\n\tv, deadlineIndex, partitionIndex, sectorNumber := createSector(t, v, worker, minerAddrs.IDAddress, 100, sealProof)\n\n\t// sanity checks about the sector created\n\n\toldSectorInfo := vm.SectorInfo(t, v, minerAddrs.RobustAddress, sectorNumber)\n\trequire.Equal(t, 0, len(oldSectorInfo.DealIDs))\n\trequire.Nil(t, oldSectorInfo.SectorKeyCID)\n\tminerPower := vm.MinerPower(t, v, minerAddrs.IDAddress)\n\trequire.Equal(t, uint64(ss), minerPower.Raw.Uint64())\n\n\t// make some unverified deals\n\tdealIDs := createDeals(t, 1, v, worker, worker, minerAddrs.IDAddress, sealProof)\n\n\t// replicaUpdate the sector\n\n\treplicaUpdate := miner.ReplicaUpdate{\n\t\tSectorID: sectorNumber,\n\t\tDeadline: deadlineIndex,\n\t\tPartition: partitionIndex,\n\t\tNewSealedSectorCID: tutil.MakeCID(\"replica1\", &miner.SealedCIDPrefix),\n\t\tDeals: dealIDs,\n\t\tUpdateProofType: abi.RegisteredUpdateProof_StackedDrg32GiBV1,\n\t}\n\n\tret := vm.ApplyOk(t, v, addrs[0], minerAddrs.RobustAddress, big.Zero(),\n\t\tbuiltin.MethodsMiner.ProveReplicaUpdates,\n\t\t&miner.ProveReplicaUpdatesParams{Updates: []miner.ReplicaUpdate{replicaUpdate}})\n\n\tupdatedSectors, ok := ret.(*bitfield.BitField)\n\trequire.True(t, ok)\n\tcount, err := updatedSectors.Count()\n\trequire.NoError(t, err)\n\trequire.Equal(t, uint64(1), count)\n\n\tisSet, err := updatedSectors.IsSet(uint64(sectorNumber))\n\trequire.NoError(t, err)\n\trequire.True(t, isSet)\n\n\tnewSectorInfo := vm.SectorInfo(t, v, minerAddrs.RobustAddress, sectorNumber)\n\trequire.Equal(t, 1, len(newSectorInfo.DealIDs))\n\trequire.Equal(t, dealIDs[0], newSectorInfo.DealIDs[0])\n\trequire.Equal(t, oldSectorInfo.SealedCID, *newSectorInfo.SectorKeyCID)\n\trequire.Equal(t, replicaUpdate.NewSealedSectorCID, newSectorInfo.SealedCID)\n\n\tminerPower = vm.MinerPower(t, v, minerAddrs.IDAddress)\n\trequire.Equal(t, uint64(ss), minerPower.Raw.Uint64())\n\n\treturn v, newSectorInfo, worker, minerAddrs, deadlineIndex, partitionIndex, uint64(ss)\n}", "title": "" }, { "docid": "74d344c9c98aea15b06ccdf675ab7089", "score": "0.49843013", "text": "func (cc *NettingScenario) Init(stub shim.ChaincodeStubInterface) peer.Response {\n\treturn initLedger(stub)\n}", "title": "" }, { "docid": "5725890d5a1505a2deac981bbd6728b3", "score": "0.49600697", "text": "func (t *SmartContract) Init(stub shim.ChaincodeStubInterface) pb.Response {\n\tfunctionName := \"[Init]\"\n\tprintln(\"=======================\" + functionName + \"=======================\")\n\tprintln(\"=======================\" + \"Create Market\" + \"=======================\")\n\tmarketKey := marketKey\n\tmarket := Market{LoanId: []string{\n\t\t\"0xfdsp3ofjsi32jr9hcsm2FkewpKwoOW00fsdJWEaase223DKwkoIK\",\n\t\t\"0xfdsp3ofjsi32jr9hcsm2FkewpKwoOW00fsdJffafASFasdaASDda\",\n\t}}\n\n\tprintln(\">> START parse market Model to ByteArray <<\")\n\tmarketAsBytes, err := json.Marshal(market)\n\tif err != nil {\n\t\tprintln(\"Marshal parser market as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser marketModel as Model to ByteArray is error\" + err.Error())\n\t}\n\tprintln(\">> END parse marketModel Model to ByteArray <<\")\n\n\t//byteArray put to state blockchain\n\tprintln(\">> START marketAsBytes PutState to state blockchain <<\")\n\terr = stub.PutState(marketKey, marketAsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\tprintln(\">> END marketAsBytes PutState to state blockchain <<\")\n\n\tprintln(\"=======================\" + \"Create Wallet\" + \"=======================\")\n\n\t//create Digital Wallet > 2\n\twalletAKey := \"0x3921h3921hg7wRipjUIG39sdkOgfkbJe3KWDindoHIsdMiiNSKw\"\n\twalletA := DigitalWallet{\n\t\tAddress: walletAKey,\n\t\tBalance: 1000000.99, //DAI\n\t\tBorrowerAsset: []string{\n\t\t\t\"0xGDhsud34nsaJHDw59Jh2HDuhJDEJdsfpkKi09YhosII114Sccks\",\n\t\t\t\"0xOGhsud34nsaJHDw59Jh2AVtuJDEJdsfrkKi09YhosII114Sookr\",\n\t\t},\n\t\tBorrowerToken: nil,\n\t\tLenderLoan: []string{\n\t\t\t\"0xfdsp3ofjsi32jr9hcsm2FkewpKwoOW00fsdJWEaase223DKwkoIK\",\n\t\t\t\"0xfdsp3ofjsi32jr9hcsm2FkewpKwoOW00fsdJffafASFasdaASDda\",\n\t\t},\n\t\tLenderPromotion: []PromotionList{\n\t\t\t{\n\t\t\t\tAsset: Asset{\n\t\t\t\t\tAssetName: \"บ้ายายมี\",\n\t\t\t\t\tValue: 1000000.00,\n\t\t\t\t},\n\t\t\t\tRiskRate: 5,\n\t\t\t\tStatus: \"Accept\",\n\t\t\t\tIssueDate: time.Now(),\n\t\t\t},\n\t\t\t{\n\t\t\t\tAsset: Asset{\n\t\t\t\t\tAssetName: \"บ้าขายหอย\",\n\t\t\t\t\tValue: 2000000.00,\n\t\t\t\t},\n\t\t\t\tRiskRate: 1,\n\t\t\t\tStatus: \"Accept\",\n\t\t\t\tIssueDate: time.Now(),\n\t\t\t},\n\t\t},\n\t\tPromotionOrder: []string{\n\t\t\t\"0x3921h3921hg7wRipjUIG39sdkOgfkbJe3KWDindoHIsdMiiNSAA\",\n\t\t\t\"0x3921h3921hg7wRipjUIG39sdkOgfkbJe3KWDindoHIsdMiiNSBB\",\n\t\t},\n\t\tTransaction: []WalletTransaction{\n\t\t\t{\n\t\t\t\tAddress: \"0xwW9OADwy9QmhVsBmff7n6L8vpWs1MricqCoMME8KMuVtxRaiOJZ54ZrnjR6BEVCI\",\n\t\t\t\tIssueDate: time.Now().AddDate(0, 0, -1),\n\t\t\t\tTransactionName: \"Buy Asset Token\",\n\t\t\t\tTransactionType: \"Buy\",\n\t\t\t\tTotal: 100.00,\n\t\t\t\tSnapshotBalance: 999900.99,\n\t\t\t},\n\t\t\t{\n\t\t\t\tIssueDate: time.Now(),\n\t\t\t\tTransactionName: \"loan by Asset Token\",\n\t\t\t\tTransactionType: \"Sell\",\n\t\t\t\tTotal: 100.00,\n\t\t\t\tSnapshotBalance: 1000000.99,\n\t\t\t},\n\t\t},\n\t\tLoanDocument: nil,\n\t}\n\n\twalletBKey := \"0xSakdsjakIhdsklmLmJDpjIOhodsol93GHudg2kDNhKHodsb9dSk\"\n\twalletB := DigitalWallet{\n\t\tAddress: walletBKey,\n\t\tBalance: 1000000.99, //DAI\n\t\tBorrowerAsset: []string{\"0xGDhsud34nsaJHDw59Jh2HDuhJDEJdsfpkKi09YhosII112Sucks\"},\n\t\tBorrowerToken: nil,\n\t\tLenderLoan: nil,\n\t\tTransaction: nil,\n\t\tLoanDocument: nil,\n\t}\n\tprintln(\">> START parse Promo Order Model to ByteArray <<\")\n\tPromoOrderKey1 := \"0x3921h3921hg7wRipjUIG39sdkOgfkbJe3KWDindoHIsdMiiNSAA\"\n\tPromoOrder1 := PromotionOrder{\n\t\tAddress: PromoOrderKey1,\n\t\tTransactionName: \"Order1\",\n\t\tRiskRate: 3,\n\t\tStatus: \"Pending\",\n\t\tIssueDate: time.Now(),\n\t}\n\tPromoOrderKey2 := \"0x3921h3921hg7wRipjUIG39sdkOgfkbJe3KWDindoHIsdMiiNSBB\"\n\tPromoOrder2 := PromotionOrder{\n\t\tAddress: PromoOrderKey2,\n\t\tTransactionName: \"Order2\",\n\t\tRiskRate: 8,\n\t\tStatus: \"Pending\",\n\t\tIssueDate: time.Now(),\n\t}\n\tPromoOrder1AsBytes, err := json.Marshal(PromoOrder1)\n\tif err != nil {\n\t\tprintln(\"Marshal parser wallet as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser walletAsBytesModel as Model to ByteArray is error\" + err.Error())\n\t}\n\tPromoOrder2AsBytes, err := json.Marshal(PromoOrder2)\n\tif err != nil {\n\t\tprintln(\"Marshal parser wallet as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser walletAsBytesModel as Model to ByteArray is error\" + err.Error())\n\t}\n\tprintln(\">> END parse Promo Order Model to ByteArray <<\")\n\t//byteArray put to state blockchain\n\tprintln(\">> START PromoOrderAsBytes PutState to state blockchain <<\")\n\terr = stub.PutState(PromoOrderKey1, PromoOrder1AsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\terr = stub.PutState(PromoOrderKey2, PromoOrder2AsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\tprintln(\">> END PromoOrderAsBytes PutState to state blockchain <<\")\n\n\tprintln(\">> START parse wallet Model to ByteArray <<\")\n\twalletAAsBytes, err := json.Marshal(walletA)\n\tif err != nil {\n\t\tprintln(\"Marshal parser wallet as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser walletAsBytesModel as Model to ByteArray is error\" + err.Error())\n\t}\n\twalletBAsBytes, err := json.Marshal(walletB)\n\tif err != nil {\n\t\tprintln(\"Marshal parser wallet as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser walletAsBytesModel as Model to ByteArray is error\" + err.Error())\n\t}\n\tprintln(\">> END parse walletModel Model to ByteArray <<\")\n\n\t//byteArray put to state blockchain\n\tprintln(\">> START walletAsBytes PutState to state blockchain <<\")\n\terr = stub.PutState(walletAKey, walletAAsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\terr = stub.PutState(walletBKey, walletBAsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\tprintln(\">> END walletAsBytes PutState to state blockchain <<\")\n\n\tprintln(\"=======================\" + \"Create Asset\" + \"=======================\")\n\t//create Asset\n\tassetKey := \"0xGDhsud34nsaJHDw59Jh2HDuhJDEJdsfpkKi09YhosII114Sccks\"\n\tasset := Asset{\n\t\tLoanId: \"0xfdsp3ofjsi32jr9hcsm2FkewpKwoOW00fsdJWEaase223DKwkoIK\",\n\t\tAssetId: assetKey,\n\t\tAddress: walletAKey,\n\t\tAssetName: \"บ้าน\",\n\t\tValue: 10000, //DAI\n\t\tLoanType: \"secure loan\",\n\t\tLoanDuration: 76, //M = 3 Year\n\t\tLoanInterest: 4, //Percent\n\t\tLoanMin: 1000, //10%\n\t\tLoanMax: 8000, //80%\n\t\tValuateInterest: 4, //Percent\n\t\tTokenAmount: 10,\n\t\tTokenBalance: 10,\n\t\tStatus: \"approved\",\n\t\tIssueDate: time.Now(),\n\t}\n\n\tassetA2Key := \"0xOGhsud34nsaJHDw59Jh2AVtuJDEJdsfrkKi09YhosII114Sookr\"\n\tassetA2 := Asset{\n\t\tLoanId: \"0xfdsp3ofjsi32jr9hcsm2FkewpKwoOW00fsdJffafASFasdaASDda\",\n\t\tAssetId: assetA2Key,\n\t\tAddress: walletAKey,\n\t\tAssetName: \"บ้าน\",\n\t\tValue: 20000, //DAI\n\t\tLoanType: \"secure loan\",\n\t\tLoanDuration: 76, //M = 3 Year\n\t\tLoanInterest: 3, //Percent\n\t\tLoanMin: 1000, //10%\n\t\tLoanMax: 8000, //80%\n\t\tValuateInterest: 4, //Percent\n\t\tTokenAmount: 10,\n\t\tTokenBalance: 10,\n\t\tStatus: \"approved\",\n\t\tIssueDate: time.Now(),\n\t}\n\n\tassetKey2 := \"0xGDhsud34nsaJHDw59Jh2HDuhJDEJdsfpkKi09YhosII112Sucks\"\n\tassetB := Asset{\n\t\tLoanId: \"0xfdsp3ofjsi32jr9hcsm2FkewpKwoOW00fsdJWEaase223Dkigluay\",\n\t\tAssetId: assetKey2,\n\t\tAddress: walletBKey,\n\t\tAssetName: \"บ้าน\",\n\t\tValue: 10, //DAI\n\t\tLoanType: \"secure loan\",\n\t\tLoanDuration: 76, //M = 3 Year\n\t\tLoanInterest: 4, //Percent\n\t\tLoanMin: 1000, //10%\n\t\tLoanMax: 8000, //80%\n\t\tValuateInterest: 4, //Percent\n\t\tTokenAmount: 10,\n\t\tTokenBalance: 10,\n\t\tStatus: \"approved\",\n\t\tIssueDate: time.Now(),\n\t}\n\tprintln(\">> START parse asset Model to ByteArray <<\")\n\tassetBAsBytes, err := json.Marshal(assetB)\n\tif err != nil {\n\t\tprintln(\"Marshal parser asset as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser asset as Model to ByteArray is error\" + err.Error())\n\t}\n\tprintln(\">> END parse assetModel Model to ByteArray <<\")\n\n\t//byteArray put to state blockchain\n\tprintln(\">> START assetAsBytes PutState to state blockchain <<\")\n\terr = stub.PutState(assetKey2, assetBAsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\n\tprintln(\">> START parse asset Model to ByteArray <<\")\n\tassetAsBytes, err := json.Marshal(asset)\n\tif err != nil {\n\t\tprintln(\"Marshal parser asset as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser asset as Model to ByteArray is error\" + err.Error())\n\t}\n\tprintln(\">> END parse assetModel Model to ByteArray <<\")\n\n\t//byteArray put to state blockchain\n\tprintln(\">> START assetAsBytes PutState to state blockchain <<\")\n\terr = stub.PutState(assetKey, assetAsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\tprintln(\">> END assetAsBytes PutState to state blockchain <<\")\n\n\tprintln(\">> START parse asset Model to ByteArray <<\")\n\tassetA2AsBytes, err := json.Marshal(assetA2)\n\tif err != nil {\n\t\tprintln(\"Marshal parser asset as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser asset as Model to ByteArray is error\" + err.Error())\n\t}\n\tprintln(\">> END parse assetModel Model to ByteArray <<\")\n\n\t//byteArray put to state blockchain\n\tprintln(\">> START assetAsBytes PutState to state blockchain <<\")\n\terr = stub.PutState(assetA2Key, assetA2AsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\n\tprintln(\"=======================\" + \"Create loanDocument\" + \"=======================\")\n\n\tloanDocumentKey := \"0xfdsp3ofjsi32jr9hcsm2FkewpKwoOW00fsdJWEaase223DKwkoIK\"\n\tloanDocument := LoanDocument{\n\t\tAssetId: assetKey,\n\t\tAddress: walletAKey,\n\t\tLoanId: loanDocumentKey,\n\t\tLoan: 8000,\n\t\tRemainDebt: 8000,\n\t\tInterest: asset.LoanInterest,\n\t\tMinDebtPerMonth: (8000 / float64(asset.LoanDuration)) * (float64(asset.LoanInterest) / float64(100)),\n\t\tIssueDate: time.Now(),\n\t\tStatus: \"callateral\",\n\t\tToken: []string{\n\t\t\t\"0x534adsDAdsfkewlvkkjsfweiQQdjefn398fps025hc8NEEIjfoe\",\n\t\t\t\"0xIJdsdnauGdeworj39NJndop0389djDjfes5iht4ncKJsweovjKa\",\n\t\t\t\"0x0347idsjfsjjfrmskgnoierl38chfs7jdJJFmekkedsojwWWfkv\",\n\t\t\t\"0x95LJUObmMKIDSt1hZoChoXz1rUH3QPTaRcNiGVH51foBAWDj90nT1z8824MVVzyT\",\n\t\t\t\"0xVx1my9LtDpa3VxVasaxzu3j2YApdKeE2GQDcMARY2zsUi5TzLPC3wyNa2hLTpTyf\",\n\t\t\t\"0xLxU81ZcCKCTOvmFZQL9UUZ4aB7IiJEu01iEtFEuCUoirBGz4AAK8P81mGUMM1TBa\",\n\t\t\t\"0xRxcbOOUjJmcOoj20ZSuPOT2Sv1JB8aaj9SWEQEi09mQbHC2U5TxDIV80zU9tGRNL\",\n\t\t\t\"0xmKVd9OnvjRt7LoGoowwRB3tiYZzM3r4Zc61hdnnrJ8H6Ch5r331vjJQsL8xCPZH4\",\n\t\t\t\"0xtLPCPT5y2qcN7s3MHxyySTn6hB865CL1n0YN8WVTvhcXP2rwZ0QnMTMPZBTB1A2y\",\n\t\t\t\"0xCBvm648FvE3atAIQ72m1auNxAIE1uqqifZti0vZju0PY6S51YteEuaJtLV6YD2hE\"},\n\t}\n\n\tloanDocumentKey2 := \"0xfdsp3ofjsi32jr9hcsm2FkewpKwoOW00fsdJffafASFasdaASDda\"\n\tloanDocument2 := LoanDocument{\n\t\tAssetId: assetA2Key,\n\t\tAddress: walletAKey,\n\t\tLoanId: loanDocumentKey2,\n\t\tLoan: 5000,\n\t\tRemainDebt: 1000,\n\t\tInterest: assetA2.LoanInterest,\n\t\tMinDebtPerMonth: (5000 / float64(assetA2.LoanDuration)) * (float64(assetA2.LoanInterest) / float64(100)),\n\t\tIssueDate: time.Now(),\n\t\tStatus: \"callateral\",\n\t\tToken: []string{\n\t\t\t\"0x534adsDAdsfkewlvkkjsfweiQQdjefn398fps025hc8NEEIjf11\",\n\t\t\t\"0xIJdsdnauGdeworj39NJndop0389djDjfes5iht4ncKJsweovj22\",\n\t\t\t},\n\t}\n\tprintln(\">> START parse loan Model to ByteArray <<\")\n\tloanAsBytes, err := json.Marshal(loanDocument)\n\tif err != nil {\n\t\tprintln(\"Marshal parser loan as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser loan as Model to ByteArray is error\" + err.Error())\n\t}\n\tprintln(\">> END parse loan Model to ByteArray <<\")\n\n\t//byteArray put to state blockchain\n\tprintln(\">> START loanAsBytes PutState to state blockchain <<\")\n\terr = stub.PutState(loanDocumentKey, loanAsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\tprintln(\">> END loanAsBytes PutState to state blockchain <<\")\n\tprintln(\">> START parse loan Model to ByteArray <<\")\n\tloan2AsBytes, err := json.Marshal(loanDocument2)\n\tif err != nil {\n\t\tprintln(\"Marshal parser loan as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser loan as Model to ByteArray is error\" + err.Error())\n\t}\n\tprintln(\">> END parse loan Model to ByteArray <<\")\n\n\t//byteArray put to state blockchain\n\tprintln(\">> START loanAsBytes PutState to state blockchain <<\")\n\terr = stub.PutState(loanDocumentKey2, loan2AsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\tprintln(\">> END loanAsBytes PutState to state blockchain <<\")\n\n\tprintln(\"=======================\" + \"Create token\" + \"=======================\")\n\n\ttoken1Key := \"0x534adsDAdsfkewlvkkjsfweiQQdjefn398fps025hc8NEEIjfoe\"\n\ttoken1 := Token{\n\t\tTokenId: token1Key,\n\t\tAssetId: assetKey,\n\t\tLenderAddress: \"\",\n\t\tRate: loanDocument.Loan / float64(asset.TokenAmount),\n\t\tIsSell: false,\n\t\tIssueDate: time.Now(),\n\t}\n\ttoken2Key := \"0xIJdsdnauGdeworj39NJndop0389djDjfes5iht4ncKJsweovjKa\"\n\ttoken2 := Token{\n\t\tTokenId: token2Key,\n\t\tAssetId: assetKey,\n\t\tLenderAddress: \"\",\n\t\tRate: loanDocument.Loan / float64(asset.TokenAmount),\n\t\tIsSell: false,\n\t\tIssueDate: time.Now(),\n\t}\n\ttoken3Key := \"0x0347idsjfsjjfrmskgnoierl38chfs7jdJJFmekkedsojwWWfkv\"\n\ttoken3 := Token{\n\t\tTokenId: token3Key,\n\t\tAssetId: assetKey,\n\t\tLenderAddress: \"\",\n\t\tRate: loanDocument.Loan / float64(asset.TokenAmount),\n\t\tIsSell: false,\n\t\tIssueDate: time.Now(),\n\t}\n\ttoken4Key := \"0x95LJUObmMKIDSt1hZoChoXz1rUH3QPTaRcNiGVH51foBAWDj90nT1z8824MVVzyT\"\n\ttoken4 := Token{\n\t\tTokenId: token4Key,\n\t\tAssetId: assetKey,\n\t\tLenderAddress: \"\",\n\t\tRate: loanDocument.Loan / float64(asset.TokenAmount),\n\t\tIsSell: false,\n\t\tIssueDate: time.Now(),\n\t}\n\n\ttoken5Key := \"0xVx1my9LtDpa3VxVasaxzu3j2YApdKeE2GQDcMARY2zsUi5TzLPC3wyNa2hLTpTyf\"\n\ttoken5 := Token{\n\t\tTokenId: token5Key,\n\t\tAssetId: assetKey,\n\t\tLenderAddress: \"\",\n\t\tRate: loanDocument.Loan / float64(asset.TokenAmount),\n\t\tIsSell: false,\n\t\tIssueDate: time.Now(),\n\t}\n\n\ttoken6Key := \"0xLxU81ZcCKCTOvmFZQL9UUZ4aB7IiJEu01iEtFEuCUoirBGz4AAK8P81mGUMM1TBa\"\n\ttoken6 := Token{\n\t\tTokenId: token6Key,\n\t\tAssetId: assetKey,\n\t\tLenderAddress: \"\",\n\t\tRate: loanDocument.Loan / float64(asset.TokenAmount),\n\t\tIsSell: true,\n\t\tIssueDate: time.Now(),\n\t}\n\n\ttoken7Key := \"0xRxcbOOUjJmcOoj20ZSuPOT2Sv1JB8aaj9SWEQEi09mQbHC2U5TxDIV80zU9tGRNL\"\n\ttoken7 := Token{\n\t\tTokenId: token7Key,\n\t\tAssetId: assetKey,\n\t\tLenderAddress: \"\",\n\t\tRate: loanDocument.Loan / float64(asset.TokenAmount),\n\t\tIsSell: true,\n\t\tIssueDate: time.Now(),\n\t}\n\n\ttoken8Key := \"0xmKVd9OnvjRt7LoGoowwRB3tiYZzM3r4Zc61hdnnrJ8H6Ch5r331vjJQsL8xCPZH4\"\n\ttoken8 := Token{\n\t\tTokenId: token8Key,\n\t\tAssetId: assetKey,\n\t\tLenderAddress: \"\",\n\t\tRate: loanDocument.Loan / float64(asset.TokenAmount),\n\t\tIsSell: true,\n\t\tIssueDate: time.Now(),\n\t}\n\n\ttoken9Key := \"0xtLPCPT5y2qcN7s3MHxyySTn6hB865CL1n0YN8WVTvhcXP2rwZ0QnMTMPZBTB1A2y\"\n\ttoken9 := Token{\n\t\tTokenId: token9Key,\n\t\tAssetId: assetKey,\n\t\tLenderAddress: \"\",\n\t\tRate: loanDocument.Loan / float64(asset.TokenAmount),\n\t\tIsSell: true,\n\t\tIssueDate: time.Now(),\n\t}\n\n\ttoken10Key := \"0xCBvm648FvE3atAIQ72m1auNxAIE1uqqifZti0vZju0PY6S51YteEuaJtLV6YD2hE\"\n\ttoken10 := Token{\n\t\tTokenId: token10Key,\n\t\tAssetId: assetKey,\n\t\tLenderAddress: \"\",\n\t\tRate: loanDocument.Loan / float64(asset.TokenAmount),\n\t\tIsSell: true,\n\t\tIssueDate: time.Now(),\n\t}\n\n\ttoken11Key := \"0x534adsDAdsfkewlvkkjsfweiQQdjefn398fps025hc8NEEIjf11\"\n\ttoken11 := Token{\n\t\tTokenId: token11Key,\n\t\tAssetId: assetA2Key,\n\t\tLenderAddress: \"\",\n\t\tRate: loanDocument2.Loan / float64(assetA2.TokenAmount),\n\t\tIsSell: true,\n\t\tIssueDate: time.Now(),\n\t}\n\n\ttoken12Key := \"0xIJdsdnauGdeworj39NJndop0389djDjfes5iht4ncKJsweovj22\"\n\ttoken12 := Token{\n\t\tTokenId: token12Key,\n\t\tAssetId: assetA2Key,\n\t\tLenderAddress: \"\",\n\t\tRate: loanDocument2.Loan / float64(assetA2.TokenAmount),\n\t\tIsSell: true,\n\t\tIssueDate: time.Now(),\n\t}\n\n\tprintln(\">> START parse token Model to ByteArray <<\")\n\ttoken1AsBytes, err := json.Marshal(token1)\n\tif err != nil {\n\t\tprintln(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t}\n\ttoken2AsBytes, err := json.Marshal(token2)\n\tif err != nil {\n\t\tprintln(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t}\n\ttoken3AsBytes, err := json.Marshal(token3)\n\tif err != nil {\n\t\tprintln(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t}\n\ttoken4AsBytes, err := json.Marshal(token4)\n\tif err != nil {\n\t\tprintln(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t}\n\ttoken5AsBytes, err := json.Marshal(token5)\n\tif err != nil {\n\t\tprintln(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t}\n\ttoken6AsBytes, err := json.Marshal(token6)\n\tif err != nil {\n\t\tprintln(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t}\n\ttoken7AsBytes, err := json.Marshal(token7)\n\tif err != nil {\n\t\tprintln(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t}\n\ttoken8AsBytes, err := json.Marshal(token8)\n\tif err != nil {\n\t\tprintln(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t}\n\ttoken9AsBytes, err := json.Marshal(token9)\n\tif err != nil {\n\t\tprintln(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t}\n\ttoken10AsBytes, err := json.Marshal(token10)\n\tif err != nil {\n\t\tprintln(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t}\n\ttoken11AsBytes, err := json.Marshal(token11)\n\tif err != nil {\n\t\tprintln(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t}\n\ttoken12AsBytes, err := json.Marshal(token12)\n\tif err != nil {\n\t\tprintln(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t\treturn shim.Error(\"Marshal parser token as Model to ByteArray is error\" + err.Error())\n\t}\n\tprintln(\">> END parse token Model to ByteArray <<\")\n\n\t//byteArray put to state blockchain\n\tprintln(\">> START tokenAsBytes PutState to state blockchain <<\")\n\terr = stub.PutState(token1Key, token1AsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\terr = stub.PutState(token2Key, token2AsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\terr = stub.PutState(token3Key, token3AsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\terr = stub.PutState(token4Key, token4AsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\terr = stub.PutState(token5Key, token5AsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\terr = stub.PutState(token6Key, token6AsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\terr = stub.PutState(token7Key, token7AsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\terr = stub.PutState(token8Key, token8AsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\terr = stub.PutState(token9Key, token9AsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\terr = stub.PutState(token10Key, token10AsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\terr = stub.PutState(token11Key, token11AsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\terr = stub.PutState(token12Key, token12AsBytes)\n\tif err != nil {\n\t\tprintln(\"PutState is error\" + err.Error())\n\t\treturn shim.Error(\"PutState is error\" + err.Error())\n\t}\n\tprintln(\">> END tokenAsBytes PutState to state blockchain <<\")\n\n\tprintln(functionName + \" successfully\")\n\tprintln(\"=======================\" + functionName + \"=======================\")\n\treturn shim.Success(nil)\n}", "title": "" }, { "docid": "cff43ba27e0438d6e8132c2fe38bff67", "score": "0.4939334", "text": "func (*whale) SetupWallets(m *Mantle) {\n\tnumCoins := 20\n\tminBaseQty, maxBaseQty, minQuoteQty, maxQuoteQty := symmetricWalletConfig(numCoins, uint64(defaultMidGap*float64(rateEncFactor)+float64(rateStep)*(1+whalePercent*2 /* twice for buffering */)))\n\tm.createWallet(baseSymbol, alpha, minBaseQty, maxBaseQty, numCoins)\n\tm.createWallet(quoteSymbol, alpha, minQuoteQty, maxQuoteQty, numCoins)\n\n\tm.log.Infof(\"Whale has been initialized with %s to %s %s balance, and %s to %s %s balance, %d initial funding coins\",\n\t\tvalString(minBaseQty, baseSymbol), valString(maxBaseQty, baseSymbol), baseSymbol,\n\t\tvalString(minQuoteQty, quoteSymbol), valString(maxQuoteQty, quoteSymbol), quoteSymbol, numCoins)\n\n}", "title": "" }, { "docid": "58236bf7dc12d56d7a9f23433f14f73d", "score": "0.48541084", "text": "func init() {\n\twalletMixin := schema.Wallet{}.Mixin()\n\twalletMixinHooks2 := walletMixin[2].(interface{ Hooks() []ent.Hook }).Hooks()\n\twallet.Hooks[0] = walletMixinHooks2[0]\n\twalletMixinFields1 := walletMixin[1].Fields()\n\twalletMixinFields2 := walletMixin[2].Fields()\n\twalletFields := schema.Wallet{}.Fields()\n\t_ = walletFields\n\t// walletDescCreateTime is the schema descriptor for create_time field.\n\twalletDescCreateTime := walletMixinFields1[0].Descriptor()\n\t// wallet.DefaultCreateTime holds the default value on creation for the create_time field.\n\twallet.DefaultCreateTime = walletDescCreateTime.Default.(func() time.Time)\n\t// walletDescUpdateTime is the schema descriptor for update_time field.\n\twalletDescUpdateTime := walletMixinFields1[1].Descriptor()\n\t// wallet.DefaultUpdateTime holds the default value on creation for the update_time field.\n\twallet.DefaultUpdateTime = walletDescUpdateTime.Default.(func() time.Time)\n\t// wallet.UpdateDefaultUpdateTime holds the default value on update for the update_time field.\n\twallet.UpdateDefaultUpdateTime = walletDescUpdateTime.UpdateDefault.(func() time.Time)\n\t// walletDescVersion is the schema descriptor for version field.\n\twalletDescVersion := walletMixinFields2[0].Descriptor()\n\t// wallet.DefaultVersion holds the default value on creation for the version field.\n\twallet.DefaultVersion = walletDescVersion.Default.(string)\n\t// walletDescLock is the schema descriptor for lock field.\n\twalletDescLock := walletFields[1].Descriptor()\n\t// wallet.DefaultLock holds the default value on creation for the lock field.\n\twallet.DefaultLock = walletDescLock.Default.(bool)\n\t// walletDescBalance is the schema descriptor for balance field.\n\twalletDescBalance := walletFields[2].Descriptor()\n\t// wallet.DefaultBalance holds the default value on creation for the balance field.\n\twallet.DefaultBalance = walletDescBalance.Default.(int)\n\t// wallet.BalanceValidator is a validator for the \"balance\" field. It is called by the builders before save.\n\twallet.BalanceValidator = walletDescBalance.Validators[0].(func(int) error)\n}", "title": "" }, { "docid": "306ef57e716ec4295e31b36a4d09a711", "score": "0.48104724", "text": "func (s *SmartContract) InitLedger(ctx contractapi.TransactionContextInterface) error {\r\n\r\n\tspecialist_ := map[string]int{\"a\":1, \"b\":0, \"c\":1}\r\n\trequestList := map[string]string{\"None\": \"None\"}\r\n\r\n\t// Instance hospital\r\n\thospital_ := Hospital{ID: \"0\", Location: 1, Accommodation: 1, Specialist: specialist_, Request: requestList}\r\n\t\r\n\r\n\thospitalAsBytes, _ := json.Marshal(hospital_)\r\n\terr := ctx.GetStub().PutState(\"0\", hospitalAsBytes)\r\n\tif err != nil {\r\n\t\t\treturn fmt.Errorf(\"Failed to put to world state. %s\", err.Error())\r\n\t\t}\r\n\treturn nil\r\n}", "title": "" }, { "docid": "9551bf50ae28a81c8603a99c018145c1", "score": "0.4797123", "text": "func getInitChainer(mapp *mock.App, keeper Keeper, accountKeeper auth.AccountKeeper, supplyKeeper supply.Keeper,\n\tblacklistedAddrs []supplyexported.ModuleAccountI, stakingKeeper staking.Keeper, bankKeeper bank.Keeper) sdk.InitChainer {\n\treturn func(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {\n\t\t// set module accounts\n\t\tfor _, macc := range blacklistedAddrs {\n\t\t\tsupplyKeeper.SetModuleAccount(ctx, macc)\n\t\t}\n\t\tmapp.InitChainer(ctx, req)\n\n\t\t// set module accounts\n\t\tfor _, macc := range blacklistedAddrs {\n\t\t\tsupplyKeeper.SetModuleAccount(ctx, macc)\n\t\t}\n\t\tstakingGenesis := staking.NewGenesisState(staking.NewParams(staking.DefaultUnbondingTime, staking.DefaultMaxValidators, staking.DefaultMaxEntries, 0, \"ustos\"), nil, nil)\n\t\ttotalSupply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000)))\n\t\tsupplyKeeper.SetSupply(ctx, supply.NewSupply(totalSupply))\n\n\t\t// set module accounts\n\t\tfor _, macc := range blacklistedAddrs {\n\t\t\tsupplyKeeper.SetModuleAccount(ctx, macc)\n\t\t}\n\t\tvalidators := staking.InitGenesis(ctx, stakingKeeper, accountKeeper, supplyKeeper, stakingGenesis)\n\t\tbankGenesis := bank.NewGenesisState(true)\n\t\tbank.InitGenesis(ctx, bankKeeper, bankGenesis)\n\n\t\t//register genesis data load\n\t\tvar lastResourceNodeStakes []LastResourceNodeStake\n\t\tlastResourceNodeStakes = append(lastResourceNodeStakes, LastResourceNodeStake{Address: resNodeAddr1, Stake: resNodeInitStake})\n\n\t\tvar lastIndexingNodeStakes []LastIndexingNodeStake\n\t\tlastIndexingNodeStakes = append(lastIndexingNodeStakes, LastIndexingNodeStake{Address: idxNodeAddr1, Stake: idxNodeInitStake})\n\t\tlastIndexingNodeStakes = append(lastIndexingNodeStakes, LastIndexingNodeStake{Address: idxNodeAddr2, Stake: idxNodeInitStake})\n\n\t\tresourceNodes := setupAllResourceNodes()\n\t\tindexingNodes := setupAllIndexingNodes()\n\n\t\tregisterGenesis := NewGenesisState(DefaultParams(), lastResourceNodeStakes, resourceNodes, lastIndexingNodeStakes, indexingNodes)\n\n\t\tInitGenesis(ctx, keeper, registerGenesis)\n\n\t\treturn abci.ResponseInitChain{\n\t\t\tValidators: validators,\n\t\t}\n\t}\n\n}", "title": "" }, { "docid": "39a836d9aec42d9084c6086b1ed8d0a8", "score": "0.47805187", "text": "func NewSetup(t *testing.T, rng *rand.Rand, n int) *Setup {\n\ts := &Setup{\n\t\tSimSetup: *NewSimSetup(rng),\n\t\tAccs: make([]*keystore.Account, n),\n\t\tParts: make([]wallet.Address, n),\n\t\tRecvs: make([]*ethwallet.Address, n),\n\t\tFunders: make([]*ethchannel.Funder, n),\n\t\tAdjs: make([]*SimAdjudicator, n),\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), defaultTxTimeout)\n\tdefer cancel()\n\tadjudicator, err := ethchannel.DeployAdjudicator(ctx, *s.CB, s.TxSender.Account)\n\trequire.NoError(t, err)\n\ts.Asset, err = ethchannel.DeployETHAssetholder(ctx, *s.CB, adjudicator, s.TxSender.Account)\n\trequire.NoError(t, err)\n\tasset := ethchannel.Asset(s.Asset)\n\n\tksWallet := wallettest.RandomWallet().(*keystore.Wallet)\n\trequire.NoErrorf(t, err, \"initializing wallet from test keystore\")\n\tfor i := 0; i < n; i++ {\n\t\ts.Accs[i] = ksWallet.NewRandomAccount(rng).(*keystore.Account)\n\t\ts.Parts[i] = s.Accs[i].Address()\n\t\ts.SimBackend.FundAddress(ctx, s.Accs[i].Account.Address)\n\t\ts.Recvs[i] = ksWallet.NewRandomAccount(rng).Address().(*ethwallet.Address)\n\t\tcb := ethchannel.NewContractBackend(s.SimBackend, keystore.NewTransactor(*ksWallet, types.NewEIP155Signer(big.NewInt(1337))))\n\t\taccounts := map[ethchannel.Asset]accounts.Account{asset: s.Accs[i].Account}\n\t\tdepositors := map[ethchannel.Asset]ethchannel.Depositor{asset: new(ethchannel.ETHDepositor)}\n\t\ts.Funders[i] = ethchannel.NewFunder(cb, accounts, depositors)\n\t\ts.Adjs[i] = NewSimAdjudicator(cb, adjudicator, common.Address(*s.Recvs[i]), s.Accs[i].Account)\n\t}\n\n\treturn s\n}", "title": "" }, { "docid": "e98996a4aaca8e33bac903ae8608f057", "score": "0.47715575", "text": "func newWallet(c *cli.Context) (err error) {\n\ts := []byte(c.Args().First())\n\t//Generate secp256k1 private key\n\th1 := sha3.Sum256(s)\n\th2 := sha3.Sum256(h1[:])\n\tprivate := h2[:]\n\tfmt.Printf(\"Secp256k1 private key in hexadecimal is : %X\\n\", h2)\n\n\t//WIF private key\n\tk := append([]byte{0x80}, private...)\n\thk := sha2(k)\n\tkey := append(k, hk[:4]...)\n\twif := base58.Encode(key)\n\tfmt.Printf(\"WIF private key is : %s\\n\", wif)\n\n\t//Address\n\t_, pub := secp256k1.PrivKeyFromBytes(private)\n\ts256 := sha256.Sum256(pub.SerializeUncompressed())\n\tr := ripemd160.New()\n\tr.Write(s256[:])\n\tr160 := r.Sum(nil)\n\taddr := append([]byte{0x00}, r160...)\n\tha := sha2(addr)\n\taddress := base58.Encode(append(addr, ha[:4]...))\n\tfmt.Printf(\"Address is : %s\\n\", address)\n\n\treturn nil\n}", "title": "" }, { "docid": "882791c6c2cfe1bf9aef9b1c26383ff5", "score": "0.4769495", "text": "func Test_GenerateWalletWithDummyFunds(t *testing.T) {\n\tnotSolo := notsolo.New(t)\n\n\t// Generates a key pair for a wallet and provides it with dummy funds.\n\t// The amount is defined in Wasp (constant testutil.RequestFundsAmount) and WaspConn plug-in (constant utxodb.RequestFundsAmount)\n\twalletSigScheme := notSolo.SigScheme.NewSignatureSchemeWithFunds()\n\n\t// Uses the walletSigScheme to get the wallet address and ensures the balance is as expected\n\tnotSolo.ValueTangle.RequireBalance(walletSigScheme, balance.ColorIOTA, initialWalletFunds)\n}", "title": "" }, { "docid": "459d6043acc63b56a32d56e89a40aafd", "score": "0.47643986", "text": "func New(cs modules.ConsensusSet, tpool modules.TransactionPool, saveDir string) (w *Wallet, err error) {\n\tif cs == nil {\n\t\terr = errors.New(\"wallet cannot use a nil state\")\n\t\treturn\n\t}\n\tif tpool == nil {\n\t\terr = errors.New(\"wallet cannot use a nil transaction pool\")\n\t\treturn\n\t}\n\n\tw = &Wallet{\n\t\tstate: cs,\n\t\ttpool: tpool,\n\n\t\tsaveDir: saveDir,\n\n\t\tage: AgeDelay + 100,\n\t\tkeys: make(map[types.UnlockHash]*key),\n\t\ttimelockedKeys: make(map[types.BlockHeight][]types.UnlockHash),\n\t\tvisibleAddresses: make(map[types.UnlockHash]struct{}),\n\t\tsiafundAddresses: make(map[types.UnlockHash]struct{}),\n\t\tsiafundOutputs: make(map[types.SiafundOutputID]types.SiafundOutput),\n\n\t\ttransactions: make(map[string]*openTransaction),\n\n\t\tmu: sync.New(modules.SafeMutexDelay, 1),\n\t}\n\n\t// Create the wallet folder.\n\terr = os.MkdirAll(saveDir, 0700)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Try to load a previously saved wallet file. If it doesn't exist, assume\n\t// that we're creating a new wallet file.\n\t// TODO: log warning if no file found?\n\terr = w.load()\n\tif os.IsNotExist(err) {\n\t\terr = nil\n\t\t// No wallet file exists... make a visible address for the user.\n\t\t_, _, err = w.coinAddress(true)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tif err != nil {\n\t\terr = fmt.Errorf(\"couldn't load wallet file %s: %v\", saveDir, err)\n\t\treturn\n\t}\n\n\tw.tpool.TransactionPoolSubscribe(w)\n\n\treturn\n}", "title": "" }, { "docid": "afe2283e81fb6f10adcf9320a5feaa78", "score": "0.47537053", "text": "func (i *impl) SetUp(ctx context.Context, s *testing.FixtState) interface{} {\n\tnoSSHVar, ok := s.Var(\"noSSH\")\n\ti.disallowSSH = false\n\tif ok {\n\t\tforbidSSH, err := strconv.ParseBool(noSSHVar)\n\t\tif err != nil {\n\t\t\ts.Fatalf(\"Invalid value for var noSSH: got %q, want true/false\", noSSHVar)\n\t\t}\n\t\ti.disallowSSH = forbidSSH\n\t}\n\ts.Log(\"Creating a new firmware Helper instance for fixture: \", i.String())\n\ti.initHelper(ctx, s)\n\n\tif i.disallowSSH {\n\t\ts.Log(\"Skipping GBB and reboot because noSSH var was set\")\n\t\treturn i.value\n\t}\n\n\tflags := pb.GBBFlagsState{Clear: common.AllGBBFlags(), Set: common.FAFTGBBFlags()}\n\tif i.value.ForcesDevMode {\n\t\tif i.value.BootMode == common.BootModeUSBDev {\n\t\t\tcommon.GBBAddFlag(&flags, pb.GBBFlag_FORCE_DEV_SWITCH_ON, pb.GBBFlag_DEV_SCREEN_SHORT_DELAY, pb.GBBFlag_FORCE_DEV_BOOT_USB)\n\t\t} else {\n\t\t\tcommon.GBBAddFlag(&flags, pb.GBBFlag_FORCE_DEV_SWITCH_ON, pb.GBBFlag_DEV_SCREEN_SHORT_DELAY)\n\t\t}\n\t}\n\tnoECSync, err := i.noECSync(s)\n\tif err != nil {\n\t\ts.Fatal(\"ECSync: \", err)\n\t}\n\tif noECSync {\n\t\tcommon.GBBAddFlag(&flags, pb.GBBFlag_DISABLE_EC_SOFTWARE_SYNC)\n\t\ts.Log(\"User selected to disable EC software sync\")\n\t}\n\ti.value.GBBFlags = &flags\n\t// If rebooting to recovery mode, verify the usb key.\n\tif i.value.BootMode == common.BootModeRecovery || i.value.BootMode == common.BootModeUSBDev {\n\t\tif err := i.value.Helper.RequireServo(ctx); err != nil {\n\t\t\ts.Error(\"Test did not run\")\n\t\t\ts.Fatal(\"Failed to connect to servod: \", err)\n\t\t}\n\t\tskipFlashUSB := false\n\t\tif skipFlashUSBStr, ok := s.Var(\"firmware.skipFlashUSB\"); ok {\n\t\t\tskipFlashUSB, err = strconv.ParseBool(skipFlashUSBStr)\n\t\t\tif err != nil {\n\t\t\t\ts.Fatalf(\"Invalid value for var firmware.skipFlashUSB: got %q, want true/false\", skipFlashUSBStr)\n\t\t\t}\n\t\t}\n\t\tcs := s.CloudStorage()\n\t\tif skipFlashUSB {\n\t\t\tcs = nil\n\t\t}\n\t\tif err := i.value.Helper.SetupUSBKey(ctx, cs); err != nil {\n\t\t\ts.Fatal(\"Failed to setup USB key: \", err)\n\t\t}\n\t}\n\treturn i.value\n}", "title": "" }, { "docid": "df9d3522d7b016c4137e602f6f77d8c0", "score": "0.47452274", "text": "func walletRunner(cmd *cobra.Command, args []string) {\n\t//initialize empty wallet\n\tmemoryWallet := wallet.PassgenWallet{\n\t\tVersion: \"1.0\",\n\t\tWallet: make(map[string]wallet.Item),\n\t}\n\n\t// Read encrypted wallet as a byte array\n\tencryptedWallet, fileReadErr := ioutil.ReadFile(walletPath)\n\tif fileReadErr != nil {\n\t\twalletCreationApproval := false\n\t\tprompt := &survey.Confirm{\n\t\t\tMessage: \"Seems like you don't have any wallet. Would you like to create one?\",\n\t\t}\n\t\tsurvey.AskOne(prompt, &walletCreationApproval, nil)\n\n\t\tif !walletCreationApproval {\n\t\t\tlog.Fatalln(\"Wallet operations are aborted!\")\n\t\t}\n\t}\n\n\t// Update survey messages depending on wallet's existence\n\tpasswordSurveyMessage := \"What is your wallet's password :\"\n\tpasswordSurveyHelp := \"Write your wallet's password for unlocking it\"\n\tif fileReadErr != nil {\n\t\tpasswordSurveyMessage = \"Enter password for your wallet :\"\n\t\tpasswordSurveyHelp = \"Write a password for locking your new wallet\"\n\t}\n\n\twalletPassword := \"\"\n\tprompt := &survey.Password{\n\t\tMessage: passwordSurveyMessage,\n\t\tHelp: passwordSurveyHelp,\n\t}\n\n\tsurveyErr := survey.AskOne(prompt, &walletPassword, func(val interface{}) error {\n\t\tif utf8.RuneCountInString(val.(string)) < 8 {\n\t\t\treturn errors.New(\"value is too short. Min length is 8\")\n\t\t}\n\n\t\tif !strings.ContainsAny(val.(string), string(generators.GenerateKeyboardWritableRunePool(\"U\"))) {\n\t\t\treturn errors.New(\"insecure password. Your password must contain at least one upper-case character\")\n\t\t}\n\n\t\tif !strings.ContainsAny(val.(string), string(generators.GenerateKeyboardWritableRunePool(\"L\"))) {\n\t\t\treturn errors.New(\"insecure password. Your password must contain at least one lower-case character\")\n\t\t}\n\n\t\tif !strings.ContainsAny(val.(string), string(generators.GenerateKeyboardWritableRunePool(\"N\"))) {\n\t\t\treturn errors.New(\"insecure password. Your password must contain at least one digit\")\n\t\t}\n\n\t\tif !strings.ContainsAny(val.(string), string(generators.GenerateKeyboardWritableRunePool(\"S\"))) {\n\t\t\treturn errors.New(\"insecure password. Your password must contain at least one symbol\")\n\t\t}\n\n\t\treturn nil\n\t})\n\tif surveyErr != nil {\n\t\tos.Exit(1)\n\t}\n\n\t// if there is no read error then decrypt and unmarshal wallet\n\tif fileReadErr == nil {\n\t\tdecryptedWallet, decryptionErr := helpers.AES256Decrypt(walletPassword, encryptedWallet)\n\t\tif decryptionErr != nil {\n\t\t\tlog.Fatalln(decryptionErr)\n\t\t}\n\n\t\tbyteReader := bytes.NewReader(decryptedWallet)\n\n\t\tdecoder := gob.NewDecoder(byteReader)\n\t\terr := decoder.Decode(&memoryWallet)\n\t\tif err != nil {\n\t\t\tlog.Fatalln(err)\n\t\t}\n\t}\n\nwalletLoop:\n\tfor {\n\t\twalletItemKey := \"\"\n\t\tallKeys := []string{\"Generate\", \"Add\", \"List\", \"Update\", \"Remove\", \"Save & Lock\", \"Lock Without Saving\"}\n\n\t\tprompt := &survey.Select{\n\t\t\tMessage: \"What do you want to do on your wallet :\",\n\t\t\tHelp: \"Select what to do on your wallet\",\n\t\t\tOptions: allKeys,\n\t\t}\n\t\terr := survey.AskOne(prompt, &walletItemKey, func(val interface{}) error {\n\t\t\tif utf8.RuneCountInString(val.(string)) == 0 {\n\t\t\t\treturn errors.New(\"this is not valid selection\")\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t\tif err != nil {\n\t\t\tlog.Fatalln(err)\n\t\t}\n\n\t\tswitch walletItemKey {\n\t\tcase \"Generate\":\n\t\t\twallet.Use(&memoryWallet)\n\t\tcase \"Add\":\n\t\t\twallet.Add(&memoryWallet)\n\t\tcase \"List\":\n\t\t\twallet.List(&memoryWallet)\n\t\tcase \"Update\":\n\t\t\twallet.Update(&memoryWallet)\n\t\tcase \"Remove\":\n\t\t\twallet.Remove(&memoryWallet)\n\t\tcase \"Save & Lock\":\n\t\t\terr := wallet.Save(walletPassword, &memoryWallet, walletPath)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tbreak walletLoop\n\t\tcase \"Lock Without Saving\":\n\t\t\tbreak walletLoop\n\t\t}\n\t}\n}", "title": "" }, { "docid": "e6c046fd70259be6f5a002b9f1053247", "score": "0.47156414", "text": "func TestPaymentChannelVoucherCreateShortfall(t *testing.T) {\n\t_ = os.Setenv(\"BELLMAN_NO_GPU\", \"1\")\n\n\tblocktime := 5 * time.Millisecond\n\tctx := context.Background()\n\tnodes, addrs := startTwoNodesOneMiner(ctx, t, blocktime)\n\tpaymentCreator := nodes[0]\n\tcreatorAddr := addrs[0]\n\treceiverAddr := addrs[1]\n\n\t// Create mock CLI\n\tmockCLI := newMockCLI(t)\n\tcreatorCLI := mockCLI.client(paymentCreator.ListenAddr)\n\n\t// creator: paych add-funds <creator> <receiver> <amount>\n\tchannelAmt := 100\n\tcmd := []string{creatorAddr.String(), receiverAddr.String(), fmt.Sprintf(\"%d\", channelAmt)}\n\tchstr := creatorCLI.runCmd(paychAddFundsCmd, cmd)\n\n\tchAddr, err := address.NewFromString(chstr)\n\trequire.NoError(t, err)\n\n\t// creator: paych voucher create <channel> <amount> --lane=1\n\tvoucherAmt1 := 60\n\tlane1 := \"--lane=1\"\n\tcmd = []string{lane1, chAddr.String(), strconv.Itoa(voucherAmt1)}\n\tvoucher1 := creatorCLI.runCmd(paychVoucherCreateCmd, cmd)\n\tfmt.Println(voucher1)\n\n\t// creator: paych voucher create <channel> <amount> --lane=2\n\tlane2 := \"--lane=2\"\n\tvoucherAmt2 := 70\n\tcmd = []string{lane2, chAddr.String(), strconv.Itoa(voucherAmt2)}\n\t_, err = creatorCLI.runCmdRaw(paychVoucherCreateCmd, cmd)\n\n\t// Should fail because channel doesn't have required amount\n\trequire.Error(t, err)\n\n\tshortfall := voucherAmt1 + voucherAmt2 - channelAmt\n\trequire.Regexp(t, regexp.MustCompile(fmt.Sprintf(\"shortfall: %d\", shortfall)), err.Error())\n}", "title": "" }, { "docid": "9ff61b64c7ace1cdfb67fbac86af1802", "score": "0.47069883", "text": "func GenWallet(testnet bool) {\n\tnet := \"mainnet\"\n\tif testnet {\n\t\tnet = \"testnet\"\n\t}\n\tlog.Printf(\"Generate bitcoin %s address\\n\", net)\n\n\tmyWallet := NewWallet()\n\n\tif !testnet {\n\t\tparams := ParamsMainNet\n\t\tmyMainNetP2PKH := myWallet.GetAddressPubKeyHash(&params)\n\t\tlog.Println(\"P2PKH:\", string(myMainNetP2PKH))\n\t\tmyMainNetP2SH := myWallet.GetAddressScriptHash(&params)\n\t\tlog.Println(\"P2SH:\", string(myMainNetP2SH))\n\t\tmyMainNetP2WSH := myWallet.GetAddressWitnessScriptHash(&params)\n\t\tlog.Println(\"P2WSH:\", string(myMainNetP2WSH))\n\t\tmyMainNetWif := myWallet.GetWif(&params)\n\t\tlog.Println(\"Private key:\", string(myMainNetWif))\n\t} else if testnet {\n\t\tparams := ParamsTestNet\n\t\tmyTestNetP2PKH := myWallet.GetAddressPubKeyHash(&params)\n\t\tlog.Println(\"TestNet P2PKH:\", string(myTestNetP2PKH))\n\t\tmyTestNetP2SH := myWallet.GetAddressScriptHash(&params)\n\t\tlog.Println(\"TestNet P2SH:\", string(myTestNetP2SH))\n\t\tmyTestNetP2WSH := myWallet.GetAddressWitnessScriptHash(&params)\n\t\tlog.Println(\"TestNet P2WSH:\", string(myTestNetP2WSH))\n\t\tmyTestNetWif := myWallet.GetWif(&params)\n\t\tlog.Println(\"Private key:\", string(myTestNetWif))\n\t}\n}", "title": "" }, { "docid": "7ffb1074cbab46b871fd1d4e8c5b5c62", "score": "0.46893558", "text": "func (s *Server) WalletInitLocal(ctx context.Context) (err error) {\n\tctx, err, fin := s.Preamble(ctx, preambleArg{\n\t\tRPCName: \"WalletInitLocal\",\n\t\tErr: &err,\n\t})\n\tdefer fin()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = stellar.CreateWallet(ctx, s.G())\n\treturn err\n}", "title": "" }, { "docid": "2d2f34f3be1e87206cfe60f7de023247", "score": "0.46847555", "text": "func InitSandboxBench(_ *testing.B, start time.Time) {\n\tinitSandboxMode(start)\n}", "title": "" }, { "docid": "2c8c2ddca031281979ffcd10c72bcdd3", "score": "0.46674427", "text": "func CreateTestInputAdvanced(t *testing.T, isCheckTx bool, initPower int64,\n\tcommunityTax sdk.Dec) (sdk.Context, auth.AccountKeeper, bank.Keeper,\n\tKeeper, staking.Keeper, params.Keeper, types.SupplyKeeper) {\n\n\tinitTokens := sdk.TokensFromConsensusPower(initPower)\n\n\tkeyDistr := sdk.NewKVStoreKey(types.StoreKey)\n\tkeyStaking := sdk.NewKVStoreKey(staking.StoreKey)\n\ttkeyStaking := sdk.NewTransientStoreKey(staking.TStoreKey)\n\tkeyAcc := sdk.NewKVStoreKey(auth.StoreKey)\n\tkeySupply := sdk.NewKVStoreKey(supply.StoreKey)\n\tkeyParams := sdk.NewKVStoreKey(params.StoreKey)\n\ttkeyParams := sdk.NewTransientStoreKey(params.TStoreKey)\n\n\tdb := dbm.NewMemDB()\n\tms := store.NewCommitMultiStore(db)\n\n\tms.MountStoreWithDB(keyDistr, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(tkeyStaking, sdk.StoreTypeTransient, nil)\n\tms.MountStoreWithDB(keyStaking, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(keySupply, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(keyAcc, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(keyParams, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(tkeyParams, sdk.StoreTypeTransient, db)\n\n\terr := ms.LoadLatestVersion()\n\trequire.Nil(t, err)\n\n\tfeeCollectorAcc := supply.NewEmptyModuleAccount(auth.FeeCollectorName)\n\tnotBondedPool := supply.NewEmptyModuleAccount(staking.NotBondedPoolName, supply.Burner, supply.Staking)\n\tbondPool := supply.NewEmptyModuleAccount(staking.BondedPoolName, supply.Burner, supply.Staking)\n\n\tblacklistedAddrs := make(map[string]bool)\n\tblacklistedAddrs[feeCollectorAcc.String()] = true\n\tblacklistedAddrs[notBondedPool.String()] = true\n\tblacklistedAddrs[bondPool.String()] = true\n\tblacklistedAddrs[distrAcc.String()] = true\n\n\tcdc := MakeTestCodec()\n\tpk := params.NewKeeper(cdc, keyParams, tkeyParams)\n\n\tctx := sdk.NewContext(ms, abci.Header{ChainID: \"foochainid\"}, isCheckTx, log.NewNopLogger())\n\taccountKeeper := auth.NewAccountKeeper(cdc, keyAcc, pk.Subspace(auth.DefaultParamspace), auth.ProtoBaseAccount)\n\tbankKeeper := bank.NewBaseKeeper(accountKeeper, pk.Subspace(bank.DefaultParamspace), blacklistedAddrs)\n\tmaccPerms := map[string][]string{\n\t\tauth.FeeCollectorName: nil,\n\t\ttypes.ModuleName: nil,\n\t\tstaking.NotBondedPoolName: {supply.Burner, supply.Staking},\n\t\tstaking.BondedPoolName: {supply.Burner, supply.Staking},\n\t}\n\tsupplyKeeper := supply.NewKeeper(cdc, keySupply, accountKeeper, bankKeeper, maccPerms)\n\n\tsk := staking.NewKeeper(cdc, keyStaking, tkeyStaking, supplyKeeper, pk.Subspace(staking.DefaultParamspace))\n\tsk.SetParams(ctx, staking.DefaultParams())\n\n\tkeeper := NewKeeper(cdc, keyDistr, pk.Subspace(DefaultParamspace), sk, supplyKeeper, auth.FeeCollectorName, blacklistedAddrs)\n\n\tinitCoins := sdk.NewCoins(sdk.NewCoin(sk.BondDenom(ctx), initTokens))\n\ttotalSupply := sdk.NewCoins(sdk.NewCoin(sk.BondDenom(ctx), initTokens.MulRaw(int64(len(TestAddrs)))))\n\tsupplyKeeper.SetSupply(ctx, supply.NewSupply(totalSupply))\n\n\t// fill all the addresses with some coins, set the loose pool tokens simultaneously\n\tfor _, addr := range TestAddrs {\n\t\t_, err := bankKeeper.AddCoins(ctx, addr, initCoins)\n\t\trequire.Nil(t, err)\n\t}\n\n\t// set module accounts\n\tkeeper.supplyKeeper.SetModuleAccount(ctx, feeCollectorAcc)\n\tkeeper.supplyKeeper.SetModuleAccount(ctx, notBondedPool)\n\tkeeper.supplyKeeper.SetModuleAccount(ctx, bondPool)\n\tkeeper.supplyKeeper.SetModuleAccount(ctx, distrAcc)\n\n\t// set the distribution hooks on staking\n\tsk.SetHooks(keeper.Hooks())\n\n\t// set genesis items required for distribution\n\tkeeper.SetFeePool(ctx, types.InitialFeePool())\n\tkeeper.SetCommunityTax(ctx, communityTax)\n\tkeeper.SetBaseProposerReward(ctx, sdk.NewDecWithPrec(1, 2))\n\tkeeper.SetBonusProposerReward(ctx, sdk.NewDecWithPrec(4, 2))\n\n\treturn ctx, accountKeeper, bankKeeper, keeper, sk, pk, supplyKeeper\n}", "title": "" }, { "docid": "f9f5e5c3e47c884dbbf9aca252da53cc", "score": "0.46596155", "text": "func CreateTestInput(t *testing.T, isCheckTx bool, initPower int64) (sdk.Context, auth.AccountKeeper, Keeper, types.SupplyKeeper) {\n\tkeyStaking := sdk.NewKVStoreKey(types.StoreKey)\n\ttkeyStaking := sdk.NewTransientStoreKey(types.TStoreKey)\n\tkeyAcc := sdk.NewKVStoreKey(auth.StoreKey)\n\tkeyParams := sdk.NewKVStoreKey(params.StoreKey)\n\ttkeyParams := sdk.NewTransientStoreKey(params.TStoreKey)\n\tkeySupply := sdk.NewKVStoreKey(supply.StoreKey)\n\n\tdb := dbm.NewMemDB()\n\tms := store.NewCommitMultiStore(db)\n\tms.MountStoreWithDB(tkeyStaking, sdk.StoreTypeTransient, nil)\n\tms.MountStoreWithDB(keyStaking, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(keyAcc, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(keyParams, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(tkeyParams, sdk.StoreTypeTransient, db)\n\tms.MountStoreWithDB(keySupply, sdk.StoreTypeIAVL, db)\n\terr := ms.LoadLatestVersion()\n\trequire.Nil(t, err)\n\n\tctx := sdk.NewContext(ms, abci.Header{ChainID: \"foochainid\"}, isCheckTx, log.NewNopLogger())\n\tctx = ctx.WithConsensusParams(\n\t\t&abci.ConsensusParams{\n\t\t\tValidator: &abci.ValidatorParams{\n\t\t\t\tPubKeyTypes: []string{tmtypes.ABCIPubKeyTypeEd25519},\n\t\t\t},\n\t\t},\n\t)\n\tcdc := MakeTestCodec()\n\n\tfeeCollectorAcc := supply.NewEmptyModuleAccount(auth.FeeCollectorName)\n\tnotBondedPool := supply.NewEmptyModuleAccount(types.NotBondedPoolName, supply.Burner, supply.Staking)\n\tbondPool := supply.NewEmptyModuleAccount(types.BondedPoolName, supply.Burner, supply.Staking)\n\n\tblacklistedAddrs := make(map[string]bool)\n\tblacklistedAddrs[feeCollectorAcc.String()] = true\n\tblacklistedAddrs[notBondedPool.String()] = true\n\tblacklistedAddrs[bondPool.String()] = true\n\n\tpk := params.NewKeeper(cdc, keyParams, tkeyParams)\n\n\taccountKeeper := auth.NewAccountKeeper(\n\t\tcdc, // amino codec\n\t\tkeyAcc, // target store\n\t\tpk.Subspace(auth.DefaultParamspace),\n\t\tauth.ProtoBaseAccount, // prototype\n\t)\n\n\tbk := bank.NewBaseKeeper(\n\t\taccountKeeper,\n\t\tpk.Subspace(bank.DefaultParamspace),\n\t\tblacklistedAddrs,\n\t)\n\n\tmaccPerms := map[string][]string{\n\t\tauth.FeeCollectorName: nil,\n\t\ttypes.NotBondedPoolName: {supply.Burner, supply.Staking},\n\t\ttypes.BondedPoolName: {supply.Burner, supply.Staking},\n\t}\n\tsupplyKeeper := supply.NewKeeper(cdc, keySupply, accountKeeper, bk, maccPerms)\n\n\tinitTokens := sdk.TokensFromConsensusPower(initPower)\n\tinitCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initTokens))\n\ttotalSupply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initTokens.MulRaw(int64(len(Addrs)))))\n\n\tsupplyKeeper.SetSupply(ctx, supply.NewSupply(totalSupply))\n\n\tkeeper := NewKeeper(cdc, keyStaking, tkeyStaking, supplyKeeper, pk.Subspace(DefaultParamspace))\n\tkeeper.SetParams(ctx, types.DefaultParams())\n\n\t// set module accounts\n\terr = notBondedPool.SetCoins(totalSupply)\n\trequire.NoError(t, err)\n\n\tsupplyKeeper.SetModuleAccount(ctx, feeCollectorAcc)\n\tsupplyKeeper.SetModuleAccount(ctx, bondPool)\n\tsupplyKeeper.SetModuleAccount(ctx, notBondedPool)\n\n\t// fill all the addresses with some coins, set the loose pool tokens simultaneously\n\tfor _, addr := range Addrs {\n\t\t_, err := bk.AddCoins(ctx, addr, initCoins)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\n\treturn ctx, accountKeeper, keeper, supplyKeeper\n}", "title": "" }, { "docid": "ff9d87d24e46efcef3961b85655db6df", "score": "0.46432006", "text": "func (z *ZBox) InitWallet(js string) error {\n\treturn json.Unmarshal([]byte(js), &z.Wallet)\n}", "title": "" }, { "docid": "5d4846360f8dd968fb433d992349a245", "score": "0.4636617", "text": "func InitializeWallet(rt *sdkrouter.Router, uid int) (*models.LbrynetServer, string, error) {\n\twid := wallet.MakeID(uid)\n\tlog := Logger.LogF(monitor.F{\"wallet_id\": wid, \"user_id\": uid})\n\twallet, lbrynetServer, err := CreateWallet(rt, uid)\n\tif err != nil {\n\t\tif errors.As(err, &WalletExists{}) {\n\t\t\tlog.Warn(err.Error())\n\t\t\treturn lbrynetServer, wid, nil\n\t\t} else if errors.As(err, &WalletNeedsLoading{}) {\n\t\t\tlog.Info(err.Error())\n\t\t\twallet, err = AddWallet(rt, uid)\n\t\t\tif err != nil && errors.As(err, &WalletAlreadyLoaded{}) {\n\t\t\t\tlog.Info(err.Error())\n\t\t\t\treturn lbrynetServer, wid, nil\n\t\t\t}\n\t\t} else {\n\t\t\tlog.Error(\"don't know how to recover from error: \", err)\n\t\t\treturn lbrynetServer, \"\", err\n\t\t}\n\t}\n\treturn lbrynetServer, wallet.ID, nil\n}", "title": "" }, { "docid": "2b6914ef75a10a5c5d068f123285bc41", "score": "0.46261466", "text": "func (t *SellSalmon) Init(stub shim.ChaincodeStubInterface) peer.Response {\n\t// Get the args from the transaction proposal\n\targs := stub.GetStringArgs()\n\tif len(args) != 2 {\n\t\treturn shim.Error(\"Incorrect arguments. Expecting a key and a value\")\n\t}\n\n\t// Set up any variables00000 or assets here by calling stub.PutState()\n\n\t// We store the key and the value on the ledger\n\terr := stub.PutState(args[0], []byte(args[1]))\n\tif err != nil {\n\t\treturn shim.Error(fmt.Sprintf(\"Failed to create asset: %s\", args[0]))\n\t}\n\treturn shim.Success(nil)\n}", "title": "" }, { "docid": "2b6914ef75a10a5c5d068f123285bc41", "score": "0.46261466", "text": "func (t *SellSalmon) Init(stub shim.ChaincodeStubInterface) peer.Response {\n\t// Get the args from the transaction proposal\n\targs := stub.GetStringArgs()\n\tif len(args) != 2 {\n\t\treturn shim.Error(\"Incorrect arguments. Expecting a key and a value\")\n\t}\n\n\t// Set up any variables00000 or assets here by calling stub.PutState()\n\n\t// We store the key and the value on the ledger\n\terr := stub.PutState(args[0], []byte(args[1]))\n\tif err != nil {\n\t\treturn shim.Error(fmt.Sprintf(\"Failed to create asset: %s\", args[0]))\n\t}\n\treturn shim.Success(nil)\n}", "title": "" }, { "docid": "e371df00ce84f050f44c20ee5addb529", "score": "0.46245798", "text": "func NewWallet(filename, label, seed, seedPassphrase string, options ...wallet.Option) (*Wallet, error) {\n\twlt := &Wallet{\n\t\tMeta: wallet.Meta{\n\t\t\twallet.MetaFilename: filename,\n\t\t\twallet.MetaLabel: label,\n\t\t\twallet.MetaSeed: seed,\n\t\t\twallet.MetaSeedPassphrase: seedPassphrase,\n\t\t\twallet.MetaEncrypted: \"false\",\n\t\t\twallet.MetaType: WalletType,\n\t\t\twallet.MetaVersion: wallet.Version,\n\t\t\twallet.MetaCoin: string(wallet.CoinTypeSkycoin),\n\t\t\twallet.MetaCryptoType: string(crypto.DefaultCryptoType),\n\t\t\twallet.MetaTimestamp: strconv.FormatInt(time.Now().Unix(), 10),\n\t\t},\n\t\taccountManager: &bip44Accounts{},\n\t\tdecoder: defaultWalletDecoder,\n\t}\n\n\tadvOpts := wallet.AdvancedOptions{}\n\t// applies options to wallet and AdvancedOptions\n\tfor _, opt := range options {\n\t\topt(wlt)\n\t\topt(&advOpts)\n\t}\n\n\tif wlt.Bip44Coin() == nil {\n\t\tswitch wlt.Coin() {\n\t\tcase wallet.CoinTypeSkycoin:\n\t\t\twlt.SetBip44Coin(bip44.CoinTypeSkycoin)\n\t\tcase wallet.CoinTypeBitcoin:\n\t\t\twlt.SetBip44Coin(bip44.CoinTypeBitcoin)\n\t\tdefault:\n\t\t\treturn nil, errors.New(\"bip44 coin type not set\")\n\t\t}\n\t}\n\n\t// validateMeta wallet before encrypting\n\tif err := validateMeta(wlt.Meta); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// generates a default account\n\tvar accountName = DefaultAccountName\n\tif advOpts.DefaultBip44AccountName != \"\" {\n\t\taccountName = advOpts.DefaultBip44AccountName\n\t}\n\n\t_, err := wlt.NewAccount(accountName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"generate default account failed: %v\", err)\n\t}\n\n\t// Generate addresses if options.GenrateN > 0\n\tgenerateN := advOpts.GenerateN\n\tif generateN == 0 {\n\t\tgenerateN = 1\n\t}\n\n\tif _, err := wlt.GenerateAddresses(generateN); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Generate a default change address\n\tif _, err := wlt.GenerateAddresses(1, wallet.OptionChange(true)); err != nil {\n\t\treturn nil, err\n\t}\n\n\tscanN := advOpts.ScanN\n\t// scans addresses if options.ScanN > 0\n\tif scanN > 0 {\n\t\tif advOpts.TF == nil {\n\t\t\treturn nil, errors.New(\"missing transaction finder for scanning addresses\")\n\t\t}\n\n\t\tif scanN > generateN {\n\t\t\tscanN = scanN - generateN\n\t\t}\n\n\t\t_, err := wlt.ScanAddresses(scanN, advOpts.TF)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// encrypts wallet if options.Encrypt is true\n\tif advOpts.Encrypt {\n\t\tif len(advOpts.Password) == 0 {\n\t\t\treturn nil, errors.New(\"missing password for encrypting wallet\")\n\t\t}\n\n\t\tif err := wlt.Lock(advOpts.Password); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// validateMeta the wallet again after encrypted\n\tif err := validateMeta(wlt.Meta); err != nil {\n\t\treturn nil, err\n\t}\n\treturn wlt, nil\n}", "title": "" }, { "docid": "98b5760b43fe9e79c3a60c7814477c11", "score": "0.46120232", "text": "func New(pass string, sigserv string, slotc chan string) (*Wormhole, error) {\n\tc := &Wormhole{\n\t\topened: make(chan struct{}),\n\t\terr: make(chan error),\n\t\tflushc: sync.NewCond(&sync.Mutex{}),\n\t}\n\n\tu, err := url.Parse(sigserv)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif u.Scheme == \"http\" || u.Scheme == \"ws\" {\n\t\tu.Scheme = \"ws\"\n\t} else {\n\t\tu.Scheme = \"wss\"\n\t}\n\twsaddr := u.String()\n\n\tws, _, err := websocket.Dial(context.TODO(), wsaddr, &websocket.DialOptions{\n\t\tSubprotocols: []string{Protocol},\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tassignedSlot, iceServers, err := readInitMsg(ws)\n\tif websocket.CloseStatus(err) == CloseWrongProto {\n\t\treturn nil, ErrBadVersion\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlogf(\"connected to signalling server, got slot: %v\", assignedSlot)\n\tslotc <- assignedSlot\n\terr = c.newPeerConnection(iceServers)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tmsgA, err := readBase64(ws)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlogf(\"got A pake msg (%v bytes)\", len(msgA))\n\n\tmsgB, mk, err := cpace.Exchange(pass, cpace.NewContextInfo(\"\", \"\", nil), msgA)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tkey := [32]byte{}\n\t_, err = io.ReadFull(hkdf.New(sha256.New, mk, nil, nil), key[:])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = writeBase64(ws, msgB)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlogf(\"have key, sent B pake msg (%v bytes)\", len(msgB))\n\n\tc.pc.OnICECandidate(func(candidate *webrtc.ICECandidate) {\n\t\tif candidate == nil {\n\t\t\treturn\n\t\t}\n\t\terr := writeEncJSON(ws, &key, candidate.ToJSON())\n\t\tif websocket.CloseStatus(err) == websocket.StatusNormalClosure {\n\t\t\treturn\n\t\t}\n\t\tif err != nil {\n\t\t\tlogf(\"cannot send local candidate: %v\", err)\n\t\t\treturn\n\t\t}\n\t\tlogf(\"sent new local candidate: %v\", candidate.String())\n\t})\n\n\toffer, err := c.pc.CreateOffer(nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = writeEncJSON(ws, &key, offer)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = c.pc.SetLocalDescription(offer)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlogf(\"sent offer\")\n\n\tvar answer webrtc.SessionDescription\n\terr = readEncJSON(ws, &key, &answer)\n\tif websocket.CloseStatus(err) == CloseBadKey {\n\t\treturn nil, ErrBadKey\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = c.pc.SetRemoteDescription(answer)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlogf(\"got answer\")\n\n\tgo c.handleRemoteCandidates(ws, &key)\n\n\tselect {\n\tcase <-c.opened:\n\t\trelay := c.IsRelay()\n\t\tlogf(\"webrtc connection succeeded (relay: %v) closing signalling channel\", relay)\n\t\tif relay {\n\t\t\tws.Close(CloseWebRTCSuccessRelay, \"\")\n\t\t} else {\n\t\t\tws.Close(CloseWebRTCSuccessDirect, \"\")\n\t\t}\n\tcase err = <-c.err:\n\t\tws.Close(CloseWebRTCFailed, \"\")\n\tcase <-time.After(30 * time.Second):\n\t\terr = ErrTimedOut\n\t\tws.Close(CloseWebRTCFailed, \"timed out\")\n\t}\n\treturn c, err\n}", "title": "" }, { "docid": "c78ff6921be050f8e55def44d42560b0", "score": "0.4604589", "text": "func newMiningHarness(chainParams *chaincfg.Params) (*miningHarness, []spendableOutput, error) {\n\t// Use a hard coded key pair for deterministic results.\n\tkeyBytes, err := hex.DecodeString(\"700868df1838811ffbdf918fb482c1f7e\" +\n\t\t\"ad62db4b97bd7012c23e726485e577d\")\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tsignPub := secp256k1.PrivKeyFromBytes(keyBytes).PubKey()\n\n\t// Generate associated pay-to-script-hash address and resulting payment\n\t// script.\n\tpubKeyBytes := signPub.SerializeCompressed()\n\th160 := stdaddr.Hash160(pubKeyBytes)\n\tpayAddr, err := stdaddr.NewAddressPubKeyHashEcdsaSecp256k1V0(h160,\n\t\tchainParams)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tpayScriptVer, payScript := payAddr.PaymentScript()\n\n\t// Create a SigCache instance.\n\tsigCache, err := txscript.NewSigCache(1000)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\t// Create a SubsidyCache instance.\n\tsubsidyCache := standalone.NewSubsidyCache(chainParams)\n\n\t// Create a fakeChain instance.\n\tchain := &fakeChain{\n\t\tblocks: make(map[chainhash.Hash]*dcrutil.Block),\n\t\tisHeaderCommitmentsAgendaActive: true,\n\t\tisTreasuryAgendaActive: true,\n\t\tparentUtxos: blockchain.NewUtxoViewpoint(nil),\n\t\tutxos: blockchain.NewUtxoViewpoint(nil),\n\t}\n\n\t// Set the proof of work limit and next required difficulty very high by\n\t// default so that the hash of generated blocks is nearly guaranteed to meet\n\t// the proof of work requirements when checking the block sanity.\n\tchainParams.PowLimitBits = 0xff01ffff\n\tchainParams.PowLimit = standalone.CompactToBig(chainParams.PowLimitBits)\n\tchain.calcNextRequiredDifficulty = chainParams.PowLimitBits\n\n\t// Create a mining policy with defaults suitable for testing.\n\tpolicy := &Policy{\n\t\tBlockMaxSize: uint32(375000),\n\t\tTxMinFreeFee: dcrutil.Amount(1e4),\n\t\tAggressiveMining: true,\n\t\tStandardVerifyFlags: func() (txscript.ScriptFlags, error) {\n\t\t\tscriptFlags := txscript.ScriptDiscourageUpgradableNops |\n\t\t\t\ttxscript.ScriptVerifyCleanStack |\n\t\t\t\ttxscript.ScriptVerifyCheckLockTimeVerify |\n\t\t\t\ttxscript.ScriptVerifyCheckSequenceVerify |\n\t\t\t\ttxscript.ScriptVerifySHA256\n\t\t\tif chain.isTreasuryAgendaActive {\n\t\t\t\tscriptFlags |= txscript.ScriptVerifyTreasury\n\t\t\t}\n\t\t\treturn scriptFlags, nil\n\t\t},\n\t}\n\n\t// Create a fakeTxSource instance.\n\ttxSource := &fakeTxSource{\n\t\tchain: chain,\n\t\tchainParams: chainParams,\n\t\tsubsidyCache: subsidyCache,\n\t\tpool: make(map[chainhash.Hash]*TxDesc),\n\t\toutpoints: make(map[wire.OutPoint]*dcrutil.Tx),\n\t\torphans: make(map[chainhash.Hash]*dcrutil.Tx),\n\t\torphansByPrev: make(map[wire.OutPoint]map[chainhash.Hash]*dcrutil.Tx),\n\t\tstaged: make(map[chainhash.Hash]*dcrutil.Tx),\n\t\tstagedOutpoints: make(map[wire.OutPoint]*dcrutil.Tx),\n\t\tvotes: make(map[chainhash.Hash][]VoteDesc),\n\t\ttspends: make(map[chainhash.Hash]*dcrutil.Tx),\n\t}\n\n\t// Create a mining view instance for the tx source. forEachRedeemer defines\n\t// the function to use to scan the tx source to find which transactions spend a\n\t// given transaction,\n\tforEachRedeemer := func(tx *dcrutil.Tx, f func(redeemerTx *TxDesc)) {\n\t\tprevOut := wire.OutPoint{Hash: *tx.Hash(), Tree: tx.Tree()}\n\t\ttxOutLen := uint32(len(tx.MsgTx().TxOut))\n\t\tfor i := uint32(0); i < txOutLen; i++ {\n\t\t\tprevOut.Index = i\n\t\t\tif txRedeemer, exists := txSource.outpoints[prevOut]; exists {\n\t\t\t\tf(txSource.pool[txRedeemer.MsgTx().TxHash()])\n\t\t\t}\n\t\t}\n\t}\n\ttxSource.miningView = NewTxMiningView(true, forEachRedeemer)\n\n\t// Create the mining harness instance.\n\tharness := &miningHarness{\n\t\tchainParams: chainParams,\n\t\tsubsidyCache: subsidyCache,\n\t\tchain: chain,\n\t\tpolicy: policy,\n\t\ttxSource: txSource,\n\t\tsignKey: keyBytes,\n\t\tsigType: dcrec.STEcdsaSecp256k1,\n\t\tpayAddr: payAddr,\n\t\tpayScriptVer: payScriptVer,\n\t\tpayScript: payScript,\n\t\tgenerator: NewBlkTmplGenerator(&Config{\n\t\t\tPolicy: policy,\n\t\t\tTxSource: txSource,\n\t\t\tTimeSource: blockchain.NewMedianTime(),\n\t\t\tSubsidyCache: subsidyCache,\n\t\t\tChainParams: chainParams,\n\t\t\tMiningTimeOffset: 0,\n\t\t\tBestSnapshot: chain.BestSnapshot,\n\t\t\tBlockByHash: chain.BlockByHash,\n\t\t\tCalcNextRequiredDifficulty: chain.CalcNextRequiredDifficulty,\n\t\t\tCalcStakeVersionByHash: chain.CalcStakeVersionByHash,\n\t\t\tCheckConnectBlockTemplate: chain.CheckConnectBlockTemplate,\n\t\t\tCheckTicketExhaustion: chain.CheckTicketExhaustion,\n\t\t\tCheckTransactionInputs: func(tx *dcrutil.Tx, txHeight int64,\n\t\t\t\tview *blockchain.UtxoViewpoint, checkFraudProof bool,\n\t\t\t\tprevHeader *wire.BlockHeader, isTreasuryEnabled,\n\t\t\t\tisAutoRevocationsEnabled bool,\n\t\t\t\tsubsidySplitVariant standalone.SubsidySplitVariant) (int64, error) {\n\n\t\t\t\treturn blockchain.CheckTransactionInputs(subsidyCache, tx, txHeight,\n\t\t\t\t\tview, checkFraudProof, chainParams, prevHeader, isTreasuryEnabled,\n\t\t\t\t\tisAutoRevocationsEnabled, subsidySplitVariant)\n\t\t\t},\n\t\t\tCheckTSpendHasVotes: chain.CheckTSpendHasVotes,\n\t\t\tCountSigOps: blockchain.CountSigOps,\n\t\t\tFetchUtxoEntry: chain.FetchUtxoEntry,\n\t\t\tFetchUtxoView: chain.FetchUtxoView,\n\t\t\tFetchUtxoViewParentTemplate: chain.FetchUtxoViewParentTemplate,\n\t\t\tForceHeadReorganization: chain.ForceHeadReorganization,\n\t\t\tHeaderByHash: chain.HeaderByHash,\n\t\t\tIsFinalizedTransaction: blockchain.IsFinalizedTransaction,\n\t\t\tIsHeaderCommitmentsAgendaActive: chain.IsHeaderCommitmentsAgendaActive,\n\t\t\tIsTreasuryAgendaActive: chain.IsTreasuryAgendaActive,\n\t\t\tIsAutoRevocationsAgendaActive: chain.IsAutoRevocationsAgendaActive,\n\t\t\tIsSubsidySplitAgendaActive: chain.IsSubsidySplitAgendaActive,\n\t\t\tIsSubsidySplitR2AgendaActive: chain.IsSubsidySplitR2AgendaActive,\n\t\t\tMaxTreasuryExpenditure: chain.MaxTreasuryExpenditure,\n\t\t\tNewUtxoViewpoint: chain.NewUtxoViewpoint,\n\t\t\tTipGeneration: chain.TipGeneration,\n\t\t\tValidateTransactionScripts: func(tx *dcrutil.Tx,\n\t\t\t\tutxoView *blockchain.UtxoViewpoint, flags txscript.ScriptFlags,\n\t\t\t\tisAutoRevocationsEnabled bool) error {\n\n\t\t\t\treturn blockchain.ValidateTransactionScripts(tx, utxoView, flags,\n\t\t\t\t\tsigCache, isAutoRevocationsEnabled)\n\t\t\t},\n\t\t}),\n\t}\n\n\t// Create a single coinbase transaction and add it to the harness\n\t// chain's utxo set and set the harness chain height such that the\n\t// coinbase will mature in the next block. This ensures the txpool\n\t// accepts transactions which spend immature coinbases that will become\n\t// mature in the next block.\n\tnumOutputs := uint32(1)\n\toutputs := make([]spendableOutput, 0, numOutputs)\n\tcurHeight := chain.bestState.Height\n\tcoinbase, err := harness.CreateCoinbaseTx(curHeight+1, numOutputs)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tharness.AddFakeUTXO(coinbase, curHeight+1, wire.NullBlockIndex,\n\t\tchain.isTreasuryAgendaActive)\n\tfor i := uint32(0); i < numOutputs; i++ {\n\t\toutputs = append(outputs, txOutToSpendableOut(coinbase, i,\n\t\t\twire.TxTreeRegular))\n\t}\n\n\t// Mock the chain best block and state.\n\tmockBestBlock := *dcrutil.NewBlock(&wire.MsgBlock{})\n\tmockBestHash := mockBestBlock.Hash()\n\tchain.tipGeneration = []chainhash.Hash{*mockBestHash}\n\tchain.blocks[*mockBestHash] = &mockBestBlock\n\tchain.bestState = blockchain.BestState{\n\t\tHash: *mockBestHash,\n\t\tHeight: int64(chainParams.CoinbaseMaturity) + curHeight,\n\t}\n\n\treturn harness, outputs, nil\n}", "title": "" }, { "docid": "b4b942f1f874007a542c45cac255425c", "score": "0.458442", "text": "func TestSimulateMsgHarvest(t *testing.T) {\n\tapp, ctx := createTestApp(false)\n\n\t// setup a single account\n\ts := rand.NewSource(1)\n\tr := rand.New(s)\n\n\taccounts := getTestingAccounts(t, r, app, ctx, 1)\n\n\t// setup epoch days to 1 to ease the test\n\tparams := app.FarmingKeeper.GetParams(ctx)\n\tparams.NextEpochDays = 1\n\tapp.FarmingKeeper.SetParams(ctx, params)\n\n\t// setup a fixed amount plan\n\tmsgPlan := &types.MsgCreateFixedAmountPlan{\n\t\tName: \"simulation\",\n\t\tCreator: accounts[0].Address.String(),\n\t\tStakingCoinWeights: sdk.NewDecCoins(\n\t\t\tsdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdk.NewDecWithPrec(10, 1)), // 100%\n\t\t),\n\t\tStartTime: types.ParseTime(\"0001-01-01T00:00:00Z\"),\n\t\tEndTime: types.ParseTime(\"9999-01-01T00:00:00Z\"),\n\t\tEpochAmount: sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 200_000_000)),\n\t}\n\n\t_, err := app.FarmingKeeper.CreateFixedAmountPlan(\n\t\tctx,\n\t\tmsgPlan,\n\t\taccounts[0].Address,\n\t\taccounts[0].Address,\n\t\ttypes.PlanTypePrivate,\n\t)\n\trequire.NoError(t, err)\n\n\t// begin a new block\n\tapp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}})\n\n\t// set staking\n\tstakingCoins := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 100_000_000))\n\terr = app.FarmingKeeper.Stake(ctx, accounts[0].Address, stakingCoins)\n\trequire.NoError(t, err)\n\n\tqueuedStaking, found := app.FarmingKeeper.GetQueuedStaking(ctx, sdk.DefaultBondDenom, accounts[0].Address)\n\trequire.Equal(t, true, found)\n\trequire.Equal(t, true, queuedStaking.Amount.IsPositive())\n\n\t// begin a new block\n\tapp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}})\n\terr = app.FarmingKeeper.AdvanceEpoch(ctx)\n\trequire.NoError(t, err)\n\n\t// check that queue coins are moved to staked coins\n\tstaking, found := app.FarmingKeeper.GetStaking(ctx, sdk.DefaultBondDenom, accounts[0].Address)\n\trequire.Equal(t, true, found)\n\trequire.Equal(t, true, staking.Amount.IsPositive())\n\tqueuedStaking, found = app.FarmingKeeper.GetQueuedStaking(ctx, sdk.DefaultBondDenom, accounts[0].Address)\n\trequire.Equal(t, false, found)\n\n\t// begin a new block\n\tapp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash}})\n\terr = app.FarmingKeeper.AdvanceEpoch(ctx)\n\trequire.NoError(t, err)\n\n\t// execute operation\n\top := simulation.SimulateMsgHarvest(app.AccountKeeper, app.BankKeeper, app.FarmingKeeper)\n\toperationMsg, futureOperations, err := op(r, app.BaseApp, ctx, accounts, \"\")\n\trequire.NoError(t, err)\n\n\tvar msg types.MsgHarvest\n\terr = app.AppCodec().UnmarshalJSON(operationMsg.Msg, &msg)\n\trequire.NoError(t, err)\n\n\trequire.True(t, operationMsg.OK)\n\trequire.Equal(t, types.TypeMsgHarvest, msg.Type())\n\trequire.Equal(t, \"cosmos1tnh2q55v8wyygtt9srz5safamzdengsnqeycj3\", msg.Farmer)\n\trequire.Equal(t, []string{\"stake\"}, msg.StakingCoinDenoms)\n\trequire.Len(t, futureOperations, 0)\n}", "title": "" }, { "docid": "786f5977145e5adee4758044c2f62367", "score": "0.4552964", "text": "func skupperInitEdgeTestScenario(ctx *base.ClusterContext, prefix string, withPolicy bool) (initSteps cli.TestScenario) {\n\tinitSteps = cli.TestScenario{\n\t\tName: prefixName(prefix, \"init-skupper-edge\"),\n\t\tTasks: []cli.SkupperTask{\n\t\t\t{Ctx: ctx, Commands: []cli.SkupperCommandTester{\n\t\t\t\t// skupper init - edge mode, no console and unsecured\n\t\t\t\t&cli.InitTester{\n\t\t\t\t\tConsoleAuth: \"unsecured\",\n\t\t\t\t\tIngress: \"none\",\n\t\t\t\t\tRouterLogging: \"trace\",\n\t\t\t\t\tRouterMode: \"edge\",\n\t\t\t\t\tSiteName: \"private\",\n\t\t\t\t\tEnableConsole: false,\n\t\t\t\t\tEnableFlowCollector: false,\n\t\t\t\t\tRouterCPU: \"100m\",\n\t\t\t\t\tRouterMemory: \"32Mi\",\n\t\t\t\t\tControllerCPU: \"50m\",\n\t\t\t\t\tControllerMemory: \"16Mi\",\n\t\t\t\t\tRouterCPULimit: \"600m\",\n\t\t\t\t\tRouterMemoryLimit: \"500Mi\",\n\t\t\t\t\tControllerCPULimit: \"600m\",\n\t\t\t\t\tControllerMemoryLimit: \"500Mi\",\n\t\t\t\t\t// ConsoleIngress: \"none\",\n\t\t\t\t},\n\t\t\t\t// skupper status - verify initialized as edge\n\t\t\t\t&cli.StatusTester{\n\t\t\t\t\tRouterMode: \"edge\",\n\t\t\t\t\tSiteName: \"private\",\n\t\t\t\t\tPolicyEnabled: cli.Boolp(withPolicy),\n\t\t\t\t},\n\t\t\t}},\n\t\t},\n\t}\n\treturn\n}", "title": "" }, { "docid": "11132e6e9559008f36eb5c11d706a059", "score": "0.45473197", "text": "func (t *SimpleChaincode) initSmartPay(stub *shim.ChaincodeStub, args []string) ([]byte, error) {\n\tvar err error\n\t// 0 1 2 3 4\n\t// \"asdf\", \"blue\", \"35\", \"bob\"\n\t// TransId DrawerID PayeeID Amount Currency\n\n\t// Check if Correct Number of arguments are passed\n\tif len(args) < 15 {\n\t\treturn nil, errors.New(\"Incorrect number of arguments. Expecting 15\")\n\t}\n\n\t// ------------------ Payment input sanitation ------------------------------\n\tfmt.Println(\"--Payment Trans Data\")\n\tif len(args[0]) <= 0 {\n\t\treturn nil, errors.New(\"1st argument must be a non-empty string\")\n\t}\n\tif len(args[1]) <= 0 {\n\t\treturn nil, errors.New(\"2nd argument must be a non-empty string\")\n\t}\n\tif len(args[2]) <= 0 {\n\t\treturn nil, errors.New(\"3rd argument must be a non-empty string\")\n\t}\n\tif len(args[3]) <= 0 {\n\t\treturn nil, errors.New(\"4th argument must be a non-empty string\")\n\t}\n\tif len(args[4]) <= 0 {\n\t\treturn nil, errors.New(\"5th argument must be a non-empty string\")\n\t}\n\n\tptransID := strings.ToLower(args[0])\n\tdrawerID := strings.ToLower(args[1])\n\tpayeeID := strings.ToLower(args[2])\n\tpAmount, err := strconv.ParseFloat(args[3], 64)\n\tif err != nil {\n\t\treturn nil, errors.New(\"3rd argument must be a Floating Point\")\n\t}\n\tcurrency := strings.ToLower(args[4])\n\n\t// ------------------ Remittance input sanitation ------------------------------\n\tfmt.Println(\"--Remittance Trans Data\")\n\tif len(args[5]) <= 0 {\n\t\treturn nil, errors.New(\"6th argument must be a non-empty string\")\n\t}\n\tif len(args[6]) <= 0 {\n\t\treturn nil, errors.New(\"7th argument must be a non-empty string\")\n\t}\n\tif len(args[7]) <= 0 {\n\t\treturn nil, errors.New(\"8th argument must be a non-empty string\")\n\t}\n\tif len(args[8]) <= 0 {\n\t\treturn nil, errors.New(\"9th argument must be a non-empty string\")\n\t}\n\tif len(args[9]) <= 0 {\n\t\treturn nil, errors.New(\"10th argument must be a non-empty string\")\n\t}\n\tif len(args[10]) <= 0 {\n\t\treturn nil, errors.New(\"11th argument must be a non-empty string\")\n\t}\n\tif len(args[11]) <= 0 {\n\t\treturn nil, errors.New(\"12th argument must be a non-empty string\")\n\t}\n\n\trtransID := strings.ToLower(args[5])\n\tsourceID := strings.ToLower(args[6])\n\tsourceCurrency := strings.ToLower(args[7])\n\tdestinationID := strings.ToLower(args[8])\n\tdestinationCurrency := strings.ToLower(args[9])\n\trAmount, err := strconv.ParseFloat(args[10], 64)\n\tif err != nil {\n\t\treturn nil, errors.New(\"10 argument must be a Floating Point\")\n\t}\n\texchangeRate, err := strconv.ParseFloat(args[11], 64)\n\tif err != nil {\n\t\treturn nil, errors.New(\"11 argument must be a Floating Point\")\n\t}\n\n\t// ------------------ Lending input sanitation ------------------------------\n\tfmt.Println(\"--Lending Trans Data\")\n\tif len(args[12]) <= 0 {\n\t\treturn nil, errors.New(\"13th argument must be a non-empty string\")\n\t}\n\tif len(args[13]) <= 0 {\n\t\treturn nil, errors.New(\"14th argument must be a non-empty string\")\n\t}\n\tif len(args[14]) <= 0 {\n\t\treturn nil, errors.New(\"15th argument must be a non-empty string\")\n\t}\n\tif len(args[15]) <= 0 {\n\t\treturn nil, errors.New(\"16th argument must be a non-empty string\")\n\t}\n\tif len(args[16]) <= 0 {\n\t\treturn nil, errors.New(\"17th argument must be a non-empty string\")\n\t}\n\tif len(args[17]) <= 0 {\n\t\treturn nil, errors.New(\"18th argument must be a non-empty string\")\n\t}\n\tif len(args[18]) <= 0 {\n\t\treturn nil, errors.New(\"19th argument must be a non-empty string\")\n\t}\n\n\tltransID := strings.ToLower(args[12])\n\tlendorID := strings.ToLower(args[13])\n\tborrowerID := strings.ToLower(args[14])\n\tloanAmount, err := strconv.ParseFloat(args[15], 64)\n\tif err != nil {\n\t\treturn nil, errors.New(\"15 argument must be a Floating Point\")\n\t}\n\tlcurrency := strings.ToLower(args[16])\n\tloanRate, err := strconv.ParseFloat(args[17], 64)\n\tif err != nil {\n\t\treturn nil, errors.New(\"17 argument must be a Floating Point\")\n\t}\n\tloanReturnDate := strings.ToLower(args[18])\n\n\t// ------------------ Lending input sanitation ------------------------------\n\tfmt.Println(\"--SmartPay Data\")\n\tif len(args[19]) <= 0 {\n\t\treturn nil, errors.New(\"20th argument must be a non-empty string\")\n\t}\n\n\tsmartPayID := strings.ToLower(args[19])\n\n\t//----------------------------------------------------------------------------------------------------------------\n\t//check if Payment already exists\n\n\tsmartPayAsBytes, err := stub.GetState(smartPayID)\n\tif err != nil {\n\t\treturn nil, errors.New(\"Failed to get Transaction name\")\n\t}\n\n\t/*\n\t\tpRes := PaymentTransaction{}\n\t\ttRes := RemittanceTransaction{}\n\t\tlRes := LendingTransacation{}\n\t*/\n\tsRes := SmartPayTransaction{}\n\n\tjson.Unmarshal(smartPayAsBytes, &sRes)\n\tif sRes.SmartPayTransID == smartPayID {\n\t\tfmt.Println(\"This SmartPay Transaction arleady exists: \" + smartPayID)\n\t\tfmt.Println(sRes)\n\t\treturn nil, errors.New(\"This smartPay Tranaction arleady exists\") //all stop a marble by this name exists\n\t}\n\n\t//build the Payment json string manually\n\tstrPmt := `{\"paymentTransID\": \"` + ptransID + `\", \"drawerID\": \"` + drawerID + `\", \"payeeID\": \"` + payeeID + `\", \"amount\": ` + strconv.FormatFloat(pAmount, 'f', -1, 64) + `, \"currency\": \"` + currency + `\"}`\n\tfmt.Println(strPmt)\n\n\tstrRem := `{\"remittanceTransID\": \"` + rtransID + `\", \"sourceID\": \"` + sourceID + `\", \"sourceCurrency\": \"` + sourceCurrency + `\", \"destinationID\": \"` + destinationID + `\", \"destinationCurrency\": \"` + destinationCurrency + `\",\"amount\": ` + strconv.FormatFloat(rAmount, 'f', -1, 64) + `, \"ExchangeRate\": ` + strconv.FormatFloat(exchangeRate, 'f', -1, 64) + `\"}`\n\tfmt.Println(strRem)\n\n\tstrLen := `{\"lendingTransID\": \"` + ltransID + `\", \"lendorID\": \"` + lendorID + `\", \"borrowerID\": \"` + borrowerID + `\", \"loanAmount\": ` + strconv.FormatFloat(loanAmount, 'f', -1, 64) + `, \"currency\": \"` + lcurrency + `\",\"loanRate\": ` + strconv.FormatFloat(loanRate, 'f', -1, 64) + `, \"loanReturnDate\": \"` + loanReturnDate + `\"}`\n\tfmt.Println(strLen)\n\n\tstrSmPay := `{\"SmartPayTransID\": \"` + smartPayID + `\", \"PaymentTrans\": \"` + strPmt + `\", \"RemitTrans\": \"` + strRem + `\", \"LendTrans\": \"` + strLen + `\"}`\n\n\terr = stub.PutState(smartPayID, []byte(strSmPay)) //store marble with id as key\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t//get the Payment index\n\tsmartPayAsBytes, err = stub.GetState(smartPayIndexStr)\n\tif err != nil {\n\t\treturn nil, errors.New(\"Failed to get marble index\")\n\t}\n\tvar smartPayIndex []string\n\tjson.Unmarshal(smartPayAsBytes, &smartPayIndex) //un stringify it aka JSON.parse()\n\n\t//append\n\tsmartPayIndex = append(smartPayIndex, smartPayID) //add marble name to index list\n\tfmt.Println(\"! Payment index: \", smartPayIndex)\n\tjsonAsBytes, _ := json.Marshal(smartPayIndex)\n\terr = stub.PutState(smartPayIndexStr, jsonAsBytes) //store name of marble\n\n\tfmt.Println(\"- End init SmartPay\")\n\treturn nil, nil\n}", "title": "" }, { "docid": "2650e26dd4dabdab871b4a3c3faa1974", "score": "0.4543276", "text": "func (t *ApesWallet) Init(stub shim.ChaincodeStubInterface) pb.Response {\n\tfmt.Println(\"########### ApesWallet Init with changes ###########\")\n\n\t// Get the function and arguments from the request\n\tfunction, _ := stub.GetFunctionAndParameters()\n\n\t// Check if the request is the init function\n\tif function != \"init\" {\n\t\treturn shim.Error(\"Unknown function call\")\n\t}\n\n\t// Return a successful message\n\treturn shim.Success(nil)\n}", "title": "" }, { "docid": "d4cd33c64da2cd1febe9c9993b86b520", "score": "0.45412064", "text": "func (f *InMemoryWalletFactory) NewWallet(cfg *coinharness.TestWalletConfig) coinharness.Wallet {\n\tpin.AssertNotNil(\"ActiveNet\", cfg.ActiveNet)\n\t//w, e := newMemWallet(, cfg.Seed)\n\n\tnet := cfg.ActiveNet\n\tharnessHDSeed := cfg.Seed.([]byte)[:]\n\thdRoot, err := hdkeychain.NewMaster(harnessHDSeed, net.Params().(*chaincfg.Params))\n\t//hdRoot, err := cfg.NewMasterKeyFromSeed(harnessHDSeed, net)\n\tpin.CheckTestSetupMalfunction(err)\n\n\tvar ekey coinharness.ExtendedKey = &ExtendedKey{hdRoot}\n\t// The first child key from the hd root is reserved as the coinbase\n\t// generation address.\n\tcoinbaseChild, err := hdRoot.Child(0)\n\tpin.CheckTestSetupMalfunction(err)\n\tcoinbaseKey, err := coinbaseChild.ECPrivKey()\n\tpin.CheckTestSetupMalfunction(err)\n\tcoinbaseAddr, err := PrivateKeyKeyToAddr(&PrivateKey{coinbaseKey}, cfg.ActiveNet)\n\tpin.CheckTestSetupMalfunction(err)\n\n\t// Track the coinbase generation address to ensure we properly track\n\t// newly generated coins we can spend.\n\taddrs := make(map[uint32]coinharness.Address)\n\taddrs[0] = coinbaseAddr\n\n\tclientFac := &RPCClientFactory{}\n\t//clientFac := cfg.RPCClientFactory\n\treturn &coinharness.InMemoryWallet{\n\t\tNet: net,\n\t\tCoinbaseKey: coinbaseKey,\n\t\tCoinbaseAddr: coinbaseAddr,\n\t\tHdIndex: 1,\n\t\tHdRoot: ekey,\n\t\tAddrs: addrs,\n\t\tUtxos: make(map[coinharness.OutPoint]*coinharness.Utxo),\n\t\tChainUpdateSignal: make(chan string),\n\t\tReorgJournal: make(map[int64]*coinharness.UndoEntry),\n\t\tRPCClientFactory: clientFac,\n\t\tPrivateKeyKeyToAddr: PrivateKeyKeyToAddr,\n\t\tReadBlockHeader: ReadBlockHeader,\n\t\tNewTxFromBytes: NewTxFromBytes,\n\t\tIsCoinBaseTx: IsCoinBaseTx,\n\t}\n\t//NewTxFromBytes func(txBytes []byte) (*Tx, error) //dcrutil.NewTxFromBytes(txBytes)\n\t//IsCoinBaseTx func(*MessageTx) bool //blockchain.IsCoinBaseTx(mtx)\n}", "title": "" }, { "docid": "9651a132c62fe6d0a87a1579ac2dc28a", "score": "0.45311984", "text": "func NewWallet(ctx context.Context, log logger.Logger, path string, params *params.ChainParams, ch chain.Blockchain, hostnode hostnode.HostNode, mempool mempool.CoinsMempool, actionMempool mempool.ActionMempool) (Wallet, error) {\n\tvar txTopic, depositTopic, depositsTopic, exitTopic, exitsTopic *pubsub.Topic\n\tvar err error\n\tif hostnode != nil {\n\t\ttxTopic, err = hostnode.Topic(p2p.MsgTxCmd)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tdepositTopic, err = hostnode.Topic(p2p.MsgDepositCmd)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tdepositsTopic, err = hostnode.Topic(p2p.MsgDepositsCmd)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\texitTopic, err = hostnode.Topic(p2p.MsgExitCmd)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\texitsTopic, err = hostnode.Topic(p2p.MsgExitsCmd)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\twall := &wallet{\n\t\tlog: log,\n\t\tdirectory: path,\n\t\tparams: params,\n\t\topen: false,\n\t\tchain: ch,\n\t\ttxTopic: txTopic,\n\t\thostnode: hostnode,\n\t\tdepositTopic: depositTopic,\n\t\tdepositsTopic: depositsTopic,\n\t\texitTopic: exitTopic,\n\t\texitsTopic: exitsTopic,\n\t\tmempool: mempool,\n\t\tctx: ctx,\n\t\tactionMempool: actionMempool,\n\t}\n\treturn wall, nil\n}", "title": "" }, { "docid": "499f360be4fe4568b5bb239ab8ad6502", "score": "0.45273733", "text": "func init() {\n\tif len(os.Args) > 1 {\n\t\tID_STR = os.Args[1]\n\t\tUSER_TYPE = os.Args[2]\n\t\tSELF_ADDR = PRE_SELF_ADDR + ID_STR\n\t\tSBC = data.NewBlockChain()\n\t} else {\n\t\tID_STR = TA_SERVER_ID_STR\n\t\tSELF_ADDR = TA_SERVER\n\t\tSBC = data.FirstBlockChain()\n\t}\n\n\tid, _ := strconv.Atoi(ID_STR)\n\tPeers = data.NewPeerList(int32(id), 32)\n\tPeers.Register(int32(id))\n\n\tMyWallet = accounts.NewMyWallet(ID_STR)\n\tMyWallet.Initial()\n\tSL.Initial()\n\tSTP.Initial()\n\n}", "title": "" }, { "docid": "ea3ee3aed00c21d1e39b5686e4dc12c7", "score": "0.45247757", "text": "func (test StakingNetworkUnrequestedChitSpammerTest) Run(network networks.Network, context testsuite.TestContext) {\n\tcastedNetwork := network.(avalancheNetwork.TestAvalancheNetwork)\n\tnetworkAcceptanceTimeout := time.Duration(networkAcceptanceTimeoutRatio * float64(test.GetExecutionTimeout().Nanoseconds()))\n\n\t// ============= ADD SET OF BYZANTINE NODES AS VALIDATORS ON THE NETWORK ===================\n\tlogrus.Infof(\"Adding byzantine chit spammer nodes as stakers...\")\n\tfor i := 0; i < numberOfByzantineNodes; i++ {\n\t\tbyzClient, err := castedNetwork.GetAvalancheClient(networks.ServiceID(byzantineNodePrefix + strconv.Itoa(i)))\n\t\tif err != nil {\n\t\t\tcontext.Fatal(stacktrace.Propagate(err, \"Failed to get byzantine client.\"))\n\t\t}\n\t\thighLevelByzClient := helpers.NewRPCWorkFlowRunner(\n\t\t\tbyzClient,\n\t\t\tapi.UserPass{Username: byzantineUsername, Password: byzantinePassword},\n\t\t\tnetworkAcceptanceTimeout)\n\t\t_, err = highLevelByzClient.ImportGenesisFundsAndStartValidating(seedAmount, stakeAmount)\n\t\tif err != nil {\n\t\t\tcontext.Fatal(stacktrace.Propagate(err, \"Failed add client as a validator.\"))\n\t\t}\n\t\tcurrentStakers, err := byzClient.PChainAPI().GetCurrentValidators(ids.Empty)\n\t\tif err != nil {\n\t\t\tcontext.Fatal(stacktrace.Propagate(err, \"Could not get current stakers.\"))\n\t\t}\n\t\tlogrus.Infof(\"Current Stakers: %d\", len(currentStakers))\n\t}\n\n\t// =================== ADD NORMAL NODE AS A VALIDATOR ON THE NETWORK =======================\n\tlogrus.Infof(\"Adding normal node as a staker...\")\n\tavailabilityChecker, err := castedNetwork.AddService(normalNodeConfigID, normalNodeServiceID)\n\tif err != nil {\n\t\tcontext.Fatal(stacktrace.Propagate(err, \"Failed to add normal node with high quorum and sample to network.\"))\n\t}\n\tif err = availabilityChecker.WaitForStartup(); err != nil {\n\t\tcontext.Fatal(stacktrace.Propagate(err, \"Failed to wait for startup of normal node.\"))\n\t}\n\tnormalClient, err := castedNetwork.GetAvalancheClient(normalNodeServiceID)\n\tif err != nil {\n\t\tcontext.Fatal(stacktrace.Propagate(err, \"Failed to get staker client.\"))\n\t}\n\thighLevelNormalClient := helpers.NewRPCWorkFlowRunner(\n\t\tnormalClient,\n\t\tapi.UserPass{Username: stakerUsername, Password: stakerPassword},\n\t\tnetworkAcceptanceTimeout)\n\t_, err = highLevelNormalClient.ImportGenesisFundsAndStartValidating(seedAmount, stakeAmount)\n\tif err != nil {\n\t\tcontext.Fatal(stacktrace.Propagate(err, \"Failed to add client as a validator.\"))\n\t}\n\n\tlogrus.Infof(\"Added normal node as a staker. Sleeping an additional 10 seconds to ensure it joins current validators...\")\n\ttime.Sleep(10 * time.Second)\n\n\t// ============= VALIDATE NETWORK STATE DESPITE BYZANTINE BEHAVIOR =========================\n\tlogrus.Infof(\"Validating network state...\")\n\tcurrentStakers, err := normalClient.PChainAPI().GetCurrentValidators(ids.Empty)\n\tif err != nil {\n\t\tcontext.Fatal(stacktrace.Propagate(err, \"Could not get current stakers.\"))\n\t}\n\tactualNumStakers := len(currentStakers)\n\texpectedNumStakers := 10\n\tlogrus.Debugf(\"Number of current stakers: %d, expected number of stakers: %d\", actualNumStakers, expectedNumStakers)\n\tif actualNumStakers != expectedNumStakers {\n\t\tcontext.AssertTrue(actualNumStakers == expectedNumStakers, stacktrace.NewError(\"Actual number of stakers, %v, != expected number of stakers, %v\", actualNumStakers, expectedNumStakers))\n\t}\n}", "title": "" }, { "docid": "7c02cb0916ba88b938e93e43fe473391", "score": "0.45196012", "text": "func getInitChainer(mapp *mock.App, keeper Keeper, accountKeeper auth.AccountKeeper, supplyKeeper supply.Keeper,\n\tblacklistedAddrs []supplyexported.ModuleAccountI, stakingKeeper staking.Keeper, registerKeeper register.Keeper, potKeeper pot.Keeper) sdk.InitChainer {\n\treturn func(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {\n\t\t// set module accounts\n\t\tfor _, macc := range blacklistedAddrs {\n\t\t\tsupplyKeeper.SetModuleAccount(ctx, macc)\n\t\t}\n\n\t\tmapp.InitChainer(ctx, req)\n\n\t\tvar lastResourceNodeStakes []register.LastResourceNodeStake\n\t\tlastResourceNodeStakes = append(lastResourceNodeStakes, register.LastResourceNodeStake{Address: addrRes1, Stake: initialStakeRes1})\n\t\tlastResourceNodeStakes = append(lastResourceNodeStakes, register.LastResourceNodeStake{Address: addrRes2, Stake: initialStakeRes2})\n\t\tlastResourceNodeStakes = append(lastResourceNodeStakes, register.LastResourceNodeStake{Address: addrRes3, Stake: initialStakeRes3})\n\t\tlastResourceNodeStakes = append(lastResourceNodeStakes, register.LastResourceNodeStake{Address: addrRes4, Stake: initialStakeRes4})\n\t\tlastResourceNodeStakes = append(lastResourceNodeStakes, register.LastResourceNodeStake{Address: addrRes5, Stake: initialStakeRes5})\n\n\t\tvar lastIndexingNodeStakes []register.LastIndexingNodeStake\n\t\tlastIndexingNodeStakes = append(lastIndexingNodeStakes, register.LastIndexingNodeStake{Address: addrIdx1, Stake: initialStakeIdx1})\n\t\tlastIndexingNodeStakes = append(lastIndexingNodeStakes, register.LastIndexingNodeStake{Address: addrIdx2, Stake: initialStakeIdx2})\n\t\tlastIndexingNodeStakes = append(lastIndexingNodeStakes, register.LastIndexingNodeStake{Address: addrIdx3, Stake: initialStakeIdx3})\n\t\tlastIndexingNodeStakes = append(lastIndexingNodeStakes, register.LastIndexingNodeStake{Address: spNodeAddrIdx1, Stake: spNodeInitialStakeIdx1})\n\n\t\tresourceNodes := setupAllResourceNodes()\n\t\tindexingNodes := setupAllIndexingNodes()\n\n\t\tregisterGenesis := register.NewGenesisState(register.DefaultParams(), lastResourceNodeStakes, resourceNodes, lastIndexingNodeStakes, indexingNodes)\n\n\t\tregister.InitGenesis(ctx, registerKeeper, registerGenesis)\n\n\t\t// set module accounts\n\t\tfor _, macc := range blacklistedAddrs {\n\t\t\tsupplyKeeper.SetModuleAccount(ctx, macc)\n\t\t}\n\n\t\tstakingGenesis := staking.NewGenesisState(staking.NewParams(staking.DefaultUnbondingTime, staking.DefaultMaxValidators, staking.DefaultMaxEntries, 0, DefaultDenom), nil, nil)\n\n\t\ttotalSupply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000)))\n\t\tsupplyKeeper.SetSupply(ctx, supply.NewSupply(totalSupply))\n\n\t\t// set module accounts\n\t\tfor _, macc := range blacklistedAddrs {\n\t\t\tsupplyKeeper.SetModuleAccount(ctx, macc)\n\t\t}\n\n\t\tvalidators := staking.InitGenesis(ctx, stakingKeeper, accountKeeper, supplyKeeper, stakingGenesis)\n\n\t\t//preset\n\t\tregisterKeeper.SetRemainingOzoneLimit(ctx, remainingOzoneLimit)\n\t\tpotKeeper.SetTotalUnissuedPrepay(ctx, totalUnissuedPrepay)\n\n\t\t//pot genesis data load\n\t\tpot.InitGenesis(ctx, potKeeper, pot.NewGenesisState(pottypes.DefaultParams(), foundationAccAddr, initialOzonePrice))\n\n\t\t// init bank genesis\n\t\tkeeper.BankKeeper.SetSendEnabled(ctx, true)\n\n\t\treturn abci.ResponseInitChain{\n\t\t\tValidators: validators,\n\t\t}\n\t}\n}", "title": "" }, { "docid": "cf5087d3a2757447a8e6d0e0cd5f7e5f", "score": "0.4493552", "text": "func (l *Loader) CreateNewWatchingOnlyWallet(pubPassphrase []byte,\n\tbday time.Time) (*Wallet, error) {\n\n\treturn l.createNewWallet(\n\t\tpubPassphrase, nil, nil, bday, true,\n\t)\n}", "title": "" }, { "docid": "4078295cb125eef36246312512438f6c", "score": "0.4488345", "text": "func (api *API) walletInitHandler(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {\n\tvar encryptionKey crypto.TwofishKey\n\tif req.FormValue(\"encryptionpassword\") != \"\" {\n\t\tencryptionKey = crypto.TwofishKey(crypto.HashObject(req.FormValue(\"encryptionpassword\")))\n\t}\n\tseed, err := api.wallet.Encrypt(encryptionKey)\n\tif err != nil {\n\t\tWriteError(w, Error{\"error when calling /wallet/init: \" + err.Error()}, http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tdictID := mnemonics.DictionaryID(req.FormValue(\"dictionary\"))\n\tif dictID == \"\" {\n\t\tdictID = \"english\"\n\t}\n\tseedStr, err := modules.SeedToString(seed, dictID)\n\tif err != nil {\n\t\tWriteError(w, Error{\"error when calling /wallet/init: \" + err.Error()}, http.StatusBadRequest)\n\t\treturn\n\t}\n\tWriteJSON(w, WalletInitPOST{\n\t\tPrimarySeed: seedStr,\n\t})\n}", "title": "" }, { "docid": "a9c430ab4deeda6065abb5571371dbd8", "score": "0.44871613", "text": "func CreateWalletSoft(ctx context.Context, g *libkb.GlobalContext) {\n\tvar err error\n\tdefer g.CTraceTimed(ctx, \"CreateWalletSoft\", func() error { return err })()\n\tif !g.LocalSigchainGuard().IsAvailable(ctx, \"CreateWalletSoft\") {\n\t\terr = fmt.Errorf(\"yielding to guard\")\n\t\treturn\n\t}\n\t_, err = CreateWalletGated(ctx, g)\n\treturn\n}", "title": "" }, { "docid": "d07c91bc77671dc26cf9011690ed3970", "score": "0.4476446", "text": "func newWallet(cfg *BTCCloneCFG, btcCfg *dexbtc.Config, node rpcClient) *ExchangeWallet {\n\t// If set in the user config, the fallback fee will be in conventional units\n\t// per kB, e.g. BTC/kB. Translate that to sats/B.\n\tfallbackFeesPerByte := toSatoshi(btcCfg.FallbackFeeRate / 1000)\n\tif fallbackFeesPerByte == 0 {\n\t\tfallbackFeesPerByte = cfg.DefaultFallbackFee\n\t}\n\tcfg.Logger.Tracef(\"Fallback fees set at %d %s/vbyte\", fallbackFeesPerByte, cfg.WalletInfo.Units)\n\n\tredeemConfTarget := btcCfg.RedeemConfTarget\n\tif redeemConfTarget == 0 {\n\t\tredeemConfTarget = defaultRedeemConfTarget\n\t}\n\tcfg.Logger.Tracef(\"Redeem conf target set to %d blocks\", redeemConfTarget)\n\n\treturn &ExchangeWallet{\n\t\tnode: node,\n\t\twallet: newWalletClient(node, cfg.Segwit, cfg.ChainParams),\n\t\tsymbol: cfg.Symbol,\n\t\tchainParams: cfg.ChainParams,\n\t\tlog: cfg.Logger,\n\t\ttipChange: cfg.WalletCFG.TipChange,\n\t\tfundingCoins: make(map[outPoint]*utxo),\n\t\tfindRedemptionQueue: make(map[outPoint]*findRedemptionReq),\n\t\tminNetworkVersion: cfg.MinNetworkVersion,\n\t\tfallbackFeeRate: fallbackFeesPerByte,\n\t\tredeemConfTarget: redeemConfTarget,\n\t\tuseSplitTx: btcCfg.UseSplitTx,\n\t\tuseLegacyBalance: cfg.LegacyBalance,\n\t\tsegwit: cfg.Segwit,\n\t\twalletInfo: cfg.WalletInfo,\n\t}\n}", "title": "" }, { "docid": "79cc97fa30673123decde39ece7f6e77", "score": "0.44420856", "text": "func (d *DexBotAction) NewWallet(bot *bot.Bot) (bool, error) {\n\treturn false, nil\n}", "title": "" }, { "docid": "64eac4ae157a7ba5ad93dbb4f231d35d", "score": "0.44159475", "text": "func initMSP(mainFlags *pflag.FlagSet) {\n\tdefaultMspDir, err := config.GetDevMspDir()\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\n\tmspMgrConfigDir := \"\"\n\tmspID := \"\"\n\tmainFlags.StringVarP(&mspMgrConfigDir, \"mspcfgdir\", \"m\", defaultMspDir, \"Path to MSP dir\")\n\tmainFlags.StringVarP(&mspID, \"mspid\", \"i\", \"DEFAULT\", \"MSP ID\")\n\n\terr = common.InitCrypto(mspMgrConfigDir, mspID)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}", "title": "" }, { "docid": "c04fa88ce85b9d278175db5a2c9da6c7", "score": "0.440774", "text": "func CreateTestInputAdvanced(t *testing.T, isCheckTx bool, initPower int64,\n\tcommunityTax sdk.Dec) (sdk.Context, account.Keeper, asset.Keeper,\n\tKeeper, staking.Keeper, params.Keeper, supply.Keeper) {\n\n\tkeyParams := sdk.NewKVStoreKey(params.StoreKey)\n\ttkeyParams := sdk.NewTransientStoreKey(params.TStoreKey)\n\n\tcdc := MakeTestCodec()\n\tdb := dbm.NewMemDB()\n\tms := store.NewCommitMultiStore(db)\n\n\tms.MountStoreWithDB(keyParams, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(tkeyParams, sdk.StoreTypeTransient, db)\n\n\tpk := params.NewKeeper(cdc, keyParams, tkeyParams)\n\tAccountKeeper := account.NewAccountKeeper(cdc, sdk.NewKVStoreKey(account.StoreKey))\n\n\tmAccPerms := map[string][]string{\n\t\tfee.CollectorName: nil,\n\t\tsupply.BlackHole: nil,\n\t\tstaking.BondedPoolName: {supply.Burner, supply.Staking},\n\t\tstaking.NotBondedPoolName: {supply.Burner, supply.Staking},\n\t\ttypes.ModuleName: nil,\n\t\tstaking.ModuleName: nil,\n\t}\n\n\tassetKeeper := asset.NewAssetKeeper(cdc, sdk.NewKVStoreKey(asset.StoreKey), AccountKeeper)\n\tsupplyKeeper := supply.NewKeeper(cdc, sdk.NewKVStoreKey(supply.StoreKey), AccountKeeper, assetKeeper, mAccPerms)\n\n\tdistrAcc := supply.NewEmptyModuleAccount(types.ModuleName)\n\tfeeCollectorAcc := supply.NewEmptyModuleAccount(fee.CollectorName)\n\tskModuleAcc := supply.NewEmptyModuleAccount(staking.ModuleName)\n\tnotBondedPool := supply.NewEmptyModuleAccount(staking.NotBondedPoolName, supply.Burner, supply.Staking)\n\tbondPool := supply.NewEmptyModuleAccount(staking.BondedPoolName, supply.Burner, supply.Staking)\n\n\tblacklistedAddrs := make(map[string]bool)\n\tblacklistedAddrs[supply.NewModuleAddress(feeCollectorAcc.GetName().String()).String()] = true\n\tblacklistedAddrs[supply.NewModuleAddress(notBondedPool.GetName().String()).String()] = true\n\tblacklistedAddrs[supply.NewModuleAddress(bondPool.GetName().String()).String()] = true\n\tblacklistedAddrs[supply.NewModuleAddress(distrAcc.GetName().String()).String()] = true\n\tblacklistedAddrs[supply.NewModuleAddress(skModuleAcc.GetName().String()).String()] = true\n\n\tsk := staking.NewKeeper(\n\t\tcdc, sdk.NewKVStoreKey(staking.StoreKey), assetKeeper, supplyKeeper, pk.Subspace(staking.DefaultParamspace), AccountKeeper)\n\n\tkeeper := NewKeeper(cdc, sdk.NewKVStoreKey(types.StoreKey), pk.Subspace(types.DefaultParamspace),\n\t\tassetKeeper, sk, supplyKeeper, AccountKeeper, fee.CollectorName, blacklistedAddrs)\n\n\tms.MountStoreWithDB(keeper.storeKey, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(sk.GetStoreKey(), sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(supplyKeeper.GetStoreKey(), sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(assetKeeper.GetStoreKey(), sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(AccountKeeper.GetStoreKey(), sdk.StoreTypeIAVL, db)\n\terr := ms.LoadLatestVersion()\n\trequire.Nil(t, err)\n\n\tctx := sdk.NewContext(ms, abci.Header{ChainID: \"foochainid\"}, isCheckTx, log.NewNopLogger())\n\tfor _, addr := range TestAddrs {\n\t\tCreateAccount(AccountKeeper, ctx, addr)\n\t}\n\tCreateAccount(AccountKeeper, ctx, Master)\n\n\tsk.SetParams(ctx, staking.DefaultParams())\n\n\tintNum1, _ := sdk.NewIntFromString(\"1000000000000000000000\")\n\tintNum2, _ := sdk.NewIntFromString(\"80000000000000000000000\")\n\tintNum3, _ := sdk.NewIntFromString(\"60000000000000000000000\")\n\tintNumFee, _ := sdk.NewIntFromString(\"20000000000000000000000\")\n\tintMaxNum, _ := sdk.NewIntFromString(\"100000000000000000000000\")\n\n\tSymbolName, _ := chainTypes.NewName(constants.DefaultBondSymbol)\n\n\tassetKeeper.Create(ctx, MasterName, SymbolName, assettypes.NewCoin(constants.DefaultBondDenom, intNum2),\n\t\ttrue, true, true, 0, assettypes.NewCoin(constants.DefaultBondDenom, intMaxNum), []byte(\"create\"))\n\n\tassetKeeper.Issue(ctx, MasterName, SymbolName,\n\t\tassettypes.NewCoin(constants.DefaultBondDenom, intNum3))\n\n\t{\n\t\tfor _, addr := range TestAddrs {\n\t\t\tCoins := chainTypes.NewCoins(chainTypes.NewCoin(constants.DefaultBondDenom, intNum1))\n\t\t\terr := assetKeeper.Transfer(ctx, Master, addr, Coins)\n\t\t\t//fmt.Println(\"id\", id, \"account\", addr.String())\n\t\t\trequire.Nil(t, err)\n\t\t}\n\t\tCoins := chainTypes.NewCoins(chainTypes.NewCoin(constants.DefaultBondDenom, intNumFee))\n\t\terr := assetKeeper.Transfer(ctx, Master, supplyKeeper.GetModuleAccount(ctx, keeper.feeCollectorName).GetID(), Coins)\n\t\trequire.Nil(t, err)\n\t}\n\n\t// set module Accounts\n\tkeeper.supplyKeeper.SetModuleAccount(ctx, feeCollectorAcc)\n\tkeeper.supplyKeeper.SetModuleAccount(ctx, notBondedPool)\n\tkeeper.supplyKeeper.SetModuleAccount(ctx, bondPool)\n\tkeeper.supplyKeeper.SetModuleAccount(ctx, distrAcc)\n\tkeeper.supplyKeeper.SetModuleAccount(ctx, skModuleAcc)\n\n\t// set the distribution hooks on staking\n\tsk.SetHooks(keeper.Hooks())\n\n\t// set genesis items required for distribution\n\tkeeper.SetFeePool(ctx, types.InitialFeePool())\n\n\tparams := types.DefaultParams()\n\tparams.CommunityTax = communityTax\n\tparams.BaseProposerReward = sdk.NewDecWithPrec(1, 2)\n\tparams.BonusProposerReward = sdk.NewDecWithPrec(4, 2)\n\tkeeper.SetParams(ctx, params)\n\n\treturn ctx, AccountKeeper, assetKeeper, keeper, sk, pk, supplyKeeper\n}", "title": "" }, { "docid": "04de701c15d2829b7c8fd053ebeed7cf", "score": "0.44033766", "text": "func (s *SmartContract) Init(stub shim.ChaincodeStubInterface) peer.Response {\n\ts.logger = shim.NewLogger(\"supplychain\")\n\ts.clock = clock.New()\n\treturn shim.Success(nil)\n}", "title": "" }, { "docid": "ce601d94bdbdb987c910f1575b8dc69b", "score": "0.43884405", "text": "func (d *Driver) Setup(cfg *asset.WalletConfig, logger dex.Logger, network dex.Network) (asset.Wallet, error) {\n\treturn NewWallet(cfg, logger, network)\n}", "title": "" }, { "docid": "f1406056052b1d99db6e802a25da538b", "score": "0.43777952", "text": "func (t *Sharing) initSharing(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n //start := time.Now()\n var err error\n\n // 0-previous hash; 1-current hash; 2-ownership claim; 3-minhash values; 4~10-complementary minhash values;\n // 11-receiver; 12-terms of service; 13-future hash; 14-randomness; 15-SignCH;\n // 16~19-PCH/QCH/GCH/HkCH; 20-chameleon hash\n if len(args) != 24 {\n return shim.Error(\"Incorrect number of arguments. Expecting 22\")\n }\n\n // Input sanitation\n //fmt.Println(\"- start init sharing\")\n if len(args[0]) <= 0 {\n return shim.Error(\"1st argument must be a non-empty string\")\n }\n if len(args[1]) <= 0 {\n return shim.Error(\"2nd argument must be a non-empty string\")\n }\n if len(args[2]) <= 0 {\n return shim.Error(\"3rd argument must be a non-empty string\")\n }\n if len(args[3]) <= 0 {\n return shim.Error(\"4th argument must be a non-empty string\")\n }\n if len(args[4]) <= 0 {\n return shim.Error(\"5th argument must be a non-empty string\")\n }\n if len(args[5]) <= 0 {\n return shim.Error(\"6th argument must be a non-empty string\")\n }\n if len(args[6]) <= 0 {\n return shim.Error(\"7th argument must be a non-empty string\")\n }\n if len(args[7]) <= 0 {\n return shim.Error(\"8th argument must be a non-empty string\")\n }\n if len(args[8]) <= 0 {\n return shim.Error(\"9th argument must be a non-empty string\")\n }\n if len(args[9]) <= 0 {\n return shim.Error(\"10th argument must be a non-empty string\")\n }\n if len(args[10]) <= 0 {\n return shim.Error(\"11th argument must be a non-empty string\")\n }\n if len(args[11]) <= 0 {\n return shim.Error(\"12th argument must be a non-empty string\")\n }\n if len(args[12]) <= 0 {\n return shim.Error(\"13th argument must be a non-empty string\")\n }\n if len(args[13]) <= 0 {\n return shim.Error(\"14th argument must be a non-empty string\")\n }\n if len(args[14]) <= 0 {\n return shim.Error(\"14th argument must be a non-empty string\")\n }\n if len(args[15]) <= 0 {\n return shim.Error(\"14th argument must be a non-empty string\")\n }\n if len(args[16]) <= 0 {\n return shim.Error(\"14th argument must be a non-empty string\")\n }\n if len(args[17]) <= 0 {\n return shim.Error(\"14th argument must be a non-empty string\")\n }\n if len(args[18]) <= 0 {\n return shim.Error(\"14th argument must be a non-empty string\")\n }\n if len(args[19]) <= 0 {\n return shim.Error(\"14th argument must be a non-empty string\")\n }\n if len(args[20]) <= 0 {\n return shim.Error(\"14th argument must be a non-empty string\")\n }\n if len(args[21]) <= 0 {\n return shim.Error(\"14th argument must be a non-empty string\")\n }\n if len(args[22]) <= 0 {\n return shim.Error(\"14th argument must be a non-empty string\")\n }\n if len(args[23]) <= 0 {\n return shim.Error(\"14th argument must be a non-empty string\")\n }\n prevhash := args[0]\n hash := args[1]\n ownership := strings.ToLower(args[2])\n minhash := args[3]\n minhash1 := args[4]\n minhash2 := args[5]\n minhash3 := args[6]\n minhash4 := args[7]\n minhash5 := args[8]\n minhash6 := args[9]\n minhash7 := args[10]\n minhash8 := args[11]\n minhash9 := args[12]\n receiver := strings.ToLower(args[13])\n tos := strings.ToLower(args[14])\n futurehash := args[15]\n randomness := args[16]\n signch := args[17]\n pch := args[18]\n qch := args[19]\n gch := args[20]\n hkch := args[21]\n chhash := args[22]\n traversehelper := strings.ToLower(args[23])\n\n\n\n // =========================================================================================\n // check if similar data exists.\n // but this is just a half-complete part since we only get the similarities but no rejection\n // or warning if similar records found.\n // enough for a check-of-performance. currently disabled for check of other functions.\n // =========================================================================================\n\n /*\n if ownership==\"owner\" {\n queryString := fmt.Sprintf(\"{\\\"selector\\\":{\\\"docType\\\":\\\"data\\\",\\\"ownership\\\":\\\"%s\\\"}}\", ownership)\n\n queryResults, err := getQueryResultForQueryString(stub, queryString, minhash)\n if err != nil {\n return shim.Error(err.Error())\n }\n //fmt.Sprintf(\"%s\",queryResults)\n if len(queryResults) != 0 {\n fmt.Sprintf(\"\\n\\n\\nSome existing records: %s\\n\\n\\n\",queryResults)\n }\n\n\n temp := \"sender\"\n queryString = fmt.Sprintf(\"{\\\"selector\\\":{\\\"docType\\\":\\\"data\\\",\\\"ownership\\\":\\\"%s\\\"}}\", temp)\n\n queryResults, err = getQueryResultForQueryString(stub, queryString, minhash)\n if err != nil {\n return shim.Error(err.Error())\n }\n //if len(queryResults) != 0 {\n fmt.Sprintf(\"\\n\\n\\nSome existing records: %s\\n\\n\\n\",queryResults)\n //}\n\n }*/\n\n\n // =========================================================================================\n // =========================================================================================\n // check if shared data already exists.\n // need to be further modified by adding a the check of minhash values\n // changed the order here between finding the same minhash values and the similar ones\n // just for experiment purposes.\n // =========================================================================================\n // =========================================================================================\n\n minhashVerify, err := stub.GetState(minhash) //note we are using minhash values as the main key for each sharing\n if err != nil {\n return shim.Error(\"Failed to get data: \" + err.Error())\n } else if minhashVerify != nil {\n //fmt.Println(\"This data already exists: \")\n return shim.Error(\"This marble already exists: \" + minhash)\n }\n\n\n // Create data object and marshal to JSON\n objectType := \"data\"\n data := &data{objectType, prevhash, hash, ownership,minhash, minhash1, minhash2,\n minhash3, minhash4, minhash5, minhash6,minhash7, minhash8,minhash9,receiver,tos,futurehash,\n randomness,signch,pch,qch,gch,hkch, chhash, traversehelper}\n dataJSONasBytes, err := json.Marshal(data)\n if err != nil {\n return shim.Error(err.Error())\n }\n\n\n\n // Save data to state\n err = stub.PutState(minhash, dataJSONasBytes)\n if err != nil {\n return shim.Error(err.Error())\n }\n\n // Data saved, return success\n //fmt.Println(\"- end init data\")\n //elapsed := time.Since(start)\n //fmt.Println(elapsed)\n //fmt.Println(\"Inserting data...\")\n\n return shim.Success(nil)\n}", "title": "" }, { "docid": "17e96c91a6d1969ea973ac2cda6dd01d", "score": "0.43705803", "text": "func ImportWallet(hash, pk, sk string) (*Wallet, error) {\n\n\tvar wallet Wallet\n\tvar signKP keyPair\n\n\t// Sanity check\n\tsecretLength := len(sk)\n\tif secretLength != 98 && secretLength != 54 {\n\t\treturn &wallet, errors.New(\"wallet prefix is not edsk\")\n\t}\n\n\tif sk[:4] != \"edsk\" {\n\t\treturn &wallet, errors.New(\"wallet prefix is not edsk\")\n\t}\n\n\t// Determine if 'secret' is an actual secret key or a seed\n\tif secretLength == 98 {\n\n\t\t// A full secret key\n\t\tdecodedSecretKey := b58cdecode(sk, edskprefix)\n\n\t\t// Public key is last 32 of decoded secret, re-encoded as edpk\n\t\tpublicKey := decodedSecretKey[32:]\n\n\t\tsignKP.PubKey = publicKey\n\t\tsignKP.PrivKey = decodedSecretKey\n\n\t\twallet.Sk = sk\n\n\t} else if secretLength == 54 {\n\n\t\t// \"secret\" is actually a seed\n\t\tdecodedSeed := b58cdecode(sk, edskprefix2)\n\n\t\t//signSeed := sodium.SignSeed{Bytes: decodedSeed}\n\n\t\t// Reconstruct keypair from seed\n\t\tprivKey := ed25519.NewKeyFromSeed(decodedSeed)\n\t\tpubKey := privKey.Public().(ed25519.PublicKey)\n\t\tsignKP.PrivKey = privKey\n\t\tsignKP.PubKey = []byte(pubKey)\n\n\t\twallet.Sk = b58cencode(signKP.PrivKey, edskprefix)\n\n\t} else {\n\t\treturn &wallet, errors.Errorf(\"wallet secret key length '%d' does not = '%d'\", 54, secretLength)\n\t}\n\n\twallet.Kp = signKP\n\n\t// Generate public address from public key\n\tgeneratedAddress, err := generatePublicHash(signKP.PubKey)\n\tif err != nil {\n\t\treturn &wallet, errors.Wrapf(err, \"could not generate public hash\")\n\t}\n\n\tif generatedAddress != hash {\n\t\treturn &wallet, errors.Errorf(\"reconstructed address '%s' does not match provided address '%s'\", generatedAddress, hash)\n\t}\n\n\twallet.Address = generatedAddress\n\n\t// Genrate and check public key\n\tgeneratedPublicKey := b58cencode(signKP.PubKey, edpkprefix)\n\tif generatedPublicKey != pk {\n\t\treturn &wallet, errors.Errorf(\"reconstructed pk '%s' does not match provided pk '%s'\", generatedPublicKey, pk)\n\t}\n\twallet.Pk = generatedPublicKey\n\n\treturn &wallet, nil\n}", "title": "" }, { "docid": "115585b6c04ca030b955b1d9a9a0b7ea", "score": "0.43647158", "text": "func (dp *deniableProver) initStep() {\n\n\tkeylen := dp.prirand.KeySize()\n\tkey := make([]byte, keylen) // secret random key\n\tdp.prirand.Read(key)\n\tdp.key = key\n\n\tmsg := make([]byte, keylen) // send commitment to it\n\tdp.suite.Cipher(key).XORKeyStream(msg, msg)\n\tdp.msg = bytes.NewBuffer(msg)\n\n\t// The Sigma-Prover will now append its proof content to dp.msg...\n}", "title": "" }, { "docid": "f8d29f169af5de0dc3ffea48d7d4243d", "score": "0.435833", "text": "func TestSignStakingTxOutputWit(t *testing.T) {\n\t// t.Parallel()\n\tw, err := iniWallet(\"StakingTxScriptWallet\")\n\tif err != nil {\n\t\tt.Errorf(\"create wallet error : %v\", err)\n\t}\n\tdefer w.close()\n\n\tpkScript, err := createP2wshStakingScript(w, 1, 1, consensus.MinFrozenPeriod)\n\tgetScript := txscript.ScriptClosure(func(addr massutil.Address) ([]byte, error) {\n\t\tscript, _ := w.WitnessMap[addr.EncodeAddress()]\n\t\treturn script, nil\n\t})\n\tgetSign := txscript.SignClosure(func(pub *btcec.PublicKey, hash []byte) (*btcec.Signature, error) {\n\t\treturn w.mgr.SignHash(pub, hash, []byte(walletpass))\n\t})\n\tif err != nil {\n\t\tt.Errorf(\"create wallet error : %v\", err)\n\t}\n\t// make key\n\t// make script based on key.\n\t// sign with magic pixie dust.\n\thashTypes := []txscript.SigHashType{\n\t\ttxscript.SigHashAll,\n\t\ttxscript.SigHashNone,\n\t\ttxscript.SigHashSingle,\n\t\ttxscript.SigHashAll | txscript.SigHashAnyOneCanPay,\n\t\ttxscript.SigHashNone | txscript.SigHashAnyOneCanPay,\n\t\ttxscript.SigHashSingle | txscript.SigHashAnyOneCanPay,\n\t}\n\ttx := &wire.MsgTx{\n\t\tVersion: 1,\n\t\tTxIn: []*wire.TxIn{\n\t\t\t{\n\t\t\t\tPreviousOutPoint: wire.OutPoint{\n\t\t\t\t\tHash: wire.Hash{},\n\t\t\t\t\tIndex: 0,\n\t\t\t\t},\n\t\t\t\tSequence: consensus.MinFrozenPeriod + 1,\n\t\t\t},\n\t\t\t{\n\t\t\t\tPreviousOutPoint: wire.OutPoint{\n\t\t\t\t\tHash: wire.Hash{},\n\t\t\t\t\tIndex: 1,\n\t\t\t\t},\n\t\t\t\tSequence: consensus.MinFrozenPeriod + 1,\n\t\t\t},\n\t\t\t{\n\t\t\t\tPreviousOutPoint: wire.OutPoint{\n\t\t\t\t\tHash: wire.Hash{},\n\t\t\t\t\tIndex: 2,\n\t\t\t\t},\n\t\t\t\tSequence: consensus.MinFrozenPeriod + 1,\n\t\t\t},\n\t\t},\n\t\tTxOut: []*wire.TxOut{\n\t\t\t{\n\t\t\t\tValue: 1,\n\t\t\t},\n\t\t\t{\n\t\t\t\tValue: 2,\n\t\t\t},\n\t\t\t{\n\t\t\t\tValue: 3,\n\t\t\t},\n\t\t},\n\t\tLockTime: 0,\n\t}\n\n\t// p2wsh\n\tfor _, hashType := range hashTypes {\n\t\tfor i := range tx.TxIn {\n\t\t\tmsg := fmt.Sprintf(\"%d:%d\", hashType, i)\n\t\t\t//output value is 0\n\t\t\tvar value = 0\n\t\t\tif err := signAndCheck(msg, tx, i, pkScript, hashType,\n\t\t\t\tgetSign, getScript, nil, int64(value)); err != nil {\n\t\t\t\tt.Error(err)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "3dc4798c4d2d4e0df150a15453e7cfda", "score": "0.43569946", "text": "func NewWallet(username string) Wallet {\n\treturn Wallet{username, NewBlockchain()}\n}", "title": "" }, { "docid": "b32251927e289fa9efcb46ad2669222c", "score": "0.4347175", "text": "func initWhisk(s *serverlessService) error {\n\tif s.owClient != nil {\n\t\treturn nil\n\t}\n\tvar config *whisk.Config\n\tif s.owConfig != nil {\n\t\tconfig = s.owConfig\n\t} else {\n\t\terr := s.CheckServerlessStatus()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcreds, err := s.ReadCredentials()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcredential := creds.Credentials[creds.APIHost][creds.Namespace]\n\t\tconfig = &whisk.Config{Host: creds.APIHost, AuthToken: credential.Auth}\n\t}\n\tclient, err := whisk.NewClient(http.DefaultClient, config)\n\tif err != nil {\n\t\treturn err\n\t}\n\ts.owClient = client\n\treturn nil\n}", "title": "" }, { "docid": "4b0140eda4d52140df69b747bcac2e40", "score": "0.43459302", "text": "func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {\n\tif core.IsSoftforkHeight(ctx, 1) {\n\t\tparams := k.GetParams(ctx)\n\t\tparams.MaxContractMsgSize = 4096\n\t\tk.SetParams(ctx, params)\n\t}\n}", "title": "" }, { "docid": "74d5947a03c87d73d820e0a33b534ff3", "score": "0.43310222", "text": "func populateWallet(wallet *gateway.Wallet) error {\n\tlog.Println(\"============ Populating wallet ============\")\n\tcredPath := filepath.Join(\n\t\t\"..\",\n\t\t\"..\",\n\t\t\"test-network\",\n\t\t\"organizations\",\n\t\t\"peerOrganizations\",\n\t\t\"org1.example.com\",\n\t\t\"users\",\n\t\t\"User1@org1.example.com\",\n\t\t\"msp\",\n\t)\n\n\tcertPath := filepath.Join(credPath, \"signcerts\", \"cert.pem\")\n\t// read the certificate pem\n\tcert, err := ioutil.ReadFile(filepath.Clean(certPath))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tkeyDir := filepath.Join(credPath, \"keystore\")\n\t// there's a single file in this dir containing the private key\n\tfiles, err := ioutil.ReadDir(keyDir)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(files) != 1 {\n\t\treturn fmt.Errorf(\"keystore folder should have contain one file\")\n\t}\n\tkeyPath := filepath.Join(keyDir, files[0].Name())\n\tkey, err := ioutil.ReadFile(filepath.Clean(keyPath))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tidentity := gateway.NewX509Identity(\"Org1MSP\", string(cert), string(key))\n\n\treturn wallet.Put(\"appUser\", identity)\n}", "title": "" }, { "docid": "560c939afed33757c6e3b25e133f7a49", "score": "0.4315991", "text": "func TestCreateWalletInvalidEntropy(t *testing.T) {\n\tt.Parallel()\n\n\t// testDir is empty, meaning wallet was not created from before.\n\ttestDir, err := ioutil.TempDir(\"\", \"testcreate\")\n\tif err != nil {\n\t\tt.Fatalf(\"unable to create temp directory: %v\", err)\n\t}\n\tdefer func() {\n\t\tos.RemoveAll(testDir)\n\t}()\n\n\t// Create new UnlockerService.\n\tservice := walletunlocker.New(testDir, testNetParams, true, nil)\n\n\t// We'll attempt to init the wallet with an invalid cipher seed and\n\t// passphrase.\n\treq := &lnrpc.InitWalletRequest{\n\t\tWalletPassword: testPassword,\n\t\tCipherSeedMnemonic: []string{\"invalid\", \"seed\"},\n\t\tAezeedPassphrase: []byte(\"fake pass\"),\n\t}\n\n\tctx := context.Background()\n\t_, err = service.InitWallet(ctx, req)\n\tif err == nil {\n\t\tt.Fatalf(\"wallet creation should have failed\")\n\t}\n}", "title": "" }, { "docid": "fdfb0f3d9989f1479d5c914fdcf3b3ee", "score": "0.4315018", "text": "func (_Rollup *RollupTransactor) Initialize(opts *bind.TransactOpts, _machineHash [32]byte, _confirmPeriodBlocks *big.Int, _extraChallengeTimeBlocks *big.Int, _arbGasSpeedLimitPerBlock *big.Int, _baseStake *big.Int, _stakeToken common.Address, _owner common.Address, _extraConfig []byte, connectedContracts [6]common.Address) (*types.Transaction, error) {\n\treturn _Rollup.contract.Transact(opts, \"initialize\", _machineHash, _confirmPeriodBlocks, _extraChallengeTimeBlocks, _arbGasSpeedLimitPerBlock, _baseStake, _stakeToken, _owner, _extraConfig, connectedContracts)\n}", "title": "" }, { "docid": "b02d2e37d18f0c796960429ca2203c7c", "score": "0.43148422", "text": "func setup(tb testing.TB, c *envConfig) *environment {\n\trequire := require.New(tb)\n\n\tvar (\n\t\tgenesisArgs *BuildGenesisArgs\n\t\tassetName = \"AVAX\"\n\t)\n\tif c.isCustomFeeAsset {\n\t\tgenesisArgs = makeCustomAssetGenesis(tb)\n\t\tassetName = feeAssetName\n\t} else {\n\t\tgenesisArgs = makeDefaultGenesis(tb)\n\t}\n\n\tgenesisBytes := buildGenesisTestWithArgs(tb, genesisArgs)\n\tctx := newContext(tb)\n\n\tbaseDBManager := manager.NewMemDB(version.Semantic1_0_0)\n\n\tm := atomic.NewMemory(prefixdb.New([]byte{0}, baseDBManager.Current().Database))\n\tctx.SharedMemory = m.NewSharedMemory(ctx.ChainID)\n\n\t// NB: this lock is intentionally left locked when this function returns.\n\t// The caller of this function is responsible for unlocking.\n\tctx.Lock.Lock()\n\n\tuserKeystore, err := keystore.CreateTestKeystore()\n\trequire.NoError(err)\n\tctx.Keystore = userKeystore.NewBlockchainKeyStore(ctx.ChainID)\n\n\tfor _, user := range c.keystoreUsers {\n\t\trequire.NoError(userKeystore.CreateUser(user.username, user.password))\n\n\t\t// Import the initially funded private keys\n\t\tkeystoreUser, err := keystoreutils.NewUserFromKeystore(ctx.Keystore, user.username, user.password)\n\t\trequire.NoError(err)\n\n\t\trequire.NoError(keystoreUser.PutKeys(user.initialKeys...))\n\t\trequire.NoError(keystoreUser.Close())\n\t}\n\n\tvmStaticConfig := config.Config{\n\t\tTxFee: testTxFee,\n\t\tCreateAssetTxFee: testTxFee,\n\t}\n\tif c.vmStaticConfig != nil {\n\t\tvmStaticConfig = *c.vmStaticConfig\n\t}\n\n\tvm := &VM{\n\t\tConfig: vmStaticConfig,\n\t}\n\n\tvmDynamicConfig := Config{\n\t\tIndexTransactions: true,\n\t}\n\tif c.vmDynamicConfig != nil {\n\t\tvmDynamicConfig = *c.vmDynamicConfig\n\t}\n\tconfigBytes, err := stdjson.Marshal(vmDynamicConfig)\n\trequire.NoError(err)\n\n\trequire.NoError(vm.Initialize(\n\t\tcontext.Background(),\n\t\tctx,\n\t\tbaseDBManager.NewPrefixDBManager([]byte{1}),\n\t\tgenesisBytes,\n\t\tnil,\n\t\tconfigBytes,\n\t\tnil,\n\t\tappend(\n\t\t\t[]*common.Fx{\n\t\t\t\t{\n\t\t\t\t\tID: secp256k1fx.ID,\n\t\t\t\t\tFx: &secp256k1fx.Fx{},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tID: nftfx.ID,\n\t\t\t\t\tFx: &nftfx.Fx{},\n\t\t\t\t},\n\t\t\t},\n\t\t\tc.additionalFxs...,\n\t\t),\n\t\t&common.SenderTest{},\n\t))\n\n\tstopVertexID := ids.GenerateTestID()\n\tissuer := make(chan common.Message, 1)\n\n\tenv := &environment{\n\t\tgenesisBytes: genesisBytes,\n\t\tgenesisTx: getCreateTxFromGenesisTest(tb, genesisBytes, assetName),\n\t\tsharedMemory: m,\n\t\tissuer: issuer,\n\t\tvm: vm,\n\t\tservice: &Service{\n\t\t\tvm: vm,\n\t\t},\n\t\twalletService: &WalletService{\n\t\t\tvm: vm,\n\t\t\tpendingTxs: linkedhashmap.New[ids.ID, *txs.Tx](),\n\t\t},\n\t}\n\n\trequire.NoError(vm.SetState(context.Background(), snow.Bootstrapping))\n\tif c.notLinearized {\n\t\treturn env\n\t}\n\n\trequire.NoError(vm.Linearize(context.Background(), stopVertexID, issuer))\n\tif c.notBootstrapped {\n\t\treturn env\n\t}\n\n\trequire.NoError(vm.SetState(context.Background(), snow.NormalOp))\n\treturn env\n}", "title": "" }, { "docid": "9dc2d4495917359bebc6ccfbeee13f62", "score": "0.43134978", "text": "func Init(ops ...Option) {\n\tfor _, op := range ops {\n\t\top(&cfg)\n\t}\n\n\tif cfg.RPCAddress == \"\" {\n\t\tcfg.RPCAddress = \"127.0.0.1:6422\"\n\t}\n\n\tif cfg.WalletDir == \"\" {\n\t\thome := util.UserHome()\n\t\tcfg.WalletDir = home + \"/.\" + os.Args[0] + \"/wallets\"\n\t}\n\n\tif cfg.DefaultWalletName == \"\" {\n\t\tcfg.DefaultWalletName = fmt.Sprintf(\"%s_cli.wlt\", os.Args[0])\n\t}\n\n\tcommands = append(commands,\n\t\taddPrivateKeyCMD(),\n\t\tblocksCMD(),\n\t\tbroadcastTxCMD(),\n\t\twalletBalanceCMD(),\n\t\twalletOutputsCMD(),\n\t\taddressBalanceCMD(),\n\t\taddressOutputsCMD(),\n\t\tcreateRawTxCMD(),\n\t\tgenerateAddrsCMD(),\n\t\tgenerateWalletCMD(),\n\t\tlastBlocksCMD(),\n\t\tlistAddressesCMD(),\n\t\tlistWalletsCMD(),\n\t\tsendCMD(),\n\t\tstatusCMD(),\n\t\ttransactionCMD(),\n\t\tversionCMD(),\n\t\twalletDirCMD(),\n\t\twalletHisCMD())\n}", "title": "" }, { "docid": "48d4db89c07792f744675df38e44a657", "score": "0.42982522", "text": "func pickWinningValidator() {\n\ttime.Sleep(time.Duration(ethereum.WinningInterval) * time.Second)\n\t/*\n\t------------------------------------------------------\n\tPurpose : temp contains all the blocks proposed during the interval\n\t------------------------------------------------------\n\t*/\n\tmutex.Lock()\n\ttemp := ethereum.TempBlocks\n\tmutex.Unlock()\n\n\n\tlotteryPool := []string{} // Holds the array of node address in multiple of stakes they have put\n\tif len(temp) > 0 { // If the number of proposed blocks during that time != 0 \n\n\t\tSKIP_NODE:\n\t\t/*\n\t\t------------------------------------------------------\n\t\tPurpose : Prepare LotteryPool Iterate through each block proposed in this timeinterval\n\t\t------------------------------------------------------\n\t\t*/\n\t\tfor _, block := range temp {\n\t\t\t// Skip the \n\t\t\tfor _, node := range lotteryPool {\n\t\t\t\tif block.Validator == node {\n\t\t\t\t\tcontinue SKIP_NODE\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Lock validators\n\t\t\tmutex.Lock()\n\t\t\tsetValidators := ethereum.Validators\n\t\t\tmutex.Unlock()\n\n\t\t\tnumberOfStakes, validatorOk := setValidators[block.Validator]\n\t\t\tif validatorOk { // If the node address is registered as \n\t\t\t\tfor i := 0; i < numberOfStakes; i++ { // Iterate as many times as number of stakes\n\t\t\t\t\tlotteryPool = append(lotteryPool, block.Validator)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/*\n\t\t------------------------------------------------------\n\t\tPurpose : Choose winner from LotteryPool\n\t\t------------------------------------------------------\n\t\t*/\n\t\ts := rand.NewSource(time.Now().Unix())\n\t\tr := rand.New(s)\n\t\tlotteryWinner := lotteryPool[r.Intn(len(lotteryPool))]\n\n\t\t/*\n\t\t------------------------------------------------------\n\t\tPurpose : Add the winner's blocks to the block chain\n\t\t------------------------------------------------------\n\t\t*/\n\t\tfor _, block := range temp {\n\t\t\tif block.Validator == lotteryWinner {\n\t\t\t\tmutex.Lock()\n\t\t\t\tethereum.Blockchain = append(ethereum.Blockchain, block)\n\t\t\t\tmutex.Unlock()\n\t\t\t}\n\t\t}\n\t\t/*\n\t\t------------------------------------------------------\n\t\tPurpose : Announce winner to all the nodes on the network\n\t\t------------------------------------------------------\n\t\t*/\n\t\tfor _ = range ethereum.Validators {\n\t\t\tethereum.Announcements <- \"\\nWinning node : \" + lotteryWinner + \"\\n\"\n\t\t}\n\t}\n\n\tmutex.Lock()\n\tethereum.TempBlocks = []BlockElement.Block{}\n\tmutex.Unlock()\n}", "title": "" }, { "docid": "cefc4880e2e9841a41dfa1aa21cbce27", "score": "0.42957634", "text": "func SetBlockOptionFirstRequest(request *Pdu) {\n blockValue,_ := request.GetOptionIntegerValue(OptionBlock2)\n block := IntToBlock(blockValue)\n if block != nil {\n block.NUM = 0\n request.SetOption(OptionBlock2, uint32(block.ToInt()))\n }\n}", "title": "" }, { "docid": "4e94a7922039a4dea7874d7c99f41516", "score": "0.42927742", "text": "func createWallet(net string) error {\n\t// create wallet\n\tlog.Printf(\"Creating lightning wallet: %v\", net)\n\n\tdcrwalletExe := filepath.Join(destination,\n\t\t\"decred-\"+tuple+\"-\"+manifestDecredVersion, \"dcrwallet\")\n\targs := []string{\"--create\"}\n\tswitch net {\n\tcase \"testnet\":\n\t\targs = append(args, \"--testnet\")\n\tcase \"simnet\":\n\t\targs = append(args, \"--simnet\")\n\t}\n\tcmd := exec.Command(dcrwalletExe, args...)\n\tcmd.Stdin = os.Stdin\n\tcmd.Stdout = os.Stdout\n\tcmd.Stderr = os.Stderr\n\treturn cmd.Run()\n}", "title": "" }, { "docid": "576b7add388bf4b91545cca0511b43bc", "score": "0.4289613", "text": "func WalletHandle(ifc interface{}) (e error) {\n\tvar cx *state.State\n\tvar ok bool\n\tif cx, ok = ifc.(*state.State); !ok {\n\t\treturn fmt.Errorf(\"cannot run without a state\")\n\t}\n\tcx.Config.WalletFile.Set(filepath.Join(cx.Config.DataDir.V(), cx.ActiveNet.Name, constant.DbName))\n\t// dbFilename := *cx.Config.DataDir + slash + cx.ActiveNet.\n\t// \tParams.Name + slash + wallet.WalletDbName\n\tif !apputil.FileExists(cx.Config.WalletFile.V()) && !cx.IsGUI {\n\t\t// D.Ln(cx.ActiveNet.Name, *cx.Config.WalletFile)\n\t\tif e = wallet.CreateWallet(cx.ActiveNet, cx.Config); E.Chk(e) {\n\t\t\tE.Ln(\"failed to create wallet\", e) /**/\n\t\t\treturn e\n\t\t}\n\t\tfmt.Println(\"restart to complete initial setup\")\n\t\t// os.Exit(0)\n\t\tinterrupt.RequestRestart()\n\t}\n\t// for security with apps launching the wallet, the public password can be set with a file that is deleted after\n\twalletPassPath := filepath.Join(cx.Config.DataDir.V(), cx.ActiveNet.Name, \"wp.txt\")\n\tD.Ln(\"reading password from\", walletPassPath)\n\tif apputil.FileExists(walletPassPath) {\n\t\tvar b []byte\n\t\tif b, e = ioutil.ReadFile(walletPassPath); !E.Chk(e) {\n\t\t\tcx.Config.WalletPass.SetBytes(b)\n\t\t\tD.Ln(\"read password '\" + string(b) + \"'\", cx.Config.WalletPass.V())\n\t\t\tif e = ioutil.WriteFile(walletPassPath, make([]byte, len(b)),\n\t\t\t\t0700); E.Chk(e) {\n\t\t\t}\n\t\t\tif e = os.Remove(walletPassPath); E.Chk(e) {\n\t\t\t}\n\t\t\tD.Ln(\"wallet cookie deleted\", cx.Config.WalletPass.V())\n\t\t}\n\t}\n\tcx.WalletKill = qu.T()\n\tif e = wallet.Main(cx); E.Chk(e) {\n\t\tE.Ln(\"failed to start up wallet\", e)\n\t}\n\t// if !*cx.Config.DisableRPC {\n\t// \tcx.WalletServer = <-cx.WalletChan\n\t// }\n\t// cx.WaitGroup.Wait()\n\tcx.WaitWait()\n\treturn\n}", "title": "" }, { "docid": "9f21e3ae7a4893bdadfb3d595af497a4", "score": "0.4286365", "text": "func initETHHelper(config *utils.IDHubConfig) (*eth.Helper, error) {\n\tif config.EthAPIURL != \"\" {\n\t\taccounts := map[string]string{}\n\t\tif config.EthereumDefaultPrivateKey != \"\" {\n\t\t\tlog.Infof(\"Initialized default Ethereum account\\n\")\n\t\t\taccounts[\"default\"] = config.EthereumDefaultPrivateKey\n\t\t}\n\t\tethHelper, err := eth.NewETHClientHelper(config.EthAPIURL, accounts)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tlog.Infof(\"Connected to Ethereum using %v\\n\", config.EthAPIURL)\n\t\treturn ethHelper, nil\n\t}\n\n\tethHelper, err := eth.NewSimulatedBackendHelper()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlog.Infof(\"Connected to Ethereum using Simulated Backend\\n\")\n\treturn ethHelper, nil\n}", "title": "" }, { "docid": "50e32c10ba7d911338ccc880fab21fde", "score": "0.4284363", "text": "func (mysuit *MySuite) TestSicBo_SettleBet(c *check.C) {\n\tutest.Init(orgID)\n\tcontractOwner := utest.DeployContract(c, contractName, orgID, contractMethods, contractInterfaces)\n\ttest := NewTestObject(contractOwner)\n\n\tgenesisOwner := utest.UTP.Helper().GenesisHelper().Token().Owner()\n\tutest.Assert(test.run().setSender(utest.UTP.Helper().AccountHelper().AccountOf(genesisOwner)) != nil)\n\tutest.Transfer(nil, test.obj.sdk.Helper().GenesisHelper().Token().Name(), test.obj.sdk.Message().Contract().Account(), bn.N(1E11))\n\taccounts := utest.NewAccounts(test.obj.sdk.Helper().GenesisHelper().Token().Name(), bn.N(1E13), 5)\n\tif accounts == nil {\n\t\tpanic(\"初始化newOwner失败\")\n\t}\n\n\tcommitLastBlock, pubKey, reveal, commit, signData, _ := PlaceBetHelper(100)\n\t//utest.AssertError(err, types.CodeOK)\n\n\ttest.run().setSender(contractOwner).InitChain()\n\tutest.AssertError(test.run().setSender(contractOwner).SetSecretSigner(pubKey[:]), types.CodeOK)\n\t//var i int64 = 0\n\t//for {\n\t//\tif i > 2 {\n\t//\t\tbreak\n\t//\t}\n\t//\tbetData := []BetData{{i + 1, bn.N(1000000000)}}\n\t//\tbetDataJsonBytes, _ := jsoniter.Marshal(betData)\n\t//\t//utest.AssertError(test.run().setSender(accounts[i]).transfer(bn.N(1000000000)).PlaceBet(string(betDataJsonBytes), commitLastBlock, commit, signData[:], \"\"), types.CodeOK)\n\t//\tutest.AssertError(test.run().setSender(accounts[i]).transfer(bn.N(1000000000)).PlaceBet(string(betDataJsonBytes), commitLastBlock,\"hello\", commit, signData[:], \"\"), types.CodeOK)\n\t//\ti++\n\t//\n\t//}\n\tbetData := []BetData{{1, bn.N(1000000000)}}\n\tbetDataJsonBytes, _ := jsoniter.Marshal(betData)\n\tbetData1 := []BetData{{2, bn.N(1000000000)}}\n\tbetDataJsonBytes1, _ := jsoniter.Marshal(betData1)\n\t// PlaceBet(betInfoJson string, commitLastBlock int64,betIndex string, commit, signData []byte, refAddress types.Address)\n\tutest.AssertError(test.run().setSender(accounts[0]).transfer(bn.N(1000000000)).PlaceBet(string(betDataJsonBytes), commitLastBlock, \"hello\", commit, signData[:], \"\"), types.CodeOK)\n\tutest.AssertError(test.run().setSender(accounts[0]).transfer(bn.N(1000000000)).PlaceBet(string(betDataJsonBytes1), commitLastBlock, \"hhgd\", commit, signData[:], \"\"), types.CodeOK)\n\tutest.AssertError(test.run().setSender(accounts[1]).transfer(bn.N(1000000000)).PlaceBet(string(betDataJsonBytes1), commitLastBlock, \"hhgdf\", commit, signData[:], \"\"), types.CodeOK)\n\tutest.AssertError(test.run().setSender(accounts[2]).transfer(bn.N(1000000000)).PlaceBet(string(betDataJsonBytes1), commitLastBlock, \"hhgdd\", commit, signData[:], \"\"), types.CodeOK)\n\tutest.AssertError(test.run().setSender(accounts[3]).transfer(bn.N(1000000000)).PlaceBet(string(betDataJsonBytes1), commitLastBlock, \"hhgdw\", commit, signData[:], \"\"), types.CodeOK)\n\t//\ti++\n\tutest.AssertError(test.run().setSender(contractOwner).SettleBet(reveal, 1), types.CodeOK)\n\tutest.AssertError(test.run().setSender(contractOwner).SettleBet(reveal, 3), types.CodeOK)\n}", "title": "" }, { "docid": "a2e90806039cbcbda3ffa258d77a8ecd", "score": "0.4281194", "text": "func (spc *InsuranceContract) InitInsurance(ctx contractapi.TransactionContextInterface) error {\n\n\tdefaultFSABalance = 1000\n\n\t// possible function to pre create policy and then create plans. then add the plans to the policy array.\n\taccountCount = 0\n\tuserCount = 0\n\tplanCount = 0\n\tpolicyCount = 0\n\n\treturn nil\n}", "title": "" }, { "docid": "0fe8795e362deb65f080c9292a3a45c1", "score": "0.42802024", "text": "func Initialize(init func(string), ccp ccprovider.ChaincodeProvider, sccp sysccprovider.SystemChaincodeProvider,\n\tpm txvalidator.PluginMapper, pr *platforms.Registry, deployedCCInfoProvider ledger.DeployedChaincodeInfoProvider,\n\tmembershipProvider ledger.MembershipInfoProvider, metricsProvider metrics.Provider) {\n\tnWorkers := viper.GetInt(\"peer.validatorPoolSize\")\n\tif nWorkers <= 0 {\n\t\tnWorkers = runtime.NumCPU()\n\t}\n\tvalidationWorkersSemaphore = semaphore.NewWeighted(int64(nWorkers))\n\n\tpluginMapper = pm\n\tchainInitializer = init\n\n\tvar cb *common.Block\n\tvar ledger ledger.PeerLedger\n\tledgermgmt.Initialize(&ledgermgmt.Initializer{\n\t\tCustomTxProcessors: ConfigTxProcessors,\n\t\tPlatformRegistry: pr,\n\t\tDeployedChaincodeInfoProvider: deployedCCInfoProvider,\n\t\tMembershipInfoProvider: membershipProvider,\n\t\tMetricsProvider: metricsProvider,\n\t})\n\tledgerIds, err := ledgermgmt.GetLedgerIDs()\n\tif err != nil {\n\t\tpanic(fmt.Errorf(\"Error in initializing ledgermgmt: %s\", err))\n\t}\n\tfor _, cid := range ledgerIds {\n\t\tpeerLogger.Infof(\"Loading chain %s\", cid)\n\t\tif ledger, err = ledgermgmt.OpenLedger(cid); err != nil {\n\t\t\tpeerLogger.Errorf(\"Failed to load ledger %s(%+v)\", cid, err)\n\t\t\tpeerLogger.Debugf(\"Error while loading ledger %s with message %s. We continue to the next ledger rather than abort.\", cid, err)\n\t\t\tcontinue\n\t\t}\n\t\tif cb, err = getCurrConfigBlockFromLedger(ledger); err != nil {\n\t\t\tpeerLogger.Errorf(\"Failed to find config block on ledger %s(%s)\", cid, err)\n\t\t\tpeerLogger.Debugf(\"Error while looking for config block on ledger %s with message %s. We continue to the next ledger rather than abort.\", cid, err)\n\t\t\tcontinue\n\t\t}\n\t\t// Create a chain if we get a valid ledger with config block\n\t\tif err = createChain(cid, ledger, cb, ccp, sccp, pm); err != nil {\n\t\t\tpeerLogger.Errorf(\"Failed to load chain %s(%s)\", cid, err)\n\t\t\tpeerLogger.Debugf(\"Error reloading chain %s with message %s. We continue to the next chain rather than abort.\", cid, err)\n\t\t\tcontinue\n\t\t}\n\n\t\tInitChain(cid)\n\t}\n}", "title": "" }, { "docid": "0f29ba6a138077b791b8ac0b7981b5d2", "score": "0.42783892", "text": "func BeginBlocker(ctx sdk.Ctx, req abci.RequestBeginBlock, k Keeper) {\n\t// reward the proposer with fees\n\tif ctx.BlockHeight() > 1 {\n\t\tpreviousProposer := k.GetPreviousProposer(ctx)\n\t\tk.blockReward(ctx, previousProposer)\n\t}\n\t// record the new proposer for when we payout on the next block\n\taddr := sdk.Address(req.Header.ProposerAddress)\n\tk.SetPreviousProposer(ctx, addr)\n\t// Iterate over all the validators which *should* have signed this block\n\t// store whether or not they have actually signed it and slash/unstake any\n\t// which have missed too many blocks in a row (downtime slashing)\n\tsignedBlocksWindow := k.SignedBlocksWindow(ctx)\n\tminSignedPerWindow := k.MinSignedPerWindow(ctx)\n\tdowntimeJailDuration := k.DowntimeJailDuration(ctx)\n\tslashFractionDowntime := k.SlashFractionDowntime(ctx)\n\n\tfor _, voteInfo := range req.LastCommitInfo.GetVotes() {\n\t\tk.handleValidatorSignature(ctx, voteInfo.Validator.Address, voteInfo.Validator.Power, voteInfo.SignedLastBlock, signedBlocksWindow, minSignedPerWindow, downtimeJailDuration, slashFractionDowntime)\n\t\t// remove those who are part of the tendermint validator set (jailed validators will never be a part of the set)\n\t}\n\t// Iterate through any newly discovered evidence of infraction\n\t// slash any validators (and since-unstaked stake within the unstaking period)\n\t// who contributed to valid infractions\n\tmaxEvidenceAgeMin := int(k.GetParams(ctx).MaxEvidenceAge.Minutes())\n\tfor _, evidence := range req.ByzantineValidators {\n\t\tswitch evidence.Type {\n\t\tcase tmtypes.ABCIEvidenceTypeDuplicateVote:\n\t\t\tif ctx.IsAfterUpgradeHeight() {\n\t\t\t\tevidenceAgeInBlocks := maxEvidenceAgeMin / 15\n\t\t\t\tif evidenceAgeInBlocks == 0 {\n\t\t\t\t\t// minimum of 1 block ago\n\t\t\t\t\tevidenceAgeInBlocks = 1\n\t\t\t\t}\n\t\t\t\tif ctx.BlockHeight()-evidence.Height <= int64(evidenceAgeInBlocks) {\n\t\t\t\t\tk.handleDoubleSign(ctx, evidence.Validator.Address, evidence.Height, evidence.Time, evidence.Validator.Power)\n\t\t\t\t} else {\n\t\t\t\t\tk.Logger(ctx).Error(fmt.Sprintf(\"disregarded %s evidence, max evidence age exceeded, height of evidence=%d\", evidence.Type, evidence.Height))\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tk.handleDoubleSign(ctx, evidence.Validator.Address, evidence.Height, evidence.Time, evidence.Validator.Power)\n\t\t\t}\n\t\tdefault:\n\t\t\tk.Logger(ctx).Error(fmt.Sprintf(\"ignored unknown evidence type: %s\", evidence.Type))\n\t\t}\n\t}\n}", "title": "" }, { "docid": "af3008a637f765be0789c0beaf6fff70", "score": "0.4271941", "text": "func main() {\n\n\t// Setup options for the program content\n\tgetopt.SetUsage(walletUsage)\n\t//rand.Seed(time.Now().UTC().UnixNano()) No need to seed with crypto/rand\n\thelpflag := getopt.Bool('h', \"\", \"help (this menu)\")\n\tverboseflag := getopt.Bool('v', \"\", \"enable verbose output\")\n \n\t// Now parse the command line arguments\n\terr := getopt.Getopt(nil)\n\tif err != nil {\n\t\t// Handle error\n\t\tfmt.Fprintln(os.Stderr, err)\n\t\tgetopt.Usage()\n\t\tos.Exit(-1)\n\t}\n\n\t// Process the flags\n\tfmt.Printf(\"help flag [%t]\\n\", *helpflag)\n\tfmt.Printf(\"verbose flag [%t]\\n\", *verboseflag)\n\tverbose = *verboseflag\n\tif *helpflag == true {\n\t\tgetopt.Usage()\n\t\tos.Exit(-1)\n\t}\n\n\t// Check the arguments to make sure we have enough, process if OK\n\tif getopt.NArgs() < 2 {\n\t\tfmt.Printf(\"Not enough arguments for wallet operation.\\n\")\n\t\tgetopt.Usage()\n\t\tos.Exit(-1)\n\t}\n\tfmt.Printf(\"wallet file [%t]\\n\", getopt.Arg(0))\n\tfilename := getopt.Arg(0)\n\tfmt.Printf(\"command [%t]\\n\", getopt.Arg(1))\n\tcommand := strings.ToLower(getopt.Arg(1))\n \n //clear the screen\n c := exec.Command(\"clear\")\n c.Stdout = os.Stdout\n c.Run()\n \n\t// Now check if we are creating a wallet\n\tif command == \"create\" {\n\t\t// Create and save the wallet as needed\n\t\twal443 := createWallet(filename)\n\t\tif wal443 != nil {\n\t\t\twal443.saveWallet()\n\t\t}\n\t} else {\n\t\t// Load the wallet, then process the command\n\t\twal443 := loadWallet(filename)\n\t\tif wal443 != nil && wal443.processWalletCommand(command) {\n\t\t\twal443.saveWallet()\n\t\t}\n\n\t}\n\n\t// Return (no return code)\n\treturn\n}", "title": "" }, { "docid": "5e4c57f0917d281466a9eee419120d78", "score": "0.42665684", "text": "func (lss *LoadSpikeSimulation) simulateMining() {\n\tpendingTxnChan := make(chan txn)\n\treadyChan := make(chan bool)\n\tblockNumChan := make(chan int64)\n\n\t// Spawn routine to produce transactions\n\tgo lss.createTxns(pendingTxnChan, readyChan, blockNumChan)\n\t// Consume transactions on main routine\n\tlss.createBlocks(pendingTxnChan, readyChan, blockNumChan)\n}", "title": "" }, { "docid": "78cac38fbec94c6a25c6add4b67fc803", "score": "0.4261275", "text": "func testFaultProofProgramScenario(t *testing.T, ctx context.Context, sys *System, s *FaultProofProgramTestScenario) {\n\tpreimageDir := t.TempDir()\n\tfppConfig := oppconf.NewConfig(sys.RollupConfig, sys.L2GenesisCfg.Config, s.L1Head, s.L2Head, s.L2OutputRoot, common.Hash(s.L2Claim), s.L2ClaimBlockNumber)\n\tfppConfig.L1URL = sys.NodeEndpoint(\"l1\")\n\tfppConfig.L2URL = sys.NodeEndpoint(\"sequencer\")\n\tfppConfig.DataDir = preimageDir\n\tif s.Detached {\n\t\t// When running in detached mode we need to compile the client executable since it will be called directly.\n\t\tfppConfig.ExecCmd = BuildOpProgramClient(t)\n\t}\n\n\t// Check the FPP confirms the expected output\n\tt.Log(\"Running fault proof in fetching mode\")\n\tlog := testlog.Logger(t, log.LvlInfo)\n\terr := opp.FaultProofProgram(ctx, log, fppConfig)\n\trequire.NoError(t, err)\n\n\tt.Log(\"Shutting down network\")\n\t// Shutdown the nodes from the actual chain. Should now be able to run using only the pre-fetched data.\n\tsys.BatchSubmitter.StopIfRunning(context.Background())\n\tsys.L2OutputSubmitter.Stop()\n\tsys.L2OutputSubmitter = nil\n\tfor _, node := range sys.EthInstances {\n\t\tnode.Close()\n\t}\n\n\tt.Log(\"Running fault proof in offline mode\")\n\t// Should be able to rerun in offline mode using the pre-fetched images\n\tfppConfig.L1URL = \"\"\n\tfppConfig.L2URL = \"\"\n\terr = opp.FaultProofProgram(ctx, log, fppConfig)\n\trequire.NoError(t, err)\n\n\t// Check that a fault is detected if we provide an incorrect claim\n\tt.Log(\"Running fault proof with invalid claim\")\n\tfppConfig.L2Claim = common.Hash{0xaa}\n\terr = opp.FaultProofProgram(ctx, log, fppConfig)\n\tif s.Detached {\n\t\trequire.Error(t, err, \"exit status 1\")\n\t} else {\n\t\trequire.ErrorIs(t, err, driver.ErrClaimNotValid)\n\t}\n}", "title": "" }, { "docid": "bb35b3a3a881586349c88f3460f4971f", "score": "0.4255891", "text": "func walletCreate(gateway *daemon.Gateway) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tlogger.Info(\"API request made to create a wallet\")\n\t\tseed := r.FormValue(\"seed\")\n\t\tw1 := Wg.CreateWallet(seed) //use seed!\n\t\tiw := wallet.NewReadableWallet(w1)\n\t\tif iw != nil {\n\t\t\tif err := Wg.SaveWallet(w1.GetID()); err != nil {\n\t\t\t\tm := \"Failed to save wallet after renaming: %v\"\n\t\t\t\tlogger.Critical(m, err)\n\t\t\t}\n\t\t}\n\t\tSendOr500(w, iw)\n\t}\n}", "title": "" }, { "docid": "95727ef1e42fd948360a8e0a08d1c71c", "score": "0.42553967", "text": "func TestLoadSeed(t *testing.T) {\n\tif testing.Short() {\n\t\tt.SkipNow()\n\t}\n\tt.Parallel()\n\twt, err := createWalletTester(t.Name(), modules.ProdDependencies)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer wt.closeWt()\n\tseed, _, err := wt.wallet.PrimarySeed()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tallSeeds, err := wt.wallet.AllSeeds()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif len(allSeeds) != 1 {\n\t\tt.Fatal(\"AllSeeds should be returning the primary seed.\")\n\t} else if allSeeds[0] != seed {\n\t\tt.Fatal(\"AllSeeds returned the wrong seed\")\n\t}\n\twt.wallet.Close()\n\n\tdir := filepath.Join(build.TempDir(modules.WalletDir, t.Name()+\"1\"), modules.WalletDir)\n\tw, err := New(wt.cs, wt.tpool, dir, modules.DefaultAddressGapLimit, false)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tnewSeed, err := w.Encrypt(nil)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tsk := crypto.NewWalletKey(crypto.HashObject(newSeed))\n\terr = w.Unlock(sk)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\t// Balance of wallet should be 0.\n\tsiacoinBal, err := w.ConfirmedBalance()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif !siacoinBal.Equals64(0) {\n\t\tt.Error(\"fresh wallet should not have a balance\")\n\t}\n\tsk = crypto.NewWalletKey(crypto.HashObject(newSeed))\n\terr = w.LoadSeed(sk, seed)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tallSeeds, err = w.AllSeeds()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif len(allSeeds) != 2 {\n\t\tt.Error(\"AllSeeds should be returning the primary seed with the recovery seed.\")\n\t}\n\tif allSeeds[0] != newSeed {\n\t\tt.Error(\"AllSeeds returned the wrong seed\")\n\t}\n\tif !bytes.Equal(allSeeds[1][:], seed[:]) {\n\t\tt.Error(\"AllSeeds returned the wrong seed\")\n\t}\n\n\tsiacoinBal2, err := w.ConfirmedBalance()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif siacoinBal2.Cmp64(0) <= 0 {\n\t\tt.Error(\"wallet failed to load a seed with money in it\")\n\t}\n\tallSeeds, err = w.AllSeeds()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif len(allSeeds) != 2 {\n\t\tt.Error(\"AllSeeds should be returning the primary seed with the recovery seed.\")\n\t}\n\tif !bytes.Equal(allSeeds[0][:], newSeed[:]) {\n\t\tt.Error(\"AllSeeds returned the wrong seed\")\n\t}\n\tif !bytes.Equal(allSeeds[1][:], seed[:]) {\n\t\tt.Error(\"AllSeeds returned the wrong seed\")\n\t}\n}", "title": "" }, { "docid": "d59a8e4d323ae0b773c07f33396b3a4c", "score": "0.42493606", "text": "func (a *Actors) Miner(cfg MinerActorCfg) Miner {\n\towner := a.Account(address.SECP256K1, cfg.OwnerBalance)\n\tworker := a.Account(address.BLS, big.Zero())\n\n\tss, err := cfg.SealProofType.SectorSize()\n\ta.bc.Assert.NoError(err, \"seal proof sector size\")\n\n\tps, err := builtin.SealProofWindowPoStPartitionSectors(cfg.SealProofType)\n\ta.bc.Assert.NoError(err, \"seal proof window PoSt partition sectors\")\n\n\tmi := &miner.MinerInfo{\n\t\tOwner: owner.ID,\n\t\tWorker: worker.ID,\n\t\tPendingWorkerKey: nil,\n\t\tPeerId: abi.PeerID(\"test\"),\n\t\tMultiaddrs: nil,\n\t\tSealProofType: cfg.SealProofType,\n\t\tSectorSize: ss,\n\t\tWindowPoStPartitionSectors: ps,\n\t}\n\tinfoCid, err := a.st.Stores.CBORStore.Put(context.Background(), mi)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// create the miner actor s.t. it exists in the init actors map\n\tminerState, err := miner.ConstructState(infoCid,\n\t\tcfg.PeriodBoundary,\n\t\tEmptyBitfieldCid,\n\t\tEmptyArrayCid,\n\t\tEmptyMapCid,\n\t\tEmptyDeadlinesCid,\n\t\tEmptyVestingFundsCid,\n\t)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// TODO allow an address to create multiple miners.\n\tminerActorAddr := worker.NextActorAddress(0, 0)\n\thandle := a.CreateActor(builtin.StorageMinerActorCodeID, minerActorAddr, big.Zero(), minerState)\n\n\t// assert miner actor has been created, exists in the state tree, and has an entry in the init actor.\n\t// next update the storage power actor to track the miner\n\n\tvar spa power.State\n\ta.st.ActorState(builtin.StoragePowerActorAddr, &spa)\n\n\t// set the miners claim\n\thm, err := adt.AsMap(adt.WrapStore(context.Background(), a.st.Stores.CBORStore), spa.Claims)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// add claim for the miner\n\t// TODO: allow caller to specify.\n\terr = hm.Put(adt.AddrKey(handle.ID), &power.Claim{\n\t\tRawBytePower: abi.NewStoragePower(0),\n\t\tQualityAdjPower: abi.NewStoragePower(0),\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// save the claim\n\tspa.Claims, err = hm.Root()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// update miner count\n\tspa.MinerCount += 1\n\n\t// update storage power actor's state in the tree\n\t_, err = a.st.Stores.CBORStore.Put(context.Background(), &spa)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tm := Miner{\n\t\tMinerActorAddr: handle,\n\t\tOwnerAddr: owner,\n\t\tWorkerAddr: worker,\n\t}\n\ta.miners = append(a.miners, m)\n\treturn m\n}", "title": "" }, { "docid": "ab8b9b8e742a87ae2e5a12eacbd638d6", "score": "0.42455316", "text": "func InitSandboxTest(_ *testing.T, start time.Time) {\n\tinitSandboxMode(start)\n}", "title": "" }, { "docid": "2262258367bea540b3e8c92ebf2f7153", "score": "0.42438242", "text": "func Init(cfg SbiCfg) (err error) {\n\n\t// Create new SBI instance\n\tif sbi != nil {\n\t\tsbi = nil\n\t}\n\tsbi = new(WaisSbi)\n\tsbi.sandboxName = cfg.SandboxName\n\tsbi.updateStaInfoCB = cfg.StaInfoCb\n\tsbi.updateAccessPointInfoCB = cfg.ApInfoCb\n\tsbi.updateScenarioNameCB = cfg.ScenarioNameCb\n\tsbi.cleanUpCB = cfg.CleanUpCb\n\n\t// Create message queue\n\tsbi.mqLocal, err = mq.NewMsgQueue(mq.GetLocalName(sbi.sandboxName), moduleName, sbi.sandboxName, cfg.RedisAddr)\n\tif err != nil {\n\t\tlog.Error(\"Failed to create Message Queue with error: \", err)\n\t\treturn err\n\t}\n\tlog.Info(\"Message Queue created\")\n\n\t// Create new active scenario model\n\tmodelCfg := mod.ModelCfg{\n\t\tName: \"activeScenario\",\n\t\tNamespace: sbi.sandboxName,\n\t\tModule: moduleName,\n\t\tUpdateCb: nil,\n\t\tDbAddr: cfg.RedisAddr,\n\t}\n\tsbi.activeModel, err = mod.NewModel(modelCfg)\n\tif err != nil {\n\t\tlog.Error(\"Failed to create model: \", err.Error())\n\t\treturn err\n\t}\n\n\t// Connect to GIS cache\n\tsbi.gisCache, err = gc.NewGisCache(sbi.sandboxName, cfg.RedisAddr)\n\tif err != nil {\n\t\tlog.Error(\"Failed to GIS Cache: \", err.Error())\n\t\treturn err\n\t}\n\tlog.Info(\"Connected to GIS Cache\")\n\n\t// Initialize service\n\tprocessActiveScenarioUpdate()\n\n\treturn nil\n}", "title": "" }, { "docid": "fbe3ab8d3ecb830f6a86e00c95834814", "score": "0.42405626", "text": "func skupperInitInteriorTestScenario(ctx *base.ClusterContext, prefix string, withPolicy bool) (initSteps cli.TestScenario) {\n\tinitSteps = cli.TestScenario{\n\t\tName: prefixName(prefix, \"init-skupper-interior\"),\n\t\tTasks: []cli.SkupperTask{\n\t\t\t{Ctx: ctx, Commands: []cli.SkupperCommandTester{\n\t\t\t\t// skupper init - interior mode, enabling console and internal authentication\n\t\t\t\t&cli.InitTester{\n\t\t\t\t\tConsoleAuth: \"internal\",\n\t\t\t\t\tConsoleUser: \"internal\",\n\t\t\t\t\tConsolePassword: \"internal\",\n\t\t\t\t\tRouterMode: \"interior\",\n\t\t\t\t\tEnableConsole: false,\n\t\t\t\t\tEnableFlowCollector: true,\n\t\t\t\t},\n\t\t\t\t// skupper status - verify initialized as interior\n\t\t\t\t&cli.StatusTester{\n\t\t\t\t\tRouterMode: \"interior\",\n\t\t\t\t\tConsoleEnabled: false,\n\t\t\t\t\tCollectorEnabled: true,\n\t\t\t\t\tConsoleAuthInternal: true,\n\t\t\t\t\tPolicyEnabled: cli.Boolp(withPolicy),\n\t\t\t\t},\n\t\t\t}},\n\t\t},\n\t}\n\treturn\n}", "title": "" }, { "docid": "1d950cae2366c7508ea73aabf68e506e", "score": "0.4236861", "text": "func main() {\n\terr := godotenv.Load()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tgo func() {\n\t\tt := time.Now()\n\t\tgenesisBlock := Block { 0, t.String(),0, \"\",\"\"}\n\t\tspew.Dump(genesisBlock)\n\t\tBlockchain = append(Blockchain, genesisBlock)\n\t}()\n\tlog.Fatal(run())\n}", "title": "" }, { "docid": "3294443bdeffee07f25a25f14b0da7df", "score": "0.4234575", "text": "func createSector(t *testing.T, v *vm.VM, workerAddress address.Address, minerAddress address.Address, firstSectorNo abi.SectorNumber, sealProof abi.RegisteredSealProof) (*vm.VM, uint64, uint64, abi.SectorNumber) {\n\n\t//\n\t// preCommit a sector\n\t//\n\tprecommit := preCommitSectors(t, v, 1, miner.PreCommitSectorBatchMaxSize, workerAddress, minerAddress, sealProof, firstSectorNo, true, v.GetEpoch()+miner.MaxSectorExpirationExtension)\n\n\tassert.Equal(t, len(precommit), 1)\n\tbalances := vm.GetMinerBalances(t, v, minerAddress)\n\tassert.True(t, balances.PreCommitDeposit.GreaterThan(big.Zero()))\n\n\t// advance time to max seal duration\n\tproveTime := v.GetEpoch() + miner.MaxProveCommitDuration[sealProof]\n\tv, _ = vm.AdvanceByDeadlineTillEpoch(t, v, minerAddress, proveTime)\n\n\t// proveCommit the sector\n\n\tsectorNumber := precommit[0].Info.SectorNumber\n\n\tv, err := v.WithEpoch(proveTime)\n\trequire.NoError(t, err)\n\n\tproveCommit := miner.ProveCommitSectorParams{\n\t\tSectorNumber: sectorNumber,\n\t}\n\n\tvm.ApplyOk(t, v, workerAddress, minerAddress, big.Zero(), builtin.MethodsMiner.ProveCommitSector, &proveCommit)\n\n\t// In the same epoch, trigger cron to validate prove commit\n\tvm.ApplyOk(t, v, builtin.SystemActorAddr, builtin.CronActorAddr, big.Zero(), builtin.MethodsCron.EpochTick, nil)\n\n\t// advance to proving period and submit post\n\tdlInfo, pIdx, v := vm.AdvanceTillProvingDeadline(t, v, minerAddress, sectorNumber)\n\n\t// sector shouldn't be active until PoSt\n\trequire.False(t, vm.CheckSectorActive(t, v, minerAddress, dlInfo.Index, pIdx, sectorNumber))\n\tvm.SubmitPoSt(t, v, minerAddress, workerAddress, dlInfo, pIdx)\n\n\t// move into the next deadline so that the created sector is mutable\n\tv, _ = vm.AdvanceByDeadlineTillEpoch(t, v, minerAddress, v.GetEpoch()+miner.WPoStChallengeWindow)\n\tv = vm.AdvanceOneEpochWithCron(t, v)\n\n\t// hooray, sector is now active\n\trequire.True(t, vm.CheckSectorActive(t, v, minerAddress, dlInfo.Index, pIdx, sectorNumber))\n\n\treturn v, dlInfo.Index, pIdx, sectorNumber\n}", "title": "" }, { "docid": "588997d2494c0962933db98f8cb0ffe2", "score": "0.42311966", "text": "func InitSwarm(buf []byte) (peerList []Peer) {\n\tchunkedList := helper.ChunkBy(buf, 6) //Peer list is always a list of a length that is a multiple of 6.\n\tfor _, val := range chunkedList {\n\t\t//First 4 bytes are the IP addr, final two are the port number.\n\t\tvar port uint16\n\t\tb := bytes.NewReader(val[4:])\n\t\terr := binary.Read(b, binary.BigEndian, &port)\n\t\tif err != nil {\n\t\t\tlog.Println(\"binary.Read failed:\", err)\n\t\t}\n\n\t\tpeerList = append(peerList, Peer{\n\t\t\tIp: net.IP(val[0:4]).String(),\n\t\t\tPort: int64(port),\n\t\t})\n\t}\n\treturn peerList\n}", "title": "" }, { "docid": "497c5635e1ba4ae8248cf2f7909acda8", "score": "0.4229986", "text": "func NewWallet(wltName string, opts ...Option) (*Wallet, error) {\n\t// generaten bip39 as default seed\n\tentropy, err := bip39.NewEntropy(128)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"generate bip39 entropy failed, err:%v\", err)\n\t}\n\n\tseed, err := bip39.NewMnemonic(entropy)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"generate bip39 seed failed, err:%v\", err)\n\t}\n\n\tw := &Wallet{\n\t\tMeta: map[string]string{\n\t\t\t\"filename\": wltName,\n\t\t\t\"version\": version,\n\t\t\t\"label\": \"\",\n\t\t\t\"seed\": seed,\n\t\t\t\"lastSeed\": seed,\n\t\t\t\"tm\": fmt.Sprintf(\"%v\", time.Now().Unix()),\n\t\t\t\"type\": \"deterministic\",\n\t\t\t\"coin\": string(CoinTypeSkycoin),\n\t\t},\n\t}\n\n\tfor _, opt := range opts {\n\t\topt(w)\n\t}\n\n\treturn w, nil\n}", "title": "" }, { "docid": "42af910eb09f602d09f3180d752dadd9", "score": "0.42285946", "text": "func SetupTestInput() (sdk.Context, bankKeeper.Keeper, government.Keeper, Keeper) {\n\n\tmemDB := db.NewMemDB()\n\tlegacyAmino := codec.NewLegacyAmino()\n\n\tkeys := sdk.NewKVStoreKeys(\n\t\tauthTypes.StoreKey,\n\t\tbankTypes.StoreKey,\n\t\tparamsTypes.StoreKey,\n\t\tgovernmentTypes.StoreKey,\n\t\ttypes.StoreKey,\n\t\tcommerciomintTypes.StoreKey,\n\t)\n\ttKeys := sdk.NewTransientStoreKeys(paramsTypes.TStoreKey)\n\n\tms := store.NewCommitMultiStore(memDB)\n\tfor _, key := range keys {\n\t\tms.MountStoreWithDB(key, sdk.StoreTypeIAVL, memDB)\n\t}\n\tfor _, tkey := range tKeys {\n\t\tms.MountStoreWithDB(tkey, sdk.StoreTypeTransient, memDB)\n\t}\n\t_ = ms.LoadLatestVersion()\n\n\tapp := simapp.Setup(false)\n\tcdc := app.AppCodec()\n\n\tctx := sdk.NewContext(ms, tmproto.Header{ChainID: \"test-chain-id\"}, false, log.NewNopLogger())\n\tctx = ctx.WithBlockTime(time.Now())\n\t//ctx = ctx.WithBlockTime(time.Now().Add(time.Hour * 1))\n\n\tmaccPerms := map[string][]string{\n\t\ttypes.ModuleName: {authTypes.Minter, authTypes.Burner},\n\t\tcommerciomintTypes.ModuleName: {authTypes.Minter, authTypes.Burner},\n\t}\n\n\tpk := paramsKeeper.NewKeeper(cdc, legacyAmino, keys[paramsTypes.StoreKey], tKeys[paramsTypes.TStoreKey])\n\tak := authKeeper.NewAccountKeeper(cdc, keys[authTypes.StoreKey], pk.Subspace(authTypes.DefaultParams().String()), authTypes.ProtoBaseAccount, maccPerms)\n\tbk := bankKeeper.NewBaseKeeper(cdc, keys[bankTypes.StoreKey], ak, pk.Subspace(bankTypes.DefaultParams().String()), nil)\n\n\t//bk.SetSupply(ctx, bankTypes.NewSupply(sdk.NewCoins(sdk.NewInt64Coin(stakeDenom, 1))))\n\t//ak.SetModuleAccount(ctx, authTypes.NewEmptyModuleAccount(types.ModuleName))\n\tgovk := government.NewKeeper(cdc, keys[governmentTypes.StoreKey], keys[governmentTypes.StoreKey])\n\n\tmintAcc := authTypes.NewEmptyModuleAccount(commerciomintTypes.ModuleName, authTypes.Minter, authTypes.Burner)\n\tak.SetModuleAccount(ctx, mintAcc)\n\n\tmk := commerciomintKeeper.NewKeeper(cdc, keys[commerciomintTypes.StoreKey], keys[commerciomintTypes.StoreKey], bk, ak, *govk, pk.Subspace(commerciomintTypes.ModuleName))\n\tmemAcc := authTypes.NewEmptyModuleAccount(types.ModuleName, authTypes.Minter, authTypes.Burner)\n\tak.SetModuleAccount(ctx, memAcc)\n\tbk.MintCoins(ctx, types.ModuleName, sdk.NewCoins(sdk.NewInt64Coin(stakeDenom, 1)))\n\n\tk := NewKeeper(\n\t\tcdc,\n\t\tkeys[types.StoreKey],\n\t\tkeys[types.MemStoreKey],\n\t\tbk, *govk, ak, *mk)\n\n\t// TODO shall we drop the following?\n\tk.mintKeeper.UpdateParams(ctx, validCommercioMintParams)\n\t// k.MintKeeper.UpdateConversionRate(ctx, sdk.NewDecWithPrec(7, 1))\n\n\tk.GovKeeper.SetGovernmentAddress(ctx, testUser3)\n\treturn ctx, bk, *govk, *k\n}", "title": "" }, { "docid": "5984e79cb5d649706607fd904e6e4d1f", "score": "0.4226439", "text": "func walletCreate(gateway *daemon.Gateway) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tlogger.Info(\"API request made to create a wallet\")\n\t\tseed := r.FormValue(\"seed\")\n\t\tlabel := r.FormValue(\"label\")\n\t\twltName := wallet.NewWalletFilename()\n\t\tvar wlt wallet.Wallet\n\t\tvar err error\n\t\t// the wallet name may dup, rename it till no conflict.\n\t\tfor {\n\t\t\twlt, err = Wg.CreateWallet(wltName, wallet.OptSeed(seed), wallet.OptLabel(label))\n\t\t\tif err != nil && strings.Contains(err.Error(), \"renaming\") {\n\t\t\t\twltName = wallet.NewWalletFilename()\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\n\t\tif err := Wg.SaveWallet(wlt.GetID()); err != nil {\n\t\t\twh.Error400(w, err.Error())\n\t\t\treturn\n\t\t}\n\n\t\trlt := wallet.NewReadableWallet(wlt)\n\t\twh.SendOr500(w, rlt)\n\t}\n}", "title": "" }, { "docid": "0fd62c1a62f22f6b0b3256afa39b9e8c", "score": "0.42259693", "text": "func (s *SmartContract) Init(stub shim.ChaincodeStubInterface) sc.Response {\n\t_, args := stub.GetFunctionAndParameters()\n\tvar treasureAmount = DefaultTreasureAmount\n\tif len(args) > 0 {\n\t\ttreasureAmount = args[0]\n\t}\n\n\tvar registration float64 = DefaultRegistrationAmount\n\tif len(args) >= 2 {\n\t\tvar value, err = strconv.ParseFloat(args[1], 64)\n\t\tif err == nil {\n\t\t\tregistration = value\n\t\t}\n\t}\n\n\ts.createTreasure(stub, []string{treasureAmount})\n\n\tvar options = make([]string, 2)\n\toptions[0] = strconv.FormatFloat(registration, 'f', -1, 64)\n\toptions[1] = DefaultCustomer\n\treturn s.setOptions(stub, options)\n}", "title": "" }, { "docid": "b26b9dafd61211ec028f38d7bedb56d9", "score": "0.42246947", "text": "func (c *Client) init(cp *Configuration) error {\n\tc.initialized = false\n\tc.local = cp.gatewayNotLocal // temporary\n\tif !cp.gatewayNotLocal {\n\t\tos.Setenv(cDiscoveryKey, \"true\")\n\t} else {\n\t\tos.Setenv(cDiscoveryKey, \"false\")\n\n\t}\n\n\tLogr.Debugf(\"%s = %s\", cDiscoveryKey, os.Getenv(cDiscoveryKey))\n\tvar err error\n\tc.wallet, err = gateway.NewFileSystemWallet(c.walletDir)\n\tif err != nil {\n\t\tLogr.Errorf(\"Failed to create wallet: %v\", err)\n\t\treturn err\n\t}\n\n\tif !c.wallet.Exists(cp.User) {\n\t\t// err = populateWallet(c.wallet, cp)\n\t\t// if err != nil {\n\t\t// \tLogr.Errorf(\"Failed to populate wallet contents: %v\", err)\n\t\t// \treturn err\n\t\t// }\n\t}\n\tLogr.Debug(\"wallet operational\")\n\tLogr.Debugf(\"Connection file %s\", filepath.Clean(cp.ConnectionFile))\n\tc.gw, err = gateway.Connect(\n\t\tgateway.WithConfig(config.FromFile(filepath.Clean(cp.ConnectionFile))),\n\t\tgateway.WithIdentity(c.wallet, cp.User),\n\t)\n\tif err != nil {\n\t\tLogr.Errorf(\"Failed to connect to gateway: %v\", err)\n\t\treturn err\n\t}\n\tLogr.Debug(\"gateway connected\")\n\tc.network, err = c.gw.GetNetwork(cp.ChannelID)\n\tif err != nil {\n\t\tLogr.Errorf(\"Failed to get network: %v\", err)\n\t\tos.Exit(1)\n\t}\n\tLogr.Debug(\"network acquired\")\n\tc.contract = c.network.GetContract(cp.ChainCodeID)\n\tc.initialized = true\n\treturn nil\n}", "title": "" }, { "docid": "3ef2541e037635f2e2bcbd5fad3d6169", "score": "0.42241868", "text": "func (_Rollup *RollupTransactorSession) Initialize(_machineHash [32]byte, _confirmPeriodBlocks *big.Int, _extraChallengeTimeBlocks *big.Int, _arbGasSpeedLimitPerBlock *big.Int, _baseStake *big.Int, _stakeToken common.Address, _owner common.Address, _extraConfig []byte, connectedContracts [6]common.Address) (*types.Transaction, error) {\n\treturn _Rollup.Contract.Initialize(&_Rollup.TransactOpts, _machineHash, _confirmPeriodBlocks, _extraChallengeTimeBlocks, _arbGasSpeedLimitPerBlock, _baseStake, _stakeToken, _owner, _extraConfig, connectedContracts)\n}", "title": "" }, { "docid": "f81799ec914ccab045c4e19bb280ad32", "score": "0.42226443", "text": "func (elephanthash *Elephanthash) mine(block *types.Block, abort chan struct{}, found chan foundResult) {\r\n\t// Extract some data from the header\r\n\theader := block.Header()\r\n\tlogger := log.New(\"elephant BFT\")\r\n\tlog.Trace(\"【*】elephant sealing process start\")\r\n\r\n\tticker := time.NewTicker(nodeHbft.BlockSealingBeat)\r\n\tdefer ticker.Stop()\r\n\tdefer elephanthash.hbftNode.SetBusy(false)\r\n\r\nseal:\r\n\tfor {\r\n\t\tselect {\r\n\t\tcase <-abort:\r\n\t\t\t// BFT sealing terminated, update stats and abort\r\n\t\t\tclose(found)\r\n\t\t\treturn\r\n\r\n\t\tcase <-ticker.C:\r\n\t\t\telephanthash.sealerLock.Lock()\r\n\t\t\tvar (\r\n\t\t\t\tret bool\r\n\t\t\t\thbftStages []*types.HBFTStageCompleted\r\n\t\t\t)\r\n\t\t\tif !common.GetConsensusBft() {\r\n\t\t\t\tseconds := (rand.Int() % 3) + 3\r\n\t\t\t\ttime.Sleep(time.Second * time.Duration(seconds))\r\n\t\t\t\tret = true\r\n\t\t\t\thbftStages = elephanthash.hbftNode.GetFakeStagesForTest(uint64(block.NumberU64()))\r\n\t\t\t} else if elephanthash.hbftNode != nil {\r\n\t\t\t\t// First check if the node should re-commit new sealing work for the BFT future block\r\n\t\t\t\tif future := elephanthash.hbftNode.EleBackend.BFTOldestFutureBlock(); future != nil {\r\n\t\t\t\t\tif sealer, work := elephanthash.hbftNode.ItsTimeToDoHbftWork(block, future); work {\r\n\t\t\t\t\t\theader.BftHash = types.EmptyHbftHash\r\n\t\t\t\t\t\tfound <- foundResult{block.WithSeal(header), elephanthash.hbftNode.CurrentState.BuildCompletedStageChain()}\r\n\t\t\t\t\t\telephanthash.sealerLock.Unlock()\r\n\t\t\t\t\t\tbreak seal\r\n\t\t\t\t\t} else if !work && common.EmptyAddress(sealer) {\r\n\t\t\t\t\t\telephanthash.sealerLock.Unlock()\r\n\t\t\t\t\t\tcontinue\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tret = elephanthash.hbftNode.StartHbftWork(block)\r\n\t\t\t\tif ret {\r\n\t\t\t\t\tticker.Stop()\r\n\t\t\t\t\tret = elephanthash.hbftNode.BlockSealedCompleted(block.Hash())\r\n\t\t\t\t} else {\r\n\t\t\t\t\telephanthash.sealerLock.Unlock()\r\n\t\t\t\t\tcontinue\r\n\t\t\t\t}\r\n\t\t\t\tif ret {\r\n\t\t\t\t\thbftStages, ret = elephanthash.hbftNode.GetSealedBlockStages()\r\n\t\t\t\t\tif !ret {\r\n\t\t\t\t\t\theader.BftHash = common.Hash{} // represents that HBFT confirm stage failed\r\n\t\t\t\t\t\tfound <- foundResult{block.WithSeal(header), elephanthash.hbftNode.CurrentState.BuildCompletedStageChain()}\r\n\t\t\t\t\t\tlog.Warn(\"GetSealedBlockStages failed, can not find completed chain of two stages\")\r\n\t\t\t\t\t\telephanthash.sealerLock.Unlock()\r\n\t\t\t\t\t\tbreak seal\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\tif elephanthash.hbftNode.GetCurrentStateStage() == hbft.PreConfirm {\r\n\t\t\t\t\t\theader.BftHash = types.EmptyHbftHash // represents that HBFT pre-confirm stage failed\r\n\t\t\t\t\t} else if elephanthash.hbftNode.GetCurrentStateStage() == hbft.Idle {\r\n\t\t\t\t\t\theader.BftHash = types.EmptyBlockHash // represents that HBFT request stage failed\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\theader.BftHash = common.Hash{} // represents that HBFT confirm stage failed\r\n\t\t\t\t\t}\r\n\t\t\t\t\tfound <- foundResult{block.WithSeal(header), elephanthash.hbftNode.CurrentState.BuildCompletedStageChain()}\r\n\t\t\t\t\telephanthash.sealerLock.Unlock()\r\n\t\t\t\t\tbreak seal\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif ret {\r\n\t\t\t\tblock.SetBftStageComplete(hbftStages)\r\n\t\t\t\theader.BftHash = types.CalcBftHash(hbftStages)\r\n\t\t\t\tstageChain := make([]*types.HBFTStageCompleted, 0)\r\n\t\t\t\tif common.GetConsensusBft() {\r\n\t\t\t\t\tstageChain = elephanthash.hbftNode.CurrentState.BuildCompletedStageChain()\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Seal and return a block (if still needed)\r\n\t\t\t\tselect {\r\n\t\t\t\tcase found <- foundResult{block.WithSeal(header), stageChain}:\r\n\t\t\t\t\tlogger.Trace(\"【*】Elephant block sealed and reported\")\r\n\t\t\t\t\t//case <-abort:\r\n\t\t\t\t\t//\tlogger.Trace(\"Elephant block sealing abort\")\r\n\t\t\t\t}\r\n\t\t\t\telephanthash.sealerLock.Unlock()\r\n\t\t\t\tbreak seal\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\ttime.Sleep(nodeHbft.BlockMinPeriodHbft)\r\n\t// Datasets are unmapped in a finalizer. Ensure that the dataset stays live\r\n\t// during sealing so it's not unmapped while being read.\r\n\t// runtime.KeepAlive(dataset)\r\n}", "title": "" }, { "docid": "345d7ed77a3e4d03ef971e454f44d0dc", "score": "0.42219874", "text": "func newBaseChain(\n\tctx context.Context,\n\tconfig ethereum.Config,\n\tclient *ethclient.Client,\n) (*baseChain, error) {\n\tchainID, err := client.ChainID(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"failed to resolve Ethereum chain id: [%v]\",\n\t\t\terr,\n\t\t)\n\t}\n\n\tif config.Network != ethereum.Developer &&\n\t\tbig.NewInt(config.Network.ChainID()).Cmp(chainID) != 0 {\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"chain id returned from ethereum api [%s] \"+\n\t\t\t\t\"doesn't match the expected chain id [%d] for [%s] network; \"+\n\t\t\t\t\"please verify the configured ethereum.url\",\n\t\t\tchainID.String(),\n\t\t\tconfig.Network.ChainID(),\n\t\t\tconfig.Network,\n\t\t)\n\t}\n\n\tkey, err := decryptKey(config)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"failed to decrypt Ethereum key: [%v]\",\n\t\t\terr,\n\t\t)\n\t}\n\n\tclientWithAddons := wrapClientAddons(config, client)\n\n\tblockCounter, err := ethutil.NewBlockCounter(clientWithAddons)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"failed to create Ethereum blockcounter: [%v]\",\n\t\t\terr,\n\t\t)\n\t}\n\n\tnonceManager := ethutil.NewNonceManager(\n\t\tclientWithAddons,\n\t\tkey.Address,\n\t)\n\n\tminingWaiter := ethutil.NewMiningWaiter(clientWithAddons, config)\n\n\ttransactionMutex := &sync.Mutex{}\n\n\t// TODO: Consider adding the balance monitoring.\n\n\ttokenStakingAddress, err := config.ContractAddress(TokenStakingContractName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"failed to resolve %s contract address: [%v]\",\n\t\t\tTokenStakingContractName,\n\t\t\terr,\n\t\t)\n\t}\n\n\ttokenStaking, err :=\n\t\tcontract.NewTokenStaking(\n\t\t\ttokenStakingAddress,\n\t\t\tchainID,\n\t\t\tkey,\n\t\t\tclient,\n\t\t\tnonceManager,\n\t\t\tminingWaiter,\n\t\t\tblockCounter,\n\t\t\ttransactionMutex,\n\t\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"failed to attach to TokenStaking contract: [%v]\",\n\t\t\terr,\n\t\t)\n\t}\n\n\treturn &baseChain{\n\t\tkey: key,\n\t\tclient: clientWithAddons,\n\t\tchainID: chainID,\n\t\tblockCounter: blockCounter,\n\t\tnonceManager: nonceManager,\n\t\tminingWaiter: miningWaiter,\n\t\ttransactionMutex: transactionMutex,\n\t\ttokenStaking: tokenStaking,\n\t}, nil\n}", "title": "" }, { "docid": "ad7cbbd4a9434c0e9c2ccaab758bce6d", "score": "0.42215586", "text": "func testStellarRelayAutoClaims(t *testing.T, startWithPUK, skipPart2 bool) {\n\ttt := newTeamTester(t)\n\tdefer tt.cleanup()\n\tuseStellarTestNet(t)\n\n\talice := tt.addUser(\"alice\")\n\tvar bob *userPlusDevice\n\tif startWithPUK {\n\t\tbob = tt.addUser(\"bob\")\n\t} else {\n\t\tbob = tt.addPuklessUser(\"bob\")\n\t}\n\talice.kickTeamRekeyd()\n\n\tt.Logf(\"alice gets funded\")\n\tacceptDisclaimer(alice)\n\n\tbaseFeeStroops := int64(alice.tc.G.GetStellar().(*stellar.Stellar).WalletStateForTest().BaseFee(alice.tc.MetaContext()))\n\n\tres, err := alice.stellarClient.GetWalletAccountsLocal(context.Background(), 0)\n\trequire.NoError(t, err)\n\tgift(t, res[0].AccountID)\n\n\tt.Logf(\"alice sends a first relay payment to bob P1\")\n\tattachIdentifyUI(t, alice.tc.G, newSimpleIdentifyUI())\n\tcmd := client.CmdWalletSend{\n\t\tContextified: libkb.NewContextified(alice.tc.G),\n\t\tRecipient: bob.username,\n\t\tAmount: \"50\",\n\t}\n\tfor i := 0; i < retryCount; i++ {\n\t\terr = cmd.Run()\n\t\tif err == nil {\n\t\t\tbreak\n\t\t}\n\t}\n\trequire.NoError(t, err)\n\n\tt.Logf(\"alice sends a second relay payment to bob P2\")\n\tcmd = client.CmdWalletSend{\n\t\tContextified: libkb.NewContextified(alice.tc.G),\n\t\tRecipient: bob.username,\n\t\tAmount: \"30\",\n\t}\n\tfor i := 0; i < retryCount; i++ {\n\t\terr = cmd.Run()\n\t\tif err == nil {\n\t\t\tbreak\n\t\t}\n\t}\n\trequire.NoError(t, err)\n\n\tt.Logf(\"get the impteam seqno to wait on later\")\n\tteam, _, _, err := teams.LookupImplicitTeam(context.Background(), alice.tc.G, alice.username+\",\"+bob.username, false, teams.ImplicitTeamOptions{})\n\trequire.NoError(t, err)\n\tnextSeqno := team.NextSeqno()\n\n\tif startWithPUK {\n\t\tt.Logf(\"bob gets a wallet\")\n\t\tacceptDisclaimer(bob)\n\t} else {\n\t\tt.Logf(\"bob gets a PUK and wallet\")\n\t\tbob.device.tctx.Tp.DisableUpgradePerUserKey = false\n\t\tacceptDisclaimer(bob)\n\n\t\tt.Logf(\"wait for alice to add bob to their impteam\")\n\t\talice.pollForTeamSeqnoLinkWithLoadArgs(keybase1.LoadTeamArg{ID: team.ID}, nextSeqno)\n\t}\n\n\tpollTime := 20 * time.Second\n\tif libkb.UseCITime(bob.tc.G) {\n\t\t// This test is especially slow because it's waiting on multiple transactions\n\t\tpollTime = 90 * time.Second\n\t}\n\n\tpollFor(t, \"claims to complete\", pollTime, bob.tc.G, func(i int) bool {\n\t\t// The first claims takes a create_account + account_merge. The second only account_merge.\n\t\tres, err = bob.stellarClient.GetWalletAccountsLocal(context.Background(), 0)\n\t\trequire.NoError(t, err)\n\t\tt.Logf(\"poll-1-%v: %v\", i, res[0].BalanceDescription)\n\t\tif res[0].BalanceDescription == \"0 XLM\" {\n\t\t\treturn false\n\t\t}\n\t\tif isWithinFeeBounds(t, res[0].BalanceDescription, \"50\", baseFeeStroops*2) {\n\t\t\tt.Logf(\"poll-1-%v: received T1 but not T2\", i)\n\t\t\treturn false\n\t\t}\n\t\tif isWithinFeeBounds(t, res[0].BalanceDescription, \"30\", baseFeeStroops*2) {\n\t\t\tt.Logf(\"poll-1-%v: received T2 but not T1\", i)\n\t\t\treturn false\n\t\t}\n\t\tt.Logf(\"poll-1-%v: received both payments\", i)\n\t\tassertWithinFeeBounds(t, res[0].BalanceDescription, \"80\", baseFeeStroops*3)\n\t\treturn true\n\t})\n\n\tif skipPart2 {\n\t\tt.Logf(\"Skipping part 2\")\n\t\treturn\n\t}\n\n\tt.Logf(\"--------------------\")\n\tt.Logf(\"Part 2: Alice sends a relay payment to bob who now already has a wallet\")\n\tcmd = client.CmdWalletSend{\n\t\tContextified: libkb.NewContextified(alice.tc.G),\n\t\tRecipient: bob.username,\n\t\tAmount: \"10\",\n\t\tForceRelay: true,\n\t}\n\tfor i := 0; i < retryCount; i++ {\n\t\terr = cmd.Run()\n\t\tif err == nil {\n\t\t\tbreak\n\t\t}\n\t}\n\trequire.NoError(t, err)\n\n\tpollFor(t, \"final claim to complete\", pollTime, bob.tc.G, func(i int) bool {\n\t\tres, err = bob.stellarClient.GetWalletAccountsLocal(context.Background(), 0)\n\t\trequire.NoError(t, err)\n\t\tt.Logf(\"poll-2-%v: %v\", i, res[0].BalanceDescription)\n\t\tif isWithinFeeBounds(t, res[0].BalanceDescription, \"80\", baseFeeStroops*3) {\n\t\t\treturn false\n\t\t}\n\t\tt.Logf(\"poll-1-%v: received final payment\", i)\n\t\tassertWithinFeeBounds(t, res[0].BalanceDescription, \"90\", baseFeeStroops*4)\n\t\treturn true\n\t})\n\n}", "title": "" }, { "docid": "9110e082c700a5979c1f3c104a72074f", "score": "0.4218906", "text": "func main() {\n\tlogging.Disable()\n\n\tgenCount := flag.Int(\"n\", 1, \"Number of addresses to generate\")\n\tisBitcoin := flag.Bool(\"b\", false, \"Print address as a bitcoin address\")\n\thexSeed := flag.Bool(\"x\", false, \"Use hex(sha256sum(rand(1024))) (CSPRNG-generated) as the seed if seed is not provided\")\n\thideSecrets := flag.Bool(\"hide-secrets\", false, \"Hide seed and secret key\")\n\tseed := flag.String(\"seed\", \"\", \"Seed for deterministic key generation. Will use bip39 as the seed if not provided\")\n\tsecKeysList := flag.Bool(\"sec-keys-list\", false, \"only print a list of secret keys\")\n\taddrsList := flag.Bool(\"addrs-list\", false, \"only print a list of addresses\")\n\tflag.Parse()\n\n\tvar coinType wallet.CoinType\n\tif *isBitcoin {\n\t\tcoinType = wallet.CoinTypeBitcoin\n\t} else {\n\t\tcoinType = wallet.CoinTypeSkycoin\n\t}\n\n\tif *seed == \"\" {\n\t\tif *hexSeed {\n\t\t\t// generate a new seed, as hex string\n\t\t\t*seed = cipher.SumSHA256(cipher.RandByte(1024)).Hex()\n\t\t} else {\n\t\t\tmnemonic, err := bip39.NewDefaultMnemonic()\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"bip39.NewDefaultMnemonic failed: %v\\n\", err)\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\n\t\t\t*seed = mnemonic\n\t\t}\n\t}\n\n\tw, err := wallet.NewWallet(\"a.wlt\", \"\", *seed, wallet.Options{\n\t\tType: deterministic.WalletType,\n\t\tCoin: coinType,\n\t\tGenerateN: uint64(*genCount),\n\t})\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tos.Exit(1)\n\t}\n\n\tif *hideSecrets {\n\t\tw.Erase()\n\t}\n\n\tif *hideSecrets && *secKeysList {\n\t\tfmt.Println(\"-hide-secrets and -sec-keys-list can't be combined\")\n\t\tos.Exit(1)\n\t}\n\n\tif *addrsList && *secKeysList {\n\t\tfmt.Println(\"-addrs-list and -sec-keys-list can't be combined\")\n\t\tos.Exit(1)\n\t}\n\n\tif *addrsList {\n\t\taddrs, err := w.GetAddresses()\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\tos.Exit(1)\n\t\t}\n\t\tfor _, a := range addrs {\n\t\t\tfmt.Println(a)\n\t\t}\n\t} else if *secKeysList {\n\t\tes, err := w.GetEntries()\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\tos.Exit(1)\n\t\t}\n\n\t\tfor _, e := range es {\n\t\t\tfmt.Println(e.Secret.Hex())\n\t\t}\n\t} else {\n\t\tif *hideSecrets {\n\t\t\tw.Erase()\n\t\t}\n\t\toutput, err := w.Serialize()\n\t\tif err != nil {\n\t\t\tfmt.Println(\"Error formating wallet to JSON. Error:\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\n\t\tfmt.Println(string(output))\n\t}\n}", "title": "" }, { "docid": "60b1e5dd6f1296d53b82e155215d574d", "score": "0.4218539", "text": "func (mysuit *MySuite) TestSicBo_WithdrawWin(c *check.C) {\n\tutest.Init(orgID)\n\tcontractOwner := utest.DeployContract(c, contractName, orgID, contractMethods, contractInterfaces)\n\ttest := NewTestObject(contractOwner)\n\n\tgenesisOwner := utest.UTP.Helper().GenesisHelper().Token().Owner()\n\tutest.Assert(test.run().setSender(utest.UTP.Helper().AccountHelper().AccountOf(genesisOwner)) != nil)\n\tutest.Transfer(nil, test.obj.sdk.Helper().GenesisHelper().Token().Name(), test.obj.sdk.Message().Contract().Account(), bn.N(1E11))\n\taccounts := utest.NewAccounts(test.obj.sdk.Helper().GenesisHelper().Token().Name(), bn.N(1E13), 5)\n\tif accounts == nil {\n\t\tpanic(\"初始化newOwner失败\")\n\t}\n\t//commitLastBlock, pubKey, reveal, commit, signData, _ := PlaceBetHelper(100)\n\tcommitLastBlock, pubKey, reveal, commit, signData, _ := PlaceBetHelper(100)\n\ttest.run().setSender(contractOwner).InitChain()\n\tutest.AssertError(test.run().setSender(contractOwner).SetSecretSigner(pubKey[:]), types.CodeOK)\n\tbetData := []BetData{{1, bn.N(1000000000)}}\n\tbetDataJsonBytes, _ := jsoniter.Marshal(betData)\n\tbetData1 := []BetData{{2, bn.N(1000000000)}}\n\tbetDataJsonBytes1, _ := jsoniter.Marshal(betData1)\n\tutest.AssertError(test.run().setSender(accounts[0]).transfer(bn.N(1000000000)).PlaceBet(string(betDataJsonBytes), commitLastBlock, \"hello\", commit, signData[:], \"\"), types.CodeOK)\n\tutest.AssertError(test.run().setSender(accounts[0]).transfer(bn.N(1000000000)).PlaceBet(string(betDataJsonBytes1), commitLastBlock, \"hhgd\", commit, signData[:], \"\"), types.CodeOK)\n\tutest.AssertError(test.run().setSender(accounts[1]).transfer(bn.N(1000000000)).PlaceBet(string(betDataJsonBytes1), commitLastBlock, \"hhgdf\", commit, signData[:], \"\"), types.CodeOK)\n\tutest.AssertError(test.run().setSender(accounts[2]).transfer(bn.N(1000000000)).PlaceBet(string(betDataJsonBytes1), commitLastBlock, \"hhgdd\", commit, signData[:], \"\"), types.CodeOK)\n\tutest.AssertError(test.run().setSender(accounts[3]).transfer(bn.N(1000000000)).PlaceBet(string(betDataJsonBytes1), commitLastBlock, \"hhgdw\", commit, signData[:], \"\"), types.CodeOK)\n\n\t//utest.AssertError(test.run().setSender(contractOwner).SettleBet(reveal, 1), types.CodeOK)\n\t//utest.AssertError(test.run().setSender(contractOwner).SettleBet(reveal, 3), types.CodeOK)\n\tutest.AssertError(test.run().setSender(contractOwner).SettleBet(reveal, 1), types.CodeOK)\n\t//utest.AssertError(test.run().setSender(contractOwner).WithdrawWin(commit), types.ErrInvalidParameter)\n\tutest.AssertError(test.run().setSender(accounts[3]).WithdrawWin(commit), types.CodeOK)\n}", "title": "" }, { "docid": "00bf2018f3f53cfb496d6a0a0103dad9", "score": "0.42095238", "text": "func (s *SmartContract) initLedger(APIstub shim.ChaincodeStubInterface) sc.Response {\n\ttnProvider := []TnProvider{\n\t\tTnProvider{Name: \"America Movil\", Uuid: uuid.New().String(), PublicKey: \"Auto Generated Entry\"},\n\t\tTnProvider{Name: \"Telefonica\", Uuid: uuid.New().String(), PublicKey: \"Auto Generated Entry\"},\n\t\tTnProvider{Name: \"Sprint\", Uuid: uuid.New().String(), PublicKey: \"Auto Generated Entry\"},\n\t\tTnProvider{Name: \"Orange\", Uuid: uuid.New().String(), PublicKey: \"Auto Generated Entry\"},\n\t\tTnProvider{Name: \"Tigo Une\", Uuid: uuid.New().String(), PublicKey: \"Auto Generated Entry\"},\n\t}\n\n\ti := 0\n\tfor i < len(tnProvider) {\n\t\tfmt.Println(\"i is \", i)\n\t\ttnProviderAsBytes, _ := json.Marshal(tnProvider[i])\n\t\tAPIstub.PutState(strconv.Itoa(i+1), tnProviderAsBytes)\n\t\tfmt.Println(\"Added Vetter\", tnProvider[i])\n\t\ti = i + 1\n\t}\n\n\treturn shim.Success(nil)\n}", "title": "" }, { "docid": "c5be68c171f7c64052b558095c589cc3", "score": "0.42037424", "text": "func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response {\n\tfmt.Println(\"Marbles Is Starting Up\")\n\t_, args := stub.GetFunctionAndParameters()\n\tvar Aval int\n\tvar err error\n\n\tif len(args) != 1 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 1\")\n\t}\n\n\t// Initialize the chaincode\n\tAval, err = strconv.Atoi(args[0])\n\tif err != nil {\n\t\treturn shim.Error(\"Expecting integer value for asset holding\")\n\t}\n\n\t// Write the state to the ledger\n\terr = stub.PutState(\"abc\", []byte(strconv.Itoa(Aval))) //making a test var \"abc\", I find it handy to read/write to it right away to test the network\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\n\tfmt.Println(\" - ready for action\")\n\treturn shim.Success(nil)\n}", "title": "" }, { "docid": "149499f86af0970eabca89590eb38c32", "score": "0.41934484", "text": "func (s *SmartContract) Init(APIstub shim.ChaincodeStubInterface) sc.Response {\n\t fmt.Println(\"Lecture_stat Init\")\n\t return shim.Success(nil)\n }", "title": "" }, { "docid": "74545ec20a668f7f5d330e6fe38f0183", "score": "0.4187308", "text": "func CreateTestMinerWith(\n\tcollateral types.AttoFIL,\n\tt *testing.T,\n\tstateTree state.Tree,\n\tvms vm.StorageMap,\n\tminerOwnerAddr address.Address,\n\tpid peer.ID,\n\theight uint64,\n) address.Address {\n\tpdata := actor.MustConvertParams(types.OneKiBSectorSize, pid)\n\tnonce := RequireGetNonce(t, stateTree, address.TestAddress)\n\tmsg := types.NewUnsignedMessage(minerOwnerAddr, address.StorageMarketAddress, nonce, collateral, storagemarket.CreateStorageMiner, pdata)\n\n\tresult, err := ApplyTestMessage(stateTree, vms, msg, types.NewBlockHeight(height))\n\trequire.NoError(t, err)\n\trequire.NotNil(t, result)\n\trequire.NoError(t, result.ExecutionError)\n\taddr, err := address.NewFromBytes(result.Receipt.Return[0])\n\trequire.NoError(t, err)\n\treturn addr\n}", "title": "" }, { "docid": "518956601f7afa80dd299314be2a9785", "score": "0.41789967", "text": "func (*impl) createStorageMiner(vmctx runtime.InvocationContext, params CreateStorageMinerParams) address.Address {\n\tvmctx.ValidateCaller(pattern.Any{})\n\n\tinitParams := miner.ConstructorParams{\n\t\tOwnerAddr: vmctx.Message().Caller(),\n\t\tWorkerAddr: vmctx.Message().Caller(),\n\t\tPeerID: params.PeerID,\n\t\tSectorSize: params.SectorSize,\n\t}\n\n\tconstructorParams, err := encoding.Encode(initParams)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tactorCodeCid := builtin.StorageMinerActorCodeID\n\tepoch := vmctx.Runtime().CurrentEpoch()\n\tif epoch == 0 {\n\t\tactorCodeCid = types.BootstrapMinerActorCodeCid\n\t}\n\n\t// create miner actor by messaging the init actor and sending it collateral\n\tret := vmctx.Send(vmaddr.InitAddress, initactor.ExecMethodID, vmctx.Message().ValueReceived(), initactor.ExecParams{\n\t\tActorCodeCid: actorCodeCid,\n\t\tConstructorParams: constructorParams,\n\t})\n\n\tactorIDAddr := ret.(address.Address)\n\n\tvar state State\n\tret, err = vmctx.State().Transaction(&state, func() (interface{}, error) {\n\t\t// Update power table.\n\t\tctx := context.Background()\n\t\tnewPowerTable, err := actor.WithLookup(ctx, vmctx.Runtime().Storage(), state.PowerTable.Cid, func(lookup storage.Lookup) error {\n\t\t\t// Do not overwrite table entry if it already exists\n\t\t\terr := lookup.Find(ctx, string(actorIDAddr.Bytes()), nil)\n\t\t\tif err != hamt.ErrNotFound { // we expect to not find the power table entry\n\t\t\t\tif err == nil {\n\t\t\t\t\treturn Errors[ErrDuplicateEntry]\n\t\t\t\t}\n\t\t\t\treturn fmt.Errorf(\"Error looking for new entry in power table at addres %s\", actorIDAddr)\n\t\t\t}\n\n\t\t\t// Create fresh entry\n\t\t\terr = lookup.Set(ctx, string(actorIDAddr.Bytes()), TableEntry{\n\t\t\t\tActivePower: types.NewBytesAmount(0),\n\t\t\t\tInactivePower: types.NewBytesAmount(0),\n\t\t\t\tAvailableBalance: types.ZeroAttoFIL,\n\t\t\t\tLockedPledgeCollateral: types.ZeroAttoFIL,\n\t\t\t\tSectorSize: params.SectorSize,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"Could not set power table at address: %s\", actorIDAddr)\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tstate.PowerTable = enccid.NewCid(newPowerTable)\n\t\treturn actorIDAddr, nil\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn ret.(address.Address)\n}", "title": "" } ]
de8a366d74e021efe417c39f827b837f
GetStateByRangeWithPagination mocks base method
[ { "docid": "0f5caca8563cf7c4b8c4501234920c69", "score": "0.7668471", "text": "func (m *MockChaincodeStubInterface) GetStateByRangeWithPagination(startKey, endKey string, pageSize int32, bookmark string) (x.StateQueryIteratorInterface, *peer.QueryResponseMetadata, error) {\n\tret := m.ctrl.Call(m, \"GetStateByRangeWithPagination\", startKey, endKey, pageSize, bookmark)\n\tret0, _ := ret[0].(x.StateQueryIteratorInterface)\n\tret1, _ := ret[1].(*peer.QueryResponseMetadata)\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}", "title": "" } ]
[ { "docid": "9a923bd9219f41efe3354187233e1117", "score": "0.69884485", "text": "func (m *MockChaincodeStubInterface) GetStateByRange(startKey, endKey string) (x.StateQueryIteratorInterface, error) {\n\tret := m.ctrl.Call(m, \"GetStateByRange\", startKey, endKey)\n\tret0, _ := ret[0].(x.StateQueryIteratorInterface)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "179de4385ba1b552545826004775a99a", "score": "0.64737916", "text": "func (m *MockChaincodeStubInterface) GetPrivateDataByRange(collection, startKey, endKey string) (x.StateQueryIteratorInterface, error) {\n\tret := m.ctrl.Call(m, \"GetPrivateDataByRange\", collection, startKey, endKey)\n\tret0, _ := ret[0].(x.StateQueryIteratorInterface)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "fcc59ed08a953af00a1f0ad6b9cbddc0", "score": "0.64004403", "text": "func (m *MockAdapter) GetRange(key string, start, end int64) (string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetRange\", key, start, end)\n\tret0, _ := ret[0].(string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "efbccd7b63a929e335cf43dda9ef2f72", "score": "0.610236", "text": "func (m *MockUniversalClient) GetRange(arg0 string, arg1, arg2 int64) *redis.StringCmd {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetRange\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(*redis.StringCmd)\n\treturn ret0\n}", "title": "" }, { "docid": "2681b7bca9870265452c5221ce6474a3", "score": "0.6101446", "text": "func TestCalculatePaginationBounds(t *testing.T) {\n\tpoint := func(a int) *int {\n\t\treturn &a\n\t}\n\n\tcases := []struct {\n\t\tname string\n\t\tfirst *int\n\t\tskip *int\n\t\tsize int\n\t\tstart int\n\t\tend int\n\t}{\n\t\t{\"nil:nil:0\", nil, nil, 0, 0, 0},\n\t\t{\"nil:nil:5\", nil, nil, 5, 0, 5},\n\t\t{\"nil:nil:-1\", nil, nil, -1, 0, 0},\n\t\t{\"0:5:5\", point(0), point(5), 5, 5, 5},\n\t\t{\"2:3:5\", point(2), point(3), 5, 3, 5},\n\t\t{\"3:0:5\", point(3), point(0), 5, 0, 3},\n\t\t{\"3:-1:5\", point(3), point(-1), 5, 0, 3},\n\t\t{\"-1:3:5\", point(-1), point(3), 5, 3, 5},\n\t\t{\"3:2:-1\", point(3), point(2), -1, 0, 0},\n\t}\n\n\tfor _, tc := range cases {\n\t\tt.Run(tc.name, func(t *testing.T) {\n\t\t\tstart, end := calculatePaginationBounds(tc.first, tc.skip, tc.size)\n\t\t\tif start != tc.start {\n\t\t\t\tt.Fatalf(\"expected start=%d, but got %d\", tc.start, start)\n\t\t\t}\n\t\t\tif end != tc.end {\n\t\t\t\tt.Fatalf(\"expected end=%d, but got %d\", tc.end, end)\n\t\t\t}\n\t\t})\n\t}\n}", "title": "" }, { "docid": "255f8add85d85a0f148c28e3bb096e13", "score": "0.5931386", "text": "func TestPaginationQueryPage(t *testing.T) {\n\tdb := dynamodb.New(unit.Session)\n\ttokens, pages, numPages, gotToEnd := []map[string]*dynamodb.AttributeValue{}, []map[string]*dynamodb.AttributeValue{}, 0, false\n\n\treqNum := 0\n\tresps := []*dynamodb.QueryOutput{\n\t\t{\n\t\t\tLastEvaluatedKey: map[string]*dynamodb.AttributeValue{\"key\": {S: aws.String(\"key1\")}},\n\t\t\tCount: aws.Int64(1),\n\t\t\tItems: []map[string]*dynamodb.AttributeValue{\n\t\t\t\t{\n\t\t\t\t\t\"key\": {S: aws.String(\"key1\")},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tLastEvaluatedKey: map[string]*dynamodb.AttributeValue{\"key\": {S: aws.String(\"key2\")}},\n\t\t\tCount: aws.Int64(1),\n\t\t\tItems: []map[string]*dynamodb.AttributeValue{\n\t\t\t\t{\n\t\t\t\t\t\"key\": {S: aws.String(\"key2\")},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tLastEvaluatedKey: map[string]*dynamodb.AttributeValue{},\n\t\t\tCount: aws.Int64(1),\n\t\t\tItems: []map[string]*dynamodb.AttributeValue{\n\t\t\t\t{\n\t\t\t\t\t\"key\": {S: aws.String(\"key3\")},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tdb.Handlers.Send.Clear() // mock sending\n\tdb.Handlers.Unmarshal.Clear()\n\tdb.Handlers.UnmarshalMeta.Clear()\n\tdb.Handlers.ValidateResponse.Clear()\n\tdb.Handlers.Build.PushBack(func(r *request.Request) {\n\t\tin := r.Params.(*dynamodb.QueryInput)\n\t\tif in == nil {\n\t\t\ttokens = append(tokens, nil)\n\t\t} else if len(in.ExclusiveStartKey) != 0 {\n\t\t\ttokens = append(tokens, in.ExclusiveStartKey)\n\t\t}\n\t})\n\tdb.Handlers.Unmarshal.PushBack(func(r *request.Request) {\n\t\tr.Data = resps[reqNum]\n\t\treqNum++\n\t})\n\n\tparams := &dynamodb.QueryInput{\n\t\tLimit: aws.Int64(2),\n\t\tTableName: aws.String(\"tablename\"),\n\t}\n\terr := db.QueryPages(params, func(p *dynamodb.QueryOutput, last bool) bool {\n\t\tnumPages++\n\t\tpages = append(pages, p.Items...)\n\t\tif last {\n\t\t\tif gotToEnd {\n\t\t\t\tt.Errorf(\"last=true happened twice\")\n\t\t\t}\n\t\t\tgotToEnd = true\n\t\t}\n\t\treturn true\n\t})\n\tif err != nil {\n\t\tt.Errorf(\"expect nil, %v\", err)\n\t}\n\n\tif e, a :=\n\t\t[]map[string]*dynamodb.AttributeValue{\n\t\t\t{\"key\": {S: aws.String(\"key1\")}},\n\t\t\t{\"key\": {S: aws.String(\"key2\")}},\n\t\t}, tokens; !reflect.DeepEqual(e, a) {\n\t\tt.Errorf(\"expect %v, got %v\", e, a)\n\t}\n\tif e, a :=\n\t\t[]map[string]*dynamodb.AttributeValue{\n\t\t\t{\"key\": {S: aws.String(\"key1\")}},\n\t\t\t{\"key\": {S: aws.String(\"key2\")}},\n\t\t\t{\"key\": {S: aws.String(\"key3\")}},\n\t\t}, pages; !reflect.DeepEqual(e, a) {\n\t\tt.Errorf(\"expect %v, got %v\", e, a)\n\t}\n\tif e, a := 3, numPages; e != a {\n\t\tt.Errorf(\"expect %v, got %v\", e, a)\n\t}\n\tif !gotToEnd {\n\t\tt.Errorf(\"expect true\")\n\t}\n\tif params.ExclusiveStartKey != nil {\n\t\tt.Errorf(\"expect nil, %v\", err)\n\t}\n}", "title": "" }, { "docid": "d971162f65dd0305ba2ee446252db4a2", "score": "0.5909209", "text": "func (m *MockStringsOperator) GetRange(key string, start, end int64) (string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetRange\", key, start, end)\n\tret0, _ := ret[0].(string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "07f8c435c8d637d3fd5da0a264412593", "score": "0.5801123", "text": "func (m *MockChaincodeStubInterface) GetStateByPartialCompositeKeyWithPagination(objectType string, keys []string, pageSize int32, bookmark string) (x.StateQueryIteratorInterface, *peer.QueryResponseMetadata, error) {\n\tret := m.ctrl.Call(m, \"GetStateByPartialCompositeKeyWithPagination\", objectType, keys, pageSize, bookmark)\n\tret0, _ := ret[0].(x.StateQueryIteratorInterface)\n\tret1, _ := ret[1].(*peer.QueryResponseMetadata)\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}", "title": "" }, { "docid": "0f7a9899b1d209d11d83f5a2cceb4d02", "score": "0.57298625", "text": "func (m *MockRedisRepository) ZRange(key string, start, stop int64) ([]string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ZRange\", key, start, stop)\n\tret0, _ := ret[0].([]string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "6f70570aef3255e56463005cb5f3021c", "score": "0.56817335", "text": "func TestPagination(t *testing.T) {\n\tdb := dynamodb.New(unit.Session)\n\ttokens, pages, numPages, gotToEnd := []string{}, []string{}, 0, false\n\n\treqNum := 0\n\tresps := []*dynamodb.ListTablesOutput{\n\t\t{TableNames: []*string{aws.String(\"Table1\"), aws.String(\"Table2\")}, LastEvaluatedTableName: aws.String(\"Table2\")},\n\t\t{TableNames: []*string{aws.String(\"Table3\"), aws.String(\"Table4\")}, LastEvaluatedTableName: aws.String(\"Table4\")},\n\t\t{TableNames: []*string{aws.String(\"Table5\")}},\n\t}\n\n\tdb.Handlers.Send.Clear() // mock sending\n\tdb.Handlers.Unmarshal.Clear()\n\tdb.Handlers.UnmarshalMeta.Clear()\n\tdb.Handlers.ValidateResponse.Clear()\n\tdb.Handlers.Build.PushBack(func(r *request.Request) {\n\t\tin := r.Params.(*dynamodb.ListTablesInput)\n\t\tif in == nil {\n\t\t\ttokens = append(tokens, \"\")\n\t\t} else if in.ExclusiveStartTableName != nil {\n\t\t\ttokens = append(tokens, *in.ExclusiveStartTableName)\n\t\t}\n\t})\n\tdb.Handlers.Unmarshal.PushBack(func(r *request.Request) {\n\t\tr.Data = resps[reqNum]\n\t\treqNum++\n\t})\n\n\tparams := &dynamodb.ListTablesInput{Limit: aws.Int64(2)}\n\terr := db.ListTablesPages(params, func(p *dynamodb.ListTablesOutput, last bool) bool {\n\t\tnumPages++\n\t\tfor _, t := range p.TableNames {\n\t\t\tpages = append(pages, *t)\n\t\t}\n\t\tif last {\n\t\t\tif gotToEnd {\n\t\t\t\tt.Errorf(\"last=true happened twice\")\n\t\t\t}\n\t\t\tgotToEnd = true\n\t\t}\n\t\treturn true\n\t})\n\n\tif e, a := []string{\"Table2\", \"Table4\"}, tokens; !reflect.DeepEqual(e, a) {\n\t\tt.Errorf(\"expect %v, got %v\", e, a)\n\t}\n\tif e, a := []string{\"Table1\", \"Table2\", \"Table3\", \"Table4\", \"Table5\"}, pages; !reflect.DeepEqual(e, a) {\n\t\tt.Errorf(\"expect %v, got %v\", e, a)\n\t}\n\tif e, a := 3, numPages; e != a {\n\t\tt.Errorf(\"expect %v, got %v\", e, a)\n\t}\n\tif !gotToEnd {\n\t\tt.Errorf(\"expect true\")\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"expect nil, %v\", err)\n\t}\n\tif params.ExclusiveStartTableName != nil {\n\t\tt.Errorf(\"expect nil, %v\", err)\n\t}\n}", "title": "" }, { "docid": "7abb574e037ef35f204185174ae41935", "score": "0.5679365", "text": "func (m *MockAdapter) LRange(key string, start, stop int64) ([]string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"LRange\", key, start, stop)\n\tret0, _ := ret[0].([]string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "056ce6f4af66be83175e4683601ceb2b", "score": "0.5677851", "text": "func (m *MockRedis) ZRange(ctx context.Context, key string, start, stop int64) ([]*Member, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ZRange\", ctx, key, start, stop)\n\tret0, _ := ret[0].([]*Member)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "b5cb22b9f54abf0124ab2d82900d4a8b", "score": "0.56381077", "text": "func (m *MockAdapter) ZRange(key string, start, stop int64) ([]string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ZRange\", key, start, stop)\n\tret0, _ := ret[0].([]string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "32ae3aaf542ba6b284673153391532c5", "score": "0.56082416", "text": "func (m *MockEnvParams) GetEnvIntRange(arg0 string, arg1, arg2 int, arg3 ...params.GetEnvSetter) (int, error) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{arg0, arg1, arg2}\n\tfor _, a := range arg3 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"GetEnvIntRange\", varargs...)\n\tret0, _ := ret[0].(int)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "71ba8e2a9cf6f08251b7e81faf4d436b", "score": "0.5598607", "text": "func TestPaginationEachPage(t *testing.T) {\n\tdb := dynamodb.New(unit.Session)\n\ttokens, pages, numPages, gotToEnd := []string{}, []string{}, 0, false\n\n\treqNum := 0\n\tresps := []*dynamodb.ListTablesOutput{\n\t\t{TableNames: []*string{aws.String(\"Table1\"), aws.String(\"Table2\")}, LastEvaluatedTableName: aws.String(\"Table2\")},\n\t\t{TableNames: []*string{aws.String(\"Table3\"), aws.String(\"Table4\")}, LastEvaluatedTableName: aws.String(\"Table4\")},\n\t\t{TableNames: []*string{aws.String(\"Table5\")}},\n\t}\n\n\tdb.Handlers.Send.Clear() // mock sending\n\tdb.Handlers.Unmarshal.Clear()\n\tdb.Handlers.UnmarshalMeta.Clear()\n\tdb.Handlers.ValidateResponse.Clear()\n\tdb.Handlers.Build.PushBack(func(r *request.Request) {\n\t\tin := r.Params.(*dynamodb.ListTablesInput)\n\t\tif in == nil {\n\t\t\ttokens = append(tokens, \"\")\n\t\t} else if in.ExclusiveStartTableName != nil {\n\t\t\ttokens = append(tokens, *in.ExclusiveStartTableName)\n\t\t}\n\t})\n\tdb.Handlers.Unmarshal.PushBack(func(r *request.Request) {\n\t\tr.Data = resps[reqNum]\n\t\treqNum++\n\t})\n\n\tparams := &dynamodb.ListTablesInput{Limit: aws.Int64(2)}\n\treq, _ := db.ListTablesRequest(params)\n\terr := req.EachPage(func(p interface{}, last bool) bool {\n\t\tnumPages++\n\t\tfor _, t := range p.(*dynamodb.ListTablesOutput).TableNames {\n\t\t\tpages = append(pages, *t)\n\t\t}\n\t\tif last {\n\t\t\tif gotToEnd {\n\t\t\t\tt.Errorf(\"last=true happened twice\")\n\t\t\t}\n\t\t\tgotToEnd = true\n\t\t}\n\n\t\treturn true\n\t})\n\n\tif e, a := []string{\"Table2\", \"Table4\"}, tokens; !reflect.DeepEqual(e, a) {\n\t\tt.Errorf(\"expect %v, got %v\", e, a)\n\t}\n\tif e, a := []string{\"Table1\", \"Table2\", \"Table3\", \"Table4\", \"Table5\"}, pages; !reflect.DeepEqual(e, a) {\n\t\tt.Errorf(\"expect %v, got %v\", e, a)\n\t}\n\tif e, a := 3, numPages; e != a {\n\t\tt.Errorf(\"expect %v, got %v\", e, a)\n\t}\n\tif !gotToEnd {\n\t\tt.Errorf(\"expect true\")\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"expect nil, %v\", err)\n\t}\n}", "title": "" }, { "docid": "7eb035e0707b0c499e4cd0b64f8314e3", "score": "0.553994", "text": "func (_m *MockRedis) GetRange(ctx context.Context, key string, start int64, end int64) *redis.StringCmd {\n\tret := _m.Called(ctx, key, start, end)\n\n\tvar r0 *redis.StringCmd\n\tif rf, ok := ret.Get(0).(func(context.Context, string, int64, int64) *redis.StringCmd); ok {\n\t\tr0 = rf(ctx, key, start, end)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(*redis.StringCmd)\n\t\t}\n\t}\n\n\treturn r0\n}", "title": "" }, { "docid": "0cc41f025a2d7f60fe567174fff6bbb1", "score": "0.5501948", "text": "func (m *MockRepo) List(limit, offset uint, after string) ([]models.Account, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"List\", limit, offset, after)\n\tret0, _ := ret[0].([]models.Account)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "c0e5a1ca87a0cd5a0e59d6f869c95845", "score": "0.5491564", "text": "func (m *MockAdapter) XRange(stream, start, stop string) ([]redis.XMessage, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"XRange\", stream, start, stop)\n\tret0, _ := ret[0].([]redis.XMessage)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "1bef446aa68fdedea0d6b9af3028ca0a", "score": "0.54403496", "text": "func (mr *MockChaincodeStubInterfaceMockRecorder) GetStateByRangeWithPagination(startKey, endKey, pageSize, bookmark interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"GetStateByRangeWithPagination\", reflect.TypeOf((*MockChaincodeStubInterface)(nil).GetStateByRangeWithPagination), startKey, endKey, pageSize, bookmark)\n}", "title": "" }, { "docid": "7ddefc0bafda59a6ee7b233c11f445bf", "score": "0.5420079", "text": "func (m *MockAdapter) ZRangeByLex(key string, opt redis.ZRangeBy) ([]string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ZRangeByLex\", key, opt)\n\tret0, _ := ret[0].([]string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "e02c7c5749743d01daf0fac552233c48", "score": "0.53978837", "text": "func (m *MockChaincodeStubInterface) GetQueryResultWithPagination(query string, pageSize int32, bookmark string) (x.StateQueryIteratorInterface, *peer.QueryResponseMetadata, error) {\n\tret := m.ctrl.Call(m, \"GetQueryResultWithPagination\", query, pageSize, bookmark)\n\tret0, _ := ret[0].(x.StateQueryIteratorInterface)\n\tret1, _ := ret[1].(*peer.QueryResponseMetadata)\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}", "title": "" }, { "docid": "b1413db15e4a0f116bb52a212fc7eee5", "score": "0.5385562", "text": "func (m *MockOauthApplicationRepository) Paginate(ktx kontext.Context, offset, limit int, tx db.TX) ([]entity.OauthApplication, exception.Exception) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Paginate\", ktx, offset, limit, tx)\n\tret0, _ := ret[0].([]entity.OauthApplication)\n\tret1, _ := ret[1].(exception.Exception)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "47640c67839f005b166a10643fe3fe2c", "score": "0.5364209", "text": "func (s *SmartContract) PaginatedRangeQuery(ctx contractapi.TransactionContextInterface, startKey string, endKey string, pagesize int32, passedBookmark string) (*utils.QueryResponse, error) {\n\tfmt.Printf(\"Entering paginated range query with pagesize [%d] and limit keys [%s ,%s]\", pagesize, startKey, endKey)\n\titerator, metadata, err := ctx.GetStub().GetStateByRangeWithPagination(startKey, endKey, pagesize, passedBookmark)\n\n\tif err != nil {\n\t\tfmt.Println(\"Error performing GetStateByRangeWithPagination: \" + err.Error())\n\t\treturn nil, err\n\t}\n\n\tresults, err := getAllResults(iterator)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trespMetadata := utils.ResponseMetadata{\n\t\tRecordsCount: metadata.GetFetchedRecordsCount(),\n\t\tBookmark: metadata.GetBookmark(),\n\t}\n\n\treturn &utils.QueryResponse{\n\t\tResults: results,\n\t\tResponseMetadata: respMetadata,\n\t}, nil\n}", "title": "" }, { "docid": "48a54dc4ff17be6ff19d3a1ac332ca96", "score": "0.53390044", "text": "func TestStateServicer_GetStates(t *testing.T) {\n\t// mock setup: expect 1 RPC to result in a search, the other to a concrete\n\t// GetMany\n\tmockStore := &mocks.Store{}\n\tmockStore.On(\"Search\",\n\t\tblobstore.CreateSearchFilter(strPtr(\"network1\"), []string{\"t1\", \"t2\"}, []string{\"k1\", \"k2\"}, nil),\n\t\tblobstore.GetDefaultLoadCriteria(),\n\t).\n\t\tReturn(map[string]blobstore.Blobs{\n\t\t\t\"network1\": {\n\t\t\t\t{Type: \"t1\", Key: \"k1\", Value: []byte(\"v1\"), Version: 42},\n\t\t\t\t{Type: \"t2\", Key: \"k2\", Value: []byte(\"v2\"), Version: 43},\n\t\t\t},\n\t\t}, nil)\n\tmockStore.On(\"GetMany\", \"network1\", storage.TKs{{Type: \"t1\", Key: \"k1\"}, {Type: \"t2\", Key: \"k2\"}}).\n\t\tReturn(blobstore.Blobs{\n\t\t\t{Type: \"t1\", Key: \"k1\", Value: []byte(\"v1\"), Version: 42},\n\t\t\t{Type: \"t2\", Key: \"k2\", Value: []byte(\"v2\"), Version: 43},\n\t\t}, nil)\n\n\tmockStore.On(\"Commit\").Return(nil)\n\n\tfact := &mocks.StoreFactory{}\n\tfact.On(\"StartTransaction\", mock.Anything).Return(mockStore, nil)\n\n\tsrv, err := protected.NewCloudStateServicer(fact)\n\tassert.NoError(t, err)\n\n\tactual, err := srv.GetStates(ctx, &protos.GetStatesRequest{\n\t\tNetworkID: \"network1\",\n\t\tTypeFilter: []string{\"t1\", \"t2\"},\n\t\tIdFilter: []string{\"k1\", \"k2\"},\n\t\tLoadValues: true,\n\t})\n\tassert.NoError(t, err)\n\texpected := &protos.GetStatesResponse{\n\t\tStates: []*protos.State{\n\t\t\t{\n\t\t\t\tType: \"t1\",\n\t\t\t\tDeviceID: \"k1\",\n\t\t\t\tValue: []byte(\"v1\"),\n\t\t\t\tVersion: 42,\n\t\t\t},\n\t\t\t{\n\t\t\t\tType: \"t2\",\n\t\t\t\tDeviceID: \"k2\",\n\t\t\t\tValue: []byte(\"v2\"),\n\t\t\t\tVersion: 43,\n\t\t\t},\n\t\t},\n\t}\n\tassert.Equal(t, expected, actual)\n\n\t// Prefer concrete GetMany over Search\n\tactual, err = srv.GetStates(ctx, &protos.GetStatesRequest{\n\t\tNetworkID: \"network1\",\n\t\tIds: []*protos.StateID{\n\t\t\t{Type: \"t1\", DeviceID: \"k1\"},\n\t\t\t{Type: \"t2\", DeviceID: \"k2\"},\n\t\t},\n\t\tTypeFilter: []string{\"t1\", \"t2\"},\n\t\tIdFilter: []string{\"k1\", \"k2\"},\n\t\tLoadValues: false,\n\t})\n\tassert.NoError(t, err)\n\tassert.Equal(t, expected, actual)\n\n\tmockStore.AssertExpectations(t)\n\tfact.AssertExpectations(t)\n}", "title": "" }, { "docid": "5918a4a8ead6daa59aa013637e7e771a", "score": "0.53342927", "text": "func (m *MockDatabase) GetMemberIDsWithScoreInsideRange(ctx context.Context, leaderboard, min, max string, offset, count int) ([]string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetMemberIDsWithScoreInsideRange\", ctx, leaderboard, min, max, offset, count)\n\tret0, _ := ret[0].([]string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "e361b9bb03f3be03f6bebcd84f5ee8d8", "score": "0.531792", "text": "func (m *MockDRaaSService) GetSolutionsPaginated(arg0 connection.APIRequestParameters) (*draas.PaginatedSolution, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetSolutionsPaginated\", arg0)\n\tret0, _ := ret[0].(*draas.PaginatedSolution)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "0ea361e506c687a2f41cf0a25c19b011", "score": "0.5302631", "text": "func (m *MockOps) GetLimitRange(arg0, arg1 string) (*v1.LimitRange, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetLimitRange\", arg0, arg1)\n\tret0, _ := ret[0].(*v1.LimitRange)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "4aee1a84e5b71a3e6b241af4e0b958ad", "score": "0.52768767", "text": "func (m *MockUniversalClient) LRange(arg0 string, arg1, arg2 int64) *redis.StringSliceCmd {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"LRange\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(*redis.StringSliceCmd)\n\treturn ret0\n}", "title": "" }, { "docid": "3b01d3c98e7bc003a00d0dfddeb68560", "score": "0.52739924", "text": "func TestPaginationEarlyExit(t *testing.T) {\n\tdb := dynamodb.New(unit.Session)\n\tnumPages, gotToEnd := 0, false\n\n\treqNum := 0\n\tresps := []*dynamodb.ListTablesOutput{\n\t\t{TableNames: []*string{aws.String(\"Table1\"), aws.String(\"Table2\")}, LastEvaluatedTableName: aws.String(\"Table2\")},\n\t\t{TableNames: []*string{aws.String(\"Table3\"), aws.String(\"Table4\")}, LastEvaluatedTableName: aws.String(\"Table4\")},\n\t\t{TableNames: []*string{aws.String(\"Table5\")}},\n\t}\n\n\tdb.Handlers.Send.Clear() // mock sending\n\tdb.Handlers.Unmarshal.Clear()\n\tdb.Handlers.UnmarshalMeta.Clear()\n\tdb.Handlers.ValidateResponse.Clear()\n\tdb.Handlers.Unmarshal.PushBack(func(r *request.Request) {\n\t\tr.Data = resps[reqNum]\n\t\treqNum++\n\t})\n\n\tparams := &dynamodb.ListTablesInput{Limit: aws.Int64(2)}\n\terr := db.ListTablesPages(params, func(p *dynamodb.ListTablesOutput, last bool) bool {\n\t\tnumPages++\n\t\tif numPages == 2 {\n\t\t\treturn false\n\t\t}\n\t\tif last {\n\t\t\tif gotToEnd {\n\t\t\t\tt.Errorf(\"last=true happened twice\")\n\t\t\t}\n\t\t\tgotToEnd = true\n\t\t}\n\t\treturn true\n\t})\n\n\tif e, a := 2, numPages; e != a {\n\t\tt.Errorf(\"expect %v, got %v\", e, a)\n\t}\n\tif gotToEnd {\n\t\tt.Errorf(\"expect false\")\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"expect nil, %v\", err)\n\t}\n}", "title": "" }, { "docid": "c26f9aeab89f1bf62af3a2fbdad99e3e", "score": "0.527383", "text": "func (m *MockListsOperator) LRange(key string, start, stop int64) ([]string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"LRange\", key, start, stop)\n\tret0, _ := ret[0].([]string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "cf1b69ca9af93ec0becc8b835f4a77ae", "score": "0.5271953", "text": "func (iState *iState) getStateByRange(stub shim.ChaincodeStubInterface, startKey string, endKey string, kindecesMap map[string]map[string][]byte, forceFetchDB bool) (iStateErr Error) {\n\n\t// // Compact Index\n\t// cIndexKey, _ := generateCIndexKey(removeLastSeparator(startKey))\n\n\t// cIndexV, iStateErr := fetchCompactIndex(stub, cIndexKey)\n\t// if iStateErr != nil {\n\t// \treturn\n\t// }\n\t// for keyRef, hashString := range cIndexV {\n\n\t// \tiStateErr = iState.loadkindecesMap(stub, kindecesMap, keyRef, hashString)\n\t// \tif iStateErr != nil {\n\t// \t\treturn\n\t// \t}\n\t// }\n\n\t// Normal Index\n\titerator, err := stub.GetStateByRange(startKey, endKey)\n\tif err != nil {\n\t\tiStateErr = newError(err, 3006)\n\t\treturn\n\t}\n\n\tdefer iterator.Close()\n\tfor i := 0; iterator.HasNext(); i++ {\n\t\titeratorResult, err := iterator.Next()\n\t\tif err != nil {\n\t\t\tiStateErr = newError(err, 3007)\n\t\t\treturn\n\t\t}\n\t\tindexkey := iteratorResult.GetKey()\n\t\thashBytes := iteratorResult.GetValue()\n\t\tkeyRef := getKeyFromIndex(indexkey)\n\n\t\tiStateErr = iState.loadkindecesMap(stub, kindecesMap, keyRef, string(hashBytes), forceFetchDB)\n\t\tif iStateErr != nil {\n\t\t\treturn\n\t\t}\n\t}\n\n\treturn\n}", "title": "" }, { "docid": "e46d8cbb7685fc53bd4e9cd026941ffb", "score": "0.5260909", "text": "func (m *MockOriginHTTPClient) IsSupportRange(url string, headers map[string]string) (bool, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"IsSupportRange\", url, headers)\n\tret0, _ := ret[0].(bool)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "348304061b404c6b5357fad18a913746", "score": "0.5236193", "text": "func (m *MockUserService) Query(arg0 []entity.UserFilter, arg1 []string, arg2, arg3 int) ([]entity.User, engine.Pagination, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Query\", arg0, arg1, arg2, arg3)\n\tret0, _ := ret[0].([]entity.User)\n\tret1, _ := ret[1].(engine.Pagination)\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}", "title": "" }, { "docid": "1cf43738c1db1bd70f0aa8121aa7a1e6", "score": "0.521921", "text": "func (m *MockAdapter) ZRemRangeByLex(key, min, max string) (int64, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ZRemRangeByLex\", key, min, max)\n\tret0, _ := ret[0].(int64)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "5fbd2bebcbf686f66e9e7c62b09cf73f", "score": "0.52152336", "text": "func (m *MockSortedSetsOperator) ZRange(key string, start, stop int64) ([]string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ZRange\", key, start, stop)\n\tret0, _ := ret[0].([]string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "90df7eadce32406a090b55c740a2479a", "score": "0.5210016", "text": "func (m *MockRepository) GetCountPages(arg0 uint64, arg1 int) (int, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetCountPages\", arg0, arg1)\n\tret0, _ := ret[0].(int)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "2d9134c3f609226b540c14f77208a88a", "score": "0.51979905", "text": "func (m *MockStateQueryIteratorInterface) Next() (*queryresult.KV, error) {\n\tret := m.ctrl.Call(m, \"Next\")\n\tret0, _ := ret[0].(*queryresult.KV)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "bbf598294211a480a5b535188440e25b", "score": "0.51962906", "text": "func (m *MockAdapter) XRangeN(stream, start, stop string, count int64) ([]redis.XMessage, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"XRangeN\", stream, start, stop, count)\n\tret0, _ := ret[0].([]redis.XMessage)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "6b5757ec25b10702e1d932d02dca1889", "score": "0.5188693", "text": "func (c *CommonProvider) getPagination(domain string) (*CommonPaginationResult, error) {\n\turl := fmt.Sprintf(\"%s&showNumPages=true\", c.formatURL(domain, 0))\n\n\tresp, err := c.MakeRequest(url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer resp.Body.Close()\n\n\tvar paginationResult CommonPaginationResult\n\tif err = json.NewDecoder(resp.Body).Decode(&paginationResult); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &paginationResult, nil\n}", "title": "" }, { "docid": "6937f708840a75af54b3f00417e04fbe", "score": "0.5181167", "text": "func (m *MockStreamsOperator) XRange(stream, start, stop string) ([]redis.XMessage, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"XRange\", stream, start, stop)\n\tret0, _ := ret[0].([]redis.XMessage)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "ff44eec590933f382b6ebfc3728fa959", "score": "0.513516", "text": "func (m *TrainStoreMock) GetBetween(start, end *time.Time) (trains []train.Train, err error) {\n\targs := m.Called(start, end)\n\treturn args.Get(0).([]train.Train), args.Error(1)\n}", "title": "" }, { "docid": "bd529b6f0e8c1fa9c0ba6745f26a3711", "score": "0.51166147", "text": "func (m *MockDRaaSService) GetSolutionBackupResourcesPaginated(arg0 string, arg1 connection.APIRequestParameters) (*draas.PaginatedBackupResource, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetSolutionBackupResourcesPaginated\", arg0, arg1)\n\tret0, _ := ret[0].(*draas.PaginatedBackupResource)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "75948f0b3f2854d7363c5cf3d6aa6e17", "score": "0.5111912", "text": "func (m *MockAdapter) SetRange(key string, offset int64, value string) (int64, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"SetRange\", key, offset, value)\n\tret0, _ := ret[0].(int64)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "f3c836516b11b9785e0fb4ba910f80c4", "score": "0.5087017", "text": "func (m *MockResourceClient) IsSupportRange(arg0 context.Context, arg1 string, arg2 source.RequestHeader) (bool, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"IsSupportRange\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(bool)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "cb1bf45f7a433133cd919841ede7c5c4", "score": "0.5079034", "text": "func (iter *PrivateMockStateRangeQueryIterator) Next() (*queryresult.KV, error) {\n\tif iter.Closed {\n\t\terr := errors.New(\"PrivateMockStateRangeQueryIterator.Next() called after Close()\")\n\t\treturn nil, err\n\t}\n\n\tif !iter.HasNext() {\n\t\terr := errors.New(\"PrivateMockStateRangeQueryIterator.Next() called when it does not HaveNext()\")\n\t\treturn nil, err\n\t}\n\n\tfor iter.Current != nil {\n\t\tcomp1 := strings.Compare(iter.Current.Value.(string), iter.StartKey)\n\t\tcomp2 := strings.Compare(iter.Current.Value.(string), iter.EndKey)\n\t\t// compare to start and end keys. or, if this is an open-ended query for\n\t\t// all keys, it should always return the key and value\n\t\tif (comp1 >= 0 && comp2 < 0) || (iter.StartKey == \"\" && iter.EndKey == \"\") {\n\t\t\tkey := iter.Current.Value.(string)\n\t\t\tvalue, err := iter.Stub.GetPrivateData(iter.Collection, key)\n\t\t\titer.Current = iter.Current.Next()\n\t\t\treturn &queryresult.KV{Key: key, Value: value}, err\n\t\t}\n\t\titer.Current = iter.Current.Next()\n\t}\n\treturn nil, errors.New(\"PrivateMockStateRangeQueryIterator.Next() went past end of range\")\n}", "title": "" }, { "docid": "a59582636e63bf100353c042f039195f", "score": "0.5077446", "text": "func (m *MockUniversalClient) XRange(arg0, arg1, arg2 string) *redis.XMessageSliceCmd {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"XRange\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(*redis.XMessageSliceCmd)\n\treturn ret0\n}", "title": "" }, { "docid": "0fdb5afb40bc0bb96fbbaded3d9016fd", "score": "0.50666636", "text": "func (mock *DefaultApiMock) GetMetricsByRangeQueryCalls() []struct {\n\tCtx _context.Context\n\tID string\n} {\n\tvar calls []struct {\n\t\tCtx _context.Context\n\t\tID string\n\t}\n\tmock.lockGetMetricsByRangeQuery.RLock()\n\tcalls = mock.calls.GetMetricsByRangeQuery\n\tmock.lockGetMetricsByRangeQuery.RUnlock()\n\treturn calls\n}", "title": "" }, { "docid": "cce9d2109f1da054b175e628eda5907f", "score": "0.5056966", "text": "func (m *MockUniversalClient) ZRangeByLex(arg0 string, arg1 redis.ZRangeBy) *redis.StringSliceCmd {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ZRangeByLex\", arg0, arg1)\n\tret0, _ := ret[0].(*redis.StringSliceCmd)\n\treturn ret0\n}", "title": "" }, { "docid": "19cd95a7679909a8906c6d85263afb6e", "score": "0.50533885", "text": "func (m *MockUniversalClient) ZRange(arg0 string, arg1, arg2 int64) *redis.StringSliceCmd {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ZRange\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(*redis.StringSliceCmd)\n\treturn ret0\n}", "title": "" }, { "docid": "21c1cd4e95c528e47033713b0b9bfb8b", "score": "0.5046115", "text": "func (m *MockRedis) ZRevRange(ctx context.Context, key string, start, stop int64) ([]*Member, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ZRevRange\", ctx, key, start, stop)\n\tret0, _ := ret[0].([]*Member)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "f0d08639a710e028dc1da06b34a503b3", "score": "0.50340307", "text": "func (m *MockAdapter) ZRevRange(key string, start, stop int64) ([]string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ZRevRange\", key, start, stop)\n\tret0, _ := ret[0].([]string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "80872856d440e98423cbf51e1736ab73", "score": "0.5012572", "text": "func (m *MockDRaaSService) GetSolutionComputeResourcesPaginated(arg0 string, arg1 connection.APIRequestParameters) (*draas.PaginatedComputeResource, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetSolutionComputeResourcesPaginated\", arg0, arg1)\n\tret0, _ := ret[0].(*draas.PaginatedComputeResource)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "ab26094a1264093c67caaafc8024c7c6", "score": "0.49852246", "text": "func (m *MockQueryManager) Iter() *mgo.Iter {\n\tret := m.ctrl.Call(m, \"Iter\")\n\tret0, _ := ret[0].(*mgo.Iter)\n\treturn ret0\n}", "title": "" }, { "docid": "d3288caff44e251ba17fda6952b27bfe", "score": "0.49758816", "text": "func TestQueryPayments(t *testing.T) {\n\t// Define table driven test for QueryPayments.\n\t// Test payments have sequence indices [1, 3, 4, 5, 6, 7].\n\ttests := []struct {\n\t\tname string\n\t\tquery PaymentsQuery\n\t\tfirstIndex uint64\n\t\tlastIndex uint64\n\n\t\t// expectedSeqNrs contains the set of sequence numbers we expect\n\t\t// our query to return.\n\t\texpectedSeqNrs []uint64\n\t}{\n\t\t{\n\t\t\tname: \"IndexOffset at the end of the payments range\",\n\t\t\tquery: PaymentsQuery{\n\t\t\t\tIndexOffset: 7,\n\t\t\t\tMaxPayments: 7,\n\t\t\t\tReversed: false,\n\t\t\t\tIncludeIncomplete: true,\n\t\t\t},\n\t\t\tfirstIndex: 0,\n\t\t\tlastIndex: 0,\n\t\t\texpectedSeqNrs: nil,\n\t\t},\n\t\t{\n\t\t\tname: \"query in forwards order, start at beginning\",\n\t\t\tquery: PaymentsQuery{\n\t\t\t\tIndexOffset: 0,\n\t\t\t\tMaxPayments: 2,\n\t\t\t\tReversed: false,\n\t\t\t\tIncludeIncomplete: true,\n\t\t\t},\n\t\t\tfirstIndex: 1,\n\t\t\tlastIndex: 3,\n\t\t\texpectedSeqNrs: []uint64{1, 3},\n\t\t},\n\t\t{\n\t\t\tname: \"query in forwards order, start at end, overflow\",\n\t\t\tquery: PaymentsQuery{\n\t\t\t\tIndexOffset: 6,\n\t\t\t\tMaxPayments: 2,\n\t\t\t\tReversed: false,\n\t\t\t\tIncludeIncomplete: true,\n\t\t\t},\n\t\t\tfirstIndex: 7,\n\t\t\tlastIndex: 7,\n\t\t\texpectedSeqNrs: []uint64{7},\n\t\t},\n\t\t{\n\t\t\tname: \"start at offset index outside of payments\",\n\t\t\tquery: PaymentsQuery{\n\t\t\t\tIndexOffset: 20,\n\t\t\t\tMaxPayments: 2,\n\t\t\t\tReversed: false,\n\t\t\t\tIncludeIncomplete: true,\n\t\t\t},\n\t\t\tfirstIndex: 0,\n\t\t\tlastIndex: 0,\n\t\t\texpectedSeqNrs: nil,\n\t\t},\n\t\t{\n\t\t\tname: \"overflow in forwards order\",\n\t\t\tquery: PaymentsQuery{\n\t\t\t\tIndexOffset: 4,\n\t\t\t\tMaxPayments: math.MaxUint64,\n\t\t\t\tReversed: false,\n\t\t\t\tIncludeIncomplete: true,\n\t\t\t},\n\t\t\tfirstIndex: 5,\n\t\t\tlastIndex: 7,\n\t\t\texpectedSeqNrs: []uint64{5, 6, 7},\n\t\t},\n\t\t{\n\t\t\tname: \"start at offset index outside of payments, \" +\n\t\t\t\t\"reversed order\",\n\t\t\tquery: PaymentsQuery{\n\t\t\t\tIndexOffset: 9,\n\t\t\t\tMaxPayments: 2,\n\t\t\t\tReversed: true,\n\t\t\t\tIncludeIncomplete: true,\n\t\t\t},\n\t\t\tfirstIndex: 6,\n\t\t\tlastIndex: 7,\n\t\t\texpectedSeqNrs: []uint64{6, 7},\n\t\t},\n\t\t{\n\t\t\tname: \"query in reverse order, start at end\",\n\t\t\tquery: PaymentsQuery{\n\t\t\t\tIndexOffset: 0,\n\t\t\t\tMaxPayments: 2,\n\t\t\t\tReversed: true,\n\t\t\t\tIncludeIncomplete: true,\n\t\t\t},\n\t\t\tfirstIndex: 6,\n\t\t\tlastIndex: 7,\n\t\t\texpectedSeqNrs: []uint64{6, 7},\n\t\t},\n\t\t{\n\t\t\tname: \"query in reverse order, starting in middle\",\n\t\t\tquery: PaymentsQuery{\n\t\t\t\tIndexOffset: 4,\n\t\t\t\tMaxPayments: 2,\n\t\t\t\tReversed: true,\n\t\t\t\tIncludeIncomplete: true,\n\t\t\t},\n\t\t\tfirstIndex: 1,\n\t\t\tlastIndex: 3,\n\t\t\texpectedSeqNrs: []uint64{1, 3},\n\t\t},\n\t\t{\n\t\t\tname: \"query in reverse order, starting in middle, \" +\n\t\t\t\t\"with underflow\",\n\t\t\tquery: PaymentsQuery{\n\t\t\t\tIndexOffset: 4,\n\t\t\t\tMaxPayments: 5,\n\t\t\t\tReversed: true,\n\t\t\t\tIncludeIncomplete: true,\n\t\t\t},\n\t\t\tfirstIndex: 1,\n\t\t\tlastIndex: 3,\n\t\t\texpectedSeqNrs: []uint64{1, 3},\n\t\t},\n\t\t{\n\t\t\tname: \"all payments in reverse, order maintained\",\n\t\t\tquery: PaymentsQuery{\n\t\t\t\tIndexOffset: 0,\n\t\t\t\tMaxPayments: 7,\n\t\t\t\tReversed: true,\n\t\t\t\tIncludeIncomplete: true,\n\t\t\t},\n\t\t\tfirstIndex: 1,\n\t\t\tlastIndex: 7,\n\t\t\texpectedSeqNrs: []uint64{1, 3, 4, 5, 6, 7},\n\t\t},\n\t\t{\n\t\t\tname: \"exclude incomplete payments\",\n\t\t\tquery: PaymentsQuery{\n\t\t\t\tIndexOffset: 0,\n\t\t\t\tMaxPayments: 7,\n\t\t\t\tReversed: false,\n\t\t\t\tIncludeIncomplete: false,\n\t\t\t},\n\t\t\tfirstIndex: 0,\n\t\t\tlastIndex: 0,\n\t\t\texpectedSeqNrs: nil,\n\t\t},\n\t\t{\n\t\t\tname: \"query payments at index gap\",\n\t\t\tquery: PaymentsQuery{\n\t\t\t\tIndexOffset: 1,\n\t\t\t\tMaxPayments: 7,\n\t\t\t\tReversed: false,\n\t\t\t\tIncludeIncomplete: true,\n\t\t\t},\n\t\t\tfirstIndex: 3,\n\t\t\tlastIndex: 7,\n\t\t\texpectedSeqNrs: []uint64{3, 4, 5, 6, 7},\n\t\t},\n\t}\n\n\tfor _, tt := range tests {\n\t\ttt := tt\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tt.Parallel()\n\n\t\t\tdb, cleanup, err := makeTestDB()\n\t\t\tdefer cleanup()\n\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"unable to init db: %v\", err)\n\t\t\t}\n\n\t\t\t// Populate the database with a set of test payments.\n\t\t\tnumberOfPayments := 7\n\t\t\tpControl := NewPaymentControl(db)\n\n\t\t\tfor i := 0; i < numberOfPayments; i++ {\n\t\t\t\t// Generate a test payment.\n\t\t\t\tinfo, _, _, err := genInfo()\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatalf(\"unable to create test \"+\n\t\t\t\t\t\t\"payment: %v\", err)\n\t\t\t\t}\n\n\t\t\t\t// Create a new payment entry in the database.\n\t\t\t\terr = pControl.InitPayment(info.PaymentHash, info)\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatalf(\"unable to initialize \"+\n\t\t\t\t\t\t\"payment in database: %v\", err)\n\t\t\t\t}\n\n\t\t\t\t// Immediately delete the payment with index 2.\n\t\t\t\tif i == 1 {\n\t\t\t\t\tdeletePayment(t, db, info.PaymentHash)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Fetch all payments in the database.\n\t\t\tallPayments, err := db.FetchPayments()\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"payments could not be fetched from \"+\n\t\t\t\t\t\"database: %v\", err)\n\t\t\t}\n\n\t\t\tif len(allPayments) != 6 {\n\t\t\t\tt.Fatalf(\"Number of payments received does not \"+\n\t\t\t\t\t\"match expected one. Got %v, want %v.\",\n\t\t\t\t\tlen(allPayments), 6)\n\t\t\t}\n\n\t\t\tquerySlice, err := db.QueryPayments(tt.query)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"unexpected error: %v\", err)\n\t\t\t}\n\t\t\tif tt.firstIndex != querySlice.FirstIndexOffset ||\n\t\t\t\ttt.lastIndex != querySlice.LastIndexOffset {\n\t\t\t\tt.Errorf(\"First or last index does not match \"+\n\t\t\t\t\t\"expected index. Want (%d, %d), got (%d, %d).\",\n\t\t\t\t\ttt.firstIndex, tt.lastIndex,\n\t\t\t\t\tquerySlice.FirstIndexOffset,\n\t\t\t\t\tquerySlice.LastIndexOffset)\n\t\t\t}\n\n\t\t\tif len(querySlice.Payments) != len(tt.expectedSeqNrs) {\n\t\t\t\tt.Errorf(\"expected: %v payments, got: %v\",\n\t\t\t\t\tlen(allPayments), len(querySlice.Payments))\n\t\t\t}\n\n\t\t\tfor i, seqNr := range tt.expectedSeqNrs {\n\t\t\t\tq := querySlice.Payments[i]\n\t\t\t\tif seqNr != q.SequenceNum {\n\t\t\t\t\tt.Errorf(\"sequence numbers do not match, \"+\n\t\t\t\t\t\t\"got %v, want %v\", q.SequenceNum, seqNr)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n}", "title": "" }, { "docid": "c5e1795b3d47ee4f817f963e2e0fa5c4", "score": "0.49677807", "text": "func (m *MockIssueQuery) Paging(req pb0.PagingIssueRequest) ([]*pb0.Issue, uint64, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Paging\", req)\n\tret0, _ := ret[0].([]*pb0.Issue)\n\tret1, _ := ret[1].(uint64)\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}", "title": "" }, { "docid": "25c27664fc8663b94aecc1dd5abdc722", "score": "0.4967421", "text": "func (m *MockAdapter) ZRevRangeByLex(key string, opt redis.ZRangeBy) ([]string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ZRevRangeByLex\", key, opt)\n\tret0, _ := ret[0].([]string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "9685d51bbf0492f1cb137d907a272a55", "score": "0.49646795", "text": "func (m *RepositoryStore) List(ctx context.Context, pageSize uint, last string) ([]model0.Repository, uint64, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"List\", ctx, pageSize, last)\n\tret0, _ := ret[0].([]model0.Repository)\n\tret1, _ := ret[1].(uint64)\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}", "title": "" }, { "docid": "e7bf59c16cea131426bde9fbb044161d", "score": "0.49537653", "text": "func (_m *IntSysSvc) List(ctx context.Context, pageSize int, cursor string) (model.IntegrationSystemPage, error) {\n\tret := _m.Called(ctx, pageSize, cursor)\n\n\tvar r0 model.IntegrationSystemPage\n\tif rf, ok := ret.Get(0).(func(context.Context, int, string) model.IntegrationSystemPage); ok {\n\t\tr0 = rf(ctx, pageSize, cursor)\n\t} else {\n\t\tr0 = ret.Get(0).(model.IntegrationSystemPage)\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(context.Context, int, string) error); ok {\n\t\tr1 = rf(ctx, pageSize, cursor)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "title": "" }, { "docid": "d04621ae16a240b3efbad1641ec16b7f", "score": "0.49490246", "text": "func (m *MockQuery) Iter() Iter {\n\tret := m.ctrl.Call(m, \"Iter\")\n\tret0, _ := ret[0].(Iter)\n\treturn ret0\n}", "title": "" }, { "docid": "884fd3606706f6929ab2cfa6eb0d19b2", "score": "0.4948987", "text": "func (m *MockInterface) GetThingWithDateRange(ctx context.Context, name string, date strfmt.DateTime) (*v9.ThingWithDateRange, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetThingWithDateRange\", ctx, name, date)\n\tret0, _ := ret[0].(*v9.ThingWithDateRange)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "9ec326ca4ccb3d143185efd5d277b6f9", "score": "0.49478114", "text": "func (m *marble) getPrivateByRange(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tif len(args) != 2 {\n\t\treturn shim.Error(errJson(\"incorrect number of arguments. expecting 2\"))\n\t}\n\n\tstartKey := args[0]\n\tendKey := args[1]\n\n\titerator, err := stub.GetPrivateDataByRange(collectionMarbles, startKey, endKey)\n\tif err != nil {\n\t\treturn shim.Error(errJson(err.Error()))\n\t}\n\tdefer iterator.Close()\n\n\tbuffer, err := constructQueryResponseFromIterator(iterator)\n\tif err != nil {\n\t\treturn shim.Error(errJson(err.Error()))\n\t}\n\n\tlog.Printf(\"getPrivateByRange queryResult:\\n%s\\n\", buffer.String())\n\treturn shim.Success(buffer.Bytes())\n}", "title": "" }, { "docid": "d1ad813ad99b967c748b90b64aa01198", "score": "0.49376285", "text": "func (m *MockInterface) Offset(arg0 interface{}) jorm.Interface {\n\tret := m.ctrl.Call(m, \"Offset\", arg0)\n\tret0, _ := ret[0].(jorm.Interface)\n\treturn ret0\n}", "title": "" }, { "docid": "99b6c447dc98945d0bf96ff8cd95199e", "score": "0.4936932", "text": "func (x *fastReflection_RequestListSnapshots) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {\n}", "title": "" }, { "docid": "b2c705a82620512f97aea20bb6ab6f4e", "score": "0.4915555", "text": "func (m *MockValidStorage) GetAllValidNumbers() []string {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetAllValidNumbers\")\n\tret0, _ := ret[0].([]string)\n\treturn ret0\n}", "title": "" }, { "docid": "6103a408ae5622bc6451bffcad3984fc", "score": "0.4901853", "text": "func (m *MockSortedSetsOperator) ZRemRangeByLex(key, min, max string) (int64, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ZRemRangeByLex\", key, min, max)\n\tret0, _ := ret[0].(int64)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "33670a3188e10443fb383fd18d94e98d", "score": "0.490057", "text": "func do(query string, timeInterval int64, step int64, group string, c ReadClient) []byte {\n\n\tu := c.config.URL\n\tu.Path = u.Path + \"/api/v1/query_range\"\n\tq := u.Query()\n\tq.Set(\"query\", query)\n\tendTime := time.Now().Unix()\n\tq.Set(\"end\", strconv.FormatInt(endTime, 10))\n\tq.Set(\"start\", strconv.FormatInt(endTime - timeInterval, 10))\n\tq.Set(\"step\", strconv.FormatInt(step, 10))\n\n\tu.RawQuery = q.Encode()\n\n\t//fmt.Println(u.String())\n\t// Take random tokens, reproducing proxy with multiple instances having separate tokens\n\ttokens := strings.Split(c.config.HttpBearerToken, \",\")\n\ts := rand.NewSource(time.Now().UnixNano())\n\tr := rand.New(s)\n\tid := r.Intn(len(tokens))\n\tvar http_bearer_token = tokens[id]\n\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\n\tif http_bearer_token != \" \" {\n\t\tvar bearer = \"Bearer \" + http_bearer_token\n\t\treq.Header.Add(\"Authorization\", bearer)\n\t}\n\tresp, err := c.client.Do(req)\n\tif err != nil {\n\t\tfmt.Print(err)\n\t\treturn nil\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tfmt.Printf(\"Non-OK HTTP status for : %d: %s\\n\", resp.StatusCode, u.String())\n\t}\n\tqueryResponseCode.WithLabelValues(group, strconv.Itoa(resp.StatusCode)).Inc()\n\n\tdefer resp.Body.Close()\n\tbodyBytes, err := ioutil.ReadAll(resp.Body)\n\treturn bodyBytes\n}", "title": "" }, { "docid": "f845fad81c1b492557f7e2f458101dd4", "score": "0.48989296", "text": "func getTicketsByRange(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tif len(args) != 2 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 2\")\n\t}\n\n\tstartKey := args[0]\n\tendKey := args[1]\n\n\tresultsIterator, err := stub.GetStateByRange(startKey, endKey)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\t// buffer is a JSON array containing QueryResults\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"[\")\n\n\tbArrayMemberAlreadyWritten := false\n\tfor resultsIterator.HasNext() {\n\t\tpointer, err := resultsIterator.Next()\n\t\tqueryResultKey, queryResultValue := pointer.GetKey(), pointer.GetValue()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\t\t// Add a comma before array members, suppress it for the first array member\n\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\tbuffer.WriteString(\",\")\n\t\t}\n\t\tbuffer.WriteString(\"{\\\"Key\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(queryResultKey)\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"Record\\\":\")\n\t\t// Record is a JSON object, so we write as-is\n\t\tbuffer.WriteString(string(queryResultValue))\n\t\tbuffer.WriteString(\"}\")\n\t\tbArrayMemberAlreadyWritten = true\n\t}\n\tbuffer.WriteString(\"]\")\n\n\tfmt.Printf(\"- getTicketsByRange queryResult:\\n%s\\n\", buffer.String())\n\n\treturn shim.Success(buffer.Bytes())\n}", "title": "" }, { "docid": "8740bfddcb87cad035729e26d4af85e1", "score": "0.4895229", "text": "func (m *MockSortedSetsOperator) ZRangeByLex(key string, opt redis.ZRangeBy) ([]string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ZRangeByLex\", key, opt)\n\tret0, _ := ret[0].([]string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "3d95b7504c04ef14713f3e41fc185f3d", "score": "0.48934793", "text": "func getOffsetBasedPagination(defLimit int32) func(OffsetPaginationInput) (int32, int32) {\n\tif defLimit <= 0 {\n\t\tlog.Fatal(\"the default limit must be greater than zero\")\n\t}\n\n\treturn func(i OffsetPaginationInput) (offset int32, limit int32) {\n\t\tif i.Offset != nil {\n\t\t\toffset = *i.Offset\n\t\t}\n\n\t\tif offset < 0 {\n\t\t\toffset = 0\n\t\t}\n\n\t\tif i.Limit != nil {\n\t\t\tlimit = *i.Limit\n\t\t}\n\n\t\tif limit <= 0 || limit > maxLimit {\n\t\t\tlimit = defLimit\n\t\t}\n\n\t\treturn offset, limit\n\t}\n}", "title": "" }, { "docid": "f2748eb0659415601bf29bb3d30d8a65", "score": "0.48930457", "text": "func (m *MockRepo) ListEntities(ctx context.Context, limit, offset int64) ([]domain.Conference, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ListEntities\", ctx, limit, offset)\n\tret0, _ := ret[0].([]domain.Conference)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "0d60119acd1b92a3f90bf583b183da3a", "score": "0.48911846", "text": "func getCursorBasedPagination(defLimit int32) func(i CursorPaginationInput) (string, string, int32) {\n\tif defLimit <= 0 {\n\t\tlog.Fatal(\"the default limit must be greater than zero\")\n\t}\n\n\treturn func(i CursorPaginationInput) (from string, to string, limit int32) {\n\t\tif i.From != nil {\n\t\t\tfrom = *i.From\n\t\t}\n\n\t\tif i.To != nil {\n\t\t\tto = *i.To\n\t\t}\n\n\t\tif i.Limit != nil {\n\t\t\tlimit = *i.Limit\n\t\t}\n\n\t\tif limit <= 0 || limit > maxLimit {\n\t\t\tlimit = defLimit\n\t\t}\n\n\t\treturn from, to, limit\n\t}\n}", "title": "" }, { "docid": "300f4df2374f6e30d4f9ce6d44ef1c81", "score": "0.48845154", "text": "func (m *MockRawStorage) GetAllRawNumbers() []string {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetAllRawNumbers\")\n\tret0, _ := ret[0].([]string)\n\treturn ret0\n}", "title": "" }, { "docid": "8d649f2d797a82345911b3283c988c64", "score": "0.4879793", "text": "func (m *MockStreamsOperator) XRangeN(stream, start, stop string, count int64) ([]redis.XMessage, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"XRangeN\", stream, start, stop, count)\n\tret0, _ := ret[0].([]redis.XMessage)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "4904a4c54ceafb0f24839f379a971d6a", "score": "0.48797765", "text": "func (m *MockDRaaSService) GetBillingTypesPaginated(arg0 connection.APIRequestParameters) (*draas.PaginatedBillingType, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetBillingTypesPaginated\", arg0)\n\tret0, _ := ret[0].(*draas.PaginatedBillingType)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "7a12d55b9c7e02f4999f4c238a99647d", "score": "0.4878579", "text": "func (s *SmartContract) queryRange(APIstub shim.ChaincodeStubInterface, args []string) sc.Response {\n\tresultsIterator, err := APIstub.GetStateByRange(args[0], args[1])\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\t// buffer is a JSON array containing QueryResults\n\tvar buffer bytes.Buffer\n\n\tbArrayMemberAlreadyWritten := false\n\tfor resultsIterator.HasNext() {\n\t\tqueryResponse, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\t\t// Add a comma before array members, suppress it for the first array member\n\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\tbuffer.WriteString(\",\\n\")\n\t\t}\n\t\tbuffer.WriteString(\"{\\\"Key\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(queryResponse.Key)\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"Record\\\":\")\n\t\t// Record is a JSON object, so we write as-is\n\t\tbuffer.WriteString(string(queryResponse.Value))\n\t\tbuffer.WriteString(\"}\")\n\t\tbArrayMemberAlreadyWritten = true\n\t}\n\n\treturn shim.Success(buffer.Bytes())\n}", "title": "" }, { "docid": "0f1a2b7f5f3dbeaa4f788c0bbafd4718", "score": "0.48719138", "text": "func TestPaginationMiddle(t *testing.T) {\n\tconf := initConf()\n\n\tr := createRequest(t, 6)\n\t// expected pages = 11\n\tp := NewPage(r, 220, conf)\n\n\tfor idx, pg := range p.PageLinks {\n\t\tif idx == 0 {\n\t\t\t// check for first page\n\t\t\tcheckIsPage(t, pg, 1)\n\t\t\tif !pg.First {\n\t\t\t\tt.Errorf(\"Expected to be first page, but got %+v\", pg)\n\t\t\t}\n\t\t\tcontinue\n\t\t} else if idx == 8 {\n\t\t\t// check for last page\n\t\t\tcheckIsPage(t, pg, 11)\n\t\t\tif !pg.Last {\n\t\t\t\tt.Errorf(\"Expected to be last page, but got %+v\", pg)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\n\t\tcheckIsPage(t, pg, idx+2)\n\t}\n}", "title": "" }, { "docid": "cb08af11eff6c518a588ed3d70338bba", "score": "0.48630902", "text": "func (m *MockAdapter) XRevRange(stream, start, stop string) ([]redis.XMessage, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"XRevRange\", stream, start, stop)\n\tret0, _ := ret[0].([]redis.XMessage)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "cf9ed01f3b31df59e2a2d807e16b486b", "score": "0.48611942", "text": "func (dl *downloader) getRange() (start, offset int64) {\n\tdl.mu.Lock()\n\tdefer dl.mu.Unlock()\n\treturn dl.start, dl.offset\n}", "title": "" }, { "docid": "39208bf1a2cca37e02fcfa46f897733c", "score": "0.48541945", "text": "func (m *MockUniversalClient) SetRange(arg0 string, arg1 int64, arg2 string) *redis.IntCmd {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"SetRange\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(*redis.IntCmd)\n\treturn ret0\n}", "title": "" }, { "docid": "e194860051b512c563ee2485938fa008", "score": "0.48524728", "text": "func (m *MockStringsOperator) SetRange(key string, offset int64, value string) (int64, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"SetRange\", key, offset, value)\n\tret0, _ := ret[0].(int64)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "a7c5e9adbb7bef63af4629d40371f23f", "score": "0.4848934", "text": "func TestStoreRangesByKey(t *testing.T) {\n\tstore, _ := createTestStore(false, t)\n\tdefer store.Close()\n\n\tr1 := addTestRange(store, engine.Key(\"A\"), engine.Key(\"C\"), t)\n\tr2 := addTestRange(store, engine.Key(\"C\"), engine.Key(\"X\"), t)\n\tr3 := addTestRange(store, engine.Key(\"X\"), engine.Key(\"ZZ\"), t)\n\n\tif store.LookupRange(engine.Key(\"a\"), nil) != nil {\n\t\tt.Errorf(\"expected \\\"a\\\" to not have an associated range\")\n\t}\n\tif r := store.LookupRange(engine.Key(\"B\"), nil); r != r1 {\n\t\tt.Errorf(\"mismatched range %+v != %+v\", r, r1.Meta)\n\t}\n\tif r := store.LookupRange(engine.Key(\"C\"), nil); r != r2 {\n\t\tt.Errorf(\"mismatched range %+v != %+v\", r, r2.Meta)\n\t}\n\tif r := store.LookupRange(engine.Key(\"M\"), nil); r != r2 {\n\t\tt.Errorf(\"mismatched range %+v != %+v\", r, r2.Meta)\n\t}\n\tif r := store.LookupRange(engine.Key(\"X\"), nil); r != r3 {\n\t\tt.Errorf(\"mismatched range %+v != %+v\", r, r3.Meta)\n\t}\n\tif r := store.LookupRange(engine.Key(\"Z\"), nil); r != r3 {\n\t\tt.Errorf(\"mismatched range %+v != %+v\", r, r3.Meta)\n\t}\n\tif store.LookupRange(engine.KeyMax, nil) != nil {\n\t\tt.Errorf(\"expected engine.KeyMax to not have an associated range\")\n\t}\n}", "title": "" }, { "docid": "a7c5e9adbb7bef63af4629d40371f23f", "score": "0.4848934", "text": "func TestStoreRangesByKey(t *testing.T) {\n\tstore, _ := createTestStore(false, t)\n\tdefer store.Close()\n\n\tr1 := addTestRange(store, engine.Key(\"A\"), engine.Key(\"C\"), t)\n\tr2 := addTestRange(store, engine.Key(\"C\"), engine.Key(\"X\"), t)\n\tr3 := addTestRange(store, engine.Key(\"X\"), engine.Key(\"ZZ\"), t)\n\n\tif store.LookupRange(engine.Key(\"a\"), nil) != nil {\n\t\tt.Errorf(\"expected \\\"a\\\" to not have an associated range\")\n\t}\n\tif r := store.LookupRange(engine.Key(\"B\"), nil); r != r1 {\n\t\tt.Errorf(\"mismatched range %+v != %+v\", r, r1.Meta)\n\t}\n\tif r := store.LookupRange(engine.Key(\"C\"), nil); r != r2 {\n\t\tt.Errorf(\"mismatched range %+v != %+v\", r, r2.Meta)\n\t}\n\tif r := store.LookupRange(engine.Key(\"M\"), nil); r != r2 {\n\t\tt.Errorf(\"mismatched range %+v != %+v\", r, r2.Meta)\n\t}\n\tif r := store.LookupRange(engine.Key(\"X\"), nil); r != r3 {\n\t\tt.Errorf(\"mismatched range %+v != %+v\", r, r3.Meta)\n\t}\n\tif r := store.LookupRange(engine.Key(\"Z\"), nil); r != r3 {\n\t\tt.Errorf(\"mismatched range %+v != %+v\", r, r3.Meta)\n\t}\n\tif store.LookupRange(engine.KeyMax, nil) != nil {\n\t\tt.Errorf(\"expected engine.KeyMax to not have an associated range\")\n\t}\n}", "title": "" }, { "docid": "514704b0b87424d3a8799fbeae07dd1f", "score": "0.48458055", "text": "func TestSearch(t *testing.T) {\n\ttestCase := []struct {\n\t\tname string\n\t\tapiKey string\n\t\tmockDBFirst func(out interface{}, filters interface{}) error\n\t\tapiClient models.ApiClient\n\t\terr error\n\t}{\n\t\t{\n\t\t\tname: \"error-on-search\",\n\t\t\tapiKey: \"test\",\n\t\t\tmockDBFirst: func(out interface{}, filters interface{}) error {\n\t\t\t\treturn errors.New(\"dummy error\")\n\t\t\t},\n\t\t\tapiClient: models.ApiClient{},\n\t\t\terr: errors.New(\"dummy error\"),\n\t\t},\n\t\t{\n\t\t\tname: \"error-on-length\",\n\t\t\tapiKey: \"test\",\n\t\t\tmockDBFirst: func(out interface{}, filters interface{}) error {\n\t\t\t\treturn errors.New(ErrNoData)\n\t\t\t},\n\t\t\tapiClient: models.ApiClient{},\n\t\t\terr: errors.New(ErrNoData),\n\t\t},\n\t\t{ // update this test case once the above TODO is resolved\n\t\t\tname: \"success\",\n\t\t\tapiKey: \"test\",\n\t\t\tmockDBFirst: func(out interface{}, filters interface{}) (err error) {\n\t\t\t\treturn\n\t\t\t},\n\t\t\tapiClient: models.ApiClient{},\n\t\t\terr: errors.New(ErrNoData),\n\t\t},\n\t}\n\n\treader := impl.Read\n\tmockCtrl := gomock.NewController(t)\n\tdefer func() {\n\t\timpl.Read = reader\n\t\tmockCtrl.Finish()\n\t}()\n\n\tmockReader := mockimpl.NewMockReader(mockCtrl)\n\timpl.Read = mockReader\n\n\t//t.Parallel()\n\tctx := context.Background()\n\tfor _, tc := range testCase {\n\t\tt.Run(tc.name, func(t *testing.T) {\n\t\t\tmockReader.EXPECT().First(gomock.Any(), gomock.Any()).Return(tc.mockDBFirst(gomock.Any(), gomock.Any()))\n\t\t\tapiClient, err := ApiClient.Search(ctx, tc.apiKey)\n\t\t\tassert.Equal(t, tc.apiClient, apiClient)\n\t\t\tassert.Equal(t, tc.err, err)\n\t\t})\n\t}\n}", "title": "" }, { "docid": "4938b718a846de30bbf49d1d972c793f", "score": "0.4838024", "text": "func (e *MockDynamoDB) QueryPages(input *dynamodb.QueryInput, fn func(*dynamodb.QueryOutput, bool) bool) error {\n\tif len(e.dynaMock.QueryExpect) > 0 {\n\t\tx := e.dynaMock.QueryExpect[0] //get first element of expectation\n\n\t\tif x.table != nil {\n\t\t\tif *x.table != *input.TableName {\n\t\t\t\treturn fmt.Errorf(\"Expect table %s but found table %s\", *x.table, *input.TableName)\n\t\t\t}\n\t\t}\n\n\t\t// delete first element of expectation\n\t\te.dynaMock.QueryExpect = append(e.dynaMock.QueryExpect[:0], e.dynaMock.QueryExpect[1:]...)\n\n\t\tfn(x.output, true)\n\t\treturn nil\n\t}\n\n\treturn fmt.Errorf(\"Query Table By Page Expectation Not Found\")\n}", "title": "" }, { "docid": "37c0486881b6d4618c6d8bbb7daa7e0f", "score": "0.48324236", "text": "func (m *MockInteractor) GetAll(ctx context.Context) (entity.UserSlice, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetAll\", ctx)\n\tret0, _ := ret[0].(entity.UserSlice)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "22f045b405d75d0af87a0a693a65167e", "score": "0.4830555", "text": "func (m *MockUniversalClient) ZRemRangeByLex(arg0, arg1, arg2 string) *redis.IntCmd {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ZRemRangeByLex\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(*redis.IntCmd)\n\treturn ret0\n}", "title": "" }, { "docid": "6ea9a9c38c613619357b0b499ca4e8bd", "score": "0.48281357", "text": "func (m *MockRepository) Get(ctx []tm.GetContext, size, offset int64) ([]tm.TokenMetadata, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Get\", ctx, size, offset)\n\tret0, _ := ret[0].([]tm.TokenMetadata)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "6dcc823a0ff726c44930adf0a53af328", "score": "0.4822501", "text": "func (m *MockRepository) GetWithEvents() ([]tzip.TZIP, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetWithEvents\")\n\tret0, _ := ret[0].([]tzip.TZIP)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "8b4d9bdcfa0669401899ff1e802be566", "score": "0.48180807", "text": "func (m *MockClientAPI) List(arg0 context.Context) (subscriptions.ListResultPage, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"List\", arg0)\n\tret0, _ := ret[0].(subscriptions.ListResultPage)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "326ec164c73730148188765791a26f82", "score": "0.48151487", "text": "func (m *MockSyncState) All(epoch int64) ([]state.State, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"All\", epoch)\n\tret0, _ := ret[0].([]state.State)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "5695f6ed6c67ff7b1493f659fb771d54", "score": "0.4811425", "text": "func (_m *Mockdatabase) ReadEncoded(ctx context.Context, namespace ident.ID, id ident.ID, start time.Time, end time.Time) ([][]xio.SegmentReader, error) {\n\tret := _m.ctrl.Call(_m, \"ReadEncoded\", ctx, namespace, id, start, end)\n\tret0, _ := ret[0].([][]xio.SegmentReader)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "301be408bd6ae52c5d9455df46bd9321", "score": "0.48085415", "text": "func (s *TestRPCControlSuite) testRPCControlLock(c *testing.T) {\n\texpectedResult := []lockStateCase{\n\t\t// Test case - 1.\n\t\t// Case where 10 read locks are held.\n\t\t// Entry for any of the 10 reads locks has to be found.\n\t\t// Since they held in a loop, Lock origin for first 10 read locks (opsID 0-9) should be the same.\n\t\t{\n\n\t\t\tvolume: \"my-bucket\",\n\t\t\tpath: \"my-object\",\n\t\t\topsID: \"0\",\n\t\t\treadLock: true,\n\t\t\tlockOrigin: \"[lock held] in github.com/minio/minio/cmd.TestLockStats[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:298]\",\n\t\t\t// expected metrics.\n\t\t\texpectedErr: nil,\n\t\t\texpectedLockStatus: \"Running\",\n\n\t\t\texpectedGlobalLockCount: 10,\n\t\t\texpectedRunningLockCount: 10,\n\t\t\texpectedBlockedLockCount: 0,\n\n\t\t\texpectedVolPathLockCount: 10,\n\t\t\texpectedVolPathRunningCount: 10,\n\t\t\texpectedVolPathBlockCount: 0,\n\t\t},\n\t\t// Test case 2.\n\t\t// Testing the existence of entry for the last read lock (read lock with opsID \"9\").\n\t\t{\n\n\t\t\tvolume: \"my-bucket\",\n\t\t\tpath: \"my-object\",\n\t\t\topsID: \"9\",\n\t\t\treadLock: true,\n\t\t\tlockOrigin: \"[lock held] in github.com/minio/minio/cmd.TestLockStats[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:298]\",\n\t\t\t// expected metrics.\n\t\t\texpectedErr: nil,\n\t\t\texpectedLockStatus: \"Running\",\n\n\t\t\texpectedGlobalLockCount: 10,\n\t\t\texpectedRunningLockCount: 10,\n\t\t\texpectedBlockedLockCount: 0,\n\n\t\t\texpectedVolPathLockCount: 10,\n\t\t\texpectedVolPathRunningCount: 10,\n\t\t\texpectedVolPathBlockCount: 0,\n\t\t},\n\n\t\t// Test case 3.\n\t\t// Hold a write lock, and it should block since 10 read locks\n\t\t// on <\"my-bucket\", \"my-object\"> are still held.\n\t\t{\n\n\t\t\tvolume: \"my-bucket\",\n\t\t\tpath: \"my-object\",\n\t\t\topsID: \"10\",\n\t\t\treadLock: false,\n\t\t\tlockOrigin: \"[lock held] in github.com/minio/minio/cmd.TestLockStats[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:298]\",\n\t\t\t// expected metrics.\n\t\t\texpectedErr: nil,\n\t\t\texpectedLockStatus: \"Blocked\",\n\n\t\t\texpectedGlobalLockCount: 11,\n\t\t\texpectedRunningLockCount: 10,\n\t\t\texpectedBlockedLockCount: 1,\n\n\t\t\texpectedVolPathLockCount: 11,\n\t\t\texpectedVolPathRunningCount: 10,\n\t\t\texpectedVolPathBlockCount: 1,\n\t\t},\n\n\t\t// Test case 4.\n\t\t// Expected result when all the read locks are released and the blocked write lock acquires the lock.\n\t\t{\n\n\t\t\tvolume: \"my-bucket\",\n\t\t\tpath: \"my-object\",\n\t\t\topsID: \"10\",\n\t\t\treadLock: false,\n\t\t\tlockOrigin: \"[lock held] in github.com/minio/minio/cmd.TestLockStats[/Users/hackintoshrao/mycode/go/src/github.com/minio/minio/cmd/namespace-lock_test.go:298]\",\n\t\t\t// expected metrics.\n\t\t\texpectedErr: nil,\n\t\t\texpectedLockStatus: \"Running\",\n\n\t\t\texpectedGlobalLockCount: 1,\n\t\t\texpectedRunningLockCount: 1,\n\t\t\texpectedBlockedLockCount: 0,\n\n\t\t\texpectedVolPathLockCount: 1,\n\t\t\texpectedVolPathRunningCount: 1,\n\t\t\texpectedVolPathBlockCount: 0,\n\t\t},\n\t\t// Test case - 5.\n\t\t// At the end after locks are released, its verified whether the counters are set to 0.\n\t\t{\n\n\t\t\tvolume: \"my-bucket\",\n\t\t\tpath: \"my-object\",\n\t\t\t// expected metrics.\n\t\t\texpectedErr: nil,\n\t\t\texpectedLockStatus: \"Blocked\",\n\n\t\t\texpectedGlobalLockCount: 0,\n\t\t\texpectedRunningLockCount: 0,\n\t\t\texpectedBlockedLockCount: 0,\n\t\t},\n\t}\n\n\t// used to make sure that the tests don't end till locks held in other go routines are released.\n\tvar wg sync.WaitGroup\n\n\t// Hold 5 read locks. We should find the info about these in the RPC response.\n\n\t// hold 10 read locks.\n\t// Then call the RPC control end point for obtaining lock instrumentation info.\n\n\tfor i := 0; i < 10; i++ {\n\t\tnsMutex.RLock(\"my-bucket\", \"my-object\", strconv.Itoa(i))\n\t}\n\n\tclient := newAuthClient(s.testAuthConf)\n\tdefer client.Close()\n\n\targs := &GenericArgs{}\n\treply := make(map[string]*SystemLockState)\n\t// Call the lock instrumentation RPC end point.\n\terr := client.Call(\"Control.LockInfo\", args, &reply)\n\tif err != nil {\n\t\tc.Errorf(\"Add: expected no error but got string %q\", err.Error())\n\t}\n\t// expected lock info.\n\texpectedLockStats := expectedResult[0]\n\t// verify the actual lock info with the expected one.\n\t// verify the existence entry for first read lock (read lock with opsID \"0\").\n\tverifyRPCLockInfoResponse(expectedLockStats, reply, c, 1)\n\texpectedLockStats = expectedResult[1]\n\t// verify the actual lock info with the expected one.\n\t// verify the existence entry for last read lock (read lock with opsID \"9\").\n\tverifyRPCLockInfoResponse(expectedLockStats, reply, c, 2)\n\n\t// now hold a write lock in a different go routine and it should block since 10 read locks are\n\t// still held.\n\twg.Add(1)\n\tgo func() {\n\t\tdefer wg.Done()\n\t\t// blocks till all read locks are released.\n\t\tnsMutex.Lock(\"my-bucket\", \"my-object\", strconv.Itoa(10))\n\t\t// Once the above attempt to lock is unblocked/acquired, we verify the stats and release the lock.\n\t\texpectedWLockStats := expectedResult[3]\n\t\t// Since the write lock acquired here, the number of blocked locks should reduce by 1 and\n\t\t// count of running locks should increase by 1.\n\n\t\t// Call the RPC control handle to fetch the lock instrumentation info.\n\t\treply = make(map[string]*SystemLockState)\n\t\t// Call the lock instrumentation RPC end point.\n\t\terr = client.Call(\"Control.LockInfo\", args, &reply)\n\t\tif err != nil {\n\t\t\tc.Errorf(\"Add: expected no error but got string %q\", err.Error())\n\t\t}\n\t\tverifyRPCLockInfoResponse(expectedWLockStats, reply, c, 4)\n\n\t\t// release the write lock.\n\t\tnsMutex.Unlock(\"my-bucket\", \"my-object\", strconv.Itoa(10))\n\n\t}()\n\t// waiting for a second so that the attempt to acquire the write lock in\n\t// the above go routines gets blocked.\n\ttime.Sleep(1 * time.Second)\n\t// The write lock should have got blocked by now,\n\t// check whether the entry for one blocked lock exists.\n\texpectedLockStats = expectedResult[2]\n\n\t// Call the RPC control handle to fetch the lock instrumentation info.\n\treply = make(map[string]*SystemLockState)\n\t// Call the lock instrumentation RPC end point.\n\terr = client.Call(\"Control.LockInfo\", args, &reply)\n\tif err != nil {\n\t\tc.Errorf(\"Add: expected no error but got string %q\", err.Error())\n\t}\n\tverifyRPCLockInfoResponse(expectedLockStats, reply, c, 3)\n\t// Release all the read locks held.\n\t// the blocked write lock in the above go routines should get unblocked.\n\tfor i := 0; i < 10; i++ {\n\t\tnsMutex.RUnlock(\"my-bucket\", \"my-object\", strconv.Itoa(i))\n\t}\n\twg.Wait()\n\t// Since all the locks are released. There should not be any entry in the lock info.\n\t// and all the counters should be set to 0.\n\treply = make(map[string]*SystemLockState)\n\t// Call the lock instrumentation RPC end point.\n\terr = client.Call(\"Control.LockInfo\", args, &reply)\n\tif err != nil {\n\t\tc.Errorf(\"Add: expected no error but got string %q\", err.Error())\n\t}\n\n\tfor _, rpcLockInfo := range reply {\n\t\tif rpcLockInfo.TotalAcquiredLocks != 0 && rpcLockInfo.TotalLocks != 0 && rpcLockInfo.TotalBlockedLocks != 0 {\n\t\t\tc.Fatalf(\"The counters are not reset properly after all locks are released\")\n\t\t}\n\t\tif len(rpcLockInfo.LocksInfoPerObject) != 0 {\n\t\t\tc.Fatalf(\"Since all locks are released there shouldn't have been any lock info entry, but found %d\", len(rpcLockInfo.LocksInfoPerObject))\n\t\t}\n\t}\n}", "title": "" }, { "docid": "d19f1f8b79c0e6d06e0c382593695ab3", "score": "0.48081663", "text": "func TestCRUDGetEntitiesCPOrderByAscLimitOffset(t *testing.T) {\n\n\t// type GetCmdTest struct {\n\t// \tID uint64 `db:\"id\" json:\"id\" sqac:\"primary_key:inc;start:90000000\"`\n\t// \tFldOneInt int `db:\"fld_one_int\" json:\"fld_one_int\" sqac:\"nullable:false;default:0\"`\n\t// \tTimeNow time.Time `db:\"time_now\" json:\"time_now\" sqac:\"nullable:false;default:now();index:unique\"`\n\t// \tFldTwoString string `db:\"fld_two_string\" json:\"fld_two_string\" sqac:\"nullable:false;default:YYC\"`\n\t// \tFldThreeFloat float64 `db:\"fld_three_float\" json:\"fld_three_float\" sqac:\"nullable:false;default:0.0\"`\n\t// \tFldFourBool bool `db:\"fld_four_bool\" json:\"fld_four_bool\" sqac:\"nullable:false;default:false\"`\n\t// \tNonPersistentColumn string `db:\"non_persistent_column\" sqac:\"-\"`\n\t// \tFldFiveString *string `db:\"fld_five_string\" json:\"fld_five_string\" sqac:\"nullable:true\"`\n\t// \tFldSixFloat *float64 `db:\"fld_six_float\" json:\"fld_six_float\" sqac:\"nullable:true\"`\n\t// \tFldSevenBool *bool `db:\"fld_seven_bool\" json:\"fld_seven_bool\" sqac:\"nullable:true\"`\n\t// }\n\n\t// determine the table names as per the table creation logic\n\ttn := common.GetTableName(GetCmdTest{})\n\n\t// drop table getcmdtest\n\terr := Handle.DropTables(GetCmdTest{})\n\tif err != nil {\n\t\tt.Errorf(\"%s\", err.Error())\n\t}\n\n\t// create table getcmdtest\n\terr = Handle.CreateTables(GetCmdTest{})\n\tif err != nil {\n\t\tt.Errorf(\"%s\", err.Error())\n\t}\n\n\t// expect that table getcmdtest exists\n\tif !Handle.ExistsTable(tn) {\n\t\tt.Errorf(\"table %s does not exist\", tn)\n\t}\n\n\t// create the test records\n\tcreateGetCmdTestRecs(t)\n\n\t// set $orderby=name$descending$limit=3$offset=2\n\tcmdMap := make(map[string]interface{})\n\tcmdMap[\"orderby\"] = \"fld_two_string\"\n\tcmdMap[\"asc\"] = nil\n\tcmdMap[\"limit\"] = 3\n\tcmdMap[\"offset\"] = 2\n\n\t// create a slice to read into\n\trecRead := []GetCmdTest{}\n\n\t// call with no parameters and no commands\n\t_, err = Handle.GetEntitiesCP(&recRead, nil, cmdMap)\n\tif err != nil {\n\t\tt.Errorf(\"error: TestCRUDGetEntitiesCPOrderByAscLimitOffset: %v\", err)\n\t}\n\n\tif len(recRead) != 3 {\n\t\tt.Errorf(\"error: TestCRUDGetEntitiesCPOrderByAscLimitOffset: expected 3 records, got: %v\", len(recRead))\n\t}\n\tif len(recRead) > 0 {\n\t\tif recRead[0].ID != 90000002 {\n\t\t\tt.Errorf(\"error: TestCRUDGetEntitiesCPOrderByAscLimitOffset: expected result[0] record with key ID == 90000002 got: %v\", recRead[0].ID)\n\t\t}\n\t} else {\n\t\tt.Errorf(\"error: TestCRUDGetEntitiesCPOrderByAscLimitOffset: expected 3 records, got: %v\", len(recRead))\n\t}\n\tif len(recRead) == 3 {\n\t\tif recRead[2].ID != 90000004 {\n\t\t\tt.Errorf(\"error: TestCRUDGetEntitiesCPOrderByAscLimitOffset: expected result[2] record with key ID == 90000004 got: %v\", recRead[2].ID)\n\t\t}\n\t} else {\n\t\tt.Errorf(\"error: TestCRUDGetEntitiesCPOrderByAscLimitOffset: expected 3 records, got: %v\", len(recRead))\n\t}\n\n\t// drop table getcmdtest\n\terr = Handle.DropTables(GetCmdTest{})\n\tif err != nil {\n\t\tt.Errorf(\"%s\", err.Error())\n\t}\n}", "title": "" }, { "docid": "a7fb43ce3b307987b456646a5e66286f", "score": "0.48073614", "text": "func (m *MockInvoicesService) List() (*do.InvoiceList, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"List\")\n\tret0, _ := ret[0].(*do.InvoiceList)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "e24df3a0d313979f365591b0e9772079", "score": "0.47913352", "text": "func TestListValidResponseWithParams(t *testing.T, router *mux.Router, path, entity, accessToken string, items []interface{}, assertExpectations func(), params map[string]string) {\n\tu, err := url.Parse(fmt.Sprintf(\"http://1.2.3.4/v1/%s\", path))\n\tassert.NoError(t, err)\n\n\t// add any params\n\tfor k, v := range params {\n\t\tq := u.Query()\n\t\tq.Set(k, v)\n\t\tu.RawQuery = q.Encode()\n\t}\n\n\t// Prepare a request\n\tr, err := http.NewRequest(\n\t\t\"GET\",\n\t\tu.String(),\n\t\tnil,\n\t)\n\tassert.NoError(t, err)\n\n\tif accessToken != \"\" {\n\t\tr.Header.Set(\"Authorization\", fmt.Sprintf(\"Bearer %s\", accessToken))\n\t}\n\n\t// And serve the request\n\tw := httptest.NewRecorder()\n\trouter.ServeHTTP(w, r)\n\n\t// Check that the mock object expectations were met\n\tassertExpectations()\n\n\t// Check the status code\n\tassert.Equal(t, http.StatusOK, w.Code)\n\n\tbaseURI := u.RequestURI()\n\n\tq := u.Query()\n\tq.Set(\"page\", \"1\")\n\tu.RawQuery = q.Encode()\n\n\tpagedURI := u.RequestURI()\n\n\texpected := &response.ListResponse{\n\t\tHal: jsonhal.Hal{\n\t\t\tLinks: map[string]*jsonhal.Link{\n\t\t\t\t\"self\": {\n\t\t\t\t\tHref: baseURI,\n\t\t\t\t},\n\t\t\t\t\"first\": {\n\t\t\t\t\tHref: pagedURI,\n\t\t\t\t},\n\t\t\t\t\"last\": {\n\t\t\t\t\tHref: pagedURI,\n\t\t\t\t},\n\t\t\t\t\"prev\": new(jsonhal.Link),\n\t\t\t\t\"next\": new(jsonhal.Link),\n\t\t\t},\n\t\t\tEmbedded: map[string]jsonhal.Embedded{\n\t\t\t\tentity: jsonhal.Embedded(items),\n\t\t\t},\n\t\t},\n\t\tCount: uint(len(items)),\n\t\tPage: 1,\n\t}\n\texpectedJSON, err := json.Marshal(expected)\n\n\tif assert.NoError(t, err, \"JSON marshalling failed\") {\n\t\tTestResponseBody(t, w, string(expectedJSON))\n\t}\n}", "title": "" }, { "docid": "28be8f98586a89db001637a245b44ce8", "score": "0.47856736", "text": "func (m *MockEndpointsSet) List(filterResource ...func(*v1.Endpoints) bool) []*v1.Endpoints {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{}\n\tfor _, a := range filterResource {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"List\", varargs...)\n\tret0, _ := ret[0].([]*v1.Endpoints)\n\treturn ret0\n}", "title": "" }, { "docid": "7863f2e077792eb553cb8f3b40892c3c", "score": "0.4777411", "text": "func (m *MockOps) ListLimitRange(arg0 string, arg1 v11.ListOptions) (*v1.LimitRangeList, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ListLimitRange\", arg0, arg1)\n\tret0, _ := ret[0].(*v1.LimitRangeList)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" }, { "docid": "44a3bd2020b30ca83a397a2ce087507c", "score": "0.47755384", "text": "func TestGetAllEndpoints(t *testing.T) {\n\tlc := LocationCache{}\n\tnodeName := nodes[0]\n\teplist := []v1.Endpoints{\n\t\t{\n\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\tName: \"ep1\",\n\t\t\t\tNamespace: \"default\",\n\t\t\t},\n\t\t\tSubsets: []v1.EndpointSubset{\n\t\t\t\t{\n\t\t\t\t\tAddresses: []v1.EndpointAddress{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIP: \"10.0.0.1\",\n\t\t\t\t\t\t\tNodeName: &nodeName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIP: \"10.0.0.2\",\n\t\t\t\t\t\t\tNodeName: &nodeName,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\tName: \"ep2\",\n\t\t\t\tNamespace: \"default\",\n\t\t\t},\n\t\t\tSubsets: []v1.EndpointSubset{\n\t\t\t\t{\n\t\t\t\t\tAddresses: []v1.EndpointAddress{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIP: \"10.0.0.3\",\n\t\t\t\t\t\t\tNodeName: &nodeName,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIP: \"10.0.0.4\",\n\t\t\t\t\t\t\tNodeName: &nodeName,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tfor _, ep := range eplist {\n\t\tlc.endpoints.Store(ep.GetNamespace()+\"/\"+ep.GetName(), ep)\n\t}\n\n\tt.Run(\"TestGetAllEndpoints() Case: Get all endpoints\", func(t *testing.T) {\n\t\tgot := lc.GetAllEndpoints()\n\t\tif len(got) != len(eplist) {\n\t\t\tt.Errorf(\"Manager.TestGetAllEndpoints() case failed: len(got): %v, len(eplist): %v\", len(got), len(eplist))\n\t\t}\n\t\tm := map[string]v1.Endpoints{}\n\t\tfor _, ep := range got {\n\t\t\tm[ep.GetNamespace()+\"/\"+ep.GetName()] = ep\n\t\t}\n\n\t\tfor _, ep := range eplist {\n\t\t\tif _, ok := m[ep.GetNamespace()+\"/\"+ep.GetName()]; !ok {\n\t\t\t\tt.Errorf(\"Manager.TestGetAllEndpoints() case failed: endpoints not exist in GetAllEndpoints() result. got: %v want: %v \", got, ep)\n\t\t\t}\n\t\t}\n\t})\n}", "title": "" }, { "docid": "de49e2acaf1b3b6b103ca3550a83f082", "score": "0.47678936", "text": "func (m *MockIndexServiceInterface) Get() func(*gin.Context) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Get\")\n\tret0, _ := ret[0].(func(*gin.Context))\n\treturn ret0\n}", "title": "" }, { "docid": "1d3e3174eba1f09154dfbcf72657873a", "score": "0.47625083", "text": "func (m *MockResourceSkusClientAPI) List(arg0 context.Context, arg1 string) (compute.ResourceSkusResultPage, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"List\", arg0, arg1)\n\tret0, _ := ret[0].(compute.ResourceSkusResultPage)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "title": "" } ]
a4d9728d60ec58b9d91d88156ddfec87
GitInit inits a new git project.
[ { "docid": "3fb41f1c88d5d4ab2d42e19e33818181", "score": "0.8114707", "text": "func GitInit(tb testing.TB) {\n\ttb.Helper()\n\tout, err := fakeGit(\"init\")\n\trequire.NoError(tb, err)\n\trequire.Contains(tb, out, \"Initialized empty Git repository\")\n\trequire.NoError(tb, err)\n\tGitCheckoutBranch(tb, \"main\")\n\t_, _ = fakeGit(\"branch\", \"-D\", \"master\")\n}", "title": "" } ]
[ { "docid": "47ecc48d7d0be5bbdc8f4224dbfd108b", "score": "0.82126087", "text": "func gitInit(_ *cli.Context) error {\n\n\terr := exec.Command(\"git\", \"init\").Run()\n\tcheckErr(err)\n\treturn nil\n}", "title": "" }, { "docid": "be4af00b0431e9f5020d36789dc3f50d", "score": "0.8021736", "text": "func gitInit(t testing.TB, dir string) {\n\tt.Helper()\n\tmustHaveGit(t)\n\n\tif _, err := run(t, dir, \"git\", \"init\"); err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif _, err := run(t, dir, \"git\", \"config\", \"user.name\", \"Go Gopher\"); err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif _, err := run(t, dir, \"git\", \"config\", \"user.email\", \"gopher@golang.org\"); err != nil {\n\t\tt.Fatal(err)\n\t}\n}", "title": "" }, { "docid": "933eddd56963d11abd2c46e40b3be5f5", "score": "0.7972631", "text": "func (c *Commander) gitInit() error {\n\tc.cmd = exec.Command(\"git\", \"init\")\n\tc.cmd.Stdin, c.cmd.Stdout, c.cmd.Stderr = os.Stdin, os.Stdout, os.Stderr\n\tif err := c.cmd.Run(); err != nil {\n\t\treturn err\n\t}\n\n\tif err := c.addRemote(); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "4c5ac5f5349b56278b30fb1e79700583", "score": "0.750197", "text": "func initGitRepo (dir string) (error) {\n\t// TODO revise so that we can specify the cwd for the command\n\t_, err := exec.Command(\"git\", \"init\").Output()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "78104fab7f87d27eece0c641cccf8588", "score": "0.74810123", "text": "func (git *Git) Init() error {\n\tif s, err := os.Stat(filepath.Join(git.root, \".git\")); err == nil && s.IsDir() {\n\t\t// Repository was already created\n\t\treturn nil\n\t}\n\n\tout, err := git.Exec(\"init\")\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"Cannot init Git repository at '%s': %s\", git.canonRoot(), out)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "870604f6a74beda9ad94a427331358ec", "score": "0.721532", "text": "func (c *Config) GitInit() {\n\tfor _, service := range c.Services {\n\t\tif service.Name != \"BDD\" {\n\t\t\tfor k := range service.Values {\n\t\t\t\tdir := filepath.Join(c.ProjectName, service.Values[k])\n\t\t\t\tif _, err := os.Stat(dir + \"/.git\"); !os.IsNotExist(err) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\trepo, err := git.PlainInit(dir, false)\n\t\t\t\tif err != nil {\n\t\t\t\t\tfmt.Println(err)\n\t\t\t\t}\n\n\t\t\t\tvalue := \"\"\n\t\t\t\tprompt := &survey.Select{\n\t\t\t\t\tMessage: \"Il y a-t-il un repo GitLab pour le \" + service.Name + \"/\" + service.Values[k] + \" ?\",\n\t\t\t\t\tOptions: []string{\"Oui\", \"Non\"},\n\t\t\t\t}\n\t\t\t\tsurvey.AskOne(prompt, &value)\n\n\t\t\t\tif value == \"Oui\" {\n\t\t\t\t\tvar urlGitlab string\n\t\t\t\t\tprompt := &survey.Input{\n\t\t\t\t\t\tMessage: \"Entrer l'URL http GitLab\",\n\t\t\t\t\t}\n\t\t\t\t\tsurvey.AskOne(prompt, &urlGitlab)\n\n\t\t\t\t\t_, err = repo.CreateRemote(&config.RemoteConfig{\n\t\t\t\t\t\tName: \"origin\",\n\t\t\t\t\t\tURLs: []string{urlGitlab},\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "title": "" }, { "docid": "0dd57fcc0d60c5975c5545259cc7d1e9", "score": "0.71050245", "text": "func (repo *TestRepo) Init(t *testing.T, bare bool) {\n\tt.Helper()\n\n\t// Don't use `GitCommand()` because the directory might not\n\t// exist yet:\n\tvar cmd *exec.Cmd\n\tif bare {\n\t\t//nolint:gosec // `repo.Path` is a path that we created.\n\t\tcmd = exec.Command(\"git\", \"init\", \"--bare\", repo.Path)\n\t} else {\n\t\t//nolint:gosec // `repo.Path` is a path that we created.\n\t\tcmd = exec.Command(\"git\", \"init\", repo.Path)\n\t}\n\tcmd.Env = CleanGitEnv()\n\terr := cmd.Run()\n\trequire.NoError(t, err)\n}", "title": "" }, { "docid": "d54029e1a809337d9d59b501266a62c7", "score": "0.70789254", "text": "func (g *GitLocal) Init(dir string) error {\n\treturn g.GitCLI.Init(dir)\n}", "title": "" }, { "docid": "c1f22f159cd2b90f3e5d131d05a01407", "score": "0.7026881", "text": "func Init(path string, args ...string) (res *Repo, err error) {\n\tcmd, _, stderr := Git(\"init\", append(args, path)...)\n\tif err = cmd.Run(); err != nil {\n\t\treturn nil, errors.New(stderr.String())\n\t}\n\tres, err = Open(path)\n\treturn\n}", "title": "" }, { "docid": "15fea1272cd49709a08f85697dff559f", "score": "0.6684927", "text": "func NewGit(c *Config) *Git {\n\tif c.GitPath == \"\" {\n\t\t// Git is optional\n\t\treturn nil\n\t}\n\treturn &Git{c.GitPath, c.HomePath}\n}", "title": "" }, { "docid": "3f979e820bb88cd2fff605b807d867f8", "score": "0.6640921", "text": "func Init(projectPath string, commit git.CallbackAddAndCommit, step int) error {\n\tpattern := filepath.Join(\"./golangci/tmpl\", \"*.tmpl\")\n\ttmpl, err := template.ParseGlob(pattern)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to load templates: %s\", err)\n\t}\n\n\tfilename := filepath.Join(projectPath, \".golangci.json\")\n\tfile, err := os.Create(filename)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create golangci config: %s\", err)\n\t}\n\tdefer func() {\n\t\t_ = file.Close()\n\t}()\n\n\tif err = tmpl.ExecuteTemplate(file, \"golangci\", nil); err != nil {\n\t\treturn fmt.Errorf(\"failed to parse template: %s\", err)\n\t}\n\n\treturn commit([]string{filename}, \"added config for golangci\", step)\n}", "title": "" }, { "docid": "c62f3fac22ec226e3bc95a6e241ca9c3", "score": "0.63584125", "text": "func Init(repo, ref string) (*DB, error) {\n\tr, err := git.InitRepository(repo, true)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdb, err := newRepo(r, ref)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn db, nil\n}", "title": "" }, { "docid": "64d12920d8fe7d0dd735d4f3641284e6", "score": "0.63582647", "text": "func Init() string {\n\tdir, err := os.Getwd()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\terr = os.Mkdir(constants.GitDir, 0755)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn filepath.Join(dir, constants.GitDir)\n}", "title": "" }, { "docid": "50453fcb7236dafcc0424467942b35c7", "score": "0.6284108", "text": "func Init(ctx context.Context, local bool, gerritUrl string) (gerrit.GerritInterface, error) {\n\tts, err := git_steps.Init(ctx, local)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar rv gerrit.GerritInterface\n\terr = td.Do(ctx, td.Props(\"Gerrit Init\").Infra(), func(ctx context.Context) error {\n\t\tclient := httputils.DefaultClientConfig().WithTokenSource(ts).Client()\n\t\tg, err := gerrit.NewGerrit(gerritUrl, td.HttpClient(ctx, client))\n\t\trv = g\n\t\treturn err\n\t})\n\treturn rv, err\n}", "title": "" }, { "docid": "4fb11889db01084fdc84375a305fc402", "score": "0.6281879", "text": "func NewGit() Git {\n\tcmd := exec.Exec(\"\", \"git\", \"version\")\n\tsubmatches := versionRegexp.FindStringSubmatch(cmd.StdOut)\n\tvar version gitVersion = noVersion\n\tif submatches != nil {\n\t\tversion = parseVersionString(submatches[1])\n\t}\n\treturn git{\n\t\tversion: version,\n\t}\n}", "title": "" }, { "docid": "dff75e2414283b527b0b6872c06bfc5f", "score": "0.6263115", "text": "func NewGit(dir string) *Git {\n\treturn &Git{\n\t\tDir: dir,\n\t}\n}", "title": "" }, { "docid": "e60dc6b8c20d829833c34ea01a9afc04", "score": "0.6178461", "text": "func (f *FakeGit) SubmoduleInit(repo string) error {\n\tf.SubmoduleInitRepo = repo\n\treturn f.SubmoduleInitError\n}", "title": "" }, { "docid": "7f28dd1e6ccf55d8ceaa115bbc1484ba", "score": "0.616507", "text": "func CmdInit(c *cli.Context) error {\n\tif c.NArg() == 0 {\n\t\tlog.Fatal(\"No project name specified\")\n\t} else if c.NArg() > 1 {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"project\": c.Args().Get(0),\n\t\t}).Warn(\"Multi project name specified. First one will use\")\n\t}\n\n\tproject := c.Args().Get(0)\n\tcfgCtrl, err := config.NewController()\n\tif err != nil {\n\t\tlog.Fatal(err.Error())\n\t}\n\n\tif cfgCtrl.PjAlreadyCreated {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"path\": cfgCtrl.ProjectRoot,\n\t\t}).Fatal(\"envrionment already exists\")\n\t}\n\n\tif err := cfgCtrl.Init(); err != nil {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"error\": err,\n\t\t}).Fatal(\"Failed to init config file\")\n\t}\n\n\ts := skeleton.Skeleton{Path: cfgCtrl.ProjectRoot}\n\tif err := s.Init(&skeleton.InitExecutable{Project: project}); err != nil {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"error\": err,\n\t\t}).Fatal(\"Failed to Exec template\")\n\t}\n\n\tcfg := &config.Config{Project: project}\n\tif err := cfgCtrl.Write(cfg); err != nil {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"error\": err,\n\t\t}).Fatal(\"Failed to dump config into file\")\n\t}\n\n\tlog.WithFields(log.Fields{\n\t\t\"name\": project,\n\t}).Infof(\"Project initialized. Environments created\")\n\treturn nil\n}", "title": "" }, { "docid": "060e337f22b2dd4481eda4c62d82d49a", "score": "0.6059537", "text": "func Init() error {\n\tif err := ensureDirectories(settings.Home); err != nil {\n\t\treturn err\n\t}\n\n\tif err := ensureDefaultRepos(settings.Home); err != nil {\n\t\treturn err\n\t}\n\n\tif err := ensureRepoFileFormat(settings.Home.RepositoryFile()); err != nil {\n\t\treturn err\n\t}\n\n\tif err := ensureUpdatedRepos(settings.Home); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "e814f69e03e08e932b376809038f0a12", "score": "0.6053323", "text": "func Init(projectPath string, cfg config.Config, license license.License, commit git.CallbackAddAndCommit, step int) error {\n\tpattern := filepath.Join(\"./readme/tmpl\", \"*.tmpl\")\n\ttmpl, err := template.ParseGlob(pattern)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to load templates: %s\", err)\n\t}\n\n\tfilename := filepath.Join(projectPath, \"README.md\")\n\tfile, err := os.Create(filename)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create readme file: %s\", err)\n\t}\n\tdefer func() {\n\t\t_ = file.Close()\n\t}()\n\n\tparams := NewParameters(cfg, license)\n\tif err = tmpl.ExecuteTemplate(file, \"readme\", params); err != nil {\n\t\treturn fmt.Errorf(\"failed to parse template: %s\", err)\n\t}\n\treturn commit([]string{filename}, \"added readme\", step)\n}", "title": "" }, { "docid": "39fc9f3e677b987d5459405d149dd1d1", "score": "0.60450834", "text": "func New(opts ...Option) *Git {\n\treturn &Git{opts: newOptions(opts...)}\n}", "title": "" }, { "docid": "1fd694a79d13fb751de23b969df5e76d", "score": "0.60080934", "text": "func Init(ctx context.Context, local bool, workdir string) (string, error) {\n\tts, err := auth_steps.Init(ctx, local, auth.SCOPE_GERRIT, auth.SCOPE_USERINFO_EMAIL)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tvar gitcookiesPath string\n\tif local {\n\t\tgitcookiesPath = gerrit.DefaultGitCookiesPath()\n\t} else {\n\t\tgitcookiesPath = path.Join(workdir, \".gitcookies\")\n\t}\n\terr = td.Do(ctx, td.Props(\"Gitauth Init\").Infra(), func(ctx context.Context) error {\n\t\t_, err := gitauth.New(ts, gitcookiesPath, true, \"\")\n\t\treturn err\n\t})\n\treturn gitcookiesPath, err\n}", "title": "" }, { "docid": "259fd5f9e3c73fd5fe8f643c24b92306", "score": "0.5996078", "text": "func init() {\n\tcurhash = git.LatestCommitHash\n}", "title": "" }, { "docid": "b34fe2910bc0850ac42034a49cf75eb3", "score": "0.59917325", "text": "func (s *imageBuilderServer) Init(ctx context.Context, gitRepo *api.GitRepo) (*api.Response, error) {\n\ts.initialized = true\n\n\t// TODO: save git repo params and clone\n\n\treturn &okResponse, nil\n}", "title": "" }, { "docid": "b767c4a1ecb405f3608cd75db26aead4", "score": "0.5975181", "text": "func init() {\n\tRootCmd.AddCommand(GetProjectCmd)\n}", "title": "" }, { "docid": "46144ef6b39bc74baf7dfbdc382845dd", "score": "0.5967467", "text": "func New(exe string) (*Git, error) {\n\tif exe == \"\" {\n\t\tg, err := exec.LookPath(\"git\")\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to find git: %v\", err)\n\t\t}\n\t\texe = g\n\t}\n\tif _, err := os.Stat(exe); err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Git{exe: exe}, nil\n}", "title": "" }, { "docid": "aec7a75becb40b626ff0a91dd900a33b", "score": "0.5930961", "text": "func Init() *GithubBridge {\n\ts := &GithubBridge{\n\t\tGoServer: &goserver.GoServer{},\n\t\tserving: true,\n\t\tgetter: prodHTTPGetter{},\n\t\tattempts: 0,\n\t\tfails: 0,\n\t\tadded: make(map[string]time.Time),\n\t\taddedMutex: &sync.Mutex{},\n\t\taddedCount: make(map[string]int64),\n\t\tissueLock: &sync.Mutex{},\n\t}\n\treturn s\n}", "title": "" }, { "docid": "86a3e4be73c831d89162fe8b151539de", "score": "0.59046566", "text": "func main() {\n\targs := os.Args\n\tcwd := args[1]\n\n\tgitFolders := allGitFolders(cwd)\n\tfmt.Println(cwd)\n\tfmt.Println(gitFolders)\n\n\tb, err := ioutil.ReadFile(cwd + \"/.git/gitname.txt\") // just pass the file name\n\tcheckError(err)\n\n\tfmt.Println(\"Current git project: \", string(b))\n\tfmt.Println(\"All git projects in this repo: \")\n\tif len(gitFolders) == 0 {\n\t\tfmt.Println(\"There are no other git projects in this directory.\")\n\t\treturn\n\t}\n\tfor index, folder := range gitFolders {\n\t\tname, err := ioutil.ReadFile(folder + \"/gitname.txt\")\n\t\tcheckError(err)\n\t\tfmt.Println(strconv.Itoa(index) + \". \" + string(name))\n\t}\n\n\tfmt.Println(\"Type the number of git project you'd like to switch to. Type anything else to exit.\")\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\ttext = strings.TrimSpace(text)\n\tinput, err := strconv.Atoi(text)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif input >= 0 && input < len(gitFolders) {\n\t\toldName := gitFolders[input]\n\t\tos.Rename(oldName, \"temp\")\n\t\tos.Rename(\".git\", oldName)\n\t\tos.Rename(\"temp\", \".git\")\n\t\tcopyFileContents(cwd+\"/.git/ReadMe.txt\", cwd+\"/ReadMe.txt\")\n\t\tcopyFileContents(cwd+\"/.git/.gitignore\", cwd+\"/.gitignore\")\n\t\tcopyFileContents(cwd+\"/.git/.gitattributes\", cwd+\"/.gitattributes\")\n\n\t}\n}", "title": "" }, { "docid": "bab95cf6cb7cf72a32c8c629cf287ead", "score": "0.58908075", "text": "func New(wd string) (Git, error) {\n\tif exe == \"\" {\n\t\tpath, err := exec.LookPath(\"git\")\n\t\tif err != nil {\n\t\t\treturn Git{}, fmt.Errorf(\"Couldn't find git: %v\", err)\n\t\t}\n\t\texe = path\n\t}\n\n\treturn Git{\n\t\twd: wd,\n\t\texe: exe,\n\t}, nil\n}", "title": "" }, { "docid": "4ab483191c08f306de2bb3325d05554c", "score": "0.58809704", "text": "func New(log pslog.Logger) Git {\n\treturn Git{\n\t\tPreviousTagGetter: Exec,\n\t\tCommitGetter: Exec,\n\t\tlog: log,\n\t}\n}", "title": "" }, { "docid": "6ecac326497c014346bf078fe81fb22f", "score": "0.5847416", "text": "func New() (GitInfo, error) {\n\treturn NewWithPath(\"\")\n}", "title": "" }, { "docid": "62d23cd71d84ee5920c3ac7887c53eaf", "score": "0.5835733", "text": "func (impl *ProjectAPIClient) CreateFromGit(ctx context.Context, token *api.Token, repo string) (reply *application.Definition, err error) {\n\terr = client.CallHTTP(ctx, impl.BaseURL, \"ProjectAPI.CreateFromGit\", atomic.AddUint64(&impl.sequence, 1), &reply, token, repo)\n\treturn\n}", "title": "" }, { "docid": "449642f9f693d965e19789d6240d4c6e", "score": "0.5827494", "text": "func (r *Store) RCSInit(ctx context.Context, name, userName, userEmail string) error {\n\tstore, _ := r.getStore(name)\n\tctx = ctxutil.WithUsername(ctx, userName)\n\tctx = ctxutil.WithEmail(ctx, userEmail)\n\n\treturn store.GitInit(ctx)\n}", "title": "" }, { "docid": "f359b7b973c54604b97c466dee572eef", "score": "0.5812608", "text": "func Init(repo *config.RepoConfig, opr *operator.Operator) Cherry {\n\tc := cherry{\n\t\towner: repo.Owner,\n\t\trepo: repo.Repo,\n\t\tready: false,\n\t\trule: repo.Rule,\n\t\trelease: repo.Release,\n\t\ttypeLabel: repo.TypeLabel,\n\t\tignoreLabel: repo.IgnoreLabel,\n\t\tdryrun: repo.Dryrun,\n\t\tforkedRepoCollaborators: make(map[string]struct{}),\n\t\tcollaboratorInvitation: make(map[string]time.Time),\n\t\topr: opr,\n\t\tcfg: repo,\n\t}\n\tgo c.runLoadCollaborators()\n\treturn &c\n}", "title": "" }, { "docid": "1212229e2cc8a6626f6b6122e611237b", "score": "0.58078945", "text": "func New(path string) *Git {\n\treturn &Git{\n\t\trepo: open(path),\n\t}\n}", "title": "" }, { "docid": "75acf6e6d1e5816db5033a0d6257360a", "score": "0.5797279", "text": "func (r *Repo) Init() error {\n\tif _, err := os.Stat(filepath.Join(r.path, \"repository\", \"root.json\")); err == nil {\n\t\treturn os.ErrExist\n\t}\n\n\t// Fuchsia repositories always use consistent snapshots.\n\treturn r.Repo.Init(true)\n}", "title": "" }, { "docid": "e4bc9b29335ea0a3781a422fd7800b53", "score": "0.57939744", "text": "func cmdInit(opt *InitOpt) (err error) {\n\n\tstdout := colorable.NewColorableStdout()\n\n\t// Check user name.\n\tif opt.UserName == \"\" {\n\t\tfmt.Fprintf(stdout, \"Checking git configuration to get the user name: \")\n\t\topt.UserName, err = gitconfig.GithubUser()\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(stdout, chalk.Red.Color(\"Cannot find user name (%v)\"), err.Error())\n\t\t\treturn cli.NewExitError(\"\", 1)\n\t\t}\n\t\tfmt.Fprintln(stdout, chalk.Yellow.Color(opt.UserName))\n\t}\n\n\t// Prepare directories.\n\tfmt.Fprintf(stdout, \"Preparing the directory to store a brew formula: \")\n\tif err = prepareDirectory(opt.Config.Homebrew); err != nil {\n\t\tfmt.Fprintf(stdout, chalk.Red.Color(\"failed (%v)\"), err.Error())\n\t\treturn cli.NewExitError(\"\", 2)\n\t}\n\tfmt.Fprintln(stdout, chalk.Green.Color(\"done\"))\n\n\t// Check Makefile doesn't exist and create it.\n\tactor := interact.NewActor(os.Stdin, stdout)\n\n\tcreateMakefile := true\n\tif _, exist := os.Stat(\"Makefile\"); exist == nil {\n\t\tcreateMakefile, err = actor.Confirm(\"Makefile already exists. Would you like to overwrite it?\", interact.ConfirmDefaultToNo)\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(stdout, chalk.Red.Color(\"failed (%v)\"), err.Error())\n\t\t\treturn cli.NewExitError(\"\", 3)\n\t\t}\n\t}\n\tif createMakefile {\n\t\tfmt.Fprintf(stdout, \"Creating Makefile: \")\n\t\terr = createResource(\"Makefile\", &fgo.Makefile{\n\t\t\tDest: opt.Config.Package,\n\t\t\tUserName: opt.UserName,\n\t\t})\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(stdout, chalk.Yellow.Color(\"skipped (%s)\\n\"), err.Error())\n\t\t} else {\n\t\t\tfmt.Fprintln(stdout, chalk.Green.Color(\"done\"))\n\t\t}\n\t} else {\n\t\tfmt.Fprintln(stdout, \"Creating Makefile:\", chalk.Yellow.Color(\"skipped\"))\n\t}\n\n\t// Check brew rb file doesn't exist and create it.\n\tif opt.Repository == \"\" {\n\t\tfmt.Fprintf(stdout, \"Checking git configuration to get the repository name: \")\n\t\topt.Repository, err = gitconfig.Repository()\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(stdout, chalk.Red.Color(\"skipped (%s).\\n\"), err.Error())\n\t\t\tfmt.Fprintln(stdout, chalk.Yellow.Color(\"You must re-run init command after setting a remote repository\"))\n\t\t}\n\t\tfmt.Fprintln(stdout, chalk.Yellow.Color(opt.Repository))\n\t}\n\tif opt.Repository != \"\" {\n\t\ttmpfile := filepath.Join(opt.Config.Homebrew, fmt.Sprintf(\"%s.rb.template\", opt.Repository))\n\n\t\tcreateTemplate := true\n\t\tif _, exist := os.Stat(tmpfile); exist == nil {\n\t\t\tcreateTemplate, err = actor.Confirm(\"brew formula template already exists. Would you like to overwrite it?\", interact.ConfirmDefaultToNo)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Fprintf(stdout, chalk.Red.Color(\"failed (%v)\"), err.Error())\n\t\t\t\treturn cli.NewExitError(\"\", 3)\n\t\t\t}\n\t\t}\n\t\tif createTemplate {\n\t\t\tfmt.Fprintf(stdout, \"Creating brew formula template: \")\n\t\t\terr = createResource(tmpfile, &fgo.FormulaTemplate{\n\t\t\t\tPackage: opt.Repository,\n\t\t\t\tUserName: opt.UserName,\n\t\t\t\tDescription: opt.Description,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\tfmt.Fprintf(stdout, chalk.Yellow.Color(\"skipped (%s).\\n\"), err.Error())\n\t\t\t} else {\n\t\t\t\tfmt.Fprintln(stdout, chalk.Green.Color(\"done\"))\n\t\t\t}\n\t\t} else {\n\t\t\tfmt.Fprintln(stdout, \"Creating brew formula template:\", chalk.Yellow.Color(\"skipped\"))\n\t\t}\n\t}\n\n\treturn\n\n}", "title": "" }, { "docid": "9c4ed090d41766aff5c6634aa64c660c", "score": "0.5773054", "text": "func NewGitUtil(entryPath string) (*GitUtil, error) {\n\tvar err error\n\tutil := GitUtil{EntryPath: entryPath}\n\tutil.TopLevelPath, err = util.ExecCommand(\"rev-parse\", \"--show-toplevel\")\n\treturn &util, err\n}", "title": "" }, { "docid": "bdcdf529796d843ad13cc6bad65594fb", "score": "0.5735211", "text": "func (r *GitRegistry) Initialize() error {\n\n\tabsPath, err := filepath.Abs(r.Repository)\n\n\tif err != nil {\n\t\treturn r.initializeRemote()\n\t}\n\tst, err := os.Stat(absPath)\n\tif st == nil || os.IsNotExist(err) {\n\t\treturn r.initializeRemote()\n\t}\n\tif !st.IsDir() {\n\t\treturn ErrorNoValidRepositoryGiven\n\t}\n\tr.Repository = absPath\n\treturn r.initializeLocal()\n}", "title": "" }, { "docid": "0e32f20dde6e0cc64dbc284224a06670", "score": "0.5718016", "text": "func CmdInit(c *cli.Context) error {\n\n\topt := InitOpt{\n\t\tConfig: Config{\n\t\t\tPackage: c.GlobalString(PackageFlag),\n\t\t\tHomebrew: c.GlobalString(HomebrewFlag),\n\t\t},\n\t\tUserName: c.Args().First(),\n\t\tRepository: c.Args().Get(1),\n\t\tDescription: c.String(\"desc\"),\n\t}\n\treturn cmdInit(&opt)\n\n}", "title": "" }, { "docid": "0ec684d80f9726a21a035dadad843914", "score": "0.5704441", "text": "func (s *GitService) InitRepository(ctx context.Context, c *CreateCommit, createRemote bool) (r *git.Repository, dir string, err error) {\n\tdir, err = os.MkdirTemp(\"\", \"repo-*\")\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\n\tgitDir := osfs.New(dir + \"/.git\")\n\tfs := osfs.New(dir)\n\tr, err = git.Init(filesystem.NewStorage(gitDir, cache.NewObjectLRUDefault()), fs)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\n\tw, err := r.Worktree()\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\n\terr = s.addCommitFiles(w, dir, c.Files)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\n\tif createRemote {\n\t\trc := &config.RemoteConfig{Name: \"origin\", URLs: []string{c.URL}}\n\t\t_, err = r.CreateRemote(rc)\n\t\tif err != nil {\n\t\t\treturn nil, \"\", err\n\t\t}\n\t}\n\n\t_, err = s.commit(w, r, c)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\n\treturn r, dir, nil\n}", "title": "" }, { "docid": "0e1fec6cdde409fdb51ad927ce7a28a9", "score": "0.5694819", "text": "func init() {\n\tFakeRepo.Init()\n}", "title": "" }, { "docid": "3b60ad6ecf220b8731f3c6ca07e81b5d", "score": "0.56903386", "text": "func InitBareRepository(path string) (*Repository, error) {\n\n\tpath, err := filepath.Abs(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Could not determine absolute path: %v\", err)\n\t}\n\n\tcmd := exec.Command(\"git\", \"init\", \"--bare\", path)\n\terr = cmd.Run()\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Repository{Path: path}, nil\n}", "title": "" }, { "docid": "baef345ae71f11b4e5cff9a242fefdca", "score": "0.5670079", "text": "func InitCommand() cli.Command {\n\treturn cli.Command{\n\t\tName: \"init\",\n\t\tAliases: []string{\"i\"},\n\t\tUsage: \"Initialize new project in current utils, if you give no project name, it will make a slug of utils name.\",\n\t\tArgsUsage: \"[project]\",\n\t\tAction: makeInitAction,\n\t}\n}", "title": "" }, { "docid": "a2782985698643944cf9e4d8f6779fa2", "score": "0.56577617", "text": "func (g *GitChartProvider) Initialize() error {\n\tif err := g.initializeRepository(); err != nil {\n\t\treturn err\n\t}\n\n\tif err := g.buildIndexFile(); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "91be15945051b890f874095d05e8a9cf", "score": "0.5634124", "text": "func NewInitTask(args []string) (Task, error) {\n\n\tflags := flag.NewFlagSet(\"init\", flag.ExitOnError)\n\n\tgoPath := flags.String(\"g\", \"\", \"the GOPATH to create\")\n\tprojectName := flags.String(\"n\", \"\", \"the project name\")\n\tscriptPath := flags.String(\"s\", \"./goenv/activate\", \"the full path to the initialization script\")\n\tprojectPath := flags.String(\"p\", \"\", \"the project path\")\n\n\tflags.Parse(args)\n\targs = flags.Args()\n\n\tif len(args) < 1 {\n\t\treturn nil, errors.New(\"no import path specified\")\n\t}\n\n\tworkingDir, err := os.Getwd()\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttask := InitTask{\n\t\tImportPath: args[0],\n\t\tGoPath: *goPath,\n\t\tProjectName: *projectName,\n\t\tProjectPath: *projectPath,\n\t\tScriptPath: *scriptPath,\n\t}\n\n\tif task.ProjectName == \"\" {\n\t\ttask.ProjectName = filepath.Base(workingDir)\n\t}\n\n\tif task.ProjectPath == \"\" {\n\t\ttask.ProjectPath = workingDir\n\t}\n\n\tif task.GoPath == \"\" {\n\t\tusr, err := user.Current()\n\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\ttask.GoPath = filepath.Join(usr.HomeDir, \".goenv/\", task.ProjectName)\n\t}\n\n\treturn &task, nil\n}", "title": "" }, { "docid": "11bd9c8ec24b7b61db6c0c358079b207", "score": "0.5609929", "text": "func (r *Repo) Init() error {\n\t// We get all needed information about the repo based on the remote url\n\tremote, err := getRemoteFromLocalRepoPath(r.LocalPath, r.RemoteName)\n\n\t// Parse the remote url into needed information, different paths for ssh vs http remotes\n\tswitch {\n\tcase strings.Contains(remote, \"://\"):\n\t\tremote = strings.TrimSpace(remote)\n\t\tremote = strings.TrimPrefix(remote, \"http://\")\n\t\tremote = strings.TrimPrefix(remote, \"https://\")\n\t\tremote = strings.TrimPrefix(remote, \"ssh://git@\")\n\t\tremote = strings.TrimSuffix(remote, \".git\")\n\t\tremoteS := strings.SplitN(remote, \"/\", 2) //nolint:gomnd\n\n\t\tr.HTTPURL = remote\n\t\tr.BaseURL = remoteS[0]\n\t\tr.Path = remoteS[1]\n\tcase strings.Contains(remote, \"@\"):\n\t\tremote = strings.TrimSpace(remote)\n\t\tremote = strings.TrimPrefix(remote, \"git@\")\n\t\tremote = strings.TrimSuffix(remote, \".git\")\n\t\tremoteS := strings.Split(remote, \":\")\n\n\t\tr.HTTPURL = remoteS[0] + \"/\" + remoteS[1]\n\t\tr.BaseURL = remoteS[0]\n\t\tr.Path = remoteS[1]\n\tdefault:\n\t\treturn fmt.Errorf(\"your remote (%s), %s, is not an SSH or HTTP remote\", r.RemoteName, remote)\n\t}\n\n\t// We create a list of gitlab groups that we can collect variables from. These are\n\t// just the paths before the repo name.\n\tgroups := path.Dir(r.Path)\n\tgroupsN := strings.Count(groups, \"/\") + 1\n\tfor i := groupsN; i > 0; i-- {\n\t\tr.Groups = append(r.Groups, groups)\n\t\tgroups = path.Dir(groups)\n\t}\n\n\treturn err\n}", "title": "" }, { "docid": "f747c90306ed1714a455d7f4d0113d6a", "score": "0.5593561", "text": "func (i *initCommand) initProject(projectName string, basepath string, force bool, empty bool) error {\n\tvar (\n\t\tfeaturesDir = filepath.Join(basepath, common.FeaturesDir)\n\t\tconfigDir = filepath.Join(basepath, common.ConfigDir)\n\t\tresultsDir = filepath.Join(basepath, common.ResultsDir)\n\t\tmacrosDir = filepath.Join(basepath, common.MacrosDir)\n\t\tresourcesDir = filepath.Join(basepath, common.ResourcesDir)\n\t\tenvironmentsJSON = filepath.Join(configDir, common.EnvironmentsFile)\n\t\tpagesJSON = filepath.Join(configDir, common.PagesFile)\n\t\tselectorsJSON = filepath.Join(configDir, common.SelectorsFile)\n\t\tsettingsJSON = filepath.Join(configDir, common.SettingsFile)\n\t\texampleFeature = filepath.Join(featuresDir, common.ExampleFeatureFile)\n\t)\n\n\tprojectStructure := []string{\n\t\tfeaturesDir,\n\t\tconfigDir,\n\t\tresultsDir,\n\t\tmacrosDir,\n\t\tresourcesDir,\n\t}\n\n\tprojectFiles := []string{\n\t\tenvironmentsJSON,\n\t\tpagesJSON,\n\t\tselectorsJSON,\n\t\tsettingsJSON,\n\t\texampleFeature,\n\t}\n\n\tif exists, _ := afero.Exists(i.initFs, basepath); exists {\n\t\tif isDir, _ := afero.IsDir(i.initFs, basepath); !isDir {\n\t\t\treturn errors.New(basepath + \" exists but is not a directory...aborting...\")\n\t\t}\n\n\t\tisEmpty, _ := afero.IsEmpty(i.initFs, basepath)\n\n\t\tswitch {\n\t\tcase !isEmpty && !force:\n\t\t\treturn errors.New(basepath + \" already exists and is not empty...aborting...\")\n\n\t\tcase !isEmpty && force:\n\t\t\tall := append(projectStructure, projectFiles...)\n\t\t\tfor _, path := range all {\n\t\t\t\tif pathExists, _ := afero.Exists(i.initFs, path); pathExists {\n\t\t\t\t\treturn errors.New(path + \" already exists...aborting...\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, dir := range projectStructure {\n\t\tif err := i.initFs.MkdirAll(dir, 0777); err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to create dir [%s]: %s\", dir, err)\n\t\t}\n\t}\n\n\tif i.initPlatform == \"web\" {\n\t\tafero.WriteReader(i.initFs, settingsJSON, bytes.NewBufferString(configfiles.GetSettingsJSON(projectName)))\n\t} else if i.initPlatform == \"desktop\" {\n\t\tafero.WriteReader(i.initFs, settingsJSON, bytes.NewBufferString(configfiles.GetSettingsDesktopJSON(projectName)))\n\t}\n\n\tafero.WriteReader(i.initFs, environmentsJSON, bytes.NewBufferString(configfiles.GetEnvironmentsJSON()))\n\tafero.WriteReader(i.initFs, pagesJSON, bytes.NewBufferString(configfiles.GetPagesJSON()))\n\tafero.WriteReader(i.initFs, selectorsJSON, bytes.NewBufferString(configfiles.GetSelectorsJSON()))\n\n\tif !empty {\n\t\tafero.WriteReader(i.initFs, exampleFeature, bytes.NewBufferString(configfiles.GetExampleFeature()))\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "1da41e59e2863b7d5416f08551d8316d", "score": "0.5566523", "text": "func (r *Repo) Git(cmd string, args ...string) (res *exec.Cmd, out, err *bytes.Buffer) {\n\tvar path string\n\tif r.WorkDir == \"\" {\n\t\tpath = r.GitDir\n\t} else {\n\t\tpath = r.WorkDir\n\t}\n\tres, out, err = Git(cmd, args...)\n\tres.Dir = path\n\treturn\n}", "title": "" }, { "docid": "6e04e95f6bcad73275a3347188abf13e", "score": "0.55380994", "text": "func (j *DSGit) ParseInit(ctx *Ctx, line string) (parsed bool, err error) {\n\tj.ParseState = GitParseStateCommit\n\tparsed = line == \"\"\n\treturn\n}", "title": "" }, { "docid": "0569c93993cc623d1530b37a71295560", "score": "0.55376816", "text": "func NewInit2Command() *cobra.Command {\n\t// Arguments\n\tvar options initProjectOptions\n\n\tinitCmd := &cobra.Command{\n\t\tUse: \"init\",\n\t\tShort: \"Initialize go vscode project\",\n\t\tLong: \"Initialize go vscode project\",\n\t\tRun: func(cmd *cobra.Command, args []string) {\n\t\t\tinitProject2(cmd, &options)\n\t\t},\n\t}\n\n\tinitCmd.Flags().StringVarP(&options.projectDir, \"project\", \"p\", \"\", \"project directory, eg:github.com/xxx/testproject\")\n\n\treturn initCmd\n}", "title": "" }, { "docid": "62ad03dd29df2e15be9dacc90726b714", "score": "0.55375576", "text": "func (template *Template) Init() error {\n\ttemplate.Directory = git.Repository(filepath.Join(TemplatesDirectory, template.Name))\n\n\tif template.Directory.ToString() == \"\" {\n\t\treturn fmt.Errorf(\"can not init a new template without a directory\")\n\t}\n\ttemplate.Files = filepath.Join(template.Directory.ToString(), \"template\")\n\ttemplate.ConfigFile = filepath.Join(template.Directory.ToString(), \"config.yaml\")\n\n\t// check for required project structure\n\tif _, err := os.Stat(template.Files); os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"%s does not have the required template directory, please check the README file\", template.Directory)\n\t}\n\n\tif _, err := os.Stat(template.ConfigFile); os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"%s does not have a config.yaml file, so it may not actually be a cgen template\", template.Directory)\n\t}\n\n\tconfigYAML, err := os.Open(template.ConfigFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer configYAML.Close()\n\tbyteValue, _ := ioutil.ReadAll(configYAML)\n\tyaml.Unmarshal(byteValue, &template)\n\n\ttags, err := template.Directory.ListTags()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlatest, err := tags.Latest()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tstable, err := tags.LatestStable()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttemplate.LatestVersion = latest\n\ttemplate.LatestStableVersion = stable\n\n\treturn nil\n}", "title": "" }, { "docid": "03b831375997a8e7ad346bfff5e3c627", "score": "0.55218565", "text": "func (b *BuildCommand) Init(c *Cli) {\n\tb.cli = c\n\n\tb.cmd = &cobra.Command{\n\t\tUse: \"build [OPTION] PATH\",\n\t\tShort: \"Build an image from a Dockerfile\",\n\t\tLong: buildDescription,\n\t\tArgs: cobra.ExactArgs(1),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\treturn b.runBuild(args)\n\t\t},\n\t}\n\tb.addFlags()\n}", "title": "" }, { "docid": "8d2c15bc220d91f6f8f7b73cabc8d328", "score": "0.55157965", "text": "func New(folder string) (*GitUtil, error) {\n\tr, err := git.PlainOpen(folder)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tutils := &GitUtil{\n\t\tRepository: r,\n\t}\n\treturn utils, nil\n\n}", "title": "" }, { "docid": "e450e5341f2877b8858f156ff53aee72", "score": "0.5513756", "text": "func NewGitLocal() *GitLocal {\n\treturn &GitLocal{\n\t\tGitCLI: NewGitCLI(),\n\t\tGitFake: &GitFake{},\n\t}\n}", "title": "" }, { "docid": "183a93863ddf42592782c3ffe013ddc1", "score": "0.5499555", "text": "func RunInit() {\n\n\treader := bufio.NewReader(os.Stdin)\n\n\tconfig := model.Config{}\n\tconfig.ReadConfig()\n\n\tprojectType := \"\"\n\n\tif len(os.Args) <= 2 {\n\t\tinfraOrApp := model.InitializeInfraOrApp()\n\t\tinfraOrApp.PrintPrompt()\n\t\tinfraOrApp.ReadResponse(reader)\n\n\t\tprojectType = infraOrApp.Response\n\t} else {\n\t\tprojectType = \"infra\"\n\t}\n\n\tconfig.ProjectType = projectType\n\n\tservice.GenerateConfig(&config, reader)\n\n\tconfig.SaveConfig()\n}", "title": "" }, { "docid": "b5d86e75cdf2b8baeead714a3ce6ac99", "score": "0.54994655", "text": "func (t *CloudBuildTrigger) Init(projectID string) error {\n\tif t.Name == \"\" {\n\t\treturn errors.New(\"name must be set\")\n\t}\n\tg := t.GitHub\n\tif g == nil {\n\t\treturn errors.New(\"github must be set\")\n\t}\n\tif g.Owner == \"\" {\n\t\treturn errors.New(\"owner in github must be set\")\n\t}\n\tif g.Name == \"\" {\n\t\treturn errors.New(\"name in github must be set\")\n\t}\n\tif (g.PullRequest != nil) == (g.Push != nil) {\n\t\treturn errors.New(\"exactly one of pull_request or push in github must be set\")\n\t}\n\tif g.PullRequest != nil {\n\t\tif g.PullRequest.Branch == \"\" {\n\t\t\treturn errors.New(\"branch in pull_request must be set\")\n\t\t}\n\t\tif cc := g.PullRequest.CommentControl; cc != \"\" && cc != \"COMMENTS_DISABLED\" && cc != \"COMMENTS_ENABLED\" {\n\t\t\treturn errors.New(\"value of comment_control in pull_request can only be one of [COMMENTS_DISABLED, COMMENTS_ENABLED]\")\n\t\t}\n\t}\n\tif g.Push != nil && (g.Push.Branch == \"\") == (g.Push.Tag == \"\") {\n\t\treturn errors.New(\"exactly one of branch or tag in push must be set\")\n\t}\n\tif t.Project != \"\" {\n\t\treturn fmt.Errorf(\"project must be unset: %v\", t.Project)\n\t}\n\tt.Project = projectID\n\treturn nil\n}", "title": "" }, { "docid": "f7639bab97b861f47c1d82f52359f524", "score": "0.5499234", "text": "func (c *MigrationsCmd) Init() {\n\tc.common.SetArgs(c.CheckArgs)\n\tc.common.SetRun(c.Run)\n}", "title": "" }, { "docid": "d565785f25c9810414ff8cc9867b44e9", "score": "0.54987156", "text": "func NewGitResource(context context.T, info string, bridge ssmparameterresolver.ISsmParameterResolverBridge) (resource *GitResource, err error) {\n\tvar gitInfo GitInfo\n\n\terrorPrefix := \"SourceInfo could not be unmarshalled for source type Git\"\n\tif gitInfo, err = parseSourceInfo(info); err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %s\", errorPrefix, err.Error())\n\t}\n\n\tgetOptions, err := gitresource.ParseCheckoutOptions(context.Log(), gitInfo.GetOptions)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %s\", errorPrefix, err.Error())\n\t}\n\n\tauthConfig := handler.GitAuthConfig{\n\t\tPrivateSSHKey: gitInfo.PrivateSSHKey,\n\t\tSkipHostKeyChecking: gitInfo.SkipHostKeyChecking,\n\t\tUsername: gitInfo.Username,\n\t\tPassword: gitInfo.Password,\n\t}\n\n\tgitHandler, err := handler.NewGitHandler(gitInfo.Repository, authConfig, *getOptions, bridge)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &GitResource{\n\t\tcontext: context,\n\t\tHandler: gitHandler,\n\t}, nil\n}", "title": "" }, { "docid": "b75c1c6231121ad70d0ccee3c5b37e6c", "score": "0.5485368", "text": "func CreateGit(git Git) error {\n\treturn DB.Create(&git).Error\n}", "title": "" }, { "docid": "4a12f4c2c5ff40c724b85366b68616ed", "score": "0.5481583", "text": "func NewGitScanner(cfg *config.Configuration, cb GitScannerFoundPointer) *GitScanner {\n\treturn &GitScanner{started: time.Now(), FoundPointer: cb, cfg: cfg}\n}", "title": "" }, { "docid": "da6d0e9f083269d61892ead69785f03e", "score": "0.5464619", "text": "func Init(croniclePath string, cloneRepo string, deployKey string, defaultConf Config) {\n\n\tabsCroniclePath, err := filepath.Abs(croniclePath)\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n\n\t//if remote is given, clone it to the cronicle path\n\tif cloneRepo != \"\" {\n\t\tvar cloneOptions git.CloneOptions\n\t\tif deployKey != \"\" {\n\t\t\tauth, err := ssh.NewPublicKeysFromFile(\"git\", deployKey, \"\")\n\t\t\tauth.HostKeyCallback = gossh.InsecureIgnoreHostKey()\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t\tcloneOptions = git.CloneOptions{URL: cloneRepo, Auth: auth}\n\t\t} else {\n\t\t\tcloneOptions = git.CloneOptions{URL: cloneRepo}\n\t\t}\n\n\t\t_, err = git.PlainClone(absCroniclePath, false, &cloneOptions)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t}\n\n\tslantyedCyan := color.New(color.FgCyan, color.Italic).SprintFunc()\n\t// errors.New(\"could not extract repos from \" + slantedRed(\"Config\"))\n\tos.MkdirAll(path.Join(absCroniclePath, path.Join(\".cronicle\", \"repos\")), 0777)\n\tcronicleFile := path.Join(absCroniclePath, \"cronicle.hcl\")\n\tfmt.Println(\"Init Cronicle: \" + slantyedCyan(cronicleFile))\n\n\tif fileExists(cronicleFile) {\n\t\tconf, err := GetConfig(cronicleFile)\n\t\tif err != nil {\n\t\t\tos.Exit(1)\n\t\t}\n\t\thcl := conf.Hcl()\n\t\tfmt.Printf(\"%s\", slantyedCyan(string(hcl.Bytes)))\n\t\t// CloneRepos(absCroniclePath, conf)\n\t} else {\n\t\tMarshallHcl(defaultConf, cronicleFile)\n\t\tf, err := os.OpenFile(path.Join(absCroniclePath, \".gitignore\"),\n\t\t\tos.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t}\n\t\tdefer f.Close()\n\t\tif _, err := f.WriteString(\".cronicle\\n\"); err != nil {\n\t\t\tlog.Println(err)\n\t\t}\n\t}\n\n}", "title": "" }, { "docid": "09215a0cd51870cc6534b9dc796cfb19", "score": "0.5453606", "text": "func Init() {\n\tdao.InitAllTables()\n\n\trepos := config.GetRepositories()\n\terr := dao.InsertManyRepositories(&repos)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor _, repo := range repos {\n\t\tbranches, err := github.GetBranches(repo.Organization, repo.Name)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\terr = dao.InsertManyBranches(&branches, repo.ID)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\n\t//for _, branch := range branches {\n\t//\terr = controllers.InstallRepositoryBranch(repository, branch)\n\t//\tif err != nil {\n\t//\t\treturn err\n\t//\t}\n\t//}\n\terr = controllers.InstallAllRepositories()\n\tfmt.Println(err)\n}", "title": "" }, { "docid": "c93b775ba62a0a442a66df5550f26566", "score": "0.5446884", "text": "func (p project) gitClone() error {\n\tif p.SkipClone {\n\t\treturn nil\n\t}\n\tcmd := fmt.Sprintf(\"git clone -b %s %s %s\", p.Branch, p.Repo, localRepos+p.Name)\n\treturn doExec(cmd, \"\")\n}", "title": "" }, { "docid": "6575130a40aa0728b2c014347a1e5d40", "score": "0.54420793", "text": "func init() {\n\turls = &pluginWebURL{\n\t\tbase: \"https://api.github.com\",\n\t\tauthURL: \"/authorizations\",\n\t\tassigneeURL: \"/repos/%s/%s/issues/%d/assignees\",\n\t\tissueURL: \"/repos/%s/%s/issues\",\n\t\tlabelURL: \"/repos/%s/%s/issues/%d/labels\",\n\t\trepo: \"/repos/%s/%s\",\n\t\tuserRepo: \"/user/repos\",\n\t}\n\n\tinfo, _ := githandler.Remote()\n\torg := info.Organisation\n\trepo := info.Repository\n\ttoken := githandler.ConfigGet(\"token\", \"phlow\")\n\n\tGitHub = &GitHubImpl{\n\t\turls,\n\t\trepo,\n\t\torg,\n\t\ttoken,\n\t}\n}", "title": "" }, { "docid": "0005edb8d1c3b45098e0b2083ad3ba0e", "score": "0.5429992", "text": "func Init() error {\n\tvar err error\n\n\tif err = createHomeFolder(); err != nil {\n\t\treturn err\n\t}\n\n\tif err = checkCompiler(); err != nil {\n\t\treturn err\n\t}\n\n\tif err = downloadGCC(); err != nil {\n\t\treturn err\n\t}\n\n\tif err = compileGCC(); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "title": "" }, { "docid": "2d42f6b5a589f17c9ef543d823f4a2bd", "score": "0.5426484", "text": "func initConfig() {\n\ttoken := rootCmd.Flag(\"token\").Value.String()\n\tgiturl := rootCmd.Flag(\"giturl\").Value.String()\n\tGitClient = gitlab.NewClient(nil, token)\n\tGitClient.SetBaseURL(giturl + \"/api/v4/\")\n}", "title": "" }, { "docid": "a29a4d43acf28ef51302c15cee9abfda", "score": "0.54245985", "text": "func gitignoreConstructor(project *Project) (*file, error) { //nolint:unparam // project is not needed when no variables\n\treturn newProjectFile(newFile(gitignoreIdentifier, gitignoreFilename, gitignoreTemplate))\n}", "title": "" }, { "docid": "92f9a2dba7135e4078214d7f553f59a7", "score": "0.5403149", "text": "func NewGitOAuth(path string, uID string) *oAuth {\n\tvar gitOAuth oAuth\n\t// Set app config\n\tgitOAuth.ClientID = \"XXXXXXXXXX\"\n\tgitOAuth.SecretID = \"XXXXXXXXXXXXXXXXXX\"\n\tgitOAuth.RequestURI = \"https://api.github.com\"\n\tgitOAuth.TokenURI = \"https://github.com/login/oauth/access_token\"\n\tgitOAuth.AuthURI = \"https://github.com/login/oauth/authorize\"\n\t// Set api config\n\tgitOAuth.Path = path\n\tgitOAuth.State = uID\n\treturn &gitOAuth\n}", "title": "" }, { "docid": "dca1d38dc9b0e989e4a4492c0b2804cf", "score": "0.5401196", "text": "func (cl *tektonClient) ConstructGitResource(name, url, revision, namespace string) *pipelinev1alpha1.PipelineResource {\n\n\tgitresource := pipelinev1alpha1.PipelineResource{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: name,\n\t\t\tNamespace: namespace,\n\t\t},\n\t\tSpec: pipelinev1alpha1.PipelineResourceSpec{\n\t\t\tType: pipelinev1alpha1.PipelineResourceTypeGit,\n\t\t\tParams: []pipelinev1alpha1.ResourceParam{{\n\t\t\t\tName: \"url\",\n\t\t\t\tValue: url,\n\t\t\t}, {\n\t\t\t\tName: \"revision\",\n\t\t\t\tValue: revision,\n\t\t\t}},\n\t\t},\n\t}\n\n\treturn &gitresource\n}", "title": "" }, { "docid": "7ec0941cfcb7bea621c837e272a561a8", "score": "0.53974104", "text": "func init() {\n\tif debug {\n\t\tlog.SetLogLevel(log.Debug)\n\t}\n\tversion = fmt.Sprintf(\"%d.%d.%d\", major, minor, patch)\n\tclean := (gitstatus == \"0\")\n\t// The docker build will pass the git tag to the build, if it is clean\n\t// from a tag it will look like v0.7.0\n\tif tag != \"v\"+version || !clean {\n\t\tlog.Debugf(\"tag is %v, clean is %v marking as pre release\", tag, clean)\n\t\tversion += \"-pre\"\n\t}\n\tif !clean {\n\t\tbuildInfo += \"-dirty\"\n\t\tlog.Debugf(\"gitstatus is %q, marking buildinfo as dirty: %v\", gitstatus, buildInfo)\n\t}\n\tlongVersion = version + \" \" + buildInfo + \" \" + runtime.Version()\n}", "title": "" }, { "docid": "147cd6a701a08bc65ca178dd52c9defb", "score": "0.5380079", "text": "func InitModuleRepo() *moduleRepo {\n\treturn &moduleRepo{}\n}", "title": "" }, { "docid": "f0aaa12a6adf9412eac94bdf552086a1", "score": "0.53754276", "text": "func InitRepository(region string, bucketName string) {\n\tlog.Println(\"Calling init\")\n\tvar err error\n\tawsSession, err := session.NewSession(&aws.Config{Region: aws.String(region)})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfileRepo = &s3Repository{s3.New(awsSession), bucketName}\n}", "title": "" }, { "docid": "d007c813cefbbac079a177093247e2f6", "score": "0.5366119", "text": "func (gosh *Goshell) Init(ctx context.Context) error {\n\tgosh.ctx = ctx\n\treturn gosh.loadCommands()\n}", "title": "" }, { "docid": "435755ce42d289514ac136ffcfb67f51", "score": "0.53628635", "text": "func (scl *SimpleConfigurationLayer) SetGit(git *ent.GitConfiguration) {\n\tscl.Git = git\n}", "title": "" }, { "docid": "facb5971939e1da8af52449a027ca8fd", "score": "0.5361731", "text": "func InitGoModules(ctx context.Context, pathToRepo, name string) error {\n\t_, err := os.Stat(pathToRepo + \"/go.mod\")\n\tif os.IsExist(err) {\n\t\treturn err // file already exists but there's some other error with it\n\t}\n\tif err == nil {\n\t\treturn nil // file already exists, do nothing\n\t}\n\n\tcmd := exec.Command(\"go\", \"mod\", \"init\", \"github.com/ONSdigital/\"+name)\n\tcmd.Dir = pathToRepo\n\terr = cmd.Run()\n\tif err != nil {\n\t\tlog.Error(ctx, \"error initialising go modules\", err)\n\t}\n\treturn nil\n}", "title": "" }, { "docid": "143344149b04cf1cf9c50a2f268e6e63", "score": "0.5359393", "text": "func Git(cmd string, args ...string) (res *exec.Cmd, stdout, stderr *bytes.Buffer) {\n\tcmdArgs := make([]string, 1)\n\tcmdArgs[0] = cmd\n\tcmdArgs = append(cmdArgs, args...)\n\tres = exec.Command(gitCmd, cmdArgs...)\n\tstdout, stderr = new(bytes.Buffer), new(bytes.Buffer)\n\tres.Stdout, res.Stderr = stdout, stderr\n\treturn\n}", "title": "" }, { "docid": "512de3e2135af6c0ca327cb45d1297f3", "score": "0.5342907", "text": "func (gen *Generator) Init(params GeneratorParams) error {\n\t// set options\n\tgen.Options.StaticOnly = params.StaticOnly\n\tgen.Options.PerformUpgrade = params.PerformUpgrade\n\tgen.Options.PromoteFile = params.PromoteFile\n\tgen.Options.Verbose = params.Verbose\n\n\tif gen.Options.Verbose {\n\t\tparams.toJSON()\n\t}\n\n\t// variables applied in this order\n\t// 1. cli options\n\t// 2. answer file\n\t// 3. environment variables\n\t// 4. user prompt\n\n\t// todo: validate inputs, that files exist etc\n\t// default destination to current working directory or use project name\n\t// check to see if an answers file exists in current dir\n\tif gen.Options.PerformUpgrade || gen.Options.PromoteFile {\n\n\t\tif gen.Options.PerformUpgrade {\n\t\t\tLog.Info(\"init\", \"running in upgrade mode\")\n\t\t}\n\n\t\tif gen.Options.PromoteFile {\n\t\t\tLog.Info(\"init\", \"running in promote mode\")\n\t\t}\n\n\t\tgen.Project = Project{\n\t\t\tDirectory: params.ProjectDirectory,\n\t\t}\n\n\t\t// Initialize project\n\t\tif err := gen.Project.Init(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tgen.Project.toJSON()\n\n\t\t// check to see if an tempate name was explicitly defined, else default to the .cgen answer file.\n\t\t// this prevents looping when running an upgrade that extends another template.\n\t\tif params.TemplateName == \"\" {\n\t\t\tparams.TemplateName = gen.Project.State.Template\n\t\t}\n\t\tgen.Template = Template{\n\t\t\tName: params.TemplateName,\n\t\t}\n\n\t\t// Initialize template\n\t\tif err := gen.Template.Init(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tgen.Template.toJSON()\n\n\t\treturn nil\n\t}\n\n\tgen.Template = Template{\n\t\tName: params.TemplateName,\n\t}\n\n\t// Initialize template\n\tif err := gen.Template.Init(); err != nil {\n\t\treturn err\n\t}\n\tgen.Template.toJSON()\n\n\tgen.Project = Project{\n\t\tName: params.ProjectName,\n\t\tDirectory: params.ProjectDirectory,\n\t\tState: ProjectState{\n\t\t\tTemplate: gen.Template.Name,\n\t\t\tVersion: gen.Template.LatestStableVersion,\n\t\t},\n\t}\n\n\t// Initialize project\n\tif err := gen.Project.Init(); err != nil {\n\t\treturn err\n\t}\n\tgen.Project.toJSON()\n\n\tgen.Project.AppendAnswer(\"Name\", gen.Project.Name)\n\t// gen.Project.AppendAnswer(\"TemplateVersion\", gen.Template.TemplateVersion)\n\t// gen.Project.AppendAnswer(\"Timestamp\", time.Now().UTC().Format(time.RFC3339))\n\n\tgen.Project.variables.Set(templates.Variable{\n\t\tKey: \"PWD\",\n\t\tValue: gen.Project.Directory,\n\t\tOverrideEnv: true,\n\t})\n\n\treturn nil\n}", "title": "" }, { "docid": "7c8eb9e41632f9335da768defe44959a", "score": "0.5338197", "text": "func (r *Repository) InitRebase(branch *AnnotatedCommit, upstream *AnnotatedCommit, onto *AnnotatedCommit, opts *RebaseOptions) (*Rebase, error) {\n\truntime.LockOSThread()\n\tdefer runtime.UnlockOSThread()\n\n\tif branch == nil {\n\t\tbranch = &AnnotatedCommit{ptr: nil}\n\t}\n\n\tif upstream == nil {\n\t\tupstream = &AnnotatedCommit{ptr: nil}\n\t}\n\n\tif onto == nil {\n\t\tonto = &AnnotatedCommit{ptr: nil}\n\t}\n\n\tvar ptr *C.git_rebase\n\terr := C.git_rebase_init(&ptr, r.ptr, branch.ptr, upstream.ptr, onto.ptr, opts.toC())\n\truntime.KeepAlive(branch)\n\truntime.KeepAlive(upstream)\n\truntime.KeepAlive(onto)\n\tif err < 0 {\n\t\treturn nil, MakeGitError(err)\n\t}\n\n\treturn newRebaseFromC(ptr), nil\n}", "title": "" }, { "docid": "2b59c9ef0a31c946453ea34d78c923fb", "score": "0.5326206", "text": "func InitProject() {\n\tfmt.Println(\"\\nDownloading template...\")\n\tresp, err := http.Get(\"https://github.com/ryanlbrown/spapp/archive/master.zip\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\tb, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tr, err := zip.NewReader(bytes.NewReader(b), int64(len(b)))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfor _, f := range r.File {\n\t\t// Ignore dot files.\n\t\tif path.Base(f.Name)[0] == '.' {\n\t\t\tcontinue\n\t\t}\n\t\tpathTokens := strings.Split(f.Name, \"/\")\n\t\tsubName := strings.Join(pathTokens[1:], \"/\")\n\t\tif subName == \"\" || subName == \"README.md\" {\n\t\t\tcontinue\n\t\t}\n\t\tif subName[len(subName)-1] == '/' {\n\t\t\tdirName := subName[:len(subName)-1]\n\t\t\tfmt.Println(\"Created:\", dirName)\n\t\t\terr = os.Mkdir(dirName, 0755)\n\t\t\tif err != nil && !os.IsExist(err) {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t} else {\n\t\t\tfa, err := f.Open()\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\tdefer fa.Close()\n\t\t\tfb, err := os.OpenFile(subName, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0644)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\tdefer fb.Close()\n\t\t\t_, err = io.Copy(fb, fa)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\tfmt.Println(\"Created:\", subName)\n\t\t}\n\t}\n\tfmt.Println()\n}", "title": "" }, { "docid": "4ea997c8e5bbca121092d20ff6497534", "score": "0.5322413", "text": "func (state *BuildState) Initialise(subrepo *Subrepo) (err error) {\n\tstate.initOnce.Do(func() {\n\t\t// If we are the root repo, or an cross-compilation of that, we don't want to re-load the config files. That's\n\t\t// handled for us already in plz.go\n\t\tif state.CurrentSubrepo != \"\" {\n\t\t\tstate.RepoConfig = &Configuration{}\n\t\t\terr = readConfigFilesInto(state.RepoConfig, append(subrepo.AdditionalConfigFiles, filepath.Join(subrepo.Root, \".plzconfig\")))\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif err = validateSubrepoNameAndPluginConfig(state.Config, state.RepoConfig, subrepo); err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t})\n\treturn\n}", "title": "" }, { "docid": "be5c020136dd72f1894f4092258bcd94", "score": "0.53174776", "text": "func main() {\n\tapp := cli.NewApp()\n\tapp.Name = \"go-init\"\n\tapp.Usage = \"Initialize a go project\"\n\tapp.Version = \"1.1.0\"\n\n\t// global flags\n\t//Log Level and Config Path\n\tapp.Flags = []cli.Flag{\n\t\tcli.StringFlag{\n\t\t\tName: \"configPath, c\",\n\t\t\tEnvVar: \"CONFIGPATH\",\n\t\t\tUsage: \"config path\",\n\t\t\tValue: \"./\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName: \"configName, n\",\n\t\t\tEnvVar: \"CONFIGNAME\",\n\t\t\tUsage: \"name of the config\",\n\t\t\tValue: \"config\",\n\t\t},\n\t\tcli.BoolFlag{\n\t\t\tName: \"force, f\",\n\t\t\tEnvVar: \"FORCE\",\n\t\t\tUsage: \"force the creatino of the folder\",\n\t\t},\n\t}\n\tapp.Action = func(c *cli.Context) {\n\t\tif len(c.Args()) == 0 {\n\t\t\treturn\n\t\t}\n\t\tif len(c.Args()) == 1 {\n\t\t\tappName = c.Args()[0]\n\t\t\tdirectory = \"./\"\n\n\t\t} else {\n\t\t\tdirectory = c.Args()[0]\n\t\t\tappName = c.Args()[1]\n\t\t}\n\t\tGenerate(c)\n\t}\n\tapp.Before = func(ctx *cli.Context) error {\n\t\tconfigPath = ctx.String(\"configPath\")\n\t\tconfigName = ctx.String(\"ConfigName\")\n\t\tforce = ctx.Bool(\"force\")\n\t\treturn nil\n\t}\n\tapp.Run(os.Args)\n\n}", "title": "" }, { "docid": "b129f5a207776ca70bedd1bc2929c7c9", "score": "0.53121734", "text": "func Init() (vc *VCSystem, err error) {\n\tvc = new(VCSystem)\n\tvc.key, err = keypair.New()\n\tif err != nil {\n\t\treturn\n\t}\n\tbVCKey, err := json.Marshal(vc.key)\n\tfmt.Println(string(bVCKey))\n\tencryptedKey, err := identity.Encrypt(bVCKey, identity.Public)\n\tif err != nil {\n\t\treturn vc, err\n\t}\n\tencryptedKeyBase64 := base64.StdEncoding.EncodeToString(encryptedKey)\n\tvc.EncryptedKeys = []string{encryptedKeyBase64}\n\tvc.CurrentBranch = \"master\"\n\tvc.BaseFolder, err = os.Getwd()\n\tif err != nil {\n\t\treturn vc, err\n\t}\n\tvc.BaseFolder, err = filepath.Abs(vc.BaseFolder)\n\tif err != nil {\n\t\treturn vc, err\n\t}\n\tos.Mkdir(\".vcs\", 0755)\n\t// load all files in directory\n\treturn vc, nil\n}", "title": "" }, { "docid": "ee6e0cbb981ca1b4331b00032ca3c8bf", "score": "0.5311287", "text": "func New(fs fs.FileSystem, runner cmd.CommandRunner) Git {\n\treturn &stiGit{\n\t\tFileSystem: fs,\n\t\tCommandRunner: runner,\n\t}\n}", "title": "" }, { "docid": "7ffec3be15be2d63a110f383e0cf6e66", "score": "0.53110677", "text": "func setupBareGitRepo(t *testing.T) *repositories.GitRepository {\n\tt.Helper()\n\tassert := assert.New(t)\n\n\trepoDir, err := ioutil.TempDir(\"\", \"rb-gateway-bare-repo-\")\n\tassert.Nil(err)\n\n\t_, err = git.PlainInit(repoDir, true)\n\tassert.Nil(err)\n\n\treturn &repositories.GitRepository{\n\t\tRepositoryInfo: repositories.RepositoryInfo{\n\t\t\tName: \"upstream\",\n\t\t\tPath: repoDir,\n\t\t},\n\t}\n}", "title": "" }, { "docid": "4670f2d87b4104ba5c3a3b5309d0263f", "score": "0.53059924", "text": "func NewGitInfo(path *string) (*GitInfo, error) {\n\tinfo := &GitInfo{}\n\trepo, err := git.PlainOpen(*path)\n\tif err != nil {\n\t\treturn info, err\n\t}\n\tref, err := repo.Head()\n\tif err != nil {\n\t\treturn info, err\n\t}\n\tcommit, err := repo.CommitObject(ref.Hash())\n\tif err != nil {\n\t\treturn info, err\n\t}\n\tinfo.LastCommit = commit.Message\n\tinfo.CurrentBranch = strings.TrimPrefix(ref.Name().String(), \"refs/heads/\")\n\treturn info, nil\n}", "title": "" }, { "docid": "4ca892d084ca4e4a01a7be99f8723a33", "score": "0.52801645", "text": "func Init() {\n\tplugins.RegisterPlugins(\"gitlab\", &GitlabPlugin{})\n}", "title": "" }, { "docid": "de751b16b147f4b38cae2f51999ab40e", "score": "0.52773696", "text": "func (o *RunOptions) Git() gits.Gitter {\n\tif o.Gitter == nil {\n\t\to.Gitter = gits.NewGitCLI()\n\t}\n\treturn o.Gitter\n}", "title": "" }, { "docid": "ef7e80389343abd04d26eef495d894a7", "score": "0.5275112", "text": "func (s *GitTestHelper) NewRepoPair(basedir string) {\n\tgit := s.Git()\n\ttarget := s.toAbsPath(basedir)\n\ts.Chdir(target)\n\ts.Mkdir(\"source\")\n\ts.Chdir(\"source\")\n\ts.Exec(git, \"init\", \"--bare\")\n\ts.Chdir(\"..\")\n\ts.Exec(git, \"clone\", \"source\", \"dest\")\n\n\ts.Chdir(\"dest\")\n\ts.TouchAndCommit(\"init.txt\", \"init\")\n\ts.Exec(git, \"push\", \"origin\")\n}", "title": "" }, { "docid": "10f97bf10ecb6e196604b992fb51e033", "score": "0.5266772", "text": "func CreateGitRepo(options *git.CloneOptions, revision models.GitRevision, isSync bool) uint64 {\n\tif options == nil {\n\t\treturn 0\n\t}\n\tlog.Printf(\"clone git repo with params %+v...\\n\", options)\n\t// request new context with updating status, so that the context wouldn't be gced\n\tctx, id := requestNewContextWithID(TypeGit, StatusUpdating)\n\t// TODO: trace clone/pull/checkout progress\n\tif isSync {\n\t\tif !createGitRepo(ctx, options, revision) {\n\t\t\t// create failed\n\t\t\treturn 0\n\t\t}\n\t} else {\n\t\tgo createGitRepo(ctx, options, revision)\n\t}\n\treturn id\n}", "title": "" }, { "docid": "acf205ad294a5833cbad2b1c7beef0f9", "score": "0.52616584", "text": "func (g *GitStatusWidget) Init() (err error) {\n\theader := g.buildHeader()\n\n\tlopt := &listable.ListWrapperOption{\n\t\tTitle: g.options.GetTitle(),\n\t\tRealHeight: g.options.GetHeight(),\n\t\tHeader: header,\n\t\tLineHighLight: true,\n\t}\n\tg.renderer = listable.NewListWrapper(lopt)\n\tg.isReady = true\n\n\tgo func() {\n\t\tbody, err := g.buildBody(g.options.ExecPath)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tif body == nil {\n\t\t\tbody = []string{\n\t\t\t\t\"Worktree is clean\",\n\t\t\t}\n\t\t}\n\t\tg.renderer.SetBody(body)\n\t\tg.renderer.ResetRender()\n\t}()\n\n\treturn\n}", "title": "" }, { "docid": "17ed2bbf3d1d02b0e25eae27bdf1ddce", "score": "0.5258404", "text": "func Init(state *core.BuildState) {\n\ttheFilegroupBuilder = &filegroupBuilder{\n\t\tbuilt: map[string]bool{},\n\t}\n\tstate.TargetHasher = newTargetHasher(state)\n}", "title": "" }, { "docid": "c25403aaca8543752b55bc731d2237f9", "score": "0.52570134", "text": "func Init() {\n\tf := tree.CreateFolder(\"\", false)\n\tlogger.Info(\"root: \" + f.Dev())\n\n\tdir.EnsureThatFolderExist(f.Dev())\n\tdir.EnsureThatFolderExist(f.Scripts())\n\tdir.EnsureThatFolderExist(f.Projects())\n}", "title": "" }, { "docid": "cf9bde9d146c955e27acc9e73407cf2b", "score": "0.5245429", "text": "func NewMockGit(ctrl *gomock.Controller) *MockGit {\n\tmock := &MockGit{ctrl: ctrl}\n\tmock.recorder = &MockGitMockRecorder{mock}\n\treturn mock\n}", "title": "" }, { "docid": "7d657c3cddf95dd7fdc420622dcf8b46", "score": "0.5243291", "text": "func init() {\n\tcmd.Root.AddCommand(version)\n}", "title": "" }, { "docid": "33888e78e3ee0d45f47d41f3d77d64e0", "score": "0.5241546", "text": "func NewInitCommand(cfg *Config) *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: \"init\",\n\t\tShort: \"do some initialization operations.\",\n\t\tRun: func(cmd *cobra.Command, args []string) {\n\t\t\tif err := runInitCommand(cfg); err != nil {\n\t\t\t\tlog.Error(err, \"init command failed\")\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\t\t},\n\t}\n\n\treturn cmd\n}", "title": "" }, { "docid": "c32707a68933292b9e84e6161c4edd7f", "score": "0.52365", "text": "func NewGitWatcher(\n\tdirectory string,\n\tbus chan task.ExecutionTask,\n\tcheckInterval time.Duration,\n\tsecrets secret.Store,\n) *GitWatcher {\n\treturn &GitWatcher{\n\t\tdirectory: directory,\n\t\tbus: bus,\n\t\tcheckInterval: checkInterval,\n\t\tsecrets: secrets,\n\n\t\tinitialise: make(chan bool),\n\t\tnewState: make(chan config.State, 16),\n\t\tstateReq: make(chan struct{}),\n\t\tstateRes: make(chan config.State),\n\t\terrors: make(chan error, 16),\n\t}\n}", "title": "" }, { "docid": "71f4392a0ee52eecd57c3b6ff874dbd9", "score": "0.5215669", "text": "func NewInitCommand(io ui.IO, newClientWithCredentials func(credentials.Provider) (secrethub.ClientInterface, error), credentialStore CredentialConfig) *InitCommand {\n\treturn &InitCommand{\n\t\tio: io,\n\t\tnewClientWithCredentials: newClientWithCredentials,\n\t\tcredentialStore: credentialStore,\n\t\tprogressPrinter: progress.NewPrinter(io.Output(), 500*time.Millisecond),\n\t}\n}", "title": "" }, { "docid": "b17f6aca3f988cdc9d9c11f925928981", "score": "0.52026117", "text": "func NewGitClient(t mockConstructorTestingTNewGitClient) *GitClient {\n\tmock := &GitClient{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "title": "" }, { "docid": "7baa752aed00cd67d0d7e5743fe7ce64", "score": "0.51932836", "text": "func withGit(url, commit, folder string, verbose bool) error {\n\tvar out bytes.Buffer\n\tdata := map[string]string{\n\t\t\"workDir\": folder,\n\t\t\"repoDir\": RepoDir(url),\n\t\t\"remote\": url,\n\t\t\"ref\": commit,\n\t}\n\tif err := gitTemplate.Execute(&out, data); err != nil {\n\t\treturn errors.Wrap(err, \"unable to create git script\")\n\t}\n\tscript := out.String()\n\tif verbose {\n\t\tfmt.Println(script)\n\t}\n\n\tcmd := exec.Command(\"bash\", \"-c\", script)\n\tif verbose {\n\t\tcmdStdout, err := cmd.StdoutPipe()\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"unable to create StdOut pipe for bash\")\n\t\t}\n\t\tstdoutScanner := bufio.NewScanner(cmdStdout)\n\t\tgo func() {\n\t\t\tfor stdoutScanner.Scan() {\n\t\t\t\tfmt.Println(\"bash: \" + stdoutScanner.Text())\n\t\t\t}\n\t\t}()\n\n\t\tcmdStderr, err := cmd.StderrPipe()\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"unable to create StdErr pipe for bash\")\n\t\t}\n\t\tstderrScanner := bufio.NewScanner(cmdStderr)\n\t\tgo func() {\n\t\t\tfor stderrScanner.Scan() {\n\t\t\t\tfmt.Println(\"bash: \" + stderrScanner.Text())\n\t\t\t}\n\t\t}()\n\t}\n\terr := cmd.Start()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"unable to start cloning with git\")\n\t}\n\terr = cmd.Wait()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"unable to clone with git\")\n\t}\n\treturn nil\n}", "title": "" } ]